<feat>调整结构,可以返回第三方消息
This commit is contained in:
parent
e2378b0a39
commit
8549c0fbbd
|
@ -44,11 +44,16 @@ 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, 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 {
|
if errCode != errorcode.Success {
|
||||||
controllers.ApiRes(c, nil, errCode)
|
controllers.ApiRes(c, nil, errCode)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
refund, errCode := thirdpay.ThirdPayRefund(check)
|
||||||
|
if errCode != errorcode.Success {
|
||||||
|
controllers.ApiRes(c, nil, errCode, refund.ThirdMsg)
|
||||||
|
return
|
||||||
|
}
|
||||||
data := thirdpay.NewOrdersResp(refund.Order)
|
data := thirdpay.NewOrdersResp(refund.Order)
|
||||||
var res front.ApiResponse
|
var res front.ApiResponse
|
||||||
res.Order = data
|
res.Order = data
|
||||||
|
|
|
@ -46,21 +46,28 @@ 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, errorCode int) {
|
func ThirdPayRefundCheck(ctx context.Context, refundReq *front.RefundReqs, appCheck *services.AppCheck, ip string) (check *thirdpay.PayCheck, 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 {
|
return check, check.CheckCode
|
||||||
return nil, 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 {
|
refund.Refund()
|
||||||
return nil, check.CheckCode
|
return refund, refund.PayCode
|
||||||
}
|
|
||||||
refund, errorCode = ThirdRefund(check)
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func ThirdPay(check *thirdpay.PayCheck) (pay *thirdpay.Pay) {
|
func ThirdPay(check *thirdpay.PayCheck) (pay *thirdpay.Pay) {
|
||||||
|
@ -76,16 +83,3 @@ func ThirdPay(check *thirdpay.PayCheck) (pay *thirdpay.Pay) {
|
||||||
}
|
}
|
||||||
return
|
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