...
|
...
|
@@ -5,10 +5,10 @@ import com.yoho.search.consumer.service.bo.ProductIBO; |
|
|
import com.yoho.search.dal.model.Brand;
|
|
|
import com.yoho.search.dal.model.Product;
|
|
|
import com.yoho.search.dal.model.ProductSort;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
import retrofit.http.HEAD;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
...
|
...
|
@@ -20,239 +20,270 @@ import java.util.Map; |
|
|
@Component
|
|
|
public class ProductILogicService {
|
|
|
|
|
|
private final Logger logger = LoggerFactory.getLogger(ProductILogicService.class);
|
|
|
private final Logger logger = LoggerFactory.getLogger(ProductILogicService.class);
|
|
|
|
|
|
/**
|
|
|
* 过滤product列表<br>
|
|
|
*
|
|
|
* @param products
|
|
|
* @param ProductSortMap
|
|
|
* @param brandMap
|
|
|
* @return <br>
|
|
|
* @author wangnan<br>
|
|
|
*/
|
|
|
public List<Product> filterProductList(List<Product> products, Map<Integer, ProductSort> ProductSortMap, Map<Integer, Brand> brandMap) {
|
|
|
List<Product> productsNew = new ArrayList<>();
|
|
|
for (Product p : products) {
|
|
|
if (ProductSortMap.containsKey(p.getMaxSortId())) {
|
|
|
if (ProductSortMap.containsKey(p.getMiddleSortId())) {
|
|
|
if (ProductSortMap.containsKey(p.getSmallSortId())) {
|
|
|
if (brandMap.containsKey(p.getBrandId())) {
|
|
|
productsNew.add(p);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
return productsNew;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 拼装ProductI数据 <br>
|
|
|
*
|
|
|
* @param products
|
|
|
* @param ProductSortMap
|
|
|
* @param brandMap
|
|
|
* @return <br>
|
|
|
* @author wangnan<br>
|
|
|
*/
|
|
|
public List<ProductIBO> buildProductIBO(List<Product> products, Map<Integer, ProductSort> ProductSortMap, Map<Integer, Brand> brandMap) {
|
|
|
|
|
|
logger.info("拼装ProductI数据开始");
|
|
|
List<ProductIBO> pdis = new ArrayList<>();
|
|
|
|
|
|
/**
|
|
|
* 拼装ProductI数据
|
|
|
*/
|
|
|
public List<ProductIBO> buildProductIBO(List<Product> products, Map<Integer, ProductSort> productSortMap, Map<Integer, Brand> brandMap) {
|
|
|
if (CollectionUtils.isEmpty(products)) {
|
|
|
return new ArrayList<>();
|
|
|
}
|
|
|
List<ProductIBO> productIBOs = new ArrayList<>();
|
|
|
for (Product p : products) {
|
|
|
ProductIBO productIBO = new ProductIBO();
|
|
|
try {
|
|
|
productIBO.setId(p.getId());
|
|
|
productIBO.setProductId(p.getId());
|
|
|
productIBO.setProductSkn(p.getErpProductId());
|
|
|
productIBO.setBrandId(p.getBrandId());
|
|
|
productIBO.setMaxSortId(p.getMaxSortId());
|
|
|
productIBO.setMiddleSortId(p.getMiddleSortId());
|
|
|
productIBO.setSmallSortId(p.getSmallSortId());
|
|
|
productIBO.setShopId(p.getShopId());
|
|
|
productIBO.setProductName(p.getProductName());
|
|
|
productIBO.setCnAlphabet(p.getCnAlphabet());
|
|
|
productIBO.setSalesPhrase(p.getSalesPhrase());
|
|
|
productIBO.setMarketPhrase(p.getMarketPhrase());
|
|
|
productIBO.setBrandId(p.getBrandId());
|
|
|
productIBO.setMaxSortId(p.getMaxSortId());
|
|
|
productIBO.setMiddleSortId(p.getMiddleSortId());
|
|
|
productIBO.setSmallSortId(p.getSmallSortId());
|
|
|
productIBO.setSeriesId(p.getSeriesId());
|
|
|
productIBO.setStyle(p.getStyle());
|
|
|
productIBO.setIsDepositAdvance(p.getIsDepositAdvance());
|
|
|
productIBO.setIsLimitbuy(p.getIsLimitbuy());
|
|
|
productIBO.setIspromotion(p.getIsPromotion());
|
|
|
productIBO.setAttribute(p.getAttribute());
|
|
|
productIBO.setFolderId(p.getFolderId());
|
|
|
productIBO.setSellChannels(p.getSellChannels());
|
|
|
productIBO.setAgeLevel(p.getAgeLevel());
|
|
|
productIBO.setAppType(p.getAppType());
|
|
|
productIBO.setIsInstalment(p.getIsInstalment());
|
|
|
productIBO.setIsSeckill("N");
|
|
|
if ("Y".equals(p.getIsSeckill()) || "1".equals(p.getIsSeckill())) {
|
|
|
if("Y".equals(p.getIsSeckill()) || "1".equals(p.getIsSeckill()))
|
|
|
{
|
|
|
productIBO.setIsSeckill("Y");
|
|
|
}
|
|
|
productIBO.setGender(p.getGender());
|
|
|
productIBO.setGenderS("男,女");
|
|
|
if (p.getGender() != null) {
|
|
|
if (p.getGender().equals("1")) {
|
|
|
productIBO.setGenderS("男");
|
|
|
}
|
|
|
if (p.getGender().equals("2")) {
|
|
|
productIBO.setGenderS("女");
|
|
|
}
|
|
|
}
|
|
|
if (p.getIsLimited() != null) {
|
|
|
if (p.getIsLimited().equals("Y")) {
|
|
|
productIBO.setIslimited("Y");
|
|
|
}
|
|
|
if (p.getIsLimited().equals("N")) {
|
|
|
productIBO.setIslimited("N");
|
|
|
}
|
|
|
}
|
|
|
if (p.getIsHot() != null) {
|
|
|
productIBO.setIsHot(p.getIsHot());
|
|
|
productIBO.setIshot(2);
|
|
|
if (p.getIsHot().equals("Y")) {
|
|
|
productIBO.setIshot(1);
|
|
|
}
|
|
|
}
|
|
|
if (p.getIsSpecial() != null) {
|
|
|
productIBO.setIsSpecial(p.getIsSpecial());
|
|
|
productIBO.setIsspecial(2);
|
|
|
if (p.getIsSpecial().equals("Y")) {
|
|
|
productIBO.setIsspecial(1);
|
|
|
}
|
|
|
}
|
|
|
productIBO.setIsSales(p.getIsSales());
|
|
|
if (p.getIsSales() != null) {
|
|
|
productIBO.setIssales(2);
|
|
|
if (p.getIsSales().equals("Y")) {
|
|
|
productIBO.setIssales(1);
|
|
|
}
|
|
|
}
|
|
|
productIBO.setIsAdvance(p.getIsAdvance());
|
|
|
if (p.getIsAdvance() != null) {
|
|
|
productIBO.setIsadvance(2);
|
|
|
if (p.getIsAdvance().equals("Y")) {
|
|
|
productIBO.setIsadvance(1);
|
|
|
}
|
|
|
}
|
|
|
productIBO.setIsAuditing(p.getIsAuditing());
|
|
|
if (p.getIsAuditing() != null) {
|
|
|
productIBO.setIsauditing(2);
|
|
|
if (p.getIsAuditing().equals("Y")) {
|
|
|
productIBO.setIsauditing(1);
|
|
|
}
|
|
|
}
|
|
|
if (p.getIsRecommend() != null) {
|
|
|
productIBO.setIsrecommend(2);
|
|
|
if (p.getIsRecommend().equals("Y")) {
|
|
|
productIBO.setIsrecommend(1);
|
|
|
}
|
|
|
}
|
|
|
productIBO.setIsDown(p.getIsDown());
|
|
|
if (p.getIsDown() != null) {
|
|
|
productIBO.setIsdown(2);
|
|
|
if (p.getIsDown().equals("Y")) {
|
|
|
productIBO.setIsdown(1);
|
|
|
}
|
|
|
}
|
|
|
productIBO.setStatus(p.getStatus());
|
|
|
if (p.getIsOutlets() != null) {
|
|
|
productIBO.setIsOutlets(2);
|
|
|
if (p.getIsOutlets().equals("Y")) {
|
|
|
productIBO.setIsOutlets(1);
|
|
|
}
|
|
|
}
|
|
|
this.buildBrandInfo(brandMap, p, productIBO);
|
|
|
this.buildSortInfo(productSortMap, p, productIBO);
|
|
|
this.buildSeason(p, productIBO);
|
|
|
this.buildTimeInfo(p, productIBO);
|
|
|
} catch (Exception e) {
|
|
|
logger.error(e.getMessage(), e);
|
|
|
} finally {
|
|
|
productIBOs.add(productIBO);
|
|
|
}
|
|
|
}
|
|
|
return productIBOs;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 构建时间
|
|
|
*/
|
|
|
private void buildTimeInfo(Product product, ProductIBO productIBO) {
|
|
|
productIBO.setFirstShelveTime(product.getFirstShelveTime());
|
|
|
productIBO.setShelveTime(product.getShelveTime());
|
|
|
productIBO.setEditTime(product.getEditTime());
|
|
|
if (product.getShelveTime() == 0) {
|
|
|
productIBO.setShelveDay("0");
|
|
|
} else {
|
|
|
String shelveDay = DateUtil.TimeStamp2DateWithFormat(Long.valueOf(product.getShelveTime()), "yyyy-MM-dd");
|
|
|
productIBO.setShelveDay(shelveDay);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 构建季节
|
|
|
*/
|
|
|
private void buildSeason(Product product, ProductIBO productIBO) {
|
|
|
productIBO.setSeasons(product.getSeasons());
|
|
|
if (product.getSeasons() != null) {
|
|
|
productIBO.setSeasonsS(4);
|
|
|
if (product.getSeasons().equals("spring") || product.getSeasons().equals("autumn") || product.getSeasons().equals("spring,autumn")) {
|
|
|
productIBO.setSeasonsS(1);
|
|
|
}
|
|
|
if (product.getSeasons().equals("summer")) {
|
|
|
productIBO.setSeasonsS(2);
|
|
|
}
|
|
|
if (product.getSeasons().equals("winter")) {
|
|
|
productIBO.setSeasonsS(3);
|
|
|
}
|
|
|
if (product.getSeasons().equals("spring,summer,autumn,winter") || product.getSeasons().equals("seasons")) {
|
|
|
productIBO.setSeasonsS(4);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 构建品牌名称
|
|
|
*/
|
|
|
private void buildBrandInfo(Map<Integer, Brand> brandMap, Product product, ProductIBO productIBO) {
|
|
|
Brand brand = brandMap.get(product.getBrandId());
|
|
|
if (brand != null) {
|
|
|
productIBO.setBrandNameCn(brand.getBrandNameCn());
|
|
|
productIBO.setBrandNameEn(brand.getBrandNameEn());
|
|
|
productIBO.setBrandKeyword(brand.getBrandKeyword());
|
|
|
productIBO.setHotKeyword(brand.getHotKeyword());
|
|
|
productIBO.setBrandName(brand.getBrandName());
|
|
|
productIBO.setBrandDomain(brand.getBrandDomain());
|
|
|
productIBO.setBrandAlif(brand.getBrandAlif());
|
|
|
productIBO.setCountryId(brand.getCountryId());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 构建品类名称
|
|
|
*/
|
|
|
private void buildSortInfo(Map<Integer, ProductSort> ProductSortMap, Product product, ProductIBO productIBO) {
|
|
|
if (ProductSortMap == null || product == null || productIBO == null) {
|
|
|
return;
|
|
|
}
|
|
|
ProductSort productSortMax = ProductSortMap.get(product.getMaxSortId());
|
|
|
if (productSortMax != null) {
|
|
|
productIBO.setMaxSort(productSortMax.getSortName());
|
|
|
productIBO.setMaxSortName(product.getMaxSortId() + ":" + productSortMax.getSortName() + ":" + productSortMax.getOrderBy());
|
|
|
if (productSortMax.getStatus() == 0) {
|
|
|
productIBO.setMaxSortName("");
|
|
|
}
|
|
|
}
|
|
|
ProductSort productSortMiddle = ProductSortMap.get(product.getMiddleSortId());
|
|
|
if (productSortMiddle != null) {
|
|
|
productIBO.setMiddleSort(productSortMiddle.getSortName());
|
|
|
productIBO.setMiddleSortName(product.getMiddleSortId() + ":" + productSortMiddle.getSortName() + ":" + productSortMiddle.getOrderBy());
|
|
|
if (productSortMiddle.getStatus() == 0) {
|
|
|
productIBO.setMiddleSortName("");
|
|
|
}
|
|
|
}
|
|
|
ProductSort productSortSmall = ProductSortMap.get(product.getSmallSortId());
|
|
|
if (productSortSmall != null) {
|
|
|
productIBO.setSmallSort(productSortSmall.getSortName());
|
|
|
productIBO.setSmallSortName(product.getSmallSortId() + ":" + productSortSmall.getSortName() + ":" + productSortSmall.getOrderBy());
|
|
|
if (productSortSmall.getStatus() == 0) {
|
|
|
productIBO.setSmallSortName("");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 过滤product列表
|
|
|
*/
|
|
|
public List<Product> filterProductList(List<Product> products, Map<Integer, ProductSort> ProductSortMap, Map<Integer, Brand> brandMap) {
|
|
|
List<Product> productsNew = new ArrayList<>();
|
|
|
for (Product p : products) {
|
|
|
if (ProductSortMap.containsKey(p.getMaxSortId())) {
|
|
|
if (ProductSortMap.containsKey(p.getMiddleSortId())) {
|
|
|
if (ProductSortMap.containsKey(p.getSmallSortId())) {
|
|
|
if (brandMap.containsKey(p.getBrandId())) {
|
|
|
productsNew.add(p);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return productsNew;
|
|
|
}
|
|
|
|
|
|
productIBO.setStyle(p.getStyle());
|
|
|
|
|
|
// set gender
|
|
|
productIBO.setGender(p.getGender());
|
|
|
productIBO.setGenderS("男,女");
|
|
|
if (p.getGender() != null) {
|
|
|
if (p.getGender().equals("1")) {
|
|
|
productIBO.setGenderS("男");
|
|
|
}
|
|
|
if (p.getGender().equals("2")) {
|
|
|
productIBO.setGenderS("女");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// set isLimit
|
|
|
if ("Y".equals(p.getIsLimited())) {
|
|
|
productIBO.setIslimited("Y");
|
|
|
} else {
|
|
|
productIBO.setIslimited("N");
|
|
|
}
|
|
|
|
|
|
// set IsHot
|
|
|
if ("Y".equals(p.getIsHot())) {
|
|
|
productIBO.setIsHot("Y");
|
|
|
productIBO.setIshot(1);
|
|
|
} else {
|
|
|
productIBO.setIsHot("N");
|
|
|
productIBO.setIshot(2);
|
|
|
}
|
|
|
|
|
|
// set IsSpecial
|
|
|
if ("Y".equals(p.getIsSpecial())) {
|
|
|
productIBO.setIsSpecial("Y");
|
|
|
productIBO.setIsspecial(1);
|
|
|
} else {
|
|
|
productIBO.setIsSpecial("N");
|
|
|
productIBO.setIsspecial(2);
|
|
|
}
|
|
|
|
|
|
// set IsSales[default is Y]
|
|
|
if ("N".equals(p.getIsSales())) {
|
|
|
productIBO.setIsSales("N");
|
|
|
productIBO.setIssales(2);
|
|
|
} else {
|
|
|
productIBO.setIsSales("Y");
|
|
|
productIBO.setIssales(1);
|
|
|
}
|
|
|
|
|
|
// set IsAdvance
|
|
|
if ("Y".equals(p.getIsAdvance())) {
|
|
|
productIBO.setIsAdvance("Y");
|
|
|
productIBO.setIsadvance(1);
|
|
|
} else {
|
|
|
productIBO.setIsAdvance("N");
|
|
|
productIBO.setIsadvance(2);
|
|
|
}
|
|
|
|
|
|
// set IsAuditing[default is Y]
|
|
|
if ("N".equals(p.getIsAuditing())) {
|
|
|
productIBO.setIsAuditing("N");
|
|
|
productIBO.setIsauditing(2);
|
|
|
} else {
|
|
|
productIBO.setIsAuditing("Y");
|
|
|
productIBO.setIsauditing(1);
|
|
|
}
|
|
|
|
|
|
// set isrecommend
|
|
|
if ("Y".equals(p.getIsRecommend())) {
|
|
|
productIBO.setIsrecommend(1);
|
|
|
} else {
|
|
|
productIBO.setIsrecommend(2);
|
|
|
}
|
|
|
|
|
|
// set isdown
|
|
|
if ("Y".equals(p.getIsDown())) {
|
|
|
productIBO.setIsdown(1);
|
|
|
productIBO.setIsDown("Y");
|
|
|
} else {
|
|
|
productIBO.setIsdown(2);
|
|
|
productIBO.setIsDown("N");
|
|
|
}
|
|
|
|
|
|
// set IsOutlets
|
|
|
if ("Y".equals(p.getIsOutlets())) {
|
|
|
productIBO.setIsOutlets(1);
|
|
|
} else {
|
|
|
productIBO.setIsOutlets(2);
|
|
|
}
|
|
|
|
|
|
// set IsLimitbuy
|
|
|
if ("Y".equals(p.getIsLimitbuy())) {
|
|
|
productIBO.setIsLimitbuy("Y");
|
|
|
} else {
|
|
|
productIBO.setIsLimitbuy("N");
|
|
|
}
|
|
|
|
|
|
// 是否分期全量要增加
|
|
|
if ("1".equals(p.getIsInstalment())) {
|
|
|
productIBO.setIsInstalment("1");
|
|
|
} else {
|
|
|
productIBO.setIsInstalment("0");
|
|
|
}
|
|
|
|
|
|
// set IsSeckill
|
|
|
if ("Y".equals(p.getIsSeckill()) || "1".equals(p.getIsSeckill())) {
|
|
|
productIBO.setIsSeckill("Y");
|
|
|
} else {
|
|
|
productIBO.setIsSeckill("N");
|
|
|
}
|
|
|
|
|
|
// set IsDepositAdvance
|
|
|
if ("Y".equals(p.getIsDepositAdvance())) {
|
|
|
productIBO.setIsDepositAdvance("Y");
|
|
|
} else {
|
|
|
productIBO.setIsDepositAdvance("N");
|
|
|
}
|
|
|
|
|
|
productIBO.setIspromotion(p.getIsPromotion());
|
|
|
productIBO.setAttribute(p.getAttribute());
|
|
|
productIBO.setSeasons(p.getSeasons());
|
|
|
|
|
|
if (p.getSeasons() != null) {
|
|
|
productIBO.setSeasonsS(4);
|
|
|
if (p.getSeasons().equals("spring") || p.getSeasons().equals("autumn") || p.getSeasons().equals("spring,autumn")) {
|
|
|
productIBO.setSeasonsS(1);
|
|
|
}
|
|
|
if (p.getSeasons().equals("summer")) {
|
|
|
productIBO.setSeasonsS(2);
|
|
|
}
|
|
|
if (p.getSeasons().equals("winter")) {
|
|
|
productIBO.setSeasonsS(3);
|
|
|
}
|
|
|
if (p.getSeasons().equals("spring,summer,autumn,winter") || p.getSeasons().equals("seasons")) {
|
|
|
productIBO.setSeasonsS(4);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
productIBO.setFirstShelveTime(p.getFirstShelveTime());
|
|
|
productIBO.setShelveTime(p.getShelveTime());
|
|
|
|
|
|
if (p.getShelveTime() == 0) {
|
|
|
productIBO.setShelveDay("0");
|
|
|
} else {
|
|
|
String shelveDay = DateUtil.TimeStamp2DateWithFormat(Long.valueOf(p.getShelveTime()), "yyyy-MM-dd");
|
|
|
productIBO.setShelveDay(shelveDay);
|
|
|
}
|
|
|
|
|
|
productIBO.setEditTime(p.getEditTime());
|
|
|
productIBO.setStatus(p.getStatus());
|
|
|
productIBO.setFolderId(p.getFolderId());
|
|
|
productIBO.setSellChannels(p.getSellChannels());
|
|
|
productIBO.setAgeLevel(p.getAgeLevel());
|
|
|
productIBO.setAppType(p.getAppType());
|
|
|
|
|
|
Brand brand = brandMap.get(p.getBrandId());
|
|
|
if (brand != null) {
|
|
|
productIBO.setBrandNameCn(brand.getBrandNameCn());
|
|
|
productIBO.setBrandNameEn(brand.getBrandNameEn());
|
|
|
productIBO.setBrandKeyword(brand.getBrandKeyword());
|
|
|
productIBO.setHotKeyword(brand.getHotKeyword());
|
|
|
productIBO.setBrandName(brand.getBrandName());
|
|
|
productIBO.setBrandDomain(brand.getBrandDomain());
|
|
|
productIBO.setBrandAlif(brand.getBrandAlif());
|
|
|
// 产地 全量要增加
|
|
|
productIBO.setCountryId(brand.getCountryId());
|
|
|
}
|
|
|
|
|
|
ProductSort productSortMax = ProductSortMap.get(p.getMaxSortId());
|
|
|
if (productSortMax != null) {
|
|
|
productIBO.setMaxSort(productSortMax.getSortName());
|
|
|
if (productSortMax.getStatus() == 0) {
|
|
|
productIBO.setMaxSortName("");
|
|
|
} else {
|
|
|
productIBO.setMaxSortName(p.getMaxSortId() + ":" + productSortMax.getSortName() + ":" + productSortMax.getOrderBy());
|
|
|
}
|
|
|
}
|
|
|
ProductSort productSortMiddle = ProductSortMap.get(p.getMiddleSortId());
|
|
|
if (productSortMiddle != null) {
|
|
|
productIBO.setMiddleSort(productSortMiddle.getSortName());
|
|
|
if (productSortMiddle.getStatus() == 0) {
|
|
|
productIBO.setMiddleSortName("");
|
|
|
} else {
|
|
|
productIBO.setMiddleSortName(p.getMiddleSortId() + ":" + productSortMiddle.getSortName() + ":" + productSortMiddle.getOrderBy());
|
|
|
}
|
|
|
}
|
|
|
ProductSort productSortSmall = ProductSortMap.get(p.getSmallSortId());
|
|
|
if (productSortSmall != null) {
|
|
|
productIBO.setSmallSort(productSortSmall.getSortName());
|
|
|
if (productSortSmall.getStatus() == 0) {
|
|
|
productIBO.setSmallSortName("");
|
|
|
} else {
|
|
|
productIBO.setSmallSortName(p.getSmallSortId() + ":" + productSortSmall.getSortName() + ":" + productSortSmall.getOrderBy());
|
|
|
}
|
|
|
}
|
|
|
pdis.add(productIBO);
|
|
|
} catch (Exception e) {
|
|
|
logger.error(e.getMessage(), e);
|
|
|
}
|
|
|
}
|
|
|
return pdis;
|
|
|
}
|
|
|
|
|
|
} |
...
|
...
|
|