Authored by chenchao

fix goods service rate percentage

@@ -7,8 +7,9 @@ import com.yohoufo.common.utils.PriceFormater; @@ -7,8 +7,9 @@ import com.yohoufo.common.utils.PriceFormater;
7 import com.yohoufo.order.model.dto.EarnestMoney; 7 import com.yohoufo.order.model.dto.EarnestMoney;
8 import com.yohoufo.order.model.dto.PlatformFeeDto; 8 import com.yohoufo.order.model.dto.PlatformFeeDto;
9 import com.yohoufo.order.model.dto.SellerOrderComputeResult; 9 import com.yohoufo.order.model.dto.SellerOrderComputeResult;
  10 +import com.yohoufo.order.model.dto.ServiceFeeRate;
10 import com.yohoufo.order.service.proxy.ResourcesProxyService; 11 import com.yohoufo.order.service.proxy.ResourcesProxyService;
11 -import org.apache.commons.lang3.StringUtils; 12 +import com.yohoufo.order.utils.MathUtils;
12 13
13 import java.math.BigDecimal; 14 import java.math.BigDecimal;
14 import java.util.Map; 15 import java.util.Map;
@@ -24,9 +25,6 @@ public final class SellerOrderConvertor { @@ -24,9 +25,6 @@ public final class SellerOrderConvertor {
24 BigDecimal earnestMoney = earnestMoneyDTO.getEarnestMoney(); 25 BigDecimal earnestMoney = earnestMoneyDTO.getEarnestMoney();
25 PlatformFeeDto platformFeeDto = computeResult.getPlatformFee(); 26 PlatformFeeDto platformFeeDto = computeResult.getPlatformFee();
26 BigDecimal income = computeResult.getIncome(); 27 BigDecimal income = computeResult.getIncome();
27 - //service tips  
28 - String serviceTipsDesc = null;  
29 - String serviceTipsSummary = null;  
30 // 28 //
31 String payPersent = computeResult.getServiceFeeRate() != null ? computeResult.getServiceFeeRate().getPayChannelPercent() : ""; 29 String payPersent = computeResult.getServiceFeeRate() != null ? computeResult.getServiceFeeRate().getPayChannelPercent() : "";
32 PlatformFee platformFeeWrapper = PlatformFee.builder() 30 PlatformFee platformFeeWrapper = PlatformFee.builder()
@@ -47,8 +45,6 @@ public final class SellerOrderConvertor { @@ -47,8 +45,6 @@ public final class SellerOrderConvertor {
47 .platformFee(platformFeeWrapper) 45 .platformFee(platformFeeWrapper)
48 .bankTransferFee(buildSubtractFee(bankTransferFeeStr)) 46 .bankTransferFee(buildSubtractFee(bankTransferFeeStr))
49 .income(incomeStr) 47 .income(incomeStr)
50 - .serviceTipsDesc(serviceTipsDesc)  
51 - .serviceTipsSummary(serviceTipsSummary)  
52 .build(); 48 .build();
53 return computeBo; 49 return computeBo;
54 50
@@ -66,9 +62,12 @@ public final class SellerOrderConvertor { @@ -66,9 +62,12 @@ public final class SellerOrderConvertor {
66 String serviceTipsDesc = null; 62 String serviceTipsDesc = null;
67 String serviceTipsSummary = null; 63 String serviceTipsSummary = null;
68 // 64 //
69 - String payPersent = computeResult.getServiceFeeRate() != null ? computeResult.getServiceFeeRate().getPayChannelPercent() : "";  
70 - if (StringUtils.isNotBlank(payPersent)){  
71 - serviceTipsSummary = String.format("(%s)", payPersent); 65 + boolean feeRateExists;
  66 + ServiceFeeRate serviceFeeRate;
  67 + String payPercent = (feeRateExists = ((serviceFeeRate=computeResult.getServiceFeeRate()) != null)) ? serviceFeeRate.getPayChannelPercent() : "";
  68 + BigDecimal goodsPaymentRate;
  69 + if (feeRateExists && (goodsPaymentRate=serviceFeeRate.getGoodsPaymentRate()) != null){
  70 + serviceTipsSummary = String.format("(%s)", MathUtils.convert2Percent(goodsPaymentRate));
72 }else{ 71 }else{
73 if(tipsConfig!=null){ 72 if(tipsConfig!=null){
74 serviceTipsDesc = tipsConfig.get(ResourcesProxyService.KEY_SERVICETIPSDESC); 73 serviceTipsDesc = tipsConfig.get(ResourcesProxyService.KEY_SERVICETIPSDESC);
@@ -81,7 +80,7 @@ public final class SellerOrderConvertor { @@ -81,7 +80,7 @@ public final class SellerOrderConvertor {
81 .appraiseFee(formatFee(platformFeeDto.getAppraiseFee())) 80 .appraiseFee(formatFee(platformFeeDto.getAppraiseFee()))
82 .packageFee(formatFee(platformFeeDto.getPackageFee())) 81 .packageFee(formatFee(platformFeeDto.getPackageFee()))
83 .serviceFee(formatFee(platformFeeDto.getServiceFee())) 82 .serviceFee(formatFee(platformFeeDto.getServiceFee()))
84 - .payChannelPercentage(payPersent) 83 + .payChannelPercentage(payPercent)
85 .build(); 84 .build();
86 // 85 //
87 String incomeStr = formatFee(income); 86 String incomeStr = formatFee(income);
1 package com.yohoufo.order.stateMachine; 1 package com.yohoufo.order.stateMachine;
2 2
3 /** 3 /**
  4 + * 主要用于扭转状态
4 * Created by chao.chen on 2019/1/3. 5 * Created by chao.chen on 2019/1/3.
5 */ 6 */
6 public interface Func<StateReference,T> { 7 public interface Func<StateReference,T> {
@@ -31,4 +31,9 @@ public class MathUtils { @@ -31,4 +31,9 @@ public class MathUtils {
31 public static double roundPrice(double price) { 31 public static double roundPrice(double price) {
32 return BigDecimalHelper.round(BigDecimal.valueOf(price)); 32 return BigDecimalHelper.round(BigDecimal.valueOf(price));
33 } 33 }
  34 +
  35 +
  36 + public static String convert2Percent(BigDecimal rate){
  37 + return rate.multiply(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP) + "%";
  38 + }
34 } 39 }