optimized compute seller goods fee
Showing
5 changed files
with
213 additions
and
163 deletions
@@ -15,7 +15,7 @@ import com.yohoufo.dal.order.model.SellerOrder; | @@ -15,7 +15,7 @@ import com.yohoufo.dal.order.model.SellerOrder; | ||
15 | import com.yohoufo.order.model.request.OrderListRequest; | 15 | import com.yohoufo.order.model.request.OrderListRequest; |
16 | import com.yohoufo.order.model.request.OrderRequest; | 16 | import com.yohoufo.order.model.request.OrderRequest; |
17 | import com.yohoufo.order.model.response.OrderSubmitResp; | 17 | import com.yohoufo.order.model.response.OrderSubmitResp; |
18 | -import com.yohoufo.order.service.handler.SellerOrderComputeHandler; | 18 | +import com.yohoufo.order.service.impl.OrderDynamicConfig; |
19 | import com.yohoufo.order.service.impl.SellerOrderService; | 19 | import com.yohoufo.order.service.impl.SellerOrderService; |
20 | import com.yohoufo.order.service.impl.SellerService; | 20 | import com.yohoufo.order.service.impl.SellerService; |
21 | import com.yohoufo.order.service.impl.SkupListService; | 21 | import com.yohoufo.order.service.impl.SkupListService; |
@@ -44,7 +44,7 @@ public class SellerOrderController { | @@ -44,7 +44,7 @@ public class SellerOrderController { | ||
44 | private SellerOrderService sellerOrderService; | 44 | private SellerOrderService sellerOrderService; |
45 | 45 | ||
46 | @Autowired | 46 | @Autowired |
47 | - private SellerOrderComputeHandler sellerOrderComputeHandler; | 47 | + protected OrderDynamicConfig orderDynamicConfig; |
48 | 48 | ||
49 | @Autowired | 49 | @Autowired |
50 | private SellerService sellerService; | 50 | private SellerService sellerService; |
@@ -211,7 +211,7 @@ public class SellerOrderController { | @@ -211,7 +211,7 @@ public class SellerOrderController { | ||
211 | @ResponseBody | 211 | @ResponseBody |
212 | public ApiResponse getEarnestMoneyRange(){ | 212 | public ApiResponse getEarnestMoneyRange(){ |
213 | return new ApiResponse.ApiResponseBuilder() | 213 | return new ApiResponse.ApiResponseBuilder() |
214 | - .data(sellerOrderComputeHandler.getEarnestMoneyrange()) | 214 | + .data(orderDynamicConfig.getEMR()) |
215 | .message("get EarnestMoneyrange success").build(); | 215 | .message("get EarnestMoneyrange success").build(); |
216 | } | 216 | } |
217 | 217 |
1 | package com.yohoufo.order.service.handler; | 1 | package com.yohoufo.order.service.handler; |
2 | 2 | ||
3 | -import com.yohoufo.common.utils.BigDecimalHelper; | ||
4 | import com.yohoufo.order.model.dto.EarnestMoney; | 3 | import com.yohoufo.order.model.dto.EarnestMoney; |
5 | -import com.yohoufo.order.model.dto.PlatformFeeDto; | ||
6 | -import com.yohoufo.order.model.dto.SellerOrderComputeResult; | ||
7 | import com.yohoufo.order.model.dto.ServiceFeeRate; | 4 | import com.yohoufo.order.model.dto.ServiceFeeRate; |
8 | -import com.yohoufo.order.utils.LoggerUtils; | ||
9 | -import org.slf4j.Logger; | ||
10 | -import org.slf4j.LoggerFactory; | ||
11 | -import org.springframework.beans.factory.annotation.Value; | 5 | +import com.yohoufo.order.service.seller.AbsSellerOrderComputeHandler; |
12 | import org.springframework.stereotype.Component; | 6 | import org.springframework.stereotype.Component; |
13 | 7 | ||
14 | -import javax.annotation.PostConstruct; | ||
15 | import java.math.BigDecimal; | 8 | import java.math.BigDecimal; |
16 | 9 | ||
17 | /** | 10 | /** |
18 | * Created by chenchao on 2018/9/14. | 11 | * Created by chenchao on 2018/9/14. |
19 | */ | 12 | */ |
20 | @Component | 13 | @Component |
21 | -public class SellerOrderComputeHandler { | ||
22 | - | ||
23 | - private Logger logger = LoggerUtils.getSellerOrderLogger(); | ||
24 | - | ||
25 | - @Value("${order.seller.earnestmoney.min:28}") | ||
26 | - private double earnestmoney_min; | ||
27 | - @Value("${order.seller.earnestmoney.max:200}") | ||
28 | - private double earnestmoney_max; | ||
29 | - private BigDecimal[] EARNESTMONEYRANGE = new BigDecimal[2]; | ||
30 | - | ||
31 | - @Value("${order.seller.appraiseFee:5}") | ||
32 | - private Double appraiseFee; | ||
33 | - /** | ||
34 | - * 有货包装费(暂定5元) | ||
35 | - */ | ||
36 | - @Value("${order.seller.packageFee:5}") | ||
37 | - private Double packageFee ; | ||
38 | - | ||
39 | - @Value("${order.seller.goodsPaymentRate}") | ||
40 | - private Double goodsPaymentRate = 0.05D; | ||
41 | - | ||
42 | - @Value("${order.seller.earnestMoneyRate}") | ||
43 | - private Double earnestMoneyRate = 0.20D; | ||
44 | - | ||
45 | - @Value("${order.seller.payChannelRate}") | ||
46 | - private Double payChannelRate = 0.006D; | ||
47 | - | ||
48 | - @PostConstruct | ||
49 | - public void init(){ | ||
50 | - EARNESTMONEYRANGE[0] = new BigDecimal(earnestmoney_min); | ||
51 | - EARNESTMONEYRANGE[1] = new BigDecimal(earnestmoney_max); | ||
52 | - } | ||
53 | - | ||
54 | - public BigDecimal[] getEarnestMoneyrange(){ | ||
55 | - return EARNESTMONEYRANGE; | ||
56 | - } | ||
57 | - | ||
58 | - public SellerOrderComputeResult compute(BigDecimal prdPrice){ | ||
59 | - | ||
60 | - //保证金(28-200(按照卖家发布商品的货款金额5%计算,最低28,封顶200)) | ||
61 | - EarnestMoney earnestMoney = calEarnestMoney(prdPrice); | ||
62 | - //init fee rate | ||
63 | - ServiceFeeRate serviceFeeRate = new ServiceFeeRate(); | ||
64 | - serviceFeeRate.setGoodsPaymentRate(new BigDecimal(goodsPaymentRate).setScale(2, BigDecimal.ROUND_HALF_UP)); | ||
65 | - serviceFeeRate.setEarnestMoneyRate(new BigDecimal(earnestMoneyRate).setScale(2, BigDecimal.ROUND_HALF_UP)); | ||
66 | - serviceFeeRate.setPayChannelRate(new BigDecimal(payChannelRate).setScale(4, BigDecimal.ROUND_HALF_UP)); | ||
67 | - // | ||
68 | - PlatformFeeDto platformFeeDto = calPlatformFee(prdPrice, serviceFeeRate.getGoodsPaymentRate()); | ||
69 | - BigDecimal bankTransferFee = calBankTransferFee(prdPrice, serviceFeeRate.getPayChannelRate()); | ||
70 | - logger.info("in SellerOrder Compute, prdPrice {}, platformFee {}, bankTransferFee {}", | ||
71 | - prdPrice, platformFeeDto, bankTransferFee); | ||
72 | - BigDecimal income = calIncome(prdPrice, platformFeeDto.getTotal(), bankTransferFee); | ||
73 | - //set | ||
74 | - SellerOrderComputeResult result = new SellerOrderComputeResult(); | ||
75 | - result.setEarnestMoney(earnestMoney); | ||
76 | - result.setPlatformFee(platformFeeDto); | ||
77 | - result.setIncome(halfUp(income)); | ||
78 | - //TODO 根据配置文件 | ||
79 | - result.setServiceFeeRate(serviceFeeRate); | ||
80 | - result.setBankTransferfee(bankTransferFee); | ||
81 | - return result; | ||
82 | - } | ||
83 | - | ||
84 | - private BigDecimal calBankTransferFee(BigDecimal prdPrice, BigDecimal payServiceFeeRate){ | ||
85 | - //支付渠道转账费率(0.6%) | ||
86 | - return halfUp(prdPrice.multiply(payServiceFeeRate)); | ||
87 | - } | ||
88 | - | ||
89 | - /** | ||
90 | - * (1-X-Z)*B-D-E * | ||
91 | - B:货款(卖家发布商品自行输入); | ||
92 | - D:有货鉴定费(暂定5元); | ||
93 | - E:有货包装费(暂定5元); | ||
94 | - X:货款抽成(暂定5%,后期可调整,上线初期为0,后期活动可根据活动进行减免,每个卖家可收费不一样); | ||
95 | - Z:支付渠道费,调用银联支付接口时实时扣款(支付宝0.55%、微信均为0.6%,统一对用户收取0.6%,前期优惠策略可暂定0) | ||
96 | - * @param prdPrice | ||
97 | - * @param platformFee | ||
98 | - * @return | ||
99 | - */ | ||
100 | - private BigDecimal calIncome(BigDecimal prdPrice,BigDecimal platformFee,BigDecimal bankTransferFee){ | ||
101 | - return prdPrice.subtract(platformFee).subtract(bankTransferFee); | ||
102 | - } | ||
103 | - | ||
104 | - public Double getAppraiseFee() { | ||
105 | - return appraiseFee; | ||
106 | - } | ||
107 | - | ||
108 | - public Double getPackageFee() { | ||
109 | - return packageFee; | ||
110 | - } | ||
111 | - | ||
112 | - /** | ||
113 | - * 通过相加得出的数据 | ||
114 | - * 服务费参与计算后需要考虑精度问题(四舍五入) | ||
115 | - * @return | ||
116 | - */ | ||
117 | - private PlatformFeeDto calPlatformFee(BigDecimal price, BigDecimal goodsServiceRate){ | ||
118 | - PlatformFeeDto platformFee = new PlatformFeeDto(); | ||
119 | - BigDecimal appraiseFee = new BigDecimal(getAppraiseFee()); | ||
120 | - BigDecimal packageFee = new BigDecimal(getPackageFee()); | ||
121 | - BigDecimal serviceFee = price.multiply(goodsServiceRate); | ||
122 | - | ||
123 | - platformFee.setAppraiseFee(halfUp(appraiseFee)); | ||
124 | - platformFee.setPackageFee(halfUp(packageFee)); | ||
125 | - BigDecimal total = appraiseFee.add(packageFee).add(serviceFee); | ||
126 | - | ||
127 | - platformFee.setTotal(halfUp(total)); | ||
128 | - platformFee.setServiceFee(halfUp(serviceFee)); | ||
129 | - return platformFee; | ||
130 | - } | 14 | +public class SellerOrderComputeHandler extends AbsSellerOrderComputeHandler{ |
131 | 15 | ||
132 | /** | 16 | /** |
133 | * 相对独立 不涉及到计算其他费用 | 17 | * 相对独立 不涉及到计算其他费用 |
134 | * @param prdPrice | 18 | * @param prdPrice |
135 | * @return | 19 | * @return |
136 | */ | 20 | */ |
137 | - private EarnestMoney calEarnestMoney(BigDecimal prdPrice){ | 21 | + protected EarnestMoney calEarnestMoney(BigDecimal prdPrice){ |
22 | + BigDecimal[] EARNEST_MONEY_RANGE = orderDynamicConfig.getEMR(); | ||
138 | EarnestMoney earnestMoney = new EarnestMoney(); | 23 | EarnestMoney earnestMoney = new EarnestMoney(); |
139 | - | ||
140 | BigDecimal real = halfUp(prdPrice.multiply(earnestMoney.getRate())); | 24 | BigDecimal real = halfUp(prdPrice.multiply(earnestMoney.getRate())); |
141 | - final BigDecimal min = EARNESTMONEYRANGE[0] == null ? earnestMoney.getMin() : EARNESTMONEYRANGE[0]; | ||
142 | - final BigDecimal max = EARNESTMONEYRANGE[1] == null ? earnestMoney.getMax() : EARNESTMONEYRANGE[1]; | ||
143 | - if(real.subtract(min).doubleValue() < 0D){ | 25 | + final BigDecimal min = EARNEST_MONEY_RANGE[0] == null ? earnestMoney.getMin() : EARNEST_MONEY_RANGE[0]; |
26 | + final BigDecimal max = EARNEST_MONEY_RANGE[1] == null ? earnestMoney.getMax() : EARNEST_MONEY_RANGE[1]; | ||
27 | + if(real.compareTo(min) < 0){ | ||
144 | real = min; | 28 | real = min; |
145 | } | 29 | } |
146 | - if (real.subtract(max).doubleValue() > 0D){ | 30 | + if (real.compareTo(max) > 0){ |
147 | real = max; | 31 | real = max; |
148 | } | 32 | } |
149 | earnestMoney.setMin(min); | 33 | earnestMoney.setMin(min); |
@@ -152,7 +36,11 @@ public class SellerOrderComputeHandler { | @@ -152,7 +36,11 @@ public class SellerOrderComputeHandler { | ||
152 | return earnestMoney; | 36 | return earnestMoney; |
153 | } | 37 | } |
154 | 38 | ||
155 | - private BigDecimal halfUp(BigDecimal fee){ | ||
156 | - return BigDecimalHelper.halfUp(fee); | 39 | + @Override |
40 | + protected ServiceFeeRate buildServiceFeeRate() { | ||
41 | + ServiceFeeRate serviceFeeRate = orderDynamicConfig.getServiceFeeRate(); | ||
42 | + return serviceFeeRate; | ||
157 | } | 43 | } |
44 | + | ||
45 | + | ||
158 | } | 46 | } |
1 | package com.yohoufo.order.service.impl; | 1 | package com.yohoufo.order.service.impl; |
2 | 2 | ||
3 | import com.yohoufo.common.utils.BigDecimalHelper; | 3 | import com.yohoufo.common.utils.BigDecimalHelper; |
4 | +import com.yohoufo.order.model.dto.ServiceFeeRate; | ||
4 | import lombok.Data; | 5 | import lombok.Data; |
5 | import lombok.Getter; | 6 | import lombok.Getter; |
6 | import org.slf4j.Logger; | 7 | import org.slf4j.Logger; |
@@ -14,12 +15,40 @@ import java.math.BigDecimal; | @@ -14,12 +15,40 @@ import java.math.BigDecimal; | ||
14 | /** | 15 | /** |
15 | * Created by chao.chen on 2018/11/15. | 16 | * Created by chao.chen on 2018/11/15. |
16 | */ | 17 | */ |
17 | -@Component("orderDynamicConfig") | ||
18 | - | 18 | +@Component |
19 | public class OrderDynamicConfig { | 19 | public class OrderDynamicConfig { |
20 | 20 | ||
21 | final private Logger logger = LoggerFactory.getLogger(getClass()); | 21 | final private Logger logger = LoggerFactory.getLogger(getClass()); |
22 | 22 | ||
23 | + @Value("${order.seller.earnestmoney.min:28}") | ||
24 | + protected double earnestmoney_min; | ||
25 | + | ||
26 | + @Value("${order.seller.earnestmoney.max:200}") | ||
27 | + protected double earnestmoney_max; | ||
28 | + /** | ||
29 | + * 货款抽成费率 | ||
30 | + */ | ||
31 | + @Value("${order.seller.goodsPaymentRate}") | ||
32 | + private Double goodsPaymentRate = 0.05D; | ||
33 | + | ||
34 | + /** | ||
35 | + * 保证金抽成费率 | ||
36 | + */ | ||
37 | + @Value("${order.seller.earnestMoneyRate}") | ||
38 | + private Double earnestMoneyRate = 0.20D; | ||
39 | + | ||
40 | + /** | ||
41 | + * (主要是第三方,支付宝 or 微信)支付渠道手续费率 | ||
42 | + */ | ||
43 | + @Value("${order.seller.payChannelRate}") | ||
44 | + private Double payChannelRate = 0.006D; | ||
45 | + | ||
46 | + /** | ||
47 | + * 保证金上下限阈值 | ||
48 | + */ | ||
49 | + private BigDecimal[] EARNEST_MONEY_RANGE = new BigDecimal[2]; | ||
50 | + | ||
51 | + | ||
23 | @Data | 52 | @Data |
24 | public static class BuyerCancelCompensateNode{ | 53 | public static class BuyerCancelCompensateNode{ |
25 | /** | 54 | /** |
@@ -70,40 +99,30 @@ public class OrderDynamicConfig { | @@ -70,40 +99,30 @@ public class OrderDynamicConfig { | ||
70 | */ | 99 | */ |
71 | private BuyerCancelCompensateNode beforeDepotReceiveBCCN; | 100 | private BuyerCancelCompensateNode beforeDepotReceiveBCCN; |
72 | 101 | ||
102 | + @Getter | ||
103 | + private ServiceFeeRate serviceFeeRate; | ||
73 | 104 | ||
74 | - | 105 | + @PostConstruct |
75 | private void init() { | 106 | private void init() { |
76 | - BigDecimal buyerCancelUnDeliveryMoney , beforeSellerDeliverRate; | ||
77 | - BigDecimal buyerCancelDeliveryMoney, beforeDepotReceiveRate; | ||
78 | - try { | ||
79 | - buyerCancelDeliveryMoney = new BigDecimal(buyerCancelUnDelivery); | ||
80 | - beforeSellerDeliverRate = new BigDecimal( sellerGetRateUnDelivery); | ||
81 | - | ||
82 | - //包装结构时做格式化,之前请保留有效位 | ||
83 | - beforeSellerDeliverBCCN = new BuyerCancelCompensateNode(BigDecimalHelper.halfUp(buyerCancelDeliveryMoney), | ||
84 | - BigDecimalHelper.halfUp(beforeSellerDeliverRate) ); | ||
85 | - | ||
86 | - buyerCancelUnDeliveryMoney = new BigDecimal(buyerCancelDelivery); | ||
87 | - beforeDepotReceiveRate = new BigDecimal(sellerGetRateDelivery); | ||
88 | - beforeDepotReceiveBCCN = new BuyerCancelCompensateNode(buyerCancelUnDeliveryMoney, beforeDepotReceiveRate); | ||
89 | - } catch (Exception e) { | ||
90 | - logger.error("买家取消罚款金额相关参数配置错误!", e); | ||
91 | - throw new Error("买家取消罚款金额相关参数配置错误!"); | ||
92 | - } | ||
93 | - if (buyerCancelDeliveryMoney.compareTo(BigDecimal.ZERO) < 0) { | ||
94 | - throw new Error("buyerCancelDeliveryMoney买家取消(货已寄出)罚款金额不能为负数"); | ||
95 | - } | ||
96 | - if (buyerCancelUnDeliveryMoney.compareTo(BigDecimal.ZERO) < 0) { | ||
97 | - throw new Error("buyerCancelUnDeliveryMoney买家取消(货未寄出)罚款金额不能为负数"); | ||
98 | - } | ||
99 | - if (beforeDepotReceiveRate.compareTo(BigDecimal.ZERO) < 0 | ||
100 | - || beforeDepotReceiveRate.compareTo(BigDecimal.ONE) > 0) { | ||
101 | - throw new Error("sellerGetRateDeliveryMoney买家取消(货已寄出)卖家获得赔偿比率必须在[0,1]"); | ||
102 | - } | ||
103 | - if (beforeSellerDeliverRate.compareTo(BigDecimal.ZERO) < 0 | ||
104 | - || beforeSellerDeliverRate.compareTo(BigDecimal.ONE) > 0) { | ||
105 | - throw new Error("sellerGetRateUnDeliveryMoney买家取消(货未寄出)卖家获得赔偿比率必须在[0,1]"); | ||
106 | - } | 107 | + EARNEST_MONEY_RANGE[0] = new BigDecimal(earnestmoney_min); |
108 | + EARNEST_MONEY_RANGE[1] = new BigDecimal(earnestmoney_max); | ||
109 | + | ||
110 | + // | ||
111 | + //ServiceFeeRate buildServiceFeeRate() { | ||
112 | + serviceFeeRate = new ServiceFeeRate(); | ||
113 | + serviceFeeRate.setGoodsPaymentRate(new BigDecimal(goodsPaymentRate).setScale(2, BigDecimal.ROUND_HALF_UP)); | ||
114 | + serviceFeeRate.setEarnestMoneyRate(new BigDecimal(earnestMoneyRate).setScale(2, BigDecimal.ROUND_HALF_UP)); | ||
115 | + serviceFeeRate.setPayChannelRate(new BigDecimal(payChannelRate).setScale(4, BigDecimal.ROUND_HALF_UP)); | ||
107 | } | 116 | } |
108 | 117 | ||
118 | + | ||
119 | + | ||
120 | + /** | ||
121 | + * | ||
122 | + * EMR : EarnestMoneyRange | ||
123 | + * @return | ||
124 | + */ | ||
125 | + public BigDecimal[] getEMR(){ | ||
126 | + return EARNEST_MONEY_RANGE; | ||
127 | + } | ||
109 | } | 128 | } |
1 | +package com.yohoufo.order.service.seller; | ||
2 | + | ||
3 | +import com.yohoufo.common.utils.BigDecimalHelper; | ||
4 | +import com.yohoufo.order.model.dto.EarnestMoney; | ||
5 | +import com.yohoufo.order.model.dto.PlatformFeeDto; | ||
6 | +import com.yohoufo.order.model.dto.SellerOrderComputeResult; | ||
7 | +import com.yohoufo.order.model.dto.ServiceFeeRate; | ||
8 | +import com.yohoufo.order.service.impl.OrderDynamicConfig; | ||
9 | +import com.yohoufo.order.utils.LoggerUtils; | ||
10 | +import org.slf4j.Logger; | ||
11 | +import org.springframework.beans.factory.annotation.Autowired; | ||
12 | +import org.springframework.beans.factory.annotation.Value; | ||
13 | + | ||
14 | +import java.math.BigDecimal; | ||
15 | + | ||
16 | +/** | ||
17 | + * Created by chao.chen on 2019/2/1. | ||
18 | + */ | ||
19 | +public abstract class AbsSellerOrderComputeHandler { | ||
20 | + | ||
21 | + protected Logger logger = LoggerUtils.getSellerOrderLogger(); | ||
22 | + | ||
23 | + | ||
24 | + @Autowired | ||
25 | + protected OrderDynamicConfig orderDynamicConfig; | ||
26 | + /** | ||
27 | + * 鉴定费 | ||
28 | + */ | ||
29 | + @Value("${order.seller.appraiseFee:5}") | ||
30 | + private Double appraiseFee; | ||
31 | + /** | ||
32 | + * 有货包装费(暂定5元) | ||
33 | + */ | ||
34 | + @Value("${order.seller.packageFee:5}") | ||
35 | + private Double packageFee ; | ||
36 | + | ||
37 | + | ||
38 | + public SellerOrderComputeResult compute(BigDecimal prdPrice){ | ||
39 | + | ||
40 | + //保证金(28-200(按照卖家发布商品的货款金额5%计算,最低28,封顶200)) | ||
41 | + EarnestMoney earnestMoney = calEarnestMoney(prdPrice); | ||
42 | + //init fee rate | ||
43 | + ServiceFeeRate serviceFeeRate = buildServiceFeeRate(); | ||
44 | + PlatformFeeDto platformFeeDto = calPlatformFee(prdPrice, serviceFeeRate); | ||
45 | + BigDecimal bankTransferFee = calBankTransferFee(prdPrice, serviceFeeRate.getPayChannelRate()); | ||
46 | + logger.info("in SellerOrder Compute, prdPrice {}, platformFee {}, bankTransferFee {}", | ||
47 | + prdPrice, platformFeeDto, bankTransferFee); | ||
48 | + BigDecimal income = calIncome(prdPrice, platformFeeDto.getTotal(), bankTransferFee); | ||
49 | + //set | ||
50 | + SellerOrderComputeResult result = new SellerOrderComputeResult(); | ||
51 | + result.setEarnestMoney(earnestMoney); | ||
52 | + result.setPlatformFee(platformFeeDto); | ||
53 | + result.setIncome(halfUp(income)); | ||
54 | + //TODO 根据配置文件 | ||
55 | + result.setServiceFeeRate(serviceFeeRate); | ||
56 | + result.setBankTransferfee(bankTransferFee); | ||
57 | + return result; | ||
58 | + } | ||
59 | + | ||
60 | + protected BigDecimal halfUp(BigDecimal fee){ | ||
61 | + return BigDecimalHelper.halfUp(fee); | ||
62 | + } | ||
63 | + | ||
64 | + protected abstract EarnestMoney calEarnestMoney(BigDecimal prdPrice); | ||
65 | + | ||
66 | + | ||
67 | + /** | ||
68 | + * (1-X-Z)*B-D-E * | ||
69 | + B:货款(卖家发布商品自行输入); | ||
70 | + D:有货鉴定费(暂定5元); | ||
71 | + E:有货包装费(暂定5元); | ||
72 | + X:货款抽成(暂定5%,后期可调整,上线初期为0,后期活动可根据活动进行减免,每个卖家可收费不一样); | ||
73 | + Z:支付渠道费,调用银联支付接口时实时扣款(支付宝0.55%、微信均为0.6%,统一对用户收取0.6%,前期优惠策略可暂定0) | ||
74 | + * @param prdPrice | ||
75 | + * @param platformFee | ||
76 | + * @return | ||
77 | + */ | ||
78 | + protected BigDecimal calIncome(BigDecimal prdPrice, BigDecimal platformFee, BigDecimal bankTransferFee){ | ||
79 | + return prdPrice.subtract(platformFee).subtract(bankTransferFee); | ||
80 | + } | ||
81 | + | ||
82 | + protected BigDecimal calBankTransferFee(BigDecimal prdPrice, BigDecimal payServiceFeeRate){ | ||
83 | + //支付渠道转账费率(0.6%) | ||
84 | + return halfUp(prdPrice.multiply(payServiceFeeRate)); | ||
85 | + } | ||
86 | + | ||
87 | + /** | ||
88 | + * 通过相加得出的数据 | ||
89 | + * 服务费参与计算后需要考虑精度问题(四舍五入) | ||
90 | + * @return | ||
91 | + */ | ||
92 | + protected PlatformFeeDto calPlatformFee(BigDecimal price, ServiceFeeRate serviceFeeRate){ | ||
93 | + BigDecimal goodsServiceRate = serviceFeeRate.getGoodsPaymentRate(); | ||
94 | + | ||
95 | + | ||
96 | + PlatformFeeDto platformFee = new PlatformFeeDto(); | ||
97 | + | ||
98 | + BigDecimal appraiseFee = new BigDecimal(getAppraiseFee()); | ||
99 | + BigDecimal packageFee = new BigDecimal(getPackageFee()); | ||
100 | + BigDecimal serviceFee = price.multiply(goodsServiceRate); | ||
101 | + | ||
102 | + platformFee.setAppraiseFee(halfUp(appraiseFee)); | ||
103 | + platformFee.setPackageFee(halfUp(packageFee)); | ||
104 | + BigDecimal total = appraiseFee.add(packageFee).add(serviceFee); | ||
105 | + | ||
106 | + platformFee.setTotal(halfUp(total)); | ||
107 | + platformFee.setServiceFee(halfUp(serviceFee)); | ||
108 | + return platformFee; | ||
109 | + } | ||
110 | + | ||
111 | + public Double getAppraiseFee() { | ||
112 | + return appraiseFee; | ||
113 | + } | ||
114 | + | ||
115 | + public Double getPackageFee() { | ||
116 | + return packageFee; | ||
117 | + } | ||
118 | + | ||
119 | + protected abstract ServiceFeeRate buildServiceFeeRate(); | ||
120 | +} |
order/src/main/java/com/yohoufo/order/service/seller/SellerAdvanceOrderComputeHandler.java
0 → 100644
1 | +package com.yohoufo.order.service.seller; | ||
2 | + | ||
3 | +import com.yohoufo.order.model.dto.EarnestMoney; | ||
4 | +import com.yohoufo.order.model.dto.ServiceFeeRate; | ||
5 | +import org.springframework.stereotype.Component; | ||
6 | + | ||
7 | +import java.math.BigDecimal; | ||
8 | + | ||
9 | +/** | ||
10 | + * Created by chao.chen on 2019/2/1. | ||
11 | + */ | ||
12 | +@Component | ||
13 | +public class SellerAdvanceOrderComputeHandler extends AbsSellerOrderComputeHandler { | ||
14 | + @Override | ||
15 | + protected EarnestMoney calEarnestMoney(BigDecimal prdPrice) { | ||
16 | + return null; | ||
17 | + } | ||
18 | + | ||
19 | + @Override | ||
20 | + protected ServiceFeeRate buildServiceFeeRate() { | ||
21 | + return null; | ||
22 | + } | ||
23 | +} |
-
Please register or login to post a comment