Browse Source

下单时候自动选择优惠金额最大的优惠券

zyj
sj 2 years ago
parent
commit
a5cdf202f1
  1. 5
      zsw-bxg/src/main/java/co/yixiang/modules/order/service/impl/YxStoreOrderServiceImpl.java

5
zsw-bxg/src/main/java/co/yixiang/modules/order/service/impl/YxStoreOrderServiceImpl.java

@ -269,6 +269,11 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<StoreOrderMapper, Y
StoreCouponUserVo storeCouponUser = null;
if (storeCouponUsers != null && !storeCouponUsers.isEmpty()) {
//如果有多张优惠券,就进行比较,按优惠金额排序
if (storeCouponUsers.size()>1){
Collections.sort(storeCouponUsers, (couponUserVo1, couponUserVo2) -> couponUserVo1.getCouponPrice()>couponUserVo2.getCouponPrice()? -1:(couponUserVo1.getCouponPrice()==couponUserVo2.getCouponPrice()? 0:1));
}
//选出优惠金额最大的券
storeCouponUser = storeCouponUsers.get(0);
}

Loading…
Cancel
Save