...
|
...
|
@@ -11,6 +11,7 @@ import com.yoho.search.dal.model.ProductI; |
|
|
import com.yoho.search.dal.model.ProductPrice;
|
|
|
import com.yoho.search.dal.model.StorageSku;
|
|
|
import com.yoho.search.dal.service.*;
|
|
|
import com.yoho.search.index.productIndex.IProductIndexBuildService;
|
|
|
import com.yoho.search.index.service.IYohoIndexService;
|
|
|
import com.yoho.search.utils.*;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
...
|
...
|
@@ -21,8 +22,6 @@ import org.springframework.amqp.rabbit.core.ChannelAwareMessageListener; |
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.math.RoundingMode;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.UUID;
|
...
|
...
|
@@ -47,6 +46,8 @@ public class ProductMqListener extends AbstractMqListener implements ChannelAwar |
|
|
private IYohoIndexService yohoIndexService;
|
|
|
@Autowired
|
|
|
private ProductPriceService productPriceService;
|
|
|
@Autowired
|
|
|
private IProductIndexBuildService productIndexBuildService;
|
|
|
|
|
|
static PerformanceMonitor updateProductIToEsMonitor = new PerformanceMonitor("UpdateProductIToEs");
|
|
|
|
...
|
...
|
@@ -115,23 +116,9 @@ public class ProductMqListener extends AbstractMqListener implements ChannelAwar |
|
|
|
|
|
//处理isNew(规则:首次上架7天内展示且折扣率小于88折)
|
|
|
productI.setIsnew("N");
|
|
|
try {
|
|
|
long dateCount = Integer.MAX_VALUE;
|
|
|
if (productI.getFirstShelveTime() > 0) {
|
|
|
dateCount = DateUtil.daysBetween(new Date(productI.getFirstShelveTime() * 1000L), new Date());
|
|
|
}
|
|
|
if (dateCount <= 7) {
|
|
|
ProductPrice productPrice = productPriceService.getById(productId);
|
|
|
if (productPrice != null) {
|
|
|
//计算折扣
|
|
|
Double discount = com.yoho.search.utils.MathUtils.getDevideValue(productPrice.getSalesPrice(), productPrice.getMarketPrice(), 2, RoundingMode.DOWN);
|
|
|
if (discount >= 0.88) {
|
|
|
productI.setIsnew("Y");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
logger.error(e.getMessage(), e);
|
|
|
ProductPrice productPrice = productPriceService.getById(productId);
|
|
|
if(productPrice!=null&&productIndexBuildService.isNew(productI.getFirstShelveTime(),productPrice.getMarketPrice(),productPrice.getSalesPrice())){
|
|
|
productI.setIsnew("Y");
|
|
|
}
|
|
|
logger.info("[step3=getProductI success][key={}][productId={}][cost={}ms]", key, productId, costStatistics.getCost());
|
|
|
|
...
|
...
|
|