| | |
| | | appUser.setLevelSettingId(TreeLevelEnum.SEED.getCode()); |
| | | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmmss"); |
| | | String format = simpleDateFormat.format(new Date()); |
| | | appLoginUser.setBindStatus(DisabledEnum.YES.getCode()); |
| | | // 生成四位随机数字 |
| | | String randomCode = String.valueOf((int) ((Math.random() * 9 + 1) * 1000)); |
| | | appUser.setCode("YH" + format + randomCode); |
| | |
| | | // 初始化用户树苗 |
| | | initUserTree(appUser.getId()); |
| | | } |
| | | }else{ |
| | | // 不存在账户,创建账户 |
| | | // 注册用户信息 |
| | | sysUser = new SysUser(); |
| | | String nickname = "用户" + IdUtil.fastSimpleUUID().substring(0, 6); |
| | | sysUser.setNickName(nickname); |
| | | sysUser.setAvatar("https://xqgwzh.obs.cn-south-1.myhuaweicloud.com/Logo%E7%A1%AE%E8%AE%A4%E7%89%88%281%29.jpg"); |
| | | sysUser.setUserName(nickname); |
| | | sysUser.setUserType("01"); // app用户 |
| | | R<SysUser> registerResult = remoteUserService.registerAppUserInfo(sysUser, |
| | | SecurityConstants.INNER); |
| | | if (registerResult.getCode() == Constants.FAIL) { |
| | | throw new ServiceException(registerResult.getMsg()); |
| | | } |
| | | SysUser sysUserRes = registerResult.getData(); |
| | | appUser = new AppUser(); |
| | | appUser.setAppleId(appleId); |
| | | appUser.setUserId(sysUserRes.getUserId()); |
| | | appUser.setNickname(nickname); |
| | | appUser.setAvatar("https://xqgwzh.obs.cn-south-1.myhuaweicloud.com/Logo%E7%A1%AE%E8%AE%A4%E7%89%88%281%29.jpg"); // TODO 待完善默认头像 |
| | | appUser.setBalance(BigDecimal.ZERO); |
| | | appUser.setSanskritFlag(DisabledEnum.NO.getCode()); |
| | | appUser.setBalance(BigDecimal.ZERO); |
| | | appUser.setIncome(BigDecimal.ZERO); |
| | | appUser.setTotalEnergyValue(0); |
| | | appUser.setRegisterTime(LocalDateTime.now()); |
| | | appUser.setLevelSettingId(TreeLevelEnum.SEED.getCode()); |
| | | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmmss"); |
| | | String format = simpleDateFormat.format(new Date()); |
| | | appLoginUser.setBindStatus(DisabledEnum.YES.getCode()); |
| | | // 生成四位随机数字 |
| | | String randomCode = String.valueOf((int) ((Math.random() * 9 + 1) * 1000)); |
| | | appUser.setCode("YH" + format + randomCode); |
| | | this.save(appUser); |
| | | // 初始化用户树苗 |
| | | initUserTree(appUser.getId()); |
| | | } |
| | | } |
| | | appLoginUser.setUserid(sysUser.getUserId()); |
| | |
| | | List<AppUserQuestion> appUserQuestionList = BeanUtils.copyList( |
| | | dto.getUserAnswerOneDTOList(), AppUserQuestion.class); |
| | | // 查询用户已填写的答案 |
| | | List<AppUserQuestion> baseAppUserQuestionList = appUserQuestionService.lambdaQuery() |
| | | .eq(AppUserQuestion::getAppUserId, appUser.getUserId()) |
| | | .list(); |
| | | if (CollUtils.isNotEmpty(baseAppUserQuestionList)) { |
| | | // 根据类型更新答案 |
| | | for (AppUserQuestion appUserQuestion : appUserQuestionList) { |
| | | // 删除之前答案 |
| | | appUserQuestionService.lambdaUpdate().eq(AppUserQuestion::getAppUserId,userId).remove(); |
| | | |
| | | Optional<AppUserQuestion> baseAppUserQuestionOptional = baseAppUserQuestionList.stream() |
| | | .filter(baseAppUserQuestion -> baseAppUserQuestion.getType() |
| | | .equals(appUserQuestion.getType())).findFirst(); |
| | | baseAppUserQuestionOptional.ifPresent( |
| | | userQuestion -> appUserQuestion.setId(userQuestion.getId())); |
| | | appUserQuestion.setAppUserId(userId); |
| | | } |
| | | } |
| | | // 根据类型更新答案 |
| | | for (AppUserQuestion appUserQuestion : appUserQuestionList) { |
| | | appUserQuestion.setAppUserId(userId); |
| | | appUserQuestion.setAppUserId(userId); |
| | | } |
| | | appUserQuestionService.saveOrUpdateBatch(appUserQuestionList); |
| | | appUserQuestionService.saveBatch(appUserQuestionList); |
| | | // 筛选答案为是和偶尔有的问题,为用户设置对应的标签 |
| | | List<AppUserQuestion> appUserQuestionYesList = appUserQuestionList.stream() |
| | | .filter(appUserQuestion -> appUserQuestion.getAnswer().equals("1") |