|
@@ -221,7 +221,7 @@ public class ProductIndexBaseService { |
|
@@ -221,7 +221,7 @@ public class ProductIndexBaseService { |
221
|
|
221
|
|
222
|
// 标签
|
222
|
// 标签
|
223
|
productMap.put("customize_tag", MapUtils.getObject(map, ProductIndexEsField.customizeTags, new JSONArray()));
|
223
|
productMap.put("customize_tag", MapUtils.getObject(map, ProductIndexEsField.customizeTags, new JSONArray()));
|
224
|
- //productMap.put("promotion_tag", this.getPomotionTags(map));// 促销标签
|
224
|
+ productMap.put("promotion_tag", this.getPromotionTag(map));// 促销标签
|
225
|
productMap.put("is_promotion_active", "N");// 当前是否有促销正在进行
|
225
|
productMap.put("is_promotion_active", "N");// 当前是否有促销正在进行
|
226
|
boolean promotionActive = getPromotionActive(map);
|
226
|
boolean promotionActive = getPromotionActive(map);
|
227
|
if (promotionActive) {
|
227
|
if (promotionActive) {
|
|
@@ -358,30 +358,58 @@ public class ProductIndexBaseService { |
|
@@ -358,30 +358,58 @@ public class ProductIndexBaseService { |
358
|
* 获取商品列表[并返回促销标签信息]
|
358
|
* 获取商品列表[并返回促销标签信息]
|
359
|
* add by wangnan in 2018/1/29
|
359
|
* add by wangnan in 2018/1/29
|
360
|
*/
|
360
|
*/
|
|
|
361
|
+ public List<JSONObject> getPromotionTag(Map<String, Object> map) {
|
|
|
362
|
+
|
|
|
363
|
+ //全量查promotion索引内容,用于和每个skn匹配,1分钟缓存
|
|
|
364
|
+ List<PromotionCond> promotionCondList = promotionCondService.getPromotionCondList();
|
|
|
365
|
+
|
|
|
366
|
+ //获取该skn匹配上的促销
|
|
|
367
|
+ List<PromotionCond> matchedPromotionCondList = promotionCondList.stream()
|
|
|
368
|
+ .filter(promotionCond -> promotionMatchService.matchProduct(promotionCond, map))
|
|
|
369
|
+ .collect(Collectors.toList());
|
|
|
370
|
+ //查询促销类型->促销名映射的索引获取map,用于填充促销标签名称,1分钟缓存
|
|
|
371
|
+ Map<String, String> promotionTypeMap = promotionTypeService.getPromotionTypeMap();
|
|
|
372
|
+ //生成促销标签对象列表
|
|
|
373
|
+ List<JSONObject> matchedPromotions = new ArrayList<>();
|
|
|
374
|
+ if (CollectionUtils.isNotEmpty(matchedPromotionCondList)) {
|
|
|
375
|
+ matchedPromotions = matchedPromotionCondList.stream()
|
|
|
376
|
+ .map(promotionCond -> {
|
|
|
377
|
+ JSONObject matchedPromotion = new JSONObject();
|
|
|
378
|
+ matchedPromotion.put("id", promotionCond.getPromotionId());
|
|
|
379
|
+ matchedPromotion.put("type", promotionCond.getPromotionType());
|
|
|
380
|
+ matchedPromotion.put("startTime", promotionCond.getStartTime());
|
|
|
381
|
+ matchedPromotion.put("endTime", promotionCond.getEndTime());
|
|
|
382
|
+ if (!promotionTypeMap.isEmpty() && promotionCond.getShowStatus() == 1) {
|
|
|
383
|
+ matchedPromotion.put("name", promotionTypeMap.get(promotionCond.getPromotionType()));
|
|
|
384
|
+ }else{
|
|
|
385
|
+ matchedPromotion.put("name", "undefined");
|
|
|
386
|
+ }
|
|
|
387
|
+ return matchedPromotion;
|
|
|
388
|
+ }).collect(Collectors.toList());
|
|
|
389
|
+ }
|
|
|
390
|
+ return matchedPromotions;
|
|
|
391
|
+ }
|
|
|
392
|
+
|
|
|
393
|
+ /**
|
|
|
394
|
+ * 获取skn促销标签-用于在待返回的列表返回之前加上促销标签这个节点
|
|
|
395
|
+ * add by wangnan in 2018/1/29
|
|
|
396
|
+ */
|
361
|
public List<Map<String, Object>> getProductListWithPromotion(List<Map<String, Object>> productEsSourceList) {
|
397
|
public List<Map<String, Object>> getProductListWithPromotion(List<Map<String, Object>> productEsSourceList) {
|
362
|
if (productEsSourceList == null || productEsSourceList.isEmpty()) {
|
398
|
if (productEsSourceList == null || productEsSourceList.isEmpty()) {
|
363
|
return new ArrayList<>();
|
399
|
return new ArrayList<>();
|
364
|
}
|
400
|
}
|
365
|
-
|
|
|
366
|
- //1.获取结果列表中的skn列表
|
|
|
367
|
- String[] sknStr = new String[productEsSourceList.size()];
|
|
|
368
|
- for (int i = 0; i < productEsSourceList.size(); i++) {
|
|
|
369
|
- sknStr[i] = MapUtils.getString(productEsSourceList.get(i), "product_skn", "");
|
|
|
370
|
- }
|
|
|
371
|
-
|
|
|
372
|
- //2.全量查promotion索引内容,用于和每个skn匹配,1分钟缓存
|
401
|
+ //1.全量查promotion索引内容,用于和每个skn匹配,1分钟缓存
|
373
|
List<PromotionCond> promotionCondList = promotionCondService.getPromotionCondList();
|
402
|
List<PromotionCond> promotionCondList = promotionCondService.getPromotionCondList();
|
374
|
-
|
|
|
375
|
- //3.构建每个skn匹配的促销
|
403
|
+ //2.构建每个skn匹配的促销
|
376
|
List<Map<String, Object>> results = new ArrayList<Map<String, Object>>();
|
404
|
List<Map<String, Object>> results = new ArrayList<Map<String, Object>>();
|
377
|
for (Map<String, Object> productEsSource : productEsSourceList) {
|
405
|
for (Map<String, Object> productEsSource : productEsSourceList) {
|
378
|
- //3.1 获取该skn匹配上的促销
|
406
|
+ //2.1 获取该skn匹配上的促销
|
379
|
List<PromotionCond> matchedPromotionCondList = promotionCondList.stream()
|
407
|
List<PromotionCond> matchedPromotionCondList = promotionCondList.stream()
|
380
|
.filter(promotionCond -> promotionMatchService.matchProduct(promotionCond, productEsSource))
|
408
|
.filter(promotionCond -> promotionMatchService.matchProduct(promotionCond, productEsSource))
|
381
|
.collect(Collectors.toList());
|
409
|
.collect(Collectors.toList());
|
382
|
- //3.2 查询促销类型->促销名映射的索引获取map,用于填充促销标签名称,1分钟缓存
|
410
|
+ //2.2 查询促销类型->促销名映射的索引获取map,用于填充促销标签名称,1分钟缓存
|
383
|
Map<String, String> promotionTypeMap = promotionTypeService.getPromotionTypeMap();
|
411
|
Map<String, String> promotionTypeMap = promotionTypeService.getPromotionTypeMap();
|
384
|
- //3.3 生成促销标签对象列表
|
412
|
+ //2.3 生成促销标签对象列表
|
385
|
if (CollectionUtils.isNotEmpty(matchedPromotionCondList)) {
|
413
|
if (CollectionUtils.isNotEmpty(matchedPromotionCondList)) {
|
386
|
List<JSONObject> matchedPromotions = matchedPromotionCondList.stream()
|
414
|
List<JSONObject> matchedPromotions = matchedPromotionCondList.stream()
|
387
|
.map(promotionCond -> {
|
415
|
.map(promotionCond -> {
|
|
@@ -397,7 +425,7 @@ public class ProductIndexBaseService { |
|
@@ -397,7 +425,7 @@ public class ProductIndexBaseService { |
397
|
}
|
425
|
}
|
398
|
return matchedPromotion;
|
426
|
return matchedPromotion;
|
399
|
}).collect(Collectors.toList());
|
427
|
}).collect(Collectors.toList());
|
400
|
- //3.4 列表中插入促销标签信息
|
428
|
+ //2.4 列表中插入促销标签信息
|
401
|
productEsSource.put("promotion_tag", matchedPromotions);
|
429
|
productEsSource.put("promotion_tag", matchedPromotions);
|
402
|
}
|
430
|
}
|
403
|
results.add(productEsSource);
|
431
|
results.add(productEsSource);
|