UserIdentityServiceImpl.java 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683
  1. package com.goafanti.user.service.impl;
  2. import java.util.ArrayList;
  3. import java.util.Calendar;
  4. import java.util.HashMap;
  5. import java.util.List;
  6. import java.util.Map;
  7. import java.util.UUID;
  8. import org.apache.commons.lang3.StringUtils;
  9. import org.slf4j.Logger;
  10. import org.slf4j.LoggerFactory;
  11. import org.springframework.beans.BeanUtils;
  12. import org.springframework.beans.factory.annotation.Autowired;
  13. import org.springframework.beans.factory.annotation.Value;
  14. import org.springframework.cache.annotation.CacheEvict;
  15. import org.springframework.stereotype.Service;
  16. import com.goafanti.app.bo.ExpertsListBo;
  17. import com.goafanti.app.bo.consultantListBo;
  18. import com.goafanti.common.bo.ReletivelyIndustry;
  19. import com.goafanti.common.bo.Result;
  20. import com.goafanti.common.bo.fieldGlossoryBo;
  21. import com.goafanti.common.constant.AFTConstants;
  22. import com.goafanti.common.dao.DistrictGlossoryMapper;
  23. import com.goafanti.common.dao.IndustryCategoryMapper;
  24. import com.goafanti.common.dao.JtCollectSearchMapper;
  25. import com.goafanti.common.dao.NoticeMapper;
  26. import com.goafanti.common.dao.UserIdentityMapper;
  27. import com.goafanti.common.dao.UserInterestMapper;
  28. import com.goafanti.common.dao.UserMapper;
  29. import com.goafanti.common.dao.UserRoleMapper;
  30. import com.goafanti.common.enums.AchievementAuditStatus;
  31. import com.goafanti.common.enums.CertifySubmitType;
  32. import com.goafanti.common.enums.IdentityAuditStatus;
  33. import com.goafanti.common.enums.NoticeReadStatus;
  34. import com.goafanti.common.enums.NoticeStatus;
  35. import com.goafanti.common.enums.SocietyTagStatus;
  36. import com.goafanti.common.enums.UserLevel;
  37. import com.goafanti.common.enums.collectType;
  38. import com.goafanti.common.model.JtCollectSearch;
  39. import com.goafanti.common.model.Notice;
  40. import com.goafanti.common.model.User;
  41. import com.goafanti.common.model.UserIdentity;
  42. import com.goafanti.common.utils.LoggerUtils;
  43. import com.goafanti.core.mybatis.BaseMybatisDao;
  44. import com.goafanti.core.mybatis.page.Pagination;
  45. import com.goafanti.core.shiro.token.TokenManager;
  46. import com.goafanti.portal.bo.UserSubscriberListBo;
  47. import com.goafanti.user.bo.Advertisings;
  48. import com.goafanti.user.bo.AuditorUserIdentityDetailBo;
  49. import com.goafanti.user.bo.CustomerAuditListBo;
  50. import com.goafanti.user.bo.InputUserIdentity;
  51. import com.goafanti.user.bo.MyInterestedBo;
  52. import com.goafanti.user.bo.UserIdentityBo;
  53. import com.goafanti.user.bo.UserIdentityDetailAdminBo;
  54. import com.goafanti.user.service.UserIdentityService;
  55. @Service
  56. public class UserIdentityServiceImpl extends BaseMybatisDao<UserIdentityMapper> implements UserIdentityService {
  57. @Autowired
  58. private UserIdentityMapper userIdentityMapper;
  59. @Autowired
  60. private UserMapper userMapper;
  61. @Autowired
  62. private UserRoleMapper userRoleMapper;
  63. @Autowired
  64. private NoticeMapper noticeMapper;
  65. @Autowired
  66. DistrictGlossoryMapper districtGlossoryMapper;
  67. @Autowired
  68. IndustryCategoryMapper industryCategoryMapper;
  69. @Autowired
  70. UserInterestMapper userInterestMapper;
  71. @Autowired
  72. JtCollectSearchMapper jtCollectSearchMapper;
  73. @Value(value="${collect_flag}")
  74. private Boolean collectFlag ;
  75. private static final Logger logger = LoggerFactory.getLogger(UserIdentityServiceImpl.class);
  76. @Override
  77. public UserIdentity selectUserIdentityByUserId(String uid) {
  78. return userIdentityMapper.selectUserIdentityByUserId(uid);
  79. }
  80. @Override
  81. public UserIdentity insert(UserIdentity userIdentity) {
  82. userIdentityMapper.insert(userIdentity);
  83. return userIdentity;
  84. }
  85. @Override
  86. public int updateByPrimaryKeySelective(UserIdentity userIdentity) {
  87. return userIdentityMapper.updateByPrimaryKeySelective(userIdentity);
  88. }
  89. @Override
  90. public UserIdentityBo selectUserIdentityBoByUserId(String uid) {
  91. return userIdentityMapper.selectUserIdentityBoByUserId(uid);
  92. }
  93. @Override
  94. public int updateByPrimaryKey(UserIdentity u) {
  95. return userIdentityMapper.updateByPrimaryKey(u);
  96. }
  97. @Override
  98. public int saveUserIdentityProcess(Result res, UserIdentity userIdentity, String uid) {
  99. UserIdentity identity = userIdentityMapper.selectUserIdentityByUserId(uid);
  100. if (null == identity) {
  101. userIdentity.setId(UUID.randomUUID().toString());
  102. userIdentity.setUid(uid);
  103. userIdentity.setWrongCount(0);
  104. userIdentity.setAuditStatus(0);
  105. return userIdentityMapper.insert(userIdentity);
  106. } else {
  107. userIdentity.setId(identity.getId());
  108. if (null != userIdentity.getAuditStatus() && 5 == userIdentity.getAuditStatus()) {
  109. User u = new User();
  110. u.setId(userIdentity.getUid());
  111. u.setLvl(1);
  112. userMapper.updateByPrimaryKeySelective(u);
  113. }
  114. return userIdentityMapper.updateByPrimaryKeySelective(userIdentity);
  115. }
  116. }
  117. @Override
  118. public int updateUserDetail(UserIdentity u, String saveSign, Integer level) {
  119. User user = userMapper.selectByPrimaryKey(u.getUid());
  120. if (!UserLevel.GENERAL.getCode().equals(user.getLvl())
  121. && !CertifySubmitType.SUBMIT.getCode().equals(saveSign)) {
  122. user.setLvl(level);
  123. userMapper.updateByPrimaryKeySelective(user);
  124. }
  125. if (CertifySubmitType.SUBMIT.getCode().equals(saveSign)) {
  126. createAuditorNotice(user);
  127. }
  128. return userIdentityMapper.updateByPrimaryKeySelective(u);
  129. }
  130. @Override
  131. public int updateUserDetailByAuditAdmin(UserIdentity ui, String aid, String mid, Integer level) {
  132. // 审核员UPDATE_USER_DETAIL
  133. User user = userMapper.selectByPrimaryKey(ui.getUid());
  134. if (!IdentityAuditStatus.PASSED.getCode().equals(ui.getAuditStatus())) {
  135. user.setLvl(UserLevel.GENERAL.getCode());
  136. userMapper.updateByPrimaryKeySelective(user);
  137. createNotice(user, ui.getAuditStatus());
  138. }
  139. if (IdentityAuditStatus.PASSED.getCode().equals(ui.getAuditStatus())) {
  140. /*
  141. * if (UserLevel.GENERAL.getCode().equals(level)) {
  142. * user.setLvl(UserLevel.CERTIFIED.getCode()); }
  143. */
  144. user.setLvl(UserLevel.CERTIFIED.getCode());
  145. user.setAid(aid);
  146. user.setMid(mid);
  147. userMapper.updateByPrimaryKeySelective(user);
  148. createNotice(user, ui.getAuditStatus());
  149. }
  150. return userIdentityMapper.updateByPrimaryKeySelective(ui);
  151. }
  152. @Override
  153. public UserIdentity insertByAdmin(UserIdentity ui, String saveSign) {
  154. userIdentityMapper.insert(ui);
  155. User u = userMapper.selectByPrimaryKey(ui.getUid());
  156. if (!TokenManager.hasRole(AFTConstants.AUDITORADMIN) && !TokenManager.hasRole(AFTConstants.SUPERADMIN)
  157. && CertifySubmitType.SUBMIT.getCode().equals(saveSign)) {
  158. u.setAid(TokenManager.getAdminId());
  159. userMapper.updateByPrimaryKeySelective(u);
  160. createAuditorNotice(u);
  161. }
  162. return ui;
  163. }
  164. @SuppressWarnings("unchecked")
  165. @Override
  166. public Pagination<UserSubscriberListBo> listSubscriber(String url,String name, Integer level, String field, Integer province,
  167. Integer city, Integer area, Integer international, Integer pNo, Integer pSize, Integer auditStatus) {
  168. Map<String, Object> params = new HashMap<>();
  169. if (StringUtils.isNotBlank(url)) {
  170. params.put("url", url);
  171. }
  172. if (StringUtils.isNotBlank(name)) {
  173. params.put("name", name);
  174. }
  175. if (null != level) {
  176. params.put("level", level);
  177. }
  178. if (StringUtils.isNotBlank(field)) {
  179. params.put("field", field);
  180. }
  181. if (null != province) {
  182. params.put("province", province);
  183. }
  184. if (null != city) {
  185. params.put("city", city);
  186. }
  187. if (null != area) {
  188. params.put("area", area);
  189. }
  190. if (null != international) {
  191. params.put("international", international);
  192. }
  193. if (pNo == null || pNo < 0) {
  194. pNo = 1;
  195. }
  196. if (pSize == null || pSize < 0 || pSize > 12) {
  197. pSize = 12;
  198. }
  199. if (null != auditStatus) {
  200. params.put("auditStatus", auditStatus);
  201. }
  202. return (Pagination<UserSubscriberListBo>) findPage("findSearchSubscriberListByPage",
  203. "findSearchSubscriberCount", params, pNo, pSize);
  204. }
  205. // 给业务员及客户经理发送通知
  206. private void createNotice(User u, Integer status) {
  207. if (!StringUtils.isBlank(u.getAid())) {
  208. Notice n = new Notice();
  209. n.setPid(u.getAid());
  210. n.setAid(u.getAid());
  211. n.setUid(u.getId());
  212. notice(n, status);
  213. }
  214. if (!StringUtils.isBlank(u.getMid())) {
  215. Notice n = new Notice();
  216. n.setUid(u.getId());
  217. n.setAid(u.getMid());
  218. if (!StringUtils.isBlank(u.getAid())) {
  219. n.setPid(u.getAid());
  220. }
  221. notice(n, status);
  222. }
  223. }
  224. // 给所有审核员发送审核通知
  225. private void createAuditorNotice(User u) {
  226. List<String> ids = userRoleMapper.listAuditor();
  227. List<Notice> list = new ArrayList<>();
  228. if (null != ids && ids.size() > 0) {
  229. for (String s : ids) {
  230. Notice n = new Notice();
  231. Calendar now = Calendar.getInstance();
  232. now.set(Calendar.MILLISECOND, 0);
  233. n.setId(UUID.randomUUID().toString());
  234. n.setCreateTime(now.getTime());
  235. n.setReaded(NoticeReadStatus.UNREAD.getCode());
  236. if (null != u) {
  237. n.setPid(u.getAid());
  238. }
  239. n.setUid(u.getId());
  240. n.setAid(s);
  241. n.setContent(NoticeStatus.PERSONALCERTIFY.getDesc() + " " + IdentityAuditStatus.COMMITTED.getDesc());
  242. n.setNoticeType(NoticeStatus.PERSONALCERTIFY.getCode());
  243. list.add(n);
  244. }
  245. noticeMapper.insertBatch(list);
  246. }
  247. }
  248. @Override
  249. public AuditorUserIdentityDetailBo selectAuditorUserIdentityByUserId(String uid) {
  250. return userIdentityMapper.selectAuditorUserIdentityByUserId(uid);
  251. }
  252. private void notice(Notice n, Integer status) {
  253. Calendar now = Calendar.getInstance();
  254. now.set(Calendar.MILLISECOND, 0);
  255. n.setId(UUID.randomUUID().toString());
  256. n.setCreateTime(now.getTime());
  257. n.setReaded(NoticeReadStatus.UNREAD.getCode());
  258. String content = NoticeStatus.PERSONALCERTIFY.getDesc();
  259. if (IdentityAuditStatus.UNCOMMITTED.getCode() == status) {
  260. content = content + " " + IdentityAuditStatus.UNCOMMITTED.getDesc();
  261. } else if (IdentityAuditStatus.COMMITTED.getCode() == status) {
  262. content = content + " " + IdentityAuditStatus.COMMITTED.getDesc();
  263. } else if (IdentityAuditStatus.UNPAID.getCode() == status) {
  264. content = content + " " + IdentityAuditStatus.UNPAID.getDesc();
  265. } else if (IdentityAuditStatus.PAID.getCode() == status) {
  266. content = content + " " + IdentityAuditStatus.PAID.getDesc();
  267. } else if (IdentityAuditStatus.PASSED.getCode() == status) {
  268. content = content + " " + IdentityAuditStatus.PASSED.getDesc();
  269. } else {
  270. content = content + " " + IdentityAuditStatus.NOTPASSED.getDesc();
  271. }
  272. n.setContent(content);
  273. n.setNoticeType(NoticeStatus.PERSONALCERTIFY.getCode());
  274. // noticeMapper.insert(n);
  275. }
  276. @Override
  277. public UserIdentityDetailAdminBo selectUserIdentityByUserIdAdmin(String uid) {
  278. UserIdentity ui = userIdentityMapper.selectUserIdentityByUserId(uid);
  279. User u = userMapper.selectByPrimaryKey(uid);
  280. UserIdentityDetailAdminBo bo = new UserIdentityDetailAdminBo();
  281. if (ui != null) {
  282. BeanUtils.copyProperties(ui, bo);
  283. }
  284. bo.setLevel(u.getLvl().toString());
  285. return bo;
  286. }
  287. @CacheEvict(value = "internationalUserList", allEntries = true)
  288. public void cleanInternationalUser() {
  289. LoggerUtils.debug(logger, "清除国际专家列表");
  290. }
  291. @Override
  292. public UserIdentityBo expertsDetail(String uid) {
  293. UserIdentityBo u=userIdentityMapper.selectUserIdentityByUid(uid);
  294. /* if (null!=u.getProvince()) {
  295. u.setProvince0(districtGlossoryMapper.selectByPrimaryKey(u.getProvince()).getName());
  296. }
  297. if (null!=u.getCity()) {
  298. u.setCity0(String.valueOf(districtGlossoryMapper.selectByPrimaryKey(u.getCity()).getName()));
  299. }
  300. if (null!=u.getArea()) {
  301. u.setArea0(String.valueOf(districtGlossoryMapper.selectByPrimaryKey(u.getArea()).getName()));
  302. }
  303. if (null!=u.getIndustry()) {
  304. u.setIndustry0(String.valueOf(industryCategoryMapper.selectByPrimaryKey(u.getIndustry()).getName()));
  305. }
  306. if (null!=u.getUid()) {
  307. u.setCountInterest(String.valueOf(userInterestMapper.countByToUid(u.getUid())));
  308. }
  309. String id=TokenManager.getUserId();
  310. if(TokenManager.isLogin()&&userInterestMapper.checkUidAndDid(uid,id)>0){
  311. u.setInterest("1");
  312. }else {
  313. u.setInterest("0");
  314. }
  315. */ return u;
  316. }
  317. @SuppressWarnings("unchecked")
  318. @Override
  319. public Pagination<UserIdentityBo> expertsList(String name,String industry, Integer pNo, Integer pSize) {
  320. Map<String, Object> params = new HashMap<>();
  321. if (StringUtils.isNotBlank(industry)) {
  322. params.put("industry", industry);
  323. }
  324. if (StringUtils.isNotBlank(name)) {
  325. params.put("name", name);
  326. }
  327. if (pNo == null || pNo < 0) {
  328. pNo = 1;
  329. }
  330. if (pSize == null || pSize < 0 || pSize > 12) {
  331. pSize = 10;
  332. }
  333. Pagination<UserIdentityBo> p= (Pagination<UserIdentityBo>) findPage("findUserIdentityListByPage",
  334. "findUserIdentityCount", params, pNo, pSize);
  335. List<UserIdentityBo> l=(List<UserIdentityBo>) p.getList();
  336. /*for (UserIdentityBo u : l) {
  337. int i=userInterestMapper.countInterest(u.getUid());
  338. u.setCountInterest(String.valueOf(i));
  339. }*/
  340. return p;
  341. }
  342. @Override
  343. public List<fieldGlossoryBo> industryList() {
  344. List<fieldGlossoryBo> list=industryCategoryMapper.selectindustryList();
  345. return list;
  346. }
  347. @SuppressWarnings("unchecked")
  348. @Override
  349. public Pagination<consultantListBo> consultantList(Integer pNo, Integer pSize) {
  350. Map<String, Object> params = new HashMap<>();
  351. if (pNo == null || pNo < 0) {
  352. pNo = 1;
  353. }
  354. if (pSize == null || pSize < 0 || pSize > 12) {
  355. pSize = 10;
  356. }
  357. Pagination<consultantListBo> p=(Pagination<consultantListBo>) findPage("findConsultantListByPage",
  358. "findConsultantCount", params, pNo, pSize);
  359. return p;
  360. }
  361. @Override
  362. public consultantListBo consultantDetail(String id) {
  363. consultantListBo c=userIdentityMapper.selectconsultantByUid(id);
  364. if (TokenManager.isLogin()&&userInterestMapper.checkUidAndDid(id, TokenManager.getUserId())>0) {
  365. c.setInterest("1");
  366. }else {
  367. c.setInterest("0");
  368. }
  369. return c;
  370. }
  371. @Override
  372. public List<Advertisings> advertising() {
  373. List<String> a=new ArrayList<>();
  374. a.add("关于开展2018年度高新技术企业认定专项审计机构申报工作的通知");
  375. a.add("转发四川省经济和信息化委员会关于开展2017年上市补助申报通知的通知");
  376. a.add("关于组织企业参加第十三届中国重庆高新技术成果交易会暨第九届中国国际军民两用技术博览会的通知");
  377. a.add("关于组织参加第十三届中国重庆高新技术交易会暨第九届中国国际军民两用技术博览会的通知");
  378. List<Advertisings> ads=new ArrayList<>();
  379. int i=0;
  380. List<String> l=new ArrayList<>();
  381. for (String s : a) {
  382. i++;
  383. l.add(s);
  384. if (i%2==0) {
  385. ads.add(new Advertisings(l));
  386. l=new ArrayList<>();
  387. }
  388. }
  389. return ads;
  390. }
  391. @SuppressWarnings("unchecked")
  392. @Override
  393. public Pagination<consultantListBo> portalConsultantList(Integer pNo, Integer pSize) {
  394. Pagination<consultantListBo> p=(Pagination<consultantListBo>) findPage("findConsultantListByPage",
  395. "findConsultantCount", new HashMap<>(), pNo, pSize);
  396. List<consultantListBo> list=(List<consultantListBo>) p.getList();
  397. for (consultantListBo c : list) {
  398. if (StringUtils.isNotBlank(TokenManager.getUserId())&&userInterestMapper.checkUidAndDid(c.getId(), TokenManager.getUserId())>0) {
  399. c.setInterest("1");
  400. }else {
  401. c.setInterest("0");
  402. }
  403. }
  404. return p;
  405. }
  406. @Override
  407. public consultantListBo portalconsultantDetail(String id) {
  408. consultantListBo c=userIdentityMapper.selectconsultantByUid(id);
  409. if (StringUtils.isNotBlank(TokenManager.getUserId())&&userInterestMapper.checkUidAndDid(id, TokenManager.getUserId())>0) {
  410. c.setInterest("1");
  411. }else {
  412. c.setInterest("0");
  413. }
  414. return c;
  415. }
  416. @Override
  417. public List<fieldGlossoryBo> domainList() {
  418. List<fieldGlossoryBo> list=industryCategoryMapper.selectDomainList();
  419. return list;
  420. }
  421. @Override
  422. public List<consultantListBo> getConsultantList(int size) {
  423. return userIdentityMapper.getConsultantList(size);
  424. }
  425. @Override
  426. public List<UserIdentityBo> getExperts(Integer size) {
  427. return userIdentityMapper.getExperts( size);
  428. }
  429. @Override
  430. public List<ReletivelyIndustry> selectIndustryReletively() {
  431. return industryCategoryMapper.selectIndustryReletively();
  432. }
  433. @SuppressWarnings("unchecked")
  434. @Override
  435. public Pagination<UserIdentityBo> listInterestedExpert(Integer pageNo, Integer pageSize) {
  436. if(pageNo==null || pageNo<1)pageNo=1;
  437. if(pageSize==null ||pageSize<1)pageSize=10;
  438. Map<String, Object> params=new HashMap<String,Object>();
  439. params.put("uid", TokenManager.getUserId());
  440. // params.put("uid", "1180fa62-7c42-44be-bc41-5583814d69f4");
  441. return (Pagination<UserIdentityBo>) findPage("listInterestedExpert", "listInterestedExpertCount", params, pageNo, pageSize);
  442. }
  443. @SuppressWarnings("unchecked")
  444. @Override
  445. public Pagination<MyInterestedBo> appMyInterestedExpert(Integer type,Integer pageNo, Integer pageSize) {
  446. if(pageNo==null || pageNo<1)pageNo=1;
  447. if(pageSize==null ||pageSize<1)pageSize=10;
  448. Map<String, Object> params=new HashMap<String,Object>();
  449. params.put("uid", TokenManager.getUserId());
  450. params.put("type", type);
  451. // params.put("uid", "1180fa62-7c42-44be-bc41-5583814d69f4");
  452. return (Pagination<MyInterestedBo>) findPage("appMyInterestedExpertList", "appMyInterestedExpertCount", params, pageNo, pageSize);
  453. }
  454. @SuppressWarnings("unchecked")
  455. @Override
  456. public Pagination<MyInterestedBo> getExpertAuditList(
  457. InputUserIdentity identity, Integer pageNo, Integer pageSize) {
  458. if(pageNo==null || pageNo<1)pageNo=1;
  459. if(pageSize==null ||pageSize<1)pageSize=10;
  460. Map<String, Object> params=new HashMap<String,Object>();
  461. //将查询参数弄到map中
  462. if(null != identity.getAuditStatus()) params.put("auditStatus", identity.getAuditStatus());
  463. if(null != identity.getIndustry()) params.put("industry", identity.getIndustry());
  464. if(null != identity.getExpert()) params.put("expert", identity.getExpert());
  465. if(null != identity.getConsultantType()) params.put("consultantType", identity.getConsultantType());
  466. if(StringUtils.isBlank(identity.getUsername())) params.put("username", identity.getIdentifyName());
  467. return (Pagination<MyInterestedBo>) findPage("getExpertAuditList", "getExpertAuditListCount", params, pageNo, pageSize);
  468. }
  469. @Override
  470. public UserIdentity getUserIdentityByUid(String uid) {
  471. //获得用户的认证信息
  472. UserIdentity u = userIdentityMapper.getUserIdentityByUid(uid);
  473. return u;
  474. }
  475. @SuppressWarnings("unchecked")
  476. @Override
  477. public Pagination<CustomerAuditListBo> selectCustomerAuditList(String name, String type, String identity,
  478. Integer pageNo, Integer pageSize) {
  479. if(pageNo==null || pageNo<1)pageNo=1;
  480. if(pageSize==null ||pageSize<1)pageSize=10;
  481. Map<String, Object> params=new HashMap<String,Object>();
  482. if(StringUtils.isNotBlank(name))params.put("name", name);
  483. if(StringUtils.isNotBlank(type))params.put("type", type);
  484. if(StringUtils.isNotBlank(identity))params.put("identity", identity);
  485. return (Pagination<CustomerAuditListBo>) findPage("selectCustomerAuditList", "selectCustomerAuditCount", params, pageNo, pageSize);
  486. }
  487. @SuppressWarnings("unchecked")
  488. @Override
  489. public Pagination<ExpertsListBo> appExpertsList(String name, String industry,Integer sortType, Integer pageNo, Integer pageSize) {
  490. if(pageNo==null || pageNo<1)pageNo=1;
  491. if(pageSize==null ||pageSize<1)pageSize=10;
  492. Map<String, Object> params=new HashMap<String,Object>();
  493. if(StringUtils.isNotBlank(name))params.put("name", name);
  494. if(StringUtils.isNotBlank(industry))params.put("industry", industry);
  495. if(null!=sortType)params.put("sortType", sortType);
  496. if(StringUtils.isNotBlank(TokenManager.getUserId()))params.put("uid", TokenManager.getUserId());
  497. return (Pagination<ExpertsListBo>) findPage("selectCustomerAuditList", "selectCustomerAuditCount", params, pageNo, pageSize);
  498. }
  499. @Override
  500. public ExpertsListBo selectExpertsDetail(String id) {
  501. ExpertsListBo expertsListBo=userIdentityMapper.selectAppExpertsDetail(id,TokenManager.getUserId());
  502. expertsListBo.setCommentDetailResult(userIdentityMapper.expertsCommentByUid(id));
  503. return expertsListBo;
  504. }
  505. @SuppressWarnings("unchecked")
  506. @Override
  507. public Pagination<ExpertsListBo> consultantList(String name, Integer sortType, Integer consultantType,
  508. Integer province, Integer city, Integer area, Integer pageNo, Integer pageSize) {
  509. if(pageNo==null || pageNo<1)pageNo=1;
  510. if(pageSize==null ||pageSize<1)pageSize=10;
  511. Map<String, Object> params=new HashMap<String,Object>();
  512. if(StringUtils.isNotBlank(name))params.put("name", name);
  513. if(null!=province)params.put("province", province);
  514. if(null!=city)params.put("city", city);
  515. if(null!=area)params.put("area", area);
  516. if(null!=consultantType)params.put("consultantType", consultantType);
  517. if(null!=sortType)params.put("sortType", sortType);
  518. if(StringUtils.isNotBlank(TokenManager.getUserId()))params.put("uid", TokenManager.getUserId());
  519. return (Pagination<ExpertsListBo>) findPage("appConsultantList", "appConsultantCount", params, pageNo, pageSize);
  520. }
  521. @Override
  522. public Integer updateAuditing(UserIdentity identity) {
  523. /*int auditStatus = AchievementAuditStatus.AUDITED.getCode().intValue();
  524. if(identity.getAuditStatus().intValue() == 0) {
  525. auditStatus=AchievementAuditStatus.UNAUDITED.getCode().intValue();
  526. }
  527. else auditStatus=AchievementAuditStatus.AUDITED.getCode().intValue();
  528. identity.setAuditStatus(auditStatus);*/
  529. if(collectFlag){
  530. ExpertsListBo u=userIdentityMapper.selectByIdentityId(identity.getId());
  531. if (identity.getAuditStatus()==2) {
  532. JtCollectSearch r=new JtCollectSearch();
  533. if(u.getExpert()==1){
  534. r.setFromTable(collectType.EXPERT.getDesc());
  535. }
  536. if(u.getExpert()==2){
  537. r.setFromTable(collectType.ADVISER.getDesc());
  538. }
  539. r.setKeyword(SocietyTagStatus.getStatus(u.getKeyword()).getDesc());
  540. r.setTitle(u.getUsername());
  541. r.setRowId(u.getUid());
  542. String sum = u.getIntroduction();
  543. if(null != sum && sum.length() > 40){
  544. sum = sum.substring(0,40) + "...";
  545. }
  546. r.setSummary(sum);
  547. jtCollectSearchMapper.insertSelective(r);
  548. }
  549. if (identity.getAuditStatus()==4||identity.getAuditStatus()==3) {
  550. if(collectFlag)jtCollectSearchMapper.deleteByrowId(u.getUid());
  551. }
  552. }
  553. return userIdentityMapper.updateAuditing(identity);
  554. }
  555. @Override
  556. public Integer updateUserIdentityDetail(InputUserIdentity identity) {
  557. Integer count = 0;
  558. //修改用户信息
  559. User user = new User();
  560. BeanUtils.copyProperties(identity, user);
  561. user.setId(TokenManager.getUserId());
  562. count += userMapper.updateByPrimaryKeySelective(user);
  563. //获得用户的认证信信息
  564. UserIdentity u = userIdentityMapper.selectUserIdentityByUserId(user.getId());
  565. UserIdentity ui = new UserIdentity();
  566. BeanUtils.copyProperties(identity, ui);
  567. //如果是法律顾问
  568. if(null != identity.getConsultantType() && identity.getConsultantType() == 4){
  569. ui.setWorkUnit(identity.getWorkUnit1());
  570. }
  571. if (null == u) {
  572. ui.setId(UUID.randomUUID().toString());
  573. ui.setUid(user.getId());
  574. if (identity.getExpert() > 0 && (identity.getAuditStatus() == AchievementAuditStatus.CREATE.getCode().intValue() || identity.getAuditStatus() == AchievementAuditStatus.UNAUDITED.getCode().intValue())) {
  575. ui.setAuditStatus(AchievementAuditStatus.SUBMIT.getCode().intValue());
  576. }
  577. count += userIdentityMapper.insert(ui);
  578. } else {
  579. //暂不认证 或者认证审核中/通过,只修改认证信息中的用户信息 1, 2
  580. if(identity.getExpert() == 0 || u.getAuditStatus() == AchievementAuditStatus.SUBMIT.getCode().intValue()
  581. || u.getAuditStatus() == AchievementAuditStatus.AUDITED.getCode().intValue()){
  582. UserIdentity ui1 = new UserIdentity();
  583. ui1.setId(u.getId());// 认证表id
  584. //允许修改为空字符但是不能是null(以防引发空指针异常)
  585. if(null != ui.getQq()) ui1.setQq(ui.getQq());
  586. if(null != ui.getSex()) ui1.setSex(ui.getSex());
  587. if(null != ui.getIdNumber()) ui1.setIdNumber(ui.getIdNumber());
  588. if(null != ui.getPostalAddress()) ui1.setPostalAddress(ui.getPostalAddress());
  589. if(null != ui.getFixedTel()) ui1.setFixedTel(ui.getFixedTel());
  590. if(null != ui.getEmail()) ui1.setEmail(ui.getEmail());
  591. if(null != ui.getDateOfBirthYear()) ui1.setDateOfBirthYear(ui.getDateOfBirthYear());
  592. if(null != ui.getDateOfBirthMonth()) ui1.setDateOfBirthMonth(ui.getDateOfBirthMonth());
  593. if(null != ui.getProvince()) ui1.setProvince(ui.getProvince());
  594. if(null != ui.getCity()) ui1.setCity(ui.getCity());
  595. if(null != ui.getArea()) ui1.setArea(ui.getArea());
  596. if(null != ui.getIndustry()) ui1.setIndustry(ui.getIndustry());
  597. count += userIdentityMapper.updateByPrimaryKeySelective(ui1);
  598. }
  599. //判断审核状态 当未审核或者审核不通过时 0, 3
  600. if (identity.getExpert() > 0 && (identity.getAuditStatus() == AchievementAuditStatus.CREATE.getCode().intValue() || identity.getAuditStatus() == AchievementAuditStatus.UNAUDITED.getCode().intValue())) {
  601. ui.setId(u.getId());
  602. ui.setAuditStatus(AchievementAuditStatus.SUBMIT.getCode().intValue());
  603. count += userIdentityMapper.updateByPrimaryKeySelective(ui);
  604. }else{// 正在审核中或者审核通过
  605. count = -1;
  606. }
  607. }
  608. return count;
  609. }
  610. }