new calculate method 4 list timeout
Showing
11 changed files
with
530 additions
and
226 deletions
@@ -91,7 +91,10 @@ public class SellerController { | @@ -91,7 +91,10 @@ public class SellerController { | ||
91 | } | 91 | } |
92 | 92 | ||
93 | 93 | ||
94 | - | 94 | + /** |
95 | + * 入驻超级卖家阈值配置 | ||
96 | + * @return | ||
97 | + */ | ||
95 | @RequestMapping(params = "method=ufo.seller.entryThresholds") | 98 | @RequestMapping(params = "method=ufo.seller.entryThresholds") |
96 | @ResponseBody | 99 | @ResponseBody |
97 | public ApiResponse getEntryThresholds() { | 100 | public ApiResponse getEntryThresholds() { |
@@ -101,7 +104,11 @@ public class SellerController { | @@ -101,7 +104,11 @@ public class SellerController { | ||
101 | } | 104 | } |
102 | 105 | ||
103 | 106 | ||
104 | - | 107 | + /** |
108 | + * 入驻的普通卖家当钱包金额满足5000,可以直接申请为超级卖家 | ||
109 | + * @param uid | ||
110 | + * @return | ||
111 | + */ | ||
105 | @RequestMapping(params = "method=ufo.seller.applySuperEnter") | 112 | @RequestMapping(params = "method=ufo.seller.applySuperEnter") |
106 | @ResponseBody | 113 | @ResponseBody |
107 | public ApiResponse applySuperEnter(@RequestParam("uid") Integer uid) { | 114 | public ApiResponse applySuperEnter(@RequestParam("uid") Integer uid) { |
1 | -package com.yohoufo.order.service.impl; | ||
2 | - | ||
3 | -import com.google.common.collect.Lists; | ||
4 | -import com.yohobuy.ufo.model.order.bo.ButtonShowBo; | ||
5 | -import com.yohobuy.ufo.model.order.bo.GoodsInfo; | ||
6 | -import com.yohobuy.ufo.model.order.bo.OrderInfo; | ||
7 | -import com.yohobuy.ufo.model.order.common.ButtonShow; | ||
8 | -import com.yohobuy.ufo.model.order.common.OrderStatus; | ||
9 | -import com.yohobuy.ufo.model.order.common.TabType; | ||
10 | -import com.yohobuy.ufo.model.order.resp.OrderListInfo; | ||
11 | -import com.yohobuy.ufo.model.order.resp.PageResp; | ||
12 | -import com.yohoufo.common.helper.ImageUrlAssist; | ||
13 | -import com.yohoufo.common.utils.DateUtil; | ||
14 | -import com.yohoufo.dal.order.model.BuyerOrder; | ||
15 | -import com.yohoufo.dal.order.model.BuyerOrderGoods; | ||
16 | -import com.yohoufo.dal.order.model.QiniuLiveRecord; | ||
17 | -import com.yohoufo.dal.order.model.SellerOrderGoods; | ||
18 | -import com.yohoufo.order.constants.ViewType; | ||
19 | -import com.yohoufo.order.model.request.OrderListRequest; | ||
20 | -import com.yohoufo.order.service.IOrderListService; | ||
21 | -import com.yohoufo.order.utils.BuyerOrderUtils; | ||
22 | -import org.apache.commons.collections.CollectionUtils; | ||
23 | -import org.slf4j.Logger; | ||
24 | -import org.slf4j.LoggerFactory; | ||
25 | - | ||
26 | -import java.util.ArrayList; | ||
27 | -import java.util.List; | ||
28 | -import java.util.Map; | ||
29 | -import java.util.function.Function; | ||
30 | -import java.util.stream.Collectors; | ||
31 | - | ||
32 | -/** | ||
33 | - * Created by chenchao on 2018/9/19. | ||
34 | - */ | ||
35 | -public abstract class AbsOrderListService extends AbsOrderViewService implements IOrderListService{ | ||
36 | - | ||
37 | - private final Logger logger = LoggerFactory.getLogger(getClass()); | ||
38 | - | ||
39 | - abstract List<Integer> initOrderListRequest(OrderListRequest request); | ||
40 | - | ||
41 | - abstract int getTotal(int uid, List<Integer> statusQuery); | ||
42 | - | ||
43 | - abstract List<BuyerOrder> getOrderList(int uid, List<Integer> statusQuery, int offset, int limit); | ||
44 | - | ||
45 | - abstract List<BuyerOrderGoods> getOrderGoodsList(int uid, List<Long> orderCodeList); | ||
46 | - | ||
47 | - abstract List<SellerOrderGoods> getBaseOrderGoodsList(List<Integer> skups); | ||
48 | - | ||
49 | - /** | ||
50 | - * 获取鉴定视频 | ||
51 | - * @param buyerOrderList | ||
52 | - * @return | ||
53 | - */ | ||
54 | - abstract Map<Long,String> getAppraiseVideo(List<BuyerOrder> buyerOrderList); | ||
55 | - | ||
56 | - | ||
57 | - /** | ||
58 | - * 订单列表 | ||
59 | - * @param request | ||
60 | - * @return | ||
61 | - */ | ||
62 | - @Override | ||
63 | - public PageResp<OrderListInfo> getOrderList(OrderListRequest request){ | ||
64 | - | ||
65 | - // check and init请求参数 | ||
66 | - List<Integer> statusQuery = initOrderListRequest(request); | ||
67 | - TabType actor = request.getActor(); | ||
68 | - int total = getTotal(request.getUid(), statusQuery); | ||
69 | - int limit = request.getLimit(); | ||
70 | - PageResp.PageRespBuilder respBuilder = PageResp.builder() | ||
71 | - .page(request.getPage()) | ||
72 | - .pageSize(limit) | ||
73 | - .total(total) | ||
74 | - .pagetotal((total % limit == 0) ? (total / limit) : (total / limit + 1)); | ||
75 | - if (total == 0){ | ||
76 | - return respBuilder.build(); | ||
77 | - } | ||
78 | - | ||
79 | - int offset = (request.getPage() - 1) * limit; | ||
80 | - | ||
81 | - List<BuyerOrder> buyerOrderList = getOrderList(request.getUid(), statusQuery, offset, limit); | ||
82 | - | ||
83 | - List<Long> orderCodeList = buyerOrderList.stream().map(BuyerOrder::getOrderCode).collect(Collectors.toList()); | ||
84 | - //TODO 可以提前计算 total offset limit三者之间的关系,减少一次网络I | ||
85 | - if (CollectionUtils.isEmpty(orderCodeList)){ | ||
86 | - return respBuilder.build(); | ||
87 | - } | ||
88 | - // buyer_order_goods ===> skup+商品成交价 1:1 | ||
89 | - List<BuyerOrderGoods> buyerOrderGoodsList = getOrderGoodsList(request.getUid(), orderCodeList); | ||
90 | - Map<Long, BuyerOrderGoods> buyerOrderGoodsMap = buyerOrderGoodsList.stream() | ||
91 | - .collect(Collectors.toMap(BuyerOrderGoods::getOrderCode, Function.identity(), (key1, key2) -> key2)); | ||
92 | - | ||
93 | - List<Integer> skups = buyerOrderGoodsList.stream().map(BuyerOrderGoods::getSkup).collect(Collectors.toList()); | ||
94 | - // seller_order_goods ===> 商品信息 | ||
95 | - List<SellerOrderGoods> sellerOrderGoodsList = getBaseOrderGoodsList(skups); | ||
96 | - Map<Integer, SellerOrderGoods> sellerOrderGoodsMap = sellerOrderGoodsList.stream().collect(Collectors.toMap(SellerOrderGoods::getId, Function.identity())); | ||
97 | - | ||
98 | - Map<Long,String> appraiseVideo = getAppraiseVideo(buyerOrderList); | ||
99 | - | ||
100 | - List<OrderListInfo> data = Lists.newArrayList(); | ||
101 | - | ||
102 | - buyerOrderList.stream().forEach(buyerOrder -> { | ||
103 | - OrderListInfo orderListInfo = convertOrderInfo(buyerOrderGoodsMap, sellerOrderGoodsMap, buyerOrder, actor, appraiseVideo); | ||
104 | - if (orderListInfo == null) return; | ||
105 | - data.add(orderListInfo); | ||
106 | - }); | ||
107 | - | ||
108 | - PageResp orderListInfoRsp = respBuilder.data(data).build(); | ||
109 | - | ||
110 | - return orderListInfoRsp; | ||
111 | - | ||
112 | - } | ||
113 | - | ||
114 | - | ||
115 | - /** | ||
116 | - * 获取返回结果 | ||
117 | - * @param buyerOrderGoodsMap | ||
118 | - * @param sellerOrderGoodsMap | ||
119 | - * @param buyerOrder | ||
120 | - * @return | ||
121 | - */ | ||
122 | - OrderListInfo convertOrderInfo(Map<Long, BuyerOrderGoods> buyerOrderGoodsMap, | ||
123 | - Map<Integer, SellerOrderGoods> sellerOrderGoodsMap, | ||
124 | - BuyerOrder buyerOrder, | ||
125 | - TabType tabType, | ||
126 | - Map<Long,String> appraiseVideo) { | ||
127 | - | ||
128 | - /** | ||
129 | - * 1.查询 buyer_order | ||
130 | - * 2.查询 buyer_order_goods ==> skup | ||
131 | - * 3.查询 seller_order_goods | ||
132 | - */ | ||
133 | - OrderListInfo orderListInfo = new OrderListInfo(); | ||
134 | - Integer buyerUid; | ||
135 | - Long orderCode; | ||
136 | - | ||
137 | - orderListInfo.setUid(buyerUid=buyerOrder.getUid()); | ||
138 | - orderListInfo.setBuyerUid(buyerUid); | ||
139 | - orderListInfo.setSellerUid(buyerOrder.getSellerUid()); | ||
140 | - orderListInfo.setOrderCode(orderCode=buyerOrder.getOrderCode()); | ||
141 | - orderListInfo.setRealPrice(buyerOrder.getAmount() == null ? "" : buyerOrder.getAmount().toPlainString()); | ||
142 | - | ||
143 | - boolean isOffline = BuyerOrderUtils.isOffline(buyerOrder.getAttributes()); | ||
144 | - orderListInfo.setIsOffline(isOffline ? "Y" : "N"); | ||
145 | - // 订单中状态显示 | ||
146 | - orderListInfo.setStatus(buyerOrder.getStatus() == null ? -1 : buyerOrder.getStatus()); | ||
147 | - OrderStatus orderStatus = OrderStatus.getOrderStatus(orderListInfo.getStatus()); | ||
148 | - | ||
149 | - if (orderStatus == null){ | ||
150 | - logger.warn("getOrderList orderStatus not exist, uid is {}, orderCode is {}, status is {}", | ||
151 | - buyerUid,orderCode, buyerOrder.getStatus()); | ||
152 | - return null; | ||
153 | - } | ||
154 | - | ||
155 | - orderListInfo.setStatuStr(orderStatus.getStatusStr(tabType)); | ||
156 | - | ||
157 | - // 当订单状态是待付款, 显示leftTime | ||
158 | - Integer leftTime = getLeftTime(tabType, buyerUid, orderCode, buyerOrder.getStatus(), buyerOrder.getCreateTime()); | ||
159 | - orderListInfo.setLeftTime(leftTime); | ||
160 | - | ||
161 | - // 按钮显示 | ||
162 | - List<ButtonShowBo> buttonShowBos = orderStatus.getListButtons(tabType); | ||
163 | - | ||
164 | - orderListInfo.setButtons(formatButtons(buyerOrder, buttonShowBos == null ? new ArrayList<>() : new ArrayList<>(buttonShowBos), ViewType.LIST)); | ||
165 | - | ||
166 | - // 当剩余时间小于0 | ||
167 | - if (!CollectionUtils.isEmpty(orderListInfo.getButtons())){ | ||
168 | - if (orderListInfo.getLeftTime() != null && orderListInfo.getLeftTime() <= 0){ | ||
169 | - orderListInfo.getButtons().removeIf(x-> x!=null && ButtonShow.NOW_BUY.getCode().equals(x.getCode())); | ||
170 | - } | ||
171 | - } | ||
172 | - | ||
173 | - BuyerOrderGoods buyerOrderGoods = buyerOrderGoodsMap.get(buyerOrder.getOrderCode()); | ||
174 | - if (buyerOrderGoods == null){ | ||
175 | - logger.warn("getOrderList buyer goods not exist, uid is {}, orderCode is {}", | ||
176 | - buyerOrder.getUid(), orderListInfo.getOrderCode()); | ||
177 | - return null; | ||
178 | - } | ||
179 | - orderListInfo.setSkup(buyerOrderGoods.getSkup()); | ||
180 | - | ||
181 | - SellerOrderGoods sellerOrderGoods = sellerOrderGoodsMap.get(buyerOrderGoods.getSkup()); | ||
182 | - if (sellerOrderGoods == null){ | ||
183 | - logger.warn("getOrderList seller goods not exist, uid is {}, orderCode is {}", | ||
184 | - buyerOrder.getUid(), orderListInfo.getOrderCode()); | ||
185 | - return null; | ||
186 | - } | ||
187 | - | ||
188 | - GoodsInfo goodsInfo = new GoodsInfo(); | ||
189 | - goodsInfo.setColorName(sellerOrderGoods.getColorName()); | ||
190 | - goodsInfo.setProductName((isOffline ? "【门店订单】" : "") + sellerOrderGoods.getProductName()); | ||
191 | - goodsInfo.setGoodImg(ImageUrlAssist.getAllProductPicUrl(sellerOrderGoods.getImageUrl(), "goodsimg", "center", "d2hpdGU=")); | ||
192 | - goodsInfo.setSizeName(sellerOrderGoods.getSizeName()); | ||
193 | - goodsInfo.setGoodPrice(buyerOrderGoods.getGoodsPrice() == null ? "" :buyerOrderGoods.getGoodsPrice().toPlainString()); | ||
194 | - goodsInfo.setStorageId(sellerOrderGoods.getStorageId()); | ||
195 | - goodsInfo.setProductId(sellerOrderGoods.getProductId()); | ||
196 | - goodsInfo.setSkup(buyerOrderGoods.getSkup()); | ||
197 | - orderListInfo.setGoodsInfo(goodsInfo); | ||
198 | - orderListInfo.setSecendLevelCreateTime(buyerOrder.getCreateTime()); | ||
199 | - orderListInfo.setCreateTime(DateUtil.formatDate(buyerOrder.getCreateTime(), DateUtil.yyyy_MM_dd_HH_mm_SS)); | ||
200 | - setAddressInfo(orderListInfo); | ||
201 | - orderListInfo.setAppraiseVideoUrl(appraiseVideo.get(buyerOrder.getOrderCode())); | ||
202 | - // | ||
203 | - orderListInfo.setPayTimeLimit(OrderInfo.PAY_TIME_SECOND); | ||
204 | - return orderListInfo; | ||
205 | - } | ||
206 | - | ||
207 | - abstract void setAddressInfo(OrderListInfo orderListInfo); | ||
208 | - | ||
209 | - protected abstract void resetDynamicProporties(List<OrderListInfo> list,int type); | ||
210 | -} | 1 | +package com.yohoufo.order.service.impl; |
2 | + | ||
3 | +import com.google.common.collect.Lists; | ||
4 | +import com.yohobuy.ufo.model.order.bo.ButtonShowBo; | ||
5 | +import com.yohobuy.ufo.model.order.bo.GoodsInfo; | ||
6 | +import com.yohobuy.ufo.model.order.bo.TimeoutBo; | ||
7 | +import com.yohobuy.ufo.model.order.common.ButtonShow; | ||
8 | +import com.yohobuy.ufo.model.order.common.OrderStatus; | ||
9 | +import com.yohobuy.ufo.model.order.common.TabType; | ||
10 | +import com.yohobuy.ufo.model.order.resp.OrderListInfo; | ||
11 | +import com.yohobuy.ufo.model.order.resp.PageResp; | ||
12 | +import com.yohoufo.common.helper.ImageUrlAssist; | ||
13 | +import com.yohoufo.common.utils.DateUtil; | ||
14 | +import com.yohoufo.dal.order.model.BuyerOrder; | ||
15 | +import com.yohoufo.dal.order.model.BuyerOrderGoods; | ||
16 | +import com.yohoufo.dal.order.model.SellerOrderGoods; | ||
17 | +import com.yohoufo.order.constants.ViewType; | ||
18 | +import com.yohoufo.order.model.request.OrderListRequest; | ||
19 | +import com.yohoufo.order.service.IOrderListService; | ||
20 | +import com.yohoufo.order.utils.BuyerOrderUtils; | ||
21 | +import org.apache.commons.collections.CollectionUtils; | ||
22 | +import org.slf4j.Logger; | ||
23 | +import org.slf4j.LoggerFactory; | ||
24 | + | ||
25 | +import java.util.ArrayList; | ||
26 | +import java.util.List; | ||
27 | +import java.util.Map; | ||
28 | +import java.util.function.Function; | ||
29 | +import java.util.stream.Collectors; | ||
30 | + | ||
31 | +/** | ||
32 | + * Created by chenchao on 2018/9/19. | ||
33 | + */ | ||
34 | +public abstract class AbsOrderListService extends AbsOrderViewService implements IOrderListService{ | ||
35 | + | ||
36 | + private final Logger logger = LoggerFactory.getLogger(getClass()); | ||
37 | + | ||
38 | + abstract List<Integer> initOrderListRequest(OrderListRequest request); | ||
39 | + | ||
40 | + abstract int getTotal(int uid, List<Integer> statusQuery); | ||
41 | + | ||
42 | + abstract List<BuyerOrder> getOrderList(int uid, List<Integer> statusQuery, int offset, int limit); | ||
43 | + | ||
44 | + abstract List<BuyerOrderGoods> getOrderGoodsList(int uid, List<Long> orderCodeList); | ||
45 | + | ||
46 | + abstract List<SellerOrderGoods> getBaseOrderGoodsList(List<Integer> skups); | ||
47 | + | ||
48 | + /** | ||
49 | + * 获取鉴定视频 | ||
50 | + * @param buyerOrderList | ||
51 | + * @return | ||
52 | + */ | ||
53 | + abstract Map<Long,String> getAppraiseVideo(List<BuyerOrder> buyerOrderList); | ||
54 | + | ||
55 | + | ||
56 | + /** | ||
57 | + * 订单列表 | ||
58 | + * @param request | ||
59 | + * @return | ||
60 | + */ | ||
61 | + @Override | ||
62 | + public PageResp<OrderListInfo> getOrderList(OrderListRequest request){ | ||
63 | + | ||
64 | + // check and init请求参数 | ||
65 | + List<Integer> statusQuery = initOrderListRequest(request); | ||
66 | + TabType actor = request.getActor(); | ||
67 | + int total = getTotal(request.getUid(), statusQuery); | ||
68 | + int limit = request.getLimit(); | ||
69 | + PageResp.PageRespBuilder respBuilder = PageResp.builder() | ||
70 | + .page(request.getPage()) | ||
71 | + .pageSize(limit) | ||
72 | + .total(total) | ||
73 | + .pagetotal((total % limit == 0) ? (total / limit) : (total / limit + 1)); | ||
74 | + if (total == 0){ | ||
75 | + return respBuilder.build(); | ||
76 | + } | ||
77 | + | ||
78 | + int offset = (request.getPage() - 1) * limit; | ||
79 | + | ||
80 | + List<BuyerOrder> buyerOrderList = getOrderList(request.getUid(), statusQuery, offset, limit); | ||
81 | + | ||
82 | + List<Long> orderCodeList = buyerOrderList.stream().map(BuyerOrder::getOrderCode).collect(Collectors.toList()); | ||
83 | + //TODO 可以提前计算 total offset limit三者之间的关系,减少一次网络I | ||
84 | + if (CollectionUtils.isEmpty(orderCodeList)){ | ||
85 | + return respBuilder.build(); | ||
86 | + } | ||
87 | + // buyer_order_goods ===> skup+商品成交价 1:1 | ||
88 | + List<BuyerOrderGoods> buyerOrderGoodsList = getOrderGoodsList(request.getUid(), orderCodeList); | ||
89 | + Map<Long, BuyerOrderGoods> buyerOrderGoodsMap = buyerOrderGoodsList.stream() | ||
90 | + .collect(Collectors.toMap(BuyerOrderGoods::getOrderCode, Function.identity(), (key1, key2) -> key2)); | ||
91 | + | ||
92 | + List<Integer> skups = buyerOrderGoodsList.stream().map(BuyerOrderGoods::getSkup).collect(Collectors.toList()); | ||
93 | + // seller_order_goods ===> 商品信息 | ||
94 | + List<SellerOrderGoods> sellerOrderGoodsList = getBaseOrderGoodsList(skups); | ||
95 | + Map<Integer, SellerOrderGoods> sellerOrderGoodsMap = sellerOrderGoodsList.stream().collect(Collectors.toMap(SellerOrderGoods::getId, Function.identity())); | ||
96 | + | ||
97 | + Map<Long,String> appraiseVideo = getAppraiseVideo(buyerOrderList); | ||
98 | + | ||
99 | + List<OrderListInfo> data = Lists.newArrayList(); | ||
100 | + | ||
101 | + buyerOrderList.stream().forEach(buyerOrder -> { | ||
102 | + OrderListInfo orderListInfo = convertOrderInfo(buyerOrderGoodsMap, sellerOrderGoodsMap, buyerOrder, actor, appraiseVideo); | ||
103 | + if (orderListInfo == null) return; | ||
104 | + data.add(orderListInfo); | ||
105 | + }); | ||
106 | + | ||
107 | + PageResp orderListInfoRsp = respBuilder.data(data).build(); | ||
108 | + | ||
109 | + return orderListInfoRsp; | ||
110 | + | ||
111 | + } | ||
112 | + | ||
113 | + | ||
114 | + /** | ||
115 | + * 获取返回结果 | ||
116 | + * @param buyerOrderGoodsMap | ||
117 | + * @param sellerOrderGoodsMap | ||
118 | + * @param buyerOrder | ||
119 | + * @return | ||
120 | + */ | ||
121 | + OrderListInfo convertOrderInfo(Map<Long, BuyerOrderGoods> buyerOrderGoodsMap, | ||
122 | + Map<Integer, SellerOrderGoods> sellerOrderGoodsMap, | ||
123 | + BuyerOrder buyerOrder, | ||
124 | + TabType tabType, | ||
125 | + Map<Long,String> appraiseVideo) { | ||
126 | + | ||
127 | + /** | ||
128 | + * 1.查询 buyer_order | ||
129 | + * 2.查询 buyer_order_goods ==> skup | ||
130 | + * 3.查询 seller_order_goods | ||
131 | + */ | ||
132 | + OrderListInfo orderListInfo = new OrderListInfo(); | ||
133 | + Integer buyerUid; | ||
134 | + Long orderCode; | ||
135 | + | ||
136 | + orderListInfo.setUid(buyerUid=buyerOrder.getUid()); | ||
137 | + orderListInfo.setBuyerUid(buyerUid); | ||
138 | + orderListInfo.setSellerUid(buyerOrder.getSellerUid()); | ||
139 | + orderListInfo.setOrderCode(orderCode=buyerOrder.getOrderCode()); | ||
140 | + orderListInfo.setRealPrice(buyerOrder.getAmount() == null ? "" : buyerOrder.getAmount().toPlainString()); | ||
141 | + | ||
142 | + boolean isOffline = BuyerOrderUtils.isOffline(buyerOrder.getAttributes()); | ||
143 | + orderListInfo.setIsOffline(isOffline ? "Y" : "N"); | ||
144 | + // 订单中状态显示 | ||
145 | + orderListInfo.setStatus(buyerOrder.getStatus() == null ? -1 : buyerOrder.getStatus()); | ||
146 | + OrderStatus orderStatus = OrderStatus.getOrderStatus(orderListInfo.getStatus()); | ||
147 | + | ||
148 | + if (orderStatus == null){ | ||
149 | + logger.warn("getOrderList orderStatus not exist, uid is {}, orderCode is {}, status is {}", | ||
150 | + buyerUid,orderCode, buyerOrder.getStatus()); | ||
151 | + return null; | ||
152 | + } | ||
153 | + | ||
154 | + orderListInfo.setStatuStr(orderStatus.getStatusStr(tabType)); | ||
155 | + | ||
156 | + // 当订单状态是待付款, 显示leftTime | ||
157 | + //Integer leftTime = getLeftTime(tabType, buyerUid, orderCode, buyerOrder.getStatus(), buyerOrder.getCreateTime()); | ||
158 | + TimeoutBo timeoutBo = calTimeout(tabType, buyerUid, orderCode, buyerOrder.getStatus(), buyerOrder.getCreateTime()); | ||
159 | + Integer leftTime = timeoutBo.getLeftTime(); | ||
160 | + orderListInfo.setLeftTime(leftTime); | ||
161 | + orderListInfo.setTimeLimit(timeoutBo.getTimelimit()); | ||
162 | + // 按钮显示 | ||
163 | + List<ButtonShowBo> buttonShowBos = orderStatus.getListButtons(tabType); | ||
164 | + | ||
165 | + orderListInfo.setButtons(formatButtons(buyerOrder, buttonShowBos == null ? new ArrayList<>() : new ArrayList<>(buttonShowBos), ViewType.LIST)); | ||
166 | + | ||
167 | + // 当剩余时间小于0 | ||
168 | + if (!CollectionUtils.isEmpty(orderListInfo.getButtons())){ | ||
169 | + if (orderListInfo.getLeftTime() != null && orderListInfo.getLeftTime() <= 0){ | ||
170 | + orderListInfo.getButtons().removeIf(x-> x!=null && ButtonShow.NOW_BUY.getCode().equals(x.getCode())); | ||
171 | + } | ||
172 | + } | ||
173 | + | ||
174 | + BuyerOrderGoods buyerOrderGoods = buyerOrderGoodsMap.get(buyerOrder.getOrderCode()); | ||
175 | + if (buyerOrderGoods == null){ | ||
176 | + logger.warn("getOrderList buyer goods not exist, uid is {}, orderCode is {}", | ||
177 | + buyerOrder.getUid(), orderListInfo.getOrderCode()); | ||
178 | + return null; | ||
179 | + } | ||
180 | + orderListInfo.setSkup(buyerOrderGoods.getSkup()); | ||
181 | + | ||
182 | + SellerOrderGoods sellerOrderGoods = sellerOrderGoodsMap.get(buyerOrderGoods.getSkup()); | ||
183 | + if (sellerOrderGoods == null){ | ||
184 | + logger.warn("getOrderList seller goods not exist, uid is {}, orderCode is {}", | ||
185 | + buyerOrder.getUid(), orderListInfo.getOrderCode()); | ||
186 | + return null; | ||
187 | + } | ||
188 | + | ||
189 | + GoodsInfo goodsInfo = new GoodsInfo(); | ||
190 | + goodsInfo.setColorName(sellerOrderGoods.getColorName()); | ||
191 | + goodsInfo.setProductName((isOffline ? "【门店订单】" : "") + sellerOrderGoods.getProductName()); | ||
192 | + goodsInfo.setGoodImg(ImageUrlAssist.getAllProductPicUrl(sellerOrderGoods.getImageUrl(), "goodsimg", "center", "d2hpdGU=")); | ||
193 | + goodsInfo.setSizeName(sellerOrderGoods.getSizeName()); | ||
194 | + goodsInfo.setGoodPrice(buyerOrderGoods.getGoodsPrice() == null ? "" :buyerOrderGoods.getGoodsPrice().toPlainString()); | ||
195 | + goodsInfo.setStorageId(sellerOrderGoods.getStorageId()); | ||
196 | + goodsInfo.setProductId(sellerOrderGoods.getProductId()); | ||
197 | + goodsInfo.setSkup(buyerOrderGoods.getSkup()); | ||
198 | + orderListInfo.setGoodsInfo(goodsInfo); | ||
199 | + orderListInfo.setSecendLevelCreateTime(buyerOrder.getCreateTime()); | ||
200 | + orderListInfo.setCreateTime(DateUtil.formatDate(buyerOrder.getCreateTime(), DateUtil.yyyy_MM_dd_HH_mm_SS)); | ||
201 | + setAddressInfo(orderListInfo); | ||
202 | + orderListInfo.setAppraiseVideoUrl(appraiseVideo.get(buyerOrder.getOrderCode())); | ||
203 | + return orderListInfo; | ||
204 | + } | ||
205 | + | ||
206 | + abstract void setAddressInfo(OrderListInfo orderListInfo); | ||
207 | + | ||
208 | + protected abstract void resetDynamicProporties(List<OrderListInfo> list,int type); | ||
209 | +} |
@@ -2,6 +2,7 @@ package com.yohoufo.order.service.impl; | @@ -2,6 +2,7 @@ package com.yohoufo.order.service.impl; | ||
2 | 2 | ||
3 | import com.yohobuy.ufo.model.order.bo.ButtonShowBo; | 3 | import com.yohobuy.ufo.model.order.bo.ButtonShowBo; |
4 | import com.yohobuy.ufo.model.order.bo.OrderInfo; | 4 | import com.yohobuy.ufo.model.order.bo.OrderInfo; |
5 | +import com.yohobuy.ufo.model.order.bo.TimeoutBo; | ||
5 | import com.yohobuy.ufo.model.order.common.*; | 6 | import com.yohobuy.ufo.model.order.common.*; |
6 | import com.yohoufo.common.utils.DateUtil; | 7 | import com.yohoufo.common.utils.DateUtil; |
7 | import com.yohoufo.dal.order.model.BuyerOrder; | 8 | import com.yohoufo.dal.order.model.BuyerOrder; |
@@ -10,6 +11,10 @@ import com.yohoufo.order.constants.ViewType; | @@ -10,6 +11,10 @@ import com.yohoufo.order.constants.ViewType; | ||
10 | import com.yohoufo.order.model.dto.BuyerPenaltyCalResult; | 11 | import com.yohoufo.order.model.dto.BuyerPenaltyCalResult; |
11 | import com.yohoufo.order.model.response.OrderDetailInfo; | 12 | import com.yohoufo.order.model.response.OrderDetailInfo; |
12 | import com.yohoufo.order.service.handler.BuyerCancelCompensateComputeHandler; | 13 | import com.yohoufo.order.service.handler.BuyerCancelCompensateComputeHandler; |
14 | +import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator; | ||
15 | +import com.yohoufo.order.service.support.codegenerator.bean.CodeMeta; | ||
16 | +import com.yohoufo.order.service.wrapper.BuyerOrderTimeoutWrapper; | ||
17 | +import com.yohoufo.order.service.wrapper.SellerOrderTimeoutWrapper; | ||
13 | import com.yohoufo.order.utils.BuyerOrderUtils; | 18 | import com.yohoufo.order.utils.BuyerOrderUtils; |
14 | import org.apache.commons.collections.CollectionUtils; | 19 | import org.apache.commons.collections.CollectionUtils; |
15 | import org.slf4j.Logger; | 20 | import org.slf4j.Logger; |
@@ -31,6 +36,8 @@ public abstract class AbsOrderViewService { | @@ -31,6 +36,8 @@ public abstract class AbsOrderViewService { | ||
31 | @Autowired | 36 | @Autowired |
32 | private BuyerCancelCompensateComputeHandler buyerCancelCompensateComputeHandler; | 37 | private BuyerCancelCompensateComputeHandler buyerCancelCompensateComputeHandler; |
33 | 38 | ||
39 | + @Autowired | ||
40 | + OrderCodeGenerator orderCodeGenerator; | ||
34 | 41 | ||
35 | abstract Logger getLogger(); | 42 | abstract Logger getLogger(); |
36 | 43 | ||
@@ -124,6 +131,81 @@ public abstract class AbsOrderViewService { | @@ -124,6 +131,81 @@ public abstract class AbsOrderViewService { | ||
124 | return detailDesc; | 131 | return detailDesc; |
125 | } | 132 | } |
126 | 133 | ||
134 | + private BuyerOrder buildBuyerOrder4Timeout(Integer uid, Long orderCode, Integer orderStatus, Integer createTime){ | ||
135 | + BuyerOrder qbo = new BuyerOrder(); | ||
136 | + qbo.setUid(uid); | ||
137 | + qbo.setOrderCode(orderCode); | ||
138 | + qbo.setStatus(orderStatus); | ||
139 | + qbo.setCreateTime(createTime); | ||
140 | + return qbo; | ||
141 | + } | ||
142 | + | ||
143 | + TimeoutBo calTimeout(TabType actor, Integer uid, Long orderCode, Integer orderStatus, Integer createTime){ | ||
144 | + | ||
145 | + boolean isBuyer = actor.equals(TabType.BUY); | ||
146 | + boolean isSeller = actor.equals(TabType.SELL); | ||
147 | + TimeoutBo timeoutBo = new TimeoutBo(); | ||
148 | + if (isBuyer){ | ||
149 | + boolean isPaid = OrderStatus.HAS_PAYED.getCode() == orderStatus; | ||
150 | + boolean isWaitingPay = OrderStatus.WAITING_PAY.getCode() == orderStatus; | ||
151 | + if (isPaid){ | ||
152 | + BuyerOrder qbo = buildBuyerOrder4Timeout(uid,orderCode,orderStatus,createTime); | ||
153 | + timeoutBo = new BuyerOrderTimeoutWrapper(qbo, ordersPayService::getDeliverLeftTime) | ||
154 | + .calDeliverLeftTime(); | ||
155 | + } | ||
156 | + | ||
157 | + if (isWaitingPay){ | ||
158 | + BuyerOrder qbo = buildBuyerOrder4Timeout(uid,orderCode,orderStatus,createTime); | ||
159 | + timeoutBo = new BuyerOrderTimeoutWrapper(qbo).calPayLeftTime(actor); | ||
160 | + } | ||
161 | + } | ||
162 | + | ||
163 | + if (isSeller){ | ||
164 | + CodeMeta codeMeta = orderCodeGenerator.expId(orderCode); | ||
165 | + if (codeMeta!=null) { | ||
166 | + OrderCodeType orderCodeType = OrderCodeType.getOrderCodeType(codeMeta.getType()); | ||
167 | + boolean isWaitingPay; | ||
168 | + boolean isPaid; | ||
169 | + //查看买家 | ||
170 | + if (orderCodeType == OrderCodeType.BUYER_TYPE) { | ||
171 | + isWaitingPay = orderStatus == OrderStatus.WAITING_PAY.getCode(); | ||
172 | + if (isWaitingPay) { | ||
173 | + timeoutBo = new SellerOrderTimeoutWrapper() | ||
174 | + .orderCodeType(orderCodeType) | ||
175 | + .orderStatus(orderStatus) | ||
176 | + .createTime(createTime) | ||
177 | + .calculatePayLeftTime(); | ||
178 | + } | ||
179 | + isPaid = orderStatus == OrderStatus.HAS_PAYED.getCode(); | ||
180 | + if (isPaid){ | ||
181 | + BuyerOrder qbo = buildBuyerOrder4Timeout(uid,orderCode,orderStatus,createTime); | ||
182 | + timeoutBo = new BuyerOrderTimeoutWrapper(qbo, ordersPayService::getDeliverLeftTime) | ||
183 | + .calDeliverLeftTime(); | ||
184 | + } | ||
185 | + } | ||
186 | + //查看卖家 | ||
187 | + if (orderCodeType == OrderCodeType.SELLER_TYPE) { | ||
188 | + isWaitingPay = orderStatus == SkupStatus.CAN_NOT_SELL.getCode(); | ||
189 | + if (isWaitingPay) { | ||
190 | + timeoutBo = new SellerOrderTimeoutWrapper() | ||
191 | + .orderCodeType(orderCodeType) | ||
192 | + .orderStatus(orderStatus) | ||
193 | + .createTime(createTime) | ||
194 | + .calculatePayLeftTime(); | ||
195 | + } | ||
196 | + } | ||
197 | + | ||
198 | + } | ||
199 | + } | ||
200 | + | ||
201 | + Integer leftTime = timeoutBo.getLeftTime(); | ||
202 | + if (leftTime != null && leftTime<0){ | ||
203 | + timeoutBo.setLeftTime(0); | ||
204 | + } | ||
205 | + return timeoutBo; | ||
206 | + } | ||
207 | + | ||
208 | + @Deprecated | ||
127 | Integer getLeftTime(TabType actor, Integer uid, Long orderCode, Integer orderStatus, Integer createTime){ | 209 | Integer getLeftTime(TabType actor, Integer uid, Long orderCode, Integer orderStatus, Integer createTime){ |
128 | Integer leftTime =null; | 210 | Integer leftTime =null; |
129 | Integer payLeftTime = getPayLeftTime(actor, orderStatus, | 211 | Integer payLeftTime = getPayLeftTime(actor, orderStatus, |
@@ -149,6 +231,15 @@ public abstract class AbsOrderViewService { | @@ -149,6 +231,15 @@ public abstract class AbsOrderViewService { | ||
149 | return leftTime; | 231 | return leftTime; |
150 | } | 232 | } |
151 | 233 | ||
234 | + /** | ||
235 | + * 请移步至 | ||
236 | + * @see {@link SellerOrderTimeoutWrapper#calculatePayLeftTime()} | ||
237 | + * @param orderCodeType | ||
238 | + * @param orderStatus | ||
239 | + * @param createTime | ||
240 | + * @return | ||
241 | + */ | ||
242 | + @Deprecated | ||
152 | Integer getPayLeftTime4Seller(OrderCodeType orderCodeType, Integer orderStatus, int createTime){ | 243 | Integer getPayLeftTime4Seller(OrderCodeType orderCodeType, Integer orderStatus, int createTime){ |
153 | if (orderCodeType == null){ | 244 | if (orderCodeType == null){ |
154 | return null; | 245 | return null; |
@@ -186,7 +277,8 @@ public abstract class AbsOrderViewService { | @@ -186,7 +277,8 @@ public abstract class AbsOrderViewService { | ||
186 | Integer getDeliverLeftTime(int buyerUid, long orderCode, Integer orderStatus){ | 277 | Integer getDeliverLeftTime(int buyerUid, long orderCode, Integer orderStatus){ |
187 | Integer leftTime = null; | 278 | Integer leftTime = null; |
188 | if (OrderStatus.HAS_PAYED.getCode() == orderStatus){ | 279 | if (OrderStatus.HAS_PAYED.getCode() == orderStatus){ |
189 | - leftTime = ordersPayService.getDeliverLeftTime(buyerUid, orderCode); | 280 | + TimeoutBo timeoutBo = ordersPayService.getDeliverLeftTime(buyerUid, orderCode); |
281 | + leftTime = timeoutBo.getLeftTime(); | ||
190 | } | 282 | } |
191 | return leftTime; | 283 | return leftTime; |
192 | } | 284 | } |
@@ -3,6 +3,7 @@ package com.yohoufo.order.service.impl; | @@ -3,6 +3,7 @@ package com.yohoufo.order.service.impl; | ||
3 | import com.google.common.collect.Maps; | 3 | import com.google.common.collect.Maps; |
4 | import com.yoho.error.ServiceError; | 4 | import com.yoho.error.ServiceError; |
5 | import com.yoho.error.exception.ServiceException; | 5 | import com.yoho.error.exception.ServiceException; |
6 | +import com.yohobuy.ufo.model.order.bo.TimeoutBo; | ||
6 | import com.yohobuy.ufo.model.order.common.ButtonShow; | 7 | import com.yohobuy.ufo.model.order.common.ButtonShow; |
7 | import com.yohobuy.ufo.model.order.common.OrderListType; | 8 | import com.yohobuy.ufo.model.order.common.OrderListType; |
8 | import com.yohobuy.ufo.model.order.common.TabType; | 9 | import com.yohobuy.ufo.model.order.common.TabType; |
@@ -128,9 +129,14 @@ public class BuyerOrderListServiceImpl extends AbsOrderListService implements IO | @@ -128,9 +129,14 @@ public class BuyerOrderListServiceImpl extends AbsOrderListService implements IO | ||
128 | if(CollectionUtils.isNotEmpty(list)){ | 129 | if(CollectionUtils.isNotEmpty(list)){ |
129 | processButtons(list); | 130 | processButtons(list); |
130 | list.forEach(oli -> { | 131 | list.forEach(oli -> { |
131 | - Integer leftTime = getLeftTime(TabType.BUY, oli.getUid(), oli.getOrderCode(), oli.getStatus(), | 132 | + //Integer leftTime = getLeftTime(TabType.BUY, oli.getUid(), oli.getOrderCode(), oli.getStatus(), |
133 | + // oli.getSecendLevelCreateTime()); | ||
134 | + | ||
135 | + TimeoutBo timeoutBo = calTimeout(TabType.BUY, oli.getUid(), oli.getOrderCode(), oli.getStatus(), | ||
132 | oli.getSecendLevelCreateTime()); | 136 | oli.getSecendLevelCreateTime()); |
133 | - oli.setLeftTime(leftTime); | 137 | + Integer leftTime = timeoutBo.getLeftTime(); |
138 | + oli.setLeftTime(leftTime); | ||
139 | + oli.setTimeLimit(timeoutBo.getTimelimit()); | ||
134 | 140 | ||
135 | if (oli.getLeftTime()!=null && oli.getLeftTime()<=0){ | 141 | if (oli.getLeftTime()!=null && oli.getLeftTime()<=0){ |
136 | oli.getButtons().removeIf(x-> x!=null && ButtonShow.NOW_BUY.getCode().equals(x.getCode())); | 142 | oli.getButtons().removeIf(x-> x!=null && ButtonShow.NOW_BUY.getCode().equals(x.getCode())); |
1 | package com.yohoufo.order.service.impl; | 1 | package com.yohoufo.order.service.impl; |
2 | 2 | ||
3 | +import com.yohobuy.ufo.model.order.bo.TimeoutBo; | ||
4 | +import com.yohobuy.ufo.model.order.constants.TimeoutCase; | ||
3 | import com.yohoufo.common.utils.DateUtil; | 5 | import com.yohoufo.common.utils.DateUtil; |
4 | import com.yohoufo.dal.order.OrdersPayMapper; | 6 | import com.yohoufo.dal.order.OrdersPayMapper; |
5 | import com.yohoufo.dal.order.model.OrdersPay; | 7 | import com.yohoufo.dal.order.model.OrdersPay; |
@@ -16,11 +18,20 @@ public class OrdersPayService { | @@ -16,11 +18,20 @@ public class OrdersPayService { | ||
16 | @Autowired | 18 | @Autowired |
17 | private OrdersPayMapper ordersPayMapper; | 19 | private OrdersPayMapper ordersPayMapper; |
18 | 20 | ||
19 | - public Integer getDeliverLeftTime(int buyerUid, long orderCode){ | 21 | + public TimeoutBo getDeliverLeftTime(int buyerUid, long orderCode){ |
20 | OrdersPay ordersPay = ordersPayMapper.selectOrdersPay(orderCode, buyerUid); | 22 | OrdersPay ordersPay = ordersPayMapper.selectOrdersPay(orderCode, buyerUid); |
21 | if (ordersPay == null){ | 23 | if (ordersPay == null){ |
22 | return null; | 24 | return null; |
23 | } | 25 | } |
24 | - return DelayTime.MINUTES_36_HOURS * 60 - (DateUtil.getCurrentTimeSecond()-ordersPay.getCreateTime()); | 26 | + int timelimit = DelayTime.MINUTES_36_HOURS * 60; |
27 | + Integer createTime = ordersPay.getCreateTime(); | ||
28 | + | ||
29 | + int left = timelimit - (DateUtil.getCurrentTimeSecond()-createTime); | ||
30 | + TimeoutBo timeoutBo = new TimeoutBo(); | ||
31 | + timeoutBo.setLeftTime(left); | ||
32 | + timeoutBo.setStartTime(createTime); | ||
33 | + timeoutBo.setTimelimit(timelimit); | ||
34 | + timeoutBo.setTimeoutCase(TimeoutCase.DELIVER); | ||
35 | + return timeoutBo; | ||
25 | } | 36 | } |
26 | } | 37 | } |
@@ -6,6 +6,7 @@ import com.yoho.error.exception.ServiceException; | @@ -6,6 +6,7 @@ import com.yoho.error.exception.ServiceException; | ||
6 | import com.yohobuy.ufo.model.order.bo.ButtonShowBo; | 6 | import com.yohobuy.ufo.model.order.bo.ButtonShowBo; |
7 | import com.yohobuy.ufo.model.order.bo.OrderInfo; | 7 | import com.yohobuy.ufo.model.order.bo.OrderInfo; |
8 | import com.yohobuy.ufo.model.order.bo.SoldPrdComputeBo; | 8 | import com.yohobuy.ufo.model.order.bo.SoldPrdComputeBo; |
9 | +import com.yohobuy.ufo.model.order.bo.TimeoutBo; | ||
9 | import com.yohobuy.ufo.model.order.common.*; | 10 | import com.yohobuy.ufo.model.order.common.*; |
10 | import com.yohobuy.ufo.model.order.constants.OrderConstant; | 11 | import com.yohobuy.ufo.model.order.constants.OrderConstant; |
11 | import com.yohobuy.ufo.model.order.resp.ExpressInfoDetail; | 12 | import com.yohobuy.ufo.model.order.resp.ExpressInfoDetail; |
@@ -31,6 +32,7 @@ import com.yohoufo.order.service.proxy.ProductProxyService; | @@ -31,6 +32,7 @@ import com.yohoufo.order.service.proxy.ProductProxyService; | ||
31 | import com.yohoufo.order.service.proxy.UserProxyService; | 32 | import com.yohoufo.order.service.proxy.UserProxyService; |
32 | import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator; | 33 | import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator; |
33 | import com.yohoufo.order.service.support.codegenerator.bean.CodeMeta; | 34 | import com.yohoufo.order.service.support.codegenerator.bean.CodeMeta; |
35 | +import com.yohoufo.order.service.wrapper.SellerOrderTimeoutWrapper; | ||
34 | import com.yohoufo.order.utils.LoggerUtils; | 36 | import com.yohoufo.order.utils.LoggerUtils; |
35 | import org.apache.commons.lang3.StringUtils; | 37 | import org.apache.commons.lang3.StringUtils; |
36 | import org.slf4j.Logger; | 38 | import org.slf4j.Logger; |
@@ -272,8 +274,13 @@ public class SellerOrderDetailService extends AbsOrderDetailService implements I | @@ -272,8 +274,13 @@ public class SellerOrderDetailService extends AbsOrderDetailService implements I | ||
272 | .build(); | 274 | .build(); |
273 | 275 | ||
274 | // 待付款时 或待发货,剩余时间 | 276 | // 待付款时 或待发货,剩余时间 |
275 | - Integer leftTime = getPayLeftTime4Seller(OrderCodeType.SELLER_TYPE, | ||
276 | - skupStatus.getCode(), order.getCreateTime()); | 277 | + //Integer leftTime = getPayLeftTime4Seller(OrderCodeType.SELLER_TYPE, skupStatus.getCode(), order.getCreateTime()); |
278 | + TimeoutBo timeoutBo = new SellerOrderTimeoutWrapper() | ||
279 | + .createTime(order.getCreateTime()) | ||
280 | + .orderCodeType(OrderCodeType.SELLER_TYPE) | ||
281 | + .orderStatus(skupStatus.getCode()) | ||
282 | + .calculatePayLeftTime(); | ||
283 | + Integer leftTime = timeoutBo.getLeftTime(); | ||
277 | statusDetail.setLeftTime(leftTime); | 284 | statusDetail.setLeftTime(leftTime); |
278 | 285 | ||
279 | return statusDetail; | 286 | return statusDetail; |
@@ -366,7 +373,13 @@ public class SellerOrderDetailService extends AbsOrderDetailService implements I | @@ -366,7 +373,13 @@ public class SellerOrderDetailService extends AbsOrderDetailService implements I | ||
366 | return ActionStatusHold.getSellerOrderIsPaidStatusList().contains(skupStatus.getCode()) ? 1 : 0; | 373 | return ActionStatusHold.getSellerOrderIsPaidStatusList().contains(skupStatus.getCode()) ? 1 : 0; |
367 | } | 374 | } |
368 | 375 | ||
369 | - | 376 | + /** |
377 | + * 当卖家查看买家订单时才会调用 | ||
378 | + * @param buyerOrder | ||
379 | + * @param orderStatus | ||
380 | + * @param tabType | ||
381 | + * @return | ||
382 | + */ | ||
370 | @Override | 383 | @Override |
371 | protected OrderDetailInfo.StatusDetail getStatusDetail(BuyerOrder buyerOrder,OrderStatus orderStatus, TabType tabType) { | 384 | protected OrderDetailInfo.StatusDetail getStatusDetail(BuyerOrder buyerOrder,OrderStatus orderStatus, TabType tabType) { |
372 | OrderDetailInfo.StatusDetail statusDetail = OrderDetailInfo.StatusDetail.builder() | 385 | OrderDetailInfo.StatusDetail statusDetail = OrderDetailInfo.StatusDetail.builder() |
@@ -401,7 +414,12 @@ public class SellerOrderDetailService extends AbsOrderDetailService implements I | @@ -401,7 +414,12 @@ public class SellerOrderDetailService extends AbsOrderDetailService implements I | ||
401 | Integer orderStatus = orderDetailInfo.getStatusDetail().getStatus(); | 414 | Integer orderStatus = orderDetailInfo.getStatusDetail().getStatus(); |
402 | if (codeMeta!=null) { | 415 | if (codeMeta!=null) { |
403 | OrderCodeType orderCodeType = OrderCodeType.getOrderCodeType(codeMeta.getType()); | 416 | OrderCodeType orderCodeType = OrderCodeType.getOrderCodeType(codeMeta.getType()); |
404 | - Integer leftTime = getPayLeftTime4Seller(orderCodeType, orderStatus, orderDetailInfo.getSecendLevelCreateTime()); | 417 | + //Integer leftTime = getPayLeftTime4Seller(orderCodeType, orderStatus, orderDetailInfo.getSecendLevelCreateTime()); |
418 | + TimeoutBo timeoutBo = new SellerOrderTimeoutWrapper().createTime(orderDetailInfo.getSecendLevelCreateTime()) | ||
419 | + .orderCodeType(orderCodeType) | ||
420 | + .orderStatus(orderStatus) | ||
421 | + .calculatePayLeftTime(); | ||
422 | + Integer leftTime = timeoutBo.getLeftTime(); | ||
405 | orderDetailInfo.getStatusDetail().setLeftTime(leftTime); | 423 | orderDetailInfo.getStatusDetail().setLeftTime(leftTime); |
406 | 424 | ||
407 | if (leftTime!=null && leftTime<=0){ | 425 | if (leftTime!=null && leftTime<=0){ |
@@ -6,6 +6,7 @@ import com.yoho.error.exception.ServiceException; | @@ -6,6 +6,7 @@ import com.yoho.error.exception.ServiceException; | ||
6 | import com.yohobuy.ufo.model.order.bo.ButtonShowBo; | 6 | import com.yohobuy.ufo.model.order.bo.ButtonShowBo; |
7 | import com.yohobuy.ufo.model.order.bo.GoodsInfo; | 7 | import com.yohobuy.ufo.model.order.bo.GoodsInfo; |
8 | import com.yohobuy.ufo.model.order.bo.OrderInfo; | 8 | import com.yohobuy.ufo.model.order.bo.OrderInfo; |
9 | +import com.yohobuy.ufo.model.order.bo.TimeoutBo; | ||
9 | import com.yohobuy.ufo.model.order.common.*; | 10 | import com.yohobuy.ufo.model.order.common.*; |
10 | import com.yohobuy.ufo.model.order.resp.OrderListInfo; | 11 | import com.yohobuy.ufo.model.order.resp.OrderListInfo; |
11 | import com.yohobuy.ufo.model.order.resp.PageResp; | 12 | import com.yohobuy.ufo.model.order.resp.PageResp; |
@@ -30,6 +31,7 @@ import com.yohoufo.order.service.proxy.ProductProxyService; | @@ -30,6 +31,7 @@ import com.yohoufo.order.service.proxy.ProductProxyService; | ||
30 | import com.yohoufo.order.service.proxy.UserProxyService; | 31 | import com.yohoufo.order.service.proxy.UserProxyService; |
31 | import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator; | 32 | import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator; |
32 | import com.yohoufo.order.service.support.codegenerator.bean.CodeMeta; | 33 | import com.yohoufo.order.service.support.codegenerator.bean.CodeMeta; |
34 | +import com.yohoufo.order.service.wrapper.SellerOrderTimeoutWrapper; | ||
33 | import com.yohoufo.order.utils.LoggerUtils; | 35 | import com.yohoufo.order.utils.LoggerUtils; |
34 | import com.yohoufo.order.utils.OrderAssist; | 36 | import com.yohoufo.order.utils.OrderAssist; |
35 | import org.apache.commons.collections.CollectionUtils; | 37 | import org.apache.commons.collections.CollectionUtils; |
@@ -70,8 +72,7 @@ public class SellerOrderListService extends AbsOrderListService implements IOrde | @@ -70,8 +72,7 @@ public class SellerOrderListService extends AbsOrderListService implements IOrde | ||
70 | @Autowired | 72 | @Autowired |
71 | private ProductProxyService productProxyService; | 73 | private ProductProxyService productProxyService; |
72 | 74 | ||
73 | - @Autowired | ||
74 | - private OrderCodeGenerator orderCodeGenerator; | 75 | + |
75 | 76 | ||
76 | @Autowired | 77 | @Autowired |
77 | private SkupListService skupListService; | 78 | private SkupListService skupListService; |
@@ -182,7 +183,13 @@ public class SellerOrderListService extends AbsOrderListService implements IOrde | @@ -182,7 +183,13 @@ public class SellerOrderListService extends AbsOrderListService implements IOrde | ||
182 | Integer orderStatus = oli.getStatus(); | 183 | Integer orderStatus = oli.getStatus(); |
183 | if (codeMeta!=null){ | 184 | if (codeMeta!=null){ |
184 | OrderCodeType orderCodeType = OrderCodeType.getOrderCodeType(codeMeta.getType()); | 185 | OrderCodeType orderCodeType = OrderCodeType.getOrderCodeType(codeMeta.getType()); |
185 | - oli.setLeftTime(getPayLeftTime4Seller(orderCodeType, orderStatus, oli.getSecendLevelCreateTime())); | 186 | + TimeoutBo timeoutBo = new SellerOrderTimeoutWrapper().createTime(oli.getSecendLevelCreateTime()) |
187 | + .orderCodeType(orderCodeType) | ||
188 | + .orderStatus(orderStatus) | ||
189 | + .calculatePayLeftTime(); | ||
190 | + oli.setLeftTime(timeoutBo.getLeftTime()); | ||
191 | + oli.setTimeLimit(timeoutBo.getTimelimit()); | ||
192 | + //oli.setLeftTime(getPayLeftTime4Seller(orderCodeType, orderStatus, oli.getSecendLevelCreateTime())); | ||
186 | } | 193 | } |
187 | 194 | ||
188 | 195 | ||
@@ -278,7 +285,6 @@ public class SellerOrderListService extends AbsOrderListService implements IOrde | @@ -278,7 +285,6 @@ public class SellerOrderListService extends AbsOrderListService implements IOrde | ||
278 | if (SHOW_OVER_FLOW_PRICE_STATUS.contains(skupStatus.getCode())){ | 285 | if (SHOW_OVER_FLOW_PRICE_STATUS.contains(skupStatus.getCode())){ |
279 | orderListInfo.setTips(overPriceTipsMap.get(OrderAssist.overFlowPriceKey(sellerOrderGoods.getStorageId(), sellerOrderGoods.getGoodsPrice()))); | 286 | orderListInfo.setTips(overPriceTipsMap.get(OrderAssist.overFlowPriceKey(sellerOrderGoods.getStorageId(), sellerOrderGoods.getGoodsPrice()))); |
280 | } | 287 | } |
281 | - orderListInfo.setPayTimeLimit(OrderInfo.SELLER_PAY_TIMEOUT); | ||
282 | return orderListInfo; | 288 | return orderListInfo; |
283 | } | 289 | } |
284 | 290 |
@@ -421,7 +421,6 @@ public class SkupListService { | @@ -421,7 +421,6 @@ public class SkupListService { | ||
421 | productInfo.setStorageNumDesc(psogOfMerge.getStorageNum() + "个商品库存"); | 421 | productInfo.setStorageNumDesc(psogOfMerge.getStorageNum() + "个商品库存"); |
422 | } | 422 | } |
423 | orderListInfo.setGoodsInfo(productInfo); | 423 | orderListInfo.setGoodsInfo(productInfo); |
424 | - orderListInfo.setPayTimeLimit(OrderInfo.SELLER_PAY_TIMEOUT); | ||
425 | return orderListInfo; | 424 | return orderListInfo; |
426 | } | 425 | } |
427 | 426 |
1 | +package com.yohoufo.order.service.wrapper; | ||
2 | + | ||
3 | +import com.yohobuy.ufo.model.order.bo.TimeoutBo; | ||
4 | +import com.yohoufo.common.utils.DateUtil; | ||
5 | +import org.slf4j.Logger; | ||
6 | + | ||
7 | +import java.util.function.BiFunction; | ||
8 | + | ||
9 | +/** | ||
10 | + * Created by chao.chen on 2019/1/23. | ||
11 | + */ | ||
12 | +public abstract class AbsTimeoutWrapper { | ||
13 | + Logger logger; | ||
14 | + BiFunction<Integer,Long,TimeoutBo> deliverLeftTimeDS ; | ||
15 | + | ||
16 | + protected int calLeftTime(int timeout, int creatTime){ | ||
17 | + int payExpire = timeout - (DateUtil.getCurrentTimeSecond() - creatTime); | ||
18 | + if (payExpire < 0){ | ||
19 | + payExpire = 0; | ||
20 | + } | ||
21 | + return payExpire; | ||
22 | + } | ||
23 | + | ||
24 | +} |
1 | +package com.yohoufo.order.service.wrapper; | ||
2 | + | ||
3 | +import com.yohobuy.ufo.model.order.bo.OrderInfo; | ||
4 | +import com.yohobuy.ufo.model.order.bo.TimeoutBo; | ||
5 | +import com.yohobuy.ufo.model.order.common.OrderStatus; | ||
6 | +import com.yohobuy.ufo.model.order.common.SkupStatus; | ||
7 | +import com.yohobuy.ufo.model.order.common.TabType; | ||
8 | +import com.yohobuy.ufo.model.order.constants.TimeoutCase; | ||
9 | +import com.yohoufo.dal.order.model.BuyerOrder; | ||
10 | +import org.slf4j.Logger; | ||
11 | + | ||
12 | +import java.util.function.BiFunction; | ||
13 | + | ||
14 | +/** | ||
15 | + * Created by chao.chen on 2019/1/23. | ||
16 | + */ | ||
17 | +public class BuyerOrderTimeoutWrapper extends AbsTimeoutWrapper{ | ||
18 | + | ||
19 | + private BuyerOrder buyerOrder; | ||
20 | + private BuyerOrderTimeoutWrapper(){ | ||
21 | + throw new RuntimeException("what r u doing?"); | ||
22 | + } | ||
23 | + | ||
24 | + public BuyerOrderTimeoutWrapper(BuyerOrder buyerOrder, BiFunction<Integer,Long,TimeoutBo> deliverLeftTimeDS){ | ||
25 | + this.buyerOrder = buyerOrder; | ||
26 | + this.deliverLeftTimeDS = deliverLeftTimeDS; | ||
27 | + } | ||
28 | + | ||
29 | + public BuyerOrderTimeoutWrapper(BuyerOrder buyerOrder){ | ||
30 | + this.buyerOrder = buyerOrder; | ||
31 | + } | ||
32 | + | ||
33 | + public BuyerOrderTimeoutWrapper logger(Logger logger){ | ||
34 | + this.logger = logger; | ||
35 | + return this; | ||
36 | + } | ||
37 | + | ||
38 | + public TimeoutBo calDeliverLeftTime(){ | ||
39 | + int buyerUid = buyerOrder.getUid(); | ||
40 | + long orderCode = buyerOrder.getOrderCode(); | ||
41 | + Integer orderStatus = buyerOrder.getStatus(); | ||
42 | + TimeoutBo timeoutBo = new TimeoutBo(); | ||
43 | + if (OrderStatus.HAS_PAYED.getCode() == orderStatus){ | ||
44 | + timeoutBo = deliverLeftTimeDS.apply(buyerUid, orderCode); | ||
45 | + } | ||
46 | + return timeoutBo; | ||
47 | + } | ||
48 | + | ||
49 | + public TimeoutBo calPayLeftTime(TabType actor){ | ||
50 | + Integer orderStatus = buyerOrder.getStatus(); | ||
51 | + int createTime = buyerOrder.getCreateTime(); | ||
52 | + boolean isBuyer = actor.equals(TabType.BUY); | ||
53 | + boolean isSeller = actor.equals(TabType.SELL); | ||
54 | + Integer leftTime = null; | ||
55 | + int timeout = OrderInfo.PAY_TIME_SECOND; | ||
56 | + boolean isFiredCal = (isBuyer && orderStatus == OrderStatus.WAITING_PAY.getCode()) | ||
57 | + || (isSeller && orderStatus == SkupStatus.CAN_NOT_SELL.getCode()); | ||
58 | + if(isFiredCal){ | ||
59 | + leftTime = calLeftTime(timeout, createTime); | ||
60 | + } | ||
61 | + TimeoutBo timeoutBo = new TimeoutBo(); | ||
62 | + timeoutBo.setLeftTime(leftTime); | ||
63 | + timeoutBo.setTimelimit(timeout); | ||
64 | + timeoutBo.setStartTime(createTime); | ||
65 | + timeoutBo.setTimeoutCase(TimeoutCase.PAY); | ||
66 | + return timeoutBo; | ||
67 | + } | ||
68 | +} |
1 | +package com.yohoufo.order.service.wrapper; | ||
2 | + | ||
3 | +import com.yohobuy.ufo.model.order.bo.OrderInfo; | ||
4 | +import com.yohobuy.ufo.model.order.bo.TimeoutBo; | ||
5 | +import com.yohobuy.ufo.model.order.common.OrderCodeType; | ||
6 | +import com.yohobuy.ufo.model.order.common.OrderStatus; | ||
7 | +import com.yohobuy.ufo.model.order.common.SkupStatus; | ||
8 | +import com.yohobuy.ufo.model.order.constants.TimeoutCase; | ||
9 | + | ||
10 | +/** | ||
11 | + * Created by chao.chen on 2019/1/23. | ||
12 | + * | ||
13 | + * @author chao.chen | ||
14 | + * @since yohobuy version 6.8.5 | ||
15 | + */ | ||
16 | +public class SellerOrderTimeoutWrapper extends AbsTimeoutWrapper{ | ||
17 | + | ||
18 | + | ||
19 | + private OrderCodeType orderCodeType; | ||
20 | + private Integer orderStatus; | ||
21 | + private int createTime; | ||
22 | + | ||
23 | + public SellerOrderTimeoutWrapper orderCodeType(OrderCodeType orderCodeType){ | ||
24 | + this.orderCodeType = orderCodeType; | ||
25 | + return this; | ||
26 | + } | ||
27 | + | ||
28 | + public SellerOrderTimeoutWrapper orderStatus(Integer orderStatus){ | ||
29 | + this.orderStatus = orderStatus; | ||
30 | + return this; | ||
31 | + } | ||
32 | + | ||
33 | + public SellerOrderTimeoutWrapper createTime(int createTime){ | ||
34 | + this.createTime = createTime; | ||
35 | + return this; | ||
36 | + } | ||
37 | + | ||
38 | + /** | ||
39 | + * | ||
40 | + * @return | ||
41 | + */ | ||
42 | + public TimeoutBo calculatePayLeftTime(){ | ||
43 | + if (orderCodeType == null){ | ||
44 | + return null; | ||
45 | + } | ||
46 | + Integer leftTime = null; | ||
47 | + Integer timeout = OrderInfo.PAY_TIME_SECOND; | ||
48 | + boolean isWaitingPay = false; | ||
49 | + //查看买家 | ||
50 | + if (orderCodeType == OrderCodeType.BUYER_TYPE){ | ||
51 | + isWaitingPay = orderStatus == OrderStatus.WAITING_PAY.getCode(); | ||
52 | + if (isWaitingPay){ | ||
53 | + timeout = OrderInfo.PAY_TIME_SECOND; | ||
54 | + } | ||
55 | + } | ||
56 | + //查看卖家 | ||
57 | + if (orderCodeType == OrderCodeType.SELLER_TYPE){ | ||
58 | + isWaitingPay = orderStatus == SkupStatus.CAN_NOT_SELL.getCode(); | ||
59 | + if (isWaitingPay)timeout = OrderInfo.SELLER_PAY_TIMEOUT; | ||
60 | + } | ||
61 | + | ||
62 | + if(isWaitingPay){ | ||
63 | + leftTime = calLeftTime(timeout, createTime); | ||
64 | + } | ||
65 | + | ||
66 | + TimeoutBo timeoutBo = new TimeoutBo(); | ||
67 | + timeoutBo.setLeftTime(leftTime); | ||
68 | + timeoutBo.setTimelimit(timeout); | ||
69 | + timeoutBo.setStartTime(createTime); | ||
70 | + timeoutBo.setTimeoutCase(TimeoutCase.PAY); | ||
71 | + return timeoutBo; | ||
72 | + } | ||
73 | + | ||
74 | +} |
-
Please register or login to post a comment