Authored by wujiexiang

扣费比例小数位数修改

... ... @@ -170,11 +170,9 @@ public class SellerService {
*/
public SellerPlatformServiceFeeResp platformServiceFeeDetail(int uid) {
logger.info("platformServiceFeeDetail uid {}", uid);
SellerPlatformServiceFee currentServiceFee = getCurrentTimeSellerPlatformServiceFee(uid);
SellerPlatformServiceFee nextPeriodServiceFee = getNextPeriodSellerPlatformServiceFee(uid);
if (!currentServiceFee.isRuleConfigured() || !nextPeriodServiceFee.isRuleConfigured()) {
SellerPlatformServiceFee currentServiceFee, nextPeriodServiceFee;
if (!(currentServiceFee = getCurrentTimeSellerPlatformServiceFee(uid)).isRuleConfigured()
|| !(nextPeriodServiceFee = getNextPeriodSellerPlatformServiceFee(uid)).isRuleConfigured()) {
logger.info("platformServiceFee rule is not configured,uid {}", uid);
return SellerPlatformServiceFeeResp.builder()
.nodes(Lists.newArrayList())
... ... @@ -193,16 +191,16 @@ public class SellerService {
List<SellerPlatformServiceFeeResp.Node> nodes = rules.stream().map(rule -> {
SellerPlatformServiceFeeResp.Node node = new SellerPlatformServiceFeeResp.Node();
node.setKey(rule.getThreshold());
node.setValue(MathUtils.convert2Percent(rule.getRate()));
node.setValue(MathUtils.convert2Percent(rule.getRate(), 1));
return node;
}).collect(Collectors.toList());
//最终返回结果
SellerPlatformServiceFeeResp resp = SellerPlatformServiceFeeResp.builder()
.currentRate(MathUtils.convert2Percent(currentServiceFee.getFeeRate()))
.currentRate(MathUtils.convert2Percent(currentServiceFee.getFeeRate(), 1))
.nodes(nodes)
.finishedOrderQuantity(nextPeriodOrderQuantity)
.nextRateToReach(MathUtils.convert2Percent(unsatisfiedFeeRule.getRate()))
.nextRateToReach(MathUtils.convert2Percent(unsatisfiedFeeRule.getRate(), 1))
.nextRateRequiredIncOrderQuantity(Math.max(0, unsatisfiedFeeRule.getThreshold() - nextPeriodOrderQuantity))
.build();
... ...
... ... @@ -34,8 +34,12 @@ public class MathUtils {
}
public static String convert2Percent(BigDecimal rate){
return rate.multiply(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP) + "%";
public static String convert2Percent(BigDecimal rate) {
return convert2Percent(rate, 2);
}
public static String convert2Percent(BigDecimal rate, int newScale) {
return rate.multiply(new BigDecimal(100)).setScale(newScale, BigDecimal.ROUND_HALF_UP) + "%";
}
/**
... ...