| | |
| | | import com.ruoyi.common.security.auth.AuthUtil; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | | import com.ruoyi.common.security.utils.SecurityUtils; |
| | | import com.ruoyi.goods.api.model.OrderQuery; |
| | | import com.ruoyi.management.api.feignClient.ManagementClient; |
| | | import com.ruoyi.management.api.model.*; |
| | | import com.ruoyi.management.api.query.UseGuideQuery; |
| | |
| | | |
| | | @Autowired |
| | | private ITIntegralRecordService integralRecordService; |
| | | |
| | | /** 家长端新用户注册赠送的会员天数 */ |
| | | private static final int GIFT_VIP_DAYS = 7; |
| | | |
| | | @PostMapping("/getUserById/{id}") |
| | | @ApiOperation(value = "根据用户id 获取用户信息", tags = {"管理后台-用户管理"}) |
| | | public R<TUser> getUserById(@PathVariable("id") Integer id) { |
| | | TUser byId = userService.getById(id); |
| | | return R.ok(byId); |
| | | } |
| | | |
| | | @PostMapping("/listAll") |
| | | public R<List<TUser>> listAll(@RequestBody OrderQuery query){ |
| | | List<TUser> list = userService.lambdaQuery() |
| | | .like(StringUtils.hasLength(query.getUserName()), TUser::getName, query.getUserName()) |
| | | .like(StringUtils.hasLength(query.getPhone()), TUser::getPhone, query.getPhone()).list(); |
| | | return R.ok(list); |
| | | } |
| | | |
| | | |
| | | @PostMapping("/vipInfoStudy") |
| | | @ApiOperation(value = "会员中心-获取会员说明、当前登录用户是否为会员、会员购买规格", tags = {"学习端-个人中心"}) |
| | |
| | | if (!rCode.equalsIgnoreCase(phoneCode)) { |
| | | return R.errorCode("登录失败,手机验证码无效!"); |
| | | } else { |
| | | tUser1 = getUser(phone); |
| | | tUser1.setHeadImg("https://haitunyingyu.obs.cn-southwest-2.myhuaweicloud.com/admin/1c6ee218aa18434db2e86df903990de8.jpg"); |
| | | String upperCase = UUIDUtil.getRandomCode(6).toUpperCase(); |
| | | tUser1.setAccount("用户"+upperCase); |
| | | tUser1.setName("用户"+upperCase); |
| | | userService.save(tUser1); |
| | | // 新用户:创建账号并赠送 7 天会员 |
| | | tUser1 = registerParentUserWithGift(phone); |
| | | } |
| | | } |
| | | } else { |
| | | String upperCase = UUIDUtil.getRandomCode(6).toUpperCase(); |
| | | tUser1 = getUser(phone); |
| | | tUser1.setHeadImg("https://haitunyingyu.obs.cn-southwest-2.myhuaweicloud.com/admin/1c6ee218aa18434db2e86df903990de8.jpg"); |
| | | tUser1.setAccount("用户"+upperCase); |
| | | tUser1.setName("用户"+upperCase); |
| | | userService.save(tUser1); |
| | | // 新用户:创建账号并赠送 7 天会员 |
| | | tUser1 = registerParentUserWithGift(phone); |
| | | } |
| | | } |
| | | LoginUserParent loginUserParent = new LoginUserParent(); |
| | |
| | | study.setPair(Constants.BURDEN_ONE); |
| | | userStudyService.save(study); |
| | | } |
| | | map.put("lookVideo", tUser1.getLookVideo()==null?0:tUser1.getLookVideo()); |
| | | return R.ok(map); |
| | | } |
| | | |
| | |
| | | user.setInsertTime(new Date()); |
| | | user.setCreateTime(new Date()); |
| | | user.setPhone(phone); |
| | | return user; |
| | | } |
| | | |
| | | /** |
| | | * 家长端新用户注册:创建账号并赠送 7 天会员 |
| | | * |
| | | * @param phone 手机号 |
| | | * @return 新建的用户 |
| | | */ |
| | | private TUser registerParentUserWithGift(String phone) throws Exception { |
| | | TUser user = getUser(phone); |
| | | user.setHeadImg("https://haitunyingyu.obs.cn-southwest-2.myhuaweicloud.com/admin/1c6ee218aa18434db2e86df903990de8.jpg"); |
| | | String upperCase = UUIDUtil.getRandomCode(6).toUpperCase(); |
| | | user.setAccount("用户" + upperCase); |
| | | user.setName("用户" + upperCase); |
| | | // 新用户福利:赠送 7 天会员,到期时间为 7 天后的 23:59:59 |
| | | Date now = new Date(); |
| | | user.setVipPayTime(now); |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(now); |
| | | calendar.add(Calendar.DATE, GIFT_VIP_DAYS); |
| | | Date vipEndTime = calendar.getTime(); |
| | | vipEndTime.setHours(23); |
| | | vipEndTime.setMinutes(59); |
| | | vipEndTime.setSeconds(59); |
| | | user.setVipEndTime(vipEndTime); |
| | | userService.save(user); |
| | | return user; |
| | | } |
| | | |
| | |
| | | byId.setIsVip(Constants.ZERO); |
| | | } |
| | | return R.ok(byId); |
| | | } |
| | | @PostMapping("/lookVideo") |
| | | @ApiOperation(value = "看完操作视频调用", tags = {"家长端-登录"}) |
| | | public R<TUser> lookVideo() { |
| | | LoginUserParent loginUserStudy = tokenService.getLoginUser1(); |
| | | if (null == loginUserStudy) { |
| | | return R.tokenError("登录失效!"); |
| | | } |
| | | TUser byId = userService.getById(loginUserStudy.getUserid()); |
| | | byId.setLookVideo(1); |
| | | userService.updateById(byId); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @PostMapping("/deleteUser") |
| | |
| | | @ApiOperation(value = "用户列表", tags = {"管理后台-用户管理"}) |
| | | public R<PageInfo<AppUserVO>> couponReceive(@RequestBody AppUserQuery query) { |
| | | PageInfo<AppUserVO> res = new PageInfo<>(query.getPageNumber(), query.getPageSize()); |
| | | List<AppUserVO> list = userService.listAll(query); |
| | | List<AppUserVO> list = userService.listAll(query,res); |
| | | for (AppUserVO appUserVO : list) { |
| | | if (appUserVO.getVipEndTime() == null) { |
| | | appUserVO.setIsVip(0); |
| | |
| | | } |
| | | } |
| | | res.setRecords(list); |
| | | res.setTotal(list.size()); |
| | | return R.ok(res); |
| | | } |
| | | |
| | |
| | | @ApiOperation(value = "列表查询", tags = {"管理后台-会员管理"}) |
| | | public R<PageInfo<VipOrderVO>> vipOrderList(@RequestBody AppUserQuery query) { |
| | | PageInfo<VipOrderVO> res = new PageInfo<>(query.getPageNumber(), query.getPageSize()); |
| | | List<VipOrderVO> list = vipOrderService.listAll(query); |
| | | List<VipOrderVO> list = vipOrderService.listAll(query,res); |
| | | res.setRecords(list); |
| | | res.setTotal(list.size()); |
| | | return R.ok(res); |
| | | } |
| | | } |