...
|
...
|
@@ -9,6 +9,8 @@ import java.util.List; |
|
|
import java.util.Map;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
import com.yoho.search.dal.ProductPriceHistoryMapper;
|
|
|
import com.yoho.search.dal.model.ProductPriceHistory;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
...
|
...
|
@@ -35,6 +37,8 @@ public class ProductPriceBuilder implements ViewBuilder { |
|
|
@Autowired
|
|
|
private ProductPriceMapper productPriceMapper;
|
|
|
@Autowired
|
|
|
private ProductPriceHistoryMapper productPriceHistoryMapper;
|
|
|
@Autowired
|
|
|
private VipPriceLogicService vipPriceLogicService;
|
|
|
@Autowired
|
|
|
private SpecialDealLogicService specialSearchFieldLogicService;
|
...
|
...
|
@@ -52,7 +56,7 @@ public class ProductPriceBuilder implements ViewBuilder { |
|
|
}
|
|
|
// 构造ProductPriceBO
|
|
|
ProductPriceBO productPriceBO = new ProductPriceBO(productPrice);
|
|
|
this.buildProductPriceBO(productPriceBO);
|
|
|
this.buildProductPriceBO(productPriceBO, productPrice);
|
|
|
// 构造ProductIndexBO
|
|
|
this.buildProductIndexBO(productIndexBO, productPriceBO);
|
|
|
} catch (Exception e) {
|
...
|
...
|
@@ -64,7 +68,7 @@ public class ProductPriceBuilder implements ViewBuilder { |
|
|
/**
|
|
|
* 增量+全量都调用
|
|
|
*/
|
|
|
public void buildProductPriceBO(ProductPriceBO productPriceBO) {
|
|
|
public void buildProductPriceBO(ProductPriceBO productPriceBO, ProductPrice productPrice) {
|
|
|
// 1、计算并重设vip相关价格
|
|
|
vipPriceLogicService.fillProductPriceVipPrice(productPriceBO);
|
|
|
// 2、计算折扣相关
|
...
|
...
|
@@ -85,6 +89,7 @@ public class ProductPriceBuilder implements ViewBuilder { |
|
|
BigDecimal studentPrice = productPriceBO.getStudentPrice();
|
|
|
productPriceBO.setIsStudentPrice(studentPrice== null || studentPrice.compareTo(BigDecimal.ZERO)==0 ? "N" : "Y");
|
|
|
productPriceBO.setIsstudentrebate(productPriceBO.getStudentCoinRate() == null || productPriceBO.getStudentCoinRate().compareTo(BigDecimal.ZERO) == 0 ? "N" : "Y");
|
|
|
productPriceBO.setIsLatestReducePrice(isLatestReducePrice(productPrice.getProductSkn(), productPrice.getCurrentPrice()));
|
|
|
}
|
|
|
|
|
|
private void buildProductIndexBO(ProductIndexBO productIndexBO, ProductPriceBO productPriceBO) {
|
...
|
...
|
@@ -124,6 +129,7 @@ public class ProductPriceBuilder implements ViewBuilder { |
|
|
}
|
|
|
// 计算specialSearchFieldPrice
|
|
|
productIndexBO.setSpecialSearchFieldPrice(specialSearchFieldLogicService.getSpecialSearchFieldPrice(productPriceBO));
|
|
|
productIndexBO.setIsLatestReducePrice(productPriceBO.getIsLatestReducePrice());
|
|
|
}
|
|
|
|
|
|
public Map<String, Object> getProductPriceModelMap(Integer productId, Integer firstShelveTime, ProductPrice pp) {
|
...
|
...
|
@@ -134,7 +140,7 @@ public class ProductPriceBuilder implements ViewBuilder { |
|
|
}
|
|
|
// 构造ProductPriceBO
|
|
|
ProductPriceBO productPriceBO = new ProductPriceBO(pp);
|
|
|
this.buildProductPriceBO(productPriceBO);
|
|
|
this.buildProductPriceBO(productPriceBO, pp);
|
|
|
indexData.put("productId", productId);
|
|
|
indexData.put("marketPrice", this.getDoubleFromBigDecimal(productPriceBO.getMarketPrice()));
|
|
|
indexData.put("salesPrice", this.getDoubleFromBigDecimal(productPriceBO.getSalesPrice()));
|
...
|
...
|
@@ -157,9 +163,24 @@ public class ProductPriceBuilder implements ViewBuilder { |
|
|
indexData.put("isnew", "Y");
|
|
|
}
|
|
|
indexData.put(ProductIndexEsField.specialSearchFieldPrice, specialSearchFieldLogicService.getSpecialSearchFieldPrice(productPriceBO));
|
|
|
indexData.put("isLatestReducePrice", productPriceBO.getIsLatestReducePrice());
|
|
|
return indexData;
|
|
|
}
|
|
|
|
|
|
private String isLatestReducePrice(Integer productSkn, BigDecimal price) {
|
|
|
if (price == null) {
|
|
|
return "N";
|
|
|
}
|
|
|
ProductPriceHistory productPriceHistory = productPriceHistoryMapper.selectByPrimaryKey(productSkn);
|
|
|
if (productPriceHistory == null) {
|
|
|
return "N";
|
|
|
}
|
|
|
if (price.compareTo(productPriceHistory.getCurrentSalesPrice()) == 0) {
|
|
|
return price.compareTo(productPriceHistory.getHistorySalesPrice()) < 0 ? "Y" : "N";
|
|
|
}
|
|
|
return price.compareTo(productPriceHistory.getCurrentSalesPrice()) < 0 ? "Y" : "N";
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* isNew 标签逻辑
|
|
|
*/
|
...
|
...
|
|