...
|
...
|
@@ -6,9 +6,9 @@ import com.yoho.error.ServiceError; |
|
|
import com.yoho.error.exception.ServiceException;
|
|
|
import com.yohobuy.ufo.model.order.common.*;
|
|
|
import com.yohobuy.ufo.model.order.req.BuyerOrderMetaUpdateReq;
|
|
|
import com.yohobuy.ufo.model.order.resp.*;
|
|
|
import com.yohobuy.ufo.model.order.resp.BuyerOrderNums;
|
|
|
import com.yohobuy.ufo.model.order.resp.OrderCntResp;
|
|
|
import com.yohobuy.ufo.model.order.vo.AddressInfo;
|
|
|
import com.yohobuy.ufo.model.order.vo.OrderListVo;
|
|
|
import com.yohoufo.common.alarm.EventBusPublisher;
|
|
|
import com.yohoufo.common.exception.UfoServiceException;
|
|
|
import com.yohoufo.common.utils.DateUtil;
|
...
|
...
|
@@ -22,14 +22,10 @@ import com.yohoufo.dal.product.ProductMapper; |
|
|
import com.yohoufo.dal.product.model.Product;
|
|
|
import com.yohoufo.order.common.ActionStatusHold;
|
|
|
import com.yohoufo.order.common.DelStatus;
|
|
|
import com.yohobuy.ufo.model.order.common.Payment;
|
|
|
import com.yohoufo.order.event.*;
|
|
|
import com.yohoufo.order.model.PayQueryBo;
|
|
|
import com.yohoufo.order.model.dto.BuyerPenaltyCalResult;
|
|
|
import com.yohoufo.order.model.request.OrderListRequest;
|
|
|
import com.yohoufo.order.model.request.OrderRequest;
|
|
|
import com.yohoufo.order.model.request.SaveQualityCheckInfoRequest;
|
|
|
import com.yohoufo.order.model.response.OrderDetailInfo;
|
|
|
import com.yohoufo.order.model.response.OrderSummaryResp;
|
|
|
import com.yohoufo.order.service.IBuyerOrderMetaService;
|
|
|
import com.yohoufo.order.service.IBuyerOrderService;
|
...
|
...
|
@@ -38,7 +34,6 @@ import com.yohoufo.order.service.IPaymentService; |
|
|
import com.yohoufo.order.service.cache.CacheCleaner;
|
|
|
import com.yohoufo.order.service.cache.CacheKeyBuilder;
|
|
|
import com.yohoufo.order.service.cache.OrderCacheService;
|
|
|
import com.yohoufo.order.service.handler.BuyerCancelCompensateComputeHandler;
|
|
|
import com.yohoufo.order.service.listener.BuyerOrderChangeEvent;
|
|
|
import com.yohoufo.order.service.listener.OrderChangeListenerContainer;
|
|
|
import com.yohoufo.order.service.pay.AbstractPayService;
|
...
|
...
|
@@ -53,7 +48,6 @@ import org.slf4j.Logger; |
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
...
|
...
|
@@ -70,12 +64,6 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { |
|
|
|
|
|
@Autowired
|
|
|
SellerOrderGoodsMapper sellerOrderGoodsMapper;
|
|
|
|
|
|
@Autowired
|
|
|
private BuyerOrderListServiceImpl buyerOrderListService;
|
|
|
|
|
|
@Autowired
|
|
|
private BuyerOrderDetailService buyerOrderDetailService;
|
|
|
|
|
|
@Autowired
|
|
|
private ProductProxyService productProxyService;
|
...
|
...
|
@@ -107,8 +95,6 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { |
|
|
@Autowired
|
|
|
private QualityCheckMapper qualityCheckMapper;
|
|
|
|
|
|
@Autowired
|
|
|
private BuyerCancelCompensateComputeHandler buyerCancelCompensateComputeHandler;
|
|
|
|
|
|
@Autowired
|
|
|
private ProductMapper productMapper;
|
...
|
...
|
@@ -493,11 +479,11 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { |
|
|
}
|
|
|
|
|
|
|
|
|
private class DataNode{
|
|
|
class DataNode{
|
|
|
BuyerOrder buyerOrderInDB;
|
|
|
}
|
|
|
|
|
|
private DataNode checkBase(OrderRequest orderRequest){
|
|
|
DataNode checkBase(OrderRequest orderRequest){
|
|
|
// 参数检查
|
|
|
if (orderRequest.getUid() < 0
|
|
|
|| orderRequest.getOrderCode() < 0){
|
...
|
...
|
@@ -554,10 +540,7 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { |
|
|
}
|
|
|
|
|
|
|
|
|
@Override
|
|
|
public OrderDetailInfo getOrderDetail(OrderRequest orderRequest) {
|
|
|
return buyerOrderDetailService.getOrderDetail(orderRequest);
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -614,40 +597,7 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { |
|
|
return sum;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public PageResp getOrderListForErpGW(OrderListRequest request) {
|
|
|
return buyerOrderListService.getOrderListForErpGW(request);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public PageResp getOrderList(OrderListRequest request, boolean isPlatform) {
|
|
|
|
|
|
OrderListVo orderListVo = orderCacheService.getOrderListInfos(request);
|
|
|
PageResp.PageRespBuilder respBuilder;
|
|
|
if (Objects.nonNull(orderListVo)){
|
|
|
respBuilder = PageResp.builder()
|
|
|
.page(request.getPage())
|
|
|
.pageSize(orderListVo.getPageSize())
|
|
|
.total(orderListVo.getTotal())
|
|
|
.pagetotal(orderListVo.getPagetotal());
|
|
|
List<OrderListInfo> oliList = orderListVo.getOrderList();
|
|
|
buyerOrderListService.resetDynamicProporties(oliList, request.getType());
|
|
|
return respBuilder.data(oliList).build();
|
|
|
}
|
|
|
PageResp orderListInfoRsp = buyerOrderListService.getOrderList(request, isPlatform);
|
|
|
|
|
|
if (orderListInfoRsp != null){
|
|
|
|
|
|
|
|
|
orderListVo = OrderListVo.builder().page(orderListInfoRsp.getPage())
|
|
|
.pageSize(orderListInfoRsp.getPageSize())
|
|
|
.orderList(orderListInfoRsp.getData())
|
|
|
.total(orderListInfoRsp.getTotal())
|
|
|
.pagetotal(orderListInfoRsp.getPagetotal()).build();
|
|
|
orderCacheService.cacheOrderList(request, orderListVo);
|
|
|
}
|
|
|
return orderListInfoRsp;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -861,62 +811,7 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { |
|
|
return resp;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public OrderCancelComputeResult cancelCompute(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 cancelCompute check orderStatus fail, orderStatus {} expectStatus {}", orderStatus,expectStatus );
|
|
|
throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE);
|
|
|
}
|
|
|
logger.info("in buyer cancelCompute, req {} expectStatus {}", orderRequest, expectStatus);
|
|
|
//case 1 :支付前
|
|
|
//case 2 :支付后,卖家发货前
|
|
|
//case 3 :卖家发货后,鉴定中心接受前
|
|
|
OrderStatus targetStatus = null;
|
|
|
BuyerPenaltyCalResult bpcr = null;
|
|
|
OrderCancelComputeResult occr = null;
|
|
|
switch (expectStatus){
|
|
|
case WAITING_PAY:
|
|
|
targetStatus = OrderStatus.BUYER_CANCEL_BEFORE_PAY;
|
|
|
occr = OrderCancelComputeResult.builder()
|
|
|
.confirmDesc("确定取消订单?").build();
|
|
|
break;
|
|
|
case HAS_PAYED:
|
|
|
targetStatus = OrderStatus.BUYER_CANCEL_BEFORE_SELLER_DELIVER;
|
|
|
bpcr = buyerCancelCompensateComputeHandler.calBuyerPenaltyCalResult(buyerOrder,
|
|
|
buyerOrderGoodsMapper.selectByOrderCode(buyerOrder.getUid(),buyerOrder.getOrderCode()),
|
|
|
targetStatus);
|
|
|
occr = bpcr2occr(bpcr);
|
|
|
occr.setNeedPenalty(true);
|
|
|
break;
|
|
|
case SELLER_SEND_OUT:
|
|
|
targetStatus = OrderStatus.BUYER_CANCEL_BEFORE_DEPOT_RECEIVE;
|
|
|
bpcr = buyerCancelCompensateComputeHandler.calBuyerPenaltyCalResult(buyerOrder,
|
|
|
buyerOrderGoodsMapper.selectByOrderCode(buyerOrder.getUid(),buyerOrder.getOrderCode()),
|
|
|
targetStatus);
|
|
|
occr = bpcr2occr(bpcr);
|
|
|
occr.setNeedPenalty(true);
|
|
|
break;
|
|
|
}
|
|
|
return occr;
|
|
|
}
|
|
|
|
|
|
private OrderCancelComputeResult bpcr2occr(BuyerPenaltyCalResult bpcr){
|
|
|
String currencyUnit = "元";
|
|
|
String orderPrice = bpcr.getOrderActualAmount().toPlainString() + currencyUnit;
|
|
|
String penaltyRate = bpcr.getPenaltyRate().multiply(new BigDecimal(100)).toPlainString() + "%";
|
|
|
String penaltyAmount = "-"+bpcr.getPenaltyAmount().toPlainString() + currencyUnit;
|
|
|
String refundAmount = bpcr.getLeftAmount().toPlainString() + currencyUnit;
|
|
|
OrderCancelComputeResult occr = OrderCancelComputeResult.builder()
|
|
|
.orderPrice(orderPrice)
|
|
|
.penaltyRate(penaltyRate)
|
|
|
.penaltyAmount(penaltyAmount)
|
|
|
.refundAmount(refundAmount)
|
|
|
.showPrice(true)
|
|
|
.build();
|
|
|
return occr;
|
|
|
}
|
|
|
|
|
|
|
|
|
} |
...
|
...
|
|