Authored by chenchao

may by not min if calculate result by range

... ... @@ -272,9 +272,24 @@ public abstract class AbsSellerOrderComputeHandler implements OrderComputeHandle
logger.info("compute CalServiceFee uid {} storageId {} price {} serviceFeeRates {} defaultGoodsServiceFeeRange {} minSFR{}",
uid, storageId, price, serviceFeeRates, defaultGoodsServiceFeeRange, minSFR);
PriceRange priceRange = Objects.nonNull(minSFR.getGoodsPaymentPriceRange()) ? minSFR.getGoodsPaymentPriceRange() : defaultGoodsServiceFeeRange;
BigDecimal tmp = calServiceFee(price, minSFR, priceRange);
BigDecimal minSF = calServiceFee(price, minSFR, priceRange);
serviceFeeRate = minSFR;
serviceFee = tmp;
serviceFee = minSF;
//may by not min if calculate result by range
//eg : {rate : 0.01,range:[10,20]}, {rate : 0.02,range:[5,9]}
for (ServiceFeeRate sfr : serviceFeeRates) {
//pass min
if (minSFR.equals(sfr)){
continue;
}
PriceRange priceRange0 = Objects.nonNull(sfr.getGoodsPaymentPriceRange()) ? sfr.getGoodsPaymentPriceRange() : defaultGoodsServiceFeeRange;
BigDecimal tmp0 = calServiceFee(price, sfr, priceRange0);
if (Objects.isNull(serviceFee) || serviceFee.compareTo(tmp0) > 0) {
serviceFeeRate = sfr;
serviceFee = tmp0;
}
}
}
return this;
}
... ...