fix refurn

This commit is contained in:
liangzai 2025-06-19 02:58:09 +08:00
parent f8155eb92f
commit e981a1e069

View File

@ -189,19 +189,39 @@ func (l *WechatPayRefundCallbackLogic) WechatPayRefundCallback(w http.ResponseWr
l.sendSuccessResponse(w) l.sendSuccessResponse(w)
return nil return nil
} }
if notification.Status == nil {
logx.Errorf("【退款回调】Status字段为空") orderNo := *notification.OutTradeNo
logx.Infof("【退款回调】提取到订单号: %s", orderNo)
// 3. 判断退款状态优先使用Status如果Status为nil则使用SuccessTime判断
var status refunddomestic.Status
var statusDetermined bool = false
if notification.Status != nil {
status = *notification.Status
statusDetermined = true
logx.Infof("【退款回调】从Status字段获取状态: %v", status)
} else if notification.SuccessTime != nil && !notification.SuccessTime.IsZero() {
// 如果Status为空但SuccessTime有值说明退款成功
status = refunddomestic.STATUS_SUCCESS
statusDetermined = true
logx.Infof("【退款回调】Status为空但SuccessTime有值(%v),判断为退款成功", notification.SuccessTime)
} else {
logx.Errorf("【退款回调】Status和SuccessTime都为空无法确定退款状态")
l.sendSuccessResponse(w) l.sendSuccessResponse(w)
return nil return nil
} }
orderNo := *notification.OutTradeNo if !statusDetermined {
status := *notification.Status logx.Errorf("【退款回调】无法确定退款状态")
logx.Infof("【退款回调】提取到订单号: %s, 状态: %v", orderNo, status) l.sendSuccessResponse(w)
return nil
}
logx.Infof("【退款回调】最终确定状态: %v", status)
var processErr error var processErr error
// 3. 根据订单号前缀处理不同类型的订单 // 4. 根据订单号前缀处理不同类型的订单
logx.Infof("【退款回调】开始根据订单号前缀分发处理") logx.Infof("【退款回调】开始根据订单号前缀分发处理")
switch { switch {
case strings.HasPrefix(orderNo, "Q_"): case strings.HasPrefix(orderNo, "Q_"):
@ -216,7 +236,7 @@ func (l *WechatPayRefundCallbackLogic) WechatPayRefundCallback(w http.ResponseWr
processErr = l.handleQueryOrderRefund(orderNo, status) processErr = l.handleQueryOrderRefund(orderNo, status)
} }
// 4. 处理错误并响应 // 5. 处理错误并响应
if processErr != nil { if processErr != nil {
logx.Errorf("【退款回调】处理退款订单失败: orderNo=%s, err=%v", orderNo, processErr) logx.Errorf("【退款回调】处理退款订单失败: orderNo=%s, err=%v", orderNo, processErr)
} else { } else {