Authored by LUOXC

Merge branch 'hotfix-buyerpenalty' into test6.9.7

@@ -5,6 +5,7 @@ import com.yohobuy.ufo.model.order.common.OrderStatus; @@ -5,6 +5,7 @@ import com.yohobuy.ufo.model.order.common.OrderStatus;
5 import com.yohoufo.common.exception.UfoServiceException; 5 import com.yohoufo.common.exception.UfoServiceException;
6 import com.yohoufo.common.utils.BigDecimalHelper; 6 import com.yohoufo.common.utils.BigDecimalHelper;
7 import com.yohoufo.dal.order.model.BuyerOrder; 7 import com.yohoufo.dal.order.model.BuyerOrder;
  8 +import com.yohoufo.dal.order.model.BuyerOrderGoods;
8 import com.yohoufo.order.common.ActionStatusHold; 9 import com.yohoufo.order.common.ActionStatusHold;
9 import com.yohoufo.order.model.dto.BuyerPenalty; 10 import com.yohoufo.order.model.dto.BuyerPenalty;
10 import com.yohoufo.order.model.dto.BuyerPenaltyCalResult; 11 import com.yohoufo.order.model.dto.BuyerPenaltyCalResult;
@@ -33,7 +34,7 @@ public class BuyerCancelCompensateComputeHandler { @@ -33,7 +34,7 @@ public class BuyerCancelCompensateComputeHandler {
33 @Autowired 34 @Autowired
34 private BuyerOrderPayDiffTimeHandler buyerOrderPayDiffTimeHandler; 35 private BuyerOrderPayDiffTimeHandler buyerOrderPayDiffTimeHandler;
35 36
36 - public BuyerPenaltyCalResult calBuyerPenaltyCalResult(BuyerOrder buyerOrder,OrderStatus targetStatus){ 37 + public BuyerPenaltyCalResult calBuyerPenaltyCalResult(BuyerOrder buyerOrder, BuyerOrderGoods buyerOrderGoods, OrderStatus targetStatus){
37 Integer buyerUid = buyerOrder.getUid(); 38 Integer buyerUid = buyerOrder.getUid();
38 Long orderCode = buyerOrder.getOrderCode(); 39 Long orderCode = buyerOrder.getOrderCode();
39 if (!ActionStatusHold.isBuyerSelfCancel(targetStatus.getCode())){ 40 if (!ActionStatusHold.isBuyerSelfCancel(targetStatus.getCode())){
@@ -45,21 +46,20 @@ public class BuyerCancelCompensateComputeHandler { @@ -45,21 +46,20 @@ public class BuyerCancelCompensateComputeHandler {
45 return BuyerPenaltyCalResult.getDefault(); 46 return BuyerPenaltyCalResult.getDefault();
46 } 47 }
47 BigDecimal orderActualAmount = buyerOrder.getAmount(); 48 BigDecimal orderActualAmount = buyerOrder.getAmount();
48 - BigDecimal shipFee = buyerOrder.getShipFee(); 49 + BigDecimal goodsActualAmount = orderActualAmount.subtract(buyerOrder.getShipFee());
49 OrderAttributes orderAttributes = OrderAttributes.getOrderAttributes(buyerOrder.getAttributes()); 50 OrderAttributes orderAttributes = OrderAttributes.getOrderAttributes(buyerOrder.getAttributes());
50 - //TODO try catch to record fail transfer  
51 - BuyerPenaltyCalResult bpcr = calBuyerPenalty(buyerUid, orderCode, targetStatus, orderActualAmount, shipFee, orderAttributes); 51 + BuyerPenaltyCalResult bpcr = calBuyerPenalty(buyerUid, orderCode, targetStatus, orderActualAmount, goodsActualAmount, orderAttributes);
52 return bpcr; 52 return bpcr;
53 } 53 }
54 54
55 /** 55 /**
56 * @param buyerUid 56 * @param buyerUid
57 - * @param orderActualAmount 订单实付金额 57 + * @param orderActualAmount
58 * @return 58 * @return
59 */ 59 */
60 public BuyerPenaltyCalResult calBuyerPenalty(Integer buyerUid, Long orderCode, OrderStatus orderStatus, 60 public BuyerPenaltyCalResult calBuyerPenalty(Integer buyerUid, Long orderCode, OrderStatus orderStatus,
61 BigDecimal orderActualAmount, 61 BigDecimal orderActualAmount,
62 - BigDecimal shipFee, 62 + BigDecimal goodsActualAmount,
63 OrderAttributes orderAttributes 63 OrderAttributes orderAttributes
64 ) { 64 ) {
65 if (Objects.isNull(orderAttributes)) { 65 if (Objects.isNull(orderAttributes)) {
@@ -78,7 +78,7 @@ public class BuyerCancelCompensateComputeHandler { @@ -78,7 +78,7 @@ public class BuyerCancelCompensateComputeHandler {
78 .diffTime(diffTime) 78 .diffTime(diffTime)
79 .select() 79 .select()
80 .orElseThrow(() -> new UfoServiceException(501, "not match calFee")); 80 .orElseThrow(() -> new UfoServiceException(501, "not match calFee"));
81 - BuyerPenaltyCalResult bpcr = calBuyerPenalty(penaltyRule, buyerUid, orderCode, orderActualAmount, shipFee); 81 + BuyerPenaltyCalResult bpcr = calBuyerPenalty(penaltyRule, buyerUid, orderCode, orderActualAmount, goodsActualAmount);
82 if (bpcr.getLeftAmount().compareTo(BigDecimal.ZERO) <= 0) { 82 if (bpcr.getLeftAmount().compareTo(BigDecimal.ZERO) <= 0) {
83 throw new UfoServiceException(501, "left amount not enough"); 83 throw new UfoServiceException(501, "left amount not enough");
84 } 84 }
@@ -86,9 +86,8 @@ public class BuyerCancelCompensateComputeHandler { @@ -86,9 +86,8 @@ public class BuyerCancelCompensateComputeHandler {
86 } 86 }
87 87
88 public BuyerPenaltyCalResult calBuyerPenalty(PenaltyRule penaltyRule, Integer buyerUid, Long orderCode, 88 public BuyerPenaltyCalResult calBuyerPenalty(PenaltyRule penaltyRule, Integer buyerUid, Long orderCode,
89 - BigDecimal orderActualAmount, BigDecimal shipFee) { 89 + BigDecimal orderActualAmount, BigDecimal goodsActualAmount) {
90 BigDecimal penaltyRate = penaltyRule.getPenaltyRate(); 90 BigDecimal penaltyRate = penaltyRule.getPenaltyRate();
91 - BigDecimal goodsActualAmount = orderActualAmount.subtract(shipFee);  
92 BigDecimal penaltyAmount = BigDecimalHelper.halfUp(goodsActualAmount.multiply(penaltyRate)); 91 BigDecimal penaltyAmount = BigDecimalHelper.halfUp(goodsActualAmount.multiply(penaltyRate));
93 if (Objects.nonNull(penaltyRule.getPenaltyMinAmount()) && penaltyAmount.compareTo(penaltyRule.getPenaltyMinAmount()) < 0) { 92 if (Objects.nonNull(penaltyRule.getPenaltyMinAmount()) && penaltyAmount.compareTo(penaltyRule.getPenaltyMinAmount()) < 0) {
94 penaltyAmount = penaltyRule.getPenaltyMinAmount(); 93 penaltyAmount = penaltyRule.getPenaltyMinAmount();
@@ -5,8 +5,10 @@ import com.yohobuy.ufo.model.order.bo.ButtonShowBo; @@ -5,8 +5,10 @@ import com.yohobuy.ufo.model.order.bo.ButtonShowBo;
5 import com.yohobuy.ufo.model.order.common.OrderStatus; 5 import com.yohobuy.ufo.model.order.common.OrderStatus;
6 import com.yohobuy.ufo.model.order.resp.OrderListInfo; 6 import com.yohobuy.ufo.model.order.resp.OrderListInfo;
7 import com.yohoufo.dal.order.model.BuyerOrder; 7 import com.yohoufo.dal.order.model.BuyerOrder;
  8 +import com.yohoufo.dal.order.model.BuyerOrderGoods;
8 import com.yohoufo.order.constants.ViewType; 9 import com.yohoufo.order.constants.ViewType;
9 import com.yohoufo.order.model.response.OrderDetailInfo; 10 import com.yohoufo.order.model.response.OrderDetailInfo;
  11 +import com.yohoufo.order.service.support.BuyerOrderButtonFormatFunction;
10 import com.yohoufo.order.service.support.ThreeFunction; 12 import com.yohoufo.order.service.support.ThreeFunction;
11 import com.yohoufo.order.utils.LoggerUtils; 13 import com.yohoufo.order.utils.LoggerUtils;
12 import org.apache.commons.collections.CollectionUtils; 14 import org.apache.commons.collections.CollectionUtils;
@@ -34,6 +36,8 @@ public class BuyerOrderButtonsHandler { @@ -34,6 +36,8 @@ public class BuyerOrderButtonsHandler {
34 36
35 private BiFunction<List<Long>, List<Integer>, List<BuyerOrder>> buyerOrderDS; 37 private BiFunction<List<Long>, List<Integer>, List<BuyerOrder>> buyerOrderDS;
36 38
  39 + private BiFunction<Integer, List<Long>, List<BuyerOrderGoods>> buyerOrderGoodsDS;
  40 +
37 public BuyerOrderButtonsHandler(List<OrderListInfo> orderListInfos){ 41 public BuyerOrderButtonsHandler(List<OrderListInfo> orderListInfos){
38 this.orderListInfos = orderListInfos; 42 this.orderListInfos = orderListInfos;
39 } 43 }
@@ -43,14 +47,15 @@ public class BuyerOrderButtonsHandler { @@ -43,14 +47,15 @@ public class BuyerOrderButtonsHandler {
43 } 47 }
44 48
45 49
46 - public BuyerOrderButtonsHandler loadBuyerOrderDS(BiFunction<List<Long>, List<Integer>, List<BuyerOrder>> buyerOrderDS){ 50 + public BuyerOrderButtonsHandler loadBuyerOrderDS(BiFunction<List<Long>, List<Integer>, List<BuyerOrder>> buyerOrderDS,BiFunction<Integer, List<Long>, List<BuyerOrderGoods>> buyerOrderGoodsDS){
47 this.buyerOrderDS = buyerOrderDS; 51 this.buyerOrderDS = buyerOrderDS;
  52 + this.buyerOrderGoodsDS = buyerOrderGoodsDS;
48 return this; 53 return this;
49 } 54 }
50 55
51 - ThreeFunction<BuyerOrder, List<ButtonShowBo>, ViewType, List<ButtonShowBo>> fmtBtnFunc; 56 + BuyerOrderButtonFormatFunction fmtBtnFunc;
52 57
53 - public BuyerOrderButtonsHandler loadFmtBtnFunc(ThreeFunction<BuyerOrder,List<ButtonShowBo>, ViewType, List<ButtonShowBo>> fmtBtnFunc){ 58 + public BuyerOrderButtonsHandler loadFmtBtnFunc(BuyerOrderButtonFormatFunction fmtBtnFunc){
54 this.fmtBtnFunc = fmtBtnFunc; 59 this.fmtBtnFunc = fmtBtnFunc;
55 return this; 60 return this;
56 } 61 }
@@ -71,7 +76,8 @@ public class BuyerOrderButtonsHandler { @@ -71,7 +76,8 @@ public class BuyerOrderButtonsHandler {
71 pbos = buyerOrderDS.apply(paidOrderCodes, statusList); 76 pbos = buyerOrderDS.apply(paidOrderCodes, statusList);
72 if (CollectionUtils.isNotEmpty(pbos)){ 77 if (CollectionUtils.isNotEmpty(pbos)){
73 BuyerOrder pbo = pbos.get(0); 78 BuyerOrder pbo = pbos.get(0);
74 - List<ButtonShowBo> fbsbs = fmtBtnFunc.apply(pbo, orderDetailInfo.getButtons(), ViewType.DETAIL); 79 + BuyerOrderGoods bog = buyerOrderGoodsDS.apply(pbo.getUid(),Lists.newArrayList(pbo.getOrderCode())).stream().findFirst().orElse(null);
  80 + List<ButtonShowBo> fbsbs = fmtBtnFunc.format(orderDetailInfo.getButtons(), pbo, bog, ViewType.DETAIL);
75 orderDetailInfo.setButtons(fbsbs); 81 orderDetailInfo.setButtons(fbsbs);
76 } 82 }
77 } 83 }
@@ -98,19 +104,24 @@ public class BuyerOrderButtonsHandler { @@ -98,19 +104,24 @@ public class BuyerOrderButtonsHandler {
98 .map(OrderListInfo::getOrderCode).collect(Collectors.toList()); 104 .map(OrderListInfo::getOrderCode).collect(Collectors.toList());
99 105
100 List<BuyerOrder> pbos = null; 106 List<BuyerOrder> pbos = null;
  107 +
101 if (CollectionUtils.isNotEmpty(paidOrderCodes)){ 108 if (CollectionUtils.isNotEmpty(paidOrderCodes)){
102 List<Integer> statusList = Lists.newArrayList(OrderStatus.HAS_PAYED.getCode()); 109 List<Integer> statusList = Lists.newArrayList(OrderStatus.HAS_PAYED.getCode());
103 pbos = buyerOrderDS.apply(paidOrderCodes, statusList); 110 pbos = buyerOrderDS.apply(paidOrderCodes, statusList);
104 } 111 }
105 112
106 if (CollectionUtils.isNotEmpty(pbos)){ 113 if (CollectionUtils.isNotEmpty(pbos)){
  114 + Integer uid = pbos.get(0).getUid();
  115 + List<Long> orderCodes = pbos.stream().map(BuyerOrder::getOrderCode).collect(Collectors.toList());
107 Map<Long, BuyerOrder> codeBuyorderMap = pbos.parallelStream() 116 Map<Long, BuyerOrder> codeBuyorderMap = pbos.parallelStream()
108 .collect(Collectors.toMap(BuyerOrder::getOrderCode, Function.identity())); 117 .collect(Collectors.toMap(BuyerOrder::getOrderCode, Function.identity()));
  118 + Map<Long, BuyerOrderGoods> buyerOrderGoodsMap = buyerOrderGoodsDS.apply(uid, orderCodes).stream().collect(Collectors.toMap(BuyerOrderGoods::getOrderCode,Function.identity()));
109 for(OrderListInfo oli : orderListInfos){ 119 for(OrderListInfo oli : orderListInfos){
110 if(olip.test(oli)) { 120 if(olip.test(oli)) {
111 Long orderCode = oli.getOrderCode(); 121 Long orderCode = oli.getOrderCode();
112 BuyerOrder pbo = codeBuyorderMap.get(orderCode); 122 BuyerOrder pbo = codeBuyorderMap.get(orderCode);
113 - List<ButtonShowBo> fbsbs = fmtBtnFunc.apply(pbo, oli.getButtons(), ViewType.LIST); 123 + BuyerOrderGoods bog = buyerOrderGoodsMap.get(orderCode);
  124 + List<ButtonShowBo> fbsbs = fmtBtnFunc.format(oli.getButtons(),pbo,bog , ViewType.LIST);
114 oli.setButtons(fbsbs); 125 oli.setButtons(fbsbs);
115 } 126 }
116 } 127 }
@@ -173,7 +173,7 @@ public abstract class AbsOrderDetailService extends AbsOrderViewService implemen @@ -173,7 +173,7 @@ public abstract class AbsOrderDetailService extends AbsOrderViewService implemen
173 orderDetailInfo.setOrderCode(orderCode = buyerOrder.getOrderCode()); 173 orderDetailInfo.setOrderCode(orderCode = buyerOrder.getOrderCode());
174 orderDetailInfo.setSubmitOrderTimeStr(DateUtil.formatDate(buyerOrder.getCreateTime(), DateUtil.yyyy_MM_dd_HH_mm_SS)); 174 orderDetailInfo.setSubmitOrderTimeStr(DateUtil.formatDate(buyerOrder.getCreateTime(), DateUtil.yyyy_MM_dd_HH_mm_SS));
175 List<ButtonShowBo> buttonShowList = orderStatus.getDetailButtons(tabType); 175 List<ButtonShowBo> buttonShowList = orderStatus.getDetailButtons(tabType);
176 - orderDetailInfo.setButtons(formatButtons(buyerOrder, buttonShowList==null? Lists.newArrayList() : new ArrayList<>(buttonShowList), ViewType.DETAIL)); 176 + orderDetailInfo.setButtons(formatButtons(buyerOrder, buyerOrderGoods, buttonShowList==null? Lists.newArrayList() : new ArrayList<>(buttonShowList), ViewType.DETAIL));
177 177
178 // 买家 买家订单号 需要处理立即支付 178 // 买家 买家订单号 需要处理立即支付
179 // 卖家 卖家订单号 不存在立即支付的按钮 179 // 卖家 卖家订单号 不存在立即支付的按钮
@@ -308,10 +308,17 @@ public abstract class AbsOrderListService extends AbsOrderViewService implements @@ -308,10 +308,17 @@ public abstract class AbsOrderListService extends AbsOrderViewService implements
308 Integer leftTime = timeoutBo.getLeftTime(); 308 Integer leftTime = timeoutBo.getLeftTime();
309 orderListInfo.setLeftTime(leftTime); 309 orderListInfo.setLeftTime(leftTime);
310 orderListInfo.setTimeLimit(timeoutBo.getTimelimit()); 310 orderListInfo.setTimeLimit(timeoutBo.getTimelimit());
  311 +
  312 + BuyerOrderGoods buyerOrderGoods = buyerOrderGoodsMap.get(buyerOrder.getOrderCode());
  313 + if (buyerOrderGoods == null){
  314 + getLogger().warn("getOrderList buyer goods not exist, uid is {}, orderCode is {}",
  315 + buyerOrder.getUid(), orderListInfo.getOrderCode());
  316 + return null;
  317 + }
311 // 按钮显示 318 // 按钮显示
312 List<ButtonShowBo> buttonShowBos = orderStatus.getListButtons(tabType); 319 List<ButtonShowBo> buttonShowBos = orderStatus.getListButtons(tabType);
313 320
314 - orderListInfo.setButtons(formatButtons(buyerOrder, buttonShowBos == null ? new ArrayList<>() : new ArrayList<>(buttonShowBos), ViewType.LIST)); 321 + orderListInfo.setButtons(formatButtons(buyerOrder, buyerOrderGoods, buttonShowBos == null ? new ArrayList<>() : new ArrayList<>(buttonShowBos), ViewType.LIST));
315 322
316 // 当剩余时间小于0 323 // 当剩余时间小于0
317 if (!CollectionUtils.isEmpty(orderListInfo.getButtons())){ 324 if (!CollectionUtils.isEmpty(orderListInfo.getButtons())){
@@ -320,12 +327,7 @@ public abstract class AbsOrderListService extends AbsOrderViewService implements @@ -320,12 +327,7 @@ public abstract class AbsOrderListService extends AbsOrderViewService implements
320 } 327 }
321 } 328 }
322 329
323 - BuyerOrderGoods buyerOrderGoods = buyerOrderGoodsMap.get(buyerOrder.getOrderCode());  
324 - if (buyerOrderGoods == null){  
325 - getLogger().warn("getOrderList buyer goods not exist, uid is {}, orderCode is {}",  
326 - buyerOrder.getUid(), orderListInfo.getOrderCode());  
327 - return null;  
328 - } 330 +
329 orderListInfo.setSkup(buyerOrderGoods.getSkup()); 331 orderListInfo.setSkup(buyerOrderGoods.getSkup());
330 332
331 SellerOrderGoods sellerOrderGoods = sellerOrderGoodsMap.get(buyerOrderGoods.getSkup()); 333 SellerOrderGoods sellerOrderGoods = sellerOrderGoodsMap.get(buyerOrderGoods.getSkup());
@@ -8,10 +8,12 @@ import com.yohobuy.ufo.model.order.common.OrderStatus; @@ -8,10 +8,12 @@ import com.yohobuy.ufo.model.order.common.OrderStatus;
8 import com.yohobuy.ufo.model.order.common.TabType; 8 import com.yohobuy.ufo.model.order.common.TabType;
9 import com.yohoufo.dal.order.model.BuyerOrder; 9 import com.yohoufo.dal.order.model.BuyerOrder;
10 import com.yohobuy.ufo.model.order.common.Payment; 10 import com.yohobuy.ufo.model.order.common.Payment;
  11 +import com.yohoufo.dal.order.model.BuyerOrderGoods;
11 import com.yohoufo.order.constants.ViewType; 12 import com.yohoufo.order.constants.ViewType;
12 import com.yohoufo.order.model.dto.BuyerPenaltyCalResult; 13 import com.yohoufo.order.model.dto.BuyerPenaltyCalResult;
13 import com.yohoufo.order.model.response.OrderDetailInfo; 14 import com.yohoufo.order.model.response.OrderDetailInfo;
14 import com.yohoufo.order.service.handler.BuyerCancelCompensateComputeHandler; 15 import com.yohoufo.order.service.handler.BuyerCancelCompensateComputeHandler;
  16 +import com.yohoufo.order.service.support.BuyerOrderButtonFormatFunction;
15 import com.yohoufo.order.service.wrapper.OrderTimeoutContext; 17 import com.yohoufo.order.service.wrapper.OrderTimeoutContext;
16 import com.yohoufo.order.service.wrapper.OrderTimeoutFactory; 18 import com.yohoufo.order.service.wrapper.OrderTimeoutFactory;
17 import com.yohoufo.order.service.wrapper.TimeoutWrapper; 19 import com.yohoufo.order.service.wrapper.TimeoutWrapper;
@@ -42,6 +44,12 @@ public abstract class AbsOrderViewService { @@ -42,6 +44,12 @@ public abstract class AbsOrderViewService {
42 44
43 abstract Logger getLogger(); 45 abstract Logger getLogger();
44 46
  47 +
  48 + BuyerOrderButtonFormatFunction buyerOrderButtonFormatFunction() {
  49 + return (buttons, buyerOrder, buyerOrderGoods, viewType) -> formatButtons(buyerOrder, buyerOrderGoods, buttons, viewType);
  50 + }
  51 +
  52 +
45 /** 53 /**
46 * 54 *
47 * @param buyerOrder 55 * @param buyerOrder
@@ -49,7 +57,7 @@ public abstract class AbsOrderViewService { @@ -49,7 +57,7 @@ public abstract class AbsOrderViewService {
49 * @param viewType 1:订单列表; 2:订单详情 57 * @param viewType 1:订单列表; 2:订单详情
50 * @return 58 * @return
51 */ 59 */
52 - List<ButtonShowBo> formatButtons(BuyerOrder buyerOrder, List<ButtonShowBo> buttons, ViewType viewType){ 60 + List<ButtonShowBo> formatButtons(BuyerOrder buyerOrder, BuyerOrderGoods buyerOrderGoods, List<ButtonShowBo> buttons, ViewType viewType){
53 if (CollectionUtils.isEmpty(buttons) || Objects.isNull(buyerOrder)){ 61 if (CollectionUtils.isEmpty(buttons) || Objects.isNull(buyerOrder)){
54 return buttons; 62 return buttons;
55 } 63 }
@@ -70,7 +78,7 @@ public abstract class AbsOrderViewService { @@ -70,7 +78,7 @@ public abstract class AbsOrderViewService {
70 BuyerPenaltyCalResult bpcr = null; 78 BuyerPenaltyCalResult bpcr = null;
71 if (Objects.nonNull(targetOrderStatus)) { 79 if (Objects.nonNull(targetOrderStatus)) {
72 try { 80 try {
73 - bpcr = buyerCancelCompensateComputeHandler.calBuyerPenaltyCalResult(buyerOrder, targetOrderStatus); 81 + bpcr = buyerCancelCompensateComputeHandler.calBuyerPenaltyCalResult(buyerOrder, buyerOrderGoods, targetOrderStatus);
74 }catch (Exception ex){ 82 }catch (Exception ex){
75 getLogger().warn("in formatButtons error buyerOrder {} buttons {}", buyerOrder, buttons, ex); 83 getLogger().warn("in formatButtons error buyerOrder {} buttons {}", buyerOrder, buttons, ex);
76 } 84 }
@@ -108,9 +108,10 @@ public class BuyerOrderCancelService { @@ -108,9 +108,10 @@ public class BuyerOrderCancelService {
108 long orderCode = bsdEvent.getOrderCode(); 108 long orderCode = bsdEvent.getOrderCode();
109 OrderStatus targetOrderStatus = bsdEvent.getTarget(); 109 OrderStatus targetOrderStatus = bsdEvent.getTarget();
110 BuyerOrder buyerOrder = buyerOrderMapper.selectByOrderCode(orderCode); 110 BuyerOrder buyerOrder = buyerOrderMapper.selectByOrderCode(orderCode);
  111 + BuyerOrderGoods buyerOrderGoods = buyerOrderGoodsMapper.selectByOrderCode(buyerOrder.getUid(),buyerOrder.getOrderCode());
111 logger.info("in buyer cancel BeforeSellerDeliver begin buyerOrderMapper.selectByOrderCode, buyerUid {}, orderCode {}, skup {} buyerOrder {}", 112 logger.info("in buyer cancel BeforeSellerDeliver begin buyerOrderMapper.selectByOrderCode, buyerUid {}, orderCode {}, skup {} buyerOrder {}",
112 buyerUid, orderCode, buyerOrder ); 113 buyerUid, orderCode, buyerOrder );
113 - BuyerPenaltyCalResult bpcr = buyerCancelCompensateComputeHandler.calBuyerPenaltyCalResult(buyerOrder, targetOrderStatus); 114 + BuyerPenaltyCalResult bpcr = buyerCancelCompensateComputeHandler.calBuyerPenaltyCalResult(buyerOrder,buyerOrderGoods, targetOrderStatus);
114 logger.info("in buyer cancel BeforeSellerDeliver, event {} BuyerPenaltyCalResult {}", bsdEvent, bpcr); 115 logger.info("in buyer cancel BeforeSellerDeliver, event {} BuyerPenaltyCalResult {}", bsdEvent, bpcr);
115 //买家实付金额(货款+运费)小于赔偿金的额度,不够赔偿的,则不允许取消 116 //买家实付金额(货款+运费)小于赔偿金的额度,不够赔偿的,则不允许取消
116 BigDecimal penaltyAmount; 117 BigDecimal penaltyAmount;
@@ -246,9 +247,10 @@ public class BuyerOrderCancelService { @@ -246,9 +247,10 @@ public class BuyerOrderCancelService {
246 long orderCode = bdrEvent.getOrderCode(); 247 long orderCode = bdrEvent.getOrderCode();
247 OrderStatus targetOrderStatus = bdrEvent.getTarget(); 248 OrderStatus targetOrderStatus = bdrEvent.getTarget();
248 BuyerOrder buyerOrder = buyerOrderMapper.selectByOrderCode(orderCode); 249 BuyerOrder buyerOrder = buyerOrderMapper.selectByOrderCode(orderCode);
  250 + BuyerOrderGoods buyerOrderGoods = buyerOrderGoodsMapper.selectByOrderCode(buyerOrder.getUid(),buyerOrder.getOrderCode());
249 logger.info("in buyer cancel BeforeDepotReceive begin buyerOrderMapper.selectByOrderCode, buyerUid {}, orderCode {}, skup {} buyerOrder {}", 251 logger.info("in buyer cancel BeforeDepotReceive begin buyerOrderMapper.selectByOrderCode, buyerUid {}, orderCode {}, skup {} buyerOrder {}",
250 buyerUid, orderCode, buyerOrder ); 252 buyerUid, orderCode, buyerOrder );
251 - BuyerPenaltyCalResult bpcr = buyerCancelCompensateComputeHandler.calBuyerPenaltyCalResult(buyerOrder, targetOrderStatus); 253 + BuyerPenaltyCalResult bpcr = buyerCancelCompensateComputeHandler.calBuyerPenaltyCalResult(buyerOrder, buyerOrderGoods, targetOrderStatus);
252 logger.info("in buyer cancel BeforeDepotReceive, event {} compensate {}", bdrEvent, bpcr); 254 logger.info("in buyer cancel BeforeDepotReceive, event {} compensate {}", bdrEvent, bpcr);
253 //买家实付金额(货款+运费)小于赔偿金的额度,不够赔偿的,则不允许取消 255 //买家实付金额(货款+运费)小于赔偿金的额度,不够赔偿的,则不允许取消
254 BigDecimal penaltyAmount; 256 BigDecimal penaltyAmount;
@@ -161,8 +161,8 @@ public class BuyerOrderDetailService extends AbsOrderDetailService implements IO @@ -161,8 +161,8 @@ public class BuyerOrderDetailService extends AbsOrderDetailService implements IO
161 161
162 private void procsessButtons(OrderDetailInfo orderDetailInfo){ 162 private void procsessButtons(OrderDetailInfo orderDetailInfo){
163 new BuyerOrderButtonsHandler(orderDetailInfo) 163 new BuyerOrderButtonsHandler(orderDetailInfo)
164 - .loadBuyerOrderDS(buyerOrderMapper::selectByOrderCodes)  
165 - .loadFmtBtnFunc(this::formatButtons) 164 + .loadBuyerOrderDS(buyerOrderMapper::selectByOrderCodes,buyerOrderGoodsMapper::selectByOrderCodeList)
  165 + .loadFmtBtnFunc(this.buyerOrderButtonFormatFunction())
166 .processDetail(); 166 .processDetail();
167 } 167 }
168 168
@@ -126,8 +126,8 @@ public class BuyerOrderListServiceImpl extends AbsOrderListService implements IO @@ -126,8 +126,8 @@ public class BuyerOrderListServiceImpl extends AbsOrderListService implements IO
126 126
127 private void processButtons(List<OrderListInfo> list){ 127 private void processButtons(List<OrderListInfo> list){
128 new BuyerOrderButtonsHandler(list) 128 new BuyerOrderButtonsHandler(list)
129 - .loadBuyerOrderDS(buyerOrderMapper::selectByOrderCodes)  
130 - .loadFmtBtnFunc(this::formatButtons) 129 + .loadBuyerOrderDS(buyerOrderMapper::selectByOrderCodes,buyerOrderGoodsMapper::selectByOrderCodeList)
  130 + .loadFmtBtnFunc(this.buyerOrderButtonFormatFunction())
131 .process(); 131 .process();
132 } 132 }
133 133
@@ -892,13 +892,17 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { @@ -892,13 +892,17 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
892 break; 892 break;
893 case HAS_PAYED: 893 case HAS_PAYED:
894 targetStatus = OrderStatus.BUYER_CANCEL_BEFORE_SELLER_DELIVER; 894 targetStatus = OrderStatus.BUYER_CANCEL_BEFORE_SELLER_DELIVER;
895 - bpcr = buyerCancelCompensateComputeHandler.calBuyerPenaltyCalResult(buyerOrder, targetStatus); 895 + bpcr = buyerCancelCompensateComputeHandler.calBuyerPenaltyCalResult(buyerOrder,
  896 + buyerOrderGoodsMapper.selectByOrderCode(buyerOrder.getUid(),buyerOrder.getOrderCode()),
  897 + targetStatus);
896 occr = bpcr2occr(bpcr); 898 occr = bpcr2occr(bpcr);
897 occr.setNeedPenalty(true); 899 occr.setNeedPenalty(true);
898 break; 900 break;
899 case SELLER_SEND_OUT: 901 case SELLER_SEND_OUT:
900 targetStatus = OrderStatus.BUYER_CANCEL_BEFORE_DEPOT_RECEIVE; 902 targetStatus = OrderStatus.BUYER_CANCEL_BEFORE_DEPOT_RECEIVE;
901 - bpcr = buyerCancelCompensateComputeHandler.calBuyerPenaltyCalResult(buyerOrder, targetStatus); 903 + bpcr = buyerCancelCompensateComputeHandler.calBuyerPenaltyCalResult(buyerOrder,
  904 + buyerOrderGoodsMapper.selectByOrderCode(buyerOrder.getUid(),buyerOrder.getOrderCode()),
  905 + targetStatus);
902 occr = bpcr2occr(bpcr); 906 occr = bpcr2occr(bpcr);
903 occr.setNeedPenalty(true); 907 occr.setNeedPenalty(true);
904 break; 908 break;
  1 +package com.yohoufo.order.service.support;
  2 +
  3 +import com.yohobuy.ufo.model.order.bo.ButtonShowBo;
  4 +import com.yohoufo.dal.order.model.BuyerOrder;
  5 +import com.yohoufo.dal.order.model.BuyerOrderGoods;
  6 +import com.yohoufo.order.constants.ViewType;
  7 +
  8 +import java.util.List;
  9 +
  10 +public interface BuyerOrderButtonFormatFunction {
  11 +
  12 + List<ButtonShowBo> format(List<ButtonShowBo> srcButtons, BuyerOrder buyerOrder, BuyerOrderGoods buyerOrderGoods, ViewType viewType);
  13 +
  14 +}