处理mlpay逻辑问题

fix/release
mofangmin 1 year ago
parent cce1c2842c
commit 48f6ec0063
  1. 13
      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. 6
      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 := &common.WithdrawOrder{}
order.ID = or.ID order.ID = or.ID
tx := db.Mysql().Begin() tx := db.Mysql().Begin()
// 打款失败的单,重新挂起到后台进入人工审核,不再返还金币给玩家
u := map[string]interface{}{ u := map[string]interface{}{
"status": status, "status": status,
"fail_reason": or.FailReason, "fail_reason": or.FailReason,
"callback_time": time.Now().Unix(), "callback_time": time.Now().Unix(),
} }
if len(or.Operator) == 0 {
status = common.StatusROrderCreate
delete(u, "callback_time")
}
if len(payChannel) > 0 { if len(payChannel) > 0 {
u["pay_channel"] = payChannel[0] u["pay_channel"] = payChannel[0]
} }
@ -423,11 +429,14 @@ func ReturnBackWithdraw(or *common.WithdrawOrder, originStatus, status uint8, pa
uid := or.UID uid := or.UID
re := new(common.RechargeInfo) re := new(common.RechargeInfo)
re.UID = uid re.UID = uid
updateRe := map[string]interface{}{ updateRe := map[string]interface{}{}
if status != common.StatusROrderCreate {
updateRe = map[string]interface{}{
"withdrawing_cash": gorm.Expr("withdrawing_cash - ?", or.WithdrawCash), "withdrawing_cash": gorm.Expr("withdrawing_cash - ?", or.WithdrawCash),
"total_withdrawing": gorm.Expr("total_withdrawing - ?", or.Amount), "total_withdrawing": gorm.Expr("total_withdrawing - ?", or.Amount),
"day_withdraw": gorm.Expr("day_withdraw - ?", or.Amount), "day_withdraw": gorm.Expr("day_withdraw - ?", or.Amount),
} }
}
if status == common.StatusROrderFail || status == common.StatusROrderRefuse { if status == common.StatusROrderFail || status == common.StatusROrderRefuse {
updateRe["withdraw_count"] = gorm.Expr("withdraw_count + ?", -1) updateRe["withdraw_count"] = gorm.Expr("withdraw_count + ?", -1)
} }
@ -438,6 +447,7 @@ func ReturnBackWithdraw(or *common.WithdrawOrder, originStatus, status uint8, pa
tx.Rollback() tx.Rollback()
return err return err
} }
if status != common.StatusROrderCreate {
if err := UpdateCurrency(&common.UpdateCurrency{ if err := UpdateCurrency(&common.UpdateCurrency{
CurrencyBalance: &common.CurrencyBalance{ CurrencyBalance: &common.CurrencyBalance{
UID: or.UID, UID: or.UID,
@ -451,6 +461,7 @@ func ReturnBackWithdraw(or *common.WithdrawOrder, originStatus, status uint8, pa
tx.Rollback() tx.Rollback()
return err return err
} }
}
// 退还代付券 // 退还代付券
// if or.Extra == "useFreeWithdraw" { // if or.Extra == "useFreeWithdraw" {
// if err := tx.Model(&common.PlayerItems{UID: uid}).Updates(map[string]interface{}{"free_withdraw": gorm.Expr("free_withdraw + 1")}).Error; err != nil { // if err := tx.Model(&common.PlayerItems{UID: uid}).Updates(map[string]interface{}{"free_withdraw": gorm.Expr("free_withdraw + 1")}).Error; err != nil {

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

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

@ -443,9 +443,15 @@ func Post(req *http.Request, ret interface{}) int {
} }
func AddWithdrawChannel(p int, amount int) { func AddWithdrawChannel(p int, amount int) {
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 { 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) log.Error("err:%v", err)
} }
}
} }
func AddPayChannel(p int, amount int) { func AddPayChannel(p int, amount int) {

@ -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) vipCon := call.GetVipCon(a.UID)
realAmount := req.Amount // 实际打款 realAmount := req.Amount // 实际打款

Loading…
Cancel
Save