Authored by chenchao

use enum

package com.yohoufo.order.constants;
/**
* Created by chao.chen on 2019/1/22.
*/
public enum ViewType {
DETAIL, LIST
}
... ...
... ... @@ -7,6 +7,7 @@ import com.yohobuy.ufo.model.order.common.SkupStatus;
import com.yohobuy.ufo.model.response.StorageDataResp;
import com.yohoufo.common.utils.BigDecimalHelper;
import com.yohoufo.order.common.Payment;
import com.yohoufo.order.constants.ViewType;
import com.yohoufo.order.service.proxy.ProductProxyService;
import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger;
... ... @@ -21,9 +22,6 @@ import java.util.List;
*/
public interface AbsSellerOrderViewService {
Logger getLogger();
enum ViewType{
DETAIL, LIST
}
ProductProxyService getProductProxyService();
... ...
... ... @@ -5,6 +5,7 @@ import com.yohobuy.ufo.model.order.bo.ButtonShowBo;
import com.yohobuy.ufo.model.order.common.OrderStatus;
import com.yohobuy.ufo.model.order.resp.OrderListInfo;
import com.yohoufo.dal.order.model.BuyerOrder;
import com.yohoufo.order.constants.ViewType;
import com.yohoufo.order.model.response.OrderDetailInfo;
import com.yohoufo.order.service.support.ThreeFunction;
import org.apache.commons.collections.CollectionUtils;
... ... @@ -42,9 +43,9 @@ public class BuyerOrderButtonsHandler {
return this;
}
ThreeFunction<BuyerOrder, List<ButtonShowBo>, Integer, List<ButtonShowBo>> fmtBtnFunc;
ThreeFunction<BuyerOrder, List<ButtonShowBo>, ViewType, List<ButtonShowBo>> fmtBtnFunc;
public BuyerOrderButtonsHandler loadFmtBtnFunc(ThreeFunction<BuyerOrder,List<ButtonShowBo>, Integer, List<ButtonShowBo>> fmtBtnFunc){
public BuyerOrderButtonsHandler loadFmtBtnFunc(ThreeFunction<BuyerOrder,List<ButtonShowBo>, ViewType, List<ButtonShowBo>> fmtBtnFunc){
this.fmtBtnFunc = fmtBtnFunc;
return this;
}
... ... @@ -65,7 +66,7 @@ public class BuyerOrderButtonsHandler {
pbos = buyerOrderDS.apply(paidOrderCodes, statusList);
if (CollectionUtils.isNotEmpty(pbos)){
BuyerOrder pbo = pbos.get(0);
List<ButtonShowBo> fbsbs = fmtBtnFunc.apply(pbo, orderDetailInfo.getButtons(), 2);
List<ButtonShowBo> fbsbs = fmtBtnFunc.apply(pbo, orderDetailInfo.getButtons(), ViewType.DETAIL);
orderDetailInfo.setButtons(fbsbs);
}
}
... ... @@ -92,7 +93,7 @@ public class BuyerOrderButtonsHandler {
if(olip.test(oli)) {
Long orderCode = oli.getOrderCode();
BuyerOrder pbo = codeBuyorderMap.get(orderCode);
List<ButtonShowBo> fbsbs = fmtBtnFunc.apply(pbo, oli.getButtons(), 1);
List<ButtonShowBo> fbsbs = fmtBtnFunc.apply(pbo, oli.getButtons(), ViewType.LIST);
oli.setButtons(fbsbs);
}
}
... ...
... ... @@ -16,6 +16,7 @@ import com.yohoufo.dal.order.model.BuyerOrder;
import com.yohoufo.dal.order.model.BuyerOrderGoods;
import com.yohoufo.dal.order.model.BuyerOrderMeta;
import com.yohoufo.dal.order.model.SellerOrderGoods;
import com.yohoufo.order.constants.ViewType;
import com.yohoufo.order.convert.GoodsInfoConvertor;
import com.yohoufo.order.model.request.OrderRequest;
import com.yohoufo.order.model.response.GoodsInfo;
... ... @@ -161,7 +162,7 @@ public abstract class AbsOrderDetailService extends AbsOrderViewService implemen
orderDetailInfo.setOrderCode(orderCode = buyerOrder.getOrderCode());
orderDetailInfo.setSubmitOrderTimeStr(DateUtil.formatDate(buyerOrder.getCreateTime(), DateUtil.yyyy_MM_dd_HH_mm_SS));
List<ButtonShowBo> buttonShowList = orderStatus.getDetailButtons(tabType);
orderDetailInfo.setButtons(formatButtons(buyerOrder, buttonShowList==null? Lists.newArrayList() : new ArrayList<>(buttonShowList), 2));
orderDetailInfo.setButtons(formatButtons(buyerOrder, buttonShowList==null? Lists.newArrayList() : new ArrayList<>(buttonShowList), ViewType.DETAIL));
// 买家 买家订单号 需要处理立即支付
// 卖家 卖家订单号 不存在立即支付的按钮
... ...
... ... @@ -15,6 +15,7 @@ import com.yohoufo.dal.order.model.BuyerOrder;
import com.yohoufo.dal.order.model.BuyerOrderGoods;
import com.yohoufo.dal.order.model.QiniuLiveRecord;
import com.yohoufo.dal.order.model.SellerOrderGoods;
import com.yohoufo.order.constants.ViewType;
import com.yohoufo.order.model.request.OrderListRequest;
import com.yohoufo.order.service.IOrderListService;
import com.yohoufo.order.utils.BuyerOrderUtils;
... ... @@ -160,7 +161,7 @@ public abstract class AbsOrderListService extends AbsOrderViewService implements
// 按钮显示
List<ButtonShowBo> buttonShowBos = orderStatus.getListButtons(tabType);
orderListInfo.setButtons(formatButtons(buyerOrder, buttonShowBos == null ? new ArrayList<>() : new ArrayList<>(buttonShowBos), 1));
orderListInfo.setButtons(formatButtons(buyerOrder, buttonShowBos == null ? new ArrayList<>() : new ArrayList<>(buttonShowBos), ViewType.LIST));
// 当剩余时间小于0
if (!CollectionUtils.isEmpty(orderListInfo.getButtons())){
... ...
... ... @@ -6,6 +6,7 @@ import com.yohobuy.ufo.model.order.common.*;
import com.yohoufo.common.utils.DateUtil;
import com.yohoufo.dal.order.model.BuyerOrder;
import com.yohoufo.order.common.Payment;
import com.yohoufo.order.constants.ViewType;
import com.yohoufo.order.model.dto.BuyerPenaltyCalResult;
import com.yohoufo.order.model.response.OrderDetailInfo;
import com.yohoufo.order.service.handler.BuyerCancelCompensateComputeHandler;
... ... @@ -37,15 +38,15 @@ public abstract class AbsOrderViewService {
*
* @param buyerOrder
* @param buttons
* @param actType 1:订单列表; 2:订单详情
* @param viewType 1:订单列表; 2:订单详情
* @return
*/
List<ButtonShowBo> formatButtons(BuyerOrder buyerOrder, List<ButtonShowBo> buttons, int actType){
List<ButtonShowBo> formatButtons(BuyerOrder buyerOrder, List<ButtonShowBo> buttons, ViewType viewType){
if (CollectionUtils.isEmpty(buttons) || Objects.isNull(buyerOrder)){
return buttons;
}
disableBuyAgainIfOffline(buyerOrder, buttons, actType);
disableBuyAgainIfOffline(buyerOrder, buttons, viewType);
//TODO optimized first query out status of order need BuyerPenaltyCalResult
int orderStatusCode = buyerOrder.getStatus();
... ... @@ -80,14 +81,14 @@ public abstract class AbsOrderViewService {
* 门店订单,不需要“再次购买”,替换为“查看详情”
* @param buyerOrder
* @param buttons
* @param actType 1:订单列表; 2:订单详情
* @param viewType 1:订单列表; 2:订单详情
*/
private void disableBuyAgainIfOffline(final BuyerOrder buyerOrder, final List<ButtonShowBo> buttons, int actType) {
private void disableBuyAgainIfOffline(final BuyerOrder buyerOrder, final List<ButtonShowBo> buttons, ViewType viewType) {
if(BuyerOrderUtils.isOffline(buyerOrder.getAttributes())
&& buttons != null && buttons.contains(ButtonShow.BUY_AGAIN.getBo())) {
buttons.remove(ButtonShow.BUY_AGAIN.getBo());
//订单列表“再次购买”替换为“查看详情”,订单详情“再次购买”直接去掉
if(actType == 1 && !buttons.contains(ButtonShow.SHOW_DETAIL.getBo())) {
if(ViewType.LIST == viewType && !buttons.contains(ButtonShow.SHOW_DETAIL.getBo())) {
buttons.add(ButtonShow.SHOW_DETAIL.getBo());
}
}
... ...
... ... @@ -16,6 +16,7 @@ import com.yohoufo.dal.order.model.*;
import com.yohoufo.order.common.ActionStatusHold;
import com.yohoufo.order.common.Payment;
import com.yohoufo.order.constants.MetaKey;
import com.yohoufo.order.constants.ViewType;
import com.yohoufo.order.convert.GoodsInfoConvertor;
import com.yohoufo.order.convert.SellerOrderConvertor;
import com.yohoufo.order.model.dto.SellerOrderComputeResult;
... ...
... ... @@ -21,6 +21,7 @@ import com.yohoufo.dal.order.model.BuyerOrder;
import com.yohoufo.dal.order.model.BuyerOrderGoods;
import com.yohoufo.dal.order.model.SellerOrder;
import com.yohoufo.dal.order.model.SellerOrderGoods;
import com.yohoufo.order.constants.ViewType;
import com.yohoufo.order.model.request.OrderListRequest;
import com.yohoufo.order.service.AbsSellerOrderViewService;
import com.yohoufo.order.service.IOrderListService;
... ...