From 90b03ff2bd0e1e8ac09234dadb5c8ff31051d946 Mon Sep 17 00:00:00 2001 From: zhora Date: Thu, 25 Sep 2025 10:34:55 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=8E=A7=E5=A2=9E=E5=8A=A0=E4=B8=AA?= =?UTF-8?q?=E4=BA=BArtp=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- call/config.go | 146 +++++++++++++++--------------- call/pay.go | 2 +- call/user.go | 52 ++++------- modules/web/providers/pg3/base.go | 2 +- 4 files changed, 93 insertions(+), 109 deletions(-) diff --git a/call/config.go b/call/config.go index 0deb95e..caeca89 100644 --- a/call/config.go +++ b/call/config.go @@ -2585,79 +2585,79 @@ func LoadConfigRtpControl() (err error) { log.Error("err:%v", err) return err } - //sort.Slice(result, func(i, j int) bool { - // a, b := result[i], result[j] - // - // // 处理RechargeDay:-1排到最后 - // if a.RechargeDay == -1 && b.RechargeDay != -1 { - // return false // a排在b后面 - // } - // if a.RechargeDay != -1 && b.RechargeDay == -1 { - // return true // a排在b前面 - // } - // if a.RechargeDay == -1 && b.RechargeDay == -1 { - // // 都是-1,继续比较下一个字段 - // if a.WithdrawPer == -1 && b.WithdrawPer != -1 { - // return false - // } - // if a.WithdrawPer != -1 && b.WithdrawPer == -1 { - // return true - // } - // if a.WithdrawPer == -1 && b.WithdrawPer == -1 { - // if a.PersonalRtp == -1 && b.PersonalRtp != -1 { - // return false - // } - // if a.PersonalRtp != -1 && b.PersonalRtp == -1 { - // return true - // } - // return a.PersonalRtp < b.PersonalRtp - // } else { - // if a.WithdrawPer != b.WithdrawPer { - // return a.WithdrawPer < b.WithdrawPer - // } - // } - // } else { - // if a.RechargeDay != b.RechargeDay { - // return a.RechargeDay < b.RechargeDay - // } - // } - // - // // 处理WithdrawPer:-1排到最后 - // if a.WithdrawPer == -1 && b.WithdrawPer != -1 { - // return false - // } - // if a.WithdrawPer != -1 && b.WithdrawPer == -1 { - // return true - // } - // if a.WithdrawPer == -1 && b.WithdrawPer == -1 { - // // 都是-1,继续比较下一个字段 - // if a.PersonalRtp == -1 && b.PersonalRtp != -1 { - // return false - // } - // if a.PersonalRtp != -1 && b.PersonalRtp == -1 { - // return true - // } - // return a.PersonalRtp < b.PersonalRtp - // } else { - // if a.WithdrawPer != b.WithdrawPer { - // return a.WithdrawPer < b.WithdrawPer - // } - // } - // - // // 处理PersonalRtp:-1排到最后 - // if a.PersonalRtp == -1 && b.PersonalRtp != -1 { - // return false - // } - // if a.PersonalRtp != -1 && b.PersonalRtp == -1 { - // return true - // } - // if a.PersonalRtp == -1 && b.PersonalRtp == -1 { - // // 都是-1,相等 - // return false - // } else { - // return a.PersonalRtp < b.PersonalRtp - // } - //}) + sort.Slice(result, func(i, j int) bool { + a, b := result[i], result[j] + + // 处理RechargeDay:-1排到最后 + if a.RechargeDay == -1 && b.RechargeDay != -1 { + return false // a排在b后面 + } + if a.RechargeDay != -1 && b.RechargeDay == -1 { + return true // a排在b前面 + } + if a.RechargeDay == -1 && b.RechargeDay == -1 { + // 都是-1,继续比较下一个字段 + if a.WithdrawPer == -1 && b.WithdrawPer != -1 { + return false + } + if a.WithdrawPer != -1 && b.WithdrawPer == -1 { + return true + } + if a.WithdrawPer == -1 && b.WithdrawPer == -1 { + if a.PersonalRtp == -1 && b.PersonalRtp != -1 { + return false + } + if a.PersonalRtp != -1 && b.PersonalRtp == -1 { + return true + } + return a.PersonalRtp < b.PersonalRtp + } else { + if a.WithdrawPer != b.WithdrawPer { + return a.WithdrawPer < b.WithdrawPer + } + } + } else { + if a.RechargeDay != b.RechargeDay { + return a.RechargeDay < b.RechargeDay + } + } + + // 处理WithdrawPer:-1排到最后 + if a.WithdrawPer == -1 && b.WithdrawPer != -1 { + return false + } + if a.WithdrawPer != -1 && b.WithdrawPer == -1 { + return true + } + if a.WithdrawPer == -1 && b.WithdrawPer == -1 { + // 都是-1,继续比较下一个字段 + if a.PersonalRtp == -1 && b.PersonalRtp != -1 { + return false + } + if a.PersonalRtp != -1 && b.PersonalRtp == -1 { + return true + } + return a.PersonalRtp < b.PersonalRtp + } else { + if a.WithdrawPer != b.WithdrawPer { + return a.WithdrawPer < b.WithdrawPer + } + } + + // 处理PersonalRtp:-1排到最后 + if a.PersonalRtp == -1 && b.PersonalRtp != -1 { + return false + } + if a.PersonalRtp != -1 && b.PersonalRtp == -1 { + return true + } + if a.PersonalRtp == -1 && b.PersonalRtp == -1 { + // 都是-1,相等 + return false + } else { + return a.PersonalRtp < b.PersonalRtp + } + }) configRtpControl = result return nil } diff --git a/call/pay.go b/call/pay.go index e625814..24c1b0d 100644 --- a/call/pay.go +++ b/call/pay.go @@ -171,7 +171,7 @@ func RechargeCallback(r *common.RechargeOrder, success bool, payAccount, extra s if re.LastRechargeAmount > 0 { eliminateBetCfg := GetConfigEliminateBet() if eliminateBetCfg.ID != 0 { - playerProfile := GetPlayerProfileByCurrency(uid, common.CurrencyINR) + playerProfile := GetPlayerProfile(uid) if playerProfile.NeedBet > 0 { cash := GetUserCurrency(uid, common.CurrencyINR) log.Debug("eliminateBet check, uid:%d cash:%d value:%d lastRecharge:%d bankruptcyCoefficient:%d", diff --git a/call/user.go b/call/user.go index bbd08a5..7129f23 100644 --- a/call/user.go +++ b/call/user.go @@ -548,7 +548,7 @@ func UpdatePlayerRechargeInfoCurrency(uid int, t common.CurrencyType, u map[stri return db.Mysql().C().Table(tableName).Where("uid = ?", uid).Updates(u).Error } -func GetPlayerProfileByCurrency(uid int, t common.CurrencyType) *common.PlayerProfile { +func GetPlayerProfile(uid int) *common.PlayerProfile { pp := &common.PlayerProfile{} db.Mysql().C().Model(&common.PlayerProfile{}).Where("uid = ?", uid).Find(pp) return pp @@ -832,10 +832,14 @@ func GetRtpControlV1(uid int, withdrawPer ...*int) int { } rechargeInfo := GetRechargeInfo(uid) cash := GetUserCurrency(uid, common.CurrencyINR) // 当前现金 - var withdrawRechargePer int64 + var withdrawRechargePer, personalRtp int64 if rechargeInfo.TotalRecharge > 0 { withdrawRechargePer = (rechargeInfo.TotalWithdraw + rechargeInfo.WithdrawingCash + cash) * 100 / rechargeInfo.TotalRecharge } + playerProfile := GetPlayerProfile(uid) + if playerProfile != nil { + personalRtp = playerProfile.TotalSettle * 100 / playerProfile.TotalBet + } if rechargeInfo.FirstRecharge == 0 { // 找表 var tmpRechargeOrder common.RechargeOrder err := db.Mysql().C().Model(&common.RechargeOrder{}).Where("uid = ? and `status` = ?", uid, common.StatusROrderPay). @@ -847,46 +851,26 @@ func GetRtpControlV1(uid int, withdrawPer ...*int) int { rechargeDay := int(math.Ceil(float64(time.Now().Unix()-rechargeInfo.FirstRecharge) / float64(24*60*60))) rtpControls := GetConfigRtpControl() - var rtpControl, defaultRtpControl *common.ConfigRtpControl + var rtpControl *common.ConfigRtpControl for _, v := range rtpControls { - if v.RechargeDay == -1 { + if rechargeDay > v.RechargeDay && v.RechargeDay != -1 { continue } - if rechargeDay != v.RechargeDay { + if int(withdrawRechargePer) > v.WithdrawPer && v.WithdrawPer != -1 { continue } - if v.WithdrawPer == -1 { - defaultRtpControl = v - } - if int(withdrawRechargePer) < v.WithdrawPer { - rtpControl = v - break - } - } - if rtpControl == nil && defaultRtpControl != nil { - rtpControl = defaultRtpControl - } - if rtpControl == nil { - for _, v := range rtpControls { - if v.RechargeDay != -1 { - continue - } - if v.WithdrawPer == -1 { - defaultRtpControl = v - } - if int(withdrawRechargePer) < v.WithdrawPer { - rtpControl = v - break - } - } - if rtpControl == nil && defaultRtpControl != nil { - rtpControl = defaultRtpControl + if int(personalRtp) > v.PersonalRtp && v.PersonalRtp != -1 { + continue } + rtpControl = v + break } - if rtpControl != nil { - log.Debug("rtpControl, uid:%d totalWithdraw:%d withdrawing:%d cash:%d totalRecharge:%d withdrawPer:%d rechargeDay:%d | %+v", - uid, rechargeInfo.TotalWithdraw, rechargeInfo.WithdrawingCash, cash, rechargeInfo.TotalRecharge, withdrawRechargePer, rechargeDay, *rtpControl) + log.Debug("rtpControl, uid:%d rechargeDay:%d withdrawPer:%d[(%d+%d+%d)*100/%d] rtp:%d[%d*100/%d] | %+v", + uid, rechargeDay, + withdrawRechargePer, rechargeInfo.TotalWithdraw, rechargeInfo.WithdrawingCash, cash, rechargeInfo.TotalRecharge, + personalRtp, playerProfile.TotalSettle, playerProfile.TotalBet, + *rtpControl) rtp = rtpControl.Rtp } if len(withdrawPer) != 0 { diff --git a/modules/web/providers/pg3/base.go b/modules/web/providers/pg3/base.go index 2c6c0d0..973f995 100644 --- a/modules/web/providers/pg3/base.go +++ b/modules/web/providers/pg3/base.go @@ -52,7 +52,7 @@ func (s *Sub) EnterGame() string { } rechargeInfo := call.GetRechargeInfo(uid) balance := call.GetUserCurrency(uid, common.CurrencyINR) - playerProfile := call.GetPlayerProfileByCurrency(uid, common.CurrencyINR) + playerProfile := call.GetPlayerProfile(uid) // Generate sign game := call.GetConfigGameListByID(providerID, gameID) if game == nil {