Authored by wangnan

merge

... ... @@ -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;
... ... @@ -23,42 +23,70 @@ public class ProductILogicService {
private final Logger logger = LoggerFactory.getLogger(ProductILogicService.class);
/**
* 拼装ProductI数据
* 过滤product列表<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) {
if (CollectionUtils.isEmpty(products)) {
return new ArrayList<>();
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);
}
}
List<ProductIBO> productIBOs = new ArrayList<>();
}
}
}
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<>();
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.setStyle(p.getStyle());
// set gender
productIBO.setGender(p.getGender());
productIBO.setGenderS("男,女");
if (p.getGender() != null) {
... ... @@ -69,127 +97,148 @@ public class ProductILogicService {
productIBO.setGenderS("女");
}
}
if (p.getIsLimited() != null) {
if (p.getIsLimited().equals("Y")) {
// set isLimit
if ("Y".equals(p.getIsLimited())) {
productIBO.setIslimited("Y");
}
if (p.getIsLimited().equals("N")) {
} else {
productIBO.setIslimited("N");
}
}
if (p.getIsHot() != null) {
productIBO.setIsHot(p.getIsHot());
productIBO.setIshot(2);
if (p.getIsHot().equals("Y")) {
// set IsHot
if ("Y".equals(p.getIsHot())) {
productIBO.setIsHot("Y");
productIBO.setIshot(1);
} else {
productIBO.setIsHot("N");
productIBO.setIshot(2);
}
}
if (p.getIsSpecial() != null) {
productIBO.setIsSpecial(p.getIsSpecial());
productIBO.setIsspecial(2);
if (p.getIsSpecial().equals("Y")) {
// set IsSpecial
if ("Y".equals(p.getIsSpecial())) {
productIBO.setIsSpecial("Y");
productIBO.setIsspecial(1);
} else {
productIBO.setIsSpecial("N");
productIBO.setIsspecial(2);
}
}
productIBO.setIsSales(p.getIsSales());
if (p.getIsSales() != null) {
// set IsSales[default is Y]
if ("N".equals(p.getIsSales())) {
productIBO.setIsSales("N");
productIBO.setIssales(2);
if (p.getIsSales().equals("Y")) {
} else {
productIBO.setIsSales("Y");
productIBO.setIssales(1);
}
}
productIBO.setIsAdvance(p.getIsAdvance());
if (p.getIsAdvance() != null) {
productIBO.setIsadvance(2);
if (p.getIsAdvance().equals("Y")) {
// set IsAdvance
if ("Y".equals(p.getIsAdvance())) {
productIBO.setIsAdvance("Y");
productIBO.setIsadvance(1);
} else {
productIBO.setIsAdvance("N");
productIBO.setIsadvance(2);
}
}
productIBO.setIsAuditing(p.getIsAuditing());
if (p.getIsAuditing() != null) {
// set IsAuditing[default is Y]
if ("N".equals(p.getIsAuditing())) {
productIBO.setIsAuditing("N");
productIBO.setIsauditing(2);
if (p.getIsAuditing().equals("Y")) {
} else {
productIBO.setIsAuditing("Y");
productIBO.setIsauditing(1);
}
}
if (p.getIsRecommend() != null) {
productIBO.setIsrecommend(2);
if (p.getIsRecommend().equals("Y")) {
// set isrecommend
if ("Y".equals(p.getIsRecommend())) {
productIBO.setIsrecommend(1);
} else {
productIBO.setIsrecommend(2);
}
}
productIBO.setIsDown(p.getIsDown());
if (p.getIsDown() != null) {
productIBO.setIsdown(2);
if (p.getIsDown().equals("Y")) {
// set isdown
if ("Y".equals(p.getIsDown())) {
productIBO.setIsdown(1);
productIBO.setIsDown("Y");
} else {
productIBO.setIsdown(2);
productIBO.setIsDown("N");
}
}
productIBO.setStatus(p.getStatus());
if (p.getIsOutlets() != null) {
productIBO.setIsOutlets(2);
if (p.getIsOutlets().equals("Y")) {
// set IsOutlets
if ("Y".equals(p.getIsOutlets())) {
productIBO.setIsOutlets(1);
} else {
productIBO.setIsOutlets(2);
}
}
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;
// 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");
}
/**
* 构建时间
*/
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");
// set IsSeckill
if ("Y".equals(p.getIsSeckill()) || "1".equals(p.getIsSeckill())) {
productIBO.setIsSeckill("Y");
} else {
String shelveDay = DateUtil.TimeStamp2DateWithFormat(Long.valueOf(product.getShelveTime()), "yyyy-MM-dd");
productIBO.setShelveDay(shelveDay);
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());
/**
* 构建季节
*/
private void buildSeason(Product product, ProductIBO productIBO) {
productIBO.setSeasons(product.getSeasons());
if (product.getSeasons() != null) {
if (p.getSeasons() != null) {
productIBO.setSeasonsS(4);
if (product.getSeasons().equals("spring") || product.getSeasons().equals("autumn") || product.getSeasons().equals("spring,autumn")) {
if (p.getSeasons().equals("spring") || p.getSeasons().equals("autumn") || p.getSeasons().equals("spring,autumn")) {
productIBO.setSeasonsS(1);
}
if (product.getSeasons().equals("summer")) {
if (p.getSeasons().equals("summer")) {
productIBO.setSeasonsS(2);
}
if (product.getSeasons().equals("winter")) {
if (p.getSeasons().equals("winter")) {
productIBO.setSeasonsS(3);
}
if (product.getSeasons().equals("spring,summer,autumn,winter") || product.getSeasons().equals("seasons")) {
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);
}
/**
* 构建品牌名称
*/
private void buildBrandInfo(Map<Integer, Brand> brandMap, Product product, ProductIBO productIBO) {
Brand brand = brandMap.get(product.getBrandId());
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());
... ... @@ -198,61 +247,43 @@ public class ProductILogicService {
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());
ProductSort productSortMax = ProductSortMap.get(p.getMaxSortId());
if (productSortMax != null) {
productIBO.setMaxSort(productSortMax.getSortName());
productIBO.setMaxSortName(product.getMaxSortId() + ":" + productSortMax.getSortName() + ":" + productSortMax.getOrderBy());
if (productSortMax.getStatus() == 0) {
productIBO.setMaxSortName("");
} else {
productIBO.setMaxSortName(p.getMaxSortId() + ":" + productSortMax.getSortName() + ":" + productSortMax.getOrderBy());
}
}
ProductSort productSortMiddle = ProductSortMap.get(product.getMiddleSortId());
ProductSort productSortMiddle = ProductSortMap.get(p.getMiddleSortId());
if (productSortMiddle != null) {
productIBO.setMiddleSort(productSortMiddle.getSortName());
productIBO.setMiddleSortName(product.getMiddleSortId() + ":" + productSortMiddle.getSortName() + ":" + productSortMiddle.getOrderBy());
if (productSortMiddle.getStatus() == 0) {
productIBO.setMiddleSortName("");
} else {
productIBO.setMiddleSortName(p.getMiddleSortId() + ":" + productSortMiddle.getSortName() + ":" + productSortMiddle.getOrderBy());
}
}
ProductSort productSortSmall = ProductSortMap.get(product.getSmallSortId());
ProductSort productSortSmall = ProductSortMap.get(p.getSmallSortId());
if (productSortSmall != null) {
productIBO.setSmallSort(productSortSmall.getSortName());
productIBO.setSmallSortName(product.getSmallSortId() + ":" + productSortSmall.getSortName() + ":" + productSortSmall.getOrderBy());
if (productSortSmall.getStatus() == 0) {
productIBO.setSmallSortName("");
} else {
productIBO.setSmallSortName(p.getSmallSortId() + ":" + productSortSmall.getSortName() + ":" + productSortSmall.getOrderBy());
}
}
}
/**
* 过滤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);
}
}
}
pdis.add(productIBO);
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
}
return productsNew;
return pdis;
}
}
... ...
... ... @@ -84,6 +84,11 @@ public class SpecialDealLogicService {
// 4、处理物理分类对应的销售分类
List<Integer> physicalChannels = salesCategoryLogicService.getPhysicalChannelsBySmallSortId(productIBO.getSmallSortId());
productIBO.setPhysicalChannels(StringUtils.join(physicalChannels, ","));
// 5、处理限购,防止数据库未设置
if (StringUtils.isBlank(productIBO.getIsLimitbuy())) {
productIBO.setIsLimitbuy("N");
}
}
/**
... ...
This diff could not be displayed because it is too large.