Authored by LUOXC

卖家无法发货

... ... @@ -23,6 +23,7 @@ import com.yohoufo.order.common.TransferCase;
import com.yohoufo.order.constants.AlarmConfig;
import com.yohoufo.order.event.BillLogEvent;
import com.yohoufo.order.service.cache.CacheCleaner;
import com.yohoufo.order.service.impl.function.BuyerOrderNoticeSender;
import com.yohoufo.order.service.listener.BuyerOrderChangeEvent;
import com.yohoufo.order.event.BuyerRefundCouponEvent;
import com.yohoufo.order.model.request.PaymentRequest;
... ... @@ -139,7 +140,11 @@ class BuyerOrderCancelHandler {
}
public NoticeBuyer withNoticeBuyer(BuyerNoticeSender buyerNoticeSender) {
return new NoticeBuyer(buyerNoticeSender);
return new NoticeBuyer().buyerNoticeSender(buyerNoticeSender);
}
public NoticeBuyer withNoticeBuyer(BuyerOrderNoticeSender buyerOrderNoticeSender) {
return new NoticeBuyer().buyerOrderNoticeSender(buyerOrderNoticeSender);
}
public RecordSuppleExpress withRecordSuppleExpress(RecordSuppleExpressSender recordSuppleExpressSender) {
... ... @@ -163,6 +168,7 @@ class BuyerOrderCancelHandler {
/**
* 异步事件
*
* @param orderChangeListenerContainer
* @return
*/
... ... @@ -413,15 +419,20 @@ class BuyerOrderCancelHandler {
}
private void noticeBuyer(BuyerOrder buyerOrder, BuyerOrderGoods buyerOrderGoods) {
NoticeBuyer noticeBuyer = this.noticeBuyer;
if (Objects.nonNull(noticeBuyer)) {
log.info("notice buyer order has closed by order {}", orderCode);
try {
BuyerNoticeSender.Request request = BuyerNoticeSender.Request.builder()
.uid(buyerOrder.getUid())
.orderCode(buyerOrder.getOrderCode())
.goodsAmount(buyerOrderGoods.getGoodsAmount())
.build();
noticeBuyer.buyerNoticeSender().notice(request);
if (Objects.nonNull(noticeBuyer.buyerNoticeSender())) {
BuyerNoticeSender.Request request = BuyerNoticeSender.Request.builder()
.uid(buyerOrder.getUid())
.orderCode(buyerOrder.getOrderCode())
.goodsAmount(buyerOrderGoods.getGoodsAmount())
.build();
noticeBuyer.buyerNoticeSender().notice(request);
} else {
noticeBuyer.buyerOrderNoticeSender().notice(buyerOrder);
}
} catch (Exception e) {
log.warn("notice buyer order has closed by order {} fail", orderCode, e);
}
... ... @@ -441,6 +452,7 @@ class BuyerOrderCancelHandler {
/**
* 订单取消异步事件
*
* @param buyerOrder
*/
public void fireAsyncCancelEvent(BuyerOrder buyerOrder) {
... ... @@ -493,7 +505,9 @@ class BuyerOrderCancelHandler {
@Accessors(fluent = true)
class NoticeBuyer {
private final BuyerNoticeSender buyerNoticeSender;
private BuyerNoticeSender buyerNoticeSender;
private BuyerOrderNoticeSender buyerOrderNoticeSender;
BuyerOrderCancelHandler and() {
BuyerOrderCancelHandler.this.noticeBuyer = this;
... ...
... ... @@ -3,6 +3,7 @@ package com.yohoufo.order.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Lists;
import com.yoho.core.rabbitmq.YhProducer;
import com.yohobuy.ufo.model.enums.InboxBusinessTypeEnum;
import com.yohobuy.ufo.model.order.bo.CustomsClearanceResult;
import com.yohobuy.ufo.model.order.bo.MerchantOrderAttachInfo;
import com.yohobuy.ufo.model.order.common.OrderStatus;
... ... @@ -157,21 +158,21 @@ public class BuyerOrderCancelService {
private BuyerOrderAssistant buyerOrderAssistant;
public int cancel(BeforeSellerDeliverEvent bsdEvent){
public int cancel(BeforeSellerDeliverEvent bsdEvent) {
int buyerUid = bsdEvent.getBuyerUid();
int sellerUid = bsdEvent.getSellerUid();
long orderCode = bsdEvent.getOrderCode();
OrderStatus targetOrderStatus = bsdEvent.getTarget();
BuyerOrder buyerOrder = buyerOrderMapper.selectByOrderCode(orderCode);
BuyerOrderGoods buyerOrderGoods = buyerOrderGoodsMapper.selectByOrderCode(buyerOrder.getUid(),buyerOrder.getOrderCode());
BuyerOrderGoods buyerOrderGoods = buyerOrderGoodsMapper.selectByOrderCode(buyerOrder.getUid(), buyerOrder.getOrderCode());
logger.info("in buyer cancel BeforeSellerDeliver begin buyerOrderMapper.selectByOrderCode, buyerUid {}, orderCode {}, skup {} buyerOrder {}",
buyerUid, orderCode, buyerOrder );
BuyerPenaltyCalResult bpcr = buyerCancelCompensateComputeHandler.calBuyerPenaltyCalResult(buyerOrder,buyerOrderGoods, targetOrderStatus);
buyerUid, orderCode, buyerOrder);
BuyerPenaltyCalResult bpcr = buyerCancelCompensateComputeHandler.calBuyerPenaltyCalResult(buyerOrder, buyerOrderGoods, targetOrderStatus);
logger.info("in buyer cancel BeforeSellerDeliver, event {} BuyerPenaltyCalResult {}", bsdEvent, bpcr);
//买家实付金额(货款+运费)小于赔偿金的额度,不够赔偿的,则不允许取消
BigDecimal penaltyAmount;
Pair<Boolean,UfoServiceException> penaltyAmountIsEnough = checkPenaltyAmount(bsdEvent.getAmount(), penaltyAmount=bpcr.getPenaltyAmount());
if(!penaltyAmountIsEnough.getLeft()){
Pair<Boolean, UfoServiceException> penaltyAmountIsEnough = checkPenaltyAmount(bsdEvent.getAmount(), penaltyAmount = bpcr.getPenaltyAmount());
if (!penaltyAmountIsEnough.getLeft()) {
logger.warn("in buyer cancel BeforeSellerDeliver not allow cancel cause of buyer amount lower than BuyerCompensateMoney, event {} compensate {}", bsdEvent, bpcr);
throw penaltyAmountIsEnough.getRight();
}
... ... @@ -180,9 +181,9 @@ public class BuyerOrderCancelService {
OrderStatus expected = bsdEvent.getExpected();
int currentTime = DateUtil.getCurrentTimeSecond();
int rows = buyerOrderMapper.updateStatusByOrderCode(orderCode, buyerUid, expected.getCode(), targetOrderStatus.getCode(), currentTime);
if (rows>0) {
if (rows > 0) {
boolean noResponsibility = Objects.isNull(penaltyAmount)
|| BigDecimal.ZERO.compareTo(penaltyAmount) == 0;
|| BigDecimal.ZERO.compareTo(penaltyAmount) == 0;
//退还优惠券
asyncRefundCoupon(buyerUid, orderCode, BuyerRefundCouponEvent.BizCase.BUYER_CANCEL_BSD);
int skup = bsdEvent.getSkup();
... ... @@ -191,7 +192,7 @@ public class BuyerOrderCancelService {
int targetSellerOrderStatus = SellerOrderStatus.BUYER_CANCEL_BEFORE_SELLER_DELIVER.getCode();
//重新上架标志 求购不需要自动上架
boolean reSellAfterCancel = !psog.isBidSkup() && (OrderAssist.skupIsCommonInStock(psog.getAttributes()) || OrderAssist.skupIsAdvance(psog.getAttributes()));
if(reSellAfterCancel){
if (reSellAfterCancel) {
targetGoodsStatus = SkupStatus.CAN_SELL.getCode();
targetSellerOrderStatus = SellerOrderStatus.HAS_PAYED.getCode();
}
... ... @@ -204,22 +205,22 @@ public class BuyerOrderCancelService {
logger.info("in buyer cancel BeforeSellerDeliver reSellAfterCancel {}, buyerUid {}, orderCode {}, skup {} buyerOrder {}",
reSellAfterCancel, buyerUid, orderCode, skup, buyerOrder);
if(reSellAfterCancel){
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{
logger.info("in buyer cancel BeforeSellerDeliver returnStorage {} reSellAfterCancel {}, buyerUid {}, orderCode {}, skup {} buyerOrder {}", isReturnSuccess,
reSellAfterCancel, buyerUid, orderCode, buyerOrder);
} else {
SellerOrder soc = new SellerOrder();
soc.setStatus(targetSellerOrderStatus);
soc.setUpdateTime(DateUtil.getCurrentTimeSecond());
sellerOrderMapper.updateBySkups(soc, Arrays.asList(skup));
}
if (noResponsibility){
sellerNoticeFacade.noticeSellerWhenBuyerCancelNoResponsibility(psog, orderCode,reSellAfterCancel);
}else {
inBoxFacade.buyerCancelBeforeSellerDeliver(buyerOrder, penaltyAmount.toPlainString(), psog,reSellAfterCancel);
if (noResponsibility) {
sellerNoticeFacade.noticeSellerWhenBuyerCancelNoResponsibility(psog, orderCode, reSellAfterCancel);
} else {
inBoxFacade.buyerCancelBeforeSellerDeliver(buyerOrder, penaltyAmount.toPlainString(), psog, reSellAfterCancel);
}
//TODO 整个过程异步去执行(考虑退费依赖订单状态)
//(退费)退保证金给卖家
... ... @@ -241,7 +242,7 @@ public class BuyerOrderCancelService {
.addInitField(InfluxdbFieldEnum.FIELD_COUNT).build())); // 统计取消订单的次数
logger.info("use one thread to execute buyer cancel BeforeSellerDeliver buyerUid {}, orderCode {}, skup {}, compensate {}, transferCase {}",
buyerUid, orderCode, skup, bpcr, transferCase);
buyerUid, orderCode, skup, bpcr, transferCase);
}
return rows;
... ... @@ -250,7 +251,7 @@ public class BuyerOrderCancelService {
public void cancelForSellerSendOutTimeout(int uid, long orderCode, int skup, SellerOrderGoods sellerOrderGoods) {
new BuyerOrderCancelHandler(uid, orderCode)
.withBuyerOrderSupplier(buyerOrderMapper, buyerOrderGoodsMapper)
.withSellerOrderSupplier(sellerOrderGoodsMapper,sellerOrderMetaMapper)
.withSellerOrderSupplier(sellerOrderGoodsMapper, sellerOrderMetaMapper)
// 已付款 -> 超时未发货取消
.withStateTransition(OrderStatus.HAS_PAYED, OrderStatus.SEND_OUT_TIMEOUT, orderStatusFlowService)
// 保证金分账给平台和买家
... ... @@ -269,9 +270,9 @@ public class BuyerOrderCancelService {
.cancel();
}
public void cancelForSellerShamSendOut(int uid, long orderCode,OrderStatus targetStatus) {
public void cancelForSellerShamSendOut(int uid, long orderCode, OrderStatus targetStatus) {
if (serviceOrderProcessor.isGoodsServiceOrder(orderCode)){
if (serviceOrderProcessor.isGoodsServiceOrder(orderCode)) {
logger.info("cancelForSellerShamSendOut isGoodsServiceOrder orderCode {}", orderCode);
ServiceOrderProcessor.ExistenceNode existenceNode = serviceOrderProcessor.findGoodsServiceInstanceAndExt(orderCode);
existenceNode.getGoodsService().shamDeliver(existenceNode.getAppraiseOrder());
... ... @@ -279,7 +280,7 @@ public class BuyerOrderCancelService {
new BuyerOrderCancelHandler(uid, orderCode)
.withBuyerOrderSupplier(buyerOrderMapper, buyerOrderGoodsMapper)
.withSellerOrderSupplier(sellerOrderGoodsMapper,sellerOrderMetaMapper)
.withSellerOrderSupplier(sellerOrderGoodsMapper, sellerOrderMetaMapper)
// 卖家发货 -> 鉴定中心收货前客服取消
// 卖家发货 -> 鉴定中心收货前系统取消
.withStateTransition(OrderStatus.SELLER_SEND_OUT, targetStatus, orderStatusFlowService)
... ... @@ -299,30 +300,55 @@ public class BuyerOrderCancelService {
.cancel();
}
private Pair<Boolean,UfoServiceException> checkPenaltyAmount(BigDecimal actualPaidAmount, BigDecimal penaltyAmount){
boolean isEnough = (actualPaidAmount !=null && actualPaidAmount.compareTo(penaltyAmount) >= 0);
public void cancelForSellerCanNotSendOut(int uid, long orderCode) {
throwServiceExceptionIf(serviceOrderProcessor.isGoodsServiceOrder(orderCode), "不支持的订单类型");
new BuyerOrderCancelHandler(uid, orderCode)
.withBuyerOrderSupplier(buyerOrderMapper, buyerOrderGoodsMapper)
.withSellerOrderSupplier(sellerOrderGoodsMapper, sellerOrderMetaMapper)
// 待卖家发货 -> 卖家无法发货
.withStateTransition(OrderStatus.HAS_PAYED, OrderStatus.SELLER_CAN_NOT_SEND_OUT, orderStatusFlowService)
// 退保证金给卖家
.withRefundEarnestMoney(payRefundService::refund, sellerOrderMapper::selectBySkup).and()
// 退买家货款
.withRefundGoodsMoney(payRefundService::refund).refundCase(RefundCase.BUYER_GOODS_MONEY).and()
// 通知买家卖家无法发货
.withNoticeBuyer(buyerNoticeFacade::noticeBuyerOfSellerCanNotSendOut).and()
// 通知卖家无法发货
.withNoticeSeller(sellerNoticeFacade::noticeSellerOfSellerCanNotSendOut).and()
// 退优惠券
.withRefundCoupon(BuyerRefundCouponEvent.BizCase.BUYER_CANCEL_BSD)
.withCacheCleaner(cacheCleaner::delete)
.withOrderChangeListenerContainer(orderChangeListenerContainer)
.cancel();
}
private Pair<Boolean, UfoServiceException> checkPenaltyAmount(BigDecimal actualPaidAmount, BigDecimal penaltyAmount) {
boolean isEnough = (actualPaidAmount != null && actualPaidAmount.compareTo(penaltyAmount) >= 0);
UfoServiceException ex = null;
if(!isEnough){
ex = new com.yohoufo.common.exception.UfoServiceException(400,"实付金额低于订单违约金,不允许取消");
if (!isEnough) {
ex = new com.yohoufo.common.exception.UfoServiceException(400, "实付金额低于订单违约金,不允许取消");
}
return Pair.of(isEnough, ex);
}
public void cancel(BeforeDepotReceiveEvent bdrEvent){
public void cancel(BeforeDepotReceiveEvent bdrEvent) {
int buyerUid = bdrEvent.getBuyerUid();
int sellerUid = bdrEvent.getSellerUid();
long orderCode = bdrEvent.getOrderCode();
OrderStatus targetOrderStatus = bdrEvent.getTarget();
BuyerOrder buyerOrder = buyerOrderMapper.selectByOrderCode(orderCode);
BuyerOrderGoods buyerOrderGoods = buyerOrderGoodsMapper.selectByOrderCode(buyerOrder.getUid(),buyerOrder.getOrderCode());
BuyerOrderGoods buyerOrderGoods = buyerOrderGoodsMapper.selectByOrderCode(buyerOrder.getUid(), buyerOrder.getOrderCode());
logger.info("in buyer cancel BeforeDepotReceive begin buyerOrderMapper.selectByOrderCode, buyerUid {}, orderCode {}, skup {} buyerOrder {}",
buyerUid, orderCode, buyerOrder );
buyerUid, orderCode, buyerOrder);
BuyerPenaltyCalResult bpcr = buyerCancelCompensateComputeHandler.calBuyerPenaltyCalResult(buyerOrder, buyerOrderGoods, targetOrderStatus);
logger.info("in buyer cancel BeforeDepotReceive, event {} compensate {}", bdrEvent, bpcr);
//买家实付金额(货款+运费)小于赔偿金的额度,不够赔偿的,则不允许取消
BigDecimal penaltyAmount;
Pair<Boolean,UfoServiceException> amountIsEnough = checkPenaltyAmount(bdrEvent.getAmount(), penaltyAmount=bpcr.getPenaltyAmount());
if(!amountIsEnough.getLeft()){
Pair<Boolean, UfoServiceException> amountIsEnough = checkPenaltyAmount(bdrEvent.getAmount(), penaltyAmount = bpcr.getPenaltyAmount());
if (!amountIsEnough.getLeft()) {
logger.warn("in buyer cancel BeforeDepotReceive not allow cancel cause of buyer amount lower than BuyerCompensateMoney, event {} compensate {}", bdrEvent, bpcr);
throw amountIsEnough.getRight();
}
... ... @@ -330,7 +356,7 @@ public class BuyerOrderCancelService {
OrderStatus expected = bdrEvent.getExpected();
int currentTime = DateUtil.getCurrentTimeSecond();
int rows = buyerOrderMapper.updateStatusByOrderCode(orderCode, buyerUid, expected.getCode(), targetOrderStatus.getCode(), currentTime);
if (rows>0) {
if (rows > 0) {
boolean useDepositGoods = bdrEvent.isUseDepositGoods();
boolean noResponsibility = Objects.isNull(penaltyAmount)
|| BigDecimal.ZERO.compareTo(penaltyAmount) == 0;
... ... @@ -349,10 +375,10 @@ public class BuyerOrderCancelService {
soc.setUpdateTime(DateUtil.getCurrentTimeSecond());
sellerOrderMapper.updateBySkups(soc, Arrays.asList(skup));
SellerOrderGoods psog = sellerOrderGoodsMapper.selectByPrimaryKey(skup);
if (noResponsibility){
sellerNoticeFacade.noticeSellerWhenBuyerCancelNoResponsibility(psog, orderCode,false);
}else {
inBoxFacade.buyerCancelBeforeDepotReceive(buyerOrder, penaltyAmount.toPlainString(), psog, useDepositGoods);
if (noResponsibility) {
sellerNoticeFacade.noticeSellerWhenBuyerCancelNoResponsibility(psog, orderCode, false);
} else {
inBoxFacade.buyerCancelBeforeDepotReceive(buyerOrder, penaltyAmount.toPlainString(), psog, useDepositGoods);
}
//整个过程异步去执行(考虑退费依赖订单状态)
//(退费)退保证金给卖家
... ... @@ -360,7 +386,7 @@ public class BuyerOrderCancelService {
//(退费)扣除赔偿款,计算剩余的货款,退给买家
TransferCase transferCase = TransferCase.PART_GOODS_MONEY_TO_SELLER;
BuyerCancelAfterProcessTask bcapt = new BuyerCancelAfterProcessTask(buyerOrder, skup,
bpcr, transferCase,false);
bpcr, transferCase, false);
bcapt.targetOrderStatus = targetOrderStatus;
bcapt.setSwdType(SellerWalletDetail.Type.BUYER_CANCEL_DELIVERY);
Future<PayRefundBo> future = ThreadPoolFactory.getBuyerCancelThreadPool().submit(bcapt);
... ... @@ -374,17 +400,17 @@ public class BuyerOrderCancelService {
//
if (useDepositGoods){
if (useDepositGoods) {
String depositCode = bdrEvent.getDepositCode();
logger.info("cancel buyer order Before Depot Receive trigger DepositGoodsCompensateAsyncEvent orderCode {} depositCode {}", orderCode, depositCode);
triggerDepositGoodsCompensateAsyncEvent(sellerUid, depositCode);
}
logger.info("use one thread to execute buyer cancel BeforeDepotReceive buyerUid {}, orderCode {}, skup {}, compensate {}, transferCase {}",
buyerUid, orderCode, skup, bpcr, transferCase);
buyerUid, orderCode, skup, bpcr, transferCase);
}
}
public void cancelForBuyerPullWool(BuyerOrderCancelReq request){
public void cancelForBuyerPullWool(BuyerOrderCancelReq request) {
Long orderCode = request.getOrderCode();
final OrderStatus targetStatus = OrderStatus.PLATFORM_CANCEL_OF_BUYER_PULL_WOOL;
final List<Integer> statusList = ActionStatusHold.getCancelStatusOfpullwool();
... ... @@ -392,14 +418,14 @@ public class BuyerOrderCancelService {
BuyerOrderAssistant.PreparedData preparedData = buyerOrderAssistant.prepare(orderCode);
BuyerOrder pbo = preparedData.getBuyerOrder();
OrderStatus cos = OrderStatus.getOrderStatus(pbo.getStatus());
if (!statusList.contains(pbo.getStatus())){
if (!statusList.contains(pbo.getStatus())) {
logger.warn("in buyer order cancelByCS status illegal,req {} status {}", request, cos.getDesc());
throw new UfoServiceException(400, String.format("当前订单状态处于%s,不支持取消",cos.getDesc()));
throw new UfoServiceException(400, String.format("当前订单状态处于%s,不支持取消", cos.getDesc()));
}
//2. update status using optimize lock , as last time filter
int rows = buyerOrderMapper.updateStatusWithStatusList(orderCode,targetStatus.getCode(), statusList, DateUtil.getCurrentTimeSecond());
logger.info("in buyer order cancelByCS because pull wool, req {} updateStatusWithStatusList {}",request, rows);
if (rows>0){
int rows = buyerOrderMapper.updateStatusWithStatusList(orderCode, targetStatus.getCode(), statusList, DateUtil.getCurrentTimeSecond());
logger.info("in buyer order cancelByCS because pull wool, req {} updateStatusWithStatusList {}", request, rows);
if (rows > 0) {
asyncProcessPenalty(preparedData, targetStatus);
//clean cache
cacheCleaner.cleanSellerAndBuyerOrderDetailAndList(pbo.getSellerUid(), pbo.getUid(), orderCode);
... ... @@ -409,7 +435,7 @@ public class BuyerOrderCancelService {
}
}
private void asyncProcessPenalty(BuyerOrderAssistant.PreparedData preparedData, final OrderStatus targetStatus){
private void asyncProcessPenalty(BuyerOrderAssistant.PreparedData preparedData, final OrderStatus targetStatus) {
BuyerOrder pbo = preparedData.getBuyerOrder();
final Long orderCode = pbo.getOrderCode();
final boolean resellFlag = false;
... ... @@ -422,7 +448,7 @@ public class BuyerOrderCancelService {
TransferCase transferCase = TransferCase.PART_GOODS_MONEY_TO_SELLER;
BuyerCancelAfterProcessTask bcapt = new BuyerCancelAfterProcessTask(pbo, skup,
bpcr, transferCase, resellFlag);
bpcr, transferCase, resellFlag);
bcapt.targetOrderStatus = targetStatus;
bcapt.setSwdType(SellerWalletDetail.Type.PULL_WOOL);
Future<PayRefundBo> future = ThreadPoolFactory.getBuyerCancelThreadPool().submit(bcapt);
... ... @@ -432,13 +458,12 @@ public class BuyerOrderCancelService {
}
private boolean compensateDepositGoods(DepositGoodsCompensateAsyncEvent event){
private boolean compensateDepositGoods(DepositGoodsCompensateAsyncEvent event) {
logger.info("cancel buyer order compensateDepositGoods, event {}", event);
return depositService.updateDepositAfterCancelBuy(event.getUid(), event.getDepositCode());
}
private void triggerDepositGoodsCompensateAsyncEvent(int sellerUid, String depositCode){
private void triggerDepositGoodsCompensateAsyncEvent(int sellerUid, String depositCode) {
logger.info("trigger DepositGoodsCompensateAsyncEvent sellerUid {} depositCode {}", sellerUid, depositCode);
DepositGoodsCompensateAsyncEvent asyncEvent
= new DepositGoodsCompensateAsyncEvent(this::compensateDepositGoods);
... ... @@ -447,7 +472,7 @@ public class BuyerOrderCancelService {
EventBusPublisher.publishEvent(asyncEvent);
}
public void clearanceFail(long orderCode, String failReason, ClearanceFailType failType){
public void clearanceFail(long orderCode, String failReason, ClearanceFailType failType) {
new ClearanceFailModel(orderCode, failReason, failType).invoke().cancel();
}
... ... @@ -455,7 +480,7 @@ public class BuyerOrderCancelService {
List<String> couponTokens;
if (goodsAmount.compareTo(BigDecimal.valueOf(2000)) > 0) {
couponTokens = Lists.newArrayList("f489885f-2000-4e15-a628-c40e660128fa");
}else if (goodsAmount.compareTo(BigDecimal.valueOf(1000)) > 0) {
} else if (goodsAmount.compareTo(BigDecimal.valueOf(1000)) > 0) {
couponTokens = Lists.newArrayList("f489885f-1000-4e15-a628-c40e660128fa");
} else {
couponTokens = Lists.newArrayList("f489885f-0000-4e15-a628-c40e660128fa");
... ... @@ -471,7 +496,8 @@ public class BuyerOrderCancelService {
tradeMqProducer.send("ufo.couponSendWithTradeMqNotify", mqBean);
}
@Data@Builder
@Data
@Builder
private static class RefundGoodsAmountNode {
BuyerOrder buyerOrder;
int skup;
... ... @@ -480,7 +506,7 @@ public class BuyerOrderCancelService {
}
class BuyerCancelAfterProcessTask implements Callable<PayRefundBo>{
class BuyerCancelAfterProcessTask implements Callable<PayRefundBo> {
int buyerUid;
long orderCode;
int skup;
... ... @@ -494,7 +520,7 @@ public class BuyerOrderCancelService {
@Setter
SellerWalletDetail.Type swdType;
public BuyerCancelAfterProcessTask(BuyerOrder buyerOrder, int skup, BuyerPenaltyCalResult bpcr, TransferCase transferCase,boolean reSellFlag) {
public BuyerCancelAfterProcessTask(BuyerOrder buyerOrder, int skup, BuyerPenaltyCalResult bpcr, TransferCase transferCase, boolean reSellFlag) {
this.buyerUid = buyerOrder.getUid();
this.orderCode = buyerOrder.getOrderCode();
this.skup = skup;
... ... @@ -504,7 +530,7 @@ public class BuyerOrderCancelService {
this.reSellFlag = reSellFlag;
}
private PayRefundBo refundSellerEarnestMoney(SellerOrder sellerOrder){
private PayRefundBo refundSellerEarnestMoney(SellerOrder sellerOrder) {
PayRefundBo prb = null;
int sellerUid = sellerOrder.getUid();
long sellerOrderCode = sellerOrder.getOrderCode();
... ... @@ -516,7 +542,7 @@ public class BuyerOrderCancelService {
.build();
boolean sellerIsSuper = sellerService.isSuperEntrySeller(sellerUid);
refundReqOfSeller.setSuper(sellerIsSuper);
if (!sellerIsSuper && PaymentHelper.isWallet(sop)){
if (!sellerIsSuper && PaymentHelper.isWallet(sop)) {
MerchantOrderAttachInfo moai = MerchantOrderAttachInfo.builder().uid(sellerUid)
.orderCode(sellerOrderCode).skup(skup).earnestMoney(sellerOrder.getEarnestMoney())
... ... @@ -529,7 +555,7 @@ public class BuyerOrderCancelService {
.payType(sellerOrder.getPayment()).refundCase(RefundCase.SELLER_EARNEST_MONEY)
.skup(skup);
logger.info("in BuyerCancelAfterProcessTask call begin payRefundService.refund seller, buyerUid {}, orderCode {}, skup {} refundReqOfSeller {}",
buyerUid, orderCode, skup, refundReqOfSeller );
buyerUid, orderCode, skup, refundReqOfSeller);
new RefundEarnestMoneyHandler()
.loadRefundAction(payRefundService::refund)
.loadBillLogEventBuilder(bleb)
... ... @@ -540,11 +566,11 @@ public class BuyerOrderCancelService {
.refund();
logger.info("in BuyerCancelAfterProcessTask call after payRefundService.refund seller, buyerUid {}, orderCode {}, skup {} refundReqOfSeller {}",
buyerUid, orderCode, skup, refundReqOfSeller );
buyerUid, orderCode, skup, refundReqOfSeller);
return prb;
}
void transferPenalty(BuyerPenaltyCalResult bpcr){
void transferPenalty(BuyerPenaltyCalResult bpcr) {
if (bpcr.getPenaltyAmount().compareTo(BigDecimal.ZERO) <= 0) {
logger.info("in BuyerCancelAfterProcessTask call non need penalty, buyerUid {}, orderCode {}, skup {}",
buyerUid, orderCode, skup);
... ... @@ -560,17 +586,17 @@ public class BuyerOrderCancelService {
.transeferCellNode(transeferCellNode)
.build();
logger.info("in BuyerCancelAfterProcessTask call begin paymentService.transferMon, buyerUid {}, orderCode {}, skup {} refundReqOfSeller {}",
buyerUid, orderCode, skup, tmReq );
buyerUid, orderCode, skup, tmReq);
transferService.transfer(tmReq);
logger.info("in BuyerCancelAfterProcessTask call after paymentService.transferMon, buyerUid {}, orderCode {}, skup {} refundReqOfSeller {}",
buyerUid, orderCode, skup, tmReq );
buyerUid, orderCode, skup, tmReq);
}
void refundLeftOrderAmount(BuyerPenaltyCalResult bpcr, BuyerOrder buyerOrder){
void refundLeftOrderAmount(BuyerPenaltyCalResult bpcr, BuyerOrder buyerOrder) {
Integer sellerUid = buyerOrder.getSellerUid();
BigDecimal leftBuyerMoney = bpcr.getLeftAmount();
logger.info("in BuyerCancelAfterProcessTask call begin payRefundService.refund buyer, buyerUid {}, orderCode {}, skup {} refundAmount {}",
buyerUid, orderCode, skup, leftBuyerMoney );
buyerUid, orderCode, skup, leftBuyerMoney);
new RefundGoodsMoneyHandler().loadLogger(logger)
.loadPaymentRequest(buyerUid, orderCode, buyerOrder.getPayment(), leftBuyerMoney)
//.loadBillLogEventBuilder(blebOfBuyer)
... ... @@ -579,7 +605,7 @@ public class BuyerOrderCancelService {
.loadSellerOrderGoods(sellerUid, skup)
.refund();
logger.info("in BuyerCancelAfterProcessTask call after payRefundService.refund buyer, buyerUid {}, orderCode {}, skup {} refundAmount {}",
buyerUid, orderCode, skup, leftBuyerMoney );
buyerUid, orderCode, skup, leftBuyerMoney);
}
@Override
... ... @@ -587,13 +613,13 @@ public class BuyerOrderCancelService {
// 整个过程异步去执行(考虑退费依赖订单状态)
//(退费)退保证金给卖家
logger.info("in BuyerCancelAfterProcessTask call buyerUid {}, orderCode {}, skup {}, transferCase {}, compensate {},reSellFlag {}",
buyerUid, orderCode, skup, transferCase, bpcr,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 {},reSellFlag {}",
buyerUid, orderCode, skup,reSellFlag );
if(!reSellFlag){
buyerUid, orderCode, skup, reSellFlag);
if (!reSellFlag) {
//只有不重新上架,才退保证金
prb = refundSellerEarnestMoney(sellerOrder);
}
... ... @@ -604,7 +630,7 @@ public class BuyerOrderCancelService {
refundLeftOrderAmount(bpcr, buyerOrder);
logger.info("out BuyerCancelAfterProcessTask call buyerUid {}, orderCode {}, skup {}, transferCase {}, compensate {}",
buyerUid, orderCode, skup, transferCase, bpcr);
}catch (Exception ex){
} catch (Exception ex) {
logger.info("occur error BuyerCancelAfterProcessTask call buyerUid {}, orderCode {}, skup {}, transferCase {}, compensate {}",
buyerUid, orderCode, skup, transferCase, bpcr, ex);
}
... ... @@ -697,7 +723,7 @@ public class BuyerOrderCancelService {
final List<Integer> expectedStatus = Lists.newArrayList(OrderStatus.WAITING_RECEIVE.getCode(), OrderStatus.HAS_PAYED.getCode());
int buyerUid = buyerOrder.getUid();
Integer sellerUid = buyerOrder.getSellerUid();
boolean changeStatusFlag = buyerOrderMapper.updateStatusWithStatusList(orderCode, targetStatus.getCode(),expectedStatus,DateUtil.getCurrentTimeSecond()) > 0;
boolean changeStatusFlag = buyerOrderMapper.updateStatusWithStatusList(orderCode, targetStatus.getCode(), expectedStatus, DateUtil.getCurrentTimeSecond()) > 0;
if (!changeStatusFlag) {
logger.info("{} changeStatus fail", logTag);
throwServiceException("订单状态变更失败");
... ... @@ -716,14 +742,13 @@ public class BuyerOrderCancelService {
asyncRefundCoupon(buyerOrder.getUid(), buyerOrder.getOrderCode(), BuyerRefundCouponEvent.BizCase.PLATFORM_BLOWN_CUSTOMS_CLEARANCE);
orderStatusFlowService.addAsy(orderCode, targetStatus.getCode(),failReason);
orderStatusFlowService.addAsy(orderCode, targetStatus.getCode(), failReason);
}
private void asyncRefundGoodsAmount() {
final ExecutorService executorService = ThreadPoolFactory.getBuyerCancelThreadPool();
executorService.execute(()->{
executorService.execute(() -> {
BigDecimal leftGoodsMoney = buyerOrder.getAmount();
BuyerOrderGoods pbog = buyerOrderGoodsMapper.selectOnlyByOrderCode(buyerOrder.getOrderCode());
... ... @@ -743,9 +768,9 @@ public class BuyerOrderCancelService {
}
private void saveFailRecord(int uid, long orderCode, String failReason){
private void saveFailRecord(int uid, long orderCode, String failReason) {
final ExecutorService executorService = ThreadPoolFactory.getBuyerCancelThreadPool();
executorService.execute(()-> {
executorService.execute(() -> {
BuyerOrderMeta record = new BuyerOrderMeta();
record.setOrderCode(orderCode);
record.setUid(uid);
... ... @@ -765,9 +790,10 @@ public class BuyerOrderCancelService {
* 货品平台自己吃了
* 买家钱退给买家
* 赔偿卖家ufo券 券金额还未定
*
* @param refundGoodsAmountNode
*/
private void platformReason(RefundGoodsAmountNode refundGoodsAmountNode){
private void platformReason(RefundGoodsAmountNode refundGoodsAmountNode) {
BuyerOrder buyerOrder = refundGoodsAmountNode.buyerOrder;
int skup = refundGoodsAmountNode.skup;
OrderStatus targetOrderStatus = refundGoodsAmountNode.targetOrderStatus;
... ... @@ -782,9 +808,10 @@ public class BuyerOrderCancelService {
* 买家原因失败
* 货品平台自己吃了
* 货款钱退给买家
*
* @param refundGoodsAmountNode
*/
private void userReason(RefundGoodsAmountNode refundGoodsAmountNode){
private void userReason(RefundGoodsAmountNode refundGoodsAmountNode) {
BuyerOrder buyerOrder = refundGoodsAmountNode.buyerOrder;
int skup = refundGoodsAmountNode.skup;
OrderStatus targetOrderStatus = refundGoodsAmountNode.targetOrderStatus;
... ... @@ -798,23 +825,23 @@ public class BuyerOrderCancelService {
}
private void refundGoodsAmount(BuyerOrder buyerOrder,int skup, OrderStatus targetOrderStatus, BigDecimal leftBuyerMoney){
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("clearanceFail refundGoodsAmount begin payRefundService.refund buyer, buyerUid {}, orderCode {}, skup {} refundAmount {}",
buyerUid, orderCode, skup, leftBuyerMoney );
buyerUid, orderCode, skup, leftBuyerMoney);
new RefundGoodsMoneyHandler().loadLogger(logger)
.loadPaymentRequest(buyerUid,orderCode,buyerOrder.getPayment(), leftBuyerMoney)
.loadPaymentRequest(buyerUid, orderCode, buyerOrder.getPayment(), leftBuyerMoney)
.loadRefundAction(payRefundService::refund)
.loadTargetOrderStatus(targetOrderStatus)
.loadSellerOrderGoods(sellerUid, skup)
.refund();
logger.info("clearanceFail refundGoodsAmount after payRefundService.refund buyer, buyerUid {}, orderCode {}, skup {} refundAmount {}",
buyerUid, orderCode, skup, leftBuyerMoney );
buyerUid, orderCode, skup, leftBuyerMoney);
}
}
}
... ...
... ... @@ -152,9 +152,10 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
/**
* 提交订单
*
* @param orderRequest
*/
public void confirm(OrderRequest orderRequest){
public void confirm(OrderRequest orderRequest) {
// 参数检查 ![待收货] 不合法
DataNode node = checkBase(orderRequest);
... ... @@ -162,12 +163,12 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
OrderStatus buyerOrderStatus = OrderStatus.getOrderStatus(buyerOrder.getStatus());
OrderStatus expectStatus;
// 如果当前订单状态为待寄存或待收货
if(buyerOrderStatus == OrderStatus.JUDGE_PASS_WAIT_WAREHOUSE){
if (buyerOrderStatus == OrderStatus.JUDGE_PASS_WAIT_WAREHOUSE) {
expectStatus = OrderStatus.JUDGE_PASS_WAIT_WAREHOUSE;
} else {
expectStatus = OrderStatus.WAITING_RECEIVE;
}
checkStatus(node,orderRequest, expectStatus);
checkStatus(node, orderRequest, expectStatus);
int uid = buyerOrder.getUid();
long orderCode = buyerOrder.getOrderCode();
int sellerUid = buyerOrder.getSellerUid();
... ... @@ -189,8 +190,8 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
.build());
//记录状态信息
logger.info("in seller confirm record status change, orderCode {},uid {} ,sellerUid {}", orderCode,uid,sellerUid);
orderStatusFlowService.addAsy(orderCode,OrderStatus.DONE.getCode());
logger.info("in seller confirm record status change, orderCode {},uid {} ,sellerUid {}", orderCode, uid, sellerUid);
orderStatusFlowService.addAsy(orderCode, OrderStatus.DONE.getCode());
cacheCleaner.cleanSellerAndBuyerOrderDetailAndList(sellerUid, uid, orderCode);
ErpBuyerOrderEvent event = new ErpBuyerOrderEvent(uid); // 清理有货个人中心接口缓存的UFO订单数量的缓存
... ... @@ -201,8 +202,6 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
}
/**
* 买家修改收货地址:
* 鉴定中心确定收货之前,都可以修改地址
... ... @@ -211,45 +210,42 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
@Override
public boolean buyerModifyAddress(int uid, long orderCode,
AddressInfo changedAddress,
final boolean fromPlatform){
final boolean fromPlatform) {
boolean result = buyerOrderMetaService.buyerSelfModifyAddress(uid, orderCode,changedAddress, fromPlatform);
boolean result = buyerOrderMetaService.buyerSelfModifyAddress(uid, orderCode, changedAddress, fromPlatform);
return result;
}
/**
* 取消订单
*
* @param orderRequest
*/
@Override
public void cancel(OrderRequest orderRequest){
public void cancel(OrderRequest orderRequest) {
logger.info("Buyer Order cancel (OrderRequest) {}", orderRequest);
doCancel(orderRequest);
}
@Override
public void cancelByCS(BuyerOrderCancelReq request) {
logger.info("in buyer order cancelByCS, req {}",request);
logger.info("in buyer order cancelByCS, req {}", request);
int uid = request.getUid();
long orderCode = request.getOrderCode();
int cancelType = request.getCancelType();
BuyerOrderCancelType boct = BuyerOrderCancelType.getBuyerOrderCancelType(cancelType);
if (Objects.isNull(boct)){
if (Objects.isNull(boct)) {
buyerOrderCancelService.cancelForSellerShamSendOut(uid, orderCode, OrderStatus.SELLER_SHAM_SEND_OUT);
return;
}
switch (boct){
switch (boct) {
case PULL_WOOL:
logger.info("in buyer order cancelByCS because pull wool, req {}",request);
logger.info("in buyer order cancelByCS because pull wool, req {}", request);
buyerOrderCancelService.cancelForBuyerPullWool(request);
break;
case SELLER_CAN_NOT_SEND_OUT:
buyerOrderCancelService.cancelForSellerCanNotSendOut(uid, orderCode);
default:
logger.warn("in buyer order cancelByCS not match any BuyerOrderCancelType, req {}", request);
break;
... ... @@ -299,28 +295,29 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
/**
* protect hack action
*
* @param buyerOrder
* @param pbog
*/
private void checkCancelable(BuyerOrder buyerOrder, BuyerOrderGoods pbog){
private void checkCancelable(BuyerOrder buyerOrder, BuyerOrderGoods pbog) {
boolean isDepositOrder = BuyerOrderUtils.isDeposit(buyerOrder);
SellerOrderGoods psog = sellerOrderGoodsMapper.selectByPrimaryKey(pbog.getSkup());
SkupType skupType = SkupType.getSkupType(psog.getAttributes());
boolean isQuickDeliverGoods = SellerGoodsHelper.isQuickDeliver(skupType);
if (isDepositOrder && isQuickDeliverGoods){
if (isDepositOrder && isQuickDeliverGoods) {
logger.warn("checkCancelable find illegal action, uid {} orderCode {}", buyerOrder.getUid(), buyerOrder.getOrderCode());
throw new UfoServiceException(400, "闪购商品订单不允许取消");
}
}
private void doCancel(OrderRequest orderRequest){
private void doCancel(OrderRequest orderRequest) {
DataNode node = checkBase(orderRequest);
BuyerOrder buyerOrder = node.buyerOrderInDB;
Integer orderStatus = buyerOrder.getStatus();
OrderStatus expectStatus = null ;
if (orderStatus == null || (expectStatus = OrderStatus.getOrderStatus(orderStatus))== null){
logger.warn("in buyer cancel check orderStatus fail, orderStatus {} expectStatus {}", orderStatus,expectStatus );
OrderStatus expectStatus = null;
if (orderStatus == null || (expectStatus = OrderStatus.getOrderStatus(orderStatus)) == null) {
logger.warn("in buyer cancel check orderStatus fail, orderStatus {} expectStatus {}", orderStatus, expectStatus);
throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE);
}
logger.info("in buyer cancel, req {} expectStatus {}", orderRequest, expectStatus);
... ... @@ -332,7 +329,7 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
Long orderCode = buyerOrder.getOrderCode();
boolean useDepositGoods = node.useDepositGoods;
switch (expectStatus){
switch (expectStatus) {
case WAITING_PAY_DEPOSIT:
targetStatus = OrderStatus.BUYER_CANCEL_BEFORE_DEPOSIT_PAY;
buyerOrderStateChangers.selectOneToChange(buyerOrder, OrderStatus.WAITING_PAY_DEPOSIT, targetStatus);
... ... @@ -372,18 +369,18 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
.useDepositGoods(useDepositGoods)
.build();
int updateOrderFlag = buyerOrderCancelService.cancel(bsde);
if (updateOrderFlag>0){
if (node.isDepositGoods){
if (updateOrderFlag > 0) {
if (node.isDepositGoods) {
asyncUnlockDepositGoods(buyerOrder.getSellerUid(), node.depositCodeOfSkup);
}
}
//取消事件
orderChangeListenerContainer.fireAsyncEvent(new BuyerOrderChangeEvent(buyerOrder, BuyerOrderChangeEvent.BizCase.CANCEL_BYBUYER, targetStatus));
orderStatusFlowService.addAsy(orderCode,targetStatus.getCode());
orderStatusFlowService.addAsy(orderCode, targetStatus.getCode());
break;
case SELLER_SEND_OUT:
bog = buyerOrderGoodsMapper.selectByOrderCode(uid = orderRequest.getUid(),
orderCode=orderRequest.getOrderCode());
orderCode = orderRequest.getOrderCode());
skup = bog.getSkup();
targetStatus = useDepositGoods ? OrderStatus.BUYER_CANCEL_BEFORE_DEPOT_RECEIVE_USE_DEPOSIT_GOODS
: OrderStatus.BUYER_CANCEL_BEFORE_DEPOT_RECEIVE;
... ... @@ -397,18 +394,18 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
buyerOrderCancelService.cancel(bdre);
//取消事件
orderChangeListenerContainer.fireAsyncEvent(new BuyerOrderChangeEvent(buyerOrder, BuyerOrderChangeEvent.BizCase.CANCEL_BYBUYER, targetStatus));
orderStatusFlowService.addAsy(orderCode,targetStatus.getCode());
orderStatusFlowService.addAsy(orderCode, targetStatus.getCode());
break;
default:
logger.warn("in buyer cancel fail uid {} order code {} expectStatus {}",
buyerOrder.getUid(),buyerOrder.getOrderCode(), expectStatus);
buyerOrder.getUid(), buyerOrder.getOrderCode(), expectStatus);
throw new UfoServiceException(401, "订单状态已变更,不能取消");
}
//记录状态变更信息
logger.info("in doCancel record status {} change to {}, orderRequest {}", expectStatus, targetStatus, orderRequest);
}
private void asyncUnlockDepositGoods(Integer sellerUid,String depositCode){
private void asyncUnlockDepositGoods(Integer sellerUid, String depositCode) {
Callable<Integer> depositGoodsTask = () -> depositService.updateSellLock(sellerUid, depositCode, 0);
Future<Integer> future = ThreadPoolFactory.getCommomExecutorService().submit(depositGoodsTask);
logger.info("asyncUnlockDepositGoodsIf depositCode {} future.isDone {}", depositCode, future.isDone());
... ... @@ -416,13 +413,12 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
}
public void cancelBeforePaid(OrderRequest orderRequest, DataNode dataNode, OrderStatus exceptStatus, OrderStatus targetStatus){
public void cancelBeforePaid(OrderRequest orderRequest, DataNode dataNode, OrderStatus exceptStatus, OrderStatus targetStatus) {
// 状态 ![待付款] 不合法
checkStatus(dataNode, orderRequest, exceptStatus);
// 近一分钟内有预支付记录
if (orderRequest.getOrderCancelEvent()!=null && !orderRequest.getOrderCancelEvent().isFinalRetry()){
if (orderRequest.getOrderCancelEvent() != null && !orderRequest.getOrderCancelEvent().isFinalRetry()) {
paymentService.checkPrePay(orderRequest.getUid(), orderRequest.getOrderCode());
}
final BuyerOrder buyerOrder = dataNode.buyerOrderInDB;
... ... @@ -437,13 +433,13 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
tbo.setOrderCode(orderCode = orderRequest.getOrderCode());
tbo.setUpdateTime(DateUtil.getCurrentTimeSecond());
buyerOrderMapper.updateByOrderCode(tbo);
if (dataNode.isDepositGoods){
if (dataNode.isDepositGoods) {
asyncUnlockDepositGoods(sellerUid, dataNode.depositCodeOfSkup);
}
// 更新skup的状态[出售中] 卖家订单为[可售]
BuyerOrderGoods bog = buyerOrderGoodsMapper.selectByOrderCode(orderRequest.getUid(), orderCode);
int skup = bog.getSkup();
SellerOrderGoods psog= sellerOrderGoodsMapper.selectByPrimaryKey(skup);
SellerOrderGoods psog = sellerOrderGoodsMapper.selectByPrimaryKey(skup);
Integer skupStatus = psog.getStatus();
//todo check skupStatus
SellerOrderGoods tsog = new SellerOrderGoods();
... ... @@ -455,7 +451,7 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
boolean isReturnSuccess = productProxyService.returnStorage(skup);
// 急速发货的场合,释放库存
if (fastDeliveryProxyService.isFastDeliveryGoods(skup)){
if (fastDeliveryProxyService.isFastDeliveryGoods(skup)) {
fastDeliveryProxyService.cancel(psog.getUid(), skup);
}
... ... @@ -476,7 +472,7 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
}
class DataNode{
class DataNode {
BuyerOrder buyerOrderInDB;
String depositCodeOfSellerUsingDeliver;
boolean useDepositGoods;
... ... @@ -484,12 +480,12 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
boolean isDepositGoods;
}
DataNode checkBase(OrderRequest orderRequest){
DataNode checkBase(OrderRequest orderRequest) {
int uid;
long orderCode;
// 参数检查
if ((uid=orderRequest.getUid()) < 0
|| (orderCode=orderRequest.getOrderCode()) < 0){
if ((uid = orderRequest.getUid()) < 0
|| (orderCode = orderRequest.getOrderCode()) < 0) {
logger.warn("check uid or orderCode empty");
throw new ServiceException(ServiceError.ORDER_REQUEST_PARM_IS_EMPTY);
}
... ... @@ -497,16 +493,16 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
// 订单存在 & 待付款的状态
// 查询订单状态
BuyerOrder buyerOrder = buyerOrderMapper.selectByOrderCodeUid(orderRequest.getOrderCode(), orderRequest.getUid());
if (buyerOrder == null){
if (buyerOrder == null) {
logger.warn("check orderCode exist, uid is {}, orderCode is {}",
orderRequest.getUid(), orderRequest.getOrderCode() );
orderRequest.getUid(), orderRequest.getOrderCode());
throw new ServiceException(ServiceError.ORDER_NULL);
}
DataNode node = new DataNode();
BuyerOrderGoods buyerOrderGoods = buyerOrderGoodsMapper.selectOnlyByOrderCode(orderCode);
SellerOrderGoods sellerOrderGoods = sellerOrderGoodsMapper.selectByPrimaryKey(buyerOrderGoods.getSkup());
SkupType skupType = SkupType.getSkupType(sellerOrderGoods.getAttributes());
if(skupType == SkupType.QUICK_DELIVER) {
if (skupType == SkupType.QUICK_DELIVER) {
String depositCode = findDepoistGoods(buyerOrder.getSellerUid(), buyerOrderGoods.getSkup());
node.depositCodeOfSkup = depositCode;
node.isDepositGoods = true;
... ... @@ -520,33 +516,32 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
}
private String findDepositCodeOfSellerUsingDeliver(Integer uid, Long orderCode){
private String findDepositCodeOfSellerUsingDeliver(Integer uid, Long orderCode) {
String depositCode = buyerOrderMetaService.getDepositCode(uid, orderCode);
return depositCode;
}
@Autowired
private SellerOrderMetaService sellerOrderMetaService;
private String findDepoistGoods(Integer sellerUid, Integer skup){
private String findDepoistGoods(Integer sellerUid, Integer skup) {
String depoistCode = sellerOrderMetaService.getDepoistCode(sellerUid, skup);
return depoistCode;
}
/**
*
* @param orderRequest
* @param orderStatusEx
*/
private void checkStatus(DataNode node, OrderRequest orderRequest, OrderStatus orderStatusEx ) {
private void checkStatus(DataNode node, OrderRequest orderRequest, OrderStatus orderStatusEx) {
BuyerOrder buyerOrder = node.buyerOrderInDB;
// 检查 订单状态
int status = buyerOrder.getStatus() == null ? -1 : buyerOrder.getStatus().intValue();
OrderStatus orderStatus = OrderStatus.getOrderStatus(status);
if (orderStatus == null || orderStatus.getCode() != orderStatusEx.getCode()){
if (orderStatus == null || orderStatus.getCode() != orderStatusEx.getCode()) {
logger.warn("check status invalidate, uid is {}, orderCode is {}, status is {}",
orderRequest.getUid(), orderRequest.getOrderCode(), buyerOrder.getStatus());
throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE);
... ... @@ -554,11 +549,11 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
// 状态是待支付的场合,到第三方检查是否支付过了
Payment payment = Payment.getPayment(buyerOrder.getPayment());
if (payment != null && status == OrderStatus.WAITING_PAY.getCode()){
if (payment != null && status == OrderStatus.WAITING_PAY.getCode()) {
AbstractPayService payService = paymentService.getPayService(payment.getCode());
PayQueryBo payQueryBo = payService.payQuery(String.valueOf(buyerOrder.getOrderCode()), buyerOrder.getCreateTime());
if (payQueryBo != null && payQueryBo.isPayStatus()){
if (payQueryBo != null && payQueryBo.isPayStatus()) {
logger.warn("check status failed ,confirm paid, uid is {}, orderCode is {}, status is {}",
orderRequest.getUid(), orderRequest.getOrderCode(), buyerOrder.getStatus());
// 主动触发支付结果确认
... ... @@ -571,23 +566,21 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
}
/**
* 查询订单数量
*
* @param uid
* @return
*/
public BuyerOrderNums getBuyerOrderNums(int uid){
public BuyerOrderNums getBuyerOrderNums(int uid) {
if (uid < 0){
if (uid < 0) {
logger.warn("buyer delete, uid or orderCode empty, uid {}", uid);
throw new ServiceException(ServiceError.ORDER_REQUEST_PARM_IS_EMPTY);
}
BuyerOrderNums buyerOrderNumsCache = orderCacheService.getBuyerOrderNums(uid);
if (buyerOrderNumsCache != null){
if (buyerOrderNumsCache != null) {
logger.info("getBuyerOrderNums result uid is {}, result is {}", uid, buyerOrderNumsCache);
return buyerOrderNumsCache;
}
... ... @@ -595,7 +588,7 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
List<BuyOrderNums> buyOrderNumList = buyerOrderMapper.selectCntByUidStatusAll(uid);
if (CollectionUtils.isEmpty(buyOrderNumList)){
if (CollectionUtils.isEmpty(buyOrderNumList)) {
return BuyerOrderNums.builder().build();
}
... ... @@ -618,12 +611,12 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
return buyerOrderNums;
}
private int getValueDefalutZero(Map<Integer, Integer> map, List<Integer> status){
private int getValueDefalutZero(Map<Integer, Integer> map, List<Integer> status) {
int sum = 0;
for(Integer key : status){
for (Integer key : status) {
int num = Objects.isNull(map.get(key)) ? 0 : map.get(key);
sum+=num;
sum += num;
}
return sum;
... ... @@ -633,54 +626,52 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
@Override
public boolean delete(int uid, long orderCode) {
if (uid < 0
|| orderCode < 0){
|| orderCode < 0) {
logger.warn("buyer delete, uid or orderCode empty, uid {}, orderCode {}", uid, orderCode);
throw new ServiceException(ServiceError.ORDER_REQUEST_PARM_IS_EMPTY);
}
BuyerOrder buyerOrder = buyerOrderMapper.selectByOrderCodeUid(orderCode, uid);
if (Objects.isNull(buyerOrder) || buyerOrder.getBuyerOrderStatus() == DelStatus.IS_DEL.getCode()){
if (Objects.isNull(buyerOrder) || buyerOrder.getBuyerOrderStatus() == DelStatus.IS_DEL.getCode()) {
logger.warn("buyer delete, order not exist, uid {}, orderCode {}", uid, orderCode);
return false;
}
Integer status;
if(ActionStatusHold.getBuyerCanDelStatusList().contains(status=buyerOrder.getStatus())){
if (ActionStatusHold.getBuyerCanDelStatusList().contains(status = buyerOrder.getStatus())) {
BuyerOrder target = new BuyerOrder();
target.setId(buyerOrder.getId());
target.setBuyerOrderStatus(DelStatus.IS_DEL.getCode());
boolean result = buyerOrderMapper.updateByPrimaryKeySelective(target) == 1;
if(result){
if (result) {
cacheCleaner.cleanList(uid, TabType.BUY.getValue());
}
return result;
}else{
} else {
logger.warn("buyer delete fail, order status {}", status);
}
return false;
}
@Override
public void confirmReceive(long orderCode) {
logger.info("in confirmReceive, orderCode {}", orderCode);
if(serviceOrderProcessor.isGoodsServiceOrder(orderCode)){
if (serviceOrderProcessor.isGoodsServiceOrder(orderCode)) {
logger.info("in confirmReceive isGoodsServiceOrder, orderCode {}", orderCode);
ServiceOrderProcessor.ExistenceNode existenceNode = serviceOrderProcessor.findGoodsServiceInstanceAndExt(orderCode);
int rows = existenceNode.getGoodsService().platformReceiveGoods(existenceNode.appraiseOrder);
if (rows==0){
if (rows == 0) {
return;
}
// 确认收货过来的是子订单号
int uid = existenceNode.getAppraiseOrder().getUid();
Long parentOrderCode = existenceNode.getAppraiseOrder().getParentOrderCode();
if (parentOrderCode == null){
if (parentOrderCode == null) {
// 平台收货 内部调拨信息
EnumExpressType expressType = EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER;
EnumExpressDataType expressDataType = EnumExpressDataType.operate_transfer;
EnumExpressDataOperateTransferCode operateTransferCode = EnumExpressDataOperateTransferCode.platform_receive;
expressInfoService.saveOperateTransferExpressInfo(existenceNode.getAppraiseOrder().getUid(), orderCode ,expressType.getCode(),expressDataType,operateTransferCode);
expressInfoService.saveOperateTransferExpressInfo(existenceNode.getAppraiseOrder().getUid(), orderCode, expressType.getCode(), expressDataType, operateTransferCode);
return;
}
// 上一个状态是[卖家已发货] 该父订单下状态为[卖家已发货]的子订单数量为0,代表父订单状态应该为 [已收货]
... ... @@ -689,28 +680,28 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
logger.info("no confirm delivery sub order cnt is {}, parentOrderCode {}", cnt, parentOrderCode);
int cdt = DateUtil.getCurrentTimeSecond();
//
if (cnt == 0){
if (cnt == 0) {
// 平台收货 内部调拨信息
try {
EnumExpressType expressType = EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER;
EnumExpressDataType expressDataType = EnumExpressDataType.operate_transfer;
EnumExpressDataOperateTransferCode operateTransferCode = EnumExpressDataOperateTransferCode.platform_receive;
expressInfoService.saveOperateTransferExpressInfo(existenceNode.getAppraiseOrder().getUid(), parentOrderCode, expressType.getCode(), expressDataType, operateTransferCode);
}catch (Exception ex){
} catch (Exception ex) {
logger.warn("in confirmReceive isGoodsServiceOrder saveOperateTransferExpressInfo fail ,orderCode {} ", orderCode, ex);
}
//update
sellerDepositOrderService.platformFinishReceiveGoods(uid, parentOrderCode);
}
}else{
} else {
confirmReceive4BuyerOrder(orderCode);
}
}
private void confirmReceive4BuyerOrder(long orderCode){
private void confirmReceive4BuyerOrder(long orderCode) {
OrderStatus expectStatus = OrderStatus.SELLER_SEND_OUT;
OrderStatus targetStatus = OrderStatus.PLATFORM_RECEIVE;
... ... @@ -718,40 +709,41 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
BuyerOrderAssistant.PreparedData preparedData = buyerOrderAssistant.prepare(orderCode);
BuyerOrder buyerOrder = preparedData.getBuyerOrder();
if (buyerOrder != null && buyerOrder.getStatus() == expectStatus.getCode()){
if (buyerOrder != null && buyerOrder.getStatus() == expectStatus.getCode()) {
int uid = buyerOrder.getUid();
int sellerUid = buyerOrder.getSellerUid();
logger.info("in confirmReceive begin update status orderCode {},uid {} ,sellerUid {}", orderCode,uid,sellerUid);
logger.info("in confirmReceive begin update status orderCode {},uid {} ,sellerUid {}", orderCode, uid, sellerUid);
int num = buyerOrderMapper.updateStatusByOrderCode(orderCode, uid, expectStatus.getCode(),
targetStatus.getCode(), DateUtil.getCurrentTimeSecond());
//记录订单的状态变更信息
if(num>=1){
logger.info("in confirmReceive record status change, orderCode {},uid {} ,sellerUid {}", orderCode,uid,sellerUid);
if (num >= 1) {
logger.info("in confirmReceive record status change, orderCode {},uid {} ,sellerUid {}", orderCode, uid, sellerUid);
buyerNoticeFacade.platformReceiveGoods(buyerOrder);
orderStatusFlowService.addAsy(buyerOrder.getOrderCode(),targetStatus.getCode());
orderStatusFlowService.addAsy(buyerOrder.getOrderCode(), targetStatus.getCode());
//
finishDepositGoodsIf(preparedData);
}else{
logger.warn("in confirmReceive not record status change cause of update empty num , orderCode {},uid {} ,sellerUid {}", orderCode,uid,sellerUid);
} else {
logger.warn("in confirmReceive not record status change cause of update empty num , orderCode {},uid {} ,sellerUid {}", orderCode, uid, sellerUid);
}
//记录调拨信息(只保存卖家一条)
EnumExpressType expressType = EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER;
EnumExpressDataType expressDataType = EnumExpressDataType.operate_transfer;
EnumExpressDataOperateTransferCode operateTransferCode = EnumExpressDataOperateTransferCode.platform_receive;
expressInfoService.saveOperateTransferExpressInfo(sellerUid,orderCode,expressType.getCode(),expressDataType,operateTransferCode);
expressInfoService.saveOperateTransferExpressInfo(sellerUid, orderCode, expressType.getCode(), expressDataType, operateTransferCode);
cleanCacheAfterUpdateStatus(orderCode,uid,sellerUid);
cleanCacheAfterUpdateStatus(orderCode, uid, sellerUid);
}
}
/**
* 现货寄存订单
* 卖家使用寄存商品发货
*
* @param preparedData
*/
private void finishDepositGoodsIf(BuyerOrderAssistant.PreparedData preparedData){
private void finishDepositGoodsIf(BuyerOrderAssistant.PreparedData preparedData) {
BuyerOrder buyerOrder = preparedData.getBuyerOrder();
int uid = buyerOrder.getUid();
Long orderCode = buyerOrder.getOrderCode();
... ... @@ -759,11 +751,11 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
SkupType skupType = SkupType.getSkupType(psog.getAttributes());
boolean isInstockDepositOrder = BuyerOrderUtils.isInstockDeposit(skupType, buyerOrder.getAttributes());
logger.info("platform confirmReceive orderCode {} buyerUid {} isInstockDepositOrder {}", orderCode, uid, isInstockDepositOrder);
if(isInstockDepositOrder){
if (isInstockDepositOrder) {
String depositCode = buyerOrderMetaService.getDepositCode(uid, orderCode);
logger.info("platform confirmReceive orderCode {} buyerUid {} isInstockDepositOrder {} depositCode {}",
orderCode, uid, isInstockDepositOrder, depositCode);
if (StringUtils.isNotBlank(depositCode)){
if (StringUtils.isNotBlank(depositCode)) {
int depositUpdate = depositService.updateDelStatus(psog.getUid(), depositCode);
logger.info("platform confirmReceive update deposit DelStatus {} orderCode {} buyerUid {} depositCode {}",
depositUpdate, orderCode, uid, depositCode);
... ... @@ -775,65 +767,64 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
// 质检通过,不需要记录物流调拨信息
@Override
@Deprecated
public void qualityCheckPass(long orderCode){
public void qualityCheckPass(long orderCode) {
logger.info("in qualityCheckPass, orderCode {}", orderCode);
OrderStatus expectStatus = OrderStatus.PLATFORM_RECEIVE;
OrderStatus targetStatus = OrderStatus.PLATFORM_CHECKING;
BuyerOrder buyerOrder = buyerOrderMapper.selectByOrderCode(orderCode);
if (buyerOrder != null && buyerOrder.getStatus() == expectStatus.getCode()){
if (buyerOrder != null && buyerOrder.getStatus() == expectStatus.getCode()) {
int uid = buyerOrder.getUid();
int sellerUid = buyerOrder.getSellerUid();
logger.info("in qualityCheckPass begin update status orderCode {},uid {} ,sellerUid {}", orderCode,uid,sellerUid);
int num=buyerOrderMapper.updateStatusByOrderCode(orderCode, uid, expectStatus.getCode(),
logger.info("in qualityCheckPass begin update status orderCode {},uid {} ,sellerUid {}", orderCode, uid, sellerUid);
int num = buyerOrderMapper.updateStatusByOrderCode(orderCode, uid, expectStatus.getCode(),
targetStatus.getCode(), DateUtil.getCurrentTimeSecond());
//记录订单的状态变更信息
if(num>=1){
logger.info("in qualityCheckPass record status change, orderCode {},uid {} ,sellerUid {}", orderCode,uid,sellerUid);
orderStatusFlowService.addAsy(buyerOrder.getOrderCode(),targetStatus.getCode());
if (num >= 1) {
logger.info("in qualityCheckPass record status change, orderCode {},uid {} ,sellerUid {}", orderCode, uid, sellerUid);
orderStatusFlowService.addAsy(buyerOrder.getOrderCode(), targetStatus.getCode());
//记录调拨信息(只保存卖家一条)
EnumExpressType expressType = EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER;
EnumExpressDataType expressDataType = EnumExpressDataType.operate_transfer;
EnumExpressDataOperateTransferCode operateTransferCode = EnumExpressDataOperateTransferCode.judging;
expressInfoService.saveOperateTransferExpressInfo(sellerUid,orderCode,expressType.getCode(),expressDataType,operateTransferCode);
expressInfoService.saveOperateTransferExpressInfo(sellerUid, orderCode, expressType.getCode(), expressDataType, operateTransferCode);
}else{
logger.warn("in qualityCheckPass not record status change cause of update empty num , orderCode {},uid {} ,sellerUid {}", orderCode,uid,sellerUid);
} else {
logger.warn("in qualityCheckPass not record status change cause of update empty num , orderCode {},uid {} ,sellerUid {}", orderCode, uid, sellerUid);
}
cleanCacheAfterUpdateStatus(orderCode,uid,sellerUid);
cleanCacheAfterUpdateStatus(orderCode, uid, sellerUid);
}
}
// 瑕疵创建
@Override
public void miniFaultCreate(SaveQualityCheckInfoRequest request){
public void miniFaultCreate(SaveQualityCheckInfoRequest request) {
logger.info("in miniFaultCreate, orderCode {}", request);
long orderCode = request.getOrderCode();
QualityCheck qualityCheck = request.getQualityCheck();
OrderStatus expectStatus = OrderStatus.PLATFORM_RECEIVE;
OrderStatus targetStatus = OrderStatus.MINI_FAULT_WAITING;
BuyerOrder buyerOrder = buyerOrderMapper.selectByOrderCode(orderCode);
if (buyerOrder == null ){
throw new ServiceException(400,"订单为空");
if (buyerOrder == null) {
throw new ServiceException(400, "订单为空");
}
if( buyerOrder.getStatus() != expectStatus.getCode()){
throw new ServiceException(400,"订单状态发生变化");
if (buyerOrder.getStatus() != expectStatus.getCode()) {
throw new ServiceException(400, "订单状态发生变化");
}
int uid = buyerOrder.getUid();
int sellerUid = buyerOrder.getSellerUid();
//保存质检有问题的图片信息
if(qualityCheck==null){
logger.warn("in miniFaultCreate qualityCheck is null, orderCode {},uid {} ,sellerUid {}", orderCode,uid,sellerUid);
throw new ServiceException(400,"瑕疵信息为空");
if (qualityCheck == null) {
logger.warn("in miniFaultCreate qualityCheck is null, orderCode {},uid {} ,sellerUid {}", orderCode, uid, sellerUid);
throw new ServiceException(400, "瑕疵信息为空");
}
qualityCheckMapper.insert(qualityCheck);
... ... @@ -845,24 +836,24 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
EnumExpressType expressType = EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER;
EnumExpressDataType expressDataType = EnumExpressDataType.operate_transfer;
EnumExpressDataOperateTransferCode operateTransferCode = EnumExpressDataOperateTransferCode.judging;
expressInfoService.saveOperateTransferExpressInfo(sellerUid,orderCode,expressType.getCode(),expressDataType,operateTransferCode);
expressInfoService.saveOperateTransferExpressInfo(sellerUid, orderCode, expressType.getCode(), expressDataType, operateTransferCode);
//记录调拨信息(只保存卖家一条)
expressType = EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER;
expressDataType = EnumExpressDataType.operate_transfer;
operateTransferCode = EnumExpressDataOperateTransferCode.mini_fault_create;
expressInfoService.saveOperateTransferExpressInfo(sellerUid,orderCode,expressType.getCode(),expressDataType,operateTransferCode);
expressInfoService.saveOperateTransferExpressInfo(sellerUid, orderCode, expressType.getCode(), expressDataType, operateTransferCode);
//TODO 产生一个延时队列(24小时后,超时确认)
BuyerMiniFaultOuterTimeEvent miniFaultOuterTimeEvent = BuyerMiniFaultOuterTimeEvent.builder().uid(uid).orderCode(orderCode).build();
logger.info("in miniFaultCreate, push event uid {} ,order code {} ", miniFaultOuterTimeEvent.getUid(),miniFaultOuterTimeEvent.getOrderCode());
logger.info("in miniFaultCreate, push event uid {} ,order code {} ", miniFaultOuterTimeEvent.getUid(), miniFaultOuterTimeEvent.getOrderCode());
EventBusPublisher.publishEvent(miniFaultOuterTimeEvent);
SellerOrderGoods sellerOrderGoods = cleanCacheAfterUpdateStatus(orderCode,uid,sellerUid);
SellerOrderGoods sellerOrderGoods = cleanCacheAfterUpdateStatus(orderCode, uid, sellerUid);
Product product = Optional.ofNullable(sellerOrderGoods).map(SellerOrderGoods::getProductId).map(productMapper::selectByPrimaryKey).orElse(null);
//消息
buyerNoticeFacade.miniFaultCreated(buyerOrder,sellerOrderGoods,product);
buyerNoticeFacade.miniFaultCreated(buyerOrder, sellerOrderGoods, product);
//记录订单的状态变更信息
logger.info("in miniFaultCreate record status change, orderCode {},uid {} ,sellerUid {}", orderCode, uid, sellerUid);
... ... @@ -871,29 +862,27 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
}
@Override
public void modifyAddressOfDepositOrder(int uid, Long orderCode, String addressIdstr) {
if (serviceOrderProcessor.isGoodsServiceOrder(orderCode)){
if (serviceOrderProcessor.isGoodsServiceOrder(orderCode)) {
sellerDepositOrderService.addOrModifyAddress(uid, orderCode, addressIdstr);
return;
}
int addressId = AddressUtil.getDecryptStr(addressIdstr);
if (addressId < 0){
if (addressId < 0) {
logger.warn("modifyAddressOfDepositOrder addressId invalidate, uid {}, orderCode {}, addressId is {}",
uid, orderCode, addressIdstr);
throw new ServiceException(ServiceError.ORDER_ADDRESSID_INVALIDATE);
}
BuyerOrder pbo = buyerOrderMapper.selectOnlyByOrderCode(orderCode);
if (pbo == null ){
if (pbo == null) {
logger.warn("in modifyAddressOfDepositOrder BuyerOrder is null,uid {} orderCode {} addressIdstr {}",
uid, orderCode, addressIdstr);
return;
}
Integer oa;
if (OrderAttributes.DEPOSITE.getCode() != (oa=pbo.getAttributes())){
if (OrderAttributes.DEPOSITE.getCode() != (oa = pbo.getAttributes())) {
logger.warn("in modifyAddressOfDepositOrder BuyerOrder.Attributes is {},uid {} orderCode {} addressIdstr {}",
oa, uid, orderCode, addressIdstr);
return;
... ... @@ -936,7 +925,7 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
@Override
public BuyerOrderMeta buildnoHiddenAddressMeta(int uid, long orderCode, String key, AddressInfo noHiddenBackAddress) {
BuyerOrderMeta noHiddenAddressMeta=new BuyerOrderMeta();
BuyerOrderMeta noHiddenAddressMeta = new BuyerOrderMeta();
noHiddenAddressMeta.setUid(uid);
noHiddenAddressMeta.setOrderCode(orderCode);
noHiddenAddressMeta.setMetaKey(key);
... ... @@ -946,7 +935,7 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
@Override
public BuyerOrderMeta buildHiddenAddressMeta(int uid, long orderCode, String hiddenKey, AddressInfo hiddenBackAddress) {
BuyerOrderMeta hiddenAddressMeta=new BuyerOrderMeta();
BuyerOrderMeta hiddenAddressMeta = new BuyerOrderMeta();
hiddenAddressMeta.setUid(uid);
hiddenAddressMeta.setOrderCode(orderCode);
hiddenAddressMeta.setMetaKey(hiddenKey);
... ... @@ -968,13 +957,11 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
}
//清理缓存
private SellerOrderGoods cleanCacheAfterUpdateStatus(long orderCode,int uid,int sellerUid){
private SellerOrderGoods cleanCacheAfterUpdateStatus(long orderCode, int uid, int sellerUid) {
BuyerOrderGoods bog = buyerOrderGoodsMapper.selectByOrderCode(uid, orderCode);
SellerOrderGoods sellerOrderGoods = sellerOrderGoodsMapper.selectByPrimaryKey(bog.getSkup());
logger.info("in cleanCacheAfterUpdateStatus begin clean cache orderCode {},uid {} ,sellerUid {}", orderCode,uid,sellerUid);
logger.info("in cleanCacheAfterUpdateStatus begin clean cache orderCode {},uid {} ,sellerUid {}", orderCode, uid, sellerUid);
cacheCleaner.cleanSellerAndBuyerOrderDetailAndList(sellerUid, uid, orderCode);
... ... @@ -984,12 +971,11 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
}
@Override
public int processOrderDeliverByDepositGoods(BuyerOrderAssistant.PreparedData preparedData,
BuyerOrderAssistant.DepositSkuCheckNode dscNode){
BuyerOrderAssistant.DepositSkuCheckNode dscNode) {
if (!dscNode.isExistDepositGoods()){
if (!dscNode.isExistDepositGoods()) {
return 0;
}
BuyerOrderGoods pbog = preparedData.getBuyerOrderGoods();
... ... @@ -1001,7 +987,7 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
Integer ownerUid = psd.getOwnerUid();
Integer sellerUid = buyerOrder.getSellerUid();
Integer skup;
boolean isExistSkup = Objects.nonNull(skup = psd.getNewSkup()) && skup>0;
boolean isExistSkup = Objects.nonNull(skup = psd.getNewSkup()) && skup > 0;
logger.info("processOrderDeliverByDepositGoods orderCode {} depositCode {} skup {}", orderCode, depositCode, skup);
//寄存商品 出库准备
... ... @@ -1031,7 +1017,7 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
logger.info("processOrderDeliverByDepositGoods orderCode {} depositCode {} updateDepositWaitToPick {}", orderCode, depositCode, rows);
if (rows>0){
if (rows > 0) {
//bind deposit code 2 buyer order
buyerOrderMetaService.saveDepositCode(depositCode, buyerUid, orderCode);
//check
... ... @@ -1041,7 +1027,7 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
//skup 下架
//skup 竟然在数据库有默认值0,什么鬼!!!
if (isExistSkup){
if (isExistSkup) {
// 减库存
asyncExecutePrdTask(psd);
//
... ... @@ -1052,11 +1038,11 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
}
private Future<Boolean> asyncExecutePrdTask(StorageDeposit psd){
private Future<Boolean> asyncExecutePrdTask(StorageDeposit psd) {
Integer skup = psd.getNewSkup();
Integer productId = psd.getProductId();
final ExecutorService executorService = ThreadPoolFactory.getCommomExecutorService();
FutureTask<Boolean> futureTask = new FutureTask<>(()->productProxyService.subtractStorage(productId, skup));
FutureTask<Boolean> futureTask = new FutureTask<>(() -> productProxyService.subtractStorage(productId, skup));
executorService.submit(futureTask);
logger.info("asyncExecutePrdTask submit task, skup {} productId {}", skup, productId);
return futureTask;
... ... @@ -1065,6 +1051,7 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
/**
* 这个方法请尽量保持单一原则
* 如果有复杂的业务逻辑 如入参数据需要动态判定时 请在调用前处理
*
* @param preparedData (include buyerOrder)
* @param req4Log
* @return
... ... @@ -1074,7 +1061,7 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
OrderStatus targetOrderStatus,
SellerDeliverToDepotReq req4Log
){
) {
/*Integer expressCompanyId,
Integer expressType,
String wayBillCode,*/
... ... @@ -1085,7 +1072,7 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
final OrderStatus expectOrderStatus = OrderStatus.HAS_PAYED;
logger.info("processBuyerOrderWhenSellerDeliver req {}, orderCode {},expectOrderStatus {} ,targetOrderStatus {} ",
new Object[]{req4Log, orderCode, expectOrderStatus, targetOrderStatus});
new Object[]{req4Log, orderCode, expectOrderStatus, targetOrderStatus});
Integer orderStatus = buyerOrder.getStatus();
if (orderStatus != expectOrderStatus.getCode()) {
logger.warn("deliverToDepot order status changed , orderCode {} orderStatus {}", orderCode, orderStatus);
... ... @@ -1103,7 +1090,7 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
int updateBuyerCnt = buyerOrderMapper.updateStatusByOrderCode(orderCode, buyerOrder.getUid(),
expectOrderStatus.getCode(), targetOrderStatus.getCode(), DateUtil.getCurrentTimeSecond());
logger.info("processBuyerOrderWhenSellerDeliver updateBuyerCnt {}, orderCode {}", updateBuyerCnt, orderCode);
if (updateBuyerCnt>0){
if (updateBuyerCnt > 0) {
//根据skup ,更新鉴定中心
int skup;
skupService.setDepotNum(skup = buyerOrderGoods.getSkup(), depotNum);
... ... @@ -1112,12 +1099,12 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
final SellerOrderGoods psog = preparedData.getSellerOrderGoods();
// 极速: 无需再向买家发一遍[卖家发货]消息 & 虚拟单号无物流
if (psog.getAttributes() == OrderAttributes.FAST_DELIVERY.getCode()){
if (psog.getAttributes() == OrderAttributes.FAST_DELIVERY.getCode()) {
// 物流直接更新成1
buyerOrderMapper.updateSellerDeliveryStatusByOrderCode(orderCode, buyerUid,1);
}else{
if (targetOrderStatus == OrderStatus.SELLER_SEND_OUT){
buyerOrderMapper.updateSellerDeliveryStatusByOrderCode(orderCode, buyerUid, 1);
} else {
if (targetOrderStatus == OrderStatus.SELLER_SEND_OUT) {
buyerNoticeFacade.sellerDeliver2Depot(buyerOrder, psog);
//卖家物流检查
BuyerOrderSellerDeliveryCheckEvent sellerDeliveryCheckEvent = BuyerOrderSellerDeliveryCheckEvent.builder().uid(buyerUid).sellerUid(sellerUid).orderCode(orderCode).build();
... ... @@ -1127,7 +1114,7 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
//
try {
cacheCleaner.cleanSellerAndBuyerOrderDetailAndList(sellerUid, buyerUid, orderCode);
}catch (Exception ex){
} catch (Exception ex) {
logger.warn("{}.processBuyerOrder clean cache fail, {}", getClass().getSimpleName(), orderCode, ex);
}
... ...
package com.yohoufo.order.service.impl.function;
import com.yohoufo.dal.order.model.BuyerOrder;
public interface BuyerOrderNoticeSender {
void notice(BuyerOrder buyerOrder);
}
... ...
... ... @@ -503,12 +503,27 @@ public class BuyerNoticeFacade extends BaseNoticeFacade {
.send();
}
public void noticeBuyerOfSellerShamSendOut(BuyerNoticeSender.Request request) {
public void noticeBuyerOfSellerCanNotSendOut(BuyerOrder buyerOrder) {
String logPrefix = "notice buyer of seller can not send out";
Integer uid = buyerOrder.getUid();
Long orderCode = buyerOrder.getOrderCode();
try {
newBuyerNotice(buyerOrder)
.withLogPrefix(logPrefix)
.withInBox(InboxBusinessTypeEnum.NOTICE_BUYER_SELLER_CAN_NOT_SEND_OUT, orderCode)
.withSms(InboxBusinessTypeEnum.SMS_NOTICE_BUYER_SELLER_CAN_NOT_SEND_OUT, orderCode)
.send();
} catch (Exception e) {
log.warn("{} fail,uid {}", logPrefix, uid, e);
}
}
public void noticeBuyerOfSellerShamSendOut(BuyerOrder buyerOrder) {
String logPrefix = "notice buyer of seller sham send out";
Integer uid = request.getUid();
Long orderCode = request.getOrderCode();
Integer uid = buyerOrder.getUid();
Long orderCode = buyerOrder.getOrderCode();
try {
BuyerOrder buyerOrder = buyerOrderMapper.selectByOrderCode(orderCode);
newBuyerNotice(buyerOrder)
.withLogPrefix(logPrefix)
.withInBox(InboxBusinessTypeEnum.NOTICE_BUYER_SELLER_SHAM_SEND_OUT, orderCode)
... ...
... ... @@ -368,7 +368,7 @@ public class SellerNoticeFacade extends BaseNoticeFacade {
String goodsTypeTag = buildGoodsTypeTag(sog, buyerOrder, TabType.SELL);
MsgSendFlg msgSendFlg = fastDeliveryProxyService.isFastDeliveryGoods(sog.getId()) ? MsgSendFlg.FAST_DELIVERY : MsgSendFlg.OTHER;
try {
Supplier<Product> productSupplier = ()-> productMapper.selectByPrimaryKey(sog.getProductId());
Supplier<Product> productSupplier = () -> productMapper.selectByPrimaryKey(sog.getProductId());
if (times == OrderConstant.SellerDeliverNotice.SECOND_TIME
|| times == OrderConstant.SellerDeliverNotice.LAST_TIME) {
Product product = productSupplier.get();
... ... @@ -380,7 +380,7 @@ public class SellerNoticeFacade extends BaseNoticeFacade {
.withInBox(InboxBusinessTypeEnum.NOTICE_SELLER_DELIVER_GOODS, goodsTypeTag, prdName, sizeName, productCode, leftTime, timeUnit)
.withSms(InboxBusinessTypeEnum.SMS_NOTIFIED_SEND_SECOND, goodsTypeTag, prdName, sizeName, productCode, leftTime, timeUnit, orderCode)
.send();
}else if (times == OrderConstant.SellerDeliverNotice.TIME_OF_CANCELED) {
} else if (times == OrderConstant.SellerDeliverNotice.TIME_OF_CANCELED) {
Product product = productSupplier.get();
String productCode = product.getProductCode();
newSellerNotice(sog)
... ... @@ -609,6 +609,27 @@ public class SellerNoticeFacade extends BaseNoticeFacade {
}
}
public void noticeSellerOfSellerCanNotSendOut(SellerOrderGoods sog, BuyerOrder buyerOrder) {
Integer sellerUid = sog.getUid();
String prdName = sog.getProductName();
String sizeName = sog.getSizeName();
try {
String goodsTypeTag = buildGoodsTypeTag(sog, buyerOrder, TabType.SELL);
boolean isFastDelivery = fastDeliveryProxyService.isFastDeliveryGoods(sog.getId());
Product product = productMapper.selectByPrimaryKey(sog.getProductId());
String productCode = product.getProductCode();
newSellerNotice(sog)
.withLogPrefix("notice seller of seller can not send out")
.withInBox(InboxBusinessTypeEnum.NOTICE_SELLER_SELLER_CAN_NOT_SEND_OUT,
goodsTypeTag, prdName, sizeName, productCode)
.withSmsIf(!isFastDelivery, InboxBusinessTypeEnum.SMS_NOTICE_SELLER_SELLER_CAN_NOT_SEND_OUT,
goodsTypeTag, prdName, sizeName, productCode, buyerOrder.getOrderCode())
.send();
} catch (Exception e) {
log.warn("notice seller of seller can not send out fail, sellerUid {}, prdName {} ", sellerUid, prdName, e);
}
}
/**
* 质检不通过,给卖家消息
*/
... ... @@ -907,7 +928,7 @@ public class SellerNoticeFacade extends BaseNoticeFacade {
}
public void buyerOrderCancelByBuyerPullWool(SellerOrderGoods sog){
public void buyerOrderCancelByBuyerPullWool(SellerOrderGoods sog) {
InboxBusinessTypeEnum ibtOfsms = InboxBusinessTypeEnum.SMS_NOTICE_SELLER_WHEN_BUYER_PULL_WOOL;
InboxBusinessTypeEnum ibt = InboxBusinessTypeEnum.NOTICE_SELLER_WHEN_BUYER_PULL_WOOL;
Integer sellerUid = sog.getUid();
... ... @@ -923,7 +944,7 @@ public class SellerNoticeFacade extends BaseNoticeFacade {
.withInBox(ibt, inboxParams)
.withSms(ibtOfsms, smsParams)
.send();
}catch (Exception ex){
} catch (Exception ex) {
log.warn("notice seller buyerOrderCancelByBuyerPullWool fail, sellerUid {}, skup {} ", sellerUid, sog.getId(), ex);
}
}
... ...