...
|
...
|
@@ -28,9 +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.*;
|
|
|
import com.yohoufo.order.model.PayQueryBo;
|
|
|
import com.yohoufo.order.model.dto.PlatformFeeDto;
|
|
|
import com.yohoufo.order.model.dto.SellerDepositOrderContext;
|
...
|
...
|
@@ -54,10 +52,7 @@ import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Objects;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
...
|
...
|
@@ -343,6 +338,9 @@ public class SellerDepositOrderService extends AbsGoodsServiceOrderService imple |
|
|
if (rows == 0){
|
|
|
return rows;
|
|
|
}
|
|
|
//
|
|
|
triggerStatusConsistencyCheck(orderCode);
|
|
|
|
|
|
Long paidCode = pao.getParentOrderCode();
|
|
|
inBoxFacade.sellerDepositOrderNotice(pao.getUid(), orderCode, targetStatus);
|
|
|
BigDecimal left = calLeftMoney(pao.getAmount(), orderCode);
|
...
|
...
|
@@ -405,6 +403,10 @@ public class SellerDepositOrderService extends AbsGoodsServiceOrderService imple |
|
|
if (rows == 0){
|
|
|
return rows;
|
|
|
}
|
|
|
//
|
|
|
Long orderCode = appraiseOrder.getOrderCode();
|
|
|
triggerStatusConsistencyCheck(orderCode);
|
|
|
//
|
|
|
AppraiseOrderStatus targetOrderStatus = AppraiseOrderStatus.CHECKING_FAKE;
|
|
|
inBoxFacade.sellerDepositOrderNotice(appraiseOrder.getUid(), appraiseOrder.getOrderCode(), targetOrderStatus);
|
|
|
depositService.insertFakeDeposit(appraiseOrder.getUid(), appraiseOrder.getOrderCode(), appraiseOrder.getParentOrderCode());
|
...
|
...
|
@@ -421,6 +423,9 @@ public class SellerDepositOrderService extends AbsGoodsServiceOrderService imple |
|
|
if (rows == 0){
|
|
|
return rows;
|
|
|
}
|
|
|
//
|
|
|
Long orderCode = appraiseOrder.getOrderCode();
|
|
|
triggerStatusConsistencyCheck(orderCode);
|
|
|
//refund amount
|
|
|
new GoodsServiceRefundHandler()
|
|
|
.loadLogger(logger)
|
...
|
...
|
@@ -447,6 +452,10 @@ public class SellerDepositOrderService extends AbsGoodsServiceOrderService imple |
|
|
if (rows == 0){
|
|
|
return rows;
|
|
|
}
|
|
|
//
|
|
|
Long orderCode = appraiseOrder.getOrderCode();
|
|
|
triggerStatusConsistencyCheck(orderCode);
|
|
|
//
|
|
|
AppraiseOrderStatus targetOrderStatus = AppraiseOrderStatus.SHAM_SEND_OUT;
|
|
|
inBoxFacade.sellerDepositOrderNotice(appraiseOrder.getUid(), appraiseOrder.getOrderCode(), targetOrderStatus);
|
|
|
//refund amount
|
...
|
...
|
@@ -567,16 +576,18 @@ public class SellerDepositOrderService extends AbsGoodsServiceOrderService imple |
|
|
if (rows == 0){
|
|
|
return rows;
|
|
|
}
|
|
|
Long orderCode = appraiseOrder.getOrderCode();
|
|
|
triggerStatusConsistencyCheck(orderCode);
|
|
|
AppraiseOrderStatus targetOrderStatus = AppraiseOrderStatus.QUALITY_CHECK_FAKE;
|
|
|
inBoxFacade.sellerDepositOrderNotice(appraiseOrder.getUid(), appraiseOrder.getOrderCode(), targetOrderStatus);
|
|
|
inBoxFacade.sellerDepositOrderNotice(appraiseOrder.getUid(), orderCode, targetOrderStatus);
|
|
|
new GoodsServiceRefundHandler()
|
|
|
.loadLogger(logger)
|
|
|
.loadUser(appraiseOrder.getUid())
|
|
|
.loadActionCase(SellerWalletDetail.Type.FLAW)
|
|
|
.loadRefundAction(payRefundService::refund)
|
|
|
.loadOrder(appraiseOrder.getOrderCode(), appraiseOrder.getParentOrderCode(), appraiseOrder.getPayment(), appraiseOrder.getAmount())
|
|
|
.loadOrder(orderCode, appraiseOrder.getParentOrderCode(), appraiseOrder.getPayment(), appraiseOrder.getAmount())
|
|
|
.refund();
|
|
|
depositService.insertFakeDeposit(appraiseOrder.getUid(), appraiseOrder.getOrderCode(), appraiseOrder.getParentOrderCode());
|
|
|
depositService.insertFakeDeposit(appraiseOrder.getUid(), orderCode, appraiseOrder.getParentOrderCode());
|
|
|
return rows;
|
|
|
}
|
|
|
|
...
|
...
|
@@ -595,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);
|
|
|
}
|
|
|
|
|
|
|
...
|
...
|
@@ -621,12 +638,23 @@ public class SellerDepositOrderService extends AbsGoodsServiceOrderService imple |
|
|
logger.warn("in getSubOrderStatistic selectByOrderCode null, orderCode {}", orderCode);
|
|
|
return new ArrayList<>(0);
|
|
|
}
|
|
|
long occ = appraiseOrder.getParentOrderCode()==null ? orderCode : appraiseOrder.getParentOrderCode();
|
|
|
long occ = findoutParentOrderCode(orderCode);
|
|
|
List<AppraiseOrder> paoList = appraiseOrderMapper.selectSubOrderStatistic(occ);
|
|
|
logger.info("getSubOrderStatistic orderCode {} ParentOrderCode {} AppraiseOrder list {}", orderCode, occ, paoList);
|
|
|
return paoList;
|
|
|
}
|
|
|
|
|
|
private Long findoutParentOrderCode(long orderCode){
|
|
|
AppraiseOrder appraiseOrder = appraiseOrderMapper.selectByOrderCode(orderCode);
|
|
|
if (Objects.isNull(appraiseOrder)){
|
|
|
logger.warn("in getSubOrderStatistic selectByOrderCode null, orderCode {}", orderCode);
|
|
|
return orderCode;
|
|
|
}
|
|
|
return appraiseOrder.getParentOrderCode()==null ? orderCode : appraiseOrder.getParentOrderCode();
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public DepositOrderStatisticInfo getAppraiseProgress(int uid, long orderCode){
|
|
|
List<AppraiseOrder> paoList = buildSubOrderStatisticList(orderCode);
|
|
|
|
...
|
...
|
@@ -681,4 +709,82 @@ public class SellerDepositOrderService extends AbsGoodsServiceOrderService imple |
|
|
|
|
|
return dosi;
|
|
|
}
|
|
|
|
|
|
public int platformFinishReceiveGoods(long parentCode){
|
|
|
AppraiseOrderStatus targetStatus = AppraiseOrderStatus.FINISH,
|
|
|
expectedStatus = AppraiseOrderStatus.PLATFORM_RECEIVE;
|
|
|
return triggerStatusChange(parentCode,targetStatus,expectedStatus);
|
|
|
}
|
|
|
|
|
|
|
|
|
public int detectAppraiseFinish(SellerDepositOrderStatusConsistencyAsyncEvent event ){
|
|
|
logger.info("detectAppraiseFinish event {}", event);
|
|
|
long orderCode = event.getOrderCode();
|
|
|
long parentOrderCode = findoutParentOrderCode(orderCode);
|
|
|
int cnt =appraiseOrderMapper.selectSubOrderCntIncludeStatus(parentOrderCode,Arrays.asList(AppraiseOrderStatus.PLATFORM_RECEIVE.getCode()));
|
|
|
logger.info("detectAppraiseFinish event {},parentOrderCode {} PLATFORM_RECEIVE count {}", event, parentOrderCode, cnt);
|
|
|
if (cnt == 0){
|
|
|
int prows = platformFinishReceiveGoods(parentOrderCode);
|
|
|
logger.info("detectAppraiseFinish platformFinishReceiveGoods, orderCode {},parentOrderCode {} parent count {}",
|
|
|
orderCode, parentOrderCode, prows);
|
|
|
return prows;
|
|
|
}
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
public void triggerStatusConsistencyCheck(long orderCode){
|
|
|
SellerDepositOrderStatusConsistencyAsyncEvent asyncEvent
|
|
|
= new SellerDepositOrderStatusConsistencyAsyncEvent(this::detectAppraiseFinish);
|
|
|
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;
|
|
|
|
|
|
}
|
|
|
} |
...
|
...
|
|