支付权重配置,临时提交

dev_aagame_provider
zhora 1 month ago
parent cf3a7d8f8c
commit bd25442109
  1. 73
      call/config.go
  2. 2
      call/pay.go
  3. 1
      common/player.go
  4. 5
      common/redis_keys.go
  5. 4
      modules/gate/agent.go
  6. 21
      modules/pay/handler.go
  7. 4
      modules/pay/values/values.go

@ -2585,6 +2585,79 @@ func LoadConfigRtpControl() (err error) {
log.Error("err:%v", err) log.Error("err:%v", err)
return 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
// }
//})
configRtpControl = result configRtpControl = result
return nil return nil
} }

@ -112,7 +112,7 @@ func RechargeCallback(r *common.RechargeOrder, success bool, payAccount, extra s
ro := &common.RechargeOrder{OrderID: r.OrderID, Status: common.StatusROrderCreate} ro := &common.RechargeOrder{OrderID: r.OrderID, Status: common.StatusROrderCreate}
return db.Mysql().Update(ro, &common.RechargeOrder{Status: common.StatusROrderFail}) return db.Mysql().Update(ro, &common.RechargeOrder{Status: common.StatusROrderFail})
} }
db.Redis().Delkey(common.GetRedisKeyUserPay(r.PayChannel, r.UID, int(r.Amount/common.DecimalDigits)))
uid := r.UID uid := r.UID
re := GetRechargeInfo(uid) re := GetRechargeInfo(uid)
CheckUserBet(uid, r.CurrencyType) CheckUserBet(uid, r.CurrencyType)

@ -331,6 +331,7 @@ type ConfigRtpControl struct {
ID int `gorm:"column:id;type:int(11) AUTO_INCREMENT;primary_key"` ID int `gorm:"column:id;type:int(11) AUTO_INCREMENT;primary_key"`
RechargeDay int `gorm:"column:recharge_day;type:bigint(20);comment:充值天数" web:"recharge_day"` RechargeDay int `gorm:"column:recharge_day;type:bigint(20);comment:充值天数" web:"recharge_day"`
WithdrawPer int `gorm:"column:withdraw_per;type:bigint(20);comment:提存比" web:"withdraw_per"` WithdrawPer int `gorm:"column:withdraw_per;type:bigint(20);comment:提存比" web:"withdraw_per"`
PersonalRtp int `gorm:"column:personal_rtp;type:bigint(20);comment:个人rtp" web:"personal_rtp"`
Rtp int `gorm:"column:rtp;type:int(11);comment:rtp" web:"rtp"` Rtp int `gorm:"column:rtp;type:int(11);comment:rtp" web:"rtp"`
UpdatedBase UpdatedBase
} }

@ -52,6 +52,7 @@ const (
RedisKeyPdd = "pdd" RedisKeyPdd = "pdd"
RedisKeyShare = "share" RedisKeyShare = "share"
RedisKeyWeekCard = "week_card" RedisKeyWeekCard = "week_card"
RedisKeyUserPay = "user_pay"
) )
const ( const (
@ -219,3 +220,7 @@ func GetRedisKeyShare(uid int) string {
func GetRedisKeyWeekCard(uid int) string { func GetRedisKeyWeekCard(uid int) string {
return fmt.Sprintf("%v:%v", RedisKeyWeekCard, uid) return fmt.Sprintf("%v:%v", RedisKeyWeekCard, uid)
} }
func GetRedisKeyUserPay(payChannelId, uid, amount int) string {
return fmt.Sprintf("%v:%d:%d:%v", RedisKeyUserPay, payChannelId, amount, uid)
}

@ -295,7 +295,7 @@ func (a *agent) ReadLoop() {
// 第一步拿到数据包长度 // 第一步拿到数据包长度
length, err := a.readInt(2) length, err := a.readInt(2)
if err != nil { if err != nil {
// log.Error("err:%v", err) // log.Error("read int err:%v", err)
return return
} }
if length > a.gate.Options().BufSize { if length > a.gate.Options().BufSize {
@ -331,7 +331,7 @@ func (a *agent) ReadLoop() {
// 第四步拿到uid // 第四步拿到uid
_, err = a.readInt(4) _, err = a.readInt(4)
if err != nil { if err != nil {
// log.Error("err:%v", err) // log.Error("get uid err:%v", err)
return return
} }
// log.Debug("uid:%v", uid) // log.Debug("uid:%v", uid)

@ -28,17 +28,34 @@ func Recharge(req *pb.InnerRechargeReq) (ret []byte, err error) {
// } else { // } else {
// payWay = values.ChoosePayWay(int(req.UID), int(req.Channel), req.Amount) // payWay = values.ChoosePayWay(int(req.UID), int(req.Channel), req.Amount)
// } // }
var isReplace bool
if req.Channel == 0 { if req.Channel == 0 {
var weightChannel uint32
for _, v := range call.GetConfigPayChannels() { for _, v := range call.GetConfigPayChannels() {
if req.Amount*common.DecimalDigits <= v.PayUp && req.Amount*common.DecimalDigits >= v.PayDown && v.CurrencyType == common.CurrencyINR { if req.Amount*common.DecimalDigits <= v.PayUp && req.Amount*common.DecimalDigits >= v.PayDown && v.CurrencyType == common.CurrencyINR {
req.Channel = uint32(v.ChannelID) weightChannel = uint32(v.ChannelID)
break break
} }
} }
for _, v := range call.GetConfigPayChannels() {
if req.Amount*common.DecimalDigits <= v.PayUp && req.Amount*common.DecimalDigits >= v.PayDown && v.CurrencyType == common.CurrencyINR {
if !db.Redis().Lock(common.GetRedisKeyUserPay(v.ChannelID, int(req.UID), int(req.Amount)), 2*time.Minute) {
continue
}
if weightChannel != uint32(v.ChannelID) {
log.Debug("recharge, replace pay channel, %v:%v", req.UID, v.ChannelID)
isReplace = true
}
weightChannel = uint32(v.ChannelID)
break
}
}
req.Channel = weightChannel
} }
if req.Channel == 0 { if req.Channel == 0 {
log.Error("get channel err, is 0") log.Error("get channel err, is 0")
} }
payWay = values.PayWay(req.Channel)
base := base.NewRechargeBase(req) base := base.NewRechargeBase(req)
allpay.NewSub(base, int(req.Channel)) allpay.NewSub(base, int(req.Channel))
start := time.Now() start := time.Now()
@ -57,6 +74,8 @@ func Recharge(req *pb.InnerRechargeReq) (ret []byte, err error) {
} }
if err != nil { if err != nil {
values.PayFail(payWay) values.PayFail(payWay)
} else if isReplace {
values.PaySuccess(payWay)
} }
return return
} }

@ -545,7 +545,9 @@ func AddWithdrawChannel(p int, amount int) {
func AddPayChannel(p int, amount int) { func AddPayChannel(p int, amount int) {
log.Debug("update pay per, %d:%d", p, amount) log.Debug("update pay per, %d:%d", p, amount)
if err := db.Mysql().C().Model(&common.ConfigPayChannels{}).Where("channel_id = ? and pay_per > 0 ", p). if err := db.Mysql().C().Model(&common.ConfigPayChannels{}).Where("channel_id = ? and pay_per > 0 ", p).
Updates(map[string]interface{}{"pay_per": gorm.Expr("pay_per + ?", amount)}).Error; err != nil { Updates(map[string]interface{}{
"pay_per": gorm.Expr("CASE WHEN pay_per + ? < 1 THEN 1 ELSE pay_per + ? END", amount, amount),
}).Error; err != nil {
log.Error("err:%v", err) log.Error("err:%v", err)
} }
} }

Loading…
Cancel
Save