From 6fc5291da18b686f5381d5abec3ffa156fa29b5f Mon Sep 17 00:00:00 2001 From: atao Date: Tue, 27 Jun 2017 18:29:28 +0800 Subject: [PATCH] 提交代码 --- LICENSE | 191 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- jfinal-weixin.iml | 40 ---------------------------------------- src/main/java/com/rnt/controller/WeixinPayController.java | 130 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------------------------------- src/main/java/com/rnt/vo/OrderVO.java | 13 +++++++++++-- src/main/webapp/WEB-INF/pages/check.html | 266 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------------------------------------------------------------------------------------------- 5 files changed, 221 insertions(+), 419 deletions(-) delete mode 100644 LICENSE delete mode 100644 jfinal-weixin.iml diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 6359bb1..0000000 --- a/LICENSE +++ /dev/null @@ -1,191 +0,0 @@ -Apache License -Version 2.0, January 2004 -http://www.apache.org/licenses/ - -TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - -1. Definitions. - -"License" shall mean the terms and conditions for use, reproduction, and -distribution as defined by Sections 1 through 9 of this document. - -"Licensor" shall mean the copyright owner or entity authorized by the copyright -owner that is granting the License. - -"Legal Entity" shall mean the union of the acting entity and all other entities -that control, are controlled by, or are under common control with that entity. -For the purposes of this definition, "control" means (i) the power, direct or -indirect, to cause the direction or management of such entity, whether by -contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the -outstanding shares, or (iii) beneficial ownership of such entity. - -"You" (or "Your") shall mean an individual or Legal Entity exercising -permissions granted by this License. - -"Source" form shall mean the preferred form for making modifications, including -but not limited to software source code, documentation source, and configuration -files. - -"Object" form shall mean any form resulting from mechanical transformation or -translation of a Source form, including but not limited to compiled object code, -generated documentation, and conversions to other media types. - -"Work" shall mean the work of authorship, whether in Source or Object form, made -available under the License, as indicated by a copyright notice that is included -in or attached to the work (an example is provided in the Appendix below). - -"Derivative Works" shall mean any work, whether in Source or Object form, that -is based on (or derived from) the Work and for which the editorial revisions, -annotations, elaborations, or other modifications represent, as a whole, an -original work of authorship. For the purposes of this License, Derivative Works -shall not include works that remain separable from, or merely link (or bind by -name) to the interfaces of, the Work and Derivative Works thereof. - -"Contribution" shall mean any work of authorship, including the original version -of the Work and any modifications or additions to that Work or Derivative Works -thereof, that is intentionally submitted to Licensor for inclusion in the Work -by the copyright owner or by an individual or Legal Entity authorized to submit -on behalf of the copyright owner. For the purposes of this definition, -"submitted" means any form of electronic, verbal, or written communication sent -to the Licensor or its representatives, including but not limited to -communication on electronic mailing lists, source code control systems, and -issue tracking systems that are managed by, or on behalf of, the Licensor for -the purpose of discussing and improving the Work, but excluding communication -that is conspicuously marked or otherwise designated in writing by the copyright -owner as "Not a Contribution." - -"Contributor" shall mean Licensor and any individual or Legal Entity on behalf -of whom a Contribution has been received by Licensor and subsequently -incorporated within the Work. - -2. Grant of Copyright License. - -Subject to the terms and conditions of this License, each Contributor hereby -grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, -irrevocable copyright license to reproduce, prepare Derivative Works of, -publicly display, publicly perform, sublicense, and distribute the Work and such -Derivative Works in Source or Object form. - -3. Grant of Patent License. - -Subject to the terms and conditions of this License, each Contributor hereby -grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, -irrevocable (except as stated in this section) patent license to make, have -made, use, offer to sell, sell, import, and otherwise transfer the Work, where -such license applies only to those patent claims licensable by such Contributor -that are necessarily infringed by their Contribution(s) alone or by combination -of their Contribution(s) with the Work to which such Contribution(s) was -submitted. If You institute patent litigation against any entity (including a -cross-claim or counterclaim in a lawsuit) alleging that the Work or a -Contribution incorporated within the Work constitutes direct or contributory -patent infringement, then any patent licenses granted to You under this License -for that Work shall terminate as of the date such litigation is filed. - -4. Redistribution. - -You may reproduce and distribute copies of the Work or Derivative Works thereof -in any medium, with or without modifications, and in Source or Object form, -provided that You meet the following conditions: - -You must give any other recipients of the Work or Derivative Works a copy of -this License; and -You must cause any modified files to carry prominent notices stating that You -changed the files; and -You must retain, in the Source form of any Derivative Works that You distribute, -all copyright, patent, trademark, and attribution notices from the Source form -of the Work, excluding those notices that do not pertain to any part of the -Derivative Works; and -If the Work includes a "NOTICE" text file as part of its distribution, then any -Derivative Works that You distribute must include a readable copy of the -attribution notices contained within such NOTICE file, excluding those notices -that do not pertain to any part of the Derivative Works, in at least one of the -following places: within a NOTICE text file distributed as part of the -Derivative Works; within the Source form or documentation, if provided along -with the Derivative Works; or, within a display generated by the Derivative -Works, if and wherever such third-party notices normally appear. The contents of -the NOTICE file are for informational purposes only and do not modify the -License. You may add Your own attribution notices within Derivative Works that -You distribute, alongside or as an addendum to the NOTICE text from the Work, -provided that such additional attribution notices cannot be construed as -modifying the License. -You may add Your own copyright statement to Your modifications and may provide -additional or different license terms and conditions for use, reproduction, or -distribution of Your modifications, or for any such Derivative Works as a whole, -provided Your use, reproduction, and distribution of the Work otherwise complies -with the conditions stated in this License. - -5. Submission of Contributions. - -Unless You explicitly state otherwise, any Contribution intentionally submitted -for inclusion in the Work by You to the Licensor shall be under the terms and -conditions of this License, without any additional terms or conditions. -Notwithstanding the above, nothing herein shall supersede or modify the terms of -any separate license agreement you may have executed with Licensor regarding -such Contributions. - -6. Trademarks. - -This License does not grant permission to use the trade names, trademarks, -service marks, or product names of the Licensor, except as required for -reasonable and customary use in describing the origin of the Work and -reproducing the content of the NOTICE file. - -7. Disclaimer of Warranty. - -Unless required by applicable law or agreed to in writing, Licensor provides the -Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, -including, without limitation, any warranties or conditions of TITLE, -NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are -solely responsible for determining the appropriateness of using or -redistributing the Work and assume any risks associated with Your exercise of -permissions under this License. - -8. Limitation of Liability. - -In no event and under no legal theory, whether in tort (including negligence), -contract, or otherwise, unless required by applicable law (such as deliberate -and grossly negligent acts) or agreed to in writing, shall any Contributor be -liable to You for damages, including any direct, indirect, special, incidental, -or consequential damages of any character arising as a result of this License or -out of the use or inability to use the Work (including but not limited to -damages for loss of goodwill, work stoppage, computer failure or malfunction, or -any and all other commercial damages or losses), even if such Contributor has -been advised of the possibility of such damages. - -9. Accepting Warranty or Additional Liability. - -While redistributing the Work or Derivative Works thereof, You may choose to -offer, and charge a fee for, acceptance of support, warranty, indemnity, or -other liability obligations and/or rights consistent with this License. However, -in accepting such obligations, You may act only on Your own behalf and on Your -sole responsibility, not on behalf of any other Contributor, and only if You -agree to indemnify, defend, and hold each Contributor harmless for any liability -incurred by, or claims asserted against, such Contributor by reason of your -accepting any such warranty or additional liability. - -END OF TERMS AND CONDITIONS - -APPENDIX: How to apply the Apache License to your work - -To apply the Apache License to your work, attach the following boilerplate -notice, with the fields enclosed by brackets "{}" replaced with your own -identifying information. (Don't include the brackets!) The text should be -enclosed in the appropriate comment syntax for the file format. We also -recommend that a file or class name and description of purpose be included on -the same "printed page" as the copyright notice for easier identification within -third-party archives. - - Copyright 2014 JFinal - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. \ No newline at end of file diff --git a/jfinal-weixin.iml b/jfinal-weixin.iml deleted file mode 100644 index 909d6a4..0000000 --- a/jfinal-weixin.iml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/main/java/com/rnt/controller/WeixinPayController.java b/src/main/java/com/rnt/controller/WeixinPayController.java index 887c08f..d9057af 100644 --- a/src/main/java/com/rnt/controller/WeixinPayController.java +++ b/src/main/java/com/rnt/controller/WeixinPayController.java @@ -138,7 +138,7 @@ public class WeixinPayController extends Controller { CardBuyVO vo = new CardBuyVO(); /** 停车场卡券id. */ - vo.setPersonCardId(cardCouponsId+""); + vo.setPersonCardId(cardCouponsId + ""); //购买数量 vo.setBuyNum(num + ""); //车牌号. @@ -392,13 +392,13 @@ public class WeixinPayController extends Controller { logger.info("--计算结束时间=" + cardBuyVO.getEndDate()); } /**创建个人卡信息.*/ - String personCardId = personCardCouponsService.savePersonCard(cardBuyVO, parkCardCoupons); - cardBuyVO.setPersonCardId(personCardId); + String personCardId = personCardCouponsService.savePersonCard(cardBuyVO, parkCardCoupons); + cardBuyVO.setPersonCardId(personCardId); //2.创建订单 /**插入停车订单.*/ String orderId = cardOrderService.saveOrder(cardBuyVO, parkCardCoupons); if (StringKit.isNotBlank(orderId)) { - result.setData(orderId); + result.setData(orderId); } else { result.setErrorMessage(ErrorType.SYSTEM_ERROR, "业务错误"); } @@ -468,7 +468,7 @@ public class WeixinPayController extends Controller { String orderId = getPara("orderId"); String openId = getPara("openId"); String payOrderId = getPara("payOrderId"); - logger.info("开始获取公众号支付JS支付参数: orderId=" + orderId + "; openId=" + openId+"; payOrderId="+payOrderId); + logger.info("开始获取公众号支付JS支付参数: orderId=" + orderId + "; openId=" + openId + "; payOrderId=" + payOrderId); //订单ID if (StringKit.isEmpty(orderId)) { bizResult.setCode(ErrorType.PARAMM_NULL.getCode()); @@ -477,23 +477,23 @@ public class WeixinPayController extends Controller { return; } - if(StringKit.isEmpty(payOrderId)){ + if (StringKit.isEmpty(payOrderId)) { bizResult.setCode(ErrorType.PARAMM_NULL.getCode()); bizResult.setMsg("支付单ID不能为空"); renderJson(bizResult); return; } - PayOrder payOrder = PayOrder.dao.findFirst("select * from td_b_pay_order t where t.pay_order_id = ?",payOrderId); + PayOrder payOrder = PayOrder.dao.findFirst("select * from td_b_pay_order t where t.pay_order_id = ?", + payOrderId); - if(null == payOrder){ + if (null == payOrder) { bizResult.setCode(ErrorType.PARAMM_NULL.getCode()); bizResult.setMsg("支付单不存在"); renderJson(bizResult); return; } - // 判断支付单状态 支付单状态:0-待支付 1-成功 2-失败(作废) if (null == payOrder.getPayOrderState() || 0 != payOrder.getPayOrderState()) { logger.info("支付单状态不正确,支付单状态为: orderState=" + payOrder.getPayOrderState()); @@ -503,7 +503,6 @@ public class WeixinPayController extends Controller { return; } - Order order = Order.dao.findFirst("select * from td_b_order t where t.order_id = ?", orderId); if (null == order) { bizResult.setCode(ErrorType.PARAMM_NULL.getCode()); @@ -528,7 +527,7 @@ public class WeixinPayController extends Controller { params.put("body", "任你停公众号订单支付"); params.put("out_trade_no", payOrderId); //支付金额 - params.put("total_fee", payFee.longValue()+""); + params.put("total_fee", payFee.longValue() + ""); String ip = IpKit.getRealIp(getRequest()); if (StrKit.isBlank(ip)) { @@ -577,9 +576,9 @@ public class WeixinPayController extends Controller { packageParams.put("nonceStr", System.currentTimeMillis() + ""); packageParams.put("package", "prepay_id=" + prepay_id); packageParams.put("signType", "MD5"); - logger.info("生成签名钱的字符串为: params="+packageParams.toString()); + logger.info("生成签名钱的字符串为: params=" + packageParams.toString()); String packageSign = PaymentKit.createSign(packageParams, paternerKey); - logger.info("获取到的密钥为: paternerKey="+paternerKey); + logger.info("获取到的密钥为: paternerKey=" + paternerKey); packageParams.put("paySign", packageSign); //生成js 支付调用串 String paySign = JsonUtils.toJson(packageParams); @@ -589,7 +588,6 @@ public class WeixinPayController extends Controller { renderJson(bizResult); } - /** * 公众号支付js-sdk */ @@ -1077,99 +1075,100 @@ public class WeixinPayController extends Controller { /** * 支付页面-入口.
*/ - public void selectCarView(){ - setAttr("openId",TLWXUser.getOpenId()); - setAttr("custId",TLWXUser.getCustId()); - this.render("select.html"); + public void selectCarView() { + setAttr("openId", TLWXUser.getOpenId()); + setAttr("custId", TLWXUser.getCustId()); + this.render("select.html"); } /** * 查看支付单错误.
*/ @Clear(BindInterceptor.class) - public void queryOrderCheckErrorView(){ - String carNum = this.getPara("carNum"); - this.setAttr("carNum", carNum); - this.render("checkerror.html"); + public void queryOrderCheckErrorView() { + String carNum = this.getPara("carNum"); + this.setAttr("carNum", carNum); + this.render("checkerror.html"); } /** * 查询历史支付车牌号.
* 步骤:根据个人cust_id 查询历史订单中最近的3个车牌号.
*/ - public void queryHistoryCarNum(){ + public void queryHistoryCarNum() { BizResult> result = new BizResult>(); OrderService orderService = Duang.duang(OrderService.class); - List list = new ArrayList(); + List list = new ArrayList(); String custId = this.getPara("personCustId"); - try{ - if(StringKit.isNotBlank(custId)){ + try { + if (StringKit.isNotBlank(custId)) { list = orderService.queryHistoryCarNum(custId); - }else{ + } else { result.setErrorMessage(ErrorType.SYSTEM_ERROR, "业务错误"); } - }catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } result.setData(list); - this.renderJson(result); } /** * 根据车牌号查询待支付的停车订单.
*/ - public void queryOrderInfoView(){ + public void queryOrderInfoView() { String carNum = this.getPara("carNum"); this.getRequest().setAttribute("carNum", carNum); this.render("check.html"); } + /** * 检查输入的车牌号是否存订单(带核算/待支付/已完成).
*/ - public void parkOrderForNotPayExist(){ + public void parkOrderForNotPayExist() { BizResult result = new BizResult<>(); String carNum = this.getPara("carNum"); - logger.info("开始校验输入车牌是否存在待核算订单..入参="+carNum); - String rs =""; + logger.info("开始校验输入车牌是否存在待核算订单..入参=" + carNum); + String rs = ""; OrderVO OrderVO = new OrderVO(); - try{ - if(StringKit.isNotBlank(carNum)){ + try { + if (StringKit.isNotBlank(carNum)) { OrderService orderService = Duang.duang(OrderService.class); IRainQueryService iRainQueryService = Duang.duang(IRainQueryService.class); /**查询待核算支付单信息.*/ Order order = orderService.findOrderByCarNum(carNum); - if(order != null && StringKit.isNotBlank(order.getOrderId())){ + if (order != null && StringKit.isNotBlank(order.getOrderId())) { result.setData(order); /**调用艾润查询费用接口.*/ rs = iRainQueryService.billQuery(carNum, order.getParkId()); - }else{ + } else { result.setErrorMessage(ErrorType.NO_PARKING_MSG, "无停车记录"); } - }else{ + } else { logger.info("入参为空!"); result.setErrorMessage(ErrorType.SYSTEM_ERROR, "业务错误"); } - if(StringKit.isNotBlank(rs)){ - if("NO_PARK_RECORD".equals(JSONObject.parseObject(rs).get("code"))){ + if (StringKit.isNotBlank(rs)) { + if ("NO_PARK_RECORD".equals(JSONObject.parseObject(rs).get("code"))) { result.setErrorMessage(ErrorType.NO_PARKING_MSG, "无停车记录"); this.renderJson(result); - return ; + return; } - }else{ + } else { result.setErrorMessage(ErrorType.NO_PARKING_MSG, "无停车记录"); this.renderJson(result); - return ; + return; } - }catch(Exception e){ + } catch (Exception e) { e.printStackTrace(); } - logger.info("结束校验输入车牌是否存在待核算订单..响应="+JSONObject.toJSONString(result)); + logger.info("结束校验输入车牌是否存在待核算订单..响应=" + JSONObject.toJSONString(result)); this.renderJson(result); } + /** * 查询待支付的停车订单.
* 步骤二: @@ -1179,30 +1178,52 @@ public class WeixinPayController extends Controller { * 4.更新订单明细费用.
* 5.插入订单流水表. */ - public void queryParkOrderForNotPay(){ + public void queryParkOrderForNotPay() { logger.info("开始查询待支付的停车订单WeixinPayController.queryParkOrderForNotPay()方法."); BizResult result = new BizResult(); String carNum = this.getPara("carNum"); OrderService orderService = Duang.duang(OrderService.class); OrderVO orderVO = new OrderVO(); - try{ + try { orderVO = orderService.queryParkOrderForNotPay(carNum); - if(orderVO != null && StringKit.isNotBlank(orderVO.getOrderId())){ + if (orderVO != null && StringKit.isNotBlank(orderVO.getOrderId())) { + //创建支付单 + PayOrder payOrder = new PayOrder(); + String payOrderId = SequenceUtil.getNextOrderId(SequenceTypeEnum.ORDER_PAY_WXGZH.value()); + payOrder.setPayOrderId(payOrderId); + payOrder.setPaySrcType(Integer.valueOf(PayOrderEnum.PAY_RESOURCE_TYPE_PARK.getValue())); + payOrder.setRltOrderId(orderVO.getOrderId()); + payOrder.setPayOrderTitle(PayOrderEnum.PAY_ORDER_TYPE_PAY.getValue()); + payOrder.setPayType(Integer.valueOf(PayOrderEnum.PAY_TYPE_WXGZH.getValue())); + payOrder.setPayOrderState(Integer.valueOf(PayOrderEnum.PAY_ORDER_STATE_WAIT_PAY.getValue())); + payOrder.setPayorderStateTime(new Date()); + payOrder.setDataState(DataStatusEnum.DATA_STATUS_VALID.value()); + payOrder.setCreateDate(new Date()); + payOrder.setModfiyDate(new Date()); + logger.info("支付单save请求数据为: payOrder=" + JSONObject.toJSONString(payOrder)); + Boolean flag = payOrder.save(); + logger.info("支付单save 响应为:flag=" + flag); + orderVO.setPayOrderId(payOrderId); + if (!flag) { + result.setCode(ErrorType.BIZ_ERROR.getCode()); + result.setMsg("支付单保存失败!"); + renderJson(result); + return; + } /**根据停车场编码查询通知艾润停车场编码.*/ result.setData(orderVO); - }else{ + } else { result.setErrorMessage(ErrorType.SYSTEM_ERROR, "业务错误"); } - }catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } this.renderJson(result); } - - public void paySuccessView(){ + public void paySuccessView() { String money = getPara("payMoney"); - setAttr("payMoney",money); + setAttr("payMoney", money); render("paysuccess.html"); } @@ -1215,7 +1236,4 @@ public class WeixinPayController extends Controller { System.out.println("offset month date :" + DateUtil.format(newDate, "yyyy-MM-dd")); } - - - } diff --git a/src/main/java/com/rnt/vo/OrderVO.java b/src/main/java/com/rnt/vo/OrderVO.java index 582a517..701e2b5 100644 --- a/src/main/java/com/rnt/vo/OrderVO.java +++ b/src/main/java/com/rnt/vo/OrderVO.java @@ -40,8 +40,17 @@ public class OrderVO { /** 停车时长 单位:小时格式:02小时52分. */ private String parkingDuration; - - + + /** 支付单ID 临时变量*/ + private String payOrderId; + + public String getPayOrderId() { + return payOrderId; + } + + public void setPayOrderId(String payOrderId) { + this.payOrderId = payOrderId; + } public String getParkAddress() { return parkAddress; diff --git a/src/main/webapp/WEB-INF/pages/check.html b/src/main/webapp/WEB-INF/pages/check.html index 251f631..c14c76b 100644 --- a/src/main/webapp/WEB-INF/pages/check.html +++ b/src/main/webapp/WEB-INF/pages/check.html @@ -3,11 +3,11 @@ 查看账单 - - - - - + + + + + @@ -18,29 +18,33 @@