From 1730a7fc4bb96f258d9dc8dec2e629cadbfdefc0 Mon Sep 17 00:00:00 2001 From: Pu Zhibing <393733352@qq.com> Date: 星期三, 18 六月 2025 13:47:42 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/2.0' into 2.0 --- ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/controller/management/MgtShopController.java | 255 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 245 insertions(+), 10 deletions(-) diff --git a/ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/controller/management/MgtShopController.java b/ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/controller/management/MgtShopController.java index 3ef9587..35d06f0 100644 --- a/ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/controller/management/MgtShopController.java +++ b/ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/controller/management/MgtShopController.java @@ -1,6 +1,7 @@ package com.ruoyi.shop.controller.management; import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.utils.poi.ExcelUtil; @@ -12,23 +13,26 @@ import com.ruoyi.shop.domain.vo.*; import com.ruoyi.shop.service.shop.*; import com.ruoyi.system.api.domain.dto.MgtBaseGetDto; +import com.ruoyi.system.api.domain.poji.shop.Shop; +import com.ruoyi.system.api.domain.poji.sys.SysUser; import com.ruoyi.system.api.domain.vo.MgtSimpleShopVo; +import com.ruoyi.system.api.service.RemoteUserService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.io.PrintWriter; +import java.rmi.server.ServerCloneException; +import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; /** * @author jqs34 @@ -61,24 +65,120 @@ @Resource private BankBranchCodeService bankBranchCodeService; - + @Resource + private RemoteUserService sysUserService; @RequestMapping(value = "/listMgtShopSimpleVo", method = RequestMethod.POST) @ApiOperation(value = "获取简易商户列表") public R<List<MgtShopListSimpleVo>> listMgtShopSimpleVo(@RequestBody MgtShopListDto mgtShopListDto) { - List<MgtShopListSimpleVo> mgtShopListSimpleVoList = shopService.listMgtShopSimpleVo(mgtShopListDto); + // 获取当前登陆人的可视权限 + SysUser sysUser = SecurityUtils.getSysUser(); + // 店铺ids + List<Long> scope = new ArrayList<>(); + if (sysUser!=null){ + String dataScope = sysUser.getDataScope(); + if (!sysUser.getUserName().equals("admin")){ + if (org.springframework.util.StringUtils.hasLength(dataScope)){ + switch (dataScope){ + case "3": + // 本部门数据 查询当前登陆人属于哪个部门 查询这个部门下所有员工关联的所有店铺 + // 根据用户id 查询同部门下所有员工id + List<Long> userIds = sysUserService.getUserIdsByDept(sysUser.getUserId()).getData(); + // 店铺ids + List<Long> data = shopService.list(new QueryWrapper<Shop>() + .in("belong_user_id", userIds) + .eq("del_flag", 0)) + .stream().map(Shop::getShopId).collect(Collectors.toList()); + if (data.size()==0){ + scope.add(0L); + }else{ + scope.addAll(data); + } + + break; + case "5": + // 仅个人数据 查询当前登陆人关联店铺下的用户 + List<Long> longs = new ArrayList<>(); + longs.add(sysUser.getUserId()); + // 获取店铺ids + List<Long> data1 = shopService.list(new QueryWrapper<Shop>() + .in("belong_user_id", longs) + .eq("del_flag", 0)) + .stream().map(Shop::getShopId).collect(Collectors.toList()); + if (data1.size()==0){ + scope.add(0L); + }else{ + scope.addAll(data1); + } + break; + } + } + } + } + List<MgtShopListSimpleVo> mgtShopListSimpleVoList = shopService.listMgtShopSimpleVo(mgtShopListDto,scope); return R.ok(mgtShopListSimpleVoList); } @RequestMapping(value = "/pageMgtShop", method = RequestMethod.POST) @ApiOperation(value = "分页获取商户列表") public R<Page<MgtShopPageVo>> pageMgtShop(@RequestBody MgtShopPageDto mgtShopPageDto) { + // 获取当前登陆人的可视权限 + SysUser sysUser = SecurityUtils.getSysUser(); + // 店铺ids + List<Long> scope = new ArrayList<>(); + if (sysUser!=null){ + String dataScope = sysUser.getDataScope(); + if (!sysUser.getUserName().equals("admin")){ + if (org.springframework.util.StringUtils.hasLength(dataScope)){ + switch (dataScope){ + case "3": + // 本部门数据 查询当前登陆人属于哪个部门 查询这个部门下所有员工关联的所有店铺 + // 根据用户id 查询同部门下所有员工id + List<Long> userIds = sysUserService.getUserIdsByDept(sysUser.getUserId()).getData(); + // 店铺ids + List<Long> data = shopService.list(new QueryWrapper<Shop>() + .in("belong_user_id", userIds) + .eq("del_flag", 0)) + .stream().map(Shop::getShopId).collect(Collectors.toList()); + if (data.size()==0){ + scope.add(0L); + }else{ + scope.addAll(data); + } + + break; + case "5": + // 仅个人数据 查询当前登陆人关联店铺下的用户 + List<Long> longs = new ArrayList<>(); + longs.add(sysUser.getUserId()); + // 获取店铺ids + List<Long> data1 = shopService.list(new QueryWrapper<Shop>() + .in("belong_user_id", longs) + .eq("del_flag", 0)) + .stream().map(Shop::getShopId).collect(Collectors.toList()); + if (data1.size()==0){ + scope.add(0L); + }else{ + scope.addAll(data1); + } + break; + } + } + } + } + if(null != mgtShopPageDto.getDeptId()){ + R<List<SysUser>> r = sysUserService.getUsersByDeptId(mgtShopPageDto.getDeptId()); + List<Long> collect = r.getData().stream().map(SysUser::getUserId).collect(Collectors.toList()); + List<Shop> shops = shopService.getShopBySysUserIds(collect); + scope.addAll(shops.stream().map(Shop::getShopId).collect(Collectors.toList())); + } + Page<MgtShopPageVo> page = new Page<>(); page.setSize(mgtShopPageDto.getPageSize()); page.setCurrent(mgtShopPageDto.getPageNum()); - List<MgtShopPageVo> mgtShopPageVoList = shopService.pageMgtShop(page,mgtShopPageDto); + List<MgtShopPageVo> mgtShopPageVoList = shopService.pageMgtShop(page,mgtShopPageDto,scope); return R.ok(page.setRecords(mgtShopPageVoList)); } @@ -93,7 +193,48 @@ page.setSize(mgtShopPageDto.getPageSize()); page.setCurrent(mgtShopPageDto.getPageNum()); } - List<MgtShopPageVo> mgtShopPageVoList = shopService.pageMgtShop(page,mgtShopPageDto); + // 获取当前登陆人的可视权限 + SysUser sysUser = SecurityUtils.getSysUser(); + // 店铺ids + List<Long> scope = new ArrayList<>(); + if (sysUser!=null){ + String dataScope = sysUser.getDataScope(); + if (!sysUser.getUserName().equals("admin")){ + if (org.springframework.util.StringUtils.hasLength(dataScope)){ + switch (dataScope){ + case "3": + // 本部门数据 查询当前登陆人属于哪个部门 查询这个部门下所有员工关联的所有店铺 + // 根据用户id 查询同部门下所有员工id + List<Long> userIds = sysUserService.getUserIdsByDept(sysUser.getUserId()).getData(); + // 店铺ids + List<Long> data = shopService.list(new QueryWrapper<Shop>() + .in("belong_user_id", userIds) + .eq("del_flag", 1)) + .stream().map(Shop::getShopId).collect(Collectors.toList()); + scope.addAll(data); + break; + case "5": + // 仅个人数据 查询当前登陆人关联店铺下的用户 + List<Long> longs = new ArrayList<>(); + longs.add(sysUser.getUserId()); + // 获取店铺ids + List<Long> data1 = shopService.list(new QueryWrapper<Shop>() + .in("belong_user_id", longs) + .eq("del_flag", 1)) + .stream().map(Shop::getShopId).collect(Collectors.toList()); + scope.addAll(data1); + break; + } + } + } + } + if(null != mgtShopPageDto.getDeptId()){ + R<List<SysUser>> r = sysUserService.getUsersByDeptId(mgtShopPageDto.getDeptId()); + List<Long> collect = r.getData().stream().map(SysUser::getUserId).collect(Collectors.toList()); + List<Shop> shops = shopService.getShopBySysUserIds(collect); + scope.addAll(shops.stream().map(Shop::getShopId).collect(Collectors.toList())); + } + List<MgtShopPageVo> mgtShopPageVoList = shopService.pageMgtShop(page,mgtShopPageDto,scope); ExcelUtil<MgtShopPageVo> util = new ExcelUtil<MgtShopPageVo>(MgtShopPageVo.class); util.exportExcel(response, mgtShopPageVoList, "商户列表"); } @@ -282,7 +423,51 @@ Page<MgtShopAuthPageVo> page = new Page<>(); page.setSize(mgtShopAuthPageDto.getPageSize()); page.setCurrent(mgtShopAuthPageDto.getPageNum()); - List<MgtShopAuthPageVo> mgtShopAuthPageVoList = shopService.pageMgtShopAuth(page,mgtShopAuthPageDto); + // 获取当前登陆人的可视权限 + SysUser sysUser = SecurityUtils.getSysUser(); + // 店铺ids + List<Long> scope = new ArrayList<>(); + if (sysUser!=null){ + String dataScope = sysUser.getDataScope(); + if (!sysUser.getUserName().equals("admin")){ + if (org.springframework.util.StringUtils.hasLength(dataScope)){ + switch (dataScope){ + case "3": + // 本部门数据 查询当前登陆人属于哪个部门 查询这个部门下所有员工关联的所有店铺 + // 根据用户id 查询同部门下所有员工id + List<Long> userIds = sysUserService.getUserIdsByDept(sysUser.getUserId()).getData(); + // 店铺ids + List<Long> data = shopService.list(new QueryWrapper<Shop>() + .in("belong_user_id", userIds) + .eq("del_flag", 0)) + .stream().map(Shop::getShopId).collect(Collectors.toList()); + if (data.size()==0){ + scope.add(0L); + }else{ + scope.addAll(data); + } + + break; + case "5": + // 仅个人数据 查询当前登陆人关联店铺下的用户 + List<Long> longs = new ArrayList<>(); + longs.add(sysUser.getUserId()); + // 获取店铺ids + List<Long> data1 = shopService.list(new QueryWrapper<Shop>() + .in("belong_user_id", longs) + .eq("del_flag", 0)) + .stream().map(Shop::getShopId).collect(Collectors.toList()); + if (data1.size()==0){ + scope.add(0L); + }else{ + scope.addAll(data1); + } + break; + } + } + } + } + List<MgtShopAuthPageVo> mgtShopAuthPageVoList = shopService.pageMgtShopAuth(page,mgtShopAuthPageDto,scope); return R.ok(page.setRecords(mgtShopAuthPageVoList)); } @@ -325,10 +510,53 @@ @RequestMapping(value = "/pageMgtShopHFTXAuth", method = RequestMethod.POST) @ApiOperation(value = "分页获取商户进件列表(汇付天下)") public R<Page<MgtShopHFTXAuthPageVo>> pageMgtShopHFTXAuth(@RequestBody MgtShopHFTXAuthPageDto mgtShopAuthPageDto) { + // 获取当前登陆人的可视权限 + SysUser sysUser = SecurityUtils.getSysUser(); + // 店铺ids + List<Long> scope = new ArrayList<>(); + if (sysUser!=null){ + String dataScope = sysUser.getDataScope(); + if (!sysUser.getUserName().equals("admin")){ + if (org.springframework.util.StringUtils.hasLength(dataScope)){ + switch (dataScope){ + case "3": + // 本部门数据 查询当前登陆人属于哪个部门 查询这个部门下所有员工关联的所有店铺 + // 根据用户id 查询同部门下所有员工id + List<Long> userIds = sysUserService.getUserIdsByDept(sysUser.getUserId()).getData(); + // 店铺ids + List<Long> data = shopService.list(new QueryWrapper<Shop>() + .in("belong_user_id", userIds) + .eq("del_flag", 0)) + .stream().map(Shop::getShopId).collect(Collectors.toList()); + if (data.size()==0){ + scope.add(0L); + }else{ + scope.addAll(data); + } + break; + case "5": + // 仅个人数据 查询当前登陆人关联店铺下的用户 + List<Long> longs = new ArrayList<>(); + longs.add(sysUser.getUserId()); + // 获取店铺ids + List<Long> data1 = shopService.list(new QueryWrapper<Shop>() + .in("belong_user_id", longs) + .eq("del_flag", 0)) + .stream().map(Shop::getShopId).collect(Collectors.toList()); + if (data1.size()==0){ + scope.add(0L); + }else{ + scope.addAll(data1); + } + break; + } + } + } + } Page<MgtShopHFTXAuthPageVo> page = new Page<>(); page.setSize(mgtShopAuthPageDto.getPageSize()); page.setCurrent(mgtShopAuthPageDto.getPageNum()); - List<MgtShopHFTXAuthPageVo> mgtShopHFTXAuthPageVos = shopService.pageMgtShopHFTXAuth(page, mgtShopAuthPageDto); + List<MgtShopHFTXAuthPageVo> mgtShopHFTXAuthPageVos = shopService.pageMgtShopHFTXAuth(page, mgtShopAuthPageDto,scope); return R.ok(page.setRecords(mgtShopHFTXAuthPageVos)); } @@ -402,4 +630,11 @@ List<Map<String, String>> bankBranchCode = bankBranchCodeService.getBankBranchCode(dto.getBankNumber()); return R.ok(bankBranchCode); } + + @RequestMapping(value = "/changeShopType", method = RequestMethod.GET) + @ApiOperation(value = "修改商户类型(转为经销商,转为加盟商)【2.0】") + public R<Void> changeShopType(@RequestParam Long shopId){ + return shopService.changeShopType(shopId); + } + } -- Gitblit v1.7.1