WebClientRest.java 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627
  1. package com.cnd3b.common.restful;
  2. import com.cnd3b.utility.Encryption;
  3. import com.alibaba.fastjson.JSONException;
  4. import com.alibaba.fastjson.JSONObject;
  5. import com.cnd3b.common.D3BReturnObject_Err;
  6. import com.cnd3b.common.data.Row;
  7. import com.cnd3b.common.data.Rows;
  8. import com.cnd3b.common.data.SQLFactory;
  9. import com.cnd3b.common.data.db.DBConnect;
  10. import com.cnd3b.common.data.db.DataPool;
  11. import com.cnd3b.common.parameter.ErrModel;
  12. import com.cnd3b.common.parameter.parameter;
  13. import com.cnd3b.restcontroller.system.system.uploadExcelData;
  14. import com.cnd3b.utility.Sms;
  15. import com.cnd3b.utility.sysmsg;
  16. import com.cnd3b.utility.wechatpay.apppay.POJO.APPQueryOrderRequest;
  17. import com.cnd3b.utility.wechatpay.apppay.POJO.AppWechatOrder;
  18. import com.cnd3b.utility.wechatpay.apppay.apppay;
  19. import com.cnd3b.utility.wechatpay.jsapipay.POJO.JSQueryOrderRequest;
  20. import com.cnd3b.utility.wechatpay.jsapipay.POJO.JSWechatOrder;
  21. import com.cnd3b.utility.wechatpay.jsapipay.jsapipay;
  22. import com.cnd3b.utility.wechatpay.nativepay.nativepay;
  23. import org.dom4j.dom.DOMElement;
  24. import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
  25. import org.glassfish.jersey.media.multipart.FormDataParam;
  26. import javax.servlet.http.HttpServletRequest;
  27. import javax.ws.rs.*;
  28. import javax.ws.rs.core.Context;
  29. import javax.ws.rs.core.MediaType;
  30. import java.io.InputStream;
  31. import java.lang.reflect.Constructor;
  32. import java.lang.reflect.InvocationTargetException;
  33. import java.lang.reflect.Method;
  34. import java.text.SimpleDateFormat;
  35. import java.util.ArrayList;
  36. import java.util.Arrays;
  37. import java.util.Calendar;
  38. import java.util.Random;
  39. @Path("webclientrest")
  40. public class WebClientRest {
  41. private static String[] nocheckphonenumber = {"17357363127", "13805731234"};
  42. @POST
  43. public String method(@Context HttpServletRequest request, String RequestContent) {
  44. // if (parameter.isdebug()) {
  45. // SQLiteJDBC db = new SQLiteJDBC();
  46. // db.InsertLogMsg("请求内容", RequestContent, "info");
  47. // }
  48. /**
  49. * 验证请求正文是否为规范的SONObject格式
  50. */
  51. JSONObject requestcontent = null;
  52. try {
  53. requestcontent = JSONObject.parseObject(RequestContent);
  54. } catch (Exception e) {
  55. return ErrModel.request_BasicJsonFormat().toString();
  56. }
  57. /**
  58. * 验证请求正文中是否包含必填的键值
  59. */
  60. String[] mustkeys = {"classname", "method", "content"};
  61. for (String mustkey : mustkeys) {
  62. if (!requestcontent.containsKey(mustkey)) {
  63. return ErrModel.request_ContainsMustKey(mustkey).toString();
  64. }
  65. }
  66. /**
  67. * 验证请求正文中的content是否为规范的SONObject格式
  68. */
  69. JSONObject content = new JSONObject();
  70. try {
  71. content = requestcontent.getJSONObject("content");
  72. } catch (Exception e) {
  73. return ErrModel.request_ContentJsonFormat().toString();
  74. }
  75. /**
  76. * 验证正文中的token是否有效
  77. */
  78. String accesstoken = "";
  79. String className = requestcontent.getString("classname");
  80. if (className.startsWith("agentclient") || className.startsWith("agentwebclient") ||
  81. className.startsWith("salerclient") || className.startsWith("salerwebclient")
  82. || className.startsWith("webclient") || className.startsWith("wechatclient")) {
  83. className = "enterprise." + className;
  84. }
  85. if (!className.contains("publicmethod")) {
  86. if (!requestcontent.containsKey("accesstoken")) {
  87. return ErrModel.token_Validate().toString();
  88. }
  89. accesstoken = requestcontent.getString("accesstoken");
  90. /**
  91. * 盘点当前账号是否存在有效的token
  92. */
  93. if (!parameter.tokenlist.containsKey(accesstoken) && !istokeninuserlist(accesstoken)) {
  94. //如果缓存中不存在,则在账号列表中进行查询,查到结果后,将tokne存入缓存
  95. return ErrModel.token_Validate().toString();
  96. }
  97. parameter.requesttime.put(accesstoken, Calendar.getInstance().getTime());
  98. }
  99. String methodName = requestcontent.getString("method");
  100. if (content.isEmpty()) {
  101. content = new JSONObject();
  102. }
  103. content.put("$classname", className);
  104. content.put("$method", methodName);
  105. content.put("$accesstoken", accesstoken);
  106. content.put("$requestHost", request.getScheme() + "://" + request.getHeader("Host"));
  107. String key = className + "." + methodName;
  108. String result;
  109. Object obj = null;
  110. try {
  111. boolean getdatafromdbanyway = content.containsKey("getdatafromdbanyway")
  112. && content.getBoolean("getdatafromdbanyway");
  113. content.remove("getdatafromdbanyway");
  114. Object data = null;
  115. if (!getdatafromdbanyway) {
  116. data = DataPool.get(content.toString());
  117. }
  118. if (data != null) {
  119. result = data.toString();
  120. saveCallMethodMsg(key, false, 0L);
  121. } else {
  122. long starttimes = Calendar.getInstance().getTimeInMillis();
  123. /**
  124. * 执行请求方法
  125. */
  126. Class clz = Class.forName("com.cnd3b.restcontroller." + className);
  127. Constructor cla = clz.getDeclaredConstructor(JSONObject.class);
  128. obj = cla.newInstance(content);
  129. Method method = obj.getClass().getDeclaredMethod(methodName);
  130. result = (String) method.invoke(obj);
  131. long endtimes = Calendar.getInstance().getTimeInMillis();
  132. saveCallMethodMsg(key, true, endtimes - starttimes);
  133. }
  134. } catch (ClassNotFoundException e) {
  135. e.printStackTrace();
  136. result = ErrModel.request_GetClass("找不到指定的类" + className).toString();
  137. } catch (InstantiationException e) {
  138. e.printStackTrace();
  139. result = ErrModel.request_GetClass("类" + className + "实例化异常").toString();
  140. } catch (IllegalAccessException e) {
  141. e.printStackTrace();
  142. result = ErrModel.request_GetClass("类" + className + "安全权限异常,可能该类为非public类").toString();
  143. } catch (NoSuchMethodException e) {
  144. e.printStackTrace();
  145. result = ErrModel.request_GetClass("找不到指定的类" + className + "的" + methodName + "方法").toString();
  146. } catch (IllegalArgumentException e) {
  147. e.printStackTrace();
  148. result = ErrModel.request_GetClass("类" + className + "的" + methodName + "方法参数不合法").toString();
  149. } catch (InvocationTargetException e) {
  150. Throwable targetException = e.getTargetException();
  151. D3BReturnObject_Err d3BReturnObject_err = new D3BReturnObject_Err();
  152. d3BReturnObject_err.setErrMsg(targetException.getMessage());
  153. result = d3BReturnObject_err.toString();
  154. } catch (Exception e) {
  155. e.printStackTrace();
  156. result = ErrModel.request_GetClass("发生未知异常" + e.getMessage()).toString();
  157. } finally {
  158. if (obj != null) {
  159. try {
  160. obj.getClass().getMethod("p2ServerSystemPaoSetClose").invoke(obj);
  161. } catch (Exception e) {
  162. e.printStackTrace();
  163. }
  164. }
  165. }
  166. return result;
  167. }
  168. public boolean istokeninuserlist(String accesstoken) {
  169. DBConnect dbConnect = new DBConnect();
  170. SQLFactory factory = new SQLFactory(this, "持久化账号列表查询");
  171. factory.addParameter("accesstoken", accesstoken);
  172. Rows rows = dbConnect.runSqlQuery(factory.getSQL());
  173. if (rows.isEmpty()) {
  174. return false;
  175. } else {
  176. for (Row row : rows) {
  177. long userid = row.getLong("userid");
  178. String token = row.getString("token");
  179. row.put("logintime", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(Calendar.getInstance().getTime()));
  180. parameter.userIdList.put(userid, row);
  181. parameter.tokenlist.put(token, userid);
  182. }
  183. return true;
  184. }
  185. }
  186. /**
  187. * 记录请求数
  188. *
  189. * @param key
  190. * @param fromdb
  191. * @param time
  192. */
  193. private void saveCallMethodMsg(String key, boolean fromdb, long time) {
  194. long callmethodTimes = parameter.callmethodTimes.containsKey(key) ? parameter.callmethodTimes.get(key) : 0L;
  195. //更新请求总数
  196. parameter.callmethodTimes.put(key, callmethodTimes + 1L);
  197. //最新请求时间
  198. parameter.lastcallmethodtime.put(key, Calendar.getInstance().getTime());
  199. //从缓存获取的次数
  200. long callmethod_fromcacheTimes = parameter.callmethod_fromcacheTimes.containsKey(key) ? parameter.callmethod_fromcacheTimes.get(key) : 0L;
  201. if (!fromdb) {
  202. /**
  203. * 方法请求从缓存获取次数
  204. */
  205. parameter.callmethod_fromcacheTimes.put(key, callmethod_fromcacheTimes + 1L);
  206. } else {
  207. /**
  208. * 方法请求查询最新耗时
  209. */
  210. parameter.callmethodLastTimeLong.put(key, time);
  211. long totaltimes = callmethodTimes - callmethod_fromcacheTimes;
  212. /**
  213. * 方法请求查询平均时间
  214. */
  215. long callmethodTimeLong = parameter.callmethodTimeLong.containsKey(key) ? parameter.callmethodTimeLong.get(key) : 0L;
  216. parameter.callmethodTimeLong.put(key, (callmethodTimeLong * totaltimes + time) / (totaltimes + 1));
  217. }
  218. }
  219. /**
  220. * 获取短信登陆验证码
  221. *
  222. * @param RequestContent
  223. * @return
  224. */
  225. @Path("getpassword")
  226. @POST
  227. public String getPassWord(@Context HttpServletRequest request, String RequestContent) {
  228. /**
  229. * 验证请求正文是否为规范的SONObject格式
  230. */
  231. JSONObject requestcontent = null;
  232. try {
  233. requestcontent = JSONObject.parseObject(RequestContent);
  234. } catch (Exception e) {
  235. return ErrModel.request_BasicJsonFormat().toString();
  236. }
  237. /**
  238. * 验证请求正文中是否包含必填的键值
  239. */
  240. String[] mustkeys = {"phonenumber"};
  241. for (String mustkey : mustkeys) {
  242. if (!requestcontent.containsKey(mustkey)) {
  243. return ErrModel.request_ContainsMustKey(mustkey).toString();
  244. }
  245. }
  246. String phonenumber = requestcontent.getString("phonenumber");
  247. String client = "";
  248. if (requestcontent.containsKey("client")) {
  249. client = requestcontent.getString("client");
  250. }
  251. DBConnect dbConnect = new DBConnect();
  252. if (dbConnect.runSqlQuery("select *from tenterprise_users where fphonenumber='" + phonenumber + "'").isEmpty()) {
  253. JSONObject object = new JSONObject();
  254. object.put("code", 0);
  255. object.put("msg", "当前手机号未注册!");
  256. return object.toString();
  257. }
  258. if ("enterpriseweb".equalsIgnoreCase(client)) {
  259. SQLFactory sqlFactory = new SQLFactory(this, "企业账号权限组查询");
  260. sqlFactory.addParameter("fphonenumber", phonenumber);
  261. if (dbConnect.runSqlQuery(sqlFactory.getSQL()).isEmpty()) {
  262. JSONObject object = new JSONObject();
  263. object.put("code", 0);
  264. object.put("msg", "当前手机号没有有效的管理员账号!");
  265. return object.toString();
  266. }
  267. }
  268. String password = createPassWord();
  269. parameter.phonenumber_password.put(phonenumber, password);
  270. Calendar calendar = Calendar.getInstance();
  271. calendar.add(Calendar.MINUTE, 5);
  272. parameter.phonenumber_date.put(phonenumber, calendar.getTime());
  273. if (parameter.isdebug()) {
  274. JSONObject object = new JSONObject();
  275. object.put("code", 1);
  276. object.put("msg", "手机验证码为:" + password);
  277. return object.toString();
  278. } else {
  279. JSONObject object = new JSONObject();
  280. Sms sms = new Sms();
  281. sms.sendOutMsg(phonenumber, password);
  282. object.put("code", 1);
  283. object.put("msg", "手机验证码已发送,请注意查收!");
  284. return object.toString();
  285. }
  286. }
  287. /**
  288. * 创建验证码
  289. *
  290. * @return
  291. */
  292. public String createPassWord() {
  293. String allChar = "1234567890";
  294. StringBuffer sb = new StringBuffer();
  295. Random random = new Random();
  296. for (int i = 0; i < 6; i++) {
  297. sb.append(allChar.charAt(random.nextInt(allChar.length())));
  298. }
  299. if (parameter.phonenumber_password.containsValue(sb.toString())) {
  300. return createPassWord();
  301. } else {
  302. return sb.toString();
  303. }
  304. }
  305. @Path("login")
  306. @POST
  307. public String login(String RequestContent) {
  308. /**
  309. * 验证请求正文是否为规范的SONObject格式
  310. */
  311. JSONObject requestcontent = null;
  312. try {
  313. requestcontent = JSONObject.parseObject(RequestContent);
  314. } catch (Exception e) {
  315. return ErrModel.request_BasicJsonFormat().toString();
  316. }
  317. /**
  318. * 验证请求正文中是否包含必填的键值
  319. */
  320. String[] mustkeys = {"phonenumber", "password"};
  321. for (String mustkey : mustkeys) {
  322. if (!requestcontent.containsKey(mustkey)) {
  323. return ErrModel.request_ContainsMustKey(mustkey).toString();
  324. }
  325. }
  326. String phonenumber = requestcontent.getString("phonenumber");
  327. String password = requestcontent.getString("password");
  328. int resultcode;
  329. DBConnect connect = new DBConnect();
  330. if (!parameter.phonenumber_password.containsKey(phonenumber)) {
  331. resultcode = 1;//没有获取验证码
  332. } else if (parameter.phonenumber_date.get(phonenumber).before(Calendar.getInstance().getTime())) {
  333. resultcode = 2;//验证码已失效
  334. } else {
  335. //系统验证码
  336. String syspassword = parameter.phonenumber_password.get(phonenumber);
  337. if (password.equals(new Encryption().Encode_MD5(syspassword))) {
  338. resultcode = 0;//验证码正确
  339. } else {
  340. resultcode = 3;//验证码错误
  341. }
  342. }
  343. if (resultcode == 0 || Arrays.asList(nocheckphonenumber).contains(phonenumber)) {
  344. SQLFactory factory = new SQLFactory(this, "手机账号列表查询");
  345. factory.addParameter("fphonenumber", phonenumber);
  346. Rows rows = connect.runSqlQuery(factory.getSQL());
  347. ArrayList<String> tokensaveList = new ArrayList<>();
  348. for (Row row : rows) {
  349. long userid = row.getLong("userid");
  350. String usertoken = new Encryption().Encode_MD5(phonenumber + password + userid + Calendar.getInstance().getTimeInMillis());
  351. row.put("token", usertoken);
  352. row.put("logintime", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(Calendar.getInstance().getTime()));
  353. parameter.userIdList.put(userid, row);
  354. parameter.tokenlist.put(usertoken, userid);
  355. tokensaveList.add("update tenterprise_users set accesstoken='" + usertoken + "' where tenterprise_userid=" + userid);
  356. }
  357. if (!tokensaveList.isEmpty()) {
  358. /**
  359. * 账号登录态持久化
  360. */
  361. connect.runSqlUpdate(tokensaveList);
  362. }
  363. JSONObject object = new JSONObject();
  364. object.put("code", 1);
  365. object.put("msg", "成功");
  366. object.put("webclienturl", "https://cnd3b.com/dsb1/#/");
  367. object.put("servicehotline", "13095738000");
  368. object.put("account_list", rows.toJsonArray());
  369. //登录成功,将验证码失效掉;
  370. Calendar calendar = Calendar.getInstance();
  371. calendar.add(Calendar.MINUTE, -5);
  372. parameter.phonenumber_date.put(phonenumber, calendar.getTime());
  373. return object.toString();
  374. } else {
  375. String msg = "";
  376. if (resultcode == 1) {
  377. msg = "请先获取所填手机号验证码!";
  378. } else if (resultcode == 2) {
  379. msg = "验证码已失效,请重新获取!";
  380. } else if (resultcode == 3) {
  381. msg = "无效的验证码!";
  382. }
  383. JSONObject object = new JSONObject();
  384. object.put("code", 0);
  385. object.put("msg", msg);
  386. return object.toString();
  387. }
  388. }
  389. @Path("loginbyaccount")
  390. @POST
  391. public String loginbyaccount(String RequestContent) {
  392. /**
  393. * 验证请求正文是否为规范的SONObject格式
  394. */
  395. JSONObject requestcontent = null;
  396. try {
  397. requestcontent = JSONObject.parseObject(RequestContent);
  398. } catch (Exception e) {
  399. return ErrModel.request_BasicJsonFormat().toString();
  400. }
  401. /**
  402. * 验证请求正文中是否包含必填的键值
  403. */
  404. String[] mustkeys = {"accountno", "password"};
  405. for (String mustkey : mustkeys) {
  406. if (!requestcontent.containsKey(mustkey)) {
  407. return ErrModel.request_ContainsMustKey(mustkey).toString();
  408. }
  409. }
  410. String accountno = requestcontent.getString("accountno");
  411. String password = requestcontent.getString("password");//md5加密
  412. boolean result = true;
  413. DBConnect connect = new DBConnect();
  414. Rows usersrows = connect.runSqlQuery("select t1.* from tenterprise_users t1 inner join tenterprise t2 on t1.siteid=t2.siteid where t2.floginmode in(2,3) and convert(varchar(100),t1.faccountno)='" + accountno + "'");
  415. if (usersrows.isEmpty()) {
  416. result = false;
  417. } else {
  418. //系统验证码
  419. String syspassword = usersrows.get(0).getString("fpassword");
  420. result = password.equals(syspassword);
  421. }
  422. if (result) {
  423. SQLFactory factory = new SQLFactory(this, "账号列表查询");
  424. factory.addParameter("faccountno", accountno);
  425. Rows rows = connect.runSqlQuery(factory.getSQL());
  426. if (rows.isEmpty()) {
  427. JSONObject object = new JSONObject();
  428. object.put("code", 0);
  429. object.put("msg", "没有包含此账号的企业或经销商!");
  430. return object.toString();
  431. }
  432. ArrayList<String> tokensaveList = new ArrayList<>();
  433. for (Row row : rows) {
  434. long userid = row.getLong("userid");
  435. String usertoken = new Encryption().Encode_MD5(accountno + password + userid + Calendar.getInstance().getTimeInMillis());
  436. row.put("token", usertoken);
  437. row.put("logintime", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(Calendar.getInstance().getTime()));
  438. parameter.userIdList.put(userid, row);
  439. parameter.tokenlist.put(usertoken, userid);
  440. tokensaveList.add("update tenterprise_users set accesstoken='" + usertoken + "' where tenterprise_userid=" + userid);
  441. }
  442. if (!tokensaveList.isEmpty()) {
  443. /**
  444. * 账号登录态持久化
  445. */
  446. connect.runSqlUpdate(tokensaveList);
  447. }
  448. JSONObject object = new JSONObject();
  449. object.put("code", 1);
  450. object.put("msg", "成功");
  451. object.put("webclienturl", "https://cnd3b.com/dsb1/#/");
  452. object.put("servicehotline", "13095738000");
  453. object.put("account_list", rows.toJsonArray());
  454. return object.toString();
  455. } else {
  456. JSONObject object = new JSONObject();
  457. object.put("code", 0);
  458. object.put("msg", "用户名或密码错误");
  459. return object.toString();
  460. }
  461. }
  462. @Path("logout")
  463. @POST
  464. public String logout(String RequestContent) {
  465. /**
  466. * 验证请求正文是否为规范的SONObject格式
  467. */
  468. JSONObject requestcontent = null;
  469. try {
  470. requestcontent = JSONObject.parseObject(RequestContent);
  471. } catch (Exception e) {
  472. return ErrModel.request_BasicJsonFormat().toString();
  473. }
  474. /**
  475. * 验证请求正文中是否包含必填的键值
  476. */
  477. String[] mustkeys = {"accesstoken"};
  478. for (String mustkey : mustkeys) {
  479. if (!requestcontent.containsKey(mustkey)) {
  480. return ErrModel.request_ContainsMustKey(mustkey).toString();
  481. }
  482. }
  483. /**
  484. * 验证正文中的token是否有效
  485. */
  486. String accesstoken = requestcontent.getString("accesstoken");
  487. parameter.tokenlist.remove(accesstoken);
  488. new DBConnect().runSqlUpdate("update tenterprise_users set accesstoken=null where accesstoken='" + accesstoken + "'");
  489. JSONObject object = new JSONObject();
  490. object.put("status", "ok");
  491. return object.toString();
  492. }
  493. /**
  494. * 数据导入
  495. *
  496. * @param uploadfileInputStream
  497. * @param uploadfile
  498. * @param userid
  499. * @param accesstoken
  500. * @param ftype
  501. * @return
  502. */
  503. @Path("uploadexcel")
  504. @POST
  505. @Consumes({"multipart/form-data"})
  506. @Produces({"application/json"})
  507. public String upLoadDoc(@FormDataParam("uploadfile") InputStream uploadfileInputStream,
  508. @FormDataParam("uploadfile") FormDataContentDisposition uploadfile,
  509. @FormDataParam("userid") String userid,
  510. @FormDataParam("accesstoken") String accesstoken, @FormDataParam("ftype") String ftype) {
  511. /**
  512. * 验证正文中的token是否有效
  513. */
  514. if (!parameter.tokenlist.containsKey(accesstoken)) {
  515. return ErrModel.token_Validate().toString();
  516. }
  517. JSONObject content = new JSONObject();
  518. content.put("userid", userid);
  519. uploadExcelData uploadExcelData = new uploadExcelData(content);
  520. return uploadExcelData.upLoadExcel(uploadfileInputStream, uploadfile, ftype);
  521. }
  522. /**
  523. * 微信支付回调接口
  524. *
  525. * @param RequestContent
  526. * @return
  527. */
  528. @POST
  529. @Path("wechatpay/returnorderstateapp")
  530. public String wechatpayapp(String RequestContent) {
  531. APPQueryOrderRequest queryOrderRequest = new APPQueryOrderRequest();
  532. AppWechatOrder order = queryOrderRequest.getWechatOrder(RequestContent);
  533. apppay apppay = new apppay();
  534. boolean success = apppay.updateLocalOrder(order);
  535. DOMElement request = new DOMElement("xml");
  536. request.addElement("return_code").addText(success ? "SUCCESS" : "FAIL");
  537. request.addElement("return_msg").addText(success ? "OK" : "校验失败");
  538. return request.asXML();
  539. }
  540. /**
  541. * 微信网页支付回调接口
  542. *
  543. * @param RequestContent
  544. * @return
  545. */
  546. @POST
  547. @Path("wechatpay/returnorderstatenative")
  548. public String wechatpaynative(String RequestContent) {
  549. nativepay nativepay = new nativepay();
  550. JSONObject returnobject = JSONObject.parseObject(RequestContent);
  551. boolean success = nativepay.updateLocalOrder_callback(returnobject);
  552. JSONObject request = new JSONObject();
  553. request.put("code", success ? "SUCCESS" : "FAIL");
  554. request.put("message", success ? "成功" : "校验失败");
  555. return request.toString();
  556. }
  557. /**
  558. * 微信网页支付回调接口
  559. *
  560. * @param RequestContent
  561. * @return
  562. */
  563. @POST
  564. @Path("wechatpay/returnorderstatejs")
  565. public String wechatpayjs(String RequestContent) {
  566. JSQueryOrderRequest queryOrderRequest = new JSQueryOrderRequest();
  567. JSWechatOrder order = queryOrderRequest.getWechatOrder(RequestContent);
  568. jsapipay jsapipay = new jsapipay();
  569. boolean success = jsapipay.updateLocalOrder(order);
  570. DOMElement request = new DOMElement("xml");
  571. request.addElement("return_code").addText(success ? "SUCCESS" : "FAIL");
  572. request.addElement("return_msg").addText(success ? "OK" : "校验失败");
  573. return request.asXML();
  574. }
  575. @Path("sysmsg")
  576. @GET
  577. @Produces(MediaType.TEXT_HTML)
  578. @Consumes(MediaType.TEXT_HTML)
  579. public String sysmsg() throws JSONException {
  580. return new sysmsg().getCustMsg();
  581. }
  582. }