...
|
...
|
@@ -36,9 +36,7 @@ import com.yohoufo.order.service.handler.RefundEarnestMoneyHandler; |
|
|
import com.yohoufo.order.service.handler.RefundGoodsMoneyHandler;
|
|
|
import com.yohoufo.order.service.handler.penalty.PenaltyResult;
|
|
|
import com.yohoufo.order.service.handler.penalty.SellerEarnestMoney2BuyerPenaltyCalculator;
|
|
|
import com.yohoufo.order.service.impl.visitor.AutoCancelCase;
|
|
|
import com.yohoufo.order.service.impl.visitor.OffShelveCancelCase;
|
|
|
import com.yohoufo.order.service.impl.visitor.UserCancelCase;
|
|
|
import com.yohoufo.order.service.impl.visitor.*;
|
|
|
import com.yohoufo.order.service.pay.AbstractPayService;
|
|
|
import com.yohoufo.order.service.proxy.InBoxFacade;
|
|
|
import com.yohoufo.order.service.proxy.OrderStatusFlowService;
|
...
|
...
|
@@ -700,9 +698,13 @@ public class SellerOrderCancelService { |
|
|
* @param offShelveCancelCase
|
|
|
*/
|
|
|
public void cancel(OffShelveCancelCase offShelveCancelCase){
|
|
|
logger.info("in cancel offShelveCancelCase {}", offShelveCancelCase);
|
|
|
|
|
|
ErpCancelSellerOrderEvent event = (ErpCancelSellerOrderEvent)offShelveCancelCase.getEvent();
|
|
|
final int skup = event.getSkup();
|
|
|
logger.info("in cancel offShelveCancelCase {}", skup);
|
|
|
SkupStatus expectSkupStatus = SkupStatus.CAN_SELL;
|
|
|
final SellerOrderStatus targetSellerOrderStatus = SellerOrderStatus.YOHO_CANCEL_SELL;
|
|
|
/*
|
|
|
if (skup <= 0){
|
|
|
logger.warn("in offShelveCancelCase ,skup is illegal, skup {}", skup);
|
|
|
return;
|
...
|
...
|
@@ -714,14 +716,14 @@ public class SellerOrderCancelService { |
|
|
return;
|
|
|
}
|
|
|
|
|
|
SkupStatus expectSkupStatus = SkupStatus.CAN_SELL;
|
|
|
|
|
|
boolean earnestMoneyPaidFlag = expectSkupStatus.getCode() == skupStatus;
|
|
|
if (!earnestMoneyPaidFlag){
|
|
|
logger.warn("in offShelveCancelCase, SellerOrderGoods status illegal, skup {}, status {}", skup, skupStatus);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
final SellerOrderStatus targetSellerOrderStatus = SellerOrderStatus.YOHO_CANCEL_SELL;
|
|
|
|
|
|
SellerOrderGoods targetGoods = new SellerOrderGoods();
|
|
|
targetGoods.setId(skup);
|
|
|
targetGoods.setStatus(targetSellerOrderStatus.getSkupStatus().getCode());
|
...
|
...
|
@@ -782,8 +784,134 @@ public class SellerOrderCancelService { |
|
|
.loadSeller(sellerUid, sellerIsSuper, orderCode, targetSellerOrderStatus)
|
|
|
.loadLogger(logger)
|
|
|
.refund();
|
|
|
|
|
|
*/
|
|
|
CancelStatusNode csn = new CancelStatusNode();
|
|
|
csn.skup = skup;
|
|
|
csn.expectSkupStatus = expectSkupStatus;
|
|
|
csn.targetSellerOrderStatus = targetSellerOrderStatus;
|
|
|
CancelPreparedNode cpn = doCancelByErp(csn, offShelveCancelCase);
|
|
|
SellerOrderGoods psog = cpn.psog;
|
|
|
Integer sellerUid = psog.getUid();
|
|
|
inBoxFacade.notifyUnshelfCauseBySpecialReason(sellerUid, psog);
|
|
|
}
|
|
|
private static class CancelStatusNode{
|
|
|
int skup;
|
|
|
SkupStatus expectSkupStatus;
|
|
|
SellerOrderStatus targetSellerOrderStatus;
|
|
|
}
|
|
|
private static class CancelPreparedNode{
|
|
|
SellerOrderGoods psog;
|
|
|
}
|
|
|
|
|
|
private CancelPreparedNode doCancelByErp(CancelStatusNode csn, OrderCancelCase orderCancelCase){
|
|
|
int skup = csn.skup;
|
|
|
String caseName = orderCancelCase.caseName();
|
|
|
logger.info("in cancel {} skup {}", caseName, skup);
|
|
|
CancelPreparedNode cpn = null;
|
|
|
if (skup <= 0){
|
|
|
logger.warn("in {} ,skup is illegal, skup {}", caseName, skup);
|
|
|
return cpn;
|
|
|
}
|
|
|
SellerOrderGoods psog = sellerOrderGoodsMapper.selectByPrimaryKey(skup);
|
|
|
Integer skupStatus;
|
|
|
if (psog == null || (skupStatus = psog.getStatus() )== null){
|
|
|
logger.warn("in {}, SellerOrderGoods or it's status illegal, skup {}", caseName,skup);
|
|
|
return cpn;
|
|
|
}
|
|
|
|
|
|
SkupStatus expectSkupStatus = SkupStatus.CAN_SELL;
|
|
|
boolean earnestMoneyPaidFlag = expectSkupStatus.getCode() == skupStatus;
|
|
|
if (!earnestMoneyPaidFlag){
|
|
|
logger.warn("in {}, SellerOrderGoods status illegal, skup {}, status {}", caseName, skup, skupStatus);
|
|
|
return cpn;
|
|
|
}
|
|
|
|
|
|
final SellerOrderStatus targetSellerOrderStatus = SellerOrderStatus.YOHO_CANCEL_SELL;
|
|
|
SellerOrderGoods targetGoods = new SellerOrderGoods();
|
|
|
targetGoods.setId(skup);
|
|
|
targetGoods.setStatus(targetSellerOrderStatus.getSkupStatus().getCode());
|
|
|
targetGoods.setExceptStatus(skupStatus);
|
|
|
//利用数据库做并发控制
|
|
|
int result = sellerOrderGoodsMapper.updateStatusBySkpu(targetGoods);
|
|
|
|
|
|
if (result == 0) {
|
|
|
logger.warn("in {}, update status fail, skup {}, skupStatus {}", caseName, skup, skupStatus);
|
|
|
return cpn;
|
|
|
}
|
|
|
SellerOrder sellerOrder = sellerOrderMapper.selectBySkup(skup);
|
|
|
Integer sellerUid = sellerOrder.getUid();
|
|
|
final Long orderCode = sellerOrder.getOrderCode();
|
|
|
//update
|
|
|
SellerOrder tso = new SellerOrder();
|
|
|
tso.setOrderCode(orderCode);
|
|
|
tso.setExceptStatus(sellerOrder.getStatus());
|
|
|
tso.setStatus(targetSellerOrderStatus.getCode());
|
|
|
tso.setUid(sellerUid);
|
|
|
tso.setUpdateTime(DateUtil.getCurrentTimeSecond());
|
|
|
sellerOrderMapper.updateByOrderCode(tso);
|
|
|
//
|
|
|
cacheCleaner.cleanList(sellerUid, TabType.SELL.getValue());
|
|
|
cacheCleaner.cleanSellerDetail(psog);
|
|
|
double earnestMoney = sellerOrder.getEarnestMoney().doubleValue();
|
|
|
|
|
|
Integer sop = sellerOrder.getPayment() == null ? 0 : sellerOrder.getPayment();
|
|
|
|
|
|
boolean sellerIsSuper = sellerService.isSuperEntrySeller(sellerUid);
|
|
|
|
|
|
//不是超级卖家 ,上架商品用钱包支付保证金
|
|
|
MerchantOrderAttachInfo moai = null;
|
|
|
if(!sellerIsSuper && PaymentHelper.isWallet(sop)){
|
|
|
moai = MerchantOrderAttachInfo.builder().uid(sellerUid)
|
|
|
.orderCode(orderCode).skup(skup).earnestMoney(sellerOrder.getEarnestMoney())
|
|
|
.type(SellerWalletDetail.Type.SYSTEM_OFF.getValue()).build();
|
|
|
}
|
|
|
|
|
|
BillLogEvent.BillLogEventBuilder bleb = BillLogEvent.builder()
|
|
|
.sellerUid(sellerUid).orderCode(orderCode)
|
|
|
.payType(sellerOrder.getPayment())
|
|
|
.refundCase(RefundCase.SELLER_EARNEST_MONEY)
|
|
|
.skup(skup);
|
|
|
PaymentRequest refundReq = PaymentRequest.builder().uid(sellerUid)
|
|
|
.orderCode(orderCode)
|
|
|
.refundCase(RefundCase.SELLER_EARNEST_MONEY)
|
|
|
.payment(sop)
|
|
|
.refundAmount(earnestMoney)
|
|
|
.isSuper(sellerIsSuper)
|
|
|
.refundattch(moai)
|
|
|
.build();
|
|
|
|
|
|
boolean refundEarnMoneyFlag = new RefundEarnestMoneyHandler()
|
|
|
.loadRefundAction(payRefundService::refund)
|
|
|
.loadBillLogEventBuilder(bleb)
|
|
|
.loadPaymentRequest(refundReq)
|
|
|
.loadSeller(sellerUid, sellerIsSuper, orderCode, targetSellerOrderStatus)
|
|
|
.loadLogger(logger)
|
|
|
.refund();
|
|
|
cpn = new CancelPreparedNode();
|
|
|
cpn.psog = psog;
|
|
|
return cpn;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 审核不通过
|
|
|
* @param auditCancelCase
|
|
|
*/
|
|
|
public void cancel(AuditCancelCase auditCancelCase){
|
|
|
AuditFailedEvent afe = (AuditFailedEvent)auditCancelCase.getEvent();
|
|
|
|
|
|
final int skup = afe.getSkup();
|
|
|
logger.info("in cancel offShelveCancelCase {}", afe);
|
|
|
SkupStatus expectSkupStatus = SkupStatus.CAN_SELL;
|
|
|
final SellerOrderStatus targetSellerOrderStatus = SellerOrderStatus.AUDIT_FAIL;
|
|
|
CancelStatusNode csn = new CancelStatusNode();
|
|
|
csn.skup = skup;
|
|
|
csn.expectSkupStatus = expectSkupStatus;
|
|
|
csn.targetSellerOrderStatus = targetSellerOrderStatus;
|
|
|
CancelPreparedNode cpn = doCancelByErp(csn, auditCancelCase);
|
|
|
SellerOrderGoods psog = cpn.psog;
|
|
|
Integer sellerUid = psog.getUid();
|
|
|
|
|
|
inBoxFacade.noticeSellerWhenSecondHandProductApplyAuditReject(sellerUid, psog, afe.getRejectReason());
|
|
|
}
|
|
|
|
|
|
} |
...
|
...
|
|