Authored by wangnan9279

ufo addscore

... ... @@ -6,10 +6,7 @@ import com.yoho.search.consumer.service.logicService.ProductIndexBOToMapService;
import com.yoho.search.consumer.service.logicService.cache.BasicDataCacheService;
import com.yoho.search.consumer.service.logicService.ufo.yoho.*;
import com.yoho.search.consumer.service.utils.IdCheckUtils;
import com.yoho.search.dal.UfoGoodsMapper;
import com.yoho.search.dal.UfoProductMapper;
import com.yoho.search.dal.UfoStorageMapper;
import com.yoho.search.dal.UfoStoragePriceMapper;
import com.yoho.search.dal.*;
import com.yoho.search.dal.model.*;
import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger;
... ... @@ -55,6 +52,8 @@ public class UfoToYohoIndexBuilder extends IIndexBuilder {
private UfoStorageMapper ufoStorageMapper;
@Autowired
private UfoStoragePriceMapper ufoStoragePriceMapper;
@Autowired
private UfoScoreProductRuleMapper ufoScoreProductRuleMapper;
@Override
public int getTotalCount() throws Exception {
... ... @@ -138,6 +137,12 @@ public class UfoToYohoIndexBuilder extends IIndexBuilder {
if (CollectionUtils.isNotEmpty(ufoStoragePriceList)) {
ufoStoragePriceMap = ufoStoragePriceList.stream().collect(Collectors.groupingBy(UfoStoragePrice::getProductId));
}
//去查这一批ufo商品的ufo_score_product_rule Set
List<Integer> ufoScoreProductRuleList = ufoScoreProductRuleMapper.selectByIdList(ufoProductIdList);
Set<Integer> ufoScoreProductRuleSet = new HashSet<>();
if (CollectionUtils.isNotEmpty(ufoScoreProductRuleList)) {
ufoScoreProductRuleSet = ufoScoreProductRuleList.stream().collect(Collectors.toSet());
}
for (UfoProduct ufoProduct : ufoProductList) {
//不合法id直接丢掉
... ... @@ -157,6 +162,8 @@ public class UfoToYohoIndexBuilder extends IIndexBuilder {
ufoToYohoSizeService.build(productIndexBO, ufoProduct, ufoSizeMap, yohoSizeNameMap, ufoStorageMap);
//价格
ufoToYohoPriceService.build(productIndexBO, ufoProduct, ufoStoragePriceMap);
//直通车
productIndexBO.setToAddScore(ufoScoreProductRuleSet.contains(ufoProduct.getId()) ? "Y" : "N");
productIndexBOList.add(productIndexBO);
}
return productIndexBOList;
... ...
... ... @@ -20,7 +20,7 @@ public class UfoScoreProductRuleMqListener extends AbstractMqListener {
@Autowired
private UfoScoreProductRuleMapper ufoScoreProductRuleMapper;
@Autowired
private UfoIndexHelper ufoIndexHelper;
private UfoIndexUpdateHelper ufoIndexUpdateHelper;
@Override
protected EventReportEnum getEventReportEnum() {
... ... @@ -32,7 +32,7 @@ public class UfoScoreProductRuleMqListener extends AbstractMqListener {
UfoScoreProductRule ufoScoreProductRule = ufoScoreProductRuleMapper.selectByPrimaryKey(Integer.valueOf(id));
ufoScoreProductRuleMapper.deleteByPrimaryKey(Integer.valueOf(id));
if (ufoScoreProductRule != null) {
ufoIndexHelper.updateUfoProductIndexByProductId(ufoScoreProductRule.getProductId());
ufoIndexUpdateHelper.updateUfoIndex(ufoScoreProductRule.getProductId());
}
}
... ... @@ -43,7 +43,7 @@ public class UfoScoreProductRuleMqListener extends AbstractMqListener {
return;
}
this.saveOrUpdate(ufoScoreProductRule);
ufoIndexHelper.updateUfoProductIndexByProductId(ufoScoreProductRule.getProductId());
ufoIndexUpdateHelper.updateUfoIndex(ufoScoreProductRule.getProductId());
}
private int saveOrUpdate(UfoScoreProductRule ufoScoreProductRule) {
... ...