Authored by LUOXC

refacotr

... ... @@ -48,8 +48,7 @@ public class BuyerCancelCompensateComputeHandler {
BigDecimal orderActualAmount = buyerOrder.getAmount();
BigDecimal goodsActualAmount = buyerOrderGoods.getGoodsAmount();
OrderAttributes orderAttributes = OrderAttributes.getOrderAttributes(buyerOrder.getAttributes());
BuyerPenaltyCalResult bpcr = calBuyerPenalty(buyerUid, orderCode, targetStatus, orderActualAmount, goodsActualAmount, orderAttributes);
return bpcr;
return calBuyerPenalty(buyerUid, orderCode, targetStatus, orderActualAmount, goodsActualAmount, orderAttributes);
}
/**
... ... @@ -78,14 +77,10 @@ public class BuyerCancelCompensateComputeHandler {
.diffTime(diffTime)
.select()
.orElseThrow(() -> new UfoServiceException(501, "not match calFee"));
BuyerPenaltyCalResult bpcr = calBuyerPenalty(penaltyRule, buyerUid, orderCode, orderActualAmount, goodsActualAmount);
if (bpcr.getLeftAmount().compareTo(BigDecimal.ZERO) <= 0) {
throw new UfoServiceException(501, "left amount not enough");
}
return bpcr;
return calBuyerPenalty(penaltyRule, buyerUid, orderCode, orderActualAmount, goodsActualAmount);
}
public BuyerPenaltyCalResult calBuyerPenalty(PenaltyRule penaltyRule, Integer buyerUid, Long orderCode,
private BuyerPenaltyCalResult calBuyerPenalty(PenaltyRule penaltyRule, Integer buyerUid, Long orderCode,
BigDecimal orderActualAmount, BigDecimal goodsActualAmount) {
BigDecimal penaltyRate = penaltyRule.getPenaltyRate();
BigDecimal penaltyAmount = BigDecimalHelper.halfUp(goodsActualAmount.multiply(penaltyRate));
... ... @@ -95,6 +90,10 @@ public class BuyerCancelCompensateComputeHandler {
if (Objects.nonNull(penaltyRule.getPenaltyMaxAmount()) && penaltyAmount.compareTo(penaltyRule.getPenaltyMaxAmount()) > 0) {
penaltyAmount = penaltyRule.getPenaltyMaxAmount();
}
// 如果赔偿金额大于支付金额
if (penaltyAmount.compareTo(orderActualAmount) > 0){
penaltyAmount = orderActualAmount;
}
BigDecimal leftAmount = orderActualAmount.subtract(penaltyAmount);
BuyerPenaltyCalResult bpcr = BuyerPenaltyCalResult.builder()
.uid(buyerUid).orderCode(orderCode)
... ...