处理mlpay逻辑问题

fix/release
mofangmin 1 year ago
parent cce1c2842c
commit 48f6ec0063
  1. 43
      call/pay.go
  2. 2
      modules/pay/base/callback.go
  3. 22
      modules/pay/mlpay/base.go
  4. 1
      modules/pay/routers/routers.go
  5. 10
      modules/pay/values/values.go
  6. 2
      modules/web/handler/share.go

@ -396,11 +396,17 @@ func ReturnBackWithdraw(or *common.WithdrawOrder, originStatus, status uint8, pa
order := &common.WithdrawOrder{}
order.ID = or.ID
tx := db.Mysql().Begin()
// 打款失败的单,重新挂起到后台进入人工审核,不再返还金币给玩家
u := map[string]interface{}{
"status": status,
"fail_reason": or.FailReason,
"callback_time": time.Now().Unix(),
}
if len(or.Operator) == 0 {
status = common.StatusROrderCreate
delete(u, "callback_time")
}
if len(payChannel) > 0 {
u["pay_channel"] = payChannel[0]
}
@ -423,10 +429,13 @@ func ReturnBackWithdraw(or *common.WithdrawOrder, originStatus, status uint8, pa
uid := or.UID
re := new(common.RechargeInfo)
re.UID = uid
updateRe := map[string]interface{}{
"withdrawing_cash": gorm.Expr("withdrawing_cash - ?", or.WithdrawCash),
"total_withdrawing": gorm.Expr("total_withdrawing - ?", or.Amount),
"day_withdraw": gorm.Expr("day_withdraw - ?", or.Amount),
updateRe := map[string]interface{}{}
if status != common.StatusROrderCreate {
updateRe = map[string]interface{}{
"withdrawing_cash": gorm.Expr("withdrawing_cash - ?", or.WithdrawCash),
"total_withdrawing": gorm.Expr("total_withdrawing - ?", or.Amount),
"day_withdraw": gorm.Expr("day_withdraw - ?", or.Amount),
}
}
if status == common.StatusROrderFail || status == common.StatusROrderRefuse {
updateRe["withdraw_count"] = gorm.Expr("withdraw_count + ?", -1)
@ -438,18 +447,20 @@ func ReturnBackWithdraw(or *common.WithdrawOrder, originStatus, status uint8, pa
tx.Rollback()
return err
}
if err := UpdateCurrency(&common.UpdateCurrency{
CurrencyBalance: &common.CurrencyBalance{
UID: or.UID,
Type: or.CurrencyType,
Value: or.WithdrawCash,
Event: common.CurrencyEventWithDrawBack,
Exs1: or.OrderID,
},
}, tx); err != nil {
log.Error("Withdraw callback err:%v", err)
tx.Rollback()
return err
if status != common.StatusROrderCreate {
if err := UpdateCurrency(&common.UpdateCurrency{
CurrencyBalance: &common.CurrencyBalance{
UID: or.UID,
Type: or.CurrencyType,
Value: or.WithdrawCash,
Event: common.CurrencyEventWithDrawBack,
Exs1: or.OrderID,
},
}, tx); err != nil {
log.Error("Withdraw callback err:%v", err)
tx.Rollback()
return err
}
}
// 退还代付券
// if or.Extra == "useFreeWithdraw" {

@ -16,10 +16,10 @@ import (
)
func (b *Base) PayCallback(c *gin.Context) {
str, err := b.Callback(c)
defer func() {
c.String(http.StatusOK, b.CallbackResp.Msg)
}()
str, err := b.Callback(c)
if err != nil {
log.Error("err:%v", err)
b.CallbackResp.Msg = "callback fail"

@ -32,12 +32,12 @@ func NewSub(b *base.Base) {
b.Resp = new(WithdrawResp)
b.ReqURL = baseUrl + withdrawURL
} else if b.Opt == base.OPTPayCB {
b.HttpType = base.HttpTypeForm
b.HttpType = base.HttpTypeGet
b.CallbackReq = new(PayCallbackReq)
b.CallbackResp.Msg = "0"
} else if b.Opt == base.OPTWithdrawCB {
b.SignKey = withdrawKey
b.HttpType = base.HttpTypeForm
b.HttpType = base.HttpTypeGet
b.CallbackReq = new(WithdrawCallbackReq)
b.CallbackResp.Msg = "0"
// } else if b.Opt == base.OPTQueryWithdraw { // 查询
@ -147,20 +147,26 @@ func (s *Sub) PackWithdrawReq() interface{} {
func (s *Sub) CheckSign(str string) bool {
log.Debug("callback:%v", s.Base.CallbackReq)
sign := ""
checkSign := ""
sign := str
if s.Base.Opt == base.OPTPayCB {
req := s.Base.CallbackReq.(*PayCallbackReq)
s.Base.CallbackResp.OrderID = req.PartnerOrderNo
s.Base.CallbackResp.APIOrderID = req.OrderNo
s.Base.CallbackResp.Success = req.Status == 1
sign = req.Sign
checkSign = req.Sign
} else if s.Base.Opt == base.OPTWithdrawCB {
req := s.Base.CallbackReq.(*WithdrawCallbackReq)
s.Base.CallbackResp.OrderID = req.PartnerWithdrawNo
s.Base.CallbackResp.Success = req.Status == 1
sign = req.Sign
}
signStr := base.GetSignStrFormURLEncode(s.Base.C, s.Base.CallbackReq, "sign")
signStr2 := base.GetSignStrURLEncode(signStr, "sign") + "&key=" + s.Base.SignKey
return strings.ToUpper(util.CalculateMD5(signStr2)) == sign
if s.Base.KeyName == "" {
sign += "&key=" + s.Base.SignKey
} else {
sign += "&" + s.Base.KeyName + "=" + s.Base.SignKey
}
ret := util.CalculateMD5(sign)
ret = strings.ToUpper(ret)
log.Info("SignStr:%v,SignMD5:%v", sign, ret)
return checkSign == ret
}

@ -58,6 +58,7 @@ func PayCallback(c *gin.Context) {
b := base.NewCallbackBase(3)
allpay.NewSub(b, index)
if b.Sub == nil {
log.Error("err:%v", err)
return
}
b.PayCallback(c)

@ -443,8 +443,14 @@ func Post(req *http.Request, ret interface{}) int {
}
func AddWithdrawChannel(p int, amount int) {
if err := db.Mysql().C().Model(&common.ConfigWithdrawChannels{}).Where("channel_id = ?", p).Updates(map[string]interface{}{"withdraw_per": gorm.Expr("withdraw_per + ?", amount)}).Error; err != nil {
log.Error("err:%v", err)
channel := &common.ConfigWithdrawChannels{
ChannelID: p,
}
db.Mysql().Get(&channel)
if channel.WithdrawPer+amount > 100 {
if err := db.Mysql().C().Model(&common.ConfigWithdrawChannels{}).Where("channel_id = ?", p).Updates(map[string]interface{}{"withdraw_per": gorm.Expr("withdraw_per + ?", amount)}).Error; err != nil {
log.Error("err:%v", err)
}
}
}

@ -267,7 +267,7 @@ func ShareWithdraw(c *gin.Context) {
}
}
orderID := util.NewOrderID(int(a.UID))
orderID := util.NewOrderID(a.UID)
vipCon := call.GetVipCon(a.UID)
realAmount := req.Amount // 实际打款

Loading…
Cancel
Save