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;
|
/**子单现价总需要支付的金额*/
|
private BigDecimal skuPrice = BigDecimal.ZERO;
|
/**子单分摊系统金额(储值金+增值金)*/
|
private BigDecimal skuSystemPrice = BigDecimal.ZERO;
|
/**子单优惠金额*/
|
private BigDecimal skuDiscountPrice = BigDecimal.ZERO;
|
/**子单剩余还需支付的金额*/
|
private BigDecimal skuRemainingPrice = BigDecimal.ZERO;
|
/**子单可抵扣最大现金金额*/
|
private BigDecimal skuMaxCash = BigDecimal.ZERO;
|
|
/**剩余可分配*/
|
private BigDecimal cash = BigDecimal.ZERO;
|
|
/**
|
* 计算抵扣金额
|
* */
|
public void handlerMoney() {
|
//计算剩余还要支付的金额
|
this.skuRemainingPrice = this.skuPrice.subtract(this.skuSystemPrice).subtract(this.skuDiscountPrice).setScale(2, RoundingMode.HALF_UP);
|
//计算子单最大可抵扣
|
this.skuMaxCash = this.maxCash.multiply(new BigDecimal(this.buyNum));
|
//如果Sku本身计算的最大抵扣现金 大于 剩余要支付的现金,取剩余要支付的现金
|
if (this.skuMaxCash.compareTo(this.skuRemainingPrice) > 0){
|
this.skuMaxCash = this.skuRemainingPrice;
|
}
|
}
|
|
/**计算数量*/
|
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);
|
}
|
}
|