...
|
...
|
@@ -5,7 +5,6 @@ import com.google.common.collect.Lists; |
|
|
import com.yoho.core.rabbitmq.YhProducer;
|
|
|
import com.yohobuy.ufo.model.order.bo.CustomsClearanceResult;
|
|
|
import com.yohobuy.ufo.model.order.bo.MerchantOrderAttachInfo;
|
|
|
import com.yohobuy.ufo.model.order.common.MetaConfigKey;
|
|
|
import com.yohobuy.ufo.model.order.common.OrderStatus;
|
|
|
import com.yohobuy.ufo.model.order.common.SellerOrderStatus;
|
|
|
import com.yohobuy.ufo.model.order.common.SkupStatus;
|
...
|
...
|
@@ -20,7 +19,6 @@ import com.yohoufo.common.alarm.UfoInfluxdbVo; |
|
|
import com.yohoufo.common.constant.InfluxdbFieldEnum;
|
|
|
import com.yohoufo.common.constant.InfluxdbMeasurementEnum;
|
|
|
import com.yohoufo.common.exception.UfoServiceException;
|
|
|
import com.yohoufo.common.utils.BigDecimalHelper;
|
|
|
import com.yohoufo.common.utils.DateUtil;
|
|
|
import com.yohoufo.dal.order.*;
|
|
|
import com.yohoufo.dal.order.model.*;
|
...
|
...
|
@@ -32,7 +30,6 @@ import com.yohoufo.order.constants.ClearanceFailType; |
|
|
import com.yohoufo.order.constants.MetaKey;
|
|
|
import com.yohoufo.order.event.*;
|
|
|
import com.yohoufo.order.model.PayRefundBo;
|
|
|
import com.yohoufo.order.model.dto.BuyerPenalty;
|
|
|
import com.yohoufo.order.model.dto.BuyerPenaltyCalResult;
|
|
|
import com.yohoufo.order.model.request.PaymentRequest;
|
|
|
import com.yohoufo.order.model.request.TranseferCellNode;
|
...
|
...
|
@@ -56,6 +53,7 @@ import lombok.Setter; |
|
|
import lombok.val;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.commons.lang3.tuple.Pair;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
...
|
...
|
@@ -64,7 +62,6 @@ import javax.annotation.Resource; |
|
|
import java.math.BigDecimal;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Objects;
|
|
|
import java.util.concurrent.Callable;
|
|
|
import java.util.concurrent.ExecutorService;
|
...
|
...
|
@@ -173,9 +170,10 @@ public class BuyerOrderCancelService { |
|
|
logger.info("in buyer cancel BeforeSellerDeliver, event {} BuyerPenaltyCalResult {}", bsdEvent, bpcr);
|
|
|
//买家实付金额(货款+运费)小于赔偿金的额度,不够赔偿的,则不允许取消
|
|
|
BigDecimal penaltyAmount;
|
|
|
if(bsdEvent.getAmount()==null||bsdEvent.getAmount().compareTo(penaltyAmount=bpcr.getPenaltyAmount()) < 0){
|
|
|
Pair<Boolean,UfoServiceException> penaltyAmountIsEnough = checkPenaltyAmount(bsdEvent.getAmount(), penaltyAmount=bpcr.getPenaltyAmount());
|
|
|
if(!penaltyAmountIsEnough.getLeft()){
|
|
|
logger.warn("in buyer cancel BeforeSellerDeliver not allow cancel cause of buyer amount lower than BuyerCompensateMoney, event {} compensate {}", bsdEvent, bpcr);
|
|
|
throw new com.yohoufo.common.exception.UfoServiceException(400,"买家赔偿金低于商品售价,不允许取消");
|
|
|
throw penaltyAmountIsEnough.getRight();
|
|
|
}
|
|
|
|
|
|
|
...
|
...
|
@@ -301,6 +299,14 @@ public class BuyerOrderCancelService { |
|
|
.cancel();
|
|
|
}
|
|
|
|
|
|
private Pair<Boolean,UfoServiceException> checkPenaltyAmount(BigDecimal actualPaidAmount, BigDecimal penaltyAmount){
|
|
|
boolean isEnough = (actualPaidAmount !=null && actualPaidAmount.compareTo(penaltyAmount) >= 0);
|
|
|
UfoServiceException ex = null;
|
|
|
if(!isEnough){
|
|
|
ex = new com.yohoufo.common.exception.UfoServiceException(400,"实付金额低于订单违约金,不允许取消");
|
|
|
}
|
|
|
return Pair.of(isEnough, ex);
|
|
|
}
|
|
|
|
|
|
public void cancel(BeforeDepotReceiveEvent bdrEvent){
|
|
|
int buyerUid = bdrEvent.getBuyerUid();
|
...
|
...
|
@@ -315,12 +321,12 @@ public class BuyerOrderCancelService { |
|
|
logger.info("in buyer cancel BeforeDepotReceive, event {} compensate {}", bdrEvent, bpcr);
|
|
|
//买家实付金额(货款+运费)小于赔偿金的额度,不够赔偿的,则不允许取消
|
|
|
BigDecimal penaltyAmount;
|
|
|
if(bdrEvent.getAmount()==null||bdrEvent.getAmount().compareTo(penaltyAmount=bpcr.getPenaltyAmount()) < 0){
|
|
|
Pair<Boolean,UfoServiceException> amountIsEnough = checkPenaltyAmount(bdrEvent.getAmount(), penaltyAmount=bpcr.getPenaltyAmount());
|
|
|
if(!amountIsEnough.getLeft()){
|
|
|
logger.warn("in buyer cancel BeforeDepotReceive not allow cancel cause of buyer amount lower than BuyerCompensateMoney, event {} compensate {}", bdrEvent, bpcr);
|
|
|
throw new com.yohoufo.common.exception.UfoServiceException(400,"买家赔偿金低于商品售价,不允许取消");
|
|
|
throw amountIsEnough.getRight();
|
|
|
}
|
|
|
|
|
|
|
|
|
OrderStatus expected = bdrEvent.getExpected();
|
|
|
int currentTime = DateUtil.getCurrentTimeSecond();
|
|
|
int rows = buyerOrderMapper.updateStatusByOrderCode(orderCode, buyerUid, expected.getCode(), targetOrderStatus.getCode(), currentTime);
|
...
|
...
|
|