...
|
...
|
@@ -5,8 +5,10 @@ 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.dal.order.model.BuyerOrderGoods;
|
|
|
import com.yohoufo.order.constants.ViewType;
|
|
|
import com.yohoufo.order.model.response.OrderDetailInfo;
|
|
|
import com.yohoufo.order.service.support.BuyerOrderButtonFormatFunction;
|
|
|
import com.yohoufo.order.service.support.ThreeFunction;
|
|
|
import com.yohoufo.order.utils.LoggerUtils;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
...
|
...
|
@@ -34,6 +36,8 @@ public class BuyerOrderButtonsHandler { |
|
|
|
|
|
private BiFunction<List<Long>, List<Integer>, List<BuyerOrder>> buyerOrderDS;
|
|
|
|
|
|
private BiFunction<Integer, List<Long>, List<BuyerOrderGoods>> buyerOrderGoodsDS;
|
|
|
|
|
|
public BuyerOrderButtonsHandler(List<OrderListInfo> orderListInfos){
|
|
|
this.orderListInfos = orderListInfos;
|
|
|
}
|
...
|
...
|
@@ -43,14 +47,15 @@ public class BuyerOrderButtonsHandler { |
|
|
}
|
|
|
|
|
|
|
|
|
public BuyerOrderButtonsHandler loadBuyerOrderDS(BiFunction<List<Long>, List<Integer>, List<BuyerOrder>> buyerOrderDS){
|
|
|
public BuyerOrderButtonsHandler loadBuyerOrderDS(BiFunction<List<Long>, List<Integer>, List<BuyerOrder>> buyerOrderDS,BiFunction<Integer, List<Long>, List<BuyerOrderGoods>> buyerOrderGoodsDS){
|
|
|
this.buyerOrderDS = buyerOrderDS;
|
|
|
this.buyerOrderGoodsDS = buyerOrderGoodsDS;
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
ThreeFunction<BuyerOrder, List<ButtonShowBo>, ViewType, List<ButtonShowBo>> fmtBtnFunc;
|
|
|
BuyerOrderButtonFormatFunction fmtBtnFunc;
|
|
|
|
|
|
public BuyerOrderButtonsHandler loadFmtBtnFunc(ThreeFunction<BuyerOrder,List<ButtonShowBo>, ViewType, List<ButtonShowBo>> fmtBtnFunc){
|
|
|
public BuyerOrderButtonsHandler loadFmtBtnFunc(BuyerOrderButtonFormatFunction fmtBtnFunc){
|
|
|
this.fmtBtnFunc = fmtBtnFunc;
|
|
|
return this;
|
|
|
}
|
...
|
...
|
@@ -71,7 +76,8 @@ 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(), ViewType.DETAIL);
|
|
|
BuyerOrderGoods bog = buyerOrderGoodsDS.apply(pbo.getUid(),Lists.newArrayList(pbo.getOrderCode())).stream().findFirst().orElse(null);
|
|
|
List<ButtonShowBo> fbsbs = fmtBtnFunc.format(orderDetailInfo.getButtons(), pbo, bog, ViewType.DETAIL);
|
|
|
orderDetailInfo.setButtons(fbsbs);
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -98,19 +104,24 @@ public class BuyerOrderButtonsHandler { |
|
|
.map(OrderListInfo::getOrderCode).collect(Collectors.toList());
|
|
|
|
|
|
List<BuyerOrder> pbos = null;
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(paidOrderCodes)){
|
|
|
List<Integer> statusList = Lists.newArrayList(OrderStatus.HAS_PAYED.getCode());
|
|
|
pbos = buyerOrderDS.apply(paidOrderCodes, statusList);
|
|
|
}
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(pbos)){
|
|
|
Integer uid = pbos.get(0).getUid();
|
|
|
List<Long> orderCodes = pbos.stream().map(BuyerOrder::getOrderCode).collect(Collectors.toList());
|
|
|
Map<Long, BuyerOrder> codeBuyorderMap = pbos.parallelStream()
|
|
|
.collect(Collectors.toMap(BuyerOrder::getOrderCode, Function.identity()));
|
|
|
Map<Long, BuyerOrderGoods> buyerOrderGoodsMap = buyerOrderGoodsDS.apply(uid, orderCodes).stream().collect(Collectors.toMap(BuyerOrderGoods::getOrderCode,Function.identity()));
|
|
|
for(OrderListInfo oli : orderListInfos){
|
|
|
if(olip.test(oli)) {
|
|
|
Long orderCode = oli.getOrderCode();
|
|
|
BuyerOrder pbo = codeBuyorderMap.get(orderCode);
|
|
|
List<ButtonShowBo> fbsbs = fmtBtnFunc.apply(pbo, oli.getButtons(), ViewType.LIST);
|
|
|
BuyerOrderGoods bog = buyerOrderGoodsMap.get(orderCode);
|
|
|
List<ButtonShowBo> fbsbs = fmtBtnFunc.format(oli.getButtons(),pbo,bog , ViewType.LIST);
|
|
|
oli.setButtons(fbsbs);
|
|
|
}
|
|
|
}
|
...
|
...
|
|