提交 | 用户 | age
|
2edfdb
|
1 |
package com.hz.his.vo.project; |
F |
2 |
|
|
3 |
import lombok.Data; |
|
4 |
|
|
5 |
import java.math.BigDecimal; |
|
6 |
import java.math.RoundingMode; |
|
7 |
|
|
8 |
/** |
|
9 |
* SKU抵扣数据 |
|
10 |
*/ |
|
11 |
@Data |
|
12 |
public class SkuDeductionVo { |
|
13 |
/**sku标识*/ |
|
14 |
private String skuId; |
|
15 |
/**sku最大可抵扣现金金额*/ |
|
16 |
private BigDecimal maxCash = BigDecimal.ZERO; |
|
17 |
/**sku抵扣最大现金金额需要支付的积分*/ |
|
18 |
private BigDecimal maxIntegralCash = BigDecimal.ZERO; |
|
19 |
|
|
20 |
/**总单购买项目数量*/ |
|
21 |
private Integer totalBuyNum = 0; |
|
22 |
/**项目数量占总单比*/ |
|
23 |
private BigDecimal skuNumRate = BigDecimal.ZERO; |
|
24 |
/**子单购买数量*/ |
|
25 |
private Integer buyNum = 0; |
bed2a0
|
26 |
/**子单现价x数量算出的总金额*/ |
2edfdb
|
27 |
private BigDecimal skuPrice = BigDecimal.ZERO; |
F |
28 |
/**子单分摊系统金额(储值金+增值金)*/ |
|
29 |
private BigDecimal skuSystemPrice = BigDecimal.ZERO; |
|
30 |
/**子单优惠金额*/ |
|
31 |
private BigDecimal skuDiscountPrice = BigDecimal.ZERO; |
|
32 |
/**子单剩余还需支付的金额*/ |
|
33 |
private BigDecimal skuRemainingPrice = BigDecimal.ZERO; |
|
34 |
/**子单可抵扣最大现金金额*/ |
|
35 |
private BigDecimal skuMaxCash = BigDecimal.ZERO; |
|
36 |
|
|
37 |
/**剩余可分配*/ |
|
38 |
private BigDecimal cash = BigDecimal.ZERO; |
|
39 |
|
|
40 |
/** |
|
41 |
* 计算抵扣金额 |
|
42 |
* */ |
|
43 |
public void handlerMoney() { |
|
44 |
//计算剩余还要支付的金额 |
|
45 |
this.skuRemainingPrice = this.skuPrice.subtract(this.skuSystemPrice).subtract(this.skuDiscountPrice).setScale(2, RoundingMode.HALF_UP); |
|
46 |
//计算子单最大可抵扣 |
|
47 |
this.skuMaxCash = this.maxCash.multiply(new BigDecimal(this.buyNum)); |
|
48 |
//如果Sku本身计算的最大抵扣现金 大于 剩余要支付的现金,取剩余要支付的现金 |
|
49 |
if (this.skuMaxCash.compareTo(this.skuRemainingPrice) > 0){ |
|
50 |
this.skuMaxCash = this.skuRemainingPrice; |
|
51 |
} |
1296bf
|
52 |
//默认赋值cash |
F |
53 |
handlerCash(BigDecimal.ZERO); |
2edfdb
|
54 |
} |
F |
55 |
|
|
56 |
/**计算数量*/ |
|
57 |
public void handlerNum(Integer totalBuyNum) { |
|
58 |
this.totalBuyNum = totalBuyNum; |
|
59 |
if (totalBuyNum != 0){ |
|
60 |
this.skuNumRate = new BigDecimal(this.buyNum).divide(new BigDecimal(this.totalBuyNum),2,RoundingMode.HALF_UP); |
|
61 |
} |
|
62 |
} |
|
63 |
|
|
64 |
/**计算数量*/ |
|
65 |
public void handlerCash(BigDecimal totalMoney) { |
|
66 |
this.cash = this.skuMaxCash.subtract(totalMoney).setScale(2,RoundingMode.HALF_UP); |
|
67 |
} |
|
68 |
} |