...
|
...
|
@@ -248,11 +248,15 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi |
|
|
@Autowired
|
|
|
private InBoxFacade inBoxFacade;
|
|
|
|
|
|
@Autowired
|
|
|
private SellerService sellerService;
|
|
|
|
|
|
public OrderSubmitResp batchPublishPrds(SellerOrderContext ctx, SellerOrderSubmitReq req) throws GatewayException {
|
|
|
// 一串校验
|
|
|
//扣减保证金
|
|
|
final int num = req.getNum();
|
|
|
int uid = req.getUid();
|
|
|
boolean isSurper = sellerService.isSuperEntrySeller(uid);
|
|
|
SellerOrderComputeResult socr = ctx.getSellerOrderComputeResult();
|
|
|
BigDecimal singleEarestMoney = socr.getEarnestMoney().getEarnestMoney();
|
|
|
BigDecimal mEarestMoney = sellerOrderPrepareProcessor.checkNGetMergeEarnestMoney(uid, singleEarestMoney, num, ctx.getSalePrice());
|
...
|
...
|
@@ -260,7 +264,7 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi |
|
|
MerchantOrderAttachInfo moai = MerchantOrderAttachInfo.builder().uid(uid)
|
|
|
.storageId(ctx.getStorageId()).earnestMoney(mEarestMoney)
|
|
|
.type(swdType.getValue()).build();
|
|
|
SellerWallet sellerWallet = merchantOrderPaymentService.useEarnest(uid, mEarestMoney, moai);
|
|
|
SellerWallet sellerWallet = isSurper ? new SellerWallet() : merchantOrderPaymentService.useEarnest(uid, mEarestMoney, moai);
|
|
|
// invoke pay by wallet
|
|
|
boolean paySuccess = Objects.nonNull(sellerWallet);
|
|
|
if (!paySuccess){
|
...
|
...
|
@@ -281,7 +285,7 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi |
|
|
forkNum = num - (i-1) * MAX_DEAL;
|
|
|
}
|
|
|
log.info("batch publish uid {} storageId {} forkNum {} num {}", uid, req.getStorageId(), forkNum, num);
|
|
|
BatchProcessTask batchProcessTask = new BatchProcessTask(ctx, cdl, forkNum, sellerWallet);
|
|
|
BatchProcessTask batchProcessTask = new BatchProcessTask(ctx, cdl, forkNum, sellerWallet, isSurper);
|
|
|
ForkJoinTask<SellerOrderSubmitHandler.ForkJoinResult> fjt = ThreadPoolFactory.getForkJoinPool().submit(batchProcessTask);
|
|
|
taskList.add(fjt);
|
|
|
}
|
...
|
...
|
@@ -334,11 +338,13 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi |
|
|
totalRefundEM = totalRefundEM.add(so.getEarnestMoney());
|
|
|
}
|
|
|
SellerWalletDetail.Type swdType = SellerWalletDetail.Type.SELLER_OFF;
|
|
|
MerchantOrderAttachInfo moai = MerchantOrderAttachInfo.builder().uid(req.getUid())
|
|
|
int uid = req.getUid();
|
|
|
boolean isSurper = sellerService.isSuperEntrySeller(uid);
|
|
|
MerchantOrderAttachInfo moai = MerchantOrderAttachInfo.builder().uid(uid)
|
|
|
.earnestMoney(totalRefundEM).productCount(needCancelSkups.size())
|
|
|
.seriNo(String.valueOf(batchNo))
|
|
|
.type(swdType.getValue()).build();
|
|
|
SellerWallet sellerWallet = merchantOrderPaymentService.refundEarnest(req.getUid(), totalRefundEM, moai, 0L, SellerWalletDetail.Type.SELLER_OFF );
|
|
|
SellerWallet sellerWallet = isSurper? new SellerWallet() : merchantOrderPaymentService.refundEarnest(req.getUid(), totalRefundEM, moai, 0L, SellerWalletDetail.Type.SELLER_OFF );
|
|
|
//2.1 划账成功
|
|
|
if (Objects.nonNull(sellerWallet)) {
|
|
|
// 3 修改 seller_order(状态)sell_order_goods(状态)
|
...
|
...
|
@@ -355,9 +361,11 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi |
|
|
sellerOrderGoodsMapper.updateByPrimaryKeys(sogc, needCancelSkups);
|
|
|
|
|
|
//4 划账记录
|
|
|
List<OrderInfo> orderList = soList.parallelStream().map(so->OrderInfo.builder()
|
|
|
.orderCode(so.getOrderCode()).amount(so.getEarnestMoney()).build()).collect(Collectors.toList());;
|
|
|
if (!isSurper) {
|
|
|
List<OrderInfo> orderList = soList.parallelStream().map(so -> OrderInfo.builder()
|
|
|
.orderCode(so.getOrderCode()).amount(so.getEarnestMoney()).build()).collect(Collectors.toList());
|
|
|
merchantOrderPaymentService.unshelveAddWalletDetail(sellerWallet, orderList);
|
|
|
}
|
|
|
SkupDto skupDto = tskupMap.values().iterator().next();
|
|
|
SellerOrderGoods sellerOrderGoods = skupDto.getSellerOrderGoods();
|
|
|
inBoxFacade.sellerPlaySelf(sellerOrderGoods.getUid(), sellerOrderGoods.getProductName());
|
...
|
...
|
@@ -575,8 +583,8 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi |
|
|
.earnestMoney(totalDiffMoney).productCount(skupMap.size())
|
|
|
.seriNo(String.valueOf(req.getBatchNo()))
|
|
|
.type(swdType.getValue()).build();
|
|
|
|
|
|
SellerWallet sellerWallet = merchantOrderPaymentService.changePriceUseEarnest(uid, totalDiffMoney, moai);
|
|
|
boolean isSurper = sellerService.isSuperEntrySeller(uid);
|
|
|
SellerWallet sellerWallet = isSurper ? new SellerWallet() : merchantOrderPaymentService.changePriceUseEarnest(uid, totalDiffMoney, moai);
|
|
|
int successCnt = 0;
|
|
|
int failCnt = 0;
|
|
|
if(Objects.nonNull(sellerWallet)) {
|
...
|
...
|
@@ -600,10 +608,12 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi |
|
|
|
|
|
//4 划账记录
|
|
|
List<SellerOrder> psoList = sellerOrderMapper.selectBySkups(skupSet);
|
|
|
if(!isSurper) {
|
|
|
List<OrderInfo> orderList = psoList.parallelStream().map(
|
|
|
so-> OrderInfo.builder().orderCode(so.getOrderCode()).amount(diffEarnestMoney).build())
|
|
|
so -> OrderInfo.builder().orderCode(so.getOrderCode()).amount(diffEarnestMoney).build())
|
|
|
.collect(Collectors.toList());
|
|
|
merchantOrderPaymentService.changePriceAddWalletDetail(sellerWallet, orderList );
|
|
|
merchantOrderPaymentService.changePriceAddWalletDetail(sellerWallet, orderList);
|
|
|
}
|
|
|
successCnt = skupMap.size();
|
|
|
List<RedisKeyBuilder> skupDetailRKBs = getSkupDetailRKBs(skupMap);
|
|
|
skupDetailRKBs.add(CacheKeyBuilder.orderListKey(req.getUid(), TabType.SELL.getValue()));
|
...
|
...
|
@@ -650,11 +660,15 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi |
|
|
|
|
|
private SellerWallet sellerWallet;
|
|
|
|
|
|
public BatchProcessTask(SellerOrderContext ctx, CountDownLatch countDownLatch, int num, SellerWallet sellerWallet) {
|
|
|
private boolean isSurper;
|
|
|
|
|
|
public BatchProcessTask(SellerOrderContext ctx, CountDownLatch countDownLatch,
|
|
|
int num, SellerWallet sellerWallet, boolean isSurper) {
|
|
|
this.ctx = ctx;
|
|
|
this.countDownLatch = countDownLatch;
|
|
|
this.num = num;
|
|
|
this.sellerWallet = sellerWallet;
|
|
|
this.isSurper = isSurper;
|
|
|
}
|
|
|
|
|
|
@Override
|
...
|
...
|
@@ -670,7 +684,8 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi |
|
|
cacheCleaner.cleanList(uid, TabType.SELL.getValue());
|
|
|
// (异步实现)记录保证金流水
|
|
|
//(异步实现)同步数据到prd,记录支付,
|
|
|
BatchPublishTailEvent bpte = BatchPublishTailEvent.builder().fjr(fjr).sellerWallet(sellerWallet).build();
|
|
|
BatchPublishTailEvent bpte = BatchPublishTailEvent.builder().isSurper(isSurper)
|
|
|
.fjr(fjr).sellerWallet(sellerWallet).build();
|
|
|
EventBusPublisher.publishEvent(bpte);
|
|
|
countDownLatch.countDown();
|
|
|
}catch (Exception ex){
|
...
|
...
|
|