diff --git a/src/main/java/com/rnt/commo/enums/ErrorType.java b/src/main/java/com/rnt/commo/enums/ErrorType.java index 232921d..d4ab40c 100644 --- a/src/main/java/com/rnt/commo/enums/ErrorType.java +++ b/src/main/java/com/rnt/commo/enums/ErrorType.java @@ -2,16 +2,19 @@ package com.rnt.commo.enums; public enum ErrorType { - WX_NO_BIND("1004","用户未绑定"), + SYSTEM_ERROR("1000", "系统错误"), APP_ERROR("1001", "应用错误"), BIZ_ERROR("1002", "业务错误:%s"), PARAMM_NULL("1003", "入参不能为空:[%s]"), RAND_CODE_ERROE("1004", "验证码验证失败!"), NO_PARKING_MSG("1005", "无停车记录!"), + WX_NO_BIND("1006","用户未绑定"), + ORDER_NO_EXISTS("1007","订单不存在"), BIZ_SUCCESS("8888", "成功"), URL_REDIRECT("-1111", "业务URL跳转"); + private String code; private String msg; diff --git a/src/main/java/com/rnt/commo/enums/OrderTypeEnum.java b/src/main/java/com/rnt/commo/enums/OrderTypeEnum.java index 63fd60f..d9e5204 100644 --- a/src/main/java/com/rnt/commo/enums/OrderTypeEnum.java +++ b/src/main/java/com/rnt/commo/enums/OrderTypeEnum.java @@ -37,7 +37,12 @@ public enum OrderTypeEnum { /**订单明细类型 */ ORDER_DETAIL_TYPE_BUY_CARD(1,"购卡"), - ORDER_DETAIL_TYPE_RENEW_CARD(2,"续费"); + ORDER_DETAIL_TYPE_RENEW_CARD(2,"续费"), + + /***封闭停车场 1、道闸*/ + ORDER_SOURCE_TYPE_IN(1,"道闸"), + /**开放停车场 2 地磁*/ + ORDER_SOURCE_TYPE_OUT(2,"地磁"); private Integer value; diff --git a/src/main/java/com/rnt/controller/ParkLotController.java b/src/main/java/com/rnt/controller/ParkLotController.java index 169f6cb..eb79b30 100644 --- a/src/main/java/com/rnt/controller/ParkLotController.java +++ b/src/main/java/com/rnt/controller/ParkLotController.java @@ -15,6 +15,7 @@ import com.jfinal.log.Log; import com.jfinal.plugin.activerecord.Page; import com.rnt.commo.enums.ErrorType; import com.rnt.model.zf.ParkCardCoupons; +import com.rnt.service.IRainQueryService; import com.rnt.service.ParkCardCouponsService; import com.rnt.service.ParkLotService; import com.rnt.service.PersonCardCouponsService; @@ -190,4 +191,21 @@ public class ParkLotController extends Controller { this.renderJson(result); } + /** + * 抬杆通知走车 + */ + public void passHandrail() { + String orderId = getPara("orderId"); + BizResult result = new BizResult<>(); + IRainQueryService service = Duang.duang(IRainQueryService.class); + try { + result = service.passHandrail(orderId); + } catch (Exception e) { + result.setErrorMessage(ErrorType.APP_ERROR, "抬杆通知失败!"); + logger.error("支付成功,抬杆通知失败!", e); + } + logger.info("支付成功,抬杆通知 result=" + JSONObject.toJSONString(result)); + renderJson(result); + } + } diff --git a/src/main/java/com/rnt/service/IRainQueryService.java b/src/main/java/com/rnt/service/IRainQueryService.java index 93c5f48..e10ac43 100644 --- a/src/main/java/com/rnt/service/IRainQueryService.java +++ b/src/main/java/com/rnt/service/IRainQueryService.java @@ -1,97 +1,213 @@ package com.rnt.service; +import java.math.BigDecimal; import java.util.HashMap; import java.util.Map; -import org.beetl.sql.core.kit.StringKit; - import com.alibaba.fastjson.JSONObject; + import com.jfinal.kit.Prop; import com.jfinal.kit.PropKit; import com.jfinal.log.Log; +import com.rnt.commo.enums.ErrorType; +import com.rnt.commo.enums.OrderTypeEnum; import com.rnt.model.park.IrainPknoRelation; +import com.rnt.model.zf.Order; +import com.rnt.model.zf.OrderDetailPark; import com.rnt.utils.HttpClientTutorial; import com.rnt.utils.MD5Utils; +import com.rnt.vo.BizResult; +import org.beetl.sql.core.kit.StringKit; /** * 艾润费用查询service.
- * + * * Copyright: Copyright (c) 2017 zteits - * + * * @ClassName: IRainQueryService.java - * @Description: + * @Description: * @version: v1.0.0 * @author: wangfs - * @date: 2017年6月13日 上午9:25:31 + * @date: 2017年6月13日 上午9:25:31 * Modification History: * Date Author Version Description - *---------------------------------------------------------* + * ---------------------------------------------------------* * 2017年6月13日 wangfs v1.0.0 创建 */ public class IRainQueryService { - private static final Log logger = Log.getLog(IRainQueryService.class); - - /** - * 调用艾润查询费用接口.
- * @param carNum - * @param parkCode - * @return - */ - public String billQuery(String carNum,String parkCode) { - logger.info("开始调用查询费用接口,入参={carNum,parkCode}="+"{"+carNum+","+parkCode+"}"); - //1.查询停车场关系映射表-获取艾润停车场查询费用编码 ztetis-park.irain_pkno_relation - StringBuffer sql = new StringBuffer("select a.irain_pkno1"); - sql.append(" from irain_pkno_relation a"); - sql.append(" where a.park_lotpkno = ?"); - String rs = ""; - IrainPknoRelation irainPknoRelation = new IrainPknoRelation().findFirst(sql.toString(), parkCode); - if(irainPknoRelation != null && StringKit.isNotBlank(irainPknoRelation.getIrainPkno1())){ - /**** 以下为模拟入参 实际入参 由app提供-------------------------------------*/ - Prop prop = PropKit.use("a_little_config.txt"); - Long time = System.currentTimeMillis(); - String md5 = MD5Utils.enMD5(prop.get("irain.appid")+prop.get("irain.appsecret")+time); - Map params = new HashMap<>(); - params.put("appid", prop.get("irain.appid")); - params.put("sign", md5); - params.put("timestamp", time); - params.put("vpl_number", carNum); - params.put("park_code", irainPknoRelation.getIrainPkno1()); - - try { - logger.info("irain 查询停车费用入参:" + JSONObject.toJSONString(params)); - rs = HttpClientTutorial.httpPostRequest(prop.get("irain.url")+"/bill/Query", params); - logger.info("irain 查询停车费用返回:" + JSONObject.toJSONString(rs)); - } catch (Exception e) { - logger.info("irain 查询停车费用出错:" + e); - } - }else{ - logger.info("没有查询到艾润查询费用编码"); - } - - logger.info("结束调用查询费用接口,结果="+JSONObject.toJSONString(rs)); - - - return JSONObject.toJSON(rs)+""; - } - - public static void main(String[] args) { - Prop prop = PropKit.use("a_little_config.txt"); - String rs = ""; - Long time = System.currentTimeMillis(); - String md5 = MD5Utils.enMD5(prop.get("irain.appid")+prop.get("irain.appsecret")+time); - Map params = new HashMap<>(); - params.put("appid", prop.get("irain.appid")); - params.put("sign", md5); - params.put("timestamp", time); - params.put("vpl_number", "苏B1B566"); - params.put("park_code", "734861a1e8656ffa51bdd90829941ca9"); - - try { - logger.info("irain 查询停车费用入参:" + JSONObject.toJSONString(params)); - rs = HttpClientTutorial.httpPostRequest(prop.get("irain.url")+"/bill/Query", params); - logger.info("irain 查询停车费用返回:" + JSONObject.toJSONString(rs)); - } catch (Exception e) { - logger.info("irain 查询停车费用出错:" + e); - } - } + private static final Log logger = Log.getLog(IRainQueryService.class); + + /** + * 调用艾润查询费用接口.
+ * + * @param carNum + * @param parkCode + * @return + */ + public String billQuery(String carNum, String parkCode) { + logger.info("开始调用查询费用接口,入参={carNum,parkCode}=" + "{" + carNum + "," + parkCode + "}"); + //1.查询停车场关系映射表-获取艾润停车场查询费用编码 ztetis-park.irain_pkno_relation + StringBuffer sql = new StringBuffer("select a.irain_pkno1"); + sql.append(" from irain_pkno_relation a"); + sql.append(" where a.park_lotpkno = ?"); + String rs = ""; + IrainPknoRelation irainPknoRelation = new IrainPknoRelation().findFirst(sql.toString(), parkCode); + if (irainPknoRelation != null && StringKit.isNotBlank(irainPknoRelation.getIrainPkno1())) { + /**** 以下为模拟入参 实际入参 由app提供-------------------------------------*/ + Prop prop = PropKit.use("a_little_config.txt"); + Long time = System.currentTimeMillis(); + String md5 = MD5Utils.enMD5(prop.get("irain.appid") + prop.get("irain.appsecret") + time); + Map params = new HashMap<>(); + params.put("appid", prop.get("irain.appid")); + params.put("sign", md5); + params.put("timestamp", time); + params.put("vpl_number", carNum); + params.put("park_code", irainPknoRelation.getIrainPkno1()); + + try { + logger.info("irain 查询停车费用入参:" + JSONObject.toJSONString(params)); + rs = HttpClientTutorial.httpPostRequest(prop.get("irain.url") + "/bill/Query", params); + logger.info("irain 查询停车费用返回:" + JSONObject.toJSONString(rs)); + } catch (Exception e) { + logger.info("irain 查询停车费用出错:" + e); + } + } else { + logger.info("没有查询到艾润查询费用编码"); + } + + logger.info("结束调用查询费用接口,结果=" + JSONObject.toJSONString(rs)); + + return JSONObject.toJSON(rs) + ""; + } + + /*** + * 支付完成,停车通过栏杆 + */ + + public BizResult passHandrail(String orderId) throws Exception { + BizResult bizResult = new BizResult<>(); + logger.info(" 支付完成,通知抬杆 ----start--- req=" + orderId); + Order order = Order.dao.findFirst("SELECT * FROM td_b_order t where t.order_id = ?", orderId); + if (null == order) { + logger.info(" 支付完成,通知抬杆 订单不存在 orderId=" + orderId); + bizResult.setErrorMessage(ErrorType.ORDER_NO_EXISTS, "订单不存在"); + return bizResult; + } + + if (order.getSourceType().equals(OrderTypeEnum.ORDER_SOURCE_TYPE_IN)) { + /** + * 艾润通知 + */ + bizResult = passIRail(order.getCarNumber(), order.getParkId(), order.getOrderTotalFee()); + logger.info("艾润抬杆通知 返回为: bizResult=" + JSONObject.toJSONString(bizResult)); + + } else if (order.getSourceType().equals(OrderTypeEnum.ORDER_SOURCE_TYPE_OUT)) { + /** + * 青岛 + */ + bizResult = passQD(order); + + } else { + logger.info("支付完成,通知抬杆 未知的订单来源类型: orderSourceType=" + order.getSourceType()); + bizResult.setErrorMessage(ErrorType.BIZ_ERROR, "未知的订单来源类型"); + } + + return bizResult; + + } + + /** + * 艾润抬杆设置 + */ + private BizResult passIRail(String vpl_number, String park_code, BigDecimal amount) throws Exception { + BizResult bizResult = new BizResult<>(); + //1.查询停车场关系映射表-获取艾润停车场查询费用编码 ztetis-park.irain_pkno_relation + StringBuffer sql = new StringBuffer("select a.irain_pkno1"); + sql.append(" from irain_pkno_relation a"); + sql.append(" where a.park_lotpkno = ?"); + String rs = ""; + IrainPknoRelation irainPknoRelation = new IrainPknoRelation().findFirst(sql.toString(), park_code); + + if (irainPknoRelation != null && StringKit.isNotBlank(irainPknoRelation.getIrainPkno2())) { + /**** 以下为模拟入参 实际入参 由app提供-------------------------------------*/ + Prop prop = PropKit.use("a_little_config.txt"); + Long time = System.currentTimeMillis(); + String md5 = MD5Utils.enMD5(prop.get("irain.appid") + prop.get("irain.appsecret") + time); + Map params = new HashMap<>(); + params.put("appid", prop.get("irain.appid")); + params.put("sign", md5); + params.put("timestamp", time); + params.put("vpl_number", vpl_number); + //要用进出场上报的那个编码 + params.put("park_code", irainPknoRelation.getIrainPkno2()); + params.put("amount", amount.intValue()); + + logger.info("开始通知irain 支付已经完成:" + JSONObject.toJSONString(params)); + rs = HttpClientTutorial.httpPostRequest(prop.get("irain.url") + "/pay/Issued", params); + logger.info("结束通知irain 支付已经完成::" + rs); + JSONObject result = JSONObject.parseObject(rs); + + if ("OK".equals(result.getString("message"))) { + bizResult.setData("通知成功!"); + } else { + bizResult.setErrorMessage(ErrorType.BIZ_ERROR, "通知irain 支付已经完成失败!"); + + } + return bizResult; + + } else { + logger.info("没有查询到艾润进出场上报编码"); + bizResult.setErrorMessage(ErrorType.BIZ_ERROR, "未查询到艾润进出场上报编码"); + return bizResult; + } + + } + + /** + * 青岛抬杆设置 + */ + private BizResult passQD(Order order) throws Exception { + BizResult bizResult = new BizResult<>(); + String url = PropKit.get("qd.retrun_fee_url"); + OrderDetailPark orderDetailPark = OrderDetailPark.dao.findFirst( + "SELECT * FROM td_b_order_detail_park t where t.order_id = ?", order.getOrderId()); + + Map params = new HashMap<>(); + params.put("orderCode", orderDetailPark.getRecordId()); + params.put("amount", order.getOrderTotalFee().intValue()); + params.put("orderPay", order.getOrderPayedFee().intValue()); + params.put("payType", 1); + + logger.info("开始通知irain 支付已经完成:" + JSONObject.toJSONString(params)); + String rs = HttpClientTutorial.httpPostRequest(url, JSONObject.toJSONString(params)); + logger.info("结束通知irain 支付已经完成:" + rs); + JSONObject result = JSONObject.parseObject(rs); + if ("1".equals(result.getString("status"))) { + bizResult.setData("通知成功!"); + } else { + bizResult.setErrorMessage(ErrorType.BIZ_ERROR, "通知青岛 支付已经完成失败!"); + } + return bizResult; + } + + public static void main(String[] args) { + Prop prop = PropKit.use("a_little_config.txt"); + String rs = ""; + Long time = System.currentTimeMillis(); + String md5 = MD5Utils.enMD5(prop.get("irain.appid") + prop.get("irain.appsecret") + time); + Map params = new HashMap<>(); + params.put("appid", prop.get("irain.appid")); + params.put("sign", md5); + params.put("timestamp", time); + params.put("vpl_number", "苏B1B566"); + params.put("park_code", "734861a1e8656ffa51bdd90829941ca9"); + + try { + logger.info("irain 查询停车费用入参:" + JSONObject.toJSONString(params)); + rs = HttpClientTutorial.httpPostRequest(prop.get("irain.url") + "/bill/Query", params); + logger.info("irain 查询停车费用返回:" + JSONObject.toJSONString(rs)); + } catch (Exception e) { + logger.info("irain 查询停车费用出错:" + e); + } + } } diff --git a/src/main/java/com/rnt/utils/HttpClientTutorial.java b/src/main/java/com/rnt/utils/HttpClientTutorial.java index d91e2f3..829ca00 100644 --- a/src/main/java/com/rnt/utils/HttpClientTutorial.java +++ b/src/main/java/com/rnt/utils/HttpClientTutorial.java @@ -96,17 +96,23 @@ public class HttpClientTutorial { } public static String httpPostRequest(String url, JSONObject jsonParam) throws UnsupportedEncodingException { - HttpPost httpPost = new HttpPost(url); + + return httpPostRequest(url,jsonParam.toJSONString()); + } + + public static String httpPostRequest(String url, String jsonParam) throws UnsupportedEncodingException { + HttpPost httpPost = new HttpPost(url); if (null != jsonParam) { //解决中文乱码问题 - StringEntity entity = new StringEntity(jsonParam.toString(), "utf-8"); + StringEntity entity = new StringEntity(jsonParam, "utf-8"); entity.setContentEncoding("UTF-8"); entity.setContentType("application/json"); httpPost.setEntity(entity); - } - return getResult(httpPost); - } - + } + return getResult(httpPost); + } + + public static String httpPostRequest(String url, Map headers, Map params) throws UnsupportedEncodingException { HttpPost httpPost = new HttpPost(url); diff --git a/src/main/resources/a_little_config.txt b/src/main/resources/a_little_config.txt index 3d92a11..5b1dbe1 100644 --- a/src/main/resources/a_little_config.txt +++ b/src/main/resources/a_little_config.txt @@ -40,8 +40,8 @@ zf.druid.testOnReturn=false zf.druid.testOnWhileIdle=true #Redis config -redis.host=127.0.0.1 -redis.port=6379 +redis.host=10.117.61.52 +redis.port=7001 redis.password=myredis @@ -79,6 +79,8 @@ irain.appsecret=rrr6uz3aqvutpsq2lsna0k18cea4mabw irain.aes=avakrky0gk1m7n00 irain.park_code=734861a1e8656ffa51bdd90829941ca9 +#青岛路侧数据 +qd.retrun_fee_url=http://zteits.gnway.cc:8088/RNT-ATMS-ADAPTER/pay/doPayAdvice #dubbo dubbo.application.name=rnt-wx