fix delete and digit number judge
Showing
10 changed files
with
133 additions
and
110 deletions
@@ -89,12 +89,14 @@ public class BigDecimalHelper { | @@ -89,12 +89,14 @@ public class BigDecimalHelper { | ||
89 | } | 89 | } |
90 | 90 | ||
91 | public static boolean isDigitalNumber(String numStr){ | 91 | public static boolean isDigitalNumber(String numStr){ |
92 | - Pattern pattern = Pattern.compile("\\d+.[0-9]+[1-9]+"); | 92 | + Pattern pattern = Pattern.compile("\\d+\\.([0-9]+)([1-9]+)"); |
93 | Matcher matcher = pattern.matcher(numStr); | 93 | Matcher matcher = pattern.matcher(numStr); |
94 | return matcher.matches(); | 94 | return matcher.matches(); |
95 | } | 95 | } |
96 | public static void main(String[] args) { | 96 | public static void main(String[] args) { |
97 | 97 | ||
98 | - System.out.println(isDigitalNumber("12.0000001")); | 98 | + System.out.println(isDigitalNumber("11111")); |
99 | + System.out.println(isDigitalNumber("1111.00")); | ||
100 | + System.out.println(isDigitalNumber("1111.001")); | ||
99 | } | 101 | } |
100 | } | 102 | } |
@@ -58,4 +58,8 @@ public interface SellerOrderGoodsMapper { | @@ -58,4 +58,8 @@ public interface SellerOrderGoodsMapper { | ||
58 | int insertBatch(@Param("records") Collection<SellerOrderGoods> records); | 58 | int insertBatch(@Param("records") Collection<SellerOrderGoods> records); |
59 | 59 | ||
60 | SellerOrderGoods selectByUidStatusGBBN(SellerOrderGoods record); | 60 | SellerOrderGoods selectByUidStatusGBBN(SellerOrderGoods record); |
61 | + | ||
62 | + List<SellerOrderGoods> selectGPByBNStatusPrice(SellerOrderGoods condition); | ||
63 | + | ||
64 | + int batchDelete(@Param("skups") Collection<Integer> skups); | ||
61 | } | 65 | } |
@@ -25,6 +25,8 @@ public interface SellerOrderMapper { | @@ -25,6 +25,8 @@ public interface SellerOrderMapper { | ||
25 | 25 | ||
26 | int updateByPrimaryKeySelective(SellerOrder record); | 26 | int updateByPrimaryKeySelective(SellerOrder record); |
27 | 27 | ||
28 | + int batchDelete(@Param("skups") Collection<Integer> skups); | ||
29 | + | ||
28 | int updateByPrimaryKey(SellerOrder record); | 30 | int updateByPrimaryKey(SellerOrder record); |
29 | 31 | ||
30 | int updateByOrderCode(SellerOrder record); | 32 | int updateByOrderCode(SellerOrder record); |
@@ -349,4 +349,22 @@ | @@ -349,4 +349,22 @@ | ||
349 | group by batch_no , goods_price ,`status` | 349 | group by batch_no , goods_price ,`status` |
350 | limit 1 | 350 | limit 1 |
351 | </select> | 351 | </select> |
352 | + | ||
353 | + | ||
354 | + <select id="selectGPByBNStatusPrice" parameterType="com.yohoufo.dal.order.model.SellerOrderGoods" resultMap="BaseResultMap"> | ||
355 | + select <include refid="Base_Column_List" /> from seller_order_goods | ||
356 | + where uid = #{uid,jdbcType=INTEGER} and is_del = 1 | ||
357 | + and batch_no = #{batchNo,jdbcType=BIGINT} | ||
358 | + and goods_price = #{goodsPrice,jdbcType=DECIMAL} | ||
359 | + and status = #{status,jdbcType=TINYINT} | ||
360 | + </select> | ||
361 | + | ||
362 | + <update id="batchDelete"> | ||
363 | + update seller_order_goods set is_del = 0 | ||
364 | + where id in | ||
365 | + <foreach collection="skups" item="id" open="(" close=")" separator=","> | ||
366 | + #{id,jdbcType=INTEGER} | ||
367 | + </foreach> | ||
368 | + </update> | ||
369 | + | ||
352 | </mapper> | 370 | </mapper> |
@@ -266,4 +266,12 @@ | @@ -266,4 +266,12 @@ | ||
266 | #{status,jdbcType=INTEGER} | 266 | #{status,jdbcType=INTEGER} |
267 | </foreach> | 267 | </foreach> |
268 | </select> | 268 | </select> |
269 | + | ||
270 | + <update id="batchDelete"> | ||
271 | + update seller_order set is_del = 0 | ||
272 | + where skup in | ||
273 | + <foreach collection="skups" item="skup" open="(" close=")" separator=","> | ||
274 | + #{skup,jdbcType=INTEGER} | ||
275 | + </foreach> | ||
276 | + </update> | ||
269 | </mapper> | 277 | </mapper> |
@@ -60,6 +60,7 @@ import com.yohoufo.order.service.proxy.ProductProxyService; | @@ -60,6 +60,7 @@ import com.yohoufo.order.service.proxy.ProductProxyService; | ||
60 | import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator; | 60 | import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator; |
61 | import com.yohoufo.order.service.support.codegenerator.bean.CodeMeta; | 61 | import com.yohoufo.order.service.support.codegenerator.bean.CodeMeta; |
62 | import com.yohoufo.order.utils.PaymentHelper; | 62 | import com.yohoufo.order.utils.PaymentHelper; |
63 | +import org.apache.commons.collections.CollectionUtils; | ||
63 | import org.apache.commons.lang3.StringUtils; | 64 | import org.apache.commons.lang3.StringUtils; |
64 | import org.slf4j.Logger; | 65 | import org.slf4j.Logger; |
65 | import org.slf4j.LoggerFactory; | 66 | import org.slf4j.LoggerFactory; |
@@ -365,15 +366,11 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi | @@ -365,15 +366,11 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi | ||
365 | CacheKeyBuilder.sellerOrderDetailKey(sellerOrderGoods) | 366 | CacheKeyBuilder.sellerOrderDetailKey(sellerOrderGoods) |
366 | )); | 367 | )); |
367 | } | 368 | } |
368 | - | ||
369 | result = true; | 369 | result = true; |
370 | }else { | 370 | }else { |
371 | - | ||
372 | //1.2 商品下架失败后 | 371 | //1.2 商品下架失败后 |
373 | result = false; | 372 | result = false; |
374 | } | 373 | } |
375 | - | ||
376 | - | ||
377 | return result; | 374 | return result; |
378 | } | 375 | } |
379 | 376 | ||
@@ -394,7 +391,11 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi | @@ -394,7 +391,11 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi | ||
394 | } | 391 | } |
395 | 392 | ||
396 | 393 | ||
397 | - | 394 | + /** |
395 | + * 删除 | ||
396 | + * @param req | ||
397 | + * @return | ||
398 | + */ | ||
398 | public boolean delete(SellerOrderCancelReq req){ | 399 | public boolean delete(SellerOrderCancelReq req){ |
399 | log.info("seller self delete order,req {}", req); | 400 | log.info("seller self delete order,req {}", req); |
400 | int uid = req.getUid(); | 401 | int uid = req.getUid(); |
@@ -423,23 +424,28 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi | @@ -423,23 +424,28 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi | ||
423 | log.warn("not exist skup in delete action, req {}", req); | 424 | log.warn("not exist skup in delete action, req {}", req); |
424 | return false; | 425 | return false; |
425 | } | 426 | } |
426 | - boolean isDelFlag = sellerOrderGoods.getIsDel() != null && DelStatus.IS_DEL.getCode() == sellerOrderGoods.getIsDel(); | ||
427 | - if (isDelFlag){ | 427 | + SellerOrderGoods sogc = new SellerOrderGoods(); |
428 | + sogc.setUid(uid); | ||
429 | + sogc.setGoodsPrice(sellerOrderGoods.getGoodsPrice()); | ||
430 | + sogc.setBatchNo(sellerOrderGoods.getBatchNo()); | ||
431 | + sogc.setStatus(sellerOrderGoods.getStatus()); | ||
432 | + List<SellerOrderGoods> sogList = sellerOrderGoodsMapper.selectGPByBNStatusPrice(sogc); | ||
433 | + Set<Integer> skups = sogList.parallelStream() | ||
434 | + .filter(csog -> csog.getIsDel() == null || DelStatus.NOT_DEL.getCode() ==csog.getIsDel()) | ||
435 | + .map(SellerOrderGoods::getId).collect(Collectors.toSet()); | ||
436 | + | ||
437 | + if (CollectionUtils.isEmpty(skups)){ | ||
438 | + log.warn("in seller delete not exist skups, req {}", req); | ||
428 | return false; | 439 | return false; |
429 | } | 440 | } |
430 | //判断状态后更新 | 441 | //判断状态后更新 |
431 | - checkSellCanDelStatus(sellerOrder.getStatus()); | ||
432 | - | ||
433 | - SellerOrder target = new SellerOrder(); | ||
434 | - target.setId(sellerOrder.getId()); | ||
435 | - target.setIsDel(DelStatus.IS_DEL.getCode()); | ||
436 | - target.setUpdateTime(DateUtil.getCurrentTimeSecond()); | ||
437 | - sellerOrderMapper.updateByPrimaryKeySelective(target); | ||
438 | 442 | ||
439 | - SellerOrderGoods tsog = new SellerOrderGoods(); | ||
440 | - tsog.setId(sellerOrder.getSkup()); | ||
441 | - tsog.setIsDel(DelStatus.IS_DEL.getCode()); | ||
442 | - sellerOrderGoodsMapper.updateByPrimaryKeySelective(tsog); | 443 | + List<SellerOrder> soList = sellerOrderMapper.selectBySkups(skups); |
444 | + for(SellerOrder so : soList){ | ||
445 | + checkSellCanDelStatus(so.getStatus()); | ||
446 | + } | ||
447 | + sellerOrderMapper.batchDelete(skups); | ||
448 | + sellerOrderGoodsMapper.batchDelete(skups); | ||
443 | } | 449 | } |
444 | 450 | ||
445 | 451 | ||
@@ -552,21 +558,19 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi | @@ -552,21 +558,19 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi | ||
552 | */ | 558 | */ |
553 | public BatchChangePriceResp batchChangePrice(BatchChangePriceReq req) throws GatewayException { | 559 | public BatchChangePriceResp batchChangePrice(BatchChangePriceReq req) throws GatewayException { |
554 | ChangePricePrepareDTO cppDto = changePricePrepareProcessor.checkAndAcquire(req); | 560 | ChangePricePrepareDTO cppDto = changePricePrepareProcessor.checkAndAcquire(req); |
555 | - BigDecimal diffEarnestMoney = cppDto.getDiffEarnestMoney(); | ||
556 | - if (diffEarnestMoney.compareTo(BigDecimal.ZERO) == 0){ | ||
557 | - throw new UfoServiceException(401, "前后价格没有变化"); | ||
558 | - } | 561 | + BigDecimal preSalePrice = cppDto.getPreSalePrice(), |
562 | + salePrice = cppDto.getSalePrice(); | ||
559 | int uid = req.getUid(); | 563 | int uid = req.getUid(); |
560 | Map<Integer, SkupDto> skupMap = cppDto.getSkupMap(); | 564 | Map<Integer, SkupDto> skupMap = cppDto.getSkupMap(); |
561 | SellerOrderComputeResult computeResult = cppDto.getComputeResult(); | 565 | SellerOrderComputeResult computeResult = cppDto.getComputeResult(); |
562 | //1 划账 | 566 | //1 划账 |
563 | - | 567 | + BigDecimal diffEarnestMoney = cppDto.getDiffEarnestMoney(); |
564 | BigDecimal totalDiffMoney = diffEarnestMoney.multiply(new BigDecimal(skupMap.size())); | 568 | BigDecimal totalDiffMoney = diffEarnestMoney.multiply(new BigDecimal(skupMap.size())); |
565 | SellerWalletDetail.Type swdType = SellerWalletDetail.Type.ADD_PRICE; | 569 | SellerWalletDetail.Type swdType = SellerWalletDetail.Type.ADD_PRICE; |
566 | MerchantOrderAttachInfo moai = MerchantOrderAttachInfo.builder().uid(req.getUid()) | 570 | MerchantOrderAttachInfo moai = MerchantOrderAttachInfo.builder().uid(req.getUid()) |
567 | - .afterProductPrice(cppDto.getSalePrice()) | 571 | + .afterProductPrice(salePrice) |
568 | .beforeEarnestMoney(cppDto.getPreEarnestMoney().toPlainString()) | 572 | .beforeEarnestMoney(cppDto.getPreEarnestMoney().toPlainString()) |
569 | - .beforeProductPrice(cppDto.getPreSalePrice()) | 573 | + .beforeProductPrice(preSalePrice) |
570 | .afterEarnestMoney(computeResult.getEarnestMoney().getEarnestMoney().toPlainString()) | 574 | .afterEarnestMoney(computeResult.getEarnestMoney().getEarnestMoney().toPlainString()) |
571 | .earnestMoney(totalDiffMoney).productCount(skupMap.size()) | 575 | .earnestMoney(totalDiffMoney).productCount(skupMap.size()) |
572 | .seriNo(String.valueOf(req.getBatchNo())) | 576 | .seriNo(String.valueOf(req.getBatchNo())) |
@@ -578,7 +582,6 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi | @@ -578,7 +582,6 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi | ||
578 | if(Objects.nonNull(sellerWallet)) { | 582 | if(Objects.nonNull(sellerWallet)) { |
579 | //1.1 划账成功后 | 583 | //1.1 划账成功后 |
580 | //TODO 2 商品变价(同步价格到商品) | 584 | //TODO 2 商品变价(同步价格到商品) |
581 | - BigDecimal salePrice = cppDto.getSalePrice(); | ||
582 | 585 | ||
583 | Set<Integer> skupSet = skupMap.keySet(); | 586 | Set<Integer> skupSet = skupMap.keySet(); |
584 | productProxyService.batchUpdatePrice(skupSet, salePrice); | 587 | productProxyService.batchUpdatePrice(skupSet, salePrice); |
@@ -57,6 +57,9 @@ public class ChangePricePrepareProcessor { | @@ -57,6 +57,9 @@ public class ChangePricePrepareProcessor { | ||
57 | @Autowired | 57 | @Autowired |
58 | private SellerOrderComputeHandler computeHandler; | 58 | private SellerOrderComputeHandler computeHandler; |
59 | 59 | ||
60 | + @Autowired | ||
61 | + private PriceComputePrepareProcessor priceComputePrepareProcessor; | ||
62 | + | ||
60 | public ChangePricePrepareDTO checkAndAcquire(BatchChangePriceReq req) throws GatewayException { | 63 | public ChangePricePrepareDTO checkAndAcquire(BatchChangePriceReq req) throws GatewayException { |
61 | int uid = req.getUid(); | 64 | int uid = req.getUid(); |
62 | if (uid <= 0){ | 65 | if (uid <= 0){ |
@@ -80,20 +83,7 @@ public class ChangePricePrepareProcessor { | @@ -80,20 +83,7 @@ public class ChangePricePrepareProcessor { | ||
80 | //check batch no | 83 | //check batch no |
81 | Long batchNo = checkNAcquireBatchNo(req.getBatchNo(), req); | 84 | Long batchNo = checkNAcquireBatchNo(req.getBatchNo(), req); |
82 | 85 | ||
83 | - BigDecimal salePrice; | ||
84 | - try{ | ||
85 | - salePrice = new BigDecimal(req.getPrice()); | ||
86 | - }catch (Exception ex){ | ||
87 | - logger.warn("ChangePrice checkAndAcquire salePrice illegal , req {}", req); | ||
88 | - throw new UfoServiceException(400, "售价格式错误"); | ||
89 | - } | ||
90 | - if (salePrice.compareTo(BigDecimal.ZERO) <= 0){ | ||
91 | - throw new UfoServiceException(401, "价格只能为正整数"); | ||
92 | - } | ||
93 | - | ||
94 | - if(BigDecimalHelper.isDigitalNumber(req.getPrice())){ | ||
95 | - throw new UfoServiceException(401, "价格只能为正整数"); | ||
96 | - } | 86 | + BigDecimal salePrice = priceComputePrepareProcessor.checkAndAcquireSalePrice(req.getPrice()); |
97 | 87 | ||
98 | //检查是否有买家下单,返回的是可售 待买家付款的skup | 88 | //检查是否有买家下单,返回的是可售 待买家付款的skup |
99 | Map<Integer, SkupDto> skupOfSalingMap = checkExistWaitingBuyerPay(batchNo, req); | 89 | Map<Integer, SkupDto> skupOfSalingMap = checkExistWaitingBuyerPay(batchNo, req); |
@@ -103,6 +93,11 @@ public class ChangePricePrepareProcessor { | @@ -103,6 +93,11 @@ public class ChangePricePrepareProcessor { | ||
103 | SkupDto sampleSkupDto = skupMap.values().iterator().next(); | 93 | SkupDto sampleSkupDto = skupMap.values().iterator().next(); |
104 | int sampleSkup = sampleSkupDto.getSkup(); | 94 | int sampleSkup = sampleSkupDto.getSkup(); |
105 | SellerOrderGoods sampleSog = sampleSkupDto.getSellerOrderGoods(); | 95 | SellerOrderGoods sampleSog = sampleSkupDto.getSellerOrderGoods(); |
96 | + BigDecimal preSalePrice = sampleSog.getGoodsPrice(); | ||
97 | + if (preSalePrice.compareTo(salePrice) == 0){ | ||
98 | + throw new UfoServiceException(401, "前后价格没有变化"); | ||
99 | + } | ||
100 | + | ||
106 | SellerOrder sellerOrder = sellerOrderMapper.selectBySkup(sampleSkup); | 101 | SellerOrder sellerOrder = sellerOrderMapper.selectBySkup(sampleSkup); |
107 | BigDecimal sourceEM = sellerOrder.getEarnestMoney(); | 102 | BigDecimal sourceEM = sellerOrder.getEarnestMoney(); |
108 | int storageId = sampleSog.getStorageId(); | 103 | int storageId = sampleSog.getStorageId(); |
@@ -139,7 +134,7 @@ public class ChangePricePrepareProcessor { | @@ -139,7 +134,7 @@ public class ChangePricePrepareProcessor { | ||
139 | .skupMap(skupMap) | 134 | .skupMap(skupMap) |
140 | .computeResult(computeResult) | 135 | .computeResult(computeResult) |
141 | .preEarnestMoney(sourceEM) | 136 | .preEarnestMoney(sourceEM) |
142 | - .preSalePrice(sampleSog.getGoodsPrice()) | 137 | + .preSalePrice(preSalePrice) |
143 | .tips(tips) | 138 | .tips(tips) |
144 | .build(); | 139 | .build(); |
145 | } | 140 | } |
@@ -34,32 +34,15 @@ public class PriceComputePrepareProcessor { | @@ -34,32 +34,15 @@ public class PriceComputePrepareProcessor { | ||
34 | } | 34 | } |
35 | } | 35 | } |
36 | 36 | ||
37 | - public PriceComputeNode checkBasePrice(SellerOrderComputeReq req) throws GatewayException { | ||
38 | - int uid = req.getUid(); | ||
39 | - if(uid <= 0){ | ||
40 | - log.warn("in computePublishPrd uid illegal , req {}", req); | ||
41 | - throw new GatewayException(400, "用户ID错误"); | ||
42 | - } | ||
43 | - // | ||
44 | - Integer storageId = req.getStorageId(); | ||
45 | - if (storageId <=0 ){ | ||
46 | - log.warn("in computePublishPrd storageId illegal , req {}", req); | ||
47 | - throw new GatewayException(400, "storageId 错误"); | ||
48 | - } | ||
49 | - int num; | ||
50 | - if ((num = req.getNum())<=0){ | ||
51 | - log.warn("in computePublishPrd num illegal , req {}", req); | ||
52 | - throw new GatewayException(400, "非法数量值"); | ||
53 | - } | 37 | + public BigDecimal checkAndAcquireSalePrice(String price){ |
54 | 38 | ||
55 | /*商品鉴定费 ¥10.00 | 39 | /*商品鉴定费 ¥10.00 |
56 | 商品包装费 ¥10.00 | 40 | 商品包装费 ¥10.00 |
57 | 平台服务费(5%,优惠期间0%) ¥0.00 | 41 | 平台服务费(5%,优惠期间0%) ¥0.00 |
58 | */ | 42 | */ |
59 | - String price = req.getPrice(); | ||
60 | if (StringUtils.isBlank(price)){ | 43 | if (StringUtils.isBlank(price)){ |
61 | - log.warn("in computePublishPrd price illegal , req {}", req); | ||
62 | - throw new GatewayException(400, "没有价格"); | 44 | + log.warn("in checkAndAcquireSalePrice price illegal , price {}", price); |
45 | + throw new UfoServiceException(400, "没有价格"); | ||
63 | } | 46 | } |
64 | /* | 47 | /* |
65 | if(!price.endsWith("9")){ | 48 | if(!price.endsWith("9")){ |
@@ -71,8 +54,8 @@ public class PriceComputePrepareProcessor { | @@ -71,8 +54,8 @@ public class PriceComputePrepareProcessor { | ||
71 | try{ | 54 | try{ |
72 | prdPrice = new BigDecimal(price); | 55 | prdPrice = new BigDecimal(price); |
73 | }catch (Exception e){ | 56 | }catch (Exception e){ |
74 | - log.warn("in computePublishPrd price convert BigDecimal fail, {}", req); | ||
75 | - throw new GatewayException(400, "非法数字"); | 57 | + log.warn("in checkAndAcquireSalePrice price convert BigDecimal fail, price {}", price); |
58 | + throw new UfoServiceException(400, "非法数字"); | ||
76 | } | 59 | } |
77 | if (prdPrice.compareTo(BigDecimal.ZERO) <= 0){ | 60 | if (prdPrice.compareTo(BigDecimal.ZERO) <= 0){ |
78 | throw new UfoServiceException(401, "价格只能为正整数"); | 61 | throw new UfoServiceException(401, "价格只能为正整数"); |
@@ -81,6 +64,28 @@ public class PriceComputePrepareProcessor { | @@ -81,6 +64,28 @@ public class PriceComputePrepareProcessor { | ||
81 | if(BigDecimalHelper.isDigitalNumber(price)){ | 64 | if(BigDecimalHelper.isDigitalNumber(price)){ |
82 | throw new UfoServiceException(401, "价格只能为正整数"); | 65 | throw new UfoServiceException(401, "价格只能为正整数"); |
83 | } | 66 | } |
67 | + return prdPrice; | ||
68 | + } | ||
69 | + | ||
70 | + public PriceComputeNode checkBasePrice(SellerOrderComputeReq req) { | ||
71 | + int uid = req.getUid(); | ||
72 | + if(uid <= 0){ | ||
73 | + log.warn("in computePublishPrd uid illegal , req {}", req); | ||
74 | + throw new UfoServiceException(400, "用户ID错误"); | ||
75 | + } | ||
76 | + // | ||
77 | + Integer storageId = req.getStorageId(); | ||
78 | + if (storageId <=0 ){ | ||
79 | + log.warn("in computePublishPrd storageId illegal , req {}", req); | ||
80 | + throw new UfoServiceException(400, "storageId 错误"); | ||
81 | + } | ||
82 | + int num; | ||
83 | + if ((num = req.getNum())<=0){ | ||
84 | + log.warn("in computePublishPrd num illegal , req {}", req); | ||
85 | + throw new UfoServiceException(400, "非法数量值"); | ||
86 | + } | ||
87 | + | ||
88 | + BigDecimal prdPrice = checkAndAcquireSalePrice(req.getPrice()); | ||
84 | 89 | ||
85 | return new PriceComputeNode(uid, storageId, num, prdPrice); | 90 | return new PriceComputeNode(uid, storageId, num, prdPrice); |
86 | } | 91 | } |
@@ -49,6 +49,9 @@ public class SellerOrderPrepareProcessor { | @@ -49,6 +49,9 @@ public class SellerOrderPrepareProcessor { | ||
49 | @Autowired | 49 | @Autowired |
50 | private SellerWalletMapper sellerWalletMapper; | 50 | private SellerWalletMapper sellerWalletMapper; |
51 | 51 | ||
52 | + @Autowired | ||
53 | + private PriceComputePrepareProcessor priceComputePrepareProcessor; | ||
54 | + | ||
52 | public SellerOrderContext buildPublishPrdCtx(SellerOrderSubmitReq req) throws GatewayException { | 55 | public SellerOrderContext buildPublishPrdCtx(SellerOrderSubmitReq req) throws GatewayException { |
53 | SellerOrderContext ctx = buildSellerOrderContext(req); | 56 | SellerOrderContext ctx = buildSellerOrderContext(req); |
54 | int uid = ctx.getUid(); | 57 | int uid = ctx.getUid(); |
@@ -91,31 +94,8 @@ public class SellerOrderPrepareProcessor { | @@ -91,31 +94,8 @@ public class SellerOrderPrepareProcessor { | ||
91 | log.warn("storageId illegal , uid {}", uid); | 94 | log.warn("storageId illegal , uid {}", uid); |
92 | throw new GatewayException(400, "storageId 错误"); | 95 | throw new GatewayException(400, "storageId 错误"); |
93 | } | 96 | } |
94 | - String price = req.getPrice(); | ||
95 | - if (StringUtils.isBlank(price)){ | ||
96 | - log.warn("in buildSellerOrderContext price illegal , req {}", req); | ||
97 | - throw new GatewayException(400, "没有价格"); | ||
98 | - } | ||
99 | - /* | ||
100 | - if(!price.endsWith("9")){ | ||
101 | - log.warn("in buildSellerOrderContext price illegal , req {}", req); | ||
102 | - throw new GatewayException(400, "价格须为以9结尾的正整数"); | ||
103 | - }*/ | ||
104 | 97 | ||
105 | - BigDecimal salePrice; | ||
106 | - try{ | ||
107 | - salePrice = new BigDecimal(req.getPrice()); | ||
108 | - }catch (Exception ex){ | ||
109 | - log.warn("storageId illegal , uid {}", uid); | ||
110 | - throw new GatewayException(400, "售价格式错误"); | ||
111 | - } | ||
112 | - if (salePrice.compareTo(BigDecimal.ZERO) <= 0){ | ||
113 | - throw new UfoServiceException(401, "价格只能为正整数"); | ||
114 | - } | ||
115 | - | ||
116 | - if(BigDecimalHelper.isDigitalNumber(price)){ | ||
117 | - throw new UfoServiceException(401, "价格只能为正整数"); | ||
118 | - } | 98 | + BigDecimal salePrice = priceComputePrepareProcessor.checkAndAcquireSalePrice(req.getPrice()); |
119 | 99 | ||
120 | int addressId = AddressUtil.getDecryptStr(req.getAddressId()); | 100 | int addressId = AddressUtil.getDecryptStr(req.getAddressId()); |
121 | if (addressId < 0){ | 101 | if (addressId < 0){ |
@@ -3,7 +3,6 @@ package com.yohoufo.order.service.proxy; | @@ -3,7 +3,6 @@ package com.yohoufo.order.service.proxy; | ||
3 | import com.yohobuy.ufo.model.order.common.SkupStatus; | 3 | import com.yohobuy.ufo.model.order.common.SkupStatus; |
4 | import com.yohoufo.common.ApiResponse; | 4 | import com.yohoufo.common.ApiResponse; |
5 | import com.yohoufo.common.caller.UfoServiceCaller; | 5 | import com.yohoufo.common.caller.UfoServiceCaller; |
6 | -import com.yohoufo.common.exception.GatewayException; | ||
7 | import com.yohoufo.common.exception.UfoServiceException; | 6 | import com.yohoufo.common.exception.UfoServiceException; |
8 | import com.yohoufo.dal.order.model.SellerOrderGoods; | 7 | import com.yohoufo.dal.order.model.SellerOrderGoods; |
9 | import com.yohoufo.product.model.ProductInfo; | 8 | import com.yohoufo.product.model.ProductInfo; |
@@ -29,23 +28,35 @@ import java.util.Set; | @@ -29,23 +28,35 @@ import java.util.Set; | ||
29 | public class ProductProxyService { | 28 | public class ProductProxyService { |
30 | 29 | ||
31 | final Logger logger = LoggerFactory.getLogger(getClass()); | 30 | final Logger logger = LoggerFactory.getLogger(getClass()); |
31 | + @Data | ||
32 | + public static class PrdPrice{ | ||
33 | + private BigDecimal maxPrice; | ||
34 | + private BigDecimal minPrice; | ||
35 | + private BigDecimal suggestMaxPrice; | ||
36 | + private BigDecimal suggestMinPrice; | ||
37 | + private BigDecimal leastPrice; | ||
38 | + } | ||
32 | 39 | ||
33 | @Autowired | 40 | @Autowired |
34 | private UfoServiceCaller ufoServiceCaller; | 41 | private UfoServiceCaller ufoServiceCaller; |
35 | 42 | ||
36 | - private final static String syncSkup = "ufo.product.createSkup"; | ||
37 | - | ||
38 | - | ||
39 | - private final static String SYNC_SKUP_STATUS = "ufo.product.sellerUpdateStatus"; | 43 | + public final static String syncSkup = "ufo.product.createSkup"; |
40 | 44 | ||
45 | + public final static String SYNC_SKUP_STATUS = "ufo.product.sellerUpdateStatus"; | ||
41 | /** | 46 | /** |
42 | * 减库存 | 47 | * 减库存 |
43 | */ | 48 | */ |
44 | - private final static String SUBTRACT_STORAGE = "ufo.product.saleSkup"; | 49 | + public final static String SUBTRACT_STORAGE = "ufo.product.saleSkup"; |
45 | /** | 50 | /** |
46 | * 归还库存 | 51 | * 归还库存 |
47 | */ | 52 | */ |
48 | - private final static String RETURN_STORAGE = "ufo.product.cancelSaleSkup"; | 53 | + public final static String RETURN_STORAGE = "ufo.product.cancelSaleSkup"; |
54 | + | ||
55 | + static String batchCreateSkup = "ufo.product.batchCreateSkup"; | ||
56 | + | ||
57 | + static String sellerBatchUpdateStatus = "ufo.product.sellerBatchUpdateStatus"; | ||
58 | + | ||
59 | + public static String STORAGE_DATA = "ufo.product.storage.data"; | ||
49 | 60 | ||
50 | 61 | ||
51 | public boolean subtractStorage(Integer productId, Integer skup){ | 62 | public boolean subtractStorage(Integer productId, Integer skup){ |
@@ -58,20 +69,10 @@ public class ProductProxyService { | @@ -58,20 +69,10 @@ public class ProductProxyService { | ||
58 | 69 | ||
59 | 70 | ||
60 | public boolean returnStorage(Integer skup){ | 71 | public boolean returnStorage(Integer skup){ |
61 | - | ||
62 | ApiResponse resp = ufoServiceCaller.call(RETURN_STORAGE, ApiResponse.class, skup, 1); | 72 | ApiResponse resp = ufoServiceCaller.call(RETURN_STORAGE, ApiResponse.class, skup, 1); |
63 | - | ||
64 | - | ||
65 | return (resp == null || resp.getData()==null) ? false : (boolean)resp.getData(); | 73 | return (resp == null || resp.getData()==null) ? false : (boolean)resp.getData(); |
66 | } | 74 | } |
67 | - @Data | ||
68 | - public static class PrdPrice{ | ||
69 | - private BigDecimal maxPrice; | ||
70 | - private BigDecimal minPrice; | ||
71 | - private BigDecimal suggestMaxPrice; | ||
72 | - private BigDecimal suggestMinPrice; | ||
73 | - private BigDecimal leastPrice; | ||
74 | - } | 75 | + |
75 | 76 | ||
76 | public PrdPrice getPrdPriceRange(int storageId){ | 77 | public PrdPrice getPrdPriceRange(int storageId){ |
77 | StorageDataResp storage = getStorageData(storageId); | 78 | StorageDataResp storage = getStorageData(storageId); |
@@ -105,9 +106,15 @@ public class ProductProxyService { | @@ -105,9 +106,15 @@ public class ProductProxyService { | ||
105 | } | 106 | } |
106 | 107 | ||
107 | 108 | ||
109 | + | ||
108 | public StorageDataResp getStorageData(int storageId){ | 110 | public StorageDataResp getStorageData(int storageId){ |
109 | - StorageDataResp prdResp = ufoServiceCaller.call("ufo.product.storage.data", storageId); | 111 | + StorageDataResp prdResp = null; |
112 | + try { | ||
113 | + prdResp = ufoServiceCaller.call(STORAGE_DATA, storageId); | ||
110 | logger.info("in getStorageData storageId {} prdResp {}", storageId, prdResp); | 114 | logger.info("in getStorageData storageId {} prdResp {}", storageId, prdResp); |
115 | + }catch (Exception ex){ | ||
116 | + logger.warn("in getStorageData call {} fail, storageId {}", STORAGE_DATA, storageId); | ||
117 | + } | ||
111 | return prdResp; | 118 | return prdResp; |
112 | } | 119 | } |
113 | 120 | ||
@@ -190,8 +197,7 @@ public class ProductProxyService { | @@ -190,8 +197,7 @@ public class ProductProxyService { | ||
190 | return (null == resp || null == resp.getData())? false : (boolean)resp.getData(); | 197 | return (null == resp || null == resp.getData())? false : (boolean)resp.getData(); |
191 | } | 198 | } |
192 | 199 | ||
193 | - static String batchCreateSkup = "ufo.product.batchCreateSkup"; | ||
194 | - static String sellerBatchUpdateStatus = "ufo.product.sellerBatchUpdateStatus"; | 200 | + |
195 | 201 | ||
196 | public boolean batchCreateSkup(List<SellerOrderGoods> sogList){ | 202 | public boolean batchCreateSkup(List<SellerOrderGoods> sogList){ |
197 | List<StoragePriceBo> skupBoList = new ArrayList<>(sogList.size()); | 203 | List<StoragePriceBo> skupBoList = new ArrayList<>(sogList.size()); |
-
Please register or login to post a comment