Compare commits

...

6 Commits

Author SHA1 Message Date
mofangmin c166294255 自动建表 1 year ago
mofangmin c6fc03ebdb Merge branch 'dev' into release 1 year ago
mofangmin 755f712100 活动修改 1 year ago
mofangmin 241fdacda0 优惠券通知 1 year ago
mofangmin 452911d4a9 优惠券接口 1 year ago
mofangmin 38f930ad38 优惠券 1 year ago
  1. 25
      call/config.go
  2. 19
      call/item.go
  3. 21
      call/mail.go
  4. 120
      call/pay.go
  5. 3
      call/redpoint.go
  6. 10
      call/reload.go
  7. 3
      call/share.go
  8. 1
      cmd/build.sh
  9. 14
      common/activity.go
  10. 1
      common/config.go
  11. 1
      common/currency.go
  12. 1
      common/player.go
  13. 3
      modules/backend/handler/examine/examine.go
  14. 4
      modules/backend/handler/statistics/reviewAppSummary.go
  15. 6
      modules/backend/handler/statistics/reviewData.go
  16. 1
      modules/backend/migrate.go
  17. 2
      modules/pay/base/callback.go
  18. 86
      modules/web/handler/activity.go
  19. 13
      modules/web/handler/mail.go
  20. 55
      modules/web/handler/recharge.go
  21. 1
      modules/web/handler/share.go
  22. 2
      modules/web/routers/routers_activity.go
  23. 12
      modules/web/values/activity.go
  24. 4
      modules/web/values/pay.go
  25. 7
      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,27 @@ 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
}
// GetConfigDiscountTicketByAmount 不存在就获取小一档的
func GetConfigDiscountTicketByAmount(amount int64) (ret common.ConfigDiscountTicket) {
for _, item := range configDiscountTicket {
if item.RechargeAmount <= amount {
ret = item
}
}
return
}

@ -4,7 +4,9 @@ import (
"fmt" "fmt"
"server/common" "server/common"
"server/db" "server/db"
"time" "server/pb"
"github.com/liangdas/mqant/log"
) )
func GetUserItem(uid, itemID int) []*common.PlayerItems { func GetUserItem(uid, itemID int) []*common.PlayerItems {
@ -13,6 +15,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 +42,12 @@ func GetUserBestDiscountTicket(uid int) *common.PlayerItems {
return nil return nil
} }
func AddUserDiscountTicket(uid int, exi1, exi2 int64) { func AddUserDiscountTicket(uid int, exi1, exi2, t, exi3 int64, notify bool) {
db.Mysql().Create(&common.PlayerItems{UID: uid, ItemID: common.ItemDiscountTicket, Time: time.Now().Unix(), Status: common.ItemStatusNormal, Exi1: exi1, Exi2: exi2}) err := db.Mysql().Create(&common.PlayerItems{UID: uid, ItemID: common.ItemDiscountTicket, Time: t, Status: common.ItemStatusNormal, Exi1: exi1, Exi2: exi2, Exi3: exi3})
if err != nil {
log.Error("AddUserDiscountTicket err:%v", err)
}
if notify {
SendNR(uid, int(pb.ServerCommonResp_CommonDisCountTicketResp), &pb.DiscountTicketNotify{Discount: exi1, Amount: exi2}, "common")
}
} }

@ -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,7 +67,18 @@ 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"
@ -13,6 +14,7 @@ import (
"server/natsClient" "server/natsClient"
"server/pb" "server/pb"
"server/util" "server/util"
"sort"
"time" "time"
"github.com/gogo/protobuf/proto" "github.com/gogo/protobuf/proto"
@ -39,7 +41,7 @@ func GetRechargeInfo(uid int) *common.RechargeInfo {
// Recharge 内部充值调用 // Recharge 内部充值调用
func Recharge(data *pb.InnerRechargeReq) (*pb.InnerRechargeResp, error) { func Recharge(data *pb.InnerRechargeReq) (*pb.InnerRechargeResp, error) {
to, cancel := context.WithTimeout(context.Background(), 5*time.Second) to, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel() defer cancel()
module := "pay" module := "pay"
if data.PaySource == common.PaySourceBlockPay { if data.PaySource == common.PaySourceBlockPay {
@ -99,11 +101,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 +112,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 +140,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 +158,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 {
@ -226,32 +174,14 @@ func RechargeCallback(r *common.RechargeOrder, success bool, payAccount, extra s
// 第三步,给玩家发货 // 第三步,给玩家发货
// 正常商城充值 // 正常商城充值
var bonus = r.Bonus var bonus = r.Bonus
discountOriginAmount := r.Amount // 折扣前的价格
if r.ProductID == 0 { if r.ProductID == 0 {
amount := PayExtra(r) // 判断特殊购买,如优惠券 amount := PayExtra(r) // 判断特殊购买,如优惠券
if amount == 0 { if amount == 0 {
amount = r.Amount amount = r.Amount
} else {
discountOriginAmount = 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
@ -282,10 +212,46 @@ func RechargeCallback(r *common.RechargeOrder, success bool, payAccount, extra s
// 以上逻辑为处理订单,更新玩家充值信息,给玩家加钱。 // 以上逻辑为处理订单,更新玩家充值信息,给玩家加钱。
// 下面逻辑处理活动,数据统计等,不影响以上效率,接下来逻辑并发执行 // 下面逻辑处理活动,数据统计等,不影响以上效率,接下来逻辑并发执行
util.Go(func() { util.Go(func() {
SendNR(r.UID, int(pb.ServerCommonResp_CommonUserInfoResp), &pb.PlayerBalanceResp{}, "common")
// 更新活动数据上传 // 更新活动数据上传
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(discountOriginAmount)
log.Info("ticket:%v", ticket)
if ticket.Id > 0 {
// 赠送优惠券
tickets := GetConfigDiscountTicket()
sort.Slice(tickets, func(i, j int) bool {
return tickets[i].RechargeAmount < tickets[j].RechargeAmount
})
// 获取下一档
nextIdx := -1
for idx, product := range tickets {
if product.RechargeAmount == discountOriginAmount {
nextIdx = idx + 1
}
}
var nextTicket = ticket
if len(tickets) > nextIdx && nextIdx != -1 {
nextTicket = tickets[nextIdx]
}
log.Info("nextTicket:%v", nextTicket)
count := ticket.CurProb + ticket.NextProb
if count > 0 {
val := rand.Intn(count)
log.Info("val:%v", val)
if val <= ticket.CurProb {
AddUserDiscountTicket(uid, ticket.DiscountAmount, ticket.RechargeAmount, -1, 0, true)
SendMailWithContent(uid, SystemTitle, fmt.Sprintf(EmailDiscount, ticket.DiscountAmount/common.DecimalDigits, ticket.RechargeAmount/common.DecimalDigits))
} else if nextTicket.Id > 0 {
AddUserDiscountTicket(uid, nextTicket.DiscountAmount, nextTicket.RechargeAmount, -1, 1, true)
SendMailWithContent(uid, SystemTitle, fmt.Sprintf(EmailDiscount, ticket.DiscountAmount/common.DecimalDigits, ticket.RechargeAmount/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) {

@ -47,10 +47,11 @@ func UpsertRedPointAndNotify(uid, num int, module string) {
func PushMailRed(uid int) { func PushMailRed(uid int) {
redPoints := &common.PlayerRed{UID: uid} redPoints := &common.PlayerRed{UID: uid}
db.Mysql().Get(redPoints) db.Mysql().Get(redPoints)
checkMail(uid, redPoints) if redPoints.Mail > 0 {
one := new(pb.RedPoint) one := new(pb.RedPoint)
one.List = append(one.List, &pb.RedInfo{ModuleName: pb.RedPointModule_RedPointMail, Num: uint32(redPoints.Mail)}) one.List = append(one.List, &pb.RedInfo{ModuleName: pb.RedPointModule_RedPointMail, Num: uint32(redPoints.Mail)})
SendNR(uid, int(pb.ServerCommonResp_CommonRedPointResp), one, "common") SendNR(uid, int(pb.ServerCommonResp_CommonRedPointResp), one, "common")
}
} }
func PushRed(uid int, module pb.RedPointModule, num uint32) { func PushRed(uid int, module pb.RedPointModule, num uint32) {

@ -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
} }

@ -9,3 +9,4 @@ cd pb/proto
cd ../.. cd ../..
#go build main.go #go build main.go
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o indiaprovider main.go CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o indiaprovider main.go
#CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o gameserver main.go

@ -546,6 +546,18 @@ 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 { func (m *ConfigActivityPopup) TableName() string {
return "config_activity_popup" 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"
}

@ -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
) )

@ -176,6 +176,7 @@ type PlayerItems struct {
Status int `gorm:"column:status;type:int(11);default:0;comment:物品状态"` Status int `gorm:"column:status;type:int(11);default:0;comment:物品状态"`
Exi1 int64 `gorm:"column:exi1;type:bigint(20);default:0;comment:物品标识字段1"` Exi1 int64 `gorm:"column:exi1;type:bigint(20);default:0;comment:物品标识字段1"`
Exi2 int64 `gorm:"column:exi2;type:bigint(20);default:0;comment:物品标识字段2"` Exi2 int64 `gorm:"column:exi2;type:bigint(20);default:0;comment:物品标识字段2"`
Exi3 int64 `gorm:"column:exi3;type:bigint(20);default:0;comment:物品标识字段3"`
} }
func (p *PlayerItems) TableName() string { func (p *PlayerItems) TableName() string {

@ -179,7 +179,10 @@ func WithdrawExamine(c *gin.Context) {
if err != nil { if err != nil {
log.Error(err.Error()) log.Error(err.Error())
} }
call.SendMailWithContent(one.UID, call.SystemTitle, fmt.Sprintf(call.EmailWithdrawFail, one.OrderID, one.Amount/common.DecimalDigits))
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)

@ -116,6 +116,7 @@ func MigrateDB() {
new(common.ConfigActivityPopup), new(common.ConfigActivityPopup),
new(common.SheetBroadcastConfig), new(common.SheetBroadcastConfig),
new(common.SheetNoticeConfig), new(common.SheetNoticeConfig),
new(common.ConfigDiscountTicket),
) )
if err != nil { if err != nil {
panic("Migrate db fail") panic("Migrate db fail")

@ -2,6 +2,7 @@ package base
import ( import (
"encoding/json" "encoding/json"
"fmt"
"io" "io"
"net/http" "net/http"
"net/url" "net/url"
@ -97,6 +98,7 @@ func (b *Base) WithdrawCallback(c *gin.Context) {
values.WithdrawAmount(values.PayWay(or.PayChannel), false, or.Amount*100) values.WithdrawAmount(values.PayWay(or.PayChannel), false, or.Amount*100)
} 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))
} }
} }

@ -1306,7 +1306,6 @@ func ActivityWeekCardInfo(c *gin.Context) {
} }
rewardList = append([]int64{cons.DayOneReward}, rewardList...) rewardList = append([]int64{cons.DayOneReward}, rewardList...)
rewardList = append(rewardList, 0) rewardList = append(rewardList, 0)
if cardInfo.ID <= 0 || len(cardInfo.Rewards) == 0 { if cardInfo.ID <= 0 || len(cardInfo.Rewards) == 0 {
cardInfo.Day = 0 cardInfo.Day = 0
rewardList, err = util.GenerateRandomSequence(cons.RewardAmount, cons.MiniLimit, 5) rewardList, err = util.GenerateRandomSequence(cons.RewardAmount, cons.MiniLimit, 5)
@ -1354,7 +1353,7 @@ func ActivityWeekCardInfo(c *gin.Context) {
resp.RewardDay = cardInfo.Day resp.RewardDay = cardInfo.Day
resp.ChannelList = call.GetConfigPayChannelsByID(common.CurrencyINR) resp.ChannelList = call.GetConfigPayChannelsByID(common.CurrencyINR)
resp.ProductList = call.GetConfigPayProductByActivityID(common.ActivityIDWeekCard) resp.ProductList = call.GetConfigPayProductByActivityID(common.ActivityIDWeekCard)
if resp.Status { if resp.Status && resp.RechargeStatus {
call.PushRed(a.UID, pb.RedPointModule_RedPointWeekCard, 1) call.PushRed(a.UID, pb.RedPointModule_RedPointWeekCard, 1)
} }
} }
@ -1373,7 +1372,7 @@ func ActivityWeekCardDraw(c *gin.Context) {
} }
resp := &values.ActivityWeekCardDrawResp{} resp := &values.ActivityWeekCardDrawResp{}
a.Data = resp a.Data = resp
conf := call.GetConfigActivityWeekCard() // conf := call.GetConfigActivityWeekCard()
card := call.GetUserWeekCard(a.UID) card := call.GetUserWeekCard(a.UID)
if card.ID == 0 { if card.ID == 0 {
a.Code = values.CodeRetry a.Code = values.CodeRetry
@ -1409,28 +1408,60 @@ func ActivityWeekCardDraw(c *gin.Context) {
// 推送当前最高额度向上一档充值满减卷 // 推送当前最高额度向上一档充值满减卷
// 用户画像二:只解锁周卡,未充值的玩家 // 用户画像二:只解锁周卡,未充值的玩家
// 推送当前额度向下一档充值满减卷,最低300 // 推送当前额度向下一档充值满减卷,最低300
var list []common.CurrencyBalance
q := elastic.NewBoolQuery() q := elastic.NewBoolQuery()
q.Filter(elastic.NewRangeQuery("time").Gte(card.RechargeTime)) q.Filter(elastic.NewRangeQuery("time").Gte(card.RechargeTime))
q.Filter(elastic.NewRangeQuery("time").Lte(now)) q.Filter(elastic.NewRangeQuery("time").Lte(now))
q.Filter(elastic.NewRangeQuery("event").Gte(common.CurrencyEventReCharge)) q.Filter(elastic.NewRangeQuery("event").Gte(common.CurrencyEventReCharge))
q.Must(elastic.NewTermsQuery("uid", a.UID)) q.Must(elastic.NewTermsQuery("uid", a.UID))
count := db.ES().Count(common.ESIndexBalance, q) db.ES().QueryList(common.ESIndexBalance, 0, 100, q, &list, "time", true)
up := false up := false
if count >= 3 { maxAmount := card.RechargeAmount
if len(list) >= 3 {
up = true up = true
for _, item := range list {
if item.Value > maxAmount {
maxAmount = item.Value
}
}
} }
exi2 := int64(300) * common.DecimalDigits log.Info("maxAmount:%v", maxAmount)
// 判断充值的金额 ticket := call.GetConfigDiscountTicketByAmount(maxAmount)
productList := call.GetConfigPayProduct() log.Info("ticket:%v", ticket)
for _, product := range productList { if ticket.Id > 0 {
if product.Amount > card.RechargeAmount && up && exi2 < product.Amount { // 赠送优惠券
exi2 = product.Amount tickets := call.GetConfigDiscountTicket()
} else if product.Amount < card.RechargeAmount && up && exi2 > product.Amount { sort.Slice(tickets, func(i, j int) bool {
exi2 = product.Amount return tickets[i].RechargeAmount < tickets[j].RechargeAmount
})
// 获取下一档
nextIdx := -1
for idx, item := range tickets {
if item.RechargeAmount == maxAmount {
if up {
nextIdx = idx + 1
} else if item.RechargeAmount >= 300*common.DecimalDigits {
nextIdx = idx - 1
}
break
}
}
var nextTicket = ticket
if len(tickets) > nextIdx && nextIdx != -1 {
nextTicket = tickets[nextIdx]
}
if up {
call.AddUserDiscountTicket(a.UID, ticket.DiscountAmount, ticket.RechargeAmount, -1, 0, false)
call.SendMailWithContent(a.UID, call.SystemTitle, fmt.Sprintf(call.EmailDiscount, ticket.DiscountAmount/common.DecimalDigits, ticket.RechargeAmount/common.DecimalDigits))
resp.DiscountTicket = ticket.DiscountAmount
resp.Amount = ticket.RechargeAmount
} else if nextTicket.Id > 0 {
call.AddUserDiscountTicket(a.UID, nextTicket.DiscountAmount, nextTicket.RechargeAmount, -1, 1, false)
call.SendMailWithContent(a.UID, call.SystemTitle, fmt.Sprintf(call.EmailDiscount, ticket.DiscountAmount/common.DecimalDigits, ticket.RechargeAmount/common.DecimalDigits))
resp.DiscountTicket = nextTicket.DiscountAmount
resp.Amount = nextTicket.RechargeAmount
} }
} }
call.AddUserDiscountTicket(a.UID, conf.Discount, exi2)
resp.DiscountTicket = conf.Discount
} }
resource := common.CurrencyResourceWeekCard resource := common.CurrencyResourceWeekCard
if card.Day > 0 { if card.Day > 0 {
@ -1778,7 +1809,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
} }
} }
@ -1934,6 +1965,7 @@ func ActivityBetDrawInfo(c *gin.Context) {
drawInfo.SpinInfo.SpinNum < drawInfo.SpinInfo.SpinCount && drawInfo.SpinInfo.SpinNum < drawInfo.SpinInfo.SpinCount &&
now.Unix() >= drawInfo.SpinInfo.NextSpinTIme { now.Unix() >= drawInfo.SpinInfo.NextSpinTIme {
call.PushRed(a.UID, pb.RedPointModule_RedPointFreeSpin, uint32(1)) call.PushRed(a.UID, pb.RedPointModule_RedPointFreeSpin, uint32(1))
break
} }
} }
} }
@ -2102,3 +2134,25 @@ 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
})
currency := call.GetUserCurrency(a.UID, common.CurrencyINR)
if len(list) > 0 && currency <= config.GetConfig().Web.BreakLimit {
resp.Ticket = &values.DiscountTicketInfo{
Amount: list[0].Exi1,
Discount: list[0].Exi2,
Id: int64(list[0].ID),
}
}
resp.ChannelList = call.GetConfigPayChannelsByID(common.CurrencyINR)
}

@ -6,6 +6,7 @@ import (
"server/db" "server/db"
"server/modules/web/app" "server/modules/web/app"
"server/modules/web/values" "server/modules/web/values"
"server/pb"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/liangdas/mqant/log" "github.com/liangdas/mqant/log"
@ -41,6 +42,10 @@ func MailList(c *gin.Context) {
Count: int(count), Count: int(count),
} }
a.Data = resp a.Data = resp
call.PushRed(a.UID, pb.RedPointModule_RedPointMail, 0)
db.Mysql().Update(&common.PlayerRed{UID: a.UID}, map[string]interface{}{
"mail": 0,
})
} }
func ReadMail(c *gin.Context) { func ReadMail(c *gin.Context) {
@ -71,8 +76,9 @@ func ReadMail(c *gin.Context) {
a.Code = values.CodeRetry a.Code = values.CodeRetry
return return
} }
call.UpsertRedPointAndNotify(a.UID, -1, call.ModuleMail) // call.UpsertRedPointAndNotify(a.UID, -1, call.ModuleMail)
a.Data = values.ReadMailResp{Mail: *one} a.Data = values.ReadMailResp{Mail: *one}
} }
// func DrawMail(c *gin.Context) { // func DrawMail(c *gin.Context) {
@ -145,7 +151,6 @@ func DeleteMail(c *gin.Context) {
if !a.S(req) { if !a.S(req) {
return return
} }
count := 0
for _, v := range req.ID { for _, v := range req.ID {
// id, err := strconv.Atoi(v) // id, err := strconv.Atoi(v)
// if err != nil { // if err != nil {
@ -171,9 +176,6 @@ func DeleteMail(c *gin.Context) {
count++ count++
} }
} }
if count > 0 {
call.UpsertRedPointAndNotify(a.UID, -count, call.ModuleMail)
}
} }
func DeleteMailAll(c *gin.Context) { func DeleteMailAll(c *gin.Context) {
@ -186,5 +188,4 @@ func DeleteMailAll(c *gin.Context) {
a.Code = values.CodeRetry a.Code = values.CodeRetry
return return
} }
call.UpsertRedPointAndNotify(a.UID, 0, call.ModuleMail)
} }

@ -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,16 @@ 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
} }
} }
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,14 @@ type ActivityPopupResp struct {
type ActivityFirstRechargeInfoResp struct { type ActivityFirstRechargeInfoResp struct {
List []*common.ConfigActivityPopup List []*common.ConfigActivityPopup
} }
type DiscountTicketInfo struct {
Id int64
Amount int64
Discount int64
}
type DiscountTicketResp struct {
Ticket *DiscountTicketInfo
ChannelList []*common.ConfigPayChannels
}

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

Loading…
Cancel
Save