LoginController.java 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642
  1. package com.template.controller;
  2. import com.alibaba.fastjson.JSON;
  3. import com.google.gson.Gson;
  4. import com.google.gson.reflect.TypeToken;
  5. import com.template.annotation.*;
  6. import com.template.api.LoginControllerAPI;
  7. import com.template.common.utils.*;
  8. import com.template.config.WxOpenidConfig;
  9. import com.template.model.enumModel.eSchool;
  10. import com.template.model.pojo.*;
  11. import com.template.model.request.changePasswordRequest;
  12. import com.template.model.request.loginRequest;
  13. import com.template.model.request.mobileLoginRequest;
  14. import com.template.model.request.payResultRequest;
  15. import com.template.model.result.CommonResult;
  16. import com.template.model.result.Wx_user;
  17. import com.template.model.vo.*;
  18. import com.template.services.*;
  19. import org.slf4j.Logger;
  20. import org.slf4j.LoggerFactory;
  21. import org.springframework.beans.factory.annotation.Autowired;
  22. import org.springframework.transaction.annotation.Transactional;
  23. import org.springframework.util.StringUtils;
  24. import org.springframework.validation.BindingResult;
  25. import org.springframework.web.bind.annotation.RequestBody;
  26. import org.springframework.web.bind.annotation.RestController;
  27. import javax.annotation.Resource;
  28. import javax.servlet.http.HttpServletResponse;
  29. import java.math.BigDecimal;
  30. import java.math.BigInteger;
  31. import java.net.URLEncoder;
  32. import java.text.ParseException;
  33. import java.util.*;
  34. /**
  35. * @Author: binguo
  36. * @Date: 2023/7/5 星期三 9:28
  37. * @Description: com.template.controller
  38. * @Version: 1.0
  39. */
  40. @RestController
  41. public class LoginController implements LoginControllerAPI {
  42. @Autowired
  43. private WxOpenidConfig wxOpenidConfig;
  44. @Resource
  45. private WelcomeOrgService welcomeOrgService;
  46. @Resource
  47. private WelcomeFamilyService welcomeFamilyService;
  48. @Resource
  49. private WelcomeStudentService welcomeStudentService;
  50. @Resource
  51. private WelcomeAccountService welcomeAccountService;
  52. @Resource
  53. private WelcomeAccompanyService welcomeAccompanyService;
  54. @Resource
  55. private WelcomePaySettingService welcomePaySettingService;
  56. @Resource
  57. private WelcomeArriveSettingService welcomeArriveSettingService;
  58. private static Logger logger = LoggerFactory.getLogger(LoginController.class);
  59. @Override
  60. @PassToken
  61. public CommonResult testUpdate() {
  62. List<Integer> ids = new ArrayList<>();
  63. ids.add(6454);
  64. ids.add(6457);
  65. ids.add(6458);
  66. ids.add(6461);
  67. ids.add(6469);
  68. ids.add(6471);
  69. ids.add(6472);
  70. ids.add(6473);
  71. ids.add(6474);
  72. int result = welcomeStudentService.updateStudents(ids);
  73. return CommonResult.ok(result);
  74. }
  75. /**
  76. * 查看系统版本号
  77. *
  78. * @return
  79. */
  80. @Override
  81. @PassToken
  82. public CommonResult queryReduce() {
  83. return CommonResult.ok("当前系统版本为:1V");
  84. }
  85. /**
  86. * 登录接口
  87. *
  88. * @param loginRequest account 账号
  89. * password 密码
  90. * @return
  91. */
  92. @Override
  93. @PassToken
  94. @AWelcomeLog("登录系统")
  95. @AWelcomeTypeLog("登录")
  96. @AWelcomeLogMode("登录模块")
  97. @AWelcomeLevelLog("信息")
  98. public CommonResult Login(@RequestBody loginRequest loginRequest, BindingResult bindingResult) {
  99. if (loginRequest == null) {
  100. return CommonResult.fail("请传递参数");
  101. }
  102. if (bindingResult.hasErrors()) {
  103. String st = paramUtils.getParamError(bindingResult);
  104. return CommonResult.fail(st);
  105. }
  106. WelcomeAccount result = welcomeAccountService.getDataByAccount(loginRequest.getAccount());
  107. if (result == null) {
  108. return CommonResult.fail("账号不存在");
  109. }
  110. if (result.getStatus() != 1) {
  111. return CommonResult.fail("账号已冻结");
  112. }
  113. String encPassword = AesUtils.encrypt(loginRequest.getPassword());
  114. if (!encPassword.equals(result.getPassword())) {
  115. return CommonResult.fail("密码错误");
  116. }
  117. TokenDateVo tokenDate = JWTUtil.getToken("", result.getId(), null);
  118. String token = tokenDate == null ? "" : tokenDate.getToken();
  119. Date expireTime = tokenDate == null ? new Date() : tokenDate.getExpireTime();
  120. LoginVO login = new LoginVO();
  121. login.setToken(token);
  122. login.setTokenTtl(TimeExchange.DateToString(expireTime, "yyyy-MM-dd HH:mm:ss"));
  123. login.setUserName(result.getName());
  124. login.setAccountId(result.getId());
  125. return CommonResult.ok("200", "登录成功", login);
  126. }
  127. /**
  128. * 修改密码
  129. *
  130. * @param cpr oldPassword 旧密码
  131. * newPassword 新密码
  132. * confirmPassword 确认密码
  133. * @param userId
  134. * @param bindingResult
  135. * @return
  136. */
  137. @Override
  138. @Transactional(rollbackFor = {Exception.class})
  139. @AWelcomeLog("修改密码")
  140. @AWelcomeTypeLog("编辑")
  141. @AWelcomeLogMode("账号管理")
  142. @AWelcomeLevelLog("信息")
  143. public CommonResult ChangePassword(String userId, changePasswordRequest cpr, BindingResult bindingResult) throws Exception {
  144. ChangePasswordVO results = new ChangePasswordVO();
  145. if (bindingResult.hasErrors()) {
  146. String st = paramUtils.getParamError(bindingResult);
  147. return CommonResult.fail(st);
  148. }
  149. WelcomeAccount result = welcomeAccountService.getManageById(userId);
  150. if (result == null) {
  151. return CommonResult.fail("账号不存在");
  152. }
  153. if (!AesUtils.encrypt(cpr.getOldPassword()).equals(result.getPassword())) {
  154. return CommonResult.fail("原密码错误!");
  155. }
  156. result.setPassword(AesUtils.encrypt(cpr.getNewPassword()));
  157. int updateData = welcomeAccountService.updateWelcomeAccount(result);
  158. return updateData > 0 ? CommonResult.ok("修改成功") : CommonResult.fail("修改失败");
  159. }
  160. @Override
  161. @PassToken
  162. @Transactional(rollbackFor = {Exception.class})
  163. public CommonResult Openid(String wxcode, String urlstr, String state, HttpServletResponse response) throws Exception {
  164. logger.info("微校授权:" + wxcode + ";redirect_uri:" + urlstr + ";H5:" + state);
  165. System.out.println("微校授权:" + wxcode);
  166. Gson gson = new Gson();
  167. String tokenUrl = "https://open.wecard.qq.com/connect/oauth2/token";
  168. Map<String, String> tokenParams = new HashMap<>();
  169. tokenParams.put("wxcode", wxcode);
  170. tokenParams.put("app_key", wxOpenidConfig.getAppid());
  171. tokenParams.put("app_secret", wxOpenidConfig.getAppkey());
  172. tokenParams.put("grant_type", wxOpenidConfig.getGranttype());
  173. tokenParams.put("redirect_uri", state); // H5
  174. // wecode换取token
  175. String respon = HttpsClient.post(tokenUrl, tokenParams);
  176. System.out.println("微校授权2:" + respon);
  177. if (!StringUtils.hasText(respon)) {
  178. System.out.println("微校授权异常信息:respon为空" + respon);
  179. return CommonResult.fail("微校授权异常信息");
  180. }
  181. HashMap<String, Object> tokenMap = gson.fromJson(respon, new TypeToken<HashMap<String, Object>>() {
  182. }.getType());
  183. String accessToken = (String) tokenMap.get("access_token");
  184. // token换取用户信息
  185. String userInfoUrl = "https://open.wecard.qq.com/connect/oauth/get-user-info";
  186. Map<String, String> userInfoParam = new HashMap<>();
  187. userInfoParam.put("access_token", accessToken);
  188. String userinfo = HttpsClient.post(userInfoUrl, userInfoParam);
  189. String card_number = null;
  190. String user_name = null;
  191. String phone = null;
  192. String college = null;
  193. int idenType = 0;
  194. int gender = 0;
  195. String profession = null;
  196. String campus = null;
  197. String id_card = null;
  198. String classStr = null;
  199. System.out.println("微校授权获取用户信息:" + userinfo);
  200. Wx_user userinfos = gson.fromJson(userinfo, new TypeToken<Wx_user>() {
  201. }.getType());
  202. System.out.println("微校授权获取用户信息类别:" + userinfos.getIdentity_type());
  203. try {
  204. card_number = userinfos.getCard_number();
  205. user_name = userinfos.getName();
  206. phone = userinfos.getTelephone();
  207. college = userinfos.getCollege();
  208. classStr = userinfos.getClassStr();
  209. idenType = userinfos.getIdentity_type() == 1 || userinfos.getIdentity_type() == 6 ? 1 : 2;//1:学生 2:非学生
  210. gender = userinfos.getGender();
  211. profession = userinfos.getProfession();
  212. campus = userinfos.getCampus();
  213. id_card = userinfos.getId_card();
  214. } catch (Exception e) {
  215. System.out.println("微校授权异常信息:" + e.getMessage());
  216. response.sendRedirect(wxOpenidConfig.getIp() + "/#/pages/404/404/?message=" + URLEncoder.encode("获取用户信息失败", "UTF-8"));
  217. return CommonResult.fail(e.getMessage());
  218. }
  219. if (card_number == null || card_number.equals("")) {
  220. response.sendRedirect(wxOpenidConfig.getIp() + "/#/pages/404/404/?message=" + URLEncoder.encode("获取用户信息失败", "UTF-8"));
  221. return CommonResult.fail("卡号为空,授权失败");
  222. }
  223. //根据卡号查询repair_user表中的用户信息
  224. WelcomeStudent student = welcomeStudentService.getDataByIdcard(id_card);
  225. System.out.println("微校授权获取用户信息" + JSON.toJSON(student));
  226. //取消授权的身份验证 谁都能进
  227. //if (identity_type != 4 && user == null) {
  228. // return CommonResult.fail("非法权限,授权失败");
  229. //}
  230. System.out.println("微校授权校区:" + campus);
  231. if (student != null) {
  232. idenType = student.getIdenType();
  233. }
  234. Integer studentId = 0;
  235. if (student == null && idenType == 2) {
  236. try {
  237. student = new WelcomeStudent();
  238. student.setAdmissNum(card_number);
  239. student.setName(user_name);
  240. student.setPhone(phone);
  241. student.setSchool(!StringUtils.hasText(campus) ? "墨轩湖校区" : campus);
  242. student.setSchoolId(!StringUtils.hasText(campus) ? 1 : eSchool.stringOf(campus));
  243. student.setSex(gender == 1 ? "男" : "女");
  244. // student.setCollege(college);
  245. // student.setMajor(profession);
  246. // student.setClassstr(classStr);
  247. student.setIdenType(idenType);
  248. student.setCardId(id_card);//身份证号
  249. int num = welcomeStudentService.insertWelcomeStudent(student);
  250. if (num <= 0) {
  251. System.out.println("微校授权失败,外来人员信息新增异常:" + user_name + "" + card_number);
  252. response.sendRedirect(wxOpenidConfig.getIp() + "/#/pages/404/404/?message=" + URLEncoder.encode("用户新增异常", "UTF-8"));
  253. throw new Exception("微校授权失败!");
  254. }
  255. studentId = num;
  256. } catch (Exception e) {
  257. System.out.println("微校授权异常信息:" + e.getMessage());
  258. response.sendRedirect(wxOpenidConfig.getIp() + "/#/pages/404/404/?message=" + URLEncoder.encode("获取用户信息失败", "UTF-8"));
  259. throw new Exception("微校授权失败!");
  260. }
  261. }
  262. if (student == null && idenType == 1) {
  263. System.out.println("微校授权失败,学生信息新增异常:" + user_name + "" + card_number);
  264. response.sendRedirect(wxOpenidConfig.getIp() + "/#/pages/404/404/?message=" + URLEncoder.encode("用户在系统中不存在,请联系管理员", "UTF-8"));
  265. throw new Exception("微校授权失败!");
  266. } else if (student != null && idenType == 1) {
  267. //更新微校获取的年纪信息
  268. // student.setAdmissNum(card_number);
  269. // student.setName(user_name);
  270. // student.setPhone(phone);
  271. // student.setSchool(!StringUtils.hasText(campus) ? "墨轩湖校区" : campus);
  272. // student.setSchoolId(!StringUtils.hasText(campus) ? 1 : eSchool.stringOf(campus));
  273. // student.setSex(gender == 1 ? "男" : "女");
  274. // student.setCollege(college);
  275. // student.setMajor(profession);
  276. student.setIdenType(idenType);
  277. //student.setClassstr(classStr);
  278. //student.setCardId(id_card);//身份证号
  279. if (student.getIdenType().intValue() == 1 && !(student.getIsPay() != null && student.getIsPay().intValue() == 1)) {
  280. List<JsonPayVo> payInfos = WelcomePayController.queryStudentPayInfo(card_number, TimeExchange.getYear());
  281. BigDecimal payAmount = new BigDecimal(BigInteger.ZERO);//实缴金额
  282. BigDecimal yjPayAmount = new BigDecimal(BigInteger.ZERO);//应缴金额
  283. BigDecimal dkAmount = new BigDecimal(BigInteger.ZERO);//贷款金额
  284. for (JsonPayVo pi : payInfos) {
  285. dkAmount = dkAmount.add(pi.getDKJE());
  286. payAmount = payAmount.add(pi.getSJJE());
  287. yjPayAmount = yjPayAmount.add(pi.getYJJE());
  288. }
  289. BigDecimal studentPay = payAmount.add(dkAmount);
  290. student.setPayAmount(studentPay);
  291. student.setAmountPayable(yjPayAmount);
  292. System.out.println("进支付比较1" + JSON.toJSON(payInfos));
  293. if (payInfos != null && payInfos.size() > 0) {
  294. System.out.println("进支付比较2");
  295. String nstartTime = null;
  296. String nendTime = null;
  297. boolean lastYear = TimeExchange.CompareDate(TimeExchange.getDate(), TimeExchange.getYear() + "-07-01", "yyyy-MM-dd");
  298. Integer yearInt = Integer.valueOf(TimeExchange.getYear());
  299. //当前时间小于本年度的7月1日 说明要查去年的数据
  300. if (lastYear) {
  301. nstartTime = (yearInt - 1) + "-06-01";
  302. nendTime = yearInt + "-06-01";
  303. } else {
  304. nstartTime = yearInt + "-06-01";
  305. nendTime = (yearInt + 1) + "-06-01";
  306. }
  307. WelcomePaySetting paySettings = welcomePaySettingService.queryPaySettingById(student.getCollegeId(), student.getMajorId(), student.getBatchValue(), nstartTime, nendTime);
  308. System.out.println("进支付比较3" + JSON.toJSON(paySettings));
  309. if (paySettings != null) {
  310. System.out.println("进支付比较4");
  311. if (studentPay.compareTo(paySettings.getPayAmount()) >= 0) {
  312. student.setIsPay(1);
  313. } else {
  314. student.setIsPay(0);
  315. }
  316. } else {
  317. student.setIsPay(0);
  318. }
  319. } else {
  320. student.setIsPay(0);
  321. }
  322. }
  323. int num = welcomeStudentService.updateWelcomeStudent(student);
  324. if (num < 0) {
  325. System.out.println("微校授权失败,用户信息新增异常:" + user_name + "" + card_number);
  326. response.sendRedirect(wxOpenidConfig.getIp() + "/#/pages/404/404/?message=" + URLEncoder.encode("用户更新异常", "UTF-8"));
  327. throw new Exception("微校授权失败!");
  328. }
  329. studentId = student.getId();
  330. }
  331. if (student.getIsPay() == null) {
  332. student.setIsPay(0);
  333. }
  334. wxLoginVo wlv = new wxLoginVo();
  335. List<WelcomeOrg> orgs = welcomeOrgService.queryDatas(college, profession, classStr);
  336. if (orgs != null && orgs.size() > 0) {
  337. for (WelcomeOrg org : orgs) {
  338. if (org.getName().equals(college)) {
  339. wlv.setCollegeId(org.getId());
  340. wlv.setCollege(college);
  341. }
  342. if (org.getName().equals(profession)) {
  343. wlv.setMajorId(org.getId());
  344. wlv.setMajor(profession);
  345. }
  346. if (org.getName().equals(classStr)) {
  347. wlv.setClassstrId(org.getId());
  348. wlv.setClassstr(classStr);
  349. }
  350. }
  351. }
  352. wlv.setId(studentId);
  353. wlv.setAdmissNum(card_number);
  354. wlv.setName(user_name);
  355. wlv.setPicture(student.getPicture());
  356. wlv.setCardId(id_card);
  357. if (StringUtils.hasText(id_card)) {
  358. if (StringUtils.hasText(student.getSex())) {
  359. wlv.setSex(student.getSex());
  360. } else {
  361. String sex = StrUtils.getGender(id_card);
  362. wlv.setSex(sex);
  363. }
  364. //家庭成员
  365. List<FamilyVo> fvs = new ArrayList<>();
  366. List<WelcomeFamily> familys = welcomeFamilyService.getManageByCardId(student.getCardId());
  367. if (familys != null && familys.size() > 0) {
  368. for (WelcomeFamily wf : familys) {
  369. FamilyVo fv = new FamilyVo();
  370. fv.setId(wf.getId());
  371. fv.setFamilyShip(wf.getFamilyShip());
  372. fv.setName(wf.getName());
  373. fv.setPhone(wf.getPhone());
  374. fv.setWorkUnit(wf.getWorkUnit());
  375. fvs.add(fv);
  376. }
  377. }
  378. wlv.setFvs(fvs);
  379. //陪同人员
  380. List<AccompanyVo> avs = new ArrayList<>();
  381. List<WelcomeAccompany> accompanys = welcomeAccompanyService.getManageByCardId(student.getCardId());
  382. if (accompanys != null && accompanys.size() > 0) {
  383. for (WelcomeAccompany ac : accompanys) {
  384. AccompanyVo av = new AccompanyVo();
  385. av.setId(ac.getId());
  386. av.setName(ac.getName());
  387. av.setPhone(ac.getPhone());
  388. avs.add(av);
  389. }
  390. }
  391. wlv.setAvs(avs);
  392. //时间段
  393. List<ArriveTimeVo> atvs = new ArrayList<>();
  394. List<WelcomeArriveSetting> wass = welcomeArriveSettingService.queryCheckDatas();
  395. if (wass != null && wass.size() > 0) {
  396. for (WelcomeArriveSetting was : wass) {
  397. ArriveTimeVo atv = new ArriveTimeVo();
  398. atv.setId(was.getId());
  399. atv.setStartTime(was.getStartTime());
  400. atv.setEndTime(was.getEndTime());
  401. atv.setTimeStr(was.getStartTime() + "-" + was.getEndTime());
  402. atv.setIsCheck((student.getArriveTimeId() != null && was.getId().equals(student.getArriveTimeId())) ? 1 : 0);
  403. atvs.add(atv);
  404. }
  405. }
  406. wlv.setAtvs(atvs);
  407. }
  408. wlv.setSchool(!StringUtils.hasText(campus) ? "墨轩湖校区" : campus);
  409. wlv.setSchoolId(!StringUtils.hasText(campus) ? 1 : eSchool.stringOf(campus));
  410. //籍贯
  411. wlv.setOprovinceId(student.getOprovinceId());
  412. wlv.setOprovince(student.getOprovince());
  413. wlv.setOcityId(student.getOcityId());
  414. wlv.setOcity(student.getOcity());
  415. wlv.setOdistrictId(student.getOdistrictId());
  416. wlv.setOdistrict(student.getOdistrict());
  417. wlv.setProvinceId(student.getProvinceId());
  418. wlv.setProvince(student.getProvince());
  419. wlv.setCityId(student.getCityId());
  420. wlv.setCity(student.getCity());
  421. wlv.setDistrictId(student.getDistrictId());
  422. wlv.setDistrict(student.getDistrict());
  423. wlv.setIsPay(student.getIsPay());
  424. wlv.setPhone(student.getPhone().replace("(+86)", ""));
  425. wlv.setArrvieDate(student.getArrvieDate());
  426. wlv.setCollege(college == null ? "微校获取不到院校" : college);
  427. long expired = 1000 * 60 * 60 * 24 * 365;
  428. TokenDateVo token = JWTUtil.getToken(id_card, student.getId(), expired);
  429. wlv.setToken(token.getToken());
  430. System.out.println("微校授权成功:" + user_name + "" + card_number);
  431. response.sendRedirect(wxOpenidConfig.getIp() + "/#/pages/index/index/?urlstr=" + urlstr + "&token=" + token.getToken() + "&type=" + idenType);
  432. System.out.println("微校授权获取用户信息结果" + JSON.toJSON(wlv));
  433. return CommonResult.ok(wlv);
  434. }
  435. @Override
  436. @PassToken
  437. @AWelcomeLog("登录系统")
  438. @AWelcomeTypeLog("登录")
  439. @AWelcomeLogMode("移动端登录模块")
  440. @AWelcomeLevelLog("信息")
  441. public CommonResult mobileLogin(mobileLoginRequest mlr, BindingResult bindingResult) throws ParseException {
  442. if (mlr == null) {
  443. return CommonResult.fail("请传递参数");
  444. }
  445. if (bindingResult.hasErrors()) {
  446. String st = paramUtils.getParamError(bindingResult);
  447. return CommonResult.fail(st);
  448. }
  449. WelcomeStudent student = welcomeStudentService.getDataByIdcardOrNum(mlr.getAdmissNum(), mlr.getCardId());
  450. if (student == null) {
  451. return CommonResult.fail("录取号和身份证不匹配,登录失败!");
  452. }
  453. if (StringUtils.hasText(student.getCardId())) {
  454. if (StringUtils.hasText(student.getSex())) {
  455. student.setSex(student.getSex());
  456. } else {
  457. String sex = StrUtils.getGender(student.getCardId());
  458. student.setSex(sex);
  459. }
  460. }
  461. //家庭成员
  462. List<FamilyVo> fvs = new ArrayList<>();
  463. List<WelcomeFamily> familys = welcomeFamilyService.getManageByCardId(student.getCardId());
  464. if (familys != null && familys.size() > 0) {
  465. for (WelcomeFamily wf : familys) {
  466. FamilyVo fv = new FamilyVo();
  467. fv.setId(wf.getId());
  468. fv.setFamilyShip(wf.getFamilyShip());
  469. fv.setName(wf.getName());
  470. fv.setPhone(wf.getPhone());
  471. fv.setWorkUnit(wf.getWorkUnit());
  472. fvs.add(fv);
  473. }
  474. }
  475. student.setFvs(fvs);
  476. //陪同人员
  477. List<AccompanyVo> avs = new ArrayList<>();
  478. List<WelcomeAccompany> accompanys = welcomeAccompanyService.getManageByCardId(student.getCardId());
  479. if (accompanys != null && accompanys.size() > 0) {
  480. for (WelcomeAccompany ac : accompanys) {
  481. AccompanyVo av = new AccompanyVo();
  482. av.setId(ac.getId());
  483. av.setName(ac.getName());
  484. av.setPhone(ac.getPhone());
  485. avs.add(av);
  486. }
  487. }
  488. student.setAvs(avs);
  489. //时间段
  490. List<ArriveTimeVo> atvs = new ArrayList<>();
  491. List<WelcomeArriveSetting> wass = welcomeArriveSettingService.queryCheckDatas();
  492. if (wass != null && wass.size() > 0) {
  493. for (WelcomeArriveSetting was : wass) {
  494. ArriveTimeVo atv = new ArriveTimeVo();
  495. atv.setId(was.getId());
  496. atv.setStartTime(was.getStartTime());
  497. atv.setEndTime(was.getEndTime());
  498. atv.setTimeStr(was.getStartTime() + "-" + was.getEndTime());
  499. atv.setIsCheck((student.getArriveTimeId() != null && was.getId().equals(student.getArriveTimeId())) ? 1 : 0);
  500. atvs.add(atv);
  501. }
  502. }
  503. student.setAtvs(atvs);
  504. if (!(student.getIsPay() != null && student.getIsPay().intValue() == 1)) {
  505. System.out.println("进支付比较");
  506. List<JsonPayVo> payInfos = WelcomePayController.queryStudentPayInfo(student.getAdmissNum(), TimeExchange.getYear());
  507. BigDecimal payAmount = new BigDecimal(BigInteger.ZERO);//实缴金额
  508. BigDecimal yjPayAmount = new BigDecimal(BigInteger.ZERO);//应缴金额
  509. BigDecimal dkAmount = new BigDecimal(BigInteger.ZERO);//贷款金额
  510. for (JsonPayVo pi : payInfos) {
  511. dkAmount = dkAmount.add(pi.getDKJE());
  512. payAmount = payAmount.add(pi.getSJJE());
  513. yjPayAmount = yjPayAmount.add(pi.getYJJE());
  514. }
  515. BigDecimal studentPay = payAmount.add(dkAmount);
  516. student.setPayAmount(studentPay);
  517. student.setAmountPayable(yjPayAmount);
  518. System.out.println("进支付比较1" + JSON.toJSON(payInfos));
  519. if (payInfos != null && payInfos.size() > 0) {
  520. System.out.println("进支付比较2");
  521. String nstartTime = null;
  522. String nendTime = null;
  523. boolean lastYear = TimeExchange.CompareDate(TimeExchange.getDate(), TimeExchange.getYear() + "-07-01", "yyyy-MM-dd");
  524. Integer yearInt = Integer.valueOf(TimeExchange.getYear());
  525. //当前时间小于本年度的7月1日 说明要查去年的数据
  526. if (lastYear) {
  527. nstartTime = (yearInt - 1) + "-06-01";
  528. nendTime = yearInt + "-06-01";
  529. } else {
  530. nstartTime = yearInt + "-06-01";
  531. nendTime = (yearInt + 1) + "-06-01";
  532. }
  533. WelcomePaySetting paySettings = welcomePaySettingService.queryPaySettingById(student.getCollegeId(), student.getMajorId(), student.getBatchValue(), nstartTime, nendTime);
  534. System.out.println("进支付比较3" + JSON.toJSON(paySettings));
  535. if (paySettings != null) {
  536. System.out.println("进支付比较4");
  537. if (studentPay.compareTo(paySettings.getPayAmount()) >= 0) {
  538. student.setIsPay(1);
  539. } else {
  540. student.setIsPay(0);
  541. }
  542. } else {
  543. student.setIsPay(0);
  544. }
  545. } else {
  546. student.setIsPay(0);
  547. }
  548. if (payInfos != null && payInfos.size() > 0) {
  549. int update = welcomeStudentService.updateWelcomeStudent(student);
  550. if (update < 0) {
  551. logger.error("获取支付信息导致学校信息查询失败");
  552. return CommonResult.fail("查询失败");
  553. }
  554. }
  555. }
  556. if (student.getIsPay() == null) {
  557. student.setIsPay(0);
  558. }
  559. long expired = 1000 * 60 * 60 * 24 * 365;
  560. TokenDateVo token = JWTUtil.getToken(student.getCardId(), student.getId(), expired);
  561. student.setToken(token.getToken());
  562. return CommonResult.ok(student);
  563. }
  564. @Override
  565. @PassToken
  566. public CommonResult writeCarInfo() {
  567. com.alibaba.fastjson.JSONObject json = new com.alibaba.fastjson.JSONObject();
  568. String ukey = "6VMZEC5C6HZM7EO8";
  569. com.alibaba.fastjson.JSONObject datas = new com.alibaba.fastjson.JSONObject();
  570. datas.put("car_number", "赣A0AY39");
  571. datas.put("begin_time", "2025-06-16 10:00:00");
  572. datas.put("end_time", "2025-06-16 18:00:00");
  573. datas.put("mobile", "18279193722");
  574. // 生成带签名的字符串并使用MD5生成签名,然后转大写
  575. String sign = datas.toJSONString() + "key=" + ukey;
  576. sign = CreateSign1.MD5(sign).toUpperCase();
  577. json.put("service_name", "visitor_sync");
  578. json.put("sign", sign);
  579. json.put("park_id", "10033845");
  580. json.put("data", datas);
  581. String msg = HttpsClient.sendJson("http://istparking.sciseetech.com/public/visitor/do", json);
  582. return CommonResult.ok(msg);
  583. }
  584. @Override
  585. public CommonResult payResult(payResultRequest mlr) {
  586. logger.info("支付回调信息,mlr参数:" + JSON.toJSON(mlr));
  587. return CommonResult.ok();
  588. }
  589. }