Authored by chenchao

add need penalty 4 control client confirm

@@ -106,7 +106,8 @@ public class BuyerOrderCancelService { @@ -106,7 +106,8 @@ public class BuyerOrderCancelService {
106 BuyerPenaltyCalResult bpcr = buyerCancelCompensateComputeHandler.calBuyerPenaltyCalResult(buyerOrder, targetOrderStatus); 106 BuyerPenaltyCalResult bpcr = buyerCancelCompensateComputeHandler.calBuyerPenaltyCalResult(buyerOrder, targetOrderStatus);
107 logger.info("in buyer cancel BeforeSellerDeliver, event {} BuyerPenaltyCalResult {}", bsdEvent, bpcr); 107 logger.info("in buyer cancel BeforeSellerDeliver, event {} BuyerPenaltyCalResult {}", bsdEvent, bpcr);
108 //买家实付金额(货款+运费)小于赔偿金的额度,不够赔偿的,则不允许取消 108 //买家实付金额(货款+运费)小于赔偿金的额度,不够赔偿的,则不允许取消
109 - if(bsdEvent.getAmount()==null||bsdEvent.getAmount().compareTo(bpcr.getPenaltyAmount()) < 0){ 109 + BigDecimal penaltyAmount;
  110 + if(bsdEvent.getAmount()==null||bsdEvent.getAmount().compareTo(penaltyAmount=bpcr.getPenaltyAmount()) < 0){
110 logger.warn("in buyer cancel BeforeSellerDeliver not allow cancel cause of buyer amount lower than BuyerCompensateMoney, event {} compensate {}", bsdEvent, bpcr); 111 logger.warn("in buyer cancel BeforeSellerDeliver not allow cancel cause of buyer amount lower than BuyerCompensateMoney, event {} compensate {}", bsdEvent, bpcr);
111 throw new com.yohoufo.common.exception.UfoServiceException(400,"买家赔偿金低于商品售价,不允许取消"); 112 throw new com.yohoufo.common.exception.UfoServiceException(400,"买家赔偿金低于商品售价,不允许取消");
112 } 113 }
@@ -116,8 +117,8 @@ public class BuyerOrderCancelService { @@ -116,8 +117,8 @@ public class BuyerOrderCancelService {
116 int currentTime = DateUtil.getCurrentTimeSecond(); 117 int currentTime = DateUtil.getCurrentTimeSecond();
117 int rows = buyerOrderMapper.updateStatusByOrderCode(orderCode, buyerUid, expected.getCode(), targetOrderStatus.getCode(), currentTime); 118 int rows = buyerOrderMapper.updateStatusByOrderCode(orderCode, buyerUid, expected.getCode(), targetOrderStatus.getCode(), currentTime);
118 if (rows>0) { 119 if (rows>0) {
119 - boolean noResponsibility = Objects.isNull(bpcr.getPenaltyAmount())  
120 - || BigDecimal.ZERO.compareTo(bpcr.getPenaltyAmount()) == 0; 120 + boolean noResponsibility = Objects.isNull(penaltyAmount)
  121 + || BigDecimal.ZERO.compareTo(penaltyAmount) == 0;
121 //退还优惠券 122 //退还优惠券
122 refundCouponIfNeed(buyerUid, orderCode); 123 refundCouponIfNeed(buyerUid, orderCode);
123 int skup = bsdEvent.getSkup(); 124 int skup = bsdEvent.getSkup();
@@ -136,7 +137,7 @@ public class BuyerOrderCancelService { @@ -136,7 +137,7 @@ public class BuyerOrderCancelService {
136 inBoxFacade.noticeSellerWhenBuyerCancelNoResponsibility(psog, orderCode); 137 inBoxFacade.noticeSellerWhenBuyerCancelNoResponsibility(psog, orderCode);
137 }else { 138 }else {
138 inBoxFacade.buyerCancelBeforeSellerDeliver(buyerUid, orderCode, 139 inBoxFacade.buyerCancelBeforeSellerDeliver(buyerUid, orderCode,
139 - bpcr.getPenaltyAmount().toPlainString(), psog); 140 + penaltyAmount.toPlainString(), psog);
140 } 141 }
141 //TODO 整个过程异步去执行(考虑退费依赖订单状态) 142 //TODO 整个过程异步去执行(考虑退费依赖订单状态)
142 //(退费)退保证金给卖家 143 //(退费)退保证金给卖家
@@ -222,7 +223,8 @@ public class BuyerOrderCancelService { @@ -222,7 +223,8 @@ public class BuyerOrderCancelService {
222 BuyerPenaltyCalResult bpcr = buyerCancelCompensateComputeHandler.calBuyerPenaltyCalResult(buyerOrder, targetOrderStatus); 223 BuyerPenaltyCalResult bpcr = buyerCancelCompensateComputeHandler.calBuyerPenaltyCalResult(buyerOrder, targetOrderStatus);
223 logger.info("in buyer cancel BeforeDepotReceive, event {} compensate {}", bdrEvent, bpcr); 224 logger.info("in buyer cancel BeforeDepotReceive, event {} compensate {}", bdrEvent, bpcr);
224 //买家实付金额(货款+运费)小于赔偿金的额度,不够赔偿的,则不允许取消 225 //买家实付金额(货款+运费)小于赔偿金的额度,不够赔偿的,则不允许取消
225 - if(bdrEvent.getAmount()==null||bdrEvent.getAmount().compareTo(bpcr.getPenaltyAmount()) < 0){ 226 + BigDecimal penaltyAmount;
  227 + if(bdrEvent.getAmount()==null||bdrEvent.getAmount().compareTo(penaltyAmount=bpcr.getPenaltyAmount()) < 0){
226 logger.warn("in buyer cancel BeforeDepotReceive not allow cancel cause of buyer amount lower than BuyerCompensateMoney, event {} compensate {}", bdrEvent, bpcr); 228 logger.warn("in buyer cancel BeforeDepotReceive not allow cancel cause of buyer amount lower than BuyerCompensateMoney, event {} compensate {}", bdrEvent, bpcr);
227 throw new com.yohoufo.common.exception.UfoServiceException(400,"买家赔偿金低于商品售价,不允许取消"); 229 throw new com.yohoufo.common.exception.UfoServiceException(400,"买家赔偿金低于商品售价,不允许取消");
228 } 230 }
@@ -231,8 +233,8 @@ public class BuyerOrderCancelService { @@ -231,8 +233,8 @@ public class BuyerOrderCancelService {
231 int currentTime = DateUtil.getCurrentTimeSecond(); 233 int currentTime = DateUtil.getCurrentTimeSecond();
232 int rows = buyerOrderMapper.updateStatusByOrderCode(orderCode, buyerUid, expected.getCode(), targetOrderStatus.getCode(), currentTime); 234 int rows = buyerOrderMapper.updateStatusByOrderCode(orderCode, buyerUid, expected.getCode(), targetOrderStatus.getCode(), currentTime);
233 if (rows>0) { 235 if (rows>0) {
234 - boolean noResponsibility = Objects.isNull(bpcr.getPenaltyAmount())  
235 - || BigDecimal.ZERO.compareTo(bpcr.getPenaltyAmount()) == 0; 236 + boolean noResponsibility = Objects.isNull(penaltyAmount)
  237 + || BigDecimal.ZERO.compareTo(penaltyAmount) == 0;
236 //退还优惠券 238 //退还优惠券
237 refundCouponIfNeed(buyerUid, orderCode); 239 refundCouponIfNeed(buyerUid, orderCode);
238 240
@@ -252,7 +254,7 @@ public class BuyerOrderCancelService { @@ -252,7 +254,7 @@ public class BuyerOrderCancelService {
252 inBoxFacade.noticeSellerWhenBuyerCancelNoResponsibility(psog, orderCode); 254 inBoxFacade.noticeSellerWhenBuyerCancelNoResponsibility(psog, orderCode);
253 }else { 255 }else {
254 inBoxFacade.buyerCancelBeforeDepotReceive(buyerUid, orderCode, 256 inBoxFacade.buyerCancelBeforeDepotReceive(buyerUid, orderCode,
255 - bpcr.getPenaltyAmount().toPlainString(), psog); 257 + penaltyAmount.toPlainString(), psog);
256 } 258 }
257 //整个过程异步去执行(考虑退费依赖订单状态) 259 //整个过程异步去执行(考虑退费依赖订单状态)
258 //(退费)退保证金给卖家 260 //(退费)退保证金给卖家
@@ -920,11 +920,13 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { @@ -920,11 +920,13 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
920 targetStatus = OrderStatus.BUYER_CANCEL_BEFORE_SELLER_DELIVER; 920 targetStatus = OrderStatus.BUYER_CANCEL_BEFORE_SELLER_DELIVER;
921 bpcr = buyerCancelCompensateComputeHandler.calBuyerPenaltyCalResult(buyerOrder, targetStatus); 921 bpcr = buyerCancelCompensateComputeHandler.calBuyerPenaltyCalResult(buyerOrder, targetStatus);
922 occr = bpcr2occr(bpcr); 922 occr = bpcr2occr(bpcr);
  923 + occr.setNeedPenalty(true);
923 break; 924 break;
924 case SELLER_SEND_OUT: 925 case SELLER_SEND_OUT:
925 targetStatus = OrderStatus.BUYER_CANCEL_BEFORE_DEPOT_RECEIVE; 926 targetStatus = OrderStatus.BUYER_CANCEL_BEFORE_DEPOT_RECEIVE;
926 bpcr = buyerCancelCompensateComputeHandler.calBuyerPenaltyCalResult(buyerOrder, targetStatus); 927 bpcr = buyerCancelCompensateComputeHandler.calBuyerPenaltyCalResult(buyerOrder, targetStatus);
927 occr = bpcr2occr(bpcr); 928 occr = bpcr2occr(bpcr);
  929 + occr.setNeedPenalty(true);
928 break; 930 break;
929 } 931 }
930 return occr; 932 return occr;
@@ -884,15 +884,20 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi @@ -884,15 +884,20 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi
884 } 884 }
885 885
886 if (OrderCodeType.BUYER_TYPE.equals(codeType)){ 886 if (OrderCodeType.BUYER_TYPE.equals(codeType)){
887 - String confirmDesc = getConfirmDesc4BuyerOrder(orderCode); 887 + BuyerOrder buyerOrder = buyerOrderMapper.selectOnlyByOrderCode(orderCode);
  888 + String confirmDesc = getConfirmDesc4BuyerOrder(buyerOrder);
888 occr.setConfirmDesc(confirmDesc); 889 occr.setConfirmDesc(confirmDesc);
  890 + //
  891 + if (buyerOrder !=null && OrderStatus.HAS_PAYED.getCode() == buyerOrder.getStatus()){
  892 + occr.setNeedPenalty(true);
  893 + }
889 } 894 }
890 return occr; 895 return occr;
891 } 896 }
892 897
893 - private String getConfirmDesc4BuyerOrder(long orderCode){ 898 + private String getConfirmDesc4BuyerOrder(BuyerOrder buyerOrder){
894 String confirmDesc = null; 899 String confirmDesc = null;
895 - BuyerOrder buyerOrder = buyerOrderMapper.selectOnlyByOrderCode(orderCode); 900 +
896 if (buyerOrder == null){ 901 if (buyerOrder == null){
897 return "订单不存在"; 902 return "订单不存在";
898 } 903 }