UserApiController.java 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970
  1. package com.goafanti.user.controller;
  2. import java.math.BigDecimal;
  3. import java.text.ParseException;
  4. import java.util.ArrayList;
  5. import java.util.List;
  6. import java.util.UUID;
  7. import javax.annotation.Resource;
  8. import javax.servlet.http.HttpServletRequest;
  9. import javax.validation.Valid;
  10. import org.apache.commons.lang3.StringUtils;
  11. import org.springframework.beans.BeanUtils;
  12. import org.springframework.stereotype.Controller;
  13. import org.springframework.validation.BindingResult;
  14. import org.springframework.web.bind.annotation.RequestMapping;
  15. import org.springframework.web.bind.annotation.RequestMethod;
  16. import org.springframework.web.bind.annotation.RequestParam;
  17. import org.springframework.web.bind.annotation.ResponseBody;
  18. import com.goafanti.cognizance.service.OrgRatepayService;
  19. import com.goafanti.common.bo.Result;
  20. import com.goafanti.common.constant.AFTConstants;
  21. import com.goafanti.common.constant.ErrorConstants;
  22. import com.goafanti.common.controller.BaseApiController;
  23. import com.goafanti.common.enums.UserAbilityFields;
  24. import com.goafanti.common.enums.UserCareerFields;
  25. import com.goafanti.common.enums.UserEduFields;
  26. import com.goafanti.common.enums.UserIdentityFields;
  27. import com.goafanti.common.enums.UserInfoBoFields;
  28. import com.goafanti.common.model.OrgHumanResource;
  29. import com.goafanti.common.model.OrganizationIdentity;
  30. import com.goafanti.common.model.OrganizationInfo;
  31. import com.goafanti.common.model.OrganizationProperties;
  32. import com.goafanti.common.model.OrganizationTech;
  33. import com.goafanti.common.model.User;
  34. import com.goafanti.common.model.UserAbility;
  35. import com.goafanti.common.model.UserCareer;
  36. import com.goafanti.common.model.UserEdu;
  37. import com.goafanti.common.model.UserIdentity;
  38. import com.goafanti.common.model.UserInfo;
  39. import com.goafanti.common.utils.DateUtils;
  40. import com.goafanti.common.utils.PasswordUtil;
  41. import com.goafanti.common.utils.TimeUtils;
  42. import com.goafanti.common.utils.VerifyCodeUtils;
  43. import com.goafanti.core.shiro.token.TokenManager;
  44. import com.goafanti.techproject.service.TechWebsiteService;
  45. import com.goafanti.user.bo.InputUserAbility;
  46. import com.goafanti.user.bo.InputUserCareer;
  47. import com.goafanti.user.bo.InputUserEdu;
  48. import com.goafanti.user.bo.InputUserIdentity;
  49. import com.goafanti.user.bo.OrgIdentityBo;
  50. import com.goafanti.user.bo.OrgProBo;
  51. import com.goafanti.user.bo.UidAndTypeBo;
  52. import com.goafanti.user.bo.UserIdentityBo;
  53. import com.goafanti.user.bo.UserInfoBo;
  54. import com.goafanti.user.bo.UserPageHomeBo;
  55. import com.goafanti.user.service.OrgHumanResourceService;
  56. import com.goafanti.user.service.OrganizationIdentityService;
  57. import com.goafanti.user.service.OrganizationInfoService;
  58. import com.goafanti.user.service.OrganizationPropertiesService;
  59. import com.goafanti.user.service.OrganizationTechService;
  60. import com.goafanti.user.service.UserAbilityService;
  61. import com.goafanti.user.service.UserCareerService;
  62. import com.goafanti.user.service.UserEduService;
  63. import com.goafanti.user.service.UserIdentityService;
  64. import com.goafanti.user.service.UserInfoService;
  65. import com.goafanti.user.service.UserService;
  66. @Controller
  67. @RequestMapping(value = "/api/user")
  68. public class UserApiController extends BaseApiController {
  69. @Resource
  70. private UserService userService;
  71. @Resource(name = "passwordUtil")
  72. private PasswordUtil passwordUtil;
  73. @Resource
  74. private UserIdentityService userIdentityService;
  75. @Resource
  76. private UserInfoService userInfoService;
  77. @Resource
  78. private UserEduService userEduService;
  79. @Resource
  80. private UserCareerService userCareerService;
  81. @Resource
  82. private UserAbilityService userAbilityService;
  83. @Resource
  84. private OrganizationIdentityService organizationIdentityService;
  85. @Resource
  86. private OrganizationInfoService organizationInfoService;
  87. @Resource
  88. private OrganizationTechService organizationTechService;
  89. @Resource
  90. private OrganizationPropertiesService organizationPropertiesService;
  91. @Resource
  92. private OrgHumanResourceService orgHumanResourceService;
  93. @Resource
  94. private TechWebsiteService techWebsiteService;
  95. @Resource
  96. private OrgRatepayService orgRatepayService;
  97. /**
  98. * 修改密码
  99. *
  100. * @param password
  101. * @param newPassword
  102. * @return
  103. */
  104. @RequestMapping(value = "/pwd", method = RequestMethod.POST)
  105. public Result updatePwd(String password, String newPassword) {
  106. Result res = new Result();
  107. if (StringUtils.isBlank(password) || StringUtils.isBlank(newPassword)) {
  108. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "必须指定", "密码"));
  109. }
  110. if (password.equals(newPassword)) {
  111. res.getError().add(buildError(ErrorConstants.PWD_SAME_ERROR, "新密码必须与原密码不同!"));
  112. }
  113. if (res.getError().isEmpty() && TokenManager.isLogin()) {
  114. User u = new User();
  115. User user = userService.selectByPrimaryKey(TokenManager.getUserId());
  116. u.setId(user.getId());
  117. u.setCreateTime(user.getCreateTime());
  118. u.setPassword(newPassword);
  119. u.setPassword(passwordUtil.getEncryptPwd(u));
  120. if (!user.getPassword().equals(passwordUtil.getEncryptPwd(password, user.getCreateTime()))) {
  121. res.getError().add(buildError(ErrorConstants.PWD_NOT_MATCH_ERROR));
  122. } else {
  123. res.setData(userService.updateByPrimaryKeySelective(u));
  124. }
  125. }
  126. return res;
  127. }
  128. /**
  129. * 重置密码
  130. *
  131. * @param resetCode
  132. * @param mobile
  133. * @param type
  134. * @param newPwd
  135. * @return
  136. */
  137. @RequestMapping(value = "/resetPwd", method = RequestMethod.POST)
  138. public Result resetPwd(String resetCode, String mobile, Integer type, String newPwd) {
  139. Result res = new Result();
  140. if (TimeUtils.checkOverTime("resetCode")) {
  141. res.getError().add(buildError(ErrorConstants.RESET_CODE_OVERTIME, "页面超时失效,请重新获取验证码!"));
  142. this.cleanCodeSession();
  143. return res;
  144. }
  145. if (!TokenManager.getSession().getAttribute(VerifyCodeUtils.RESET_CODE).equals(resetCode)) {
  146. res.getError().add(buildError(ErrorConstants.RESET_CODE_ERROR, "页面失效,请重新获取验证码!"));
  147. this.cleanCodeSession();
  148. return res;
  149. }
  150. if (StringUtils.isBlank(newPwd)){
  151. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "新密码"));
  152. return res;
  153. }
  154. if (StringUtils.isBlank(mobile)){
  155. res.getError().add(buildError(ErrorConstants.MOBILE_EMPTY_ERROR, "", "mobile"));
  156. return res;
  157. }
  158. if (1 != type || 0 != type){
  159. res.getError().add(buildError(ErrorConstants.PARAM_PATTERN_ERROR, "", "type"));
  160. return res;
  161. }
  162. User user = userService.selectByMobieAndType(mobile, type);
  163. if (null == user){
  164. res.getError().add(buildError(ErrorConstants.MOBILE_EMPTY_ERROR, "", "mobile"));
  165. return res;
  166. }
  167. user.setPassword(newPwd);
  168. user.setPassword(passwordUtil.getEncryptPwd(user));
  169. userService.updateByPrimaryKey(user);
  170. TokenManager.getSession().removeAttribute(VerifyCodeUtils.RESET_CODE);
  171. TokenManager.getSession().removeAttribute(VerifyCodeUtils.RESET_CODE_TIME);
  172. return res;
  173. }
  174. /**
  175. *
  176. * @param mobileCode
  177. * @return
  178. */
  179. @RequestMapping(value = "/checkMCode", method = RequestMethod.POST)
  180. public Result checkMCode(String mobileCode) {
  181. Result res = new Result();
  182. if (StringUtils.isBlank(mobileCode)){
  183. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "手机验证码"));
  184. return res;
  185. }
  186. if (TimeUtils.checkOverTime("register")) {
  187. res.getError().add(buildError(ErrorConstants.MCODE_OVERTIME_ERROR, "手机验证码超时失效"));
  188. TokenManager.getSession().removeAttribute(VerifyCodeUtils.M_CODE);
  189. TokenManager.getSession().removeAttribute(VerifyCodeUtils.M_CODE_TIME);
  190. return res;
  191. }
  192. System.out.println(TokenManager.getSession().getAttribute(VerifyCodeUtils.M_CODE));
  193. if (!TokenManager.getSession().getAttribute(VerifyCodeUtils.M_CODE).equals(mobileCode)) {
  194. res.getError().add(buildError(ErrorConstants.MCODE_ERROR, "手机验证码错误"));
  195. return res;
  196. }
  197. return res;
  198. }
  199. /**
  200. * 更换手机
  201. *
  202. * @param mobile
  203. * @param mobileCode
  204. * @return
  205. */
  206. @RequestMapping(value = "/mobile", method = RequestMethod.POST)
  207. public Result updateMobile(String mobile, String mobileCode) {
  208. Result res = new Result();
  209. if (StringUtils.isBlank(mobile)) {
  210. res.getError().add(buildError(ErrorConstants.MOBILE_EMPTY_ERROR, "手机号不能为空!"));
  211. return res;
  212. }
  213. if (StringUtils.isBlank(mobileCode)){
  214. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "手机验证码"));
  215. return res;
  216. }
  217. // 验证码15分钟有效
  218. if (TimeUtils.checkOverTime("register")) {
  219. res.getError().add(buildError(ErrorConstants.MCODE_OVERTIME_ERROR, "手机验证码超时失效"));
  220. return res;
  221. }
  222. if (!TokenManager.getSession().getAttribute(VerifyCodeUtils.M_CODE).equals(mobileCode)) {
  223. res.getError().add(buildError(ErrorConstants.MCODE_ERROR, "手机验证码错误"));
  224. return res;
  225. }
  226. User user = userService.selectByPrimaryKey(TokenManager.getUserId());
  227. if (mobile.equals(user.getMobile())) {
  228. res.getError().add(buildError(ErrorConstants.MOBILE_SAME_ERROR, "新手机号必须和原手机号不同!"));
  229. return res;
  230. }
  231. if (res.getError().isEmpty() && TokenManager.isLogin()) {
  232. user.setMobile(mobile);
  233. res.setData(userService.updateByPrimaryKey(user));
  234. }
  235. return res;
  236. }
  237. /**
  238. * 个人会员基本信息
  239. *
  240. * @param userIdentity
  241. * @param bindingResult
  242. * @return
  243. */
  244. @RequestMapping(value = "/userIndentity", method = RequestMethod.POST)
  245. public Result basicInfo(@Valid InputUserIdentity userIdentity, BindingResult bindingResult) {
  246. Result res = new Result();
  247. if (bindingResult.hasErrors()) {
  248. res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage(),
  249. UserIdentityFields.getFieldDesc(bindingResult.getFieldError().getField())));
  250. return res;
  251. }
  252. if (res.getError().isEmpty()) {
  253. UserIdentity ui = new UserIdentity();
  254. BeanUtils.copyProperties(userIdentity, ui);
  255. if (null == ui.getId()) {
  256. ui.setId(UUID.randomUUID().toString());
  257. ui.setUid(TokenManager.getUserId());
  258. userIdentityService.insert(ui);
  259. } else {
  260. userIdentityService.updateByPrimaryKeySelective(ui);
  261. }
  262. }
  263. res.setData(userIdentity);
  264. return res;
  265. }
  266. /**
  267. * 公共
  268. *
  269. * @param req
  270. * @return
  271. */
  272. @RequestMapping(value = "/avatar/upload", method = RequestMethod.POST)
  273. public Result avatar(HttpServletRequest req) {
  274. Result res = new Result();
  275. res.setData(handleFile(res, "/avatar/", false, req, ""));
  276. return res;
  277. }
  278. /**
  279. * 公共可替换
  280. */
  281. @RequestMapping(value = "/avatar/uploadReplace", method = RequestMethod.POST)
  282. public Result avatarReplace(HttpServletRequest req, String sign) {
  283. Result res = new Result();
  284. res.setData(handleFile(res, "/avatar/", false, req, sign));
  285. return res;
  286. }
  287. /**
  288. * 认证
  289. *
  290. * @param req
  291. * @return
  292. */
  293. @RequestMapping(value = "/identity/upload", method = RequestMethod.POST)
  294. public Result identityFile(HttpServletRequest req, String sign) {
  295. Result res = new Result();
  296. res.setData(handleFile(res, "/identity/", true, req, sign));
  297. return res;
  298. }
  299. /**
  300. * 个人资料
  301. *
  302. * @param userInfoBo
  303. * @param bindingResult
  304. * @return
  305. */
  306. @RequestMapping(value = "/userInfo", method = RequestMethod.POST)
  307. public Result personalData(@Valid UserInfoBo userInfoBo, BindingResult bindingResult) {
  308. Result res = new Result();
  309. if (bindingResult.hasErrors()) {
  310. res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage(),
  311. UserInfoBoFields.getFieldDesc(bindingResult.getFieldError().getField())));
  312. return res;
  313. }
  314. if (res.getError().isEmpty()) {
  315. User u = userService.selectByPrimaryKey(TokenManager.getUserId());
  316. u.setNickname(userInfoBo.getNickname());
  317. u.setEmail(userInfoBo.getEmail());
  318. userService.updateByPrimaryKeySelective(u);
  319. UserInfo ui = new UserInfo();
  320. BeanUtils.copyProperties(userInfoBo, ui);
  321. if (StringUtils.isBlank(ui.getId())) {
  322. ui.setId(UUID.randomUUID().toString());
  323. ui.setUid(TokenManager.getUserId());
  324. userInfoService.insert(ui);
  325. } else {
  326. userInfoService.updateByPrimaryKeySelective(ui);
  327. }
  328. }
  329. res.setData(userInfoBo);
  330. return res;
  331. }
  332. /**
  333. * 个人会员教育信息
  334. *
  335. * @param userEdu
  336. * @return
  337. */
  338. @RequestMapping(value = "/userEdu", method = RequestMethod.POST)
  339. public Result educationInfo(@Valid InputUserEdu userEdu, BindingResult bindingResult) {
  340. Result res = new Result();
  341. if (bindingResult.hasErrors()) {
  342. res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage(),
  343. UserEduFields.getFieldDesc(bindingResult.getFieldError().getField())));
  344. return res;
  345. }
  346. UserEdu ue = new UserEdu();
  347. BeanUtils.copyProperties(userEdu, ue);
  348. if (StringUtils.isBlank(ue.getId())) {
  349. userEdu.setId(UUID.randomUUID().toString());
  350. userEdu.setUid(TokenManager.getUserId());
  351. userEduService.insert(ue);
  352. } else {
  353. userEduService.updateByPrimaryKeySelective(ue);
  354. }
  355. res.setData(userEdu);
  356. return res;
  357. }
  358. /**
  359. * 个人会员职业信息
  360. *
  361. * @param userCareer
  362. * @return
  363. */
  364. @RequestMapping(value = "/userCareer", method = RequestMethod.POST)
  365. public Result careerInfo(@Valid InputUserCareer userCareer, BindingResult bindingResult) {
  366. Result res = new Result();
  367. if (bindingResult.hasErrors()) {
  368. res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage(),
  369. UserCareerFields.getFieldDesc(bindingResult.getFieldError().getField())));
  370. return res;
  371. }
  372. UserCareer uc = new UserCareer();
  373. BeanUtils.copyProperties(userCareer, uc);
  374. if (StringUtils.isBlank(uc.getId())) {
  375. uc.setId(UUID.randomUUID().toString());
  376. uc.setUid(TokenManager.getUserId());
  377. userCareerService.insert(uc);
  378. } else {
  379. userCareerService.updateByPrimaryKeySelective(uc);
  380. }
  381. res.setData(userCareer);
  382. return res;
  383. }
  384. /**
  385. * 会员能力标签
  386. *
  387. * @param userAbility
  388. * @return
  389. */
  390. @RequestMapping(value = "/userAbility", method = RequestMethod.POST)
  391. public Result abilityLabel(@Valid InputUserAbility userAbility, BindingResult bindingResult) {
  392. Result res = new Result();
  393. if (bindingResult.hasErrors()) {
  394. res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage(),
  395. UserAbilityFields.getFieldDesc(bindingResult.getFieldError().getField())));
  396. return res;
  397. }
  398. UserAbility ua = new UserAbility();
  399. BeanUtils.copyProperties(userAbility, ua);
  400. if (StringUtils.isBlank(ua.getId())) {
  401. ua.setId(UUID.randomUUID().toString());
  402. ua.setUid(TokenManager.getUserId());
  403. userAbilityService.insert(ua);
  404. } else {
  405. userAbilityService.updateByPrimaryKeySelective(ua);
  406. }
  407. res.setData(userAbility);
  408. return res;
  409. }
  410. /**
  411. * 团体会员基本信息
  412. *
  413. * @param orgIdentityBo
  414. * @return
  415. */
  416. @RequestMapping(value = "/orgIdentity", method = RequestMethod.POST)
  417. public Result groupBasicInfo(OrgIdentityBo orgIdentityBo) {
  418. Result res = new Result();
  419. OrganizationIdentity organizationIdentity = new OrganizationIdentity();
  420. OrganizationIdentity identity = organizationIdentityService.selectOrgIdentityByUserId(TokenManager.getUserId());
  421. User u = userService.selectByPrimaryKey(TokenManager.getUserId());
  422. u.setEmail(orgIdentityBo.getEmail());
  423. userService.updateByPrimaryKeySelective(u);
  424. organizationIdentity.setContacts(orgIdentityBo.getContacts());
  425. organizationIdentity.setFixedTel(orgIdentityBo.getFixedTel());
  426. organizationIdentity.setQq(orgIdentityBo.getQq());
  427. organizationIdentity.setPostalAddress(orgIdentityBo.getPostalAddress());
  428. organizationIdentity.setPostcode(orgIdentityBo.getPostcode());
  429. organizationIdentity.setLegalPerson(orgIdentityBo.getLegalPerson());
  430. organizationIdentity.setFirstContacts(orgIdentityBo.getFirstContacts());
  431. organizationIdentity.setSecondContacts(orgIdentityBo.getSecondContacts());
  432. organizationIdentity.setThirdContacts(orgIdentityBo.getThirdContacts());
  433. organizationIdentity.setFirstMobile(orgIdentityBo.getFirstMobile());
  434. organizationIdentity.setSecondMobile(orgIdentityBo.getSecondMobile());
  435. organizationIdentity.setThirdMobile(orgIdentityBo.getThirdMobile());
  436. if (identity == null) {
  437. organizationIdentity.setId(UUID.randomUUID().toString());
  438. organizationIdentity.setUid(TokenManager.getUserId());
  439. organizationIdentityService.insert(organizationIdentity);
  440. } else {
  441. organizationIdentity.setId(identity.getId());
  442. organizationIdentityService.updateByPrimaryKeySelective(organizationIdentity);
  443. }
  444. res.setData(orgIdentityBo);
  445. return res;
  446. }
  447. /**
  448. * 团体会员单位资料
  449. *
  450. * @param orgInfo
  451. * @return
  452. */
  453. @RequestMapping(value = "/orgPro", method = RequestMethod.POST)
  454. public Result groupProInfo(OrgProBo proBo) {
  455. Result res = new Result();
  456. OrganizationInfo orgInfo = proBo.getInfo();
  457. OrganizationProperties orgPro = proBo.getPro();
  458. OrganizationInfo info = organizationInfoService.selectOrgInfoByUserId(TokenManager.getUserId());
  459. OrganizationProperties pro = organizationPropertiesService.selectOrgProByUserId(TokenManager.getUserId());
  460. if (info == null) {
  461. orgInfo.setId(UUID.randomUUID().toString());
  462. orgInfo.setUid(TokenManager.getUserId());
  463. orgInfo = organizationInfoService.insert(orgInfo);
  464. } else {
  465. orgInfo.setId(info.getId());
  466. organizationInfoService.updateByPrimaryKeySelective(orgInfo);
  467. }
  468. if (pro == null) {
  469. orgPro.setId(UUID.randomUUID().toString());
  470. orgPro.setOid(orgInfo.getId());
  471. organizationPropertiesService.insert(orgPro);
  472. } else {
  473. orgPro.setId(pro.getId());
  474. organizationPropertiesService.updateByPrimaryKeySelective(orgPro);
  475. }
  476. res.setData(proBo);
  477. return res;
  478. }
  479. /**
  480. * 团体会员技术能力
  481. *
  482. * @param orgTech
  483. * @return
  484. */
  485. @RequestMapping(value = "/orgTech", method = RequestMethod.POST)
  486. public Result tech(OrganizationTech orgTech) {
  487. Result res = new Result();
  488. OrganizationTech tech = organizationTechService.selectOrgTechByUserId(TokenManager.getUserId());
  489. if (tech == null) {
  490. orgTech.setId(UUID.randomUUID().toString());
  491. orgTech.setUid(TokenManager.getUserId());
  492. organizationTechService.insert(orgTech);
  493. } else {
  494. orgTech.setId(tech.getId());
  495. organizationTechService.updateByPrimaryKeySelective(orgTech);
  496. }
  497. res.setData(orgTech);
  498. return res;
  499. }
  500. /**
  501. * 个人会员基本信息/团体会员基本信息
  502. *
  503. * @return
  504. */
  505. @RequestMapping(value = "/base", method = RequestMethod.GET)
  506. public Result basic() {
  507. Result res = new Result();
  508. UidAndTypeBo ub = basicInfo(userService);
  509. if (ub.getType() == 0) {
  510. UserIdentityBo u = userIdentityService.selectUserIdentityBoByUserId(ub.getUid());
  511. res.setData(u);
  512. } else {
  513. OrgIdentityBo o = organizationIdentityService.selectOrgIdentityBoByUserId(ub.getUid());
  514. res.setData(o);
  515. }
  516. return res;
  517. }
  518. /**
  519. * 个人资料/团体会员资料
  520. *
  521. * @return
  522. */
  523. @RequestMapping(value = "/member", method = RequestMethod.GET)
  524. public Result member() {
  525. Result res = new Result();
  526. UidAndTypeBo ub = basicInfo(userService);
  527. if (ub.getType() == 0) {
  528. UserInfoBo u = userInfoService.selectUserInfoBoByUserId(ub.getUid());
  529. res.setData(u);
  530. } else {
  531. OrganizationInfo o = organizationInfoService.selectOrgInfoByUserId(ub.getUid());
  532. OrganizationProperties p = organizationPropertiesService.selectOrgProByUserId(ub.getUid());
  533. OrgProBo bo = new OrgProBo(o, p);
  534. res.setData(bo);
  535. }
  536. return res;
  537. }
  538. /**
  539. * 个人会员教育信息
  540. *
  541. * @return
  542. */
  543. @RequestMapping(value = "/educate", method = RequestMethod.GET)
  544. public Result educate() {
  545. Result res = new Result();
  546. UidAndTypeBo ub = basicInfo(userService);
  547. UserEdu u = userEduService.selectUserEduByUserId(ub.getUid());
  548. res.setData(u);
  549. return res;
  550. }
  551. /**
  552. * 个人会员职业信息/团体会员技术能力
  553. *
  554. * @return
  555. */
  556. @RequestMapping(value = "/job", method = RequestMethod.GET)
  557. public Result job() {
  558. Result res = new Result();
  559. UidAndTypeBo ub = basicInfo(userService);
  560. if (ub.getType() == 0) {
  561. UserCareer u = userCareerService.selectUserCareerByUserId(ub.getUid());
  562. res.setData(u);
  563. } else {
  564. OrganizationTech o = organizationTechService.selectOrgTechByUserId(ub.getUid());
  565. res.setData(o);
  566. }
  567. return res;
  568. }
  569. /**
  570. * 个人/团体能力标签
  571. *
  572. * @return
  573. */
  574. @RequestMapping(value = "/ability", method = RequestMethod.GET)
  575. public Result ability() {
  576. Result res = new Result();
  577. UidAndTypeBo ub = basicInfo(userService);
  578. UserAbility u = userAbilityService.selectUserAbilityByUserId(ub.getUid());
  579. res.setData(u);
  580. return res;
  581. }
  582. /**
  583. * 团体人力资源情况入口
  584. * @return
  585. */
  586. @RequestMapping(value = "/humanResource", method = RequestMethod.GET)
  587. @ResponseBody
  588. public Result humanResource(Integer year, String pageNo, String pageSize ) {
  589. Result res = new Result();
  590. res = checkCertify(res);
  591. if (res.getError().isEmpty()) {
  592. Integer pNo = 1;
  593. Integer pSize = 10;
  594. if (StringUtils.isNumeric(pageSize)) {
  595. pSize = Integer.parseInt(pageSize);
  596. }
  597. if (StringUtils.isNumeric(pageNo)) {
  598. pNo = Integer.parseInt(pageNo);
  599. }
  600. res.setData(orgHumanResourceService.listOrgHumanResource(year, pNo, pSize, TokenManager.getUserId()));
  601. }
  602. return res;
  603. }
  604. /**
  605. * 团体人力资源情况修改保存(用户端)
  606. * @param orgHumanResource
  607. * @return
  608. */
  609. @RequestMapping(value = "/SaveHumanResource", method = RequestMethod.POST)
  610. public Result SaveHumanResource(OrgHumanResource orgHumanResource){
  611. Result res = new Result();
  612. if (null == orgHumanResource.getId()){
  613. if (null != orgHumanResourceService.selectOrgHumanResourceByUidAndYear(orgHumanResource.getYear(),
  614. orgHumanResource.getUid())){
  615. res.getError().add(buildError(ErrorConstants.DUPLICATE_DATA_ERROR, "当年度人力资源情况已录入!"));
  616. return res;
  617. }
  618. orgHumanResource.setId(UUID.randomUUID().toString());
  619. orgHumanResource.setUid(TokenManager.getUserId());
  620. orgHumanResource.setDeletedSign(0);
  621. orgHumanResourceService.insert(orgHumanResource);
  622. } else {
  623. orgHumanResourceService.updateByPrimaryKeySelective(orgHumanResource);
  624. }
  625. return res;
  626. }
  627. /**
  628. * 删除团体人力资源
  629. * @return
  630. */
  631. public Result deleteHumanResource(@RequestParam(name = "ids[]", required = true) String[] ids){
  632. Result res = new Result();
  633. List<String> id = new ArrayList<String>();
  634. for (String s : ids) {
  635. id.add(s);
  636. }
  637. orgHumanResourceService.batchDeleteByPrimaryKey(id);
  638. return res;
  639. }
  640. /**
  641. * 首页
  642. *
  643. * @return
  644. */
  645. @RequestMapping(value = "/homePage", method = RequestMethod.GET)
  646. public Result homePage() {
  647. Result res = new Result();
  648. if (TokenManager.isLogin()) {
  649. UserPageHomeBo userPageHomeBo = userService.selectUserPageHomeBoByUserId(TokenManager.getUserId());
  650. res.setData(userPageHomeBo);
  651. }
  652. return res;
  653. }
  654. /**
  655. * 登陆后返回用户基本信息
  656. *
  657. * @return
  658. */
  659. @RequestMapping(value = "/afterSignIn", method = RequestMethod.GET)
  660. public Result afterSignIn() {
  661. Result res = new Result();
  662. if (TokenManager.isLogin()) {
  663. User u = userService.selectByPrimaryKey(TokenManager.getUserId());
  664. res.setData(u);
  665. }
  666. return res;
  667. }
  668. /**
  669. * 个人实名认证流程入口
  670. *
  671. * @return
  672. */
  673. @RequestMapping(value = "/userPro", method = RequestMethod.GET)
  674. public Result userProcess() {
  675. Result res = new Result();
  676. if (TokenManager.isLogin()) {
  677. res.setData(userIdentityService.selectUserIdentityByUserId(TokenManager.getUserId()));
  678. }
  679. return res;
  680. }
  681. /**
  682. * 个人实名认证流程下一步
  683. */
  684. @RequestMapping(value = "/userNextPro", method = RequestMethod.POST)
  685. public Result userNextProcess(UserIdentity userIdentity, String verificationCode) {
  686. Result res = new Result();
  687. if (1 == userIdentity.getProcess()) {
  688. if (!TokenManager.getSession().getAttribute(VerifyCodeUtils.V_CODE).equals(verificationCode)) {
  689. res.getError().add(buildError(ErrorConstants.VCODE_ERROR, "验证码错误"));
  690. return res;
  691. }
  692. }
  693. if (3 == userIdentity.getProcess()) {
  694. UserIdentity u = userIdentityService.selectUserIdentityByUserId(TokenManager.getUserId());
  695. u.setAuditStatus(1);
  696. userIdentityService.updateByPrimaryKeySelective(u);
  697. }
  698. if (5 == userIdentity.getProcess()) {
  699. UserIdentity u = userIdentityService.selectUserIdentityByUserId(TokenManager.getUserId());
  700. if ((System.currentTimeMillis() - u.getPaymentDate().getTime()) > 432000000) {
  701. u.setAuditStatus(4);
  702. userIdentityService.updateByPrimaryKeySelective(u);
  703. res.getError().add(buildError("", "1"));// 超过打款日期5日,无法提交确认
  704. return res;
  705. }
  706. if (3 == u.getWrongCount()) {
  707. u.setAuditStatus(4);
  708. u.setProcess(5);
  709. userIdentityService.updateByPrimaryKeySelective(u);
  710. res.getError().add(buildError("", "2"));// 输入错误金额次数过多
  711. return res;
  712. }
  713. if (0 != (u.getAmountMoney().compareTo(userIdentity.getAmountMoney()))) {
  714. int t = 3 - u.getWrongCount() - 1;
  715. u.setWrongCount(u.getWrongCount() + 1);
  716. if (0 == t) {
  717. u.setAuditStatus(4);
  718. u.setProcess(5);
  719. res.getError().add(buildError("", "2"));// 输入错误金额次数过多
  720. } else {
  721. res.getError().add(buildError("", "输入打款金额错误,您还有" + t + "次机会"));
  722. }
  723. userIdentityService.updateByPrimaryKeySelective(u);
  724. return res;
  725. }
  726. userIdentity.setAuditStatus(5);
  727. }
  728. return dealUserProcess(res, userIdentity, TokenManager.getUserId());
  729. }
  730. /**
  731. * 团体实名认证流程入口
  732. */
  733. @RequestMapping(value = "/orgProcess", method = RequestMethod.GET)
  734. public Result orgProcess() {
  735. Result res = new Result();
  736. if (TokenManager.isLogin()) {
  737. res.setData(organizationIdentityService.selectOrgIdentityByUserId(TokenManager.getUserId()));
  738. }
  739. return res;
  740. }
  741. /**
  742. * 团体实名认证流程下一步
  743. * @throws ParseException
  744. */
  745. @RequestMapping(value = "/orgNextPro", method = RequestMethod.POST)
  746. public Result orgNextProcess(OrganizationIdentity orgIdentity, String listedDateFormattedDate, String verificationCode) throws ParseException {
  747. Result res = new Result();
  748. if (1 == orgIdentity.getProcess()) {
  749. if (!TokenManager.getSession().getAttribute(VerifyCodeUtils.V_CODE).equals(verificationCode)) {
  750. res.getError().add(buildError(ErrorConstants.VCODE_ERROR, "验证码错误"));
  751. return res;
  752. }
  753. if (!StringUtils.isBlank(listedDateFormattedDate)){
  754. orgIdentity.setListedDate(DateUtils.parseDate(listedDateFormattedDate, AFTConstants.YYYYMMDD));
  755. }
  756. /*res.setData(organizationIdentityService.saveLastYearTaxReprotUrl(orgIdentity, TokenManager.getUserId()));
  757. return res;*/
  758. }
  759. if (3 == orgIdentity.getProcess()) {
  760. OrganizationIdentity o = organizationIdentityService.selectOrgIdentityByUserId(TokenManager.getUserId());
  761. o.setAuditStatus(1);
  762. organizationIdentityService.updateByPrimaryKeySelective(o);
  763. return res;
  764. }
  765. if (5 == orgIdentity.getProcess()) {
  766. OrganizationIdentity o = organizationIdentityService.selectOrgIdentityByUserId(TokenManager.getUserId());
  767. if (System.currentTimeMillis() - o.getPaymentDate().getTime() > 432000000) {
  768. o.setAuditStatus(4);
  769. organizationIdentityService.updateByPrimaryKeySelective(o);
  770. res.getError().add(buildError("", "1"));// 超过打款日期5日,无法提交确认
  771. return res;
  772. }
  773. if (3 == o.getWrongCount()) {
  774. o.setAuditStatus(4);
  775. o.setProcess(5);
  776. organizationIdentityService.updateByPrimaryKeySelective(o);
  777. res.getError().add(buildError("", "2"));// 输入错误金额次数过多
  778. return res;
  779. }
  780. if (0 != (o.getValidationAmount().compareTo(orgIdentity.getValidationAmount()))) {
  781. int t = 3 - o.getWrongCount() - 1;
  782. o.setWrongCount(o.getWrongCount() + 1);
  783. if (0 == t) {
  784. o.setAuditStatus(4);
  785. o.setProcess(6);
  786. res.getError().add(buildError("", "2"));// 输入错误金额次数过多
  787. } else {
  788. res.getError().add(buildError("", "输入打款金额错误,您还有" + t + "次机会"));
  789. }
  790. organizationIdentityService.updateByPrimaryKeySelective(o);
  791. return res;
  792. }
  793. orgIdentity.setAuditStatus(5);
  794. }
  795. return dealOrgProcess(res, orgIdentity, TokenManager.getUserId());
  796. }
  797. /**
  798. * 认证失败
  799. */
  800. @RequestMapping(value = "/identFailed", method = RequestMethod.GET)
  801. public Result authenticationFailed() {
  802. Result res = new Result();
  803. return dealFaild(res);
  804. }
  805. /**
  806. * 管理端确认用户认证
  807. *
  808. * @param auditStatus
  809. * @param money
  810. * @param uid
  811. * @return
  812. */
  813. @RequestMapping(value = "/adminConfirmIdent", method = RequestMethod.POST)
  814. public Result adminConfirmIdent(Integer auditStatus, BigDecimal money, String uid) {
  815. Result res = new Result();
  816. if (0 == userService.selectByPrimaryKey(uid).getType()) {
  817. UserIdentity u = userIdentityService.selectUserIdentityByUserId(uid);
  818. u.setAuditStatus(auditStatus);
  819. u.setAmountMoney(money);
  820. res.setData(userIdentityService.updateByPrimaryKeySelective(u));
  821. } else {
  822. OrganizationIdentity o = organizationIdentityService.selectOrgIdentityByUserId(uid);
  823. o.setAuditStatus(auditStatus);
  824. o.setValidationAmount(money);
  825. res.setData(organizationIdentityService.updateByPrimaryKeySelective(o));
  826. }
  827. return res;
  828. }
  829. /**
  830. * 获取公司联系人
  831. * @param uid
  832. * @return
  833. */
  834. @RequestMapping(value = "/getContacts", method = RequestMethod.GET)
  835. public Result getContacts(){
  836. Result res = new Result();
  837. res.setData(organizationIdentityService.selectContactsByUserId(TokenManager.getUserId()));
  838. return res;
  839. }
  840. // 认证失败清除相关认证信息
  841. private Result dealFaild(Result res) {
  842. if (0 == userService.selectByPrimaryKey(TokenManager.getUserId()).getType()) {
  843. UserIdentity u = userIdentityService.selectUserIdentityByUserId(TokenManager.getUserId());
  844. UserIdentity user = new UserIdentity();
  845. user.setId(u.getId());
  846. user.setUid(u.getUid());
  847. user.setProcess(0);
  848. user.setWrongCount(0);
  849. user.setAmountMoney(new BigDecimal(0));
  850. user.setAuditStatus(0);
  851. res.setData(userIdentityService.updateByPrimaryKey(user));
  852. } else {
  853. OrganizationIdentity o = organizationIdentityService.selectOrgIdentityByUserId(TokenManager.getUserId());
  854. OrganizationIdentity org = new OrganizationIdentity();
  855. org.setId(o.getId());
  856. org.setUid(o.getUid());
  857. org.setProcess(0);
  858. org.setWrongCount(0);
  859. org.setAuditStatus(0);
  860. org.setValidationAmount(new BigDecimal(0));
  861. res.setData(organizationIdentityService.updateByPrimaryKey(org));
  862. }
  863. return res;
  864. }
  865. // orgProcess
  866. private Result dealOrgProcess(Result res, OrganizationIdentity o, String uid) {
  867. res.setData(organizationIdentityService.saveOrgIndentityProcess(res, o, uid));
  868. return res;
  869. }
  870. // userProcess
  871. private Result dealUserProcess(Result res, UserIdentity u, String uid) {
  872. res.setData(userIdentityService.saveUserIdentityProcess(res, u, uid));
  873. return res;
  874. }
  875. private void cleanCodeSession() {
  876. TokenManager.getSession().removeAttribute(VerifyCodeUtils.RESET_CODE);
  877. TokenManager.getSession().removeAttribute(VerifyCodeUtils.RESET_CODE_TIME);
  878. TokenManager.getSession().removeAttribute(VerifyCodeUtils.M_CODE);
  879. TokenManager.getSession().removeAttribute(VerifyCodeUtils.M_CODE_TIME);
  880. }
  881. private UidAndTypeBo basicInfo(UserService userService) {
  882. User u = userService.selectByPrimaryKey(TokenManager.getUserId());
  883. UidAndTypeBo ub = new UidAndTypeBo();
  884. ub.setType(u.getType());
  885. ub.setUid(u.getId());
  886. return ub;
  887. }
  888. // 判断用户是否通过认证
  889. private Result checkCertify(Result res) {
  890. OrganizationIdentity o = organizationIdentityService.selectOrgIdentityByUserId(TokenManager.getUserId());
  891. if (null == o || 5 != o.getAuditStatus()) {
  892. res.getError().add(buildError(ErrorConstants.NON_CERTIFIED, "未通过实名认证,无法操作!"));
  893. }
  894. return res;
  895. }
  896. }