收到银行返回信息 通知水表接口充值水费
修改水表示实施查询逻辑 修改 水表充值 逻辑
正在显示
9 个修改的文件
包含
102 行增加
和
49 行删除
| @@ -3,8 +3,12 @@ package com.sunyo.energy.location.controller; | @@ -3,8 +3,12 @@ package com.sunyo.energy.location.controller; | ||
| 3 | import com.alibaba.fastjson.JSON; | 3 | import com.alibaba.fastjson.JSON; |
| 4 | import com.alibaba.fastjson.JSONObject; | 4 | import com.alibaba.fastjson.JSONObject; |
| 5 | import com.sunyo.energy.location.controller.response.ResultJson; | 5 | import com.sunyo.energy.location.controller.response.ResultJson; |
| 6 | +import com.sunyo.energy.location.dao.PayRecordsMapper; | ||
| 6 | import com.sunyo.energy.location.dao.PayResponseMapper; | 7 | import com.sunyo.energy.location.dao.PayResponseMapper; |
| 7 | import com.sunyo.energy.location.model.PayResponse; | 8 | import com.sunyo.energy.location.model.PayResponse; |
| 9 | +import com.sunyo.energy.location.service.PayOrderService; | ||
| 10 | +import com.sunyo.energy.location.service.WaterMeterService; | ||
| 11 | +import com.sunyo.energy.location.service.imp.WaterMeterServiceImp; | ||
| 8 | import com.sunyo.energy.location.websocket.WebSocketServer; | 12 | import com.sunyo.energy.location.websocket.WebSocketServer; |
| 9 | import io.swagger.annotations.ApiOperation; | 13 | import io.swagger.annotations.ApiOperation; |
| 10 | import org.springframework.beans.factory.annotation.Autowired; | 14 | import org.springframework.beans.factory.annotation.Autowired; |
| @@ -29,6 +33,12 @@ public class PayRseponeController { | @@ -29,6 +33,12 @@ public class PayRseponeController { | ||
| 29 | @Autowired | 33 | @Autowired |
| 30 | private PayResponseMapper payResponseMapperl; | 34 | private PayResponseMapper payResponseMapperl; |
| 31 | 35 | ||
| 36 | + @Autowired | ||
| 37 | + private WaterMeterService waterMeterService; | ||
| 38 | + | ||
| 39 | + @Autowired | ||
| 40 | + private PayRecordsMapper payRecordsMapper; | ||
| 41 | + | ||
| 32 | /** | 42 | /** |
| 33 | * 接受字段 | 43 | * 接受字段 |
| 34 | * @param POSID 商户柜台代码 | 44 | * @param POSID 商户柜台代码 |
| @@ -49,7 +59,7 @@ public class PayRseponeController { | @@ -49,7 +59,7 @@ public class PayRseponeController { | ||
| 49 | * @param PAYTYPE 支付方式 | 59 | * @param PAYTYPE 支付方式 |
| 50 | * @param SIGN 数字签名 | 60 | * @param SIGN 数字签名 |
| 51 | */ | 61 | */ |
| 52 | - @RequestMapping(value = "/payRseponse") | 62 | + @RequestMapping(value = "/payResponse") |
| 53 | @ApiOperation(value = "支付回执是否成功") | 63 | @ApiOperation(value = "支付回执是否成功") |
| 54 | @ResponseBody | 64 | @ResponseBody |
| 55 | public ResultJson payCodeRsepone(@RequestParam(value = "POSID", required = false) String POSID, | 65 | public ResultJson payCodeRsepone(@RequestParam(value = "POSID", required = false) String POSID, |
| @@ -89,16 +99,30 @@ public class PayRseponeController { | @@ -89,16 +99,30 @@ public class PayRseponeController { | ||
| 89 | payResponse.setUsrinfo(USRINFO); | 99 | payResponse.setUsrinfo(USRINFO); |
| 90 | payResponse.setPaytype(PAYTYPE); | 100 | payResponse.setPaytype(PAYTYPE); |
| 91 | payResponse.setSign(SIGN); | 101 | payResponse.setSign(SIGN); |
| 92 | - int msg = 0; | 102 | + int msg =0; |
| 93 | int i = payResponseMapperl.insertSelective(payResponse); | 103 | int i = payResponseMapperl.insertSelective(payResponse); |
| 94 | if (i>0){ | 104 | if (i>0){ |
| 95 | - msg=1; | ||
| 96 | - WebSocketServer webSocketServer = new WebSocketServer(); | 105 | + msg =1; |
| 106 | + // 查询该订单设备编号 | ||
| 107 | + String orderNumber = payRecordsMapper.findOrderNumber(ORDERID); | ||
| 108 | + // 通知充值水费 | ||
| 109 | + if (!"".equals(orderNumber)){ | ||
| 110 | + ResultJson resultJson = waterMeterService.payWater(PAYMENT, orderNumber); | ||
| 111 | + if ("200".equals(resultJson.getCode())){ | ||
| 112 | + WebSocketServer webSocketServer = new WebSocketServer(); | ||
| 113 | + JSONObject jsonObject = new JSONObject(); | ||
| 114 | + jsonObject.put("orderNumber", ORDERID); | ||
| 115 | + jsonObject.put("success", "Y"); | ||
| 116 | + webSocketServer.broadcast(jsonObject.toJSONString()); | ||
| 117 | + }else { | ||
| 118 | + WebSocketServer webSocketServer = new WebSocketServer(); | ||
| 119 | + JSONObject jsonObject = new JSONObject(); | ||
| 120 | + jsonObject.put("orderNumber", ORDERID); | ||
| 121 | + jsonObject.put("success", "N"); | ||
| 122 | + webSocketServer.broadcast(jsonObject.toJSONString()); | ||
| 123 | + } | ||
| 124 | + } | ||
| 97 | 125 | ||
| 98 | - JSONObject jsonObject = new JSONObject(); | ||
| 99 | - jsonObject.put("orderNumber", ORDERID); | ||
| 100 | - jsonObject.put("success", SUCCESS); | ||
| 101 | - webSocketServer.broadcast(jsonObject.toJSONString()); | ||
| 102 | } | 126 | } |
| 103 | return i==1? new ResultJson("200","支付回执信息接受成功"):new ResultJson("500","支付回执信息接受失败"); | 127 | return i==1? new ResultJson("200","支付回执信息接受成功"):new ResultJson("500","支付回执信息接受失败"); |
| 104 | } | 128 | } |
| @@ -40,11 +40,9 @@ public class UserPayController { | @@ -40,11 +40,9 @@ public class UserPayController { | ||
| 40 | @ApiOperation(value = "充值水费") | 40 | @ApiOperation(value = "充值水费") |
| 41 | @PostMapping("/add") | 41 | @PostMapping("/add") |
| 42 | public ResultJson payWater(@RequestParam(value = "payFees", required = false) String payFees, | 42 | public ResultJson payWater(@RequestParam(value = "payFees", required = false) String payFees, |
| 43 | - @RequestParam(value = "wmId", required = false) String wmId, | ||
| 44 | - @RequestParam(value = "userId", required = false) String userId, | ||
| 45 | - @RequestParam(value = "realName", required = false) String realName){ | 43 | + @RequestParam(value = "wmId", required = false) String wmId){ |
| 46 | 44 | ||
| 47 | - return waterMeterService.payWater(payFees, wmId, userId, realName); | 45 | + return waterMeterService.payWater(payFees, wmId); |
| 48 | } | 46 | } |
| 49 | 47 | ||
| 50 | @ApiOperation(value = "请求返回二维码") | 48 | @ApiOperation(value = "请求返回二维码") |
| @@ -21,4 +21,6 @@ public interface PayRecordsMapper { | @@ -21,4 +21,6 @@ public interface PayRecordsMapper { | ||
| 21 | List<PayRecords> findAll(@Param(value = "orderNumber") String orderNumber, | 21 | List<PayRecords> findAll(@Param(value = "orderNumber") String orderNumber, |
| 22 | @Param(value = "startTime") String startTime, | 22 | @Param(value = "startTime") String startTime, |
| 23 | @Param(value = "endTime") String endTime); | 23 | @Param(value = "endTime") String endTime); |
| 24 | + | ||
| 25 | + String findOrderNumber(String orderId); | ||
| 24 | } | 26 | } |
| @@ -12,7 +12,7 @@ public interface WaterMeterService { | @@ -12,7 +12,7 @@ public interface WaterMeterService { | ||
| 12 | 12 | ||
| 13 | WaterMeter findRealTime(String wmId); | 13 | WaterMeter findRealTime(String wmId); |
| 14 | 14 | ||
| 15 | - ResultJson payWater(String payFees, String wmId, String userId, String realName); | 15 | + ResultJson payWater(String payFees, String wmId); |
| 16 | 16 | ||
| 17 | ResultJson waterMeterAll(String wmId); | 17 | ResultJson waterMeterAll(String wmId); |
| 18 | 18 |
| 1 | package com.sunyo.energy.location.service.imp; | 1 | package com.sunyo.energy.location.service.imp; |
| 2 | 2 | ||
| 3 | import com.sunyo.energy.location.dao.LocationMapper; | 3 | import com.sunyo.energy.location.dao.LocationMapper; |
| 4 | +import com.sunyo.energy.location.model.WaterMeter; | ||
| 4 | import com.sunyo.energy.location.service.LocationService; | 5 | import com.sunyo.energy.location.service.LocationService; |
| 5 | import com.sunyo.energy.location.utils.AllUtils; | 6 | import com.sunyo.energy.location.utils.AllUtils; |
| 6 | import org.springframework.beans.factory.annotation.Autowired; | 7 | import org.springframework.beans.factory.annotation.Autowired; |
| @@ -8,6 +9,7 @@ import org.springframework.stereotype.Service; | @@ -8,6 +9,7 @@ import org.springframework.stereotype.Service; | ||
| 8 | import org.springframework.util.StringUtils; | 9 | import org.springframework.util.StringUtils; |
| 9 | 10 | ||
| 10 | import java.util.ArrayList; | 11 | import java.util.ArrayList; |
| 12 | +import java.util.HashMap; | ||
| 11 | import java.util.List; | 13 | import java.util.List; |
| 12 | import java.util.Map; | 14 | import java.util.Map; |
| 13 | 15 | ||
| @@ -27,14 +29,33 @@ public class LocationServiceImp implements LocationService { | @@ -27,14 +29,33 @@ public class LocationServiceImp implements LocationService { | ||
| 27 | /** | 29 | /** |
| 28 | * 水费查询 | 30 | * 水费查询 |
| 29 | */ | 31 | */ |
| 30 | - // 查询房间号 水表实施查询list | ||
| 31 | - Map<String, Object> waterMap = locationMapper.userPayList(roomNumber); | ||
| 32 | - | ||
| 33 | - if (!StringUtils.isEmpty(waterMap.get("wmSacc").toString()) && !StringUtils.isEmpty( waterMap.get("wmLacc").toString())){ | ||
| 34 | - // 计算剩余量 充值量 减去 消费量 参数1 减去 参数2 | ||
| 35 | - String subtraction = AllUtils.nubmerSubtraction(waterMap.get("wmSacc").toString(), waterMap.get("wmLacc").toString()); | ||
| 36 | - // 余量 | ||
| 37 | - waterMap.put("subtraction", subtraction); | 32 | + // 查询房间号 水表本地查询list |
| 33 | + Map<String, Object> thisLocalityWaterMap = locationMapper.userPayList(roomNumber); | ||
| 34 | + Map<String, Object> distanceWaterMap = new HashMap<>(); | ||
| 35 | + // 是否为null 为null则去线上查询 | ||
| 36 | + if (thisLocalityWaterMap != null){ | ||
| 37 | + if (!StringUtils.isEmpty(thisLocalityWaterMap.get("wmSacc").toString()) && !StringUtils.isEmpty( thisLocalityWaterMap.get("wmLacc").toString())){ | ||
| 38 | + // 计算剩余量 充值量 减去 消费量 参数1 减去 参数2 | ||
| 39 | + String subtraction = AllUtils.nubmerSubtraction(thisLocalityWaterMap.get("wmSacc").toString(), thisLocalityWaterMap.get("wmLacc").toString()); | ||
| 40 | + // 余量 | ||
| 41 | + thisLocalityWaterMap.put("subtraction", subtraction); | ||
| 42 | + } | ||
| 43 | + list.add(thisLocalityWaterMap); | ||
| 44 | + }else { | ||
| 45 | + // 查询该房间号的水表编号 | ||
| 46 | + String wmId = locationMapper.findWmId(roomNumber); | ||
| 47 | + if (!"".equals(wmId) && "" != wmId){ | ||
| 48 | + Map<String,Object> waterMaps = new HashMap<>(); | ||
| 49 | + WaterMeterServiceImp waterMeterServiceImp = new WaterMeterServiceImp(); | ||
| 50 | + WaterMeter realTime = waterMeterServiceImp.findRealTime(wmId); | ||
| 51 | + String subtraction = AllUtils.nubmerSubtraction(realTime.getWmSacc(), realTime.getWmLacc()); | ||
| 52 | + distanceWaterMap.put("subtraction", subtraction); | ||
| 53 | + distanceWaterMap.put("wmSacc",realTime.getWmSacc()); | ||
| 54 | + distanceWaterMap.put("wmFmstate",realTime.getWmFmstate()); | ||
| 55 | + distanceWaterMap.put("wmLacc",realTime.getWmLacc()); | ||
| 56 | + distanceWaterMap.put("wmId", wmId); | ||
| 57 | + list.add(distanceWaterMap); | ||
| 58 | + } | ||
| 38 | } | 59 | } |
| 39 | /** | 60 | /** |
| 40 | * 电费查询 | 61 | * 电费查询 |
| @@ -44,7 +65,6 @@ public class LocationServiceImp implements LocationService { | @@ -44,7 +65,6 @@ public class LocationServiceImp implements LocationService { | ||
| 44 | // Map<String, Object> electricityMap = electricityMeterServiceImp.electricityInfo(roomNumber); | 65 | // Map<String, Object> electricityMap = electricityMeterServiceImp.electricityInfo(roomNumber); |
| 45 | // | 66 | // |
| 46 | // list.add(electricityMap); | 67 | // list.add(electricityMap); |
| 47 | - list.add(waterMap); | ||
| 48 | return list; | 68 | return list; |
| 49 | } | 69 | } |
| 50 | return null; | 70 | return null; |
| @@ -122,28 +122,19 @@ public class WaterMeterServiceImp implements WaterMeterService { | @@ -122,28 +122,19 @@ public class WaterMeterServiceImp implements WaterMeterService { | ||
| 122 | * 水费充值 换算总水量 生成订单 | 122 | * 水费充值 换算总水量 生成订单 |
| 123 | * @param payFees | 123 | * @param payFees |
| 124 | * @param wmId | 124 | * @param wmId |
| 125 | - * @param userId | ||
| 126 | - * @param realName | ||
| 127 | * @return | 125 | * @return |
| 128 | */ | 126 | */ |
| 129 | @Override | 127 | @Override |
| 130 | - public ResultJson payWater(String payFees, String wmId, String userId, String realName) { | 128 | + public ResultJson payWater(String payFees, String wmId) { |
| 131 | 129 | ||
| 132 | ResultJson<Object> resultJson = new ResultJson<>(); | 130 | ResultJson<Object> resultJson = new ResultJson<>(); |
| 133 | try { | 131 | try { |
| 134 | // 得到请求接口 返回值 和总水量 | 132 | // 得到请求接口 返回值 和总水量 |
| 135 | Map<String, Object> map = allWater(payFees, wmId); | 133 | Map<String, Object> map = allWater(payFees, wmId); |
| 136 | - | ||
| 137 | Map hashMap = JSON.parseObject(map.get("status").toString(), HashMap.class); | 134 | Map hashMap = JSON.parseObject(map.get("status").toString(), HashMap.class); |
| 138 | if ("0".equals(hashMap.get("state").toString())){ | 135 | if ("0".equals(hashMap.get("state").toString())){ |
| 139 | int update = waterMeterMapper.update(wmId, map.get("allSacc").toString()); | 136 | int update = waterMeterMapper.update(wmId, map.get("allSacc").toString()); |
| 140 | - // 成功生成水费订单 | ||
| 141 | - PayRecords payRecords = payRecords(payFees, wmId, userId, realName); | ||
| 142 | - | ||
| 143 | - int i = payRecordsMapper.insertSelective(payRecords); | ||
| 144 | - if (update > 0 && i >0){ | ||
| 145 | - resultJson.setCode("200"); | ||
| 146 | - } | 137 | + resultJson.setCode("200"); |
| 147 | }else { | 138 | }else { |
| 148 | resultJson.setCode("203"); | 139 | resultJson.setCode("203"); |
| 149 | } | 140 | } |
| @@ -67,6 +67,10 @@ | @@ -67,6 +67,10 @@ | ||
| 67 | select count(parent) from location where parent = #{value} | 67 | select count(parent) from location where parent = #{value} |
| 68 | </select> | 68 | </select> |
| 69 | 69 | ||
| 70 | + <select id="findWmId" parameterType="string" resultType="string"> | ||
| 71 | + select wm_id from location where adrname = #{value} | ||
| 72 | + </select> | ||
| 73 | + | ||
| 70 | <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" > | 74 | <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" > |
| 71 | delete from location | 75 | delete from location |
| 72 | where id = #{id,jdbcType=INTEGER} | 76 | where id = #{id,jdbcType=INTEGER} |
| @@ -47,6 +47,10 @@ | @@ -47,6 +47,10 @@ | ||
| 47 | order by payTime desc | 47 | order by payTime desc |
| 48 | </select> | 48 | </select> |
| 49 | 49 | ||
| 50 | + <select id="findOrderNumber" parameterType="string" resultType="string"> | ||
| 51 | + select distinct payTypeAddress from pay_records where orderNumber = #{value} | ||
| 52 | + </select> | ||
| 53 | + | ||
| 50 | <update id="deleteByPrimaryKey" parameterType="java.lang.Integer" > | 54 | <update id="deleteByPrimaryKey" parameterType="java.lang.Integer" > |
| 51 | UPDATE pay_records | 55 | UPDATE pay_records |
| 52 | SET reamke1 = '1' | 56 | SET reamke1 = '1' |
| @@ -221,23 +225,31 @@ | @@ -221,23 +225,31 @@ | ||
| 221 | </set> | 225 | </set> |
| 222 | where id = #{id,jdbcType=INTEGER} | 226 | where id = #{id,jdbcType=INTEGER} |
| 223 | </update> | 227 | </update> |
| 228 | +<!-- <update id="updateByPrimaryKey" parameterType="com.sunyo.energy.location.model.PayRecords" >--> | ||
| 229 | +<!-- update pay_records--> | ||
| 230 | +<!-- set payFees = #{payfees,jdbcType=DECIMAL},--> | ||
| 231 | +<!-- payUserId = #{payuserid,jdbcType=INTEGER},--> | ||
| 232 | +<!-- payTime = #{paytime,jdbcType=TIMESTAMP},--> | ||
| 233 | +<!-- payLocationId = #{paylocationid,jdbcType=INTEGER},--> | ||
| 234 | +<!-- payStatus = #{paystatus,jdbcType=BIT},--> | ||
| 235 | +<!-- payType = #{paytype,jdbcType=BIT},--> | ||
| 236 | +<!-- payFessType = #{payfesstype,jdbcType=BIT},--> | ||
| 237 | +<!-- orderNumber = #{ordernumber,jdbcType=VARCHAR},--> | ||
| 238 | +<!-- reamke1 = #{reamke1,jdbcType=VARCHAR},--> | ||
| 239 | +<!-- reamke2 = #{reamke2,jdbcType=VARCHAR},--> | ||
| 240 | +<!-- reamke3 = #{reamke3,jdbcType=VARCHAR},--> | ||
| 241 | +<!-- reamke4 = #{reamke4,jdbcType=VARCHAR},--> | ||
| 242 | +<!-- payUserName = #{payusername,jdbcType=VARCHAR},--> | ||
| 243 | +<!-- payLocationName = #{paylocationname,jdbcType=VARCHAR},--> | ||
| 244 | +<!-- payTypeAddress = #{paytypeaddress,jdbcType=VARCHAR}--> | ||
| 245 | +<!-- where id = #{id,jdbcType=INTEGER}--> | ||
| 246 | +<!-- </update>--> | ||
| 224 | <update id="updateByPrimaryKey" parameterType="com.sunyo.energy.location.model.PayRecords" > | 247 | <update id="updateByPrimaryKey" parameterType="com.sunyo.energy.location.model.PayRecords" > |
| 225 | update pay_records | 248 | update pay_records |
| 226 | - set payFees = #{payfees,jdbcType=DECIMAL}, | ||
| 227 | - payUserId = #{payuserid,jdbcType=INTEGER}, | ||
| 228 | - payTime = #{paytime,jdbcType=TIMESTAMP}, | ||
| 229 | - payLocationId = #{paylocationid,jdbcType=INTEGER}, | ||
| 230 | - payStatus = #{paystatus,jdbcType=BIT}, | ||
| 231 | - payType = #{paytype,jdbcType=BIT}, | ||
| 232 | - payFessType = #{payfesstype,jdbcType=BIT}, | ||
| 233 | - orderNumber = #{ordernumber,jdbcType=VARCHAR}, | ||
| 234 | - reamke1 = #{reamke1,jdbcType=VARCHAR}, | ||
| 235 | - reamke2 = #{reamke2,jdbcType=VARCHAR}, | ||
| 236 | - reamke3 = #{reamke3,jdbcType=VARCHAR}, | ||
| 237 | - reamke4 = #{reamke4,jdbcType=VARCHAR}, | ||
| 238 | - payUserName = #{payusername,jdbcType=VARCHAR}, | ||
| 239 | - payLocationName = #{paylocationname,jdbcType=VARCHAR}, | ||
| 240 | - payTypeAddress = #{paytypeaddress,jdbcType=VARCHAR} | ||
| 241 | - where id = #{id,jdbcType=INTEGER} | 249 | + set |
| 250 | + payStatus = 1, | ||
| 251 | + reamke3 = #{reamke3,jdbcType=VARCHAR} | ||
| 252 | + where orderNumber = #{ordernumber,jdbcType=VARCHAR} | ||
| 253 | + | ||
| 242 | </update> | 254 | </update> |
| 243 | </mapper> | 255 | </mapper> |
-
请 注册 或 登录 后发表评论