Showing
4 changed files
with
80 additions
and
10 deletions
@@ -94,7 +94,27 @@ public class ErpFastDeliveryController { | @@ -94,7 +94,27 @@ public class ErpFastDeliveryController { | ||
94 | 94 | ||
95 | logger.info("singleDownSelf param {}", req); | 95 | logger.info("singleDownSelf param {}", req); |
96 | 96 | ||
97 | - boolean result = erpFastDeliveryService.singleDownSelf(req); | 97 | + boolean result = erpFastDeliveryService.batchDownSelf(req); |
98 | + String msg = "下架成功"; | ||
99 | + if (!result) { | ||
100 | + msg = "下架失败"; | ||
101 | + } | ||
102 | + return new ApiResponse.ApiResponseBuilder().data(result).code(200).message(msg).build(); | ||
103 | + } | ||
104 | + | ||
105 | + /** | ||
106 | + * 批量下架 | ||
107 | + * @param req | ||
108 | + * @return | ||
109 | + */ | ||
110 | + @IgnoreSignature | ||
111 | + @IgnoreSession | ||
112 | + @RequestMapping("/batchDownSelf") | ||
113 | + public ApiResponse batchDownSelf(@RequestBody FastDeliveryDownShelfReq req){ | ||
114 | + | ||
115 | + logger.info("batchDownSelf param {}", req); | ||
116 | + | ||
117 | + boolean result = erpFastDeliveryService.batchDownSelf(req); | ||
98 | String msg = "下架成功"; | 118 | String msg = "下架成功"; |
99 | if (!result) { | 119 | if (!result) { |
100 | msg = "下架失败"; | 120 | msg = "下架失败"; |
@@ -46,6 +46,13 @@ public interface IErpFastDeliveryService { | @@ -46,6 +46,13 @@ public interface IErpFastDeliveryService { | ||
46 | 46 | ||
47 | 47 | ||
48 | /** | 48 | /** |
49 | + * 批量下架 | ||
50 | + * @param req | ||
51 | + */ | ||
52 | + public boolean batchDownSelf(FastDeliveryDownShelfReq req); | ||
53 | + | ||
54 | + | ||
55 | + /** | ||
49 | * 获取货号尺寸信息 | 56 | * 获取货号尺寸信息 |
50 | * @param req | 57 | * @param req |
51 | * @return | 58 | * @return |
@@ -334,7 +334,7 @@ public class ErpFastDeliveryServiceImpl implements IErpFastDeliveryService { | @@ -334,7 +334,7 @@ public class ErpFastDeliveryServiceImpl implements IErpFastDeliveryService { | ||
334 | 334 | ||
335 | /** | 335 | /** |
336 | * 获取某个货号的最低价 | 336 | * 获取某个货号的最低价 |
337 | - * @param productCode | 337 | + * @param req |
338 | * @return | 338 | * @return |
339 | */ | 339 | */ |
340 | public List<StorageInfoResp> getLeastPriceByProductCode(FastDeliveryLeastPriceReq req){ | 340 | public List<StorageInfoResp> getLeastPriceByProductCode(FastDeliveryLeastPriceReq req){ |
@@ -400,6 +400,36 @@ public class ErpFastDeliveryServiceImpl implements IErpFastDeliveryService { | @@ -400,6 +400,36 @@ public class ErpFastDeliveryServiceImpl implements IErpFastDeliveryService { | ||
400 | return result.successCnt > 0 ? true : false; | 400 | return result.successCnt > 0 ? true : false; |
401 | } | 401 | } |
402 | 402 | ||
403 | + | ||
404 | + /** | ||
405 | + * 批量下架 | ||
406 | + * @param req | ||
407 | + */ | ||
408 | + public boolean batchDownSelf(FastDeliveryDownShelfReq req){ | ||
409 | + | ||
410 | + if (req.getUid() < 0){ | ||
411 | + logger.warn("uid is empty"); | ||
412 | + throw new UfoServiceException(400, "参数[uid]不合法"); | ||
413 | + } | ||
414 | + | ||
415 | + if (CollectionUtils.isEmpty(req.getSkups())){ | ||
416 | + logger.warn("skups is empty"); | ||
417 | + throw new UfoServiceException(401, "参数[skups]不合法"); | ||
418 | + } | ||
419 | + | ||
420 | + checkFastDeliveryAuth(req.getUid()); | ||
421 | + | ||
422 | + SkupDownShelfPrepareDto skupDtoMap = sellerDownShelfPrepareProcessor.getDownShelfFastDeliveryPreDto(req.getSkups()); | ||
423 | + SellerTaskDTO<SkupDownShelfPrepareDto> taskDTO = new SellerTaskDTO(req.getUid(), | ||
424 | + SellerWalletDetail.Type.SELLER_OFF.getValue(), | ||
425 | + sellerDownShelfTaskHandler, | ||
426 | + JSON.toJSONString(req), | ||
427 | + skupDtoMap); | ||
428 | + | ||
429 | + SellerTaskResult result = sellerTaskProcessor.process(taskDTO); | ||
430 | + return result.successCnt > 0 ? true : false; | ||
431 | + } | ||
432 | + | ||
403 | /** | 433 | /** |
404 | * 单个下架 | 434 | * 单个下架 |
405 | * @param req | 435 | * @param req |
@@ -418,7 +448,7 @@ public class ErpFastDeliveryServiceImpl implements IErpFastDeliveryService { | @@ -418,7 +448,7 @@ public class ErpFastDeliveryServiceImpl implements IErpFastDeliveryService { | ||
418 | 448 | ||
419 | checkFastDeliveryAuth(req.getUid()); | 449 | checkFastDeliveryAuth(req.getUid()); |
420 | 450 | ||
421 | - SkupDownShelfPrepareDto skupDtoMap = sellerDownShelfPrepareProcessor.getDownShelfPreDto(req.getSkup()); | 451 | + SkupDownShelfPrepareDto skupDtoMap = sellerDownShelfPrepareProcessor.getDownShelfFastDeliveryPreDto(Lists.newArrayList(req.getSkup())); |
422 | SellerTaskDTO<SkupDownShelfPrepareDto> taskDTO = new SellerTaskDTO(req.getUid(), | 452 | SellerTaskDTO<SkupDownShelfPrepareDto> taskDTO = new SellerTaskDTO(req.getUid(), |
423 | SellerWalletDetail.Type.SELLER_OFF.getValue(), | 453 | SellerWalletDetail.Type.SELLER_OFF.getValue(), |
424 | sellerDownShelfTaskHandler, | 454 | sellerDownShelfTaskHandler, |
@@ -23,6 +23,7 @@ import java.util.Arrays; | @@ -23,6 +23,7 @@ import java.util.Arrays; | ||
23 | import java.util.List; | 23 | import java.util.List; |
24 | import java.util.Map; | 24 | import java.util.Map; |
25 | import java.util.Objects; | 25 | import java.util.Objects; |
26 | +import java.util.function.Function; | ||
26 | import java.util.stream.Collectors; | 27 | import java.util.stream.Collectors; |
27 | 28 | ||
28 | /** | 29 | /** |
@@ -82,23 +83,35 @@ public class SellerDownShelfPrepareProcessor { | @@ -82,23 +83,35 @@ public class SellerDownShelfPrepareProcessor { | ||
82 | 83 | ||
83 | /** | 84 | /** |
84 | * 获取skup对应的商品信息 | 85 | * 获取skup对应的商品信息 |
85 | - * @param skup | 86 | + * @param skups |
86 | * @return | 87 | * @return |
87 | */ | 88 | */ |
88 | - public SkupDownShelfPrepareDto getDownShelfPreDto(int skup){ | 89 | + public SkupDownShelfPrepareDto getDownShelfFastDeliveryPreDto(List<Integer> skups){ |
89 | 90 | ||
90 | - SellerOrderGoods sog = sellerOrderGoodsMapper.selectByPrimaryKey(skup); | ||
91 | - if (sog == null || (sog.getStatus() != null && !CAN_OFF_STATUS.contains(sog.getStatus()))){ | ||
92 | - logger.warn("getSellerOrderGoodInfo has buyed, skup {}", skup); | 91 | + List<SellerOrderGoods> sogs = sellerOrderGoodsMapper.selectBySkups(skups); |
92 | + if (CollectionUtils.isEmpty(sogs)){ | ||
93 | + logger.warn("getDownShelfFastDeliveryPreDto order goods not exist"); | ||
93 | throw new UfoServiceException(501, "商品已被下单购买"); | 94 | throw new UfoServiceException(501, "商品已被下单购买"); |
94 | } | 95 | } |
95 | 96 | ||
97 | + // 过滤出状态=出售中的商品 | ||
98 | + List<SellerOrderGoods> canSellSellerOrderGoods = sogs.stream().filter(x->x.getStatus()==SkupStatus.CAN_SELL.getCode()).collect(Collectors.toList()); | ||
99 | + if (CollectionUtils.isEmpty(canSellSellerOrderGoods)){ | ||
100 | + logger.warn("getDownShelfFastDeliveryPreDto can sell order goods not exist"); | ||
101 | + throw new UfoServiceException(501, "商品已被下单购买"); | ||
102 | + } | ||
103 | + | ||
104 | + // 根据skup转成普通的map | ||
105 | + Map<Integer, SellerOrderGoods> sellerOrderGoodsMap = canSellSellerOrderGoods.stream().collect(Collectors.toMap(SellerOrderGoods::getId, Function.identity(), (key1, key2) -> key2)); | ||
106 | + | ||
96 | Map<Integer, SkupDto> skupMap = Maps.newHashMap(); | 107 | Map<Integer, SkupDto> skupMap = Maps.newHashMap(); |
97 | - skupMap.put(sog.getId(), SkupDto.builder().skup(sog.getId()).sellerOrderGoods(sog).batchNo(sog.getBatchNo()).build()); | 108 | + for (Integer skup : sellerOrderGoodsMap.keySet()){ |
109 | + skupMap.put(skup, SkupDto.builder().skup(skup).sellerOrderGoods(sellerOrderGoodsMap.get(skup)).batchNo(sellerOrderGoodsMap.get(skup).getBatchNo()).build()); | ||
110 | + } | ||
98 | 111 | ||
99 | SkupDownShelfPrepareDto sdspDto = SkupDownShelfPrepareDto.builder() | 112 | SkupDownShelfPrepareDto sdspDto = SkupDownShelfPrepareDto.builder() |
100 | .idSkupMap(skupMap) | 113 | .idSkupMap(skupMap) |
101 | - .skupType(SkupType.getSkupType(sog.getAttributes())) | 114 | + .skupType(SkupType.FAST_DELIVERY) |
102 | .build(); | 115 | .build(); |
103 | return sdspDto; | 116 | return sdspDto; |
104 | } | 117 | } |
-
Please register or login to post a comment