diff --git a/call/config.go b/call/config.go index d9556bb..b8130ef 100644 --- a/call/config.go +++ b/call/config.go @@ -64,6 +64,7 @@ var ( configTgRobot []*common.ConfigTgRobot configBetDraw []*common.ConfigActivityBetDraw configActivityPopup []*common.ConfigActivityPopup + configDiscountTicket []common.ConfigDiscountTicket // 客服 configCustomerRobot []*common.ConfigCustomerRobot customerOrderLabel []*common.CustomerOrderLabel @@ -1558,3 +1559,26 @@ func GetConfigActivityPopupByType(jumpType int) []*common.ConfigActivityPopup { } return ret } + +func LoadConfigDiscountTicket() (err error) { + var list []common.ConfigDiscountTicket + if _, err = db.Mysql().QueryAll("", "", &common.ConfigDiscountTicket{}, &list); err != nil { + log.Error("err:%v", err) + return err + } + configDiscountTicket = list + return nil +} + +func GetConfigDiscountTicket() []common.ConfigDiscountTicket { + return configDiscountTicket +} + +func GetConfigDiscountTicketByAmount(amount int64) common.ConfigDiscountTicket { + for _, item := range configDiscountTicket { + if item.RechargeAmount == amount { + return item + } + } + return common.ConfigDiscountTicket{} +} diff --git a/call/item.go b/call/item.go index 5e2dd57..c1c5e78 100644 --- a/call/item.go +++ b/call/item.go @@ -4,7 +4,7 @@ import ( "fmt" "server/common" "server/db" - "time" + "server/pb" ) func GetUserItem(uid, itemID int) []*common.PlayerItems { @@ -13,6 +13,11 @@ func GetUserItem(uid, itemID int) []*common.PlayerItems { return list } +func GetItem(id int) *common.PlayerItems { + list := &common.PlayerItems{ID: id, Status: common.ItemStatusNormal} + db.Mysql().Get(&list) + return list +} func GetUserValidItems(uid, itemID int) []*common.PlayerItems { list := []*common.PlayerItems{} db.Mysql().QueryAll(fmt.Sprintf("uid = %d and item_id = %d and status = %d", uid, itemID, common.ItemStatusNormal), "", &common.PlayerItems{}, &list) @@ -35,6 +40,8 @@ func GetUserBestDiscountTicket(uid int) *common.PlayerItems { return nil } -func AddUserDiscountTicket(uid int, exi1, exi2 int64) { - db.Mysql().Create(&common.PlayerItems{UID: uid, ItemID: common.ItemDiscountTicket, Time: time.Now().Unix(), Status: common.ItemStatusNormal, Exi1: exi1, Exi2: exi2}) +func AddUserDiscountTicket(uid int, exi1, exi2, t int64) { + db.Mysql().Create(&common.PlayerItems{UID: uid, ItemID: common.ItemDiscountTicket, Time: t, Status: common.ItemStatusNormal, Exi1: exi1, Exi2: exi2}) + SendNR(uid, int(pb.ServerCommonResp_CommonDisCountTicketResp), &pb.DiscountTicketNotify{Discount: exi1, Amount: exi2}) + } diff --git a/call/mail.go b/call/mail.go index ebebc13..6eb4af9 100644 --- a/call/mail.go +++ b/call/mail.go @@ -10,6 +10,14 @@ import ( "gorm.io/gorm" ) +var ( + SystemTitle = "System Notice" + EmailWithdrawPass = "Your order %v, amount: $%v is in the payment status, please be patient." + EmailWithdrawSuccess = "Your order %v, amount: $%v has been credited, please check. If you have any questions, you can contact customer service." + EmailWithdrawFail = "Your order %v, Amount: $%v\nYour withdrawal failed due to incorrect information. Please verify or change your withdrawal details and resubmit" + EmailDiscount = "Congratulations, you have received a $%v coupon for a top-up of $%v or more." +) + func checkMail(uid int, red *common.PlayerRed) { data := &common.PlayerData{UID: uid} db.Mysql().Get(data) @@ -59,6 +67,17 @@ func SendWithdrawMail(uid int, contentType string) { UpsertRedPointAndNotify(uid, 1, ModuleMail) } +func SendMailWithContent(uid int, title, content string) { + one := &common.Mail{ + Sender: "System", + Receiver: uid, + Title: title, + Content: content, + Time: time.Now().Unix(), + } + db.Mysql().Create(one) + UpsertRedPointAndNotify(uid, 1, ModuleMail) +} func SendMail(mail *common.Mail) { db.Mysql().Create(mail) UpsertRedPointAndNotify(mail.Receiver, 1, ModuleMail) diff --git a/call/pay.go b/call/pay.go index 0eb59e4..6f507bf 100644 --- a/call/pay.go +++ b/call/pay.go @@ -6,6 +6,7 @@ import ( "errors" "fmt" "io/ioutil" + "math/rand" "net/http" "server/common" "server/config" @@ -99,11 +100,6 @@ func RechargeCallback(r *common.RechargeOrder, success bool, payAccount, extra s log.Error("get recharage info err:%v,uid:%v", err, r.UID) return err } - // product := GetConfigPayProductByID(r.ProductID) - // if product == nil { - // log.Error("unkonwn product:%d", r.ProductID) - // return errors.New("unkonwn product") - // } amount := r.Amount notCharge := re.TotalRecharge == 0 @@ -115,31 +111,9 @@ func RechargeCallback(r *common.RechargeOrder, success bool, payAccount, extra s dayR = true re.DayRecharge += amount } - // if util.IsSameWeek(re.LastRecharge, now) || re.LastRecharge == 0 { - // weekR = true - // re.WeekRecharge += amount - // } - re.LastRecharge = now re.TotalRechargeCount++ - // re.ProductPayCount = common.AddProductPayCount(re.ProductPayCount, r.ProductID) - // if product.IsFirstPayProduct() { - // json.Unmarshal([]byte(re.ProductFirstPay), &re.ProductFirstPaySub) - // if util.SliceContain(re.ProductFirstPaySub, product.ProductID) { // 该商品已购买,替换为可多次购买的同价值商品 - // product = GetConfigPayProductShopByAmount(product.Amount) - // if product == nil { - // return errors.New("product invalid") - // } - // } else { - // re.ProductFirstPaySub = append(re.ProductFirstPaySub, int(product.ProductID)) - // str, _ := json.Marshal(re.ProductFirstPaySub) - // re.ProductFirstPay = string(str) - // } - // } - // var per int64 = 0 - // level := GetConfigFirstPayLevelByAmount(r.Amount) - // playerPayData := GetPlayerPayData(uid) tx := db.Mysql().Begin() defer func() { if err == nil { @@ -165,27 +139,6 @@ func RechargeCallback(r *common.RechargeOrder, success bool, payAccount, extra s return nil } - // 更新paydata - // if playerPayData.ID == 0 { - // err = tx.Model(playerPayData).Create(playerPayData).Error - // if err != nil { - // log.Error("err:%v", err) - // return - // } - // } else { - // playerPayData.SubFirstPay = append(playerPayData.SubFirstPay, level) - // updatePayData, _ := json.Marshal(playerPayData.SubFirstPay) - // res := tx.Model(playerPayData).Where("id = ? and first_pay = ?", playerPayData.ID, playerPayData.FirstPay).Updates(map[string]interface{}{"first_pay": string(updatePayData)}) - // if res.RowsAffected == 0 { - // log.Error("err:%v", err) - // return errors.New("update payData fail") - // } - // if err != nil { - // log.Error("update payData err:%v", err) - // return err - // } - // } - // 第二步,更新recharge_info payData := &common.ESPlayerPayData{UID: uid, Channel: r.ChannelID, Type: 1, CurrencyType: r.CurrencyType} if re.ID == 0 { @@ -204,19 +157,13 @@ func RechargeCallback(r *common.RechargeOrder, success bool, payAccount, extra s "total_recharge_count": gorm.Expr("total_recharge_count + 1"), "total_recharge": gorm.Expr("total_recharge + ?", amount), "last_recharge": now, - // "product_paycount": re.ProductPayCount, - // "product_firstpay": re.ProductFirstPay, } if dayR { updates["day_recharge"] = gorm.Expr("day_recharge + ?", amount) } else { updates["day_recharge"] = amount } - // if weekR { - // updates["week_recharge"] = gorm.Expr("week_recharge + ?", amount) - // } else { - // updates["week_recharge"] = amount - // } + err = tx.Model(re).Where("uid=?", re.UID).Updates(updates).Error } if err != nil { @@ -231,27 +178,6 @@ func RechargeCallback(r *common.RechargeOrder, success bool, payAccount, extra s if amount == 0 { amount = r.Amount } - // cb := &common.CurrencyBalance{ - // UID: r.UID, - // Type: r.CurrencyType, - // Value: amount, - // Event: common.CurrencyEvent(r.Event), - // Exs1: r.OrderID, - // Exi1: int(amount), // 充值金额传递 - // Exi2: r.ProductID, - // NeedBet: GetConfigCurrencyResourceNeedBet(common.CurrencyResourceRecharge, amount), - // } - // err = UpdateCurrencyProReal(&common.UpdateCurrency{ - // CurrencyBalance: cb, - // }).Err - // if err != nil { - // return - // } - // } else { - // per := GetConfigFirstPayPerByAmount(notCharge, amount) - // if per > 0 { - // bonus = amount * per / 100 - // } t := common.CurrencyResourceRecharge if notCharge && bonus > 0 { // 首充 t = common.CurrencyResourceFirstRecharge @@ -286,6 +212,32 @@ func RechargeCallback(r *common.RechargeOrder, success bool, payAccount, extra s if bonus > 0 { UploadActivityData(uid, common.ActivityIDRecharge, common.ActivityDataJoin, bonus) } + if r.ProductID == 0 { + ticket := GetConfigDiscountTicketByAmount(r.Amount) + if ticket.Id > 0 { + // 赠送优惠券 + products := GetConfigPayProductByActivityID(0) + nextProduct := &common.ConfigPayProduct{} + for _, product := range products { + if product.Amount > r.Amount && nextProduct.Amount < product.Amount { + nextProduct = product + } + } + var nextTicket common.ConfigDiscountTicket + if nextProduct != nil { + nextTicket = GetConfigDiscountTicketByAmount(nextProduct.Amount) + } + count := ticket.CurProb + ticket.NextProb + val := rand.Intn(count) + if val <= ticket.CurProb { + AddUserDiscountTicket(uid, ticket.RechargeAmount, ticket.DiscountAmount, -1) + SendMailWithContent(uid, SystemTitle, fmt.Sprintf(EmailDiscount, ticket.RechargeAmount/common.DecimalDigits, ticket.DiscountAmount/common.DecimalDigits)) + } else if nextTicket.Id > 0 { + AddUserDiscountTicket(uid, nextTicket.RechargeAmount, nextTicket.DiscountAmount, -1) + SendMailWithContent(uid, SystemTitle, fmt.Sprintf(EmailDiscount, ticket.RechargeAmount/common.DecimalDigits, ticket.DiscountAmount/common.DecimalDigits)) + } + } + } user, _ := GetUserInfo(uid) PayActivity(r, notCharge, user) if r.Event != int(common.CurrencyEventGMRecharge) { diff --git a/call/reload.go b/call/reload.go index 92d8e2c..c63050d 100644 --- a/call/reload.go +++ b/call/reload.go @@ -466,6 +466,16 @@ func CommonReload(c map[int][]func(*pb.ReloadGameConfig) error) { return nil }} } + + if _, ok := c[common.ReloadConfigDiscountTicket]; !ok { + c[common.ReloadConfigDiscountTicket] = []func(*pb.ReloadGameConfig) error{func(rgc *pb.ReloadGameConfig) error { + if err := LoadConfigDiscountTicket(); err != nil { + log.Error("error : [%s]", err.Error()) + return err + } + return nil + }} + } // 客服 if _, ok := c[common.ReloadConfigCustomerRobot]; !ok { c[common.ReloadConfigCustomerRobot] = []func(*pb.ReloadGameConfig) error{func(rgc *pb.ReloadGameConfig) error { diff --git a/call/share.go b/call/share.go index 0fb8d1b..dfda928 100644 --- a/call/share.go +++ b/call/share.go @@ -67,9 +67,6 @@ func ShareBind(share string, isOld bool, uid, cid int) { // 判断分享,发放有效用户奖励 func CheckShare(r *common.RechargeOrder) { reward := GetConfigShareSys().ShareReward - if reward <= 0 { - return - } if r.Amount < GetConfigShareSys().ShareRecharge { return } diff --git a/common/activity.go b/common/activity.go index 450787a..245ca2e 100644 --- a/common/activity.go +++ b/common/activity.go @@ -546,6 +546,14 @@ type ConfigActivityPopup struct { AdditionalInfo string `gorm:"column:additional_info;type:text;comment:附加信息" web:"additional_info"` } -func (c *ConfigActivityPopup) TableName() string { - return "config_activity_popup" +type ConfigDiscountTicket struct { + Id int `gorm:"column:id;type:int(11) AUTO_INCREMENT;primary_key" json:"id"` + RechargeAmount int64 `gorm:"column:recharge_amount;type:bigint(20)" json:"recharge_amount"` + DiscountAmount int64 `gorm:"column:discount_amount;type:bigint(20)" json:"discount_amount"` + CurProb int `gorm:"column:cur_prob;type:int(11)" json:"cur_prob"` + NextProb int `gorm:"column:next_prob;type:int(11)" json:"next_prob"` +} + +func (m *ConfigDiscountTicket) TableName() string { + return "config_discount_ticket" } diff --git a/common/config.go b/common/config.go index 151a115..7c640b5 100644 --- a/common/config.go +++ b/common/config.go @@ -52,6 +52,7 @@ const ( ReloadConfigTgRobot // tg机器人配置 ReloadConfigBetDraw // 下注抽奖 ReloadConfigActivityPopup // 活动弹窗 + ReloadConfigDiscountTicket // 折扣券 ReloadConfigCustomerRobot // 客服系统机器人配置 ReloadConfigCustomerLabel // 客服系统订单标签 diff --git a/common/currency.go b/common/currency.go index 43e1498..cbe2a02 100644 --- a/common/currency.go +++ b/common/currency.go @@ -29,6 +29,7 @@ const ( CurrencyResourceRechargeBonus // bonus充值 CurrencyResourceFirstRecharge // 首充 CurrencyResourceWeekCard // 周卡 + CurrencyResourceShare // 分享 CurrencyResourceAll ) diff --git a/modules/backend/handler/examine/examine.go b/modules/backend/handler/examine/examine.go index 62df62a..fbe317a 100644 --- a/modules/backend/handler/examine/examine.go +++ b/modules/backend/handler/examine/examine.go @@ -178,7 +178,9 @@ func WithdrawExamine(c *gin.Context) { if err != nil { log.Error(err.Error()) } + return } + call.SendMailWithContent(one.UID, call.SystemTitle, fmt.Sprintf(call.EmailWithdrawPass, one.OrderID, one.Amount/common.DecimalDigits)) a.RecordEdit(values.PowerExamineWithdraw, fmt.Sprintf("审核退出订单ID:%v", req.ID)) } diff --git a/modules/backend/handler/statistics/reviewAppSummary.go b/modules/backend/handler/statistics/reviewAppSummary.go index 0c8254d..49ca8cf 100644 --- a/modules/backend/handler/statistics/reviewAppSummary.go +++ b/modules/backend/handler/statistics/reviewAppSummary.go @@ -144,7 +144,7 @@ func ReviewAppSummary(c *gin.Context) { // activePlayTime += ap // ar, _ := strconv.ParseFloat(resp.PlatformData[i].ARPPU, 64) // arppu += ar - // ws, _ := strconv.ParseFloat(strings.ReplaceAll(resp.PlatformData[i].WithdrawSuccess, "%", ""), 64) + // ws, _ := strconv.ParseFloat(strings.ReplaceAll(resp.PlatformData[i].EmailWithdrawSuccess, "%", ""), 64) // withdrawSuccess += ws } @@ -164,7 +164,7 @@ func ReviewAppSummary(c *gin.Context) { // resp.Total.OldPlayTime = util.FormatFloat(oldPlayTime/float64(len(tempChannelArr)), 2) // resp.Total.ActivePlayTime = util.FormatFloat(activePlayTime/float64(len(tempChannelArr)), 2) // resp.Total.ARPPU = util.FormatFloat(arppu/float64(len(tempChannelArr)), 2) - // resp.Total.WithdrawSuccess = utils.GetPer(int64(withdrawSuccess*100), int64(len(tempChannelArr))*10000) + // resp.Total.EmailWithdrawSuccess = utils.GetPer(int64(withdrawSuccess*100), int64(len(tempChannelArr))*10000) } switch req.Sort { diff --git a/modules/backend/handler/statistics/reviewData.go b/modules/backend/handler/statistics/reviewData.go index edab3f0..53b9429 100644 --- a/modules/backend/handler/statistics/reviewData.go +++ b/modules/backend/handler/statistics/reviewData.go @@ -150,7 +150,7 @@ func ReviewData(c *gin.Context) { // activePlayTime += ap // ar, _ := strconv.ParseFloat(one.ARPPU, 64) // arppu += ar - // withdrawSuccess = utils.AddPerFloat(withdrawSuccess, one.WithdrawSuccess) + // withdrawSuccess = utils.AddPerFloat(withdrawSuccess, one.EmailWithdrawSuccess) } sort.Slice(resp.PlatformData, func(i, j int) bool { return resp.PlatformData[i].Time > resp.PlatformData[j].Time @@ -169,7 +169,7 @@ func ReviewData(c *gin.Context) { // total.OldPlayTime = util.FormatFloat(oldPlayTime/float64(resp.Count), 2) // total.ActivePlayTime = util.FormatFloat(activePlayTime/float64(resp.Count), 2) // total.ARPPU = util.FormatFloat(arppu/float64(resp.Count), 2) - // total.WithdrawSuccess = utils.GetPer(int64(withdrawSuccess*100), resp.Count*10000) + // total.EmailWithdrawSuccess = utils.GetPer(int64(withdrawSuccess*100), resp.Count*10000) total.NewPayPer = utils.GetPer(total.NewPayCount, total.NewCount) // total.NewPlayPer = utils.GetPer(total.NewPlayCount, total.NewCount) @@ -353,7 +353,7 @@ func GetReviewPlatformData(start, end int64, platform ...*int) *values.ReviewDat db.Mysql().C().Table("withdraw_order").Where(sql).Distinct("uid").Count(&ret.WithdrawPlayerNum) // 退出成功率 - // ret.WithdrawSuccess = utils.GetPer(ret.WithdrawCount, withdrawAll) + // ret.EmailWithdrawSuccess = utils.GetPer(ret.WithdrawCount, withdrawAll) // 人次成功率 // ret.WithdrawPlayerSuccess = utils.GetPer(ret.WithdrawPlayerNum, totalWithdrawPlayer) diff --git a/modules/pay/base/callback.go b/modules/pay/base/callback.go index 0b6877c..08fe752 100644 --- a/modules/pay/base/callback.go +++ b/modules/pay/base/callback.go @@ -2,6 +2,7 @@ package base import ( "encoding/json" + "fmt" "io" "net/http" "net/url" @@ -95,8 +96,10 @@ func (b *Base) WithdrawCallback(c *gin.Context) { } if !success { values.WithdrawAmount(values.PayWay(or.PayChannel), false, or.Amount*100) + call.SendMailWithContent(or.UID, call.SystemTitle, fmt.Sprintf(call.EmailWithdrawFail, or.OrderID, or.Amount/common.DecimalDigits)) } else { values.WithdrawSuccess(values.PayWay(or.PayChannel)) + call.SendMailWithContent(or.UID, call.SystemTitle, fmt.Sprintf(call.EmailWithdrawSuccess, or.OrderID, or.Amount/common.DecimalDigits)) } } diff --git a/modules/web/handler/activity.go b/modules/web/handler/activity.go index aaa61fd..558f00e 100644 --- a/modules/web/handler/activity.go +++ b/modules/web/handler/activity.go @@ -1429,8 +1429,9 @@ func ActivityWeekCardDraw(c *gin.Context) { exi2 = product.Amount } } - call.AddUserDiscountTicket(a.UID, conf.Discount, exi2) + call.AddUserDiscountTicket(a.UID, exi2-exi2*conf.Discount/100, exi2, -1) resp.DiscountTicket = conf.Discount + resp.Amount = exi2 } resource := common.CurrencyResourceWeekCard if card.Day > 0 { @@ -1778,7 +1779,7 @@ func ActivitySevenDayBoxDraw(c *gin.Context) { call.UploadActivityData(a.UID, common.ActivityIDSevenDayBox, common.ActivityDataJoin, reward) } if oneDiscount.Discount > 0 { - // call.AddUserDiscountTicket(a.UID, oneDiscount.Discount) + // call.AddUserDiscountTicket(a.UID, oneDiscount.EmailDiscount) resp.Discount = oneDiscount.Discount } } @@ -2102,3 +2103,22 @@ func WeekCardDraw(c *gin.Context) { resp.List = call.GetConfigActivityPopupByType(req.JumpType) } } + +func DiscountTicketInfo(c *gin.Context) { + a := app.NewApp(c) + defer func() { + a.Response() + }() + resp := new(values.DiscountTicketResp) + a.Data = resp + list := call.GetUserValidItems(a.UID, common.ItemDiscountTicket) + sort.Slice(list, func(i, j int) bool { + return list[i].Exi2 > list[i].Exi2 + }) + if len(list) > 0 { + resp.Ticket = &values.DiscountTicketInfo{ + Amount: list[0].Exi1, + Discount: list[0].Exi2, + } + } +} diff --git a/modules/web/handler/recharge.go b/modules/web/handler/recharge.go index 274b4eb..fc56f82 100644 --- a/modules/web/handler/recharge.go +++ b/modules/web/handler/recharge.go @@ -2,7 +2,6 @@ package handler import ( "encoding/json" - "fmt" "server/call" "server/config" "server/db" @@ -91,36 +90,21 @@ func RechargeInfo(c *gin.Context) { if a.UID > 0 { // 判断是否有折扣券 tickets := call.GetUserValidItems(a.UID, common.ItemDiscountTicket) - discount := int64(0) for _, v := range tickets { - thisDiscount := v.Exi1 - diff := v.Time + common.ActivityWeekCardTicketExpireTime - time.Now().Unix() - if diff <= 0 { + diff := v.Time - time.Now().Unix() + if v.Time != -1 && diff <= 0 { id := v.ID util.Go(func() { db.Mysql().Update(&common.PlayerItems{ID: id}, map[string]interface{}{"status": common.ItemStatusInvalid}) }) continue } - if discount < thisDiscount { - discount = thisDiscount - resp.DiscountTicket = append(resp.DiscountTicket, &values.DiscountTicket{ - // Level: con.Level, - Discount: fmt.Sprintf("%d", 100-discount), - TimeLeft: diff, - Amount: v.Exi2, - }) - // 折扣券 - // con := call.GetConfigActivityWeekCardByLevel(1) - // if con != nil { - // resp.DiscountTicket.Range = con.SubRange - // } - // if discount > 50 { - // resp.DiscountTicket.Level = 1 - // } else { - // resp.DiscountTicket.Level = 2 - // } - } + resp.DiscountTicket = append(resp.DiscountTicket, &values.DiscountTicket{ + Id: v.ID, + Discount: v.Exi1, + TimeLeft: v.Time, + Amount: v.Exi2, + }) } } } @@ -254,37 +238,17 @@ func NewRechargeImp(req *values.RechargeReq, uid, cid int, ip string) *RechargeI ProductID: req.ProductID, } // 只有商城购买才能使用优惠券 - if req.ProductID == 0 { - // 首先判断折扣券 - var ticket *common.PlayerItems - discount := int64(-1) - exi2 := int64(0) + if req.ProductID == 0 && req.DiscountTicketId > 0 { // 判断是否有折扣券 - tickets := call.GetUserValidItems(uid, common.ItemDiscountTicket) - for i, v := range tickets { - thisDiscount := v.Exi1 - diff := v.Time + common.ActivityWeekCardTicketExpireTime - time.Now().Unix() - if diff <= 0 { - id := v.ID - util.Go(func() { - db.Mysql().Update(&common.PlayerItems{ID: id}, map[string]interface{}{"status": common.ItemStatusInvalid}) - }) - continue - } - if discount < 0 || thisDiscount < discount { - discount = thisDiscount - ticket = tickets[i] - exi2 = v.Exi2 - } - } - if discount > 0 && order.Amount == exi2 && ticket != nil { + ticket := call.GetItem(req.DiscountTicketId) + if ticket != nil && req.Amount >= ticket.Exi2 { ticketData := common.ActivityRechargeData{ID: common.ItemDiscountTicket, I1: int(ticket.Exi1), I2: req.Amount} ticketByte, _ := json.Marshal(ticketData) order.Extra = string(ticketByte) - req.Amount = common.RoundCurrency(common.CurrencyINR, req.Amount*discount/common.DecimalDigits) + req.Amount = common.RoundCurrency(common.CurrencyINR, req.Amount-ticket.Exi1) order.Amount = req.Amount + db.Mysql().Update(&common.PlayerItems{ID: ticket.ID}, map[string]interface{}{"status": common.ItemStatusInvalid}) } - } re := call.GetRechargeInfo(uid) notCharge := re.TotalRecharge == 0 diff --git a/modules/web/handler/share.go b/modules/web/handler/share.go index 9a67953..8141022 100644 --- a/modules/web/handler/share.go +++ b/modules/web/handler/share.go @@ -232,6 +232,7 @@ func ShareWithdraw(c *gin.Context) { ChannelID: a.Channel, Value: req.Amount, Event: common.CurrencyEventShareWithdraw, + NeedBet: call.GetConfigCurrencyResourceNeedBet(common.CurrencyResourceShare, req.Amount), }, }) return diff --git a/modules/web/routers/routers_activity.go b/modules/web/routers/routers_activity.go index 9b48aab..3331cc5 100644 --- a/modules/web/routers/routers_activity.go +++ b/modules/web/routers/routers_activity.go @@ -46,4 +46,6 @@ func activity(e *gin.RouterGroup) { e.POST("/activity/firstRechargeBack/draw", handler.ActivityFirstRechargeBackDraw) e.POST("/activity/weekCard/info", handler.ActivityWeekCardInfo) e.POST("/activity/weekCard/draw", handler.ActivityWeekCardDraw) + // 优惠券 + e.POST("/activity/discountTicket/info", handler.DiscountTicketInfo) } diff --git a/modules/web/values/activity.go b/modules/web/values/activity.go index de5c948..fe6f1f5 100644 --- a/modules/web/values/activity.go +++ b/modules/web/values/activity.go @@ -165,6 +165,7 @@ type ActivityWeekCardDrawReq struct { type ActivityWeekCardDrawResp struct { Reward int64 DiscountTicket int64 + Amount int64 } // Spin 可转次数 @@ -313,3 +314,11 @@ type ActivityPopupResp struct { type ActivityFirstRechargeInfoResp struct { List []*common.ConfigActivityPopup } + +type DiscountTicketInfo struct { + Amount int64 + Discount int64 +} +type DiscountTicketResp struct { + Ticket *DiscountTicketInfo +} diff --git a/modules/web/values/pay.go b/modules/web/values/pay.go index 573e502..36dd9d1 100644 --- a/modules/web/values/pay.go +++ b/modules/web/values/pay.go @@ -29,18 +29,20 @@ type RechargeInfoResp struct { } type DiscountTicket struct { - Discount string + Id int + Discount int64 TimeLeft int64 Amount int64 } // RechargeReq 充值请求 地址格式为:{"city":"Mumbai","street":"sarang street","houseNumber":"-54/a"} type RechargeReq struct { - CurrencyType common.CurrencyType `json:"CurrencyType"` - Amount int64 `json:"Amount"` - PayChannel int - ProductID int - Bonus bool + CurrencyType common.CurrencyType `json:"CurrencyType"` + Amount int64 `json:"Amount"` + PayChannel int + ProductID int + Bonus bool + DiscountTicketId int // 折扣券ID } // RechargeHistoryReq 请求充值记录 diff --git a/pb/proto/platform.proto b/pb/proto/platform.proto index bbc2173..cf3747a 100644 --- a/pb/proto/platform.proto +++ b/pb/proto/platform.proto @@ -106,12 +106,13 @@ enum ServerCommonReq{ enum ServerCommonResp{ CommonInvalidResp = 0; - CommonPlayerBalanceResp = 1; // 返回用户余额 PlayerBalanceResp + CommonPlayerBalanceResp = 1; // 返回用户余额 PlayerBalanceResp CommonRedPointResp = 2; // 红点推送 RedPoint - CommonConfigChangeResp = 3; // 配置变动通知 ConfigChangeResp - CommonActivityItemResp = 4; // 活动获得物品通知 ActivityResp - CommonVipResp = 5; // 活动获得物品通知 ActivityResp - CommonBroadcastResp = 6; // 广播 + CommonConfigChangeResp = 3; // 配置变动通知 ConfigChangeResp + CommonActivityItemResp = 4; // 活动获得物品通知 ActivityResp + CommonVipResp = 5; // 活动获得物品通知 ActivityResp + CommonBroadcastResp = 6; // 广播 + CommonDisCountTicketResp = 7; // 折扣券 } // 获取用户余额 @@ -149,7 +150,10 @@ message Product { int64 Amount = 3; // 充值的金额 } - +message DiscountTicketNotify{ + int64 discount = 1; // 满减金额 + int64 amount = 2; // 充值金额 +} /****************************************通用平台类消息开始**********************************************/ enum ServerCommonCmd{