e80df919
atao
init
|
1
2
|
package com.rnt.service;
|
b95f41af
atao
提交代码
|
3
|
import java.math.BigDecimal;
|
e80df919
atao
init
|
4
5
6
7
8
|
import java.util.HashMap;
import java.util.Map;
import org.beetl.sql.core.kit.StringKit;
|
e80df919
atao
init
|
9
|
import com.alibaba.fastjson.JSONObject;
|
e80df919
atao
init
|
10
11
12
|
import com.jfinal.kit.Prop;
import com.jfinal.kit.PropKit;
import com.jfinal.log.Log;
|
b95f41af
atao
提交代码
|
13
14
|
import com.rnt.commo.enums.ErrorType;
import com.rnt.commo.enums.OrderTypeEnum;
|
e80df919
atao
init
|
15
|
import com.rnt.model.park.IrainPknoRelation;
|
b95f41af
atao
提交代码
|
16
17
|
import com.rnt.model.zf.Order;
import com.rnt.model.zf.OrderDetailPark;
|
e80df919
atao
init
|
18
19
|
import com.rnt.utils.HttpClientTutorial;
import com.rnt.utils.MD5Utils;
|
b95f41af
atao
提交代码
|
20
|
import com.rnt.vo.BizResult;
|
6040c55c
王富生
提交
|
21
|
import com.rnt.vo.RoadsideRequest;
|
e80df919
atao
init
|
22
23
24
|
/**
* 艾润费用查询service.<br/>
|
b95f41af
atao
提交代码
|
25
|
*
|
e80df919
atao
init
|
26
|
* Copyright: Copyright (c) 2017 zteits
|
b95f41af
atao
提交代码
|
27
|
*
|
e80df919
atao
init
|
28
|
* @ClassName: IRainQueryService.java
|
b95f41af
atao
提交代码
|
29
|
* @Description:
|
e80df919
atao
init
|
30
31
|
* @version: v1.0.0
* @author: wangfs
|
b95f41af
atao
提交代码
|
32
|
* @date: 2017年6月13日 上午9:25:31
|
e80df919
atao
init
|
33
34
|
* Modification History:
* Date Author Version Description
|
b95f41af
atao
提交代码
|
35
|
* ---------------------------------------------------------*
|
e80df919
atao
init
|
36
37
38
|
* 2017年6月13日 wangfs v1.0.0 创建
*/
public class IRainQueryService {
|
b95f41af
atao
提交代码
|
39
|
private static final Log logger = Log.getLog(IRainQueryService.class);
|
e80df919
atao
init
|
40
41
42
43
44
45
46
|
/**
* 调用艾润查询费用接口.<br/>
* @param carNum
* @param parkCode
* @return
*/
|
44ea6641
王富生
提交
|
47
48
|
public Map<String, String> billQuery(String carNum,String parkCode) {
logger.info("---begin调用艾润查询费用接口,入参={carNum,parkCode}="+"{"+carNum+","+parkCode+"}");
|
e80df919
atao
init
|
49
50
51
52
53
|
//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 = "";
|
44ea6641
王富生
提交
|
54
|
Map<String, String> map = new HashMap<String, String>();
|
e80df919
atao
init
|
55
|
IrainPknoRelation irainPknoRelation = new IrainPknoRelation().findFirst(sql.toString(), parkCode);
|
44ea6641
王富生
提交
|
56
|
logger.info("获取查询费用编码数据结果="+JSONObject.toJSON(irainPknoRelation));
|
e80df919
atao
init
|
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
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<String, Object> 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));
|
44ea6641
王富生
提交
|
73
74
75
76
77
78
|
if (StringKit.isNotBlank(rs) && !"NO_PARK_RECORD".equals(JSONObject.parseObject(rs).get("code"))) {
map = this.jsonToMapForIrunResult(rs);
}else{
logger.info("调用艾润费用查询接口:无停车记录");
}
|
e80df919
atao
init
|
79
80
81
82
83
84
85
|
} catch (Exception e) {
logger.info("irain 查询停车费用出错:" + e);
}
}else{
logger.info("没有查询到艾润查询费用编码");
}
|
44ea6641
王富生
提交
|
86
|
logger.info("---end调用艾润查询费用接口,结果="+JSONObject.toJSON(map));
|
e80df919
atao
init
|
87
88
|
|
44ea6641
王富生
提交
|
89
|
return map;
|
e80df919
atao
init
|
90
|
}
|
e5b4babd
王富生
提交
|
91
|
|
44ea6641
王富生
提交
|
92
93
94
95
96
97
98
|
/**
* 青岛路侧费用查询接口.<br/>
* @param recordId
* @return
*/
public static Map<String, String> queryBillRoadside(String recordId){
logger.info("---begin调用青岛路侧费用查询接口,入参={recordId}="+"{"+recordId+"}");
|
e5b4babd
王富生
提交
|
99
|
Prop prop = PropKit.use("a_little_config.txt");
|
44ea6641
王富生
提交
|
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
Map<String, Object> params = new HashMap<>();
Long time = System.currentTimeMillis();
params.put("orderCode", recordId);
params.put("timestamp",time);
Map<String, String> rsMap = new HashMap<String, String>();
try{
String qingdaors = HttpClientTutorial.httpPostRequest(prop.get("qindao.url")+"", JSONObject.toJSONString(params));
logger.info("青岛路侧查询停车费用返回:" + JSONObject.toJSONString(qingdaors));
RoadsideRequest roadsideRequest = JSONObject.parseObject(qingdaors,RoadsideRequest.class);
logger.info("青岛路侧返回JSON转换对象结果"+JSONObject.toJSON(roadsideRequest));
if(roadsideRequest != null){
rsMap.put("record_id", roadsideRequest.getOrderCode());
// 出场时间
rsMap.put("park_out_time", roadsideRequest.getOuttime());
//入场时间
rsMap.put("park_in_time", roadsideRequest.getIntime());
//总费用
rsMap.put("order_total_fee", roadsideRequest.getOrderPay() != null ? roadsideRequest.getOrderPay().toString() :"1");
//已付费用
rsMap.put("order_payed_fee", "0");
//未支付费用(本次应付金额)
rsMap.put("order_not_pay_fee", roadsideRequest.getOrderPay() != null ? roadsideRequest.getOrderPay().toString() :"1");
//停车时长 单位:秒
rsMap.put("parking_duration",roadsideRequest.getStaytime() != null ? String.valueOf(roadsideRequest.getStaytime()) :"1");
//停车场名车
rsMap.put("park_name", roadsideRequest.getParkName());
}
}catch (Exception e) {
e.printStackTrace();
}
logger.info("---end调用青岛路侧费用查询接口,结果="+JSONObject.toJSON(rsMap));
return rsMap;
}
|
6040c55c
王富生
提交
|
135
136
137
|
public static void main(String[] args) {
queryBillRoadside("869775012497209-170030-2017-05-31 09:10:00");
}
|
44ea6641
王富生
提交
|
138
139
140
141
142
143
144
|
/**
* 获取查询费用返回结果.<br/>
*
* @param json
* @return
*/
|
e09659a0
王富生
Merge branch 'mas...
|
145
|
private Map<String, String> jsonToMapForIrunResult(String json) {
|
44ea6641
王富生
提交
|
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
|
JSONObject jsobj = JSONObject.parseObject(json);
Map<String, String> map = new HashMap<String, String>();
if (jsobj != null) {
if (!jsobj.get("status").toString().equals("0")) {
JSONObject data = (JSONObject)jsobj.get("data");
// 出场时间对象
JSONObject parkOutObject = (JSONObject)data.get("out");
//停车记录id
map.put("record_id", data.getString("id"));
// 出场时间
map.put("park_out_time", parkOutObject.getString("time"));
if (data.get("park") != null) {
map.put("park_name", JSONObject.parseObject(data.get("park").toString()).get("name") + "");
map.put("park_address", JSONObject.parseObject(data.get("park").toString()).get("address") + "");
}
//入场时间
if (data.get("in") != null) {
map.put("park_in_time", JSONObject.parseObject(data.get("in").toString()).getString("time"));
}
//总费用
map.put("order_total_fee", JSONObject.parseObject(data.get("charge").toString()).getString("due"));
//已付费用
map.put("order_payed_fee", JSONObject.parseObject(data.get("charge").toString()).getString("paid"));
//未支付费用(本次应付金额)
map.put("order_not_pay_fee", JSONObject.parseObject(data.get("charge").toString()).getString("unpaid"));
//停车时长 单位:秒
map.put("parking_duration",
JSONObject.parseObject(data.get("charge").toString()).getString("duration"));
}
}
return map;
}
|
6040c55c
王富生
提交
|
181
|
|
e09659a0
王富生
Merge branch 'mas...
|
182
|
|
b95f41af
atao
提交代码
|
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
|
/***
* 支付完成,停车通过栏杆
*/
public BizResult<String> passHandrail(String orderId) throws Exception {
BizResult<String> 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<String> passIRail(String vpl_number, String park_code, BigDecimal amount) throws Exception {
BizResult<String> 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<String, Object> 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<String> passQD(Order order) throws Exception {
BizResult<String> 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<String, Object> 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;
}
|
e09659a0
王富生
Merge branch 'mas...
|
293
|
|
e80df919
atao
init
|
294
|
}
|