| @@ -81,11 +81,11 @@ public class WxCarCallBackController extends BaseController { | |||
| String tenantId = "456"; | |||
| WxPark parkQ = new WxPark(); | |||
| parkQ.setVendorType(EnumCarVendor.CAR_ETCP.getCode()); | |||
| parkQ.setParkId(etcpParkId); | |||
| parkQ.setParkingId(etcpParkId); | |||
| WxPark park = wxParkService.getByObj(parkQ); | |||
| if (park == null) { | |||
| logger.error("etcpParkInCallback: ETCP车场未找到" + etcpParkId); | |||
| //return new Result(ErrorCode.CAR_PARK_NOT_FOUND.getCode(), "ETCP车场未找到"+ etcpParkId); | |||
| return new Result(ErrorCode.CAR_PARK_NOT_FOUND.getCode(), "ETCP车场未找到"+ etcpParkId); | |||
| } else { | |||
| tenantId = park.getTenantId(); | |||
| wxCarCmdLog.setTenantId(park.getTenantId()); | |||
| @@ -150,11 +150,11 @@ public class WxCarCallBackController extends BaseController { | |||
| String etcpParkId = paramMap.get("parkId"); | |||
| WxPark parkQ = new WxPark(); | |||
| parkQ.setVendorType(EnumCarVendor.CAR_ETCP.getCode()); | |||
| parkQ.setParkId(etcpParkId); | |||
| parkQ.setParkingId(etcpParkId); | |||
| WxPark park = wxParkService.getByObj(parkQ); | |||
| if (park == null) { | |||
| logger.error("etcpParkOutCallback: ETCP车场未找到 " + etcpParkId); | |||
| //return new Result(ErrorCode.CAR_PARK_NOT_FOUND.getCode(), "ETCP车场未找到"+ etcpParkId); | |||
| return new Result(ErrorCode.CAR_PARK_NOT_FOUND.getCode(), "ETCP车场未找到"+ etcpParkId); | |||
| } else { | |||
| wxCarCmdLog.setTenantId(park.getTenantId()); | |||
| } | |||
| @@ -55,6 +55,9 @@ public class WxCarController extends BaseController { | |||
| @Autowired | |||
| WxCUserTagsService wxCUserTagsService; | |||
| @Autowired | |||
| WxCarCmdLogService wxCarCmdLogService; | |||
| private WxPark getCurrentPark(WxCUser user) { | |||
| WxPark parkQ = new WxPark(); | |||
| parkQ.setTenantId(user.getTenantId()); | |||
| @@ -500,6 +503,20 @@ public class WxCarController extends BaseController { | |||
| JSONObject retObj = JSON.parseObject(ret); | |||
| if (retObj.getIntValue("code") == 0) { | |||
| JSONObject feeObj = retObj.getJSONArray("data").getJSONObject(0); | |||
| Date currentDate = new Date(); | |||
| WxCarCmdLog wxCarCmdLog = new WxCarCmdLog(); | |||
| wxCarCmdLog.setVendorType(EnumCarVendor.CAR_ETCP.getCode()); | |||
| wxCarCmdLog.setCmdType(EnumCarCmd.CAR_ETCP_CALLBACK_UNPAY.getCode()); | |||
| String feeStr = JSON.toJSONString(feeObj); | |||
| wxCarCmdLog.setCmdJson(feeStr); | |||
| wxCarCmdLog.setCreateDate(currentDate); | |||
| wxCarCmdLog.setUpdateDate(currentDate); | |||
| try { | |||
| wxCarCmdLogService.saveOrUpdate(wxCarCmdLog); | |||
| } catch (Exception e) { | |||
| logger.error("etcpOrderUnpay: 入库错误:" + feeStr); | |||
| return new ResultData(ErrorCode.DB_FAIL.getCode(), "入库错误", feeStr); | |||
| } | |||
| return new ResultData(Result.SUCCESS, "停车费获取成功", feeObj); | |||
| } else { | |||
| String message = retObj.getString("message"); | |||
| @@ -711,13 +728,41 @@ public class WxCarController extends BaseController { | |||
| String merchantNo = objParams.getString("merchantNo"); | |||
| String merchantKey = objParams.getString("merchantKey"); | |||
| String version = objParams.getString("version"); | |||
| if (park.getParkingId() == null) { | |||
| String lat = objParams.getString("lat"); | |||
| String lon = objParams.getString("lon"); | |||
| String radius = objParams.getString("radius"); | |||
| String ret = etcp.parkingInfo(url, merchantNo, merchantKey, version, lat, lon, radius); | |||
| logger.info(ret); | |||
| JSONObject retObj = JSON.parseObject(ret); | |||
| if (retObj.getIntValue("code") == EnumETCPCode.SUCCESS.getCode()) { | |||
| JSONObject retData = retObj.getJSONObject("data"); | |||
| if (retData != null) { | |||
| JSONArray retDataList = retData.getJSONArray("list"); | |||
| if (retDataList != null) { | |||
| JSONObject parkData = retDataList.getJSONObject(0); | |||
| if (parkData != null) { | |||
| String parkId = parkData.getString("id"); | |||
| objParams.put("parkId", parkId); | |||
| params = JSON.toJSONString(objParams); | |||
| park.setVendorParams(params); | |||
| park.setParkingId(parkId); | |||
| wxParkService.saveOrUpdate(park); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| } | |||
| if (park.getParkingId() != null) { | |||
| String ret = etcp.parkingStatus(url, merchantNo, merchantKey, version, park.getParkingId()); | |||
| String ret = etcp.parkingStatus(url, merchantNo, merchantKey, version, park.getParkId()); | |||
| JSONObject retObj = JSON.parseObject(ret); | |||
| if (retObj.getIntValue("code") == EnumETCPCode.SUCCESS.getCode()) { | |||
| return new ResultData(retObj.getJSONArray("data").getJSONObject(0)); | |||
| JSONObject retObj = JSON.parseObject(ret); | |||
| if (retObj.getIntValue("code") == EnumETCPCode.SUCCESS.getCode()) { | |||
| if (retObj.get("data") != null) { | |||
| return new ResultData(retObj.getJSONObject("data")); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| return new ResultData(ErrorCode.CAR_VENDOR_NOT_SUPPORT.getCode(), "车场不支持"); | |||
| @@ -41,37 +41,40 @@ public class WxPark implements Serializable { | |||
| /*租户ID**/ | |||
| /**租户ID**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="租户ID",name="tenantId") | |||
| private String tenantId; | |||
| /*停车场图片**/ | |||
| /**停车场图片**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="停车场图片",name="imgUrl") | |||
| private String imgUrl; | |||
| /*停车场地址**/ | |||
| /**停车场地址**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="停车场地址",name="addr") | |||
| private String addr; | |||
| /*车位数**/ | |||
| /**车位数**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="车位数",name="number") | |||
| private Integer number; | |||
| /*出入口数量**/ | |||
| /**出入口数量**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="出入口数量",name="entryExit") | |||
| private Integer entryExit; | |||
| /*停车费**/ | |||
| /**停车费**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="停车费",name="stopFee") | |||
| private String stopFee; | |||
| /*创建时间**/ | |||
| /**创建时间**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate") | |||
| private Date createDate; | |||
| /*更新时间**/ | |||
| /**更新时间**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate") | |||
| private Date updateDate; | |||
| /*第三方停车场ID**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="第三方停车场ID",name="parkId") | |||
| /**第三方停车场ID(密文)**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="第三方停车场ID(密文)",name="parkId") | |||
| private String parkId; | |||
| /*厂商类型(1:ETCP,2:停简单)**/ | |||
| /**第三方停车场ID(明文)**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="第三方停车场ID(明文)",name="parkingId") | |||
| private String parkingId; | |||
| /**厂商类型(1:ETCP,2:停简单)**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="厂商类型(1:ETCP,2:停简单)",name="vendorType") | |||
| private Integer vendorType; | |||
| /*厂商参数etcp{"url":"http://mapi.test.etcp.cn","appId":"FMLK","merchantNo":"C7AEAF80BA8C44ADB42F3DB3CBC7D18A","merchantKey":"C292FFC7DCFB46AFB02792CD43F6DCC7","version": "1.0.0","parkId":"Wj7YdvqyiYM="},TJD{"url":"http://prep.tingjiandan.com/openapi/gateway","partner":"7dbc8ec9037d403b822cb60addfdc681","key":"f356cb1bf5a74fb7a564e86128d2c49f","version":"1.0"}**/ | |||
| /**厂商参数etcp{"url":"http://mapi.test.etcp.cn","appId":"FMLK","merchantNo":"C7AEAF80BA8C44ADB42F3DB3CBC7D18A","merchantKey":"C292FFC7DCFB46AFB02792CD43F6DCC7","version": "1.0.0","parkId":"Wj7YdvqyiYM="},TJD{"url":"http://prep.tingjiandan.com/openapi/gateway","partner":"7dbc8ec9037d403b822cb60addfdc681","key":"f356cb1bf5a74fb7a564e86128d2c49f","version":"1.0"}**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="厂商参数etcp{\"url\":\"http://mapi.test.etcp.cn\",\"appId\":\"FMLK\",\"merchantNo\":\"C7AEAF80BA8C44ADB42F3DB3CBC7D18A\",\"merchantKey\":\"C292FFC7DCFB46AFB02792CD43F6DCC7\",\"version\": \"1.0.0\",\"parkId\":\"Wj7YdvqyiYM=\"},TJD{\"url\":\"http://prep.tingjiandan.com/openapi/gateway\",\"partner\":\"7dbc8ec9037d403b822cb60addfdc681\",\"key\":\"f356cb1bf5a74fb7a564e86128d2c49f\",\"version\":\"1.0\"}",name="vendorParams") | |||
| private String vendorParams; | |||
| public String getTenantId() { | |||
| @@ -134,6 +137,15 @@ public class WxPark implements Serializable { | |||
| public void setParkId(String _parkId) { | |||
| parkId = _parkId; | |||
| } | |||
| public String getParkingId() { | |||
| return parkingId; | |||
| } | |||
| public void setParkingId(String parkingId) { | |||
| this.parkingId = parkingId; | |||
| } | |||
| public Integer getVendorType() { | |||
| return vendorType; | |||
| } | |||
| @@ -159,6 +171,7 @@ public class WxPark implements Serializable { | |||
| ,CreateDate_ASC("`create_date` ASC"),CreateDate_DESC("`create_date` DESC") | |||
| ,UpdateDate_ASC("`update_date` ASC"),UpdateDate_DESC("`update_date` DESC") | |||
| ,ParkId_ASC("`park_id` ASC"),ParkId_DESC("`park_id` DESC") | |||
| ,ParkingId_ASC("`parking_id` ASC"),ParkingId_DESC("`parking_id` DESC") | |||
| ,VendorType_ASC("`vendor_type` ASC"),VendorType_DESC("`vendor_type` DESC") | |||
| ,VendorParams_ASC("`vendor_params` ASC"),VendorParams_DESC("`vendor_params` DESC") | |||
| ; | |||
| @@ -9,7 +9,8 @@ public enum EnumCarCmd { | |||
| CAR_ETCP_CALLBACK_PARK_IN(601, "ETCP入场通知"), | |||
| CAR_ETCP_CALLBACK_PARK_OUT(602, "ETCP出场通知"), | |||
| CAR_ETCP_CALLBACK_UNBIND(603, "ETCP车辆解绑通知"), | |||
| CAR_ETCP_CALLBACK_PAY_MANUAL(604, "主动支付结果通知"), | |||
| CAR_ETCP_CALLBACK_PAY_MANUAL(604, "支付结果通知"), | |||
| CAR_ETCP_CALLBACK_UNPAY(605, "停车费获取"), | |||
| CAR_TJD_CALLBACK_PARK_IN(610, "停简单入场通知"), | |||
| CAR_TJD_CALLBACK_PARK_OUT(611, "停简单出场通知"), | |||
| ; | |||
| @@ -611,6 +611,29 @@ public class ETCPUtil { | |||
| data, sign, timeStamp, merchantNo); | |||
| } | |||
| /** | |||
| * 11.1. 车场信息查询 | |||
| * | |||
| * @param lat, lon, radius | |||
| * @return 车场信息查询 | |||
| */ | |||
| public String parkingInfo(String baseUrl, | |||
| String merchantNo, String merchantKey, String version, | |||
| String lat, String lon, String radius) { | |||
| JSONObject jsonObject = new JSONObject(); | |||
| jsonObject.put("lat", lat); | |||
| jsonObject.put("lon", lon); | |||
| jsonObject.put("radius", radius); | |||
| jsonObject.put("payType", "1"); // 1:电子支付 | |||
| String data = jsonObject.toJSONString(); | |||
| String timeStamp = dateTimeFormatter.format(LocalDateTime.now()); | |||
| String sign = genSign(data, merchantKey, timeStamp); | |||
| return doPost(baseUrl + parkingInfoUrl.replaceAll("\\{version}", version), | |||
| data, sign, timeStamp, merchantNo); | |||
| } | |||
| /** | |||
| * 11.2. 车场状态查询 | |||
| * | |||
| @@ -1,102 +1,95 @@ | |||
| <?xml version="1.0" encoding="UTF-8"?> | |||
| <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |||
| <mapper namespace="com.iformall.mapper.WxParkMapper"> | |||
| <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxPark"> | |||
| <id column="id" jdbcType="BIGINT" property="id" /> | |||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" /> | |||
| <result column="img_url" jdbcType="VARCHAR" property="imgUrl" /> | |||
| <result column="addr" jdbcType="VARCHAR" property="addr" /> | |||
| <result column="number" jdbcType="INTEGER" property="number" /> | |||
| <result column="entry_exit" jdbcType="INTEGER" property="entryExit" /> | |||
| <result column="stop_fee" jdbcType="VARCHAR" property="stopFee" /> | |||
| <result column="create_date" jdbcType="TIMESTAMP" property="createDate" /> | |||
| <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" /> | |||
| <result column="park_id" jdbcType="VARCHAR" property="parkId" /> | |||
| <result column="vendor_type" jdbcType="INTEGER" property="vendorType" /> | |||
| <result column="vendor_params" jdbcType="VARCHAR" property="vendorParams" /> | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `id`,`tenant_id`,`img_url`,`addr`,`number`,`entry_exit`,`stop_fee`,`create_date`,`update_date`,`park_id`,`vendor_type`,`vendor_params` | |||
| </sql> | |||
| <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxPark"> | |||
| <id column="id" jdbcType="BIGINT" property="id"/> | |||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/> | |||
| <result column="img_url" jdbcType="VARCHAR" property="imgUrl"/> | |||
| <result column="addr" jdbcType="VARCHAR" property="addr"/> | |||
| <result column="number" jdbcType="INTEGER" property="number"/> | |||
| <result column="entry_exit" jdbcType="INTEGER" property="entryExit"/> | |||
| <result column="stop_fee" jdbcType="VARCHAR" property="stopFee"/> | |||
| <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/> | |||
| <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/> | |||
| <result column="park_id" jdbcType="VARCHAR" property="parkId"/> | |||
| <result column="parking_id" jdbcType="VARCHAR" property="parkingId"/> | |||
| <result column="vendor_type" jdbcType="INTEGER" property="vendorType"/> | |||
| <result column="vendor_params" jdbcType="VARCHAR" property="vendorParams"/> | |||
| </resultMap> | |||
| <sql id="dynamicWhereConditions"> | |||
| where 1 = 1 | |||
| <if test=" null != id "> | |||
| and `id` = #{id} | |||
| </if> | |||
| <if test=" null != tenantId "> | |||
| and `tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != imgUrl "> | |||
| and `imgUrl` like concat('%', #{imgUrl},'%') | |||
| </if> | |||
| <if test=" null != addr "> | |||
| and `addr` like concat('%', #{addr},'%') | |||
| </if> | |||
| <if test=" null != number "> | |||
| and `number` = #{number} | |||
| </if> | |||
| <if test=" null != entryExit "> | |||
| and `entry_exit` = #{entryExit} | |||
| </if> | |||
| <if test=" null != stopFee "> | |||
| and `stop_fee` = #{stopFee} | |||
| </if> | |||
| <if test=" null != createDate "> | |||
| and `create_date` = #{createDate} | |||
| </if> | |||
| <if test=" null != updateDate "> | |||
| and `update_date` = #{updateDate} | |||
| </if> | |||
| <if test=" null != parkId "> | |||
| and `park_id` like concat('%', #{parkId},'%') | |||
| </if> | |||
| <if test=" null != vendorType "> | |||
| and `vendor_type` = #{vendorType} | |||
| </if> | |||
| <if test=" null != vendorParams "> | |||
| and `vendor_params` like concat('%', #{vendorParams},'%') | |||
| </if> | |||
| <if test=" null != ids "> | |||
| and id in | |||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||
| #{idItem} | |||
| </foreach> | |||
| </if> | |||
| <if test=" null != sortColumns"> order by ${sortColumns} </if> | |||
| <sql id="allColumns"> | |||
| `id`,`tenant_id`,`img_url`,`addr`,`number`,`entry_exit`,`stop_fee`,`create_date`,`update_date`,`park_id`,`parking_id`,`vendor_type`,`vendor_params` | |||
| </sql> | |||
| <select id="findList" parameterType="com.iformall.domain.po.WxPark" resultMap="BaseResultMap"> | |||
| select <include refid="allColumns" /> from wx_park | |||
| <include refid="dynamicWhereConditions" /> | |||
| </select> | |||
| <sql id="dynamicWhereConditions"> | |||
| where 1 = 1 | |||
| <if test=" null != id "> | |||
| and `id` = #{id} | |||
| </if> | |||
| <if test=" null != tenantId "> | |||
| and `tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != imgUrl "> | |||
| and `imgUrl` like concat('%', #{imgUrl},'%') | |||
| </if> | |||
| <if test=" null != addr "> | |||
| and `addr` like concat('%', #{addr},'%') | |||
| </if> | |||
| <if test=" null != number "> | |||
| and `number` = #{number} | |||
| </if> | |||
| <if test=" null != entryExit "> | |||
| and `entry_exit` = #{entryExit} | |||
| </if> | |||
| <if test=" null != stopFee "> | |||
| and `stop_fee` = #{stopFee} | |||
| </if> | |||
| <if test=" null != createDate "> | |||
| and `create_date` = #{createDate} | |||
| </if> | |||
| <if test=" null != updateDate "> | |||
| and `update_date` = #{updateDate} | |||
| </if> | |||
| <if test=" null != parkId "> | |||
| and `park_id` = #{parkId} | |||
| </if> | |||
| <if test=" null != parkingId "> | |||
| and `parking_id` = #{parkingId} | |||
| </if> | |||
| <if test=" null != vendorType "> | |||
| and `vendor_type` = #{vendorType} | |||
| </if> | |||
| <if test=" null != vendorParams "> | |||
| and `vendor_params` like concat('%', #{vendorParams},'%') | |||
| </if> | |||
| <if test=" null != ids "> | |||
| and id in | |||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||
| #{idItem} | |||
| </foreach> | |||
| </if> | |||
| <if test=" null != sortColumns">order by ${sortColumns}</if> | |||
| </sql> | |||
| <select id="findList" parameterType="com.iformall.domain.po.WxPark" resultMap="BaseResultMap"> | |||
| select | |||
| <include refid="allColumns"/> | |||
| from wx_park | |||
| <include refid="dynamicWhereConditions"/> | |||
| </select> | |||
| </mapper> | |||