| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032 |
- package com.goafanti.user.controller;
- import java.math.BigDecimal;
- import java.util.Base64;
- import java.util.UUID;
- import java.util.regex.Matcher;
- import java.util.regex.Pattern;
- import javax.annotation.Resource;
- import javax.servlet.http.HttpServletRequest;
- import javax.validation.Valid;
- import org.apache.commons.lang3.StringUtils;
- import org.springframework.beans.BeanUtils;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.util.Assert;
- import org.springframework.validation.BindingResult;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RequestMethod;
- import org.springframework.web.bind.annotation.RestController;
- import com.goafanti.business.service.JtBusinessService;
- import com.goafanti.common.bo.Result;
- import com.goafanti.common.constant.ErrorConstants;
- import com.goafanti.common.controller.BaseApiController;
- import com.goafanti.common.enums.AttachmentType;
- import com.goafanti.common.enums.IdentityAuditStatus;
- import com.goafanti.common.enums.IdentityProcess;
- import com.goafanti.common.enums.OrgProFields;
- import com.goafanti.common.enums.OrganizationTechFields;
- import com.goafanti.common.enums.UserAbilityFields;
- import com.goafanti.common.enums.UserAuthentication;
- import com.goafanti.common.enums.UserCareerFields;
- import com.goafanti.common.enums.UserEduFields;
- import com.goafanti.common.enums.UserIdentityFields;
- import com.goafanti.common.enums.UserType;
- import com.goafanti.common.model.OrganizationIdentity;
- import com.goafanti.common.model.OrganizationTech;
- import com.goafanti.common.model.User;
- import com.goafanti.common.model.UserAbility;
- import com.goafanti.common.model.UserCareer;
- import com.goafanti.common.model.UserEdu;
- import com.goafanti.common.model.UserIdentity;
- import com.goafanti.common.utils.PasswordUtil;
- import com.goafanti.common.utils.TimeUtils;
- import com.goafanti.common.utils.VerifyCodeUtils;
- import com.goafanti.core.shiro.token.TokenManager;
- import com.goafanti.easemob.EasemobUtils;
- import com.goafanti.user.bo.ExpertUserIdentity;
- import com.goafanti.user.bo.InputOrgPro;
- import com.goafanti.user.bo.InputOrganizationIdentity;
- import com.goafanti.user.bo.InputOrganizationTech;
- import com.goafanti.user.bo.InputUserAbility;
- import com.goafanti.user.bo.InputUserCareer;
- import com.goafanti.user.bo.InputUserEdu;
- import com.goafanti.user.bo.InputUserIdentity;
- import com.goafanti.user.bo.OrgIdentityBo;
- import com.goafanti.user.bo.UserContactBo;
- import com.goafanti.user.service.OrganizationIdentityService;
- import com.goafanti.user.service.OrganizationTechService;
- import com.goafanti.user.service.UserAbilityService;
- import com.goafanti.user.service.UserCareerService;
- import com.goafanti.user.service.UserContactService;
- import com.goafanti.user.service.UserEduService;
- import com.goafanti.user.service.UserIdentityService;
- import com.goafanti.user.service.UserService;
- @RestController
- @RequestMapping(value = "/api/user")
- public class UserApiController extends BaseApiController {
- @Resource
- private UserService userService;
- @Resource(name = "passwordUtil")
- private PasswordUtil passwordUtil;
- @Resource
- private UserIdentityService userIdentityService;
- @Resource
- private UserEduService userEduService;
- @Resource
- private UserCareerService userCareerService;
- @Resource
- private UserAbilityService userAbilityService;
- @Resource
- private OrganizationIdentityService organizationIdentityService;
- @Resource
- private OrganizationTechService organizationTechService;
- @Resource
- private UserContactService userContactService;
- @Autowired
- private EasemobUtils easemobUtils;
-
- @Resource
- private JtBusinessService jtBusinessService;
- private static final Integer STEP_ONE = 1;
- // private static final Integer STEP_TWO = 2;
- private static final Integer STEP_THREE = 3;
- // private static final Integer STEP_FOUR = 4;
- private static final Integer STEP_FIVE = 5;
- private static final Integer MAX_WRONG_COUNT = 3;
- private static final Integer INIT_WRONG_COUNT = 0;
- /**
- * 修改密码
- *
- * @param password
- * @param newPassword
- * @return
- */
- @RequestMapping(value = "/pwd", method = RequestMethod.POST)
- public Result updatePwd(String password, String newPassword) {
- Result res = new Result();
- if (StringUtils.isBlank(password) || StringUtils.isBlank(newPassword)) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "必须指定", "密码"));
- }
- if (password.equals(newPassword)) {
- res.getError().add(buildError(ErrorConstants.PWD_SAME_ERROR, "新密码必须与原密码不匹配!"));
- }
- if (res.getError().isEmpty() && TokenManager.isLogin()) {
- User u = new User();
- User user = userService.selectByPrimaryKey(TokenManager.getUserId());
- u.setId(user.getId());
- u.setCreateTime(user.getCreateTime());
- u.setPassword(newPassword);
- u.setPassword(passwordUtil.getEncryptPwd(u));
- if (!user.getPassword().equals(passwordUtil.getEncryptPwd(password, user.getCreateTime()))) {
- res.getError().add(buildError(ErrorConstants.PWD_NOT_MATCH_ERROR));
- } else {
- res.setData(userService.updateByPrimaryKeySelective(u));
- }
- }
- return res;
- }
- /**
- * 更换手机
- *
- * @param mobile
- * @param mobileCode
- * @return
- */
- @RequestMapping(value = "/mobile", method = RequestMethod.POST)
- public Result updateMobile(String mobile, String mobileCode) {
- Result res = new Result();
- if (StringUtils.isBlank(mobile)) {
- res.getError().add(buildError(ErrorConstants.MOBILE_EMPTY_ERROR, "手机号不能为空!"));
- return res;
- }
- if (StringUtils.isBlank(mobileCode)) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "手机验证码为空?"));
- return res;
- }
- // 验证码15分钟有效
- if (TimeUtils.checkOverTime("register")) {
- res.getError().add(buildError(ErrorConstants.MCODE_OVERTIME_ERROR, "手机验证码超时失效"));
- return res;
- }
- if (!TokenManager.getSession().getAttribute(VerifyCodeUtils.M_CODE).equals(mobileCode)) {
- res.getError().add(buildError(ErrorConstants.MCODE_ERROR, "手机验证码错误?"));
- return res;
- }
- User user = userService.selectByPrimaryKey(TokenManager.getUserId());
- if (mobile.equals(user.getMobile())) {
- res.getError().add(buildError(ErrorConstants.MOBILE_SAME_ERROR));
- return res;
- }
- User u = userService.selectByMobieAndType(mobile, user.getType());
- if (null != u) {
- res.getError().add(buildError(ErrorConstants.DUNPLICATE_KAY_ERROR, "", mobile));
- return res;
- }
- if (res.getError().isEmpty()) {
- user.setMobile(mobile);
- res.setData(userService.updateByPrimaryKeySelective(user));
- }
- return res;
- }
-
- /**
- * 公共
- *
- * @param req
- * @return
- */
- @RequestMapping(value = "/avatar/upload", method = RequestMethod.POST)
- public Result avatar(HttpServletRequest req) {
- Result res = new Result();
- res.setData(handleFile(res, "/avatar/", false, req, ""));
- return res;
- }
- /**
- * 公共可替代
- */
- @RequestMapping(value = "/avatar/uploadReplace", method = RequestMethod.POST)
- public Result avatarReplace(HttpServletRequest req, String sign) {
- Result res = new Result();
- res.setData(handleFile(res, "/avatar/", false, req, sign));
- return res;
- }
- /**
- * 认证
- *
- * @param req
- * @return
- */
- @RequestMapping(value = "/identity/upload", method = RequestMethod.POST)
- public Result identityFile(HttpServletRequest req, String sign) {
- Result res = new Result();
- res.setData(handleFile(res, "/identity/", true, req, sign));
- return res;
- }
- /**
- * 个人资料
- *
- * @param userInfoBo
- * @param bindingResult
- * @return
- */
- @RequestMapping(value = "/userInfo", method = RequestMethod.POST)
- public Result personalData(BindingResult bindingResult) {
- Result res = new Result();
-
- return res;
- }
- /**
- * 个人会员教育信息
- *
- * @param userEdu
- * @return
- */
- @RequestMapping(value = "/userEdu", method = RequestMethod.POST)
- public Result educationInfo(@Valid InputUserEdu userEdu, BindingResult bindingResult) {
- Result res = new Result();
- if (bindingResult.hasErrors()) {
- res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage(),
- UserEduFields.getFieldDesc(bindingResult.getFieldError().getField())));
- return res;
- }
- UserEdu ue = new UserEdu();
- BeanUtils.copyProperties(userEdu, ue);
- UserEdu u = userEduService.selectUserEduByUserId(TokenManager.getUserId());
- if (null == u && StringUtils.isBlank(ue.getId())) {
- ue.setId(UUID.randomUUID().toString());
- ue.setUid(TokenManager.getUserId());
- userEduService.insert(ue);
- } else {
- if (StringUtils.isBlank(ue.getId())) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "教育信息ID"));
- return res;
- }
- userEduService.updateByPrimaryKeySelective(ue);
- }
- res.setData(userEdu);
- return res;
- }
- /**
- * 个人会员职业信息
- *
- * @param userCareer
- * @return
- */
- @RequestMapping(value = "/userCareer", method = RequestMethod.POST)
- public Result careerInfo(@Valid InputUserCareer userCareer, BindingResult bindingResult) {
- Result res = new Result();
- if (bindingResult.hasErrors()) {
- res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage(),
- UserCareerFields.getFieldDesc(bindingResult.getFieldError().getField())));
- return res;
- }
- UserCareer uc = new UserCareer();
- BeanUtils.copyProperties(userCareer, uc);
- UserCareer u = userCareerService.selectUserCareerByUserId(TokenManager.getUserId());
- if (null == u && StringUtils.isBlank(uc.getId())) {
- uc.setId(UUID.randomUUID().toString());
- uc.setUid(TokenManager.getUserId());
- userCareerService.insert(uc);
- } else {
- if (StringUtils.isBlank(uc.getId())) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "职业信息ID"));
- return res;
- }
- userCareerService.updateByPrimaryKeySelective(uc);
- }
- res.setData(userCareer);
- return res;
- }
- /**
- * 会员能力标签
- *
- * @param userAbility
- * @return
- */
- @RequestMapping(value = "/userAbility", method = RequestMethod.POST)
- public Result abilityLabel(@Valid InputUserAbility userAbility, BindingResult bindingResult) {
- Result res = new Result();
- if (bindingResult.hasErrors()) {
- res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage(),
- UserAbilityFields.getFieldDesc(bindingResult.getFieldError().getField())));
- return res;
- }
- UserAbility ua = new UserAbility();
- BeanUtils.copyProperties(userAbility, ua);
- UserAbility u = userAbilityService.selectUserAbilityByUserId(TokenManager.getUserId());
- if (null == u && StringUtils.isBlank(ua.getId())) {
- ua.setId(UUID.randomUUID().toString());
- ua.setUid(TokenManager.getUserId());
- userAbilityService.insert(ua);
- } else {
- if (StringUtils.isBlank(ua.getId())) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "能力标签ID"));
- return res;
- }
- userAbilityService.updateByPrimaryKeySelective(ua);
- }
- res.setData(userAbility);
- return res;
- }
- /**
- * 团体会员单位资料
- *
- * @param orgInfo
- * @return
- */
- @RequestMapping(value = "/orgPro", method = RequestMethod.POST)
- public Result groupProInfo(@Valid InputOrgPro pro, BindingResult bindingResult) {
- Result res = new Result();
- if (bindingResult.hasErrors()) {
- res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage(),
- OrgProFields.getFieldDesc(bindingResult.getFieldError().getField())));
- return res;
- }
- if (StringUtils.isBlank(pro.getCompanyName())) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到单位名称", "单位名称"));
- return res;
- }
- return res;
- }
- /**
- * 团体会员技术能力
- *
- * @param orgTech
- * @return
- */
- @RequestMapping(value = "/orgTech", method = RequestMethod.POST)
- public Result tech(@Valid InputOrganizationTech orgTech, BindingResult bindingResult) {
- Result res = new Result();
- if (bindingResult.hasErrors()) {
- res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage(),
- OrganizationTechFields.getFieldDesc(bindingResult.getFieldError().getField())));
- return res;
- }
- OrganizationTech ot = new OrganizationTech();
- BeanUtils.copyProperties(orgTech, ot);
- OrganizationTech o = organizationTechService.selectOrgTechByUserId(TokenManager.getUserId());
- if (null == o && StringUtils.isBlank(ot.getId())) {
- ot.setId(UUID.randomUUID().toString());
- ot.setUid(TokenManager.getUserId());
- organizationTechService.insert(ot);
- } else {
- organizationTechService.updateByPrimaryKeySelective(ot);
- }
- res.setData(orgTech);
- return res;
- }
- /**
- * 个人会员基本信息
- *
- * @return
- */
- @RequestMapping(value = "/getUserDetail", method = RequestMethod.GET)
- public Result getUserDetail() {
- Result res = new Result();
- res.setData(userIdentityService.selectUserIdentityBoByUserId(TokenManager.getUserId()));
- return res;
- }
-
- /**
- * 个人会员基本信息
- *
- * @param userIdentity
- * @param bindingResult
- * @return
- */
- @RequestMapping(value = "/updateUserDetail", method = RequestMethod.POST)
- public Result updateUserDetail(@Valid InputUserIdentity userIdentity, BindingResult bindingResult) {
- //将电话号码置为空
- userIdentity.setMobile(null);
- Result res = new Result();
- if (bindingResult.hasErrors()) {
- res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage(),
- UserIdentityFields.getFieldDesc(bindingResult.getFieldError().getField())));
- return res;
- }
- if(null == userIdentity.getAuditStatus()){
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "审核状态未提交"));
- return res;
- }
- if(StringUtils.isBlank(userIdentity.getUid())) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "用户ID"));
- return res;
- }
- if(userIdentity.getAuthentication().intValue() == UserAuthentication.AUTHENTICATION.getCode().intValue()
- && userIdentity.getType().intValue() == UserType.ORGANIZATION.getCode().intValue()){
- res.getError().add(buildError(null, "", "用户已经企业认证"));
- return res;
- }else if(userIdentity.getAuthentication().intValue() == UserAuthentication.UN_AUTHENTICATION.getCode().intValue()){
- userIdentity.setType(UserType.PERSONAL.getCode());
- userIdentity.setAuthentication(UserAuthentication.AUTHENTICATION.getCode());
- }
- if (res.getError().isEmpty()) {
- if(userIdentityService.updateUserIdentityDetail(userIdentity) < 0){
- userIdentity.setAuditInfo("系统提示:修改用户的基本信息,没有修改认证信息");
- }
- }
- res.setData(userIdentity);
- return res;
- }
-
- /**
- * 更新专家信息
- *
- * @param userIdentity
- * @param bindingResult
- * @return
- */
- @RequestMapping(value = "/updateExpertDetail", method = RequestMethod.POST)
- public Result updateExpertDetail(@Valid ExpertUserIdentity userIdentity, BindingResult bindingResult) {
- Result res = new Result();
- if (bindingResult.hasErrors()) {
- res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage(),
- UserIdentityFields.getFieldDesc(bindingResult.getFieldError().getField())));
- return res;
- }
- if(StringUtils.isBlank(userIdentity.getUid())) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "用户ID"));
- return res;
- }
- if(userIdentity.getAuthentication().intValue() == UserAuthentication.UN_AUTHENTICATION.getCode().intValue()){
- // userIdentity.setType(UserType.PERSONAL.getCode());
- userIdentity.setAuthentication(UserAuthentication.AUTHENTICATION.getCode());
- }
- if (res.getError().isEmpty()) {
- UserIdentity ui = new UserIdentity();
- User user = new User();
- BeanUtils.copyProperties(userIdentity, ui);
- BeanUtils.copyProperties(userIdentity, user);
- UserIdentity u = userIdentityService.selectUserIdentityByUserId(TokenManager.getUserId());
- if (null == u&&userIdentity.getAuthenticationType()==0) {
- ui.setId(UUID.randomUUID().toString());
- ui.setExpert(1);//直接变为专家
- ui.setAuditStatus(1);//提交审核
- ui.setUid(TokenManager.getUserId());
- userIdentityService.insert(ui);
- }else if (null == u&&userIdentity.getAuthenticationType()==1) {
- ui.setId(UUID.randomUUID().toString());
- ui.setExpert(2);//直接变为专家
- ui.setAuditStatus(1);//提交审核
- ui.setUid(TokenManager.getUserId());
- userIdentityService.insert(ui);
- } else {
- ui.setId(u.getId());
- userIdentityService.updateByPrimaryKeySelective(ui);
- }
- user.setId(TokenManager.getUserId());
- userService.updateByPrimaryKeySelective(user);
-
- }
- res.setData(userIdentity);
- return res;
- }
-
- /**
- * 企业信息详情
- * @return
- */
- @RequestMapping(value = "/getOrganizationDetail", method = RequestMethod.GET)
- public Result getOrganizationDetail(){
- Result res = new Result();
- OrgIdentityBo o = organizationIdentityService.selectOrgIdentityBoByUserId(TokenManager.getUserId());
- res.setData(o);
- return res;
- }
-
- /**
- * 修改企业信息
- *
- * @param userIdentity
- * @param bindingResult
- * @return
- */
- @RequestMapping(value = "/updateOrganizationDetail", method = RequestMethod.POST)
- public Result updateOrganizationDetail(@Valid InputOrganizationIdentity organizationIdentity, BindingResult bindingResult) {
- Result res = new Result();
- if (bindingResult.hasErrors()) {
- res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage(),
- UserIdentityFields.getFieldDesc(bindingResult.getFieldError().getField())));
- return res;
- }
- res=validation(organizationIdentity, res);
- if (!res.getError().isEmpty()) {
- return res;
- }
-
- if (res.getError().isEmpty()) {
-
- OrganizationIdentity oi = new OrganizationIdentity();
- User user = new User();
- BeanUtils.copyProperties(organizationIdentity, oi);
- BeanUtils.copyProperties(organizationIdentity, user);
- OrganizationIdentity u = organizationIdentityService.selectOrgIdentityByUserId(TokenManager.getUserId());
- if (null == u) {
- oi.setId(UUID.randomUUID().toString());
- oi.setUid(TokenManager.getUserId());
- organizationIdentityService.insert(oi);
- } else {
- oi.setId(u.getId());
- if(null == oi.getEnterpriseScale()){
- oi.setEnterpriseScale("");
- }
- organizationIdentityService.updateByPrimaryKeySelective(oi);
- }
- user.setId(TokenManager.getUserId());
- userService.updateByPrimaryKeySelective(user);
- }
- res.setData(organizationIdentity);
- return res;
- }
- private Result validation(InputOrganizationIdentity organizationIdentity, Result res) {
- if(StringUtils.isBlank(organizationIdentity.getUid())) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "用户ID", "用户ID"));
- return res;
- }
- if(StringUtils.isBlank(organizationIdentity.getQq())) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "企业QQ", "企业QQ"));
- return res;
- }
- if(StringUtils.isBlank(organizationIdentity.getIdentifyName())) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "单位名称", "单位名称"));
- return res;
- }
- if(StringUtils.isBlank(organizationIdentity.getCompanyLogoUrl())) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "LOGO", "LOGO"));
- return res;
- }
- if(StringUtils.isBlank(organizationIdentity.getBusinessScope())) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "业务范围", "业务范围"));
- return res;
- }
- if(StringUtils.isBlank(organizationIdentity.getIntroduction())) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "企业简介", "企业简介"));
- return res;
- }
- if(StringUtils.isBlank(organizationIdentity.getHonorPicture())) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "荣誉资质", "荣誉资质"));
- return res;
- }
- if(StringUtils.isBlank(organizationIdentity.getEmail())) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "企业邮箱", "企业邮箱"));
- return res;
- }
- /*if(null==organizationIdentity.getLicenceProvince()||null==organizationIdentity.getLicenceCity()) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "地区"));
- return res;
- }*/
- if(organizationIdentity.getAuthentication() == UserAuthentication.AUTHENTICATION.getCode()
- && organizationIdentity.getType() == UserType.PERSONAL.getCode()){
- res.getError().add(buildError(null, "", "用户已经个人认证"));
- return res;
- }else if(organizationIdentity.getAuthentication() == UserAuthentication.UN_AUTHENTICATION.getCode()){
- organizationIdentity.setType(UserType.ORGANIZATION.getCode());
- organizationIdentity.setAuthentication(UserAuthentication.AUTHENTICATION.getCode());
- }
- return res;
- }
-
- /**
- * 个人资料/团体会员资料
- */
- @RequestMapping(value = "/member", method = RequestMethod.GET)
- public Result member() {
- Result res = new Result();
-
- return res;
- }
- /**
- * 个人会员教育信息
- *
- * @return
- */
- @RequestMapping(value = "/educate", method = RequestMethod.GET)
- public Result educate() {
- Result res = new Result();
- UserEdu u = userEduService.selectUserEduByUserId(TokenManager.getUserId());
- res.setData(u);
- return res;
- }
- /**
- * 个人会员职业信息/团体会员技术能力
- *
- * @return
- */
- @RequestMapping(value = "/job", method = RequestMethod.GET)
- public Result job() {
- Result res = new Result();
- if (UserType.PERSONAL.getCode().equals(TokenManager.getUserType())) {
- UserCareer u = userCareerService.selectUserCareerByUserId(TokenManager.getUserId());
- res.setData(u);
- } else {
- OrganizationTech o = organizationTechService.selectOrgTechByUserId(TokenManager.getUserId());
- res.setData(o);
- }
- return res;
- }
- /**
- * 个人/团体能力标签
- *
- * @return
- */
- @RequestMapping(value = "/ability", method = RequestMethod.GET)
- public Result ability() {
- Result res = new Result();
- UserAbility u = userAbilityService.selectUserAbilityByUserId(TokenManager.getUserId());
- res.setData(u);
- return res;
- }
- /**
- * 获取昵称
- *
- * @return
- */
- @RequestMapping(value = "/nickname", method = RequestMethod.GET)
- public Result nickname() {
- User u = userService.selectByPrimaryKey(TokenManager.getUserId());
- Assert.notNull(u, "用户不存在");
- return res().data(u.getNickname());
- }
- /**
- * 首页
- *
- * @return
- */
- @RequestMapping(value = "/homePage", method = RequestMethod.GET)
- public Result homePage() {
- Result res = new Result();
- res.setData(userService.selectUserPageHomeBoByUserId(TokenManager.getUserId()));
- return res;
- }
-
- /**
- * 用户基本信息
- * @return
- */
- @RequestMapping(value = "/userBase", method = RequestMethod.GET)
- public Result userBase(){
- Result res = new Result();
- res.setData(userService.selectUserBase(TokenManager.getUserId()));
- return res;
- }
- /**
- * 修改用户基本信息
- * @return
- */
- @RequestMapping(value = "/updateUserBase", method = RequestMethod.POST)
- public Result updateUserBase(String identifyName,String mobile,String email,String nickname,Integer type){
- Result res = new Result();
- if(StringUtils.isBlank(identifyName) || StringUtils.isBlank(mobile)
- ||StringUtils.isBlank(nickname)){
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"用户信息不全"));
- }
- if (nickname.length()>6) {
- res.getError().add(buildError("昵称长度必须小于6","昵称长度必须小于6"));
- }
- User user = new User();
- user.setId(TokenManager.getUserId());
- user.setIdentifyName(identifyName);
- if(StringUtils.isNotEmpty(mobile)){
- //验证手机号码格式是否正确
- Pattern p = Pattern.compile("^[1][3,4,5,7,8][0-9]{9}$"); // 验证手机号
- Matcher m = p.matcher(mobile);
- if(!m.matches()){
- res.getError().add(buildError("电话号码格式不对","电话号码格式不对"));
- }else{
- //验证手机是否存在
- int i = userService.getCountByMobile(user.getId(),mobile,type);
- if(i>0){
- res.getError().add(buildError("电话号码重复","电话号码重复"));
- }else{
- user.setMobile(mobile);//修改电话号码
- }
- }
- }
- if(StringUtils.isNotBlank(email))user.setEmail(email);
- user.setNickname(nickname);
- if(type !=null)user.setType(type);
- if(res.getError().size()>0){
- return res;
- }
- userService.updateByPrimaryKeySelective(user);
- return res;
- }
-
-
- /**
- * 登陆后返回用户基本信息
- *
- * @return
- */
- @RequestMapping(value = "/afterSignIn", method = RequestMethod.GET)
- public Result afterSignIn() {
- Result res = new Result();
- if (TokenManager.isLogin()) {
- User u = userService.selectByPrimaryKey(TokenManager.getUserId());
- res.setData(u);
- }
- return res;
- }
- /**
- * 个人实名认证流程入口
- *
- * @return
- */
- @RequestMapping(value = "/userPro", method = RequestMethod.GET)
- public Result userProcess() {
- Result res = new Result();
- if (TokenManager.isLogin()) {
- res.setData(userIdentityService.selectUserIdentityByUserId(TokenManager.getUserId()));
- }
- return res;
- }
- /**
- * 个人实名认证流程下一步
- */
- @RequestMapping(value = "/userNextPro", method = RequestMethod.POST)
- public Result userNextProcess(UserIdentity userIdentity, String verificationCode) {
- Result res = new Result();
- if (null == userIdentity.getProcess()) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "process"));
- return res;
- }
- if (STEP_ONE.equals(userIdentity.getProcess())) {
- if (StringUtils.isBlank(verificationCode)) {
- res.getError().add(buildError(ErrorConstants.VCODE_EMPTY_ERROR));
- return res;
- }
- if (!VerifyCodeUtils.verifyCode(verificationCode)) {
- res.getError().add(buildError(ErrorConstants.VCODE_ERROR));
- return res;
- }
- } else if (STEP_THREE.equals(userIdentity.getProcess())) {
- UserIdentity u = userIdentityService.selectUserIdentityByUserId(TokenManager.getUserId());
- u.setProcess(IdentityProcess.COMMITTED.getCode());
- u.setAuditStatus(IdentityAuditStatus.COMMITTED.getCode());
- userIdentityService.updateByPrimaryKeySelective(u);
- return res;
- } else if (STEP_FIVE.equals(userIdentity.getProcess())) {
- UserIdentity u = userIdentityService.selectUserIdentityByUserId(TokenManager.getUserId());
- if ((System.currentTimeMillis() - u.getPaymentDate().getTime()) > 432000000) {
- u.setAuditStatus(IdentityAuditStatus.NOTPASSED.getCode());// 4
- userIdentityService.updateByPrimaryKeySelective(u);
- res.getError().add(buildError(ErrorConstants.IDENTITY_PAY_OVER_TIME));// 超过打款日期5日,无法提交确认
- return res;
- }
- if (MAX_WRONG_COUNT.equals(u.getWrongCount())) {
- u.setAuditStatus(IdentityAuditStatus.NOTPASSED.getCode());// 4
- u.setProcess(IdentityProcess.SUCCESS.getCode());// 5
- userIdentityService.updateByPrimaryKeySelective(u);
- res.getError().add(buildError(ErrorConstants.OVER_MAX_WRONG_COUNT));// 输入错误金额次数过多
- return res;
- }
- if (0 != (u.getAmountMoney().compareTo(userIdentity.getAmountMoney()))) {
- int t = 3 - u.getWrongCount() - 1;
- u.setWrongCount(u.getWrongCount() + 1);
- if (0 == t) {
- u.setAuditStatus(IdentityAuditStatus.NOTPASSED.getCode());// 4
- u.setProcess(IdentityProcess.SUCCESS.getCode());// 5
- res.getError().add(buildError(ErrorConstants.OVER_MAX_WRONG_COUNT));// 输入错误金额次数过多
- } else {
- res.getError().add(buildError(ErrorConstants.WRONG_MONEY, "", t));
- }
- userIdentityService.updateByPrimaryKeySelective(u);
- return res;
- }
- userIdentity.setAuditStatus(IdentityAuditStatus.PASSED.getCode());
- userIdentity.setProcess(IdentityProcess.SUCCESS.getCode());
- }
- return dealUserProcess(res, userIdentity, TokenManager.getUserId());
- }
- // 认证失败清除相关认证信息
- private Result dealFaild(Result res) {
- if (UserType.PERSONAL.getCode().equals(userService.selectByPrimaryKey(TokenManager.getUserId()).getType())) {
- UserIdentity u = userIdentityService.selectUserIdentityByUserId(TokenManager.getUserId());
- UserIdentity user = new UserIdentity();
- user.setId(u.getId());
- user.setUid(u.getUid());
- user.setProcess(IdentityProcess.UNCOMMITTED.getCode());
- user.setWrongCount(INIT_WRONG_COUNT);
- user.setAmountMoney(new BigDecimal(0));
- user.setAuditStatus(IdentityAuditStatus.UNCOMMITTED.getCode());
- res.setData(userIdentityService.updateByPrimaryKey(user));
- } else {
- OrganizationIdentity o = organizationIdentityService.selectOrgIdentityByUserId(TokenManager.getUserId());
- OrganizationIdentity org = new OrganizationIdentity();
- org.setId(o.getId());
- org.setUid(o.getUid());
- org.setProcess(IdentityProcess.UNCOMMITTED.getCode());
- org.setWrongCount(INIT_WRONG_COUNT);
- org.setAuditStatus(IdentityAuditStatus.UNCOMMITTED.getCode());
- org.setValidationAmount(new BigDecimal(0));
- res.setData(organizationIdentityService.updateByPrimaryKey(org));
- }
- return res;
- }
- // orgProcess
- private Result dealOrgProcess(Result res, OrganizationIdentity o, String uid) {
- //res.setData(organizationIdentityService.saveOrgIndentityProcess(res, o, uid));
- return res;
- }
- // userProcess
- private Result dealUserProcess(Result res, UserIdentity u, String uid) {
- res.setData(userIdentityService.saveUserIdentityProcess(res, u, uid));
- return res;
- }
- // 判断用户是否通过认证
- private Result checkCertify(Result res) {
- OrganizationIdentity o = organizationIdentityService.selectOrgIdentityByUserId(TokenManager.getUserId());
- if (null == o || !IdentityAuditStatus.PASSED.getCode().equals(o.getAuditStatus())) {
- res.getError().add(buildError(ErrorConstants.NON_CERTIFIED, "未通过实名认证,无法操作!"));
- }
- return res;
- }
-
- /**
- * 新增客户联系人
- * @param bo
- * @return
- */
- @RequestMapping(value = "/addUserContcat", method = RequestMethod.POST)
- public Result addUserContcat(UserContactBo bo){
- Result res = new Result();
- if(StringUtils.isBlank(bo.getMobile())){
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "手机号码不能为空"));
- return res;
- }
- if(userContactService.checkUserContact(TokenManager.getUserId(), bo.getMobile())){
- res.getError().add(buildError(ErrorConstants.USER_CONTACT_ALREADY_EXIST,"联系人已存在"));
- }
- bo.setUid(TokenManager.getUserId());
- userContactService.insertSelective(bo);
- return res;
- }
-
- /**
- * 修改客户联系人
- * @param bo
- * @return
- */
- @RequestMapping(value = "/udpateUserContact", method = RequestMethod.POST)
- public Result udpateUserContact(UserContactBo bo){
- Result res = new Result();
- if(StringUtils.isBlank(bo.getMobile())){
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "手机号码不能为空"));
- return res;
- }
- if(StringUtils.isBlank(bo.getId())){
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "联系人ID"));
- return res;
- }
- userContactService.updateByPrimaryKeySelective(bo);
- return res;
- }
-
- /**
- * 删除客户联系人
- * @param id
- * @return
- */
- @RequestMapping(value = "/deleteUserContact", method = RequestMethod.GET)
- public Result deleteUserContact(String id){
- Result res = new Result();
- if(StringUtils.isBlank(id)){
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "联系人ID"));
- return res;
- }
- userContactService.deleteUserContact(id);
- return res;
- }
-
- /**
- * 获取用户联系人
- * @return
- */
- @RequestMapping(value = "/getUserContacts", method = RequestMethod.GET)
- public Result getUserContacts(){
- Result res = new Result();
- res.setData(userContactService.selectContactByUid(TokenManager.getUserId()));
- return res;
- }
-
- /**
- * 图片上传
- */
- @RequestMapping(value = "/uploadPicture", method = RequestMethod.POST)
- public Result uploadPicture(HttpServletRequest req, String sign) {
- Result res = new Result();
- AttachmentType attachmentType = AttachmentType.getField(sign);
- if (attachmentType == AttachmentType.USER_PICTURE) {
- res.setData(handleFiles(res, "/user/", false, req, sign, TokenManager.getUserId()));
- } else {
- res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示"));
- }
- return res;
- }
-
- @RequestMapping(value = "/uploadHonerPicture", method = RequestMethod.POST)
- public Result uploadHonerPicture(HttpServletRequest req, String sign) {
- Result res = new Result();
- AttachmentType attachmentType = AttachmentType.getField(sign);
- if (attachmentType == AttachmentType.HONOR_PICTURE
- ) {
- res.setData(handleFiles(res, "/honorPicture/", false, req, sign, ""));
- } else {
- res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "图片"));
- }
- return res;
- }
-
- /**
- * 顾问专家审核列表
- * @return
- */
- @RequestMapping(value = "/customerAuditList", method = RequestMethod.GET)
- public Result customerAuditList(String name,String type,String identity, Integer pageNo,Integer pageSize) {
- Result res = new Result();
- res.setData(userIdentityService.selectCustomerAuditList(name,type,identity,pageNo,pageSize));
- return res;
- }
- /**
- * 顾问专家审核
- * @return
- */
- @RequestMapping(value = "/customerAudit", method = RequestMethod.GET)
- public Result customerAudit(String id) {
- Result res = new Result();
- //res.setData(userIdentityService.selectCustomerAuditList(name,type,identity,pageNo,pageSize));
- return res;
- }
-
- /**
- * 解码base64位图片
- * @param picturebase
- * @param filename
- * @param sign
- * @return
- */
- @RequestMapping(value="/uploadPicture64")
- public Result uploadPicture64(String picturebase, String filename,String sign){
- Result res = new Result();
- byte[] bs=Base64.getDecoder().decode(picturebase);
- AttachmentType attachmentType = AttachmentType.getField(sign);
- if (attachmentType == AttachmentType.USER_PICTURE) {
- filename = System.nanoTime() + filename.substring(filename.indexOf("."));
- res.setData(handleBaseFiles(res, "/user/", false,bs, sign, TokenManager.getUserId(),filename));
- } else {
- res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示"));
- }
- return res;
- }
- /**
- * 获取用户邀请码
- */
- @RequestMapping(value = "/InvitationCode", method = RequestMethod.GET)
- public Result InvitationCode(String uid) {
- Result res = new Result();
- if (uid==null) {
- if(!(TokenManager.getToken() instanceof User)||TokenManager.getUserId()==null){
- res.getError().add(buildError("未获取到用户信息", "未获取到用户信息"));
- return res;
- }
- uid=TokenManager.getUserId();
- }
- res.data(userService.updateGetInvitationCode(uid));
- return res;
- }
-
-
- }
|