<feat>调整结构,可以返回第三方消息
This commit is contained in:
parent
e2378b0a39
commit
8549c0fbbd
|
@ -44,11 +44,16 @@ func Refund(c *gin.Context) {
|
|||
c.Set("OutTradeNo", req.OutTradeNo)
|
||||
|
||||
appCheckInfo := controllers.GetAppCheckInfo(c).(*services.AppCheck)
|
||||
refund, errCode := thirdpay.ThirdPayRefund(c.Request.Context(), req, appCheckInfo, c.ClientIP())
|
||||
check, errCode := thirdpay.ThirdPayRefundCheck(c.Request.Context(), req, appCheckInfo, c.ClientIP())
|
||||
if errCode != errorcode.Success {
|
||||
controllers.ApiRes(c, nil, errCode)
|
||||
return
|
||||
}
|
||||
refund, errCode := thirdpay.ThirdPayRefund(check)
|
||||
if errCode != errorcode.Success {
|
||||
controllers.ApiRes(c, nil, errCode, refund.ThirdMsg)
|
||||
return
|
||||
}
|
||||
data := thirdpay.NewOrdersResp(refund.Order)
|
||||
var res front.ApiResponse
|
||||
res.Order = data
|
||||
|
|
|
@ -46,21 +46,28 @@ func ThirdPayInfoCheck(ctx context.Context, payReq *front.PayReqs, appCheck *ser
|
|||
return
|
||||
}
|
||||
|
||||
func ThirdPayRefund(ctx context.Context, refundReq *front.RefundReqs, appCheck *services.AppCheck, ip string) (refund *thirdpay.Pay, errorCode int) {
|
||||
func ThirdPayRefundCheck(ctx context.Context, refundReq *front.RefundReqs, appCheck *services.AppCheck, ip string) (check *thirdpay.PayCheck, errorCode int) {
|
||||
var req types.Reqs
|
||||
copier.Copy(&req, refundReq)
|
||||
check := thirdpay.NewPayCheck(&ctx, &req, appCheck, ip)
|
||||
check = thirdpay.NewPayCheck(&ctx, &req, appCheck, ip)
|
||||
// 校验表单
|
||||
check.CheckPayInfo()
|
||||
if check.CheckCode != errorcode.Success {
|
||||
return nil, check.CheckCode
|
||||
return check, check.CheckCode
|
||||
}
|
||||
|
||||
func ThirdPayRefund(check *thirdpay.PayCheck) (refund *thirdpay.Pay, errorCode int) {
|
||||
|
||||
refund = thirdpay.NewPayWithPayCheck(check)
|
||||
if refund.CheckRefundOrder() {
|
||||
refund.CreateOrder(common.ORDER_TYPE_REFUND)
|
||||
if refund.PayCode != errorcode.Success {
|
||||
return refund, refund.PayCode
|
||||
}
|
||||
}
|
||||
check.CheckOrderRefund()
|
||||
if check.CheckCode != errorcode.Success {
|
||||
return nil, check.CheckCode
|
||||
}
|
||||
refund, errorCode = ThirdRefund(check)
|
||||
return
|
||||
|
||||
refund.Refund()
|
||||
return refund, refund.PayCode
|
||||
|
||||
}
|
||||
|
||||
func ThirdPay(check *thirdpay.PayCheck) (pay *thirdpay.Pay) {
|
||||
|
@ -76,16 +83,3 @@ func ThirdPay(check *thirdpay.PayCheck) (pay *thirdpay.Pay) {
|
|||
}
|
||||
return
|
||||
}
|
||||
|
||||
func ThirdRefund(check *thirdpay.PayCheck) (refund *thirdpay.Pay, errCode int) {
|
||||
refund = thirdpay.NewPayWithPayCheck(check)
|
||||
if refund.CheckRefundOrder() {
|
||||
refund.CreateOrder(common.ORDER_TYPE_REFUND)
|
||||
if refund.PayCode != errorcode.Success {
|
||||
return refund, refund.PayCode
|
||||
}
|
||||
}
|
||||
|
||||
refund.Refund()
|
||||
return refund, refund.PayCode
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue