diff --git a/mallinkService/src/main/java/com/iformall/domain/po/StockReduceResult.java b/mallinkService/src/main/java/com/iformall/domain/po/StockReduceResult.java index c2ff53e31..108ee019e 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/StockReduceResult.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/StockReduceResult.java @@ -3,6 +3,7 @@ package com.iformall.domain.po; public class StockReduceResult { private boolean isChannelStockReduce; + private boolean isChannelPrice; private Integer currentPrice; public boolean isChannelStockReduce() { @@ -17,4 +18,10 @@ public class StockReduceResult { public void setCurrentPrice(Integer currentPrice) { this.currentPrice = currentPrice; } + public boolean isChannelPrice() { + return isChannelPrice; + } + public void setChannelPrice(boolean isChannelPrice) { + this.isChannelPrice = isChannelPrice; + } } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java index 9f3ee496c..f7822cc03 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java @@ -920,6 +920,7 @@ public class WxOrderServiceImpl implements WxOrderService { StockReduceResult reduceResult = new StockReduceResult(); boolean isChannelStockReduce = false; + boolean isChannelPrice = false; Integer currentPrice = coupon.getSalePrice(); if (null != couponChannel ) { if (null != couponChannel.getChannelStock()) { @@ -927,6 +928,7 @@ public class WxOrderServiceImpl implements WxOrderService { } if (null != couponChannel.getChannelPrice()) { currentPrice = couponChannel.getChannelPrice(); + isChannelPrice = true; } } @@ -1009,6 +1011,7 @@ public class WxOrderServiceImpl implements WxOrderService { } reduceResult.setChannelStockReduce(isChannelStockReduce); reduceResult.setCurrentPrice(currentPrice); + reduceResult.setChannelPrice(isChannelPrice); return reduceResult; } @@ -2935,7 +2938,7 @@ public class WxOrderServiceImpl implements WxOrderService { public WxOrder saveNoFreeOrderForCoupon(Date orderDate,boolean allowUnPayOrder,WxComposeOrder composeOrder,WxCUserBasicInfo user, WxCoupon coupon,int couponNumber,WxCouponChannel couponChannel,OrderComposeSaveDto orderdto,EnumPayWay payWay) { WxOrderServiceImpl proxy = (WxOrderServiceImpl) AopContext.currentProxy(); - // 3. 减库存操作 + // 3. 减库存操作。所有的订单都跟减库存操作时的订单详情保持一致 StockReduceResult stockReduceResult = proxy.stockReduce(allowUnPayOrder,user, coupon, couponChannel,couponNumber); // 3. 当积分券或者积分停车券时 则进行积分支付 @@ -2947,16 +2950,18 @@ public class WxOrderServiceImpl implements WxOrderService { orderType = EnumOrderType.COUPON.getCode(); } - //渠道的库存和价格可以随时修改。这里需要校验一下 + //扣库存的时候价格是什么样的,如果此时有变化,则不让继续。渠道的库存和价格可以随时修改。这里需要校验一下 if (stockReduceResult.isChannelStockReduce()) { //再查询一下,此时有可能价格已经修改 WxCouponChannel wxCouponChannel = wxCouponChannelService.getById(couponChannel.getId(),coupon.getTenantId()); - //如果这个时候渠道价格已经清空了 - if (null == wxCouponChannel.getChannelPrice()) { - throw new MallinkException(ErrorCode.ORDER_SAVE_ERR.getCode(),"["+coupon.getTitle()+"]渠道价格已变动[清空],请刷新后重新下单."); - } - if (wxCouponChannel.getChannelPrice().intValue() != couponChannel.getChannelPrice().intValue()) { - throw new MallinkException(ErrorCode.ORDER_SAVE_ERR.getCode(),"["+coupon.getTitle()+"]渠道价格已变更,请刷新后重新下单."); + if (stockReduceResult.isChannelPrice()) { + //如果这个时候渠道价格已经清空了 + if (null == wxCouponChannel.getChannelPrice()) { + throw new MallinkException(ErrorCode.ORDER_SAVE_ERR.getCode(),"["+coupon.getTitle()+"]渠道价格已变动[清空],请刷新后重新下单."); + } + if (wxCouponChannel.getChannelPrice().intValue() != couponChannel.getChannelPrice().intValue()) { + throw new MallinkException(ErrorCode.ORDER_SAVE_ERR.getCode(),"["+coupon.getTitle()+"]渠道价格已变更,请刷新后重新下单."); + } } }