WechatController.java 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541
  1. package com.chuanghai.smartschool.tuitionpayment.controller;
  2. import com.alibaba.fastjson.JSON;
  3. import com.alibaba.fastjson.JSONArray;
  4. import com.alibaba.fastjson.JSONObject;
  5. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  6. import com.chuanghai.smartschool.tuitionpayment.common.exception.BizCodeEnume;
  7. import com.chuanghai.smartschool.tuitionpayment.common.exception.RRException;
  8. import com.chuanghai.smartschool.tuitionpayment.common.utils.CommonResult;
  9. import com.chuanghai.smartschool.tuitionpayment.config.WechatConfig;
  10. import com.chuanghai.smartschool.tuitionpayment.config.WeixiaoConfig;
  11. import com.chuanghai.smartschool.tuitionpayment.entity.PayItem;
  12. import com.chuanghai.smartschool.tuitionpayment.entity.PayOrderEntity;
  13. import com.chuanghai.smartschool.tuitionpayment.entity.PayableInfoEntity;
  14. import com.chuanghai.smartschool.tuitionpayment.entity.PayableInfoWaterEntity;
  15. import com.chuanghai.smartschool.tuitionpayment.service.PayItemService;
  16. import com.chuanghai.smartschool.tuitionpayment.service.PayOrderService;
  17. import com.chuanghai.smartschool.tuitionpayment.service.PayableInfoService;
  18. import com.chuanghai.smartschool.tuitionpayment.service.PayableInfoWaterService;
  19. import com.chuanghai.smartschool.tuitionpayment.vo.PayableInfoStudentResultVO;
  20. import com.chuanghai.smartschool.tuitionpayment.vo.WeixiaoVO;
  21. import com.fasterxml.jackson.core.type.TypeReference;
  22. import com.fasterxml.jackson.databind.JsonNode;
  23. import com.fasterxml.jackson.databind.ObjectMapper;
  24. import org.apache.poi.ss.formula.functions.T;
  25. import org.springframework.beans.factory.annotation.Autowired;
  26. import org.springframework.http.HttpEntity;
  27. import org.springframework.http.HttpHeaders;
  28. import org.springframework.http.MediaType;
  29. import org.springframework.http.ResponseEntity;
  30. import org.springframework.http.converter.StringHttpMessageConverter;
  31. import org.springframework.scheduling.annotation.Scheduled;
  32. import org.springframework.stereotype.Controller;
  33. import org.springframework.web.bind.annotation.*;
  34. import org.springframework.web.client.RestTemplate;
  35. import java.net.URLEncoder;
  36. import java.nio.charset.StandardCharsets;
  37. import java.util.ArrayList;
  38. import java.util.HashMap;
  39. import java.util.List;
  40. import java.util.Map;
  41. /**
  42. * 微信相关接口
  43. *
  44. * @author codingliang
  45. * @email codingliang@gmail.com
  46. * @date 2021-08-12 16:04
  47. */
  48. @Controller
  49. @RequestMapping("tuitionpayment/wechat")
  50. public class WechatController {
  51. @Autowired
  52. private WechatConfig wechatConfig;
  53. @Autowired
  54. private WeixiaoConfig weixiaoConfig;
  55. /**
  56. * 用于记录用户的access_token
  57. */
  58. private String accessTokenPublic = "";
  59. /**
  60. * 用于记录催缴的次数 计时器
  61. */
  62. private Integer askCount = 0;
  63. @Autowired
  64. private PayableInfoService payableInfoService;
  65. @Autowired
  66. private PayableInfoWaterService payableInfoWaterService;
  67. @Autowired
  68. private PayOrderService payOrderService;
  69. @Autowired
  70. private FeedbackMsgController feedbackMsgController;
  71. @Autowired
  72. private PayItemService payItemService;
  73. /**
  74. * 微信授权回调地址
  75. *
  76. * @param code 微信code
  77. * @apiNote 用户跳转到微信授权链接上,微信服务器接收用户授权后会携带code回调到该接口上,该接口使用code获取到用户的openId信息。
  78. * 如果openId获取成功,该接口会以 【fontendUrl + 路由地址 + ?openId=wx123456】 的形式跳回到前端应用页面;
  79. * 如果openId获取失败,该接口会以 【fontendUrl + /error/?errorMsg=获取用户openId失败】 的形式跳回到前端应用页面。
  80. * <strong>注意:</strong>
  81. * fontendUrl + 路由地址:前端项目地址+页面路由地址,用于前端页面接收用户的信息或错误信息,该地址需要前端人员与后台开发人员协调好。
  82. */
  83. @GetMapping("pub/auth")
  84. public String pubAuth(String code, String state) {
  85. // code换取access_token
  86. String url = "https://api.weixin.qq.com/sns/oauth2/access_token?" +
  87. "appid=" + wechatConfig.getAppid() +
  88. "&secret=" + wechatConfig.getSecret() +
  89. "&code=" + code +
  90. "&grant_type=authorization_code";
  91. try {
  92. RestTemplate restTemplate = new RestTemplate();
  93. restTemplate.getMessageConverters().set(1, new StringHttpMessageConverter(StandardCharsets.UTF_8)); // 解决回参中文乱码
  94. String response = restTemplate.getForObject(url, String.class);
  95. ObjectMapper mapper = new ObjectMapper();
  96. JsonNode jsonNode = mapper.readTree(response);
  97. String openid = jsonNode.get("openid").asText();
  98. return "redirect:" + wechatConfig.getFontendUrl() + "/#/" + state + "/?openId=" + openid;
  99. } catch (Exception e) {
  100. return "redirect:" + wechatConfig.getFontendUrl() + "/error/?errorMsg=获取用户openId失败";
  101. }
  102. }
  103. /**
  104. * 微校授权回调地址
  105. *
  106. * @param wxcode 微校code
  107. * @param state 透传数据
  108. * @return
  109. * @apiNote 用户跳转到微校授权链接上,微校服务器接收用户授权后会携带wxcode回调到该接口上,该接口使用wxcode获取到用户的信息。
  110. * 如果用户信息获取成功,该接口会以 【fontendUrl + /?cardNumber=wx123456&name=测试用户】 的形式跳回到前端应用页面;
  111. * 如果用户信息获取失败,该接口会以 【fontendUrl + /error/?errorMsg=获取用户信息失败】 的形式跳回到前端应用页面。
  112. * <strong>注意:</strong>
  113. * fontendUrl + 路由地址:前端项目地址+页面路由地址,用于前端页面接收用户的信息或错误信息,该地址需要前端人员与后台开发人员协调好。
  114. * </p>
  115. */
  116. @GetMapping("weixiao/auth")
  117. public String weixiaoAuth(String wxcode, String state) {
  118. String tokenUrl = "https://open.wecard.qq.com/connect/oauth2/token";
  119. Map<String, String> tokenParams = new HashMap<>();
  120. tokenParams.put("wxcode", wxcode);
  121. tokenParams.put("app_key", weixiaoConfig.getAppKey());
  122. tokenParams.put("app_secret", weixiaoConfig.getAppSecret());
  123. tokenParams.put("grant_type", "authorization_code");
  124. tokenParams.put("redirect_uri", state); // 该地址需要与发起授权地址保持一直
  125. try {
  126. // wecode换取token
  127. RestTemplate client = new RestTemplate();
  128. HttpHeaders headers = new HttpHeaders();
  129. headers.setContentType(MediaType.APPLICATION_JSON);
  130. HttpEntity<Map<String, String>> request = new HttpEntity<>(tokenParams, headers);
  131. //ResponseEntity<String> tokenResponse = client.postForEntity(tokenUrl, tokenParams, String.class);
  132. ResponseEntity<String> tokenResponse = client.postForEntity(tokenUrl, request, String.class);
  133. ObjectMapper mapper = new ObjectMapper();
  134. Map<String, Object> jsonMap = mapper.readValue(tokenResponse.getBody(), new TypeReference<Map<String, Object>>() {
  135. });
  136. String accessToken = (String) jsonMap.get("access_token");
  137. // token换取用户信息
  138. String userInfoUrl = "https://open.wecard.qq.com/connect/oauth/get-user-info";
  139. Map<String, String> userInfoParam = new HashMap<>();
  140. userInfoParam.put("access_token", accessToken);
  141. ResponseEntity<String> userInfoResponse = client.postForEntity(userInfoUrl, userInfoParam, String.class);
  142. Map<String, Object> userInfoMap = mapper.readValue(userInfoResponse.getBody(), new TypeReference<Map<String, Object>>() {
  143. });
  144. String cardNumber = userInfoMap.get("card_number").toString();
  145. String encodeName = URLEncoder.encode(userInfoMap.get("name").toString(), "utf-8");
  146. return "redirect:" + weixiaoConfig.getFontendUrl() + "/#/pages/index/index/?cardNumber=" + cardNumber + "&name=" + encodeName;
  147. } catch (Exception e) {
  148. e.printStackTrace();
  149. return "redirect:" + weixiaoConfig.getFontendUrl() + "/#/error/";
  150. }
  151. }
  152. /**
  153. * 获取微校的应用有效凭证 7200s有效 两小时内有效
  154. * @return
  155. */
  156. @Scheduled(fixedDelay = 7190000)
  157. public void getWeiXiaoToken() {
  158. try {
  159. RestTemplate client = new RestTemplate();
  160. ObjectMapper mapper = new ObjectMapper();
  161. String userInfoUrl = "https://open.wecard.qq.com/cgi-bin/oauth2/token";
  162. Map<String, String> userInfoParam = new HashMap<>();
  163. userInfoParam.put("app_key", weixiaoConfig.getAppKey());
  164. userInfoParam.put("app_secret", weixiaoConfig.getAppSecret());
  165. userInfoParam.put("grant_type", "client_credentials");
  166. userInfoParam.put("scope", "base");
  167. userInfoParam.put("ocode", "1015730314");
  168. ResponseEntity<String> userInfoResponse = client.postForEntity(userInfoUrl, userInfoParam, String.class);
  169. Map<String, Object> userInfoMap = mapper.readValue(userInfoResponse.getBody(), new TypeReference<Map<String, Object>>() {
  170. });
  171. accessTokenPublic = userInfoMap.get("access_token").toString();
  172. } catch (Exception e) {
  173. e.printStackTrace();
  174. }
  175. }
  176. /**
  177. * 通过学生姓名 身份证查找用户的cardNumber
  178. * @param studentName
  179. * @param idCard
  180. * @return
  181. */
  182. @GetMapping("getWeiXiaoToken1")
  183. @ResponseBody
  184. public String getCardNumber(String studentName, String idCard) {
  185. String card_number = "";
  186. try {
  187. RestTemplate client = new RestTemplate();
  188. ObjectMapper mapper = new ObjectMapper();
  189. String userInfoUrl ="https://open.wecard.qq.com/cgi-bin/user/search";
  190. Map<String, String> userInfoParam = new HashMap<>();
  191. userInfoParam.put("access_token", accessTokenPublic);
  192. userInfoParam.put("keywords", studentName);
  193. ResponseEntity<String> userInfoResponse = client.postForEntity(userInfoUrl, userInfoParam, String.class);
  194. JSONObject jsonObj = JSON.parseObject(userInfoResponse.getBody());
  195. JSONArray userlist = jsonObj.getJSONArray("userlist");
  196. Map<String, Object> userInfoMap = mapper.readValue(userlist.get(0).toString(), new TypeReference<Map<String, Object>>() {
  197. });
  198. String id_card = "";
  199. if (userInfoMap.get("card_number") != null) {
  200. card_number = userInfoMap.get("card_number").toString();
  201. }
  202. if (userInfoMap.get("id_card") != null) {
  203. id_card = userInfoMap.get("id_card").toString();
  204. }
  205. if (idCard.equals(id_card)) {
  206. return card_number;
  207. }
  208. } catch (Exception e) {
  209. e.printStackTrace();
  210. }
  211. return card_number;
  212. }
  213. public PayableInfoStudentResultVO queryStudent() {
  214. PayableInfoStudentResultVO payableInfoStudentResultVO = new PayableInfoStudentResultVO();
  215. try {
  216. // token换取用户信息
  217. RestTemplate client = new RestTemplate();
  218. ObjectMapper mapper = new ObjectMapper();
  219. String userInfoUrl = "https://open.wecard.qq.com/connect/oauth/get-user-info";
  220. Map<String, String> userInfoParam = new HashMap<>();
  221. userInfoParam.put("access_token", accessTokenPublic);
  222. ResponseEntity<String> userInfoResponse = client.postForEntity(userInfoUrl, userInfoParam, String.class);
  223. Map<String, Object> userInfoMap = mapper.readValue(userInfoResponse.getBody(), new TypeReference<Map<String, Object>>() {
  224. });
  225. String name = userInfoMap.get("name").toString();
  226. String card_number = userInfoMap.get("card_number").toString();
  227. String grade = userInfoMap.get("grade").toString();
  228. grade = grade.substring(2, grade.length());
  229. String clazz = userInfoMap.get("class").toString();
  230. payableInfoStudentResultVO.setIdCard(card_number);
  231. payableInfoStudentResultVO.setStudentName(name);
  232. payableInfoStudentResultVO.setMajor(grade + clazz);
  233. } catch (Exception e) {
  234. e.printStackTrace();
  235. }
  236. return payableInfoStudentResultVO;
  237. }
  238. /**
  239. * 实现同步下发缴费订单功能
  240. *
  241. * @param itemName
  242. * @return
  243. */
  244. @PostMapping("/oneKey")
  245. @ResponseBody
  246. public CommonResult<T> oneKey(String itemName) {
  247. WeixiaoVO weixiaoVO = new WeixiaoVO();
  248. QueryWrapper<PayableInfoEntity> wrapper = new QueryWrapper<>();
  249. QueryWrapper<PayableInfoWaterEntity> water = new QueryWrapper<>();
  250. wrapper.eq("pay_notice_type", "1")
  251. .eq("payment_item", itemName);
  252. water.eq("pay_notice_type", "1")
  253. .eq("payment_item", itemName);
  254. List<PayableInfoEntity> payableInfoEntityList = payableInfoService.list(wrapper);
  255. List<PayableInfoWaterEntity> payableInfoWaterEntityList = payableInfoWaterService.list(water);
  256. List<String> cardNumberList = new ArrayList<>();
  257. if (payableInfoEntityList.size() > 0) {
  258. payableInfoEntityList.forEach(payableInfoEntity -> {
  259. payableInfoEntity.setPayNoticeType("2");
  260. cardNumberList.add(payableInfoEntity.getCardNumber());
  261. payableInfoService.updateById(payableInfoEntity);
  262. });
  263. }
  264. if (payableInfoWaterEntityList.size() > 0) {
  265. payableInfoWaterEntityList.forEach(payableInfoEntityWater -> {
  266. payableInfoEntityWater.setPayNoticeType("2");
  267. cardNumberList.add(payableInfoEntityWater.getCardNumber());
  268. payableInfoWaterService.updateById(payableInfoEntityWater);
  269. });
  270. }
  271. weixiaoVO.setCardNumberList(cardNumberList);
  272. weixiaoVO.setTitle(itemName + "缴纳通知");
  273. weixiaoVO.setSender("财务办公室");
  274. weixiaoVO.setContent("同学你好," + itemName + "缴费已经开始,请尽快查看缴费详情完成缴费,谢谢合作!");
  275. JSONObject jsonObject = (JSONObject) JSONObject.toJSON(weixiaoVO);
  276. return notice(jsonObject);
  277. }
  278. /**
  279. * 实现催缴下发缴费订单功能
  280. *
  281. * @param jsonObject
  282. * @return
  283. */
  284. @PostMapping("/oneKeyNotice")
  285. @ResponseBody
  286. public CommonResult<T> oneKeyNotice(@RequestBody JSONObject jsonObject) {
  287. String itemName = jsonObject.get("itemName").toString();
  288. JSONArray cardNumberList = jsonObject.getJSONArray("cardNumberList");
  289. if (cardNumberList.size() == 0) {
  290. QueryWrapper<PayableInfoEntity> wrapper = new QueryWrapper<>();
  291. QueryWrapper<PayableInfoWaterEntity> water = new QueryWrapper<>();
  292. wrapper.in("pay_item_type", "1","3")
  293. .eq("payment_item", itemName);
  294. water.eq("pay_notice_type", "1")
  295. .eq("payment_item", itemName);
  296. List<PayableInfoEntity> payableInfoEntityList = payableInfoService.list(wrapper);
  297. List<PayableInfoWaterEntity> payableInfoWaterEntityList = payableInfoWaterService.list(water);
  298. if (payableInfoEntityList.size() > 0) {
  299. payableInfoEntityList.forEach(payableInfoEntity -> {
  300. cardNumberList.add(payableInfoEntity.getCardNumber());
  301. });
  302. }
  303. if (payableInfoWaterEntityList.size() > 0) {
  304. payableInfoWaterEntityList.forEach(payableInfoEntityWater -> {
  305. cardNumberList.add(payableInfoEntityWater.getCardNumber());
  306. });
  307. }
  308. }
  309. WeixiaoVO weixiaoVO = new WeixiaoVO();
  310. weixiaoVO.setCardNumberList(cardNumberList);
  311. weixiaoVO.setTitle(itemName + "催缴通知");
  312. weixiaoVO.setSender("财务办公室");
  313. weixiaoVO.setContent("同学你好," + itemName + "缴费已经开始,请尽快查看缴费详情完成缴费,谢谢合作!");
  314. JSONObject json = (JSONObject) JSONObject.toJSON(weixiaoVO);
  315. return notice(json);
  316. }
  317. /**
  318. * @param jsonObject 封装了发送微校通知的参数信息
  319. * @return
  320. */
  321. @PostMapping("weixiao/notice")
  322. @ResponseBody
  323. public CommonResult<T> notice(@RequestBody JSONObject jsonObject) {
  324. WeixiaoVO weixiaoVO = JSONObject.toJavaObject(jsonObject, WeixiaoVO.class);
  325. Map<String, String> param = new HashMap<>();
  326. param.put("title", weixiaoVO.getTitle());
  327. String s = JSON.parseArray(weixiaoVO.getCardNumberList().toString()).toJSONString();
  328. param.put("cards", s);
  329. param.put("content", weixiaoVO.getContent());
  330. param.put("sender", weixiaoVO.getSender());
  331. String url = "https://open.wecard.qq.com/cgi-bin/notice/send?access_token=" + accessTokenPublic;
  332. try {
  333. RestTemplate restTemplate = new RestTemplate();
  334. HttpHeaders headers = new HttpHeaders();
  335. headers.setContentType(MediaType.APPLICATION_JSON);
  336. HttpEntity<Map<String, String>> request = new HttpEntity<>(param, headers);
  337. ResponseEntity<String> responseEntity = restTemplate.postForEntity(url, request, String.class);
  338. }catch (Exception e){
  339. throw new RRException(BizCodeEnume.TOKET_INVALID);
  340. }
  341. return CommonResult.ok();
  342. }
  343. /**
  344. * 缴费异常订单自动发送微校通知
  345. * itemName 缴费项目
  346. *
  347. * @return
  348. */
  349. @ResponseBody
  350. public CommonResult<T> sendException(String itemName, String orderNo) {
  351. QueryWrapper<PayItem> wrapper1 = new QueryWrapper<>();
  352. wrapper1.eq("item_name", itemName);
  353. PayItem payItem = payItemService.getOne(wrapper1);
  354. //查询微校通知数据 isSend 2 表示开启推送
  355. if (payItem.getItemExcept()) {
  356. QueryWrapper<PayOrderEntity> wrapper = new QueryWrapper<>();
  357. wrapper.eq("status", "1");
  358. wrapper.eq("except_type", "1");
  359. wrapper.eq("pay_item", itemName);
  360. wrapper.eq("order_no", orderNo);
  361. PayOrderEntity payOrder = payOrderService.getOne(wrapper);
  362. List<String> cardNumberList = new ArrayList<>();
  363. WeixiaoVO weixiaoVO = new WeixiaoVO();
  364. if (payOrder != null) {
  365. payOrder.setExceptType("2");
  366. String cardNumber = payOrder.getPayerIdentify();
  367. cardNumberList.add(cardNumber);
  368. weixiaoVO.setTitle(payOrder.getPayItem() + "缴纳异常通知");
  369. }
  370. weixiaoVO.setCardNumberList(cardNumberList);
  371. weixiaoVO.setContent("同学你好,你的" + itemName + "缴费订单异常缴费失败,请尽快查看缴费详情,并再次缴费。若为系统原因,请及时反馈!");
  372. weixiaoVO.setSender("财务办公室");
  373. JSONObject jsonObject = (JSONObject) JSONObject.toJSON(weixiaoVO);
  374. notice(jsonObject);
  375. //更新订单异常推送的状态
  376. payOrderService.updateById(payOrder);
  377. }
  378. return CommonResult.ok();
  379. }
  380. /**
  381. * 每天执行一次催缴 下午15点
  382. */
  383. @Scheduled(fixedDelay = 20000)
  384. // @Scheduled(cron = "0 0 15 * * ?")
  385. public void autoTiming() {
  386. List<PayItem> payItemList = payItemService.list();
  387. for (int i = 0; i < payItemList.size(); i++) {
  388. PayItem payItem = (PayItem) payItemList.get(i);
  389. String itemName = payItem.getItemName();
  390. Boolean itemAsk = payItem.getItemAsk();
  391. Integer itemAskDay = Integer.parseInt(payItem.getItemAskDay());
  392. //获取设置的请求次数
  393. Integer itemAskCount = Integer.parseInt(payItem.getItemAskCount());
  394. //获取本请求成功的次数
  395. Integer count = Integer.parseInt(payItem.getRequestCount());
  396. if (itemAsk) {
  397. if ((count < itemAskCount) && (askCount % itemAskDay == 0)) {
  398. askPay(itemName);
  399. count += 1;
  400. payItem.setRequestCount(String.valueOf(count));
  401. payItemService.updateById(payItem);
  402. }
  403. }
  404. }
  405. //催缴计数器累加
  406. askCount += 1;
  407. }
  408. /**
  409. * 是否催缴,发送微校通知
  410. *
  411. * @return
  412. */
  413. public CommonResult<T> askPay(String itemName) {
  414. QueryWrapper<PayItem> wrapper1 = new QueryWrapper<>();
  415. wrapper1.eq("item_name", itemName);
  416. PayItem payItem = payItemService.getOne(wrapper1);
  417. if (!itemName.equals("水费缴纳")) {
  418. WeixiaoVO weixiaoVO = new WeixiaoVO();
  419. List<String> cardNumberList = new ArrayList<>();
  420. //查询微校通知数据 isSend 2 表示开启推送
  421. QueryWrapper<PayableInfoEntity> wapper = new QueryWrapper<>();
  422. wapper.eq("pay_notice_type", "2")
  423. .eq("pay_item_type", "1")
  424. .eq("payment_item", itemName);
  425. List<PayableInfoEntity> list = payableInfoService.list(wapper);
  426. //催缴的人员编号
  427. if (list.size() > 0) {
  428. list.forEach(payableInfoEntity -> {
  429. String cardNumber = payableInfoEntity.getCardNumber();
  430. cardNumberList.add(cardNumber);
  431. weixiaoVO.setTitle(payableInfoEntity.getPaymentItem() + "缴纳通知");
  432. });
  433. }
  434. weixiaoVO.setCardNumberList(cardNumberList);
  435. weixiaoVO.setContent("同学你好," + itemName + "缴费详情已经下发,请尽快查看缴费项目并完成缴费,谢谢配合!");
  436. weixiaoVO.setSender("财务办公室");
  437. JSONObject jsonObject = (JSONObject) JSONObject.toJSON(weixiaoVO);
  438. return notice(jsonObject);
  439. } else {
  440. WeixiaoVO weixiaoVO = new WeixiaoVO();
  441. List<String> cardNumberList = new ArrayList<>();
  442. //查询微校通知数据 isSend 2 表示开启推送
  443. QueryWrapper<PayableInfoWaterEntity> wapper1 = new QueryWrapper<>();
  444. wapper1.eq("pay_notice_type", "2")
  445. .eq("pay_item_type", "1")
  446. .eq("payment_item", itemName);
  447. List<PayableInfoWaterEntity> list1 = payableInfoWaterService.list(wapper1);
  448. //催缴的人员编号
  449. if (list1.size() > 0) {
  450. list1.forEach(payableInfoEntity -> {
  451. String cardNumber = payableInfoEntity.getCardNumber();
  452. cardNumberList.add(cardNumber);
  453. weixiaoVO.setTitle(payableInfoEntity.getPaymentItem() + "缴纳通知");
  454. });
  455. weixiaoVO.setCardNumberList(cardNumberList);
  456. weixiaoVO.setContent("同学你好," + itemName + "缴费详情已经下发,请尽快查看缴费项目并完成缴费,谢谢配合!");
  457. weixiaoVO.setSender("财务办公室");
  458. JSONObject jsonObject = (JSONObject) JSONObject.toJSON(weixiaoVO);
  459. return notice(jsonObject);
  460. }
  461. }
  462. return CommonResult.ok();
  463. }
  464. /**
  465. * 处理反馈后开启反馈通知功能
  466. *
  467. * @param cardNumber 反馈通知对象的微校账号 card_number
  468. * @param content 处理内容
  469. * @return
  470. */
  471. @GetMapping("/disposeSend")
  472. @ResponseBody
  473. public CommonResult<T> disposeSend(@RequestParam("cardNumber") String cardNumber,
  474. @RequestParam("content") String content,
  475. @RequestParam("id") Long id) {
  476. List<String> cardNumberList = new ArrayList<>();
  477. cardNumberList.add(cardNumber);
  478. WeixiaoVO weixiaoVO = new WeixiaoVO();
  479. weixiaoVO.setTitle("缴费反馈处理通知");
  480. weixiaoVO.setCardNumberList(cardNumberList);
  481. weixiaoVO.setContent(content);
  482. weixiaoVO.setSender("财务办公室");
  483. JSONObject jsonObject = (JSONObject) JSONObject.toJSON(weixiaoVO);
  484. feedbackMsgController.handleFeedbackMsg(id, content);
  485. return notice(jsonObject);
  486. }
  487. }