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 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> 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> 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> getMonthlyTrend( @RequestParam(value = "months", required = false, defaultValue = "6") Integer months) { return success(financeReportService.getMonthlyTrend(months)); } }