Authored by unknown

fix 价格构建的逻辑

package com.yoho.search.consumer.index.fullbuild.tblProductNew;
import com.yoho.search.base.utils.DateUtil;
import com.yoho.search.consumer.service.bo.ProductIndexBO;
import com.yoho.search.dal.model.TblProduct;
import org.springframework.stereotype.Component;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.yoho.search.base.utils.DateUtil;
import com.yoho.search.consumer.service.bo.ProductIndexBO;
import com.yoho.search.consumer.service.bo.ProductPriceBO;
import com.yoho.search.consumer.service.logic.productIndex.ProductPriceBOLogicService;
import com.yoho.search.dal.model.TblProduct;
/**
* Created by wangnan on 2017/4/18.
*/
@Component
public class GeneralBuilder {
protected final static Map<Integer, String> countryFieldMap = new HashMap<Integer, String>() {
@Autowired
private ProductPriceBOLogicService productPriceBOLogicService;
protected final static Map<Integer, String> countryFieldMap = new HashMap<Integer, String>() {
private static final long serialVersionUID = 5438202156909229827L;
{
put(374, "美国");
put(44, "英国");
put(46, "瑞典");
put(81, "日本");
put(82, "韩国");
put(852, "香港");
put(49, "德国");
put(86, "国内现货");
}
};
put(374, "美国");
put(44, "英国");
put(46, "瑞典");
put(81, "日本");
put(82, "韩国");
put(852, "香港");
put(49, "德国");
put(86, "国内现货");
}
};
public ProductIndexBO build(ProductIndexBO productIndexBO, TblProduct tblProduct) {
// 全球购标识
productIndexBO.setIsGlobal("Y");
productIndexBO.setPhysicalChannels("1,2,3,4");
// 名称
productIndexBO.setProductName(tblProduct.getProductName());
// 特殊处理id,productId,productSkn
productIndexBO.setId(tblProduct.getProductSkn() * (-1));
productIndexBO.setProductId(tblProduct.getProductSkn());
productIndexBO.setProductSkn(tblProduct.getProductSkn());
if (tblProduct.getIsLimited() != null) {
productIndexBO.setIslimited("1".equals(tblProduct.getIsLimited()) ? "Y" : "N");
}
if (tblProduct.getGender() != null) {
productIndexBO.setGender(tblProduct.getGender());
productIndexBO.setGenderS(tblProduct.getGender().replace('1', '男').replace('2', '女').replace("3", "男/女"));
}
productIndexBO.setIsSpecial("N");
productIndexBO.setIsHot("N");
productIndexBO.setIshot(2);
productIndexBO.setIspromotion(0);
productIndexBO.setIsAdvance("N");
productIndexBO.setIsadvance(2);
productIndexBO.setIsAuditing("N");
productIndexBO.setIsauditing(2);
productIndexBO.setAttribute(1);
productIndexBO.setIsDown("N");
productIndexBO.setIsdown(2);
productIndexBO.setIsrecommend(2);
productIndexBO.setIsOutlets(2);
if (null != tblProduct.getShelfTime()) {
productIndexBO.setShelveTime(tblProduct.getShelfTime());
productIndexBO.setFirstShelveTime(0);
productIndexBO.setShelveDay(DateUtil.TimeStamp2DateWithFormat(Long.valueOf(productIndexBO.getShelveTime()), "yyyy-MM-dd"));
}
productIndexBO.setEditTime(null == tblProduct.getUpdateTime() ? null : tblProduct.getUpdateTime());
productIndexBO.setBreakingRate(0d);
productIndexBO.setBasePinRatio(0);
// 处理国家id和名称
productIndexBO.setTblCountryId(tblProduct.getCountryId());
productIndexBO.setTblCountryName(countryFieldMap.get(tblProduct.getCountryId()));
productIndexBO.setAgeLevel("1");
public ProductIndexBO build(ProductIndexBO productIndexBO, TblProduct tblProduct) {
// 全球购标识
productIndexBO.setIsGlobal("Y");
productIndexBO.setPhysicalChannels("1,2,3,4");
// 名称
productIndexBO.setProductName(tblProduct.getProductName());
// 特殊处理id,productId,productSkn
productIndexBO.setId(tblProduct.getProductSkn() * (-1));
productIndexBO.setProductId(tblProduct.getProductSkn());
productIndexBO.setProductSkn(tblProduct.getProductSkn());
if (tblProduct.getIsLimited() != null) {
productIndexBO.setIslimited("1".equals(tblProduct.getIsLimited()) ? "Y" : "N");
}
if (tblProduct.getGender() != null) {
productIndexBO.setGender(tblProduct.getGender());
productIndexBO.setGenderS(tblProduct.getGender().replace('1', '男').replace('2', '女').replace("3", "男/女"));
}
productIndexBO.setIsSpecial("N");
productIndexBO.setIsHot("N");
productIndexBO.setIshot(2);
productIndexBO.setIspromotion(0);
productIndexBO.setIsAdvance("N");
productIndexBO.setIsadvance(2);
productIndexBO.setIsAuditing("N");
productIndexBO.setIsauditing(2);
productIndexBO.setAttribute(1);
productIndexBO.setIsDown("N");
productIndexBO.setIsdown(2);
productIndexBO.setIsrecommend(2);
productIndexBO.setIsOutlets(2);
productIndexBO.setIsnew("N");
if (null != tblProduct.getShelfTime()) {
productIndexBO.setShelveTime(tblProduct.getShelfTime());
productIndexBO.setFirstShelveTime(0);
productIndexBO.setShelveDay(DateUtil.TimeStamp2DateWithFormat(Long.valueOf(productIndexBO.getShelveTime()), "yyyy-MM-dd"));
}
productIndexBO.setEditTime(null == tblProduct.getUpdateTime() ? null : tblProduct.getUpdateTime());
productIndexBO.setMarketPrice(null == tblProduct.getOrignPrice() ? new BigDecimal(0) : tblProduct.getOrignPrice());
productIndexBO.setSalesPrice(null == tblProduct.getGoodsPrice() ? new BigDecimal(0) : tblProduct.getGoodsPrice());
if (productIndexBO.getSalesPrice() != null) {
if (productIndexBO.getMarketPrice() != null && productIndexBO.getMarketPrice().doubleValue() != 0d) {
BigDecimal promotionDiscount = productIndexBO.getSalesPrice().divide(productIndexBO.getMarketPrice(), 4, BigDecimal.ROUND_HALF_UP);
productIndexBO.setPromotionDiscount(promotionDiscount);
productIndexBO.setPromotionDiscountInt((promotionDiscount.multiply(BigDecimal.TEN)).longValue());
if (productIndexBO.getSalesPrice().compareTo(productIndexBO.getMarketPrice()) < 0) {
productIndexBO.setIsDiscount("Y");
}
}
productIndexBO.setVip1Price(productIndexBO.getSalesPrice());
productIndexBO.setVip2Price(productIndexBO.getSalesPrice());
productIndexBO.setVip3Price(productIndexBO.getSalesPrice());
productIndexBO.setVipPrice(productIndexBO.getSalesPrice());
productIndexBO.setSpecialPrice(productIndexBO.getSalesPrice());
}
productIndexBO.setSpecialoffer("N");
productIndexBO.setIsDiscount("N");
productIndexBO.setBreakingRate(0d);
productIndexBO.setBasePinRatio(0);
// 处理国家id和名称
productIndexBO.setTblCountryId(tblProduct.getCountryId());
productIndexBO.setTblCountryName(countryFieldMap.get(tblProduct.getCountryId()));
productIndexBO.setAgeLevel("1");
return productIndexBO;
// 设置价格
ProductPriceBO productPriceBo = new ProductPriceBO(productIndexBO.getProductSkn());
productIndexBO.setProductPriceBO(productPriceBo);
}
// fillproductPriceBo
BigDecimal marketPrice = (null == tblProduct.getOrignPrice() ? new BigDecimal(0) : tblProduct.getOrignPrice());
BigDecimal salesPrice = (null == tblProduct.getGoodsPrice() ? new BigDecimal(0) : tblProduct.getGoodsPrice());
productPriceBo.setMarketPrice(marketPrice);
productPriceBo.setSalesPrice(salesPrice);
productPriceBo.setVipPrice(salesPrice);
productPriceBo.setVip1Price(salesPrice);
productPriceBo.setVip2Price(salesPrice);
productPriceBo.setVip3Price(salesPrice);
// 2、计算折扣相关
productPriceBOLogicService.fillProductPriceBODiscount(productPriceBo);
return productIndexBO;
}
}
... ...
... ... @@ -28,7 +28,6 @@ public class ProductIBO implements Serializable {
private String genderS;
private String style;
private String pattern;
private String isnew;
private String islimited;
private Integer ishot;
private String isHot;
... ... @@ -469,14 +468,6 @@ public class ProductIBO implements Serializable {
this.productSkn = productSkn;
}
public String getIsnew() {
return isnew;
}
public void setIsnew(String isnew) {
this.isnew = isnew;
}
public String getBrandNameCn() {
return brandNameCn;
}
... ...
package com.yoho.search.consumer.service.bo;
import com.alibaba.fastjson.JSONArray;
import java.io.Serializable;
import java.math.BigDecimal;
import com.alibaba.fastjson.JSONArray;
/**
* 商品实体索引
*
... ... @@ -15,24 +15,8 @@ public class ProductIndexBO extends ProductIBO implements Serializable {
private static final long serialVersionUID = 1L;
// from product_price
private BigDecimal specialPrice;
private BigDecimal marketPrice;
private Integer vipDiscountType;
private BigDecimal vipPrice;
private BigDecimal vip1Price;
private BigDecimal vip2Price;
private BigDecimal vip3Price;
private String vipLevels;// 支持的vip等级
private String specialSearchFieldPrice;// 全量才会构建的特殊搜索字段
private BigDecimal salesPrice;
private BigDecimal studentPrice;
private String isStudentPrice;
private Long promotionDiscountInt;
private BigDecimal promotionDiscount;
private String specialoffer;
private String isDiscount;
// from productPriceBO
private ProductPriceBO productPriceBO;
// from product_keywords
private String productKeyword;
... ... @@ -90,8 +74,6 @@ public class ProductIndexBO extends ProductIBO implements Serializable {
private double discountScore;
private String poolId;
private String isStudentRebate;
// form storage
private Integer storageUpdateTime;
... ... @@ -119,7 +101,6 @@ public class ProductIndexBO extends ProductIBO implements Serializable {
private String productAttrField;
private BigDecimal heatValue;
private Integer priceUpdateTime;
private String promotionTitles;
... ... @@ -129,66 +110,54 @@ public class ProductIndexBO extends ProductIBO implements Serializable {
private Integer giveValue;
private Integer profitValue;
// from product_price
private Integer lastReducePriceTime;
// from score_skn_rule
private String toAddScore;
// from videos
private String specialSearchFieldVideo;
//from ctr_value
private BigDecimal ctrValue;
// from ctr_value
private BigDecimal ctrValue;
//skn_flow
private Integer flowType;
// skn_flow
private Integer flowType;
//product_sales_info
private BigDecimal sevendayMoney;
// product_sales_info
private BigDecimal sevendayMoney;
private String isLatestReducePrice;
public String getIsLatestReducePrice() {
return isLatestReducePrice;
public ProductPriceBO getProductPriceBO() {
return productPriceBO;
}
public void setIsLatestReducePrice(String isLatestReducePrice) {
this.isLatestReducePrice = isLatestReducePrice;
public void setProductPriceBO(ProductPriceBO productPriceBO) {
this.productPriceBO = productPriceBO;
}
public BigDecimal getSevendayMoney() {
return sevendayMoney;
}
public void setSevendayMoney(BigDecimal sevendayMoney) {
this.sevendayMoney = sevendayMoney;
}
public BigDecimal getCtrValue() {
return ctrValue;
}
public void setCtrValue(BigDecimal ctrValue) {
this.ctrValue = ctrValue;
}
return sevendayMoney;
}
public Integer getFlowType() {
return flowType;
}
public void setSevendayMoney(BigDecimal sevendayMoney) {
this.sevendayMoney = sevendayMoney;
}
public void setFlowType(Integer flowType) {
this.flowType = flowType;
}
public BigDecimal getCtrValue() {
return ctrValue;
}
public Integer getLastReducePriceTime() {
return lastReducePriceTime;
public void setCtrValue(BigDecimal ctrValue) {
this.ctrValue = ctrValue;
}
public void setLastReducePriceTime(Integer lastReducePriceTime) {
this.lastReducePriceTime = lastReducePriceTime;
public Integer getFlowType() {
return flowType;
}
public void setFlowType(Integer flowType) {
this.flowType = flowType;
}
public Integer getActiveValue() {
return activeValue;
}
... ... @@ -221,62 +190,6 @@ public class ProductIndexBO extends ProductIBO implements Serializable {
this.profitValue = profitValue;
}
public BigDecimal getSpecialPrice() {
return specialPrice;
}
public BigDecimal getMarketPrice() {
return marketPrice;
}
public Integer getVipDiscountType() {
return vipDiscountType;
}
public BigDecimal getVipPrice() {
return vipPrice;
}
public BigDecimal getVip1Price() {
return vip1Price;
}
public BigDecimal getVip2Price() {
return vip2Price;
}
public BigDecimal getVip3Price() {
return vip3Price;
}
public String getVipLevels() {
return vipLevels;
}
public void setVipLevels(String vipLevels) {
this.vipLevels = vipLevels;
}
public BigDecimal getSalesPrice() {
return salesPrice;
}
public Long getPromotionDiscountInt() {
return promotionDiscountInt;
}
public BigDecimal getPromotionDiscount() {
return promotionDiscount;
}
public String getSpecialoffer() {
return specialoffer;
}
public String getIsDiscount() {
return isDiscount;
}
public String getProductKeyword() {
return productKeyword;
}
... ... @@ -369,54 +282,6 @@ public class ProductIndexBO extends ProductIBO implements Serializable {
return poolId;
}
public void setSpecialPrice(BigDecimal specialPrice) {
this.specialPrice = specialPrice;
}
public void setMarketPrice(BigDecimal marketPrice) {
this.marketPrice = marketPrice;
}
public void setVipDiscountType(Integer vipDiscountType) {
this.vipDiscountType = vipDiscountType;
}
public void setVipPrice(BigDecimal vipPrice) {
this.vipPrice = vipPrice;
}
public void setVip1Price(BigDecimal vip1Price) {
this.vip1Price = vip1Price;
}
public void setVip2Price(BigDecimal vip2Price) {
this.vip2Price = vip2Price;
}
public void setVip3Price(BigDecimal vip3Price) {
this.vip3Price = vip3Price;
}
public void setSalesPrice(BigDecimal salesPrice) {
this.salesPrice = salesPrice;
}
public void setPromotionDiscountInt(Long promotionDiscountInt) {
this.promotionDiscountInt = promotionDiscountInt;
}
public void setPromotionDiscount(BigDecimal promotionDiscount) {
this.promotionDiscount = promotionDiscount;
}
public void setSpecialoffer(String specialoffer) {
this.specialoffer = specialoffer;
}
public void setIsDiscount(String isDiscount) {
this.isDiscount = isDiscount;
}
public void setProductKeyword(String productKeyword) {
this.productKeyword = productKeyword;
}
... ... @@ -509,14 +374,6 @@ public class ProductIndexBO extends ProductIBO implements Serializable {
this.poolId = poolId;
}
public BigDecimal getStudentPrice() {
return studentPrice;
}
public void setStudentPrice(BigDecimal studentPrice) {
this.studentPrice = studentPrice;
}
public String getSizeNames() {
return sizeNames;
}
... ... @@ -529,18 +386,10 @@ public class ProductIndexBO extends ProductIBO implements Serializable {
this.breakSizePercent = breakSizePercent;
}
public String getIsStudentPrice() {
return isStudentPrice;
}
public void setSizeNames(String sizeNames) {
this.sizeNames = sizeNames;
}
public void setIsStudentPrice(String isStudentPrice) {
this.isStudentPrice = isStudentPrice;
}
public Long getShopWeight() {
return shopWeight;
}
... ... @@ -549,14 +398,6 @@ public class ProductIndexBO extends ProductIBO implements Serializable {
this.shopWeight = shopWeight;
}
public String getIsStudentRebate() {
return isStudentRebate;
}
public void setIsStudentRebate(String isStudentRebate) {
this.isStudentRebate = isStudentRebate;
}
public Integer getStorageUpdateTime() {
return storageUpdateTime;
}
... ... @@ -661,14 +502,6 @@ public class ProductIndexBO extends ProductIBO implements Serializable {
this.heatValue = heatValue;
}
public Integer getPriceUpdateTime() {
return priceUpdateTime;
}
public void setPriceUpdateTime(Integer priceUpdateTime) {
this.priceUpdateTime = priceUpdateTime;
}
public String getPromotionTitles() {
return promotionTitles;
}
... ... @@ -685,14 +518,6 @@ public class ProductIndexBO extends ProductIBO implements Serializable {
this.toAddScore = toAddScore;
}
public String getSpecialSearchFieldPrice() {
return specialSearchFieldPrice;
}
public void setSpecialSearchFieldPrice(String specialSearchFieldPrice) {
this.specialSearchFieldPrice = specialSearchFieldPrice;
}
public String getSpecialSearchFieldVideo() {
return specialSearchFieldVideo;
}
... ...
... ... @@ -5,38 +5,42 @@ import java.math.BigDecimal;
import com.yoho.search.dal.model.ProductPrice;
public class ProductPriceBO {
private Integer productSkn = 0;
// 市场价+销售价
private BigDecimal marketPrice = new BigDecimal(0);
private BigDecimal salesPrice = new BigDecimal(0);// 构造的时候使用currentSalesPrice构建
// vip价格相关属性
private Integer vipDiscountType = 3;// 构造的时候使用currentVipDiscountType构建
private BigDecimal vipDiscount = new BigDecimal(0);
private BigDecimal vipPrice = new BigDecimal(0);
private BigDecimal vip1Price = new BigDecimal(0);
private BigDecimal vip2Price = new BigDecimal(0);
private BigDecimal vip3Price = new BigDecimal(0);
// 学生价属性
private BigDecimal studentPrice = new BigDecimal(0);
private BigDecimal studentCoinRate = new BigDecimal(0);
private String isStudentPrice = "N";
private String isstudentrebate = "N";
// 更新时间
private Integer priceUpdateTime = 0;
private Integer lastReducePriceTime = 0;
private BigDecimal basicPrice = new BigDecimal(0);
private Integer productVipStatus = 0;
private BigDecimal vipDiscount = new BigDecimal(0);
private BigDecimal salesPrice = new BigDecimal(0);// 构造的时候使用currentSalesPrice构建
private Integer vipDiscountType = 0;// 构造的时候使用currentVipDiscountType构建
// others
// 折扣相关-单独设置
private String isDiscount = "N";
private String specialoffer = "N";
private String isStudentPrice = "N";
private String isstudentrebate = "N";
private String isLatestReducePrice = "N";
private String isnew = "N";
private Long promotionDiscountInt = 10L;
private BigDecimal promotionDiscount = new BigDecimal(1);
private String specialoffer = "N";
// others-单独设置
private String vipLevels = "";
private String isLatestReducePrice = "N";
private String isnew = "N";
private String specialSearchFieldPrice = "";
public ProductPriceBO(Integer productSkn) {
this.productSkn = productSkn;
}
... ... @@ -51,24 +55,29 @@ public class ProductPriceBO {
} else {
this.salesPrice = productPrice.getSalesPrice();// 兜底方案
}
this.marketPrice = productPrice.getRetailPrice();// 吊牌价
//vip
Integer currentVipDiscountType = productPrice.getCurrentVipDiscountType();
if (currentVipDiscountType != null) {
this.vipDiscountType = currentVipDiscountType;
} else {
this.vipDiscountType = productPrice.getVipDiscountType();
}
this.marketPrice = productPrice.getRetailPrice();// 吊牌价
this.vipDiscount = productPrice.getVipDiscount();
this.vipPrice = productPrice.getVipPrice();
this.vip1Price = productPrice.getVip1Price();
this.vip2Price = productPrice.getVip2Price();
this.vip3Price = productPrice.getVip3Price();
// 学生价相关
this.studentPrice = productPrice.getStudentPrice();
this.studentCoinRate = productPrice.getStudentCoinRate();
this.isStudentPrice = (productPrice.getStudentPrice() == null || productPrice.getStudentPrice().compareTo(BigDecimal.ZERO) == 0 ? "N" : "Y");
this.isstudentrebate = productPrice.getStudentCoinRate() == null || productPrice.getStudentCoinRate().compareTo(BigDecimal.ZERO) == 0 ? "N" : "Y";
// 更新时间
this.priceUpdateTime = productPrice.getUpdateTime();
this.lastReducePriceTime = productPrice.getLastReducePriceTime();
this.basicPrice = productPrice.getBasicPrice();
this.productVipStatus = productPrice.getProductVipStatus();
this.vipDiscount = productPrice.getVipDiscount();
}
public Integer getProductSkn() {
... ... @@ -167,12 +176,12 @@ public class ProductPriceBO {
this.studentPrice = studentPrice;
}
public BigDecimal getStudentCoinRate() {
return studentCoinRate;
public String getIsstudentrebate() {
return isstudentrebate;
}
public void setStudentCoinRate(BigDecimal studentCoinRate) {
this.studentCoinRate = studentCoinRate;
public void setIsstudentrebate(String isstudentrebate) {
this.isstudentrebate = isstudentrebate;
}
public String getIsDiscount() {
... ... @@ -215,14 +224,6 @@ public class ProductPriceBO {
this.isStudentPrice = isStudentPrice;
}
public String getIsstudentrebate() {
return isstudentrebate;
}
public void setIsstudentrebate(String isstudentrebate) {
this.isstudentrebate = isstudentrebate;
}
public String getVipLevels() {
return vipLevels;
}
... ... @@ -238,22 +239,6 @@ public class ProductPriceBO {
public void setPriceUpdateTime(Integer priceUpdateTime) {
this.priceUpdateTime = priceUpdateTime;
}
public BigDecimal getBasicPrice() {
return basicPrice;
}
public void setBasicPrice(BigDecimal basicPrice) {
this.basicPrice = basicPrice;
}
public Integer getProductVipStatus() {
return productVipStatus;
}
public void setProductVipStatus(Integer productVipStatus) {
this.productVipStatus = productVipStatus;
}
public String getSpecialSearchFieldPrice() {
return specialSearchFieldPrice;
... ...
package com.yoho.search.consumer.service.logic.productIndex;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONException;
import com.yoho.search.base.utils.ProductIndexEsField;
import com.yoho.search.consumer.service.bo.ProductIndexBO;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONException;
import com.yoho.search.base.utils.ProductIndexEsField;
import com.yoho.search.consumer.service.bo.ProductIndexBO;
import com.yoho.search.consumer.service.bo.ProductPriceBO;
@Component
public class ProductIndexBOToMapService {
... ... @@ -23,6 +24,7 @@ public class ProductIndexBOToMapService {
Map map = new HashMap(500);
map.put(ProductIndexEsField.id, productIndexBO.getId());
map.put(ProductIndexEsField.productId, productIndexBO.getProductId());
map.put(ProductIndexEsField.productSkn, productIndexBO.getProductSkn());
map.put(ProductIndexEsField.shopId, productIndexBO.getShopId());
map.put(ProductIndexEsField.salesNum, productIndexBO.getSalesNum());
map.put(ProductIndexEsField.shelveTime, productIndexBO.getShelveTime());
... ... @@ -68,50 +70,43 @@ public class ProductIndexBOToMapService {
map.put(ProductIndexEsField.isrecommend, productIndexBO.getIsrecommend());
map.put(ProductIndexEsField.isOutlets, productIndexBO.getIsOutlets());
map.put(ProductIndexEsField.firstShelveTime, productIndexBO.getFirstShelveTime());
BigDecimal temp = productIndexBO.getSpecialPrice();
if (temp != null) {
map.put(ProductIndexEsField.specialPrice, productIndexBO.getSpecialPrice().doubleValue());
}
temp = productIndexBO.getMarketPrice();
if (temp != null) {
map.put(ProductIndexEsField.marketPrice, productIndexBO.getMarketPrice().doubleValue());
}
temp = productIndexBO.getVipPrice();
if (temp != null) {
map.put(ProductIndexEsField.vipPrice, productIndexBO.getVipPrice().doubleValue());
}
temp = productIndexBO.getVip1Price();
if (temp != null) {
map.put(ProductIndexEsField.vip1Price, productIndexBO.getVip1Price().doubleValue());
}
temp = productIndexBO.getVip2Price();
if (temp != null) {
map.put(ProductIndexEsField.vip2Price, productIndexBO.getVip2Price().doubleValue());
}
temp = productIndexBO.getVip3Price();
if (temp != null) {
map.put(ProductIndexEsField.vip3Price, productIndexBO.getVip3Price().doubleValue());
}
temp = productIndexBO.getSalesPrice();
if (temp != null) {
map.put(ProductIndexEsField.salesPrice, productIndexBO.getSalesPrice().doubleValue());
}
map.put(ProductIndexEsField.vipLevels, productIndexBO.getVipLevels());
temp = productIndexBO.getPromotionDiscount();
if (temp != null) {
map.put(ProductIndexEsField.promotionDiscount, productIndexBO.getPromotionDiscount().doubleValue());
/*---------------处理价格相关属性 begin-------------------------------*/
ProductPriceBO productPriceBO = productIndexBO.getProductPriceBO();
if (productPriceBO == null) {
productPriceBO = new ProductPriceBO(productIndexBO.getProductSkn());
}
map.put(ProductIndexEsField.vipDiscountType, productIndexBO.getVipDiscountType());
map.put(ProductIndexEsField.promotionDiscountInt, productIndexBO.getPromotionDiscountInt());
map.put(ProductIndexEsField.specialoffer, productIndexBO.getSpecialoffer());
map.put(ProductIndexEsField.marketPrice, productPriceBO.getMarketPrice());
map.put(ProductIndexEsField.salesPrice, productPriceBO.getSalesPrice());
map.put(ProductIndexEsField.vipDiscountType, productPriceBO.getVipDiscountType());
map.put(ProductIndexEsField.vipDiscount, productPriceBO.getVipDiscount());
map.put(ProductIndexEsField.vipPrice, productPriceBO.getVipPrice());
map.put(ProductIndexEsField.vip1Price, productPriceBO.getVip1Price());
map.put(ProductIndexEsField.vip2Price, productPriceBO.getVip2Price());
map.put(ProductIndexEsField.vip3Price, productPriceBO.getVip3Price());
map.put(ProductIndexEsField.vipLevels, productPriceBO.getVipLevels());
map.put(ProductIndexEsField.studentPrice, productPriceBO.getStudentPrice());
map.put(ProductIndexEsField.isStudentPrice, productPriceBO.getIsStudentPrice());
map.put(ProductIndexEsField.isstudentrebate, productPriceBO.getIsstudentrebate());
map.put(ProductIndexEsField.priceUpdateTime, productPriceBO.getPriceUpdateTime());
map.put(ProductIndexEsField.lastReducePriceTime, productPriceBO.getLastReducePriceTime());
map.put(ProductIndexEsField.isDiscount, productPriceBO.getIsDiscount());
map.put(ProductIndexEsField.promotionDiscount, productPriceBO.getPromotionDiscount());
map.put(ProductIndexEsField.promotionDiscountInt, productPriceBO.getPromotionDiscountInt());
map.put(ProductIndexEsField.specialoffer, productPriceBO.getSpecialoffer());
map.put(ProductIndexEsField.specialSearchFieldPrice, productPriceBO.getSpecialSearchFieldPrice());
map.put(ProductIndexEsField.isLatestReducePrice, productPriceBO.getIsLatestReducePrice());
map.put(ProductIndexEsField.isnew, productPriceBO.getIsnew());
/*---------------处理价格相关属性end-------------------------------*/
map.put(ProductIndexEsField.sellChannels, productIndexBO.getSellChannels());
map.put(ProductIndexEsField.productSkn, productIndexBO.getProductSkn());
temp = productIndexBO.getStorageNum();
if (temp != null) {
map.put(ProductIndexEsField.storageNum, productIndexBO.getStorageNum().longValue());
}
map.put(ProductIndexEsField.storageNum, productIndexBO.getStorageNum() == null ? 0 : productIndexBO.getStorageNum().longValue());
map.put(ProductIndexEsField.islimited, productIndexBO.getIslimited());
map.put(ProductIndexEsField.isnew, productIndexBO.getIsnew());
map.put(ProductIndexEsField.colorIds, productIndexBO.getColorIds());
map.put(ProductIndexEsField.colorNames, productIndexBO.getColorNames());
map.put(ProductIndexEsField.sizeIds, productIndexBO.getSizeIds());
... ... @@ -129,7 +124,6 @@ public class ProductIndexBOToMapService {
map.put(ProductIndexEsField.isSoonSoldOut, productIndexBO.getIsSoonSoldOut());
map.put(ProductIndexEsField.isSoldOut, productIndexBO.getIsSoldOut());
map.put(ProductIndexEsField.soldOut, productIndexBO.getSoldOut());
map.put(ProductIndexEsField.isDiscount, productIndexBO.getIsDiscount());
map.put(ProductIndexEsField.sortWeight, productIndexBO.getSortWeight());
map.put(ProductIndexEsField.brandWeight, productIndexBO.getBrandWeight());
map.put(ProductIndexEsField.shopWeight, productIndexBO.getShopWeight());
... ... @@ -148,11 +142,9 @@ public class ProductIndexBOToMapService {
map.put(ProductIndexEsField.isGlobal, productIndexBO.getIsGlobal());
map.put(ProductIndexEsField.appType, productIndexBO.getAppType());
map.put(ProductIndexEsField.studentPrice, productIndexBO.getStudentPrice());
map.put(ProductIndexEsField.isStudentPrice, productIndexBO.getIsStudentPrice());
map.put(ProductIndexEsField.isInstalment, productIndexBO.getIsInstalment());
map.put(ProductIndexEsField.countryId, productIndexBO.getCountryId());
map.put(ProductIndexEsField.isstudentrebate, productIndexBO.getIsStudentRebate());
map.put(ProductIndexEsField.isSeckill, productIndexBO.getIsSeckill());
map.put(ProductIndexEsField.storageUpdateTime, productIndexBO.getStorageUpdateTime());
... ... @@ -196,28 +188,24 @@ public class ProductIndexBOToMapService {
map.put(ProductIndexEsField.bundleType, productIndexBO.getBundleType());
map.put(ProductIndexEsField.heatValue, productIndexBO.getHeatValue());
map.put(ProductIndexEsField.skuIds, productIndexBO.getSkuIds());
map.put(ProductIndexEsField.priceUpdateTime, productIndexBO.getPriceUpdateTime());
map.put(ProductIndexEsField.activeValue, productIndexBO.getActiveValue());
map.put(ProductIndexEsField.transferValue, productIndexBO.getTransferValue());
map.put(ProductIndexEsField.giveValue, productIndexBO.getGiveValue());
map.put(ProductIndexEsField.profitValue, productIndexBO.getProfitValue());
map.put(ProductIndexEsField.promotionTitle, productIndexBO.getPromotionTitles());
map.put(ProductIndexEsField.lastReducePriceTime, productIndexBO.getLastReducePriceTime());
map.put(ProductIndexEsField.couponLimitStatus, productIndexBO.getCouponLimitStatus());
map.put(ProductIndexEsField.isFobbiden, productIndexBO.getIsFobbiden());
map.put(ProductIndexEsField.storeShowStatus, productIndexBO.getStoreShowStatus());
map.put(ProductIndexEsField.toAddScore, productIndexBO.getToAddScore());
map.put(ProductIndexEsField.specialSearchField, productIndexBO.getSpecialSearchField());
map.put(ProductIndexEsField.specialSearchFieldPrice, productIndexBO.getSpecialSearchFieldPrice());
map.put(ProductIndexEsField.specialSearchFieldVideo, productIndexBO.getSpecialSearchFieldVideo());
map.put(ProductIndexEsField.ctrValue, productIndexBO.getCtrValue());
map.put(ProductIndexEsField.flowType, productIndexBO.getFlowType());
map.put(ProductIndexEsField.sevendayMoney,productIndexBO.getSevendayMoney());
map.put("isLatestReducePrice", productIndexBO.getIsLatestReducePrice());
map.put(ProductIndexEsField.ctrValue, productIndexBO.getCtrValue());
map.put(ProductIndexEsField.flowType, productIndexBO.getFlowType());
map.put(ProductIndexEsField.sevendayMoney, productIndexBO.getSevendayMoney());
return map;
}
... ...
... ... @@ -76,6 +76,18 @@ public class ProductPriceBOLogicService {
// 1、计算并重设vip相关价格
vipPriceLogicService.fillProductPriceVipPrice(productPriceBO);
// 2、计算折扣相关
this.fillProductPriceBODiscount(productPriceBO);
// 3、设置SpecialSearchFieldPric
productPriceBO.setSpecialSearchFieldPrice(specialDealLogicService.getSpecialSearchFieldPrice(productPriceBO));
// 4、设置最新降价
productPriceBO.setIsLatestReducePrice(this.isLatestReducePrice(productPrice, productPriceHistory));
}
/**
* 计算价格的折扣相关逻辑
* @param productPriceBO
*/
public void fillProductPriceBODiscount(ProductPriceBO productPriceBO){
double salesPrice = this.getDoubleFromBigDecimal(productPriceBO.getSalesPrice());
double marketPrice = this.getDoubleFromBigDecimal(productPriceBO.getMarketPrice());
productPriceBO.setIsDiscount(salesPrice < marketPrice ? "Y" : "N");
... ... @@ -89,16 +101,8 @@ public class ProductPriceBOLogicService {
productPriceBO.setPromotionDiscountInt((long) promotionDiscountInt);
double promotionDiscount = this.divide(3, productPriceBO.getSalesPrice(), productPriceBO.getMarketPrice());
productPriceBO.setPromotionDiscount(this.getBigDecimalFromDouble(promotionDiscount));
// 3、设置学生价相关属性
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");
// 4、设置
productPriceBO.setSpecialSearchFieldPrice(specialDealLogicService.getSpecialSearchFieldPrice(productPriceBO));
// 5、设置最新降价
productPriceBO.setIsLatestReducePrice(this.isLatestReducePrice(productPrice, productPriceHistory));
}
private String isLatestReducePrice(ProductPrice productPrice, ProductPriceHistory productPriceHistory) {
BigDecimal newPrice = productPrice.getCurrentPrice();
if (newPrice == null || productPriceHistory == null) {
... ... @@ -137,12 +141,12 @@ public class ProductPriceBOLogicService {
}
return new BigDecimal(d);
}
/**
* @计算isNew
* @首次上架7天内展示且折扣率大于等于88折)
*/
public boolean isNew(Integer firstShelveTime, BigDecimal marketPrice, BigDecimal salesPrice) {
private boolean isNew(Integer firstShelveTime, BigDecimal marketPrice, BigDecimal salesPrice) {
try {
if (firstShelveTime == null || firstShelveTime <= 0 || salesPrice == null || marketPrice == null) {
return false;
... ...
... ... @@ -6,7 +6,6 @@ import java.util.stream.Collectors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
... ... @@ -51,7 +50,7 @@ public class ProductPriceBuilder implements ViewBuilder {
}
private void buildProductIndexBO(ProductIndexBO productIndexBO, ProductPriceBO productPriceBO) {
BeanUtils.copyProperties(productPriceBO, productIndexBO);
productIndexBO.setProductPriceBO(productPriceBO);
//全量建索引时单独设置isnew
productPriceBOLogicService.buildisNew(productIndexBO, productPriceBO);
}
... ...