puzhibing
2024-01-26 7b772959ec96e54a52c1750ebaa7a4409e08e81a
ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/order/OrderServiceImpl.java
@@ -3031,7 +3031,9 @@
        }
        //数据权限
        List<Long> userId = remoteUserService.getScopeOfAuthorityUserId();
        List<Shop> shops = remoteShopService.getShopBySysUserIds(userId);
        BoardMemberTotalDto boardMemberTotalDto = new BoardMemberTotalDto();
        boardMemberTotalDto.setUserIds(userId);
        List<Shop> shops = remoteShopService.getShopBySysUserIds(boardMemberTotalDto);
        if (!shops.isEmpty()) {
            List<Long> collect = shops.stream().map(Shop::getShopId).collect(Collectors.toList());
            String join = collect.stream().map(Object::toString).collect(Collectors.joining(","));
@@ -3126,7 +3128,9 @@
        }
        //数据权限
        List<Long> userId = remoteUserService.getScopeOfAuthorityUserId();
        List<Shop> shops = remoteShopService.getShopBySysUserIds(userId);
        BoardMemberTotalDto boardMemberTotalDto = new BoardMemberTotalDto();
        boardMemberTotalDto.setUserIds(userId);
        List<Shop> shops = remoteShopService.getShopBySysUserIds(boardMemberTotalDto);
        if (!shops.isEmpty()) {
            List<Long> collect = shops.stream().map(Shop::getShopId).collect(Collectors.toList());
            String join = collect.stream().map(Object::toString).collect(Collectors.joining(","));
@@ -3187,7 +3191,9 @@
        }
        //数据权限
        List<Long> userId = remoteUserService.getScopeOfAuthorityUserId();
        List<Shop> shops = remoteShopService.getShopBySysUserIds(userId);
        BoardMemberTotalDto boardMemberTotalDto = new BoardMemberTotalDto();
        boardMemberTotalDto.setUserIds(userId);
        List<Shop> shops = remoteShopService.getShopBySysUserIds(boardMemberTotalDto);
        if (!shops.isEmpty()) {
            List<Long> collect = shops.stream().map(Shop::getShopId).collect(Collectors.toList());
            String join = collect.stream().map(Object::toString).collect(Collectors.joining(","));
@@ -3360,7 +3366,9 @@
     */
    @Override
    public MgtBulletinBoardVo boardOrderTotal(List<Long> userIds) {
        List<Shop> shopList = remoteShopService.getShopBySysUserIds(userIds);
        BoardMemberTotalDto boardMemberTotalDto = new BoardMemberTotalDto();
        boardMemberTotalDto.setUserIds(userIds);
        List<Shop> shopList = remoteShopService.getShopBySysUserIds(boardMemberTotalDto);
        List<Long> collect = shopList.stream().map(Shop::getShopId).collect(Collectors.toList());
        MgtBulletinBoardVo mgtBulletinBoardVo = orderMapper.boardOrderTotal(collect);
        Integer activityUserTotal = orderMapper.activityUserTotal(collect);
@@ -3870,6 +3878,19 @@
                mgtBasePlatformDto.setUserIdList(userIdList);
            }
        }
        //数据权限
        List<Long> userIds = remoteUserService.getScopeOfAuthorityUserId();
        if(null != userIds){
            List<Long> userIdList = mgtBasePlatformDto.getUserIdList();
            if(null != userIdList){
                userIdList.addAll(userIds);
            }else{
                userIdList = userIds;
            }
            mgtBasePlatformDto.setUserIdList(userIdList);
        }
        List<Long> shopIdList = new ArrayList<>();
        if(mgtBasePlatformDto.getShopId()!=null){
            shopIdList.add(mgtBasePlatformDto.getShopId());
@@ -3923,16 +3944,65 @@
            List<Long> userIdList = new ArrayList<>();
            if (mgtBasePlatformDto.getUserId() != null) {
                userIdList.add(mgtBasePlatformDto.getUserId());
            } else {
                MgtUserIdByDept mgtUserIdByDept = new MgtUserIdByDept();
                mgtUserIdByDept.setDeptId(mgtBasePlatformDto.getUserId());
                mgtUserIdByDept = remoteConfigService.getUserIdByDept(mgtUserIdByDept).getData();
                userIdList = mgtUserIdByDept.getUserIdList();
            }
            else {
                // 如果当前登陆人的可视权限是仅个人 只选择了部门也只能看自己的数据
                SysUser sysUser = SecurityUtils.getSysUser();
                if (sysUser.getDataScope().equals("5")){
                    userIdList.add(sysUser.getUserId());
                }else{
                    MgtUserIdByDept mgtUserIdByDept = new MgtUserIdByDept();
                    mgtUserIdByDept.setDeptId(mgtBasePlatformDto.getDeptId());
                    mgtUserIdByDept = remoteConfigService.getUserIdByDept(mgtUserIdByDept).getData();
                    userIdList = mgtUserIdByDept.getUserIdList();
                }
            }
            if (!userIdList.isEmpty()) {
                mgtBasePlatformDto.setUserIdList(userIdList);
            }
        }else{
            // 没有选择筛选部门和员工 获取当前登陆人的可视权限
            SysUser sysUser = SecurityUtils.getSysUser();
            // 如果当前登陆人是查看个人数据
            Long userId1  = null;
            // 如果当前登陆人权限是查看部门数据
            List<Long> userList = 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":
                                // 本部门数据 查询当前登陆人属于哪个部门 查询这个部门下所有员工关联的所有店铺
                                MgtUserIdByDept mgtUserIdByDept = new MgtUserIdByDept();
                                mgtUserIdByDept.setDeptId(sysUser.getDeptId());
                                mgtUserIdByDept = remoteConfigService.getUserIdByDept(mgtUserIdByDept).getData();
                                userList = mgtUserIdByDept.getUserIdList();
                                mgtBasePlatformDto.setDeptId(sysUser.getDeptId());
                                mgtBasePlatformDto.setUserIdList(userList);
                            case "5":
                                // 仅个人数据 查询当前登陆人关联店铺下的用户
                                userId1 = sysUser.getUserId();
                                userList.add(userId1);
                                mgtBasePlatformDto.setDeptId(sysUser.getDeptId());
                                mgtBasePlatformDto.setUserIdList(userList);
                                break;
                        }
                    }
                }
            }
        }
        //数据权限
        List<Long> userIdList = mgtBasePlatformDto.getUserIdList();
        List<Long> userIds = remoteUserService.getScopeOfAuthorityUserId();
        if(null != userIdList){
            userIdList.addAll(userIds);
        }else{
            userIdList = userIds;
        }
        mgtBasePlatformDto.setUserIdList(userIdList);
        MgtTotalOrderTotalVo mgtTotalOrderTotalVo = new MgtTotalOrderTotalVo();
        mgtTotalOrderTotalVo.setOrderTotal(0);
        mgtTotalOrderTotalVo.setOnlineTotal(0);
@@ -3957,6 +4027,7 @@
        mgtTotalOrderTotalVo.setGoodsTypeMoneyList(Lists.newArrayList());
        mgtTotalOrderTotalVo.setGoodsRankList(Lists.newArrayList());
        mgtTotalOrderTotalVo.setOrderFromRankList(Lists.newArrayList());
        List<Long> shopIdList = remoteShopService.listShopIdByPlTotal(mgtBasePlatformDto).getData();
        if (mgtBasePlatformDto.getUserId() != null || StringUtils.isNotBlank(mgtBasePlatformDto.getShopProvinceCode()) || StringUtils.isNotBlank(mgtBasePlatformDto.getShopCityCode()) || StringUtils.isNotBlank(mgtBasePlatformDto.getShopAreaCode())) {
            if(shopIdList==null||shopIdList.isEmpty()){
@@ -4160,6 +4231,7 @@
        if(mgtBasePlatformDto.getActivityFrom()!=null&&mgtBasePlatformDto.getActivityFrom()==2){
            return totalActivityTotalVo;
        }
        List<Long> shopIdList = remoteShopService.listShopIdByPlTotal(mgtBasePlatformDto).getData();
        if (StringUtils.isNotBlank(mgtBasePlatformDto.getShopProvinceCode()) || StringUtils.isNotBlank(mgtBasePlatformDto.getShopCityCode()) || StringUtils.isNotBlank(mgtBasePlatformDto.getShopAreaCode())) {
            if(shopIdList==null||shopIdList.isEmpty()){
@@ -4170,7 +4242,20 @@
            shopIdList = new ArrayList<>();
            shopIdList.add(mgtBasePlatformDto.getShopId());
        }
        mgtBasePlatformDto.setShopIdList(shopIdList);
        //数据权限
        List<Long> userIds = remoteUserService.getScopeOfAuthorityUserId();
        if(null != userIds){
            BoardMemberTotalDto boardMemberTotalDto = new BoardMemberTotalDto();
            boardMemberTotalDto.setUserIds(userIds);
            List<Shop> shopList = remoteShopService.getShopBySysUserIds(boardMemberTotalDto);
            List<Long> collect = shopList.stream().map(Shop::getShopId).collect(Collectors.toList());
            if(null != shopIdList){
                shopIdList.addAll(collect);
            }else{
                shopIdList = collect;
            }
            mgtBasePlatformDto.setShopIdList(shopIdList);
        }
        //获取基础统计
        MgtPlTotalActivityTotalVo mgtTotalActivityTotalVo = orderMapper.getPlTotalActivityTotal(mgtBasePlatformDto);
        totalActivityTotalVo.setOrderTotal(mgtTotalActivityTotalVo.getOrderTotal());
@@ -4277,8 +4362,10 @@
        }
        HashSet<String> set = new HashSet<>();
        // 遍历MgtMemberOrderPageVoList,获取shopId并添加到set中
        for (Long shopId : mgtBasePlatformDto.getShopIdList()) {
            set.add(shopId.toString());
        if(null != mgtBasePlatformDto.getShopIdList()){
            for (Long shopId : mgtBasePlatformDto.getShopIdList()) {
                set.add(shopId.toString());
            }
        }
        // 将set中的shopId转换为逗号分隔的字符串
        String joinedString = String.join(",", set);
@@ -4347,52 +4434,6 @@
            totalActivityTotalVo.setOrderTotalValue(orderTotalValue);
            totalActivityTotalVo.setOrderMoneyValue(orderMoneyValue);
        }
        //参与人数  2023-09-06 另开接口
        /*List<MgtMapIntTotalVo> joinList = orderMapper.getMgtActivityMemberTotal(mgtBasePlatformDto);
        // 将查询结果转为Map
        Map<String, Integer> mgtMapIntTotalVoMap = new HashMap<>();
        if (joinList != null && !joinList.isEmpty()) {
            mgtMapIntTotalVoMap = joinList.stream()
                    .collect(Collectors.toMap(MgtMapIntTotalVo::getMapKey, MgtMapIntTotalVo::getMapValue));
        }
        // 获取日期范围
        List<String> dateList = getDateRange(mgtBasePlatformDto.getStartDate(), mgtBasePlatformDto.getEndDate());
        int size = dateList.size();
        // 创建日期和成员总数的数组
        String[] joinMemberTotalKey = new String[size];
        Integer[] joinMemberTotalValue = new Integer[size];
        // 遍历日期列表,设置日期和成员总数的数组
        String str;
        Integer value;
        for (int i = 0; i < size; i++) {
            str = dateList.get(i);
            joinMemberTotalKey[i] = str;
            value = mgtMapIntTotalVoMap.get(str);
            joinMemberTotalValue[i] = (value != null) ? value : 0;
        }
        totalActivityTotalVo.setJoinMemberTotalKey(joinMemberTotalKey);
        totalActivityTotalVo.setJoinMemberTotalValue(joinMemberTotalValue);
        //获客人数
        List<MgtMapIntTotalVo> getList = orderMapper.getMgtActivityGetMemberTotal(mgtBasePlatformDto);
        // 将查询结果转为Map
        Map<String, Integer> getMemberMap = new HashMap<>();
        if (getList != null && !getList.isEmpty()) {
            getMemberMap = getList.stream()
                    .collect(Collectors.toMap(MgtMapIntTotalVo::getMapKey, MgtMapIntTotalVo::getMapValue));
        }
        // 创建日期和成员总数的数组
        String[] getMemberTotalKey = new String[size];
        Integer[] getMemberTotalValue = new Integer[size];
        // 遍历日期列表,设置日期和成员总数的数组
        for (int i = 0; i < size; i++) {
            str = dateList.get(i);
            getMemberTotalKey[i] = str;
            value = getMemberMap.get(str);
            getMemberTotalValue[i] = (value != null) ? value : 0;
        }
        totalActivityTotalVo.setGetMemberTotalKey(getMemberTotalKey);
        totalActivityTotalVo.setGetMemberTotalValue(getMemberTotalValue);*/
        return totalActivityTotalVo;
    }
@@ -4408,24 +4449,6 @@
        if(mgtBasePlatformDto.getActivityFrom()!=null&&mgtBasePlatformDto.getActivityFrom()==2){
            return totalActivityTotalVo;
        }
        /*if(mgtBasePlatformDto.getActivityType()!=null&&mgtBasePlatformDto.getActivityType()!=1){
            return new MgtPlTotalActivityTotalVo();
        }*/
        //获取需要关联的用户id集合
        /*if (mgtBasePlatformDto.getDeptId() != null) {
            List<Long> userIdList = new ArrayList<>();
            if (mgtBasePlatformDto.getUserId() != null) {
                userIdList.add(mgtBasePlatformDto.getUserId());
            } else {
                MgtUserIdByDept mgtUserIdByDept = new MgtUserIdByDept();
                mgtUserIdByDept.setDeptId(mgtBasePlatformDto.getUserId());
                mgtUserIdByDept = remoteConfigService.getUserIdByDept(mgtUserIdByDept).getData();
                userIdList = mgtUserIdByDept.getUserIdList();
            }
            if (!userIdList.isEmpty()) {
                mgtBasePlatformDto.setUserIdList(userIdList);
            }
        }*/
        List<Long> shopIdList = remoteShopService.listShopIdByPlTotal(mgtBasePlatformDto).getData();
        log.info("shopIdList1-----"+shopIdList.toString());
@@ -4440,6 +4463,17 @@
        if(mgtBasePlatformDto.getShopId()!=null){
            shopIdList = new ArrayList<>();
            shopIdList.add(mgtBasePlatformDto.getShopId());
        }
        List<Long> userIds = remoteUserService.getScopeOfAuthorityUserId();
        BoardMemberTotalDto boardMemberTotalDto = new BoardMemberTotalDto();
        boardMemberTotalDto.setUserIds(userIds);
        List<Shop> shopList = remoteShopService.getShopBySysUserIds(boardMemberTotalDto);
        List<Long> collect = shopList.stream().map(Shop::getShopId).collect(Collectors.toList());
        if(null != shopIdList){
            shopIdList.addAll(collect);
        }else{
            shopIdList = collect;
        }
        mgtBasePlatformDto.setShopIdList(shopIdList);
        if(mgtBasePlatformDto.getAgeType()!=null){
@@ -4493,24 +4527,6 @@
        if(mgtBasePlatformDto.getActivityFrom()!=null&&mgtBasePlatformDto.getActivityFrom()==2){
            return totalActivityTotalVo;
        }
        /*if(mgtBasePlatformDto.getActivityType()!=null&&mgtBasePlatformDto.getActivityType()!=1){
            return new MgtPlTotalActivityTotalVo();
        }*/
        //获取需要关联的用户id集合
        /*if (mgtBasePlatformDto.getDeptId() != null) {
            List<Long> userIdList = new ArrayList<>();
            if (mgtBasePlatformDto.getUserId() != null) {
                userIdList.add(mgtBasePlatformDto.getUserId());
            } else {
                MgtUserIdByDept mgtUserIdByDept = new MgtUserIdByDept();
                mgtUserIdByDept.setDeptId(mgtBasePlatformDto.getUserId());
                mgtUserIdByDept = remoteConfigService.getUserIdByDept(mgtUserIdByDept).getData();
                userIdList = mgtUserIdByDept.getUserIdList();
            }
            if (!userIdList.isEmpty()) {
                mgtBasePlatformDto.setUserIdList(userIdList);
            }
        }*/
        List<Long> shopIdList = remoteShopService.listShopIdByPlTotal(mgtBasePlatformDto).getData();
        if (StringUtils.isNotBlank(mgtBasePlatformDto.getShopProvinceCode()) || StringUtils.isNotBlank(mgtBasePlatformDto.getShopCityCode()) || StringUtils.isNotBlank(mgtBasePlatformDto.getShopAreaCode())) {
            if(shopIdList==null||shopIdList.isEmpty()){
@@ -4521,6 +4537,17 @@
            shopIdList = new ArrayList<>();
            shopIdList.add(mgtBasePlatformDto.getShopId());
        }
        //数据权限
        List<Long> userIds = remoteUserService.getScopeOfAuthorityUserId();
        BoardMemberTotalDto boardMemberTotalDto = new BoardMemberTotalDto();
        boardMemberTotalDto.setUserIds(userIds);
        List<Shop> shopList = remoteShopService.getShopBySysUserIds(boardMemberTotalDto);
        List<Long> collect = shopList.stream().map(Shop::getShopId).collect(Collectors.toList());
        if(null != shopIdList){
            shopIdList.addAll(collect);
        }else{
            shopIdList = collect;
        }
        mgtBasePlatformDto.setShopIdList(shopIdList);
        if(mgtBasePlatformDto.getAgeType()!=null){
            List<Long> userIdList = remoteMemberService.listUserIdByAgeType(mgtBasePlatformDto.getAgeType()).getData();