@Test public void test_getAvailableCost() { PointRecPo rec = new PointRecPo(); rec.setTotalCost(DecimalUtils.ZERO); BigDecimal result = this.calculator.getAvailableCost(rec); Assertions.assertEquals(DecimalUtils.ZERO, result); rec.setTotalCost(BigDecimal.valueOf(100L)) .setFrozenCost(BigDecimal.valueOf(5L)) .setUsedCost(BigDecimal.valueOf(6L)) .setRefundCost(BigDecimal.valueOf(7L)); BigDecimal expect = BigDecimal.valueOf(100L - 5L - 6L - 7L); result = this.calculator.getAvailableCost(rec); Assertions.assertEquals(expect, result); }
public BigDecimal getAvailableCost(PointRecPo rec) { if (rec.getTotalCost() == null || DecimalUtils.lte(rec.getTotalCost(), DecimalUtils.ZERO)) { return DecimalUtils.ZERO; } BigDecimal ret = rec.getTotalCost().subtract(rec.getUsedCost()) .subtract(rec.getFrozenCost()) .subtract(rec.getRefundCost()); if (DecimalUtils.gt(ret, DecimalUtils.ZERO)) { return ret; } else { return DecimalUtils.ZERO; } }
CostCalculator { public BigDecimal getAvailableCost(PointRecPo rec) { if (rec.getTotalCost() == null || DecimalUtils.lte(rec.getTotalCost(), DecimalUtils.ZERO)) { return DecimalUtils.ZERO; } BigDecimal ret = rec.getTotalCost().subtract(rec.getUsedCost()) .subtract(rec.getFrozenCost()) .subtract(rec.getRefundCost()); if (DecimalUtils.gt(ret, DecimalUtils.ZERO)) { return ret; } else { return DecimalUtils.ZERO; } } }
CostCalculator { public BigDecimal getAvailableCost(PointRecPo rec) { if (rec.getTotalCost() == null || DecimalUtils.lte(rec.getTotalCost(), DecimalUtils.ZERO)) { return DecimalUtils.ZERO; } BigDecimal ret = rec.getTotalCost().subtract(rec.getUsedCost()) .subtract(rec.getFrozenCost()) .subtract(rec.getRefundCost()); if (DecimalUtils.gt(ret, DecimalUtils.ZERO)) { return ret; } else { return DecimalUtils.ZERO; } }  }
CostCalculator { public BigDecimal getAvailableCost(PointRecPo rec) { if (rec.getTotalCost() == null || DecimalUtils.lte(rec.getTotalCost(), DecimalUtils.ZERO)) { return DecimalUtils.ZERO; } BigDecimal ret = rec.getTotalCost().subtract(rec.getUsedCost()) .subtract(rec.getFrozenCost()) .subtract(rec.getRefundCost()); if (DecimalUtils.gt(ret, DecimalUtils.ZERO)) { return ret; } else { return DecimalUtils.ZERO; } }  BigDecimal getAvailableCost(PointRecPo rec); BigDecimal accountPoint(PointRecPo rec, BigDecimal cost); BigDecimal accountCost(PointRecPo rec, BigDecimal delta); BigDecimal accountCost4Unfreeze(PointRecPo rec, BigDecimal delta); }
CostCalculator { public BigDecimal getAvailableCost(PointRecPo rec) { if (rec.getTotalCost() == null || DecimalUtils.lte(rec.getTotalCost(), DecimalUtils.ZERO)) { return DecimalUtils.ZERO; } BigDecimal ret = rec.getTotalCost().subtract(rec.getUsedCost()) .subtract(rec.getFrozenCost()) .subtract(rec.getRefundCost()); if (DecimalUtils.gt(ret, DecimalUtils.ZERO)) { return ret; } else { return DecimalUtils.ZERO; } }  BigDecimal getAvailableCost(PointRecPo rec); BigDecimal accountPoint(PointRecPo rec, BigDecimal cost); BigDecimal accountCost(PointRecPo rec, BigDecimal delta); BigDecimal accountCost4Unfreeze(PointRecPo rec, BigDecimal delta);  }