|
|
@@ -231,8 +231,8 @@ public class ChannelProdServiceImpl extends ServiceImpl<ChannelProdMapper, Chann
|
|
|
if (importVO.getChannelName() == null) {
|
|
|
throw new RuntimeException("渠道不能为空");
|
|
|
}
|
|
|
- if (importVO.getSkuId() == null) {
|
|
|
- throw new RuntimeException("海博商品ID不能为空");
|
|
|
+ if (importVO.getSkuId() == null && importVO.getSkuCode() == null) {
|
|
|
+ throw new RuntimeException("失败原因:海博商品ID和商品编码不能同时为空");
|
|
|
}
|
|
|
if (importVO.getShopName() == null) {
|
|
|
throw new RuntimeException("海博门店不能为空");
|
|
|
@@ -246,17 +246,28 @@ public class ChannelProdServiceImpl extends ServiceImpl<ChannelProdMapper, Chann
|
|
|
Channel channel = channelMapper.selectByName(importVO.getChannelName());
|
|
|
if (ObjectUtil.isEmpty(channel)) {
|
|
|
log.error("渠道:{},在系统中不存在", importVO.getChannelName());
|
|
|
- throw new GlobalException(String.format("第%d行数据导入失败! 失败原因: 渠道=%s,在系统中不存在", i + 2, importVO.getChannelName()));
|
|
|
+ throw new GlobalException(String.format("失败原因: 渠道=%s,在系统中不存在", importVO.getChannelName()));
|
|
|
}
|
|
|
channelProd.setChannelId(channel.getId());
|
|
|
|
|
|
- Sku sku = skuMapper.selectByHbSkuId(importVO.getSkuId());
|
|
|
+ Sku sku = skuMapper.selectOne(new LambdaQueryWrapper<Sku>()
|
|
|
+ .eq(importVO.getSkuId()!=null,Sku::getHbSkuId, importVO.getSkuId())
|
|
|
+ .eq(importVO.getSkuCode()!=null,Sku::getSkuCode, importVO.getSkuCode())
|
|
|
+ .eq(Sku::getIsDelete, 0));
|
|
|
if (ObjectUtil.isEmpty(sku)) {
|
|
|
- log.error("商品ID:{},在系统中不存在", importVO.getSkuId());
|
|
|
-
|
|
|
- throw new GlobalException(String.format("第%d行数据导入失败! 失败原因: 商品ID=%s,在系统中不存在", i + 2, importVO.getSkuId()));
|
|
|
+ if (importVO.getSkuId() != null && importVO.getSkuCode() != null){
|
|
|
+ log.error("商品ID:{} 商品编码:{},在系统中不存在", importVO.getSkuId(), importVO.getSkuCode());
|
|
|
+ throw new GlobalException(String.format("失败原因: 商品ID=%s 商品编码=%s,在系统中不存在", importVO.getSkuId(), importVO.getSkuCode()));
|
|
|
+ }
|
|
|
+ if (importVO.getSkuId() != null){
|
|
|
+ log.error("商品ID:{},在系统中不存在", importVO.getSkuId());
|
|
|
+ throw new GlobalException(String.format("失败原因: 商品ID=%s,在系统中不存在", importVO.getSkuId()));
|
|
|
+ }
|
|
|
+ if (importVO.getSkuCode() != null){
|
|
|
+ log.error("商品编码:{},在系统中不存在", importVO.getSkuCode());
|
|
|
+ throw new GlobalException(String.format("失败原因: 商品编码=%s,在系统中不存在", importVO.getSkuCode()));
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
channelProd.setSkuId(sku.getSkuId());
|
|
|
channelProd.setPurchasePrice(importVO.getPurchasePrice());
|
|
|
channelProd.setDeliveryPrice(importVO.getDeliveryPrice());
|
|
|
@@ -268,7 +279,7 @@ public class ChannelProdServiceImpl extends ServiceImpl<ChannelProdMapper, Chann
|
|
|
ShopDetail shopDetail = shopDetailMapper.selectOne(new LambdaQueryWrapper<ShopDetail>().eq(ShopDetail::getShopName, importVO.getShopName()));
|
|
|
if (ObjectUtil.isEmpty(shopDetail)) {
|
|
|
log.error("门店:{},在系统中不存在", importVO.getShopName());
|
|
|
- throw new GlobalException(String.format("第%d行数据导入失败! 失败原因: 门店=%s,在系统中不存在", i + 2, importVO.getShopName()));
|
|
|
+ throw new GlobalException(String.format("失败原因: 门店=%s,在系统中不存在", importVO.getShopName()));
|
|
|
}
|
|
|
channelProd.setShopId(shopDetail.getShopId());
|
|
|
|
|
|
@@ -301,8 +312,8 @@ public class ChannelProdServiceImpl extends ServiceImpl<ChannelProdMapper, Chann
|
|
|
}
|
|
|
successCount++;
|
|
|
} catch (Exception e) {
|
|
|
- log.error("导入数据失败,行号:{},错误:{}", i + 2, e.getMessage());
|
|
|
- throw new GlobalException(String.format("第%s行数据导入失败:%s", i + 2,e.getMessage()));
|
|
|
+ log.error("导入数据失败,行号:{},错误:{}", i + 3, e.getMessage());
|
|
|
+ throw new GlobalException(String.format("第%s行数据导入失败! %s", i + 3,e.getMessage()));
|
|
|
}
|
|
|
}
|
|
|
return String.format("导入完成,成功:%d条", successCount);
|