<feat>报错内容错误

This commit is contained in:
Rzy 2024-08-12 09:18:06 +08:00
parent c15044b862
commit 848ebcc443
2 changed files with 10 additions and 7 deletions

View File

@ -44,9 +44,9 @@ func Refund(c *gin.Context) {
c.Set("OutTradeNo", req.OutTradeNo) c.Set("OutTradeNo", req.OutTradeNo)
appCheckInfo := controllers.GetAppCheckInfo(c).(*services.AppCheck) appCheckInfo := controllers.GetAppCheckInfo(c).(*services.AppCheck)
refund := thirdpay.ThirdPayRefund(c.Request.Context(), req, appCheckInfo, c.ClientIP()) refund, errCode := thirdpay.ThirdPayRefund(c.Request.Context(), req, appCheckInfo, c.ClientIP())
if refund.PayCode != errorcode.Success { if errCode != errorcode.Success {
controllers.ApiRes(c, nil, refund.PayCode) controllers.ApiRes(c, nil, errCode)
return return
} }
data := thirdpay.NewOrdersResp(refund.Order) data := thirdpay.NewOrdersResp(refund.Order)

View File

@ -46,23 +46,26 @@ func ThirdPayInfoCheck(ctx context.Context, payReq *front.PayReqs, appCheck *ser
return return
} }
func ThirdPayRefund(ctx context.Context, refundReq *front.RefundReqs, appCheck *services.AppCheck, ip string) (refund *thirdpay.Pay) { func ThirdPayRefund(ctx context.Context, refundReq *front.RefundReqs, appCheck *services.AppCheck, ip string) (refund *thirdpay.Pay, errorCode int) {
var req types.Reqs var req types.Reqs
copier.Copy(&req, refundReq) copier.Copy(&req, refundReq)
check := thirdpay.NewPayCheck(&ctx, &req, appCheck, ip) check := thirdpay.NewPayCheck(&ctx, &req, appCheck, ip)
// 校验表单 // 校验表单
check.CheckPayInfo() check.CheckPayInfo()
if check.CheckCode != errorcode.Success { if check.CheckCode != errorcode.Success {
return return nil, check.CheckCode
} }
check.CheckOrderRefund() check.CheckOrderRefund()
if check.CheckCode != errorcode.Success { if check.CheckCode != errorcode.Success {
return return nil, check.CheckCode
} }
refund = thirdpay.NewPayWithPayCheck(check) refund = thirdpay.NewPayWithPayCheck(check)
refund.CreateOrder(common.ORDER_TYPE_REFUND) refund.CreateOrder(common.ORDER_TYPE_REFUND)
if refund.PayCode != errorcode.Success {
return refund, refund.PayCode
}
refund.Refund() refund.Refund()
return return refund, errorcode.Success
} }
func ThirdPay(check *thirdpay.PayCheck) (pay *thirdpay.Pay) { func ThirdPay(check *thirdpay.PayCheck) (pay *thirdpay.Pay) {