diff --git a/src/shop/orderConfirm/index.tsx b/src/shop/orderConfirm/index.tsx index 05a9753..58fe1c1 100644 --- a/src/shop/orderConfirm/index.tsx +++ b/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 { // 用户选择不使用优惠券,继续支付 }