邮件
dev
mofangmin 1 year ago
parent f97dcd0289
commit 38f930ad38
  1. 24
      call/config.go
  2. 13
      call/item.go
  3. 19
      call/mail.go
  4. 104
      call/pay.go
  5. 10
      call/reload.go
  6. 3
      call/share.go
  7. 12
      common/activity.go
  8. 1
      common/config.go
  9. 1
      common/currency.go
  10. 2
      modules/backend/handler/examine/examine.go
  11. 4
      modules/backend/handler/statistics/reviewAppSummary.go
  12. 6
      modules/backend/handler/statistics/reviewData.go
  13. 3
      modules/pay/base/callback.go
  14. 24
      modules/web/handler/activity.go
  15. 56
      modules/web/handler/recharge.go
  16. 1
      modules/web/handler/share.go
  17. 2
      modules/web/routers/routers_activity.go
  18. 9
      modules/web/values/activity.go
  19. 4
      modules/web/values/pay.go
  20. 6
      pb/proto/platform.proto

@ -64,6 +64,7 @@ var (
configTgRobot []*common.ConfigTgRobot configTgRobot []*common.ConfigTgRobot
configBetDraw []*common.ConfigActivityBetDraw configBetDraw []*common.ConfigActivityBetDraw
configActivityPopup []*common.ConfigActivityPopup configActivityPopup []*common.ConfigActivityPopup
configDiscountTicket []common.ConfigDiscountTicket
// 客服 // 客服
configCustomerRobot []*common.ConfigCustomerRobot configCustomerRobot []*common.ConfigCustomerRobot
customerOrderLabel []*common.CustomerOrderLabel customerOrderLabel []*common.CustomerOrderLabel
@ -1558,3 +1559,26 @@ func GetConfigActivityPopupByType(jumpType int) []*common.ConfigActivityPopup {
} }
return ret 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{}
}

@ -4,7 +4,7 @@ import (
"fmt" "fmt"
"server/common" "server/common"
"server/db" "server/db"
"time" "server/pb"
) )
func GetUserItem(uid, itemID int) []*common.PlayerItems { func GetUserItem(uid, itemID int) []*common.PlayerItems {
@ -13,6 +13,11 @@ func GetUserItem(uid, itemID int) []*common.PlayerItems {
return list 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 { func GetUserValidItems(uid, itemID int) []*common.PlayerItems {
list := []*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) 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 return nil
} }
func AddUserDiscountTicket(uid int, exi1, exi2 int64) { func AddUserDiscountTicket(uid int, exi1, exi2, t int64) {
db.Mysql().Create(&common.PlayerItems{UID: uid, ItemID: common.ItemDiscountTicket, Time: time.Now().Unix(), Status: common.ItemStatusNormal, Exi1: exi1, Exi2: exi2}) 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})
} }

@ -10,6 +10,14 @@ import (
"gorm.io/gorm" "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) { func checkMail(uid int, red *common.PlayerRed) {
data := &common.PlayerData{UID: uid} data := &common.PlayerData{UID: uid}
db.Mysql().Get(data) db.Mysql().Get(data)
@ -59,6 +67,17 @@ func SendWithdrawMail(uid int, contentType string) {
UpsertRedPointAndNotify(uid, 1, ModuleMail) 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) { func SendMail(mail *common.Mail) {
db.Mysql().Create(mail) db.Mysql().Create(mail)
UpsertRedPointAndNotify(mail.Receiver, 1, ModuleMail) UpsertRedPointAndNotify(mail.Receiver, 1, ModuleMail)

@ -6,6 +6,7 @@ import (
"errors" "errors"
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"math/rand"
"net/http" "net/http"
"server/common" "server/common"
"server/config" "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) log.Error("get recharage info err:%v,uid:%v", err, r.UID)
return err return err
} }
// product := GetConfigPayProductByID(r.ProductID)
// if product == nil {
// log.Error("unkonwn product:%d", r.ProductID)
// return errors.New("unkonwn product")
// }
amount := r.Amount amount := r.Amount
notCharge := re.TotalRecharge == 0 notCharge := re.TotalRecharge == 0
@ -115,31 +111,9 @@ func RechargeCallback(r *common.RechargeOrder, success bool, payAccount, extra s
dayR = true dayR = true
re.DayRecharge += amount re.DayRecharge += amount
} }
// if util.IsSameWeek(re.LastRecharge, now) || re.LastRecharge == 0 {
// weekR = true
// re.WeekRecharge += amount
// }
re.LastRecharge = now re.LastRecharge = now
re.TotalRechargeCount++ 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() tx := db.Mysql().Begin()
defer func() { defer func() {
if err == nil { if err == nil {
@ -165,27 +139,6 @@ func RechargeCallback(r *common.RechargeOrder, success bool, payAccount, extra s
return nil 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 // 第二步,更新recharge_info
payData := &common.ESPlayerPayData{UID: uid, Channel: r.ChannelID, Type: 1, CurrencyType: r.CurrencyType} payData := &common.ESPlayerPayData{UID: uid, Channel: r.ChannelID, Type: 1, CurrencyType: r.CurrencyType}
if re.ID == 0 { 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_count": gorm.Expr("total_recharge_count + 1"),
"total_recharge": gorm.Expr("total_recharge + ?", amount), "total_recharge": gorm.Expr("total_recharge + ?", amount),
"last_recharge": now, "last_recharge": now,
// "product_paycount": re.ProductPayCount,
// "product_firstpay": re.ProductFirstPay,
} }
if dayR { if dayR {
updates["day_recharge"] = gorm.Expr("day_recharge + ?", amount) updates["day_recharge"] = gorm.Expr("day_recharge + ?", amount)
} else { } else {
updates["day_recharge"] = amount 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 err = tx.Model(re).Where("uid=?", re.UID).Updates(updates).Error
} }
if err != nil { if err != nil {
@ -231,27 +178,6 @@ func RechargeCallback(r *common.RechargeOrder, success bool, payAccount, extra s
if amount == 0 { if amount == 0 {
amount = r.Amount 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 t := common.CurrencyResourceRecharge
if notCharge && bonus > 0 { // 首充 if notCharge && bonus > 0 { // 首充
t = common.CurrencyResourceFirstRecharge t = common.CurrencyResourceFirstRecharge
@ -286,6 +212,32 @@ func RechargeCallback(r *common.RechargeOrder, success bool, payAccount, extra s
if bonus > 0 { if bonus > 0 {
UploadActivityData(uid, common.ActivityIDRecharge, common.ActivityDataJoin, bonus) 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) user, _ := GetUserInfo(uid)
PayActivity(r, notCharge, user) PayActivity(r, notCharge, user)
if r.Event != int(common.CurrencyEventGMRecharge) { if r.Event != int(common.CurrencyEventGMRecharge) {

@ -466,6 +466,16 @@ func CommonReload(c map[int][]func(*pb.ReloadGameConfig) error) {
return nil 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 { if _, ok := c[common.ReloadConfigCustomerRobot]; !ok {
c[common.ReloadConfigCustomerRobot] = []func(*pb.ReloadGameConfig) error{func(rgc *pb.ReloadGameConfig) error { c[common.ReloadConfigCustomerRobot] = []func(*pb.ReloadGameConfig) error{func(rgc *pb.ReloadGameConfig) error {

@ -67,9 +67,6 @@ func ShareBind(share string, isOld bool, uid, cid int) {
// 判断分享,发放有效用户奖励 // 判断分享,发放有效用户奖励
func CheckShare(r *common.RechargeOrder) { func CheckShare(r *common.RechargeOrder) {
reward := GetConfigShareSys().ShareReward reward := GetConfigShareSys().ShareReward
if reward <= 0 {
return
}
if r.Amount < GetConfigShareSys().ShareRecharge { if r.Amount < GetConfigShareSys().ShareRecharge {
return return
} }

@ -546,6 +546,14 @@ type ConfigActivityPopup struct {
AdditionalInfo string `gorm:"column:additional_info;type:text;comment:附加信息" web:"additional_info"` AdditionalInfo string `gorm:"column:additional_info;type:text;comment:附加信息" web:"additional_info"`
} }
func (c *ConfigActivityPopup) TableName() string { type ConfigDiscountTicket struct {
return "config_activity_popup" 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"
} }

@ -52,6 +52,7 @@ const (
ReloadConfigTgRobot // tg机器人配置 ReloadConfigTgRobot // tg机器人配置
ReloadConfigBetDraw // 下注抽奖 ReloadConfigBetDraw // 下注抽奖
ReloadConfigActivityPopup // 活动弹窗 ReloadConfigActivityPopup // 活动弹窗
ReloadConfigDiscountTicket // 折扣券
ReloadConfigCustomerRobot // 客服系统机器人配置 ReloadConfigCustomerRobot // 客服系统机器人配置
ReloadConfigCustomerLabel // 客服系统订单标签 ReloadConfigCustomerLabel // 客服系统订单标签

@ -29,6 +29,7 @@ const (
CurrencyResourceRechargeBonus // bonus充值 CurrencyResourceRechargeBonus // bonus充值
CurrencyResourceFirstRecharge // 首充 CurrencyResourceFirstRecharge // 首充
CurrencyResourceWeekCard // 周卡 CurrencyResourceWeekCard // 周卡
CurrencyResourceShare // 分享
CurrencyResourceAll CurrencyResourceAll
) )

@ -178,7 +178,9 @@ func WithdrawExamine(c *gin.Context) {
if err != nil { if err != nil {
log.Error(err.Error()) 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)) a.RecordEdit(values.PowerExamineWithdraw, fmt.Sprintf("审核退出订单ID:%v", req.ID))
} }

@ -144,7 +144,7 @@ func ReviewAppSummary(c *gin.Context) {
// activePlayTime += ap // activePlayTime += ap
// ar, _ := strconv.ParseFloat(resp.PlatformData[i].ARPPU, 64) // ar, _ := strconv.ParseFloat(resp.PlatformData[i].ARPPU, 64)
// arppu += ar // arppu += ar
// ws, _ := strconv.ParseFloat(strings.ReplaceAll(resp.PlatformData[i].WithdrawSuccess, "%", ""), 64) // ws, _ := strconv.ParseFloat(strings.ReplaceAll(resp.PlatformData[i].EmailWithdrawSuccess, "%", ""), 64)
// withdrawSuccess += ws // withdrawSuccess += ws
} }
@ -164,7 +164,7 @@ func ReviewAppSummary(c *gin.Context) {
// resp.Total.OldPlayTime = util.FormatFloat(oldPlayTime/float64(len(tempChannelArr)), 2) // resp.Total.OldPlayTime = util.FormatFloat(oldPlayTime/float64(len(tempChannelArr)), 2)
// resp.Total.ActivePlayTime = util.FormatFloat(activePlayTime/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.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 { switch req.Sort {

@ -150,7 +150,7 @@ func ReviewData(c *gin.Context) {
// activePlayTime += ap // activePlayTime += ap
// ar, _ := strconv.ParseFloat(one.ARPPU, 64) // ar, _ := strconv.ParseFloat(one.ARPPU, 64)
// arppu += ar // arppu += ar
// withdrawSuccess = utils.AddPerFloat(withdrawSuccess, one.WithdrawSuccess) // withdrawSuccess = utils.AddPerFloat(withdrawSuccess, one.EmailWithdrawSuccess)
} }
sort.Slice(resp.PlatformData, func(i, j int) bool { sort.Slice(resp.PlatformData, func(i, j int) bool {
return resp.PlatformData[i].Time > resp.PlatformData[j].Time 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.OldPlayTime = util.FormatFloat(oldPlayTime/float64(resp.Count), 2)
// total.ActivePlayTime = util.FormatFloat(activePlayTime/float64(resp.Count), 2) // total.ActivePlayTime = util.FormatFloat(activePlayTime/float64(resp.Count), 2)
// total.ARPPU = util.FormatFloat(arppu/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.NewPayPer = utils.GetPer(total.NewPayCount, total.NewCount)
// total.NewPlayPer = utils.GetPer(total.NewPlayCount, 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) 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) // ret.WithdrawPlayerSuccess = utils.GetPer(ret.WithdrawPlayerNum, totalWithdrawPlayer)

@ -2,6 +2,7 @@ package base
import ( import (
"encoding/json" "encoding/json"
"fmt"
"io" "io"
"net/http" "net/http"
"net/url" "net/url"
@ -95,8 +96,10 @@ func (b *Base) WithdrawCallback(c *gin.Context) {
} }
if !success { if !success {
values.WithdrawAmount(values.PayWay(or.PayChannel), false, or.Amount*100) 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 { } else {
values.WithdrawSuccess(values.PayWay(or.PayChannel)) values.WithdrawSuccess(values.PayWay(or.PayChannel))
call.SendMailWithContent(or.UID, call.SystemTitle, fmt.Sprintf(call.EmailWithdrawSuccess, or.OrderID, or.Amount/common.DecimalDigits))
} }
} }

@ -1429,8 +1429,9 @@ func ActivityWeekCardDraw(c *gin.Context) {
exi2 = product.Amount 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.DiscountTicket = conf.Discount
resp.Amount = exi2
} }
resource := common.CurrencyResourceWeekCard resource := common.CurrencyResourceWeekCard
if card.Day > 0 { if card.Day > 0 {
@ -1778,7 +1779,7 @@ func ActivitySevenDayBoxDraw(c *gin.Context) {
call.UploadActivityData(a.UID, common.ActivityIDSevenDayBox, common.ActivityDataJoin, reward) call.UploadActivityData(a.UID, common.ActivityIDSevenDayBox, common.ActivityDataJoin, reward)
} }
if oneDiscount.Discount > 0 { if oneDiscount.Discount > 0 {
// call.AddUserDiscountTicket(a.UID, oneDiscount.Discount) // call.AddUserDiscountTicket(a.UID, oneDiscount.EmailDiscount)
resp.Discount = oneDiscount.Discount resp.Discount = oneDiscount.Discount
} }
} }
@ -2102,3 +2103,22 @@ func WeekCardDraw(c *gin.Context) {
resp.List = call.GetConfigActivityPopupByType(req.JumpType) 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,
}
}
}

@ -2,7 +2,6 @@ package handler
import ( import (
"encoding/json" "encoding/json"
"fmt"
"server/call" "server/call"
"server/config" "server/config"
"server/db" "server/db"
@ -91,36 +90,21 @@ func RechargeInfo(c *gin.Context) {
if a.UID > 0 { if a.UID > 0 {
// 判断是否有折扣券 // 判断是否有折扣券
tickets := call.GetUserValidItems(a.UID, common.ItemDiscountTicket) tickets := call.GetUserValidItems(a.UID, common.ItemDiscountTicket)
discount := int64(0)
for _, v := range tickets { for _, v := range tickets {
thisDiscount := v.Exi1 diff := v.Time - time.Now().Unix()
diff := v.Time + common.ActivityWeekCardTicketExpireTime - time.Now().Unix() if v.Time != -1 && diff <= 0 {
if diff <= 0 {
id := v.ID id := v.ID
util.Go(func() { util.Go(func() {
db.Mysql().Update(&common.PlayerItems{ID: id}, map[string]interface{}{"status": common.ItemStatusInvalid}) db.Mysql().Update(&common.PlayerItems{ID: id}, map[string]interface{}{"status": common.ItemStatusInvalid})
}) })
continue continue
} }
if discount < thisDiscount {
discount = thisDiscount
resp.DiscountTicket = append(resp.DiscountTicket, &values.DiscountTicket{ resp.DiscountTicket = append(resp.DiscountTicket, &values.DiscountTicket{
// Level: con.Level, Id: v.ID,
Discount: fmt.Sprintf("%d", 100-discount), Discount: v.Exi1,
TimeLeft: diff, TimeLeft: v.Time,
Amount: v.Exi2, 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
// }
}
} }
} }
} }
@ -254,37 +238,17 @@ func NewRechargeImp(req *values.RechargeReq, uid, cid int, ip string) *RechargeI
ProductID: req.ProductID, ProductID: req.ProductID,
} }
// 只有商城购买才能使用优惠券 // 只有商城购买才能使用优惠券
if req.ProductID == 0 { if req.ProductID == 0 && req.DiscountTicketId > 0 {
// 首先判断折扣券
var ticket *common.PlayerItems
discount := int64(-1)
exi2 := int64(0)
// 判断是否有折扣券 // 判断是否有折扣券
tickets := call.GetUserValidItems(uid, common.ItemDiscountTicket) ticket := call.GetItem(req.DiscountTicketId)
for i, v := range tickets { if ticket != nil && req.Amount >= ticket.Exi2 {
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 {
ticketData := common.ActivityRechargeData{ID: common.ItemDiscountTicket, I1: int(ticket.Exi1), I2: req.Amount} ticketData := common.ActivityRechargeData{ID: common.ItemDiscountTicket, I1: int(ticket.Exi1), I2: req.Amount}
ticketByte, _ := json.Marshal(ticketData) ticketByte, _ := json.Marshal(ticketData)
order.Extra = string(ticketByte) 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 order.Amount = req.Amount
db.Mysql().Update(&common.PlayerItems{ID: ticket.ID}, map[string]interface{}{"status": common.ItemStatusInvalid})
} }
} }
re := call.GetRechargeInfo(uid) re := call.GetRechargeInfo(uid)
notCharge := re.TotalRecharge == 0 notCharge := re.TotalRecharge == 0

@ -232,6 +232,7 @@ func ShareWithdraw(c *gin.Context) {
ChannelID: a.Channel, ChannelID: a.Channel,
Value: req.Amount, Value: req.Amount,
Event: common.CurrencyEventShareWithdraw, Event: common.CurrencyEventShareWithdraw,
NeedBet: call.GetConfigCurrencyResourceNeedBet(common.CurrencyResourceShare, req.Amount),
}, },
}) })
return return

@ -46,4 +46,6 @@ func activity(e *gin.RouterGroup) {
e.POST("/activity/firstRechargeBack/draw", handler.ActivityFirstRechargeBackDraw) e.POST("/activity/firstRechargeBack/draw", handler.ActivityFirstRechargeBackDraw)
e.POST("/activity/weekCard/info", handler.ActivityWeekCardInfo) e.POST("/activity/weekCard/info", handler.ActivityWeekCardInfo)
e.POST("/activity/weekCard/draw", handler.ActivityWeekCardDraw) e.POST("/activity/weekCard/draw", handler.ActivityWeekCardDraw)
// 优惠券
e.POST("/activity/discountTicket/info", handler.DiscountTicketInfo)
} }

@ -165,6 +165,7 @@ type ActivityWeekCardDrawReq struct {
type ActivityWeekCardDrawResp struct { type ActivityWeekCardDrawResp struct {
Reward int64 Reward int64
DiscountTicket int64 DiscountTicket int64
Amount int64
} }
// Spin 可转次数 // Spin 可转次数
@ -313,3 +314,11 @@ type ActivityPopupResp struct {
type ActivityFirstRechargeInfoResp struct { type ActivityFirstRechargeInfoResp struct {
List []*common.ConfigActivityPopup List []*common.ConfigActivityPopup
} }
type DiscountTicketInfo struct {
Amount int64
Discount int64
}
type DiscountTicketResp struct {
Ticket *DiscountTicketInfo
}

@ -29,7 +29,8 @@ type RechargeInfoResp struct {
} }
type DiscountTicket struct { type DiscountTicket struct {
Discount string Id int
Discount int64
TimeLeft int64 TimeLeft int64
Amount int64 Amount int64
} }
@ -41,6 +42,7 @@ type RechargeReq struct {
PayChannel int PayChannel int
ProductID int ProductID int
Bonus bool Bonus bool
DiscountTicketId int // 折扣券ID
} }
// RechargeHistoryReq 请求充值记录 // RechargeHistoryReq 请求充值记录

@ -112,6 +112,7 @@ enum ServerCommonResp{
CommonActivityItemResp = 4; // ActivityResp CommonActivityItemResp = 4; // ActivityResp
CommonVipResp = 5; // ActivityResp CommonVipResp = 5; // ActivityResp
CommonBroadcastResp = 6; // 广 CommonBroadcastResp = 6; // 广
CommonDisCountTicketResp = 7; //
} }
// //
@ -149,7 +150,10 @@ message Product {
int64 Amount = 3; // int64 Amount = 3; //
} }
message DiscountTicketNotify{
int64 discount = 1; //
int64 amount = 2; //
}
/****************************************通用平台类消息开始**********************************************/ /****************************************通用平台类消息开始**********************************************/
enum ServerCommonCmd{ enum ServerCommonCmd{

Loading…
Cancel
Save