LoginController.java 25 KB

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