| | |
| | | import com.ruoyi.common.redis.service.RedisService; |
| | | import com.ruoyi.common.security.annotation.Logical; |
| | | import com.ruoyi.common.security.annotation.RequiresPermissions; |
| | | import com.ruoyi.common.security.annotation.InnerAuth; |
| | | import com.ruoyi.common.security.auth.AuthUtil; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | | import com.ruoyi.common.security.utils.SecurityUtils; |
| | |
| | | private TAppUserWhitelistService appUserWhitelistService; |
| | | @Resource |
| | | private PartnerClient partnerClient; |
| | | @Resource |
| | | private PartnerAppUserAccessService partnerAppUserAccessService; |
| | | |
| | | @Autowired |
| | | private RedissonClient redissonClient; |
| | |
| | | } |
| | | |
| | | @ApiOperation(value = "管理后台-根据手机号查询用户ids", tags = {"管理后台-活动费用统计"}) |
| | | @RequiresPermissions(value = {"/appUser/select", "/appUser/list"}, logical = Logical.OR) |
| | | @PostMapping(value = "/user/getUserIdsByPhone") |
| | | public R<List<Long>> getUserIdsByPhone(@RequestParam("phone") String phone) { |
| | | return R.ok(appUserService.list(new QueryWrapper<TAppUser>().like("phone",phone)).stream().map(TAppUser::getId).collect(Collectors.toList())); |
| | |
| | | .eq(userListQueryDto.getVipTypeId() != null, TAppUser::getVipId, userListQueryDto.getVipTypeId()) |
| | | .in(!userIds.isEmpty(),TAppUser::getId,userIds) |
| | | .orderByDesc(BasePojo::getCreateTime); |
| | | List<Long> partnerVisibleUserIds = partnerAppUserAccessService.getVisibleUserIdsForCurrentPartner(); |
| | | if (partnerVisibleUserIds != null) { |
| | | query.in(TAppUser::getId, partnerVisibleUserIds); |
| | | } |
| | | if (Integer.valueOf(1).equals(userListQueryDto.getWhitelistFlag())) { |
| | | if (whitelistUserIds.isEmpty() && whitelistPhones.isEmpty()) { |
| | | query.eq(TAppUser::getId, -1L); |
| | |
| | | @Log(title = "【用户列表】添加编辑用户", businessType = BusinessType.INSERT,operatorType = OperatorType.MANAGE) |
| | | public R addOrUpdate(@RequestBody TAppUser tAppUser) { |
| | | if (tAppUser.getId() != null){ |
| | | AuthUtil.checkPermi("/appUser/update"); |
| | | partnerAppUserAccessService.assertUserVisible(tAppUser.getId()); |
| | | //为编辑操作,要进行vip的逻辑处理 |
| | | TAppUser nowUser = appUserService.getById(tAppUser.getId()); |
| | | //会员结束时间不为空 |
| | |
| | | } |
| | | |
| | | }else { |
| | | AuthUtil.checkPermi("/appUser/add"); |
| | | List<TAppUser> list = appUserService.lambdaQuery().eq(TAppUser::getPhone, tAppUser.getPhone()).list(); |
| | | if (!list.isEmpty()){ |
| | | return R.fail("该手机号已注册"); |
| | |
| | | } |
| | | |
| | | |
| | | @RequiresPermissions(value = {"/appUser/select", "/vipList/select"}, logical = Logical.OR) |
| | | @RequiresPermissions(value = {"/appUser/list", "/appUser/select", "/vipList/select"}, logical = Logical.OR) |
| | | @ApiOperation(value = "用户详情", tags = {"用户管理-用户列表"}) |
| | | @GetMapping(value = "/user/detail/{id}") |
| | | public R<UserDetailDto> userDetail(@PathVariable Long id) { |
| | | partnerAppUserAccessService.assertUserVisible(id); |
| | | TAppUser user = appUserService.getById(id); |
| | | R<Map<Integer, String>> vipMap = otherClient.getVipMap(Collections.singletonList(user.getVipId())); |
| | | if (user.getVipEndTime()!=null&&user.getVipEndTime().isAfter(LocalDateTime.now())) { |
| | |
| | | return R.ok(userDetailDto); |
| | | } |
| | | |
| | | @RequiresPermissions(value = {"/appUser/select", "/vipList/select"}, logical = Logical.OR) |
| | | @RequiresPermissions(value = {"/appUser/list", "/appUser/select", "/vipList/select"}, logical = Logical.OR) |
| | | @ApiOperation(value = "用户详情积分明细", tags = {"后台-用户管理-用户列表"}) |
| | | @PostMapping(value = "/user/points/page") |
| | | public R<Page<TAppUserIntegralChange>> pointsDetail(@RequestBody PointsQueryDto pointsQueryDto) { |
| | | if (pointsQueryDto.getUserId()==null){ |
| | | pointsQueryDto.setUserId(tokenService.getLoginUserApplet().getUserId()); |
| | | } |
| | | partnerAppUserAccessService.assertUserVisible(pointsQueryDto.getUserId()); |
| | | List<Integer> types = new ArrayList<>(); |
| | | if (pointsQueryDto.getType()==null){ |
| | | types.add(1); |
| | |
| | | @ApiOperation(value = "用户详情积分明细", tags = {"小程序-个人中心"}) |
| | | @PostMapping(value = "/user/points/page1") |
| | | public R<Page<TAppUserIntegralChange>> pointsDetail1(@RequestBody PointsQueryDto pointsQueryDto) { |
| | | if (pointsQueryDto.getUserId()==null){ |
| | | pointsQueryDto.setUserId(tokenService.getLoginUserApplet().getUserId()); |
| | | } |
| | | // 强制绑定当前登录用户,防止越权查询他人积分明细 |
| | | pointsQueryDto.setUserId(tokenService.getLoginUserApplet().getUserId()); |
| | | List<Integer> types = new ArrayList<>(); |
| | | if (pointsQueryDto.getType()==null){ |
| | | types.add(1); |
| | |
| | | |
| | | } |
| | | |
| | | @RequiresPermissions(value = {"/appUser/select", "/vipList/select"}, logical = Logical.OR) |
| | | @RequiresPermissions(value = {"/appUser/list", "/appUser/select", "/vipList/select"}, logical = Logical.OR) |
| | | @ApiOperation(value = "用户详情余额明细", tags = {"后台-用户管理-用户列表"}) |
| | | @PostMapping(value = "/user/balance/page") |
| | | public R<Page<TExchangeCodeUseRecord>> adminBalanceDetail(@RequestBody ExchangeCodeUseRecordQuery queryDto) { |
| | | partnerAppUserAccessService.assertUserVisible(queryDto.getUserId()); |
| | | return otherClient.exchangeCodeUseRecordPage(queryDto); |
| | | } |
| | | |
| | | @ApiOperation(value = "余额明细", tags = {"小程序-个人中心"}) |
| | | @PostMapping(value = "/user/balance/page1") |
| | | public R<Page<TExchangeCodeUseRecord>> balanceDetail(@RequestBody ExchangeCodeUseRecordQuery queryDto) { |
| | | if (queryDto.getUserId() == null) { |
| | | queryDto.setUserId(tokenService.getLoginUserApplet().getUserId()); |
| | | } |
| | | // 强制绑定当前登录用户,防止越权查询他人余额明细 |
| | | queryDto.setUserId(tokenService.getLoginUserApplet().getUserId()); |
| | | return otherClient.exchangeCodeUseRecordPage(queryDto); |
| | | } |
| | | |
| | |
| | | @PostMapping(value = "/user/status/change") |
| | | @Log(title = "【用户列表】冻结解冻用户", businessType = BusinessType.UPDATE,operatorType = OperatorType.MANAGE) |
| | | public R pointsDetail(@RequestBody UserChangeDto userChangeDto) { |
| | | partnerAppUserAccessService.assertUserVisible(userChangeDto.getUserId()); |
| | | TAppUser appUser = appUserService.getById(userChangeDto.getUserId()); |
| | | appUser.setStatus(userChangeDto.getStatus()); |
| | | appUser.setRemark(userChangeDto.getRemark()); |
| | |
| | | @PostMapping(value = "/user/unit/change") |
| | | @Log(title = "【用户列表】修改用户单位", businessType = BusinessType.UPDATE,operatorType = OperatorType.MANAGE) |
| | | public R unitChange(@RequestBody UnitChangeDto unitChangeDto) { |
| | | for (String s : unitChangeDto.getIds().split(",")) { |
| | | TAppUser byId = appUserService.getById(s); |
| | | List<Long> userIds = parseUserIds(unitChangeDto.getIds()); |
| | | partnerAppUserAccessService.assertUsersVisible(userIds); |
| | | for (Long userId : userIds) { |
| | | TAppUser byId = appUserService.getById(userId); |
| | | byId.setCompanyId(unitChangeDto.getUnitId()); |
| | | appUserService.updateById(byId); |
| | | } |
| | |
| | | @DeleteMapping(value = "/user/delete") |
| | | @Log(title = "【用户列表】删除用户", businessType = BusinessType.DELETE,operatorType = OperatorType.MANAGE) |
| | | public R userDelete(String ids) { |
| | | String[] split = ids.split(","); |
| | | for (String s : split) { |
| | | appUserService.removeById(s); |
| | | List<Long> userIds = parseUserIds(ids); |
| | | partnerAppUserAccessService.assertUsersVisible(userIds); |
| | | for (Long userId : userIds) { |
| | | appUserService.removeById(userId); |
| | | } |
| | | return R.ok(); |
| | | |
| | |
| | | @PostMapping(value = "/user/give/vip") |
| | | @Log(title = "【用户列表】赠送会员", businessType = BusinessType.OTHER,operatorType = OperatorType.MANAGE) |
| | | public R giveVip(@RequestBody GiveVipDto giveVipDto) { |
| | | String[] split = giveVipDto.getUserIds().split(","); |
| | | for (String s : split) { |
| | | TAppUser nowUser = appUserService.getById(s); |
| | | List<Long> userIds = parseUserIds(giveVipDto.getUserIds()); |
| | | partnerAppUserAccessService.assertUsersVisible(userIds); |
| | | for (Long userId : userIds) { |
| | | TAppUser nowUser = appUserService.getById(userId); |
| | | int plusDay = 0; |
| | | if (giveVipDto.getType() == 1) { |
| | | plusDay = 1; |
| | |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | private List<Long> parseUserIds(String ids) { |
| | | if (StringUtils.isBlank(ids)) { |
| | | return Collections.emptyList(); |
| | | } |
| | | return Arrays.stream(ids.split(",")) |
| | | .map(String::trim) |
| | | .filter(StringUtils::isNotBlank) |
| | | .map(Long::valueOf) |
| | | .distinct() |
| | | .collect(Collectors.toList()); |
| | | } |
| | | |
| | | |
| | | |
| | | @RequiresPermissions(value = {"/appUser/giftVip", "/appUser/gift_vip"}, logical = Logical.OR) |
| | | @PostMapping(value = "/user/give/vip1") |
| | | public R giveVip1(@RequestBody GiveVipDto giveVipDto) { |
| | | String[] split = giveVipDto.getUserIds().split(","); |
| | |
| | | sendMessageDTO.getChargingCapacity(), sendMessageDTO.getChargingFee()); |
| | | String result4 = HttpUtils.post(MsgConstants.SEND_URL, reqStr4); |
| | | return R.ok(result4); |
| | | case 5: |
| | | String reqStr5 = MsgUtil.companyBalanceWarnMsg(sendMessageDTO.getPhone(), sendMessageDTO.getCompanyName(), |
| | | sendMessageDTO.getBalance(), sendMessageDTO.getWarnAmount()); |
| | | String result5 = HttpUtils.post(MsgConstants.SEND_URL, reqStr5); |
| | | return R.ok(result5); |
| | | case 6: |
| | | String reqStr6 = MsgUtil.subBalanceWarnMsg(sendMessageDTO.getPhone(), sendMessageDTO.getCompanyName(), |
| | | sendMessageDTO.getUserInfo(), sendMessageDTO.getBalance(), sendMessageDTO.getWarnAmount()); |
| | | String result6 = HttpUtils.post(MsgConstants.SEND_URL, reqStr6); |
| | | return R.ok(result6); |
| | | default: |
| | | String reqStr3 = MsgUtil.faultMsg(sendMessageDTO.getPhone(), sendMessageDTO.getSite(), sendMessageDTO.getChargeGun()); |
| | | String result3 = HttpUtils.post(MsgConstants.SEND_URL, reqStr3); |