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