Authored by chenchao

super entry seller

... ... @@ -16,6 +16,15 @@
from super_entry_seller
where uid = #{uid,jdbcType=INTEGER}
</select>
<select id="selectAll" parameterType="java.lang.Short" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from super_entry_seller
where status = #{status,jdbcType=SMALLINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from super_entry_seller
where uid = #{uid,jdbcType=INTEGER}
... ...
... ... @@ -16,6 +16,7 @@ import com.yohoufo.order.model.request.OrderRequest;
import com.yohoufo.order.model.response.OrderSubmitResp;
import com.yohoufo.order.service.handler.SellerOrderComputeHandler;
import com.yohoufo.order.service.impl.SellerOrderService;
import com.yohoufo.order.service.impl.SellerService;
import org.apache.kafka.common.requests.LeaderAndIsrRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
... ... @@ -279,4 +280,19 @@ public class SellerOrderController {
return new ApiResponse.ApiResponseBuilder().code(200).data(orderListInfoRsp).message("刷新成功").build();
}
@Autowired
private SellerService sellerService;
@RequestMapping(params = "method=ufo.order.isSurperEntrySeller")
@ResponseBody
public ApiResponse isSurperEntrySeller(
@RequestParam("uid") int uid) {
boolean isSuper = sellerService.isSuperEntrySeller(uid);
return new ApiResponse.ApiResponseBuilder().code(200).data(isSuper).message("刷新成功").build();
}
}
... ...
... ... @@ -19,4 +19,5 @@ public class BatchPublishTailEvent extends Event {
private SellerOrderSubmitHandler.ForkJoinResult fjr;
private SellerWallet sellerWallet;
private boolean isSurper;
}
... ...
package com.yohoufo.order.model.request;
import com.yohobuy.ufo.model.order.bo.MerchantOrderAttachInfo;
import com.yohoufo.dal.order.model.SellerWalletDetail;
import com.yohoufo.order.common.RefundCase;
import lombok.AllArgsConstructor;
import lombok.Data;
... ... @@ -34,4 +33,6 @@ public class PaymentRequest {
private RefundCase refundCase;
private MerchantOrderAttachInfo refundattch;
private boolean isSuper;
}
... ...
... ... @@ -80,7 +80,7 @@ public class SellerOrderCancelDeliverDelayMsgConsumer implements YhConsumer {
transferService.transfer(tmReq);
//
BigDecimal goodsMoney = buyerOrder.getAmount();
PaymentRequest req = PaymentRequest.builder().uid(buyerUid)
PaymentRequest req = PaymentRequest.builder().uid(buyerUid).refundCase(RefundCase.BUYER_GOODS_MONEY)
.orderCode(orderCode).refundAmount(goodsMoney.doubleValue())
.build();
BillLogEvent.BillLogEventBuilder bleb = BillLogEvent.builder()
... ...
... ... @@ -28,17 +28,19 @@ public class BatchPublishTailHandler implements IEventHandler<BatchPublishTailEv
@Override
@Subscribe
public void handle(BatchPublishTailEvent event) {
batchPublishTailProcess(event.getFjr(), event.getSellerWallet());
batchPublishTailProcess(event.getFjr(), event.getSellerWallet(), event.isSurper());
}
private void batchPublishTailProcess(SellerOrderSubmitHandler.ForkJoinResult fjr, SellerWallet sellerWallet){
private void batchPublishTailProcess(SellerOrderSubmitHandler.ForkJoinResult fjr, SellerWallet sellerWallet, boolean isSurper){
// (异步实现)记录保证金流水
List<OrderInfo> orderList = fjr.getSellerOrderList().parallelStream().map(sellerOrder ->
OrderInfo.builder().orderCode(sellerOrder.getOrderCode())
.amount(sellerOrder.getEarnestMoney()).build()
).collect(Collectors.toList());
merchantOrderPaymentService.useEarnestAddWalletDetail(sellerWallet, orderList);
if(!isSurper) {
List<OrderInfo> orderList = fjr.getSellerOrderList().parallelStream().map(sellerOrder ->
OrderInfo.builder().orderCode(sellerOrder.getOrderCode())
.amount(sellerOrder.getEarnestMoney()).build()
).collect(Collectors.toList());
merchantOrderPaymentService.useEarnestAddWalletDetail(sellerWallet, orderList);
}
//(异步实现)同步数据到prd,记录支付,
productProxyService.batchCreateSkup(fjr.getSellerOrderGoodsList());
productProxyService.sellerBatchUpdateStatus(fjr.getSkupIds(), ProductProxyService.PrdShelvelStatus.on);
... ...
... ... @@ -84,6 +84,9 @@ public class AppraiseService {
@Autowired
private CacheCleaner cacheCleaner;
@Autowired
private SellerService sellerService;
public ApiResponse appraiseSuccess(Integer expressCompanyId, Long orderCode, String wayBillCode,Integer depotNum){
ApiResponse apiResponse=new ApiResponse();
... ... @@ -152,15 +155,18 @@ public class AppraiseService {
*/
//refund earnestMoney
BigDecimal earnestMoney = sellerOrder.getEarnestMoney();
PaymentRequest req = PaymentRequest.builder().uid(sellerUid)
PaymentRequest refundReqOfSeller = PaymentRequest.builder().uid(sellerUid)
.refundCase(RefundCase.SELLER_EARNEST_MONEY)
.orderCode(sellerOrderCode).refundAmount(earnestMoney.doubleValue())
.build();
if (PaymentHelper.isWallet(sellerOrder.getPayment())){
boolean sellerIsSurper = sellerService.isSuperEntrySeller(sellerUid);
refundReqOfSeller.setSuper(sellerIsSurper);
if (!sellerIsSurper && PaymentHelper.isWallet(sellerOrder.getPayment())){
SellerWalletDetail.Type swdType = SellerWalletDetail.Type.APPRAISE_OK;
MerchantOrderAttachInfo moai = MerchantOrderAttachInfo.builder().uid(sellerUid)
.orderCode(sellerOrderCode).skup(skup).earnestMoney(sellerOrder.getEarnestMoney())
.type(swdType.getValue()).build();
req.setRefundattch(moai);
refundReqOfSeller.setRefundattch(moai);
}
BillLogEvent.BillLogEventBuilder bleb = BillLogEvent.builder()
... ... @@ -170,20 +176,21 @@ public class AppraiseService {
SellerOrderGoods sellerOrderGoods;
sellerOrderGoods = sellerOrderGoodsMapper.selectByPrimaryKey(skup);
try {
payRefundService.refund(req, bleb);
payRefundService.refund(refundReqOfSeller, bleb);
//通知卖家退还保证金
BuyerConfirmEvent buyerConfirmEvent = BuyerConfirmEvent.builder().uid(buyerUid).orderCode(orderCode).build();
EventBusPublisher.publishEvent(buyerConfirmEvent);
//记录物流信息
expressInfoService.appraiseSuccess(buyerUid, expressCompanyId, orderCode, wayBillCode, depotNum);
//平台已发货给买家
inBoxFacade.appraisePassNotice(buyerUid, orderCode, sellerOrderGoods);
}catch (Exception ex){
LOGGER.warn("in appraiseSuccess,refund fail, req {}", req, ex);
BillLogEvent sellerBillLogEvent = bleb.tradeStatus(BillTradeStatus.FAIL.getCode())
.build();
EventBusPublisher.publishEvent(sellerBillLogEvent);
LOGGER.warn("in appraiseSuccess,refund fail, refundReqOfSeller {}", refundReqOfSeller, ex);
if (!sellerIsSurper) {
BillLogEvent sellerBillLogEvent = bleb.tradeStatus(BillTradeStatus.FAIL.getCode())
.build();
EventBusPublisher.publishEvent(sellerBillLogEvent);
}
String content = "鉴定通过时,订单"+ orderCode + "退还保证金失败";
AlarmConfig alarmConfig = AlarmConfig.APPRAISE_SUCCESS;
SmsAlarmEvent smsAlarmEvent = new SmsAlarmEvent(alarmConfig.getRefundName(), alarmConfig.name(), content);
... ...
... ... @@ -28,7 +28,6 @@ import com.yohoufo.order.service.proxy.CouponProxyService;
import com.yohoufo.order.service.proxy.InBoxFacade;
import com.yohoufo.order.utils.LoggerUtils;
import com.yohoufo.order.utils.PaymentHelper;
import lombok.Data;
import lombok.Setter;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -78,6 +77,9 @@ public class BuyerOrderCancelService {
@Autowired
private InBoxFacade inBoxFacade;
@Autowired
private SellerService sellerService;
public void cancel(BeforeSellerDeliverEvent bsdEvent){
OrderDynamicConfig.BuyerCancelCompensateNode compensate = orderDynamicConfig.getBeforeSellerDeliverBCCN();
... ... @@ -210,34 +212,36 @@ public class BuyerOrderCancelService {
int sellerUid = sellerOrder.getUid();
long sellerOrderCode = sellerOrder.getOrderCode();
BigDecimal earnestMoney = sellerOrder.getEarnestMoney();
PaymentRequest req = PaymentRequest.builder().uid(sellerUid)
PaymentRequest refundReqOfSeller = PaymentRequest.builder().uid(sellerUid)
.orderCode(sellerOrderCode).refundAmount(earnestMoney.doubleValue())
.build();
if (PaymentHelper.isWallet(sellerOrder.getPayment())){
boolean sellerIsSurper = sellerService.isSuperEntrySeller(sellerUid);
refundReqOfSeller.setSuper(sellerIsSurper);
if (!sellerIsSurper && PaymentHelper.isWallet(sellerOrder.getPayment())){
MerchantOrderAttachInfo moai = MerchantOrderAttachInfo.builder().uid(sellerUid)
.orderCode(sellerOrderCode).skup(skup).earnestMoney(sellerOrder.getEarnestMoney())
.type(swdType.getValue()).build();
req.setRefundattch(moai);
refundReqOfSeller.setRefundattch(moai);
}
BillLogEvent.BillLogEventBuilder bleb = BillLogEvent.builder()
.buyerUid(buyerUid).sellerUid(sellerUid).orderCode(sellerOrder.getOrderCode())
.payType(sellerOrder.getPayment()).refundCase(RefundCase.SELLER_EARNEST_MONEY)
.skup(skup);
logger.info("in BuyerCancelAfterProcessTask call begin payRefundService.refund seller, buyerUid {}, orderCode {}, skup {} req {}",
buyerUid, orderCode, skup, req );
prb = payRefundService.refund(req, bleb);
logger.info("in BuyerCancelAfterProcessTask call after payRefundService.refund seller, buyerUid {}, orderCode {}, skup {} req {}",
buyerUid, orderCode, skup, req );
logger.info("in BuyerCancelAfterProcessTask call begin payRefundService.refund seller, buyerUid {}, orderCode {}, skup {} refundReqOfSeller {}",
buyerUid, orderCode, skup, refundReqOfSeller );
prb = payRefundService.refund(refundReqOfSeller, bleb);
logger.info("in BuyerCancelAfterProcessTask call after payRefundService.refund seller, buyerUid {}, orderCode {}, skup {} refundReqOfSeller {}",
buyerUid, orderCode, skup, refundReqOfSeller );
//(转账)瓜分指定赔偿款给卖家和平台
TransferMoneyRequest tmReq = TransferMoneyRequest.builder().buyerOrderCode(orderCode)
.type(transferCase.getCode()).transferCase(transferCase).build();
logger.info("in BuyerCancelAfterProcessTask call begin paymentService.transferMon, buyerUid {}, orderCode {}, skup {} req {}",
logger.info("in BuyerCancelAfterProcessTask call begin paymentService.transferMon, buyerUid {}, orderCode {}, skup {} refundReqOfSeller {}",
buyerUid, orderCode, skup, tmReq );
paymentService.transferMon(tmReq);
logger.info("in BuyerCancelAfterProcessTask call after paymentService.transferMon, buyerUid {}, orderCode {}, skup {} req {}",
logger.info("in BuyerCancelAfterProcessTask call after paymentService.transferMon, buyerUid {}, orderCode {}, skup {} refundReqOfSeller {}",
buyerUid, orderCode, skup, tmReq );
//(退费)扣除赔偿款,计算剩余的货款,退给买家
... ... @@ -253,10 +257,10 @@ public class BuyerOrderCancelService {
.buyerUid(buyerUid).sellerUid(sellerUid).orderCode(orderCode)
.payType(buyerOrder.getPayment()).refundCase(RefundCase.BUYER_GOODS_MONEY)
.skup(skup);
logger.info("in BuyerCancelAfterProcessTask call begin payRefundService.refund buyer, buyerUid {}, orderCode {}, skup {} req {}",
logger.info("in BuyerCancelAfterProcessTask call begin payRefundService.refund buyer, buyerUid {}, orderCode {}, skup {} refundReqOfSeller {}",
buyerUid, orderCode, skup, rprOfBuyer );
payRefundService.refund(rprOfBuyer, blebOfBuyer);
logger.info("in BuyerCancelAfterProcessTask call after payRefundService.refund buyer, buyerUid {}, orderCode {}, skup {} req {}",
logger.info("in BuyerCancelAfterProcessTask call after payRefundService.refund buyer, buyerUid {}, orderCode {}, skup {} refundReqOfSeller {}",
buyerUid, orderCode, skup, rprOfBuyer );
logger.info("out BuyerCancelAfterProcessTask call buyerUid {}, orderCode {}, skup {}, transferCase {}, compensate {}",
... ...
... ... @@ -2,6 +2,7 @@ package com.yohoufo.order.service.impl;
import com.yohoufo.common.alarm.EventBusPublisher;
import com.yohoufo.order.common.BillTradeStatus;
import com.yohoufo.order.common.RefundCase;
import com.yohoufo.order.constants.RefundContant;
import com.yohoufo.order.event.BillLogEvent;
import com.yohoufo.order.model.PayRefundBo;
... ... @@ -25,12 +26,19 @@ public class PayRefundService {
public PayRefundBo refund(PaymentRequest refundReq, BillLogEvent.BillLogEventBuilder bleBuilder){
logger.info("in pay refund, refundReq {}", refundReq);
boolean toSeller = refundReq.getRefundCase() !=null && RefundCase.SELLER_EARNEST_MONEY == refundReq.getRefundCase();
if(refundReq.isSuper() && toSeller){
return null;
}
PayRefundBo refundResp = paymentService.refund(refundReq);
BillLogEvent buyererBillLogEvent;
int status ;
int status;
if (refundReq != null && RefundContant.PAYMENT_REFUND_RESULTCODE_SUCCESS == refundResp.getRefundStatus()) {
status = BillTradeStatus.SUCCESS.getCode();
}else{
} else {
status = BillTradeStatus.FAIL.getCode();
}
buyererBillLogEvent = bleBuilder.tradeStatus(status).build();
... ...
... ... @@ -86,6 +86,9 @@ public class SellerOrderCancelService {
@Autowired
private PayRefundService payRefundService;
@Autowired
private SellerService sellerService;
/**
* TODO 如何控制好并发,必须控制不能重复转账 退款
* 使用乐观锁,带着查询到的状态且符合条件时再去更新
... ... @@ -281,7 +284,6 @@ public class SellerOrderCancelService {
}
private int cancelAfterPayButNotBuyAction(SellerOrder sellerOrder){
/**case 2: 支付完成,没有买家下单
* actions as blow:
... ... @@ -303,10 +305,12 @@ public class SellerOrderCancelService {
if(result > 0 ){
double earnestMoney = sellerOrder.getEarnestMoney().doubleValue();
boolean isSurper = sellerService.isSuperEntrySeller(sellerUid);
PaymentRequest refundReq = PaymentRequest.builder().uid(sellerUid)
.orderCode(orderCode)
.orderCode(orderCode).isSuper(isSurper)
.refundAmount(earnestMoney).build();
if (PaymentHelper.isWallet(sellerOrder.getPayment())){
if (!isSurper && PaymentHelper.isWallet(sellerOrder.getPayment())){
SellerWalletDetail.Type swdType = SellerWalletDetail.Type.SELLER_OFF;
MerchantOrderAttachInfo moai = MerchantOrderAttachInfo.builder().uid(sellerUid)
.orderCode(orderCode).skup(skup).earnestMoney(sellerOrder.getEarnestMoney())
... ... @@ -326,9 +330,11 @@ public class SellerOrderCancelService {
sellerUid, orderCode, skup, earnestMoney);
}catch (Exception ex){
logger.warn("in appraiseSuccess, refund fail, req {}", refundReq, ex);
BillLogEvent sellerBillLogEvent = bleb.tradeStatus(BillTradeStatus.FAIL.getCode())
.build();
EventBusPublisher.publishEvent(sellerBillLogEvent);
if (!isSurper) {
BillLogEvent sellerBillLogEvent = bleb.tradeStatus(BillTradeStatus.FAIL.getCode())
.build();
EventBusPublisher.publishEvent(sellerBillLogEvent);
}
String content = "用户" + sellerUid + "退保证金订单"+ orderCode +"失败";
SmsAlarmEvent smsAlarmEvent = new SmsAlarmEvent("notPaidSellerOrder.selfCancel", "cancelBeforeBuy", content);
EventBusPublisher.publishEvent(smsAlarmEvent);
... ... @@ -393,7 +399,8 @@ public class SellerOrderCancelService {
BigDecimal goodsMoney = buyerOrder.getAmount();
PaymentRequest refundReq = PaymentRequest.builder().uid(buyerUid)
.orderCode(buyerOrderCode).refundAmount(goodsMoney.doubleValue())
.orderCode(buyerOrderCode).refundCase(RefundCase.BUYER_GOODS_MONEY)
.refundAmount(goodsMoney.doubleValue())
.build();
BillLogEvent.BillLogEventBuilder bleb = BillLogEvent.builder()
.buyerUid(buyerUid).sellerUid(sellerUid).orderCode(buyerOrderCode)
... ... @@ -552,7 +559,10 @@ public class SellerOrderCancelService {
.orderCode(orderCode)
.refundAmount(earnestMoney).build();
Integer payment = sellerOrder.getPayment();
if(PaymentHelper.isWallet(payment)){
boolean sellerIsSurper = sellerService.isSuperEntrySeller(sellerUid);
refundReq.setSuper(sellerIsSurper);
//
if(!sellerIsSurper && PaymentHelper.isWallet(payment)){
MerchantOrderAttachInfo moai = MerchantOrderAttachInfo.builder().uid(sellerUid)
.orderCode(orderCode).skup(skup).earnestMoney(sellerOrder.getEarnestMoney())
.type(SellerWalletDetail.Type.SYSTEM_OFF.getValue()).build();
... ... @@ -572,9 +582,11 @@ public class SellerOrderCancelService {
}catch (Exception ex){
logger.warn("in yoho Off Shelve Cancel, refund earnestMoney fail, seller {}, order code {}, skup {}, earnestMoney {}",
sellerUid, orderCode, skup, earnestMoney, ex);
BillLogEvent sellerBillLogEvent = bleb.tradeStatus(BillTradeStatus.FAIL.getCode())
.build();
EventBusPublisher.publishEvent(sellerBillLogEvent);
if(!sellerIsSurper) {
BillLogEvent sellerBillLogEvent = bleb.tradeStatus(BillTradeStatus.FAIL.getCode())
.build();
EventBusPublisher.publishEvent(sellerBillLogEvent);
}
String content = "下架skup时,退用户" + sellerUid + "保证金订单"+ orderCode +"失败";
SmsAlarmEvent smsAlarmEvent = new SmsAlarmEvent("PaidSellerOrder.PlatformCancel", "cancelBeforeBuy", content);
EventBusPublisher.publishEvent(smsAlarmEvent);
... ...
... ... @@ -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());;
merchantOrderPaymentService.unshelveAddWalletDetail(sellerWallet, orderList);
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);
List<OrderInfo> orderList = psoList.parallelStream().map(
so-> OrderInfo.builder().orderCode(so.getOrderCode()).amount(diffEarnestMoney).build())
.collect(Collectors.toList());
merchantOrderPaymentService.changePriceAddWalletDetail(sellerWallet, orderList );
if(!isSurper) {
List<OrderInfo> orderList = psoList.parallelStream().map(
so -> OrderInfo.builder().orderCode(so.getOrderCode()).amount(diffEarnestMoney).build())
.collect(Collectors.toList());
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){
... ...