|
@@ -10,7 +10,9 @@ import com.sunyo.energy.location.service.ElectricityMeterService; |
|
@@ -10,7 +10,9 @@ import com.sunyo.energy.location.service.ElectricityMeterService; |
10
|
import com.sunyo.energy.location.service.WaterMeterService;
|
10
|
import com.sunyo.energy.location.service.WaterMeterService;
|
11
|
import com.sunyo.energy.location.websocket.WebSocketServer;
|
11
|
import com.sunyo.energy.location.websocket.WebSocketServer;
|
12
|
import io.swagger.annotations.ApiOperation;
|
12
|
import io.swagger.annotations.ApiOperation;
|
|
|
13
|
+import lombok.extern.slf4j.Slf4j;
|
13
|
import org.springframework.beans.factory.annotation.Autowired;
|
14
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
15
|
+import org.springframework.stereotype.Controller;
|
14
|
import org.springframework.web.bind.annotation.RequestMapping;
|
16
|
import org.springframework.web.bind.annotation.RequestMapping;
|
15
|
import org.springframework.web.bind.annotation.RequestParam;
|
17
|
import org.springframework.web.bind.annotation.RequestParam;
|
16
|
import org.springframework.web.bind.annotation.ResponseBody;
|
18
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
@@ -21,7 +23,9 @@ import java.util.Date; |
|
@@ -21,7 +23,9 @@ import java.util.Date; |
21
|
import java.util.UUID;
|
23
|
import java.util.UUID;
|
22
|
|
24
|
|
23
|
|
25
|
|
|
|
26
|
+@Slf4j
|
24
|
@RequestMapping("/payCode")
|
27
|
@RequestMapping("/payCode")
|
|
|
28
|
+@Controller
|
25
|
public class PayRseponeController {
|
29
|
public class PayRseponeController {
|
26
|
|
30
|
|
27
|
|
31
|
|
|
@@ -79,6 +83,7 @@ public class PayRseponeController { |
|
@@ -79,6 +83,7 @@ public class PayRseponeController { |
79
|
@RequestParam(value = "PAYTYPE", required = false) String PAYTYPE,
|
83
|
@RequestParam(value = "PAYTYPE", required = false) String PAYTYPE,
|
80
|
@RequestParam(value = "SIGN", required = false) String SIGN) throws IOException {
|
84
|
@RequestParam(value = "SIGN", required = false) String SIGN) throws IOException {
|
81
|
|
85
|
|
|
|
86
|
+ log.info("接受建行返回信息");
|
82
|
PayResponse payResponse = new PayResponse();
|
87
|
PayResponse payResponse = new PayResponse();
|
83
|
payResponse.setId(UUID.randomUUID().toString());
|
88
|
payResponse.setId(UUID.randomUUID().toString());
|
84
|
payResponse.setPosid(POSID);
|
89
|
payResponse.setPosid(POSID);
|
|
@@ -98,75 +103,99 @@ public class PayRseponeController { |
|
@@ -98,75 +103,99 @@ public class PayRseponeController { |
98
|
payResponse.setUsrinfo(USRINFO);
|
103
|
payResponse.setUsrinfo(USRINFO);
|
99
|
payResponse.setPaytype(PAYTYPE);
|
104
|
payResponse.setPaytype(PAYTYPE);
|
100
|
payResponse.setSign(SIGN);
|
105
|
payResponse.setSign(SIGN);
|
101
|
- int msg = 0;
|
|
|
102
|
- int i = payResponseMapperl.insertSelective(payResponse);
|
|
|
103
|
- if (i > 0) {
|
|
|
104
|
- msg = 1;
|
|
|
105
|
- PayRecords payRecords = new PayRecords();
|
|
|
106
|
- // 支付类型
|
|
|
107
|
- if (!"".equals(ACC_TYPE)) {
|
|
|
108
|
- if ("WX".equals(ACC_TYPE)) {
|
|
|
109
|
- payRecords.setPayfesstype(false);
|
106
|
+ try {
|
|
|
107
|
+ int msg = 0;
|
|
|
108
|
+ int i = payResponseMapperl.insertSelective(payResponse);
|
|
|
109
|
+ log.info("插入数据库{},信息{}",i, payResponse);
|
|
|
110
|
+ if (i > 0) {
|
|
|
111
|
+ msg = 1;
|
|
|
112
|
+ PayRecords payRecords = new PayRecords();
|
|
|
113
|
+ // 支付类型
|
|
|
114
|
+ if (!"".equals(ACC_TYPE)) {
|
|
|
115
|
+ if ("WX".equals(ACC_TYPE)) {
|
|
|
116
|
+ payRecords.setPayfesstype(false);
|
|
|
117
|
+ } else {
|
|
|
118
|
+ payRecords.setPayfesstype(true);
|
|
|
119
|
+ }
|
|
|
120
|
+
|
|
|
121
|
+ }
|
|
|
122
|
+ if ("Y".equals(SUCCESS)) {
|
|
|
123
|
+ payRecords.setOrdernumber(ORDERID);
|
|
|
124
|
+ payRecords.setReamke3("1");
|
110
|
} else {
|
125
|
} else {
|
111
|
- payRecords.setPayfesstype(true);
|
126
|
+ payRecords.setOrdernumber(ORDERID);
|
|
|
127
|
+ payRecords.setReamke3("0");
|
112
|
}
|
128
|
}
|
|
|
129
|
+ /**
|
|
|
130
|
+ * 修改订单支付状态
|
|
|
131
|
+ */
|
|
|
132
|
+ payRecordsMapper.updateOrderStatus(payRecords);
|
113
|
|
133
|
|
114
|
- }
|
|
|
115
|
- if ("Y".equals(SUCCESS)) {
|
|
|
116
|
- payRecords.setOrdernumber(ORDERID);
|
|
|
117
|
- payRecords.setReamke3("1");
|
|
|
118
|
- } else {
|
|
|
119
|
- payRecords.setOrdernumber(ORDERID);
|
|
|
120
|
- payRecords.setReamke3("0");
|
|
|
121
|
- }
|
|
|
122
|
-
|
|
|
123
|
- // 查询是水还是电
|
|
|
124
|
- boolean selectType = payRecordsMapper.selectType(ORDERID);
|
|
|
125
|
- if (selectType) {
|
|
|
126
|
- // 查询该订单设备编号
|
|
|
127
|
- String eeId = payRecordsMapper.findOrderNumber(ORDERID);
|
|
|
128
|
- if (!"".equals(eeId)) {
|
|
|
129
|
- // 通知充值电费
|
|
|
130
|
- int eeResult = electricityMeterService.rechargeDevices(eeId, PAYMENT, "0", ORDERID);
|
|
|
131
|
- if (eeResult > 0) {
|
|
|
132
|
- // 修改订单状态
|
|
|
133
|
- int i1 = payRecordsMapper.updateByPrimaryKey(payRecords);
|
|
|
134
|
- if (i1 > 0) {
|
|
|
135
|
- WebSocketServer webSocketServer = new WebSocketServer();
|
|
|
136
|
- JSONObject jsonObject = new JSONObject();
|
|
|
137
|
- jsonObject.put("orderNumber", ORDERID);
|
|
|
138
|
- jsonObject.put("success", "Y");
|
|
|
139
|
- webSocketServer.broadcast(jsonObject.toJSONString());
|
134
|
+ // 查询是水还是电
|
|
|
135
|
+ boolean selectType = payRecordsMapper.selectType(ORDERID);
|
|
|
136
|
+ if (selectType) {
|
|
|
137
|
+ // 查询该订单设备编号
|
|
|
138
|
+ String eeId = payRecordsMapper.findOrderNumber(ORDERID);
|
|
|
139
|
+ if (!"".equals(eeId)) {
|
|
|
140
|
+ // 通知充值电费
|
|
|
141
|
+ int eeResult = electricityMeterService.rechargeDevices(eeId, PAYMENT, "0", ORDERID);
|
|
|
142
|
+ if (eeResult > 0) {
|
|
|
143
|
+ log.info("电表信息充值成功{}",eeResult);
|
|
|
144
|
+ /**
|
|
|
145
|
+ * 修改电表充值状态
|
|
|
146
|
+ */
|
|
|
147
|
+ int i1 = payRecordsMapper.updateByPrimaryKey(payRecords);
|
|
|
148
|
+ log.info("修改电表订单状态{}, 修改信息{}", i1, payRecords);
|
|
|
149
|
+ if (i1 > 0) {
|
|
|
150
|
+ WebSocketServer webSocketServer = new WebSocketServer();
|
|
|
151
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
152
|
+ jsonObject.put("orderNumber", ORDERID);
|
|
|
153
|
+ jsonObject.put("success", "Y");
|
|
|
154
|
+ webSocketServer.broadcast(jsonObject.toJSONString());
|
|
|
155
|
+ log.info("通知前端消息结果");
|
|
|
156
|
+ } else {
|
|
|
157
|
+ WebSocketServer webSocketServer = new WebSocketServer();
|
|
|
158
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
159
|
+ jsonObject.put("orderNumber", ORDERID);
|
|
|
160
|
+ jsonObject.put("success", "N");
|
|
|
161
|
+ webSocketServer.broadcast(jsonObject.toJSONString());
|
|
|
162
|
+ }
|
140
|
} else {
|
163
|
} else {
|
141
|
WebSocketServer webSocketServer = new WebSocketServer();
|
164
|
WebSocketServer webSocketServer = new WebSocketServer();
|
142
|
JSONObject jsonObject = new JSONObject();
|
165
|
JSONObject jsonObject = new JSONObject();
|
143
|
jsonObject.put("orderNumber", ORDERID);
|
166
|
jsonObject.put("orderNumber", ORDERID);
|
144
|
- jsonObject.put("success", "N");
|
167
|
+ jsonObject.put("success", "S");
|
145
|
webSocketServer.broadcast(jsonObject.toJSONString());
|
168
|
webSocketServer.broadcast(jsonObject.toJSONString());
|
146
|
}
|
169
|
}
|
147
|
- } else {
|
|
|
148
|
- WebSocketServer webSocketServer = new WebSocketServer();
|
|
|
149
|
- JSONObject jsonObject = new JSONObject();
|
|
|
150
|
- jsonObject.put("orderNumber", ORDERID);
|
|
|
151
|
- jsonObject.put("success", "S");
|
|
|
152
|
- webSocketServer.broadcast(jsonObject.toJSONString());
|
|
|
153
|
}
|
170
|
}
|
154
|
- }
|
|
|
155
|
- } else {
|
|
|
156
|
- // 查询该订单设备编号
|
|
|
157
|
- String wmId = payRecordsMapper.findOrderNumber(ORDERID);
|
|
|
158
|
- // 通知充值水费
|
|
|
159
|
- if (!"".equals(wmId)) {
|
|
|
160
|
- ResultJson resultJson = waterMeterService.payWater(PAYMENT, wmId);
|
|
|
161
|
- if ("200".equals(resultJson.getCode())) {
|
|
|
162
|
- // 修改订单状态
|
|
|
163
|
- int i1 = payRecordsMapper.updateByPrimaryKey(payRecords);
|
|
|
164
|
- if (i1 > 0) {
|
|
|
165
|
- WebSocketServer webSocketServer = new WebSocketServer();
|
|
|
166
|
- JSONObject jsonObject = new JSONObject();
|
|
|
167
|
- jsonObject.put("orderNumber", ORDERID);
|
|
|
168
|
- jsonObject.put("success", "Y");
|
|
|
169
|
- webSocketServer.broadcast(jsonObject.toJSONString());
|
171
|
+ } else {
|
|
|
172
|
+ // 查询该订单设备编号
|
|
|
173
|
+ String wmId = payRecordsMapper.findOrderNumber(ORDERID);
|
|
|
174
|
+ // 通知充值水费
|
|
|
175
|
+ if (!"".equals(wmId)) {
|
|
|
176
|
+ ResultJson resultJson = waterMeterService.payWater(PAYMENT, wmId);
|
|
|
177
|
+ if ("200".equals(resultJson.getCode())) {
|
|
|
178
|
+ log.info("水表信息充值成功{}",resultJson.getCode());
|
|
|
179
|
+ /**
|
|
|
180
|
+ * 修改订单充值状态
|
|
|
181
|
+ */
|
|
|
182
|
+ int i1 = payRecordsMapper.updateByPrimaryKey(payRecords);
|
|
|
183
|
+ log.info("修改水表订单状态{}, 修改信息{}", i1, payRecords);
|
|
|
184
|
+ if (i1 > 0) {
|
|
|
185
|
+
|
|
|
186
|
+ WebSocketServer webSocketServer = new WebSocketServer();
|
|
|
187
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
188
|
+ jsonObject.put("orderNumber", ORDERID);
|
|
|
189
|
+ jsonObject.put("success", "Y");
|
|
|
190
|
+ webSocketServer.broadcast(jsonObject.toJSONString());
|
|
|
191
|
+ log.info("通知前端消息结果");
|
|
|
192
|
+ } else {
|
|
|
193
|
+ WebSocketServer webSocketServer = new WebSocketServer();
|
|
|
194
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
195
|
+ jsonObject.put("orderNumber", ORDERID);
|
|
|
196
|
+ jsonObject.put("success", "N");
|
|
|
197
|
+ webSocketServer.broadcast(jsonObject.toJSONString());
|
|
|
198
|
+ }
|
170
|
} else {
|
199
|
} else {
|
171
|
WebSocketServer webSocketServer = new WebSocketServer();
|
200
|
WebSocketServer webSocketServer = new WebSocketServer();
|
172
|
JSONObject jsonObject = new JSONObject();
|
201
|
JSONObject jsonObject = new JSONObject();
|
|
@@ -174,18 +203,16 @@ public class PayRseponeController { |
|
@@ -174,18 +203,16 @@ public class PayRseponeController { |
174
|
jsonObject.put("success", "N");
|
203
|
jsonObject.put("success", "N");
|
175
|
webSocketServer.broadcast(jsonObject.toJSONString());
|
204
|
webSocketServer.broadcast(jsonObject.toJSONString());
|
176
|
}
|
205
|
}
|
177
|
- } else {
|
|
|
178
|
- WebSocketServer webSocketServer = new WebSocketServer();
|
|
|
179
|
- JSONObject jsonObject = new JSONObject();
|
|
|
180
|
- jsonObject.put("orderNumber", ORDERID);
|
|
|
181
|
- jsonObject.put("success", "N");
|
|
|
182
|
- webSocketServer.broadcast(jsonObject.toJSONString());
|
|
|
183
|
}
|
206
|
}
|
184
|
}
|
207
|
}
|
185
|
- }
|
|
|
186
|
|
208
|
|
|
|
209
|
+ }
|
|
|
210
|
+ return i == 1 ? new ResultJson("200", "支付回执信息接受成功") : new ResultJson("500", "支付回执信息接受失败");
|
|
|
211
|
+ }catch (Exception e){
|
|
|
212
|
+ e.printStackTrace();
|
|
|
213
|
+ log.info("系统异常-----------");
|
|
|
214
|
+ return null;
|
187
|
}
|
215
|
}
|
188
|
- return i == 1 ? new ResultJson("200", "支付回执信息接受成功") : new ResultJson("500", "支付回执信息接受失败");
|
|
|
189
|
}
|
216
|
}
|
190
|
|
217
|
|
191
|
} |
218
|
} |