| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.account.api.model.*; |
| | | import com.ruoyi.account.dto.ApplyForAdmissionDTO; |
| | | import com.ruoyi.account.dto.ChangeAppUserInfo; |
| | | import com.ruoyi.account.mapper.AppUserMapper; |
| | | import com.ruoyi.account.service.*; |
| | | import com.ruoyi.account.util.ObsUploadUtil; |
| | |
| | | import com.ruoyi.order.model.Order; |
| | | import com.ruoyi.other.api.domain.Shop; |
| | | import com.ruoyi.other.api.feignClient.ShopClient; |
| | | import com.ruoyi.system.api.domain.SysConfig; |
| | | import com.ruoyi.system.api.domain.SysUser; |
| | | import com.ruoyi.system.api.feignClient.SysConfigClient; |
| | | import com.ruoyi.system.api.feignClient.SysUserClient; |
| | | import com.ruoyi.system.api.model.LoginUser; |
| | | import io.swagger.annotations.*; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | |
| | | private SysUserClient sysUserClient; |
| | | @Resource |
| | | private OrderClient orderClient; |
| | | @Resource |
| | | private SysConfigClient sysConfigClient; |
| | | |
| | | @Resource |
| | | private UserCancellationLogService userCancellationLogService; |
| | |
| | | @ApiOperation(value = "手机号登录") |
| | | public R<LoginVo> mobileLogin(@RequestBody MobileLogin mobileLogin) { |
| | | return appUserService.mobileLogin(mobileLogin); |
| | | } |
| | | |
| | | |
| | | @GetMapping("/logout") |
| | | @ApiOperation(value = "登出") |
| | | public R logout() { |
| | | Long userId = tokenService.getLoginUserApplet().getUserid(); |
| | | loginout(userId); |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | /* @ResponseBody |
| | | @PostMapping("/registerAccount") |
| | | @ApiOperation(value = "注册新账号") |
| | | public R<LoginVo> registerAccount(@RequestBody RegisterAccount registerAccount) { |
| | | return appUserService.registerAccount(registerAccount); |
| | | }*/ |
| | | |
| | | |
| | | /* @ResponseBody |
| | | @GetMapping("/getReferrer/{id}") |
| | | @ApiOperation(value = "获取推荐人信息") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "id", value = "推荐人id", required = true, dataType = "long") |
| | | }) |
| | | public R<String> getReferrer(@PathVariable("id") Long id) { |
| | | AppUser appUser = appUserService.getById(id); |
| | | String phone = appUser.getPhone(); |
| | | phone = phone.substring(0, 3) + "****" + phone.substring(7); |
| | | return R.ok(appUser.getName() + "-" + phone); |
| | | } |
| | | |
| | | */ |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/info") |
| | | @ApiOperation(value = "我的资料", tags = {"小程序-个人中心首页-我的资料"}) |
| | | public R<AppUser> info() { |
| | | Long userId = tokenService.getLoginUserApplet().getUserid(); |
| | | AppUser user = appUserService.getById(userId); |
| | | if(StringUtils.isEmpty(user.getQrCode())){ |
| | | //获取微信推广二维码 |
| | | String fileName = UUID.randomUUID() + ".jpg"; |
| | | String getwxacodeunlimit = weChatUtil.getwxacodeunlimit("pages/start/start", "id=" + user.getId(), EnvVersion.RELEASE, filePath + fileName); |
| | | user.setQrCode(getwxacodeunlimit); |
| | | appUserService.updateById(user); |
| | | } |
| | | return R.ok(user); |
| | | } |
| | | |
| | | |
| | | |
| | |
| | | public R unregis() { |
| | | Long userId = tokenService.getLoginUserApplet().getUserid(); |
| | | AppUser user = appUserService.getById(userId); |
| | | |
| | | //添加注销记录 |
| | | UserCancellationLog userCancellationLog = new UserCancellationLog(); |
| | | userCancellationLog.setAppUserId(user.getId()); |
| | | userCancellationLog.setVipId(user.getVipId()); |
| | | userCancellationLogService.save(userCancellationLog); |
| | | user.setStatus(3); |
| | | appUserService.updateById(user); |
| | | |
| | | List<AppUser> subUserList = appUserService.list(new LambdaQueryWrapper<AppUser>() |
| | | .eq(AppUser::getInviteUserId, userId)); |
| | | for (AppUser appUser : subUserList) { |
| | | Long inviteUserId = user.getInviteUserId(); |
| | | appUser.setInviteUserId(inviteUserId); |
| | | } |
| | | appUserService.updateBatchById(subUserList); |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | | @GetMapping("/recommend") |
| | | @ApiOperation(value = "推广中心", tags = {"小程序-推广中心"}) |
| | | public R<AppUser> recommend() { |
| | | Long userId = tokenService.getLoginUserApplet().getUserid(); |
| | | //获取绑定门店 |
| | | AppUser user = appUserService.getById(userId); |
| | | return R.ok(user); |
| | | @GetMapping("/getServicePhone") |
| | | @ApiOperation(value = "获取客服电话", tags = {"小程序-个人中心首页-客服"}) |
| | | public R getServicePhone() { |
| | | SysConfig data = sysConfigClient.getInfo(7L).getData(); |
| | | List<String> phoneList = null; |
| | | if (data != null) { |
| | | phoneList = Arrays.stream(data.getConfigValue().split(";")) |
| | | .map(String::trim) // 去除每个号码前后的空格 |
| | | .filter(s -> !s.isEmpty()) // 过滤空字符串 |
| | | .collect(Collectors.toList()); |
| | | } |
| | | return R.ok(phoneList); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | @GetMapping("/index") |
| | | @ApiOperation(value = "个人中心首页", tags = {"小程序-个人中心首页"}) |
| | | @ApiOperation(value = "个人信息", tags = {"小程序-个人中心首页"}) |
| | | public R<AppUser> index() { |
| | | Long userId = tokenService.getLoginUserApplet().getUserid(); |
| | | //当前用户信息 |
| | | AppUser user = appUserService.getById(userId); |
| | | if(StringUtils.isEmpty(user.getQrCode())){ |
| | | //获取微信推广二维码 |
| | | String fileName = UUID.randomUUID() + ".jpg"; |
| | | String getwxacodeunlimit = weChatUtil.getwxacodeunlimit("pages/start/start", "id=" + user.getId(), EnvVersion.RELEASE, filePath + fileName); |
| | | user.setQrCode(getwxacodeunlimit); |
| | | appUserService.updateById(user); |
| | | } |
| | | return R.ok(user); |
| | | return R.ok(appUserService.index()); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 获取门店作为服务商的所有用户 |
| | | * @param shopId |
| | | * @return |
| | | */ |
| | | public Set<Long> getShopServerUser(Integer shopId){ |
| | | Shop shop = shopClient.getShopById(shopId).getData(); |
| | | List<Shop> shopList = shopClient.getAllShop().getData(); |
| | | List<Long> appUserIds = shopList.stream().map(Shop::getAppUserId).collect(Collectors.toList()); |
| | | Long appUserId = shop.getAppUserId(); |
| | | //所有未开店的用户 |
| | | List<AppUser> list = appUserService.list(new LambdaQueryWrapper<AppUser>().eq(AppUser::getDelFlag, 0) |
| | | .ne(AppUser::getStatus, 3).notIn(AppUser::getId, appUserIds)); |
| | | Set<Long> ids = new HashSet<>(); |
| | | getShopServerUser(appUserId, list, ids); |
| | | return ids; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | public void getShopServerUser(Long appUserId, List<AppUser> appUserList, Set<Long> ids){ |
| | | List<AppUser> collect = appUserList.stream().filter(s->s.getInviteUserId().equals(appUserId)).collect(Collectors.toList()); |
| | | if(collect.size() == 0){ |
| | | return; |
| | | } |
| | | Set<Long> appUserSet = collect.stream().map(AppUser::getId).collect(Collectors.toSet()); |
| | | if(ids.containsAll(appUserSet)){ |
| | | return; |
| | | } |
| | | ids.addAll(appUserSet); |
| | | for (AppUser appUser : collect) { |
| | | getShopServerUser(appUser.getId(), appUserList, ids); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | @GetMapping("/index/change") |
| | | @PostMapping("/index/change") |
| | | @ApiOperation(value = "修改个人资料", tags = {"小程序-个人中心首页"}) |
| | | public R<AppUser> indexchange(String avatar, String name) { |
| | | public R<AppUser> indexchange(@RequestBody ChangeAppUserInfo changeAppInfo) { |
| | | Long userId = tokenService.getLoginUserApplet().getUserid(); |
| | | //当前用户信息 |
| | | AppUser user = appUserService.getById(userId); |
| | | user.setName(name); |
| | | user.setAvatar(avatar); |
| | | if (null != changeAppInfo.getName()){ |
| | | user.setName(changeAppInfo.getName()); |
| | | } |
| | | if (null != changeAppInfo.getAvatar()){ |
| | | user.setAvatar(changeAppInfo.getAvatar()); |
| | | } |
| | | appUserService.updateById(user); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 获取用户的祖籍列表 |
| | | */ |
| | | @GetMapping("/getUserAncestorList") |
| | | public R<List<AppUser>> getUserAncestorList(Long id) { |
| | | List<AppUser> list = appUserService.getUserAncestorList(id, null); |
| | | return R.ok(list); |
| | | } |
| | | |
| | | /** |
| | | * 获取用户的直帮上级用户 |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/getSuperiorLeader") |
| | | @ApiOperation(value = "获取用户的直帮上级用户") |
| | | public R<AppUser> getSuperiorLeader(@RequestParam("id") Long id) { |
| | | AppUser superiorLeader = appUserService.getSuperiorLeader(id); |
| | | return R.ok(superiorLeader); |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/onlineRecord") |
| | | @ApiOperation(value = "10分钟定时任务调用,记录用户在线时长", tags = {"小程序-个人中心首页"}) |
| | | public R onlineRecord() { |
| | | appUserService.onlineRecord(); |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | /** |
| | |
| | | List<Order> orders = orderClient.getRedeemedOrdersByShop(shopId).getData(); |
| | | List<Long> userIds = orders.stream().map(Order::getAppUserId).collect(Collectors.toList()); |
| | | //门店作为服务商的用户 |
| | | Set<Long> shopServerUser = getShopServerUser(shopId); |
| | | userIds.addAll(shopServerUser); |
| | | /* Set<Long> shopServerUser = getShopServerUser(shopId); |
| | | userIds.addAll(shopServerUser);*/ |
| | | queryWrapper.in(!CollectionUtils.isEmpty(userIds), "id", userIds) |
| | | .like(StringUtils.isNotEmpty( appUser.getName()),"name", appUser.getName()); |
| | | } |
| | |
| | | appUser.setExcludeStatus(3); |
| | | IPage<AppUser> appuserPage = appUserService.getAppuserPage(pageNum, pageSize, appUser, shopId, userId); |
| | | for (AppUser record : appuserPage.getRecords()) { |
| | | if (record.getInviteUserId() != null) { |
| | | AppUser byId1 = appUserService.getById(record.getInviteUserId()); |
| | | if (byId1!=null) { |
| | | record.setInviteUserName(byId1.getName()); |
| | | } |
| | | } |
| | | Shop shop1 = shopClient.getServiceProvider(record.getId()).getData(); |
| | | if(null != shop1){ |
| | | record.setShopName(shop1.getName()); |
| | |
| | | } |
| | | IPage<AppUser> appuserPage = appUserService.getAppuserPage(pageNum, pageSize, appUser, shopId, userId); |
| | | for (AppUser record : appuserPage.getRecords()) { |
| | | if (record.getInviteUserId() != null) { |
| | | /* if (record.getInviteUserId() != null) { |
| | | AppUser byId1 = appUserService.getById(record.getInviteUserId()); |
| | | if (byId1!=null) { |
| | | record.setInviteUserName(byId1.getName()); |
| | | } |
| | | } |
| | | }*/ |
| | | if (record.getShopId()!=null){ |
| | | R<Shop> shopById = shopClient.getShopById(record.getShopId()); |
| | | if (shopById.getData()!=null){ |
| | |
| | | for (Order datum : listR.getData()) { |
| | | userIds.add(datum.getAppUserId()); |
| | | } |
| | | Set<Long> shopServerUser = getShopServerUser(objectId); |
| | | userIds.addAll(shopServerUser); |
| | | /* Set<Long> shopServerUser = getShopServerUser(objectId); |
| | | userIds.addAll(shopServerUser);*/ |
| | | } |
| | | IPage<AppUser> appuserPage = appUserService.getAppuserPage1(pageCurr, pageSize, appUser, userIds); |
| | | return R.ok(appuserPage); |
| | |
| | | byId.setShopNames(shopName); |
| | | } |
| | | //推广人 |
| | | if (byId.getInviteUserId() != null) { |
| | | /*if (byId.getInviteUserId() != null) { |
| | | AppUser appUser = appUserService.getById(byId.getInviteUserId()); |
| | | if(null != appUser){ |
| | | byId.setInviteUserName(appUser.getName()); |
| | | } |
| | | } |
| | | }*/ |
| | | //最后下单时间 |
| | | R<Order> lastOrder = remoteOrderGoodsClient.getLastOrder(id); |
| | | if (lastOrder.getData() != null) { |
| | | byId.setLastOrderTime(lastOrder.getData().getCreateTime()); |
| | | } |
| | | List<AppUser> list = appUserService.lambdaQuery().eq(AppUser::getInviteUserId, id).list(); |
| | | byId.setBottomUsers(list); |
| | | /*List<AppUser> list = appUserService.lambdaQuery().eq(AppUser::getInviteUserId, id).list(); |
| | | byId.setBottomUsers(list);*/ |
| | | //消费总金额 |
| | | if(null == shopId || 1 == sysUser.getRoleType()){ |
| | | shopId = -1; |
| | |
| | | return R.ok(byId); |
| | | } |
| | | |
| | | /** |
| | | * 获取指定用户的下级用户 |
| | | */ |
| | | @GetMapping("/bottom/list") |
| | | @ApiOperation(value = "用户列表-下级用户", tags = {"管理后台"}) |
| | | public R<Page<AppUser>> bottom(Integer pageNum, Integer pageSize, Long userId){ |
| | | Page<AppUser> page = appUserService.page(Page.of(pageNum, pageSize), new LambdaQueryWrapper<AppUser>() |
| | | .eq(AppUser::getInviteUserId, userId)); |
| | | return R.ok(page); |
| | | } |
| | | |
| | | |
| | | |
| | | @GetMapping("/bottom") |
| | | @ApiOperation(value = "用户列表-绑定下级列表", tags = {"管理后台"}) |
| | | public R<Page<AppUser>> bottom(Long id, Integer pageNum, Integer pageSize) { |
| | | //绑定下级 |
| | | Page<AppUser> page = appUserService.lambdaQuery() |
| | | .eq(AppUser::getInviteUserId, id) |
| | | .eq(AppUser::getDelFlag, 0) |
| | | .eq(AppUser::getStatus, 1) |
| | | .page(Page.of(pageNum, pageSize)); |
| | | return R.ok(page); |
| | | |
| | | } |
| | | |
| | | @GetMapping("/orders") |
| | | @ApiOperation(value = "用户列表-订单列表", tags = {"管理后台"}) |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 设置指定用户的下级用户绑定门店 |
| | | */ |
| | | @PostMapping("/setLowerUserShop") |
| | | public R<Void> setLowerUserShop(@RequestParam("userId") Long userId,@RequestParam("shopId") Integer shopId) { |
| | | appUserService.update(new LambdaUpdateWrapper<AppUser>() |
| | | .set(AppUser::getShopId,shopId) |
| | | .eq(AppUser::getInviteUserId, userId)); |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | /** |
| | |
| | | shopId = data.getObjectId(); |
| | | if(null == userId){ |
| | | userIds = orderClient.getAppUserByShoppingShop(shopId).getData(); |
| | | Set<Long> shopServerUser = getShopServerUser(shopId); |
| | | userIds.addAll(shopServerUser); |
| | | /* Set<Long> shopServerUser = getShopServerUser(shopId); |
| | | userIds.addAll(shopServerUser);*/ |
| | | }else{ |
| | | userIds = new HashSet<>(); |
| | | userIds.add(userId); |