AccountUtils.java 37 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118
  1. package com.uas.sso.util;
  2. import com.alibaba.fastjson.JSON;
  3. import com.alibaba.fastjson.JSONObject;
  4. import com.alibaba.fastjson.TypeReference;
  5. import com.uas.sso.AccountConfig;
  6. import com.uas.sso.ResultWrap;
  7. import com.uas.sso.common.util.HttpUtil;
  8. import com.uas.sso.entity.*;
  9. import org.springframework.data.domain.Page;
  10. import org.springframework.ui.ModelMap;
  11. import org.springframework.util.StringUtils;
  12. import java.util.ArrayList;
  13. import java.util.List;
  14. import java.util.Map;
  15. /**
  16. * 客户端使用,操作企业资料、用户资料
  17. *
  18. * @author wangmh
  19. *
  20. */
  21. public class AccountUtils {
  22. /**
  23. * 企业解除绑定的应用
  24. *
  25. * @author wangmh
  26. * @date 2018/1/26 16:34
  27. * @param spaceUU 企业uu号
  28. * @param appId 应用id
  29. * @throws Exception
  30. */
  31. public static void unbindApp(Long spaceUU, String appId) throws Exception {
  32. String saveUrl = AccountConfig.getSpaceSaveUrl();
  33. if (!StringUtils.isEmpty(saveUrl)) {
  34. ModelMap formData = new ModelMap();
  35. formData.put("_operate", "unbind");
  36. formData.put("spaceUU", spaceUU);
  37. formData.put("appId", appId);
  38. HttpUtil.ResponseWrap res = HttpUtil.doPost(saveUrl, formData);
  39. if (!res.isSuccess()) {
  40. throw new Exception(res.getContent());
  41. } else {
  42. ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class);
  43. if (!result.isSuccess()) {
  44. throw new Exception(result.getErrMsg());
  45. }
  46. }
  47. }
  48. }
  49. /**
  50. * 企业开通应用
  51. * @param spaceUU 企业uu号
  52. * @param appId 应用id
  53. * @throws Exception
  54. */
  55. public static void bindApp(Long spaceUU, String appId) throws Exception {
  56. String saveUrl = AccountConfig.getSpaceSaveUrl();
  57. if (!StringUtils.isEmpty(saveUrl)) {
  58. ModelMap formData = new ModelMap();
  59. formData.put("_operate", "bind");
  60. formData.put("spaceUU", spaceUU);
  61. formData.put("appId", appId);
  62. HttpUtil.ResponseWrap res = HttpUtil.doPost(saveUrl, formData);
  63. if (!res.isSuccess()) {
  64. throw new Exception(res.getContent());
  65. } else {
  66. ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class);
  67. if (!result.isSuccess()) {
  68. throw new Exception(result.getErrMsg());
  69. }
  70. }
  71. }
  72. }
  73. /**
  74. * 用户解除绑定企业
  75. * @param userUU 用户uu号
  76. * @param spaceUU 企业uu号
  77. * @throws Exception
  78. */
  79. public static void unbindUserSpace(Long userUU, Long spaceUU) throws Exception {
  80. String saveUrl = AccountConfig.getUserSaveUrl();
  81. if (!StringUtils.isEmpty(saveUrl)) {
  82. ModelMap formData = new ModelMap();
  83. formData.put("_operate", "bind");
  84. formData.put("userUU", userUU);
  85. formData.put("spaceUU", spaceUU);
  86. HttpUtil.ResponseWrap res = HttpUtil.doPost(saveUrl, formData);
  87. if (!res.isSuccess()) {
  88. throw new Exception(res.getContent());
  89. } else {
  90. ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class);
  91. if (!result.isSuccess()) {
  92. throw new Exception(result.getErrMsg());
  93. }
  94. }
  95. }
  96. }
  97. /**
  98. * 用户绑定企业
  99. * @param userUU 用户uu号
  100. * @param spaceUU 企业uu号
  101. * @throws Exception
  102. */
  103. public static void bindUserSpace(Long userUU, Long spaceUU) throws Exception {
  104. String saveUrl = AccountConfig.getUserSaveUrl();
  105. if (!StringUtils.isEmpty(saveUrl)) {
  106. ModelMap formData = new ModelMap();
  107. formData.put("_operate", "unbind");
  108. formData.put("userUU", userUU);
  109. formData.put("spaceUU", spaceUU);
  110. HttpUtil.ResponseWrap res = HttpUtil.doPost(saveUrl, formData);
  111. if (!res.isSuccess()) {
  112. throw new Exception(res.getContent());
  113. } else {
  114. ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class);
  115. if (!result.isSuccess()) {
  116. throw new Exception(result.getErrMsg());
  117. }
  118. }
  119. }
  120. }
  121. /**
  122. * 根据营业执照号获得企业信息
  123. * @param businessCode 营业执照号
  124. * @return
  125. */
  126. public List<UserSpaceView> findByBusinessCode(String businessCode) throws Exception {
  127. String saveUrl = AccountConfig.getSpaceSaveUrl();
  128. if (!StringUtils.isEmpty(saveUrl)) {
  129. ModelMap formData = new ModelMap();
  130. saveUrl = saveUrl + "/info/businessCode";
  131. formData.put("businessCode", businessCode);
  132. HttpUtil.ResponseWrap res = HttpUtil.doPost(saveUrl, formData);
  133. if (!res.isSuccess()) {
  134. throw new Exception(res.getContent());
  135. } else {
  136. ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class);
  137. if (!result.isSuccess()) {
  138. throw new Exception(result.getErrMsg());
  139. } else if (result.getContent() != null){
  140. return JSON.parseArray(result.getContent().toString(), UserSpaceView.class);
  141. }
  142. }
  143. }
  144. return null;
  145. }
  146. /**
  147. * 根据营业执照号获得企业信息
  148. * @param spaceName 营业执照号
  149. * @return
  150. */
  151. public List<UserSpaceView> findBySpaceName(String spaceName) throws Exception {
  152. String saveUrl = AccountConfig.getSpaceSaveUrl();
  153. if (!StringUtils.isEmpty(saveUrl)) {
  154. ModelMap formData = new ModelMap();
  155. saveUrl = saveUrl + "/info/businessCode";
  156. formData.put("spaceName", spaceName);
  157. HttpUtil.ResponseWrap res = HttpUtil.doPost(saveUrl, formData);
  158. if (!res.isSuccess()) {
  159. throw new Exception(res.getContent());
  160. } else {
  161. ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class);
  162. if (!result.isSuccess()) {
  163. throw new Exception(result.getErrMsg());
  164. } else if (result.getContent() != null){
  165. return JSON.parseArray(result.getContent().toString(), UserSpaceView.class);
  166. }
  167. }
  168. }
  169. return null;
  170. }
  171. /**
  172. * 用户申请绑定企业
  173. * @param userUU 用户uu号
  174. * @param spaceUU 企业uu号
  175. * @throws Exception
  176. */
  177. public static void applyUserSpace(Long userUU, Long spaceUU) throws Exception {
  178. String saveUrl = AccountConfig.getUserSaveUrl();
  179. if (!StringUtils.isEmpty(saveUrl)) {
  180. ModelMap formData = new ModelMap();
  181. saveUrl = saveUrl + "/apply/bind";
  182. formData.put("userUU", userUU);
  183. formData.put("spaceUU", spaceUU);
  184. HttpUtil.ResponseWrap res = HttpUtil.doPost(saveUrl, formData);
  185. if (!res.isSuccess()) {
  186. throw new Exception(res.getContent());
  187. } else {
  188. ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class);
  189. if (!result.isSuccess()) {
  190. throw new Exception(result.getErrMsg());
  191. }
  192. }
  193. }
  194. }
  195. /**
  196. * 分页查找个人申请记录
  197. *
  198. * @author wangmh
  199. * @date 2018/2/1 15:47
  200. * @param userUU 用户uu号
  201. * @param page 页数(从0开始)
  202. * @param size 每页大小
  203. * @return
  204. * @throws Exception
  205. */
  206. public static Page<ApplyUserSpaceView> findApplyInfo(Long userUU, int page, int size) throws Exception {
  207. String url = AccountConfig.getUserSaveUrl();
  208. if (!StringUtils.isEmpty(url)) {
  209. url = url + "/apply/info";
  210. ModelMap data = new ModelMap();
  211. data.put("userUU", userUU);
  212. data.put("page", page);
  213. data.put("size", size);
  214. HttpUtil.ResponseWrap res = HttpUtil.doGet(url, data);
  215. if (!res.isSuccess()) {
  216. throw new Exception(res.getContent());
  217. } else {
  218. ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class);
  219. if (!result.isSuccess()) {
  220. throw new Exception(result.getErrMsg());
  221. } else if (result.getContent() != null) {
  222. return JSON.parseObject(result.getContent().toString(), new TypeReference<Page<ApplyUserSpaceView>>() {
  223. });
  224. }
  225. }
  226. }
  227. return null;
  228. }
  229. /**
  230. * 统计该企业审批记录数量
  231. * @param spaceUU 企业uu号
  232. * @return
  233. * @throws Exception
  234. */
  235. public static Map<String, Integer> applyCount(Long spaceUU) throws Exception {
  236. String url = AccountConfig.getSpaceSaveUrl();
  237. if (!StringUtils.isEmpty(url)) {
  238. url = url + "/apply/count";
  239. ModelMap data = new ModelMap();
  240. data.put("spaceUU", spaceUU);
  241. HttpUtil.ResponseWrap res = HttpUtil.doGet(url, data);
  242. if (!res.isSuccess()) {
  243. throw new Exception(res.getContent());
  244. } else {
  245. ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class);
  246. if (!result.isSuccess()) {
  247. throw new Exception(result.getErrMsg());
  248. } else if (result.getContent() != null) {
  249. return JSON.parseObject(result.getContent().toString(), Map.class);
  250. }
  251. }
  252. }
  253. return null;
  254. }
  255. /**
  256. * 校验企业名称
  257. * @param spaceName 企业名称
  258. */
  259. public static void checkSpaceName(String spaceName) throws Exception {
  260. String url = AccountConfig.getSpaceSaveUrl();
  261. if (!StringUtils.isEmpty(url)) {
  262. url = url + "/checkSpaceName";
  263. ModelMap data = new ModelMap();
  264. data.put("spaceName", spaceName);
  265. HttpUtil.ResponseWrap res = HttpUtil.doGet(url, data);
  266. if (!res.isSuccess()) {
  267. throw new Exception(res.getContent());
  268. } else {
  269. ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class);
  270. if (!result.isSuccess()) {
  271. throw new Exception(result.getErrMsg());
  272. }
  273. }
  274. }
  275. }
  276. /**
  277. * 校验企业营业执照号
  278. * @param businessCode 企业营业执照号
  279. */
  280. public static void checkBusinessCode(String businessCode) throws Exception {
  281. String url = AccountConfig.getSpaceSaveUrl();
  282. if (!StringUtils.isEmpty(url)) {
  283. url = url + "/checkBusinessCode";
  284. ModelMap data = new ModelMap();
  285. data.put("businessCode", businessCode);
  286. HttpUtil.ResponseWrap res = HttpUtil.doGet(url, data);
  287. if (!res.isSuccess()) {
  288. throw new Exception(res.getContent());
  289. } else {
  290. ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class);
  291. if (!result.isSuccess()) {
  292. throw new Exception(result.getErrMsg());
  293. }
  294. }
  295. }
  296. }
  297. /**
  298. * 根据用户uu号获取用户信息
  299. * @param userUU 用户uu号
  300. * @return
  301. * @throws Exception
  302. */
  303. public static UserView findByUserUU(Long userUU) throws Exception {
  304. String url = AccountConfig.getUserSaveUrl();
  305. if (!StringUtils.isEmpty(url)) {
  306. url = url + "/info";
  307. ModelMap data = new ModelMap();
  308. data.put("userUU", userUU);
  309. HttpUtil.ResponseWrap res = HttpUtil.doGet(url, data);
  310. if (!res.isSuccess()) {
  311. throw new Exception(res.getContent());
  312. } else {
  313. ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class);
  314. if (!result.isSuccess()) {
  315. throw new Exception(result.getErrMsg());
  316. } else if (result.getContent() != null) {
  317. return JSON.parseObject(result.getContent().toString(), UserView.class);
  318. }
  319. }
  320. }
  321. return null;
  322. }
  323. /**
  324. * 根据用户uu号获取用户信息
  325. * @param spaceUU 企业uu号
  326. * @return
  327. * @throws Exception
  328. */
  329. public static UserSpaceView findBySpaceUU(Long spaceUU) throws Exception {
  330. String url = AccountConfig.getUserSaveUrl();
  331. if (!StringUtils.isEmpty(url)) {
  332. url = url + "/checkBusinessCode";
  333. ModelMap data = new ModelMap();
  334. data.put("spaceUU", spaceUU);
  335. HttpUtil.ResponseWrap res = HttpUtil.doGet(url, data);
  336. if (!res.isSuccess()) {
  337. throw new Exception(res.getContent());
  338. } else {
  339. ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class);
  340. if (!result.isSuccess()) {
  341. throw new Exception(result.getErrMsg());
  342. } else if (result.getContent() != null) {
  343. return JSON.parseObject(result.getContent().toString(), UserSpaceView.class);
  344. }
  345. }
  346. }
  347. return null;
  348. }
  349. /**
  350. * 通过当前企业号和企业列表中的企业号查询申请状态
  351. *
  352. * @return
  353. * @throws Exception
  354. */
  355. public static RequestStatus getStatusByCustUidAndVendUid(String custBusinessCode, String vendBusinessCode) throws Exception {
  356. String url = AccountConfig.getEnPartnersUrl();
  357. RequestStatus request = new RequestStatus();
  358. if (!StringUtils.isEmpty(url)) {
  359. HttpUtil.ResponseWrap res = HttpUtil.doGet(url, new ModelMap("_operate", "getRequestStatus")
  360. .addAttribute("vendBusinessCode", vendBusinessCode)
  361. .addAttribute("custBusinessCode", custBusinessCode));
  362. if (!res.isSuccess()) {
  363. throw new Exception(res.getContent());
  364. } else {
  365. request = JSON.parseObject(res.getContent(), RequestStatus.class);
  366. }
  367. }
  368. return request;
  369. }
  370. /// 之后方法会恢复并修改
  371. //
  372. // /**
  373. // * 获取校验码
  374. // *
  375. // * @param username
  376. // * 手机号或邮箱地址
  377. // * @return
  378. // */
  379. // public static void sendValidCode(String username) throws Exception {
  380. // String saveUrl = AccountConfig.getUserSaveUrl();
  381. // if (!StringUtils.isEmpty(saveUrl)) {
  382. // ResponseWrap res = HttpUtil.doGet(saveUrl, new ModelMap("_operate", "getVcode").addAttribute("username", username));
  383. // if (!res.isSuccess())
  384. // throw new Exception(res.getContent());
  385. // else {
  386. // ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class);
  387. // if (!result.isSuccess())
  388. // throw new Exception(result.getErrMsg());
  389. // }
  390. // }
  391. // }
  392. //
  393. // /**
  394. // * 验证校验码
  395. // *
  396. // * @param username
  397. // * 手机号或邮箱地址
  398. // * @param validCode
  399. // * 校验码
  400. // * @return
  401. // */
  402. // public static boolean checkValidCode(String username, String validCode) throws Exception {
  403. // String saveUrl = AccountConfig.getUserSaveUrl();
  404. // if (!StringUtils.isEmpty(saveUrl)) {
  405. // ResponseWrap res = HttpUtil.doGet(saveUrl, new ModelMap("_operate", "checkVcode").addAttribute("username", username)
  406. // .addAttribute("validCode", validCode));
  407. // if (!res.isSuccess())
  408. // throw new Exception(res.getContent());
  409. // else {
  410. // ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class);
  411. // if (!result.isSuccess())
  412. // throw new Exception(result.getErrMsg());
  413. // else
  414. // return true;
  415. // }
  416. // }
  417. // return false;
  418. // }
  419. //
  420. // public static String getAccessToken(String appId, String spaceDialectUID, String uid) throws Exception {
  421. // String saveUrl = AccountConfig.getUserSaveUrl();
  422. // if (!StringUtils.isEmpty(saveUrl)) {
  423. // saveUrl = saveUrl + "/getToken";
  424. // JSONObject formData = new JSONObject();
  425. // formData.put("appId", appId);
  426. // formData.put("spaceDialectUID", spaceDialectUID);
  427. // formData.put("uid", uid);
  428. // ResponseWrap res = HttpUtil.doGet(saveUrl, formData);
  429. // if (!res.isSuccess()) {
  430. // throw new Exception(res.getContent());
  431. // } else {
  432. // return res.getContent();
  433. // }
  434. // }
  435. // return null;
  436. // }
  437. //
  438. // /**
  439. // * 验证密码,返回绑定身份信息的token
  440. // *
  441. // * @return
  442. // */
  443. // public static String getAccessToken(User user) throws Exception {
  444. // String saveUrl = AccountConfig.getUserSaveUrl();
  445. // if (!StringUtils.isEmpty(saveUrl)) {
  446. // JSONObject formData = JSON.parseObject(JSON.toJSONString(user));
  447. // formData.put("_operate", "getToken");
  448. // ResponseWrap res = HttpUtil.doGet(saveUrl, formData);
  449. // if (!res.isSuccess())
  450. // throw new Exception(res.getContent());
  451. // else {
  452. // ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class);
  453. // if (!result.isSuccess())
  454. // throw new Exception(result.getErrMsg());
  455. // else
  456. // return String.valueOf(result.getContent());
  457. // }
  458. // }
  459. // return null;
  460. // }
  461. //
  462. // /**
  463. // * 验证token,返回当前应用相关的身份信息
  464. // *
  465. // * @return
  466. // */
  467. // public static UserView checkAccessToken(String token) throws Exception {
  468. // String saveUrl = AccountConfig.getUserSaveUrl();
  469. // if (!StringUtils.isEmpty(saveUrl)) {
  470. // ResponseWrap res = HttpUtil.doGet(
  471. // saveUrl,
  472. // new ModelMap("_operate", "checkToken").addAttribute("token", token).addAttribute("appId",
  473. // SSOHelper.getSSOService().getConfig().getAppName()));
  474. // if (!res.isSuccess())
  475. // throw new Exception(res.getContent());
  476. // else {
  477. // ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class);
  478. // if (!result.isSuccess())
  479. // throw new Exception(result.getErrMsg());
  480. // else
  481. // return JSON.parseObject(JSON.toJSONString(result.getContent()), UserView.class);
  482. // }
  483. // }
  484. // return null;
  485. // }
  486. //
  487. // /**
  488. // * 用token验证登录
  489. // *
  490. // * @param request
  491. // * @param response
  492. // * @param token
  493. // * @throws Exception
  494. // */
  495. // public static UserView loginByAccessToken(HttpServletRequest request, HttpServletResponse response, String token) throws Exception {
  496. // UserView user = checkAccessToken(token);
  497. // if (null != user) {
  498. // SSOToken st = new SSOToken(request, user.getUid());
  499. // st.setData(JSON.toJSONString(user));
  500. // SSOHelper.setSSOCookie(request, response, st, true);
  501. // }
  502. // return user;
  503. // }
  504. /**
  505. * 传入当前登录的企业的营业执照号,查询发出的申请
  506. *
  507. * @param businessCode 营业执照号
  508. * @param statusCode 状态吗
  509. * @param keyword 关键词
  510. * @param pageNumber 页号(0开始)
  511. * @param pageSize 每页数量
  512. * @return
  513. * @throws Exception
  514. */
  515. public static Page<PartnershipRecordView> getAllRequest(String businessCode, Integer statusCode, String keyword, int pageNumber,
  516. int pageSize) throws Exception {
  517. String getUrl = AccountConfig.getEnPartnersUrl();
  518. if (!StringUtils.isEmpty(getUrl)) {
  519. HttpUtil.ResponseWrap res = HttpUtil.doGet(getUrl, new ModelMap("_operate", "getAllRequest").addAttribute("businessCode", businessCode)
  520. .addAttribute("statusCode", statusCode).addAttribute("businessCode", businessCode).addAttribute("keyword", keyword)
  521. .addAttribute("pageNumber", pageNumber).addAttribute("pageSize", pageSize));
  522. if (!res.isSuccess()) {
  523. throw new Exception(res.getContent());
  524. } else {
  525. ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class);
  526. if (!result.isSuccess()) {
  527. throw new Exception(result.getErrMsg());
  528. } else if (result.getContent() != null) {
  529. return JSONObject.parseObject(res.getContent(), new TypeReference<Page<PartnershipRecordView>>() {});
  530. }
  531. }
  532. }
  533. return null;
  534. }
  535. //
  536. // /**
  537. // * 通过已存在uu过滤,取出全部合作伙伴(UAS接口用)
  538. // * @param businessCode
  539. // * @param statusCode
  540. // * @param keyword
  541. // * @param pageNumber
  542. // * @param pageSize
  543. // * @param partnerUUs
  544. // * @return
  545. // */
  546. // public static Page<PartnershipRecord> getRequestFilterByPartnerUUs(String businessCode, Integer statusCode, String keyword, List<Long> partnerUUs, int pageNumber, int pageSize) throws Exception {
  547. // String getUrl = AccountConfig.getEnPartnersUrl();
  548. // if (!StringUtils.isEmpty(getUrl)) {
  549. // ResponseWrap res = HttpUtil.doGet(getUrl, new ModelMap("_operate", "getAllRequestFilterByPartnerUUs").addAttribute("businessCode", businessCode)
  550. // .addAttribute("statusCode", statusCode).addAttribute("keyword", keyword).addAttribute("partnerUUs", JSON.toJSON(partnerUUs))
  551. // .addAttribute("pageNumber", pageNumber).addAttribute("pageSize", pageSize));
  552. // if (!res.isSuccess())
  553. // throw new Exception(res.getContent());
  554. // return JSON.parseObject(res.getContent(), new TypeReference<Page<PartnershipRecord>>() {
  555. // });
  556. // }
  557. // return null;
  558. // }
  559. //
  560. /**
  561. * 进入企业圈
  562. *
  563. * @return
  564. * @throws Exception
  565. */
  566. public static String redirectContactPage() throws Exception {
  567. String enterUrl = AccountConfig.getContactPageUrl();
  568. return enterUrl;
  569. }
  570. //
  571. // /**
  572. // * 通过关键词搜索企业信息
  573. // *
  574. // * @param keyword
  575. // * @return
  576. // * @throws Exception
  577. // */
  578. // public static Page<UserSpaceDetail> getUserSpacesByKeyword(String keyword, int pageNumber, int pageSize) throws Exception {
  579. // String Url = AccountConfig.getEnPartnersUrl();
  580. // if (!StringUtils.isEmpty(Url)) {
  581. // ResponseWrap res = HttpUtil.doGet(Url,
  582. // new ModelMap("_operate", "getUserSpaces").addAttribute("keyword", keyword).addAttribute("pageNumber", pageNumber)
  583. // .addAttribute("pageSize", pageSize));
  584. // if (!res.isSuccess())
  585. // throw new Exception(res.getContent());
  586. // return JSON.parseObject(res.getContent(), new TypeReference<Page<UserSpaceDetail>>() {
  587. // });
  588. // }
  589. // return null;
  590. // }
  591. //
  592. // /**
  593. // * 通过手机号搜索用户账号信息
  594. // *
  595. // * @param uid
  596. // * @return
  597. // * @throws Exception
  598. // */
  599. // public static List<User> getUserInfoByUid(String uid) throws Exception {
  600. // String Url = AccountConfig.getSpaceSaveUrl();
  601. // if (!StringUtils.isEmpty(Url)) {
  602. // ResponseWrap res = HttpUtil.doGet(Url + "/userInfo",
  603. // new ModelMap("uid", uid));
  604. // if (!res.isSuccess())
  605. // throw new Exception(res.getContent());
  606. // String resText = res.getContent();
  607. // JSONObject object = JSON.parseObject(resText);
  608. // String contentText = object.getString("content");
  609. // return JSON.parseArray(contentText, User.class);
  610. // }
  611. // return null;
  612. // }
  613. //
  614. // /**
  615. // * 通过营业执照号获取企业应用
  616. // *
  617. // * @param uid
  618. // * @return
  619. // * @throws Exception
  620. // */
  621. // public static List<UserSpace> getUserSpaceByUid(String uid) throws Exception {
  622. // String Url = AccountConfig.getSpaceSaveUrl();
  623. // if (!StringUtils.isEmpty(Url)) {
  624. // ResponseWrap res = HttpUtil.doGet(Url + "/" + uid);
  625. // if (!res.isSuccess())
  626. // throw new Exception(res.getContent());
  627. // String resText = res.getContent();
  628. // JSONObject object = JSON.parseObject(resText);
  629. // String contentText = object.getString("content");
  630. // return JSON.parseArray(contentText, UserSpace.class);
  631. // }
  632. // return null;
  633. // }
  634. /**
  635. * 新增一条合作关系记录
  636. *
  637. * @param record
  638. * @return
  639. * @throws Exception
  640. */
  641. public static String addNewRecord(PartnershipRecordView record) throws Exception {
  642. String url = AccountConfig.getEnPartnersUrl();
  643. String result = null;
  644. if (!StringUtils.isEmpty(url)) {
  645. JSONObject formData = JSON.parseObject(JSON.toJSONString(record));
  646. formData.put("_operate", "addPartner");
  647. HttpUtil.ResponseWrap res = HttpUtil.doPost(url, formData);
  648. result = res.getContent();
  649. }
  650. return result;
  651. }
  652. /**
  653. * 同步供应商关系为合作关系记录
  654. *
  655. * @param record
  656. * @return
  657. * @throws Exception
  658. */
  659. public static String synchronizeRecord(PartnershipRecordView record) throws Exception {
  660. String url = AccountConfig.getEnPartnersUrl();
  661. String result = null;
  662. if (!StringUtils.isEmpty(url)) {
  663. JSONObject formData = JSON.parseObject(JSON.toJSONString(record));
  664. formData.put("_operate", "synchronizePartner");
  665. HttpUtil.ResponseWrap res = HttpUtil.doPost(url, formData);
  666. result = res.getContent();
  667. }
  668. return result;
  669. }
  670. /**
  671. * 通过id和申请人的电话进行确认
  672. *
  673. * @param id
  674. * @param vendUserTel
  675. * @param appId
  676. * @return
  677. * @throws Exception
  678. */
  679. public static String acceptRequest(Long id, String vendUserTel, String appId) throws Exception {
  680. String url = AccountConfig.getEnPartnersUrl();
  681. String result = null;
  682. if (!StringUtils.isEmpty(url)) {
  683. HttpUtil.ResponseWrap res = HttpUtil.doGet(
  684. url,
  685. new ModelMap("_operate", "acceptRequest").addAttribute("id", id).addAttribute("vendUserTel", vendUserTel)
  686. .addAttribute("appId", appId));
  687. if (!res.isSuccess()) {
  688. throw new Exception(res.getContent());
  689. } else {
  690. result = res.getContent();
  691. }
  692. }
  693. return result;
  694. }
  695. //
  696. /**
  697. * 申请不通过,通过申请人的电话操作,并标出原因
  698. *
  699. * @param id
  700. * @param reason
  701. * @param vendUserTel
  702. * @param appId
  703. * @return
  704. * @throws Exception
  705. */
  706. public static String rejectRequest(Long id, String reason, String vendUserTel, String appId) throws Exception {
  707. String url = AccountConfig.getEnPartnersUrl();
  708. String result = null;
  709. if (!StringUtils.isEmpty(url)) {
  710. HttpUtil.ResponseWrap res = HttpUtil.doGet(
  711. url,
  712. new ModelMap("_operate", "rejectRequest").addAttribute("id", id).addAttribute("reason", reason)
  713. .addAttribute("vendUserTel", vendUserTel).addAttribute("appId", appId));
  714. if (!res.isSuccess()) {
  715. throw new Exception(res.getContent());
  716. } else {
  717. result = res.getContent();
  718. }
  719. }
  720. return result;
  721. }
  722. // /**
  723. // * 通过当前企业号和企业列表中的企业号查询申请状态
  724. // *
  725. // * @return
  726. // * @throws Exception
  727. // */
  728. // public static RequsetStatus getStatusByCustUidAndVendUid(String custUid, String vendUid) throws Exception {
  729. // String url = AccountConfig.getEnPartnersUrl();
  730. // RequsetStatus request = new RequsetStatus();
  731. // if (!StringUtils.isEmpty(url)) {
  732. // ResponseWrap res = HttpUtil.doGet(url, new ModelMap("_operate", "getRequestStatus").addAttribute("custUid", custUid)
  733. // .addAttribute("vendUid", vendUid));
  734. // if (!res.isSuccess())
  735. // throw new Exception(res.getContent());
  736. // else {
  737. // request = JSON.parseObject(res.getContent(), RequsetStatus.class);
  738. // }
  739. // }
  740. // return request;
  741. // }
  742. //
  743. // /**
  744. // * 搜索词通过id返回数据
  745. // *
  746. // * @param ids
  747. // * @return
  748. // * @throws Exception
  749. // */
  750. // public static List<UserSpaceDetail> findAll(String ids) throws Exception {
  751. // String url = AccountConfig.getEnPartnersUrl();
  752. // List<UserSpaceDetail> details = new ArrayList<UserSpaceDetail>();
  753. // if (!StringUtils.isEmpty(url)) {
  754. // ResponseWrap res = HttpUtil.doGet(url, new ModelMap("_operate", "findAll").addAttribute("ids", ids));
  755. // if(!res.isSuccess())
  756. // throw new Exception(res.getContent());
  757. // else
  758. // details = JSONObject.parseArray(res.getContent(), UserSpaceDetail.class);
  759. // }
  760. // return details;
  761. // }
  762. /**
  763. * 通过企业营业执照查询收到的待处理的请求
  764. *
  765. * @param businessCode
  766. * @return
  767. * @throws Exception
  768. */
  769. public static String getRequestTodo(String businessCode) throws Exception {
  770. String url = AccountConfig.getEnPartnersUrl();
  771. String result = null;
  772. if (!StringUtils.isEmpty(url)) {
  773. HttpUtil.ResponseWrap res = HttpUtil.doGet(url,
  774. new ModelMap("_operate", "getRequestTodo").addAttribute("businessCode", businessCode));
  775. if (!res.isSuccess()) {
  776. throw new Exception(res.getContent());
  777. } else {
  778. result = res.getContent();
  779. }
  780. }
  781. return result;
  782. }
  783. /**
  784. * 其他应用发起邀请注册,同步数据
  785. *
  786. * @param jsonStr
  787. * @throws Exception
  788. */
  789. public static void synchroInvitation(String jsonStr) throws Exception {
  790. String url = AccountConfig.getEnPartnersUrl();
  791. if (!StringUtils.isEmpty(url)) {
  792. HttpUtil.doPost(url, new ModelMap("_operate", "invitation").addAttribute("jsonStr", jsonStr));
  793. }
  794. }
  795. // /**
  796. // * ERP、SAAS新开账套名称校验
  797. // *
  798. // * @param name
  799. // * @return
  800. // * @throws Exception
  801. // */
  802. // public static String validName(String name) throws Exception {
  803. // String result = null;
  804. // String url = AccountConfig.getSpaceSaveUrl();
  805. // if (!StringUtils.isEmpty(url)) {
  806. // ResponseWrap res = HttpUtil.doGet(url, new ModelMap("_operate", "validName").addAttribute("name", name),
  807. // 50);
  808. // if (!res.isSuccess())
  809. // throw new Exception(res.getContent());
  810. // else
  811. // result = res.getContent();
  812. // }
  813. // return result;
  814. // }
  815. //
  816. // /**
  817. // * ERP、SAAS新开账套名称校验
  818. // *
  819. // * @param businessCode
  820. // * @return
  821. // * @throws Exception
  822. // */
  823. // public static String validBusinessCode(String businessCode) throws Exception {
  824. // String result = null;
  825. // String url = AccountConfig.getSpaceSaveUrl();
  826. // if (!StringUtils.isEmpty(url)) {
  827. // ResponseWrap res = HttpUtil.doGet(url,
  828. // new ModelMap("_operate", "validBusinessCode").addAttribute("businessCode", businessCode), 50);
  829. // if (!res.isSuccess())
  830. // throw new Exception(res.getContent());
  831. // else
  832. // result = res.getContent();
  833. // }
  834. // return result;
  835. // }
  836. //
  837. // /**
  838. // * 通过营业执照号查找 企业详细信息
  839. // *
  840. // * @param
  841. // * @return
  842. // * @throws Exception
  843. // */
  844. // public static UserSpaceDetail findByBusinessCode(String businessCode) throws Exception {
  845. // String result = null;
  846. // String url = AccountConfig.getSpaceSaveUrl();
  847. // if (!StringUtils.isEmpty(url)) {
  848. // ResponseWrap res = HttpUtil.doGet(url,
  849. // new ModelMap("_operate", "findByBusinessCode").addAttribute("businessCode", businessCode), 50);
  850. // if (!res.isSuccess())
  851. // throw new Exception(res.getContent());
  852. // else
  853. // result = res.getContent();
  854. // }
  855. // return JSON.parseObject(result,UserSpaceDetail.class);
  856. // }
  857. //
  858. // /**
  859. // * ERP、SAAS新开账套
  860. // *
  861. // * @param userSpaceDetail
  862. // * @param users
  863. // * @throws Exception
  864. // */
  865. // public static String applyApp(UserSpaceDetail userSpaceDetail, List<UserDetail> users) throws Exception {
  866. // String url = AccountConfig.getSpaceSaveUrl();
  867. // String result = null;
  868. // if (!StringUtils.isEmpty(url)) {
  869. // ResponseWrap res = HttpUtil.doPost(url, new ModelMap("_operate", "registerBranchAccount")
  870. // .addAttribute("detail", JSON.toJSON(userSpaceDetail))
  871. // .addAttribute("userInfos", JSON.toJSON(users)));
  872. // if (!res.isSuccess())
  873. // throw new Exception(res.getContent());
  874. // else
  875. // result = res.getContent();
  876. // }
  877. // return result;
  878. // }
  879. //
  880. // /**
  881. // * 商城个人账号增加企业注册
  882. // *
  883. // * @param userSpaceDetail
  884. // * @throws Exception
  885. // */
  886. // public static String applyAppForMall(UserSpaceDetail userSpaceDetail) throws Exception {
  887. // String url = AccountConfig.getSpaceSaveUrl();
  888. // String result = null;
  889. // if (!StringUtils.isEmpty(url)) {
  890. // ResponseWrap res = HttpUtil.doPost(url,
  891. // new ModelMap("_operate", "registForMall")
  892. // .addAttribute("detail", JSON.toJSON(userSpaceDetail)));
  893. // if (!res.isSuccess())
  894. // throw new Exception(res.getContent());
  895. // else
  896. // result = res.getContent();
  897. // }
  898. // return result;
  899. // }
  900. //
  901. // /**
  902. // * 设置hr账号
  903. // *
  904. // * @param user
  905. // * @param detail
  906. // * @return
  907. // * @throws Exception
  908. // */
  909. // public static String setHrAccount(User user, UuzcUserSpaceDetail detail) throws Exception {
  910. // String saveUrl = AccountConfig.getUserSaveUrl();
  911. // saveUrl = saveUrl + "/setHrAccount";
  912. // if (!StringUtils.isEmpty(saveUrl)) {
  913. // JSONObject formData = new JSONObject();
  914. // if (detail != null) {
  915. // formData = JSON.parseObject(JSON.toJSONString(detail));
  916. // }
  917. // if (null != user) {
  918. // formData.putAll(JSON.parseObject(JSON.toJSONString(user)));
  919. // }
  920. // ResponseWrap response = HttpUtil.doPost(saveUrl, formData);
  921. // if (!response.isSuccess())
  922. // throw new Exception(response.getContent());
  923. // else {
  924. // return response.getContent();
  925. // }
  926. // }
  927. // return null;
  928. // }
  929. //
  930. // /**
  931. // * 根据营业执照获取众创需要的企业资料
  932. // *
  933. // * @param businessCode
  934. // * @return
  935. // * @throws Exception
  936. // */
  937. // public static UuzcUserSpaceDetail getUuzcUserSpaceDetail(String businessCode) throws Exception {
  938. // String saveUrl = AccountConfig.getUserSaveUrl();
  939. // if (!StringUtils.isEmpty(saveUrl)) {
  940. // ResponseWrap response = HttpUtil.doGet(saveUrl + "/uuzcSpace" , new ModelMap("businessCode", businessCode));
  941. // if (!response.isSuccess())
  942. // throw new Exception(response.getContent());
  943. // else {
  944. // return JSONObject.parseObject(response.getContent(), UuzcUserSpaceDetail.class);
  945. // }
  946. // }
  947. // return null;
  948. // }
  949. //
  950. // /**
  951. // * 判断当前企业是否设置了hr
  952. // *
  953. // * @param businessCode
  954. // * @return
  955. // * @throws Exception
  956. // */
  957. // public static String getHrAccount(String businessCode) throws Exception {
  958. // String saveUrl = AccountConfig.getUserSaveUrl();
  959. // if (!StringUtils.isEmpty(saveUrl)) {
  960. // ResponseWrap response = HttpUtil.doGet(saveUrl + "/hrcount" , new ModelMap("businessCode", businessCode));
  961. // if (!response.isSuccess())
  962. // throw new Exception(response.getContent());
  963. // else {
  964. // return response.getContent();
  965. // }
  966. // }
  967. // return null;
  968. // }
  969. //
  970. // /**
  971. // * 获取当前企业的HR信息
  972. // *
  973. // * @param businessCode
  974. // * @return
  975. // * @throws Exception
  976. // */
  977. // public static User getHrInfo(String businessCode) throws Exception {
  978. // String saveUrl = AccountConfig.getUserSaveUrl();
  979. // if (!StringUtils.isEmpty(saveUrl)) {
  980. // ResponseWrap response = HttpUtil.doGet(saveUrl + "/hrInfo" , new ModelMap("businessCode", businessCode));
  981. // if (!response.isSuccess())
  982. // throw new Exception(response.getContent());
  983. // else {
  984. // return JSONObject.parseObject(response.getContent(), User.class);
  985. // }
  986. // }
  987. // return null;
  988. // }
  989. //
  990. // /**
  991. // * 获取当前企业人员账号信息
  992. // *
  993. // * @param businessCode
  994. // * @return
  995. // * @throws Exception
  996. // */
  997. // public static List<User> getEmployees(String businessCode) throws Exception {
  998. // String saveUrl = AccountConfig.getUserSaveUrl();
  999. // saveUrl = saveUrl + "/employees";
  1000. // if (!StringUtils.isEmpty(saveUrl)) {
  1001. // ResponseWrap response = HttpUtil.doPost(saveUrl, new ModelMap("businessCode", businessCode));
  1002. // if (!response.isSuccess())
  1003. // throw new Exception(response.getContent());
  1004. // else {
  1005. // return JSON.parseArray(response.getContent(), User.class);
  1006. // }
  1007. // }
  1008. // return null;
  1009. // }
  1010. //
  1011. // /**
  1012. // * 保存用户密保问题
  1013. // * @param questions
  1014. // * @throws Exception
  1015. // */
  1016. // public static void saveUserQuestions(List<UserQuestion> questions) throws Exception {
  1017. // String saveUrl = AccountConfig.getUserSaveUrl();
  1018. // saveUrl = saveUrl + "/save/question";
  1019. // if (!StringUtils.isEmpty(saveUrl)) {
  1020. // ResponseWrap res = HttpUtil.doPost(saveUrl, new ModelMap("question", questions));
  1021. // if (!res.isSuccess()) {
  1022. // throw new Exception(res.getContent());
  1023. // }
  1024. // }
  1025. // }
  1026. //
  1027. // /**
  1028. // * 保存用户密保问题
  1029. // * @param userQuestion
  1030. // * @throws Exception
  1031. // */
  1032. // public static void saveUserQuestion(UserQuestion userQuestion) throws Exception {
  1033. // String saveUrl = AccountConfig.getUserSaveUrl();
  1034. // saveUrl = saveUrl + "/save/question";
  1035. // if (!StringUtils.isEmpty(saveUrl)) {
  1036. // JSONObject formData = JSON.parseObject(JSON.toJSONString(userQuestion));
  1037. // formData.put("_count", "one");
  1038. // ResponseWrap res = HttpUtil.doPost(saveUrl, formData);
  1039. // if (!res.isSuccess()) {
  1040. // throw new Exception(res.getContent());
  1041. // }
  1042. // }
  1043. // }
  1044. //
  1045. // /**
  1046. // * 根据imId获取用户userUU(没有则返回null)
  1047. // */
  1048. // public static User getUserByImId (Long imId) throws Exception {
  1049. // String url = AccountConfig.getUserSaveUrl();
  1050. // User result = null;
  1051. // if (!StringUtils.isEmpty(url)) {
  1052. // ResponseWrap res = HttpUtil.doGet(url,
  1053. // new ModelMap("_operate", "getUserByImId")
  1054. // .addAttribute("imId", imId));
  1055. // if (!res.isSuccess())
  1056. // throw new Exception(res.getContent());
  1057. // else
  1058. // result = JSON.parseObject(res.getContent(), User.class);
  1059. // }
  1060. // return result;
  1061. // }
  1062. //
  1063. // /**
  1064. // * 根据营业执照号分页查找该企业的用户
  1065. // * @param businessCode
  1066. // * @param pageNumber
  1067. // * @param pageSize
  1068. // * @return
  1069. // * @throws Exception
  1070. // */
  1071. // public Page<User> findUsersByBusinessCode(String businessCode, int pageNumber, int pageSize) throws Exception {
  1072. // String url = AccountConfig.getUserSaveUrl();
  1073. // if (!StringUtils.isEmpty(url)) {
  1074. // url = url + "/findByBusinessCode";
  1075. // String appId = SSOHelper.getSSOService().getConfig().getAppName();
  1076. // ModelMap data = new ModelMap();
  1077. // data.put("businessCode", businessCode);
  1078. // data.put("appId", appId);
  1079. // data.put("pageNumber", pageNumber);
  1080. // data.put("pageSize", pageSize);
  1081. // ResponseWrap res = HttpUtil.doGet(url, data);
  1082. // if (!res.isSuccess()) {
  1083. // throw new Exception(res.getContent());
  1084. // } else {
  1085. // return JSON.parseObject(res.getContent(), new TypeReference<Page<User>>() {});
  1086. // }
  1087. // }
  1088. // return null;
  1089. // }
  1090. }