...
|
...
|
@@ -32,7 +32,9 @@ import com.yohoufo.order.service.handler.RefundGoodsMoneyHandler; |
|
|
import com.yohoufo.order.service.proxy.CouponProxyService;
|
|
|
import com.yohoufo.order.service.proxy.InBoxFacade;
|
|
|
import com.yohoufo.order.service.proxy.OrderStatusFlowService;
|
|
|
import com.yohoufo.order.service.proxy.ProductProxyService;
|
|
|
import com.yohoufo.order.utils.LoggerUtils;
|
|
|
import com.yohoufo.order.utils.OrderAssist;
|
|
|
import com.yohoufo.order.utils.PaymentHelper;
|
|
|
import lombok.Setter;
|
|
|
import org.slf4j.Logger;
|
...
|
...
|
@@ -75,6 +77,8 @@ public class BuyerOrderCancelService { |
|
|
@Autowired
|
|
|
private SellerOrderMetaMapper sellerOrderMetaMapper;
|
|
|
|
|
|
@Autowired
|
|
|
private ProductProxyService productProxyService;
|
|
|
|
|
|
@Autowired
|
|
|
private PayRefundService payRefundService;
|
...
|
...
|
@@ -122,17 +126,36 @@ public class BuyerOrderCancelService { |
|
|
//退还优惠券
|
|
|
refundCouponIfNeed(buyerUid, orderCode);
|
|
|
int skup = bsdEvent.getSkup();
|
|
|
SellerOrderGoods psog = sellerOrderGoodsMapper.selectByPrimaryKey(skup);
|
|
|
int targetGoodsStatus = SkupStatus.BUYER_CANCEL_BEFORE_SELLER_DELIVER.getCode();
|
|
|
int targetSellerOrderStatus = SellerOrderStatus.BUYER_CANCEL_BEFORE_SELLER_DELIVER.getCode();
|
|
|
//重新上架标志
|
|
|
boolean reSellAfterCancel=(OrderAssist.skupIsCommonInStock(psog.getAttributes())||OrderAssist.skupIsAdvance(psog.getAttributes()))?true:false;
|
|
|
if(reSellAfterCancel){
|
|
|
targetGoodsStatus = SkupStatus.CAN_SELL.getCode();
|
|
|
targetSellerOrderStatus = SellerOrderStatus.HAS_PAYED.getCode();
|
|
|
}
|
|
|
|
|
|
SellerOrderGoods targetGoods = new SellerOrderGoods();
|
|
|
targetGoods.setId(skup);
|
|
|
targetGoods.setStatus(SkupStatus.BUYER_CANCEL_BEFORE_SELLER_DELIVER.getCode());
|
|
|
targetGoods.setStatus(targetGoodsStatus);
|
|
|
targetGoods.setExceptStatus(SkupStatus.SELL_OUT.getCode());
|
|
|
sellerOrderGoodsMapper.updateStatusBySkpu(targetGoods);
|
|
|
|
|
|
logger.info("in buyer cancel BeforeSellerDeliver reSellAfterCancel {}, buyerUid {}, orderCode {}, skup {} buyerOrder {}",
|
|
|
reSellAfterCancel, buyerUid, orderCode, buyerOrder );
|
|
|
if(reSellAfterCancel){
|
|
|
// 恢复product skup的库存
|
|
|
boolean isReturnSuccess = productProxyService.returnStorage(skup);
|
|
|
logger.info("in buyer cancel BeforeSellerDeliver returnStorage {} reSellAfterCancel {}, buyerUid {}, orderCode {}, skup {} buyerOrder {}",isReturnSuccess,
|
|
|
reSellAfterCancel, buyerUid, orderCode, buyerOrder );
|
|
|
}else{
|
|
|
SellerOrder soc = new SellerOrder();
|
|
|
soc.setStatus(SellerOrderStatus.BUYER_CANCEL_BEFORE_SELLER_DELIVER.getCode());
|
|
|
soc.setStatus(targetSellerOrderStatus);
|
|
|
soc.setUpdateTime(DateUtil.getCurrentTimeSecond());
|
|
|
sellerOrderMapper.updateBySkups(soc, Arrays.asList(skup));
|
|
|
SellerOrderGoods psog = sellerOrderGoodsMapper.selectByPrimaryKey(skup);
|
|
|
}
|
|
|
|
|
|
if (noResponsibility){
|
|
|
inBoxFacade.noticeSellerWhenBuyerCancelNoResponsibility(psog, orderCode);
|
|
|
}else {
|
...
|
...
|
@@ -145,7 +168,7 @@ public class BuyerOrderCancelService { |
|
|
TransferCase transferCase = TransferCase.PART_GOODS_MONEY_TO_SELLER;
|
|
|
//(退费)扣除赔偿款,计算剩余的货款,退给买家
|
|
|
BuyerCancelAfterProcessTask bcapt = new BuyerCancelAfterProcessTask(buyerOrder, skup,
|
|
|
bpcr, transferCase);
|
|
|
bpcr, transferCase,reSellAfterCancel);
|
|
|
bcapt.targetOrderStatus = targetOrderStatus;
|
|
|
bcapt.setSwdType(SellerWalletDetail.Type.BUYER_CANCEL_NO_DELIVERY);
|
|
|
Future<PayRefundBo> future = ThreadPoolFactory.getBuyerCancelThreadPool().submit(bcapt);
|
...
|
...
|
@@ -262,7 +285,7 @@ public class BuyerOrderCancelService { |
|
|
//(退费)扣除赔偿款,计算剩余的货款,退给买家
|
|
|
TransferCase transferCase = TransferCase.PART_GOODS_MONEY_TO_SELLER;
|
|
|
BuyerCancelAfterProcessTask bcapt = new BuyerCancelAfterProcessTask(buyerOrder, skup,
|
|
|
bpcr, transferCase);
|
|
|
bpcr, transferCase,false);
|
|
|
bcapt.targetOrderStatus = targetOrderStatus;
|
|
|
bcapt.setSwdType(SellerWalletDetail.Type.BUYER_CANCEL_DELIVERY);
|
|
|
Future<PayRefundBo> future = ThreadPoolFactory.getBuyerCancelThreadPool().submit(bcapt);
|
...
|
...
|
@@ -293,17 +316,19 @@ public class BuyerOrderCancelService { |
|
|
BuyerOrder buyerOrder;
|
|
|
TransferCase transferCase;
|
|
|
OrderStatus targetOrderStatus;
|
|
|
boolean reSellFlag;//重新上架标志,重新上架则不退保证金了
|
|
|
|
|
|
@Setter
|
|
|
SellerWalletDetail.Type swdType;
|
|
|
|
|
|
public BuyerCancelAfterProcessTask(BuyerOrder buyerOrder, int skup, BuyerPenaltyCalResult bpcr, TransferCase transferCase) {
|
|
|
public BuyerCancelAfterProcessTask(BuyerOrder buyerOrder, int skup, BuyerPenaltyCalResult bpcr, TransferCase transferCase,boolean reSellFlag) {
|
|
|
this.buyerUid = buyerOrder.getUid();
|
|
|
this.orderCode = buyerOrder.getOrderCode();
|
|
|
this.skup = skup;
|
|
|
this.bpcr = bpcr;
|
|
|
this.transferCase = transferCase;
|
|
|
this.buyerOrder = buyerOrder;
|
|
|
this.reSellFlag = reSellFlag;
|
|
|
}
|
|
|
|
|
|
private PayRefundBo refundSellerEarnestMoney(SellerOrder sellerOrder){
|
...
|
...
|
@@ -421,14 +446,17 @@ public class BuyerOrderCancelService { |
|
|
public PayRefundBo call() throws Exception {
|
|
|
// 整个过程异步去执行(考虑退费依赖订单状态)
|
|
|
//(退费)退保证金给卖家
|
|
|
logger.info("in BuyerCancelAfterProcessTask call buyerUid {}, orderCode {}, skup {}, transferCase {}, compensate {}",
|
|
|
buyerUid, orderCode, skup, transferCase, bpcr);
|
|
|
logger.info("in BuyerCancelAfterProcessTask call buyerUid {}, orderCode {}, skup {}, transferCase {}, compensate {},reSellFlag {}",
|
|
|
buyerUid, orderCode, skup, transferCase, bpcr,reSellFlag);
|
|
|
PayRefundBo prb = null;
|
|
|
try {
|
|
|
SellerOrder sellerOrder = sellerOrderMapper.selectBySkup(skup);
|
|
|
logger.info("in BuyerCancelAfterProcessTask call sellerOrderMapper.selectBySkup, buyerUid {}, orderCode {}, skup {}",
|
|
|
buyerUid, orderCode, skup );
|
|
|
logger.info("in BuyerCancelAfterProcessTask call sellerOrderMapper.selectBySkup, buyerUid {}, orderCode {}, skup {},reSellFlag {}",
|
|
|
buyerUid, orderCode, skup,reSellFlag );
|
|
|
if(!reSellFlag){
|
|
|
//只有不重新上架,才退保证金
|
|
|
prb = refundSellerEarnestMoney(sellerOrder);
|
|
|
}
|
|
|
|
|
|
//(转账)瓜分指定赔偿款给卖家和平台
|
|
|
transferPenalty(bpcr);
|
...
|
...
|
|