change tips of buyer cancel
Showing
1 changed file
with
15 additions
and
9 deletions
@@ -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); |
-
Please register or login to post a comment