diff --git a/app/constants/errorcode/error_code.go b/app/constants/errorcode/error_code.go index 2f7170e..39aaee3 100644 --- a/app/constants/errorcode/error_code.go +++ b/app/constants/errorcode/error_code.go @@ -87,6 +87,9 @@ const ( PreRefundFail = 1702 ThirdRefundFail = 1710 + + // 退款 + RefundOutTradeNoSame = 1801 ) var MsgEN = map[int]string{ @@ -160,6 +163,7 @@ var MsgZH = map[int]string{ PreRefundFail: "创建退款单失败", OrderNotSupportRefundPart: "订单暂不支持部分退款", OrderRefundAmountError: "退款金额错误", + RefundOutTradeNoSame: "支付商户单号和退款商户单号不能相同", ThirdRefundFail: "第三方退款失败", } diff --git a/app/services/thirdpay/do/pay.go b/app/services/thirdpay/do/pay.go index 308112e..f2a32ed 100644 --- a/app/services/thirdpay/do/pay.go +++ b/app/services/thirdpay/do/pay.go @@ -55,7 +55,7 @@ func NewPayWithPayCheck(paycheck *PayCheck) *Pay { func (w *Pay) CheckRefundOrder() bool { cond := builder.NewCond() - cond = cond.And(builder.Eq{"app_id": w.PayParam.App_id}, builder.Eq{"out_trade_no": w.PayParam.OutTradeNo}) + cond = cond.And(builder.Eq{"app_id": w.PayParam.App_id}, builder.Eq{"order_type": common.ORDER_TYPE_REFUND}, builder.Eq{"out_trade_no": w.PayParam.OutTradeNo}) order, code := services.OrderFindOne(&ordersmodel.Orders{}, cond) if code != errorcode.Success { return true diff --git a/app/services/thirdpay/do/pay_check.go b/app/services/thirdpay/do/pay_check.go index 6f5142e..22ab448 100644 --- a/app/services/thirdpay/do/pay_check.go +++ b/app/services/thirdpay/do/pay_check.go @@ -80,6 +80,7 @@ func (w *PayCheck) CheckOrderPay() { } func (w *PayCheck) CheckOrderRefund() (order *ordersmodel.Orders) { + // 查询原来的支付单 w.GetOldOrder(&types.OrderFindOne{ OutTradeNo: w.Reqs.RefundOutTradeNo, OrderId: w.Reqs.RefundOrderId, diff --git a/app/services/thirdpay/pay.go b/app/services/thirdpay/pay.go index 0d95185..24ba937 100644 --- a/app/services/thirdpay/pay.go +++ b/app/services/thirdpay/pay.go @@ -48,6 +48,10 @@ func ThirdPayInfoCheck(ctx context.Context, payReq *front.PayReqs, appCheck *ser func ThirdPayRefundCheck(ctx context.Context, refundReq *front.RefundReqs, appCheck *services.AppCheck, ip string) (check *thirdpay.PayCheck, errorCode int) { var req types.Reqs + // 外部商户单号,支付商户单号和退款商户单号不能相同 + if refundReq.OutTradeNo == refundReq.RefundOutTradeNo { + return check, errorcode.RefundOutTradeNoSame + } copier.Copy(&req, refundReq) check = thirdpay.NewPayCheck(&ctx, &req, appCheck, ip) // 校验表单