|
@@ -3,6 +3,7 @@ package com.yohoufo.order.service.impl; |
|
@@ -3,6 +3,7 @@ package com.yohoufo.order.service.impl; |
3
|
import com.alibaba.fastjson.JSON;
|
3
|
import com.alibaba.fastjson.JSON;
|
4
|
import com.google.common.collect.Lists;
|
4
|
import com.google.common.collect.Lists;
|
5
|
import com.yohobuy.ufo.model.ProductInfo;
|
5
|
import com.yohobuy.ufo.model.ProductInfo;
|
|
|
6
|
+import com.yohobuy.ufo.model.enums.StorageCheckEnum;
|
6
|
import com.yohobuy.ufo.model.order.bo.SellerBo;
|
7
|
import com.yohobuy.ufo.model.order.bo.SellerBo;
|
7
|
import com.yohobuy.ufo.model.order.common.OrderStatus;
|
8
|
import com.yohobuy.ufo.model.order.common.OrderStatus;
|
8
|
import com.yohobuy.ufo.model.order.common.SellerFuncEnum;
|
9
|
import com.yohobuy.ufo.model.order.common.SellerFuncEnum;
|
|
@@ -14,8 +15,12 @@ import com.yohobuy.ufo.model.order.resp.FastDeliveryGetShelfResp; |
|
@@ -14,8 +15,12 @@ import com.yohobuy.ufo.model.order.resp.FastDeliveryGetShelfResp; |
14
|
import com.yohobuy.ufo.model.order.resp.OrderListInfo;
|
15
|
import com.yohobuy.ufo.model.order.resp.OrderListInfo;
|
15
|
import com.yohobuy.ufo.model.order.resp.PageResp;
|
16
|
import com.yohobuy.ufo.model.order.resp.PageResp;
|
16
|
import com.yohobuy.ufo.model.request.product.ProductImportTranItemBo;
|
17
|
import com.yohobuy.ufo.model.request.product.ProductImportTranItemBo;
|
|
|
18
|
+import com.yohobuy.ufo.model.request.product.ProductRequestBo;
|
17
|
import com.yohobuy.ufo.model.response.ProductDetailResp;
|
19
|
import com.yohobuy.ufo.model.response.ProductDetailResp;
|
|
|
20
|
+import com.yohobuy.ufo.model.response.StorageCheckResp;
|
|
|
21
|
+import com.yohobuy.ufo.model.response.StorageInfoResp;
|
18
|
import com.yohoufo.common.exception.UfoServiceException;
|
22
|
import com.yohoufo.common.exception.UfoServiceException;
|
|
|
23
|
+import com.yohoufo.common.utils.StringUtil;
|
19
|
import com.yohoufo.dal.order.*;
|
24
|
import com.yohoufo.dal.order.*;
|
20
|
import com.yohoufo.dal.order.model.*;
|
25
|
import com.yohoufo.dal.order.model.*;
|
21
|
import com.yohoufo.order.common.BillTradeStatus;
|
26
|
import com.yohoufo.order.common.BillTradeStatus;
|
|
@@ -145,6 +150,8 @@ public class ErpFastDeliveryServiceImpl implements IErpFastDeliveryService { |
|
@@ -145,6 +150,8 @@ public class ErpFastDeliveryServiceImpl implements IErpFastDeliveryService { |
145
|
req.setPage(1);
|
150
|
req.setPage(1);
|
146
|
}
|
151
|
}
|
147
|
|
152
|
|
|
|
153
|
+ checkFastDeliveryAuth(req.getUid());
|
|
|
154
|
+
|
148
|
int total = sellerOrderGoodsMapper.selectCntByMulti(req.getUid(), req.getStatus(), req.getSkup(),
|
155
|
int total = sellerOrderGoodsMapper.selectCntByMulti(req.getUid(), req.getStatus(), req.getSkup(),
|
149
|
req.getOrderCode(), req.getStartTime(), req.getEndTime());
|
156
|
req.getOrderCode(), req.getStartTime(), req.getEndTime());
|
150
|
if (total == 0) {
|
157
|
if (total == 0) {
|
|
@@ -296,6 +303,28 @@ public class ErpFastDeliveryServiceImpl implements IErpFastDeliveryService { |
|
@@ -296,6 +303,28 @@ public class ErpFastDeliveryServiceImpl implements IErpFastDeliveryService { |
296
|
|
303
|
|
297
|
|
304
|
|
298
|
/**
|
305
|
/**
|
|
|
306
|
+ * 获取某个货号的最低价
|
|
|
307
|
+ * @param productCode
|
|
|
308
|
+ * @return
|
|
|
309
|
+ */
|
|
|
310
|
+ public List<StorageInfoResp> getLeastPriceByProductCode(FastDeliveryLeastPriceReq req){
|
|
|
311
|
+
|
|
|
312
|
+ if (req.getUid() < 0){
|
|
|
313
|
+ logger.warn("uid is empty");
|
|
|
314
|
+ throw new UfoServiceException(400, "参数[uid]不合法");
|
|
|
315
|
+ }
|
|
|
316
|
+
|
|
|
317
|
+ if (StringUtils.isBlank(req.getProductCode())){
|
|
|
318
|
+ logger.warn("productCode is empty");
|
|
|
319
|
+ throw new UfoServiceException(400, "参数[productCode]不合法");
|
|
|
320
|
+ }
|
|
|
321
|
+
|
|
|
322
|
+ checkFastDeliveryAuth(req.getUid());
|
|
|
323
|
+
|
|
|
324
|
+ return productProxyService.getLowestPrice(req.getProductCode());
|
|
|
325
|
+ }
|
|
|
326
|
+
|
|
|
327
|
+ /**
|
299
|
* 单个调价
|
328
|
* 单个调价
|
300
|
* @param req
|
329
|
* @param req
|
301
|
* @return
|
330
|
* @return
|
|
@@ -317,6 +346,8 @@ public class ErpFastDeliveryServiceImpl implements IErpFastDeliveryService { |
|
@@ -317,6 +346,8 @@ public class ErpFastDeliveryServiceImpl implements IErpFastDeliveryService { |
317
|
throw new UfoServiceException(402, "参数[newPrice]不合法");
|
346
|
throw new UfoServiceException(402, "参数[newPrice]不合法");
|
318
|
}
|
347
|
}
|
319
|
|
348
|
|
|
|
349
|
+ checkFastDeliveryAuth(req.getUid());
|
|
|
350
|
+
|
320
|
ChangePricePrepareDTO cppDto = adjustPricePrepareProcessor.getChangePricePreDto(req);
|
351
|
ChangePricePrepareDTO cppDto = adjustPricePrepareProcessor.getChangePricePreDto(req);
|
321
|
SellerTaskDTO<ChangePricePrepareDTO> taskDTO = null;
|
352
|
SellerTaskDTO<ChangePricePrepareDTO> taskDTO = null;
|
322
|
if (cppDto.getSalePrice().compareTo(cppDto.getPreSalePrice()) > 0) {
|
353
|
if (cppDto.getSalePrice().compareTo(cppDto.getPreSalePrice()) > 0) {
|
|
@@ -355,6 +386,8 @@ public class ErpFastDeliveryServiceImpl implements IErpFastDeliveryService { |
|
@@ -355,6 +386,8 @@ public class ErpFastDeliveryServiceImpl implements IErpFastDeliveryService { |
355
|
throw new UfoServiceException(401, "参数[skup]不合法");
|
386
|
throw new UfoServiceException(401, "参数[skup]不合法");
|
356
|
}
|
387
|
}
|
357
|
|
388
|
|
|
|
389
|
+ checkFastDeliveryAuth(req.getUid());
|
|
|
390
|
+
|
358
|
SkupDownShelfPrepareDto skupDtoMap = sellerDownShelfPrepareProcessor.getDownShelfPreDto(req.getSkup());
|
391
|
SkupDownShelfPrepareDto skupDtoMap = sellerDownShelfPrepareProcessor.getDownShelfPreDto(req.getSkup());
|
359
|
SellerTaskDTO<SkupDownShelfPrepareDto> taskDTO = new SellerTaskDTO(req.getUid(),
|
392
|
SellerTaskDTO<SkupDownShelfPrepareDto> taskDTO = new SellerTaskDTO(req.getUid(),
|
360
|
SellerWalletDetail.Type.SELLER_OFF.getValue(),
|
393
|
SellerWalletDetail.Type.SELLER_OFF.getValue(),
|
|
@@ -372,39 +405,47 @@ public class ErpFastDeliveryServiceImpl implements IErpFastDeliveryService { |
|
@@ -372,39 +405,47 @@ public class ErpFastDeliveryServiceImpl implements IErpFastDeliveryService { |
372
|
// 检查入口参数
|
405
|
// 检查入口参数
|
373
|
checkBatchOnShelf(req);
|
406
|
checkBatchOnShelf(req);
|
374
|
|
407
|
|
375
|
- // 检查用户权限(批量上架权限)
|
|
|
376
|
- int uid = req.getUid();
|
|
|
377
|
- SellerWrapper sellerWrapper = sellerService.getFullDimensionSeller(req.getUid());
|
|
|
378
|
- SellerBo sellerBo = sellerWrapper.buildSellerBo();
|
|
|
379
|
- if (!sellerBo.isFastDeliverySuper()){
|
|
|
380
|
- logger.warn("batchOnShelf not legal super, uid {} ", uid);
|
|
|
381
|
- throw new UfoServiceException(501, "用户权限不合法!");
|
|
|
382
|
- }
|
|
|
383
|
- sellerWrapper = sellerWrapper.attachSellerLevelFunc((sw)->sellerFuncService.getSellerLevelFunc(sw));
|
|
|
384
|
- sellerAuthCheckService.checkAuth(sellerBo, null, SellerFuncEnum.BATCH_PUBLISH);
|
408
|
+ // 检查用户权限(急速发货权限)
|
|
|
409
|
+ SellerWrapper sellerWrapper = checkFastDeliveryAuth(req.getUid());
|
385
|
|
410
|
|
386
|
- // 检查货号and尺寸是否存在
|
|
|
387
|
- List<ProductInfoReq> productInfoReqList = req.getProductInfos().stream().map(x -> {
|
|
|
388
|
- ProductInfoReq productInfoReq = new ProductInfoReq();
|
|
|
389
|
- productInfoReq.setProductCode(x.getProductCode());
|
|
|
390
|
- productInfoReq.setSizeName(x.getSizeName());
|
|
|
391
|
- return productInfoReq;
|
|
|
392
|
- }).distinct().collect(Collectors.toList());
|
411
|
+ // 检查批量上架权限
|
|
|
412
|
+ sellerWrapper = sellerWrapper.attachSellerLevelFunc((sw)->sellerFuncService.getSellerLevelFunc(sw));
|
|
|
413
|
+ sellerAuthCheckService.checkAuth(sellerWrapper.buildSellerBo(), null, SellerFuncEnum.BATCH_PUBLISH);
|
|
|
414
|
+
|
|
|
415
|
+ // 检查货号&尺寸 --> storageId
|
|
|
416
|
+ List<StorageCheckResp> storageCheckRespList = productProxyService.getStorageInfoList(buildStorageReq(req));
|
|
|
417
|
+ StorageCheckResp storageResp = storageCheckRespList.stream().filter(x->x.getStatus()!= StorageCheckEnum.PRODUCT_SIZE_MATCH.getType()).findAny().get();
|
|
|
418
|
+ if (storageResp != null){
|
|
|
419
|
+ logger.warn("productCode {} and sizeName {} invalidate", storageResp.getProductCode(), storageResp.getSizeName());
|
|
|
420
|
+ throw new UfoServiceException(400, "["+getProductCodeSizeNameKey(storageResp.getProductCode(),storageResp.getSizeName())+"]"+storageResp.getStatusStr());
|
|
|
421
|
+ }
|
393
|
|
422
|
|
394
|
- // 调用商品服务获取到商品的storageId
|
|
|
395
|
- // 无法获取则异常
|
423
|
+ Map<String,StorageCheckResp> storageMap = storageCheckRespList.stream().collect(Collectors.toMap(k->getProductCodeSizeNameKey(k.getProductCode(),k.getSizeName()), v->v));
|
396
|
|
424
|
|
397
|
// 上架
|
425
|
// 上架
|
398
|
List<ProductImportTranItemBo> responseList = Lists.newArrayList();
|
426
|
List<ProductImportTranItemBo> responseList = Lists.newArrayList();
|
|
|
427
|
+
|
|
|
428
|
+ // 上架的代码(和之前同)
|
399
|
for(FastDeliveryBatchOnShelfReq.ProductInfo productInfo : req.getProductInfos()){
|
429
|
for(FastDeliveryBatchOnShelfReq.ProductInfo productInfo : req.getProductInfos()){
|
400
|
- Integer storageId = productInfo.getStorageId();
|
|
|
401
|
- BigDecimal salePrice = productInfo.getConvertedPrice();
|
|
|
402
|
- int storageNum = productInfo.getNum();
|
|
|
403
|
- ImPrdNode node = ImPrdNode.builder().uid(uid)
|
430
|
+
|
|
|
431
|
+ StorageCheckResp storage = storageMap.get(storageMap.get(getProductCodeSizeNameKey(productInfo.getProductCode(), productInfo.getSizeName())));
|
|
|
432
|
+ if (storage == null){
|
|
|
433
|
+ logger.warn("productCode {} and sizeName {}. storageId not exist.", productInfo.getProductCode(), productInfo.getSizeName());
|
|
|
434
|
+ throw new UfoServiceException(403, "货号和尺寸对应的storageId不存在");
|
|
|
435
|
+ }
|
|
|
436
|
+
|
|
|
437
|
+ productInfo.setStorageId(storage.getStorageId());
|
|
|
438
|
+
|
|
|
439
|
+ ImPrdNode node = ImPrdNode.builder().uid(req.getUid())
|
404
|
.sellerWrapper(sellerWrapper)
|
440
|
.sellerWrapper(sellerWrapper)
|
405
|
- .storageId(storageId).salePrice(salePrice).storageNum(storageNum).productCode(productInfo.getProductCode()).sizeName(productInfo.getSizeName())
|
441
|
+ .storageId(productInfo.getStorageId())
|
|
|
442
|
+ .salePrice(productInfo.getConvertedPrice())
|
|
|
443
|
+ .storageNum(productInfo.getNum())
|
|
|
444
|
+ .productCode(productInfo.getProductCode())
|
|
|
445
|
+ .sizeName(productInfo.getSizeName())
|
406
|
.skupType(SkupType.FAST_DELIVERY.getCode())
|
446
|
.skupType(SkupType.FAST_DELIVERY.getCode())
|
407
|
.build();
|
447
|
.build();
|
|
|
448
|
+
|
408
|
int successNum=0;
|
449
|
int successNum=0;
|
409
|
try{
|
450
|
try{
|
410
|
SellerOrderSubmitHandler.ForkJoinResult fjr = importPublishExcutor.publishOne(node);
|
451
|
SellerOrderSubmitHandler.ForkJoinResult fjr = importPublishExcutor.publishOne(node);
|
|
@@ -413,7 +454,8 @@ public class ErpFastDeliveryServiceImpl implements IErpFastDeliveryService { |
|
@@ -413,7 +454,8 @@ public class ErpFastDeliveryServiceImpl implements IErpFastDeliveryService { |
413
|
responseList.add(buildShelfResp(req, productInfo, successNum));
|
454
|
responseList.add(buildShelfResp(req, productInfo, successNum));
|
414
|
}catch(Exception ex){
|
455
|
}catch(Exception ex){
|
415
|
logger.warn("in batchOnShelf.publishOne fail, uid {} productCode {} sizeName {} storageId {} salePrice {} storageNum {}",
|
456
|
logger.warn("in batchOnShelf.publishOne fail, uid {} productCode {} sizeName {} storageId {} salePrice {} storageNum {}",
|
416
|
- uid, productInfo.getProductCode(), productInfo.getSizeName(), storageId, salePrice, storageNum);
|
457
|
+ req.getUid(), productInfo.getProductCode(), productInfo.getSizeName(), productInfo.getStorageId(),
|
|
|
458
|
+ productInfo.getConvertedPrice(), productInfo.getNum());
|
417
|
}
|
459
|
}
|
418
|
}
|
460
|
}
|
419
|
|
461
|
|
|
@@ -426,6 +468,45 @@ public class ErpFastDeliveryServiceImpl implements IErpFastDeliveryService { |
|
@@ -426,6 +468,45 @@ public class ErpFastDeliveryServiceImpl implements IErpFastDeliveryService { |
426
|
|
468
|
|
427
|
}
|
469
|
}
|
428
|
|
470
|
|
|
|
471
|
+
|
|
|
472
|
+
|
|
|
473
|
+
|
|
|
474
|
+ private String getProductCodeSizeNameKey(String productCode, String sizeName){
|
|
|
475
|
+
|
|
|
476
|
+ StringBuilder sb = new StringBuilder();
|
|
|
477
|
+ sb.append(productCode);
|
|
|
478
|
+ sb.append("_");
|
|
|
479
|
+ sb.append(sizeName);
|
|
|
480
|
+ return sb.toString();
|
|
|
481
|
+
|
|
|
482
|
+ }
|
|
|
483
|
+ private List<ProductRequestBo> buildStorageReq(FastDeliveryBatchOnShelfReq req) {
|
|
|
484
|
+ return req.getProductInfos().stream().map(x -> {
|
|
|
485
|
+ ProductRequestBo productInfoReq = new ProductRequestBo();
|
|
|
486
|
+ productInfoReq.setProductCode(x.getProductCode());
|
|
|
487
|
+ productInfoReq.setSizeName(x.getSizeName());
|
|
|
488
|
+ return productInfoReq;
|
|
|
489
|
+ }).distinct().collect(Collectors.toList());
|
|
|
490
|
+ }
|
|
|
491
|
+
|
|
|
492
|
+
|
|
|
493
|
+ /**
|
|
|
494
|
+ * 检查极速发货用户权限
|
|
|
495
|
+ * @param uid
|
|
|
496
|
+ * @return
|
|
|
497
|
+ */
|
|
|
498
|
+ public SellerWrapper checkFastDeliveryAuth(int uid){
|
|
|
499
|
+
|
|
|
500
|
+ SellerWrapper sellerWrapper = sellerService.getFullDimensionSeller(uid);
|
|
|
501
|
+ SellerBo sellerBo = sellerWrapper.buildSellerBo();
|
|
|
502
|
+ if (!sellerBo.isFastDeliverySuper()){
|
|
|
503
|
+ logger.warn("checkFastDeliveryAuth not legal super, uid {} ", uid);
|
|
|
504
|
+ throw new UfoServiceException(501, "用户权限不合法!");
|
|
|
505
|
+ }
|
|
|
506
|
+
|
|
|
507
|
+ return sellerWrapper;
|
|
|
508
|
+ }
|
|
|
509
|
+
|
429
|
private ProductImportTranItemBo buildShelfResp(FastDeliveryBatchOnShelfReq req, FastDeliveryBatchOnShelfReq.ProductInfo productInfo, int successNum) {
|
510
|
private ProductImportTranItemBo buildShelfResp(FastDeliveryBatchOnShelfReq req, FastDeliveryBatchOnShelfReq.ProductInfo productInfo, int successNum) {
|
430
|
// 构造结果对象 最终结果插入到 商品服务的product_import_tran_item表中
|
511
|
// 构造结果对象 最终结果插入到 商品服务的product_import_tran_item表中
|
431
|
ProductImportTranItemBo productImportTranItemBo = new ProductImportTranItemBo();
|
512
|
ProductImportTranItemBo productImportTranItemBo = new ProductImportTranItemBo();
|