diff --git a/modules/pay/mlpay/base.go b/modules/pay/mlpay/base.go index 3a426c5..11ddd34 100644 --- a/modules/pay/mlpay/base.go +++ b/modules/pay/mlpay/base.go @@ -72,14 +72,14 @@ func (s *Sub) GetResp() (proto.Message, error) { log.Debug("resp:%v", s.Base.Resp) if s.Base.Opt == base.OPTPay { resp := s.Base.Resp.(*PayResp) - if resp.Data == "" { - return nil, errors.New("pay fail") + if resp.Code != "0000" { + return nil, errors.New("pay fail " + resp.Msg) } return &pb.InnerRechargeResp{APIOrderID: s.Base.PayReq.OrderID, URL: resp.Data, Channel: uint32(values.MLPay)}, nil } else if s.Base.Opt == base.OPTWithdraw { resp := s.Base.Resp.(*WithdrawResp) - if s.Base.Status == 0 && resp.Code == "0000" { - return nil, errors.New("withdraw fail") + if resp.Code != "0000" { + return nil, errors.New("withdraw fail " + resp.Msg) } return &pb.InnerWithdrawResp{APIOrderID: resp.Data, Channel: uint32(values.MLPay)}, nil } @@ -152,17 +152,11 @@ func (s *Sub) CheckSign(str string) bool { req := s.Base.CallbackReq.(*PayCallbackReq) s.Base.CallbackResp.OrderID = req.PartnerOrderNo s.Base.CallbackResp.APIOrderID = req.OrderNo - // if req.Status == 1 { - // return false - // } s.Base.CallbackResp.Success = req.Status == 1 sign = req.Sign } else if s.Base.Opt == base.OPTWithdrawCB { req := s.Base.CallbackReq.(*WithdrawCallbackReq) s.Base.CallbackResp.OrderID = req.PartnerWithdrawNo - // if req.Status == 1 { - // return false - // } s.Base.CallbackResp.Success = req.Status == 1 sign = req.Sign } diff --git a/modules/pay/values/values.go b/modules/pay/values/values.go index b0eda17..efae297 100644 --- a/modules/pay/values/values.go +++ b/modules/pay/values/values.go @@ -449,8 +449,14 @@ func AddWithdrawChannel(p int, amount int) { } func AddPayChannel(p int, amount int) { - if err := db.Mysql().C().Model(&common.ConfigPayChannels{}).Where("channel_id = ?", p).Updates(map[string]interface{}{"pay_per": gorm.Expr("pay_per + ?", amount)}).Error; err != nil { - log.Error("err:%v", err) + channel := &common.ConfigPayChannels{ + ChannelID: p, + } + db.Mysql().Get(&channel) + if channel.PayPer+amount > 100 { + if err := db.Mysql().C().Model(&common.ConfigPayChannels{}).Where("channel_id = ?", p).Updates(map[string]interface{}{"pay_per": gorm.Expr("pay_per + ?", amount)}).Error; err != nil { + log.Error("err:%v", err) + } } } diff --git a/modules/web/handler/recharge.go b/modules/web/handler/recharge.go index 481cdc9..9236950 100644 --- a/modules/web/handler/recharge.go +++ b/modules/web/handler/recharge.go @@ -207,6 +207,7 @@ func PlayerRecharge(c *gin.Context) { payImp := NewRechargeImp(req, a.UID, a.Channel, a.GetRemoteIP()) if payImp == nil { a.Code = values.CodeRetry + a.Msg = "channel unavailable" log.Error("req params err:%v", req) return }