Authored by unknown

fix vipDiscountType相关逻辑

... ... @@ -7,9 +7,7 @@ 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;
... ... @@ -20,7 +18,9 @@ public class ProductPriceBO {
private BigDecimal basicPrice;
private Integer productVipStatus;
private BigDecimal vipDiscount;
private Integer currentVipDiscountType;
private BigDecimal salesPrice;// 构造的时候使用currentSalesPrice构建
private Integer vipDiscountType;// 构造的时候使用currentVipDiscountType构建
// others
private String isDiscount;
... ... @@ -33,15 +33,21 @@ public class ProductPriceBO {
public ProductPriceBO(ProductPrice productPrice) {
super();
this.marketPrice = productPrice.getRetailPrice();// 吊牌价
BigDecimal currentPrice = productPrice.getCurrentPrice();// 综合了变价计划和商品售价的结果,生成的逻辑完全由后台控制。
// 使用currentSalesPrice和currentVipDiscountType构建salesPrice和vipDiscountType【综合了变价计划和商品本身价格的结果,生成的逻辑完全由后台控制】
BigDecimal currentPrice = productPrice.getCurrentPrice();//
if (currentPrice != null && currentPrice.compareTo(BigDecimal.ZERO) == 1) {
this.salesPrice = currentPrice;
} else {
this.salesPrice = productPrice.getSalesPrice();// 兜底方案
}
this.vipPrice = productPrice.getVipPrice();
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();
... ... @@ -52,15 +58,6 @@ public class ProductPriceBO {
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() {
... ...
... ... @@ -16,8 +16,9 @@ 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());
... ... @@ -26,18 +27,21 @@ public class VipPriceLogicService {
/**
* 计算并重设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
// 设置vipLevels
double salesPrice = this.getDoubleFromBigDecimal(productPriceBO.getSalesPrice());
double vip1Price = productPriceBO.getVip1Price().doubleValue();
double vip2Price = productPriceBO.getVip2Price().doubleValue();
double vip3Price = productPriceBO.getVip3Price().doubleValue();
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");
... ... @@ -52,20 +56,17 @@ public class VipPriceLogicService {
}
/**
* 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));
... ...