Esempio n. 1
0
  /**
   * 完善用户信息 依次校验 身份证唯一性 手机号唯一性 验证码是否正确 身份证真实姓名是否匹配 然后授权 更新用户信息 其中校验 身份证号码格式 唯一性 和真实姓名是否匹配 已经在 {@link
   * AccountRest#isYLBAccount(String)} 中校验
   *
   * @return
   */
  @Path("/full/userInfo")
  @POST
  @Produces("application/json;charset=utf-8")
  public String fullUserMsg(String content) {
    if (StringUtils.isEmpty(content)) {
      return OpenResult.parameterError("无参数").buildJson();
    }
    JSONObject json = JSONObject.parseObject(content);
    String realName = json.getString("realName");
    String idNumber = json.getString("idNumber");
    String mobileNo = json.getString("mobileNo");
    String code = json.getString("code");
    String ssoId = json.getString("UID");
    String userId = ssoId;
    boolean flag = ValidateUtil.isMobile(mobileNo);
    if (!flag) {
      return OpenResult.serviceError(10119, "手机号码有误").buildJson();
    }
    try {
      // 检验手机号是否被注册
      JSONObject result = registService.mobileUnique(mobileNo);
      if (result != null) {
        if (result.getIntValue("retcode") != 0) {
          return OpenResult.parameterError(result.getIntValue("retcode"), result.getString("msg"))
              .buildJson();
        }
      } else {
        return OpenResult.unknown("服务异常").buildJson();
      }

      // 检验验证码
      JSONObject codeResult =
          registService.checkIdentifyingCode(mobileNo, CodeType.REGISTER.type, code);
      if (codeResult != null) {
        Integer retcode = codeResult.getInteger("retcode");
        String msg = codeResult.getString("msg");
        if (retcode != 0) {
          return OpenResult.parameterError(retcode, msg).buildJson();
        }
      } else {
        return OpenResult.unknown("服务异常").buildJson();
      }
      // 注册盈利宝
      //			String passwd = generatePassword(8);
      //			记得改成通行证注册 2014-10-20
      /*		JSONObject regResult  = registService.mobileRegist(mobileNo,passwd,code);
      if (regResult != null) {
      	if (regResult.getIntValue("retcode") != 0) {
      		return OpenResult.parameterError(
      				regResult.getIntValue("retcode"),
      				regResult.getString("msg")).buildJson();
      	}
      } else {
      	return OpenResult.unknown("服务异常").buildJson();
      }

      String userId = regResult.getString("userid");*/
      // 授权
      //			accountAuthService.authorize(userId, ssoId, AuthType.JRJSSO);
      //
      UserInfo userInfo = userInfoService.queryUserInfo(userId);
      UserInfo info = null;
      if (userInfo == null) {
        info = userInfoService.createUserInfo(userId, UserStatus.COMPETE);
        if (info == null) {
          OpenResult.serviceError("-1", "完善信息失败").buildJson();
        }
      } else {
        if (userInfo.getStatus() == UserStatus.INCOMPLETE.status) {
          info = userInfoService.updateUserInfo(userId, UserStatus.COMPETE);
          if (info == null) {
            OpenResult.serviceError("-1", "完善信息失败").buildJson();
          }
        }
        if (userInfo.getStatus() == UserStatus.COMPETE.status) {
          String errorNo = "-1";
          String errorInfo = "您已完善信息";
          return OpenResult.serviceError(errorNo, errorInfo).buildJson();
        }
      }
      // 更新用户信息
      JSONObject IDRealresult =
          personalService.updateRealNameIDNumber(ssoId, idNumber, realName, mobileNo);
      if (IDRealresult != null) {
        if (IDRealresult.getInteger("retcode") != 0) {
          return IDRealresult.toJSONString();
        }
      } else {
        return OpenResult.unknown("服务异常").buildJson();
      }
      FullUserResult user = new FullUserResult();
      user.setUserId(ssoId);
      return OpenResult.ok().add("data", user).buildJson();
    } catch (ServiceException e) {
      log.error("Full user authorize ServiceException -->" + e.getMessage(), e);
      return OpenResult.serviceError(e.getErrorNo(), e.getErrorInfo()).buildJson();
    } catch (StockServiceException e) {
      log.error("Full user  StockServiceException -->" + e.getMessage(), e);
      return OpenResult.serviceError(e.getRetcode(), e.getMsg()).buildJson();
    } catch (Exception e) {
      log.error("Full user Exception -->" + e.getMessage(), e);
      return OpenResult.serviceError("-1", e.getMessage()).buildJson();
    }
  }