fix(thirdpay): 修复邮储银行退款状态处理逻辑及相关细节
1. 调整退款订单状态更新逻辑,根据渠道和退款结果正确设置订单状态 2. 优化邮储退款接口的退款状态判断条件 3. 补充退款成功时间的格式化输出 4. 修复退款请求参数中退款描述的硬编码问题 5. 添加邮储退款解密响应的日志打印
This commit is contained in:
parent
53c1e3e00b
commit
b15442f99d
|
|
@ -253,7 +253,20 @@ func (w *Pay) Refund() {
|
|||
}
|
||||
res := paymentService.OrderRefund(*w.ctx, *thirdPayRefund)
|
||||
if res.Code == payCommon.PAY_SUCCESS_CODE {
|
||||
if w.PayParam.Channel.ChannelType == common.PAY_CHANNEL_PSBC {
|
||||
if res.Result.RefundStatus == payCommon.PAY_REFUND_STATU_SUCCESS {
|
||||
// 退款成功
|
||||
w.Order.Status = common.ORDER_STATUS_PAYED
|
||||
} else if res.Result.RefundStatus == payCommon.PAY_REFUND_STATU_ING {
|
||||
//
|
||||
w.Order.Status = common.ORDER_STATUS_PAYING
|
||||
} else {
|
||||
w.Order.Status = common.ORDER_STATUS_FAILED
|
||||
}
|
||||
} else {
|
||||
w.Order.Status = common.ORDER_STATUS_PAYING
|
||||
}
|
||||
|
||||
code := services.OrderUpdate(w.Order, "status")
|
||||
if code != errorcode.Success {
|
||||
w.PayCode = code
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package payment
|
||||
|
||||
import (
|
||||
"PaymentCenter/app/utils"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"time"
|
||||
|
|
@ -33,13 +34,13 @@ func (c *Client) Refund(req RefundRequest) (*RefundResponse, error) {
|
|||
"data": map[string]string{
|
||||
"txnCode": "1003",
|
||||
"sourceId": "16",
|
||||
"reqTraceId": req.OrderNo + now[4:14], // MMDDHHmmss 10位后缀
|
||||
"reqTraceId": req.OrderNo + "0010",
|
||||
"reqDate": now, // 14 位 YYYYMMDDHHmmss
|
||||
"mchtNo": c.cfg.MchtNo,
|
||||
"orgTxnSeq": req.OrgTxnSeq,
|
||||
"txnAmt": req.Price,
|
||||
"orgTxnAmt": req.Price,
|
||||
"refundDesc": "用户主动退款",
|
||||
"refundDesc": req.RefundDesc,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
@ -60,6 +61,7 @@ func (c *Client) Refund(req RefundRequest) (*RefundResponse, error) {
|
|||
}
|
||||
|
||||
responseData, err := c.DecryptResponse(string(body), false)
|
||||
utils.Log(nil, "邮储退款解密响应", responseData)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("解密响应失败: %v,原始响应: %s", err, string(body))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import (
|
|||
"fmt"
|
||||
"github.com/qit-team/snow-core/log/logger"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
type PsbcPay struct {
|
||||
|
|
@ -156,10 +157,9 @@ func PsbcRefundOrder(ctx context.Context, orderRefundRequest OrderRefundRequest)
|
|||
}
|
||||
|
||||
refundStatus := payCommon.PAY_REFUND_STATU_COMMON
|
||||
switch resp.RefundOrderSta {
|
||||
case "03":
|
||||
if resp.RespCode == "000000" && resp.RefundOrderSta == "03" {
|
||||
refundStatus = payCommon.PAY_REFUND_STATU_SUCCESS
|
||||
default:
|
||||
} else {
|
||||
refundStatus = payCommon.PAY_REFUND_STATU_FAIL
|
||||
}
|
||||
|
||||
|
|
@ -177,7 +177,7 @@ func PsbcRefundOrder(ctx context.Context, orderRefundRequest OrderRefundRequest)
|
|||
RefundFee: refundFee,
|
||||
RefundOrderId: orderRefundRequest.RefundOrderId,
|
||||
RefundStatus: refundStatus,
|
||||
RefundSuccessTime: "",
|
||||
RefundSuccessTime: time.Now().Format(time.DateTime),
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue