gaoluyang
2026-10-26 bac50872dc8d80fd8c3879f02aa98084db4d6cc8
fix(basic): 超级管理员查询客户不再受领用/共享范围限制

销项发票等页面的客户下拉走 /basic/customer/list?type=0,私海查询只返回
usage_user/create_user/共享名单中命中当前用户的数据,管理员(user_id=1)
没有领用记录,导致客户列表为空、详情页客户无法回显。

- listPage / list 两处私海查询条件:loginUserId 为空时只按私海/公海过滤
- CustomerServiceImpl:超级管理员(SysUser.isAdmin)传空 loginUserId
- 普通用户逻辑不变,仍按领用/共享范围过滤

Co-Authored-By: Claude Code <noreply@anthropic.com>
已修改2个文件
25 ■■■■■ 文件已修改
src/main/java/com/ruoyi/basic/service/impl/CustomerServiceImpl.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/basic/CustomerMapper.xml 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/basic/service/impl/CustomerServiceImpl.java
@@ -129,7 +129,8 @@
    @Override
    public IPage<CustomerVo> selectCustomerList(Page<CustomerDto> page, CustomerDto customer) {
        LoginUser loginUser = SecurityUtils.getLoginUser();
        Long loginUserId = loginUser.getUserId();
        // 超级管理员不受客户领用/共享范围限制,可查看全部客户
        Long loginUserId = isSuperAdmin(loginUser) ? null : loginUser.getUserId();
        IPage<CustomerVo> customerPage = customerMapper.listPage(page, customer, loginUserId);
        List<CustomerVo> records = customerPage.getRecords();
@@ -280,10 +281,16 @@
    @Override
    public List<CustomerVo> selectCustomerLists(CustomerDto customer) {
        LoginUser loginUser = SecurityUtils.getLoginUser();
        Long loginUserId = loginUser.getUserId();
        // 超级管理员不受客户领用/共享范围限制,可导出全部客户
        Long loginUserId = isSuperAdmin(loginUser) ? null : loginUser.getUserId();
        return customerMapper.list(customer, loginUserId);
    }
    /** 超级管理员:不受客户领用/共享范围限制 */
    private boolean isSuperAdmin(LoginUser loginUser) {
        return loginUser != null && loginUser.getUser() != null && loginUser.getUser().isAdmin();
    }
    @Override
    public R importData(MultipartFile file, Integer type) {
        try {
src/main/resources/mapper/basic/CustomerMapper.xml
@@ -45,8 +45,9 @@
            </if>
            <!-- 私海查询:type = 0(私海客户)或者 type = 1(公海客户)且已被分配,并且是自己领用、自己创建或者共享给自己的客户 -->
            <if test="c.type != null and c.type == 0">
                and (
                    (type = #{c.type} or (type = 1 and is_assigned = 1))
                and (type = #{c.type} or (type = 1 and is_assigned = 1))
                <!-- loginUserId 为空表示超级管理员,不受领用/共享范围限制 -->
                <if test="loginUserId != null">
                    and (
                        c.usage_user = #{loginUserId}
                        or c.create_user = #{loginUserId}
@@ -56,7 +57,7 @@
                            and cu.user_id = #{loginUserId}
                        )
                    )
                )
                </if>
            </if>
        </where>
        order by c.id desc
@@ -107,8 +108,9 @@
            </if>
            <!-- 私海查询:type = 0(私海客户)或者 type = 1(公海客户)且已被分配,并且是自己领用、自己创建或者共享给自己的客户 -->
            <if test="c.type != null and c.type == 0">
                and (
                    (type = #{c.type} or (type = 1 and is_assigned = 1))
                and (type = #{c.type} or (type = 1 and is_assigned = 1))
                <!-- loginUserId 为空表示超级管理员,不受领用/共享范围限制 -->
                <if test="loginUserId != null">
                    and (
                        c.usage_user = #{loginUserId}
                        or c.create_user = #{loginUserId}
@@ -118,7 +120,7 @@
                            and cu.user_id = #{loginUserId}
                        )
                    )
                )
                </if>
            </if>
        </where>
        order by c.id desc