| 
1
 | 
 package com.sunyo.energy.location.controller;
 | 
1
 | 
 package com.sunyo.energy.location.controller;
 | 
| 
2
 | 
 
 | 
2
 | 
 
 | 
| 
3
 | 
 import com.alibaba.fastjson.JSONObject;
 | 
3
 | 
 import com.alibaba.fastjson.JSONObject;
 | 
| 
 | 
   | 
4
 | 
+import com.google.gson.internal.$Gson$Preconditions;
 | 
| 
4
 | 
 import com.sunyo.energy.location.controller.response.ResultJson;
 | 
5
 | 
 import com.sunyo.energy.location.controller.response.ResultJson;
 | 
| 
5
 | 
 import com.sunyo.energy.location.dao.PayRecordsMapper;
 | 
6
 | 
 import com.sunyo.energy.location.dao.PayRecordsMapper;
 | 
| 
6
 | 
 import com.sunyo.energy.location.dao.PayResponseMapper;
 | 
7
 | 
 import com.sunyo.energy.location.dao.PayResponseMapper;
 | 
 | 
@@ -107,111 +108,125 @@ public class PayRseponeController { | 
 | 
@@ -107,111 +108,125 @@ public class PayRseponeController { | 
| 
107
 | 
         payResponse.setPaytype(PAYTYPE);
 | 
108
 | 
         payResponse.setPaytype(PAYTYPE);
 | 
| 
108
 | 
         payResponse.setSign(SIGN);
 | 
109
 | 
         payResponse.setSign(SIGN);
 | 
| 
109
 | 
         try {
 | 
110
 | 
         try {
 | 
| 
110
 | 
-            int msg = 0;
 | 
 | 
   | 
| 
111
 | 
-            int i = payResponseMapperl.insertSelective(payResponse);
 | 
 | 
   | 
| 
112
 | 
-            log.info("插入数据库{},信息{}",i, payResponse);
 | 
 | 
   | 
| 
113
 | 
-            if (i > 0) {
 | 
 | 
   | 
| 
114
 | 
-                msg = 1;
 | 
 | 
   | 
| 
115
 | 
-                PayRecords payRecords = new PayRecords();
 | 
 | 
   | 
| 
116
 | 
-                // 支付类型
 | 
 | 
   | 
| 
117
 | 
-                if (!"".equals(ACC_TYPE)) {
 | 
 | 
   | 
| 
118
 | 
-                    if ("WX".equals(ACC_TYPE)) {
 | 
 | 
   | 
| 
119
 | 
-                        payRecords.setPayfesstype(false);
 | 
 | 
   | 
| 
120
 | 
-                    } else {
 | 
 | 
   | 
| 
121
 | 
-                        payRecords.setPayfesstype(true);
 | 
 | 
   | 
| 
122
 | 
-                    }
 | 
 | 
   | 
| 
123
 | 
 
 | 
111
 | 
 
 | 
| 
124
 | 
-                }
 | 
 | 
   | 
| 
125
 | 
-                if ("Y".equals(SUCCESS)) {
 | 
 | 
   | 
| 
126
 | 
-                    payRecords.setOrdernumber(ORDERID);
 | 
 | 
   | 
| 
127
 | 
-                    payRecords.setReamke3("1");
 | 
 | 
   | 
| 
128
 | 
-                } else {
 | 
 | 
   | 
| 
129
 | 
-                    payRecords.setOrdernumber(ORDERID);
 | 
 | 
   | 
| 
130
 | 
-                    payRecords.setReamke3("0");
 | 
 | 
   | 
| 
131
 | 
-                }
 | 
 | 
   | 
| 
132
 | 
-                /**
 | 
 | 
   | 
| 
133
 | 
-                 * 修改订单支付状态
 | 
 | 
   | 
| 
134
 | 
-                 */
 | 
 | 
   | 
| 
135
 | 
-                payRecordsMapper.updateOrderStatus(payRecords);
 | 
 | 
   | 
| 
136
 | 
-
 | 
 | 
   | 
| 
137
 | 
-                // 查询是水还是电
 | 
 | 
   | 
| 
138
 | 
-                boolean selectType = payRecordsMapper.selectType(ORDERID);
 | 
 | 
   | 
| 
139
 | 
-                if (selectType) {
 | 
 | 
   | 
| 
140
 | 
-                    // 查询该订单设备编号
 | 
 | 
   | 
| 
141
 | 
-                    String eeId = payRecordsMapper.findOrderNumber(ORDERID);
 | 
 | 
   | 
| 
142
 | 
-                    if (!"".equals(eeId)) {
 | 
 | 
   | 
| 
143
 | 
-                        // 通知充值电费
 | 
 | 
   | 
| 
144
 | 
-                        int eeResult = electricityMeterService.rechargeDevices(eeId, PAYMENT, "0", ORDERID);
 | 
 | 
   | 
| 
145
 | 
-                        if (eeResult > 0) {
 | 
 | 
   | 
| 
146
 | 
-
 | 
 | 
   | 
| 
147
 | 
-                            log.info("电表信息充值成功{}",eeResult);
 | 
 | 
   | 
| 
148
 | 
-                            /**
 | 
 | 
   | 
| 
149
 | 
-                             * 修改电表充值状态
 | 
 | 
   | 
| 
150
 | 
-                              */
 | 
 | 
   | 
| 
151
 | 
-                            int i1 = payRecordsMapper.updateByPrimaryKey(payRecords);
 | 
 | 
   | 
| 
152
 | 
-                            log.info("修改电表订单状态{}, 修改信息{}", i1, payRecords);
 | 
 | 
   | 
| 
153
 | 
-                            if (i1 > 0) {
 | 
 | 
   | 
| 
154
 | 
-                                WebSocketServer webSocketServer = new WebSocketServer();
 | 
 | 
   | 
| 
155
 | 
-                                JSONObject jsonObject = new JSONObject();
 | 
 | 
   | 
| 
156
 | 
-                                jsonObject.put("orderNumber", ORDERID);
 | 
 | 
   | 
| 
157
 | 
-                                jsonObject.put("success", "Y");
 | 
 | 
   | 
| 
158
 | 
-                                webSocketServer.broadcast(jsonObject.toJSONString());
 | 
 | 
   | 
| 
159
 | 
-                                log.info("通知前端消息结果");
 | 
 | 
   | 
| 
160
 | 
-                            } else {
 | 
 | 
   | 
| 
161
 | 
-                                WebSocketServer webSocketServer = new WebSocketServer();
 | 
 | 
   | 
| 
162
 | 
-                                JSONObject jsonObject = new JSONObject();
 | 
 | 
   | 
| 
163
 | 
-                                jsonObject.put("orderNumber", ORDERID);
 | 
 | 
   | 
| 
164
 | 
-                                jsonObject.put("success", "N");
 | 
 | 
   | 
| 
165
 | 
-                                webSocketServer.broadcast(jsonObject.toJSONString());
 | 
 | 
   | 
| 
166
 | 
-                            }
 | 
112
 | 
+            int msg = 0;
 | 
| 
 | 
   | 
113
 | 
+            /**
 | 
| 
 | 
   | 
114
 | 
+             * 解决建行反馈多次原因
 | 
| 
 | 
   | 
115
 | 
+             */
 | 
| 
 | 
   | 
116
 | 
+            if(payResponseMapperl.count(ORDERID) == 0){
 | 
| 
 | 
   | 
117
 | 
+                int i = payResponseMapperl.insertSelective(payResponse);
 | 
| 
 | 
   | 
118
 | 
+                log.info("插入数据库{},信息{}",i, payResponse);
 | 
| 
 | 
   | 
119
 | 
+                if (i > 0) {
 | 
| 
 | 
   | 
120
 | 
+                    msg = 1;
 | 
| 
 | 
   | 
121
 | 
+                    PayRecords payRecords = new PayRecords();
 | 
| 
 | 
   | 
122
 | 
+                    // 支付类型
 | 
| 
 | 
   | 
123
 | 
+                    if (!"".equals(ACC_TYPE)) {
 | 
| 
 | 
   | 
124
 | 
+                        if ("WX".equals(ACC_TYPE)) {
 | 
| 
 | 
   | 
125
 | 
+                            payRecords.setPayfesstype(false);
 | 
| 
167
 | 
                         } else {
 | 
126
 | 
                         } else {
 | 
| 
168
 | 
-                            WebSocketServer webSocketServer = new WebSocketServer();
 | 
 | 
   | 
| 
169
 | 
-                            JSONObject jsonObject = new JSONObject();
 | 
 | 
   | 
| 
170
 | 
-                            jsonObject.put("orderNumber", ORDERID);
 | 
 | 
   | 
| 
171
 | 
-                            jsonObject.put("success", "S");
 | 
 | 
   | 
| 
172
 | 
-                            webSocketServer.broadcast(jsonObject.toJSONString());
 | 
127
 | 
+                            payRecords.setPayfesstype(true);
 | 
| 
173
 | 
                         }
 | 
128
 | 
                         }
 | 
| 
 | 
   | 
129
 | 
+
 | 
| 
174
 | 
                     }
 | 
130
 | 
                     }
 | 
| 
175
 | 
-                } else {
 | 
 | 
   | 
| 
176
 | 
-                    // 查询该订单设备编号
 | 
 | 
   | 
| 
177
 | 
-                    String wmId = payRecordsMapper.findOrderNumber(ORDERID);
 | 
 | 
   | 
| 
178
 | 
-                    // 通知充值水费
 | 
 | 
   | 
| 
179
 | 
-                    if (!"".equals(wmId)) {
 | 
 | 
   | 
| 
180
 | 
-                        ResultJson resultJson = waterMeterService.payWater(PAYMENT, wmId);
 | 
 | 
   | 
| 
181
 | 
-                        if ("200".equals(resultJson.getCode())) {
 | 
 | 
   | 
| 
182
 | 
-                            log.info("水表信息充值成功{}",resultJson.getCode());
 | 
 | 
   | 
| 
183
 | 
-                            /**
 | 
 | 
   | 
| 
184
 | 
-                             * 修改订单充值状态
 | 
 | 
   | 
| 
185
 | 
-                              */
 | 
 | 
   | 
| 
186
 | 
-                            int i1 = payRecordsMapper.updateByPrimaryKey(payRecords);
 | 
 | 
   | 
| 
187
 | 
-                            log.info("修改水表订单状态{}, 修改信息{}", i1, payRecords);
 | 
 | 
   | 
| 
188
 | 
-                            if (i1 > 0) {
 | 
 | 
   | 
| 
189
 | 
-
 | 
 | 
   | 
| 
190
 | 
-                                WebSocketServer webSocketServer = new WebSocketServer();
 | 
 | 
   | 
| 
191
 | 
-                                JSONObject jsonObject = new JSONObject();
 | 
 | 
   | 
| 
192
 | 
-                                jsonObject.put("orderNumber", ORDERID);
 | 
 | 
   | 
| 
193
 | 
-                                jsonObject.put("success", "Y");
 | 
 | 
   | 
| 
194
 | 
-                                webSocketServer.broadcast(jsonObject.toJSONString());
 | 
 | 
   | 
| 
195
 | 
-                                log.info("通知前端消息结果");
 | 
 | 
   | 
| 
196
 | 
-                            } else {
 | 
 | 
   | 
| 
197
 | 
-                                WebSocketServer webSocketServer = new WebSocketServer();
 | 
 | 
   | 
| 
198
 | 
-                                JSONObject jsonObject = new JSONObject();
 | 
 | 
   | 
| 
199
 | 
-                                jsonObject.put("orderNumber", ORDERID);
 | 
 | 
   | 
| 
200
 | 
-                                jsonObject.put("success", "N");
 | 
 | 
   | 
| 
201
 | 
-                                webSocketServer.broadcast(jsonObject.toJSONString());
 | 
131
 | 
+                    if ("Y".equals(SUCCESS)) {
 | 
| 
 | 
   | 
132
 | 
+                        payRecords.setOrdernumber(ORDERID);
 | 
| 
 | 
   | 
133
 | 
+                        payRecords.setReamke3("1");
 | 
| 
 | 
   | 
134
 | 
+                        /**
 | 
| 
 | 
   | 
135
 | 
+                         * 修改订单支付状态
 | 
| 
 | 
   | 
136
 | 
+                         */
 | 
| 
 | 
   | 
137
 | 
+                        payRecordsMapper.updateOrderStatus(payRecords);
 | 
| 
 | 
   | 
138
 | 
+                        // 查询是水还是电
 | 
| 
 | 
   | 
139
 | 
+                        boolean selectType = payRecordsMapper.selectType(ORDERID);
 | 
| 
 | 
   | 
140
 | 
+                        if (selectType) {
 | 
| 
 | 
   | 
141
 | 
+                            // 查询该订单设备编号
 | 
| 
 | 
   | 
142
 | 
+                            String eeId = payRecordsMapper.findOrderNumber(ORDERID);
 | 
| 
 | 
   | 
143
 | 
+                            if (!"".equals(eeId)) {
 | 
| 
 | 
   | 
144
 | 
+                                // 通知充值电费
 | 
| 
 | 
   | 
145
 | 
+                                int eeResult = electricityMeterService.rechargeDevices(eeId, PAYMENT, "0", ORDERID);
 | 
| 
 | 
   | 
146
 | 
+                                if (eeResult > 0) {
 | 
| 
 | 
   | 
147
 | 
+
 | 
| 
 | 
   | 
148
 | 
+                                    log.info("电表信息充值成功{}",eeResult);
 | 
| 
 | 
   | 
149
 | 
+                                    /**
 | 
| 
 | 
   | 
150
 | 
+                                     * 修改电表充值状态
 | 
| 
 | 
   | 
151
 | 
+                                     */
 | 
| 
 | 
   | 
152
 | 
+                                    int i1 = payRecordsMapper.updateByPrimaryKey(payRecords);
 | 
| 
 | 
   | 
153
 | 
+                                    log.info("修改电表订单状态{}, 修改信息{}", i1, payRecords);
 | 
| 
 | 
   | 
154
 | 
+                                    if (i1 > 0) {
 | 
| 
 | 
   | 
155
 | 
+                                        WebSocketServer webSocketServer = new WebSocketServer();
 | 
| 
 | 
   | 
156
 | 
+                                        JSONObject jsonObject = new JSONObject();
 | 
| 
 | 
   | 
157
 | 
+                                        jsonObject.put("orderNumber", ORDERID);
 | 
| 
 | 
   | 
158
 | 
+                                        jsonObject.put("success", "Y");
 | 
| 
 | 
   | 
159
 | 
+                                        webSocketServer.broadcast(jsonObject.toJSONString());
 | 
| 
 | 
   | 
160
 | 
+                                        log.info("通知前端消息结果");
 | 
| 
 | 
   | 
161
 | 
+                                    } else {
 | 
| 
 | 
   | 
162
 | 
+                                        WebSocketServer webSocketServer = new WebSocketServer();
 | 
| 
 | 
   | 
163
 | 
+                                        JSONObject jsonObject = new JSONObject();
 | 
| 
 | 
   | 
164
 | 
+                                        jsonObject.put("orderNumber", ORDERID);
 | 
| 
 | 
   | 
165
 | 
+                                        jsonObject.put("success", "N");
 | 
| 
 | 
   | 
166
 | 
+                                        webSocketServer.broadcast(jsonObject.toJSONString());
 | 
| 
 | 
   | 
167
 | 
+                                    }
 | 
| 
 | 
   | 
168
 | 
+                                } else {
 | 
| 
 | 
   | 
169
 | 
+                                    WebSocketServer webSocketServer = new WebSocketServer();
 | 
| 
 | 
   | 
170
 | 
+                                    JSONObject jsonObject = new JSONObject();
 | 
| 
 | 
   | 
171
 | 
+                                    jsonObject.put("orderNumber", ORDERID);
 | 
| 
 | 
   | 
172
 | 
+                                    jsonObject.put("success", "S");
 | 
| 
 | 
   | 
173
 | 
+                                    webSocketServer.broadcast(jsonObject.toJSONString());
 | 
| 
 | 
   | 
174
 | 
+                                }
 | 
| 
202
 | 
                             }
 | 
175
 | 
                             }
 | 
| 
203
 | 
                         } else {
 | 
176
 | 
                         } else {
 | 
| 
204
 | 
-                            WebSocketServer webSocketServer = new WebSocketServer();
 | 
 | 
   | 
| 
205
 | 
-                            JSONObject jsonObject = new JSONObject();
 | 
 | 
   | 
| 
206
 | 
-                            jsonObject.put("orderNumber", ORDERID);
 | 
 | 
   | 
| 
207
 | 
-                            jsonObject.put("success", "N");
 | 
 | 
   | 
| 
208
 | 
-                            webSocketServer.broadcast(jsonObject.toJSONString());
 | 
177
 | 
+                            // 查询该订单设备编号
 | 
| 
 | 
   | 
178
 | 
+                            String wmId = payRecordsMapper.findOrderNumber(ORDERID);
 | 
| 
 | 
   | 
179
 | 
+                            // 通知充值水费
 | 
| 
 | 
   | 
180
 | 
+                            if (!"".equals(wmId)) {
 | 
| 
 | 
   | 
181
 | 
+                                ResultJson resultJson = waterMeterService.payWater(PAYMENT, wmId);
 | 
| 
 | 
   | 
182
 | 
+                                if ("200".equals(resultJson.getCode())) {
 | 
| 
 | 
   | 
183
 | 
+                                    log.info("水表信息充值成功{}",resultJson.getCode());
 | 
| 
 | 
   | 
184
 | 
+                                    /**
 | 
| 
 | 
   | 
185
 | 
+                                     * 修改订单充值状态
 | 
| 
 | 
   | 
186
 | 
+                                     */
 | 
| 
 | 
   | 
187
 | 
+                                    int i1 = payRecordsMapper.updateByPrimaryKey(payRecords);
 | 
| 
 | 
   | 
188
 | 
+                                    log.info("修改水表订单状态{}, 修改信息{}", i1, payRecords);
 | 
| 
 | 
   | 
189
 | 
+                                    if (i1 > 0) {
 | 
| 
 | 
   | 
190
 | 
+
 | 
| 
 | 
   | 
191
 | 
+                                        WebSocketServer webSocketServer = new WebSocketServer();
 | 
| 
 | 
   | 
192
 | 
+                                        JSONObject jsonObject = new JSONObject();
 | 
| 
 | 
   | 
193
 | 
+                                        jsonObject.put("orderNumber", ORDERID);
 | 
| 
 | 
   | 
194
 | 
+                                        jsonObject.put("success", "Y");
 | 
| 
 | 
   | 
195
 | 
+                                        webSocketServer.broadcast(jsonObject.toJSONString());
 | 
| 
 | 
   | 
196
 | 
+                                        log.info("通知前端消息结果");
 | 
| 
 | 
   | 
197
 | 
+                                    } else {
 | 
| 
 | 
   | 
198
 | 
+                                        WebSocketServer webSocketServer = new WebSocketServer();
 | 
| 
 | 
   | 
199
 | 
+                                        JSONObject jsonObject = new JSONObject();
 | 
| 
 | 
   | 
200
 | 
+                                        jsonObject.put("orderNumber", ORDERID);
 | 
| 
 | 
   | 
201
 | 
+                                        jsonObject.put("success", "N");
 | 
| 
 | 
   | 
202
 | 
+                                        webSocketServer.broadcast(jsonObject.toJSONString());
 | 
| 
 | 
   | 
203
 | 
+                                    }
 | 
| 
 | 
   | 
204
 | 
+                                } else {
 | 
| 
 | 
   | 
205
 | 
+                                    WebSocketServer webSocketServer = new WebSocketServer();
 | 
| 
 | 
   | 
206
 | 
+                                    JSONObject jsonObject = new JSONObject();
 | 
| 
 | 
   | 
207
 | 
+                                    jsonObject.put("orderNumber", ORDERID);
 | 
| 
 | 
   | 
208
 | 
+                                    jsonObject.put("success", "N");
 | 
| 
 | 
   | 
209
 | 
+                                    webSocketServer.broadcast(jsonObject.toJSONString());
 | 
| 
 | 
   | 
210
 | 
+                                }
 | 
| 
 | 
   | 
211
 | 
+                            }
 | 
| 
209
 | 
                         }
 | 
212
 | 
                         }
 | 
| 
 | 
   | 
213
 | 
+
 | 
| 
 | 
   | 
214
 | 
+                    } else {
 | 
| 
 | 
   | 
215
 | 
+                        payRecords.setOrdernumber(ORDERID);
 | 
| 
 | 
   | 
216
 | 
+                        payRecords.setReamke3("0");
 | 
| 
 | 
   | 
217
 | 
+                        /**
 | 
| 
 | 
   | 
218
 | 
+                         * 修改订单支付状态
 | 
| 
 | 
   | 
219
 | 
+                         */
 | 
| 
 | 
   | 
220
 | 
+                        payRecordsMapper.updateOrderStatus(payRecords);
 | 
| 
210
 | 
                     }
 | 
221
 | 
                     }
 | 
| 
211
 | 
                 }
 | 
222
 | 
                 }
 | 
| 
212
 | 
-
 | 
223
 | 
+                return i == 1 ? new ResultJson("200", "支付回执信息接受成功") : new ResultJson("500", "支付回执信息接受失败");
 | 
| 
 | 
   | 
224
 | 
+            }else {
 | 
| 
 | 
   | 
225
 | 
+                return 1 == 1 ? new ResultJson("200", "2次调用") : new ResultJson("500", "2次调用");
 | 
| 
213
 | 
             }
 | 
226
 | 
             }
 | 
| 
214
 | 
-            return i == 1 ? new ResultJson("200", "支付回执信息接受成功") : new ResultJson("500", "支付回执信息接受失败");
 | 
227
 | 
+
 | 
| 
 | 
   | 
228
 | 
+
 | 
| 
 | 
   | 
229
 | 
+
 | 
| 
215
 | 
         }catch (Exception e){
 | 
230
 | 
         }catch (Exception e){
 | 
| 
216
 | 
             e.printStackTrace();
 | 
231
 | 
             e.printStackTrace();
 | 
| 
217
 | 
             log.info("系统异常-----------");
 | 
232
 | 
             log.info("系统异常-----------");
 | 
 | 
@@ -219,4 +234,5 @@ public class PayRseponeController { | 
 | 
@@ -219,4 +234,5 @@ public class PayRseponeController { | 
| 
219
 | 
         }
 | 
234
 | 
         }
 | 
| 
220
 | 
     }
 | 
235
 | 
     }
 | 
| 
221
 | 
 
 | 
236
 | 
 
 | 
| 
 | 
   | 
237
 | 
+
 | 
| 
222
 | 
 } | 
238
 | 
 } |