fubojin преди 3 дни
родител
ревизия
2821839a68
променени са 1 файла, в които са добавени 16 реда и са изтрити 10 реда
  1. 16 10
      yami-shop-service/src/main/java/com/yami/shop/service/impl/ChannelProdServiceImpl.java

+ 16 - 10
yami-shop-service/src/main/java/com/yami/shop/service/impl/ChannelProdServiceImpl.java

@@ -272,15 +272,6 @@ public class ChannelProdServiceImpl extends ServiceImpl<ChannelProdMapper, Chann
                 channelProd.setChannelProdPrice(importVO.getChannelProdPrice());
                 channelProd.setRecTime(new Date());
 
-//                // 检查是否已存在
-//                int count = channelProdMapper.selectCount(
-//                        new LambdaQueryWrapper<ChannelProd>().eq(ChannelProd::getChannelId, channel.getId())
-//                                .eq(ChannelProd::getSkuId, sku.getSkuId()));
-//                if (count > 0) {
-//                    log.error("渠道:{},在系统中已存在商品ID:{}", importVO.getChannelName(), importVO.getSkuId());
-//                    throw new GlobalException(String.format("第%d行数据导入失败! 失败原因: 渠道=%s,在系统中已存在 商品ID=%s", i + 1, importVO.getChannelName(), importVO.getSkuId()));
-//                }
-
                 //检查门店是否存在
                 ShopDetail shopDetail = shopDetailMapper.selectOne(new LambdaQueryWrapper<ShopDetail>().eq(ShopDetail::getShopName, importVO.getShopName()));
                 if (ObjectUtil.isEmpty(shopDetail)) {
@@ -311,7 +302,7 @@ public class ChannelProdServiceImpl extends ServiceImpl<ChannelProdMapper, Chann
                 if (channelShopCount == 0) {
                     ChannelShop channelShop = new ChannelShop();
                     channelShop.setIsDelete(0);
-                    channelShop.setChannelId(channel.getId());
+                    channelShop.setChannelId(channelProd.getChannelId());
                     channelShop.setShopId(shopDetail.getShopId());
                     channelShopMapper.insert(channelShop);
                     log.info("添加渠道门店关联数据成功");
@@ -377,8 +368,23 @@ public class ChannelProdServiceImpl extends ServiceImpl<ChannelProdMapper, Chann
                 channelProd.setChannelProdPrice(setChannelPriceDto.getChannelProdPrice());
                 channelProd.setRecTime(new Date());
                 channelProdMapper.insert(channelProd);
+
+                //检查门店是否已存在
+                int channelShopCount = channelShopMapper.selectCount(new LambdaQueryWrapper<ChannelShop>()
+                        .eq(ChannelShop::getShopId, updateShannerProdDTO.getShopId())
+                        .eq(ChannelShop::getIsDelete, 0)
+                        .eq(ChannelShop::getChannelId, setChannelPriceDto.getChannelId()));
+                if (channelShopCount == 0) {
+                    ChannelShop channelShop = new ChannelShop();
+                    channelShop.setIsDelete(0);
+                    channelShop.setChannelId(setChannelPriceDto.getChannelId());
+                    channelShop.setShopId(updateShannerProdDTO.getShopId());
+                    channelShopMapper.insert(channelShop);
+                    log.info("添加渠道门店关联数据成功");
+                }
             }
         }
+
     }
 
 }