...
|
...
|
@@ -3,6 +3,7 @@ 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.enums.StorageCheckEnum;
|
|
|
import com.yohobuy.ufo.model.order.bo.SellerBo;
|
|
|
import com.yohobuy.ufo.model.order.common.OrderStatus;
|
|
|
import com.yohobuy.ufo.model.order.common.SellerFuncEnum;
|
...
|
...
|
@@ -14,8 +15,12 @@ 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.request.product.ProductRequestBo;
|
|
|
import com.yohobuy.ufo.model.response.ProductDetailResp;
|
|
|
import com.yohobuy.ufo.model.response.StorageCheckResp;
|
|
|
import com.yohobuy.ufo.model.response.StorageInfoResp;
|
|
|
import com.yohoufo.common.exception.UfoServiceException;
|
|
|
import com.yohoufo.common.utils.StringUtil;
|
|
|
import com.yohoufo.dal.order.*;
|
|
|
import com.yohoufo.dal.order.model.*;
|
|
|
import com.yohoufo.order.common.BillTradeStatus;
|
...
|
...
|
@@ -145,6 +150,8 @@ public class ErpFastDeliveryServiceImpl implements IErpFastDeliveryService { |
|
|
req.setPage(1);
|
|
|
}
|
|
|
|
|
|
checkFastDeliveryAuth(req.getUid());
|
|
|
|
|
|
int total = sellerOrderGoodsMapper.selectCntByMulti(req.getUid(), req.getStatus(), req.getSkup(),
|
|
|
req.getOrderCode(), req.getStartTime(), req.getEndTime());
|
|
|
if (total == 0) {
|
...
|
...
|
@@ -296,6 +303,28 @@ public class ErpFastDeliveryServiceImpl implements IErpFastDeliveryService { |
|
|
|
|
|
|
|
|
/**
|
|
|
* 获取某个货号的最低价
|
|
|
* @param productCode
|
|
|
* @return
|
|
|
*/
|
|
|
public List<StorageInfoResp> getLeastPriceByProductCode(FastDeliveryLeastPriceReq req){
|
|
|
|
|
|
if (req.getUid() < 0){
|
|
|
logger.warn("uid is empty");
|
|
|
throw new UfoServiceException(400, "参数[uid]不合法");
|
|
|
}
|
|
|
|
|
|
if (StringUtils.isBlank(req.getProductCode())){
|
|
|
logger.warn("productCode is empty");
|
|
|
throw new UfoServiceException(400, "参数[productCode]不合法");
|
|
|
}
|
|
|
|
|
|
checkFastDeliveryAuth(req.getUid());
|
|
|
|
|
|
return productProxyService.getLowestPrice(req.getProductCode());
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 单个调价
|
|
|
* @param req
|
|
|
* @return
|
...
|
...
|
@@ -317,6 +346,8 @@ public class ErpFastDeliveryServiceImpl implements IErpFastDeliveryService { |
|
|
throw new UfoServiceException(402, "参数[newPrice]不合法");
|
|
|
}
|
|
|
|
|
|
checkFastDeliveryAuth(req.getUid());
|
|
|
|
|
|
ChangePricePrepareDTO cppDto = adjustPricePrepareProcessor.getChangePricePreDto(req);
|
|
|
SellerTaskDTO<ChangePricePrepareDTO> taskDTO = null;
|
|
|
if (cppDto.getSalePrice().compareTo(cppDto.getPreSalePrice()) > 0) {
|
...
|
...
|
@@ -355,6 +386,8 @@ public class ErpFastDeliveryServiceImpl implements IErpFastDeliveryService { |
|
|
throw new UfoServiceException(401, "参数[skup]不合法");
|
|
|
}
|
|
|
|
|
|
checkFastDeliveryAuth(req.getUid());
|
|
|
|
|
|
SkupDownShelfPrepareDto skupDtoMap = sellerDownShelfPrepareProcessor.getDownShelfPreDto(req.getSkup());
|
|
|
SellerTaskDTO<SkupDownShelfPrepareDto> taskDTO = new SellerTaskDTO(req.getUid(),
|
|
|
SellerWalletDetail.Type.SELLER_OFF.getValue(),
|
...
|
...
|
@@ -372,39 +405,47 @@ public class ErpFastDeliveryServiceImpl implements IErpFastDeliveryService { |
|
|
// 检查入口参数
|
|
|
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);
|
|
|
// 检查用户权限(急速发货权限)
|
|
|
SellerWrapper sellerWrapper = checkFastDeliveryAuth(req.getUid());
|
|
|
|
|
|
// 检查货号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());
|
|
|
// 检查批量上架权限
|
|
|
sellerWrapper = sellerWrapper.attachSellerLevelFunc((sw)->sellerFuncService.getSellerLevelFunc(sw));
|
|
|
sellerAuthCheckService.checkAuth(sellerWrapper.buildSellerBo(), null, SellerFuncEnum.BATCH_PUBLISH);
|
|
|
|
|
|
// 检查货号&尺寸 --> storageId
|
|
|
List<StorageCheckResp> storageCheckRespList = productProxyService.getStorageInfoList(buildStorageReq(req));
|
|
|
StorageCheckResp storageResp = storageCheckRespList.stream().filter(x->x.getStatus()!= StorageCheckEnum.PRODUCT_SIZE_MATCH.getType()).findAny().get();
|
|
|
if (storageResp != null){
|
|
|
logger.warn("productCode {} and sizeName {} invalidate", storageResp.getProductCode(), storageResp.getSizeName());
|
|
|
throw new UfoServiceException(400, "["+getProductCodeSizeNameKey(storageResp.getProductCode(),storageResp.getSizeName())+"]"+storageResp.getStatusStr());
|
|
|
}
|
|
|
|
|
|
// 调用商品服务获取到商品的storageId
|
|
|
// 无法获取则异常
|
|
|
Map<String,StorageCheckResp> storageMap = storageCheckRespList.stream().collect(Collectors.toMap(k->getProductCodeSizeNameKey(k.getProductCode(),k.getSizeName()), v->v));
|
|
|
|
|
|
// 上架
|
|
|
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)
|
|
|
|
|
|
StorageCheckResp storage = storageMap.get(storageMap.get(getProductCodeSizeNameKey(productInfo.getProductCode(), productInfo.getSizeName())));
|
|
|
if (storage == null){
|
|
|
logger.warn("productCode {} and sizeName {}. storageId not exist.", productInfo.getProductCode(), productInfo.getSizeName());
|
|
|
throw new UfoServiceException(403, "货号和尺寸对应的storageId不存在");
|
|
|
}
|
|
|
|
|
|
productInfo.setStorageId(storage.getStorageId());
|
|
|
|
|
|
ImPrdNode node = ImPrdNode.builder().uid(req.getUid())
|
|
|
.sellerWrapper(sellerWrapper)
|
|
|
.storageId(storageId).salePrice(salePrice).storageNum(storageNum).productCode(productInfo.getProductCode()).sizeName(productInfo.getSizeName())
|
|
|
.storageId(productInfo.getStorageId())
|
|
|
.salePrice(productInfo.getConvertedPrice())
|
|
|
.storageNum(productInfo.getNum())
|
|
|
.productCode(productInfo.getProductCode())
|
|
|
.sizeName(productInfo.getSizeName())
|
|
|
.skupType(SkupType.FAST_DELIVERY.getCode())
|
|
|
.build();
|
|
|
|
|
|
int successNum=0;
|
|
|
try{
|
|
|
SellerOrderSubmitHandler.ForkJoinResult fjr = importPublishExcutor.publishOne(node);
|
...
|
...
|
@@ -413,7 +454,8 @@ public class ErpFastDeliveryServiceImpl implements IErpFastDeliveryService { |
|
|
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);
|
|
|
req.getUid(), productInfo.getProductCode(), productInfo.getSizeName(), productInfo.getStorageId(),
|
|
|
productInfo.getConvertedPrice(), productInfo.getNum());
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
@@ -426,6 +468,45 @@ public class ErpFastDeliveryServiceImpl implements IErpFastDeliveryService { |
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String getProductCodeSizeNameKey(String productCode, String sizeName){
|
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
sb.append(productCode);
|
|
|
sb.append("_");
|
|
|
sb.append(sizeName);
|
|
|
return sb.toString();
|
|
|
|
|
|
}
|
|
|
private List<ProductRequestBo> buildStorageReq(FastDeliveryBatchOnShelfReq req) {
|
|
|
return req.getProductInfos().stream().map(x -> {
|
|
|
ProductRequestBo productInfoReq = new ProductRequestBo();
|
|
|
productInfoReq.setProductCode(x.getProductCode());
|
|
|
productInfoReq.setSizeName(x.getSizeName());
|
|
|
return productInfoReq;
|
|
|
}).distinct().collect(Collectors.toList());
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 检查极速发货用户权限
|
|
|
* @param uid
|
|
|
* @return
|
|
|
*/
|
|
|
public SellerWrapper checkFastDeliveryAuth(int uid){
|
|
|
|
|
|
SellerWrapper sellerWrapper = sellerService.getFullDimensionSeller(uid);
|
|
|
SellerBo sellerBo = sellerWrapper.buildSellerBo();
|
|
|
if (!sellerBo.isFastDeliverySuper()){
|
|
|
logger.warn("checkFastDeliveryAuth not legal super, uid {} ", uid);
|
|
|
throw new UfoServiceException(501, "用户权限不合法!");
|
|
|
}
|
|
|
|
|
|
return sellerWrapper;
|
|
|
}
|
|
|
|
|
|
private ProductImportTranItemBo buildShelfResp(FastDeliveryBatchOnShelfReq req, FastDeliveryBatchOnShelfReq.ProductInfo productInfo, int successNum) {
|
|
|
// 构造结果对象 最终结果插入到 商品服务的product_import_tran_item表中
|
|
|
ProductImportTranItemBo productImportTranItemBo = new ProductImportTranItemBo();
|
...
|
...
|
|