Authored by wangnan

merge

@@ -5,10 +5,10 @@ import com.yoho.search.consumer.service.bo.ProductIBO; @@ -5,10 +5,10 @@ import com.yoho.search.consumer.service.bo.ProductIBO;
5 import com.yoho.search.dal.model.Brand; 5 import com.yoho.search.dal.model.Brand;
6 import com.yoho.search.dal.model.Product; 6 import com.yoho.search.dal.model.Product;
7 import com.yoho.search.dal.model.ProductSort; 7 import com.yoho.search.dal.model.ProductSort;
8 -import org.apache.commons.collections.CollectionUtils;  
9 import org.slf4j.Logger; 8 import org.slf4j.Logger;
10 import org.slf4j.LoggerFactory; 9 import org.slf4j.LoggerFactory;
11 import org.springframework.stereotype.Component; 10 import org.springframework.stereotype.Component;
  11 +import retrofit.http.HEAD;
12 12
13 import java.util.ArrayList; 13 import java.util.ArrayList;
14 import java.util.List; 14 import java.util.List;
@@ -20,239 +20,270 @@ import java.util.Map; @@ -20,239 +20,270 @@ import java.util.Map;
20 @Component 20 @Component
21 public class ProductILogicService { 21 public class ProductILogicService {
22 22
23 - private final Logger logger = LoggerFactory.getLogger(ProductILogicService.class); 23 + private final Logger logger = LoggerFactory.getLogger(ProductILogicService.class);
  24 +
  25 + /**
  26 + * 过滤product列表<br>
  27 + *
  28 + * @param products
  29 + * @param ProductSortMap
  30 + * @param brandMap
  31 + * @return <br>
  32 + * @author wangnan<br>
  33 + */
  34 + public List<Product> filterProductList(List<Product> products, Map<Integer, ProductSort> ProductSortMap, Map<Integer, Brand> brandMap) {
  35 + List<Product> productsNew = new ArrayList<>();
  36 + for (Product p : products) {
  37 + if (ProductSortMap.containsKey(p.getMaxSortId())) {
  38 + if (ProductSortMap.containsKey(p.getMiddleSortId())) {
  39 + if (ProductSortMap.containsKey(p.getSmallSortId())) {
  40 + if (brandMap.containsKey(p.getBrandId())) {
  41 + productsNew.add(p);
  42 + }
  43 + }
  44 + }
  45 +
  46 + }
  47 + }
  48 + return productsNew;
  49 + }
  50 +
  51 + /**
  52 + * 拼装ProductI数据 <br>
  53 + *
  54 + * @param products
  55 + * @param ProductSortMap
  56 + * @param brandMap
  57 + * @return <br>
  58 + * @author wangnan<br>
  59 + */
  60 + public List<ProductIBO> buildProductIBO(List<Product> products, Map<Integer, ProductSort> ProductSortMap, Map<Integer, Brand> brandMap) {
  61 +
  62 + logger.info("拼装ProductI数据开始");
  63 + List<ProductIBO> pdis = new ArrayList<>();
24 64
25 - /**  
26 - * 拼装ProductI数据  
27 - */  
28 - public List<ProductIBO> buildProductIBO(List<Product> products, Map<Integer, ProductSort> productSortMap, Map<Integer, Brand> brandMap) {  
29 - if (CollectionUtils.isEmpty(products)) {  
30 - return new ArrayList<>();  
31 - }  
32 - List<ProductIBO> productIBOs = new ArrayList<>();  
33 for (Product p : products) { 65 for (Product p : products) {
34 ProductIBO productIBO = new ProductIBO(); 66 ProductIBO productIBO = new ProductIBO();
35 try { 67 try {
36 productIBO.setId(p.getId()); 68 productIBO.setId(p.getId());
37 productIBO.setProductId(p.getId()); 69 productIBO.setProductId(p.getId());
38 productIBO.setProductSkn(p.getErpProductId()); 70 productIBO.setProductSkn(p.getErpProductId());
39 - productIBO.setBrandId(p.getBrandId());  
40 - productIBO.setMaxSortId(p.getMaxSortId());  
41 - productIBO.setMiddleSortId(p.getMiddleSortId());  
42 - productIBO.setSmallSortId(p.getSmallSortId());  
43 productIBO.setShopId(p.getShopId()); 71 productIBO.setShopId(p.getShopId());
44 productIBO.setProductName(p.getProductName()); 72 productIBO.setProductName(p.getProductName());
45 productIBO.setCnAlphabet(p.getCnAlphabet()); 73 productIBO.setCnAlphabet(p.getCnAlphabet());
46 productIBO.setSalesPhrase(p.getSalesPhrase()); 74 productIBO.setSalesPhrase(p.getSalesPhrase());
  75 + productIBO.setMarketPhrase(p.getMarketPhrase());
  76 + productIBO.setBrandId(p.getBrandId());
  77 + productIBO.setMaxSortId(p.getMaxSortId());
  78 + productIBO.setMiddleSortId(p.getMiddleSortId());
  79 + productIBO.setSmallSortId(p.getSmallSortId());
47 productIBO.setSeriesId(p.getSeriesId()); 80 productIBO.setSeriesId(p.getSeriesId());
48 - productIBO.setStyle(p.getStyle());  
49 - productIBO.setIsDepositAdvance(p.getIsDepositAdvance());  
50 - productIBO.setIsLimitbuy(p.getIsLimitbuy());  
51 - productIBO.setIspromotion(p.getIsPromotion());  
52 - productIBO.setAttribute(p.getAttribute());  
53 - productIBO.setFolderId(p.getFolderId());  
54 - productIBO.setSellChannels(p.getSellChannels());  
55 - productIBO.setAgeLevel(p.getAgeLevel());  
56 - productIBO.setAppType(p.getAppType());  
57 - productIBO.setIsInstalment(p.getIsInstalment());  
58 productIBO.setIsSeckill("N"); 81 productIBO.setIsSeckill("N");
59 - if ("Y".equals(p.getIsSeckill()) || "1".equals(p.getIsSeckill())) { 82 + if("Y".equals(p.getIsSeckill()) || "1".equals(p.getIsSeckill()))
  83 + {
60 productIBO.setIsSeckill("Y"); 84 productIBO.setIsSeckill("Y");
61 } 85 }
62 - productIBO.setGender(p.getGender());  
63 - productIBO.setGenderS("男,女");  
64 - if (p.getGender() != null) {  
65 - if (p.getGender().equals("1")) {  
66 - productIBO.setGenderS("男");  
67 - }  
68 - if (p.getGender().equals("2")) {  
69 - productIBO.setGenderS("女");  
70 - }  
71 - }  
72 - if (p.getIsLimited() != null) {  
73 - if (p.getIsLimited().equals("Y")) {  
74 - productIBO.setIslimited("Y");  
75 - }  
76 - if (p.getIsLimited().equals("N")) {  
77 - productIBO.setIslimited("N");  
78 - }  
79 - }  
80 - if (p.getIsHot() != null) {  
81 - productIBO.setIsHot(p.getIsHot());  
82 - productIBO.setIshot(2);  
83 - if (p.getIsHot().equals("Y")) {  
84 - productIBO.setIshot(1);  
85 - }  
86 - }  
87 - if (p.getIsSpecial() != null) {  
88 - productIBO.setIsSpecial(p.getIsSpecial());  
89 - productIBO.setIsspecial(2);  
90 - if (p.getIsSpecial().equals("Y")) {  
91 - productIBO.setIsspecial(1);  
92 - }  
93 - }  
94 - productIBO.setIsSales(p.getIsSales());  
95 - if (p.getIsSales() != null) {  
96 - productIBO.setIssales(2);  
97 - if (p.getIsSales().equals("Y")) {  
98 - productIBO.setIssales(1);  
99 - }  
100 - }  
101 - productIBO.setIsAdvance(p.getIsAdvance());  
102 - if (p.getIsAdvance() != null) {  
103 - productIBO.setIsadvance(2);  
104 - if (p.getIsAdvance().equals("Y")) {  
105 - productIBO.setIsadvance(1);  
106 - }  
107 - }  
108 - productIBO.setIsAuditing(p.getIsAuditing());  
109 - if (p.getIsAuditing() != null) {  
110 - productIBO.setIsauditing(2);  
111 - if (p.getIsAuditing().equals("Y")) {  
112 - productIBO.setIsauditing(1);  
113 - }  
114 - }  
115 - if (p.getIsRecommend() != null) {  
116 - productIBO.setIsrecommend(2);  
117 - if (p.getIsRecommend().equals("Y")) {  
118 - productIBO.setIsrecommend(1);  
119 - }  
120 - }  
121 - productIBO.setIsDown(p.getIsDown());  
122 - if (p.getIsDown() != null) {  
123 - productIBO.setIsdown(2);  
124 - if (p.getIsDown().equals("Y")) {  
125 - productIBO.setIsdown(1);  
126 - }  
127 - }  
128 - productIBO.setStatus(p.getStatus());  
129 - if (p.getIsOutlets() != null) {  
130 - productIBO.setIsOutlets(2);  
131 - if (p.getIsOutlets().equals("Y")) {  
132 - productIBO.setIsOutlets(1);  
133 - }  
134 - }  
135 - this.buildBrandInfo(brandMap, p, productIBO);  
136 - this.buildSortInfo(productSortMap, p, productIBO);  
137 - this.buildSeason(p, productIBO);  
138 - this.buildTimeInfo(p, productIBO);  
139 - } catch (Exception e) {  
140 - logger.error(e.getMessage(), e);  
141 - } finally {  
142 - productIBOs.add(productIBO);  
143 - }  
144 - }  
145 - return productIBOs;  
146 - }  
147 -  
148 -  
149 - /**  
150 - * 构建时间  
151 - */  
152 - private void buildTimeInfo(Product product, ProductIBO productIBO) {  
153 - productIBO.setFirstShelveTime(product.getFirstShelveTime());  
154 - productIBO.setShelveTime(product.getShelveTime());  
155 - productIBO.setEditTime(product.getEditTime());  
156 - if (product.getShelveTime() == 0) {  
157 - productIBO.setShelveDay("0");  
158 - } else {  
159 - String shelveDay = DateUtil.TimeStamp2DateWithFormat(Long.valueOf(product.getShelveTime()), "yyyy-MM-dd");  
160 - productIBO.setShelveDay(shelveDay);  
161 - }  
162 - }  
163 -  
164 -  
165 - /**  
166 - * 构建季节  
167 - */  
168 - private void buildSeason(Product product, ProductIBO productIBO) {  
169 - productIBO.setSeasons(product.getSeasons());  
170 - if (product.getSeasons() != null) {  
171 - productIBO.setSeasonsS(4);  
172 - if (product.getSeasons().equals("spring") || product.getSeasons().equals("autumn") || product.getSeasons().equals("spring,autumn")) {  
173 - productIBO.setSeasonsS(1);  
174 - }  
175 - if (product.getSeasons().equals("summer")) {  
176 - productIBO.setSeasonsS(2);  
177 - }  
178 - if (product.getSeasons().equals("winter")) {  
179 - productIBO.setSeasonsS(3);  
180 - }  
181 - if (product.getSeasons().equals("spring,summer,autumn,winter") || product.getSeasons().equals("seasons")) {  
182 - productIBO.setSeasonsS(4);  
183 - }  
184 - }  
185 -  
186 - }  
187 -  
188 - /**  
189 - * 构建品牌名称  
190 - */  
191 - private void buildBrandInfo(Map<Integer, Brand> brandMap, Product product, ProductIBO productIBO) {  
192 - Brand brand = brandMap.get(product.getBrandId());  
193 - if (brand != null) {  
194 - productIBO.setBrandNameCn(brand.getBrandNameCn());  
195 - productIBO.setBrandNameEn(brand.getBrandNameEn());  
196 - productIBO.setBrandKeyword(brand.getBrandKeyword());  
197 - productIBO.setHotKeyword(brand.getHotKeyword());  
198 - productIBO.setBrandName(brand.getBrandName());  
199 - productIBO.setBrandDomain(brand.getBrandDomain());  
200 - productIBO.setBrandAlif(brand.getBrandAlif());  
201 - productIBO.setCountryId(brand.getCountryId());  
202 - }  
203 - }  
204 -  
205 -  
206 - /**  
207 - * 构建品类名称  
208 - */  
209 - private void buildSortInfo(Map<Integer, ProductSort> ProductSortMap, Product product, ProductIBO productIBO) {  
210 - if (ProductSortMap == null || product == null || productIBO == null) {  
211 - return;  
212 - }  
213 - ProductSort productSortMax = ProductSortMap.get(product.getMaxSortId());  
214 - if (productSortMax != null) {  
215 - productIBO.setMaxSort(productSortMax.getSortName());  
216 - productIBO.setMaxSortName(product.getMaxSortId() + ":" + productSortMax.getSortName() + ":" + productSortMax.getOrderBy());  
217 - if (productSortMax.getStatus() == 0) {  
218 - productIBO.setMaxSortName("");  
219 - }  
220 - }  
221 - ProductSort productSortMiddle = ProductSortMap.get(product.getMiddleSortId());  
222 - if (productSortMiddle != null) {  
223 - productIBO.setMiddleSort(productSortMiddle.getSortName());  
224 - productIBO.setMiddleSortName(product.getMiddleSortId() + ":" + productSortMiddle.getSortName() + ":" + productSortMiddle.getOrderBy());  
225 - if (productSortMiddle.getStatus() == 0) {  
226 - productIBO.setMiddleSortName("");  
227 - }  
228 - }  
229 - ProductSort productSortSmall = ProductSortMap.get(product.getSmallSortId());  
230 - if (productSortSmall != null) {  
231 - productIBO.setSmallSort(productSortSmall.getSortName());  
232 - productIBO.setSmallSortName(product.getSmallSortId() + ":" + productSortSmall.getSortName() + ":" + productSortSmall.getOrderBy());  
233 - if (productSortSmall.getStatus() == 0) {  
234 - productIBO.setSmallSortName("");  
235 - }  
236 - }  
237 - }  
238 -  
239 -  
240 - /**  
241 - * 过滤product列表  
242 - */  
243 - public List<Product> filterProductList(List<Product> products, Map<Integer, ProductSort> ProductSortMap, Map<Integer, Brand> brandMap) {  
244 - List<Product> productsNew = new ArrayList<>();  
245 - for (Product p : products) {  
246 - if (ProductSortMap.containsKey(p.getMaxSortId())) {  
247 - if (ProductSortMap.containsKey(p.getMiddleSortId())) {  
248 - if (ProductSortMap.containsKey(p.getSmallSortId())) {  
249 - if (brandMap.containsKey(p.getBrandId())) {  
250 - productsNew.add(p);  
251 - }  
252 - }  
253 - }  
254 - }  
255 - }  
256 - return productsNew;  
257 - } 86 +
  87 + productIBO.setStyle(p.getStyle());
  88 +
  89 + // set gender
  90 + productIBO.setGender(p.getGender());
  91 + productIBO.setGenderS("男,女");
  92 + if (p.getGender() != null) {
  93 + if (p.getGender().equals("1")) {
  94 + productIBO.setGenderS("男");
  95 + }
  96 + if (p.getGender().equals("2")) {
  97 + productIBO.setGenderS("女");
  98 + }
  99 + }
  100 +
  101 + // set isLimit
  102 + if ("Y".equals(p.getIsLimited())) {
  103 + productIBO.setIslimited("Y");
  104 + } else {
  105 + productIBO.setIslimited("N");
  106 + }
  107 +
  108 + // set IsHot
  109 + if ("Y".equals(p.getIsHot())) {
  110 + productIBO.setIsHot("Y");
  111 + productIBO.setIshot(1);
  112 + } else {
  113 + productIBO.setIsHot("N");
  114 + productIBO.setIshot(2);
  115 + }
  116 +
  117 + // set IsSpecial
  118 + if ("Y".equals(p.getIsSpecial())) {
  119 + productIBO.setIsSpecial("Y");
  120 + productIBO.setIsspecial(1);
  121 + } else {
  122 + productIBO.setIsSpecial("N");
  123 + productIBO.setIsspecial(2);
  124 + }
  125 +
  126 + // set IsSales[default is Y]
  127 + if ("N".equals(p.getIsSales())) {
  128 + productIBO.setIsSales("N");
  129 + productIBO.setIssales(2);
  130 + } else {
  131 + productIBO.setIsSales("Y");
  132 + productIBO.setIssales(1);
  133 + }
  134 +
  135 + // set IsAdvance
  136 + if ("Y".equals(p.getIsAdvance())) {
  137 + productIBO.setIsAdvance("Y");
  138 + productIBO.setIsadvance(1);
  139 + } else {
  140 + productIBO.setIsAdvance("N");
  141 + productIBO.setIsadvance(2);
  142 + }
  143 +
  144 + // set IsAuditing[default is Y]
  145 + if ("N".equals(p.getIsAuditing())) {
  146 + productIBO.setIsAuditing("N");
  147 + productIBO.setIsauditing(2);
  148 + } else {
  149 + productIBO.setIsAuditing("Y");
  150 + productIBO.setIsauditing(1);
  151 + }
  152 +
  153 + // set isrecommend
  154 + if ("Y".equals(p.getIsRecommend())) {
  155 + productIBO.setIsrecommend(1);
  156 + } else {
  157 + productIBO.setIsrecommend(2);
  158 + }
  159 +
  160 + // set isdown
  161 + if ("Y".equals(p.getIsDown())) {
  162 + productIBO.setIsdown(1);
  163 + productIBO.setIsDown("Y");
  164 + } else {
  165 + productIBO.setIsdown(2);
  166 + productIBO.setIsDown("N");
  167 + }
  168 +
  169 + // set IsOutlets
  170 + if ("Y".equals(p.getIsOutlets())) {
  171 + productIBO.setIsOutlets(1);
  172 + } else {
  173 + productIBO.setIsOutlets(2);
  174 + }
  175 +
  176 + // set IsLimitbuy
  177 + if ("Y".equals(p.getIsLimitbuy())) {
  178 + productIBO.setIsLimitbuy("Y");
  179 + } else {
  180 + productIBO.setIsLimitbuy("N");
  181 + }
  182 +
  183 + // 是否分期全量要增加
  184 + if ("1".equals(p.getIsInstalment())) {
  185 + productIBO.setIsInstalment("1");
  186 + } else {
  187 + productIBO.setIsInstalment("0");
  188 + }
  189 +
  190 + // set IsSeckill
  191 + if ("Y".equals(p.getIsSeckill()) || "1".equals(p.getIsSeckill())) {
  192 + productIBO.setIsSeckill("Y");
  193 + } else {
  194 + productIBO.setIsSeckill("N");
  195 + }
  196 +
  197 + // set IsDepositAdvance
  198 + if ("Y".equals(p.getIsDepositAdvance())) {
  199 + productIBO.setIsDepositAdvance("Y");
  200 + } else {
  201 + productIBO.setIsDepositAdvance("N");
  202 + }
  203 +
  204 + productIBO.setIspromotion(p.getIsPromotion());
  205 + productIBO.setAttribute(p.getAttribute());
  206 + productIBO.setSeasons(p.getSeasons());
  207 +
  208 + if (p.getSeasons() != null) {
  209 + productIBO.setSeasonsS(4);
  210 + if (p.getSeasons().equals("spring") || p.getSeasons().equals("autumn") || p.getSeasons().equals("spring,autumn")) {
  211 + productIBO.setSeasonsS(1);
  212 + }
  213 + if (p.getSeasons().equals("summer")) {
  214 + productIBO.setSeasonsS(2);
  215 + }
  216 + if (p.getSeasons().equals("winter")) {
  217 + productIBO.setSeasonsS(3);
  218 + }
  219 + if (p.getSeasons().equals("spring,summer,autumn,winter") || p.getSeasons().equals("seasons")) {
  220 + productIBO.setSeasonsS(4);
  221 + }
  222 + }
  223 +
  224 + productIBO.setFirstShelveTime(p.getFirstShelveTime());
  225 + productIBO.setShelveTime(p.getShelveTime());
  226 +
  227 + if (p.getShelveTime() == 0) {
  228 + productIBO.setShelveDay("0");
  229 + } else {
  230 + String shelveDay = DateUtil.TimeStamp2DateWithFormat(Long.valueOf(p.getShelveTime()), "yyyy-MM-dd");
  231 + productIBO.setShelveDay(shelveDay);
  232 + }
  233 +
  234 + productIBO.setEditTime(p.getEditTime());
  235 + productIBO.setStatus(p.getStatus());
  236 + productIBO.setFolderId(p.getFolderId());
  237 + productIBO.setSellChannels(p.getSellChannels());
  238 + productIBO.setAgeLevel(p.getAgeLevel());
  239 + productIBO.setAppType(p.getAppType());
  240 +
  241 + Brand brand = brandMap.get(p.getBrandId());
  242 + if (brand != null) {
  243 + productIBO.setBrandNameCn(brand.getBrandNameCn());
  244 + productIBO.setBrandNameEn(brand.getBrandNameEn());
  245 + productIBO.setBrandKeyword(brand.getBrandKeyword());
  246 + productIBO.setHotKeyword(brand.getHotKeyword());
  247 + productIBO.setBrandName(brand.getBrandName());
  248 + productIBO.setBrandDomain(brand.getBrandDomain());
  249 + productIBO.setBrandAlif(brand.getBrandAlif());
  250 + // 产地 全量要增加
  251 + productIBO.setCountryId(brand.getCountryId());
  252 + }
  253 +
  254 + ProductSort productSortMax = ProductSortMap.get(p.getMaxSortId());
  255 + if (productSortMax != null) {
  256 + productIBO.setMaxSort(productSortMax.getSortName());
  257 + if (productSortMax.getStatus() == 0) {
  258 + productIBO.setMaxSortName("");
  259 + } else {
  260 + productIBO.setMaxSortName(p.getMaxSortId() + ":" + productSortMax.getSortName() + ":" + productSortMax.getOrderBy());
  261 + }
  262 + }
  263 + ProductSort productSortMiddle = ProductSortMap.get(p.getMiddleSortId());
  264 + if (productSortMiddle != null) {
  265 + productIBO.setMiddleSort(productSortMiddle.getSortName());
  266 + if (productSortMiddle.getStatus() == 0) {
  267 + productIBO.setMiddleSortName("");
  268 + } else {
  269 + productIBO.setMiddleSortName(p.getMiddleSortId() + ":" + productSortMiddle.getSortName() + ":" + productSortMiddle.getOrderBy());
  270 + }
  271 + }
  272 + ProductSort productSortSmall = ProductSortMap.get(p.getSmallSortId());
  273 + if (productSortSmall != null) {
  274 + productIBO.setSmallSort(productSortSmall.getSortName());
  275 + if (productSortSmall.getStatus() == 0) {
  276 + productIBO.setSmallSortName("");
  277 + } else {
  278 + productIBO.setSmallSortName(p.getSmallSortId() + ":" + productSortSmall.getSortName() + ":" + productSortSmall.getOrderBy());
  279 + }
  280 + }
  281 + pdis.add(productIBO);
  282 + } catch (Exception e) {
  283 + logger.error(e.getMessage(), e);
  284 + }
  285 + }
  286 + return pdis;
  287 + }
  288 +
258 } 289 }
@@ -84,8 +84,13 @@ public class SpecialDealLogicService { @@ -84,8 +84,13 @@ public class SpecialDealLogicService {
84 // 4、处理物理分类对应的销售分类 84 // 4、处理物理分类对应的销售分类
85 List<Integer> physicalChannels = salesCategoryLogicService.getPhysicalChannelsBySmallSortId(productIBO.getSmallSortId()); 85 List<Integer> physicalChannels = salesCategoryLogicService.getPhysicalChannelsBySmallSortId(productIBO.getSmallSortId());
86 productIBO.setPhysicalChannels(StringUtils.join(physicalChannels, ",")); 86 productIBO.setPhysicalChannels(StringUtils.join(physicalChannels, ","));
  87 +
  88 + // 5、处理限购,防止数据库未设置
  89 + if (StringUtils.isBlank(productIBO.getIsLimitbuy())) {
  90 + productIBO.setIsLimitbuy("N");
  91 + }
87 } 92 }
88 - 93 +
89 /** 94 /**
90 * 建索引时对Pi索引的字段做一些特殊处理 95 * 建索引时对Pi索引的字段做一些特殊处理
91 * 96 *
This diff could not be displayed because it is too large.