| | |
| | | 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.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("/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 = {"小程序-个人中心首页"}) |
| | | 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); |
| | | } |
| | | |
| | |
| | | |
| | | |
| | | |
| | | @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(); |
| | | } |