may by not min if calculate result by range
Showing
1 changed file
with
17 additions
and
2 deletions
@@ -272,9 +272,24 @@ public abstract class AbsSellerOrderComputeHandler implements OrderComputeHandle | @@ -272,9 +272,24 @@ public abstract class AbsSellerOrderComputeHandler implements OrderComputeHandle | ||
272 | logger.info("compute CalServiceFee uid {} storageId {} price {} serviceFeeRates {} defaultGoodsServiceFeeRange {} minSFR{}", | 272 | logger.info("compute CalServiceFee uid {} storageId {} price {} serviceFeeRates {} defaultGoodsServiceFeeRange {} minSFR{}", |
273 | uid, storageId, price, serviceFeeRates, defaultGoodsServiceFeeRange, minSFR); | 273 | uid, storageId, price, serviceFeeRates, defaultGoodsServiceFeeRange, minSFR); |
274 | PriceRange priceRange = Objects.nonNull(minSFR.getGoodsPaymentPriceRange()) ? minSFR.getGoodsPaymentPriceRange() : defaultGoodsServiceFeeRange; | 274 | PriceRange priceRange = Objects.nonNull(minSFR.getGoodsPaymentPriceRange()) ? minSFR.getGoodsPaymentPriceRange() : defaultGoodsServiceFeeRange; |
275 | - BigDecimal tmp = calServiceFee(price, minSFR, priceRange); | 275 | + BigDecimal minSF = calServiceFee(price, minSFR, priceRange); |
276 | serviceFeeRate = minSFR; | 276 | serviceFeeRate = minSFR; |
277 | - serviceFee = tmp; | 277 | + serviceFee = minSF; |
278 | + //may by not min if calculate result by range | ||
279 | + //eg : {rate : 0.01,range:[10,20]}, {rate : 0.02,range:[5,9]} | ||
280 | + for (ServiceFeeRate sfr : serviceFeeRates) { | ||
281 | + //pass min | ||
282 | + if (minSFR.equals(sfr)){ | ||
283 | + continue; | ||
284 | + } | ||
285 | + PriceRange priceRange0 = Objects.nonNull(sfr.getGoodsPaymentPriceRange()) ? sfr.getGoodsPaymentPriceRange() : defaultGoodsServiceFeeRange; | ||
286 | + BigDecimal tmp0 = calServiceFee(price, sfr, priceRange0); | ||
287 | + if (Objects.isNull(serviceFee) || serviceFee.compareTo(tmp0) > 0) { | ||
288 | + serviceFeeRate = sfr; | ||
289 | + serviceFee = tmp0; | ||
290 | + } | ||
291 | + } | ||
292 | + | ||
278 | } | 293 | } |
279 | return this; | 294 | return this; |
280 | } | 295 | } |
-
Please register or login to post a comment