|
|
@@ -45,7 +45,18 @@ public class CouponController {
|
|
|
Long userCouponId = ParamUtils.getLong(params.get("userCouponId"));
|
|
|
String orderType = (String) params.get("orderType");
|
|
|
Integer orderAmount = Integer.valueOf(params.get("orderAmount").toString());
|
|
|
- Integer discount = couponService.apply(userId, userCouponId, orderType, orderAmount);
|
|
|
+ // 结算预览:透传本次订单商品 ID 集合,与下单创建(ProductOrderService)的商品维度校验保持一致。
|
|
|
+ // 否则商品绑定券(如菌群测评券 product_id=3)在预览端因无商品上下文(productIds=null)恒判"不可用"。
|
|
|
+ List<Long> productIds = null;
|
|
|
+ Object rawProductIds = params.get("productIds");
|
|
|
+ if (rawProductIds instanceof java.util.Collection && !((java.util.Collection<?>) rawProductIds).isEmpty()) {
|
|
|
+ productIds = new ArrayList<>();
|
|
|
+ for (Object o : (java.util.Collection<?>) rawProductIds) {
|
|
|
+ if (o == null) continue;
|
|
|
+ productIds.add(o instanceof Number ? ((Number) o).longValue() : Long.valueOf(o.toString()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Integer discount = couponService.apply(userId, userCouponId, orderType, orderAmount, productIds);
|
|
|
if (discount == null) {
|
|
|
return Result.error("优惠券不可用");
|
|
|
}
|