Showing
6 changed files
with
125 additions
and
19 deletions
@@ -62,4 +62,8 @@ public interface SellerOrderGoodsMapper { | @@ -62,4 +62,8 @@ public interface SellerOrderGoodsMapper { | ||
62 | List<SellerOrderGoods> selectGPByBNStatusPrice(SellerOrderGoods condition); | 62 | List<SellerOrderGoods> selectGPByBNStatusPrice(SellerOrderGoods condition); |
63 | 63 | ||
64 | int batchDelete(@Param("skups") Collection<Integer> skups); | 64 | int batchDelete(@Param("skups") Collection<Integer> skups); |
65 | + | ||
66 | + List<SellerOrderGoods> selectByUidBNStatusGBBPSList(@Param("uid")int uid, | ||
67 | + @Param("batchNo")Long batchNo, | ||
68 | + @Param("statusList") List<Integer> statusList); | ||
65 | } | 69 | } |
@@ -367,4 +367,10 @@ | @@ -367,4 +367,10 @@ | ||
367 | </foreach> | 367 | </foreach> |
368 | </update> | 368 | </update> |
369 | 369 | ||
370 | + <select id="selectByUidBNStatusGBBPSList" resultMap="BaseResultMap"> | ||
371 | + select <include refid="Base_Column_List" />,count(*) num,GROUP_CONCAT(id) skup_list from seller_order_goods | ||
372 | + where batch_no = #{batchNo,jdbcType=BIGINT} | ||
373 | + and <include refid="sql_where_4_select_UidStatusGBBNList"/> | ||
374 | + order by id desc | ||
375 | + </select> | ||
370 | </mapper> | 376 | </mapper> |
1 | package com.yohoufo.order.controller; | 1 | package com.yohoufo.order.controller; |
2 | 2 | ||
3 | import com.yohobuy.ufo.model.order.bo.SoldPrdComputeBo; | 3 | import com.yohobuy.ufo.model.order.bo.SoldPrdComputeBo; |
4 | +import com.yohobuy.ufo.model.order.common.TabType; | ||
4 | import com.yohobuy.ufo.model.order.req.*; | 5 | import com.yohobuy.ufo.model.order.req.*; |
5 | import com.yohobuy.ufo.model.order.resp.BatchChangePriceResp; | 6 | import com.yohobuy.ufo.model.order.resp.BatchChangePriceResp; |
7 | +import com.yohobuy.ufo.model.order.resp.OrderListInfo; | ||
8 | +import com.yohobuy.ufo.model.order.resp.PageResp; | ||
6 | import com.yohoufo.common.ApiResponse; | 9 | import com.yohoufo.common.ApiResponse; |
7 | import com.yohoufo.common.annotation.IgnoreSession; | 10 | import com.yohoufo.common.annotation.IgnoreSession; |
8 | import com.yohoufo.common.annotation.IgnoreSignature; | 11 | import com.yohoufo.common.annotation.IgnoreSignature; |
9 | import com.yohoufo.common.exception.GatewayException; | 12 | import com.yohoufo.common.exception.GatewayException; |
10 | import com.yohoufo.dal.order.model.SellerOrder; | 13 | import com.yohoufo.dal.order.model.SellerOrder; |
14 | +import com.yohoufo.order.model.request.OrderListRequest; | ||
15 | +import com.yohoufo.order.model.request.OrderRequest; | ||
11 | import com.yohoufo.order.model.response.OrderSubmitResp; | 16 | import com.yohoufo.order.model.response.OrderSubmitResp; |
12 | import com.yohoufo.order.service.handler.SellerOrderComputeHandler; | 17 | import com.yohoufo.order.service.handler.SellerOrderComputeHandler; |
13 | import com.yohoufo.order.service.impl.SellerOrderService; | 18 | import com.yohoufo.order.service.impl.SellerOrderService; |
19 | +import org.apache.kafka.common.requests.LeaderAndIsrRequest; | ||
14 | import org.slf4j.Logger; | 20 | import org.slf4j.Logger; |
15 | import org.slf4j.LoggerFactory; | 21 | import org.slf4j.LoggerFactory; |
16 | import org.springframework.beans.factory.annotation.Autowired; | 22 | import org.springframework.beans.factory.annotation.Autowired; |
@@ -20,6 +26,9 @@ import org.springframework.web.bind.annotation.RequestMapping; | @@ -20,6 +26,9 @@ import org.springframework.web.bind.annotation.RequestMapping; | ||
20 | import org.springframework.web.bind.annotation.RequestParam; | 26 | import org.springframework.web.bind.annotation.RequestParam; |
21 | import org.springframework.web.bind.annotation.ResponseBody; | 27 | import org.springframework.web.bind.annotation.ResponseBody; |
22 | 28 | ||
29 | +import java.util.List; | ||
30 | +import java.util.Objects; | ||
31 | + | ||
23 | /** | 32 | /** |
24 | * Created by chenchao on 2018/9/13. | 33 | * Created by chenchao on 2018/9/13. |
25 | */ | 34 | */ |
@@ -233,4 +242,41 @@ public class SellerOrderController { | @@ -233,4 +242,41 @@ public class SellerOrderController { | ||
233 | return new ApiResponse.ApiResponseBuilder().code(200).data(computeBo).message("算费成功").build(); | 242 | return new ApiResponse.ApiResponseBuilder().code(200).data(computeBo).message("算费成功").build(); |
234 | } | 243 | } |
235 | 244 | ||
245 | + | ||
246 | + @RequestMapping(params = "method=ufo.order.refresh") | ||
247 | + @ResponseBody | ||
248 | + public ApiResponse refresh(@RequestParam("type") int type, | ||
249 | + @RequestParam("uid") int uid, | ||
250 | + @RequestParam("tabType") String tabType, | ||
251 | + @RequestParam(value = "orderCode") long orderCode) { | ||
252 | + | ||
253 | + | ||
254 | + TabType actor = TabType.getTabType(tabType); | ||
255 | + | ||
256 | + if (Objects.isNull(actor)){ | ||
257 | + return new ApiResponse.ApiResponseBuilder().code(400).message("非法的tab").build(); | ||
258 | + } | ||
259 | + OrderRequest orderRequest = OrderRequest.builder() | ||
260 | + .uid(uid) | ||
261 | + .type(type) | ||
262 | + .tabType(tabType) | ||
263 | + .actor(actor) | ||
264 | + .orderCode(orderCode) | ||
265 | + .build(); | ||
266 | + logger.info("in ufo.order.refresh, req {}", orderRequest); | ||
267 | + List<OrderListInfo> orderListInfoRsp = null; | ||
268 | + switch (actor){ | ||
269 | + case BUY: | ||
270 | + | ||
271 | + break; | ||
272 | + case SELL: | ||
273 | + orderListInfoRsp = sellerOrderService.refresh(orderRequest); | ||
274 | + break; | ||
275 | + default: | ||
276 | + orderListInfoRsp = null; | ||
277 | + } | ||
278 | + | ||
279 | + return new ApiResponse.ApiResponseBuilder().code(200).data(orderListInfoRsp).message("刷新成功").build(); | ||
280 | + } | ||
281 | + | ||
236 | } | 282 | } |
@@ -74,6 +74,24 @@ public class SellerOrderListService extends AbsOrderListService implements IOrde | @@ -74,6 +74,24 @@ public class SellerOrderListService extends AbsOrderListService implements IOrde | ||
74 | @Autowired | 74 | @Autowired |
75 | private SellerOrderPrepareProcessor sellerOrderPrepareProcessor; | 75 | private SellerOrderPrepareProcessor sellerOrderPrepareProcessor; |
76 | 76 | ||
77 | + public List<OrderListInfo> buildOrderList(List<SellerOrderGoods> sogList, SellerType sellerType){ | ||
78 | + sogList.stream().forEach(item -> { | ||
79 | + item.setImageUrl(ImageUrlAssist.getAllProductPicUrl(item.getImageUrl(), "goodsimg", "center", "d2hpdGU=")); | ||
80 | + }); | ||
81 | + Map<String, String> overPriceTipsMap = buildOverPriceTipsMap(sogList); | ||
82 | + Map<Integer, SellerOrderGoods> skupSellerOrderGoodsMap = sogList.parallelStream() | ||
83 | + .collect(Collectors.toMap(SellerOrderGoods::getId, (SellerOrderGoods sog) -> sog)); | ||
84 | + List<Integer> skupList = sogList.parallelStream().map(SellerOrderGoods::getId).collect(Collectors.toList()); | ||
85 | + List<SellerOrder> sellerOrders = sellerOrderMapper.selectBySkups(skupList); | ||
86 | + List<OrderListInfo> data ; | ||
87 | + data = sellerOrders.parallelStream() | ||
88 | + .map(sellerOrder -> buildOrderListInfo(skupSellerOrderGoodsMap.get(sellerOrder.getSkup()), | ||
89 | + sellerOrder, sellerType, overPriceTipsMap)) | ||
90 | + .filter(oli -> Objects.nonNull(oli)) | ||
91 | + .collect(Collectors.toList()); | ||
92 | + return data; | ||
93 | + } | ||
94 | + | ||
77 | @Override | 95 | @Override |
78 | public PageResp<OrderListInfo> getOrderList(OrderListRequest request){ | 96 | public PageResp<OrderListInfo> getOrderList(OrderListRequest request){ |
79 | OrderListVo orderListVo = orderCacheService.getOrderListInfos(request); | 97 | OrderListVo orderListVo = orderCacheService.getOrderListInfos(request); |
@@ -92,8 +110,7 @@ public class SellerOrderListService extends AbsOrderListService implements IOrde | @@ -92,8 +110,7 @@ public class SellerOrderListService extends AbsOrderListService implements IOrde | ||
92 | int type; | 110 | int type; |
93 | if ((type=request.getType()) == SellerOrderListType.IN_SALE.getType()){ | 111 | if ((type=request.getType()) == SellerOrderListType.IN_SALE.getType()){ |
94 | List<Integer> statusList = initOrderListRequest(request); | 112 | List<Integer> statusList = initOrderListRequest(request); |
95 | - boolean isEntry = userProxyService.isEntryShop(request.getUid()); | ||
96 | - final SellerType sellerType = isEntry ? SellerType.ENTRY : SellerType.COMMON; | 113 | + |
97 | int total = sellerOrderGoodsMapper.selectCntByUidStatusGBBNList(request.getUid(), statusList); | 114 | int total = sellerOrderGoodsMapper.selectCntByUidStatusGBBNList(request.getUid(), statusList); |
98 | int limit = request.getLimit(); | 115 | int limit = request.getLimit(); |
99 | respBuilder = PageResp.builder() | 116 | respBuilder = PageResp.builder() |
@@ -112,23 +129,10 @@ public class SellerOrderListService extends AbsOrderListService implements IOrde | @@ -112,23 +129,10 @@ public class SellerOrderListService extends AbsOrderListService implements IOrde | ||
112 | log.warn("seller get order list SellerOrderGoods is empty,req {}", request); | 129 | log.warn("seller get order list SellerOrderGoods is empty,req {}", request); |
113 | return respBuilder.build(); | 130 | return respBuilder.build(); |
114 | } | 131 | } |
115 | - sogList.stream().forEach(item -> { | ||
116 | - item.setImageUrl(ImageUrlAssist.getAllProductPicUrl(item.getImageUrl(), "goodsimg", "center", "d2hpdGU=")); | ||
117 | - }); | ||
118 | - Map<String, String> overPriceTipsMap = buildOverPriceTipsMap(sogList); | ||
119 | - Map<Integer, SellerOrderGoods> skupSellerOrderGoodsMap = sogList.parallelStream() | ||
120 | - .collect(Collectors.toMap(SellerOrderGoods::getId, (SellerOrderGoods sog) -> sog)); | ||
121 | - List<Integer> skupList = sogList.parallelStream().map(SellerOrderGoods::getId).collect(Collectors.toList()); | ||
122 | - List<SellerOrder> sellerOrders = sellerOrderMapper.selectBySkups(skupList); | ||
123 | - List<OrderListInfo> data ; | ||
124 | - data = sellerOrders.parallelStream() | ||
125 | - .map(sellerOrder -> buildOrderListInfo(skupSellerOrderGoodsMap.get(sellerOrder.getSkup()), | ||
126 | - sellerOrder, sellerType, overPriceTipsMap)) | ||
127 | - .filter(oli -> Objects.nonNull(oli)) | ||
128 | - .collect(Collectors.toList()); | ||
129 | - | 132 | + boolean isEntry = userProxyService.isEntryShop(request.getUid()); |
133 | + final SellerType sellerType = isEntry ? SellerType.ENTRY : SellerType.COMMON; | ||
134 | + List<OrderListInfo> data = buildOrderList(sogList, sellerType); | ||
130 | orderListInfoRsp = respBuilder.data(data).build(); | 135 | orderListInfoRsp = respBuilder.data(data).build(); |
131 | - | ||
132 | }else{ | 136 | }else{ |
133 | orderListInfoRsp = super.getOrderList(request); | 137 | orderListInfoRsp = super.getOrderList(request); |
134 | } | 138 | } |
@@ -57,6 +57,7 @@ import com.yohoufo.order.service.impl.visitor.OffShelveCancelCase; | @@ -57,6 +57,7 @@ import com.yohoufo.order.service.impl.visitor.OffShelveCancelCase; | ||
57 | import com.yohoufo.order.service.impl.visitor.UserCancelCase; | 57 | import com.yohoufo.order.service.impl.visitor.UserCancelCase; |
58 | import com.yohoufo.order.service.proxy.InBoxFacade; | 58 | import com.yohoufo.order.service.proxy.InBoxFacade; |
59 | import com.yohoufo.order.service.proxy.ProductProxyService; | 59 | import com.yohoufo.order.service.proxy.ProductProxyService; |
60 | +import com.yohoufo.order.service.proxy.UserProxyService; | ||
60 | import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator; | 61 | import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator; |
61 | import com.yohoufo.order.service.support.codegenerator.bean.CodeMeta; | 62 | import com.yohoufo.order.service.support.codegenerator.bean.CodeMeta; |
62 | import com.yohoufo.order.utils.LoggerUtils; | 63 | import com.yohoufo.order.utils.LoggerUtils; |
@@ -138,6 +139,8 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi | @@ -138,6 +139,8 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi | ||
138 | @Autowired | 139 | @Autowired |
139 | private SellerFeeService sellerFeeService; | 140 | private SellerFeeService sellerFeeService; |
140 | 141 | ||
142 | + @Autowired | ||
143 | + private UserProxyService userProxyService; | ||
141 | 144 | ||
142 | 145 | ||
143 | public SoldPrdComputeBo computePublishPrd(SellerOrderComputeReq req) throws GatewayException { | 146 | public SoldPrdComputeBo computePublishPrd(SellerOrderComputeReq req) throws GatewayException { |
@@ -705,7 +708,48 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi | @@ -705,7 +708,48 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi | ||
705 | return total; | 708 | return total; |
706 | } | 709 | } |
707 | 710 | ||
708 | - public List<OrderListInfo> refresh(){ | 711 | + public List<OrderListInfo> refresh(OrderRequest req){ |
712 | + int uid = req.getUid(); | ||
713 | + if(uid <= 0){ | ||
714 | + log.warn("seller refresh uid illegal , req {}", req); | ||
715 | + throw new UfoServiceException(400, "用户ID错误"); | ||
716 | + } | ||
717 | + | ||
718 | + long orderCode = req.getOrderCode(); | ||
719 | + if(orderCode <= 0L){ | ||
720 | + log.warn("seller refresh orderCode illegal , req {}", req); | ||
721 | + throw new UfoServiceException(400, "订单号错误"); | ||
722 | + } | ||
723 | + CodeMeta codeMeta = orderCodeGenerator.expId(orderCode); | ||
724 | + if (Objects.isNull(codeMeta)){ | ||
725 | + log.warn("seller refresh orderCode illegal, req {}", req); | ||
726 | + throw new ServiceException(ServiceError.ORDER_REQUEST_PARM_IS_EMPTY); | ||
727 | + } | ||
728 | + int type = req.getType(); | ||
729 | + SellerOrderListType solt = SellerOrderListType.getOrderListType(type); | ||
730 | + if (solt == null){ | ||
731 | + log.warn("seller refresh type illegal, req {}", req); | ||
732 | + throw new UfoServiceException(400, "type错误"); | ||
733 | + } | ||
734 | + if(OrderCodeType.SELLER_TYPE.getType() == codeMeta.getType()){ | ||
735 | + SellerOrder pso = sellerOrderMapper.selectByOrderCodeUid(orderCode, uid); | ||
736 | + if (pso == null){ | ||
737 | + log.warn("seller refresh SellerOrder is null,req {}", req); | ||
738 | + return null; | ||
739 | + } | ||
740 | + int skup = pso.getSkup(); | ||
741 | + SellerOrderGoods psog = sellerOrderGoodsMapper.selectByPrimaryKey(skup); | ||
742 | + Long bn = psog.getBatchNo(); | ||
743 | + List<SellerOrderGoods> psogList = sellerOrderGoodsMapper.selectByUidBNStatusGBBPSList(uid, bn, solt.getStatus()); | ||
744 | + if (CollectionUtils.isEmpty(psogList)){ | ||
745 | + log.warn("seller refresh,SellerOrderGoods is empty,req {} bn {} status {}", req, bn, solt.getStatus()); | ||
746 | + return null; | ||
747 | + } | ||
748 | + boolean isEntry = userProxyService.isEntryShop(uid); | ||
749 | + final SellerType sellerType = isEntry ? SellerType.ENTRY : SellerType.COMMON; | ||
750 | + log.info("seller refresh ready 2 buildOrderList req {}", req); | ||
751 | + return sellerOrderListService.buildOrderList(psogList,sellerType); | ||
752 | + } | ||
709 | return null; | 753 | return null; |
710 | } | 754 | } |
711 | 755 |
-
Please register or login to post a comment