...
|
...
|
@@ -10,7 +10,9 @@ import com.sunyo.energy.location.service.ElectricityMeterService; |
|
|
import com.sunyo.energy.location.service.WaterMeterService;
|
|
|
import com.sunyo.energy.location.websocket.WebSocketServer;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
...
|
...
|
@@ -21,7 +23,9 @@ import java.util.Date; |
|
|
import java.util.UUID;
|
|
|
|
|
|
|
|
|
@Slf4j
|
|
|
@RequestMapping("/payCode")
|
|
|
@Controller
|
|
|
public class PayRseponeController {
|
|
|
|
|
|
|
...
|
...
|
@@ -79,6 +83,7 @@ public class PayRseponeController { |
|
|
@RequestParam(value = "PAYTYPE", required = false) String PAYTYPE,
|
|
|
@RequestParam(value = "SIGN", required = false) String SIGN) throws IOException {
|
|
|
|
|
|
log.info("接受建行返回信息");
|
|
|
PayResponse payResponse = new PayResponse();
|
|
|
payResponse.setId(UUID.randomUUID().toString());
|
|
|
payResponse.setPosid(POSID);
|
...
|
...
|
@@ -98,75 +103,99 @@ public class PayRseponeController { |
|
|
payResponse.setUsrinfo(USRINFO);
|
|
|
payResponse.setPaytype(PAYTYPE);
|
|
|
payResponse.setSign(SIGN);
|
|
|
int msg = 0;
|
|
|
int i = payResponseMapperl.insertSelective(payResponse);
|
|
|
if (i > 0) {
|
|
|
msg = 1;
|
|
|
PayRecords payRecords = new PayRecords();
|
|
|
// 支付类型
|
|
|
if (!"".equals(ACC_TYPE)) {
|
|
|
if ("WX".equals(ACC_TYPE)) {
|
|
|
payRecords.setPayfesstype(false);
|
|
|
try {
|
|
|
int msg = 0;
|
|
|
int i = payResponseMapperl.insertSelective(payResponse);
|
|
|
log.info("插入数据库{},信息{}",i, payResponse);
|
|
|
if (i > 0) {
|
|
|
msg = 1;
|
|
|
PayRecords payRecords = new PayRecords();
|
|
|
// 支付类型
|
|
|
if (!"".equals(ACC_TYPE)) {
|
|
|
if ("WX".equals(ACC_TYPE)) {
|
|
|
payRecords.setPayfesstype(false);
|
|
|
} else {
|
|
|
payRecords.setPayfesstype(true);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
if ("Y".equals(SUCCESS)) {
|
|
|
payRecords.setOrdernumber(ORDERID);
|
|
|
payRecords.setReamke3("1");
|
|
|
} else {
|
|
|
payRecords.setPayfesstype(true);
|
|
|
payRecords.setOrdernumber(ORDERID);
|
|
|
payRecords.setReamke3("0");
|
|
|
}
|
|
|
/**
|
|
|
* 修改订单支付状态
|
|
|
*/
|
|
|
payRecordsMapper.updateOrderStatus(payRecords);
|
|
|
|
|
|
}
|
|
|
if ("Y".equals(SUCCESS)) {
|
|
|
payRecords.setOrdernumber(ORDERID);
|
|
|
payRecords.setReamke3("1");
|
|
|
} else {
|
|
|
payRecords.setOrdernumber(ORDERID);
|
|
|
payRecords.setReamke3("0");
|
|
|
}
|
|
|
|
|
|
// 查询是水还是电
|
|
|
boolean selectType = payRecordsMapper.selectType(ORDERID);
|
|
|
if (selectType) {
|
|
|
// 查询该订单设备编号
|
|
|
String eeId = payRecordsMapper.findOrderNumber(ORDERID);
|
|
|
if (!"".equals(eeId)) {
|
|
|
// 通知充值电费
|
|
|
int eeResult = electricityMeterService.rechargeDevices(eeId, PAYMENT, "0", ORDERID);
|
|
|
if (eeResult > 0) {
|
|
|
// 修改订单状态
|
|
|
int i1 = payRecordsMapper.updateByPrimaryKey(payRecords);
|
|
|
if (i1 > 0) {
|
|
|
WebSocketServer webSocketServer = new WebSocketServer();
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
jsonObject.put("orderNumber", ORDERID);
|
|
|
jsonObject.put("success", "Y");
|
|
|
webSocketServer.broadcast(jsonObject.toJSONString());
|
|
|
// 查询是水还是电
|
|
|
boolean selectType = payRecordsMapper.selectType(ORDERID);
|
|
|
if (selectType) {
|
|
|
// 查询该订单设备编号
|
|
|
String eeId = payRecordsMapper.findOrderNumber(ORDERID);
|
|
|
if (!"".equals(eeId)) {
|
|
|
// 通知充值电费
|
|
|
int eeResult = electricityMeterService.rechargeDevices(eeId, PAYMENT, "0", ORDERID);
|
|
|
if (eeResult > 0) {
|
|
|
log.info("电表信息充值成功{}",eeResult);
|
|
|
/**
|
|
|
* 修改电表充值状态
|
|
|
*/
|
|
|
int i1 = payRecordsMapper.updateByPrimaryKey(payRecords);
|
|
|
log.info("修改电表订单状态{}, 修改信息{}", i1, payRecords);
|
|
|
if (i1 > 0) {
|
|
|
WebSocketServer webSocketServer = new WebSocketServer();
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
jsonObject.put("orderNumber", ORDERID);
|
|
|
jsonObject.put("success", "Y");
|
|
|
webSocketServer.broadcast(jsonObject.toJSONString());
|
|
|
log.info("通知前端消息结果");
|
|
|
} else {
|
|
|
WebSocketServer webSocketServer = new WebSocketServer();
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
jsonObject.put("orderNumber", ORDERID);
|
|
|
jsonObject.put("success", "N");
|
|
|
webSocketServer.broadcast(jsonObject.toJSONString());
|
|
|
}
|
|
|
} else {
|
|
|
WebSocketServer webSocketServer = new WebSocketServer();
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
jsonObject.put("orderNumber", ORDERID);
|
|
|
jsonObject.put("success", "N");
|
|
|
jsonObject.put("success", "S");
|
|
|
webSocketServer.broadcast(jsonObject.toJSONString());
|
|
|
}
|
|
|
} else {
|
|
|
WebSocketServer webSocketServer = new WebSocketServer();
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
jsonObject.put("orderNumber", ORDERID);
|
|
|
jsonObject.put("success", "S");
|
|
|
webSocketServer.broadcast(jsonObject.toJSONString());
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
// 查询该订单设备编号
|
|
|
String wmId = payRecordsMapper.findOrderNumber(ORDERID);
|
|
|
// 通知充值水费
|
|
|
if (!"".equals(wmId)) {
|
|
|
ResultJson resultJson = waterMeterService.payWater(PAYMENT, wmId);
|
|
|
if ("200".equals(resultJson.getCode())) {
|
|
|
// 修改订单状态
|
|
|
int i1 = payRecordsMapper.updateByPrimaryKey(payRecords);
|
|
|
if (i1 > 0) {
|
|
|
WebSocketServer webSocketServer = new WebSocketServer();
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
jsonObject.put("orderNumber", ORDERID);
|
|
|
jsonObject.put("success", "Y");
|
|
|
webSocketServer.broadcast(jsonObject.toJSONString());
|
|
|
} else {
|
|
|
// 查询该订单设备编号
|
|
|
String wmId = payRecordsMapper.findOrderNumber(ORDERID);
|
|
|
// 通知充值水费
|
|
|
if (!"".equals(wmId)) {
|
|
|
ResultJson resultJson = waterMeterService.payWater(PAYMENT, wmId);
|
|
|
if ("200".equals(resultJson.getCode())) {
|
|
|
log.info("水表信息充值成功{}",resultJson.getCode());
|
|
|
/**
|
|
|
* 修改订单充值状态
|
|
|
*/
|
|
|
int i1 = payRecordsMapper.updateByPrimaryKey(payRecords);
|
|
|
log.info("修改水表订单状态{}, 修改信息{}", i1, payRecords);
|
|
|
if (i1 > 0) {
|
|
|
|
|
|
WebSocketServer webSocketServer = new WebSocketServer();
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
jsonObject.put("orderNumber", ORDERID);
|
|
|
jsonObject.put("success", "Y");
|
|
|
webSocketServer.broadcast(jsonObject.toJSONString());
|
|
|
log.info("通知前端消息结果");
|
|
|
} else {
|
|
|
WebSocketServer webSocketServer = new WebSocketServer();
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
jsonObject.put("orderNumber", ORDERID);
|
|
|
jsonObject.put("success", "N");
|
|
|
webSocketServer.broadcast(jsonObject.toJSONString());
|
|
|
}
|
|
|
} else {
|
|
|
WebSocketServer webSocketServer = new WebSocketServer();
|
|
|
JSONObject jsonObject = new JSONObject();
|
...
|
...
|
@@ -174,18 +203,16 @@ public class PayRseponeController { |
|
|
jsonObject.put("success", "N");
|
|
|
webSocketServer.broadcast(jsonObject.toJSONString());
|
|
|
}
|
|
|
} else {
|
|
|
WebSocketServer webSocketServer = new WebSocketServer();
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
jsonObject.put("orderNumber", ORDERID);
|
|
|
jsonObject.put("success", "N");
|
|
|
webSocketServer.broadcast(jsonObject.toJSONString());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
return i == 1 ? new ResultJson("200", "支付回执信息接受成功") : new ResultJson("500", "支付回执信息接受失败");
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
log.info("系统异常-----------");
|
|
|
return null;
|
|
|
}
|
|
|
return i == 1 ? new ResultJson("200", "支付回执信息接受成功") : new ResultJson("500", "支付回执信息接受失败");
|
|
|
}
|
|
|
|
|
|
} |
...
|
...
|
|