Merge branch 'test6.9.16' of http://git.yoho.cn/ufo/yohoufo-fore into test6.9.16
Showing
7 changed files
with
132 additions
and
38 deletions
@@ -11,6 +11,8 @@ import java.util.List; | @@ -11,6 +11,8 @@ import java.util.List; | ||
11 | */ | 11 | */ |
12 | @Data | 12 | @Data |
13 | public class SellerOrderComputeResult { | 13 | public class SellerOrderComputeResult { |
14 | + Integer uid; | ||
15 | + Integer storageId; | ||
14 | BigDecimal prdPrice; | 16 | BigDecimal prdPrice; |
15 | 17 | ||
16 | EarnestMoney earnestMoney; | 18 | EarnestMoney earnestMoney; |
@@ -5,7 +5,6 @@ import com.google.common.collect.Lists; | @@ -5,7 +5,6 @@ import com.google.common.collect.Lists; | ||
5 | import com.yoho.core.rabbitmq.YhProducer; | 5 | import com.yoho.core.rabbitmq.YhProducer; |
6 | import com.yohobuy.ufo.model.order.bo.CustomsClearanceResult; | 6 | import com.yohobuy.ufo.model.order.bo.CustomsClearanceResult; |
7 | import com.yohobuy.ufo.model.order.bo.MerchantOrderAttachInfo; | 7 | import com.yohobuy.ufo.model.order.bo.MerchantOrderAttachInfo; |
8 | -import com.yohobuy.ufo.model.order.common.MetaConfigKey; | ||
9 | import com.yohobuy.ufo.model.order.common.OrderStatus; | 8 | import com.yohobuy.ufo.model.order.common.OrderStatus; |
10 | import com.yohobuy.ufo.model.order.common.SellerOrderStatus; | 9 | import com.yohobuy.ufo.model.order.common.SellerOrderStatus; |
11 | import com.yohobuy.ufo.model.order.common.SkupStatus; | 10 | import com.yohobuy.ufo.model.order.common.SkupStatus; |
@@ -20,7 +19,6 @@ import com.yohoufo.common.alarm.UfoInfluxdbVo; | @@ -20,7 +19,6 @@ import com.yohoufo.common.alarm.UfoInfluxdbVo; | ||
20 | import com.yohoufo.common.constant.InfluxdbFieldEnum; | 19 | import com.yohoufo.common.constant.InfluxdbFieldEnum; |
21 | import com.yohoufo.common.constant.InfluxdbMeasurementEnum; | 20 | import com.yohoufo.common.constant.InfluxdbMeasurementEnum; |
22 | import com.yohoufo.common.exception.UfoServiceException; | 21 | import com.yohoufo.common.exception.UfoServiceException; |
23 | -import com.yohoufo.common.utils.BigDecimalHelper; | ||
24 | import com.yohoufo.common.utils.DateUtil; | 22 | import com.yohoufo.common.utils.DateUtil; |
25 | import com.yohoufo.dal.order.*; | 23 | import com.yohoufo.dal.order.*; |
26 | import com.yohoufo.dal.order.model.*; | 24 | import com.yohoufo.dal.order.model.*; |
@@ -32,7 +30,6 @@ import com.yohoufo.order.constants.ClearanceFailType; | @@ -32,7 +30,6 @@ import com.yohoufo.order.constants.ClearanceFailType; | ||
32 | import com.yohoufo.order.constants.MetaKey; | 30 | import com.yohoufo.order.constants.MetaKey; |
33 | import com.yohoufo.order.event.*; | 31 | import com.yohoufo.order.event.*; |
34 | import com.yohoufo.order.model.PayRefundBo; | 32 | import com.yohoufo.order.model.PayRefundBo; |
35 | -import com.yohoufo.order.model.dto.BuyerPenalty; | ||
36 | import com.yohoufo.order.model.dto.BuyerPenaltyCalResult; | 33 | import com.yohoufo.order.model.dto.BuyerPenaltyCalResult; |
37 | import com.yohoufo.order.model.request.PaymentRequest; | 34 | import com.yohoufo.order.model.request.PaymentRequest; |
38 | import com.yohoufo.order.model.request.TranseferCellNode; | 35 | import com.yohoufo.order.model.request.TranseferCellNode; |
@@ -56,6 +53,7 @@ import lombok.Setter; | @@ -56,6 +53,7 @@ import lombok.Setter; | ||
56 | import lombok.val; | 53 | import lombok.val; |
57 | import org.apache.commons.collections.CollectionUtils; | 54 | import org.apache.commons.collections.CollectionUtils; |
58 | import org.apache.commons.lang3.StringUtils; | 55 | import org.apache.commons.lang3.StringUtils; |
56 | +import org.apache.commons.lang3.tuple.Pair; | ||
59 | import org.slf4j.Logger; | 57 | import org.slf4j.Logger; |
60 | import org.springframework.beans.factory.annotation.Autowired; | 58 | import org.springframework.beans.factory.annotation.Autowired; |
61 | import org.springframework.stereotype.Service; | 59 | import org.springframework.stereotype.Service; |
@@ -64,7 +62,6 @@ import javax.annotation.Resource; | @@ -64,7 +62,6 @@ import javax.annotation.Resource; | ||
64 | import java.math.BigDecimal; | 62 | import java.math.BigDecimal; |
65 | import java.util.Arrays; | 63 | import java.util.Arrays; |
66 | import java.util.List; | 64 | import java.util.List; |
67 | -import java.util.Map; | ||
68 | import java.util.Objects; | 65 | import java.util.Objects; |
69 | import java.util.concurrent.Callable; | 66 | import java.util.concurrent.Callable; |
70 | import java.util.concurrent.ExecutorService; | 67 | import java.util.concurrent.ExecutorService; |
@@ -173,9 +170,10 @@ public class BuyerOrderCancelService { | @@ -173,9 +170,10 @@ public class BuyerOrderCancelService { | ||
173 | logger.info("in buyer cancel BeforeSellerDeliver, event {} BuyerPenaltyCalResult {}", bsdEvent, bpcr); | 170 | logger.info("in buyer cancel BeforeSellerDeliver, event {} BuyerPenaltyCalResult {}", bsdEvent, bpcr); |
174 | //买家实付金额(货款+运费)小于赔偿金的额度,不够赔偿的,则不允许取消 | 171 | //买家实付金额(货款+运费)小于赔偿金的额度,不够赔偿的,则不允许取消 |
175 | BigDecimal penaltyAmount; | 172 | BigDecimal penaltyAmount; |
176 | - if(bsdEvent.getAmount()==null||bsdEvent.getAmount().compareTo(penaltyAmount=bpcr.getPenaltyAmount()) < 0){ | 173 | + Pair<Boolean,UfoServiceException> penaltyAmountIsEnough = checkPenaltyAmount(bsdEvent.getAmount(), penaltyAmount=bpcr.getPenaltyAmount()); |
174 | + if(!penaltyAmountIsEnough.getLeft()){ | ||
177 | logger.warn("in buyer cancel BeforeSellerDeliver not allow cancel cause of buyer amount lower than BuyerCompensateMoney, event {} compensate {}", bsdEvent, bpcr); | 175 | logger.warn("in buyer cancel BeforeSellerDeliver not allow cancel cause of buyer amount lower than BuyerCompensateMoney, event {} compensate {}", bsdEvent, bpcr); |
178 | - throw new com.yohoufo.common.exception.UfoServiceException(400,"买家赔偿金低于商品售价,不允许取消"); | 176 | + throw penaltyAmountIsEnough.getRight(); |
179 | } | 177 | } |
180 | 178 | ||
181 | 179 | ||
@@ -301,6 +299,14 @@ public class BuyerOrderCancelService { | @@ -301,6 +299,14 @@ public class BuyerOrderCancelService { | ||
301 | .cancel(); | 299 | .cancel(); |
302 | } | 300 | } |
303 | 301 | ||
302 | + private Pair<Boolean,UfoServiceException> checkPenaltyAmount(BigDecimal actualPaidAmount, BigDecimal penaltyAmount){ | ||
303 | + boolean isEnough = (actualPaidAmount !=null && actualPaidAmount.compareTo(penaltyAmount) >= 0); | ||
304 | + UfoServiceException ex = null; | ||
305 | + if(!isEnough){ | ||
306 | + ex = new com.yohoufo.common.exception.UfoServiceException(400,"实付金额低于订单违约金,不允许取消"); | ||
307 | + } | ||
308 | + return Pair.of(isEnough, ex); | ||
309 | + } | ||
304 | 310 | ||
305 | public void cancel(BeforeDepotReceiveEvent bdrEvent){ | 311 | public void cancel(BeforeDepotReceiveEvent bdrEvent){ |
306 | int buyerUid = bdrEvent.getBuyerUid(); | 312 | int buyerUid = bdrEvent.getBuyerUid(); |
@@ -315,12 +321,12 @@ public class BuyerOrderCancelService { | @@ -315,12 +321,12 @@ public class BuyerOrderCancelService { | ||
315 | logger.info("in buyer cancel BeforeDepotReceive, event {} compensate {}", bdrEvent, bpcr); | 321 | logger.info("in buyer cancel BeforeDepotReceive, event {} compensate {}", bdrEvent, bpcr); |
316 | //买家实付金额(货款+运费)小于赔偿金的额度,不够赔偿的,则不允许取消 | 322 | //买家实付金额(货款+运费)小于赔偿金的额度,不够赔偿的,则不允许取消 |
317 | BigDecimal penaltyAmount; | 323 | BigDecimal penaltyAmount; |
318 | - if(bdrEvent.getAmount()==null||bdrEvent.getAmount().compareTo(penaltyAmount=bpcr.getPenaltyAmount()) < 0){ | 324 | + Pair<Boolean,UfoServiceException> amountIsEnough = checkPenaltyAmount(bdrEvent.getAmount(), penaltyAmount=bpcr.getPenaltyAmount()); |
325 | + if(!amountIsEnough.getLeft()){ | ||
319 | logger.warn("in buyer cancel BeforeDepotReceive not allow cancel cause of buyer amount lower than BuyerCompensateMoney, event {} compensate {}", bdrEvent, bpcr); | 326 | logger.warn("in buyer cancel BeforeDepotReceive not allow cancel cause of buyer amount lower than BuyerCompensateMoney, event {} compensate {}", bdrEvent, bpcr); |
320 | - throw new com.yohoufo.common.exception.UfoServiceException(400,"买家赔偿金低于商品售价,不允许取消"); | 327 | + throw amountIsEnough.getRight(); |
321 | } | 328 | } |
322 | 329 | ||
323 | - | ||
324 | OrderStatus expected = bdrEvent.getExpected(); | 330 | OrderStatus expected = bdrEvent.getExpected(); |
325 | int currentTime = DateUtil.getCurrentTimeSecond(); | 331 | int currentTime = DateUtil.getCurrentTimeSecond(); |
326 | int rows = buyerOrderMapper.updateStatusByOrderCode(orderCode, buyerUid, expected.getCode(), targetOrderStatus.getCode(), currentTime); | 332 | int rows = buyerOrderMapper.updateStatusByOrderCode(orderCode, buyerUid, expected.getCode(), targetOrderStatus.getCode(), currentTime); |
@@ -131,7 +131,7 @@ public class SellerBidPublishService { | @@ -131,7 +131,7 @@ public class SellerBidPublishService { | ||
131 | .storageId(storageId).prdPrice(saleableBidSkup.getPrice()).build(); | 131 | .storageId(storageId).prdPrice(saleableBidSkup.getPrice()).build(); |
132 | priceComputePrepareProcessor.checkPulishAuthNPriceRange(pqr, true); | 132 | priceComputePrepareProcessor.checkPulishAuthNPriceRange(pqr, true); |
133 | 133 | ||
134 | - SellerOrderComputeResult pcc = getSellerBidGoodsFeeRate(uid, skupType); | 134 | + SellerOrderComputeResult pcc = getSellerBidGoodsFeeRate(uid, storageId, skupType); |
135 | 135 | ||
136 | OrderComputeHandler computeHandler = orderComputeProvider.findBySkupType(skupType); | 136 | OrderComputeHandler computeHandler = orderComputeProvider.findBySkupType(skupType); |
137 | SellerOrderComputeResult computeResult = computeHandler.compute(saleableBidSkup.getPrice(), pcc); | 137 | SellerOrderComputeResult computeResult = computeHandler.compute(saleableBidSkup.getPrice(), pcc); |
@@ -227,13 +227,15 @@ public class SellerBidPublishService { | @@ -227,13 +227,15 @@ public class SellerBidPublishService { | ||
227 | return Pair.of(noHiddenBackAddress, hiddenBackAddress); | 227 | return Pair.of(noHiddenBackAddress, hiddenBackAddress); |
228 | } | 228 | } |
229 | 229 | ||
230 | - public SellerOrderComputeResult getSellerBidGoodsFeeRate(int uid, SkupType skupType) { | 230 | + public SellerOrderComputeResult getSellerBidGoodsFeeRate(int uid, int storageId, SkupType skupType) { |
231 | logger.info("in getSellerBidGoodsFeeRate uid {}, skupType {}", | 231 | logger.info("in getSellerBidGoodsFeeRate uid {}, skupType {}", |
232 | uid, skupType); | 232 | uid, skupType); |
233 | ServiceFeeRate rate = getSellerBidGoodsFeeRate(skupType); | 233 | ServiceFeeRate rate = getSellerBidGoodsFeeRate(skupType); |
234 | List<ServiceFeeRate> allConfig = Lists.newArrayList(rate); | 234 | List<ServiceFeeRate> allConfig = Lists.newArrayList(rate); |
235 | SellerOrderComputeResult socr = new SellerOrderComputeResult(); | 235 | SellerOrderComputeResult socr = new SellerOrderComputeResult(); |
236 | socr.setServiceFeeRates(allConfig); | 236 | socr.setServiceFeeRates(allConfig); |
237 | + socr.setUid(uid); | ||
238 | + socr.setStorageId(storageId); | ||
237 | return socr; | 239 | return socr; |
238 | } | 240 | } |
239 | 241 |
@@ -5,8 +5,6 @@ import com.yohoufo.common.utils.BigDecimalHelper; | @@ -5,8 +5,6 @@ import com.yohoufo.common.utils.BigDecimalHelper; | ||
5 | import com.yohoufo.order.model.dto.*; | 5 | import com.yohoufo.order.model.dto.*; |
6 | import com.yohoufo.order.service.impl.MetaConfigService; | 6 | import com.yohoufo.order.service.impl.MetaConfigService; |
7 | import com.yohoufo.order.service.impl.OrderDynamicConfig; | 7 | import com.yohoufo.order.service.impl.OrderDynamicConfig; |
8 | -import com.yohoufo.order.service.seller.fee.GoodsServiceFeeRateDimension; | ||
9 | -import com.yohoufo.order.service.seller.fee.GoodsServiceFeeRateWrapper; | ||
10 | import com.yohoufo.order.utils.LoggerUtils; | 8 | import com.yohoufo.order.utils.LoggerUtils; |
11 | import org.apache.commons.collections.CollectionUtils; | 9 | import org.apache.commons.collections.CollectionUtils; |
12 | import org.apache.commons.lang3.tuple.Pair; | 10 | import org.apache.commons.lang3.tuple.Pair; |
@@ -50,21 +48,23 @@ public abstract class AbsSellerOrderComputeHandler implements OrderComputeHandle | @@ -50,21 +48,23 @@ public abstract class AbsSellerOrderComputeHandler implements OrderComputeHandle | ||
50 | @Override | 48 | @Override |
51 | public SellerOrderComputeResult compute(BigDecimal prdPrice, | 49 | public SellerOrderComputeResult compute(BigDecimal prdPrice, |
52 | SellerOrderComputeResult personalComputeConfig){ | 50 | SellerOrderComputeResult personalComputeConfig){ |
53 | - | 51 | + final boolean personalComputeConfigExist; |
52 | + Integer uid = (personalComputeConfigExist= Objects.nonNull(personalComputeConfig)) ? personalComputeConfig.getUid() : null; | ||
53 | + Integer storageId = personalComputeConfigExist ? personalComputeConfig.getStorageId() : null; | ||
54 | //计算保证金(28-200(按照卖家发布商品的货款金额5%计算,最低28,封顶200)) | 54 | //计算保证金(28-200(按照卖家发布商品的货款金额5%计算,最低28,封顶200)) |
55 | EarnestMoney earnestMoney = calEarnestMoney(prdPrice); | 55 | EarnestMoney earnestMoney = calEarnestMoney(prdPrice); |
56 | //init fee rate | 56 | //init fee rate |
57 | - List<ServiceFeeRate> psfr = personalComputeConfig!=null ? personalComputeConfig.getServiceFeeRates() : null; | 57 | + List<ServiceFeeRate> psfr = personalComputeConfigExist ? personalComputeConfig.getServiceFeeRates() : null; |
58 | //目前根据商品类型匹配费率,未来的趋势是有多维度配置,根据策略择优 | 58 | //目前根据商品类型匹配费率,未来的趋势是有多维度配置,根据策略择优 |
59 | - PlatformFeeDto ppf = personalComputeConfig!=null ? personalComputeConfig.getPlatformFee() : null; | 59 | + PlatformFeeDto ppf = personalComputeConfigExist ? personalComputeConfig.getPlatformFee() : null; |
60 | //计算平台费用:1.鉴定费 2.包装费 3.货款抽成 | 60 | //计算平台费用:1.鉴定费 2.包装费 3.货款抽成 |
61 | - Pair<ServiceFeeRate,PlatformFeeDto> calPlatformFee = calPlatformFee(prdPrice, psfr, ppf); | 61 | + Pair<ServiceFeeRate,PlatformFeeDto> calPlatformFee = calPlatformFee(uid, storageId, prdPrice, psfr, ppf); |
62 | ServiceFeeRate serviceFeeRate = calPlatformFee.getLeft(); | 62 | ServiceFeeRate serviceFeeRate = calPlatformFee.getLeft(); |
63 | PlatformFeeDto platformFeeDto = calPlatformFee.getRight(); | 63 | PlatformFeeDto platformFeeDto = calPlatformFee.getRight(); |
64 | //计算支付服务费 | 64 | //计算支付服务费 |
65 | BigDecimal bankTransferFee = calBankTransferFee(prdPrice, serviceFeeRate.getPayChannelRate()); | 65 | BigDecimal bankTransferFee = calBankTransferFee(prdPrice, serviceFeeRate.getPayChannelRate()); |
66 | - logger.info("in SellerOrder Compute, prdPrice {}, platformFee {}, bankTransferFee {}", | ||
67 | - prdPrice, platformFeeDto, bankTransferFee); | 66 | + logger.info("in SellerOrder Compute,uid {} storageId {}, prdPrice {}, platformFee {}, bankTransferFee {}", |
67 | + uid, storageId, prdPrice, platformFeeDto, bankTransferFee); | ||
68 | //计算收入 | 68 | //计算收入 |
69 | BigDecimal income = calIncome(prdPrice, platformFeeDto.getTotal(), bankTransferFee); | 69 | BigDecimal income = calIncome(prdPrice, platformFeeDto.getTotal(), bankTransferFee); |
70 | //目前只有预售有买家和卖家阶梯处罚 | 70 | //目前只有预售有买家和卖家阶梯处罚 |
@@ -151,7 +151,11 @@ public abstract class AbsSellerOrderComputeHandler implements OrderComputeHandle | @@ -151,7 +151,11 @@ public abstract class AbsSellerOrderComputeHandler implements OrderComputeHandle | ||
151 | * 服务费参与计算后需要考虑精度问题(四舍五入) | 151 | * 服务费参与计算后需要考虑精度问题(四舍五入) |
152 | * @return | 152 | * @return |
153 | */ | 153 | */ |
154 | - protected Pair<ServiceFeeRate,PlatformFeeDto> calPlatformFee(BigDecimal price, List<ServiceFeeRate> serviceFeeRates, PlatformFeeDto ppf){ | 154 | + protected Pair<ServiceFeeRate,PlatformFeeDto> calPlatformFee(Integer uid, |
155 | + Integer storageId, | ||
156 | + BigDecimal price, | ||
157 | + List<ServiceFeeRate> serviceFeeRates, | ||
158 | + PlatformFeeDto ppf){ | ||
155 | 159 | ||
156 | 160 | ||
157 | PlatformFeeDto platformFee = new PlatformFeeDto(); | 161 | PlatformFeeDto platformFee = new PlatformFeeDto(); |
@@ -173,7 +177,7 @@ public abstract class AbsSellerOrderComputeHandler implements OrderComputeHandle | @@ -173,7 +177,7 @@ public abstract class AbsSellerOrderComputeHandler implements OrderComputeHandle | ||
173 | } | 177 | } |
174 | //目前而言,商品抽成的阈值只有公共配置 | 178 | //目前而言,商品抽成的阈值只有公共配置 |
175 | PriceRange defaultGoodsServiceFeeRange = pfc.getGoodsServiceFeeRange(); | 179 | PriceRange defaultGoodsServiceFeeRange = pfc.getGoodsServiceFeeRange(); |
176 | - ChooseServiceReeRateAndCalServiceFeeModel chooseServiceReeRateAndCalServiceFee = new ChooseServiceReeRateAndCalServiceFeeModel(price, serviceFeeRates, defaultGoodsServiceFeeRange) | 180 | + ChooseServiceReeRateAndCalServiceFeeModel chooseServiceReeRateAndCalServiceFee = new ChooseServiceReeRateAndCalServiceFeeModel(uid, storageId, price, serviceFeeRates, defaultGoodsServiceFeeRange) |
177 | .invoke(); | 181 | .invoke(); |
178 | ServiceFeeRate serviceFeeRate = chooseServiceReeRateAndCalServiceFee.getServiceFeeRate(); | 182 | ServiceFeeRate serviceFeeRate = chooseServiceReeRateAndCalServiceFee.getServiceFeeRate(); |
179 | BigDecimal serviceFee = chooseServiceReeRateAndCalServiceFee.getServiceFee(); | 183 | BigDecimal serviceFee = chooseServiceReeRateAndCalServiceFee.getServiceFee(); |
@@ -231,13 +235,21 @@ public abstract class AbsSellerOrderComputeHandler implements OrderComputeHandle | @@ -231,13 +235,21 @@ public abstract class AbsSellerOrderComputeHandler implements OrderComputeHandle | ||
231 | protected abstract Collection<BuyerPenalty.Fee> buildStagedCollection(); | 235 | protected abstract Collection<BuyerPenalty.Fee> buildStagedCollection(); |
232 | 236 | ||
233 | private class ChooseServiceReeRateAndCalServiceFeeModel { | 237 | private class ChooseServiceReeRateAndCalServiceFeeModel { |
238 | + private Integer uid; | ||
239 | + private Integer storageId; | ||
234 | private BigDecimal price; | 240 | private BigDecimal price; |
235 | private List<ServiceFeeRate> serviceFeeRates; | 241 | private List<ServiceFeeRate> serviceFeeRates; |
236 | private PriceRange defaultGoodsServiceFeeRange; | 242 | private PriceRange defaultGoodsServiceFeeRange; |
237 | private ServiceFeeRate serviceFeeRate; | 243 | private ServiceFeeRate serviceFeeRate; |
238 | private BigDecimal serviceFee; | 244 | private BigDecimal serviceFee; |
239 | 245 | ||
240 | - public ChooseServiceReeRateAndCalServiceFeeModel(BigDecimal price, List<ServiceFeeRate> serviceFeeRates, PriceRange defaultGoodsServiceFeeRange) { | 246 | + public ChooseServiceReeRateAndCalServiceFeeModel(Integer uid, |
247 | + Integer storageId, | ||
248 | + BigDecimal price, | ||
249 | + List<ServiceFeeRate> serviceFeeRates, | ||
250 | + PriceRange defaultGoodsServiceFeeRange) { | ||
251 | + this.uid = uid; | ||
252 | + this.storageId = storageId; | ||
241 | this.price = price; | 253 | this.price = price; |
242 | this.serviceFeeRates = serviceFeeRates; | 254 | this.serviceFeeRates = serviceFeeRates; |
243 | this.defaultGoodsServiceFeeRange = defaultGoodsServiceFeeRange; | 255 | this.defaultGoodsServiceFeeRange = defaultGoodsServiceFeeRange; |
@@ -256,16 +268,27 @@ public abstract class AbsSellerOrderComputeHandler implements OrderComputeHandle | @@ -256,16 +268,27 @@ public abstract class AbsSellerOrderComputeHandler implements OrderComputeHandle | ||
256 | serviceFeeRate = buildDefaultServiceFeeRate(); | 268 | serviceFeeRate = buildDefaultServiceFeeRate(); |
257 | serviceFee = calServiceFee(price, serviceFeeRate, defaultGoodsServiceFeeRange); | 269 | serviceFee = calServiceFee(price, serviceFeeRate, defaultGoodsServiceFeeRange); |
258 | } else { | 270 | } else { |
259 | - for (ServiceFeeRate e : serviceFeeRates) { | ||
260 | - PriceRange priceRange = Objects.nonNull(e.getGoodsPaymentPriceRange()) ? e.getGoodsPaymentPriceRange() : defaultGoodsServiceFeeRange; | ||
261 | - BigDecimal tmp = calServiceFee(price, e, priceRange); | ||
262 | - if (Objects.isNull(serviceFee) || serviceFee.compareTo(tmp) > 0) { | ||
263 | - serviceFeeRate = e; | ||
264 | - serviceFee = tmp; | ||
265 | - } | ||
266 | - } | 271 | + ServiceFeeRate minSFR = matchMinRate(serviceFeeRates); |
272 | + logger.info("compute CalServiceFee uid {} storageId {} price {} serviceFeeRates {} defaultGoodsServiceFeeRange {} minSFR{}", | ||
273 | + uid, storageId, price, serviceFeeRates, defaultGoodsServiceFeeRange, minSFR); | ||
274 | + PriceRange priceRange = Objects.nonNull(minSFR.getGoodsPaymentPriceRange()) ? minSFR.getGoodsPaymentPriceRange() : defaultGoodsServiceFeeRange; | ||
275 | + BigDecimal tmp = calServiceFee(price, minSFR, priceRange); | ||
276 | + serviceFeeRate = minSFR; | ||
277 | + serviceFee = tmp; | ||
267 | } | 278 | } |
268 | return this; | 279 | return this; |
269 | } | 280 | } |
281 | + | ||
282 | + private ServiceFeeRate matchMinRate(List<ServiceFeeRate> serviceFeeRates){ | ||
283 | + ServiceFeeRate min = null; | ||
284 | + for (ServiceFeeRate e : serviceFeeRates) { | ||
285 | + if (Objects.isNull(min) || min.getGoodsPaymentRate().compareTo(e.getGoodsPaymentRate()) > 0) { | ||
286 | + min = e; | ||
287 | + } | ||
288 | + } | ||
289 | + return min; | ||
290 | + } | ||
270 | } | 291 | } |
292 | + | ||
293 | + | ||
271 | } | 294 | } |
@@ -17,10 +17,8 @@ import org.springframework.beans.factory.annotation.Autowired; | @@ -17,10 +17,8 @@ import org.springframework.beans.factory.annotation.Autowired; | ||
17 | import org.springframework.stereotype.Service; | 17 | import org.springframework.stereotype.Service; |
18 | 18 | ||
19 | import java.math.BigDecimal; | 19 | import java.math.BigDecimal; |
20 | -import java.util.Comparator; | ||
21 | import java.util.List; | 20 | import java.util.List; |
22 | import java.util.Objects; | 21 | import java.util.Objects; |
23 | -import java.util.Optional; | ||
24 | 22 | ||
25 | @Service | 23 | @Service |
26 | public class GoodsAmountService { | 24 | public class GoodsAmountService { |
@@ -60,6 +58,8 @@ public class GoodsAmountService { | @@ -60,6 +58,8 @@ public class GoodsAmountService { | ||
60 | 58 | ||
61 | SellerOrderComputeResult socr = new SellerOrderComputeResult(); | 59 | SellerOrderComputeResult socr = new SellerOrderComputeResult(); |
62 | socr.setServiceFeeRates(allConfig); | 60 | socr.setServiceFeeRates(allConfig); |
61 | + socr.setUid(uid); | ||
62 | + socr.setStorageId(storageId); | ||
63 | return socr; | 63 | return socr; |
64 | } | 64 | } |
65 | 65 |
1 | package com.yohoufo.order.service.seller; | 1 | package com.yohoufo.order.service.seller; |
2 | 2 | ||
3 | import com.alibaba.fastjson.JSONObject; | 3 | import com.alibaba.fastjson.JSONObject; |
4 | +import com.google.common.collect.Lists; | ||
5 | +import com.yohobuy.ufo.model.order.bo.SoldPrdComputeBo; | ||
6 | +import com.yohobuy.ufo.model.order.constants.SkupType; | ||
7 | +import com.yohoufo.order.BaseWebTest; | ||
8 | +import com.yohoufo.order.convert.SellerOrderConvertor; | ||
9 | +import com.yohoufo.order.model.dto.PriceRange; | ||
4 | import com.yohoufo.order.model.dto.SellerOrderComputeResult; | 10 | import com.yohoufo.order.model.dto.SellerOrderComputeResult; |
11 | +import com.yohoufo.order.model.dto.ServiceFeeRate; | ||
12 | +import com.yohoufo.order.service.proxy.ResourcesProxyService; | ||
13 | +import com.yohoufo.order.service.seller.fee.GoodsServiceFeeRateDimension; | ||
14 | +import com.yohoufo.order.service.seller.fee.GoodsServiceFeeRateWrapper; | ||
5 | import com.yohoufo.order.service.seller.inStock.SellerOrderComputeHandler; | 15 | import com.yohoufo.order.service.seller.inStock.SellerOrderComputeHandler; |
6 | import org.junit.Test; | 16 | import org.junit.Test; |
17 | +import org.springframework.beans.factory.annotation.Autowired; | ||
7 | 18 | ||
8 | import java.math.BigDecimal; | 19 | import java.math.BigDecimal; |
20 | +import java.util.HashMap; | ||
21 | +import java.util.List; | ||
22 | +import java.util.Map; | ||
23 | +import java.util.function.Supplier; | ||
9 | 24 | ||
10 | /** | 25 | /** |
11 | * Created by chenchao on 2018/9/14. | 26 | * Created by chenchao on 2018/9/14. |
12 | */ | 27 | */ |
13 | -public class SellerOrderServiceTest { | 28 | +public class SellerOrderServiceTest extends BaseWebTest { |
29 | + | ||
30 | + @Autowired | ||
31 | + private OrderComputeProvider orderComputeProvider; | ||
14 | 32 | ||
15 | @Test | 33 | @Test |
16 | public void testBuildSoldPrdComputeBo(){ | 34 | public void testBuildSoldPrdComputeBo(){ |
17 | - SellerOrderComputeHandler sos = new SellerOrderComputeHandler(); | ||
18 | - BigDecimal prdPrice = new BigDecimal(100D); | ||
19 | - SellerOrderComputeResult bo = sos.compute(prdPrice, null); | 35 | + SkupType skupType = SkupType.IN_STOCK; |
36 | + OrderComputeHandler sos = orderComputeProvider.findBySkupType(skupType); | ||
37 | + BigDecimal prdPrice = new BigDecimal(5009D); | ||
38 | + | ||
39 | + PriceRange goodsPaymentPriceRange; | ||
40 | + ServiceFeeRate serviceFeeRateOnDB = new ServiceFeeRate(); | ||
41 | + serviceFeeRateOnDB.setPayChannelRate(new BigDecimal(0.01D)); | ||
42 | + serviceFeeRateOnDB.setGoodsPaymentRate(new BigDecimal(0.03D)); | ||
43 | + // | ||
44 | + goodsPaymentPriceRange = new PriceRange(); | ||
45 | + goodsPaymentPriceRange.setMin(0D); | ||
46 | + goodsPaymentPriceRange.setMax(100D); | ||
47 | + serviceFeeRateOnDB.setGoodsPaymentPriceRange(goodsPaymentPriceRange); | ||
48 | + // | ||
49 | + List<ServiceFeeRate> allConfig = Lists.newArrayListWithCapacity(3); | ||
50 | + // | ||
51 | + BigDecimal feeRateOfOUOGT = new BigDecimal(0.05); | ||
52 | + GoodsServiceFeeRateWrapper gsfrwOfOUOGT = new GoodsServiceFeeRateWrapper(GoodsServiceFeeRateDimension.ONE_USER_ONE_GOODS_TYPE, serviceFeeRateOnDB); | ||
53 | + gsfrwOfOUOGT.setGoodsPaymentRate(feeRateOfOUOGT); | ||
54 | + // | ||
55 | + allConfig.add(gsfrwOfOUOGT); | ||
56 | + | ||
57 | + // | ||
58 | + allConfig.add(new GoodsServiceFeeRateWrapper(GoodsServiceFeeRateDimension.GOODS_TYPE, serviceFeeRateOnDB)); | ||
59 | + | ||
60 | + | ||
61 | + | ||
62 | + SellerOrderComputeResult socr = new SellerOrderComputeResult(); | ||
63 | + socr.setServiceFeeRates(allConfig); | ||
64 | + | ||
65 | + SellerOrderComputeResult computeResult = sos.compute(prdPrice, socr); | ||
66 | + | ||
67 | + System.out.println("in testBuildSoldPrdComputeBo :"+ JSONObject.toJSONString(computeResult)); | ||
68 | + | ||
20 | 69 | ||
21 | - System.out.println("in testBuildSoldPrdComputeBo :"+ JSONObject.toJSONString(bo)); | 70 | + Supplier<Map<String,String>> tipsConfigSupplier = () -> { |
71 | + Map<String,String> tipsConfigMap = new HashMap<>(); | ||
72 | + tipsConfigMap.put(ResourcesProxyService.KEY_SERVICETIPSDESC,"5%"); | ||
73 | + tipsConfigMap.put(ResourcesProxyService.KEY_SERVICETIPSSUMARY,"5%"); | ||
74 | + return tipsConfigMap; | ||
75 | + }; | ||
76 | + SoldPrdComputeBo spc; | ||
77 | + spc = SellerOrderConvertor.computeResult2SoldPrdComputeBo(computeResult, tipsConfigSupplier); | ||
78 | + System.out.println("computeResult2SoldPrdComputeBo computeResult ->"+ JSONObject.toJSONString(spc)); | ||
22 | } | 79 | } |
23 | } | 80 | } |
@@ -126,7 +126,9 @@ rabbit_user=yoho | @@ -126,7 +126,9 @@ rabbit_user=yoho | ||
126 | rabbit_password=yoho | 126 | rabbit_password=yoho |
127 | 127 | ||
128 | #二次发货提醒 24*60 minutes | 128 | #二次发货提醒 24*60 minutes |
129 | -mq.seller.deliverNotice.second=1440 | 129 | +mq.seller.deliverNotice.second=40 |
130 | +mq.seller.deliverNotice.totalTime=60 | ||
131 | +mq.seller.deliverNotice.lastTime=20 | ||
130 | #发货失败提醒 36*60 minutes | 132 | #发货失败提醒 36*60 minutes |
131 | mq.seller.deliverNotice.third=15 | 133 | mq.seller.deliverNotice.third=15 |
132 | 134 | ||
@@ -155,3 +157,5 @@ ufo.certification.timesLimit=3 | @@ -155,3 +157,5 @@ ufo.certification.timesLimit=3 | ||
155 | # Unionpay | 157 | # Unionpay |
156 | unionpay.env=00 | 158 | unionpay.env=00 |
157 | unionpay.notifyurl=http://testapi.yohops.com/payment/ufo_unionpay_notify | 159 | unionpay.notifyurl=http://testapi.yohops.com/payment/ufo_unionpay_notify |
160 | + | ||
161 | +ufo.alipay.sendPaymentInfo.switch=false |
-
Please register or login to post a comment