From 3a12bbdaab43d249887683223191e57f1092d377 Mon Sep 17 00:00:00 2001
From: puzhibing <393733352@qq.com>
Date: 星期二, 23 一月 2024 10:56:16 +0800
Subject: [PATCH] 新增加管理后台数据权限

---
 ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/service/impl/shop/ShopServiceImpl.java |   53 ++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 48 insertions(+), 5 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 f8c3ec3..7dc14fa 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
@@ -556,8 +556,21 @@
         if (StringUtils.isNotBlank(mgtShopPageDto.getShopTags())) {
             mgtShopPageDto.setShopTags(mgtShopPageDto.getShopTags().replace(",", "|"));
         }
+        List<Long> belongUserIds = null;
+        if(null != mgtShopPageDto.getDeptId()){
+            if(null != mgtShopPageDto.getBelongUserId()){
+                belongUserIds = new ArrayList<>();
+                belongUserIds.add(mgtShopPageDto.getBelongUserId());
+            }else{
+                R<List<SysUser>> r = sysUserService.getUsersByDeptId(mgtShopPageDto.getDeptId());
+                if(r.getCode() != 200){
+                    throw new RuntimeException(r.getMsg());
+                }
+                belongUserIds = r.getData().stream().map(SysUser::getUserId).collect(Collectors.toList());
+            }
+        }
         // 分页查询商铺信息
-        List<MgtShopPageVo> mgtShopPageVoList = shopMapper.pageMgtShop(page, mgtShopPageDto);
+        List<MgtShopPageVo> mgtShopPageVoList = shopMapper.pageMgtShop(page, mgtShopPageDto, belongUserIds);
         // 如果查询结果不为空
         if (!mgtShopPageVoList.isEmpty()) {
             // 创建签约用户ID集合和所属用户ID集合
@@ -599,8 +612,9 @@
                     shopPageVo.setSignUser(signUserMap.get(shopPageVo.getSignUserId()).getNickName());
                 }
                 if (belongUserMap!=null&&!belongUserMap.isEmpty()&&shopPageVo.getBelongUserId() != null) {
-                    shopPageVo.setBelongUser(belongUserMap.get(shopPageVo.getBelongUserId()).getNickName());
-                    shopPageVo.setBelongDept(belongUserMap.get(shopPageVo.getBelongUserId()).getDeptName());
+                    MgtSysSimpleUserVo mgtSysSimpleUserVo = belongUserMap.get(shopPageVo.getBelongUserId());
+                    shopPageVo.setBelongUser(null == mgtSysSimpleUserVo ? "" : mgtSysSimpleUserVo.getNickName());
+                    shopPageVo.setBelongDept(null == mgtSysSimpleUserVo ? "" : mgtSysSimpleUserVo.getDeptName());
                 }
             }
         }
@@ -1103,8 +1117,8 @@
      * @date 2023/6/18 16:59
      */
     @Override
-    public MgtBulletinBoardVo boardShopTotal(){
-        MgtBulletinBoardVo mgtBulletinBoardVoShop = shopMapper.shopTotal();
+    public MgtBulletinBoardVo boardShopTotal(List<Long> userIds){
+        MgtBulletinBoardVo mgtBulletinBoardVoShop = shopMapper.shopTotal(userIds);
         return mgtBulletinBoardVoShop;
     }
 
@@ -1900,4 +1914,33 @@
         Integer pageSize = merchantBasicdataSettlementDto.getPageSize();
         return HuiFuTianXiaUtil.getMerchantBasicdataSettlement(IdUtils.simpleUUID(), huifuId, startTime, endTime, pageNum.toString(), pageSize.toString());
     }
+
+
+
+    /**
+     * @description
+     * @author  jqs
+     * @date    2023/8/10 22:53
+     * @param cityCodes
+     * @return  List<Long>
+     */
+    @Override
+    public List<Shop> listShopByCityCode(List<String> cityCodes){
+        return shopMapper.listShopByCityCode(cityCodes);
+    }
+
+
+    /**
+     * 根据员工id获取对应的门店
+     * @param userIds
+     * @return
+     */
+    @Override
+    public List<Shop> getShopBySysUserIds(List<Long> userIds) {
+        if(userIds.size() == 0){
+            userIds.add(0L);
+        }
+        List<Shop> list = this.list(new QueryWrapper<Shop>().eq("del_flag", 0).ne("shop_status", -1).in("belong_user_id", userIds));
+        return list;
+    }
 }

--
Gitblit v1.7.1