gaoluyang
3 天以前 d39e4f7d839167c16425086dfa2f8747bccfdff9
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
package cn.iocoder.yudao.module.crm.controller.admin.finance;
 
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.crm.controller.admin.finance.vo.CrmCustomerStatementRespVO;
import cn.iocoder.yudao.module.crm.controller.admin.finance.vo.CrmFinanceTrendRespVO;
import cn.iocoder.yudao.module.crm.controller.admin.finance.vo.CrmShippedNotInvoicedRespVO;
import cn.iocoder.yudao.module.crm.controller.admin.finance.vo.CrmUnwrittenOffRespVO;
import cn.iocoder.yudao.module.crm.service.finance.CrmFinanceReportService;
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 org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
 
import java.util.List;
 
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
 
/**
 * 管理后台 - CRM 财务对账与报表
 *
 * @author 超级管理员
 */
@Tag(name = "管理后台 - CRM 财务对账与报表")
@RestController
@RequestMapping("/crm/finance/report")
@Validated
public class CrmFinanceReportController {
 
    @Resource
    private CrmFinanceReportService financeReportService;
 
    @GetMapping("/customer-statement")
    @Operation(summary = "获得客户应收对账单", description = "按客户统计所有已审核销售订单的订单金额、出库金额、开票金额、回款金额、未核销应收及下月回款计划")
    @Parameter(name = "customerId", description = "客户编号", required = true)
    @PreAuthorize("@ss.hasPermission('crm:receivable:query')")
    public CommonResult<CrmCustomerStatementRespVO> getCustomerStatement(@RequestParam("customerId") Long customerId) {
        return success(financeReportService.getCustomerStatement(customerId));
    }
 
    @GetMapping("/shipped-not-invoiced")
    @Operation(summary = "获得已发货未开票明细")
    @Parameter(name = "customerId", description = "客户编号,不传时统计全部客户")
    @PreAuthorize("@ss.hasPermission('crm:invoice:query')")
    public CommonResult<List<CrmShippedNotInvoicedRespVO>> getShippedNotInvoicedList(
            @RequestParam(value = "customerId", required = false) Long customerId) {
        return success(financeReportService.getShippedNotInvoicedList(customerId));
    }
 
    @GetMapping("/unwritten-off")
    @Operation(summary = "获得未核销应收明细", description = "已审批通过开票中仍有未回款金额的部分,返回账龄")
    @Parameter(name = "customerId", description = "客户编号,不传时统计全部客户")
    @PreAuthorize("@ss.hasPermission('crm:receivable:query')")
    public CommonResult<List<CrmUnwrittenOffRespVO>> getUnwrittenOffList(
            @RequestParam(value = "customerId", required = false) Long customerId) {
        return success(financeReportService.getUnwrittenOffList(customerId));
    }
 
    @GetMapping("/monthly-trend")
    @Operation(summary = "获得财务月度趋势", description = "返回最近 N 个月的开票金额(审批通过)与回款金额(审批通过)")
    @Parameter(name = "months", description = "月份数量,默认 6,范围 1-36")
    @PreAuthorize("@ss.hasPermission('crm:receivable:query')")
    public CommonResult<List<CrmFinanceTrendRespVO>> getMonthlyTrend(
            @RequestParam(value = "months", required = false, defaultValue = "6") Integer months) {
        return success(financeReportService.getMonthlyTrend(months));
    }
 
}