xiaoyi
3 天以前 abf1c0a35d85d38239ff5d2ed746a4e4b797c9d1
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
package cn.iocoder.yudao.module.crm.controller.admin.refund;
 
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.module.crm.controller.admin.refund.vo.CrmRefundAuditReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.refund.vo.CrmRefundPageReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.refund.vo.CrmRefundRespVO;
import cn.iocoder.yudao.module.crm.controller.admin.refund.vo.CrmRefundSaveReqVO;
import cn.iocoder.yudao.module.crm.service.refund.CrmRefundService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
 
import java.io.IOException;
import java.util.List;
import java.util.Map;
 
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.common.pojo.PageParam.PAGE_SIZE_NONE;
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
 
@Tag(name = "管理后台 - CRM 退费单")
@RestController
@RequestMapping("/crm/refund")
@Validated
public class CrmRefundController {
 
    @Resource
    private CrmRefundService refundService;
 
    @PostMapping("/create")
    @Operation(summary = "创建退费单")
    @PreAuthorize("@ss.hasPermission('crm:refund:create')")
    public CommonResult<Long> createRefund(@Valid @RequestBody CrmRefundSaveReqVO createReqVO) {
        return success(refundService.createRefund(createReqVO));
    }
 
    @PutMapping("/update")
    @Operation(summary = "更新退费单")
    @PreAuthorize("@ss.hasPermission('crm:refund:update')")
    public CommonResult<Boolean> updateRefund(@Valid @RequestBody CrmRefundSaveReqVO updateReqVO) {
        refundService.updateRefund(updateReqVO);
        return success(true);
    }
 
    @PutMapping("/audit")
    @Operation(summary = "审批退费单(通过/驳回)")
    @PreAuthorize("@ss.hasPermission('crm:refund:update')")
    public CommonResult<Boolean> auditRefund(@Valid @RequestBody CrmRefundAuditReqVO auditReqVO) {
        refundService.auditRefund(auditReqVO);
        return success(true);
    }
 
    @PutMapping("/submit")
    @Operation(summary = "提交退费单审批")
    @PreAuthorize("@ss.hasPermission('crm:refund:update')")
    public CommonResult<Boolean> submitRefund(@RequestParam("id") Long id,
                                              @RequestParam("processDefinitionKey") String processDefinitionKey) {
        refundService.submitRefund(id, processDefinitionKey, getLoginUserId());
        return success(true);
    }
 
    @GetMapping("/approve-process-list")
    @Operation(summary = "获得退费单审批流程定义列表")
    @PreAuthorize("@ss.hasPermission('crm:refund:query')")
    public CommonResult<List<Map<String, Object>>> getRefundApproveProcessDefinitionList() {
        return success(refundService.getRefundApproveProcessDefinitionList());
    }
 
    @DeleteMapping("/delete")
    @Operation(summary = "删除退费单")
    @Parameter(name = "id", description = "编号", required = true)
    @PreAuthorize("@ss.hasPermission('crm:refund:delete')")
    public CommonResult<Boolean> deleteRefund(@RequestParam("id") Long id) {
        refundService.deleteRefund(id);
        return success(true);
    }
 
    @GetMapping("/get")
    @Operation(summary = "获得退费单")
    @Parameter(name = "id", description = "编号", required = true)
    @PreAuthorize("@ss.hasPermission('crm:refund:query')")
    public CommonResult<CrmRefundRespVO> getRefund(@RequestParam("id") Long id) {
        return success(refundService.getRefund(id));
    }
 
    @GetMapping("/page")
    @Operation(summary = "获得退费单分页")
    @PreAuthorize("@ss.hasPermission('crm:refund:query')")
    public CommonResult<PageResult<CrmRefundRespVO>> getRefundPage(@Valid CrmRefundPageReqVO pageReqVO) {
        return success(refundService.getRefundPage(pageReqVO));
    }
 
    @GetMapping("/export-excel")
    @Operation(summary = "导出退费单 Excel")
    @PreAuthorize("@ss.hasPermission('crm:refund:export')")
    @ApiAccessLog(operateType = EXPORT)
    public void exportRefundExcel(@Valid CrmRefundPageReqVO exportReqVO,
                                  HttpServletResponse response) throws IOException {
        exportReqVO.setPageSize(PAGE_SIZE_NONE);
        List<CrmRefundRespVO> list = refundService.getRefundList(exportReqVO);
        ExcelUtils.write(response, "退费单.xls", "数据", CrmRefundRespVO.class, list);
    }
 
}