...
|
...
|
@@ -4,6 +4,7 @@ import com.yoho.error.ServiceError; |
|
|
import com.yoho.error.exception.ServiceException;
|
|
|
import com.yohobuy.ufo.model.order.bo.MerchantOrderAttachInfo;
|
|
|
import com.yohobuy.ufo.model.order.common.*;
|
|
|
import com.yohobuy.ufo.model.order.constants.SkupType;
|
|
|
import com.yohoufo.common.alarm.EventBusPublisher;
|
|
|
import com.yohoufo.common.alarm.UfoInfluxdbEvent;
|
|
|
import com.yohoufo.common.alarm.UfoInfluxdbVo;
|
...
|
...
|
@@ -27,6 +28,7 @@ import com.yohoufo.order.model.request.TransferMoneyRequest; |
|
|
import com.yohoufo.order.mq.DelayTime;
|
|
|
import com.yohoufo.order.mq.TopicConstants;
|
|
|
import com.yohoufo.order.mq.producer.TradeMqSender;
|
|
|
import com.yohoufo.order.service.DepositService;
|
|
|
import com.yohoufo.order.service.IPaymentService;
|
|
|
import com.yohoufo.order.service.MerchantOrderPaymentService;
|
|
|
import com.yohoufo.order.service.cache.CacheCleaner;
|
...
|
...
|
@@ -51,6 +53,7 @@ import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator; |
|
|
import com.yohoufo.order.service.support.codegenerator.bean.CodeMeta;
|
|
|
import com.yohoufo.order.utils.LoggerUtils;
|
|
|
import com.yohoufo.order.utils.PaymentHelper;
|
|
|
import com.yohoufo.order.utils.SellerGoodsHelper;
|
|
|
import lombok.Builder;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.slf4j.Logger;
|
...
|
...
|
@@ -133,6 +136,9 @@ public class SellerOrderCancelService { |
|
|
@Autowired
|
|
|
private OrderChangeListenerContainer orderChangeListenerContainer;
|
|
|
|
|
|
@Autowired
|
|
|
private DepositService depositService;
|
|
|
|
|
|
/**
|
|
|
* TODO 如何控制好并发,必须控制不能重复转账 退款
|
|
|
* 使用乐观锁,带着查询到的状态且符合条件时再去更新
|
...
|
...
|
@@ -448,9 +454,22 @@ public class SellerOrderCancelService { |
|
|
int result = cancelBeforeBuyerPayAction(sellerUid, orderCode, skup, statusNode);
|
|
|
|
|
|
if(result > 0 ){
|
|
|
refundEarnestMoney(sellerOrder, targetSOStatus,sellerOrder.getEarnestMoney());
|
|
|
//async execute msg
|
|
|
SellerOrderGoods psog = sellerOrderGoodsMapper.selectByPrimaryKey(skup);
|
|
|
SkupType skupType = SkupType.getSkupType(psog.getAttributes());
|
|
|
boolean isQuickDeliver = SellerGoodsHelper.isQuickDeliver(skupType);
|
|
|
if (isQuickDeliver){
|
|
|
try {
|
|
|
depositService.changeSaleStatusOff(sellerUid, skup);
|
|
|
}catch (Exception ex){
|
|
|
logger.warn("in cancelAfterPayButNotBuyAction changeSaleStatusOff fail, uid {} skup {}",
|
|
|
sellerUid, skup, ex);
|
|
|
}
|
|
|
}
|
|
|
if (!isQuickDeliver) {
|
|
|
refundEarnestMoney(sellerOrder, targetSOStatus, sellerOrder.getEarnestMoney());
|
|
|
}
|
|
|
//async execute msg
|
|
|
|
|
|
inBoxFacade.sellerPlaySelf(sellerUid, psog);
|
|
|
}
|
|
|
|
...
|
...
|
@@ -623,13 +642,7 @@ public class SellerOrderCancelService { |
|
|
} else {
|
|
|
logger.error("can not find penalty result, uid = {}, skup={}", sellerOrder.getUid(), sellerOrder.getSkup());
|
|
|
}
|
|
|
/*
|
|
|
BillLogEvent.BillLogEventBuilder bleb = BillLogEvent.builder()
|
|
|
.buyerUid(buyerUid).sellerUid(sellerUid).orderCode(buyerOrderCode)
|
|
|
.payType(buyerOrder.getPayment()).refundCase(RefundCase.BUYER_GOODS_MONEY)
|
|
|
.amount(goodsMoney)
|
|
|
.skup(sellerOrder.getSkup());
|
|
|
*/
|
|
|
|
|
|
// 退买家货款
|
|
|
new RefundGoodsMoneyHandler().loadLogger(logger)
|
|
|
.loadTargetOrderStatus(targetBOStatus)
|
...
|
...
|
@@ -795,46 +808,62 @@ public class SellerOrderCancelService { |
|
|
//
|
|
|
cacheCleaner.cleanList(sellerUid, TabType.SELL.getValue());
|
|
|
cacheCleaner.cleanSellerDetail(psog);
|
|
|
double earnestMoney = sellerOrder.getEarnestMoney().doubleValue();
|
|
|
SkupType skupType = SkupType.getSkupType(psog.getAttributes());
|
|
|
boolean isQuickDeliver = SellerGoodsHelper.isQuickDeliver(skupType);
|
|
|
|
|
|
Integer sop = sellerOrder.getPayment() == null ? 0 : sellerOrder.getPayment();
|
|
|
if (isQuickDeliver){
|
|
|
try {
|
|
|
depositService.changeSaleStatusOff(sellerUid, skup);
|
|
|
}catch (Exception ex){
|
|
|
logger.warn("in doCancelByErp changeSaleStatusOff fail, uid {} skup {}",
|
|
|
sellerUid, skup, ex);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
boolean sellerIsSuper = sellerService.isSuperEntrySeller(sellerUid);
|
|
|
if (!isQuickDeliver) {
|
|
|
double earnestMoney = sellerOrder.getEarnestMoney().doubleValue();
|
|
|
|
|
|
//不是超级卖家 ,上架商品用钱包支付保证金
|
|
|
MerchantOrderAttachInfo moai = null;
|
|
|
if(!sellerIsSuper && PaymentHelper.isWallet(sop)){
|
|
|
moai = MerchantOrderAttachInfo.builder().uid(sellerUid)
|
|
|
.orderCode(orderCode).skup(skup).earnestMoney(sellerOrder.getEarnestMoney())
|
|
|
.type(orderCancelCase.getSwdType().getValue()).build();
|
|
|
}
|
|
|
RefundCase refundCase = RefundCase.SELLER_EARNEST_MONEY;
|
|
|
BillLogEvent.BillLogEventBuilder bleb = BillLogEvent.builder()
|
|
|
.sellerUid(sellerUid).orderCode(orderCode)
|
|
|
.payType(sellerOrder.getPayment())
|
|
|
.refundCase(refundCase)
|
|
|
.skup(skup);
|
|
|
PaymentRequest refundReq = PaymentRequest.builder().uid(sellerUid)
|
|
|
.orderCode(orderCode)
|
|
|
.refundCase(refundCase)
|
|
|
.payment(sop)
|
|
|
.refundAmount(earnestMoney)
|
|
|
.isSuper(sellerIsSuper)
|
|
|
.refundattch(moai)
|
|
|
.build();
|
|
|
Integer sop = sellerOrder.getPayment() == null ? 0 : sellerOrder.getPayment();
|
|
|
|
|
|
boolean refundEarnMoneyFlag = new RefundEarnestMoneyHandler()
|
|
|
.loadRefundAction(payRefundService::refund)
|
|
|
.loadBillLogEventBuilder(bleb)
|
|
|
.loadPaymentRequest(refundReq)
|
|
|
.loadSeller(sellerUid, sellerIsSuper, orderCode, targetSellerOrderStatus)
|
|
|
.loadLogger(logger)
|
|
|
.refund();
|
|
|
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(orderCancelCase.getSwdType().getValue()).build();
|
|
|
}
|
|
|
RefundCase refundCase = RefundCase.SELLER_EARNEST_MONEY;
|
|
|
BillLogEvent.BillLogEventBuilder bleb = BillLogEvent.builder()
|
|
|
.sellerUid(sellerUid).orderCode(orderCode)
|
|
|
.payType(sellerOrder.getPayment())
|
|
|
.refundCase(refundCase)
|
|
|
.skup(skup);
|
|
|
PaymentRequest refundReq = PaymentRequest.builder().uid(sellerUid)
|
|
|
.orderCode(orderCode)
|
|
|
.refundCase(refundCase)
|
|
|
.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
|
...
|
...
|
|