PayOrderController.java
6.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
package com.sunyo.energy.location.controller;
import com.github.pagehelper.PageInfo;
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.dao.WaterEleCountMoneyMapper;
import com.sunyo.energy.location.model.Location;
import com.sunyo.energy.location.model.PayRecords;
import com.sunyo.energy.location.model.WaterEleCountMoney;
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 org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/**
* Created by XYH on 2019/12/16.
* 订单查询,新增,更新,删除
*/
@Api(description = "订单管理")
@RestController
@RequestMapping("/order")
public class PayOrderController {
@Autowired
PayOrderService payOrderService;
@Autowired
PayRecordsMapper payRecordsMapper;
@Autowired
ElectricityMeterService electricityMeterService;
@Autowired
private WaterMeterService waterMeterService;
@Autowired
private LocationMapper locationMapper;
@Autowired
WaterEleCountMoneyMapper waterEleCountMoneyMapperl;
@ApiOperation(value = "查询缴费订单")
@RequestMapping("/list")
public PageInfo<PayRecords> getOrder(@RequestParam(value = "pageSize", required = false, defaultValue = "100000") int pageSize,
@RequestParam(value = "pageNum", required = false, defaultValue = "1") int pageNum,
@RequestParam(value = "orderNumber", required = false) String orderNumber,
@RequestParam(value = "payTime", required = false) String payTime,
@RequestParam(value = "username", required = false) String username,
@RequestParam(value = "payType", required = false) String payType,
@RequestParam(value = "paystatus", required = false) String paystatus) {
PageInfo<PayRecords> order = payOrderService.getOrder(pageSize, pageNum, orderNumber, payTime, username, payType, paystatus);
return order;
}
@ApiOperation(value = "新增缴费订单")
@PostMapping("/add")
public ResultJson addOrder(@RequestBody PayRecords records) {
int mgs = 0;
int result = payOrderService.addOrder(records);
if (result > 0) {
mgs = 1;
}
return mgs == 1 ? new ResultJson("200", "新增订单成功") : new ResultJson("500", "新增订单失败");
}
@ApiOperation(value = "更新缴费订单")
@PutMapping("/edi")
public ResultJson ediOrder(@RequestBody PayRecords records) {
int mgs = 0;
int result = payOrderService.ediOrder(records);
if (result > 0) {
mgs = 1;
}
return mgs == 1 ? new ResultJson("200", "订单信息更新成功") : new ResultJson("500", "订单信息更新失败");
}
@ApiOperation(value = "删除缴费订单")
@DeleteMapping("/del")
public ResultJson delOrder(@RequestBody PayRecords payRecords) {
int mgs = 0;
int result = payOrderService.delOrder(payRecords);
if (result > 0) {
mgs = 1;
}
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());
/**
* 支付状态 充值状态满足条件进入否则不操作
*/
if (payRecords.getPaystatus() == true && "0".equals(payRecords.getReamke3())){
/**
* 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;
}
}
}else {
return new ResultJson("201", "充值失败");
}
}
@ApiOperation(value = "处理失败订单充值信息")
@PostMapping("/remoteTopUpWater")
public ResultJson remoteTopUpWater(@RequestBody PayRecords payRecords) throws Exception {
/**
* 查询水表编号
*/
Location location = locationMapper.waterId_eleId(payRecords.getPaylocationname());
ResultJson resultJson = waterMeterService.remoteTopUpWater(location.getWmid());
return resultJson;
}
@ApiOperation(value = "水电剩余余额统计")
@GetMapping("/waterEleCount")
public ResultJson waterEleCount() throws Exception {
List<WaterEleCountMoney> waterEleCountMonies = waterEleCountMoneyMapperl.selectByPrimaryKey();
return new ResultJson("200", "success", waterEleCountMonies);
}
}