From 1f09f6daaf73bc83cceb4ae22b862b7b365635cf Mon Sep 17 00:00:00 2001
From: Pu Zhibing <393733352@qq.com>
Date: 星期四, 03 四月 2025 19:59:17 +0800
Subject: [PATCH] 修改反馈文档bug

---
 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopController.java |  198 +++++++++++++++++++++++++++++--------------------
 1 files changed, 118 insertions(+), 80 deletions(-)

diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopController.java
index 438422a..e586a1f 100644
--- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopController.java
+++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopController.java
@@ -18,6 +18,8 @@
 import com.ruoyi.order.vo.OrderSaleNum;
 import com.ruoyi.order.vo.VerifiableShopVo;
 import com.ruoyi.other.api.domain.*;
+import com.ruoyi.other.mapper.ShopBalanceStatementCopyMapper;
+import com.ruoyi.other.mapper.ShopGiveawayTemporaryMapper;
 import com.ruoyi.other.mapper.ShopMapper;
 import com.ruoyi.other.service.*;
 import com.ruoyi.other.util.GeodesyUtil;
@@ -89,6 +91,9 @@
     private TechnicianService technicianService;
     @Resource
     private ReceiverBankChannelService receiverBankChannelService;
+    
+    @Resource
+    private ShopGiveawayTemporaryMapper shopGiveawayTemporaryMapper;
 
 
 
@@ -408,6 +413,10 @@
         return R.ok();
     }
 
+    public static void main(String[] args) {
+        System.out.println("17780483325".substring(5));
+    }
+
 
     @PutMapping("/freezingOrThawing")
     @ApiOperation(value = "门店管理-冻结/解冻门店", tags = {"管理后台-门店管理"})
@@ -678,8 +687,17 @@
     @PostMapping("/getShopIdByName")
     public R<Set<Integer>> getShopIdByName(@RequestParam("shopName") String shopName){
         List<Shop> list = shopService.list(new LambdaQueryWrapper<Shop>()
-                .like(Shop::getName, shopName));
+                .like(Shop::getName, shopName)
+                .eq(Shop::getDelFlag, 0));
         return R.ok(list.stream().map(Shop::getId).collect(Collectors.toSet()));
+    }
+
+    @PostMapping("/getManagerByManagerName")
+    public R<Set<Long>> getManagerByManagerName(@RequestParam("managerName") String managerName){
+        List<Shop> list = shopService.list(new LambdaQueryWrapper<Shop>()
+                .like(Shop::getShopManager, managerName)
+                .eq(Shop::getDelFlag, 0));
+        return R.ok(list.stream().map(Shop::getAppUserId).collect(Collectors.toSet()));
     }
 
     /**
@@ -689,35 +707,20 @@
     @ApiOperation(value = "门店统计", tags = {"管理后台-首页统计"})
     public R<ShopStatistics> shopStatistics(@ApiParam("门店id") Integer shopId) {
         ShopStatistics shopStatistics = shopMapper.getShopStatistics(shopId);
-        List<Integer> shopIds;
-
-        shopIds = shopService.list(new LambdaQueryWrapper<Shop>()
-                        .eq(Shop::getDelFlag, 0)
-                        .eq(shopId !=null,Shop::getId, shopId))
-                .stream()
-                .map(Shop::getId)
-                .collect(Collectors.toList());
-
-
-        if (CollectionUtils.isEmpty(shopIds)){
-            shopStatistics.setTotalOrder(0);
-            shopStatistics.setServiceOrder(0);
-            shopStatistics.setGoodsOrder(0);
-        }else {
-            OrderSaleNum serviceOrderSaleNum = new OrderSaleNum();
-            serviceOrderSaleNum.setShopIds(shopIds);
-            serviceOrderSaleNum.setType(1);
-            Integer serviceOrder = orderClient.getShopSaleNumByShopIds(serviceOrderSaleNum).getData();
-
-            OrderSaleNum goodsOrderSaleNum = new OrderSaleNum();
-            goodsOrderSaleNum.setShopIds(shopIds);
-            goodsOrderSaleNum.setType(2);
-            Integer goodsOrder = orderClient.getShopSaleNumByShopIds(goodsOrderSaleNum).getData();
-
-            shopStatistics.setTotalOrder(serviceOrder + goodsOrder);
-            shopStatistics.setServiceOrder(serviceOrder);
-            shopStatistics.setGoodsOrder(goodsOrder);
-        }
+    
+        OrderSaleNum serviceOrderSaleNum = new OrderSaleNum();
+        serviceOrderSaleNum.setShopIds(null == shopId ? new ArrayList<>() : Arrays.asList(shopId));
+        serviceOrderSaleNum.setType(1);
+        Integer serviceOrder = orderClient.getShopSaleNumByShopIds(serviceOrderSaleNum).getData();
+    
+        OrderSaleNum goodsOrderSaleNum = new OrderSaleNum();
+        goodsOrderSaleNum.setShopIds(null == shopId ? new ArrayList<>() : Arrays.asList(shopId));
+        goodsOrderSaleNum.setType(2);
+        Integer goodsOrder = orderClient.getShopSaleNumByShopIds(goodsOrderSaleNum).getData();
+    
+        shopStatistics.setTotalOrder(serviceOrder + goodsOrder);
+        shopStatistics.setServiceOrder(serviceOrder);
+        shopStatistics.setGoodsOrder(goodsOrder);
         return R.ok(shopStatistics);
     }
     
@@ -808,6 +811,21 @@
         return R.ok();
     }
 
+    @PostMapping("/saveWithdrawalAppletAccount")
+    @ApiOperation(value = "保存提现账户", tags = {"小程序-个人中心-门店管理-门店钱包"})
+    public R saveWithdrawalAppletAccount(@RequestBody SaveWithdrawalAccount saveWithdrawalAccount){
+
+        Shop shop = shopService.getById(saveWithdrawalAccount.getShopId());
+        if(null != shop){
+            shop.setReceiverAccountNoEnc(saveWithdrawalAccount.getReceiverAccountNoEnc());
+            shop.setReceiverNameEnc(saveWithdrawalAccount.getReceiverNameEnc());
+            shop.setReceiverAccountType(saveWithdrawalAccount.getReceiverAccountType());
+            shop.setReceiverBankChannelNo(saveWithdrawalAccount.getReceiverBankChannelNo());
+            shopService.updateById(shop);
+        }
+        return R.ok();
+    }
+
 
     /**
      * 获取所有门店
@@ -833,6 +851,21 @@
     }
 
 
+    @ResponseBody
+    @GetMapping("/verifyAppletConfiguration")
+    @ApiOperation(value = "判断是否有提现账户", tags = {"门店后台-财务管理-提现明细","小程序-个人中心-门店管理-门店钱包"})
+    public R verifyAppletConfiguration(Integer shopId){
+        Shop shop = shopService.getById(shopId);
+        if(StringUtils.hasLength(shop.getReceiverAccountNoEnc())){
+            return R.ok(true);
+        }
+        return R.ok(false);
+    }
+
+
+
+
+
 
     @ResponseBody
     @GetMapping("/getBankSerialNumber")
@@ -855,8 +888,17 @@
         BigDecimal giveawayMoney = BigDecimal.ZERO;
         for (Shop shop : shopList) {
             serverGiveawayMoney = serverGiveawayMoney.add(shop.getServerGiveawayMoney());
-            giveawayMoney = giveawayMoney.add(shop.getGiveawayMoney());
+            giveawayMoney = giveawayMoney.add(shop.getGiveawayMoney().add(shop.getLowerLevelGiveawayMoney()));
         }
+        LambdaQueryWrapper<ShopGiveawayTemporary> wrapper = new LambdaQueryWrapper<>();
+        if(null != shopId && 0 != shopId){
+            wrapper.eq(ShopGiveawayTemporary::getShopId, shopId);
+        }
+        List<ShopGiveawayTemporary> list = shopGiveawayTemporaryMapper.selectList(wrapper);
+        BigDecimal reduce = list.stream().map(ShopGiveawayTemporary::getServerGiveawayMoney).reduce(BigDecimal.ZERO, BigDecimal::add);
+        serverGiveawayMoney = serverGiveawayMoney.add(reduce);
+        BigDecimal reduce1 = list.stream().map(ShopGiveawayTemporary::getGiveawayMoney).reduce(BigDecimal.ZERO, BigDecimal::add);
+        giveawayMoney = giveawayMoney.add(reduce1);
         Map<String, BigDecimal> map = new HashMap<>();
         map.put("serverGiveawayMoney", serverGiveawayMoney);
         map.put("giveawayMoney", giveawayMoney);
@@ -865,67 +907,63 @@
 
     /**
      * 获取指定用户的服务商
-     * @param userId
      * @return
      */
     @GetMapping("/getServiceProvider")
-    public R<Shop> getServiceProvider(Long userId){
-        List<AppUser> allSuperiors = getAllSuperiors(userId);
-        //当前绑定门店的店铺信息(服务商)
-        Shop serviceProvider = null;
-        for (AppUser allSuperior : allSuperiors) {
-            List<Shop> shopList = shopService.lambdaQuery().eq(Shop::getAppUserId, allSuperior.getId()).eq(Shop::getDelFlag,0).list();
-            if (!CollectionUtils.isEmpty(shopList)){
-                serviceProvider = shopList.get(0);
-                break;
+    public R<Shop> getServiceProvider(@RequestParam("appUserId") Long appUserId){
+        //向上找获取第一个开店的门店
+        List<Shop> list = shopService.list(new LambdaQueryWrapper<Shop>().eq(Shop::getDelFlag, 0).eq(Shop::getStatus, 1));
+        AppUser appUser = appUserClient.getAppUserById(appUserId);
+        //上级集合,防止循环关联
+        Set<Long> pid = new HashSet<>();
+        Shop shop = getSuperiorStore(appUser, list, 1, 1, pid);
+        return R.ok(shop);
+    }
+    
+    
+    
+    public Shop getSuperiorStore(AppUser appUser, List<Shop> list, Integer hierarchy, Integer num, Set<Long> pid){
+        if(null == appUser.getInviteUserId()){
+            return null;
+        }
+        if(pid.contains(appUser.getInviteUserId())){
+            return null;
+        }
+        AppUser appUser1 = appUserClient.getAppUserById(appUser.getInviteUserId());
+        if(null != appUser1){
+            Optional<Shop> first = list.stream().filter(shop -> shop.getAppUserId().equals(appUser1.getId())).findFirst();
+            if(first.isPresent()){
+                if(hierarchy.equals(num)){
+                    return first.get();
+                }
+                num++;
             }
         }
-        return R.ok(serviceProvider);
+        return getSuperiorStore(appUser1, list, hierarchy, num, pid);
     }
+
+
+
+
+
+
+
+
+
 
     /**
      * 获取指定用户的高级服务商
      * @return
      */
     @GetMapping("/getSuperiorServiceProvider")
-    public R<Shop> getSuperiorServiceProvider(Long userId){
-        List<AppUser> allSuperiors = getAllSuperiors(userId);
-        Long techerId = null;
-        for (AppUser allSuperior : allSuperiors) {
-            List<Shop> shopList = shopService.lambdaQuery().eq(Shop::getAppUserId, allSuperior.getId()).eq(Shop::getDelFlag,0).list();
-            if (!CollectionUtils.isEmpty(shopList)){
-                techerId = allSuperior.getId();
-                break;
-            }
-        }
-        if (techerId == null){
-            return R.fail("暂无高级服务商");
-        }
-        List<AppUser> allSuperiors1 = getAllSuperiors(techerId);
-        for (AppUser allSuperior : allSuperiors1) {
-            List<Shop> shopList = shopService.lambdaQuery().eq(Shop::getAppUserId, allSuperior.getId()).eq(Shop::getDelFlag,0).list();
-            if (!CollectionUtils.isEmpty(shopList)){
-                return R.ok(shopList.get(0));
-            }
-        }
-        return R.fail("暂无高级服务商");
-    }
-
-
-    public List<AppUser> getAllSuperiors(Long userId) {
-        List<AppUser> allSuperiors = new ArrayList<>();
-
-        // 获取当前用户的直接上级
-        AppUser currentUser = appUserClient.getAppUserById(userId);
-        if (currentUser != null && currentUser.getInviteUserId() != null) {
-            AppUser superior = appUserClient.getAppUserById(currentUser.getInviteUserId());
-            if (superior != null) {
-                allSuperiors.add(superior); // 添加直接上级
-                allSuperiors.addAll(getAllSuperiors(superior.getId())); // 递归添加上级的上级
-            }
-        }
-
-        return allSuperiors;
+    public R<Shop> getSuperiorServiceProvider(@RequestParam("appUserId") Long appUserId){
+        //向上找获取第一个开店的门店
+        List<Shop> list = shopService.list(new LambdaQueryWrapper<Shop>().eq(Shop::getDelFlag, 0).eq(Shop::getStatus, 1));
+        AppUser appUser = appUserClient.getAppUserById(appUserId);
+        //上级集合,防止循环关联
+        Set<Long> pid = new HashSet<>();
+        Shop shop = getSuperiorStore(appUser, list, 2, 1, pid);
+        return R.ok(shop);
     }
 
 }

--
Gitblit v1.7.1