|
|
package com.yohoufo.order.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.yohobuy.ufo.model.ProductInfo;
|
|
|
import com.yohobuy.ufo.model.order.bo.SellerBo;
|
|
|
import com.yohobuy.ufo.model.order.common.OrderStatus;
|
|
|
import com.yohobuy.ufo.model.order.common.SellerFuncEnum;
|
|
|
import com.yohobuy.ufo.model.order.common.SkupStatus;
|
|
|
import com.yohobuy.ufo.model.order.constants.SkupType;
|
|
|
import com.yohobuy.ufo.model.order.req.*;
|
|
|
import com.yohobuy.ufo.model.order.resp.FastDeliveryGetShelfDetailResp;
|
|
|
import com.yohobuy.ufo.model.order.resp.FastDeliveryGetShelfResp;
|
|
|
import com.yohobuy.ufo.model.order.resp.OrderListInfo;
|
|
|
import com.yohobuy.ufo.model.order.resp.PageResp;
|
|
|
import com.yohobuy.ufo.model.request.product.ProductImportTranItemBo;
|
|
|
import com.yohobuy.ufo.model.response.ProductDetailResp;
|
|
|
import com.yohoufo.common.exception.UfoServiceException;
|
|
|
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.model.dto.*;
|
|
|
import com.yohoufo.order.service.IErpFastDeliveryService;
|
|
|
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.proxy.ProductProxyService;
|
|
|
import com.yohoufo.order.service.seller.ImportPublishExcutor;
|
|
|
import com.yohoufo.order.service.seller.SellerAuthCheckService;
|
|
|
import com.yohoufo.order.service.seller.processor.AdjustPricePrepareProcessor;
|
|
|
import com.yohoufo.order.service.seller.processor.PriceComputePrepareProcessor;
|
|
|
import com.yohoufo.order.service.seller.processor.SellerDownShelfPrepareProcessor;
|
|
|
import com.yohoufo.order.service.seller.processor.SellerTaskProcessor;
|
|
|
import com.yohoufo.order.service.seller.setting.SellerFuncService;
|
|
|
import com.yohoufo.order.service.seller.setting.SellerService;
|
|
|
import com.yohoufo.order.service.seller.setting.SellerWrapper;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
|
import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
|
public class ErpFastDeliveryServiceImpl implements IErpFastDeliveryService {
|
|
|
|
|
|
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
|
|
|
|
|
@Autowired
|
|
|
private SellerService sellerService;
|
|
|
|
|
|
@Autowired
|
|
|
private SellerAuthCheckService sellerAuthCheckService;
|
|
|
|
|
|
@Autowired
|
|
|
private SellerFuncService sellerFuncService;
|
|
|
|
|
|
@Autowired
|
|
|
ImportPublishExcutor importPublishExcutor;
|
|
|
|
|
|
@Autowired
|
|
|
private ProductProxyService productProxyService;
|
|
|
|
|
|
@Autowired
|
|
|
private SellerDownShelfPrepareProcessor sellerDownShelfPrepareProcessor;
|
|
|
|
|
|
@Autowired
|
|
|
private SellerDownShelfTaskHandler sellerDownShelfTaskHandler;
|
|
|
|
|
|
@Autowired
|
|
|
private SellerTaskProcessor sellerTaskProcessor;
|
|
|
|
|
|
@Autowired
|
|
|
private AdjustPricePrepareProcessor adjustPricePrepareProcessor;
|
|
|
|
|
|
@Autowired
|
|
|
private SellerIncrPriceTaskHandler sellerIncrPriceTaskHandler;
|
|
|
|
|
|
@Autowired
|
|
|
private SellerDecrPriceTaskHandler sellerDecrPriceTaskHandler;
|
|
|
|
|
|
@Autowired
|
|
|
PriceComputePrepareProcessor priceComputePrepareProcessor;
|
|
|
|
|
|
@Autowired
|
|
|
private SellerOrderGoodsMapper sellerOrderGoodsMapper;
|
|
|
|
|
|
@Autowired
|
|
|
private BuyerOrderMapper buyerOrderMapper;
|
|
|
|
|
|
@Autowired
|
|
|
private BuyerOrderGoodsMapper buyerOrderGoodsMapper;
|
|
|
|
|
|
@Autowired
|
|
|
private OrdersPayTransferMapper ordersPayTransferMapper;
|
|
|
|
|
|
@Autowired
|
|
|
private TradeBillsMapper tradeBillsMapper;
|
|
|
|
|
|
/**
|
|
|
* 货款收入
|
|
|
*/
|
|
|
private static List<Integer> GOODS_INCOME = Lists.newArrayList(OrderStatus.JUDGE_PASS.getCode(), OrderStatus.WAITING_RECEIVE.getCode(),
|
|
|
OrderStatus.DONE.getCode());
|
|
|
|
|
|
/**
|
|
|
* 保证金扣除
|
|
|
*/
|
|
|
private static List<Integer> DEDUCTION_EARNEST_MONEY = Lists.newArrayList(OrderStatus.SEND_OUT_TIMEOUT.getCode(),
|
|
|
OrderStatus.CHECKING_FAKE.getCode(),
|
|
|
OrderStatus.PLATFORM_DETECTION_NOT_PASS.getCode(),
|
|
|
OrderStatus.QUALITY_CHECK_FAKE.getCode(),
|
|
|
OrderStatus.SELLER_SHAM_SEND_OUT.getCode());
|
|
|
|
|
|
/**
|
|
|
* 因为买家原因获得的收入
|
|
|
*/
|
|
|
private static List<Integer> BUYER_REASON_INCOME = Lists.newArrayList(OrderStatus.BUYER_CANCEL_BEFORE_DEPOT_RECEIVE.getCode(),
|
|
|
OrderStatus.BUYER_CANCEL_BEFORE_SELLER_DELIVER.getCode());
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 查询上架商品的信息
|
|
|
* @param req
|
|
|
*/
|
|
|
public FastDeliveryGetShelfResp getShelfInfo(FastDeliveryGetShelfReq req) {
|
|
|
|
|
|
if (req.getUid() < 0) {
|
|
|
logger.warn("uid is empty");
|
|
|
throw new UfoServiceException(400, "必须指定卖家");
|
|
|
}
|
|
|
|
|
|
if (req.getLimit() <= 0){
|
|
|
req.setLimit(10); // 默认值
|
|
|
}
|
|
|
|
|
|
if (req.getPage() <= 0){
|
|
|
req.setPage(1);
|
|
|
}
|
|
|
|
|
|
int total = sellerOrderGoodsMapper.selectCntByMulti(req.getUid(), req.getStatus(), req.getSkup(),
|
|
|
req.getOrderCode(), req.getStartTime(), req.getEndTime());
|
|
|
if (total == 0) {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
int limit = req.getLimit();
|
|
|
int offset = (req.getPage() - 1) * limit;
|
|
|
|
|
|
List<FastDeliveryGetShelfDetailResp> list = sellerOrderGoodsMapper.selectInfoByMulti(req.getUid(), req.getStatus(),
|
|
|
req.getSkup(), req.getOrderCode(), req.getStartTime(), req.getEndTime(), offset, limit);
|
|
|
|
|
|
// product_id -----> productCode
|
|
|
Map<Integer, ProductInfo> productInfoMap = productProxyService.getProductCodeList(list.stream().map(FastDeliveryGetShelfDetailResp::getProductId).collect(Collectors.toList()));
|
|
|
|
|
|
// 对账信息 以买家订单号的状态为准
|
|
|
List<Integer> skupLists = list.stream().map(FastDeliveryGetShelfDetailResp::getSkup).collect(Collectors.toList());
|
|
|
List<BuyerOrderGoods> buyerOrderGoodList = buyerOrderGoodsMapper.selectBySkups(skupLists);
|
|
|
// skup ---> buyer orderCode (取最新的一个)
|
|
|
Map<Integer, Long> skupToOrderCode = buyerOrderGoodList.stream().collect(Collectors.toMap(BuyerOrderGoods::getSkup, BuyerOrderGoods::getOrderCode, (key1, key2) -> key2));
|
|
|
|
|
|
Collection<Long> buyerOrderCodeList = skupToOrderCode.values();
|
|
|
|
|
|
Map<Long, BuyerOrder> orderCodeToBuyer = null;
|
|
|
Map<Long, List<TradeBills>> buyerOrderToTradeBills = null;
|
|
|
if (CollectionUtils.isNotEmpty(buyerOrderCodeList)){
|
|
|
List<BuyerOrder> buyerOrderList = buyerOrderMapper.selectByOrderCodes(buyerOrderCodeList, null);
|
|
|
// buyer orderCode ---> buyer order
|
|
|
orderCodeToBuyer = buyerOrderList.stream().collect(Collectors.toMap(BuyerOrder::getOrderCode, Function.identity(), (key1, key2) -> key2));
|
|
|
|
|
|
// 交易记录
|
|
|
List<TradeBills> tradeBillsList = tradeBillsMapper.selectByOrderCodeList(buyerOrderCodeList);
|
|
|
// buyer orderCode ---> ordersPayTransfer
|
|
|
buyerOrderToTradeBills = tradeBillsList.stream().collect(Collectors.groupingBy(TradeBills::getOrderCode));
|
|
|
}
|
|
|
|
|
|
// 对账信息
|
|
|
// 鉴定通过 -- 货款收入
|
|
|
// 鉴定不通过 -- 保证金扣款
|
|
|
// 买家取消时 -- 扣款
|
|
|
Map<Long, BuyerOrder> finalOrderCodeToBuyer = orderCodeToBuyer;
|
|
|
Map<Long, List<TradeBills>> finalBuyerOrderToTradeBills = buyerOrderToTradeBills;
|
|
|
List<FastDeliveryGetShelfDetailResp> data = list.stream().map(sellerOrder -> {
|
|
|
return covertToFastDeliveryShelfResp(productInfoMap, skupToOrderCode, finalOrderCodeToBuyer, finalBuyerOrderToTradeBills, sellerOrder);
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
FastDeliveryGetShelfResp fastDeliveryGetShelfResp = new FastDeliveryGetShelfResp();
|
|
|
fastDeliveryGetShelfResp.setData(data);
|
|
|
fastDeliveryGetShelfResp.setPage(req.getPage());
|
|
|
fastDeliveryGetShelfResp.setPageSize(req.getLimit());
|
|
|
fastDeliveryGetShelfResp.setTotal(total);
|
|
|
fastDeliveryGetShelfResp.setPagetotal((total % limit == 0) ? (total / limit) : (total / limit + 1));
|
|
|
|
|
|
return fastDeliveryGetShelfResp;
|
|
|
|
|
|
}
|
|
|
|
|
|
private FastDeliveryGetShelfDetailResp covertToFastDeliveryShelfResp(Map<Integer, ProductInfo> productInfoMap,
|
|
|
Map<Integer, Long> skupToOrderCode,
|
|
|
Map<Long, BuyerOrder> orderCodeToBuyer,
|
|
|
Map<Long, List<TradeBills>> buyerOrderToTradeBills,
|
|
|
FastDeliveryGetShelfDetailResp sellerOrder) {
|
|
|
|
|
|
if (productInfoMap != null){
|
|
|
sellerOrder.setProductCode(productInfoMap.getOrDefault(sellerOrder.getProductId(), new ProductInfo()).getProductCode());
|
|
|
}
|
|
|
|
|
|
sellerOrder.setStatusDesc(SkupStatus.getSkupStatus(sellerOrder.getStatus()).getDesc());
|
|
|
|
|
|
// 商品是否是上架关闭
|
|
|
if (sellerOrder.getStatus() == SkupStatus.SELLER_CANCEL_SELL.getCode()) {
|
|
|
// 无对账信息
|
|
|
return sellerOrder;
|
|
|
}
|
|
|
|
|
|
// 是否存在买家订单
|
|
|
Long buyerOrderCode = null;
|
|
|
BuyerOrder buyerOrder = null;
|
|
|
// 检查是否存在买家信息
|
|
|
if (skupToOrderCode == null
|
|
|
|| orderCodeToBuyer == null
|
|
|
|| (buyerOrderCode=skupToOrderCode.get(sellerOrder.getSkup()))==null
|
|
|
|| (buyerOrder=orderCodeToBuyer.get(buyerOrderCode)) == null){
|
|
|
return sellerOrder;
|
|
|
}
|
|
|
|
|
|
|
|
|
// 买家
|
|
|
FastDeliveryGetShelfDetailResp.BuyerOrder buyerOrderResp = new FastDeliveryGetShelfDetailResp.BuyerOrder();
|
|
|
buyerOrderResp.setOrderCode(buyerOrderCode);
|
|
|
buyerOrderResp.setStatus(buyerOrder.getStatus());
|
|
|
buyerOrderResp.setStatusDesc(OrderStatus.getOrderStatus(buyerOrder.getStatus()).getDesc());
|
|
|
sellerOrder.setBuyerOrderCode(buyerOrderResp);
|
|
|
|
|
|
if (buyerOrderToTradeBills == null){
|
|
|
return sellerOrder;
|
|
|
}
|
|
|
|
|
|
List<TradeBills> tradeBills = buyerOrderToTradeBills.get(buyerOrderCode);
|
|
|
if (CollectionUtils.isEmpty(tradeBills)) {
|
|
|
return sellerOrder;
|
|
|
}
|
|
|
|
|
|
FastDeliveryGetShelfDetailResp.TradeBill tradeBillResp = new FastDeliveryGetShelfDetailResp.TradeBill();
|
|
|
// 货款收入 incomeOutcome 1:用户收入 2:用户支出
|
|
|
TradeBills one = null;
|
|
|
if (GOODS_INCOME.contains(buyerOrder.getStatus())) {
|
|
|
one = getOneTradeBills(tradeBills, sellerOrder.getUid(), TradeType.goods_income.getCode(), 1, buyerOrderCode);
|
|
|
if (one != null){
|
|
|
tradeBillResp.setGoodIncome(one.getAmount());
|
|
|
tradeBillResp.setStatus(BillTradeStatus.getTradeTypeByCode(one.getTradeStatus()).getDesc());
|
|
|
}
|
|
|
}
|
|
|
// 保证金扣除
|
|
|
else if (DEDUCTION_EARNEST_MONEY.contains(buyerOrder.getStatus())) {
|
|
|
one = getOneTradeBills(tradeBills, buyerOrder.getUid(), TradeType.compensateIncome.getCode(), 1, buyerOrderCode);
|
|
|
if (one != null){
|
|
|
tradeBillResp.setEarnestMoneyDeduction(one.getAmount());
|
|
|
tradeBillResp.setStatus(BillTradeStatus.getTradeTypeByCode(one.getTradeStatus()).getDesc());
|
|
|
}
|
|
|
}
|
|
|
// 罚款收入
|
|
|
else if (BUYER_REASON_INCOME.contains(buyerOrder.getStatus())) {
|
|
|
one = getOneTradeBills(tradeBills, sellerOrder.getUid(), TradeType.compensateIncome.getCode(), 1, buyerOrderCode);
|
|
|
if (one != null){
|
|
|
tradeBillResp.setBuyerPenaltyIncome(one.getAmount());
|
|
|
tradeBillResp.setStatus(BillTradeStatus.getTradeTypeByCode(one.getTradeStatus()).getDesc());
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
sellerOrder.setTradeBill(tradeBillResp);
|
|
|
|
|
|
return sellerOrder;
|
|
|
}
|
|
|
|
|
|
|
|
|
private TradeBills getOneTradeBills(List<TradeBills> tradeBills, int uid, Integer tradeType, Integer incomeOutcome, Long orderCode){
|
|
|
List<TradeBills> any = tradeBills.stream().filter(trade -> trade.getUid() == uid
|
|
|
&& trade.getTradeType() == tradeType
|
|
|
&& trade.getIncomeOutcome() == incomeOutcome).collect(Collectors.toList());
|
|
|
if (CollectionUtils.isEmpty(any)){
|
|
|
logger.warn("getOneTradeBills buyerOrderCode {}", orderCode);
|
|
|
return null;
|
|
|
}
|
|
|
return any.stream().sorted(Comparator.comparing(TradeBills::getCreateTime).reversed()).limit(1).findFirst().get();
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 单个调价
|
|
|
* @param req
|
|
|
* @return
|
|
|
*/
|
|
|
public boolean singleAdjustPrice(FastDeliveryAdjustPriceReq req){
|
|
|
|
|
|
if (req.getUid() < 0){
|
|
|
logger.warn("uid is empty");
|
|
|
throw new UfoServiceException(400, "参数[uid]不合法");
|
|
|
}
|
|
|
|
|
|
if (req.getSkup() < 0){
|
|
|
logger.warn("skup is empty");
|
|
|
throw new UfoServiceException(401, "参数[skup]不合法");
|
|
|
}
|
|
|
|
|
|
if (StringUtils.isBlank(req.getNewPrice())){
|
|
|
logger.warn("price is invalidate");
|
|
|
throw new UfoServiceException(402, "参数[newPrice]不合法");
|
|
|
}
|
|
|
|
|
|
ChangePricePrepareDTO cppDto = adjustPricePrepareProcessor.getChangePricePreDto(req);
|
|
|
SellerTaskDTO<ChangePricePrepareDTO> taskDTO = null;
|
|
|
if (cppDto.getSalePrice().compareTo(cppDto.getPreSalePrice()) > 0) {
|
|
|
//涨价
|
|
|
taskDTO = new SellerTaskDTO(req.getUid(),
|
|
|
SellerWalletDetail.Type.ADD_PRICE.getValue(),
|
|
|
sellerIncrPriceTaskHandler,
|
|
|
JSON.toJSONString(req),cppDto);
|
|
|
} else if (cppDto.getSalePrice().compareTo(cppDto.getPreSalePrice()) < 0) {
|
|
|
//降价
|
|
|
taskDTO = new SellerTaskDTO(req.getUid(),
|
|
|
SellerWalletDetail.Type.SUBTRACT_PRICE.getValue(),
|
|
|
sellerDecrPriceTaskHandler,
|
|
|
JSON.toJSONString(req),cppDto);
|
|
|
} else {
|
|
|
throw new UfoServiceException(400, "价格没有变化");
|
|
|
}
|
|
|
|
|
|
SellerTaskResult result = sellerTaskProcessor.process(taskDTO);
|
|
|
return result.successCnt > 0 ? true : false;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 单个下架
|
|
|
* @param req
|
|
|
*/
|
|
|
public boolean singleDownSelf(FastDeliveryDownShelfReq req){
|
|
|
|
|
|
if (req.getUid() < 0){
|
|
|
logger.warn("uid is empty");
|
|
|
throw new UfoServiceException(400, "参数[uid]不合法");
|
|
|
}
|
|
|
|
|
|
if (req.getSkup() < 0){
|
|
|
logger.warn("skup is empty");
|
|
|
throw new UfoServiceException(401, "参数[skup]不合法");
|
|
|
}
|
|
|
|
|
|
SkupDownShelfPrepareDto skupDtoMap = sellerDownShelfPrepareProcessor.getDownShelfPreDto(req.getSkup());
|
|
|
SellerTaskDTO<SkupDownShelfPrepareDto> taskDTO = new SellerTaskDTO(req.getUid(),
|
|
|
SellerWalletDetail.Type.SELLER_OFF.getValue(),
|
|
|
sellerDownShelfTaskHandler,
|
|
|
JSON.toJSONString(req),
|
|
|
skupDtoMap);
|
|
|
|
|
|
SellerTaskResult result = sellerTaskProcessor.process(taskDTO);
|
|
|
return result.successCnt > 0 ? true : false;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void batchOnShelf(FastDeliveryBatchOnShelfReq req) {
|
|
|
|
|
|
// 检查入口参数
|
|
|
checkBatchOnShelf(req);
|
|
|
|
|
|
// 检查用户权限(批量上架权限)
|
|
|
int uid = req.getUid();
|
|
|
SellerWrapper sellerWrapper = sellerService.getFullDimensionSeller(req.getUid());
|
|
|
SellerBo sellerBo = sellerWrapper.buildSellerBo();
|
|
|
if (!sellerBo.isFastDeliverySuper()){
|
|
|
logger.warn("batchOnShelf not legal super, uid {} ", uid);
|
|
|
throw new UfoServiceException(501, "用户权限不合法!");
|
|
|
}
|
|
|
sellerWrapper = sellerWrapper.attachSellerLevelFunc((sw)->sellerFuncService.getSellerLevelFunc(sw));
|
|
|
sellerAuthCheckService.checkAuth(sellerBo, null, SellerFuncEnum.BATCH_PUBLISH);
|
|
|
|
|
|
// 检查货号and尺寸是否存在
|
|
|
List<ProductInfoReq> productInfoReqList = req.getProductInfos().stream().map(x -> {
|
|
|
ProductInfoReq productInfoReq = new ProductInfoReq();
|
|
|
productInfoReq.setProductCode(x.getProductCode());
|
|
|
productInfoReq.setSizeName(x.getSizeName());
|
|
|
return productInfoReq;
|
|
|
}).distinct().collect(Collectors.toList());
|
|
|
|
|
|
// 调用商品服务获取到商品的storageId
|
|
|
// 无法获取则异常
|
|
|
|
|
|
// 上架
|
|
|
List<ProductImportTranItemBo> responseList = Lists.newArrayList();
|
|
|
for(FastDeliveryBatchOnShelfReq.ProductInfo productInfo : req.getProductInfos()){
|
|
|
Integer storageId = productInfo.getStorageId();
|
|
|
BigDecimal salePrice = productInfo.getConvertedPrice();
|
|
|
int storageNum = productInfo.getNum();
|
|
|
ImPrdNode node = ImPrdNode.builder().uid(uid)
|
|
|
.sellerWrapper(sellerWrapper)
|
|
|
.storageId(storageId).salePrice(salePrice).storageNum(storageNum).productCode(productInfo.getProductCode()).sizeName(productInfo.getSizeName())
|
|
|
.skupType(SkupType.FAST_DELIVERY.getCode())
|
|
|
.build();
|
|
|
int successNum=0;
|
|
|
try{
|
|
|
SellerOrderSubmitHandler.ForkJoinResult fjr = importPublishExcutor.publishOne(node);
|
|
|
successNum = Objects.isNull(fjr) || Objects.isNull(fjr.getSkupIds()) ? 0 : fjr.getSkupIds().size();
|
|
|
|
|
|
responseList.add(buildShelfResp(req, productInfo, successNum));
|
|
|
}catch(Exception ex){
|
|
|
logger.warn("in batchOnShelf.publishOne fail, uid {} productCode {} sizeName {} storageId {} salePrice {} storageNum {}",
|
|
|
uid, productInfo.getProductCode(), productInfo.getSizeName(), storageId, salePrice, storageNum);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(responseList)){
|
|
|
productProxyService.batchAdd(responseList);
|
|
|
}else{
|
|
|
logger.warn("responseList empty");
|
|
|
throw new UfoServiceException(502, "上架失败!");
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
private ProductImportTranItemBo buildShelfResp(FastDeliveryBatchOnShelfReq req, FastDeliveryBatchOnShelfReq.ProductInfo productInfo, int successNum) {
|
|
|
// 构造结果对象 最终结果插入到 商品服务的product_import_tran_item表中
|
|
|
ProductImportTranItemBo productImportTranItemBo = new ProductImportTranItemBo();
|
|
|
productImportTranItemBo.setUid(req.getUid());
|
|
|
productImportTranItemBo.setProductCode(productInfo.getProductCode());
|
|
|
productImportTranItemBo.setStorageId(productInfo.getStorageId());
|
|
|
productImportTranItemBo.setSizeName(productInfo.getSizeName());
|
|
|
productImportTranItemBo.setPrice(productInfo.getConvertedPrice());
|
|
|
productImportTranItemBo.setNum(productInfo.getNum());
|
|
|
productImportTranItemBo.setSuccessdNum(successNum);
|
|
|
productImportTranItemBo.setTranId(0); // 不关心这个值 固定为0
|
|
|
return productImportTranItemBo;
|
|
|
}
|
|
|
|
|
|
|
|
|
private void checkBatchOnShelf(FastDeliveryBatchOnShelfReq req) {
|
|
|
|
|
|
if (req.getUid() < 0){
|
|
|
logger.warn("uid is empty");
|
|
|
throw new UfoServiceException(400, "参数[uid]错误");
|
|
|
}
|
|
|
|
|
|
if (CollectionUtils.isEmpty(req.getProductInfos())){
|
|
|
logger.warn("productInfo is empty");
|
|
|
throw new UfoServiceException(400, "商品信息为空");
|
|
|
}
|
|
|
|
|
|
for(FastDeliveryBatchOnShelfReq.ProductInfo productInfo : req.getProductInfos()){
|
|
|
if (StringUtils.isBlank(productInfo.getSizeName())
|
|
|
|| StringUtils.isBlank(productInfo.getProductCode())
|
|
|
|| productInfo.getNum() == null){
|
|
|
logger.warn("productInfo is invalidate {}", productInfo);
|
|
|
throw new UfoServiceException(400, "商品信息不合法");
|
|
|
}
|
|
|
|
|
|
// 价格已9结尾
|
|
|
BigDecimal salePrice = priceComputePrepareProcessor.checkAndAcquireSalePrice(productInfo.getPrice(), SkupType.FAST_DELIVERY);
|
|
|
productInfo.setConvertedPrice(salePrice);
|
|
|
}
|
|
|
}
|
|
|
} |
...
|
...
|
|