...
|
...
|
@@ -7,6 +7,7 @@ import com.yohobuy.ufo.model.ProductInfo; |
|
|
import com.yohobuy.ufo.model.enums.StorageCheckEnum;
|
|
|
import com.yohobuy.ufo.model.order.bo.SellerBo;
|
|
|
import com.yohobuy.ufo.model.order.common.*;
|
|
|
import com.yohobuy.ufo.model.order.constants.DepotType;
|
|
|
import com.yohobuy.ufo.model.order.constants.SkupType;
|
|
|
import com.yohobuy.ufo.model.order.req.*;
|
|
|
import com.yohobuy.ufo.model.order.resp.*;
|
...
|
...
|
@@ -23,17 +24,21 @@ import com.yohoufo.dal.order.*; |
|
|
import com.yohoufo.dal.order.model.*;
|
|
|
import com.yohoufo.order.common.BillTradeStatus;
|
|
|
import com.yohoufo.order.common.TradeType;
|
|
|
import com.yohoufo.order.event.OrderCancelEvent;
|
|
|
import com.yohoufo.order.model.dto.*;
|
|
|
import com.yohoufo.order.service.IErpFastDeliveryService;
|
|
|
import com.yohoufo.order.service.IExpressInfoService;
|
|
|
import com.yohoufo.order.service.handler.SellerDecrPriceTaskHandler;
|
|
|
import com.yohoufo.order.service.handler.SellerDownShelfTaskHandler;
|
|
|
import com.yohoufo.order.service.handler.SellerIncrPriceTaskHandler;
|
|
|
import com.yohoufo.order.service.handler.SellerOrderSubmitHandler;
|
|
|
import com.yohoufo.order.service.impl.visitor.UserCancelCase;
|
|
|
import com.yohoufo.order.service.proxy.FastDeliveryProxyService;
|
|
|
import com.yohoufo.order.service.proxy.ProductProxyService;
|
|
|
import com.yohoufo.order.service.proxy.UserProxyService;
|
|
|
import com.yohoufo.order.service.seller.ImportPublishExcutor;
|
|
|
import com.yohoufo.order.service.seller.SellerAuthCheckService;
|
|
|
import com.yohoufo.order.service.seller.SellerOrderCancelService;
|
|
|
import com.yohoufo.order.service.seller.processor.AdjustPricePrepareProcessor;
|
|
|
import com.yohoufo.order.service.seller.processor.PriceComputePrepareProcessor;
|
|
|
import com.yohoufo.order.service.seller.processor.SellerDownShelfPrepareProcessor;
|
...
|
...
|
@@ -48,6 +53,7 @@ import org.slf4j.Logger; |
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.core.annotation.Order;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.math.BigDecimal;
|
...
|
...
|
@@ -371,6 +377,121 @@ public class ErpFastDeliveryServiceImpl implements IErpFastDeliveryService { |
|
|
return any.stream().sorted(Comparator.comparing(TradeBills::getCreateTime).reversed()).limit(1).findFirst().get();
|
|
|
}
|
|
|
|
|
|
@Autowired
|
|
|
private IExpressInfoService expressInfoService;
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
SellerOrderMapper sellerOrderMapper;
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
private SellerOrderCancelService sellerOrderCancelService;
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 取消发货
|
|
|
* @param req
|
|
|
*/
|
|
|
public void cancelDeliver(FastDeliveryDownShelfReq req){
|
|
|
|
|
|
if (req.getUid() < 0){
|
|
|
logger.warn("uid is empty");
|
|
|
throw new UfoServiceException(400, "参数[uid]不合法");
|
|
|
}
|
|
|
|
|
|
if (req.getSkup()<0){
|
|
|
logger.warn("productCode is empty");
|
|
|
throw new UfoServiceException(400, "参数[skup]不合法");
|
|
|
}
|
|
|
|
|
|
BuyerOrder buyerOrder = checkSellerParam(req.getSkup(), req.getUid(), OrderStatus.SELLER_CANCEL_AFTER_PAY, OrderStatus.HAS_PAYED);
|
|
|
if (Objects.isNull(buyerOrder)){
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
OrderCancelEvent event = OrderCancelEvent.builder().uid(buyerOrder.getUid())
|
|
|
.orderCode(buyerOrder.getOrderCode()).actorType(TabType.SELL).build();
|
|
|
UserCancelCase userCancelCase = new UserCancelCase(event);
|
|
|
userCancelCase.accept(sellerOrderCancelService);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 卖家发货
|
|
|
* @param req
|
|
|
*/
|
|
|
public void deliverToDepot(FastDeliveryDownShelfReq req){
|
|
|
|
|
|
if (req.getUid() < 0){
|
|
|
logger.warn("uid is empty");
|
|
|
throw new UfoServiceException(400, "参数[uid]不合法");
|
|
|
}
|
|
|
|
|
|
if (req.getSkup()<0){
|
|
|
logger.warn("productCode is empty");
|
|
|
throw new UfoServiceException(400, "参数[skup]不合法");
|
|
|
}
|
|
|
|
|
|
if (StringUtils.isBlank(req.getWayBillCode())){
|
|
|
logger.warn("wayBillCode is empty");
|
|
|
throw new UfoServiceException(400, "参数[wayBillCode]不合法");
|
|
|
}
|
|
|
|
|
|
BuyerOrder buyerOrder = checkSellerParam(req.getSkup(), req.getUid(), OrderStatus.SELLER_SEND_OUT, OrderStatus.HAS_PAYED);
|
|
|
if (Objects.isNull(buyerOrder)){
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
SellerDeliverToDepotReq sdtdReq = SellerDeliverToDepotReq.builder()
|
|
|
.sellerUid(req.getUid())
|
|
|
// 卖家订单号
|
|
|
.orderCode(buyerOrder.getOrderCode())
|
|
|
.wayBillCode(req.getWayBillCode())
|
|
|
.depotNum(DepotType.NJ.getCode())
|
|
|
.expressCompanyId(0)
|
|
|
.build();
|
|
|
expressInfoService.deliverToDepot(sdtdReq);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
private BuyerOrder checkSellerParam(Integer skup, Integer serllerUid, OrderStatus targetStatus, OrderStatus originalStatus){
|
|
|
|
|
|
// 获取到买家订单号
|
|
|
BuyerOrderGoods buyerOrderGoods = buyerOrderGoodsMapper.selectLastOrderBySkup(skup);
|
|
|
if (buyerOrderGoods == null){
|
|
|
logger.warn("{} buyerOrderGoods is empty", skup);
|
|
|
throw new UfoServiceException(501, "该商品的购买记录不存在,请检查参数!");
|
|
|
}
|
|
|
|
|
|
BuyerOrder buyerOrder = buyerOrderMapper.selectByOrderCode(buyerOrderGoods.getOrderCode());
|
|
|
if (buyerOrder == null || buyerOrder.getStatus() == null ){
|
|
|
logger.warn("{} buyerOrder is empty", skup);
|
|
|
throw new UfoServiceException(501, "该商品的购买记录不存在,请检查参数!");
|
|
|
}
|
|
|
|
|
|
if (buyerOrder.getSellerUid() != serllerUid){
|
|
|
logger.warn("{} sellerUid inconsistent {}, {}", skup, buyerOrder.getSellerUid(), serllerUid);
|
|
|
throw new UfoServiceException(501, "指定的卖家uid和上架商品的uid不一致,请检查参数!");
|
|
|
}
|
|
|
|
|
|
if (buyerOrder.getStatus() == targetStatus.getCode()){
|
|
|
logger.info("{} checkSellerParam success", skup);
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
if (buyerOrder.getStatus() != originalStatus.getCode()){
|
|
|
logger.warn("{} immediately status is {},originalStatus {}", skup, buyerOrder.getStatus(), originalStatus.getCode());
|
|
|
throw new UfoServiceException(502, "该商品的状态已发生变化,请检查!【"+OrderStatus.getOrderStatus(buyerOrder.getStatus()).getDesc()+"】");
|
|
|
}
|
|
|
|
|
|
return buyerOrder;
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取某个货号的最低价
|
...
|
...
|
|