| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010 |
- 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){
- Result res = new Result();
- if(StringUtils.isBlank(identifyName) || StringUtils.isBlank(mobile)
- ||StringUtils.isBlank(nickname)){
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"用户信息不全"));
- }
- 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);
- if(i>0){
- res.getError().add(buildError("电话号码重复","电话号码重复"));
- }else{
- user.setMobile(mobile);//修改电话号码
- }
- }
- }
- if(StringUtils.isNotBlank(email))user.setEmail(email);
- user.setNickname(nickname);
- 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;
- }
-
- }
|