...
|
...
|
@@ -16,8 +16,11 @@ import java.util.function.BinaryOperator; |
|
|
import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
import com.yohobuy.ufo.model.request.product.ProductRequestBo;
|
|
|
import com.yohobuy.ufo.model.response.StorageCheckResp;
|
|
|
import com.yohobuy.ufo.model.response.store.StoreInfoBo;
|
|
|
import com.yohoufo.common.ApiResponse;
|
|
|
import com.yohoufo.common.utils.OrikaUtils;
|
|
|
import com.yohoufo.dal.product.*;
|
|
|
import com.yohoufo.dal.product.model.*;
|
|
|
import org.apache.commons.collections.MapUtils;
|
...
|
...
|
@@ -33,7 +36,7 @@ import org.springframework.stereotype.Service; |
|
|
import org.springframework.ui.ModelMap;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
import org.springframework.web.servlet.ModelAndView;
|
|
|
|
|
|
import com.yohobuy.ufo.model.enums.StorageCheckEnum;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.google.common.collect.Lists;
|
...
|
...
|
@@ -68,6 +71,7 @@ import com.yohoufo.product.response.SkupDetailForScreenResp; |
|
|
import com.yohoufo.product.response.StorageLeastPriceResp;
|
|
|
import com.yohoufo.product.service.ProductSearchService;
|
|
|
import com.yohoufo.product.service.ProductService;
|
|
|
import com.yohoufo.dal.product.model.Size;
|
|
|
|
|
|
|
|
|
@Service
|
...
|
...
|
@@ -206,7 +210,7 @@ public class ProductServiceImpl implements ProductService { |
|
|
BigDecimal quickDeliveryLeastPrice = quickDeliveryLeastPriceList.stream().min((p1, p2) -> (p1.compareTo(p2))).get();
|
|
|
productInfo.setQuickDeliveryPrice(quickDeliveryLeastPrice);
|
|
|
}
|
|
|
|
|
|
|
|
|
goodsSizes.sort(Comparator.comparing(GoodsSize::getOrderBy));
|
|
|
List<JSONObject> otherAddSizeList = getOtherSizeList(product.getMaxSortId(), product.getMidSortId(), goodsSizes);
|
|
|
if(!CollectionUtils.isEmpty(otherAddSizeList)) {
|
...
|
...
|
@@ -2078,7 +2082,7 @@ public class ProductServiceImpl implements ProductService { |
|
|
|
|
|
/**
|
|
|
* 根据编码查询货号 名称 和图片 商品颜色
|
|
|
* @param productId
|
|
|
* @param productIds
|
|
|
* @return
|
|
|
*/
|
|
|
public Map<Integer, ProductInfo> queryProductInfoMap(List<Integer> productIds) {
|
...
|
...
|
@@ -2138,4 +2142,115 @@ public class ProductServiceImpl implements ProductService { |
|
|
return false;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public List<StorageCheckResp> getStorageByCodeAndColorName(List<ProductRequestBo> reqList) {
|
|
|
List<StorageCheckResp> result = new ArrayList<>();
|
|
|
|
|
|
// 请求参数中的货号
|
|
|
List<String> reqProductCode = new ArrayList<>();
|
|
|
|
|
|
// 系统中有的货号
|
|
|
List<String> resultProductCode = new ArrayList<>();
|
|
|
|
|
|
// 系统中货号对应的productIds
|
|
|
List<Integer> productIds = new ArrayList<>();
|
|
|
HashMap<Integer, String> productIdAndCode = new HashMap<>();
|
|
|
|
|
|
// 请求参数中的尺码名称
|
|
|
List<String> reqSizeName = new ArrayList<>();
|
|
|
|
|
|
// 系统中的尺码名称
|
|
|
List<String> resultSizeName = new ArrayList<>();
|
|
|
HashMap<Integer, String> sizeIdAndName = new HashMap<>();
|
|
|
|
|
|
List<Integer> resultSizeIds = new ArrayList<>();
|
|
|
|
|
|
if (CollectionUtils.isEmpty(reqList)) {
|
|
|
throw new ServiceException(400, "参数错误");
|
|
|
}
|
|
|
|
|
|
// 1. 获取参数中的productCode, sizeName,
|
|
|
reqList.stream().forEach(item -> {
|
|
|
reqProductCode.add(item.getProductCode());
|
|
|
reqSizeName.add(item.getSizeName());
|
|
|
result.add(OrikaUtils.map(item, StorageCheckResp.class));
|
|
|
});
|
|
|
|
|
|
LOGGER.info("int reqProductCode lengh= {}", resultProductCode.size());
|
|
|
// 2. 查询 productCode 对应的product_id, 根据product_id 查询storage
|
|
|
List<Product> products = productMapper.selectByCodes(reqProductCode);
|
|
|
|
|
|
// 货号都不存在
|
|
|
if (CollectionUtils.isEmpty(products)) {
|
|
|
for(StorageCheckResp item : result) {
|
|
|
setStorageCheckRespStatusInfo(item, StorageCheckEnum.PRODUCT_NOT_FOUND.getType());
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
products.stream().forEach(item -> {
|
|
|
productIds.add(item.getId());
|
|
|
resultProductCode.add(item.getProductCode());
|
|
|
productIdAndCode.put(item.getId(), item.getProductCode());
|
|
|
});
|
|
|
LOGGER.info("int resultProductCode lengh= {}", resultProductCode.size());
|
|
|
|
|
|
// 3.查询系统中的库存
|
|
|
List<Storage> storages = storageMapper.selectByProductIds(productIds);
|
|
|
|
|
|
// 4. 查询 sizeName 对应的size_id
|
|
|
List<Size> sizes = sizeMapper.selectByNames(reqSizeName);
|
|
|
sizes.stream().forEach(item->{
|
|
|
resultSizeName.add(item.getSizeName());
|
|
|
resultSizeIds.add(item.getId());
|
|
|
sizeIdAndName.put(item.getId(), item.getSizeName());
|
|
|
});
|
|
|
|
|
|
// 5. 标记检测情况
|
|
|
// 5.1 不存在的货号
|
|
|
reqProductCode.removeAll(resultProductCode);
|
|
|
// 5.2 不存在的尺码名称
|
|
|
reqSizeName.removeAll(resultSizeName);
|
|
|
|
|
|
loop: for(StorageCheckResp item : result) {
|
|
|
// 不存在的货号
|
|
|
if (reqProductCode.contains(item.getProductCode())) {
|
|
|
setStorageCheckRespStatusInfo(item, StorageCheckEnum.PRODUCT_NOT_FOUND.getType());
|
|
|
LOGGER.info("货号不存在 = {}", item);
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
// 不存在的尺码
|
|
|
if (reqSizeName.contains(item.getSizeName())) {
|
|
|
LOGGER.info("尺码名称不存在 = {}", item);
|
|
|
setStorageCheckRespStatusInfo(item, StorageCheckEnum.SIZE_NOT_FOUND.getType());
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
for(Storage storage : storages) {
|
|
|
// 货号和尺码匹配
|
|
|
if (item.getProductCode() == productIdAndCode.get(storage.getProductId()) && item.getSizeName() == sizeIdAndName.get(storage.getSizeId())) {
|
|
|
setStorageCheckRespStatusInfo(item, StorageCheckEnum.PRODUCT_SIZE_MATCH.getType());
|
|
|
continue loop;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 货号和尺码不匹配
|
|
|
setStorageCheckRespStatusInfo(item, StorageCheckEnum.PRODUCT_SIZE_NOT_MATCH.getType());
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 设置检测结果状态信息
|
|
|
* @param item
|
|
|
* @param status
|
|
|
* @return
|
|
|
*/
|
|
|
private StorageCheckResp setStorageCheckRespStatusInfo(StorageCheckResp item, Integer status) {
|
|
|
item.setStatus(status);
|
|
|
item.setStatusStr(StorageCheckEnum.getTypeName(status));
|
|
|
return item;
|
|
|
}
|
|
|
} |
...
|
...
|
|