Authored by chenchao

add deliver time out 4 seller deposit order

... ... @@ -3,6 +3,8 @@ package com.yohoufo.order.mq.consumer;
import com.yohoufo.order.event.SellerCancelDeliverEvent;
import com.yohoufo.order.mq.TopicConstants;
import com.yohoufo.order.service.impl.BuyerOrderCancelService;
import com.yohoufo.order.service.impl.ServiceOrderProcessor;
import com.yohoufo.order.service.seller.deposit.SellerDepositOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
... ... @@ -14,8 +16,14 @@ import org.springframework.stereotype.Component;
public class SellerOrderCancelDeliverDelayMsgConsumer extends JsonObjectMessageConsumer<SellerCancelDeliverEvent> {
@Autowired
private ServiceOrderProcessor serviceOrderProcessor;
@Autowired
private BuyerOrderCancelService buyerOrderCancelService;
@Autowired
private SellerDepositOrderService sellerDepositOrderService;
@Override
public String getTopic() {
return TopicConstants.SELLER_ORDER_AUTO_CANCEL_DELIVER;
... ... @@ -23,6 +31,11 @@ public class SellerOrderCancelDeliverDelayMsgConsumer extends JsonObjectMessageC
@Override
public void handle(SellerCancelDeliverEvent event) {
buyerOrderCancelService.cancelForSellerSendOutTimeout(event.getUid(), event.getOrderCode(), event.getSkup(), event.getSellerOrderGoods());
long orderCode = event.getOrderCode();
if (serviceOrderProcessor.isGoodsServiceOrder(orderCode)){
int rows = sellerDepositOrderService.cancelForSendOutTimeout(orderCode);
return;
}
buyerOrderCancelService.cancelForSellerSendOutTimeout(event.getUid(), orderCode, event.getSkup(), event.getSellerOrderGoods());
}
}
... ...
... ... @@ -28,10 +28,7 @@ import com.yohoufo.dal.order.model.*;
import com.yohoufo.order.common.ClientType;
import com.yohoufo.order.common.DelStatus;
import com.yohoufo.order.constants.MetaKey;
import com.yohoufo.order.event.OrderCancelEvent;
import com.yohoufo.order.event.PayConfirmEvent;
import com.yohoufo.order.event.SellerDepositOrderCancelAsyncEvent;
import com.yohoufo.order.event.SellerDepositOrderStatusConsistencyAsyncEvent;
import com.yohoufo.order.event.*;
import com.yohoufo.order.model.PayQueryBo;
import com.yohoufo.order.model.dto.PlatformFeeDto;
import com.yohoufo.order.model.dto.SellerDepositOrderContext;
... ... @@ -609,14 +606,20 @@ public class SellerDepositOrderService extends AbsGoodsServiceOrderService imple
}
public void processAfterPay(OrderInfo orderInfo){
Long orderCode = orderInfo.getOrderCode();
Integer uid = orderInfo.getUid();
AppraiseOrderStatus targetOrderStatus = AppraiseOrderStatus.HAS_PAYED;
inBoxFacade.sellerDepositOrderNotice(orderInfo.getUid(), orderInfo.getOrderCode(), targetOrderStatus);
SellerDepositOrderCancelAsyncEvent event = new SellerDepositOrderCancelAsyncEvent(this::handleOrderCancelAsyncEvent);
event.setUid(orderInfo.getUid());
event.setOrderCode(orderInfo.getOrderCode());
event.setUid(uid);
event.setOrderCode(orderCode);
EventBusPublisher.publishEvent(event);
logger.info("processAfterPay seller deposit order , SellerDepositOrderCancelAsyncEvent send out, event {}", event);
SellerCancelDeliverEvent cancelDeliverEvent =
SellerCancelDeliverEvent.builder()
.uid(orderInfo.getUid())
.orderCode(orderCode).build();
EventBusPublisher.publishEvent(cancelDeliverEvent);
}
... ... @@ -735,4 +738,53 @@ public class SellerDepositOrderService extends AbsGoodsServiceOrderService imple
asyncEvent.setOrderCode(orderCode);
EventBusPublisher.publishEvent(asyncEvent);
}
/**
* 发货超时取消
* @param orderCode
*/
public int cancelForSendOutTimeout(long orderCode){
logger.info("in cancel seller deposit order For Send Out Timeout orderCode {}", orderCode);
ServiceOrderProcessor.ExistenceNode existenceNode = serviceOrderProcessor.isAppraiseOrder(orderCode);
if (!existenceNode.isExisted()){
logger.warn("auto cancel AppraiseOrder not exist, orderCode {}", orderCode);
throw new UfoServiceException(400, "订单已迷路");
}
AppraiseOrder pao = existenceNode.getAppraiseOrder();
OrderAttributes oa = OrderAttributes.getOrderAttributes(pao.getAttributes());
if (!OrderAttributes.DEPOSITE.equals(oa)){
logger.warn("auto cancel AppraiseOrder not deposit Order, orderCode {}", orderCode);
throw new UfoServiceException(400, "订单已迷路");
}
int uid = pao.getUid();
AppraiseOrderStatus appraiseOrderStatus = AppraiseOrderStatus.getByCode(pao.getStatus());
int rows = 0;
AppraiseOrderStatus targetOrderStatus = null;
switch (appraiseOrderStatus){
case HAS_PAYED:
targetOrderStatus= AppraiseOrderStatus.SEND_OUT_TIMEOUT;
rows = super.triggerStatusChange(orderCode, targetOrderStatus, appraiseOrderStatus);
if (rows>0){
new GoodsServiceRefundHandler()
.loadLogger(logger)
.loadUser(uid)
.loadActionCase(SellerWalletDetail.Type.SELLER_OVER_TIME)
.loadRefundAction(payRefundService::refund)
.loadOrder(orderCode, orderCode, pao.getPayment(), pao.getAmount())
.refund();
//notice
inBoxFacade.sellerDepositOrderNotice(uid, orderCode, targetOrderStatus);
}
break;
default:
throw new UfoServiceException(400, "订单不支持取消");
}
return rows;
}
}
... ...