doum
7 天以前 074bcb8394fab66ce531c219e1e7de7c142ff2d5
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
package com.doumee.cloud.admin;
 
import com.doumee.api.BaseController;
import com.doumee.core.annotation.pr.PreventRepeat;
import com.doumee.core.model.ApiResponse;
import com.doumee.core.model.PageData;
import com.doumee.core.model.PageWrap;
import com.doumee.core.utils.Constants;
import com.doumee.config.annotation.CloudRequiredPermission;
import com.doumee.dao.business.dto.*;
import com.doumee.dao.business.model.YwConditioner;
import com.doumee.dao.business.model.YwCustomerGs;
import com.doumee.dao.business.model.YwElectrical;
import com.doumee.service.business.YwCustomerRechargeBizService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import javax.servlet.http.HttpServletResponse;
import java.util.Map;
 
@Api(tags = "商户充值")
@RestController
@RequestMapping(Constants.CLOUD_SERVICE_URL_INDEX + "/business/ywCustomerRecharge")
public class YwCustomerRechargeCloudController extends BaseController {
 
    @Autowired
    private YwCustomerRechargeBizService ywCustomerRechargeBizService;
 
    @ApiOperation("商户分页列表")
    @PostMapping("/merchantPage")
    @CloudRequiredPermission("business:ywcustomerrecharge:query")
    public ApiResponse<PageData<YwCustomerRechargeMerchantVO>> merchantPage(
            @RequestBody PageWrap<YwCustomerRechargeQueryDTO> pageWrap,
            @RequestHeader(Constants.HEADER_USER_TOKEN) String token) {
        if (pageWrap == null) {
            pageWrap = new PageWrap<>();
        }
        return ApiResponse.success(ywCustomerRechargeBizService.findMerchantPage(pageWrap));
    }
 
    @ApiOperation("商户详情")
    @GetMapping("/{customerId}/detail")
    @CloudRequiredPermission("business:ywcustomerrecharge:query")
    public ApiResponse<YwCustomerRechargeDetailVO> detail(@PathVariable Integer customerId,
                                                          @RequestHeader(Constants.HEADER_USER_TOKEN) String token) {
        return ApiResponse.success(ywCustomerRechargeBizService.getDetail(customerId));
    }
 
    @ApiOperation("关联电表列表")
    @PostMapping("/electrical/page")
    @CloudRequiredPermission("business:ywcustomerrecharge:query")
    public ApiResponse<PageData<YwElectrical>> electricalPage(
            @RequestBody PageWrap<YwElectrical> pageWrap,
            @RequestParam Integer customerId,
            @RequestHeader(Constants.HEADER_USER_TOKEN) String token) {
        return ApiResponse.success(ywCustomerRechargeBizService.listCustomerElectrical(pageWrap, customerId));
    }
 
    @ApiOperation("可选电表列表")
    @PostMapping("/electrical/selectablePage")
    @CloudRequiredPermission("business:ywcustomerrecharge:bindDevice")
    public ApiResponse<PageData<YwElectrical>> selectableElectricalPage(
            @RequestBody PageWrap<YwElectrical> pageWrap,
            @RequestParam Integer customerId,
            @RequestHeader(Constants.HEADER_USER_TOKEN) String token) {
        return ApiResponse.success(ywCustomerRechargeBizService.pageSelectableElectrical(pageWrap, customerId));
    }
 
    @PreventRepeat
    @ApiOperation("保存关联电表")
    @PostMapping("/electrical/save")
    @CloudRequiredPermission("business:ywcustomerrecharge:bindDevice")
    public ApiResponse saveElectrical(@RequestBody YwCustomerElectricalSaveDTO dto,
                                      @RequestHeader(Constants.HEADER_USER_TOKEN) String token) {
        ywCustomerRechargeBizService.saveCustomerElectrical(dto, getLoginUser(token));
        return ApiResponse.success(null);
    }
 
    @ApiOperation("删除关联电表")
    @GetMapping("/electrical/delete")
    @CloudRequiredPermission("business:ywcustomerrecharge:bindDevice")
    public ApiResponse deleteElectrical(@RequestParam Integer customerId,
                                        @RequestParam Integer electricalId,
                                        @RequestHeader(Constants.HEADER_USER_TOKEN) String token) {
        ywCustomerRechargeBizService.removeCustomerElectrical(customerId, electricalId, getLoginUser(token));
        return ApiResponse.success(null);
    }
 
    @ApiOperation("关联空调列表")
    @PostMapping("/conditioner/page")
    @CloudRequiredPermission("business:ywcustomerrecharge:query")
    public ApiResponse<PageData<YwConditioner>> conditionerPage(
            @RequestBody PageWrap<YwConditioner> pageWrap,
            @RequestParam Integer customerId,
            @RequestHeader(Constants.HEADER_USER_TOKEN) String token) {
        return ApiResponse.success(ywCustomerRechargeBizService.listCustomerConditioner(pageWrap, customerId));
    }
 
    @ApiOperation("空调 GS 配置")
    @GetMapping("/conditioner/gsConfig")
    @CloudRequiredPermission("business:ywcustomerrecharge:query")
    public ApiResponse<YwCustomerGs> gsConfig(@RequestParam Integer customerId,
                                              @RequestHeader(Constants.HEADER_USER_TOKEN) String token) {
        return ApiResponse.success(ywCustomerRechargeBizService.getCustomerGsConfig(customerId));
    }
 
    @PreventRepeat
    @ApiOperation("保存空调 GS 配置")
    @PostMapping("/conditioner/saveGsConfig")
    @CloudRequiredPermission("business:ywcustomerrecharge:bindDevice")
    public ApiResponse saveGsConfig(@RequestBody YwCustomerGsConfigDTO dto,
                                    @RequestHeader(Constants.HEADER_USER_TOKEN) String token) {
        ywCustomerRechargeBizService.saveCustomerGsConfig(dto, getLoginUser(token));
        return ApiResponse.success(null);
    }
 
    @PreventRepeat
    @ApiOperation("电表充值")
    @PostMapping("/recharge/electrical")
    @CloudRequiredPermission("business:ywcustomerrecharge:recharge")
    public ApiResponse<String> rechargeElectrical(@RequestBody YwCustomerRechargeElectricalDTO dto,
                                                  @RequestHeader(Constants.HEADER_USER_TOKEN) String token) {
        return ApiResponse.success(ywCustomerRechargeBizService.rechargeElectrical(dto, getLoginUser(token)));
    }
 
    @PreventRepeat
    @ApiOperation("电表清零")
    @PostMapping("/reset/electrical")
    @CloudRequiredPermission("business:ywcustomerrecharge:recharge")
    public ApiResponse<String> resetElectrical(@RequestBody YwCustomerRechargeElectricalDTO dto,
                                               @RequestHeader(Constants.HEADER_USER_TOKEN) String token) {
        return ApiResponse.success(ywCustomerRechargeBizService.resetElectricalAccount(dto, getLoginUser(token)));
    }
 
    @ApiOperation("电表抄表刷新")
    @GetMapping("/readMeter")
    @CloudRequiredPermission("business:ywcustomerrecharge:recharge")
    public ApiResponse<Map<String, Object>> readMeter(@RequestParam Integer customerId,
                                                      @RequestParam Integer electricalId,
                                                      @RequestHeader(Constants.HEADER_USER_TOKEN) String token) {
        return ApiResponse.success(ywCustomerRechargeBizService.readMeterAndRefresh(customerId, electricalId, getLoginUser(token)));
    }
 
    @ApiOperation("电表远程信息")
    @GetMapping("/electrical/remoteInfo")
    @CloudRequiredPermission("business:ywcustomerrecharge:recharge")
    public ApiResponse<Map<String, Object>> electricalRemoteInfo(@RequestParam Integer electricalId,
                                                                  @RequestHeader(Constants.HEADER_USER_TOKEN) String token) {
        return ApiResponse.success(ywCustomerRechargeBizService.getElectricalRemoteInfo(electricalId));
    }
 
    @ApiOperation("空调充值前信息")
    @GetMapping("/recharge/conditioner/info")
    @CloudRequiredPermission("business:ywcustomerrecharge:recharge")
    public ApiResponse<Map<String, Object>> conditionerRechargeInfo(@RequestParam Integer customerId,
                                                                      @RequestHeader(Constants.HEADER_USER_TOKEN) String token) {
        return ApiResponse.success(ywCustomerRechargeBizService.getConditionerRechargeInfo(customerId));
    }
 
    @PreventRepeat
    @ApiOperation("空调充值")
    @PostMapping("/recharge/conditioner")
    @CloudRequiredPermission("business:ywcustomerrecharge:recharge")
    public ApiResponse<String> rechargeConditioner(@RequestBody YwCustomerRechargeConditionerDTO dto,
                                                   @RequestHeader(Constants.HEADER_USER_TOKEN) String token) {
        return ApiResponse.success(ywCustomerRechargeBizService.rechargeConditioner(dto, getLoginUser(token)));
    }
 
    @PreventRepeat
    @ApiOperation("空调清零")
    @PostMapping("/clean/conditioner")
    @CloudRequiredPermission("business:ywcustomerrecharge:recharge")
    public ApiResponse<String> cleanConditioner(@RequestParam Integer customerId,
                                                @RequestHeader(Constants.HEADER_USER_TOKEN) String token) {
        return ApiResponse.success(ywCustomerRechargeBizService.cleanConditionerAccount(customerId, getLoginUser(token)));
    }
 
    @ApiOperation("充值记录分页")
    @PostMapping("/rechargeRecord/page")
    @CloudRequiredPermission("business:ywcustomerrechargerecord:query")
    public ApiResponse<PageData<YwCustomerRechargeRecordVO>> rechargeRecordPage(
            @RequestBody PageWrap<YwCustomerRechargeRecordQueryDTO> pageWrap,
            @RequestHeader(Constants.HEADER_USER_TOKEN) String token) {
        return ApiResponse.success(ywCustomerRechargeBizService.findRechargeRecordPage(pageWrap));
    }
 
    @PreventRepeat
    @ApiOperation("再次提交充值")
    @PostMapping("/rechargeRecord/retry/{id}")
    @CloudRequiredPermission("business:ywcustomerrechargerecord:retry")
    public ApiResponse<String> retryRecharge(@PathVariable Integer id,
                                             @RequestHeader(Constants.HEADER_USER_TOKEN) String token) {
        return ApiResponse.success(ywCustomerRechargeBizService.retryRecharge(id, getLoginUser(token)));
    }
 
    @PreventRepeat
    @ApiOperation("手动同步充值状态")
    @PostMapping("/rechargeRecord/sync/{id}")
    @CloudRequiredPermission("business:ywcustomerrechargerecord:syncStatus")
    public ApiResponse<String> syncRechargeStatus(@PathVariable Integer id,
                                                  @RequestHeader(Constants.HEADER_USER_TOKEN) String token) {
        return ApiResponse.success(ywCustomerRechargeBizService.syncRechargeStatus(id, getLoginUser(token)));
    }
 
    @ApiOperation("导出充值记录")
    @PostMapping("/rechargeRecord/exportExcel")
    @CloudRequiredPermission("business:ywcustomerrechargerecord:exportExcel")
    public void exportRechargeRecord(@RequestBody PageWrap<YwCustomerRechargeRecordQueryDTO> pageWrap,
                                     HttpServletResponse response,
                                     @RequestHeader(Constants.HEADER_USER_TOKEN) String token) {
        ywCustomerRechargeBizService.exportRechargeRecord(pageWrap, response);
    }
}