Authored by chenchao

use enum

  1 +package com.yohoufo.order.constants;
  2 +
  3 +/**
  4 + * Created by chao.chen on 2019/1/22.
  5 + */
  6 +public enum ViewType {
  7 + DETAIL, LIST
  8 +}
@@ -7,6 +7,7 @@ import com.yohobuy.ufo.model.order.common.SkupStatus; @@ -7,6 +7,7 @@ import com.yohobuy.ufo.model.order.common.SkupStatus;
7 import com.yohobuy.ufo.model.response.StorageDataResp; 7 import com.yohobuy.ufo.model.response.StorageDataResp;
8 import com.yohoufo.common.utils.BigDecimalHelper; 8 import com.yohoufo.common.utils.BigDecimalHelper;
9 import com.yohoufo.order.common.Payment; 9 import com.yohoufo.order.common.Payment;
  10 +import com.yohoufo.order.constants.ViewType;
10 import com.yohoufo.order.service.proxy.ProductProxyService; 11 import com.yohoufo.order.service.proxy.ProductProxyService;
11 import org.apache.commons.collections.CollectionUtils; 12 import org.apache.commons.collections.CollectionUtils;
12 import org.slf4j.Logger; 13 import org.slf4j.Logger;
@@ -21,9 +22,6 @@ import java.util.List; @@ -21,9 +22,6 @@ import java.util.List;
21 */ 22 */
22 public interface AbsSellerOrderViewService { 23 public interface AbsSellerOrderViewService {
23 Logger getLogger(); 24 Logger getLogger();
24 - enum ViewType{  
25 - DETAIL, LIST  
26 - }  
27 25
28 ProductProxyService getProductProxyService(); 26 ProductProxyService getProductProxyService();
29 27
@@ -5,6 +5,7 @@ import com.yohobuy.ufo.model.order.bo.ButtonShowBo; @@ -5,6 +5,7 @@ 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.order.constants.ViewType;
8 import com.yohoufo.order.model.response.OrderDetailInfo; 9 import com.yohoufo.order.model.response.OrderDetailInfo;
9 import com.yohoufo.order.service.support.ThreeFunction; 10 import com.yohoufo.order.service.support.ThreeFunction;
10 import org.apache.commons.collections.CollectionUtils; 11 import org.apache.commons.collections.CollectionUtils;
@@ -42,9 +43,9 @@ public class BuyerOrderButtonsHandler { @@ -42,9 +43,9 @@ public class BuyerOrderButtonsHandler {
42 return this; 43 return this;
43 } 44 }
44 45
45 - ThreeFunction<BuyerOrder, List<ButtonShowBo>, Integer, List<ButtonShowBo>> fmtBtnFunc; 46 + ThreeFunction<BuyerOrder, List<ButtonShowBo>, ViewType, List<ButtonShowBo>> fmtBtnFunc;
46 47
47 - public BuyerOrderButtonsHandler loadFmtBtnFunc(ThreeFunction<BuyerOrder,List<ButtonShowBo>, Integer, List<ButtonShowBo>> fmtBtnFunc){ 48 + public BuyerOrderButtonsHandler loadFmtBtnFunc(ThreeFunction<BuyerOrder,List<ButtonShowBo>, ViewType, List<ButtonShowBo>> fmtBtnFunc){
48 this.fmtBtnFunc = fmtBtnFunc; 49 this.fmtBtnFunc = fmtBtnFunc;
49 return this; 50 return this;
50 } 51 }
@@ -65,7 +66,7 @@ public class BuyerOrderButtonsHandler { @@ -65,7 +66,7 @@ public class BuyerOrderButtonsHandler {
65 pbos = buyerOrderDS.apply(paidOrderCodes, statusList); 66 pbos = buyerOrderDS.apply(paidOrderCodes, statusList);
66 if (CollectionUtils.isNotEmpty(pbos)){ 67 if (CollectionUtils.isNotEmpty(pbos)){
67 BuyerOrder pbo = pbos.get(0); 68 BuyerOrder pbo = pbos.get(0);
68 - List<ButtonShowBo> fbsbs = fmtBtnFunc.apply(pbo, orderDetailInfo.getButtons(), 2); 69 + List<ButtonShowBo> fbsbs = fmtBtnFunc.apply(pbo, orderDetailInfo.getButtons(), ViewType.DETAIL);
69 orderDetailInfo.setButtons(fbsbs); 70 orderDetailInfo.setButtons(fbsbs);
70 } 71 }
71 } 72 }
@@ -92,7 +93,7 @@ public class BuyerOrderButtonsHandler { @@ -92,7 +93,7 @@ public class BuyerOrderButtonsHandler {
92 if(olip.test(oli)) { 93 if(olip.test(oli)) {
93 Long orderCode = oli.getOrderCode(); 94 Long orderCode = oli.getOrderCode();
94 BuyerOrder pbo = codeBuyorderMap.get(orderCode); 95 BuyerOrder pbo = codeBuyorderMap.get(orderCode);
95 - List<ButtonShowBo> fbsbs = fmtBtnFunc.apply(pbo, oli.getButtons(), 1); 96 + List<ButtonShowBo> fbsbs = fmtBtnFunc.apply(pbo, oli.getButtons(), ViewType.LIST);
96 oli.setButtons(fbsbs); 97 oli.setButtons(fbsbs);
97 } 98 }
98 } 99 }
@@ -16,6 +16,7 @@ import com.yohoufo.dal.order.model.BuyerOrder; @@ -16,6 +16,7 @@ import com.yohoufo.dal.order.model.BuyerOrder;
16 import com.yohoufo.dal.order.model.BuyerOrderGoods; 16 import com.yohoufo.dal.order.model.BuyerOrderGoods;
17 import com.yohoufo.dal.order.model.BuyerOrderMeta; 17 import com.yohoufo.dal.order.model.BuyerOrderMeta;
18 import com.yohoufo.dal.order.model.SellerOrderGoods; 18 import com.yohoufo.dal.order.model.SellerOrderGoods;
  19 +import com.yohoufo.order.constants.ViewType;
19 import com.yohoufo.order.convert.GoodsInfoConvertor; 20 import com.yohoufo.order.convert.GoodsInfoConvertor;
20 import com.yohoufo.order.model.request.OrderRequest; 21 import com.yohoufo.order.model.request.OrderRequest;
21 import com.yohoufo.order.model.response.GoodsInfo; 22 import com.yohoufo.order.model.response.GoodsInfo;
@@ -161,7 +162,7 @@ public abstract class AbsOrderDetailService extends AbsOrderViewService implemen @@ -161,7 +162,7 @@ public abstract class AbsOrderDetailService extends AbsOrderViewService implemen
161 orderDetailInfo.setOrderCode(orderCode = buyerOrder.getOrderCode()); 162 orderDetailInfo.setOrderCode(orderCode = buyerOrder.getOrderCode());
162 orderDetailInfo.setSubmitOrderTimeStr(DateUtil.formatDate(buyerOrder.getCreateTime(), DateUtil.yyyy_MM_dd_HH_mm_SS)); 163 orderDetailInfo.setSubmitOrderTimeStr(DateUtil.formatDate(buyerOrder.getCreateTime(), DateUtil.yyyy_MM_dd_HH_mm_SS));
163 List<ButtonShowBo> buttonShowList = orderStatus.getDetailButtons(tabType); 164 List<ButtonShowBo> buttonShowList = orderStatus.getDetailButtons(tabType);
164 - orderDetailInfo.setButtons(formatButtons(buyerOrder, buttonShowList==null? Lists.newArrayList() : new ArrayList<>(buttonShowList), 2)); 165 + orderDetailInfo.setButtons(formatButtons(buyerOrder, buttonShowList==null? Lists.newArrayList() : new ArrayList<>(buttonShowList), ViewType.DETAIL));
165 166
166 // 买家 买家订单号 需要处理立即支付 167 // 买家 买家订单号 需要处理立即支付
167 // 卖家 卖家订单号 不存在立即支付的按钮 168 // 卖家 卖家订单号 不存在立即支付的按钮
@@ -15,6 +15,7 @@ import com.yohoufo.dal.order.model.BuyerOrder; @@ -15,6 +15,7 @@ import com.yohoufo.dal.order.model.BuyerOrder;
15 import com.yohoufo.dal.order.model.BuyerOrderGoods; 15 import com.yohoufo.dal.order.model.BuyerOrderGoods;
16 import com.yohoufo.dal.order.model.QiniuLiveRecord; 16 import com.yohoufo.dal.order.model.QiniuLiveRecord;
17 import com.yohoufo.dal.order.model.SellerOrderGoods; 17 import com.yohoufo.dal.order.model.SellerOrderGoods;
  18 +import com.yohoufo.order.constants.ViewType;
18 import com.yohoufo.order.model.request.OrderListRequest; 19 import com.yohoufo.order.model.request.OrderListRequest;
19 import com.yohoufo.order.service.IOrderListService; 20 import com.yohoufo.order.service.IOrderListService;
20 import com.yohoufo.order.utils.BuyerOrderUtils; 21 import com.yohoufo.order.utils.BuyerOrderUtils;
@@ -160,7 +161,7 @@ public abstract class AbsOrderListService extends AbsOrderViewService implements @@ -160,7 +161,7 @@ public abstract class AbsOrderListService extends AbsOrderViewService implements
160 // 按钮显示 161 // 按钮显示
161 List<ButtonShowBo> buttonShowBos = orderStatus.getListButtons(tabType); 162 List<ButtonShowBo> buttonShowBos = orderStatus.getListButtons(tabType);
162 163
163 - orderListInfo.setButtons(formatButtons(buyerOrder, buttonShowBos == null ? new ArrayList<>() : new ArrayList<>(buttonShowBos), 1)); 164 + orderListInfo.setButtons(formatButtons(buyerOrder, buttonShowBos == null ? new ArrayList<>() : new ArrayList<>(buttonShowBos), ViewType.LIST));
164 165
165 // 当剩余时间小于0 166 // 当剩余时间小于0
166 if (!CollectionUtils.isEmpty(orderListInfo.getButtons())){ 167 if (!CollectionUtils.isEmpty(orderListInfo.getButtons())){
@@ -6,6 +6,7 @@ import com.yohobuy.ufo.model.order.common.*; @@ -6,6 +6,7 @@ import com.yohobuy.ufo.model.order.common.*;
6 import com.yohoufo.common.utils.DateUtil; 6 import com.yohoufo.common.utils.DateUtil;
7 import com.yohoufo.dal.order.model.BuyerOrder; 7 import com.yohoufo.dal.order.model.BuyerOrder;
8 import com.yohoufo.order.common.Payment; 8 import com.yohoufo.order.common.Payment;
  9 +import com.yohoufo.order.constants.ViewType;
9 import com.yohoufo.order.model.dto.BuyerPenaltyCalResult; 10 import com.yohoufo.order.model.dto.BuyerPenaltyCalResult;
10 import com.yohoufo.order.model.response.OrderDetailInfo; 11 import com.yohoufo.order.model.response.OrderDetailInfo;
11 import com.yohoufo.order.service.handler.BuyerCancelCompensateComputeHandler; 12 import com.yohoufo.order.service.handler.BuyerCancelCompensateComputeHandler;
@@ -37,15 +38,15 @@ public abstract class AbsOrderViewService { @@ -37,15 +38,15 @@ public abstract class AbsOrderViewService {
37 * 38 *
38 * @param buyerOrder 39 * @param buyerOrder
39 * @param buttons 40 * @param buttons
40 - * @param actType 1:订单列表; 2:订单详情 41 + * @param viewType 1:订单列表; 2:订单详情
41 * @return 42 * @return
42 */ 43 */
43 - List<ButtonShowBo> formatButtons(BuyerOrder buyerOrder, List<ButtonShowBo> buttons, int actType){ 44 + List<ButtonShowBo> formatButtons(BuyerOrder buyerOrder, List<ButtonShowBo> buttons, ViewType viewType){
44 if (CollectionUtils.isEmpty(buttons) || Objects.isNull(buyerOrder)){ 45 if (CollectionUtils.isEmpty(buttons) || Objects.isNull(buyerOrder)){
45 return buttons; 46 return buttons;
46 } 47 }
47 48
48 - disableBuyAgainIfOffline(buyerOrder, buttons, actType); 49 + disableBuyAgainIfOffline(buyerOrder, buttons, viewType);
49 50
50 //TODO optimized first query out status of order need BuyerPenaltyCalResult 51 //TODO optimized first query out status of order need BuyerPenaltyCalResult
51 int orderStatusCode = buyerOrder.getStatus(); 52 int orderStatusCode = buyerOrder.getStatus();
@@ -80,14 +81,14 @@ public abstract class AbsOrderViewService { @@ -80,14 +81,14 @@ public abstract class AbsOrderViewService {
80 * 门店订单,不需要“再次购买”,替换为“查看详情” 81 * 门店订单,不需要“再次购买”,替换为“查看详情”
81 * @param buyerOrder 82 * @param buyerOrder
82 * @param buttons 83 * @param buttons
83 - * @param actType 1:订单列表; 2:订单详情 84 + * @param viewType 1:订单列表; 2:订单详情
84 */ 85 */
85 - private void disableBuyAgainIfOffline(final BuyerOrder buyerOrder, final List<ButtonShowBo> buttons, int actType) { 86 + private void disableBuyAgainIfOffline(final BuyerOrder buyerOrder, final List<ButtonShowBo> buttons, ViewType viewType) {
86 if(BuyerOrderUtils.isOffline(buyerOrder.getAttributes()) 87 if(BuyerOrderUtils.isOffline(buyerOrder.getAttributes())
87 && buttons != null && buttons.contains(ButtonShow.BUY_AGAIN.getBo())) { 88 && buttons != null && buttons.contains(ButtonShow.BUY_AGAIN.getBo())) {
88 buttons.remove(ButtonShow.BUY_AGAIN.getBo()); 89 buttons.remove(ButtonShow.BUY_AGAIN.getBo());
89 //订单列表“再次购买”替换为“查看详情”,订单详情“再次购买”直接去掉 90 //订单列表“再次购买”替换为“查看详情”,订单详情“再次购买”直接去掉
90 - if(actType == 1 && !buttons.contains(ButtonShow.SHOW_DETAIL.getBo())) { 91 + if(ViewType.LIST == viewType && !buttons.contains(ButtonShow.SHOW_DETAIL.getBo())) {
91 buttons.add(ButtonShow.SHOW_DETAIL.getBo()); 92 buttons.add(ButtonShow.SHOW_DETAIL.getBo());
92 } 93 }
93 } 94 }
@@ -16,6 +16,7 @@ import com.yohoufo.dal.order.model.*; @@ -16,6 +16,7 @@ import com.yohoufo.dal.order.model.*;
16 import com.yohoufo.order.common.ActionStatusHold; 16 import com.yohoufo.order.common.ActionStatusHold;
17 import com.yohoufo.order.common.Payment; 17 import com.yohoufo.order.common.Payment;
18 import com.yohoufo.order.constants.MetaKey; 18 import com.yohoufo.order.constants.MetaKey;
  19 +import com.yohoufo.order.constants.ViewType;
19 import com.yohoufo.order.convert.GoodsInfoConvertor; 20 import com.yohoufo.order.convert.GoodsInfoConvertor;
20 import com.yohoufo.order.convert.SellerOrderConvertor; 21 import com.yohoufo.order.convert.SellerOrderConvertor;
21 import com.yohoufo.order.model.dto.SellerOrderComputeResult; 22 import com.yohoufo.order.model.dto.SellerOrderComputeResult;
@@ -21,6 +21,7 @@ import com.yohoufo.dal.order.model.BuyerOrder; @@ -21,6 +21,7 @@ import com.yohoufo.dal.order.model.BuyerOrder;
21 import com.yohoufo.dal.order.model.BuyerOrderGoods; 21 import com.yohoufo.dal.order.model.BuyerOrderGoods;
22 import com.yohoufo.dal.order.model.SellerOrder; 22 import com.yohoufo.dal.order.model.SellerOrder;
23 import com.yohoufo.dal.order.model.SellerOrderGoods; 23 import com.yohoufo.dal.order.model.SellerOrderGoods;
  24 +import com.yohoufo.order.constants.ViewType;
24 import com.yohoufo.order.model.request.OrderListRequest; 25 import com.yohoufo.order.model.request.OrderListRequest;
25 import com.yohoufo.order.service.AbsSellerOrderViewService; 26 import com.yohoufo.order.service.AbsSellerOrderViewService;
26 import com.yohoufo.order.service.IOrderListService; 27 import com.yohoufo.order.service.IOrderListService;