Authored by wangnan9279

ufo addscore

@@ -6,10 +6,7 @@ import com.yoho.search.consumer.service.logicService.ProductIndexBOToMapService; @@ -6,10 +6,7 @@ import com.yoho.search.consumer.service.logicService.ProductIndexBOToMapService;
6 import com.yoho.search.consumer.service.logicService.cache.BasicDataCacheService; 6 import com.yoho.search.consumer.service.logicService.cache.BasicDataCacheService;
7 import com.yoho.search.consumer.service.logicService.ufo.yoho.*; 7 import com.yoho.search.consumer.service.logicService.ufo.yoho.*;
8 import com.yoho.search.consumer.service.utils.IdCheckUtils; 8 import com.yoho.search.consumer.service.utils.IdCheckUtils;
9 -import com.yoho.search.dal.UfoGoodsMapper;  
10 -import com.yoho.search.dal.UfoProductMapper;  
11 -import com.yoho.search.dal.UfoStorageMapper;  
12 -import com.yoho.search.dal.UfoStoragePriceMapper; 9 +import com.yoho.search.dal.*;
13 import com.yoho.search.dal.model.*; 10 import com.yoho.search.dal.model.*;
14 import org.apache.commons.collections.CollectionUtils; 11 import org.apache.commons.collections.CollectionUtils;
15 import org.slf4j.Logger; 12 import org.slf4j.Logger;
@@ -55,6 +52,8 @@ public class UfoToYohoIndexBuilder extends IIndexBuilder { @@ -55,6 +52,8 @@ public class UfoToYohoIndexBuilder extends IIndexBuilder {
55 private UfoStorageMapper ufoStorageMapper; 52 private UfoStorageMapper ufoStorageMapper;
56 @Autowired 53 @Autowired
57 private UfoStoragePriceMapper ufoStoragePriceMapper; 54 private UfoStoragePriceMapper ufoStoragePriceMapper;
  55 + @Autowired
  56 + private UfoScoreProductRuleMapper ufoScoreProductRuleMapper;
58 57
59 @Override 58 @Override
60 public int getTotalCount() throws Exception { 59 public int getTotalCount() throws Exception {
@@ -138,6 +137,12 @@ public class UfoToYohoIndexBuilder extends IIndexBuilder { @@ -138,6 +137,12 @@ public class UfoToYohoIndexBuilder extends IIndexBuilder {
138 if (CollectionUtils.isNotEmpty(ufoStoragePriceList)) { 137 if (CollectionUtils.isNotEmpty(ufoStoragePriceList)) {
139 ufoStoragePriceMap = ufoStoragePriceList.stream().collect(Collectors.groupingBy(UfoStoragePrice::getProductId)); 138 ufoStoragePriceMap = ufoStoragePriceList.stream().collect(Collectors.groupingBy(UfoStoragePrice::getProductId));
140 } 139 }
  140 + //去查这一批ufo商品的ufo_score_product_rule Set
  141 + List<Integer> ufoScoreProductRuleList = ufoScoreProductRuleMapper.selectByIdList(ufoProductIdList);
  142 + Set<Integer> ufoScoreProductRuleSet = new HashSet<>();
  143 + if (CollectionUtils.isNotEmpty(ufoScoreProductRuleList)) {
  144 + ufoScoreProductRuleSet = ufoScoreProductRuleList.stream().collect(Collectors.toSet());
  145 + }
141 146
142 for (UfoProduct ufoProduct : ufoProductList) { 147 for (UfoProduct ufoProduct : ufoProductList) {
143 //不合法id直接丢掉 148 //不合法id直接丢掉
@@ -157,6 +162,8 @@ public class UfoToYohoIndexBuilder extends IIndexBuilder { @@ -157,6 +162,8 @@ public class UfoToYohoIndexBuilder extends IIndexBuilder {
157 ufoToYohoSizeService.build(productIndexBO, ufoProduct, ufoSizeMap, yohoSizeNameMap, ufoStorageMap); 162 ufoToYohoSizeService.build(productIndexBO, ufoProduct, ufoSizeMap, yohoSizeNameMap, ufoStorageMap);
158 //价格 163 //价格
159 ufoToYohoPriceService.build(productIndexBO, ufoProduct, ufoStoragePriceMap); 164 ufoToYohoPriceService.build(productIndexBO, ufoProduct, ufoStoragePriceMap);
  165 + //直通车
  166 + productIndexBO.setToAddScore(ufoScoreProductRuleSet.contains(ufoProduct.getId()) ? "Y" : "N");
160 productIndexBOList.add(productIndexBO); 167 productIndexBOList.add(productIndexBO);
161 } 168 }
162 return productIndexBOList; 169 return productIndexBOList;
@@ -20,7 +20,7 @@ public class UfoScoreProductRuleMqListener extends AbstractMqListener { @@ -20,7 +20,7 @@ public class UfoScoreProductRuleMqListener extends AbstractMqListener {
20 @Autowired 20 @Autowired
21 private UfoScoreProductRuleMapper ufoScoreProductRuleMapper; 21 private UfoScoreProductRuleMapper ufoScoreProductRuleMapper;
22 @Autowired 22 @Autowired
23 - private UfoIndexHelper ufoIndexHelper; 23 + private UfoIndexUpdateHelper ufoIndexUpdateHelper;
24 24
25 @Override 25 @Override
26 protected EventReportEnum getEventReportEnum() { 26 protected EventReportEnum getEventReportEnum() {
@@ -32,7 +32,7 @@ public class UfoScoreProductRuleMqListener extends AbstractMqListener { @@ -32,7 +32,7 @@ public class UfoScoreProductRuleMqListener extends AbstractMqListener {
32 UfoScoreProductRule ufoScoreProductRule = ufoScoreProductRuleMapper.selectByPrimaryKey(Integer.valueOf(id)); 32 UfoScoreProductRule ufoScoreProductRule = ufoScoreProductRuleMapper.selectByPrimaryKey(Integer.valueOf(id));
33 ufoScoreProductRuleMapper.deleteByPrimaryKey(Integer.valueOf(id)); 33 ufoScoreProductRuleMapper.deleteByPrimaryKey(Integer.valueOf(id));
34 if (ufoScoreProductRule != null) { 34 if (ufoScoreProductRule != null) {
35 - ufoIndexHelper.updateUfoProductIndexByProductId(ufoScoreProductRule.getProductId()); 35 + ufoIndexUpdateHelper.updateUfoIndex(ufoScoreProductRule.getProductId());
36 } 36 }
37 } 37 }
38 38
@@ -43,7 +43,7 @@ public class UfoScoreProductRuleMqListener extends AbstractMqListener { @@ -43,7 +43,7 @@ public class UfoScoreProductRuleMqListener extends AbstractMqListener {
43 return; 43 return;
44 } 44 }
45 this.saveOrUpdate(ufoScoreProductRule); 45 this.saveOrUpdate(ufoScoreProductRule);
46 - ufoIndexHelper.updateUfoProductIndexByProductId(ufoScoreProductRule.getProductId()); 46 + ufoIndexUpdateHelper.updateUfoIndex(ufoScoreProductRule.getProductId());
47 } 47 }
48 48
49 private int saveOrUpdate(UfoScoreProductRule ufoScoreProductRule) { 49 private int saveOrUpdate(UfoScoreProductRule ufoScoreProductRule) {