package com.hz.his.vo.project; import lombok.Data; import java.math.BigDecimal; import java.math.RoundingMode; /** * SKU抵扣数据 */ @Data public class SkuDeductionVo { /**sku标识*/ private String skuId; /**sku最大可抵扣现金金额*/ private BigDecimal maxCash = BigDecimal.ZERO; /**sku抵扣最大现金金额需要支付的积分*/ private BigDecimal maxIntegralCash = BigDecimal.ZERO; /**总单购买项目数量*/ private Integer totalBuyNum = 0; /**项目数量占总单比*/ private BigDecimal skuNumRate = BigDecimal.ZERO; /**子单购买数量*/ private Integer buyNum = 0; /**子单现价x数量算出的总金额*/ private BigDecimal skuPrice = BigDecimal.ZERO; /**子单可抵扣最大现金金额*/ private BigDecimal skuMaxCash = BigDecimal.ZERO; /**剩余可分配*/ private BigDecimal cash = BigDecimal.ZERO; /** * 计算抵扣金额 * */ public void handlerMoney() { //计算子单最大可抵扣 this.skuMaxCash = this.maxCash.multiply(new BigDecimal(this.buyNum)); //默认赋值cash handlerCash(BigDecimal.ZERO); } /**计算数量*/ public void handlerNum(Integer totalBuyNum) { this.totalBuyNum = totalBuyNum; if (totalBuyNum != 0){ this.skuNumRate = new BigDecimal(this.buyNum).divide(new BigDecimal(this.totalBuyNum),2,RoundingMode.HALF_UP); } } /**计算数量*/ public void handlerCash(BigDecimal totalMoney) { this.cash = this.skuMaxCash.subtract(totalMoney).setScale(2,RoundingMode.HALF_UP); } }