WxPay.java 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584
  1. //package com.happy.action;
  2. //
  3. //import com.happy.Model.Consume;
  4. //import com.happy.Model.Price;
  5. //import com.happy.Model.Recharge;
  6. //import com.happy.Model.Users;
  7. //import com.happy.Until.HttpUtils;
  8. //import com.happy.Until.ResUtil;
  9. //import com.google.gson.Gson;
  10. //import com.google.gson.reflect.TypeToken;
  11. //import com.happy.common.http.HttpsClient;
  12. //import com.happy.common.wx.WxConfig;
  13. //import com.happy.common.wx.WxConstants;
  14. //import com.happy.common.wx.WxUtil;
  15. //import com.happy.dao.RechargeDao;
  16. //import com.happy.service.ConsumeService;
  17. //import com.happy.service.RechargeService;
  18. //import com.happy.service.UserService;
  19. //import com.happy.service.WxMenuService;
  20. //import com.opensymphony.xwork2.ActionSupport;
  21. //import net.sf.json.JSON;
  22. //import net.sf.json.JSONObject;
  23. //import org.apache.commons.lang3.StringUtils;
  24. //import org.apache.struts2.ServletActionContext;
  25. //import org.apache.struts2.interceptor.ServletRequestAware;
  26. //
  27. //import javax.annotation.Resource;
  28. //import javax.servlet.http.HttpServletRequest;
  29. //import javax.servlet.http.HttpServletResponse;
  30. //import java.math.BigDecimal;
  31. //import java.text.SimpleDateFormat;
  32. //import java.util.*;
  33. //
  34. //public class WxPay extends ActionSupport implements ServletRequestAware {
  35. //
  36. // private HttpServletRequest request;
  37. // public HttpServletResponse response;
  38. // public WxMenuService wxMenuService;
  39. //
  40. // public String user;
  41. // public String card_number;
  42. // public String collect_code;
  43. // public String begin_time;
  44. //
  45. // @Resource
  46. // public UserService userService;
  47. // @Resource
  48. // public ConsumeService consumeService;
  49. // @Resource
  50. // public RechargeService rechargeService;
  51. //
  52. // public String user_name;
  53. // public BigDecimal account;
  54. // public String order_id;
  55. // public String re_time;
  56. // public String amount;
  57. // public String user_id;
  58. //
  59. // public String getUser_id() {
  60. // return user_id;
  61. // }
  62. //
  63. // public void setUser_id(String user_id) {
  64. // this.user_id = user_id;
  65. // }
  66. //
  67. // public String getAmount() {
  68. // return amount;
  69. // }
  70. //
  71. // public void setAmount(String amount) {
  72. // this.amount = amount;
  73. // }
  74. //
  75. // public String getRe_time() {
  76. // return re_time;
  77. // }
  78. //
  79. // public void setRe_time(String re_time) {
  80. // this.re_time = re_time;
  81. // }
  82. //
  83. // public String getOrder_id() {
  84. // return order_id;
  85. // }
  86. //
  87. // public void setOrder_id(String order_id) {
  88. // this.order_id = order_id;
  89. // }
  90. //
  91. // public BigDecimal getAccount() {
  92. // return account;
  93. // }
  94. //
  95. // public void setAccount(BigDecimal account) {
  96. // this.account = account;
  97. // }
  98. //
  99. // public String getBegin_time() {
  100. // return begin_time;
  101. // }
  102. //
  103. // public void setBegin_time(String begin_time) {
  104. // this.begin_time = begin_time;
  105. // }
  106. //
  107. // public String getUser_name() {
  108. // return user_name;
  109. // }
  110. //
  111. // public void setUser_name(String user_name) {
  112. // this.user_name = user_name;
  113. // }
  114. //
  115. // public String getCollect_code() {
  116. // return collect_code;
  117. // }
  118. //
  119. // public void setCollect_code(String collect_code) {
  120. // this.collect_code = collect_code;
  121. // }
  122. //
  123. // public String getCard_number() {
  124. // return card_number;
  125. // }
  126. //
  127. // public void setCard_number(String card_number) {
  128. // this.card_number = card_number;
  129. // }
  130. //
  131. // public WxMenuService getWxMenuService() {
  132. // return wxMenuService;
  133. // }
  134. //
  135. // public void setWxMenuService(WxMenuService wxMenuService) {
  136. // this.wxMenuService = wxMenuService;
  137. // }
  138. //
  139. // public HttpServletRequest getRequest() {
  140. // return request;
  141. // }
  142. //
  143. // public void setRequest(HttpServletRequest request) {
  144. // this.request = request;
  145. // }
  146. //
  147. // public void setServletRequest(HttpServletRequest request) {
  148. // this.request = request;
  149. // }
  150. //
  151. // public HttpServletResponse getResponse() {
  152. // return response;
  153. // }
  154. //
  155. // public void setResponse(HttpServletResponse response) {
  156. // this.response = response;
  157. // }
  158. //
  159. // public String getUser() {
  160. // return user;
  161. // }
  162. //
  163. // public void setUser(String user) {
  164. // this.user = user;
  165. // }
  166. //
  167. //// public String test() throws Exception {
  168. //// JSONObject resultJson = new JSONObject();
  169. //// String ll = wxMenuService.test(card_number);
  170. //// resultJson.put("ess", ll);
  171. //// ResUtil.write(resultJson, ServletActionContext.getResponse());
  172. //// return null;
  173. //// }
  174. ////
  175. //// public String test2() throws Exception {
  176. //// JSONObject resultJson = new JSONObject();
  177. //// SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");// 设置日期格式
  178. //// String time = df.format(new Date());
  179. //// String dang = WxUtil.mchOrderNo();
  180. //// String sign = wxMenuService.wxUrl(dang, WxConstants.SING_MD5, collect_code, time);
  181. //// System.out.println("aa: "+sign);
  182. //// HashMap<String, String> data = new HashMap<String, String>();
  183. //// data.put("apicode", WxConfig.apicode);
  184. //// data.put("collect_code", collect_code);
  185. //// data.put("order_no", dang);
  186. //// data.put("amount", "10");
  187. //// data.put("timestamp", time);
  188. //// data.put("sign", sign);
  189. //// JSONObject json = JSONObject.fromObject(data);//将java对象转换为json对象
  190. //// String str = json.toString();
  191. //// String reponseString = HttpUtils.post(WxConstants.PAY_UNIFIEDORDER, str);
  192. //// resultJson.put("ess", reponseString);
  193. //// ResUtil.write(resultJson, ServletActionContext.getResponse());
  194. //// return null;
  195. //// }
  196. //////
  197. //// public String test3() throws Exception {
  198. //// JSONObject resultJson = new JSONObject();
  199. //// SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");// 设置日期格式
  200. //// String time = df.format(new Date());
  201. //// String dang = WxUtil.mchOrderNo();
  202. //// String sign = wxMenuService.wxUrl(dang, WxConstants.SING_MD5, collect_code, time);
  203. //// HashMap<String, String> data = new HashMap<String, String>();
  204. //// data.put("apicode", WxConfig.apicode);
  205. //// data.put("collect_code", collect_code);
  206. //// data.put("order_no", dang);
  207. //// data.put("amount", "10");
  208. //// data.put("timestamp", time);
  209. //// data.put("sign", sign);
  210. //// String reponseString = HttpUtils.post(WxConstants.PAY_UNIFIEDORDER, data);
  211. //// resultJson.put("ess", reponseString);
  212. //// ResUtil.write(resultJson, ServletActionContext.getResponse());
  213. //// return null;
  214. //// }
  215. //
  216. //// public String start2() throws Exception {
  217. //// JSONObject resultJson = new JSONObject();
  218. //// SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");// 设置日期格式
  219. //// String time = df.format(new Date());
  220. //// String dang = WxUtil.mchOrderNo();
  221. //// if(StringUtils.isNotBlank(collect_code)) {
  222. //// String sign = wxMenuService.wxUrl(dang, WxConstants.SING_MD5, collect_code, time);
  223. ////// String requestUrl = "https://app.dev.9kbs.com?apicode=" + WxConfig.apicode
  224. ////// + "&collect_code=" + collect_code + "&order_no=" + dang + "&amount=10&timestamp="
  225. ////// + time + "&sign=" + sign;
  226. //// String requestUrl = WxConstants.Test;
  227. //// String json = HttpsClient.sendPost(requestUrl, "card_number=123456");
  228. //// if (StringUtils.isNotBlank(json)) {
  229. //// resultJson.put("mess", json);
  230. //// ResUtil.write(resultJson, ServletActionContext.getResponse());
  231. //// } else {
  232. //// resultJson.put("mess", "获取失败!");
  233. //// ResUtil.write(resultJson, ServletActionContext.getResponse());
  234. //// }
  235. //// }else {
  236. //// resultJson.put("mess", "收集码获取失败!");
  237. //// ResUtil.write(resultJson, ServletActionContext.getResponse());
  238. //// }
  239. //// return null;
  240. //// }
  241. ////
  242. // public String start3() throws Exception {
  243. // JSONObject resultJson = new JSONObject();
  244. // SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");// 设置日期格式
  245. // String time = df.format(new Date());
  246. // String dang = WxUtil.mchOrderNo();
  247. // if(StringUtils.isNotBlank(collect_code)) {
  248. // String sign = wxMenuService.wxUrl(dang, WxConstants.SING_MD5, collect_code, time);
  249. // String url = WxConstants.PAY_UNIFIEDORDER;
  250. // String request = "apicode=" + WxConfig.apicode
  251. // + "&collect_code=" + collect_code + "&order_no=" + dang + "&amount=10&timestamp="
  252. // + time + "&sign=" + sign;
  253. // String json = HttpUtils.post(url, request);
  254. // if (StringUtils.isNotBlank(json)) {
  255. // resultJson.put("mess", json);
  256. // ResUtil.write(resultJson, ServletActionContext.getResponse());
  257. // } else {
  258. // resultJson.put("mess", "获取失败!");
  259. // ResUtil.write(resultJson, ServletActionContext.getResponse());
  260. // }
  261. // }else {
  262. // resultJson.put("mess", "收集码获取失败!");
  263. // ResUtil.write(resultJson, ServletActionContext.getResponse());
  264. // }
  265. // return null;
  266. // }
  267. //
  268. // public String consume() throws Exception {
  269. // Gson gson=new Gson();
  270. // JSONObject resultJson = new JSONObject();
  271. // SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");// 设置日期格式
  272. // String time = df.format(new Date());
  273. // String dang = WxUtil.mchOrderNo();
  274. // BigDecimal basic_amount = new BigDecimal("10");
  275. // BigDecimal residue = new BigDecimal("0.00");
  276. // BigDecimal use_size = new BigDecimal("0.00");
  277. // if(StringUtils.isNotBlank(collect_code)) {
  278. // String sign = wxMenuService.wxUrl("", WxConstants.SING_MD5, collect_code, time);
  279. // String requestUrl = "https://app.dev.9kbs.com/shopOpenApi/services/deviceAntiScode/getStartCode?apicode=" + WxConfig.apicode
  280. // + "&collect_code=" + collect_code + "&order_no=" + "" + "&amount=10&timestamp="
  281. // + time + "&sign=" + sign;
  282. // String json = HttpsClient.sendPost2(requestUrl, "");
  283. // System.out.println(json);
  284. // HashMap<String, Object> userMap = gson.fromJson(json.toString(), new TypeToken<HashMap<String, Object>>(){}.getType());
  285. // String status = userMap.get("status").toString();
  286. // if (status.equals("succ")) {
  287. // String data = userMap.get("data").toString();
  288. // HashMap<String, Object> device = gson.fromJson(data.toString(), new TypeToken<HashMap<String, Object>>() {}.getType());
  289. // String collect_data = device.get("collect_data").toString();
  290. // HashMap<String, Object> money = gson.fromJson(collect_data.toString(), new TypeToken<HashMap<String, Object>>() {}.getType());
  291. // String order_no = new BigDecimal(money.get("order_no").toString()).toString();
  292. // String use_amount = money.get("use_amount").toString();
  293. // // 根据订单号获取本次消费记录
  294. // List<Consume> reconsumes = consumeService.queryRecordByOrder(order_no);
  295. // // 订单异常
  296. // if (reconsumes == null){
  297. // resultJson.put("mess", "订单异常,请联系管理员!");
  298. // ResUtil.write(resultJson, ServletActionContext.getResponse());
  299. // return null;
  300. // }else {
  301. // // 上次消费卡号
  302. // String recard_number = reconsumes.get(0).getCard_number();
  303. // // 本次用户信息
  304. // List<Users> reusers = userService.selectByCard(recard_number);
  305. // if (reusers != null ) {
  306. // if (reconsumes.get(0).getState() == 0) { // 本次消费未结算
  307. // BigDecimal rebalance = reusers.get(0).getBalance();
  308. // BigDecimal use_amounts = new BigDecimal(use_amount);
  309. // if (rebalance.compareTo(use_amounts) > 0) {
  310. // residue = rebalance.subtract(use_amounts);
  311. // List<Price> ws = consumeService.water_price("热水");
  312. // if (ws!=null){
  313. // use_size = use_amounts.divide(ws.get(0).getPrice(), BigDecimal.ROUND_HALF_UP);
  314. // }
  315. // int num1 = consumeService.updateConsume(order_no, time, use_amounts, use_size, 1);
  316. // int num2 = consumeService.updateBalance(recard_number, residue);
  317. // // 本次消费扣除完毕
  318. // if (num1 > 0 && num2 > 0) {
  319. // resultJson.put("mess", "支付成功!");
  320. // resultJson.put("use_amount", use_amounts);
  321. // ResUtil.write(resultJson, ServletActionContext.getResponse());
  322. // return null;
  323. // } else {
  324. // resultJson.put("mess", "结算异常!请联系管理员");
  325. // ResUtil.write(resultJson, ServletActionContext.getResponse());
  326. // return null;
  327. // }
  328. // } else {
  329. // resultJson.put("mess", "上次消费用户余额不足!");
  330. // ResUtil.write(resultJson, ServletActionContext.getResponse());
  331. // return null;
  332. // }
  333. // } else { // 本次消费已结算
  334. // resultJson.put("mess", "已支付!请勿重复支付");
  335. // ResUtil.write(resultJson, ServletActionContext.getResponse());
  336. // return null;
  337. // }
  338. // } else {
  339. // resultJson.put("mess", "用户信息异常!");
  340. // ResUtil.write(resultJson, ServletActionContext.getResponse());
  341. // return null;
  342. // }
  343. // }
  344. //
  345. // }else {
  346. // resultJson.put("mess", "请求参数错误!");
  347. // ResUtil.write(resultJson, ServletActionContext.getResponse());
  348. // }
  349. // }else {
  350. // resultJson.put("mess", "收集码获取失败!");
  351. // ResUtil.write(resultJson, ServletActionContext.getResponse());
  352. // }
  353. // return null;
  354. // }
  355. //
  356. //
  357. // public String start() throws Exception {
  358. // Gson gson=new Gson();
  359. // JSONObject resultJson = new JSONObject();
  360. // SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");// 设置日期格式
  361. // String time = df.format(new Date());
  362. // String dang = WxUtil.mchOrderNo();
  363. // BigDecimal basic_amount = new BigDecimal("10");
  364. // BigDecimal residue = new BigDecimal("0.00");
  365. // BigDecimal use_size = new BigDecimal("0.00");
  366. // if(StringUtils.isNotBlank(collect_code)) {
  367. // String sign = wxMenuService.wxUrl(dang, WxConstants.SING_MD5, collect_code, time);
  368. // String requestUrl = "https://app.dev.9kbs.com/shopOpenApi/services/deviceAntiScode/getStartCode?apicode=" + WxConfig.apicode
  369. // + "&collect_code=" + collect_code + "&order_no=" + dang + "&amount=10&timestamp="
  370. // + time + "&sign=" + sign;
  371. // String json = HttpsClient.sendPost2(requestUrl, "");
  372. // HashMap<String, Object> userMap = gson.fromJson(json.toString(), new TypeToken<HashMap<String, Object>>(){}.getType());
  373. // String status = userMap.get("status").toString();
  374. // if (status.equals("succ")) {
  375. // String data = userMap.get("data").toString();
  376. // HashMap<String, Object> device = gson.fromJson(data.toString(), new TypeToken<HashMap<String, Object>>() {}.getType());
  377. // String start_code = device.get("start_code").toString();
  378. // String collect_data = device.get("collect_data").toString();
  379. // HashMap<String, Object> money = gson.fromJson(collect_data.toString(), new TypeToken<HashMap<String, Object>>() {}.getType());
  380. // String device_code = money.get("device_code").toString();
  381. // String order_no = new BigDecimal(money.get("order_no").toString()).toString();
  382. // String use_amount = money.get("use_amount").toString();
  383. // // 根据订单号获取上次消费记录
  384. // List<Consume> reconsumes = consumeService.queryRecordByOrder(order_no);
  385. // // 本次消息信息
  386. // List<Users> user0 = userService.selectByCard(card_number);
  387. // // 上次无用户消费
  388. // if (reconsumes == null){
  389. // if (user0 != null) { // 本次消费信息,余额
  390. // BigDecimal balance = user0.get(0).getBalance();
  391. // if (balance.compareTo(basic_amount) > 0) {
  392. // // 保存本次消费信息,但是没有消费金额
  393. // Consume cons = new Consume();
  394. // cons.setCard_number(card_number);
  395. // cons.setUser_name(user_name);
  396. // cons.setOrder_no(dang);
  397. // cons.setBegin_time(time);
  398. // cons.setStart_code(start_code);
  399. // cons.setDevice_code(device_code);
  400. // int num = consumeService.insertComsume(cons);
  401. // if (num > 0) { // 保存成功
  402. // resultJson.put("start_code", start_code);
  403. // ResUtil.write(resultJson, ServletActionContext.getResponse());
  404. // return null;
  405. // }
  406. // } else {
  407. // resultJson.put("mess", "余额小于10元!请充值");
  408. // ResUtil.write(resultJson, ServletActionContext.getResponse());
  409. // return null;
  410. // }
  411. // } else {
  412. // resultJson.put("mess", "卡号异常");
  413. // ResUtil.write(resultJson, ServletActionContext.getResponse());
  414. // return null;
  415. // }
  416. // }else {
  417. // // 上次消费卡号
  418. // String recard_number = reconsumes.get(0).getCard_number();
  419. // // 上次用户信息
  420. // List<Users> reusers = userService.selectByCard(recard_number);
  421. // if (reusers != null ) {
  422. // if (reconsumes.get(0).getState() == 0) { // 上次消费未结算
  423. // BigDecimal rebalance = reusers.get(0).getBalance();
  424. // BigDecimal use_amounts = new BigDecimal(use_amount);
  425. // if (rebalance.compareTo(use_amounts) > 0) {
  426. // residue = rebalance.subtract(use_amounts);
  427. // List<Price> ws = consumeService.water_price("热水");
  428. // if (ws!=null){
  429. // use_size = use_amounts.divide(ws.get(0).getPrice(), BigDecimal.ROUND_HALF_UP);
  430. // }
  431. // int num1 = consumeService.updateConsume(order_no, time, use_amounts, use_size, 1);
  432. // int num2 = consumeService.updateBalance(recard_number, residue);
  433. // // 上次消费扣除完毕
  434. // if (num1 > 0 && num2 > 0) {
  435. // // 查询本次用户信息
  436. // List<Users> users2 = userService.selectByCard(card_number);
  437. // if (users2 != null ) {
  438. // // 保存本次消费记录,但是没有消费金额
  439. // Consume cons = new Consume();
  440. // cons.setCard_number(card_number);
  441. // cons.setUser_name(user_name);
  442. // cons.setOrder_no(dang);
  443. // cons.setBegin_time(time);
  444. // cons.setStart_code(start_code);
  445. // cons.setDevice_code(device_code);
  446. // int num = consumeService.insertComsume(cons);
  447. // if (num > 0) {
  448. // BigDecimal bal = users2.get(0).getBalance();
  449. // if (bal.compareTo(basic_amount) > 0) {
  450. // resultJson.put("start_code", start_code);
  451. // ResUtil.write(resultJson, ServletActionContext.getResponse());
  452. // return null;
  453. // } else {
  454. // resultJson.put("mess", "余额不足!请充值");
  455. // ResUtil.write(resultJson, ServletActionContext.getResponse());
  456. // return null;
  457. // }
  458. // } else {
  459. // resultJson.put("mess", "本次订单提交失败!");
  460. // ResUtil.write(resultJson, ServletActionContext.getResponse());
  461. // return null;
  462. // }
  463. // } else {
  464. // resultJson.put("mess", "用户信息异常!");
  465. // ResUtil.write(resultJson, ServletActionContext.getResponse());
  466. // return null;
  467. // }
  468. // } else {
  469. // resultJson.put("mess", "结算失败!请联系管理员");
  470. // ResUtil.write(resultJson, ServletActionContext.getResponse());
  471. // return null;
  472. // }
  473. // } else {
  474. // resultJson.put("mess", "上次消费用户余额不足!");
  475. // ResUtil.write(resultJson, ServletActionContext.getResponse());
  476. // return null;
  477. // }
  478. // } else { // 上次消费已结算
  479. // // 查询本次用户信息
  480. // List<Users> users2 = userService.selectByCard(card_number);
  481. // if (users2 != null ) {
  482. // // 保存本次消费记录,但是没有消费金额
  483. // Consume cons = new Consume();
  484. // cons.setCard_number(card_number);
  485. // cons.setUser_name(user_name);
  486. // cons.setOrder_no(dang);
  487. // cons.setBegin_time(time);
  488. // cons.setStart_code(start_code);
  489. // cons.setDevice_code(device_code);
  490. // int num = consumeService.insertComsume(cons);
  491. // if (num > 0) {
  492. // BigDecimal bal = users2.get(0).getBalance();
  493. // if (bal.compareTo(basic_amount) > 0) {
  494. // resultJson.put("start_code", start_code);
  495. // ResUtil.write(resultJson, ServletActionContext.getResponse());
  496. // return null;
  497. // } else {
  498. // resultJson.put("mess", "余额不足!请充值");
  499. // ResUtil.write(resultJson, ServletActionContext.getResponse());
  500. // return null;
  501. // }
  502. // } else {
  503. // resultJson.put("mess", "本次订单提交失败!");
  504. // ResUtil.write(resultJson, ServletActionContext.getResponse());
  505. // return null;
  506. // }
  507. // } else {
  508. // resultJson.put("mess", "用户信息异常!");
  509. // ResUtil.write(resultJson, ServletActionContext.getResponse());
  510. // return null;
  511. // }
  512. // }
  513. // } else {
  514. // resultJson.put("mess", "用户信息异常!");
  515. // ResUtil.write(resultJson, ServletActionContext.getResponse());
  516. // return null;
  517. // }
  518. // }
  519. //
  520. // }else {
  521. // resultJson.put("mess", "请求参数错误!");
  522. // ResUtil.write(resultJson, ServletActionContext.getResponse());
  523. // }
  524. // }else {
  525. // resultJson.put("mess", "收集码获取失败!");
  526. // ResUtil.write(resultJson, ServletActionContext.getResponse());
  527. // }
  528. // return null;
  529. // }
  530. //
  531. // public String queryConsume() throws Exception {
  532. // JSONObject resultJson = new JSONObject();
  533. // if (card_number!=null){
  534. // List<Consume> consumes = consumeService.queryRecordByCard(card_number, begin_time);
  535. // resultJson.put("mess", consumes);
  536. // ResUtil.write(resultJson, ServletActionContext.getResponse());
  537. // }
  538. // return null;
  539. // }
  540. //
  541. // public String recharge() throws Exception {
  542. // JSONObject resultJson = new JSONObject();
  543. // Enumeration<String> paraNames = request.getParameterNames();
  544. // for(Enumeration e=paraNames;e.hasMoreElements();){
  545. // String thisName=e.nextElement().toString();
  546. // String thisValue=request.getParameter(thisName);
  547. // System.out.println(thisName+"--------------"+thisValue); }
  548. // if (user_id == null || amount == null){
  549. // resultJson.put("mess", "数据异常");
  550. // ResUtil.write(resultJson, ServletActionContext.getResponse());
  551. // return null;
  552. // }
  553. // System.out.println("订单号: "+order_id);
  554. // BigDecimal acc = new BigDecimal(amount);
  555. // SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");// 设置日期格式
  556. // String time = df.format(new Date());
  557. // List<Users> users = userService.selectByCard(user_id);
  558. // Recharge recharge = new Recharge();
  559. // recharge.setRe_time(time);
  560. // recharge.setCard_number(user_id);
  561. // recharge.setUser_name(users.get(0).getUser_name());
  562. // recharge.setAccount(acc.divide(new BigDecimal("100")));
  563. // recharge.setOrder_num(order_id);
  564. // recharge.setState(1);
  565. // rechargeService.insertRecharge(recharge);
  566. // System.out.println("余额:"+users.get(0).getBalance());
  567. // BigDecimal bal = users.get(0).getBalance().add(acc.divide(new BigDecimal("100")));
  568. // consumeService.updateBalance(user_id, bal);
  569. // return null;
  570. // }
  571. //
  572. // public List<Recharge> queryByCard() throws Exception {
  573. // JSONObject resultJson = new JSONObject();
  574. // if (card_number == null){
  575. // resultJson.put("mess", "卡号异常");
  576. // ResUtil.write(resultJson, ServletActionContext.getResponse());
  577. // return null;
  578. // }
  579. // List<Recharge> rechar = rechargeService.queryByCard(card_number, re_time);
  580. // resultJson.put("mess", rechar);
  581. // ResUtil.write(resultJson, ServletActionContext.getResponse());
  582. // return null;
  583. // }
  584. //}