This commit is contained in:
Mrx
2026-06-06 17:03:08 +08:00
parent a85436950e
commit 35e9191981
28 changed files with 666 additions and 286 deletions

View File

@@ -42,8 +42,8 @@ func (l *PaymentCheckLogic) PaymentCheck(req *types.PaymentCheckReq) (resp *type
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "查询订单失败: %v", findErr)
}
// xpay 轮询pending 时主动查微信单
if order.Status == "pending" && order.PaymentScene == "wxmini" &&
// xpay 轮询pending 时主动查微信单并到账(不通知微信发货)
if order.Status == model.OrderStatusPending && model.IsXpayOrder(order) &&
l.svcCtx.XpayService != nil && l.svcCtx.XpayService.Enabled() {
if syncErr := l.syncXpayOrderStatus(order); syncErr != nil {
l.Errorf("[xpay] 轮询查单失败 order_no=%s err=%v", req.OrderNo, syncErr)
@@ -68,27 +68,14 @@ func (l *PaymentCheckLogic) syncXpayOrderStatus(order *model.Order) error {
if err != nil {
return err
}
sessionKey, err := l.svcCtx.XpayService.GetSessionKey(l.ctx, userID)
if err != nil {
return err
}
status, err := l.svcCtx.XpayService.QueryOrder(l.ctx, openid, order.OrderNo, sessionKey)
status, err := l.svcCtx.XpayService.QueryOrder(l.ctx, openid, order.OrderNo, "")
if err != nil {
return err
}
if service.IsXpayPaidStatus(status.Status) {
credited, fulfillErr := fulfillQueryOrderPaid(l.ctx, l.svcCtx, order, "", status.PaidFee)
if fulfillErr != nil {
return fulfillErr
}
if credited {
wxOrderID := ""
_ = l.svcCtx.XpayService.NotifyProvideGoods(l.ctx, openid, order.OrderNo, wxOrderID, sessionKey)
_ = l.svcCtx.XpayService.MarkNotified(l.ctx, order.OrderNo)
}
return nil
_, fulfillErr := fulfillQueryOrderPaid(l.ctx, l.svcCtx, order, status.WxOrderID, status.PaidFee)
return fulfillErr
}
if service.IsXpayClosedStatus(status.Status) {