WxService.java 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539
  1. package com.boot.security.server.service;
  2. import java.io.IOException;
  3. import java.io.InputStream;
  4. import java.util.HashMap;
  5. import java.util.List;
  6. import java.util.Map;
  7. import java.util.Random;
  8. import java.util.UUID;
  9. import java.util.regex.Matcher;
  10. import java.util.regex.Pattern;
  11. import org.slf4j.Logger;
  12. import org.slf4j.LoggerFactory;
  13. import org.springframework.beans.factory.annotation.Autowired;
  14. import org.springframework.mock.web.MockMultipartFile;
  15. import org.springframework.stereotype.Service;
  16. import org.springframework.web.multipart.MultipartFile;
  17. import com.alibaba.fastjson.JSON;
  18. import com.alibaba.fastjson.JSONObject;
  19. import com.boot.security.server.config.MyProps;
  20. import com.boot.security.server.config.TokenThread;
  21. import com.boot.security.server.dao.CusAuditInfoDao;
  22. import com.boot.security.server.dao.CusAuthInfoDao;
  23. import com.boot.security.server.dao.CusLoginInfoDao;
  24. import com.boot.security.server.dao.CusSelfInfoDao;
  25. import com.boot.security.server.dao.DictDao;
  26. import com.boot.security.server.dao.SmsVerifycodeDao;
  27. import com.boot.security.server.model.CusAuditInfo;
  28. import com.boot.security.server.model.CusAuthInfo;
  29. import com.boot.security.server.model.CusLoginInfo;
  30. import com.boot.security.server.model.CusSelfInfo;
  31. import com.boot.security.server.model.Dict;
  32. import com.boot.security.server.model.FileInfo;
  33. import com.boot.security.server.model.SmsVerifycode;
  34. import com.boot.security.server.utils.AesCbcUtil;
  35. import com.boot.security.server.utils.DateTimeUtil;
  36. import com.boot.security.server.utils.HttpUtil;
  37. import com.boot.security.server.utils.SMSUtil;
  38. import com.boot.security.server.utils.StrUtil;
  39. @Service("wxService")
  40. public class WxService {
  41. private static final Logger log = LoggerFactory.getLogger("adminLogger");
  42. @Autowired
  43. private MyProps myProps;
  44. @Autowired
  45. private FileService fileService;
  46. @Autowired
  47. private SmsVerifycodeDao smsVerifycodeDao;
  48. @Autowired
  49. private CusLoginInfoDao cusLoginInfoDao;
  50. @Autowired
  51. private CusAuthInfoDao cusAuthInfoDao;
  52. @Autowired
  53. private CusSelfInfoDao cusSelfInfoDao;
  54. @Autowired
  55. private CusAuditInfoDao cusAuditInfoDao;
  56. @Autowired
  57. private DictDao dictDao;
  58. /**
  59. * 微信用户登录
  60. *@return
  61. **/
  62. public String wxLogin(Map<String,Object> paramMap) {
  63. log.info("微信用户登录---------start-------");
  64. Map<String,Object> resultMap = new HashMap<String,Object>();
  65. String code = (String) paramMap.get("code");
  66. String iv = (String) paramMap.get("iv");
  67. String encryptedData = (String) paramMap.get("encryptedData");
  68. if(StrUtil.isEmpty(code)) {
  69. resultMap.put("data", "");
  70. resultMap.put("code", "1");
  71. resultMap.put("msg", "code不能为空!");
  72. log.info("微信用户登录失败---------code为空-------");
  73. return JSON.toJSONString(resultMap);
  74. }
  75. Map<String,Object> dataMap = new HashMap<String,Object>();
  76. String token = "";
  77. String session_key = "";
  78. String openid = "";
  79. String unionid = "";
  80. String appid = myProps.getWxAppid();
  81. String secret = myProps.getWxSecret();
  82. String auth = myProps.getWxAuth();
  83. String url = myProps.getWxloginUrl();
  84. log.info("微信登录url:"+url+"appid="+appid+"&secret="+secret+"&js_code="+code+"&grant_type="+auth );
  85. String result = HttpUtil.sendGet(url+"appid="+appid+"&secret="+secret+"&js_code="+code+"&grant_type="+auth, "");
  86. log.info("微信登录接口返回结果:"+result);
  87. if("fail".equals(result)) {
  88. resultMap.put("data", "");
  89. resultMap.put("code", "1");
  90. resultMap.put("msg", "fail");
  91. log.info("微信用户登录失败---------fail-------");
  92. return JSON.toJSONString(resultMap);
  93. }else {
  94. JSONObject reJo = JSON.parseObject(result);
  95. if(StrUtil.isNotEmpty(reJo.getString("errcode"))) {
  96. resultMap.put("data", "");
  97. resultMap.put("code", "1");
  98. resultMap.put("msg", reJo.getString("errcode"));
  99. log.info("微信用户登录失败---------code失效-------");
  100. return JSON.toJSONString(resultMap);
  101. }else {
  102. log.info("微信用户登录成功---------result:"+JSON.toJSONString(result));
  103. token = UUID.randomUUID().toString().replaceAll("-", "");
  104. session_key = reJo.getString("session_key");
  105. openid = reJo.getString("openid");
  106. unionid = reJo.getString("unionid");
  107. // 查询登录信息表中是否有此openid
  108. CusLoginInfo detailByOpenId = cusLoginInfoDao.getDetailByOpenId(openid);
  109. // 存入微信用户登录信息表
  110. CusLoginInfo cusLoginInfo = new CusLoginInfo();
  111. if(detailByOpenId!=null) {
  112. cusLoginInfo.setOpenId(openid);
  113. cusLoginInfo.setToken(token);
  114. cusLoginInfo.setSessionKey(session_key);
  115. cusLoginInfo.setUnionId(unionid);
  116. cusLoginInfo.setLastModTime(DateTimeUtil.getCurrentDateTime());
  117. log.info("微信用户登录成功---------token更新-------");
  118. cusLoginInfoDao.updateByOpenId(cusLoginInfo);
  119. }else {
  120. cusLoginInfo.setOpenId(openid);
  121. cusLoginInfo.setToken(token);
  122. cusLoginInfo.setSessionKey(session_key);
  123. cusLoginInfo.setUnionId(unionid);
  124. cusLoginInfo.setCreateTime(DateTimeUtil.getCurrentDateTime());
  125. cusLoginInfo.setLastModTime(DateTimeUtil.getCurrentDateTime());
  126. log.info("微信用户登录成功---------添加登录信息成功-------");
  127. cusLoginInfoDao.save(cusLoginInfo);
  128. // 解密用户基本信息,添加用户基本信息
  129. try {
  130. String resu = AesCbcUtil.decrypt(encryptedData, session_key, iv, "UTF-8");
  131. JSONObject jo = JSON.parseObject(resu);
  132. String nickName=jo.getString("nickName"); //用户昵称
  133. String jsonsds=jo.getString("avatarUrl"); //用户头像
  134. String sex = jo.getString("gender");//性别
  135. //String unionid = jo.getString("unionid");
  136. //String city = jo.getString("city"); //城市
  137. //String province = jo.getString("province");//省份
  138. //String country = jo.getString("country"); //国家s
  139. CusSelfInfo cusSelfInfo = new CusSelfInfo();
  140. cusSelfInfo.setId(UUID.randomUUID().toString().replaceAll("-", ""));
  141. cusSelfInfo.setNickName(nickName);
  142. cusSelfInfo.setHeadImg(jsonsds);
  143. cusSelfInfo.setOpenId(openid);
  144. cusSelfInfo.setUserType("1");//普通用户
  145. cusSelfInfo.setCreateTime(DateTimeUtil.getCurrentDateTime());
  146. cusSelfInfo.setLastModBy(nickName);
  147. cusSelfInfo.setCreateUser(nickName);
  148. cusSelfInfo.setLastModTime(DateTimeUtil.getCurrentDateTime());
  149. if("1".equals(sex)) {
  150. cusSelfInfo.setSex("1");
  151. }else if("2".equals(sex)) {
  152. cusSelfInfo.setSex("0");
  153. }else {
  154. cusSelfInfo.setSex("2");// 未知
  155. }
  156. cusSelfInfoDao.save(cusSelfInfo);
  157. } catch (Exception e) {
  158. e.printStackTrace();
  159. }
  160. }
  161. // 根据openid判断是否绑定手机
  162. CusAuthInfo isAuth = cusAuthInfoDao.getByOpenId(openid);
  163. if(isAuth!=null) {
  164. dataMap.put("isAuth", true);
  165. }else {
  166. dataMap.put("isAuth", false);
  167. }
  168. // 根据openid判断是否是大V用户
  169. CusAuditInfo isAudit = cusAuditInfoDao.getByOpenId(openid);
  170. if(isAudit!=null) {
  171. String auditStatus = isAudit.getAuditStatus();
  172. dataMap.put("isAudit", auditStatus);
  173. }else {
  174. dataMap.put("isAudit", "3");// 未申请
  175. }
  176. // 将session_key\token返回给前端
  177. dataMap.put("token", token);
  178. dataMap.put("openid", openid);
  179. dataMap.put("session_key", session_key);
  180. resultMap.put("data", dataMap);
  181. resultMap.put("code", "0");
  182. resultMap.put("msg", "成功");
  183. }
  184. }
  185. return JSON.toJSONString(resultMap);
  186. }
  187. /**
  188. * 微信服务鉴权
  189. */
  190. public String commenAuth(Map<String, Object> paramMap) {
  191. Map<String,Object> resultMap = new HashMap<String,Object>();
  192. String openid = (String) paramMap.get("openId");
  193. String token = (String) paramMap.get("token");
  194. String msg = "";
  195. if(StrUtil.isEmpty(token)) {
  196. msg = "token不能为空";
  197. }
  198. if(StrUtil.isEmpty(openid)) {
  199. msg = "openid不能为空";
  200. }
  201. if(StrUtil.isNotEmpty(msg)) {
  202. resultMap.put("code", "1");
  203. resultMap.put("msg", msg);
  204. resultMap.put("data", "");
  205. return JSON.toJSONString(resultMap);
  206. }
  207. CusLoginInfo byToken = cusLoginInfoDao.getDetailByToken(token);
  208. if(StrUtil.isEmpty(byToken)) {
  209. resultMap.put("code", "2");
  210. resultMap.put("msg", "token非法");
  211. resultMap.put("data", "");
  212. return JSON.toJSONString(resultMap);
  213. }
  214. if(!openid.equals(byToken.getOpenId())) {
  215. resultMap.put("code", "1");
  216. resultMap.put("msg", "openid不一致");
  217. resultMap.put("data", "");
  218. }else {
  219. resultMap.put("code", "0");
  220. resultMap.put("msg", "验证通过");
  221. resultMap.put("data", "");
  222. }
  223. return JSON.toJSONString(resultMap);
  224. }
  225. /**
  226. * 获取短信验证码
  227. *@return
  228. **/
  229. public String getVerifyCode(HashMap<String, Object> paramMap) {
  230. log.info("获取短信验证码---------start-------");
  231. Map<String,Object> resultMap = new HashMap<String,Object>();
  232. String openid = (String) paramMap.get("openId");
  233. String phone = (String) paramMap.get("phone");
  234. String msg = "";
  235. if(StrUtil.isEmpty(openid)) {
  236. msg = "openId不能为空";
  237. }
  238. if(StrUtil.isEmpty(phone)) {
  239. msg = "mobile不能为空";
  240. }else {
  241. // 校验手机号
  242. Pattern pattern = Pattern.compile("/^1([38][0-9]|4[579]|5[0-3,5-9]|6[6]|7[0135678]|9[89])\\d{8}$/");
  243. Matcher matcher = pattern.matcher(phone);
  244. if(!matcher.matches()) {
  245. msg = "手机号不正确";
  246. }
  247. }
  248. if(StrUtil.isNotEmpty(msg)) {
  249. resultMap.put("code", "1");
  250. resultMap.put("msg", msg);
  251. resultMap.put("data", "");
  252. return JSON.toJSONString(resultMap);
  253. }
  254. // 校验手机号是否已经使用
  255. // 校验是否曾经认证成功
  256. CusAuthInfo selective = cusAuthInfoDao.getBySelective(paramMap);
  257. if(selective!=null) {
  258. resultMap.put("code", "1");
  259. resultMap.put("msg", "您已经是认证用户,无需重新认证!");
  260. resultMap.put("data", "");
  261. return JSON.toJSONString(resultMap);
  262. }
  263. // 校验openid是否合法
  264. CusLoginInfo detailByOpenId = cusLoginInfoDao.getDetailByOpenId(openid);
  265. if(detailByOpenId==null) {
  266. resultMap.put("code", "1");
  267. resultMap.put("msg", "openid非法");
  268. resultMap.put("data", "");
  269. return JSON.toJSONString(resultMap);
  270. }
  271. // 调用56短信平台接口发送短信
  272. String verifyCode = String.valueOf(new Random().nextInt(899999)+100000);
  273. // 是否发送过验证码,且验证码有效
  274. SmsVerifycode smsVerifycodeTemp = smsVerifycodeDao.SelectOne(phone);
  275. if(smsVerifycodeTemp != null && "0".equals(smsVerifycodeTemp.getIsExpire())) {
  276. verifyCode = smsVerifycodeTemp.getVerifycode();
  277. }
  278. String content = "您的验证码为:"+verifyCode+",该验证码有效期为5分钟,该码只能使用一次!";
  279. String smsUrl = myProps.getSmsUrl();
  280. String comid = myProps.getComid();
  281. String smsUname = myProps.getSmsUname();
  282. String smsPwd = myProps.getSmsPwd();
  283. String result = "";
  284. try {
  285. String httpLink = smsUrl+"comid="+comid+"&username="+smsUname+"&userpwd="+smsPwd+"&handtel="+phone+"&sendcontent="+content+"&sendtime=定时时间&smsnumber=所用平台";
  286. log.info("短信平台调用地址URL>>>>"+httpLink);
  287. result = SMSUtil.invokeHttpSMS(httpLink);
  288. } catch (Exception e) {
  289. log.info("调用短信接口异常》》》》》",e);
  290. resultMap.put("code", "1");
  291. resultMap.put("msg", "短信接口异常");
  292. resultMap.put("data", "");
  293. return JSON.toJSONString(resultMap);
  294. }
  295. if("1".equals(result)) {
  296. // 发送成功,入库
  297. SmsVerifycode smsVer = new SmsVerifycode();
  298. smsVer.setId(UUID.randomUUID().toString().replaceAll("-", ""));
  299. smsVer.setCreateTime(DateTimeUtil.getCurrentDateTime());
  300. smsVer.setLastModTime(DateTimeUtil.getCurrentDateTime());
  301. smsVer.setMobile(phone);
  302. smsVer.setOpenId(openid);
  303. smsVer.setSmsContent(content);
  304. smsVer.setVerifycode(verifyCode);
  305. smsVerifycodeDao.save(smsVer);
  306. resultMap.put("code", "0");
  307. resultMap.put("msg", "发送短信验证码成功");
  308. resultMap.put("data", "");
  309. return JSON.toJSONString(resultMap);
  310. }else {
  311. resultMap.put("code", "1");
  312. resultMap.put("msg", "发送短信验证码失败");
  313. resultMap.put("data", "");
  314. return JSON.toJSONString(resultMap);
  315. }
  316. }
  317. /**
  318. * 用户手机号绑定
  319. *@return
  320. **/
  321. public String bindMobile(HashMap<String, Object> paramMap) {
  322. log.info("用户手机号绑定---------start-------");
  323. // 微信服务鉴权
  324. String auth = commenAuth(paramMap);
  325. JSONObject jsonObject = JSON.parseObject(auth);
  326. if(!"0".equals((String)jsonObject.get("code"))) {
  327. return auth;
  328. }
  329. Map<String,Object> resultMap = new HashMap<String,Object>();
  330. String openid = (String) paramMap.get("openId");
  331. String iv = (String) paramMap.get("iv");
  332. String encryptedData = (String) paramMap.get("encryptedData");
  333. String sessionKey = (String) paramMap.get("sessionKey");
  334. String mobile = "";
  335. //String verifyCode = (String) paramMap.get("verifyCode");
  336. //String mobile = (String) paramMap.get("mobile");
  337. // 根据openid查询用户基本信息
  338. CusLoginInfo loginDetaild = cusLoginInfoDao.getDetailByOpenId(openid);
  339. if(loginDetaild==null) {
  340. resultMap.put("code", "1");
  341. resultMap.put("msg", "获取用户登录信息失败");
  342. resultMap.put("data", "");
  343. return JSON.toJSONString(resultMap);
  344. }else {
  345. // 解密手机号
  346. String result;
  347. try {
  348. result = AesCbcUtil.decrypt(encryptedData, sessionKey, iv, "UTF-8");
  349. if (null != result && result.length() > 0) {
  350. log.info("获取解密后数据————————————"+result);
  351. // 将解密后的JSON格式字符串转化为对象
  352. JSONObject jo = JSON.parseObject(result);
  353. mobile = jo.getString("phoneNumber");
  354. log.info("获取到手机号为-------"+mobile);
  355. }
  356. if(StrUtil.isEmpty(mobile)) {
  357. resultMap.put("code", "1");
  358. resultMap.put("msg", "获取手机号为空");
  359. resultMap.put("data", "");
  360. return JSON.toJSONString(resultMap);
  361. }
  362. // 校验手机号是否绑定其他账号
  363. // 校验短信验证码是否有效(暂时抛弃)
  364. CusAuthInfo cusAuthInfo1 = cusAuthInfoDao.getDetailByMobile(mobile);
  365. if(cusAuthInfo1!=null) {
  366. resultMap.put("code", "1");
  367. resultMap.put("msg", "该手机号已绑定其他账号");
  368. resultMap.put("data", "");
  369. return JSON.toJSONString(resultMap);
  370. }else {
  371. CusAuthInfo cusAuthInfo = new CusAuthInfo();
  372. cusAuthInfo.setId(UUID.randomUUID().toString().replaceAll("-", ""));
  373. cusAuthInfo.setOpenId(openid);
  374. cusAuthInfo.setMobile(mobile);
  375. cusAuthInfo.setCreateTime(DateTimeUtil.getCurrentDateTime());
  376. cusAuthInfo.setLastModTime(DateTimeUtil.getCurrentDateTime());
  377. cusAuthInfoDao.save(cusAuthInfo);
  378. resultMap.put("code", "0");
  379. resultMap.put("msg", "用户手机号绑定成功");
  380. resultMap.put("data", "");
  381. return JSON.toJSONString(resultMap);
  382. }
  383. } catch (Exception e) {
  384. e.printStackTrace();
  385. }
  386. }
  387. return JSON.toJSONString(resultMap);
  388. }
  389. /**
  390. * 上传文件接口
  391. */
  392. public String uploadFile(MultipartFile file, String openid,String token) throws Exception{
  393. Map<String,Object> resultMap = new HashMap<String,Object>();
  394. HashMap<String,Object> paramMap = new HashMap<String,Object>();
  395. paramMap.put("openId", openid);
  396. paramMap.put("token", token);
  397. // 微信服务鉴权
  398. String auth = commenAuth(paramMap);
  399. JSONObject jsonObject = JSON.parseObject(auth);
  400. if(!"0".equals((String)jsonObject.get("code"))) {
  401. return auth;
  402. }
  403. FileInfo fileInfo = fileService.save(file);
  404. resultMap.put("code", "0");
  405. resultMap.put("msg", "上传成功");
  406. resultMap.put("data", fileInfo);
  407. return JSON.toJSONString(resultMap);
  408. }
  409. /**
  410. * 大V认证接口
  411. */
  412. public String auditCheck(HashMap<String, Object> paramMap) {
  413. Map<String,Object> resultMap = new HashMap<String,Object>();
  414. String openid = (String) paramMap.get("openId");
  415. String picPath = (String) paramMap.get("picPath");
  416. // 微信服务鉴权
  417. String auth = commenAuth(paramMap);
  418. JSONObject jsonObject = JSON.parseObject(auth);
  419. if(!"0".equals((String)jsonObject.get("code"))) {
  420. return auth;
  421. }
  422. // 根据openid查询用户基本信息
  423. CusSelfInfo selfInfo = cusSelfInfoDao.getByOpenId(openid);
  424. if(selfInfo==null) {
  425. resultMap.put("code", "1");
  426. resultMap.put("msg", "获取用户基本信息失败");
  427. resultMap.put("data", "");
  428. return JSON.toJSONString(resultMap);
  429. }else {
  430. // 根据openid查看是否申请认证过
  431. CusAuditInfo byOpenId = cusAuditInfoDao.getByOpenIdAndStatus(openid,"0");
  432. // 存在申请中的数据
  433. if(byOpenId!=null) {
  434. resultMap.put("code", "1");
  435. resultMap.put("msg", "请勿重复申请");
  436. resultMap.put("data", byOpenId);
  437. }else {
  438. CusAuditInfo auditInfo = new CusAuditInfo();
  439. auditInfo.setId(UUID.randomUUID().toString().replaceAll("-", ""));
  440. auditInfo.setCusSelfId(selfInfo.getId());
  441. auditInfo.setCertifiedImg(picPath);
  442. auditInfo.setAuditStatus("0");
  443. auditInfo.setCreateTime(DateTimeUtil.getCurrentDateTime());
  444. auditInfo.setLastModTime(DateTimeUtil.getCurrentDateTime());
  445. auditInfo.setCreateUser("用户申请");
  446. auditInfo.setLastModBy("用户申请");
  447. auditInfo.setOpenid(openid);
  448. cusAuditInfoDao.save(auditInfo);
  449. resultMap.put("code", "0");
  450. resultMap.put("msg", "申请成功");
  451. resultMap.put("data", auditInfo);
  452. }
  453. return JSON.toJSONString(resultMap);
  454. }
  455. }
  456. /**
  457. * 获取字典列表接口
  458. * @param type
  459. */
  460. public String getDictByType(HashMap<String, Object> paramMap) {
  461. Map<String,Object> resultMap = new HashMap<String,Object>();
  462. String type = (String) paramMap.get("type");
  463. // 微信服务鉴权
  464. String auth = commenAuth(paramMap);
  465. JSONObject jsonObject =JSON.parseObject(auth);
  466. if(!"0".equals((String)jsonObject.get("code"))) {
  467. return auth;
  468. }
  469. List<Dict> dictList = dictDao.listByType(type);
  470. resultMap.put("code", "0");
  471. resultMap.put("msg", "获取字典列表成功");
  472. resultMap.put("data", dictList);
  473. return JSON.toJSONString(resultMap);
  474. }
  475. public String createQRCode(String path,String width,String scene) {
  476. Map<String,Object> resultMap = new HashMap<String,Object>();
  477. String id = UUID.randomUUID().toString().replaceAll("-", "");
  478. String picName = id+".jpg";
  479. String url = myProps.getWxCreateQRCode();
  480. log.info("微信登录url:"+url);
  481. String accessToken = TokenThread.accessToken.getToken();
  482. url = url+"access_token="+accessToken;
  483. JSONObject json = new JSONObject();
  484. json.put("path", path);
  485. json.put("width", width);
  486. json.put("scene", scene);
  487. //json.put("is_hyaline", true);
  488. InputStream instream;
  489. try {
  490. instream = HttpUtil.postResponse(url, json);
  491. if(instream!=null) {
  492. MultipartFile multipartFile = new MockMultipartFile(picName,picName,"", instream);
  493. FileInfo save = fileService.save(multipartFile);
  494. log.info("生成二维码成功----------------"+JSON.toJSONString(save));
  495. resultMap.put("code", "0");
  496. resultMap.put("msg", "生成二维码成功");
  497. resultMap.put("data", save);
  498. }else {
  499. resultMap.put("code", "1");
  500. resultMap.put("msg", "生成二维码失败");
  501. resultMap.put("data", "");
  502. }
  503. } catch (IOException e) {
  504. e.printStackTrace();
  505. }
  506. return JSON.toJSONString(resultMap);
  507. }
  508. }