Browse Source

```

feat(shop/orderConfirm): 优化优惠券使用后的支付逻辑当用户选择使用推荐优惠券时,现在会重新构建订单数据并递归调用支付函数,
确保传递最新的优惠券信息。同时添加了日志以便调试,并提前返回以避免重复执行支付逻辑。```
master
科技小王子 1 week ago
parent
commit
cce108a666
  1. 22
      src/shop/orderConfirm/index.tsx

22
src/shop/orderConfirm/index.tsx

@ -404,8 +404,26 @@ const OrderConfirm = () => {
if (confirmResult) {
setSelectedCoupon(bestCoupon)
// 使用优惠券后重新计算价格,然后继续支付
// 注意:这里不直接return,让代码继续执行支付逻辑
// 🔄 使用优惠券后需要重新构建订单数据,这里直接递归调用支付函数
// 但要确保传递最新的优惠券信息
const currentPaymentType = payment.type === 0 ? PaymentType.BALANCE : PaymentType.WECHAT;
const updatedOrderData = buildSingleGoodsOrder(
goods.goodsId!,
quantity,
address.id,
{
comments: goods.name,
deliveryType: 0,
buyerRemarks: orderRemark,
couponId: parseInt(String(bestCoupon.id), 10)
}
);
console.log('🎯 使用推荐优惠券的订单数据:', updatedOrderData);
// 执行支付
await PaymentHandler.pay(updatedOrderData, currentPaymentType);
return; // 提前返回,避免重复执行支付
} else {
// 用户选择不使用优惠券,继续支付
}

Loading…
Cancel
Save