|
|
package com.yohoufo.product.service.impl;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.Collection;
|
|
|
import java.util.Collections;
|
|
|
import java.util.Comparator;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.HashSet;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Map.Entry;
|
|
|
import java.util.Objects;
|
|
|
import java.util.Set;
|
|
|
import java.util.UUID;
|
|
|
import java.util.function.BinaryOperator;
|
|
|
import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.serializer.SerializerFeature;
|
|
|
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.constant.BusinessClientEnum;
|
|
|
import com.yohoufo.common.exception.UfoServiceException;
|
|
|
import com.yohoufo.common.utils.OrikaUtils;
|
|
|
import com.yohoufo.dal.product.*;
|
|
|
import com.yohoufo.dal.product.model.*;
|
|
|
import org.apache.commons.collections.MapUtils;
|
|
|
import org.apache.commons.lang.ArrayUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
...
|
...
|
@@ -28,14 +28,14 @@ import org.slf4j.LoggerFactory; |
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Propagation;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
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.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.alibaba.fastjson.serializer.SerializerFeature;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.yoho.core.common.helpers.ImagesHelper;
|
|
|
import com.yoho.core.config.ConfigReader;
|
...
|
...
|
@@ -45,15 +45,65 @@ import com.yohobuy.ufo.model.GoodsBO; |
|
|
import com.yohobuy.ufo.model.GoodsImageBO;
|
|
|
import com.yohobuy.ufo.model.GoodsSize;
|
|
|
import com.yohobuy.ufo.model.ProductInfo;
|
|
|
import com.yohobuy.ufo.model.enums.StorageCheckEnum;
|
|
|
import com.yohobuy.ufo.model.request.StoragePriceBo;
|
|
|
import com.yohobuy.ufo.model.request.product.PriceTrendBO;
|
|
|
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.StorageDataResp;
|
|
|
import com.yohobuy.ufo.model.response.StorageInfoResp;
|
|
|
import com.yohobuy.ufo.model.response.store.StoreInfoBo;
|
|
|
import com.yohoufo.common.ApiResponse;
|
|
|
import com.yohoufo.common.caller.UfoServiceCaller;
|
|
|
import com.yohoufo.common.constant.BusinessClientEnum;
|
|
|
import com.yohoufo.common.helper.ImageUrlAssist;
|
|
|
import com.yohoufo.common.utils.DateUtil;
|
|
|
import com.yohoufo.common.utils.OrikaUtils;
|
|
|
import com.yohoufo.common.utils.UfoStringUtils;
|
|
|
import com.yohobuy.ufo.model.request.product.PriceTrendBO;
|
|
|
import com.yohoufo.dal.product.BrandMapper;
|
|
|
import com.yohoufo.dal.product.BrandSeriesMapper;
|
|
|
import com.yohoufo.dal.product.GoodsImagesMapper;
|
|
|
import com.yohoufo.dal.product.GoodsMapper;
|
|
|
import com.yohoufo.dal.product.PriceTrendDayMapper;
|
|
|
import com.yohoufo.dal.product.PriceTrendMonthMapper;
|
|
|
import com.yohoufo.dal.product.ProductLimitSaleMapper;
|
|
|
import com.yohoufo.dal.product.ProductMapper;
|
|
|
import com.yohoufo.dal.product.ProductProfitMapper;
|
|
|
import com.yohoufo.dal.product.ProductSalesMapper;
|
|
|
import com.yohoufo.dal.product.ProductSortMapper;
|
|
|
import com.yohoufo.dal.product.SaleCategoryMapper;
|
|
|
import com.yohoufo.dal.product.SecondhandFlawMapper;
|
|
|
import com.yohoufo.dal.product.SecondhandImagesMapper;
|
|
|
import com.yohoufo.dal.product.SecondhandInfoMapper;
|
|
|
import com.yohoufo.dal.product.SelfSizeMapper;
|
|
|
import com.yohoufo.dal.product.SelfSizeUidMapper;
|
|
|
import com.yohoufo.dal.product.SizeMapper;
|
|
|
import com.yohoufo.dal.product.SizePoolDetailMapper;
|
|
|
import com.yohoufo.dal.product.SizePoolMapper;
|
|
|
import com.yohoufo.dal.product.StorageMapper;
|
|
|
import com.yohoufo.dal.product.StoragePriceMapper;
|
|
|
import com.yohoufo.dal.product.model.Brand;
|
|
|
import com.yohoufo.dal.product.model.BrandSeries;
|
|
|
import com.yohoufo.dal.product.model.Goods;
|
|
|
import com.yohoufo.dal.product.model.GoodsImages;
|
|
|
import com.yohoufo.dal.product.model.PriceTrendModel;
|
|
|
import com.yohoufo.dal.product.model.Product;
|
|
|
import com.yohoufo.dal.product.model.ProductLimitSale;
|
|
|
import com.yohoufo.dal.product.model.ProductProfit;
|
|
|
import com.yohoufo.dal.product.model.ProductSales;
|
|
|
import com.yohoufo.dal.product.model.ProductSort;
|
|
|
import com.yohoufo.dal.product.model.SaleCategory;
|
|
|
import com.yohoufo.dal.product.model.SecondhandFlaw;
|
|
|
import com.yohoufo.dal.product.model.SecondhandImages;
|
|
|
import com.yohoufo.dal.product.model.SecondhandInfo;
|
|
|
import com.yohoufo.dal.product.model.SelfSize;
|
|
|
import com.yohoufo.dal.product.model.SelfSizeUid;
|
|
|
import com.yohoufo.dal.product.model.Size;
|
|
|
import com.yohoufo.dal.product.model.SizePool;
|
|
|
import com.yohoufo.dal.product.model.SizePoolDetail;
|
|
|
import com.yohoufo.dal.product.model.Storage;
|
|
|
import com.yohoufo.dal.product.model.StoragePrice;
|
|
|
import com.yohoufo.product.model.ProductSeriesTemplate;
|
|
|
import com.yohoufo.product.model.ProductSortTemplate;
|
|
|
import com.yohoufo.product.model.SkupDetailForScreenInfo;
|
...
|
...
|
@@ -68,7 +118,6 @@ 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
|
...
|
...
|
@@ -165,26 +214,25 @@ public class ProductServiceImpl implements ProductService { |
|
|
|
|
|
@Autowired
|
|
|
private BidProductService bidProductService;
|
|
|
|
|
|
@Autowired
|
|
|
private SizePoolMapper sizePoolMapper;
|
|
|
|
|
|
@Autowired
|
|
|
private SizePoolDetailMapper sizePoolDetailMapper;
|
|
|
|
|
|
@Override
|
|
|
public ProductDetailResp queryProductDetailById(Integer productId) {
|
|
|
ProductDetailResp productDetailResp = new ProductDetailResp();
|
|
|
Product product = productMapper.selectByPrimaryKey(productId);
|
|
|
Product product = productHelpService.selectByIdCache(productId);
|
|
|
if (product != null) {
|
|
|
ProductInfo productInfo = new ProductInfo();
|
|
|
productInfo.setProductId(product.getId());
|
|
|
productInfo.setProductName(product.getProductName());
|
|
|
productInfo.setProductCode(product.getProductCode());
|
|
|
productInfo.setMaxSortId(product.getMaxSortId());
|
|
|
productInfo.setMaxPrice(product.getMaxPrice());
|
|
|
productInfo.setMinPrice(product.getMinPrice());
|
|
|
productInfo.setShelveStatus(product.getShelveStatus());
|
|
|
productInfo.setGender(productHelpService.getGenderName(product.getGender()));
|
|
|
productInfo.setSaleTime((product.getSaleTime() == null || product.getSaleTime().equals(0)) ? "0" : DateUtil.getDateString(product.getSaleTime(), DateUtil.YYYY_MM_DD_DOT));
|
|
|
productInfo.setOfferPrice(product.getOfferPrice());
|
|
|
setBrand(productInfo, product.getBrandId());
|
|
|
setSeries(productInfo, product.getSeriesId());
|
|
|
productInfo.setLeastPrice(null);
|
|
|
productInfo.setProductId(product.getId()).setProductName(product.getProductName()).setProductCode(product.getProductCode())
|
|
|
.setMaxSortId(product.getMaxSortId()).setMaxPrice(product.getMaxPrice()).setMinPrice(product.getMinPrice()).setLeastPrice(null)
|
|
|
.setShelveStatus(product.getShelveStatus()).setGender(productHelpService.getGenderName(product.getGender())).setOfferPrice(product.getOfferPrice())
|
|
|
.setSaleTime((product.getSaleTime() == null || product.getSaleTime().equals(0)) ? "0" : DateUtil.getDateString(product.getSaleTime(), DateUtil.YYYY_MM_DD_DOT));
|
|
|
|
|
|
productHelpService.setBrand(productInfo, product.getBrandId()).setSeries(productInfo, product.getSeriesId());
|
|
|
|
|
|
List<GoodsBO> goodsBOList = getGoodsList(product.getId(), product.getMinPrice(), product.getMaxPrice());
|
|
|
if (!CollectionUtils.isEmpty(goodsBOList) && goodsBOList.get(0) != null) {
|
...
|
...
|
@@ -195,46 +243,13 @@ public class ProductServiceImpl implements ProductService { |
|
|
// 设置求购信息
|
|
|
bidProductService.setBidStroagePrice(goodsSizes, productId, false);
|
|
|
|
|
|
List<BigDecimal> leastPriceList = goodsSizes.stream().map(GoodsSize::getLeastPrice).filter(Objects::nonNull).collect(Collectors.toList());
|
|
|
if (!CollectionUtils.isEmpty(leastPriceList)) {
|
|
|
BigDecimal leastPrice = leastPriceList.stream().min((p1, p2) -> (p1.compareTo(p2))).get();
|
|
|
productInfo.setLeastPrice(leastPrice);
|
|
|
}
|
|
|
List<BigDecimal> preSaleLeastPriceList = goodsSizes.stream().map(GoodsSize::getPreSaleLeastPrice).filter(Objects::nonNull).collect(Collectors.toList());
|
|
|
if (!CollectionUtils.isEmpty(preSaleLeastPriceList)) {
|
|
|
BigDecimal preSaleLeastPrice = preSaleLeastPriceList.stream().min((p1, p2) -> (p1.compareTo(p2))).get();
|
|
|
productInfo.setPreSaleLeastPrice(preSaleLeastPrice);
|
|
|
}
|
|
|
|
|
|
List<BigDecimal> secondHandLeastPriceList = goodsSizes.stream().map(GoodsSize::getSecondHandLeastPrice).filter(Objects::nonNull).collect(Collectors.toList());
|
|
|
if (!CollectionUtils.isEmpty(secondHandLeastPriceList)) {
|
|
|
BigDecimal secondHandLeastPrice = secondHandLeastPriceList.stream().min((p1, p2) -> (p1.compareTo(p2))).get();
|
|
|
productInfo.setSecondHandLeastPrice(secondHandLeastPrice);
|
|
|
}
|
|
|
|
|
|
List<BigDecimal> hkLeastPriceList = goodsSizes.stream().map(GoodsSize::getHkLeastPrice).filter(Objects::nonNull).collect(Collectors.toList());
|
|
|
if(!CollectionUtils.isEmpty(hkLeastPriceList)) {
|
|
|
BigDecimal hkLeastPrice = hkLeastPriceList.stream().min((p1, p2) -> (p1.compareTo(p2))).get();
|
|
|
productInfo.setHkLeastPrice(hkLeastPrice);
|
|
|
}
|
|
|
|
|
|
List<BigDecimal> flashLeastPriceList = goodsSizes.stream().map(GoodsSize::getFlashLeastPrice).filter(Objects::nonNull).collect(Collectors.toList());
|
|
|
if(!CollectionUtils.isEmpty(flashLeastPriceList)) {
|
|
|
BigDecimal flashLeastPrice = flashLeastPriceList.stream().min((p1, p2) -> (p1.compareTo(p2))).get();
|
|
|
productInfo.setFlashLeastPrice(flashLeastPrice);
|
|
|
}
|
|
|
|
|
|
List<BigDecimal> quickDeliveryLeastPriceList = goodsSizes.stream().map(GoodsSize::getQuickDeliveryPrice).filter(Objects::nonNull).collect(Collectors.toList());
|
|
|
if(!CollectionUtils.isEmpty(quickDeliveryLeastPriceList)) {
|
|
|
BigDecimal quickDeliveryLeastPrice = quickDeliveryLeastPriceList.stream().min((p1, p2) -> (p1.compareTo(p2))).get();
|
|
|
productInfo.setQuickDeliveryPrice(quickDeliveryLeastPrice);
|
|
|
}
|
|
|
|
|
|
List<BigDecimal> bidMosterPriceList = goodsSizes.stream().map(GoodsSize::getBidMosterPrice).filter(Objects::nonNull).collect(Collectors.toList());
|
|
|
if(!CollectionUtils.isEmpty(bidMosterPriceList)) {
|
|
|
BigDecimal bidMosterPrice = bidMosterPriceList.stream().max((p1, p2) -> (p1.compareTo(p2))).get();
|
|
|
productInfo.setMosterPrice(bidMosterPrice);
|
|
|
}
|
|
|
productHelpService.setSkupLeastPrice(goodsSizes, GoodsSize::getLeastPrice, productInfo::setLeastPrice)
|
|
|
.setSkupLeastPrice(goodsSizes, GoodsSize::getPreSaleLeastPrice, productInfo::setPreSaleLeastPrice)
|
|
|
.setSkupLeastPrice(goodsSizes, GoodsSize::getSecondHandLeastPrice, productInfo::setSecondHandLeastPrice)
|
|
|
.setSkupLeastPrice(goodsSizes, GoodsSize::getHkLeastPrice, productInfo::setHkLeastPrice)
|
|
|
.setSkupLeastPrice(goodsSizes, GoodsSize::getFlashLeastPrice, productInfo::setFlashLeastPrice)
|
|
|
.setSkupLeastPrice(goodsSizes, GoodsSize::getQuickDeliveryPrice, productInfo::setQuickDeliveryPrice)
|
|
|
.setSkupLeastPrice(goodsSizes, GoodsSize::getBidMosterPrice, productInfo::setMosterPrice);
|
|
|
|
|
|
goodsSizes.sort(Comparator.comparing(GoodsSize::getOrderBy));
|
|
|
List<JSONObject> otherAddSizeList = getOtherSizeList(product.getMaxSortId(), product.getMidSortId(), goodsSizes);
|
...
|
...
|
@@ -1941,6 +1956,30 @@ public class ProductServiceImpl implements ProductService { |
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public String getSizeImage(Integer productId) {
|
|
|
Product product = productMapper.selectByPrimaryKey(productId);
|
|
|
if(null == product) {
|
|
|
return StringUtils.EMPTY;
|
|
|
}
|
|
|
List<SizePoolDetail> list = sizePoolDetailMapper.queryByProductId(productId);
|
|
|
if(CollectionUtils.isEmpty(list)) {
|
|
|
list = sizePoolDetailMapper.queryByBrandId(product.getBrandId());
|
|
|
}
|
|
|
|
|
|
if(CollectionUtils.isEmpty(list)) {
|
|
|
return StringUtils.EMPTY;
|
|
|
}
|
|
|
|
|
|
List<Integer> poolIdList = list.stream().map(SizePoolDetail::getSizePoolId).collect(Collectors.toList());
|
|
|
SizePool pool = sizePoolMapper.querySizePoolByIds(poolIdList);
|
|
|
if(null == pool) {
|
|
|
return StringUtils.EMPTY;
|
|
|
}
|
|
|
|
|
|
return pool.getImageUrl();
|
|
|
}
|
|
|
|
|
|
private List<Integer> buildSizeIdList(String[] sizeIdArr){
|
|
|
List<Integer> sizeIdList = Lists.newArrayList();
|
|
|
for(int i=0; i<sizeIdArr.length; i++) {
|
...
|
...
|
|