From 772b65fd196a11403281a49e4fd4341336d8298c Mon Sep 17 00:00:00 2001 From: zhora Date: Mon, 22 Sep 2025 15:50:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B6=88=E7=A0=81=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- call/config.go | 17 +++++++ call/pay.go | 44 ++++++++++++++++++- call/reload.go | 9 ++++ call/user.go | 3 +- common/config.go | 16 +++++++ common/recharge.go | 1 + .../guser/getGameUserRechargeHistory.go | 8 ++-- modules/backend/migrate.go | 1 + modules/backend/values/gm.go | 2 + modules/web/handler/recharge.go | 5 ++- 10 files changed, 98 insertions(+), 8 deletions(-) diff --git a/call/config.go b/call/config.go index 54a8df1..30e61c8 100644 --- a/call/config.go +++ b/call/config.go @@ -100,6 +100,8 @@ var ( configWeekCard *common.ConfigWeekCard configRtpControl []*common.ConfigRtpControl + + configEliminateBet common.ConfigEliminateBet ) var ( @@ -2590,3 +2592,18 @@ func LoadConfigRtpControl() (err error) { func GetConfigRtpControl() []*common.ConfigRtpControl { return configRtpControl } + +func LoadConfigEliminateBet() (err error) { + var result common.ConfigEliminateBet + err = db.Mysql().C().Model(&common.ConfigEliminateBet{}).Find(&result).Error + if err != nil { + log.Error("err:%v", err) + return err + } + configEliminateBet = result + return nil +} + +func GetConfigEliminateBet() common.ConfigEliminateBet { + return configEliminateBet +} diff --git a/call/pay.go b/call/pay.go index bd8587e..c574a78 100644 --- a/call/pay.go +++ b/call/pay.go @@ -155,6 +155,47 @@ func RechargeCallback(r *common.RechargeOrder, success bool, payAccount, extra s return nil } + if re.LastRechargeAmount == 0 { + var tmpRechargeOrder common.RechargeOrder + err = db.Mysql().C().Model(&common.RechargeOrder{}). + Where("uid = ? and event = ? and status = ?", re.UID, common.CurrencyEventReCharge, 2). + Order("id desc").Find(&tmpRechargeOrder).Error + if err != nil { + log.Error("get user last recharge order err, %s", err.Error()) + } + if tmpRechargeOrder.ID != 0 { + re.LastRechargeAmount = tmpRechargeOrder.Amount + } + } + + if re.LastRechargeAmount > 0 { + eliminateBetCfg := GetConfigEliminateBet() + if eliminateBetCfg.ID != 0 { + playerProfile := GetPlayerProfileByCurrency(uid, common.CurrencyINR) + if playerProfile.NeedBet > 0 { + cash := GetUserCurrency(uid, common.CurrencyINR) + log.Debug("eliminateBet check, uid:%d cash:%d value:%d lastRecharge:%d bankruptcyCoefficient:%d", + uid, cash, re.LastRechargeAmount*int64(eliminateBetCfg.BankruptcyCoefficient)/100, re.LastRechargeAmount, eliminateBetCfg.BankruptcyCoefficient) + if cash <= re.LastRechargeAmount*int64(eliminateBetCfg.BankruptcyCoefficient)/100 { + eliminateBet := re.LastRechargeAmount * int64(eliminateBetCfg.EliminateCoefficient) / 100 + if playerProfile.NeedBet < eliminateBet { + eliminateBet = playerProfile.NeedBet + } + log.Debug("eliminateBet, uid:%d cash:%d lastRecharge:%d bankruptcyCoe:%d eliminateCoe:%d, eliminateBet:%d", + uid, cash, re.LastRechargeAmount, eliminateBetCfg.BankruptcyCoefficient, eliminateBetCfg.EliminateCoefficient, eliminateBet) + err = db.Mysql().C().Model(&common.PlayerProfile{}). + Where("uid = ?", playerProfile.UID). + Updates(map[string]interface{}{ + "need_bet": gorm.Expr("CASE WHEN `need_bet` - ? <= 0 THEN 0 ELSE `need_bet` - ? END", eliminateBet, eliminateBet), + }).Error + if err != nil { + log.Error("eliminateBet err, %s", err.Error()) + } + } + } + } + } + // 第二步,更新recharge_info payData := &common.ESPlayerPayData{UID: uid, Channel: r.ChannelID, Type: 1, CurrencyType: r.CurrencyType} if topThree { @@ -178,6 +219,7 @@ func RechargeCallback(r *common.RechargeOrder, success bool, payAccount, extra s payData.FirstAmount = amount } else { updates := map[string]interface{}{ + "last_recharge_amount": r.Amount, "total_recharge_count": gorm.Expr("total_recharge_count + 1"), "total_recharge": gorm.Expr("total_recharge + ?", amount), "last_recharge": now, @@ -226,7 +268,7 @@ func RechargeCallback(r *common.RechargeOrder, success bool, payAccount, extra s } var needBet int64 if r.ActivityID != 0 { - needBet = GetConfigCurrencyResourceNeedBetByActId(r.ActivityID, amount) + needBet = GetConfigCurrencyResourceNeedBetByActId(r.ActivityID, amount+bonus) } if needBet == 0 { needBet += GetConfigCurrencyResourceNeedBet(common.CurrencyResourceRecharge, amount) diff --git a/call/reload.go b/call/reload.go index f805bc2..51f4f68 100644 --- a/call/reload.go +++ b/call/reload.go @@ -641,4 +641,13 @@ func CommonReload(c map[int][]func(*pb.ReloadGameConfig) error) { return nil }} } + if _, ok := c[common.ReloadConfigEliminateBet]; !ok { + c[common.ReloadConfigEliminateBet] = []func(*pb.ReloadGameConfig) error{func(rgc *pb.ReloadGameConfig) error { + if err := LoadConfigEliminateBet(); err != nil { + log.Error("error : [%s]", err.Error()) + return err + } + return nil + }} + } } diff --git a/call/user.go b/call/user.go index 6f7701c..bbd08a5 100644 --- a/call/user.go +++ b/call/user.go @@ -550,8 +550,7 @@ func UpdatePlayerRechargeInfoCurrency(uid int, t common.CurrencyType, u map[stri func GetPlayerProfileByCurrency(uid int, t common.CurrencyType) *common.PlayerProfile { pp := &common.PlayerProfile{} - tableName := fmt.Sprintf("player_profile_%s", t.GetCurrencyName()) - db.Mysql().C().Table(tableName).Where("uid = ?", uid).Scan(pp) + db.Mysql().C().Model(&common.PlayerProfile{}).Where("uid = ?", uid).Find(pp) return pp } diff --git a/common/config.go b/common/config.go index 7cf76ed..1ea1631 100644 --- a/common/config.go +++ b/common/config.go @@ -74,6 +74,7 @@ const ( ReloadTypeConfigShareRankAward ReloadConfigWeekCard // 周卡 ReloadConfigRtpControl + ReloadConfigEliminateBet ReloadTypeExcel ) @@ -204,6 +205,8 @@ func GetConfigStructByType(t int) (interface{}, interface{}) { return &ConfigWeekCard{}, &[]ConfigWeekCard{} case ReloadConfigRtpControl: return &ConfigRtpControl{}, &[]ConfigRtpControl{} + case ReloadConfigEliminateBet: + return &ConfigEliminateBet{}, &[]ConfigEliminateBet{} default: return nil, nil } @@ -789,3 +792,16 @@ const ( WithdrawSorceBlock WithdrawSorceShare // 分享 ) + +// ConfigEliminateBet 消除打码量配置 +type ConfigEliminateBet struct { + ID int `gorm:"primarykey"` + BankruptcyCoefficient int `gorm:"column:bankruptcy_coefficient;default:0;type:int(11);comment:破产系数(*100)" web:"bankruptcy_coefficient"` + EliminateCoefficient int `gorm:"column:eliminate_coefficient;default:0;type:int(11);comment:消除系数(*100)" web:"eliminate_coefficient"` + // 更新信息 + UpdatedBase +} + +func (c *ConfigEliminateBet) TableName() string { + return "config_eliminate_bet" +} diff --git a/common/recharge.go b/common/recharge.go index 37d82ab..c7a3eaf 100644 --- a/common/recharge.go +++ b/common/recharge.go @@ -204,6 +204,7 @@ type RechargeInfo struct { TotalRechargeCount int64 `gorm:"column:total_recharge_count;type:bigint(20);default:0;comment:总充值次数"` FirstRecharge int64 `gorm:"column:first_recharge;type:bigint(20);default:0;comment:第一次充值的时间戳"` LastRecharge int64 `gorm:"column:last_recharge;type:bigint(20);default:0;comment:最近一次充值的时间戳"` + LastRechargeAmount int64 `gorm:"column:last_recharge_amount;type:bigint(20);default:0;comment:最近一次充值的数值"` TotalRecharge int64 `gorm:"column:total_recharge;type:bigint(20);default:0;comment:总充值数额,不论货币"` TotalWithdrawCount int64 `gorm:"column:total_withdraw_count;type:bigint(20);default:0;comment:总退出次数"` TotalWithdraw int64 `gorm:"column:total_withdraw;type:bigint(20);default:0;comment:总退出数额,不论货币"` diff --git a/modules/backend/handler/guser/getGameUserRechargeHistory.go b/modules/backend/handler/guser/getGameUserRechargeHistory.go index c062081..f51c35c 100644 --- a/modules/backend/handler/guser/getGameUserRechargeHistory.go +++ b/modules/backend/handler/guser/getGameUserRechargeHistory.go @@ -24,7 +24,7 @@ func GetGameUserRechargeHistory(c *gin.Context) { resp := values.GetGameUserRechargeHistoryResp{} var ret []common.RechargeOrder if req.UID > 0 { - count, err := db.Mysql().QueryPlayerRWHistory(&req.UID, nil, req.Page-1, req.Num, []int{int(common.CurrencyEventReCharge), + count, err := db.Mysql().QueryPlayerRWHistory(&req.UID, nil, req.Page-1, req.Num, []int{int(common.CurrencyEventReCharge), int(common.CurrencyEventActivityWeekCard), common.CurrencyEventGMRecharge}, req.Start, req.End, &common.RechargeOrder{}, &ret, req.Status) if err != nil { log.Error("err:%v", err) @@ -37,17 +37,17 @@ func GetGameUserRechargeHistory(c *gin.Context) { Amount: v.Amount, Status: int(v.Status), MyOrderID: v.OrderID, OrderID: v.APIPayID, PayChannel: v.PayChannel, PaySource: v.PaySource}) } - resp.RechargeCount = db.Mysql().Count(&common.RechargeOrder{}, fmt.Sprintf("uid = %v and (event = %v or event = %v)", req.UID, common.CurrencyEventReCharge, common.CurrencyEventGMRecharge)) + resp.RechargeCount = db.Mysql().Count(&common.RechargeOrder{}, fmt.Sprintf("uid = %v and (event = %v or event = %v or event = %v)", req.UID, common.CurrencyEventReCharge, common.CurrencyEventGMRecharge, common.CurrencyEventActivityWeekCard)) re := &common.RechargeInfo{UID: req.UID} err = db.Mysql().Get(re) if err != nil { log.Error(err.Error()) } resp.RechargeTotal = re.TotalRecharge - successCount := db.Mysql().Count(&common.RechargeOrder{}, fmt.Sprintf("uid = %v and (event = %v or event = %v) and status = %v", req.UID, common.CurrencyEventReCharge, common.CurrencyEventGMRecharge, common.StatusROrderPay)) + successCount := db.Mysql().Count(&common.RechargeOrder{}, fmt.Sprintf("uid = %v and (event = %v or event = %v or event = %v) and status = %v", req.UID, common.CurrencyEventReCharge, common.CurrencyEventGMRecharge, common.CurrencyEventActivityWeekCard, common.StatusROrderPay)) resp.RechargeSuccessPer = utils.GetPer(successCount, resp.RechargeCount) } else if req.OrderID != "" { - resp.Count, _ = db.Mysql().QueryList(req.Page-1, req.Num, fmt.Sprintf(`event = %v and (apipayid = "%v" or orderid = "%v")`, common.CurrencyEventReCharge, req.OrderID, req.OrderID), "create_time desc", &common.RechargeOrder{}, &ret) + resp.Count, _ = db.Mysql().QueryList(req.Page-1, req.Num, fmt.Sprintf(`event = %v or event = %v and (apipayid = "%v" or orderid = "%v")`, common.CurrencyEventReCharge, common.CurrencyEventActivityWeekCard, req.OrderID, req.OrderID), "create_time desc", &common.RechargeOrder{}, &ret) // log.Debug("ret:%v", ret) for _, v := range ret { resp.List = append(resp.List, values.OneRechargeList{UID: v.UID, Time: v.CreateTime, CallbackTime: v.CallbackTime, CurrencyType: v.CurrencyType, diff --git a/modules/backend/migrate.go b/modules/backend/migrate.go index be0b118..4ad5bee 100644 --- a/modules/backend/migrate.go +++ b/modules/backend/migrate.go @@ -152,6 +152,7 @@ func MigrateDB() { new(common.ConfigWeekCard), new(common.WeekCardData), new(common.ConfigRtpControl), + new(common.ConfigEliminateBet), ) if err != nil { panic("Migrate db fail") diff --git a/modules/backend/values/gm.go b/modules/backend/values/gm.go index 29b02b8..1208178 100644 --- a/modules/backend/values/gm.go +++ b/modules/backend/values/gm.go @@ -208,6 +208,8 @@ func GetControlType(path string) int { return common.ReloadConfigWeekCard case "rtpControl": return common.ReloadConfigRtpControl + case "eliminateBet": + return common.ReloadConfigEliminateBet default: return 0 } diff --git a/modules/web/handler/recharge.go b/modules/web/handler/recharge.go index 8fb2221..9405fa3 100644 --- a/modules/web/handler/recharge.go +++ b/modules/web/handler/recharge.go @@ -315,6 +315,9 @@ func NewRechargeImp(req *values.RechargeReq, uid, cid int, ip string) *RechargeI switch req.ActivityID { case common.ActivityIDWeekCard: order.Event = int(common.CurrencyEventActivityWeekCard) + if weekCard := call.GetConfigWeekCard(); weekCard != nil { + order.Bonus = int64(weekCard.AwardDetails[1].AwardLower*common.DecimalDigits) - req.Amount + } } } // 只有商城购买才能使用优惠券 @@ -334,7 +337,7 @@ func NewRechargeImp(req *values.RechargeReq, uid, cid int, ip string) *RechargeI //notCharge := re.TotalRecharge == 0 //per := call.GetConfigFirstPayPerByAmount(notCharge, order.Amount) var times int - if req.Bonus { + if req.Bonus && req.ActivityID == 0 { times = re.BuyAmountDataMap[fmt.Sprintf("%d", order.Amount)] per, topThree := call.GetConfigFirstPayByCount(order.Amount, times) if per > 0 {