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
package com.by4cloud.platformx.business.controller;
 
import cn.hutool.core.util.StrUtil;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.by4cloud.platformx.business.dto.BankStatementUpdateDTO;
import com.by4cloud.platformx.business.entity.BankStatement;
import com.by4cloud.platformx.common.core.util.R;
import com.by4cloud.platformx.common.log.annotation.SysLog;
import com.by4cloud.platformx.business.service.BankStatementService;
import org.springframework.security.access.prepost.PreAuthorize;
import com.by4cloud.platformx.common.excel.annotation.ResponseExcel;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.http.HttpHeaders;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
 
import java.util.List;
import java.util.Objects;
 
/**
 * 银行流水
 *
 * @author syt
 * @date 2026-08-07 16:10:36
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/bankStatement" )
@Tag(description = "bankStatement" , name = "银行流水管理" )
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class BankStatementController {
 
    private final  BankStatementService bankStatementService;
 
    /**
     * 分页查询
     * @param page 分页对象
     * @param bankStatement 银行流水
     * @return
     */
    @Operation(summary = "分页查询" , description = "分页查询" )
    @GetMapping("/page" )
    @PreAuthorize("@pms.hasPermission('business_bankStatement_view')" )
    public R getBankStatementPage(@ParameterObject Page page, @ParameterObject BankStatement bankStatement) {
        LambdaQueryWrapper<BankStatement> wrapper = Wrappers.lambdaQuery();
        wrapper.like(StrUtil.isNotBlank(bankStatement.getPayBankAccName()),BankStatement::getPayBankAccName,bankStatement.getPayBankAccName());
        wrapper.like(StrUtil.isNotBlank(bankStatement.getReceiveBankAccName()),BankStatement::getReceiveBankAccName,bankStatement.getReceiveBankAccName());
        wrapper.orderByDesc(BankStatement::getCreateTime);
        return R.ok(bankStatementService.pageByScope(page, wrapper));
    }
 
 
    /**
     * 通过id查询银行流水
     * @param id id
     * @return R
     */
    @Operation(summary = "通过id查询" , description = "通过id查询" )
    @GetMapping("/{id}" )
    @PreAuthorize("@pms.hasPermission('business_bankStatement_view')" )
    public R getById(@PathVariable("id" ) Long id) {
        return R.ok(bankStatementService.getById(id));
    }
 
    /**
     * 新增银行流水
     * @param bankStatement 银行流水
     * @return R
     */
    @Operation(summary = "新增银行流水" , description = "新增银行流水" )
    @SysLog("新增银行流水" )
    @PostMapping
    @PreAuthorize("@pms.hasPermission('business_bankStatement_add')" )
    public R save(@RequestBody BankStatement bankStatement) {
        return R.ok(bankStatementService.save(bankStatement));
    }
 
    /**
     * 修改银行流水
     * @param updateDTO 银行流水
     * @return R
     */
    @Operation(summary = "修改银行流水" , description = "修改银行流水" )
    @SysLog("修改银行流水" )
    @PostMapping("/edit")
    public R updateById(@RequestBody BankStatementUpdateDTO updateDTO) {
        return bankStatementService.edit(updateDTO);
    }
 
    /**
     * 通过id删除银行流水
     * @param ids id列表
     * @return R
     */
    @Operation(summary = "通过id删除银行流水" , description = "通过id删除银行流水" )
    @SysLog("通过id删除银行流水" )
    @DeleteMapping
    @PreAuthorize("@pms.hasPermission('business_bankStatement_del')" )
    public R removeById(@RequestBody Long[] ids) {
        return R.ok(bankStatementService.removeBatchByIds(CollUtil.toList(ids)));
    }
 
 
    /**
     * 导出excel 表格
     * @param bankStatement 查询条件
        * @param ids 导出指定ID
     * @return excel 文件流
     */
    @ResponseExcel
    @GetMapping("/export")
    @PreAuthorize("@pms.hasPermission('business_bankStatement_export')" )
    public List<BankStatement> export(BankStatement bankStatement,Long[] ids) {
        return bankStatementService.list(Wrappers.lambdaQuery(bankStatement).in(ArrayUtil.isNotEmpty(ids), BankStatement::getId, ids));
    }
 
    /**
     * 通过id查询银行流水历史确认
     * @param id id
     * @return R
     */
    @Operation(summary = "通过id查询银行流水历史确认" , description = "通过id查询银行流水历史确认" )
    @GetMapping("/history/{id}" )
    public R getHistoryById(@PathVariable("id" ) Long id) {
        return bankStatementService.getHistoryById(id);
    }
 
    /**
     * 通过id删除银行流水历史确认
     * @param id id
     * @return R
     */
    @Operation(summary = "通过id删除银行流水历史确认" , description = "通过id删除银行流水历史确认" )
    @GetMapping("/itemDel/{id}" )
    public R delHistoryById(@PathVariable("id" ) Long id) {
        return bankStatementService.delHistoryById(id);
    }
 
    /**
     * 通过id退回银行流水历史
     * @param id id
     * @return R
     */
    @Operation(summary = "通过id退回银行流水历史" , description = "通过id退回银行流水历史" )
    @GetMapping("/backHis/{id}" )
    public R backHis(@PathVariable("id" ) Long id) {
        return bankStatementService.backHis(id);
    }
 
    /**
     * 通过id退回银行流水余额
     * @param id id
     * @return R
     */
    @Operation(summary = "通过id退回银行流水余额" , description = "通过id退回银行流水余额" )
    @GetMapping("/backBal/{id}" )
    public R backBal(@PathVariable("id" ) Long id) {
        return bankStatementService.backBal(id);
    }
 
    /**
     * 通过id退回银行流水全部
     * @param id id
     * @return R
     */
    @Operation(summary = "通过id退回银行流水全部" , description = "通过id退回银行流水全部" )
    @GetMapping("/backAll/{id}" )
    public R backAll(@PathVariable("id" ) Long id) {
        return bankStatementService.backAll(id);
    }
 
}