temp
This commit is contained in:
@@ -5,7 +5,6 @@ import (
|
||||
"net/http"
|
||||
"tyc-server/app/main/api/internal/svc"
|
||||
|
||||
"github.com/wechatpay-apiv3/wechatpay-go/services/refunddomestic"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
@@ -24,32 +23,36 @@ func NewWechatPayRefundCallbackLogic(ctx context.Context, svcCtx *svc.ServiceCon
|
||||
}
|
||||
|
||||
func (l *WechatPayRefundCallbackLogic) WechatPayRefundCallback(w http.ResponseWriter, r *http.Request) error {
|
||||
notification, err := l.svcCtx.WechatPayService.HandleRefundNotification(l.ctx, r)
|
||||
if err != nil {
|
||||
logx.Errorf("微信退款回调,%+v", err)
|
||||
return nil
|
||||
}
|
||||
order, findOrderErr := l.svcCtx.OrderModel.FindOneByOrderNo(l.ctx, *notification.OutTradeNo)
|
||||
if findOrderErr != nil {
|
||||
logx.Errorf("微信退款回调,查找订单信息失败: %+v", findOrderErr)
|
||||
return nil
|
||||
}
|
||||
// notification, err := l.svcCtx.PayService.re(l.ctx, r)
|
||||
// if err != nil {
|
||||
// logx.Errorf("微信退款回调,%+v", err)
|
||||
// return nil
|
||||
// }
|
||||
// order, findOrderErr := l.svcCtx.OrderModel.FindOneByOrderNo(l.ctx, *notification.OutTradeNo)
|
||||
// if findOrderErr != nil {
|
||||
// logx.Errorf("微信退款回调,查找订单信息失败: %+v", findOrderErr)
|
||||
// return nil
|
||||
// }
|
||||
|
||||
switch *notification.Status {
|
||||
case refunddomestic.STATUS_SUCCESS:
|
||||
order.Status = "refunded"
|
||||
case refunddomestic.STATUS_ABNORMAL:
|
||||
// 异常
|
||||
return nil
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
if updateErr := l.svcCtx.OrderModel.UpdateWithVersion(l.ctx, nil, order); updateErr != nil {
|
||||
logx.Errorf("微信退款回调,更新订单失败%+v", updateErr)
|
||||
return nil
|
||||
}
|
||||
// 响应微信回调成功
|
||||
w.WriteHeader(http.StatusOK)
|
||||
_, _ = w.Write([]byte("success")) // 确保只写入一次响应
|
||||
// switch *notification.Status {
|
||||
// case refunddomestic.STATUS_SUCCESS:
|
||||
// order.Status = "refunded"
|
||||
// order.RefundTime = sql.NullTime{
|
||||
// Time: time.Now(),
|
||||
// Valid: true,
|
||||
// }
|
||||
// case refunddomestic.STATUS_ABNORMAL:
|
||||
// // 异常
|
||||
// return nil
|
||||
// default:
|
||||
// return nil
|
||||
// }
|
||||
// if updateErr := l.svcCtx.OrderModel.UpdateWithVersion(l.ctx, nil, order); updateErr != nil {
|
||||
// logx.Errorf("微信退款回调,更新订单失败%+v", updateErr)
|
||||
// return nil
|
||||
// }
|
||||
// // 响应微信回调成功
|
||||
// w.WriteHeader(http.StatusOK)
|
||||
// _, _ = w.Write([]byte("success")) // 确保只写入一次响应
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user