...
|
...
|
@@ -8,15 +8,18 @@ import com.yohoufo.dal.order.BuyerOrderMapper; |
|
|
import com.yohoufo.dal.order.OrderCouponMapper;
|
|
|
import com.yohoufo.dal.order.SellerOrderGoodsMapper;
|
|
|
import com.yohoufo.dal.order.SellerOrderMapper;
|
|
|
import com.yohoufo.dal.order.model.BuyerOrder;
|
|
|
import com.yohoufo.dal.order.model.OrderCoupon;
|
|
|
import com.yohoufo.dal.order.model.SellerOrder;
|
|
|
import com.yohoufo.dal.order.model.SellerOrderGoods;
|
|
|
import com.yohoufo.order.common.RefundCase;
|
|
|
import com.yohoufo.order.common.TransferCase;
|
|
|
import com.yohoufo.order.event.BeforeDepotReceiveEvent;
|
|
|
import com.yohoufo.order.event.BeforeSellerDeliverEvent;
|
|
|
import com.yohoufo.order.event.BillLogEvent;
|
|
|
import com.yohoufo.order.model.bo.CouponBo;
|
|
|
import com.yohoufo.order.model.request.PaymentRequest;
|
|
|
import com.yohoufo.order.model.request.TransferMoneyRequest;
|
|
|
import com.yohoufo.order.service.IPaymentService;
|
|
|
import com.yohoufo.order.service.concurrent.ThreadPoolFactory;
|
|
|
import com.yohoufo.order.service.proxy.CouponProxyService;
|
...
|
...
|
@@ -85,23 +88,14 @@ public class BuyerOrderCancelService { |
|
|
|
|
|
//TODO 整个过程异步去执行(考虑退费依赖订单状态)
|
|
|
//(退费)退保证金给卖家
|
|
|
SellerOrder sellerOrder = sellerOrderMapper.selectByOrderCode(orderCode);
|
|
|
int sellerUid = sellerOrder.getUid();
|
|
|
long sellerOrderCode = sellerOrder.getOrderCode();
|
|
|
BigDecimal earnestMoney = sellerOrder.getEarnestMoney();
|
|
|
PaymentRequest req = PaymentRequest.builder().uid(sellerUid)
|
|
|
.orderCode(sellerOrderCode).refundAmount(earnestMoney.doubleValue())
|
|
|
.build();
|
|
|
BillLogEvent.BillLogEventBuilder bleb = BillLogEvent.builder()
|
|
|
.buyerUid(buyerUid).sellerUid(sellerUid).orderCode(sellerOrder.getOrderCode())
|
|
|
.payType(sellerOrder.getPayment()).refundCase(RefundCase.SELLER_EARNEST_MONEY)
|
|
|
.skup(skup);
|
|
|
payRefundService.refund(req, bleb);
|
|
|
|
|
|
//(转账)瓜分指定赔偿款给卖家和平台
|
|
|
TransferCase transferCase = TransferCase.BUYER_CANCEL_BEFORE_SELLER_DELIVER;
|
|
|
//(退费)扣除赔偿款,计算剩余的货款,退给买家
|
|
|
BuyerCancelAfterProcessTask bcapt = new BuyerCancelAfterProcessTask();
|
|
|
BuyerCancelAfterProcessTask bcapt = new BuyerCancelAfterProcessTask(buyerUid, orderCode, skup,
|
|
|
compensate, transferCase);
|
|
|
ThreadPoolFactory.getBuyerCancelThreadPool().submit(bcapt);
|
|
|
logger.info("use one thread to execute buyer cancel BeforeSellerDeliver buyerUid {}, orderCode {}, skup {}, compensate {}, transferCase {}",
|
|
|
buyerUid, orderCode, skup, compensate, transferCase);
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
@@ -124,18 +118,73 @@ public class BuyerOrderCancelService { |
|
|
targetGoods.setExceptStatus(SkupStatus.SELL_OUT.getCode());
|
|
|
sellerOrderGoodsMapper.updateStatusBySkpu(targetGoods);
|
|
|
|
|
|
//TODO 整个过程异步去执行(考虑退费依赖订单状态)
|
|
|
//整个过程异步去执行(考虑退费依赖订单状态)
|
|
|
//(退费)退保证金给卖家
|
|
|
|
|
|
//(转账)瓜分指定赔偿款给卖家和平台
|
|
|
//(退费)扣除赔偿款,计算剩余的货款,退给买家
|
|
|
TransferCase transferCase = TransferCase.BUYER_CANCEL_BEFORE_DEPOT_RECEIVE;
|
|
|
BuyerCancelAfterProcessTask bcapt = new BuyerCancelAfterProcessTask(buyerUid, orderCode, skup,
|
|
|
compensate, transferCase);
|
|
|
ThreadPoolFactory.getBuyerCancelThreadPool().submit(bcapt);
|
|
|
logger.info("use one thread to execute buyer cancel BeforeDepotReceive buyerUid {}, orderCode {}, skup {}, compensate {}, transferCase {}",
|
|
|
buyerUid, orderCode, skup, compensate, transferCase);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
class BuyerCancelAfterProcessTask implements Callable{
|
|
|
int buyerUid;
|
|
|
long orderCode;
|
|
|
int skup;
|
|
|
OrderDynamicConfig.BuyerCancelCompensateNode compensate;
|
|
|
TransferCase transferCase;
|
|
|
|
|
|
public BuyerCancelAfterProcessTask(int buyerUid, long orderCode, int skup, OrderDynamicConfig.
|
|
|
BuyerCancelCompensateNode compensate, TransferCase transferCase) {
|
|
|
this.buyerUid = buyerUid;
|
|
|
this.orderCode = orderCode;
|
|
|
this.skup = skup;
|
|
|
this.compensate = compensate;
|
|
|
this.transferCase = transferCase;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public Object call() throws Exception {
|
|
|
// 整个过程异步去执行(考虑退费依赖订单状态)
|
|
|
//(退费)退保证金给卖家
|
|
|
SellerOrder sellerOrder = sellerOrderMapper.selectByOrderCode(orderCode);
|
|
|
int sellerUid = sellerOrder.getUid();
|
|
|
long sellerOrderCode = sellerOrder.getOrderCode();
|
|
|
BigDecimal earnestMoney = sellerOrder.getEarnestMoney();
|
|
|
PaymentRequest req = PaymentRequest.builder().uid(sellerUid)
|
|
|
.orderCode(sellerOrderCode).refundAmount(earnestMoney.doubleValue())
|
|
|
.build();
|
|
|
BillLogEvent.BillLogEventBuilder bleb = BillLogEvent.builder()
|
|
|
.buyerUid(buyerUid).sellerUid(sellerUid).orderCode(sellerOrder.getOrderCode())
|
|
|
.payType(sellerOrder.getPayment()).refundCase(RefundCase.SELLER_EARNEST_MONEY)
|
|
|
.skup(skup);
|
|
|
payRefundService.refund(req, bleb);
|
|
|
|
|
|
//(转账)瓜分指定赔偿款给卖家和平台
|
|
|
|
|
|
TransferMoneyRequest tmReq = TransferMoneyRequest.builder().buyerOrderCode(orderCode)
|
|
|
.type(transferCase.getCode()).transferCase(transferCase).build();
|
|
|
paymentService.transferMon(tmReq);
|
|
|
|
|
|
//(退费)扣除赔偿款,计算剩余的货款,退给买家
|
|
|
BigDecimal compensateMoney = compensate.getBuyerCompensateMoney();
|
|
|
|
|
|
|
|
|
BuyerOrder buyerOrder = buyerOrderMapper.selectByOrderCode(orderCode);
|
|
|
BigDecimal leftBuyerMoney = buyerOrder.getAmount().subtract(compensateMoney);
|
|
|
PaymentRequest rprOfBuyer = PaymentRequest.builder().uid(buyerUid)
|
|
|
.orderCode(orderCode).refundAmount(leftBuyerMoney.doubleValue())
|
|
|
.build();
|
|
|
BillLogEvent.BillLogEventBuilder blebOfBuyer = BillLogEvent.builder()
|
|
|
.buyerUid(buyerUid).sellerUid(sellerUid).orderCode(orderCode)
|
|
|
.payType(buyerOrder.getPayment()).refundCase(RefundCase.BUYER_GOODS_MONEY)
|
|
|
.skup(skup);
|
|
|
payRefundService.refund(rprOfBuyer, blebOfBuyer);
|
|
|
|
|
|
return null;
|
|
|
}
|
|
|
}
|
...
|
...
|
|