From 1af77abfa06a1a0d537bb120ae0c362aae9d3b83 Mon Sep 17 00:00:00 2001
From: huliguo <2023611923@qq.com>
Date: 星期三, 30 七月 2025 10:14:40 +0800
Subject: [PATCH] bug修改

---
 ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/service/impl/shop/ShopServiceImpl.java |   69 +++++++++++++++++++++++++---------
 1 files changed, 51 insertions(+), 18 deletions(-)

diff --git a/ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/service/impl/shop/ShopServiceImpl.java b/ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/service/impl/shop/ShopServiceImpl.java
index a03ddfd..75a34d8 100644
--- a/ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/service/impl/shop/ShopServiceImpl.java
+++ b/ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/service/impl/shop/ShopServiceImpl.java
@@ -245,13 +245,15 @@
             shopRelTagService.deleteByShopId(shop.getShopId());
             shopRelUserService.deleteByShopId(shop.getShopId());
             //默认登录账号开关 开启后原默认账号开关关闭
-            List<Long> openIdList = Arrays.stream(mgtEditShopDto.getRelUserOpenIds().split(","))
-                    .map(String::trim)
-                    .filter(StringUtils::isNotBlank)
-                    .map(Long::valueOf)
-                    .collect(Collectors.toList());
-            if ( !openIdList.isEmpty()) {
-                shopRelUserService.setDefaultCloseByUserIdList(openIdList);
+            if(StringUtils.isNotEmpty(mgtEditShopDto.getRelUserOpenIds())){
+                List<Long> openIdList = Arrays.stream(mgtEditShopDto.getRelUserOpenIds().split(","))
+                        .map(String::trim)
+                        .filter(StringUtils::isNotBlank)
+                        .map(Long::valueOf)
+                        .collect(Collectors.toList());
+                if ( !openIdList.isEmpty()) {
+                    shopRelUserService.setDefaultCloseByUserIdList(openIdList);
+                }
             }
 
             //清空归属
@@ -317,7 +319,10 @@
             handleShopStaff(shop.getShopId(),belongSysUser);
         }*/
         //商户关联人员
-        String[] openIds = mgtEditShopDto.getRelUserOpenIds().split(",");//开启默认登录账号
+        String[] openIds = null;
+        if(StringUtils.isNotEmpty(mgtEditShopDto.getRelUserOpenIds())){
+            openIds = mgtEditShopDto.getRelUserOpenIds().split(",");//开启默认登录账号
+        }
         if(StringUtils.isNotBlank(relUserIds)){
             shopStaffService.clearShopStaffRelation(shop.getShopId());
             String[] relUserIdArray = relUserIds.split(",");
@@ -334,7 +339,7 @@
                 shopRelUser.setUserName(sysUser.getNickName());
                 shopRelUser.setUserMobile(sysUser.getPhonenumber());
                 shopRelUser.setUserDeptId(sysUser.getDeptId());
-                shopRelUser.setIsDefault((openIds.length > 0  && Arrays.asList(openIds).contains(str)) ? 1 : 0);
+                shopRelUser.setIsDefault((null != openIds && openIds.length > 0  && Arrays.asList(openIds).contains(str)) ? 1 : 0);
                 shopRelUserService.save(shopRelUser);
                 handleShopStaff(shop.getShopId(),sysUser);
             }
@@ -406,10 +411,10 @@
         shopProportion.setDelFlag(0);
         shopProportion.setShopId(shop.getShopId());
         shopProportion.setShopType(shop.getShopType());
+        BigDecimal proportionPercent = new BigDecimal("30");
         String proportionPercentStr = redisService.getCacheObject(SecurityConstant.SHOP_COMMON_PROPORTION);
-        BigDecimal proportionPercent = new BigDecimal(proportionPercentStr);
-        if(proportionPercent==null){
-            proportionPercent = new BigDecimal("30");
+        if(StringUtils.isNotEmpty(proportionPercentStr)){
+            proportionPercent = new BigDecimal(proportionPercentStr);
         }
         shopProportion.setProportionPercent(proportionPercent);
         shopProportion.setUpdateTime(new Date());
@@ -964,13 +969,13 @@
         MerHomeShopTotalVo orderVo = remoteOrderService.getMerHomeTotal(merHomeShopTotalVo).getData();
         merHomeShopTotalVo.setShopId(shopId);
         merHomeShopTotalVo.setShopType(shop.getShopType());
-        merHomeShopTotalVo.setTodayShop(orderVo.getTodayShop());
-        merHomeShopTotalVo.setUnHandleOrder(orderVo.getUnHandleOrder());
+        merHomeShopTotalVo.setTodayShop(null == orderVo ? 0: orderVo.getTodayShop());
+        merHomeShopTotalVo.setUnHandleOrder(null == orderVo ? 0: orderVo.getUnHandleOrder());
         List<Integer> taskCount = memberTaskService.getMemberIngTotal(shopId);
         merHomeShopTotalVo.setTask(taskCount.size());
-        merHomeShopTotalVo.setShopTurnover(orderVo.getShopTurnover());
-        merHomeShopTotalVo.setCycleSurp(orderVo.getCycleSurp());
-        merHomeShopTotalVo.setExplorationSurp(orderVo.getExplorationSurp());
+        merHomeShopTotalVo.setShopTurnover(null == orderVo ? BigDecimal.ZERO : orderVo.getShopTurnover());
+        merHomeShopTotalVo.setCycleSurp(null == orderVo ? 0: orderVo.getCycleSurp());
+        merHomeShopTotalVo.setExplorationSurp(null == orderVo ? 0: orderVo.getExplorationSurp());
         merHomeShopTotalVo.setPlatformBirthdayFlag(shop.getPlatformBirthdayFlag());
         merHomeShopTotalVo.setPlatformCouponFlag(shop.getPlatformCouponFlag());
         int unHandleReserve = shopAppointableTimeService.count(new LambdaQueryWrapper<TShopAppointableTime>().eq(TShopAppointableTime::getShopId, shopId).eq(TShopAppointableTime::getStatus, 1));
@@ -1993,6 +1998,21 @@
         if (shop.getShopType()==2){
             //经销商转加盟商:  先解绑该经销商下所有加盟商
             shopMapper.setBelongShopIdNull(shopId);
+        } else {
+            //该加盟商所属区域下的加盟商 改为该新转换的经销商
+            List<String> areaCodes = Optional.ofNullable(shop.getSignAreaCode())
+                    .map(codes -> codes.split(";"))
+                    .map(Arrays::asList)
+                    .orElse(Collections.emptyList());//签约区域
+            if (!areaCodes.isEmpty()){
+                // 1. 查询符合条件的加盟商列表
+                List<Long> shopIds = shopMapper.getShopListBySignAreaCodes(areaCodes);
+
+                // 2. 批量更新(优化性能,避免循环中单条更新)
+                if(null != shopIds && !shopIds.isEmpty()){
+                    shopMapper.updateBelongShopIdBatch(shopIds,shop.getShopId());
+                }
+            }
         }
         shop.setUpdateUserId(SecurityUtils.getUserId());
         shopMapper.updateById(shop);
@@ -2047,11 +2067,24 @@
                         .setDelFlag(0));
             }
         }
-        shopFileService.saveBatch(coverUrlList);
+        shopFileService.saveBatch(bannerList);
 
         //批量修改门店信息
         oneClinkSyncing.setShopIdList(shopIdList);
         shopMapper.updateShopByOneClinkSyncing(oneClinkSyncing);
         return R.ok();
     }
+
+    @Override
+    public List<String> getRelUserShop(Long userId) {
+        List<ShopRelUser> shopRelUserList = shopRelUserService.getByUserId(userId);
+        List<Long> shopIds = shopRelUserList.stream().map(ShopRelUser::getShopId).collect(Collectors.toList());
+        if(!shopIds.isEmpty()){
+            List<Shop> shops = shopMapper.selectList(new LambdaQueryWrapper<Shop>()
+                    .ne(Shop::getShopStatus,-1)
+                    .in(Shop::getShopId,shopIds));
+            return shops.stream().map(Shop::getShopName).collect(Collectors.toList());
+        }
+        return null;
+    }
 }

--
Gitblit v1.7.1