Authored by unknown

fix vipDiscountType相关逻辑

... ... @@ -6,229 +6,226 @@ import java.math.BigDecimal;
public class ProductPriceBO {
private BigDecimal marketPrice;
private BigDecimal salesPrice;
private BigDecimal vipPrice;
private Integer vipDiscountType;
private BigDecimal vip1Price;
private BigDecimal vip2Price;
private BigDecimal vip3Price;
private BigDecimal studentPrice;
private BigDecimal studentCoinRate;
private Integer updateTime;
private Integer lastReducePriceTime;
private BigDecimal basicPrice;
private Integer productVipStatus;
private BigDecimal vipDiscount;
private Integer currentVipDiscountType;
// others
private String isDiscount;
private String specialoffer;
private Long promotionDiscountInt;
private BigDecimal promotionDiscount;
private String isStudentPrice;
private String isstudentrebate;
private String vipLevels;
public ProductPriceBO(ProductPrice productPrice) {
super();
this.marketPrice = productPrice.getRetailPrice();// 吊牌价
BigDecimal currentPrice = productPrice.getCurrentPrice();// 综合了变价计划和商品售价的结果,生成的逻辑完全由后台控制。
if (currentPrice != null && currentPrice.compareTo(BigDecimal.ZERO) == 1) {
this.salesPrice = currentPrice;
} else {
this.salesPrice = productPrice.getSalesPrice();// 兜底方案
}
this.vipPrice = productPrice.getVipPrice();
this.vipDiscountType = productPrice.getVipDiscountType();
this.vip1Price = productPrice.getVip1Price();
this.vip2Price = productPrice.getVip2Price();
this.vip3Price = productPrice.getVip3Price();
this.studentPrice = productPrice.getStudentPrice();
this.studentCoinRate = productPrice.getStudentCoinRate();
this.updateTime = productPrice.getUpdateTime();
this.lastReducePriceTime = productPrice.getLastReducePriceTime();
this.basicPrice = productPrice.getBasicPrice();
this.productVipStatus = productPrice.getProductVipStatus();
this.vipDiscount = productPrice.getVipDiscount();
this.currentVipDiscountType = productPrice.getCurrentVipDiscountType();
}
public Integer getCurrentVipDiscountType() {
return currentVipDiscountType;
}
public void setCurrentVipDiscountType(Integer currentVipDiscountType) {
this.currentVipDiscountType = currentVipDiscountType;
}
public BigDecimal getVipDiscount() {
return vipDiscount;
}
public void setVipDiscount(BigDecimal vipDiscount) {
this.vipDiscount = vipDiscount;
}
public Integer getLastReducePriceTime() {
return lastReducePriceTime;
}
public void setLastReducePriceTime(Integer lastReducePriceTime) {
this.lastReducePriceTime = lastReducePriceTime;
}
public BigDecimal getMarketPrice() {
return marketPrice;
}
public void setMarketPrice(BigDecimal marketPrice) {
this.marketPrice = marketPrice;
}
public BigDecimal getSalesPrice() {
return salesPrice;
}
public void setSalesPrice(BigDecimal salesPrice) {
this.salesPrice = salesPrice;
}
public BigDecimal getVipPrice() {
return vipPrice;
}
public void setVipPrice(BigDecimal vipPrice) {
this.vipPrice = vipPrice;
}
public Integer getVipDiscountType() {
return vipDiscountType;
}
public void setVipDiscountType(Integer vipDiscountType) {
this.vipDiscountType = vipDiscountType;
}
public BigDecimal getVip1Price() {
return vip1Price;
}
public void setVip1Price(BigDecimal vip1Price) {
this.vip1Price = vip1Price;
}
public BigDecimal getVip2Price() {
return vip2Price;
}
public void setVip2Price(BigDecimal vip2Price) {
this.vip2Price = vip2Price;
}
public BigDecimal getVip3Price() {
return vip3Price;
}
public void setVip3Price(BigDecimal vip3Price) {
this.vip3Price = vip3Price;
}
public BigDecimal getStudentPrice() {
return studentPrice;
}
public void setStudentPrice(BigDecimal studentPrice) {
this.studentPrice = studentPrice;
}
public BigDecimal getStudentCoinRate() {
return studentCoinRate;
}
public void setStudentCoinRate(BigDecimal studentCoinRate) {
this.studentCoinRate = studentCoinRate;
}
public String getIsDiscount() {
return isDiscount;
}
private BigDecimal marketPrice;
private BigDecimal vipPrice;
private BigDecimal vip1Price;
private BigDecimal vip2Price;
private BigDecimal vip3Price;
private BigDecimal studentPrice;
private BigDecimal studentCoinRate;
private Integer updateTime;
private Integer lastReducePriceTime;
private BigDecimal basicPrice;
private Integer productVipStatus;
private BigDecimal vipDiscount;
private BigDecimal salesPrice;// 构造的时候使用currentSalesPrice构建
private Integer vipDiscountType;// 构造的时候使用currentVipDiscountType构建
// others
private String isDiscount;
private String specialoffer;
private Long promotionDiscountInt;
private BigDecimal promotionDiscount;
private String isStudentPrice;
private String isstudentrebate;
private String vipLevels;
public ProductPriceBO(ProductPrice productPrice) {
super();
// 使用currentSalesPrice和currentVipDiscountType构建salesPrice和vipDiscountType【综合了变价计划和商品本身价格的结果,生成的逻辑完全由后台控制】
BigDecimal currentPrice = productPrice.getCurrentPrice();//
if (currentPrice != null && currentPrice.compareTo(BigDecimal.ZERO) == 1) {
this.salesPrice = currentPrice;
} else {
this.salesPrice = productPrice.getSalesPrice();// 兜底方案
}
Integer currentVipDiscountType = productPrice.getCurrentVipDiscountType();
if (currentVipDiscountType != null) {
this.vipDiscountType = currentVipDiscountType;
} else {
this.vipDiscountType = productPrice.getVipDiscountType();
}
this.marketPrice = productPrice.getRetailPrice();// 吊牌价
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.updateTime = productPrice.getUpdateTime();
this.lastReducePriceTime = productPrice.getLastReducePriceTime();
this.basicPrice = productPrice.getBasicPrice();
this.productVipStatus = productPrice.getProductVipStatus();
this.vipDiscount = productPrice.getVipDiscount();
}
public BigDecimal getVipDiscount() {
return vipDiscount;
}
public void setVipDiscount(BigDecimal vipDiscount) {
this.vipDiscount = vipDiscount;
}
public Integer getLastReducePriceTime() {
return lastReducePriceTime;
}
public void setLastReducePriceTime(Integer lastReducePriceTime) {
this.lastReducePriceTime = lastReducePriceTime;
}
public BigDecimal getMarketPrice() {
return marketPrice;
}
public void setMarketPrice(BigDecimal marketPrice) {
this.marketPrice = marketPrice;
}
public BigDecimal getSalesPrice() {
return salesPrice;
}
public void setSalesPrice(BigDecimal salesPrice) {
this.salesPrice = salesPrice;
}
public BigDecimal getVipPrice() {
return vipPrice;
}
public void setVipPrice(BigDecimal vipPrice) {
this.vipPrice = vipPrice;
}
public Integer getVipDiscountType() {
return vipDiscountType;
}
public void setVipDiscountType(Integer vipDiscountType) {
this.vipDiscountType = vipDiscountType;
}
public BigDecimal getVip1Price() {
return vip1Price;
}
public void setVip1Price(BigDecimal vip1Price) {
this.vip1Price = vip1Price;
}
public BigDecimal getVip2Price() {
return vip2Price;
}
public void setVip2Price(BigDecimal vip2Price) {
this.vip2Price = vip2Price;
}
public BigDecimal getVip3Price() {
return vip3Price;
}
public void setVip3Price(BigDecimal vip3Price) {
this.vip3Price = vip3Price;
}
public BigDecimal getStudentPrice() {
return studentPrice;
}
public void setStudentPrice(BigDecimal studentPrice) {
this.studentPrice = studentPrice;
}
public BigDecimal getStudentCoinRate() {
return studentCoinRate;
}
public void setStudentCoinRate(BigDecimal studentCoinRate) {
this.studentCoinRate = studentCoinRate;
}
public String getIsDiscount() {
return isDiscount;
}
public void setIsDiscount(String isDiscount) {
this.isDiscount = isDiscount;
}
public String getSpecialoffer() {
return specialoffer;
}
public void setIsDiscount(String isDiscount) {
this.isDiscount = isDiscount;
}
public void setSpecialoffer(String specialoffer) {
this.specialoffer = specialoffer;
}
public String getSpecialoffer() {
return specialoffer;
}
public Long getPromotionDiscountInt() {
return promotionDiscountInt;
}
public void setSpecialoffer(String specialoffer) {
this.specialoffer = specialoffer;
}
public void setPromotionDiscountInt(Long promotionDiscountInt) {
this.promotionDiscountInt = promotionDiscountInt;
}
public Long getPromotionDiscountInt() {
return promotionDiscountInt;
}
public BigDecimal getPromotionDiscount() {
return promotionDiscount;
}
public void setPromotionDiscountInt(Long promotionDiscountInt) {
this.promotionDiscountInt = promotionDiscountInt;
}
public void setPromotionDiscount(BigDecimal promotionDiscount) {
this.promotionDiscount = promotionDiscount;
}
public BigDecimal getPromotionDiscount() {
return promotionDiscount;
}
public String getIsStudentPrice() {
return isStudentPrice;
}
public void setPromotionDiscount(BigDecimal promotionDiscount) {
this.promotionDiscount = promotionDiscount;
}
public void setIsStudentPrice(String isStudentPrice) {
this.isStudentPrice = isStudentPrice;
}
public String getIsStudentPrice() {
return isStudentPrice;
}
public String getIsstudentrebate() {
return isstudentrebate;
}
public void setIsStudentPrice(String isStudentPrice) {
this.isStudentPrice = isStudentPrice;
}
public void setIsstudentrebate(String isstudentrebate) {
this.isstudentrebate = isstudentrebate;
}
public String getIsstudentrebate() {
return isstudentrebate;
}
public String getVipLevels() {
return vipLevels;
}
public void setIsstudentrebate(String isstudentrebate) {
this.isstudentrebate = isstudentrebate;
}
public void setVipLevels(String vipLevels) {
this.vipLevels = vipLevels;
}
public String getVipLevels() {
return vipLevels;
}
public Integer getUpdateTime() {
return updateTime;
}
public void setVipLevels(String vipLevels) {
this.vipLevels = vipLevels;
}
public void setUpdateTime(Integer updateTime) {
this.updateTime = updateTime;
}
public Integer getUpdateTime() {
return updateTime;
}
public BigDecimal getBasicPrice() {
return basicPrice;
}
public void setUpdateTime(Integer updateTime) {
this.updateTime = updateTime;
}
public void setBasicPrice(BigDecimal basicPrice) {
this.basicPrice = basicPrice;
}
public BigDecimal getBasicPrice() {
return basicPrice;
}
public Integer getProductVipStatus() {
return productVipStatus;
}
public void setBasicPrice(BigDecimal basicPrice) {
this.basicPrice = basicPrice;
}
public Integer getProductVipStatus() {
return productVipStatus;
}
public void setProductVipStatus(Integer productVipStatus) {
this.productVipStatus = productVipStatus;
}
public void setProductVipStatus(Integer productVipStatus) {
this.productVipStatus = productVipStatus;
}
}
... ...
... ... @@ -12,60 +12,61 @@ import java.util.List;
@Service
public class VipPriceLogicService {
/**
* 设置计划的vip价格
*/
public void fillProductPricePlanVipPrice(ProductPricePlan p){
VipPriceBO vipPriceBO = this.getVipPriceBO(p.getCurrentSaleprice(), p.getVipPrice(), p.getVip1Price(), p.getVip2Price(), p.getVip3Price(), p.getVipDiscountType(), p.getVipDiscount());
public void fillProductPricePlanVipPrice(ProductPricePlan p) {
VipPriceBO vipPriceBO = this.getVipPriceBO(p.getCurrentSaleprice(), p.getVipDiscountType(), p.getVipPrice(), p.getVip1Price(), p.getVip2Price(), p.getVip3Price(),
p.getVipDiscount());
p.setVip1Price(vipPriceBO.getVip1PriceBigDecimal());
p.setVip2Price(vipPriceBO.getVip2PriceBigDecimal());
p.setVip3Price(vipPriceBO.getVip3PriceBigDecimal());
}
/**
* 计算并重设vip相关价格
*/
public void fillProductPriceVipPrice(ProductPriceBO productPriceBO){
VipPriceBO vipPriceBO = this.getVipPriceBO(productPriceBO.getSalesPrice(), productPriceBO.getVipPrice(), productPriceBO.getVip1Price(), productPriceBO.getVip2Price(), productPriceBO.getVip3Price(), productPriceBO.getCurrentVipDiscountType(),
productPriceBO.getVipDiscount());
public void fillProductPriceVipPrice(ProductPriceBO productPriceBO) {
/**
* salesPrice等于productPrice表的currentPrice,
* type是productPrice表的currentVipDiscountType
*/
VipPriceBO vipPriceBO = this.getVipPriceBO(productPriceBO.getSalesPrice(), productPriceBO.getVipDiscountType(), productPriceBO.getVipPrice(),
productPriceBO.getVip1Price(), productPriceBO.getVip2Price(), productPriceBO.getVip3Price(), productPriceBO.getVipDiscount());
productPriceBO.setVip1Price(vipPriceBO.getVip1PriceBigDecimal());
productPriceBO.setVip2Price(vipPriceBO.getVip2PriceBigDecimal());
productPriceBO.setVip3Price(vipPriceBO.getVip3PriceBigDecimal());
//设置vipLevels
double salesPrice = this.getDoubleFromBigDecimal(productPriceBO.getSalesPrice());
double vip1Price = productPriceBO.getVip1Price().doubleValue();
double vip2Price = productPriceBO.getVip2Price().doubleValue();
double vip3Price = productPriceBO.getVip3Price().doubleValue();
List<String> vipLevels = new ArrayList<String>();
if (vip1Price > 0 && vip1Price < salesPrice) {
vipLevels.add("1");
}
if (vip2Price > 0 && vip2Price < salesPrice) {
vipLevels.add("2");
}
if (vip3Price > 0 && vip3Price < salesPrice) {
vipLevels.add("3");
}
productPriceBO.setVipLevels(StringUtils.join(vipLevels, ","));
// 设置vipLevels
double salesPrice = this.getDoubleFromBigDecimal(productPriceBO.getSalesPrice());
double vip1Price = this.getDoubleFromBigDecimal(productPriceBO.getVip1Price());
double vip2Price = this.getDoubleFromBigDecimal(productPriceBO.getVip2Price());
double vip3Price = this.getDoubleFromBigDecimal(productPriceBO.getVip3Price());
List<String> vipLevels = new ArrayList<String>();
if (vip1Price > 0 && vip1Price < salesPrice) {
vipLevels.add("1");
}
if (vip2Price > 0 && vip2Price < salesPrice) {
vipLevels.add("2");
}
if (vip3Price > 0 && vip3Price < salesPrice) {
vipLevels.add("3");
}
productPriceBO.setVipLevels(StringUtils.join(vipLevels, ","));
}
/**
* salesPrice等于productPrice表的currentPrice,type是productPrice表的currentVipDiscountType
*/
private VipPriceBO getVipPriceBO(BigDecimal salesPrice, BigDecimal vipPrice, BigDecimal vip1Price, BigDecimal vip2Price, BigDecimal vip3Price, Integer type,
BigDecimal vipDiscount) {
double salesPriceDoubleCeil = Math.ceil(this.getDoubleFromBigDecimal(salesPrice));
private VipPriceBO getVipPriceBO(BigDecimal currentSalesPrice, Integer currentVipDiscountType, BigDecimal vipPrice, BigDecimal vip1Price, BigDecimal vip2Price,
BigDecimal vip3Price, BigDecimal vipDiscount) {
double salesPriceDoubleCeil = Math.ceil(this.getDoubleFromBigDecimal(currentSalesPrice));
// 默认取销售价
double vip1PriceResult = salesPriceDoubleCeil;
double vip2PriceResult = salesPriceDoubleCeil;
double vip3PriceResult = salesPriceDoubleCeil;
if (type == null) {
if (currentVipDiscountType == null) {
return new VipPriceBO(vip1PriceResult, vip2PriceResult, vip3PriceResult);
}
switch (type) {
switch (currentVipDiscountType) {
case 1:
vip1PriceResult = Double.valueOf(String.format("%.2f", salesPriceDoubleCeil * 0.95));
vip2PriceResult = Double.valueOf(String.format("%.2f", salesPriceDoubleCeil * 0.9));
... ...
... ... @@ -67,7 +67,7 @@ public class ProductPriceBuilder implements ViewBuilder {
// 2、计算折扣相关
double salesPrice = this.getDoubleFromBigDecimal(productPriceBO.getSalesPrice());
double marketPrice = this.getDoubleFromBigDecimal(productPriceBO.getMarketPrice());
productPriceBO.setIsDiscount(salesPrice < marketPrice ? "Y" : "N");
productPriceBO.setIsDiscount(salesPrice < marketPrice ? "Y" : "N");
double specialOffer = this.divide(1, productPriceBO.getSalesPrice(), productPriceBO.getMarketPrice());
if (specialOffer <= 0.5) {
productPriceBO.setSpecialoffer("Y");
... ...