Commit b95f41afa5c4e5ed1d306f34a09e0ed0f01d607f

Authored by atao
1 parent 9f169425

提交代码

src/main/java/com/rnt/commo/enums/ErrorType.java
... ... @@ -2,16 +2,19 @@ package com.rnt.commo.enums;
2 2  
3 3 public enum ErrorType {
4 4  
5   - WX_NO_BIND("1004","用户未绑定"),
  5 +
6 6 SYSTEM_ERROR("1000", "系统错误"),
7 7 APP_ERROR("1001", "应用错误"),
8 8 BIZ_ERROR("1002", "业务错误:%s"),
9 9 PARAMM_NULL("1003", "入参不能为空:[%s]"),
10 10 RAND_CODE_ERROE("1004", "验证码验证失败!"),
11 11 NO_PARKING_MSG("1005", "无停车记录!"),
  12 + WX_NO_BIND("1006","用户未绑定"),
  13 + ORDER_NO_EXISTS("1007","订单不存在"),
12 14 BIZ_SUCCESS("8888", "成功"),
13 15 URL_REDIRECT("-1111", "业务URL跳转");
14 16  
  17 +
15 18 private String code;
16 19 private String msg;
17 20  
... ...
src/main/java/com/rnt/commo/enums/OrderTypeEnum.java
... ... @@ -37,7 +37,12 @@ public enum OrderTypeEnum {
37 37  
38 38 /**订单明细类型 */
39 39 ORDER_DETAIL_TYPE_BUY_CARD(1,"购卡"),
40   - ORDER_DETAIL_TYPE_RENEW_CARD(2,"续费");
  40 + ORDER_DETAIL_TYPE_RENEW_CARD(2,"续费"),
  41 +
  42 + /***封闭停车场 1、道闸*/
  43 + ORDER_SOURCE_TYPE_IN(1,"道闸"),
  44 + /**开放停车场 2 地磁*/
  45 + ORDER_SOURCE_TYPE_OUT(2,"地磁");
41 46  
42 47  
43 48 private Integer value;
... ...
src/main/java/com/rnt/controller/ParkLotController.java
... ... @@ -15,6 +15,7 @@ import com.jfinal.log.Log;
15 15 import com.jfinal.plugin.activerecord.Page;
16 16 import com.rnt.commo.enums.ErrorType;
17 17 import com.rnt.model.zf.ParkCardCoupons;
  18 +import com.rnt.service.IRainQueryService;
18 19 import com.rnt.service.ParkCardCouponsService;
19 20 import com.rnt.service.ParkLotService;
20 21 import com.rnt.service.PersonCardCouponsService;
... ... @@ -190,4 +191,21 @@ public class ParkLotController extends Controller {
190 191 this.renderJson(result);
191 192 }
192 193  
  194 + /**
  195 + * 抬杆通知走车
  196 + */
  197 + public void passHandrail() {
  198 + String orderId = getPara("orderId");
  199 + BizResult<String> result = new BizResult<>();
  200 + IRainQueryService service = Duang.duang(IRainQueryService.class);
  201 + try {
  202 + result = service.passHandrail(orderId);
  203 + } catch (Exception e) {
  204 + result.setErrorMessage(ErrorType.APP_ERROR, "抬杆通知失败!");
  205 + logger.error("支付成功,抬杆通知失败!", e);
  206 + }
  207 + logger.info("支付成功,抬杆通知 result=" + JSONObject.toJSONString(result));
  208 + renderJson(result);
  209 + }
  210 +
193 211 }
... ...
src/main/java/com/rnt/service/IRainQueryService.java
1 1 package com.rnt.service;
2 2  
  3 +import java.math.BigDecimal;
3 4 import java.util.HashMap;
4 5 import java.util.Map;
5 6  
6   -import org.beetl.sql.core.kit.StringKit;
7   -
8 7 import com.alibaba.fastjson.JSONObject;
  8 +
9 9 import com.jfinal.kit.Prop;
10 10 import com.jfinal.kit.PropKit;
11 11 import com.jfinal.log.Log;
  12 +import com.rnt.commo.enums.ErrorType;
  13 +import com.rnt.commo.enums.OrderTypeEnum;
12 14 import com.rnt.model.park.IrainPknoRelation;
  15 +import com.rnt.model.zf.Order;
  16 +import com.rnt.model.zf.OrderDetailPark;
13 17 import com.rnt.utils.HttpClientTutorial;
14 18 import com.rnt.utils.MD5Utils;
  19 +import com.rnt.vo.BizResult;
  20 +import org.beetl.sql.core.kit.StringKit;
15 21  
16 22 /**
17 23 * 艾润费用查询service.<br/>
18   - *
  24 + *
19 25 * Copyright: Copyright (c) 2017 zteits
20   - *
  26 + *
21 27 * @ClassName: IRainQueryService.java
22   - * @Description:
  28 + * @Description:
23 29 * @version: v1.0.0
24 30 * @author: wangfs
25   - * @date: 2017年6月13日 上午9:25:31
  31 + * @date: 2017年6月13日 上午9:25:31
26 32 * Modification History:
27 33 * Date Author Version Description
28   - *---------------------------------------------------------*
  34 + * ---------------------------------------------------------*
29 35 * 2017年6月13日 wangfs v1.0.0 创建
30 36 */
31 37 public class IRainQueryService {
32   - private static final Log logger = Log.getLog(IRainQueryService.class);
33   -
34   - /**
35   - * 调用艾润查询费用接口.<br/>
36   - * @param carNum
37   - * @param parkCode
38   - * @return
39   - */
40   - public String billQuery(String carNum,String parkCode) {
41   - logger.info("开始调用查询费用接口,入参={carNum,parkCode}="+"{"+carNum+","+parkCode+"}");
42   - //1.查询停车场关系映射表-获取艾润停车场查询费用编码 ztetis-park.irain_pkno_relation
43   - StringBuffer sql = new StringBuffer("select a.irain_pkno1");
44   - sql.append(" from irain_pkno_relation a");
45   - sql.append(" where a.park_lotpkno = ?");
46   - String rs = "";
47   - IrainPknoRelation irainPknoRelation = new IrainPknoRelation().findFirst(sql.toString(), parkCode);
48   - if(irainPknoRelation != null && StringKit.isNotBlank(irainPknoRelation.getIrainPkno1())){
49   - /**** 以下为模拟入参 实际入参 由app提供-------------------------------------*/
50   - Prop prop = PropKit.use("a_little_config.txt");
51   - Long time = System.currentTimeMillis();
52   - String md5 = MD5Utils.enMD5(prop.get("irain.appid")+prop.get("irain.appsecret")+time);
53   - Map<String, Object> params = new HashMap<>();
54   - params.put("appid", prop.get("irain.appid"));
55   - params.put("sign", md5);
56   - params.put("timestamp", time);
57   - params.put("vpl_number", carNum);
58   - params.put("park_code", irainPknoRelation.getIrainPkno1());
59   -
60   - try {
61   - logger.info("irain 查询停车费用入参:" + JSONObject.toJSONString(params));
62   - rs = HttpClientTutorial.httpPostRequest(prop.get("irain.url")+"/bill/Query", params);
63   - logger.info("irain 查询停车费用返回:" + JSONObject.toJSONString(rs));
64   - } catch (Exception e) {
65   - logger.info("irain 查询停车费用出错:" + e);
66   - }
67   - }else{
68   - logger.info("没有查询到艾润查询费用编码");
69   - }
70   -
71   - logger.info("结束调用查询费用接口,结果="+JSONObject.toJSONString(rs));
72   -
73   -
74   - return JSONObject.toJSON(rs)+"";
75   - }
76   -
77   - public static void main(String[] args) {
78   - Prop prop = PropKit.use("a_little_config.txt");
79   - String rs = "";
80   - Long time = System.currentTimeMillis();
81   - String md5 = MD5Utils.enMD5(prop.get("irain.appid")+prop.get("irain.appsecret")+time);
82   - Map<String, Object> params = new HashMap<>();
83   - params.put("appid", prop.get("irain.appid"));
84   - params.put("sign", md5);
85   - params.put("timestamp", time);
86   - params.put("vpl_number", "苏B1B566");
87   - params.put("park_code", "734861a1e8656ffa51bdd90829941ca9");
88   -
89   - try {
90   - logger.info("irain 查询停车费用入参:" + JSONObject.toJSONString(params));
91   - rs = HttpClientTutorial.httpPostRequest(prop.get("irain.url")+"/bill/Query", params);
92   - logger.info("irain 查询停车费用返回:" + JSONObject.toJSONString(rs));
93   - } catch (Exception e) {
94   - logger.info("irain 查询停车费用出错:" + e);
95   - }
96   - }
  38 + private static final Log logger = Log.getLog(IRainQueryService.class);
  39 +
  40 + /**
  41 + * 调用艾润查询费用接口.<br/>
  42 + *
  43 + * @param carNum
  44 + * @param parkCode
  45 + * @return
  46 + */
  47 + public String billQuery(String carNum, String parkCode) {
  48 + logger.info("开始调用查询费用接口,入参={carNum,parkCode}=" + "{" + carNum + "," + parkCode + "}");
  49 + //1.查询停车场关系映射表-获取艾润停车场查询费用编码 ztetis-park.irain_pkno_relation
  50 + StringBuffer sql = new StringBuffer("select a.irain_pkno1");
  51 + sql.append(" from irain_pkno_relation a");
  52 + sql.append(" where a.park_lotpkno = ?");
  53 + String rs = "";
  54 + IrainPknoRelation irainPknoRelation = new IrainPknoRelation().findFirst(sql.toString(), parkCode);
  55 + if (irainPknoRelation != null && StringKit.isNotBlank(irainPknoRelation.getIrainPkno1())) {
  56 + /**** 以下为模拟入参 实际入参 由app提供-------------------------------------*/
  57 + Prop prop = PropKit.use("a_little_config.txt");
  58 + Long time = System.currentTimeMillis();
  59 + String md5 = MD5Utils.enMD5(prop.get("irain.appid") + prop.get("irain.appsecret") + time);
  60 + Map<String, Object> params = new HashMap<>();
  61 + params.put("appid", prop.get("irain.appid"));
  62 + params.put("sign", md5);
  63 + params.put("timestamp", time);
  64 + params.put("vpl_number", carNum);
  65 + params.put("park_code", irainPknoRelation.getIrainPkno1());
  66 +
  67 + try {
  68 + logger.info("irain 查询停车费用入参:" + JSONObject.toJSONString(params));
  69 + rs = HttpClientTutorial.httpPostRequest(prop.get("irain.url") + "/bill/Query", params);
  70 + logger.info("irain 查询停车费用返回:" + JSONObject.toJSONString(rs));
  71 + } catch (Exception e) {
  72 + logger.info("irain 查询停车费用出错:" + e);
  73 + }
  74 + } else {
  75 + logger.info("没有查询到艾润查询费用编码");
  76 + }
  77 +
  78 + logger.info("结束调用查询费用接口,结果=" + JSONObject.toJSONString(rs));
  79 +
  80 + return JSONObject.toJSON(rs) + "";
  81 + }
  82 +
  83 + /***
  84 + * 支付完成,停车通过栏杆
  85 + */
  86 +
  87 + public BizResult<String> passHandrail(String orderId) throws Exception {
  88 + BizResult<String> bizResult = new BizResult<>();
  89 + logger.info(" 支付完成,通知抬杆 ----start--- req=" + orderId);
  90 + Order order = Order.dao.findFirst("SELECT * FROM td_b_order t where t.order_id = ?", orderId);
  91 + if (null == order) {
  92 + logger.info(" 支付完成,通知抬杆 订单不存在 orderId=" + orderId);
  93 + bizResult.setErrorMessage(ErrorType.ORDER_NO_EXISTS, "订单不存在");
  94 + return bizResult;
  95 + }
  96 +
  97 + if (order.getSourceType().equals(OrderTypeEnum.ORDER_SOURCE_TYPE_IN)) {
  98 + /**
  99 + * 艾润通知
  100 + */
  101 + bizResult = passIRail(order.getCarNumber(), order.getParkId(), order.getOrderTotalFee());
  102 + logger.info("艾润抬杆通知 返回为: bizResult=" + JSONObject.toJSONString(bizResult));
  103 +
  104 + } else if (order.getSourceType().equals(OrderTypeEnum.ORDER_SOURCE_TYPE_OUT)) {
  105 + /**
  106 + * 青岛
  107 + */
  108 + bizResult = passQD(order);
  109 +
  110 + } else {
  111 + logger.info("支付完成,通知抬杆 未知的订单来源类型: orderSourceType=" + order.getSourceType());
  112 + bizResult.setErrorMessage(ErrorType.BIZ_ERROR, "未知的订单来源类型");
  113 + }
  114 +
  115 + return bizResult;
  116 +
  117 + }
  118 +
  119 + /**
  120 + * 艾润抬杆设置
  121 + */
  122 + private BizResult<String> passIRail(String vpl_number, String park_code, BigDecimal amount) throws Exception {
  123 + BizResult<String> bizResult = new BizResult<>();
  124 + //1.查询停车场关系映射表-获取艾润停车场查询费用编码 ztetis-park.irain_pkno_relation
  125 + StringBuffer sql = new StringBuffer("select a.irain_pkno1");
  126 + sql.append(" from irain_pkno_relation a");
  127 + sql.append(" where a.park_lotpkno = ?");
  128 + String rs = "";
  129 + IrainPknoRelation irainPknoRelation = new IrainPknoRelation().findFirst(sql.toString(), park_code);
  130 +
  131 + if (irainPknoRelation != null && StringKit.isNotBlank(irainPknoRelation.getIrainPkno2())) {
  132 + /**** 以下为模拟入参 实际入参 由app提供-------------------------------------*/
  133 + Prop prop = PropKit.use("a_little_config.txt");
  134 + Long time = System.currentTimeMillis();
  135 + String md5 = MD5Utils.enMD5(prop.get("irain.appid") + prop.get("irain.appsecret") + time);
  136 + Map<String, Object> params = new HashMap<>();
  137 + params.put("appid", prop.get("irain.appid"));
  138 + params.put("sign", md5);
  139 + params.put("timestamp", time);
  140 + params.put("vpl_number", vpl_number);
  141 + //要用进出场上报的那个编码
  142 + params.put("park_code", irainPknoRelation.getIrainPkno2());
  143 + params.put("amount", amount.intValue());
  144 +
  145 + logger.info("开始通知irain 支付已经完成:" + JSONObject.toJSONString(params));
  146 + rs = HttpClientTutorial.httpPostRequest(prop.get("irain.url") + "/pay/Issued", params);
  147 + logger.info("结束通知irain 支付已经完成::" + rs);
  148 + JSONObject result = JSONObject.parseObject(rs);
  149 +
  150 + if ("OK".equals(result.getString("message"))) {
  151 + bizResult.setData("通知成功!");
  152 + } else {
  153 + bizResult.setErrorMessage(ErrorType.BIZ_ERROR, "通知irain 支付已经完成失败!");
  154 +
  155 + }
  156 + return bizResult;
  157 +
  158 + } else {
  159 + logger.info("没有查询到艾润进出场上报编码");
  160 + bizResult.setErrorMessage(ErrorType.BIZ_ERROR, "未查询到艾润进出场上报编码");
  161 + return bizResult;
  162 + }
  163 +
  164 + }
  165 +
  166 + /**
  167 + * 青岛抬杆设置
  168 + */
  169 + private BizResult<String> passQD(Order order) throws Exception {
  170 + BizResult<String> bizResult = new BizResult<>();
  171 + String url = PropKit.get("qd.retrun_fee_url");
  172 + OrderDetailPark orderDetailPark = OrderDetailPark.dao.findFirst(
  173 + "SELECT * FROM td_b_order_detail_park t where t.order_id = ?", order.getOrderId());
  174 +
  175 + Map<String, Object> params = new HashMap<>();
  176 + params.put("orderCode", orderDetailPark.getRecordId());
  177 + params.put("amount", order.getOrderTotalFee().intValue());
  178 + params.put("orderPay", order.getOrderPayedFee().intValue());
  179 + params.put("payType", 1);
  180 +
  181 + logger.info("开始通知irain 支付已经完成:" + JSONObject.toJSONString(params));
  182 + String rs = HttpClientTutorial.httpPostRequest(url, JSONObject.toJSONString(params));
  183 + logger.info("结束通知irain 支付已经完成:" + rs);
  184 + JSONObject result = JSONObject.parseObject(rs);
  185 + if ("1".equals(result.getString("status"))) {
  186 + bizResult.setData("通知成功!");
  187 + } else {
  188 + bizResult.setErrorMessage(ErrorType.BIZ_ERROR, "通知青岛 支付已经完成失败!");
  189 + }
  190 + return bizResult;
  191 + }
  192 +
  193 + public static void main(String[] args) {
  194 + Prop prop = PropKit.use("a_little_config.txt");
  195 + String rs = "";
  196 + Long time = System.currentTimeMillis();
  197 + String md5 = MD5Utils.enMD5(prop.get("irain.appid") + prop.get("irain.appsecret") + time);
  198 + Map<String, Object> params = new HashMap<>();
  199 + params.put("appid", prop.get("irain.appid"));
  200 + params.put("sign", md5);
  201 + params.put("timestamp", time);
  202 + params.put("vpl_number", "苏B1B566");
  203 + params.put("park_code", "734861a1e8656ffa51bdd90829941ca9");
  204 +
  205 + try {
  206 + logger.info("irain 查询停车费用入参:" + JSONObject.toJSONString(params));
  207 + rs = HttpClientTutorial.httpPostRequest(prop.get("irain.url") + "/bill/Query", params);
  208 + logger.info("irain 查询停车费用返回:" + JSONObject.toJSONString(rs));
  209 + } catch (Exception e) {
  210 + logger.info("irain 查询停车费用出错:" + e);
  211 + }
  212 + }
97 213 }
... ...
src/main/java/com/rnt/utils/HttpClientTutorial.java
... ... @@ -96,17 +96,23 @@ public class HttpClientTutorial {
96 96 }
97 97  
98 98 public static String httpPostRequest(String url, JSONObject jsonParam) throws UnsupportedEncodingException {
99   - HttpPost httpPost = new HttpPost(url);
  99 +
  100 + return httpPostRequest(url,jsonParam.toJSONString());
  101 + }
  102 +
  103 + public static String httpPostRequest(String url, String jsonParam) throws UnsupportedEncodingException {
  104 + HttpPost httpPost = new HttpPost(url);
100 105 if (null != jsonParam) {
101 106 //解决中文乱码问题
102   - StringEntity entity = new StringEntity(jsonParam.toString(), "utf-8");
  107 + StringEntity entity = new StringEntity(jsonParam, "utf-8");
103 108 entity.setContentEncoding("UTF-8");
104 109 entity.setContentType("application/json");
105 110 httpPost.setEntity(entity);
106   - }
107   - return getResult(httpPost);
108   - }
109   -
  111 + }
  112 + return getResult(httpPost);
  113 + }
  114 +
  115 +
110 116 public static String httpPostRequest(String url, Map<String, Object> headers, Map<String, Object> params)
111 117 throws UnsupportedEncodingException {
112 118 HttpPost httpPost = new HttpPost(url);
... ...
src/main/resources/a_little_config.txt
... ... @@ -40,8 +40,8 @@ zf.druid.testOnReturn=false
40 40 zf.druid.testOnWhileIdle=true
41 41  
42 42 #Redis config
43   -redis.host=127.0.0.1
44   -redis.port=6379
  43 +redis.host=10.117.61.52
  44 +redis.port=7001
45 45 redis.password=myredis
46 46  
47 47  
... ... @@ -79,6 +79,8 @@ irain.appsecret=rrr6uz3aqvutpsq2lsna0k18cea4mabw
79 79 irain.aes=avakrky0gk1m7n00
80 80 irain.park_code=734861a1e8656ffa51bdd90829941ca9
81 81  
  82 +#青岛路侧数据
  83 +qd.retrun_fee_url=http://zteits.gnway.cc:8088/RNT-ATMS-ADAPTER/pay/doPayAdvice
82 84  
83 85 #dubbo
84 86 dubbo.application.name=rnt-wx
... ...