...
|
...
|
@@ -52,6 +52,9 @@ import java.util.List; |
|
|
import java.util.Objects;
|
|
|
import java.util.concurrent.Callable;
|
|
|
import java.util.concurrent.Future;
|
|
|
import java.util.concurrent.locks.Lock;
|
|
|
import java.util.function.Consumer;
|
|
|
import java.util.function.Supplier;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -332,31 +335,48 @@ public class BuyerOrderCancelService { |
|
|
}
|
|
|
BuyerOrder buyerOrder = buyerOrderMapper.selectOnlyByOrderCode(orderCode);
|
|
|
if (buyerOrder == null){
|
|
|
logger.info("in cancelOverseasOrder buyer Order not exist, orderCode {} CutomsClearanceFailType {}", orderCode, failType);
|
|
|
logger.warn("in cancelOverseasOrder buyer Order not exist, orderCode {} CutomsClearanceFailType {}", orderCode, failType);
|
|
|
return;
|
|
|
}
|
|
|
Integer orderAttr = buyerOrder.getAttributes();
|
|
|
SkupTypeCodeSupport.CodeNode codeNode = SkupTypeCodeSupport.explain(orderAttr);
|
|
|
if (codeNode.getRegion() == RegionEnum.MAINLAND.getCode()){
|
|
|
logger.info("in cancelOverseasOrder buyer Order is not overseas, Attr {}, orderCode {} CutomsClearanceFailType {}",
|
|
|
logger.warn("in cancelOverseasOrder buyer Order is not overseas, Attr {}, orderCode {} CutomsClearanceFailType {}",
|
|
|
orderAttr, orderCode, failType);
|
|
|
return;
|
|
|
}
|
|
|
OrderStatus targetStatus = null;
|
|
|
Consumer<BuyerOrder> consumer = null;
|
|
|
switch (failType){
|
|
|
case PLATFORM:
|
|
|
targetStatus = OrderStatus.PLATFORM_BLOWN_CUSTOMS_CLEARANCE;
|
|
|
cancelOverseasOrderByPlatform(buyerOrder);
|
|
|
consumer = (buyerOrder1) -> cancelOverseasOrderByPlatform(buyerOrder1);
|
|
|
break;
|
|
|
case BUYER:
|
|
|
targetStatus = OrderStatus.BUYER_BLOWN_CUSTOMS_CLEARANCE;
|
|
|
cancelOverseasOrderByBuyer(buyerOrder);
|
|
|
consumer = (buyerOrder1) -> cancelOverseasOrderByBuyer(buyerOrder1);
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
if (targetStatus != null){
|
|
|
orderStatusFlowService.addAsy(orderCode,targetStatus.getCode());
|
|
|
|
|
|
if (targetStatus == null){
|
|
|
logger.warn("cancelOverseasOrder buyer Order targetStatus is null, Attr {}, orderCode {} CutomsClearanceFailType {}",
|
|
|
orderAttr, orderCode, failType);
|
|
|
return;
|
|
|
}
|
|
|
final OrderStatus expectedStatus = OrderStatus.WAITING_RECEIVE;
|
|
|
int buyerUid = buyerOrder.getUid();
|
|
|
boolean changeStatusFlag = buyerOrderMapper.updateStatusByOrderCode(orderCode, buyerUid, expectedStatus.getCode(),
|
|
|
targetStatus.getCode(), DateUtil.getCurrentTimeSecond()) > 0;
|
|
|
if (!changeStatusFlag){
|
|
|
logger.warn("cancelOverseasOrder fail -> buyerOrderMapper.updateStatusByOrderCode, orderCode {}", orderCode);
|
|
|
return;
|
|
|
}
|
|
|
//
|
|
|
buyerOrder.setStatus(targetStatus.getCode());
|
|
|
consumer.accept(buyerOrder);
|
|
|
//
|
|
|
orderStatusFlowService.addAsy(orderCode,targetStatus.getCode());
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -380,6 +400,26 @@ public class BuyerOrderCancelService { |
|
|
|
|
|
}
|
|
|
|
|
|
private void refundGoodsAmount(BuyerOrder buyerOrder,int skup, OrderStatus targetOrderStatus, BigDecimal leftBuyerMoney){
|
|
|
Integer buyerUid = buyerOrder.getUid();
|
|
|
Integer sellerUid = buyerOrder.getSellerUid();
|
|
|
Long orderCode = buyerOrder.getOrderCode();
|
|
|
//
|
|
|
|
|
|
logger.info("cancelOverseasOrder refundGoodsAmount begin payRefundService.refund buyer, buyerUid {}, orderCode {}, skup {} refundAmount {}",
|
|
|
buyerUid, orderCode, skup, leftBuyerMoney );
|
|
|
|
|
|
new RefundGoodsMoneyHandler().loadLogger(logger)
|
|
|
.loadPaymentRequest(buyerUid,orderCode,buyerOrder.getPayment(), leftBuyerMoney)
|
|
|
.loadRefundAction(payRefundService::refund)
|
|
|
.loadTargetOrderStatus(targetOrderStatus)
|
|
|
.loadSellerOrderGoods(sellerUid, skup)
|
|
|
.refund();
|
|
|
logger.info("cancelOverseasOrder refundGoodsAmount after payRefundService.refund buyer, buyerUid {}, orderCode {}, skup {} refundAmount {}",
|
|
|
buyerUid, orderCode, skup, leftBuyerMoney );
|
|
|
}
|
|
|
|
|
|
|
|
|
class BuyerCancelAfterProcessTask implements Callable<PayRefundBo>{
|
|
|
int buyerUid;
|
|
|
long orderCode;
|
...
|
...
|
@@ -468,19 +508,22 @@ public class BuyerOrderCancelService { |
|
|
void refundLeftOrderAmount(BuyerPenaltyCalResult bpcr, BuyerOrder buyerOrder){
|
|
|
Integer sellerUid = buyerOrder.getSellerUid();
|
|
|
BigDecimal leftBuyerMoney = bpcr.getLeftAmount();
|
|
|
/*
|
|
|
BillLogEvent.BillLogEventBuilder blebOfBuyer = BillLogEvent.builder()
|
|
|
.buyerUid(buyerUid).sellerUid(sellerUid).orderCode(orderCode)
|
|
|
.payType(buyerOrder.getPayment()).refundCase(RefundCase.BUYER_GOODS_MONEY)
|
|
|
.amount(leftBuyerMoney)
|
|
|
.skup(skup);
|
|
|
*/
|
|
|
logger.info("in BuyerCancelAfterProcessTask call begin payRefundService.refund buyer, buyerUid {}, orderCode {}, skup {} refundAmount {}",
|
|
|
buyerUid, orderCode, skup, leftBuyerMoney );
|
|
|
|
|
|
new RefundGoodsMoneyHandler().loadLogger(logger)
|
|
|
.loadPaymentRequest(buyerUid,orderCode,leftBuyerMoney)
|
|
|
.loadBillLogEventBuilder(blebOfBuyer)
|
|
|
.loadPaymentRequest(buyerUid, orderCode, buyerOrder.getPayment(), leftBuyerMoney)
|
|
|
//.loadBillLogEventBuilder(blebOfBuyer)
|
|
|
.loadRefundAction(payRefundService::refund)
|
|
|
.loadTargetOrderStatus(targetOrderStatus)
|
|
|
.loadSellerOrderGoods(sellerUid, skup)
|
|
|
.refund();
|
|
|
logger.info("in BuyerCancelAfterProcessTask call after payRefundService.refund buyer, buyerUid {}, orderCode {}, skup {} refundAmount {}",
|
|
|
buyerUid, orderCode, skup, leftBuyerMoney );
|
...
|
...
|
|