From 3ae8d536cd4f4fc082084e239c2292950ed0389f Mon Sep 17 00:00:00 2001
From: luojiaquan <1583622118@qq.com>
Date: Tue, 13 Oct 2026 10:38:50 +0800
Subject: [PATCH] =?UTF-8?q?=E6=94=B6=E6=AC=BE=E7=AE=A1=E7=90=86?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../controller/ar/ArReceiptController.java | 164 ++
.../customermoney/domain/CustomerReceipt.java | 6 +
.../mapper/ar/ArBalanceWriteoffMapper.xml | 7 +
.../mapper/customer/CustomerMoneyMapper.xml | 17 +-
bms-back/sql/20261013_ar_receipt_menu.sql | 44 +
bms-front/src/api/ar/receipt.js | 50 +
bms-front/src/views/ar/receipt/index.vue | 1371 +++++++++++++++++
7 files changed, 1655 insertions(+), 4 deletions(-)
create mode 100644 bms-back/bms-admin/src/main/java/com/bms/web/controller/ar/ArReceiptController.java
create mode 100644 bms-back/sql/20261013_ar_receipt_menu.sql
create mode 100644 bms-front/src/api/ar/receipt.js
create mode 100644 bms-front/src/views/ar/receipt/index.vue
diff --git a/bms-back/bms-admin/src/main/java/com/bms/web/controller/ar/ArReceiptController.java b/bms-back/bms-admin/src/main/java/com/bms/web/controller/ar/ArReceiptController.java
new file mode 100644
index 00000000..59a66ffa
--- /dev/null
+++ b/bms-back/bms-admin/src/main/java/com/bms/web/controller/ar/ArReceiptController.java
@@ -0,0 +1,164 @@
+package com.bms.web.controller.ar;
+
+import java.time.LocalDate;
+import java.time.format.DateTimeFormatter;
+import java.util.List;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import com.bms.ar.domain.ArBalanceWriteoff;
+import com.bms.ar.domain.ArBill;
+import com.bms.ar.service.IArBalanceWriteoffService;
+import com.bms.common.annotation.Log;
+import com.bms.common.core.controller.BaseController;
+import com.bms.common.core.domain.AjaxResult;
+import com.bms.common.core.page.TableDataInfo;
+import com.bms.common.enums.BusinessType;
+import com.bms.customer.customermoney.domain.CustomerReceipt;
+import com.bms.customer.customermoney.service.ICustomerMoneyService;
+
+/**
+ * 收款管理 Controller(账单管理-收款管理)
+ *
+ * 收款登记/审核/取消与「客户余额-登记收款」复用同一套 Service 逻辑;
+ * 账单核销同样复用余额核销 Service:登记收款时可携带核销计划(审核通过后联动核销),
+ * 本页「账单核销」页签可直接对账单发起核销/反核销。
+ *
+ * @author bms
+ * @date 2026-10-13
+ */
+@RestController
+@RequestMapping("/ar/receipt")
+public class ArReceiptController extends BaseController
+{
+ @Autowired
+ private ICustomerMoneyService customerMoneyService;
+
+ @Autowired
+ private IArBalanceWriteoffService balanceWriteoffService;
+
+ /** 收款时间查询/默认范围格式:精确到秒 */
+ private static final DateTimeFormatter DATE_TIME_FORMATTER =
+ DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+
+ /**
+ * 查询收款记录(跨客户)。支持按客户、收款时间(精确到时分秒)等维度查询,未传时间范围时默认查当天。
+ */
+ @PreAuthorize("@ss.hasPermi('ar:receipt:list')")
+ @GetMapping("/list")
+ public TableDataInfo list(CustomerReceipt query)
+ {
+ if (query != null)
+ {
+ Object begin = query.getParams() == null ? null : query.getParams().get("beginTime");
+ Object end = query.getParams() == null ? null : query.getParams().get("endTime");
+ if (begin == null && end == null)
+ {
+ // 默认当天 00:00:00 ~ 23:59:59
+ LocalDate today = LocalDate.now();
+ query.getParams().put("beginTime", today.atStartOfDay().format(DATE_TIME_FORMATTER));
+ query.getParams().put("endTime", today.atTime(23, 59, 59).format(DATE_TIME_FORMATTER));
+ }
+ }
+ startPage();
+ List list = customerMoneyService.selectReceiptList(query);
+ return getDataTable(list);
+ }
+
+ /**
+ * 获取收款单详情(含核销计划与收款附件)
+ */
+ @PreAuthorize("@ss.hasPermi('ar:receipt:query')")
+ @GetMapping("/{id}")
+ public AjaxResult getInfo(@PathVariable("id") Long id)
+ {
+ return success(customerMoneyService.selectReceiptById(id));
+ }
+
+ /**
+ * 登记收款(必须选择客户;默认待确认,审核通过后入账并执行登记时选择的核销计划)
+ */
+ @PreAuthorize("@ss.hasPermi('ar:receipt:add')")
+ @Log(title = "收款管理-登记收款", businessType = BusinessType.INSERT)
+ @PostMapping
+ public AjaxResult add(@RequestBody CustomerReceipt receipt)
+ {
+ receipt.setCreateBy(getUsername());
+ return toAjax(customerMoneyService.insertReceipt(receipt));
+ }
+
+ /**
+ * 审核通过收款单:确认后金额计入客户余额,登记时选择的账单一并核销
+ */
+ @PreAuthorize("@ss.hasPermi('ar:receipt:review')")
+ @Log(title = "收款管理-收款审核", businessType = BusinessType.UPDATE)
+ @PutMapping("/confirm/{id}")
+ public AjaxResult confirm(@PathVariable("id") Long id)
+ {
+ return toAjax(customerMoneyService.confirmReceipt(id));
+ }
+
+ /**
+ * 取消收款单(仅待确认可取消)
+ */
+ @PreAuthorize("@ss.hasPermi('ar:receipt:edit')")
+ @Log(title = "收款管理-取消收款", businessType = BusinessType.UPDATE)
+ @PutMapping("/cancel/{id}")
+ public AjaxResult cancel(@PathVariable("id") Long id)
+ {
+ return toAjax(customerMoneyService.cancelReceipt(id));
+ }
+
+ /**
+ * 查询客户可核销账单(已确认/部分核销,未核销额大于0),登记收款选账单与核销页签共用
+ */
+ @PreAuthorize("@ss.hasPermi('ar:receipt:list')")
+ @GetMapping("/bill/unsettled/{customerId}")
+ public AjaxResult unsettledBills(@PathVariable("customerId") Long customerId)
+ {
+ return success(balanceWriteoffService.selectUnsettledBills(customerId));
+ }
+
+ /**
+ * 查询核销记录(跨客户,支持客户/账单号/状态/核销日期范围)
+ */
+ @PreAuthorize("@ss.hasPermi('ar:receipt:list')")
+ @GetMapping("/writeoff/list")
+ public TableDataInfo writeoffList(ArBalanceWriteoff query)
+ {
+ startPage();
+ List list = balanceWriteoffService.selectWriteoffList(query);
+ return getDataTable(list);
+ }
+
+ /**
+ * 账单核销(账单核销页签直接核销;与客户余额页核销同一套逻辑)
+ */
+ @PreAuthorize("@ss.hasPermi('ar:receipt:writeoff')")
+ @Log(title = "收款管理-账单核销", businessType = BusinessType.UPDATE)
+ @PostMapping("/writeoff")
+ public AjaxResult writeoff(@RequestBody ArBalanceWriteoff cmd)
+ {
+ cmd.setCreateBy(getUsername());
+ return success(balanceWriteoffService.writeoff(cmd));
+ }
+
+ /**
+ * 反核销(取消一笔有效核销,账单恢复未核销金额)
+ */
+ @PreAuthorize("@ss.hasPermi('ar:receipt:writeoff:cancel')")
+ @Log(title = "收款管理-反核销", businessType = BusinessType.UPDATE)
+ @PutMapping("/writeoff/{writeoffId}/cancel")
+ public AjaxResult cancelWriteoff(@PathVariable("writeoffId") Long writeoffId,
+ @RequestBody(required = false) ArBalanceWriteoff body)
+ {
+ balanceWriteoffService.cancelWriteoff(writeoffId, body == null ? null : body.getCancelRemark());
+ return success();
+ }
+}
diff --git a/bms-back/bms-system/src/main/java/com/bms/customer/customermoney/domain/CustomerReceipt.java b/bms-back/bms-system/src/main/java/com/bms/customer/customermoney/domain/CustomerReceipt.java
index 8f6012a7..ebfc1722 100644
--- a/bms-back/bms-system/src/main/java/com/bms/customer/customermoney/domain/CustomerReceipt.java
+++ b/bms-back/bms-system/src/main/java/com/bms/customer/customermoney/domain/CustomerReceipt.java
@@ -51,6 +51,12 @@ public class CustomerReceipt extends BaseEntity
/** 客户ID */
private Long customerId;
+ /** 客户编码(列表关联查询,仅展示) */
+ private String customerCode;
+
+ /** 客户名称(列表关联查询,仅展示) */
+ private String customerName;
+
/** 客户账户ID(预留) */
private Long accountId;
diff --git a/bms-back/bms-system/src/main/resources/mapper/ar/ArBalanceWriteoffMapper.xml b/bms-back/bms-system/src/main/resources/mapper/ar/ArBalanceWriteoffMapper.xml
index f13a6fb6..59f0ac57 100644
--- a/bms-back/bms-system/src/main/resources/mapper/ar/ArBalanceWriteoffMapper.xml
+++ b/bms-back/bms-system/src/main/resources/mapper/ar/ArBalanceWriteoffMapper.xml
@@ -83,6 +83,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and w.currency = #{currency}
and w.writeoff_no like concat('%', #{writeoffNo}, '%')
and w.bill_no like concat('%', #{billNo}, '%')
+ and w.receipt_id = #{receiptId}
+
+ and date_format(w.writeoff_date,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d')
+
+
+ and date_format(w.writeoff_date,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d')
+
order by w.create_time desc, w.writeoff_id desc
diff --git a/bms-back/bms-system/src/main/resources/mapper/customer/CustomerMoneyMapper.xml b/bms-back/bms-system/src/main/resources/mapper/customer/CustomerMoneyMapper.xml
index d26b1cd0..1e082cc1 100644
--- a/bms-back/bms-system/src/main/resources/mapper/customer/CustomerMoneyMapper.xml
+++ b/bms-back/bms-system/src/main/resources/mapper/customer/CustomerMoneyMapper.xml
@@ -236,6 +236,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+
+
@@ -268,7 +270,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
- select r.id, r.receipt_no, r.customer_id, r.account_id, r.receipt_type, r.amount, r.allocated_amount,
+ select r.id, r.receipt_no, r.customer_id, c.customer_code, c.customer_name, r.account_id, r.receipt_type,
+ r.amount, r.allocated_amount,
r.unallocated_amount, r.currency, r.exchange_rate, r.rate_source, r.rate_source_desc,
r.base_amount, r.pay_method, r.bank_account_id, r.bank_account_name,
r.bank_account_no, r.bank_name, r.bank_transaction_no,
@@ -278,6 +281,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
(select count(1) from ctr_customer_attachment a
where a.biz_id = r.id and a.attachment_type = '3' and a.del_flag = '0') as attachment_count
from ctr_customer_receipt r
+ left join ctr_customer c on c.customer_id = r.customer_id