|
|
package com.yoho.search.consumer.service.logic;
|
|
|
|
|
|
import com.yoho.search.base.utils.DateUtil;
|
|
|
import com.yoho.search.base.utils.MathUtils;
|
|
|
import com.yoho.search.consumer.service.base.Product15DaySalesNumService;
|
|
|
import com.yoho.search.consumer.service.base.ProductActivitiesLinkService;
|
|
|
import com.yoho.search.consumer.service.bo.*;
|
|
|
import com.yoho.search.dal.*;
|
|
|
import com.yoho.search.dal.model.*;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
import java.text.DecimalFormat;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import com.yoho.search.base.utils.DateUtil;
|
|
|
import com.yoho.search.base.utils.MathUtils;
|
|
|
import com.yoho.search.consumer.service.base.Product15DaySalesNumService;
|
|
|
import com.yoho.search.consumer.service.base.ProductActivitiesLinkService;
|
|
|
import com.yoho.search.consumer.service.bo.ProductActivitiesBO;
|
|
|
import com.yoho.search.consumer.service.bo.ProductGoodsBO;
|
|
|
import com.yoho.search.consumer.service.bo.ProductIBO;
|
|
|
import com.yoho.search.consumer.service.bo.ProductIndexBO;
|
|
|
import com.yoho.search.consumer.service.bo.ProductPoolDetailSknBO;
|
|
|
import com.yoho.search.consumer.service.bo.ProductSearchBrandWeightBO;
|
|
|
import com.yoho.search.consumer.service.bo.ProductSearchShopWeightBO;
|
|
|
import com.yoho.search.consumer.service.bo.ProductSearchSortWeightBO;
|
|
|
import com.yoho.search.consumer.service.bo.ProductStandardsBO;
|
|
|
import com.yoho.search.dal.BasePinRatioMapper;
|
|
|
import com.yoho.search.dal.BrandMapper;
|
|
|
import com.yoho.search.dal.BrokenCodeProductMapper;
|
|
|
import com.yoho.search.dal.DiscountProductSknMapper;
|
|
|
import com.yoho.search.dal.GoodsImagesMapper;
|
|
|
import com.yoho.search.dal.GoodsMapper;
|
|
|
import com.yoho.search.dal.ProductColorsMapper;
|
|
|
import com.yoho.search.dal.ProductDefaultImageMapper;
|
|
|
import com.yoho.search.dal.ProductMapper;
|
|
|
import com.yoho.search.dal.ProductPoolDetailMapper;
|
|
|
import com.yoho.search.dal.ProductSortMapper;
|
|
|
import com.yoho.search.dal.ProductStyleMapper;
|
|
|
import com.yoho.search.dal.ProductStyleRelationMapper;
|
|
|
import com.yoho.search.dal.PromotionProductMapper;
|
|
|
import com.yoho.search.dal.model.BasePinRatio;
|
|
|
import com.yoho.search.dal.model.Brand;
|
|
|
import com.yoho.search.dal.model.BrokenCode;
|
|
|
import com.yoho.search.dal.model.DiscountProductSkn;
|
|
|
import com.yoho.search.dal.model.Product;
|
|
|
import com.yoho.search.dal.model.Product15DaySalesNum;
|
|
|
import com.yoho.search.dal.model.ProductActivitiesLink;
|
|
|
import com.yoho.search.dal.model.ProductColors;
|
|
|
import com.yoho.search.dal.model.ProductDefaultImage;
|
|
|
import com.yoho.search.dal.model.ProductFeature;
|
|
|
import com.yoho.search.dal.model.ProductKeywords;
|
|
|
import com.yoho.search.dal.model.ProductPrice;
|
|
|
import com.yoho.search.dal.model.ProductSizes;
|
|
|
import com.yoho.search.dal.model.ProductSort;
|
|
|
import com.yoho.search.dal.model.ProductStyles;
|
|
|
import com.yoho.search.dal.model.PromotionProduct;
|
|
|
import com.yoho.search.dal.model.StorageUpdateTime;
|
|
|
|
|
|
/**
|
|
|
* Created by wangnan on 2016/6/29.
|
|
|
*/
|
...
|
...
|
@@ -85,6 +124,8 @@ public class ProductIndexLogicService { |
|
|
private ProductStyleMapper productStyleMapper;
|
|
|
@Autowired
|
|
|
private StorageUpdateTimeLogicService storageUpdateTimeLogicService;
|
|
|
@Autowired
|
|
|
private PromotionProductMapper promotionProductMapper;
|
|
|
|
|
|
/**
|
|
|
* 获取ProductIndex列表,用于取代视图。
|
...
|
...
|
@@ -203,7 +244,8 @@ public class ProductIndexLogicService { |
|
|
Map<Integer, ProductFeature> productFeatureSknsMap = getProductFeatureSknsMap(skns);
|
|
|
Map<Integer, ProductPoolDetailSknBO> getProductPoolDetailSknMap = getProductPoolDetailSknMap(skns);
|
|
|
Map<Integer, Product15DaySalesNum> productProduct15DaySalesNumMap = getProduct15DaySalesNumMap(skns);
|
|
|
|
|
|
Map<Integer, String> promotionProductMap = getPromotionProductMap(skns);
|
|
|
|
|
|
|
|
|
for (ProductIBO productIBO : productIBOs) {
|
|
|
ProductIndexBO productIndexBO = new ProductIndexBO();
|
...
|
...
|
@@ -249,6 +291,9 @@ public class ProductIndexLogicService { |
|
|
productIndexBO = buildProductPoolDetailSkn(productIBO, productIndexBO, getProductPoolDetailSknMap);
|
|
|
//来自StorageUpdateTimeBO
|
|
|
productIndexBO = buildStorageUpdateTime(productIBO, productIndexBO, getStorageUpdateTimeBOsMap);
|
|
|
//来自erp_product.promotion_product
|
|
|
productIndexBO = buildPromotionProduct(productIBO, productIndexBO,promotionProductMap);
|
|
|
|
|
|
productIndexBOs.add(productIndexBO);
|
|
|
}
|
|
|
return productIndexBOs;
|
...
|
...
|
@@ -706,7 +751,14 @@ public class ProductIndexLogicService { |
|
|
}
|
|
|
return pi;
|
|
|
}
|
|
|
|
|
|
private ProductIndexBO buildPromotionProduct(ProductIBO p, ProductIndexBO pi, Map<Integer, String> getPromotionProductMap) {
|
|
|
String pp = getPromotionProductMap.get(p.getProductSkn());
|
|
|
if (pp != null) {
|
|
|
pi.setPromotionIds(pp);
|
|
|
}
|
|
|
return pi;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @param p
|
|
|
* @param pi
|
...
|
...
|
@@ -827,6 +879,35 @@ public class ProductIndexLogicService { |
|
|
List<Product15DaySalesNum> product15DaySalesNum = product15DaySalesNumService.getSalesNumListList(skns);
|
|
|
return product15DaySalesNum.stream().parallel().collect(Collectors.toMap(Product15DaySalesNum::getProductSkn, (p) -> p));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 从erp_product.promotion_product表中获取promotionId
|
|
|
*
|
|
|
* @param skns
|
|
|
* @return
|
|
|
*/
|
|
|
private Map<Integer, String> getPromotionProductMap(List<Integer> skns) {
|
|
|
Map<Integer, String> boList= new HashMap<Integer,String>();
|
|
|
List<PromotionProduct> list = promotionProductMapper.selectListBySkns(skns);
|
|
|
for(PromotionProduct pp:list){
|
|
|
try {
|
|
|
Integer promotionId = pp.getPromotionId();
|
|
|
if(promotionId==null){
|
|
|
continue;
|
|
|
}
|
|
|
String ps=boList.get(pp.getProductSkn());
|
|
|
if(ps==null){
|
|
|
boList.put(pp.getProductSkn(), promotionId.toString());
|
|
|
}else{
|
|
|
boList.put(pp.getProductSkn(), new StringBuffer(ps).append(",").append(promotionId.toString()).toString());
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
logger.error(e.getMessage(),e);
|
|
|
}
|
|
|
}
|
|
|
return boList;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* product_price 表查询
|
...
|
...
|
|