Authored by qinchao

Merge branch 'dev_qc693_取消skup重新上架' into test6.9.3

@@ -32,7 +32,9 @@ import com.yohoufo.order.service.handler.RefundGoodsMoneyHandler; @@ -32,7 +32,9 @@ import com.yohoufo.order.service.handler.RefundGoodsMoneyHandler;
32 import com.yohoufo.order.service.proxy.CouponProxyService; 32 import com.yohoufo.order.service.proxy.CouponProxyService;
33 import com.yohoufo.order.service.proxy.InBoxFacade; 33 import com.yohoufo.order.service.proxy.InBoxFacade;
34 import com.yohoufo.order.service.proxy.OrderStatusFlowService; 34 import com.yohoufo.order.service.proxy.OrderStatusFlowService;
  35 +import com.yohoufo.order.service.proxy.ProductProxyService;
35 import com.yohoufo.order.utils.LoggerUtils; 36 import com.yohoufo.order.utils.LoggerUtils;
  37 +import com.yohoufo.order.utils.OrderAssist;
36 import com.yohoufo.order.utils.PaymentHelper; 38 import com.yohoufo.order.utils.PaymentHelper;
37 import lombok.Setter; 39 import lombok.Setter;
38 import org.slf4j.Logger; 40 import org.slf4j.Logger;
@@ -75,6 +77,8 @@ public class BuyerOrderCancelService { @@ -75,6 +77,8 @@ public class BuyerOrderCancelService {
75 @Autowired 77 @Autowired
76 private SellerOrderMetaMapper sellerOrderMetaMapper; 78 private SellerOrderMetaMapper sellerOrderMetaMapper;
77 79
  80 + @Autowired
  81 + private ProductProxyService productProxyService;
78 82
79 @Autowired 83 @Autowired
80 private PayRefundService payRefundService; 84 private PayRefundService payRefundService;
@@ -122,17 +126,36 @@ public class BuyerOrderCancelService { @@ -122,17 +126,36 @@ public class BuyerOrderCancelService {
122 //退还优惠券 126 //退还优惠券
123 refundCouponIfNeed(buyerUid, orderCode); 127 refundCouponIfNeed(buyerUid, orderCode);
124 int skup = bsdEvent.getSkup(); 128 int skup = bsdEvent.getSkup();
  129 + SellerOrderGoods psog = sellerOrderGoodsMapper.selectByPrimaryKey(skup);
  130 + int targetGoodsStatus = SkupStatus.BUYER_CANCEL_BEFORE_SELLER_DELIVER.getCode();
  131 + int targetSellerOrderStatus = SellerOrderStatus.BUYER_CANCEL_BEFORE_SELLER_DELIVER.getCode();
  132 + //重新上架标志
  133 + boolean reSellAfterCancel=(OrderAssist.skupIsCommonInStock(psog.getAttributes())||OrderAssist.skupIsAdvance(psog.getAttributes()))?true:false;
  134 + if(reSellAfterCancel){
  135 + targetGoodsStatus = SkupStatus.CAN_SELL.getCode();
  136 + targetSellerOrderStatus = SellerOrderStatus.HAS_PAYED.getCode();
  137 + }
  138 +
125 SellerOrderGoods targetGoods = new SellerOrderGoods(); 139 SellerOrderGoods targetGoods = new SellerOrderGoods();
126 targetGoods.setId(skup); 140 targetGoods.setId(skup);
127 - targetGoods.setStatus(SkupStatus.BUYER_CANCEL_BEFORE_SELLER_DELIVER.getCode()); 141 + targetGoods.setStatus(targetGoodsStatus);
128 targetGoods.setExceptStatus(SkupStatus.SELL_OUT.getCode()); 142 targetGoods.setExceptStatus(SkupStatus.SELL_OUT.getCode());
129 sellerOrderGoodsMapper.updateStatusBySkpu(targetGoods); 143 sellerOrderGoodsMapper.updateStatusBySkpu(targetGoods);
130 144
131 - SellerOrder soc = new SellerOrder();  
132 - soc.setStatus(SellerOrderStatus.BUYER_CANCEL_BEFORE_SELLER_DELIVER.getCode());  
133 - soc.setUpdateTime(DateUtil.getCurrentTimeSecond());  
134 - sellerOrderMapper.updateBySkups(soc, Arrays.asList(skup));  
135 - SellerOrderGoods psog = sellerOrderGoodsMapper.selectByPrimaryKey(skup); 145 + logger.info("in buyer cancel BeforeSellerDeliver reSellAfterCancel {}, buyerUid {}, orderCode {}, skup {} buyerOrder {}",
  146 + reSellAfterCancel, buyerUid, orderCode, buyerOrder );
  147 + if(reSellAfterCancel){
  148 + // 恢复product skup的库存
  149 + boolean isReturnSuccess = productProxyService.returnStorage(skup);
  150 + logger.info("in buyer cancel BeforeSellerDeliver returnStorage {} reSellAfterCancel {}, buyerUid {}, orderCode {}, skup {} buyerOrder {}",isReturnSuccess,
  151 + reSellAfterCancel, buyerUid, orderCode, buyerOrder );
  152 + }else{
  153 + SellerOrder soc = new SellerOrder();
  154 + soc.setStatus(targetSellerOrderStatus);
  155 + soc.setUpdateTime(DateUtil.getCurrentTimeSecond());
  156 + sellerOrderMapper.updateBySkups(soc, Arrays.asList(skup));
  157 + }
  158 +
136 if (noResponsibility){ 159 if (noResponsibility){
137 inBoxFacade.noticeSellerWhenBuyerCancelNoResponsibility(psog, orderCode); 160 inBoxFacade.noticeSellerWhenBuyerCancelNoResponsibility(psog, orderCode);
138 }else { 161 }else {
@@ -145,7 +168,7 @@ public class BuyerOrderCancelService { @@ -145,7 +168,7 @@ public class BuyerOrderCancelService {
145 TransferCase transferCase = TransferCase.PART_GOODS_MONEY_TO_SELLER; 168 TransferCase transferCase = TransferCase.PART_GOODS_MONEY_TO_SELLER;
146 //(退费)扣除赔偿款,计算剩余的货款,退给买家 169 //(退费)扣除赔偿款,计算剩余的货款,退给买家
147 BuyerCancelAfterProcessTask bcapt = new BuyerCancelAfterProcessTask(buyerOrder, skup, 170 BuyerCancelAfterProcessTask bcapt = new BuyerCancelAfterProcessTask(buyerOrder, skup,
148 - bpcr, transferCase); 171 + bpcr, transferCase,reSellAfterCancel);
149 bcapt.targetOrderStatus = targetOrderStatus; 172 bcapt.targetOrderStatus = targetOrderStatus;
150 bcapt.setSwdType(SellerWalletDetail.Type.BUYER_CANCEL_NO_DELIVERY); 173 bcapt.setSwdType(SellerWalletDetail.Type.BUYER_CANCEL_NO_DELIVERY);
151 Future<PayRefundBo> future = ThreadPoolFactory.getBuyerCancelThreadPool().submit(bcapt); 174 Future<PayRefundBo> future = ThreadPoolFactory.getBuyerCancelThreadPool().submit(bcapt);
@@ -262,7 +285,7 @@ public class BuyerOrderCancelService { @@ -262,7 +285,7 @@ public class BuyerOrderCancelService {
262 //(退费)扣除赔偿款,计算剩余的货款,退给买家 285 //(退费)扣除赔偿款,计算剩余的货款,退给买家
263 TransferCase transferCase = TransferCase.PART_GOODS_MONEY_TO_SELLER; 286 TransferCase transferCase = TransferCase.PART_GOODS_MONEY_TO_SELLER;
264 BuyerCancelAfterProcessTask bcapt = new BuyerCancelAfterProcessTask(buyerOrder, skup, 287 BuyerCancelAfterProcessTask bcapt = new BuyerCancelAfterProcessTask(buyerOrder, skup,
265 - bpcr, transferCase); 288 + bpcr, transferCase,false);
266 bcapt.targetOrderStatus = targetOrderStatus; 289 bcapt.targetOrderStatus = targetOrderStatus;
267 bcapt.setSwdType(SellerWalletDetail.Type.BUYER_CANCEL_DELIVERY); 290 bcapt.setSwdType(SellerWalletDetail.Type.BUYER_CANCEL_DELIVERY);
268 Future<PayRefundBo> future = ThreadPoolFactory.getBuyerCancelThreadPool().submit(bcapt); 291 Future<PayRefundBo> future = ThreadPoolFactory.getBuyerCancelThreadPool().submit(bcapt);
@@ -293,17 +316,19 @@ public class BuyerOrderCancelService { @@ -293,17 +316,19 @@ public class BuyerOrderCancelService {
293 BuyerOrder buyerOrder; 316 BuyerOrder buyerOrder;
294 TransferCase transferCase; 317 TransferCase transferCase;
295 OrderStatus targetOrderStatus; 318 OrderStatus targetOrderStatus;
  319 + boolean reSellFlag;//重新上架标志,重新上架则不退保证金了
296 320
297 @Setter 321 @Setter
298 SellerWalletDetail.Type swdType; 322 SellerWalletDetail.Type swdType;
299 323
300 - public BuyerCancelAfterProcessTask(BuyerOrder buyerOrder, int skup, BuyerPenaltyCalResult bpcr, TransferCase transferCase) { 324 + public BuyerCancelAfterProcessTask(BuyerOrder buyerOrder, int skup, BuyerPenaltyCalResult bpcr, TransferCase transferCase,boolean reSellFlag) {
301 this.buyerUid = buyerOrder.getUid(); 325 this.buyerUid = buyerOrder.getUid();
302 this.orderCode = buyerOrder.getOrderCode(); 326 this.orderCode = buyerOrder.getOrderCode();
303 this.skup = skup; 327 this.skup = skup;
304 this.bpcr = bpcr; 328 this.bpcr = bpcr;
305 this.transferCase = transferCase; 329 this.transferCase = transferCase;
306 this.buyerOrder = buyerOrder; 330 this.buyerOrder = buyerOrder;
  331 + this.reSellFlag = reSellFlag;
307 } 332 }
308 333
309 private PayRefundBo refundSellerEarnestMoney(SellerOrder sellerOrder){ 334 private PayRefundBo refundSellerEarnestMoney(SellerOrder sellerOrder){
@@ -421,14 +446,17 @@ public class BuyerOrderCancelService { @@ -421,14 +446,17 @@ public class BuyerOrderCancelService {
421 public PayRefundBo call() throws Exception { 446 public PayRefundBo call() throws Exception {
422 // 整个过程异步去执行(考虑退费依赖订单状态) 447 // 整个过程异步去执行(考虑退费依赖订单状态)
423 //(退费)退保证金给卖家 448 //(退费)退保证金给卖家
424 - logger.info("in BuyerCancelAfterProcessTask call buyerUid {}, orderCode {}, skup {}, transferCase {}, compensate {}",  
425 - buyerUid, orderCode, skup, transferCase, bpcr); 449 + logger.info("in BuyerCancelAfterProcessTask call buyerUid {}, orderCode {}, skup {}, transferCase {}, compensate {},reSellFlag {}",
  450 + buyerUid, orderCode, skup, transferCase, bpcr,reSellFlag);
426 PayRefundBo prb = null; 451 PayRefundBo prb = null;
427 try { 452 try {
428 SellerOrder sellerOrder = sellerOrderMapper.selectBySkup(skup); 453 SellerOrder sellerOrder = sellerOrderMapper.selectBySkup(skup);
429 - logger.info("in BuyerCancelAfterProcessTask call sellerOrderMapper.selectBySkup, buyerUid {}, orderCode {}, skup {}",  
430 - buyerUid, orderCode, skup );  
431 - prb = refundSellerEarnestMoney(sellerOrder); 454 + logger.info("in BuyerCancelAfterProcessTask call sellerOrderMapper.selectBySkup, buyerUid {}, orderCode {}, skup {},reSellFlag {}",
  455 + buyerUid, orderCode, skup,reSellFlag );
  456 + if(!reSellFlag){
  457 + //只有不重新上架,才退保证金
  458 + prb = refundSellerEarnestMoney(sellerOrder);
  459 + }
432 460
433 //(转账)瓜分指定赔偿款给卖家和平台 461 //(转账)瓜分指定赔偿款给卖家和平台
434 transferPenalty(bpcr); 462 transferPenalty(bpcr);
@@ -22,6 +22,11 @@ public class OrderAssist { @@ -22,6 +22,11 @@ public class OrderAssist {
22 return new StringBuilder().append(storageId).append("_").append(salePrice).toString(); 22 return new StringBuilder().append(storageId).append("_").append(salePrice).toString();
23 } 23 }
24 24
  25 + //普通现货
  26 + public static boolean skupIsCommonInStock(Integer attribute){
  27 + return Objects.nonNull(attribute) && SkupType.IN_STOCK.getCode() == attribute;
  28 + }
  29 +
25 public static boolean skupIsAdvance(Integer attribute){ 30 public static boolean skupIsAdvance(Integer attribute){
26 return Objects.nonNull(attribute) && SkupType.ADVANCE.getCode() == attribute; 31 return Objects.nonNull(attribute) && SkupType.ADVANCE.getCode() == attribute;
27 } 32 }