Authored by unknown

fix vipDiscountType相关逻辑

@@ -6,229 +6,226 @@ import java.math.BigDecimal; @@ -6,229 +6,226 @@ import java.math.BigDecimal;
6 6
7 public class ProductPriceBO { 7 public class ProductPriceBO {
8 8
9 - private BigDecimal marketPrice;  
10 - private BigDecimal salesPrice;  
11 - private BigDecimal vipPrice;  
12 - private Integer vipDiscountType;  
13 - private BigDecimal vip1Price;  
14 - private BigDecimal vip2Price;  
15 - private BigDecimal vip3Price;  
16 - private BigDecimal studentPrice;  
17 - private BigDecimal studentCoinRate;  
18 - private Integer updateTime;  
19 - private Integer lastReducePriceTime;  
20 - private BigDecimal basicPrice;  
21 - private Integer productVipStatus;  
22 - private BigDecimal vipDiscount;  
23 - private Integer currentVipDiscountType;  
24 -  
25 - // others  
26 - private String isDiscount;  
27 - private String specialoffer;  
28 - private Long promotionDiscountInt;  
29 - private BigDecimal promotionDiscount;  
30 - private String isStudentPrice;  
31 - private String isstudentrebate;  
32 - private String vipLevels;  
33 -  
34 - public ProductPriceBO(ProductPrice productPrice) {  
35 - super();  
36 - this.marketPrice = productPrice.getRetailPrice();// 吊牌价  
37 - BigDecimal currentPrice = productPrice.getCurrentPrice();// 综合了变价计划和商品售价的结果,生成的逻辑完全由后台控制。  
38 - if (currentPrice != null && currentPrice.compareTo(BigDecimal.ZERO) == 1) {  
39 - this.salesPrice = currentPrice;  
40 - } else {  
41 - this.salesPrice = productPrice.getSalesPrice();// 兜底方案  
42 - }  
43 - this.vipPrice = productPrice.getVipPrice();  
44 - this.vipDiscountType = productPrice.getVipDiscountType();  
45 - this.vip1Price = productPrice.getVip1Price();  
46 - this.vip2Price = productPrice.getVip2Price();  
47 - this.vip3Price = productPrice.getVip3Price();  
48 - this.studentPrice = productPrice.getStudentPrice();  
49 - this.studentCoinRate = productPrice.getStudentCoinRate();  
50 - this.updateTime = productPrice.getUpdateTime();  
51 - this.lastReducePriceTime = productPrice.getLastReducePriceTime();  
52 - this.basicPrice = productPrice.getBasicPrice();  
53 - this.productVipStatus = productPrice.getProductVipStatus();  
54 - this.vipDiscount = productPrice.getVipDiscount();  
55 - this.currentVipDiscountType = productPrice.getCurrentVipDiscountType();  
56 - }  
57 -  
58 - public Integer getCurrentVipDiscountType() {  
59 - return currentVipDiscountType;  
60 - }  
61 -  
62 - public void setCurrentVipDiscountType(Integer currentVipDiscountType) {  
63 - this.currentVipDiscountType = currentVipDiscountType;  
64 - }  
65 -  
66 - public BigDecimal getVipDiscount() {  
67 - return vipDiscount;  
68 - }  
69 -  
70 - public void setVipDiscount(BigDecimal vipDiscount) {  
71 - this.vipDiscount = vipDiscount;  
72 - }  
73 -  
74 - public Integer getLastReducePriceTime() {  
75 - return lastReducePriceTime;  
76 - }  
77 -  
78 - public void setLastReducePriceTime(Integer lastReducePriceTime) {  
79 - this.lastReducePriceTime = lastReducePriceTime;  
80 - }  
81 -  
82 - public BigDecimal getMarketPrice() {  
83 - return marketPrice;  
84 - }  
85 -  
86 - public void setMarketPrice(BigDecimal marketPrice) {  
87 - this.marketPrice = marketPrice;  
88 - }  
89 -  
90 - public BigDecimal getSalesPrice() {  
91 - return salesPrice;  
92 - }  
93 -  
94 - public void setSalesPrice(BigDecimal salesPrice) {  
95 - this.salesPrice = salesPrice;  
96 - }  
97 -  
98 - public BigDecimal getVipPrice() {  
99 - return vipPrice;  
100 - }  
101 -  
102 - public void setVipPrice(BigDecimal vipPrice) {  
103 - this.vipPrice = vipPrice;  
104 - }  
105 -  
106 - public Integer getVipDiscountType() {  
107 - return vipDiscountType;  
108 - }  
109 -  
110 - public void setVipDiscountType(Integer vipDiscountType) {  
111 - this.vipDiscountType = vipDiscountType;  
112 - }  
113 -  
114 - public BigDecimal getVip1Price() {  
115 - return vip1Price;  
116 - }  
117 -  
118 - public void setVip1Price(BigDecimal vip1Price) {  
119 - this.vip1Price = vip1Price;  
120 - }  
121 -  
122 - public BigDecimal getVip2Price() {  
123 - return vip2Price;  
124 - }  
125 -  
126 - public void setVip2Price(BigDecimal vip2Price) {  
127 - this.vip2Price = vip2Price;  
128 - }  
129 -  
130 - public BigDecimal getVip3Price() {  
131 - return vip3Price;  
132 - }  
133 -  
134 - public void setVip3Price(BigDecimal vip3Price) {  
135 - this.vip3Price = vip3Price;  
136 - }  
137 -  
138 - public BigDecimal getStudentPrice() {  
139 - return studentPrice;  
140 - }  
141 -  
142 - public void setStudentPrice(BigDecimal studentPrice) {  
143 - this.studentPrice = studentPrice;  
144 - }  
145 -  
146 - public BigDecimal getStudentCoinRate() {  
147 - return studentCoinRate;  
148 - }  
149 -  
150 - public void setStudentCoinRate(BigDecimal studentCoinRate) {  
151 - this.studentCoinRate = studentCoinRate;  
152 - }  
153 -  
154 - public String getIsDiscount() {  
155 - return isDiscount;  
156 - } 9 + private BigDecimal marketPrice;
  10 + private BigDecimal vipPrice;
  11 + private BigDecimal vip1Price;
  12 + private BigDecimal vip2Price;
  13 + private BigDecimal vip3Price;
  14 + private BigDecimal studentPrice;
  15 + private BigDecimal studentCoinRate;
  16 + private Integer updateTime;
  17 + private Integer lastReducePriceTime;
  18 + private BigDecimal basicPrice;
  19 + private Integer productVipStatus;
  20 + private BigDecimal vipDiscount;
  21 +
  22 + private BigDecimal salesPrice;// 构造的时候使用currentSalesPrice构建
  23 + private Integer vipDiscountType;// 构造的时候使用currentVipDiscountType构建
  24 +
  25 + // others
  26 + private String isDiscount;
  27 + private String specialoffer;
  28 + private Long promotionDiscountInt;
  29 + private BigDecimal promotionDiscount;
  30 + private String isStudentPrice;
  31 + private String isstudentrebate;
  32 + private String vipLevels;
  33 +
  34 + public ProductPriceBO(ProductPrice productPrice) {
  35 + super();
  36 + // 使用currentSalesPrice和currentVipDiscountType构建salesPrice和vipDiscountType【综合了变价计划和商品本身价格的结果,生成的逻辑完全由后台控制】
  37 + BigDecimal currentPrice = productPrice.getCurrentPrice();//
  38 + if (currentPrice != null && currentPrice.compareTo(BigDecimal.ZERO) == 1) {
  39 + this.salesPrice = currentPrice;
  40 + } else {
  41 + this.salesPrice = productPrice.getSalesPrice();// 兜底方案
  42 + }
  43 + Integer currentVipDiscountType = productPrice.getCurrentVipDiscountType();
  44 + if (currentVipDiscountType != null) {
  45 + this.vipDiscountType = currentVipDiscountType;
  46 + } else {
  47 + this.vipDiscountType = productPrice.getVipDiscountType();
  48 + }
  49 + this.marketPrice = productPrice.getRetailPrice();// 吊牌价
  50 + this.vipPrice = productPrice.getVipPrice();
  51 + this.vip1Price = productPrice.getVip1Price();
  52 + this.vip2Price = productPrice.getVip2Price();
  53 + this.vip3Price = productPrice.getVip3Price();
  54 + this.studentPrice = productPrice.getStudentPrice();
  55 + this.studentCoinRate = productPrice.getStudentCoinRate();
  56 + this.updateTime = productPrice.getUpdateTime();
  57 + this.lastReducePriceTime = productPrice.getLastReducePriceTime();
  58 + this.basicPrice = productPrice.getBasicPrice();
  59 + this.productVipStatus = productPrice.getProductVipStatus();
  60 + this.vipDiscount = productPrice.getVipDiscount();
  61 + }
  62 +
  63 + public BigDecimal getVipDiscount() {
  64 + return vipDiscount;
  65 + }
  66 +
  67 + public void setVipDiscount(BigDecimal vipDiscount) {
  68 + this.vipDiscount = vipDiscount;
  69 + }
  70 +
  71 + public Integer getLastReducePriceTime() {
  72 + return lastReducePriceTime;
  73 + }
  74 +
  75 + public void setLastReducePriceTime(Integer lastReducePriceTime) {
  76 + this.lastReducePriceTime = lastReducePriceTime;
  77 + }
  78 +
  79 + public BigDecimal getMarketPrice() {
  80 + return marketPrice;
  81 + }
  82 +
  83 + public void setMarketPrice(BigDecimal marketPrice) {
  84 + this.marketPrice = marketPrice;
  85 + }
  86 +
  87 + public BigDecimal getSalesPrice() {
  88 + return salesPrice;
  89 + }
  90 +
  91 + public void setSalesPrice(BigDecimal salesPrice) {
  92 + this.salesPrice = salesPrice;
  93 + }
  94 +
  95 + public BigDecimal getVipPrice() {
  96 + return vipPrice;
  97 + }
  98 +
  99 + public void setVipPrice(BigDecimal vipPrice) {
  100 + this.vipPrice = vipPrice;
  101 + }
  102 +
  103 + public Integer getVipDiscountType() {
  104 + return vipDiscountType;
  105 + }
  106 +
  107 + public void setVipDiscountType(Integer vipDiscountType) {
  108 + this.vipDiscountType = vipDiscountType;
  109 + }
  110 +
  111 + public BigDecimal getVip1Price() {
  112 + return vip1Price;
  113 + }
  114 +
  115 + public void setVip1Price(BigDecimal vip1Price) {
  116 + this.vip1Price = vip1Price;
  117 + }
  118 +
  119 + public BigDecimal getVip2Price() {
  120 + return vip2Price;
  121 + }
  122 +
  123 + public void setVip2Price(BigDecimal vip2Price) {
  124 + this.vip2Price = vip2Price;
  125 + }
  126 +
  127 + public BigDecimal getVip3Price() {
  128 + return vip3Price;
  129 + }
  130 +
  131 + public void setVip3Price(BigDecimal vip3Price) {
  132 + this.vip3Price = vip3Price;
  133 + }
  134 +
  135 + public BigDecimal getStudentPrice() {
  136 + return studentPrice;
  137 + }
  138 +
  139 + public void setStudentPrice(BigDecimal studentPrice) {
  140 + this.studentPrice = studentPrice;
  141 + }
  142 +
  143 + public BigDecimal getStudentCoinRate() {
  144 + return studentCoinRate;
  145 + }
  146 +
  147 + public void setStudentCoinRate(BigDecimal studentCoinRate) {
  148 + this.studentCoinRate = studentCoinRate;
  149 + }
  150 +
  151 + public String getIsDiscount() {
  152 + return isDiscount;
  153 + }
  154 +
  155 + public void setIsDiscount(String isDiscount) {
  156 + this.isDiscount = isDiscount;
  157 + }
  158 +
  159 + public String getSpecialoffer() {
  160 + return specialoffer;
  161 + }
157 162
158 - public void setIsDiscount(String isDiscount) {  
159 - this.isDiscount = isDiscount;  
160 - } 163 + public void setSpecialoffer(String specialoffer) {
  164 + this.specialoffer = specialoffer;
  165 + }
161 166
162 - public String getSpecialoffer() {  
163 - return specialoffer;  
164 - } 167 + public Long getPromotionDiscountInt() {
  168 + return promotionDiscountInt;
  169 + }
165 170
166 - public void setSpecialoffer(String specialoffer) {  
167 - this.specialoffer = specialoffer;  
168 - } 171 + public void setPromotionDiscountInt(Long promotionDiscountInt) {
  172 + this.promotionDiscountInt = promotionDiscountInt;
  173 + }
169 174
170 - public Long getPromotionDiscountInt() {  
171 - return promotionDiscountInt;  
172 - } 175 + public BigDecimal getPromotionDiscount() {
  176 + return promotionDiscount;
  177 + }
173 178
174 - public void setPromotionDiscountInt(Long promotionDiscountInt) {  
175 - this.promotionDiscountInt = promotionDiscountInt;  
176 - } 179 + public void setPromotionDiscount(BigDecimal promotionDiscount) {
  180 + this.promotionDiscount = promotionDiscount;
  181 + }
177 182
178 - public BigDecimal getPromotionDiscount() {  
179 - return promotionDiscount;  
180 - } 183 + public String getIsStudentPrice() {
  184 + return isStudentPrice;
  185 + }
181 186
182 - public void setPromotionDiscount(BigDecimal promotionDiscount) {  
183 - this.promotionDiscount = promotionDiscount;  
184 - } 187 + public void setIsStudentPrice(String isStudentPrice) {
  188 + this.isStudentPrice = isStudentPrice;
  189 + }
185 190
186 - public String getIsStudentPrice() {  
187 - return isStudentPrice;  
188 - } 191 + public String getIsstudentrebate() {
  192 + return isstudentrebate;
  193 + }
189 194
190 - public void setIsStudentPrice(String isStudentPrice) {  
191 - this.isStudentPrice = isStudentPrice;  
192 - } 195 + public void setIsstudentrebate(String isstudentrebate) {
  196 + this.isstudentrebate = isstudentrebate;
  197 + }
193 198
194 - public String getIsstudentrebate() {  
195 - return isstudentrebate;  
196 - } 199 + public String getVipLevels() {
  200 + return vipLevels;
  201 + }
197 202
198 - public void setIsstudentrebate(String isstudentrebate) {  
199 - this.isstudentrebate = isstudentrebate;  
200 - } 203 + public void setVipLevels(String vipLevels) {
  204 + this.vipLevels = vipLevels;
  205 + }
201 206
202 - public String getVipLevels() {  
203 - return vipLevels;  
204 - } 207 + public Integer getUpdateTime() {
  208 + return updateTime;
  209 + }
205 210
206 - public void setVipLevels(String vipLevels) {  
207 - this.vipLevels = vipLevels;  
208 - } 211 + public void setUpdateTime(Integer updateTime) {
  212 + this.updateTime = updateTime;
  213 + }
209 214
210 - public Integer getUpdateTime() {  
211 - return updateTime;  
212 - } 215 + public BigDecimal getBasicPrice() {
  216 + return basicPrice;
  217 + }
213 218
214 - public void setUpdateTime(Integer updateTime) {  
215 - this.updateTime = updateTime;  
216 - } 219 + public void setBasicPrice(BigDecimal basicPrice) {
  220 + this.basicPrice = basicPrice;
  221 + }
217 222
218 - public BigDecimal getBasicPrice() {  
219 - return basicPrice;  
220 - } 223 + public Integer getProductVipStatus() {
  224 + return productVipStatus;
  225 + }
221 226
222 - public void setBasicPrice(BigDecimal basicPrice) {  
223 - this.basicPrice = basicPrice;  
224 - }  
225 -  
226 - public Integer getProductVipStatus() {  
227 - return productVipStatus;  
228 - }  
229 -  
230 - public void setProductVipStatus(Integer productVipStatus) {  
231 - this.productVipStatus = productVipStatus;  
232 - } 227 + public void setProductVipStatus(Integer productVipStatus) {
  228 + this.productVipStatus = productVipStatus;
  229 + }
233 230
234 } 231 }
@@ -12,60 +12,61 @@ import java.util.List; @@ -12,60 +12,61 @@ import java.util.List;
12 12
13 @Service 13 @Service
14 public class VipPriceLogicService { 14 public class VipPriceLogicService {
15 - 15 +
16 /** 16 /**
17 * 设置计划的vip价格 17 * 设置计划的vip价格
18 */ 18 */
19 - public void fillProductPricePlanVipPrice(ProductPricePlan p){  
20 - VipPriceBO vipPriceBO = this.getVipPriceBO(p.getCurrentSaleprice(), p.getVipPrice(), p.getVip1Price(), p.getVip2Price(), p.getVip3Price(), p.getVipDiscountType(), p.getVipDiscount()); 19 + public void fillProductPricePlanVipPrice(ProductPricePlan p) {
  20 + VipPriceBO vipPriceBO = this.getVipPriceBO(p.getCurrentSaleprice(), p.getVipDiscountType(), p.getVipPrice(), p.getVip1Price(), p.getVip2Price(), p.getVip3Price(),
  21 + p.getVipDiscount());
21 p.setVip1Price(vipPriceBO.getVip1PriceBigDecimal()); 22 p.setVip1Price(vipPriceBO.getVip1PriceBigDecimal());
22 p.setVip2Price(vipPriceBO.getVip2PriceBigDecimal()); 23 p.setVip2Price(vipPriceBO.getVip2PriceBigDecimal());
23 p.setVip3Price(vipPriceBO.getVip3PriceBigDecimal()); 24 p.setVip3Price(vipPriceBO.getVip3PriceBigDecimal());
24 } 25 }
25 - 26 +
26 /** 27 /**
27 * 计算并重设vip相关价格 28 * 计算并重设vip相关价格
28 */ 29 */
29 - public void fillProductPriceVipPrice(ProductPriceBO productPriceBO){  
30 - VipPriceBO vipPriceBO = this.getVipPriceBO(productPriceBO.getSalesPrice(), productPriceBO.getVipPrice(), productPriceBO.getVip1Price(), productPriceBO.getVip2Price(), productPriceBO.getVip3Price(), productPriceBO.getCurrentVipDiscountType(),  
31 - productPriceBO.getVipDiscount()); 30 + public void fillProductPriceVipPrice(ProductPriceBO productPriceBO) {
  31 + /**
  32 + * salesPrice等于productPrice表的currentPrice,
  33 + * type是productPrice表的currentVipDiscountType
  34 + */
  35 + VipPriceBO vipPriceBO = this.getVipPriceBO(productPriceBO.getSalesPrice(), productPriceBO.getVipDiscountType(), productPriceBO.getVipPrice(),
  36 + productPriceBO.getVip1Price(), productPriceBO.getVip2Price(), productPriceBO.getVip3Price(), productPriceBO.getVipDiscount());
32 productPriceBO.setVip1Price(vipPriceBO.getVip1PriceBigDecimal()); 37 productPriceBO.setVip1Price(vipPriceBO.getVip1PriceBigDecimal());
33 productPriceBO.setVip2Price(vipPriceBO.getVip2PriceBigDecimal()); 38 productPriceBO.setVip2Price(vipPriceBO.getVip2PriceBigDecimal());
34 productPriceBO.setVip3Price(vipPriceBO.getVip3PriceBigDecimal()); 39 productPriceBO.setVip3Price(vipPriceBO.getVip3PriceBigDecimal());
35 -  
36 - //设置vipLevels  
37 - double salesPrice = this.getDoubleFromBigDecimal(productPriceBO.getSalesPrice());  
38 - double vip1Price = productPriceBO.getVip1Price().doubleValue();  
39 - double vip2Price = productPriceBO.getVip2Price().doubleValue();  
40 - double vip3Price = productPriceBO.getVip3Price().doubleValue();  
41 - List<String> vipLevels = new ArrayList<String>();  
42 - if (vip1Price > 0 && vip1Price < salesPrice) {  
43 - vipLevels.add("1");  
44 - }  
45 - if (vip2Price > 0 && vip2Price < salesPrice) {  
46 - vipLevels.add("2");  
47 - }  
48 - if (vip3Price > 0 && vip3Price < salesPrice) {  
49 - vipLevels.add("3");  
50 - }  
51 - productPriceBO.setVipLevels(StringUtils.join(vipLevels, ",")); 40 + // 设置vipLevels
  41 + double salesPrice = this.getDoubleFromBigDecimal(productPriceBO.getSalesPrice());
  42 + double vip1Price = this.getDoubleFromBigDecimal(productPriceBO.getVip1Price());
  43 + double vip2Price = this.getDoubleFromBigDecimal(productPriceBO.getVip2Price());
  44 + double vip3Price = this.getDoubleFromBigDecimal(productPriceBO.getVip3Price());
  45 + List<String> vipLevels = new ArrayList<String>();
  46 + if (vip1Price > 0 && vip1Price < salesPrice) {
  47 + vipLevels.add("1");
  48 + }
  49 + if (vip2Price > 0 && vip2Price < salesPrice) {
  50 + vipLevels.add("2");
  51 + }
  52 + if (vip3Price > 0 && vip3Price < salesPrice) {
  53 + vipLevels.add("3");
  54 + }
  55 + productPriceBO.setVipLevels(StringUtils.join(vipLevels, ","));
52 56
53 } 57 }
54 58
55 - /**  
56 - * salesPrice等于productPrice表的currentPrice,type是productPrice表的currentVipDiscountType  
57 - */  
58 - private VipPriceBO getVipPriceBO(BigDecimal salesPrice, BigDecimal vipPrice, BigDecimal vip1Price, BigDecimal vip2Price, BigDecimal vip3Price, Integer type,  
59 - BigDecimal vipDiscount) {  
60 - double salesPriceDoubleCeil = Math.ceil(this.getDoubleFromBigDecimal(salesPrice)); 59 + private VipPriceBO getVipPriceBO(BigDecimal currentSalesPrice, Integer currentVipDiscountType, BigDecimal vipPrice, BigDecimal vip1Price, BigDecimal vip2Price,
  60 + BigDecimal vip3Price, BigDecimal vipDiscount) {
  61 + double salesPriceDoubleCeil = Math.ceil(this.getDoubleFromBigDecimal(currentSalesPrice));
61 // 默认取销售价 62 // 默认取销售价
62 double vip1PriceResult = salesPriceDoubleCeil; 63 double vip1PriceResult = salesPriceDoubleCeil;
63 double vip2PriceResult = salesPriceDoubleCeil; 64 double vip2PriceResult = salesPriceDoubleCeil;
64 double vip3PriceResult = salesPriceDoubleCeil; 65 double vip3PriceResult = salesPriceDoubleCeil;
65 - if (type == null) { 66 + if (currentVipDiscountType == null) {
66 return new VipPriceBO(vip1PriceResult, vip2PriceResult, vip3PriceResult); 67 return new VipPriceBO(vip1PriceResult, vip2PriceResult, vip3PriceResult);
67 } 68 }
68 - switch (type) { 69 + switch (currentVipDiscountType) {
69 case 1: 70 case 1:
70 vip1PriceResult = Double.valueOf(String.format("%.2f", salesPriceDoubleCeil * 0.95)); 71 vip1PriceResult = Double.valueOf(String.format("%.2f", salesPriceDoubleCeil * 0.95));
71 vip2PriceResult = Double.valueOf(String.format("%.2f", salesPriceDoubleCeil * 0.9)); 72 vip2PriceResult = Double.valueOf(String.format("%.2f", salesPriceDoubleCeil * 0.9));
@@ -67,7 +67,7 @@ public class ProductPriceBuilder implements ViewBuilder { @@ -67,7 +67,7 @@ public class ProductPriceBuilder implements ViewBuilder {
67 // 2、计算折扣相关 67 // 2、计算折扣相关
68 double salesPrice = this.getDoubleFromBigDecimal(productPriceBO.getSalesPrice()); 68 double salesPrice = this.getDoubleFromBigDecimal(productPriceBO.getSalesPrice());
69 double marketPrice = this.getDoubleFromBigDecimal(productPriceBO.getMarketPrice()); 69 double marketPrice = this.getDoubleFromBigDecimal(productPriceBO.getMarketPrice());
70 - productPriceBO.setIsDiscount(salesPrice < marketPrice ? "Y" : "N"); 70 + productPriceBO.setIsDiscount(salesPrice < marketPrice ? "Y" : "N");
71 double specialOffer = this.divide(1, productPriceBO.getSalesPrice(), productPriceBO.getMarketPrice()); 71 double specialOffer = this.divide(1, productPriceBO.getSalesPrice(), productPriceBO.getMarketPrice());
72 if (specialOffer <= 0.5) { 72 if (specialOffer <= 0.5) {
73 productPriceBO.setSpecialoffer("Y"); 73 productPriceBO.setSpecialoffer("Y");