Authored by wujiexiang

扣费比例小数位数修改

@@ -170,11 +170,9 @@ public class SellerService { @@ -170,11 +170,9 @@ public class SellerService {
170 */ 170 */
171 public SellerPlatformServiceFeeResp platformServiceFeeDetail(int uid) { 171 public SellerPlatformServiceFeeResp platformServiceFeeDetail(int uid) {
172 logger.info("platformServiceFeeDetail uid {}", uid); 172 logger.info("platformServiceFeeDetail uid {}", uid);
173 - SellerPlatformServiceFee currentServiceFee = getCurrentTimeSellerPlatformServiceFee(uid);  
174 -  
175 - SellerPlatformServiceFee nextPeriodServiceFee = getNextPeriodSellerPlatformServiceFee(uid);  
176 -  
177 - if (!currentServiceFee.isRuleConfigured() || !nextPeriodServiceFee.isRuleConfigured()) { 173 + SellerPlatformServiceFee currentServiceFee, nextPeriodServiceFee;
  174 + if (!(currentServiceFee = getCurrentTimeSellerPlatformServiceFee(uid)).isRuleConfigured()
  175 + || !(nextPeriodServiceFee = getNextPeriodSellerPlatformServiceFee(uid)).isRuleConfigured()) {
178 logger.info("platformServiceFee rule is not configured,uid {}", uid); 176 logger.info("platformServiceFee rule is not configured,uid {}", uid);
179 return SellerPlatformServiceFeeResp.builder() 177 return SellerPlatformServiceFeeResp.builder()
180 .nodes(Lists.newArrayList()) 178 .nodes(Lists.newArrayList())
@@ -193,16 +191,16 @@ public class SellerService { @@ -193,16 +191,16 @@ public class SellerService {
193 List<SellerPlatformServiceFeeResp.Node> nodes = rules.stream().map(rule -> { 191 List<SellerPlatformServiceFeeResp.Node> nodes = rules.stream().map(rule -> {
194 SellerPlatformServiceFeeResp.Node node = new SellerPlatformServiceFeeResp.Node(); 192 SellerPlatformServiceFeeResp.Node node = new SellerPlatformServiceFeeResp.Node();
195 node.setKey(rule.getThreshold()); 193 node.setKey(rule.getThreshold());
196 - node.setValue(MathUtils.convert2Percent(rule.getRate())); 194 + node.setValue(MathUtils.convert2Percent(rule.getRate(), 1));
197 return node; 195 return node;
198 }).collect(Collectors.toList()); 196 }).collect(Collectors.toList());
199 197
200 //最终返回结果 198 //最终返回结果
201 SellerPlatformServiceFeeResp resp = SellerPlatformServiceFeeResp.builder() 199 SellerPlatformServiceFeeResp resp = SellerPlatformServiceFeeResp.builder()
202 - .currentRate(MathUtils.convert2Percent(currentServiceFee.getFeeRate())) 200 + .currentRate(MathUtils.convert2Percent(currentServiceFee.getFeeRate(), 1))
203 .nodes(nodes) 201 .nodes(nodes)
204 .finishedOrderQuantity(nextPeriodOrderQuantity) 202 .finishedOrderQuantity(nextPeriodOrderQuantity)
205 - .nextRateToReach(MathUtils.convert2Percent(unsatisfiedFeeRule.getRate())) 203 + .nextRateToReach(MathUtils.convert2Percent(unsatisfiedFeeRule.getRate(), 1))
206 .nextRateRequiredIncOrderQuantity(Math.max(0, unsatisfiedFeeRule.getThreshold() - nextPeriodOrderQuantity)) 204 .nextRateRequiredIncOrderQuantity(Math.max(0, unsatisfiedFeeRule.getThreshold() - nextPeriodOrderQuantity))
207 .build(); 205 .build();
208 206
@@ -34,8 +34,12 @@ public class MathUtils { @@ -34,8 +34,12 @@ public class MathUtils {
34 } 34 }
35 35
36 36
37 - public static String convert2Percent(BigDecimal rate){  
38 - return rate.multiply(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP) + "%"; 37 + public static String convert2Percent(BigDecimal rate) {
  38 + return convert2Percent(rate, 2);
  39 + }
  40 +
  41 + public static String convert2Percent(BigDecimal rate, int newScale) {
  42 + return rate.multiply(new BigDecimal(100)).setScale(newScale, BigDecimal.ROUND_HALF_UP) + "%";
39 } 43 }
40 44
41 /** 45 /**