作者 shenhailong

配置文件修改端口 添加订单充值失败处理

... ... @@ -5,7 +5,7 @@ docker:
server:
ip: 192.168.1.63
server:
port: 10003
port: 10004
# servlet:
# context-path: ${SERVER_CONTEXTPATH:}
spring:
... ... @@ -182,4 +182,26 @@ eeUrl:
#获取设备跟公寓信息
# getRoomAndDeviceUrl: "http://10.5.10.102:8000/api/emcs/getRoomAndDevice"
getRoomAndDeviceUrl: "http://192.168.1.7:18080/api/emcs/getRoomAndDevice"
payInfo:
#商户代码
merchantid: "105001453995827"
#商户柜台代码
posid: "031575220"
#分行代码
branchid: "410000000"
#交易码
txcode: "530550"
#应柜台的公钥后30位
pub32tr2: "8578d1cd9340dba556126a71020111"
# #商户代码
# merchantid: "105000045820502"
# #商户柜台代码
# posid: "049347762"
# #分行代码
# branchid: "410000000"
# #交易码
# txcode: "530550"
# #应柜台的公钥后30位
# pub32tr2: "1c99bca545a2baf6bed0637b020111"
... ...
package com.sunyo.energy.location.controller;
import com.github.pagehelper.PageInfo;
import com.google.gson.internal.$Gson$Preconditions;
import com.sunyo.energy.location.controller.response.ResultJson;
import com.sunyo.energy.location.dao.LocationMapper;
import com.sunyo.energy.location.dao.PayRecordsMapper;
import com.sunyo.energy.location.model.Location;
import com.sunyo.energy.location.model.PayRecords;
import com.sunyo.energy.location.service.ElectricityMeterService;
import com.sunyo.energy.location.service.PayOrderService;
import com.sunyo.energy.location.service.WaterMeterService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
/**
... ... @@ -18,9 +25,21 @@ import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/order")
public class PayOrderController {
@Autowired
PayOrderService payOrderService;
@Autowired
PayRecordsMapper payRecordsMapper;
@Autowired
ElectricityMeterService electricityMeterService;
@Autowired
private WaterMeterService waterMeterService;
@Autowired
private LocationMapper locationMapper;
@ApiOperation(value = "查询缴费订单")
@RequestMapping("/list")
... ... @@ -69,4 +88,39 @@ public class PayOrderController {
return mgs == 1 ? new ResultJson("200", "订单信息移出成功") : new ResultJson("500", "订单信息删除失败");
}
@ApiOperation(value = "处理失败订单充值信息")
@PostMapping("/defeatedOrder")
public ResultJson defeatedOrder(@RequestBody PayRecords payRecords){
/**
* 查询水电表编号
*/
Location location = locationMapper.waterId_eleId(payRecords.getPaylocationname());
/**
* true 为电 false 为水
*/
if (payRecords.getPaytype()){
int i = electricityMeterService.rechargeDevices(location.getEeid(), String.valueOf(payRecords.getPayfees()),
"0", payRecords.getOrdernumber());
if (i == 1){
payRecords.setReamke3("1");
int i1 = payRecordsMapper.updateByPrimaryKey(payRecords);
return i1 == 1? new ResultJson("200", "电费充值成功"): new ResultJson("201", "电费充值失败");
}else {
return new ResultJson("201", "电费充值失败");
}
}else {
ResultJson resultJson = waterMeterService.payWater(String.valueOf(payRecords.getPayfees()), location.getWmid());
if ("200".equals(resultJson.getCode())){
payRecords.setReamke3("1");
int i1 = payRecordsMapper.updateByPrimaryKey(payRecords);
return i1 == 1? new ResultJson("200", "水费充值成功"): new ResultJson("201", "水费充值失败");
}else {
resultJson.setCode("201");
return resultJson;
}
}
}
}
... ...
... ... @@ -10,6 +10,7 @@ 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;
... ... @@ -21,7 +22,7 @@ import java.math.BigDecimal;
import java.util.Date;
import java.util.UUID;
@Slf4j
@RequestMapping("/payCode")
public class PayRseponeController {
... ... @@ -78,7 +79,7 @@ public class PayRseponeController {
@RequestParam(value = "USRMSG", required = false) String USRMSG,
@RequestParam(value = "USRINFO", required = false) String USRINFO,
@RequestParam(value = "PAYTYPE", required = false) String PAYTYPE,
@RequestParam(value = "SIGN", required = false) String SIGN) throws IOException {
@RequestParam(value = "SIGN", required = false) String SIGN){
PayResponse payResponse = new PayResponse();
payResponse.setId(UUID.randomUUID().toString());
... ... @@ -99,6 +100,7 @@ public class PayRseponeController {
payResponse.setUsrinfo(USRINFO);
payResponse.setPaytype(PAYTYPE);
payResponse.setSign(SIGN);
try {
int msg = 0;
int i = payResponseMapperl.insertSelective(payResponse);
if (i > 0) {
... ... @@ -187,6 +189,12 @@ public class PayRseponeController {
}
return i == 1 ? new ResultJson("200", "支付回执信息接受成功") : new ResultJson("500", "支付回执信息接受失败");
}catch (Exception e){
e.printStackTrace();
log.info("系统异常--------------------");
return null;
}
}
}
... ...
... ... @@ -20,6 +20,8 @@ public interface LocationMapper {
List<Location> selectAllAdrName(String adrName);
Location waterId_eleId(String adrName);
int updateByPrimaryKeySelective(Location record);
int updateByPrimaryKey(Location record);
... ...
... ... @@ -6,33 +6,48 @@ import java.util.HashMap;
import java.util.Map;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.sunyo.energy.location.model.WaterMeter;
import net.sf.json.JSONObject;
import net.sf.json.util.JSONUtils;
import springfox.documentation.spring.web.json.Json;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
public class QrDemo {
public static String orUrl(String orderId, String payMent) throws UnsupportedEncodingException {
private String MERCHANTIDS;
private String POSIDS;
private String BRANCHIDS;
private String TXCODES;
private String PUB32TR2S;
public QrDemo(String MERCHANTIDS, String POSIDS, String BRANCHIDS, String TXCODES, String PUB32TR2S) {
this.MERCHANTIDS = MERCHANTIDS;
this.POSIDS = POSIDS;
this.BRANCHIDS = BRANCHIDS;
this.TXCODES = TXCODES;
this.PUB32TR2S = PUB32TR2S;
}
public String orUrl(String orderId, String payMent) throws UnsupportedEncodingException {
String bankURL = "https://ibsbjstar.ccb.com.cn/CCBIS/ccbMain";
/**
* 商户代码
*/
String MERCHANTID = "105000045820502";
// String MERCHANTID = "105001453995827";
String MERCHANTID = MERCHANTIDS;
/**
* 商户柜台代码
*/
String POSID = "049347762";
// String POSID = "031575220";
String POSID = POSIDS;
/**
* 分行代码
*/
// String BRANCHID = "410803805";
String BRANCHID = "410000000";
String BRANCHID = BRANCHIDS;
/**
* 货币种类 01 人民币 只支持人民币
*/
... ... @@ -40,7 +55,7 @@ public class QrDemo {
/**
* 交易码
*/
String TXCODE = "530550";
String TXCODE = TXCODES;
String REMARK1 = "";
String REMARK2 = "";
/**
... ... @@ -51,10 +66,9 @@ public class QrDemo {
/**
* 应柜台的公钥后30位
*/
String PUB32TR2 = "57b3055539f4925efaf9dacb020111";
// String PUB32TR2= "8578d1cd9340dba556126a71020111";
String PUB32TR2 = PUB32TR2S;
StringBuffer tmp = new StringBuffer(); //ÑéÇ©×Ö¶Î
StringBuffer tmp = new StringBuffer();
tmp.append("MERCHANTID=");
tmp.append(MERCHANTID);
tmp.append("&POSID=");
... ... @@ -81,7 +95,7 @@ public class QrDemo {
tmp.append(PUB32TR2);
Map map = new HashMap();
map.put("CCB_IBSVersion", "V6"); //±ØÊäÏî
map.put("CCB_IBSVersion", "V6");
map.put("MERCHANTID", MERCHANTID);
map.put("BRANCHID", BRANCHID);
map.put("POSID", POSID);
... ...
... ... @@ -39,18 +39,18 @@ public class LocationServiceImp implements LocationService {
Map<String, Object> thisLocalityWaterMap = locationMapper.userPayList(roomNumber);
Map<String, Object> distanceWaterMap = new HashMap<>();
// 是否为null 为null则去线上查询
if (thisLocalityWaterMap != null) {
if (!StringUtils.isEmpty(thisLocalityWaterMap.get("wmSacc").toString()) && !StringUtils.isEmpty(thisLocalityWaterMap.get("wmLacc").toString())) {
// 计算剩余量 充值量 减去 消费量 参数1 减去 参数2
String subtraction = AllUtils.nubmerSubtraction(thisLocalityWaterMap.get("wmSacc").toString(), thisLocalityWaterMap.get("wmLacc").toString());
// 余量
thisLocalityWaterMap.put("subtraction", subtraction);
}
list.add(thisLocalityWaterMap);
} else {
// if (thisLocalityWaterMap != null) {
// if (!StringUtils.isEmpty(thisLocalityWaterMap.get("wmSacc").toString()) && !StringUtils.isEmpty(thisLocalityWaterMap.get("wmLacc").toString())) {
// // 计算剩余量 充值量 减去 消费量 参数1 减去 参数2
// String subtraction = AllUtils.nubmerSubtraction(thisLocalityWaterMap.get("wmSacc").toString(), thisLocalityWaterMap.get("wmLacc").toString());
// // 余量
// thisLocalityWaterMap.put("subtraction", subtraction);
// }
// list.add(thisLocalityWaterMap);
// } else {
// 查询该房间号的水表编号
String wmId = locationMapper.findWmId(roomNumber);
if (!"".equals(wmId) && "" != wmId) {
if (!"".equals(wmId)) {
Map<String, Object> waterMaps = new HashMap<>();
WaterMeterServiceImp waterMeterServiceImp = new WaterMeterServiceImp();
WaterMeter realTime = waterMeterServiceImp.findRealTime(wmId);
... ... @@ -62,7 +62,7 @@ public class LocationServiceImp implements LocationService {
distanceWaterMap.put("wmId", wmId);
list.add(distanceWaterMap);
}
}
// }
/**
* 电费查询 通过房间号查询设备id
*/
... ...
... ... @@ -13,6 +13,7 @@ import com.sunyo.energy.location.service.WaterMeterService;
import com.sunyo.energy.location.utils.AllUtils;
import com.sunyo.energy.location.utils.HttpsUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
... ... @@ -35,6 +36,21 @@ public class WaterMeterServiceImp implements WaterMeterService {
@Autowired
private LocationMapper locationMapper;
@Value("${payInfo.merchantid}")
private String MERCHANTIDS;
@Value("${payInfo.posid}")
private String POSIDS;
@Value("${payInfo.branchid}")
private String BRANCHIDS;
@Value("${payInfo.txcode}")
private String TXCODES;
@Value("${payInfo.pub32tr2}")
private String PUB32TR2S;
/**
* 查询所有水表
*/
... ... @@ -163,11 +179,12 @@ public class WaterMeterServiceImp implements WaterMeterService {
@Override
public ResultJson qrCode(String payFees, String wmId, String userId, String realName, String eeId) throws UnsupportedEncodingException {
ResultJson<Object> resultJson = new ResultJson<>();
QrDemo qrDemo = new QrDemo(MERCHANTIDS,POSIDS,BRANCHIDS,TXCODES,PUB32TR2S);
// 成功生成水费订单
if (!"".equals(wmId)) {
PayRecords payRecords = payRecords(payFees, wmId, userId, realName, "");
// 请求返回二维码lujing
String url = QrDemo.orUrl(payRecords.getOrdernumber(), payFees);
String url = qrDemo.orUrl(payRecords.getOrdernumber(), payFees);
if (!"".equals(url)) {
payRecords.setReamke2(url);
... ... @@ -185,7 +202,7 @@ public class WaterMeterServiceImp implements WaterMeterService {
PayRecords payRecords = payRecords(payFees, "", userId, realName, eeId);
// 请求返回二维码lujing
String url = QrDemo.orUrl(payRecords.getOrdernumber(), payFees);
String url = qrDemo.orUrl(payRecords.getOrdernumber(), payFees);
if (!"".equals(url)) {
payRecords.setReamke2(url);
... ... @@ -217,9 +234,8 @@ public class WaterMeterServiceImp implements WaterMeterService {
// 充值最后立方水数值
String s = AllUtils.nubmerDivision(payFees);
// 查询累计充值量
String oneWmSacc = waterMeterMapper.findOneWmSacc(wmId);
String allSacc = AllUtils.nubmerAdd(s, oneWmSacc);
WaterMeter realTime = findRealTime(wmId);
String allSacc = AllUtils.nubmerAdd(s, realTime.getWmSacc());
Map<String, Object> datas = new HashMap<>();
datas.put("MtId", wmId);
datas.put("Add_sacc", allSacc);
... ...
... ... @@ -38,6 +38,10 @@
adrName = #{adrname, jdbcType=VARCHAR}
</select>
<select id="waterId_eleId" resultMap="BaseResultMap" parameterType="string">
select * from location where adrName = #{adrname, jdbcType=VARCHAR}
</select>
<select id="userPayList" resultType="java.util.HashMap">
select
wm.wm_id as wmId, wm.wm_fmstate as wmFmstate,
... ...
... ... @@ -45,7 +45,7 @@
and payTime &lt; #{endTime,jdbcType=VARCHAR}
</if>
<if test="username != '' and username != null">
and payUserName = #{username,jdbcType=VARCHAR}
and payLocationName = #{username,jdbcType=VARCHAR}
</if>
order by payTime desc
</select>
... ... @@ -260,7 +260,6 @@
<update id="updateByPrimaryKey" parameterType="com.sunyo.energy.location.model.PayRecords">
update pay_records
set
payStatus = 1,
reamke3 = #{reamke3,jdbcType=VARCHAR},
payFessType = #{payfesstype,jdbcType=BIT}
where orderNumber = #{ordernumber,jdbcType=VARCHAR}
... ...