From 33860a93e73b8b01645e6613919ea369b3e4f9db Mon Sep 17 00:00:00 2001 From: “wangming” <“wangming@antissoft.com”> Date: Tue, 9 Dec 2025 22:52:16 +0800 Subject: [PATCH] feat: 新增合同管理系统功能 --- netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqContract/ContractExpenseStatisticsInput.cs | 41 +++++++++++++++++++++++++++++++++++++++++ netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqContract/ContractExpenseStatisticsOutput.cs | 108 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqContract/LqContractCrInput.cs | 108 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqContract/LqContractInfoOutput.cs | 132 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqContract/LqContractListOutput.cs | 126 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqContract/LqContractListQueryInput.cs | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqContract/LqContractRentDetailListOutput.cs | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqContract/LqContractRentDetailMarkPaidInput.cs | 42 ++++++++++++++++++++++++++++++++++++++++++ netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqContract/LqContractUpInput.cs | 116 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqInventoryUsage/LqInventoryUsageBatchCreateInput.cs | 23 +++++++++++++++++++++++ netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqInventoryUsage/LqInventoryUsageBatchInfoOutput.cs | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqInventoryUsage/StoreReceiveStatisticsInput.cs | 34 ++++++++++++++++++++++++++++++++++ netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqInventoryUsageApplication/LqInventoryUsageApplicationApproveInput.cs | 18 ++++++++++++++++++ netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqInventoryUsageApplication/LqInventoryUsageApplicationCrInput.cs | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqInventoryUsageApplication/LqInventoryUsageApplicationInfoOutput.cs | 305 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqInventoryUsageApplication/LqInventoryUsageApplicationListOutput.cs | 133 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqInventoryUsageApplication/LqInventoryUsageApplicationListQueryInput.cs | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqInventoryUsageApplication/LqInventoryUsageApplicationReceiveInput.cs | 18 ++++++++++++++++++ netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqInventoryUsageApplication/LqInventoryUsageApplicationUpInput.cs | 23 +++++++++++++++++++++++ netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqReimbursementApplicationInfoOutput.cs | 2 +- netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqTechTeacherSalary/TechTeacherSalaryInput.cs | 2 ++ netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqTechTeacherSalary/TechTeacherSalaryOutput.cs | 2 ++ netcore/src/Modularity/Extend/NCC.Extend.Entitys/Entity/lq_contract/LqContractEntity.cs | 140 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ netcore/src/Modularity/Extend/NCC.Extend.Entitys/Entity/lq_contract_rent_detail/LqContractRentDetailEntity.cs | 98 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ netcore/src/Modularity/Extend/NCC.Extend.Entitys/Entity/lq_inventory_usage/LqInventoryUsageEntity.cs | 12 ++++++++++++ netcore/src/Modularity/Extend/NCC.Extend.Entitys/Entity/lq_inventory_usage_application/LqInventoryUsageApplicationEntity.cs | 130 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ netcore/src/Modularity/Extend/NCC.Extend.Entitys/Entity/lq_inventory_usage_application_node/LqInventoryUsageApplicationNodeEntity.cs | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ netcore/src/Modularity/Extend/NCC.Extend.Entitys/Entity/lq_inventory_usage_approval_record/LqInventoryUsageApprovalRecordEntity.cs | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ netcore/src/Modularity/Extend/NCC.Extend.Interfaces/LqInventoryUsageApplication/ILqInventoryUsageApplicationService.cs | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ netcore/src/Modularity/Extend/NCC.Extend.Interfaces/LqMdMajorProjectTeacherAssignment/ILqMdMajorProjectTeacherAssignmentService.cs | 5 +++-- netcore/src/Modularity/Extend/NCC.Extend/LqContractService.cs | 1039 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ netcore/src/Modularity/Extend/NCC.Extend/LqInventoryUsageService.cs | 583 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------- netcore/src/Modularity/Extend/NCC.Extend/LqMdMajorProjectTeacherAssignmentService.cs | 2 +- netcore/src/Modularity/Extend/NCC.Extend/LqReimbursementApplicationService.cs | 8 ++++++++ sql/创建合同管理表结构.sql | 116 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ sql/创建库存使用申请审批流程表.sql | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ sql/库存管理审批功能相关表结构.sql | 202 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ sql/库存管理审批功能表结构.sql | 214 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 合同管理系统-前端调用说明.md | 792 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 合同管理系统-逻辑梳理.md | 230 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 库存使用审批流程-前端调用说明.md | 442 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 41 files changed, 5911 insertions(+), 12 deletions(-) create mode 100644 netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqContract/ContractExpenseStatisticsInput.cs create mode 100644 netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqContract/ContractExpenseStatisticsOutput.cs create mode 100644 netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqContract/LqContractCrInput.cs create mode 100644 netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqContract/LqContractInfoOutput.cs create mode 100644 netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqContract/LqContractListOutput.cs create mode 100644 netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqContract/LqContractListQueryInput.cs create mode 100644 netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqContract/LqContractRentDetailListOutput.cs create mode 100644 netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqContract/LqContractRentDetailMarkPaidInput.cs create mode 100644 netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqContract/LqContractUpInput.cs create mode 100644 netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqInventoryUsage/StoreReceiveStatisticsInput.cs create mode 100644 netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqInventoryUsageApplication/LqInventoryUsageApplicationApproveInput.cs create mode 100644 netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqInventoryUsageApplication/LqInventoryUsageApplicationCrInput.cs create mode 100644 netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqInventoryUsageApplication/LqInventoryUsageApplicationInfoOutput.cs create mode 100644 netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqInventoryUsageApplication/LqInventoryUsageApplicationListOutput.cs create mode 100644 netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqInventoryUsageApplication/LqInventoryUsageApplicationListQueryInput.cs create mode 100644 netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqInventoryUsageApplication/LqInventoryUsageApplicationReceiveInput.cs create mode 100644 netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqInventoryUsageApplication/LqInventoryUsageApplicationUpInput.cs create mode 100644 netcore/src/Modularity/Extend/NCC.Extend.Entitys/Entity/lq_contract/LqContractEntity.cs create mode 100644 netcore/src/Modularity/Extend/NCC.Extend.Entitys/Entity/lq_contract_rent_detail/LqContractRentDetailEntity.cs create mode 100644 netcore/src/Modularity/Extend/NCC.Extend.Entitys/Entity/lq_inventory_usage_application/LqInventoryUsageApplicationEntity.cs create mode 100644 netcore/src/Modularity/Extend/NCC.Extend.Entitys/Entity/lq_inventory_usage_application_node/LqInventoryUsageApplicationNodeEntity.cs create mode 100644 netcore/src/Modularity/Extend/NCC.Extend.Entitys/Entity/lq_inventory_usage_approval_record/LqInventoryUsageApprovalRecordEntity.cs create mode 100644 netcore/src/Modularity/Extend/NCC.Extend.Interfaces/LqInventoryUsageApplication/ILqInventoryUsageApplicationService.cs create mode 100644 netcore/src/Modularity/Extend/NCC.Extend/LqContractService.cs create mode 100644 sql/创建合同管理表结构.sql create mode 100644 sql/创建库存使用申请审批流程表.sql create mode 100644 sql/库存管理审批功能相关表结构.sql create mode 100644 sql/库存管理审批功能表结构.sql create mode 100644 合同管理系统-前端调用说明.md create mode 100644 合同管理系统-逻辑梳理.md create mode 100644 库存使用审批流程-前端调用说明.md diff --git a/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqContract/ContractExpenseStatisticsInput.cs b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqContract/ContractExpenseStatisticsInput.cs new file mode 100644 index 0000000..6a99c1a --- /dev/null +++ b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqContract/ContractExpenseStatisticsInput.cs @@ -0,0 +1,41 @@ +using System; +using System.ComponentModel.DataAnnotations; + +namespace NCC.Extend.Entitys.Dto.LqContract +{ + /// + /// 合同费用统计输入 + /// + public class ContractExpenseStatisticsInput + { + /// + /// 门店ID(必填) + /// + [Required(ErrorMessage = "门店ID不能为空")] + [Display(Name = "门店ID")] + public string StoreId { get; set; } + + /// + /// 统计年份(必填) + /// + [Required(ErrorMessage = "年份不能为空")] + [Range(2020, 2100, ErrorMessage = "年份必须在2020-2100之间")] + [Display(Name = "年份")] + public int Year { get; set; } + + /// + /// 统计月份(必填,1-12) + /// + [Required(ErrorMessage = "月份不能为空")] + [Range(1, 12, ErrorMessage = "月份必须在1-12之间")] + [Display(Name = "月份")] + public int Month { get; set; } + + /// + /// 分类列表(可选,不传则统计所有分类) + /// + [Display(Name = "分类列表")] + public string[] Categories { get; set; } + } +} + diff --git a/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqContract/ContractExpenseStatisticsOutput.cs b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqContract/ContractExpenseStatisticsOutput.cs new file mode 100644 index 0000000..9d88c4c --- /dev/null +++ b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqContract/ContractExpenseStatisticsOutput.cs @@ -0,0 +1,108 @@ +using System.Collections.Generic; + +namespace NCC.Extend.Entitys.Dto.LqContract +{ + /// + /// 合同费用统计输出 + /// + public class ContractExpenseStatisticsOutput + { + /// + /// 门店ID + /// + public string storeId { get; set; } + + /// + /// 门店名称 + /// + public string storeName { get; set; } + + /// + /// 统计年份 + /// + public int year { get; set; } + + /// + /// 统计月份 + /// + public int month { get; set; } + + /// + /// 总费用(所有分类的费用总和) + /// + public decimal totalAmount { get; set; } + + /// + /// 按分类统计的费用明细 + /// + public List categoryDetails { get; set; } + } + + /// + /// 分类费用明细 + /// + public class CategoryExpenseDetail + { + /// + /// 分类名称 + /// + public string category { get; set; } + + /// + /// 该分类的费用总额 + /// + public decimal amount { get; set; } + + /// + /// 该分类的明细数量 + /// + public int detailCount { get; set; } + + /// + /// 明细列表 + /// + public List details { get; set; } + } + + /// + /// 费用明细项 + /// + public class ExpenseDetailItem + { + /// + /// 明细ID + /// + public string detailId { get; set; } + + /// + /// 合同ID + /// + public string contractId { get; set; } + + /// + /// 合同标题 + /// + public string contractTitle { get; set; } + + /// + /// 分类 + /// + public string category { get; set; } + + /// + /// 应缴金额 + /// + public decimal dueAmount { get; set; } + + /// + /// 是否已缴(0-未缴,1-已缴) + /// + public int isPaid { get; set; } + + /// + /// 实际缴费金额(如果已缴费) + /// + public decimal? actualPaymentAmount { get; set; } + } +} + diff --git a/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqContract/LqContractCrInput.cs b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqContract/LqContractCrInput.cs new file mode 100644 index 0000000..03c550f --- /dev/null +++ b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqContract/LqContractCrInput.cs @@ -0,0 +1,108 @@ +using System; +using System.ComponentModel.DataAnnotations; + +namespace NCC.Extend.Entitys.Dto.LqContract +{ + /// + /// 合同创建输入 + /// + public class LqContractCrInput + { + /// + /// 门店ID(关联lq_mdxx.F_Id) + /// + [Required(ErrorMessage = "门店ID不能为空")] + [StringLength(50, ErrorMessage = "门店ID长度不能超过50个字符")] + [Display(Name = "门店ID")] + public string StoreId { get; set; } + + /// + /// 标题 + /// + [Required(ErrorMessage = "标题不能为空")] + [StringLength(200, ErrorMessage = "标题长度不能超过200个字符")] + [Display(Name = "标题")] + public string Title { get; set; } + + /// + /// 分类(string类型,自己填写) + /// + [StringLength(100, ErrorMessage = "分类长度不能超过100个字符")] + [Display(Name = "分类")] + public string Category { get; set; } + + /// + /// 户名 + /// + [StringLength(200, ErrorMessage = "户名长度不能超过200个字符")] + [Display(Name = "户名")] + public string TenantName { get; set; } + + /// + /// 合同起始日期 + /// + [Required(ErrorMessage = "合同起始日期不能为空")] + [Display(Name = "合同起始日期")] + public DateTime ContractStartDate { get; set; } + + /// + /// 合同结束日期 + /// + [Required(ErrorMessage = "合同结束日期不能为空")] + [Display(Name = "合同结束日期")] + public DateTime ContractEndDate { get; set; } + + /// + /// 提前多少天提醒 + /// + [Range(0, 365, ErrorMessage = "提前提醒天数必须在0-365之间")] + [Display(Name = "提前提醒天数")] + public int ReminderDays { get; set; } = 0; + + /// + /// 押金 + /// + [Range(0, double.MaxValue, ErrorMessage = "押金不能小于0")] + [Display(Name = "押金")] + public decimal Deposit { get; set; } = 0; + + /// + /// 月租 + /// + [Required(ErrorMessage = "月租不能为空")] + [Range(0, double.MaxValue, ErrorMessage = "月租不能小于0")] + [Display(Name = "月租")] + public decimal MonthlyRent { get; set; } + + /// + /// 缴租金额(每次交租的金额,通常=月租×交租周期) + /// + [Required(ErrorMessage = "缴租金额不能为空")] + [Range(0, double.MaxValue, ErrorMessage = "缴租金额不能小于0")] + [Display(Name = "缴租金额")] + public decimal PaymentAmount { get; set; } + + /// + /// 交租周期(数字,表示几个月,如1、3、6等) + /// + [Required(ErrorMessage = "交租周期不能为空")] + [Range(1, 12, ErrorMessage = "交租周期必须在1-12个月之间")] + [Display(Name = "交租周期")] + public int PaymentCycle { get; set; } + + /// + /// 备注 + /// + [StringLength(1000, ErrorMessage = "备注长度不能超过1000个字符")] + [Display(Name = "备注")] + public string Remarks { get; set; } + + /// + /// 附件(存储附件路径或JSON) + /// + [StringLength(500, ErrorMessage = "附件长度不能超过500个字符")] + [Display(Name = "附件")] + public string Attachment { get; set; } + } +} + diff --git a/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqContract/LqContractInfoOutput.cs b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqContract/LqContractInfoOutput.cs new file mode 100644 index 0000000..c142fe9 --- /dev/null +++ b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqContract/LqContractInfoOutput.cs @@ -0,0 +1,132 @@ +using System; +using System.Collections.Generic; + +namespace NCC.Extend.Entitys.Dto.LqContract +{ + /// + /// 合同详情输出 + /// + public class LqContractInfoOutput + { + /// + /// 合同ID + /// + public string id { get; set; } + + /// + /// 门店ID + /// + public string storeId { get; set; } + + /// + /// 店名 + /// + public string storeName { get; set; } + + /// + /// 标题 + /// + public string title { get; set; } + + /// + /// 分类 + /// + public string category { get; set; } + + /// + /// 户名 + /// + public string tenantName { get; set; } + + /// + /// 合同起始日期 + /// + public DateTime contractStartDate { get; set; } + + /// + /// 合同结束日期 + /// + public DateTime contractEndDate { get; set; } + + /// + /// 提前多少天提醒 + /// + public int reminderDays { get; set; } + + /// + /// 押金 + /// + public decimal deposit { get; set; } + + /// + /// 下次应交时间 + /// + public DateTime? nextPaymentDate { get; set; } + + /// + /// 月租 + /// + public decimal monthlyRent { get; set; } + + /// + /// 缴租金额 + /// + public decimal paymentAmount { get; set; } + + /// + /// 交租周期 + /// + public int paymentCycle { get; set; } + + /// + /// 备注 + /// + public string remarks { get; set; } + + /// + /// 附件 + /// + public string attachment { get; set; } + + /// + /// 创建人ID + /// + public string createUser { get; set; } + + /// + /// 创建人姓名 + /// + public string createUserName { get; set; } + + /// + /// 创建时间 + /// + public DateTime createTime { get; set; } + + /// + /// 更新人ID + /// + public string updateUser { get; set; } + + /// + /// 更新人姓名 + /// + public string updateUserName { get; set; } + + /// + /// 更新时间 + /// + public DateTime? updateTime { get; set; } + + /// + /// 是否有效 + /// + public int isEffective { get; set; } + + /// + /// 月租明细列表 + /// + public List rentDetails { get; set; } + } +} + diff --git a/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqContract/LqContractListOutput.cs b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqContract/LqContractListOutput.cs new file mode 100644 index 0000000..f078e58 --- /dev/null +++ b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqContract/LqContractListOutput.cs @@ -0,0 +1,126 @@ +using System; + +namespace NCC.Extend.Entitys.Dto.LqContract +{ + /// + /// 合同列表输出 + /// + public class LqContractListOutput + { + /// + /// 合同ID + /// + public string id { get; set; } + + /// + /// 门店ID + /// + public string storeId { get; set; } + + /// + /// 店名 + /// + public string storeName { get; set; } + + /// + /// 标题 + /// + public string title { get; set; } + + /// + /// 分类 + /// + public string category { get; set; } + + /// + /// 户名 + /// + public string tenantName { get; set; } + + /// + /// 合同起始日期 + /// + public DateTime contractStartDate { get; set; } + + /// + /// 合同结束日期 + /// + public DateTime contractEndDate { get; set; } + + /// + /// 提前多少天提醒 + /// + public int reminderDays { get; set; } + + /// + /// 押金 + /// + public decimal deposit { get; set; } + + /// + /// 下次应交时间 + /// + public DateTime? nextPaymentDate { get; set; } + + /// + /// 月租 + /// + public decimal monthlyRent { get; set; } + + /// + /// 缴租金额 + /// + public decimal paymentAmount { get; set; } + + /// + /// 交租周期 + /// + public int paymentCycle { get; set; } + + /// + /// 备注 + /// + public string remarks { get; set; } + + /// + /// 附件 + /// + public string attachment { get; set; } + + /// + /// 创建人ID + /// + public string createUser { get; set; } + + /// + /// 创建人姓名 + /// + public string createUserName { get; set; } + + /// + /// 创建时间 + /// + public DateTime createTime { get; set; } + + /// + /// 更新人ID + /// + public string updateUser { get; set; } + + /// + /// 更新人姓名 + /// + public string updateUserName { get; set; } + + /// + /// 更新时间 + /// + public DateTime? updateTime { get; set; } + + /// + /// 是否有效 + /// + public int isEffective { get; set; } + } +} + diff --git a/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqContract/LqContractListQueryInput.cs b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqContract/LqContractListQueryInput.cs new file mode 100644 index 0000000..a559736 --- /dev/null +++ b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqContract/LqContractListQueryInput.cs @@ -0,0 +1,67 @@ +using NCC.Common.Filter; +using System; +using System.ComponentModel.DataAnnotations; + +namespace NCC.Extend.Entitys.Dto.LqContract +{ + /// + /// 合同列表查询输入 + /// + public class LqContractListQueryInput : PageInputBase + { + /// + /// 门店ID + /// + [Display(Name = "门店ID", Description = "根据门店ID筛选")] + public string StoreId { get; set; } + + /// + /// 门店名称(模糊查询) + /// + [Display(Name = "门店名称", Description = "根据门店名称筛选")] + public string StoreName { get; set; } + + /// + /// 分类 + /// + [Display(Name = "分类", Description = "根据分类筛选")] + public string Category { get; set; } + + /// + /// 标题(模糊查询) + /// + [Display(Name = "标题", Description = "根据标题筛选")] + public string Title { get; set; } + + /// + /// 合同起始日期(开始) + /// + [Display(Name = "合同起始日期(开始)", Description = "根据合同起始日期范围筛选")] + public DateTime? ContractStartDateBegin { get; set; } + + /// + /// 合同起始日期(结束) + /// + [Display(Name = "合同起始日期(结束)", Description = "根据合同起始日期范围筛选")] + public DateTime? ContractStartDateEnd { get; set; } + + /// + /// 合同结束日期(开始) + /// + [Display(Name = "合同结束日期(开始)", Description = "根据合同结束日期范围筛选")] + public DateTime? ContractEndDateBegin { get; set; } + + /// + /// 合同结束日期(结束) + /// + [Display(Name = "合同结束日期(结束)", Description = "根据合同结束日期范围筛选")] + public DateTime? ContractEndDateEnd { get; set; } + + /// + /// 是否有效 + /// + [Display(Name = "是否有效", Description = "根据是否有效筛选")] + public int? IsEffective { get; set; } + } +} + diff --git a/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqContract/LqContractRentDetailListOutput.cs b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqContract/LqContractRentDetailListOutput.cs new file mode 100644 index 0000000..aec9644 --- /dev/null +++ b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqContract/LqContractRentDetailListOutput.cs @@ -0,0 +1,91 @@ +using System; + +namespace NCC.Extend.Entitys.Dto.LqContract +{ + /// + /// 月租明细列表输出 + /// + public class LqContractRentDetailListOutput + { + /// + /// 明细ID + /// + public string id { get; set; } + + /// + /// 合同ID + /// + public string contractId { get; set; } + + /// + /// 应缴月份(表示哪个月份,格式:YYYY-MM-01) + /// + public DateTime paymentMonth { get; set; } + + /// + /// 应缴日期(具体应缴日期) + /// + public DateTime dueDate { get; set; } + + /// + /// 应缴金额 + /// + public decimal dueAmount { get; set; } + + /// + /// 是否已缴(0-未缴,1-已缴) + /// + public int isPaid { get; set; } + + /// + /// 实际缴费时间 + /// + public DateTime? actualPaymentDate { get; set; } + + /// + /// 实际缴费金额 + /// + public decimal? actualPaymentAmount { get; set; } + + /// + /// 备注 + /// + public string remarks { get; set; } + + /// + /// 创建人ID + /// + public string createUser { get; set; } + + /// + /// 创建人姓名 + /// + public string createUserName { get; set; } + + /// + /// 创建时间 + /// + public DateTime createTime { get; set; } + + /// + /// 更新人ID + /// + public string updateUser { get; set; } + + /// + /// 更新人姓名 + /// + public string updateUserName { get; set; } + + /// + /// 更新时间 + /// + public DateTime? updateTime { get; set; } + + /// + /// 是否有效 + /// + public int isEffective { get; set; } + } +} + diff --git a/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqContract/LqContractRentDetailMarkPaidInput.cs b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqContract/LqContractRentDetailMarkPaidInput.cs new file mode 100644 index 0000000..bf78c82 --- /dev/null +++ b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqContract/LqContractRentDetailMarkPaidInput.cs @@ -0,0 +1,42 @@ +using System; +using System.ComponentModel.DataAnnotations; + +namespace NCC.Extend.Entitys.Dto.LqContract +{ + /// + /// 月租明细标记已缴费输入 + /// + public class LqContractRentDetailMarkPaidInput + { + /// + /// 明细ID + /// + [Required(ErrorMessage = "明细ID不能为空")] + [StringLength(50, ErrorMessage = "明细ID长度不能超过50个字符")] + [Display(Name = "明细ID")] + public string Id { get; set; } + + /// + /// 实际缴费时间 + /// + [Required(ErrorMessage = "实际缴费时间不能为空")] + [Display(Name = "实际缴费时间")] + public DateTime ActualPaymentDate { get; set; } + + /// + /// 实际缴费金额 + /// + [Required(ErrorMessage = "实际缴费金额不能为空")] + [Range(0, double.MaxValue, ErrorMessage = "实际缴费金额不能小于0")] + [Display(Name = "实际缴费金额")] + public decimal ActualPaymentAmount { get; set; } + + /// + /// 备注 + /// + [StringLength(500, ErrorMessage = "备注长度不能超过500个字符")] + [Display(Name = "备注")] + public string Remarks { get; set; } + } +} + diff --git a/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqContract/LqContractUpInput.cs b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqContract/LqContractUpInput.cs new file mode 100644 index 0000000..41d07f5 --- /dev/null +++ b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqContract/LqContractUpInput.cs @@ -0,0 +1,116 @@ +using System; +using System.ComponentModel.DataAnnotations; + +namespace NCC.Extend.Entitys.Dto.LqContract +{ + /// + /// 合同更新输入 + /// + public class LqContractUpInput + { + /// + /// 合同ID + /// + [Required(ErrorMessage = "合同ID不能为空")] + [StringLength(50, ErrorMessage = "合同ID长度不能超过50个字符")] + [Display(Name = "合同ID")] + public string Id { get; set; } + + /// + /// 门店ID(关联lq_mdxx.F_Id) + /// + [Required(ErrorMessage = "门店ID不能为空")] + [StringLength(50, ErrorMessage = "门店ID长度不能超过50个字符")] + [Display(Name = "门店ID")] + public string StoreId { get; set; } + + /// + /// 标题 + /// + [Required(ErrorMessage = "标题不能为空")] + [StringLength(200, ErrorMessage = "标题长度不能超过200个字符")] + [Display(Name = "标题")] + public string Title { get; set; } + + /// + /// 分类(string类型,自己填写) + /// + [StringLength(100, ErrorMessage = "分类长度不能超过100个字符")] + [Display(Name = "分类")] + public string Category { get; set; } + + /// + /// 户名 + /// + [StringLength(200, ErrorMessage = "户名长度不能超过200个字符")] + [Display(Name = "户名")] + public string TenantName { get; set; } + + /// + /// 合同起始日期 + /// + [Required(ErrorMessage = "合同起始日期不能为空")] + [Display(Name = "合同起始日期")] + public DateTime ContractStartDate { get; set; } + + /// + /// 合同结束日期 + /// + [Required(ErrorMessage = "合同结束日期不能为空")] + [Display(Name = "合同结束日期")] + public DateTime ContractEndDate { get; set; } + + /// + /// 提前多少天提醒 + /// + [Range(0, 365, ErrorMessage = "提前提醒天数必须在0-365之间")] + [Display(Name = "提前提醒天数")] + public int ReminderDays { get; set; } = 0; + + /// + /// 押金 + /// + [Range(0, double.MaxValue, ErrorMessage = "押金不能小于0")] + [Display(Name = "押金")] + public decimal Deposit { get; set; } = 0; + + /// + /// 月租 + /// + [Required(ErrorMessage = "月租不能为空")] + [Range(0, double.MaxValue, ErrorMessage = "月租不能小于0")] + [Display(Name = "月租")] + public decimal MonthlyRent { get; set; } + + /// + /// 缴租金额(每次交租的金额,通常=月租×交租周期) + /// + [Required(ErrorMessage = "缴租金额不能为空")] + [Range(0, double.MaxValue, ErrorMessage = "缴租金额不能小于0")] + [Display(Name = "缴租金额")] + public decimal PaymentAmount { get; set; } + + /// + /// 交租周期(数字,表示几个月,如1、3、6等) + /// + [Required(ErrorMessage = "交租周期不能为空")] + [Range(1, 12, ErrorMessage = "交租周期必须在1-12个月之间")] + [Display(Name = "交租周期")] + public int PaymentCycle { get; set; } + + /// + /// 备注 + /// + [StringLength(1000, ErrorMessage = "备注长度不能超过1000个字符")] + [Display(Name = "备注")] + public string Remarks { get; set; } + + /// + /// 附件(存储附件路径或JSON) + /// + [StringLength(500, ErrorMessage = "附件长度不能超过500个字符")] + [Display(Name = "附件")] + public string Attachment { get; set; } + } +} + diff --git a/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqInventoryUsage/LqInventoryUsageBatchCreateInput.cs b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqInventoryUsage/LqInventoryUsageBatchCreateInput.cs index 7c1b5b6..7891445 100644 --- a/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqInventoryUsage/LqInventoryUsageBatchCreateInput.cs +++ b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqInventoryUsage/LqInventoryUsageBatchCreateInput.cs @@ -23,6 +23,29 @@ namespace NCC.Extend.Entitys.Dto.LqInventoryUsage [StringLength(50, ErrorMessage = "批次ID长度不能超过50个字符")] [Display(Name = "使用批次ID")] public string BatchId { get; set; } + + /// + /// 审批人ID(财务老师或库管,必填,创建申请记录并提交审批) + /// + [Required(ErrorMessage = "审批人ID不能为空")] + [StringLength(50, ErrorMessage = "审批人ID长度不能超过50个字符")] + [Display(Name = "审批人ID")] + public string ApproverId { get; set; } + + /// + /// 申请门店ID(必填) + /// + [Required(ErrorMessage = "申请门店ID不能为空")] + [StringLength(50, ErrorMessage = "申请门店ID长度不能超过50个字符")] + [Display(Name = "申请门店ID")] + public string ApplicationStoreId { get; set; } + + /// + /// 备注(可选) + /// + [StringLength(500, ErrorMessage = "备注长度不能超过500个字符")] + [Display(Name = "备注")] + public string Remarks { get; set; } } /// diff --git a/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqInventoryUsage/LqInventoryUsageBatchInfoOutput.cs b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqInventoryUsage/LqInventoryUsageBatchInfoOutput.cs index b60804e..2a7b101 100644 --- a/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqInventoryUsage/LqInventoryUsageBatchInfoOutput.cs +++ b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqInventoryUsage/LqInventoryUsageBatchInfoOutput.cs @@ -57,6 +57,67 @@ namespace NCC.Extend.Entitys.Dto.LqInventoryUsage /// 使用记录列表 /// public List UsageRecords { get; set; } + + /// + /// 申请记录信息(如果有) + /// + public ApplicationInfo ApplicationInfo { get; set; } + } + + /// + /// 申请记录信息 + /// + public class ApplicationInfo + { + /// + /// 申请ID + /// + public string Id { get; set; } + + /// + /// 申请人ID + /// + public string ApplicationUserId { get; set; } + + /// + /// 申请人姓名 + /// + public string ApplicationUserName { get; set; } + + /// + /// 申请门店ID + /// + public string ApplicationStoreId { get; set; } + + /// + /// 申请时间 + /// + public DateTime ApplicationTime { get; set; } + + /// + /// 审批状态 + /// + public string ApprovalStatus { get; set; } + + /// + /// 是否已领取 + /// + public int IsReceived { get; set; } + + /// + /// 领取时间 + /// + public DateTime? ReceiveTime { get; set; } + + /// + /// 领取人ID + /// + public string ReceiveUser { get; set; } + + /// + /// 备注 + /// + public string Remarks { get; set; } } } diff --git a/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqInventoryUsage/StoreReceiveStatisticsInput.cs b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqInventoryUsage/StoreReceiveStatisticsInput.cs new file mode 100644 index 0000000..dc363eb --- /dev/null +++ b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqInventoryUsage/StoreReceiveStatisticsInput.cs @@ -0,0 +1,34 @@ +using System.ComponentModel.DataAnnotations; + +namespace NCC.Extend.Entitys.Dto.LqInventoryUsage +{ + /// + /// 门店领取统计查询输入 + /// + public class StoreReceiveStatisticsInput + { + /// + /// 统计年份 + /// + [Required(ErrorMessage = "统计年份不能为空")] + [Range(2020, 2100, ErrorMessage = "年份必须在2020-2100之间")] + [Display(Name = "统计年份")] + public int Year { get; set; } + + /// + /// 统计月份(1-12) + /// + [Required(ErrorMessage = "统计月份不能为空")] + [Range(1, 12, ErrorMessage = "月份必须在1-12之间")] + [Display(Name = "统计月份")] + public int Month { get; set; } + + /// + /// 门店ID(可选,用于筛选特定门店) + /// + [StringLength(50, ErrorMessage = "门店ID长度不能超过50个字符")] + [Display(Name = "门店ID")] + public string StoreId { get; set; } + } +} + diff --git a/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqInventoryUsageApplication/LqInventoryUsageApplicationApproveInput.cs b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqInventoryUsageApplication/LqInventoryUsageApplicationApproveInput.cs new file mode 100644 index 0000000..2b49778 --- /dev/null +++ b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqInventoryUsageApplication/LqInventoryUsageApplicationApproveInput.cs @@ -0,0 +1,18 @@ +namespace NCC.Extend.Entitys.Dto.LqInventoryUsageApplication +{ + /// + /// 库存使用申请审批输入 + /// + public class LqInventoryUsageApplicationApproveInput + { + /// + /// 审批结果(通过/不通过/退回) + /// + public string result { get; set; } + + /// + /// 审批意见 + /// + public string opinion { get; set; } + } +} diff --git a/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqInventoryUsageApplication/LqInventoryUsageApplicationCrInput.cs b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqInventoryUsageApplication/LqInventoryUsageApplicationCrInput.cs new file mode 100644 index 0000000..c1307e1 --- /dev/null +++ b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqInventoryUsageApplication/LqInventoryUsageApplicationCrInput.cs @@ -0,0 +1,61 @@ +using System.Collections.Generic; + +namespace NCC.Extend.Entitys.Dto.LqInventoryUsageApplication +{ + /// + /// 库存使用申请创建输入 + /// + public class LqInventoryUsageApplicationCrInput + { + /// + /// 使用批次ID(关联lq_inventory_usage.F_UsageBatchId) + /// + public string usageBatchId { get; set; } + + /// + /// 申请门店ID + /// + public string applicationStoreId { get; set; } + + /// + /// 备注 + /// + public string remarks { get; set; } + + /// + /// 审批节点配置(单节点,固定为1个节点) + /// + public ApprovalNodeConfig node { get; set; } + } + + /// + /// 审批节点配置 + /// + public class ApprovalNodeConfig + { + /// + /// 节点序号(固定为1) + /// + public int nodeOrder { get; set; } = 1; + + /// + /// 节点名称(如:财务审批、库管审批) + /// + public string nodeName { get; set; } + + /// + /// 审批类型(会签/或签,单节点通常使用"或签") + /// + public string approvalType { get; set; } = "或签"; + + /// + /// 审批人ID列表 + /// + public List approverIds { get; set; } + + /// + /// 审批人姓名列表 + /// + public List approverNames { get; set; } + } +} diff --git a/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqInventoryUsageApplication/LqInventoryUsageApplicationInfoOutput.cs b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqInventoryUsageApplication/LqInventoryUsageApplicationInfoOutput.cs new file mode 100644 index 0000000..bfb9679 --- /dev/null +++ b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqInventoryUsageApplication/LqInventoryUsageApplicationInfoOutput.cs @@ -0,0 +1,305 @@ +using System; +using System.Collections.Generic; + +namespace NCC.Extend.Entitys.Dto.LqInventoryUsageApplication +{ + /// + /// 库存使用申请详情输出 + /// + public class LqInventoryUsageApplicationInfoOutput + { + /// + /// 申请编号 + /// + public string id { get; set; } + + /// + /// 使用批次ID + /// + public string usageBatchId { get; set; } + + /// + /// 申请人ID + /// + public string applicationUserId { get; set; } + + /// + /// 申请人姓名 + /// + public string applicationUserName { get; set; } + + /// + /// 申请门店ID + /// + public string applicationStoreId { get; set; } + + /// + /// 申请门店名称 + /// + public string applicationStoreName { get; set; } + + /// + /// 申请时间 + /// + public DateTime applicationTime { get; set; } + + /// + /// 节点数量(固定为1) + /// + public int nodeCount { get; set; } + + /// + /// 当前审批节点(0-待审批,1-审批中,2-已完成) + /// + public int currentNodeOrder { get; set; } + + /// + /// 当前节点ID + /// + public string currentNodeId { get; set; } + + /// + /// 审批状态(待审批/审批中/已通过/未通过/已退回) + /// + public string approvalStatus { get; set; } + + /// + /// 是否已领取(1-已领取,0-未领取) + /// + public int isReceived { get; set; } + + /// + /// 领取时间 + /// + public DateTime? receiveTime { get; set; } + + /// + /// 领取人ID + /// + public string receiveUser { get; set; } + + /// + /// 领取人姓名 + /// + public string receiveUserName { get; set; } + + /// + /// 备注 + /// + public string remarks { get; set; } + + /// + /// 创建时间 + /// + public DateTime createTime { get; set; } + + /// + /// 创建人ID + /// + public string createUser { get; set; } + + /// + /// 创建人姓名 + /// + public string createUserName { get; set; } + + /// + /// 更新时间 + /// + public DateTime? updateTime { get; set; } + + /// + /// 更新人ID + /// + public string updateUser { get; set; } + + /// + /// 更新人姓名 + /// + public string updateUserName { get; set; } + + /// + /// 是否有效(1-有效,0-无效) + /// + public int isEffective { get; set; } + + /// + /// 审批节点信息 + /// + public ApprovalNodeInfo nodeInfo { get; set; } + + /// + /// 审批记录列表 + /// + public List approvalRecords { get; set; } + + /// + /// 使用记录列表(该批次的所有使用记录) + /// + public List usageRecords { get; set; } + } + + /// + /// 审批节点信息 + /// + public class ApprovalNodeInfo + { + /// + /// 节点ID + /// + public string nodeId { get; set; } + + /// + /// 节点序号 + /// + public int nodeOrder { get; set; } + + /// + /// 节点名称 + /// + public string nodeName { get; set; } + + /// + /// 审批类型(会签/或签) + /// + public string approvalType { get; set; } + + /// + /// 审批人列表 + /// + public List approvers { get; set; } + } + + /// + /// 审批人信息 + /// + public class ApproverInfo + { + /// + /// 审批人ID + /// + public string userId { get; set; } + + /// + /// 审批人姓名 + /// + public string userName { get; set; } + } + + /// + /// 审批记录信息 + /// + public class ApprovalRecordInfo + { + /// + /// 审批记录ID + /// + public string id { get; set; } + + /// + /// 节点ID + /// + public string nodeId { get; set; } + + /// + /// 节点序号 + /// + public int nodeOrder { get; set; } + + /// + /// 审批人ID + /// + public string approverId { get; set; } + + /// + /// 审批人姓名 + /// + public string approverName { get; set; } + + /// + /// 审批结果(待审批/已通过/未通过/已退回) + /// + public string approvalResult { get; set; } + + /// + /// 审批意见 + /// + public string approvalOpinion { get; set; } + + /// + /// 审批时间 + /// + public DateTime? approvalTime { get; set; } + + /// + /// 是否当前节点(1-是,0-否) + /// + public int isCurrentNode { get; set; } + } + + /// + /// 使用记录信息 + /// + public class UsageRecordInfo + { + /// + /// 使用记录ID + /// + public string id { get; set; } + + /// + /// 产品ID + /// + public string productId { get; set; } + + /// + /// 产品名称 + /// + public string productName { get; set; } + + /// + /// 产品类别 + /// + public string productCategory { get; set; } + + /// + /// 产品价格 + /// + public decimal productPrice { get; set; } + + /// + /// 门店ID + /// + public string storeId { get; set; } + + /// + /// 门店名称 + /// + public string storeName { get; set; } + + /// + /// 使用时间 + /// + public DateTime usageTime { get; set; } + + /// + /// 使用数量 + /// + public int usageQuantity { get; set; } + + /// + /// 单价 + /// + public decimal unitPrice { get; set; } + + /// + /// 合计金额 + /// + public decimal totalAmount { get; set; } + + /// + /// 关联消耗ID + /// + public string relatedConsumeId { get; set; } + } +} diff --git a/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqInventoryUsageApplication/LqInventoryUsageApplicationListOutput.cs b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqInventoryUsageApplication/LqInventoryUsageApplicationListOutput.cs new file mode 100644 index 0000000..7c8beef --- /dev/null +++ b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqInventoryUsageApplication/LqInventoryUsageApplicationListOutput.cs @@ -0,0 +1,133 @@ +using System; +using System.Collections.Generic; + +namespace NCC.Extend.Entitys.Dto.LqInventoryUsageApplication +{ + /// + /// 库存使用申请列表输出 + /// + public class LqInventoryUsageApplicationListOutput + { + /// + /// 申请编号 + /// + public string id { get; set; } + + /// + /// 使用批次ID + /// + public string usageBatchId { get; set; } + + /// + /// 申请人ID + /// + public string applicationUserId { get; set; } + + /// + /// 申请人姓名 + /// + public string applicationUserName { get; set; } + + /// + /// 申请门店ID + /// + public string applicationStoreId { get; set; } + + /// + /// 申请门店名称 + /// + public string applicationStoreName { get; set; } + + /// + /// 申请时间 + /// + public DateTime applicationTime { get; set; } + + /// + /// 审批状态(待审批/审批中/已通过/未通过/已退回) + /// + public string approvalStatus { get; set; } + + /// + /// 是否已领取(1-已领取,0-未领取) + /// + public int isReceived { get; set; } + + /// + /// 领取时间 + /// + public DateTime? receiveTime { get; set; } + + /// + /// 领取人ID + /// + public string receiveUser { get; set; } + + /// + /// 领取人姓名 + /// + public string receiveUserName { get; set; } + + /// + /// 备注 + /// + public string remarks { get; set; } + + /// + /// 创建时间 + /// + public DateTime createTime { get; set; } + + /// + /// 当前审批人信息列表 + /// + public List currentApprovers { get; set; } + + /// + /// 使用记录统计信息(批次总数量、总金额等) + /// + public BatchUsageInfo batchUsageInfo { get; set; } + } + + /// + /// 当前审批人信息 + /// + public class CurrentApproverInfo + { + /// + /// 审批人ID + /// + public string approverId { get; set; } + + /// + /// 审批人姓名 + /// + public string approverName { get; set; } + + /// + /// 审批结果(待审批/已通过/未通过/已退回) + /// + public string approvalResult { get; set; } + } + + /// + /// 批次使用统计信息 + /// + public class BatchUsageInfo + { + /// + /// 使用记录总数 + /// + public int totalCount { get; set; } + + /// + /// 总使用数量 + /// + public int totalQuantity { get; set; } + + /// + /// 总金额 + /// + public decimal totalAmount { get; set; } + } +} diff --git a/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqInventoryUsageApplication/LqInventoryUsageApplicationListQueryInput.cs b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqInventoryUsageApplication/LqInventoryUsageApplicationListQueryInput.cs new file mode 100644 index 0000000..482e3d1 --- /dev/null +++ b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqInventoryUsageApplication/LqInventoryUsageApplicationListQueryInput.cs @@ -0,0 +1,83 @@ +namespace NCC.Extend.Entitys.Dto.LqInventoryUsageApplication +{ + /// + /// 库存使用申请列表查询输入 + /// + public class LqInventoryUsageApplicationListQueryInput + { + /// + /// 当前页码 + /// + public int currentPage { get; set; } = 1; + + /// + /// 每页数量 + /// + public int pageSize { get; set; } = 20; + + /// + /// 排序字段 + /// + public string sidx { get; set; } + + /// + /// 排序方式(asc/desc) + /// + public string sort { get; set; } + + /// + /// 关键字搜索 + /// + public string keyword { get; set; } + + /// + /// 申请编号 + /// + public string id { get; set; } + + /// + /// 使用批次ID + /// + public string usageBatchId { get; set; } + + /// + /// 申请人ID + /// + public string applicationUserId { get; set; } + + /// + /// 申请门店ID + /// + public string applicationStoreId { get; set; } + + /// + /// 审批状态(待审批/审批中/已通过/未通过/已退回) + /// + public string approvalStatus { get; set; } + + /// + /// 是否已领取(1-已领取,0-未领取) + /// + public int? isReceived { get; set; } + + /// + /// 申请时间开始 + /// + public System.DateTime? applicationTimeStart { get; set; } + + /// + /// 申请时间结束 + /// + public System.DateTime? applicationTimeEnd { get; set; } + + /// + /// 是否有效(1-有效,0-无效) + /// + public int? isEffective { get; set; } + + /// + /// 查询JSON(用于复杂查询条件) + /// + public string queryJson { get; set; } + } +} diff --git a/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqInventoryUsageApplication/LqInventoryUsageApplicationReceiveInput.cs b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqInventoryUsageApplication/LqInventoryUsageApplicationReceiveInput.cs new file mode 100644 index 0000000..df2c06d --- /dev/null +++ b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqInventoryUsageApplication/LqInventoryUsageApplicationReceiveInput.cs @@ -0,0 +1,18 @@ +namespace NCC.Extend.Entitys.Dto.LqInventoryUsageApplication +{ + /// + /// 库存使用申请领取输入 + /// + public class LqInventoryUsageApplicationReceiveInput + { + /// + /// 是否已领取(1-已领取,0-未领取) + /// + public int isReceived { get; set; } + + /// + /// 备注 + /// + public string remarks { get; set; } + } +} diff --git a/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqInventoryUsageApplication/LqInventoryUsageApplicationUpInput.cs b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqInventoryUsageApplication/LqInventoryUsageApplicationUpInput.cs new file mode 100644 index 0000000..5044e15 --- /dev/null +++ b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqInventoryUsageApplication/LqInventoryUsageApplicationUpInput.cs @@ -0,0 +1,23 @@ +namespace NCC.Extend.Entitys.Dto.LqInventoryUsageApplication +{ + /// + /// 库存使用申请更新输入 + /// + public class LqInventoryUsageApplicationUpInput + { + /// + /// 申请编号 + /// + public string id { get; set; } + + /// + /// 是否已领取(1-已领取,0-未领取) + /// + public int? isReceived { get; set; } + + /// + /// 备注 + /// + public string remarks { get; set; } + } +} diff --git a/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqReimbursementApplicationInfoOutput.cs b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqReimbursementApplicationInfoOutput.cs index cbcda0d..df440ab 100644 --- a/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqReimbursementApplicationInfoOutput.cs +++ b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqReimbursementApplicationInfoOutput.cs @@ -27,7 +27,7 @@ namespace NCC.Extend.Entitys.Dto.LqReimbursementApplication /// 申请门店 /// public string applicationStoreId { get; set; } - + /// /// 申请门店名称 /// diff --git a/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqTechTeacherSalary/TechTeacherSalaryInput.cs b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqTechTeacherSalary/TechTeacherSalaryInput.cs index 24e8abe..33395db 100644 --- a/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqTechTeacherSalary/TechTeacherSalaryInput.cs +++ b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqTechTeacherSalary/TechTeacherSalaryInput.cs @@ -30,3 +30,5 @@ namespace NCC.Extend.Entitys.Dto.LqTechTeacherSalary } } + + diff --git a/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqTechTeacherSalary/TechTeacherSalaryOutput.cs b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqTechTeacherSalary/TechTeacherSalaryOutput.cs index 3e254cd..f3e0765 100644 --- a/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqTechTeacherSalary/TechTeacherSalaryOutput.cs +++ b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqTechTeacherSalary/TechTeacherSalaryOutput.cs @@ -319,3 +319,5 @@ namespace NCC.Extend.Entitys.Dto.LqTechTeacherSalary } } + + diff --git a/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Entity/lq_contract/LqContractEntity.cs b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Entity/lq_contract/LqContractEntity.cs new file mode 100644 index 0000000..53d274f --- /dev/null +++ b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Entity/lq_contract/LqContractEntity.cs @@ -0,0 +1,140 @@ +using System; +using NCC.Common.Const; +using SqlSugar; + +namespace NCC.Extend.Entitys.lq_contract +{ + /// + /// 合同表 + /// + [SugarTable("lq_contract")] + [Tenant(ClaimConst.TENANT_ID)] + public class LqContractEntity + { + /// + /// 主键ID + /// + [SugarColumn(ColumnName = "F_Id", IsPrimaryKey = true)] + public string Id { get; set; } + + /// + /// 门店ID(关联lq_mdxx.F_Id) + /// + [SugarColumn(ColumnName = "F_StoreId")] + public string StoreId { get; set; } + + /// + /// 店名(冗余字段,便于查询) + /// + [SugarColumn(ColumnName = "F_StoreName")] + public string StoreName { get; set; } + + /// + /// 标题 + /// + [SugarColumn(ColumnName = "F_Title")] + public string Title { get; set; } + + /// + /// 分类(string类型,自己填写) + /// + [SugarColumn(ColumnName = "F_Category")] + public string Category { get; set; } + + /// + /// 户名 + /// + [SugarColumn(ColumnName = "F_TenantName")] + public string TenantName { get; set; } + + /// + /// 合同起始日期 + /// + [SugarColumn(ColumnName = "F_ContractStartDate")] + public DateTime ContractStartDate { get; set; } + + /// + /// 合同结束日期 + /// + [SugarColumn(ColumnName = "F_ContractEndDate")] + public DateTime ContractEndDate { get; set; } + + /// + /// 提前多少天提醒 + /// + [SugarColumn(ColumnName = "F_ReminderDays")] + public int ReminderDays { get; set; } = 0; + + /// + /// 押金 + /// + [SugarColumn(ColumnName = "F_Deposit", DecimalDigits = 2)] + public decimal Deposit { get; set; } = 0; + + /// + /// 下次应交时间 + /// + [SugarColumn(ColumnName = "F_NextPaymentDate")] + public DateTime? NextPaymentDate { get; set; } + + /// + /// 月租 + /// + [SugarColumn(ColumnName = "F_MonthlyRent", DecimalDigits = 2)] + public decimal MonthlyRent { get; set; } + + /// + /// 缴租金额(每次交租的金额,通常=月租×交租周期) + /// + [SugarColumn(ColumnName = "F_PaymentAmount", DecimalDigits = 2)] + public decimal PaymentAmount { get; set; } + + /// + /// 交租周期(数字,表示几个月,如1、3、6等) + /// + [SugarColumn(ColumnName = "F_PaymentCycle")] + public int PaymentCycle { get; set; } + + /// + /// 备注 + /// + [SugarColumn(ColumnName = "F_Remarks")] + public string Remarks { get; set; } + + /// + /// 附件(存储附件路径或JSON) + /// + [SugarColumn(ColumnName = "F_Attachment")] + public string Attachment { get; set; } + + /// + /// 创建人ID + /// + [SugarColumn(ColumnName = "F_CreateUser")] + public string CreateUser { get; set; } + + /// + /// 创建时间 + /// + [SugarColumn(ColumnName = "F_CreateTime")] + public DateTime CreateTime { get; set; } + + /// + /// 更新人ID + /// + [SugarColumn(ColumnName = "F_UpdateUser")] + public string UpdateUser { get; set; } + + /// + /// 更新时间 + /// + [SugarColumn(ColumnName = "F_UpdateTime")] + public DateTime? UpdateTime { get; set; } + + /// + /// 是否有效(1-有效,0-无效) + /// + [SugarColumn(ColumnName = "F_IsEffective")] + public int IsEffective { get; set; } = 1; + } +} diff --git a/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Entity/lq_contract_rent_detail/LqContractRentDetailEntity.cs b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Entity/lq_contract_rent_detail/LqContractRentDetailEntity.cs new file mode 100644 index 0000000..9ac6f4f --- /dev/null +++ b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Entity/lq_contract_rent_detail/LqContractRentDetailEntity.cs @@ -0,0 +1,98 @@ +using System; +using NCC.Common.Const; +using SqlSugar; + +namespace NCC.Extend.Entitys.lq_contract_rent_detail +{ + /// + /// 月租明细表 + /// + [SugarTable("lq_contract_rent_detail")] + [Tenant(ClaimConst.TENANT_ID)] + public class LqContractRentDetailEntity + { + /// + /// 主键ID + /// + [SugarColumn(ColumnName = "F_Id", IsPrimaryKey = true)] + public string Id { get; set; } + + /// + /// 合同ID(关联lq_contract.F_Id) + /// + [SugarColumn(ColumnName = "F_ContractId")] + public string ContractId { get; set; } + + /// + /// 应缴月份(表示哪个月份,格式:YYYY-MM-01) + /// + [SugarColumn(ColumnName = "F_PaymentMonth")] + public DateTime PaymentMonth { get; set; } + + /// + /// 应缴日期(具体应缴日期) + /// + [SugarColumn(ColumnName = "F_DueDate")] + public DateTime DueDate { get; set; } + + /// + /// 应缴金额 + /// + [SugarColumn(ColumnName = "F_DueAmount", DecimalDigits = 2)] + public decimal DueAmount { get; set; } + + /// + /// 是否已缴(0-未缴,1-已缴) + /// + [SugarColumn(ColumnName = "F_IsPaid")] + public int IsPaid { get; set; } = 0; + + /// + /// 实际缴费时间 + /// + [SugarColumn(ColumnName = "F_ActualPaymentDate")] + public DateTime? ActualPaymentDate { get; set; } + + /// + /// 实际缴费金额 + /// + [SugarColumn(ColumnName = "F_ActualPaymentAmount", DecimalDigits = 2)] + public decimal? ActualPaymentAmount { get; set; } + + /// + /// 备注 + /// + [SugarColumn(ColumnName = "F_Remarks")] + public string Remarks { get; set; } + + /// + /// 创建人ID + /// + [SugarColumn(ColumnName = "F_CreateUser")] + public string CreateUser { get; set; } + + /// + /// 创建时间 + /// + [SugarColumn(ColumnName = "F_CreateTime")] + public DateTime CreateTime { get; set; } + + /// + /// 更新人ID + /// + [SugarColumn(ColumnName = "F_UpdateUser")] + public string UpdateUser { get; set; } + + /// + /// 更新时间 + /// + [SugarColumn(ColumnName = "F_UpdateTime")] + public DateTime? UpdateTime { get; set; } + + /// + /// 是否有效(1-有效,0-无效) + /// + [SugarColumn(ColumnName = "F_IsEffective")] + public int IsEffective { get; set; } = 1; + } +} diff --git a/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Entity/lq_inventory_usage/LqInventoryUsageEntity.cs b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Entity/lq_inventory_usage/LqInventoryUsageEntity.cs index 66babf8..d4e6622 100644 --- a/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Entity/lq_inventory_usage/LqInventoryUsageEntity.cs +++ b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Entity/lq_inventory_usage/LqInventoryUsageEntity.cs @@ -42,6 +42,18 @@ namespace NCC.Extend.Entitys.lq_inventory_usage public int UsageQuantity { get; set; } /// + /// 单价(从产品表F_Price获取) + /// + [SugarColumn(ColumnName = "F_UnitPrice")] + public decimal UnitPrice { get; set; } + + /// + /// 合计金额(单价×数量) + /// + [SugarColumn(ColumnName = "F_TotalAmount")] + public decimal TotalAmount { get; set; } + + /// /// 关联消耗ID /// [SugarColumn(ColumnName = "F_RelatedConsumeId")] diff --git a/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Entity/lq_inventory_usage_application/LqInventoryUsageApplicationEntity.cs b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Entity/lq_inventory_usage_application/LqInventoryUsageApplicationEntity.cs new file mode 100644 index 0000000..b4fa096 --- /dev/null +++ b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Entity/lq_inventory_usage_application/LqInventoryUsageApplicationEntity.cs @@ -0,0 +1,130 @@ +using NCC.Common.Const; +using SqlSugar; +using System; + +namespace NCC.Extend.Entitys.lq_inventory_usage_application +{ + /// + /// 库存使用申请表 + /// + [SugarTable("lq_inventory_usage_application")] + [Tenant(ClaimConst.TENANT_ID)] + public class LqInventoryUsageApplicationEntity + { + /// + /// 申请编号 + /// + [SugarColumn(ColumnName = "F_Id", IsPrimaryKey = true)] + public string Id { get; set; } + + /// + /// 使用批次ID(关联lq_inventory_usage.F_UsageBatchId) + /// + [SugarColumn(ColumnName = "F_UsageBatchId")] + public string UsageBatchId { get; set; } + + /// + /// 申请人ID + /// + [SugarColumn(ColumnName = "F_ApplicationUserId")] + public string ApplicationUserId { get; set; } + + /// + /// 申请人姓名 + /// + [SugarColumn(ColumnName = "F_ApplicationUserName")] + public string ApplicationUserName { get; set; } + + /// + /// 申请门店ID + /// + [SugarColumn(ColumnName = "F_ApplicationStoreId")] + public string ApplicationStoreId { get; set; } + + /// + /// 申请时间 + /// + [SugarColumn(ColumnName = "F_ApplicationTime")] + public DateTime ApplicationTime { get; set; } + + /// + /// 节点数量(固定为1) + /// + [SugarColumn(ColumnName = "F_NodeCount")] + public int NodeCount { get; set; } = 1; + + /// + /// 当前审批节点(0-待审批,1-审批中,2-已完成) + /// + [SugarColumn(ColumnName = "F_CurrentNodeOrder")] + public int CurrentNodeOrder { get; set; } = 0; + + /// + /// 当前节点ID + /// + [SugarColumn(ColumnName = "F_CurrentNodeId")] + public string CurrentNodeId { get; set; } + + /// + /// 审批状态(待审批/审批中/已通过/未通过/已退回) + /// + [SugarColumn(ColumnName = "F_ApprovalStatus")] + public string ApprovalStatus { get; set; } = "待审批"; + + /// + /// 是否已领取(1-已领取,0-未领取) + /// + [SugarColumn(ColumnName = "F_IsReceived")] + public int IsReceived { get; set; } = 0; + + /// + /// 领取时间 + /// + [SugarColumn(ColumnName = "F_ReceiveTime")] + public DateTime? ReceiveTime { get; set; } + + /// + /// 领取人ID + /// + [SugarColumn(ColumnName = "F_ReceiveUser")] + public string ReceiveUser { get; set; } + + /// + /// 备注 + /// + [SugarColumn(ColumnName = "F_Remarks")] + public string Remarks { get; set; } + + /// + /// 创建时间 + /// + [SugarColumn(ColumnName = "F_CreateTime")] + public DateTime CreateTime { get; set; } + + /// + /// 创建人ID + /// + [SugarColumn(ColumnName = "F_CreateUser")] + public string CreateUser { get; set; } + + /// + /// 更新时间 + /// + [SugarColumn(ColumnName = "F_UpdateTime")] + public DateTime? UpdateTime { get; set; } + + /// + /// 更新人ID + /// + [SugarColumn(ColumnName = "F_UpdateUser")] + public string UpdateUser { get; set; } + + /// + /// 是否有效(1-有效,0-无效) + /// + [SugarColumn(ColumnName = "F_IsEffective")] + public int IsEffective { get; set; } = 1; + } +} + + diff --git a/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Entity/lq_inventory_usage_application_node/LqInventoryUsageApplicationNodeEntity.cs b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Entity/lq_inventory_usage_application_node/LqInventoryUsageApplicationNodeEntity.cs new file mode 100644 index 0000000..2de8618 --- /dev/null +++ b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Entity/lq_inventory_usage_application_node/LqInventoryUsageApplicationNodeEntity.cs @@ -0,0 +1,58 @@ +using NCC.Common.Const; +using SqlSugar; +using System; + +namespace NCC.Extend.Entitys.lq_inventory_usage_application_node +{ + /// + /// 库存使用申请节点表(每个申请的节点配置,固定为1个节点) + /// + [SugarTable("lq_inventory_usage_application_node")] + [Tenant(ClaimConst.TENANT_ID)] + public class LqInventoryUsageApplicationNodeEntity + { + /// + /// 节点编号 + /// + [SugarColumn(ColumnName = "F_Id", IsPrimaryKey = true)] + public string Id { get; set; } + + /// + /// 申请ID + /// + [SugarColumn(ColumnName = "F_ApplicationId")] + public string ApplicationId { get; set; } + + /// + /// 节点顺序(固定为1) + /// + [SugarColumn(ColumnName = "F_NodeOrder")] + public int NodeOrder { get; set; } = 1; + + /// + /// 节点名称 + /// + [SugarColumn(ColumnName = "F_NodeName")] + public string NodeName { get; set; } = "审批"; + + /// + /// 审批类型(会签/或签) + /// + [SugarColumn(ColumnName = "F_ApprovalType")] + public string ApprovalType { get; set; } = "会签"; + + /// + /// 是否必审(1-必审,0-可选) + /// + [SugarColumn(ColumnName = "F_IsRequired")] + public int IsRequired { get; set; } = 1; + + /// + /// 创建时间 + /// + [SugarColumn(ColumnName = "F_CreateTime")] + public DateTime CreateTime { get; set; } + } +} + + diff --git a/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Entity/lq_inventory_usage_approval_record/LqInventoryUsageApprovalRecordEntity.cs b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Entity/lq_inventory_usage_approval_record/LqInventoryUsageApprovalRecordEntity.cs new file mode 100644 index 0000000..5826882 --- /dev/null +++ b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Entity/lq_inventory_usage_approval_record/LqInventoryUsageApprovalRecordEntity.cs @@ -0,0 +1,76 @@ +using NCC.Common.Const; +using SqlSugar; +using System; + +namespace NCC.Extend.Entitys.lq_inventory_usage_approval_record +{ + /// + /// 库存使用申请审批记录表 + /// + [SugarTable("lq_inventory_usage_approval_record")] + [Tenant(ClaimConst.TENANT_ID)] + public class LqInventoryUsageApprovalRecordEntity + { + /// + /// 记录编号 + /// + [SugarColumn(ColumnName = "F_Id", IsPrimaryKey = true)] + public string Id { get; set; } + + /// + /// 申请ID + /// + [SugarColumn(ColumnName = "F_ApplicationId")] + public string ApplicationId { get; set; } + + /// + /// 节点编号 + /// + [SugarColumn(ColumnName = "F_NodeId")] + public string NodeId { get; set; } + + /// + /// 节点顺序(固定为1) + /// + [SugarColumn(ColumnName = "F_NodeOrder")] + public int NodeOrder { get; set; } = 1; + + /// + /// 审批人ID + /// + [SugarColumn(ColumnName = "F_ApproverId")] + public string ApproverId { get; set; } + + /// + /// 审批人姓名 + /// + [SugarColumn(ColumnName = "F_ApproverName")] + public string ApproverName { get; set; } + + /// + /// 审批结果(通过/不通过/退回) + /// + [SugarColumn(ColumnName = "F_ApprovalResult")] + public string ApprovalResult { get; set; } + + /// + /// 审批意见 + /// + [SugarColumn(ColumnName = "F_ApprovalOpinion")] + public string ApprovalOpinion { get; set; } + + /// + /// 审批时间 + /// + [SugarColumn(ColumnName = "F_ApprovalTime")] + public DateTime ApprovalTime { get; set; } + + /// + /// 是否当前节点(1-是,0-否) + /// + [SugarColumn(ColumnName = "F_IsCurrentNode")] + public int IsCurrentNode { get; set; } = 0; + } +} + + diff --git a/netcore/src/Modularity/Extend/NCC.Extend.Interfaces/LqInventoryUsageApplication/ILqInventoryUsageApplicationService.cs b/netcore/src/Modularity/Extend/NCC.Extend.Interfaces/LqInventoryUsageApplication/ILqInventoryUsageApplicationService.cs new file mode 100644 index 0000000..a744977 --- /dev/null +++ b/netcore/src/Modularity/Extend/NCC.Extend.Interfaces/LqInventoryUsageApplication/ILqInventoryUsageApplicationService.cs @@ -0,0 +1,78 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using NCC.Extend.Entitys.Dto.LqInventoryUsageApplication; + +namespace NCC.Extend.Interfaces.LqInventoryUsageApplication +{ + /// + /// 库存使用申请服务接口 + /// + public interface ILqInventoryUsageApplicationService + { + /// + /// 获取库存使用申请列表 + /// + /// 查询参数 + /// 分页列表 + Task GetList(LqInventoryUsageApplicationListQueryInput input); + + /// + /// 获取库存使用申请详情 + /// + /// 申请编号 + /// 申请详情 + Task GetInfo(string id); + + /// + /// 创建库存使用申请 + /// + /// 创建参数 + /// 创建的申请ID + Task Create(LqInventoryUsageApplicationCrInput input); + + /// + /// 更新库存使用申请 + /// + /// 申请编号 + /// 更新参数 + /// + Task Update(string id, LqInventoryUsageApplicationUpInput input); + + /// + /// 提交审批 + /// + /// 申请编号 + /// + Task SubmitApproval(string id); + + /// + /// 审批操作(通过/不通过/退回) + /// + /// 申请编号 + /// 审批参数 + /// + Task Approve(string id, LqInventoryUsageApplicationApproveInput input); + + /// + /// 领取操作 + /// + /// 申请编号 + /// 领取参数 + /// + Task Receive(string id, LqInventoryUsageApplicationReceiveInput input); + + /// + /// 查询待审批列表 + /// + /// 查询参数 + /// 分页列表 + Task PendingApproval(LqInventoryUsageApplicationListQueryInput input); + + /// + /// 查询审批历史 + /// + /// 申请编号 + /// 审批历史记录列表 + Task ApprovalHistory(string id); + } +} diff --git a/netcore/src/Modularity/Extend/NCC.Extend.Interfaces/LqMdMajorProjectTeacherAssignment/ILqMdMajorProjectTeacherAssignmentService.cs b/netcore/src/Modularity/Extend/NCC.Extend.Interfaces/LqMdMajorProjectTeacherAssignment/ILqMdMajorProjectTeacherAssignmentService.cs index 03d3bf7..c42e95d 100644 --- a/netcore/src/Modularity/Extend/NCC.Extend.Interfaces/LqMdMajorProjectTeacherAssignment/ILqMdMajorProjectTeacherAssignmentService.cs +++ b/netcore/src/Modularity/Extend/NCC.Extend.Interfaces/LqMdMajorProjectTeacherAssignment/ILqMdMajorProjectTeacherAssignmentService.cs @@ -12,8 +12,9 @@ namespace NCC.Extend.Interfaces.LqMdMajorProjectTeacherAssignment /// /// 复制上月设置 /// - /// 目标月份(YYYYMM格式),如果为空则复制到当前月份 + /// 目标年份(YYYY格式),如果为空则复制到当前年份 + /// 目标月份(MM格式),如果为空则复制到当前月份 /// - Task CopyLastMonthData(string targetMonth = null); + Task CopyLastMonthData(string targetYear = null, string targetMonth = null); } } diff --git a/netcore/src/Modularity/Extend/NCC.Extend/LqContractService.cs b/netcore/src/Modularity/Extend/NCC.Extend/LqContractService.cs new file mode 100644 index 0000000..9a85e27 --- /dev/null +++ b/netcore/src/Modularity/Extend/NCC.Extend/LqContractService.cs @@ -0,0 +1,1039 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; +using NCC.Common.Core.Manager; +using NCC.Common.Filter; +using NCC.Dependency; +using NCC.DynamicApiController; +using NCC.Extend.Entitys.Dto.LqContract; +using NCC.Extend.Entitys.Enum; +using NCC.Extend.Entitys.lq_contract; +using NCC.Extend.Entitys.lq_contract_rent_detail; +using NCC.Extend.Entitys.lq_mdxx; +using NCC.FriendlyException; +using NCC.System.Entitys.Permission; +using SqlSugar; +using Yitter.IdGenerator; + +namespace NCC.Extend +{ + /// + /// 合同管理服务 + /// + [ApiDescriptionSettings(Tag = "绿纤合同管理", Name = "LqContract", Order = 250)] + [Route("api/Extend/LqContract")] + public class LqContractService : IDynamicApiController, ITransient + { + private readonly IUserManager _userManager; + private readonly ILogger _logger; + private readonly ISqlSugarClient _db; + + /// + /// 构造函数 + /// + /// 用户管理器 + /// 日志记录器 + /// 数据库客户端 + public LqContractService(IUserManager userManager, ILogger logger, ISqlSugarClient db) + { + _userManager = userManager; + _logger = logger; + _db = db; + } + + #region 创建合同 + + /// + /// 创建合同 + /// + /// + /// 创建新合同,系统会自动根据合同信息生成月租明细 + /// + /// 示例请求: + /// ```json + /// { + /// "storeId": "门店ID", + /// "title": "门店租赁合同", + /// "category": "租赁合同", + /// "tenantName": "张三", + /// "contractStartDate": "2025-01-01T00:00:00", + /// "contractEndDate": "2025-12-31T23:59:59", + /// "reminderDays": 7, + /// "deposit": 5000.00, + /// "monthlyRent": 1000.00, + /// "paymentAmount": 3000.00, + /// "paymentCycle": 3, + /// "remarks": "季度交租", + /// "attachment": "" + /// } + /// ``` + /// + /// 业务流程: + /// 1. 验证合同信息 + /// 2. 查询门店信息(获取店名) + /// 3. 创建合同记录 + /// 4. 自动生成月租明细(根据合同起始日期、结束日期、交租周期、缴租金额) + /// 5. 计算下次应交时间 + /// + /// 创建输入 + /// 创建结果 + /// 创建成功 + /// 请求参数错误 + /// 服务器错误 + [HttpPost("Create")] + public async Task CreateAsync([FromBody] LqContractCrInput input) + { + try + { + // 验证合同日期 + if (input.ContractStartDate >= input.ContractEndDate) + { + throw NCCException.Oh("合同起始日期必须小于合同结束日期"); + } + + // 验证交租周期 + if (input.PaymentCycle <= 0 || input.PaymentCycle > 12) + { + throw NCCException.Oh("交租周期必须在1-12个月之间"); + } + + // 查询门店信息 + var store = await _db.Queryable() + .Where(x => x.Id == input.StoreId) + .Select(x => new { x.Dm }) + .FirstAsync(); + + if (store == null) + { + throw NCCException.Oh("门店不存在"); + } + + _db.Ado.BeginTran(); + + try + { + // 创建合同 + var contractEntity = new LqContractEntity + { + Id = YitIdHelper.NextId().ToString(), + StoreId = input.StoreId, + StoreName = store.Dm ?? "", + Title = input.Title, + Category = input.Category, + TenantName = input.TenantName, + ContractStartDate = input.ContractStartDate, + ContractEndDate = input.ContractEndDate, + ReminderDays = input.ReminderDays, + Deposit = input.Deposit, + MonthlyRent = input.MonthlyRent, + PaymentAmount = input.PaymentAmount, + PaymentCycle = input.PaymentCycle, + Remarks = input.Remarks, + Attachment = input.Attachment, + CreateUser = _userManager.UserId, + CreateTime = DateTime.Now, + IsEffective = StatusEnum.有效.GetHashCode() + }; + + var insertCount = await _db.Insertable(contractEntity).ExecuteCommandAsync(); + if (insertCount <= 0) + { + throw NCCException.Oh("创建合同失败"); + } + + // 自动生成月租明细 + await GenerateRentDetailsAsync(contractEntity.Id, contractEntity.ContractStartDate, contractEntity.ContractEndDate, contractEntity.PaymentCycle, contractEntity.PaymentAmount); + + // 计算下次应交时间 + await CalculateNextPaymentDate(contractEntity.Id); + + _db.Ado.CommitTran(); + } + catch + { + _db.Ado.RollbackTran(); + throw; + } + } + catch (Exception ex) + { + _db.Ado.RollbackTran(); + _logger.LogError(ex, "创建合同失败"); + throw NCCException.Oh($"创建失败:{ex.Message}"); + } + } + + #endregion + + #region 更新合同 + + /// + /// 更新合同 + /// + /// + /// 更新合同信息。如果修改了合同起始日期、结束日期、交租周期或缴租金额,系统会重新生成月租明细。 + /// + /// 示例请求: + /// ```json + /// { + /// "id": "合同ID", + /// "storeId": "门店ID", + /// "title": "门店租赁合同", + /// "category": "租赁合同", + /// "tenantName": "张三", + /// "contractStartDate": "2025-01-01T00:00:00", + /// "contractEndDate": "2025-12-31T23:59:59", + /// "reminderDays": 7, + /// "deposit": 5000.00, + /// "monthlyRent": 1000.00, + /// "paymentAmount": 3000.00, + /// "paymentCycle": 3, + /// "remarks": "季度交租", + /// "attachment": "" + /// } + /// ``` + /// + /// 更新输入 + /// 更新结果 + /// 更新成功 + /// 请求参数错误或合同不存在 + /// 服务器错误 + [HttpPut("Update")] + public async Task UpdateAsync([FromBody] LqContractUpInput input) + { + try + { + // 查询合同 + var contract = await _db.Queryable() + .Where(x => x.Id == input.Id && x.IsEffective == StatusEnum.有效.GetHashCode()) + .FirstAsync(); + + if (contract == null) + { + throw NCCException.Oh("合同不存在或已失效"); + } + + // 验证合同日期 + if (input.ContractStartDate >= input.ContractEndDate) + { + throw NCCException.Oh("合同起始日期必须小于合同结束日期"); + } + + // 验证交租周期 + if (input.PaymentCycle <= 0 || input.PaymentCycle > 12) + { + throw NCCException.Oh("交租周期必须在1-12个月之间"); + } + + // 查询门店信息 + var store = await _db.Queryable() + .Where(x => x.Id == input.StoreId) + .Select(x => new { x.Dm }) + .FirstAsync(); + + if (store == null) + { + throw NCCException.Oh("门店不存在"); + } + + _db.Ado.BeginTran(); + + try + { + // 判断是否需要重新生成明细 + bool needRegenerateDetails = contract.ContractStartDate != input.ContractStartDate || + contract.ContractEndDate != input.ContractEndDate || + contract.PaymentCycle != input.PaymentCycle || + contract.PaymentAmount != input.PaymentAmount; + + // 更新合同信息 + contract.StoreId = input.StoreId; + contract.StoreName = store.Dm ?? ""; + contract.Title = input.Title; + contract.Category = input.Category; + contract.TenantName = input.TenantName; + contract.ContractStartDate = input.ContractStartDate; + contract.ContractEndDate = input.ContractEndDate; + contract.ReminderDays = input.ReminderDays; + contract.Deposit = input.Deposit; + contract.MonthlyRent = input.MonthlyRent; + contract.PaymentAmount = input.PaymentAmount; + contract.PaymentCycle = input.PaymentCycle; + contract.Remarks = input.Remarks; + contract.Attachment = input.Attachment; + contract.UpdateUser = _userManager.UserId; + contract.UpdateTime = DateTime.Now; + + var updateCount = await _db.Updateable(contract).ExecuteCommandAsync(); + if (updateCount <= 0) + { + throw NCCException.Oh("更新合同失败"); + } + + // 如果需要重新生成明细,先删除旧明细,再生成新明细 + if (needRegenerateDetails) + { + // 删除旧的明细(逻辑删除) + await _db.Updateable() + .SetColumns(x => new LqContractRentDetailEntity + { + IsEffective = StatusEnum.无效.GetHashCode(), + UpdateUser = _userManager.UserId, + UpdateTime = DateTime.Now + }) + .Where(x => x.ContractId == contract.Id && x.IsEffective == StatusEnum.有效.GetHashCode()) + .ExecuteCommandAsync(); + + // 生成新的明细 + await GenerateRentDetailsAsync(contract.Id, contract.ContractStartDate, contract.ContractEndDate, contract.PaymentCycle, contract.PaymentAmount); + } + + // 重新计算下次应交时间 + await CalculateNextPaymentDate(contract.Id); + + _db.Ado.CommitTran(); + } + catch + { + _db.Ado.RollbackTran(); + throw; + } + } + catch (Exception ex) + { + _db.Ado.RollbackTran(); + _logger.LogError(ex, "更新合同失败"); + throw NCCException.Oh($"更新失败:{ex.Message}"); + } + } + + #endregion + + #region 删除合同 + + /// + /// 删除合同 + /// + /// + /// 删除合同,同时会级联删除该合同的所有月租明细(逻辑删除) + /// + /// 示例请求: + /// ``` + /// DELETE /api/Extend/LqContract/{id} + /// ``` + /// + /// 合同ID + /// 删除结果 + /// 删除成功 + /// 合同不存在 + /// 服务器错误 + [HttpDelete("{id}")] + public async Task DeleteAsync([FromRoute] string id) + { + try + { + if (string.IsNullOrWhiteSpace(id)) + { + throw NCCException.Oh("合同ID不能为空"); + } + + // 查询合同 + var contract = await _db.Queryable() + .Where(x => x.Id == id && x.IsEffective == StatusEnum.有效.GetHashCode()) + .FirstAsync(); + + if (contract == null) + { + throw NCCException.Oh("合同不存在或已失效"); + } + + _db.Ado.BeginTran(); + + try + { + // 删除该合同的所有月租明细(逻辑删除) + await _db.Updateable() + .SetColumns(x => new LqContractRentDetailEntity + { + IsEffective = StatusEnum.无效.GetHashCode(), + UpdateUser = _userManager.UserId, + UpdateTime = DateTime.Now + }) + .Where(x => x.ContractId == id && x.IsEffective == StatusEnum.有效.GetHashCode()) + .ExecuteCommandAsync(); + + // 删除合同(逻辑删除) + contract.IsEffective = StatusEnum.无效.GetHashCode(); + contract.UpdateUser = _userManager.UserId; + contract.UpdateTime = DateTime.Now; + + var updateCount = await _db.Updateable(contract).ExecuteCommandAsync(); + if (updateCount <= 0) + { + throw NCCException.Oh("删除合同失败"); + } + + _db.Ado.CommitTran(); + } + catch + { + _db.Ado.RollbackTran(); + throw; + } + } + catch (Exception ex) + { + _db.Ado.RollbackTran(); + _logger.LogError(ex, "删除合同失败"); + throw NCCException.Oh($"删除失败:{ex.Message}"); + } + } + + #endregion + + #region 获取合同列表 + + /// + /// 获取合同列表 + /// + /// + /// 分页查询合同列表,支持多条件筛选 + /// + /// 示例请求: + /// ``` + /// GET /api/Extend/LqContract/GetList?currentPage=1&pageSize=10&storeId=门店ID&title=合同标题 + /// ``` + /// + /// 查询输入 + /// 合同列表 + /// 查询成功 + /// 服务器错误 + [HttpGet("GetList")] + public async Task GetListAsync([FromQuery] LqContractListQueryInput input) + { + try + { + var sidx = string.IsNullOrEmpty(input.sidx) ? "createTime" : input.sidx; + var sort = string.IsNullOrEmpty(input.sort) ? "desc" : input.sort; + + var data = await _db.Queryable() + .WhereIF(!string.IsNullOrWhiteSpace(input.StoreId), x => x.StoreId == input.StoreId) + .WhereIF(!string.IsNullOrWhiteSpace(input.StoreName), x => x.StoreName != null && x.StoreName.Contains(input.StoreName)) + .WhereIF(!string.IsNullOrWhiteSpace(input.Category), x => x.Category == input.Category) + .WhereIF(!string.IsNullOrWhiteSpace(input.Title), x => x.Title != null && x.Title.Contains(input.Title)) + .WhereIF(input.ContractStartDateBegin.HasValue, x => x.ContractStartDate >= input.ContractStartDateBegin.Value) + .WhereIF(input.ContractStartDateEnd.HasValue, x => x.ContractStartDate <= input.ContractStartDateEnd.Value) + .WhereIF(input.ContractEndDateBegin.HasValue, x => x.ContractEndDate >= input.ContractEndDateBegin.Value) + .WhereIF(input.ContractEndDateEnd.HasValue, x => x.ContractEndDate <= input.ContractEndDateEnd.Value) + .WhereIF(input.IsEffective.HasValue, x => x.IsEffective == input.IsEffective.Value) + .Where(x => x.IsEffective == StatusEnum.有效.GetHashCode()) + .Select(x => new LqContractListOutput + { + id = x.Id, + storeId = x.StoreId, + storeName = x.StoreName, + title = x.Title, + category = x.Category, + tenantName = x.TenantName, + contractStartDate = x.ContractStartDate, + contractEndDate = x.ContractEndDate, + reminderDays = x.ReminderDays, + deposit = x.Deposit, + nextPaymentDate = x.NextPaymentDate, + monthlyRent = x.MonthlyRent, + paymentAmount = x.PaymentAmount, + paymentCycle = x.PaymentCycle, + remarks = x.Remarks, + attachment = x.Attachment, + createUser = x.CreateUser, + createUserName = "", + createTime = x.CreateTime, + updateUser = x.UpdateUser, + updateUserName = "", + updateTime = x.UpdateTime, + isEffective = x.IsEffective + }) + .MergeTable() + .OrderBy(sidx + " " + sort) + .ToPagedListAsync(input.currentPage, input.pageSize); + + // 补充用户信息 + var userIds = data.list.SelectMany(x => new[] { x.createUser, x.updateUser }) + .Where(x => !string.IsNullOrEmpty(x)) + .Distinct() + .ToList(); + + if (userIds.Any()) + { + var userList = await _db.Queryable() + .Where(x => userIds.Contains(x.Id)) + .Select(x => new { x.Id, x.RealName }) + .ToListAsync(); + var userDict = userList.ToDictionary(k => k.Id, v => v.RealName); + + foreach (var item in data.list) + { + if (!string.IsNullOrEmpty(item.createUser) && userDict.ContainsKey(item.createUser)) + item.createUserName = userDict[item.createUser]; + if (!string.IsNullOrEmpty(item.updateUser) && userDict.ContainsKey(item.updateUser)) + item.updateUserName = userDict[item.updateUser]; + } + } + + return PageResult.SqlSugarPageResult(data); + } + catch (Exception ex) + { + _logger.LogError(ex, "获取合同列表失败"); + throw NCCException.Oh($"获取合同列表失败:{ex.Message}"); + } + } + + #endregion + + #region 获取合同详情 + + /// + /// 获取合同详情 + /// + /// + /// 根据合同ID获取合同详细信息,包括月租明细列表 + /// + /// 示例请求: + /// ``` + /// GET /api/Extend/LqContract/GetInfo?id=合同ID + /// ``` + /// + /// 合同ID + /// 合同详情 + /// 查询成功 + /// 合同ID不能为空 + /// 合同不存在 + /// 服务器错误 + [HttpGet("GetInfo")] + public async Task GetInfoAsync([FromQuery] string id) + { + try + { + if (string.IsNullOrWhiteSpace(id)) + { + throw NCCException.Oh("合同ID不能为空"); + } + + // 查询合同 + var contract = await _db.Queryable() + .Where(x => x.Id == id && x.IsEffective == StatusEnum.有效.GetHashCode()) + .FirstAsync(); + + if (contract == null) + { + throw NCCException.Oh("合同不存在或已失效"); + } + + // 查询月租明细 + var rentDetails = await _db.Queryable() + .Where(x => x.ContractId == id && x.IsEffective == StatusEnum.有效.GetHashCode()) + .OrderBy(x => x.PaymentMonth) + .Select(x => new LqContractRentDetailListOutput + { + id = x.Id, + contractId = x.ContractId, + paymentMonth = x.PaymentMonth, + dueDate = x.DueDate, + dueAmount = x.DueAmount, + isPaid = x.IsPaid, + actualPaymentDate = x.ActualPaymentDate, + actualPaymentAmount = x.ActualPaymentAmount, + remarks = x.Remarks, + createUser = x.CreateUser, + createUserName = "", + createTime = x.CreateTime, + updateUser = x.UpdateUser, + updateUserName = "", + updateTime = x.UpdateTime, + isEffective = x.IsEffective + }) + .ToListAsync(); + + // 补充用户信息 + var userIds = new List { contract.CreateUser, contract.UpdateUser }; + userIds.AddRange(rentDetails.SelectMany(x => new[] { x.createUser, x.updateUser }).Where(x => !string.IsNullOrEmpty(x))); + + string createUserName = ""; + string updateUserName = ""; + + if (userIds.Any()) + { + var userList = await _db.Queryable() + .Where(x => userIds.Distinct().Contains(x.Id)) + .Select(x => new { x.Id, x.RealName }) + .ToListAsync(); + var userDict = userList.ToDictionary(k => k.Id, v => v.RealName); + + if (!string.IsNullOrEmpty(contract.CreateUser) && userDict.ContainsKey(contract.CreateUser)) + createUserName = userDict[contract.CreateUser]; + if (!string.IsNullOrEmpty(contract.UpdateUser) && userDict.ContainsKey(contract.UpdateUser)) + updateUserName = userDict[contract.UpdateUser]; + + foreach (var detail in rentDetails) + { + if (!string.IsNullOrEmpty(detail.createUser) && userDict.ContainsKey(detail.createUser)) + detail.createUserName = userDict[detail.createUser]; + if (!string.IsNullOrEmpty(detail.updateUser) && userDict.ContainsKey(detail.updateUser)) + detail.updateUserName = userDict[detail.updateUser]; + } + } + + return new LqContractInfoOutput + { + id = contract.Id, + storeId = contract.StoreId, + storeName = contract.StoreName, + title = contract.Title, + category = contract.Category, + tenantName = contract.TenantName, + contractStartDate = contract.ContractStartDate, + contractEndDate = contract.ContractEndDate, + reminderDays = contract.ReminderDays, + deposit = contract.Deposit, + nextPaymentDate = contract.NextPaymentDate, + monthlyRent = contract.MonthlyRent, + paymentAmount = contract.PaymentAmount, + paymentCycle = contract.PaymentCycle, + remarks = contract.Remarks, + attachment = contract.Attachment, + createUser = contract.CreateUser, + createUserName = createUserName, + createTime = contract.CreateTime, + updateUser = contract.UpdateUser, + updateUserName = updateUserName, + updateTime = contract.UpdateTime, + isEffective = contract.IsEffective, + rentDetails = rentDetails + }; + } + catch (Exception ex) + { + _logger.LogError(ex, "获取合同详情失败"); + throw NCCException.Oh($"获取合同详情失败:{ex.Message}"); + } + } + + #endregion + + #region 获取月租明细列表 + + /// + /// 获取月租明细列表 + /// + /// + /// 根据合同ID获取该合同的所有月租明细 + /// + /// 示例请求: + /// ``` + /// GET /api/Extend/LqContract/GetRentDetails?contractId=合同ID + /// ``` + /// + /// 合同ID + /// 月租明细列表 + /// 查询成功 + /// 合同ID不能为空 + /// 服务器错误 + [HttpGet("GetRentDetails")] + public async Task GetRentDetailsAsync([FromQuery] string contractId) + { + try + { + if (string.IsNullOrWhiteSpace(contractId)) + { + throw NCCException.Oh("合同ID不能为空"); + } + + var rentDetails = await _db.Queryable() + .Where(x => x.ContractId == contractId && x.IsEffective == StatusEnum.有效.GetHashCode()) + .OrderBy(x => x.PaymentMonth) + .Select(x => new LqContractRentDetailListOutput + { + id = x.Id, + contractId = x.ContractId, + paymentMonth = x.PaymentMonth, + dueDate = x.DueDate, + dueAmount = x.DueAmount, + isPaid = x.IsPaid, + actualPaymentDate = x.ActualPaymentDate, + actualPaymentAmount = x.ActualPaymentAmount, + remarks = x.Remarks, + createUser = x.CreateUser, + createUserName = "", + createTime = x.CreateTime, + updateUser = x.UpdateUser, + updateUserName = "", + updateTime = x.UpdateTime, + isEffective = x.IsEffective + }) + .ToListAsync(); + + // 补充用户信息 + var userIds = rentDetails.SelectMany(x => new[] { x.createUser, x.updateUser }) + .Where(x => !string.IsNullOrEmpty(x)) + .Distinct() + .ToList(); + + if (userIds.Any()) + { + var userList = await _db.Queryable() + .Where(x => userIds.Contains(x.Id)) + .Select(x => new { x.Id, x.RealName }) + .ToListAsync(); + var userDict = userList.ToDictionary(k => k.Id, v => v.RealName); + + foreach (var detail in rentDetails) + { + if (!string.IsNullOrEmpty(detail.createUser) && userDict.ContainsKey(detail.createUser)) + detail.createUserName = userDict[detail.createUser]; + if (!string.IsNullOrEmpty(detail.updateUser) && userDict.ContainsKey(detail.updateUser)) + detail.updateUserName = userDict[detail.updateUser]; + } + } + + return rentDetails; + } + catch (Exception ex) + { + _logger.LogError(ex, "获取月租明细列表失败"); + throw NCCException.Oh($"获取月租明细列表失败:{ex.Message}"); + } + } + + #endregion + + #region 标记明细已缴费 + + /// + /// 标记月租明细已缴费 + /// + /// + /// 标记某条月租明细已缴费,记录实际缴费时间和金额 + /// + /// 示例请求: + /// ```json + /// { + /// "id": "明细ID", + /// "actualPaymentDate": "2025-01-15T00:00:00", + /// "actualPaymentAmount": 3000.00, + /// "remarks": "已缴费" + /// } + /// ``` + /// + /// 标记已缴费输入 + /// 标记结果 + /// 标记成功 + /// 明细不存在或已缴费 + /// 服务器错误 + [HttpPut("MarkRentDetailPaid")] + public async Task MarkRentDetailPaidAsync([FromBody] LqContractRentDetailMarkPaidInput input) + { + try + { + // 查询明细 + var detail = await _db.Queryable() + .Where(x => x.Id == input.Id && x.IsEffective == StatusEnum.有效.GetHashCode()) + .FirstAsync(); + + if (detail == null) + { + throw NCCException.Oh("月租明细不存在或已失效"); + } + + if (detail.IsPaid == 1) + { + throw NCCException.Oh("该明细已标记为已缴费"); + } + + _db.Ado.BeginTran(); + + try + { + // 更新明细 + detail.IsPaid = 1; + detail.ActualPaymentDate = input.ActualPaymentDate; + detail.ActualPaymentAmount = input.ActualPaymentAmount; + detail.Remarks = input.Remarks; + detail.UpdateUser = _userManager.UserId; + detail.UpdateTime = DateTime.Now; + + var updateCount = await _db.Updateable(detail).ExecuteCommandAsync(); + if (updateCount <= 0) + { + throw NCCException.Oh("标记已缴费失败"); + } + + // 重新计算下次应交时间 + await CalculateNextPaymentDate(detail.ContractId); + + _db.Ado.CommitTran(); + } + catch + { + _db.Ado.RollbackTran(); + throw; + } + } + catch (Exception ex) + { + _db.Ado.RollbackTran(); + _logger.LogError(ex, "标记明细已缴费失败"); + throw NCCException.Oh($"标记失败:{ex.Message}"); + } + } + + #endregion + + #region 私有方法 + + /// + /// 自动生成月租明细 + /// + /// 合同ID + /// 合同起始日期 + /// 合同结束日期 + /// 交租周期(月) + /// 缴租金额 + private async Task GenerateRentDetailsAsync(string contractId, DateTime contractStartDate, DateTime contractEndDate, int paymentCycle, decimal paymentAmount) + { + var details = new List(); + var currentDate = contractStartDate.Date; + + // 从合同起始日期开始,每隔交租周期生成一条明细 + while (currentDate <= contractEndDate) + { + // 应缴月份:当前日期的月份第一天(格式:YYYY-MM-01) + var paymentMonth = new DateTime(currentDate.Year, currentDate.Month, 1); + // 应缴日期:应缴月份的第一天(根据业务规则,应缴日期为应缴月份的第一天) + var dueDate = paymentMonth; + + var detail = new LqContractRentDetailEntity + { + Id = YitIdHelper.NextId().ToString(), + ContractId = contractId, + PaymentMonth = paymentMonth, + DueDate = dueDate, + DueAmount = paymentAmount, + IsPaid = 0, + CreateUser = _userManager.UserId, + CreateTime = DateTime.Now, + IsEffective = StatusEnum.有效.GetHashCode() + }; + + details.Add(detail); + + // 计算下一个交租日期(加上交租周期) + currentDate = currentDate.AddMonths(paymentCycle); + } + + // 批量插入 + if (details.Any()) + { + await _db.Insertable(details).ExecuteCommandAsync(); + } + } + + /// + /// 计算下次应交时间(匿名方法) + /// + /// 合同ID + private async Task CalculateNextPaymentDate(string contractId) + { + // 查询合同信息 + var contract = await _db.Queryable() + .Where(x => x.Id == contractId && x.IsEffective == StatusEnum.有效.GetHashCode()) + .FirstAsync(); + + if (contract == null) + { + return; + } + + // 查询该合同未缴费的明细,按应缴日期升序排列 + var unpaidDetail = await _db.Queryable() + .Where(x => x.ContractId == contractId && x.IsEffective == StatusEnum.有效.GetHashCode() && x.IsPaid == 0) + .OrderBy(x => x.DueDate) + .FirstAsync(); + + if (unpaidDetail != null) + { + // 计算:下次应交时间 = 最早应缴日期 - 提前提醒天数 + var nextPaymentDate = unpaidDetail.DueDate.AddDays(-contract.ReminderDays); + + // 更新合同的下次应交时间 + contract.NextPaymentDate = nextPaymentDate; + contract.UpdateUser = _userManager.UserId; + contract.UpdateTime = DateTime.Now; + + await _db.Updateable(contract).ExecuteCommandAsync(); + } + else + { + // 如果没有未缴费的明细,清空下次应交时间 + contract.NextPaymentDate = null; + contract.UpdateUser = _userManager.UserId; + contract.UpdateTime = DateTime.Now; + + await _db.Updateable(contract).ExecuteCommandAsync(); + } + } + + #endregion + + #region 统计门店合同费用 + + /// + /// 统计门店合同费用 + /// + /// + /// 根据门店ID和月份统计该门店的合同费用,支持按分类统计(租门店、员工宿舍、车辆、场所等) + /// + /// 示例请求: + /// ```json + /// { + /// "storeId": "1649328471923847168", + /// "year": 2025, + /// "month": 1, + /// "categories": ["租门店", "员工宿舍", "车辆", "场所"] + /// } + /// ``` + /// + /// 参数说明: + /// - storeId: 门店ID(必填) + /// - year: 统计年份(必填) + /// - month: 统计月份(必填,1-12) + /// - categories: 分类列表(可选,不传则统计所有分类) + /// + /// 返回数据说明: + /// - storeId: 门店ID + /// - storeName: 门店名称 + /// - year: 统计年份 + /// - month: 统计月份 + /// - totalAmount: 总费用(所有分类的费用总和) + /// - categoryDetails: 按分类统计的费用明细 + /// - category: 分类名称 + /// - amount: 该分类的费用总额 + /// - detailCount: 该分类的明细数量 + /// - details: 明细列表 + /// + /// 统计输入 + /// 费用统计结果 + /// 统计成功 + /// 请求参数错误 + /// 服务器错误 + [HttpPost("GetExpenseStatistics")] + public async Task GetExpenseStatisticsAsync([FromBody] ContractExpenseStatisticsInput input) + { + try + { + // 验证月份 + if (input.Month < 1 || input.Month > 12) + { + throw NCCException.Oh("月份必须在1-12之间"); + } + + // 构建统计月份的开始和结束时间 + var statisticsMonth = new DateTime(input.Year, input.Month, 1); + var monthStart = statisticsMonth; + var monthEnd = statisticsMonth.AddMonths(1).AddDays(-1); + + // 查询门店信息 + var store = await _db.Queryable() + .Where(x => x.Id == input.StoreId) + .Select(x => new { x.Dm }) + .FirstAsync(); + + if (store == null) + { + throw NCCException.Oh("门店不存在"); + } + + // 查询该门店在指定月份的月租明细 + var details = await _db.Queryable( + (detail, contract) => new JoinQueryInfos( + JoinType.Inner, detail.ContractId == contract.Id)) + .Where((detail, contract) => + contract.StoreId == input.StoreId && + contract.IsEffective == StatusEnum.有效.GetHashCode() && + detail.IsEffective == StatusEnum.有效.GetHashCode() && + detail.PaymentMonth >= monthStart && + detail.PaymentMonth <= monthEnd) + .WhereIF(input.Categories != null && input.Categories.Length > 0, + (detail, contract) => contract.Category != null && input.Categories.Contains(contract.Category)) + .Select((detail, contract) => new + { + DetailId = detail.Id, + ContractId = contract.Id, + ContractTitle = contract.Title, + Category = contract.Category ?? "未分类", + DueAmount = detail.DueAmount, + IsPaid = detail.IsPaid, + ActualPaymentAmount = detail.ActualPaymentAmount + }) + .ToListAsync(); + + // 按分类分组统计 + var categoryGroups = details.GroupBy(x => x.Category).ToList(); + + var categoryDetails = new List(); + decimal totalAmount = 0; + + foreach (var group in categoryGroups) + { + var categoryName = group.Key; + var categoryItems = group.ToList(); + var categoryAmount = categoryItems.Sum(x => x.DueAmount); + totalAmount += categoryAmount; + + var expenseDetails = categoryItems.Select(x => new ExpenseDetailItem + { + detailId = x.DetailId, + contractId = x.ContractId, + contractTitle = x.ContractTitle, + category = x.Category, + dueAmount = x.DueAmount, + isPaid = x.IsPaid, + actualPaymentAmount = x.ActualPaymentAmount + }).ToList(); + + categoryDetails.Add(new CategoryExpenseDetail + { + category = categoryName, + amount = categoryAmount, + detailCount = categoryItems.Count, + details = expenseDetails + }); + } + + // 按分类名称排序 + categoryDetails = categoryDetails.OrderBy(x => x.category).ToList(); + + return new ContractExpenseStatisticsOutput + { + storeId = input.StoreId, + storeName = store.Dm ?? "", + year = input.Year, + month = input.Month, + totalAmount = totalAmount, + categoryDetails = categoryDetails + }; + } + catch (Exception ex) + { + _logger.LogError(ex, "统计门店合同费用失败"); + throw NCCException.Oh($"统计失败:{ex.Message}"); + } + } + + #endregion + } +} + diff --git a/netcore/src/Modularity/Extend/NCC.Extend/LqInventoryUsageService.cs b/netcore/src/Modularity/Extend/NCC.Extend/LqInventoryUsageService.cs index f9fca08..8d1b187 100644 --- a/netcore/src/Modularity/Extend/NCC.Extend/LqInventoryUsageService.cs +++ b/netcore/src/Modularity/Extend/NCC.Extend/LqInventoryUsageService.cs @@ -14,6 +14,8 @@ using NCC.Extend.Entitys.Enum; using NCC.Extend.Entitys.lq_inventory; using NCC.Extend.Entitys.lq_product; using NCC.Extend.Entitys.lq_inventory_usage; +using NCC.Extend.Entitys.lq_inventory_usage_application; +using NCC.Extend.Entitys.lq_inventory_usage_approval_record; using NCC.Extend.Entitys.lq_mdxx; using NCC.Extend.Interfaces.LqInventoryUsage; using NCC.FriendlyException; @@ -89,6 +91,10 @@ namespace NCC.Extend _db.Ado.BeginTran(); + // 自动计算单价和合计金额 + var unitPrice = product.Price; + var totalAmount = unitPrice * input.UsageQuantity; + // 创建使用记录 var usageEntity = new LqInventoryUsageEntity { @@ -97,6 +103,8 @@ namespace NCC.Extend StoreId = input.StoreId, UsageTime = input.UsageTime, UsageQuantity = input.UsageQuantity, + UnitPrice = unitPrice, + TotalAmount = totalAmount, RelatedConsumeId = input.RelatedConsumeId, CreateUser = _userManager.UserId, CreateTime = DateTime.Now, @@ -120,15 +128,19 @@ namespace NCC.Extend #region 批量添加库存使用记录 /// - /// 批量添加库存使用记录 + /// 批量添加库存使用记录(带审批流程) /// /// - /// 一次性添加多条库存使用记录,同一批次的所有记录使用相同的批次ID + /// 一次性添加多条库存使用记录,同一批次的所有记录使用相同的批次ID。创建使用记录后会自动创建申请记录并提交审批。 + /// 系统会自动计算单价(从产品表获取)和合计金额(单价×数量)。 /// /// 示例请求: /// ```json /// { /// "batchId": "可选,不传则自动生成", + /// "approverId": "审批人ID(财务老师或库管,必填)", + /// "applicationStoreId": "申请门店ID(必填)", + /// "remarks": "备注(可选)", /// "usageItems": [ /// { /// "productId": "产品ID", @@ -143,12 +155,21 @@ namespace NCC.Extend /// /// 参数说明: /// - batchId: 批次ID,可选。如果不传,系统会自动生成一个唯一的批次ID + /// - approverId: 审批人ID(财务老师或库管),必填。创建申请记录后会自动提交审批 + /// - applicationStoreId: 申请门店ID,必填 + /// - remarks: 备注,可选 /// - usageItems: 使用记录列表,至少需要一条记录 /// - productId: 产品ID(必填) /// - storeId: 门店ID(必填) /// - usageTime: 使用时间(必填) /// - usageQuantity: 使用数量(必填,必须大于0) /// - relatedConsumeId: 关联消耗ID(可选) + /// + /// 业务流程: + /// 1. 验证库存是否充足 + /// 2. 创建使用记录(自动计算单价和合计金额) + /// 3. 创建申请记录(状态:审批中) + /// 4. 返回批次ID和创建结果 /// /// 批量创建输入 /// 批量创建结果,包含批次ID和成功/失败信息 @@ -183,12 +204,13 @@ namespace NCC.Extend var usageList = await _db.Queryable().Where(x => productIds.Contains(x.ProductId) && x.IsEffective == StatusEnum.有效.GetHashCode()).GroupBy(x => x.ProductId).Select(x => new { ProductId = x.ProductId, TotalUsage = SqlFunc.AggregateSum(x.UsageQuantity) }).ToListAsync(); var usageMap = usageList.ToDictionary(x => x.ProductId, x => Convert.ToInt32(x.TotalUsage)); - // 批量查询所有产品的名称 + // 批量查询所有产品的名称和价格 var productDict = await _db.Queryable() .Where(x => productIds.Contains(x.Id)) - .Select(x => new { x.Id, x.ProductName }) + .Select(x => new { x.Id, x.ProductName, x.Price }) .ToListAsync(); var productNameMap = productDict.ToDictionary(x => x.Id, x => x.ProductName ?? "未知产品"); + var productPriceMap = productDict.ToDictionary(x => x.Id, x => x.Price); // 检查每个产品的库存 foreach (var productGroup in productGroups) @@ -213,12 +235,16 @@ namespace NCC.Extend try { - // 创建使用记录 + // 创建使用记录(自动计算单价和合计金额) var entitiesToInsert = new List(); for (int i = 0; i < input.UsageItems.Count; i++) { var item = input.UsageItems[i]; + // 从产品价格字典获取单价 + var unitPrice = productPriceMap.GetValueOrDefault(item.ProductId, 0); + var totalAmount = unitPrice * item.UsageQuantity; + var usageEntity = new LqInventoryUsageEntity { Id = YitIdHelper.NextId().ToString(), @@ -226,6 +252,8 @@ namespace NCC.Extend StoreId = item.StoreId, UsageTime = item.UsageTime, UsageQuantity = item.UsageQuantity, + UnitPrice = unitPrice, + TotalAmount = totalAmount, RelatedConsumeId = item.RelatedConsumeId, UsageBatchId = batchId, CreateUser = _userManager.UserId, @@ -247,6 +275,64 @@ namespace NCC.Extend } } + // 创建申请记录并提交审批(审批人ID为必填) + if (string.IsNullOrWhiteSpace(input.ApproverId)) + { + throw NCCException.Oh("审批人ID不能为空"); + } + if (string.IsNullOrWhiteSpace(input.ApplicationStoreId)) + { + throw NCCException.Oh("申请门店ID不能为空"); + } + + { + // 获取申请人信息 + var applicantUser = await _db.Queryable() + .Where(x => x.Id == _userManager.UserId) + .Select(x => new { x.Id, x.RealName }) + .FirstAsync(); + + // 获取审批人信息 + var approverUser = await _db.Queryable() + .Where(x => x.Id == input.ApproverId) + .Select(x => new { x.Id, x.RealName }) + .FirstAsync(); + + if (approverUser == null) + { + throw NCCException.Oh("审批人不存在"); + } + + // 生成节点ID(使用批次ID作为节点ID,因为只有一个节点) + var nodeId = YitIdHelper.NextId().ToString(); + + // 创建申请记录 + var applicationEntity = new LqInventoryUsageApplicationEntity + { + Id = YitIdHelper.NextId().ToString(), + UsageBatchId = batchId, + ApplicationUserId = applicantUser?.Id ?? _userManager.UserId, + ApplicationUserName = applicantUser?.RealName ?? "", + ApplicationStoreId = input.ApplicationStoreId, + ApplicationTime = DateTime.Now, + NodeCount = 1, + CurrentNodeOrder = 1, // 审批中 + CurrentNodeId = nodeId, + ApprovalStatus = "审批中", + IsReceived = 0, + Remarks = input.Remarks, + CreateUser = _userManager.UserId, + CreateTime = DateTime.Now, + IsEffective = StatusEnum.有效.GetHashCode() + }; + + var applicationInsertCount = await _db.Insertable(applicationEntity).ExecuteCommandAsync(); + if (applicationInsertCount <= 0) + { + throw NCCException.Oh("创建申请记录失败"); + } + } + _db.Ado.CommitTran(); return new LqInventoryUsageBatchCreateOutput @@ -420,17 +506,23 @@ namespace NCC.Extend /// 根据批次号获取批次信息 /// /// - /// 根据批次ID查询该批次的所有使用记录信息,包括批次基本信息和详细的使用记录列表 + /// 根据批次ID查询该批次的所有使用记录信息,包括批次基本信息和详细的使用记录列表。 + /// 兼容旧数据:如果该批次没有申请记录(旧数据),ApplicationInfo字段为null。 /// /// 返回数据结构: /// - 批次基本信息:批次ID、创建时间、创建人、统计信息等 /// - 使用记录列表:该批次的所有使用记录详情 + /// - 申请记录信息(ApplicationInfo):如果存在申请记录,包含审批状态、是否已领取等信息;如果不存在(旧数据),则为null /// /// 参数说明: /// - batchId: 批次ID(必填) + /// + /// 兼容性说明: + /// - 新数据:包含完整的申请记录信息 + /// - 旧数据:ApplicationInfo为null,但不影响使用记录的查询和显示 /// /// 批次ID - /// 批次信息,包含该批次的所有使用记录 + /// 批次信息,包含该批次的所有使用记录和申请记录(如果有) /// 查询成功,返回批次信息和使用记录列表 /// 批次ID不能为空 /// 批次不存在 @@ -512,6 +604,29 @@ namespace NCC.Extend var effectiveRecords = usageRecords.Where(x => x.isEffective == StatusEnum.有效.GetHashCode()).ToList(); var ineffectiveRecords = usageRecords.Where(x => x.isEffective == StatusEnum.无效.GetHashCode()).ToList(); + // 查询申请记录(如果有) + var application = await _db.Queryable() + .Where(x => x.UsageBatchId == batchId && x.IsEffective == StatusEnum.有效.GetHashCode()) + .FirstAsync(); + + ApplicationInfo applicationInfo = null; + if (application != null) + { + applicationInfo = new ApplicationInfo + { + Id = application.Id, + ApplicationUserId = application.ApplicationUserId, + ApplicationUserName = application.ApplicationUserName, + ApplicationStoreId = application.ApplicationStoreId, + ApplicationTime = application.ApplicationTime, + ApprovalStatus = application.ApprovalStatus, + IsReceived = application.IsReceived, + ReceiveTime = application.ReceiveTime, + ReceiveUser = application.ReceiveUser, + Remarks = application.Remarks + }; + } + var batchInfo = new LqInventoryUsageBatchInfoOutput { BatchId = batchId, @@ -523,7 +638,8 @@ namespace NCC.Extend IneffectiveCount = ineffectiveRecords.Count, TotalUsageQuantity = effectiveRecords.Sum(x => x.usageQuantity), TotalUsageAmount = effectiveRecords.Sum(x => x.usageTotalValue), - UsageRecords = usageRecords + UsageRecords = usageRecords, + ApplicationInfo = applicationInfo }; return batchInfo; @@ -768,6 +884,457 @@ namespace NCC.Extend } #endregion + #region 审批相关功能 + + /// + /// 审批库存使用申请(通过/不通过) + /// + /// + /// 审批库存使用申请,支持通过和不通过两种结果 + /// + /// 示例请求: + /// ``` + /// POST /api/Extend/LqInventoryUsage/Approve/{applicationId}?result=通过&opinion=审批意见 + /// ``` + /// + /// 参数说明: + /// - applicationId: 申请ID(必填) + /// - result: 审批结果(必填,值:通过/不通过) + /// - opinion: 审批意见(可选) + /// + /// 申请ID + /// 审批结果(通过/不通过) + /// 审批意见 + /// 审批结果 + /// 审批成功 + /// 申请不存在或状态不正确 + /// 服务器错误 + [HttpPost("Approve/{applicationId}")] + public async Task ApproveApplicationAsync([FromRoute] string applicationId, [FromQuery] string result, [FromQuery] string opinion = "") + { + try + { + if (string.IsNullOrWhiteSpace(applicationId)) + { + throw NCCException.Oh("申请ID不能为空"); + } + + if (string.IsNullOrWhiteSpace(result) || (result != "通过" && result != "不通过")) + { + throw NCCException.Oh("审批结果必须为'通过'或'不通过'"); + } + + // 获取申请记录 + var application = await _db.Queryable() + .Where(x => x.Id == applicationId && x.IsEffective == StatusEnum.有效.GetHashCode()) + .FirstAsync(); + + if (application == null) + { + throw NCCException.Oh("申请记录不存在或已失效"); + } + + // 验证申请状态 + if (application.ApprovalStatus != "审批中") + { + throw NCCException.Oh($"申请当前状态为{application.ApprovalStatus},无法进行审批操作"); + } + + // 获取当前用户信息 + var userInfo = await _userManager.GetUserInfo(); + var approverUser = await _db.Queryable() + .Where(x => x.Id == userInfo.userId) + .Select(x => new { x.Id, x.RealName }) + .FirstAsync(); + + _db.Ado.BeginTran(); + + try + { + // 创建审批记录 + var approvalRecord = new LqInventoryUsageApprovalRecordEntity + { + Id = YitIdHelper.NextId().ToString(), + ApplicationId = applicationId, + NodeId = application.CurrentNodeId, + NodeOrder = 1, + ApproverId = approverUser.Id, + ApproverName = approverUser.RealName ?? "", + ApprovalResult = result, + ApprovalOpinion = opinion, + ApprovalTime = DateTime.Now, + IsCurrentNode = 1 + }; + + await _db.Insertable(approvalRecord).ExecuteCommandAsync(); + + // 更新申请状态 + if (result == "通过") + { + application.ApprovalStatus = "已通过"; + application.CurrentNodeOrder = 2; // 已完成 + } + else + { + application.ApprovalStatus = "未通过"; + application.CurrentNodeOrder = 0; // 回到待审批状态 + } + + application.UpdateUser = userInfo.userId; + application.UpdateTime = DateTime.Now; + + await _db.Updateable(application).ExecuteCommandAsync(); + + _db.Ado.CommitTran(); + } + catch + { + _db.Ado.RollbackTran(); + throw; + } + } + catch (Exception ex) + { + _db.Ado.RollbackTran(); + _logger.LogError(ex, "审批申请失败"); + throw NCCException.Oh($"审批失败:{ex.Message}"); + } + } + + /// + /// 标记申请已领取 + /// + /// + /// 审批通过后,可以标记申请已领取 + /// + /// 示例请求: + /// ``` + /// PUT /api/Extend/LqInventoryUsage/MarkReceived/{applicationId} + /// ``` + /// + /// 参数说明: + /// - applicationId: 申请ID(必填) + /// + /// 申请ID + /// 标记结果 + /// 标记成功 + /// 申请不存在或状态不正确 + /// 服务器错误 + [HttpPut("MarkReceived/{applicationId}")] + public async Task MarkReceivedAsync([FromRoute] string applicationId) + { + try + { + if (string.IsNullOrWhiteSpace(applicationId)) + { + throw NCCException.Oh("申请ID不能为空"); + } + + // 获取申请记录 + var application = await _db.Queryable() + .Where(x => x.Id == applicationId && x.IsEffective == StatusEnum.有效.GetHashCode()) + .FirstAsync(); + + if (application == null) + { + throw NCCException.Oh("申请记录不存在或已失效"); + } + + // 验证申请状态(只有已通过的申请才能标记已领取) + if (application.ApprovalStatus != "已通过") + { + throw NCCException.Oh($"申请当前状态为{application.ApprovalStatus},只有已通过的申请才能标记已领取"); + } + + // 获取当前用户信息 + var userInfo = await _userManager.GetUserInfo(); + + // 更新申请记录 + application.IsReceived = 1; + application.ReceiveTime = DateTime.Now; + application.ReceiveUser = userInfo.userId; + application.UpdateUser = userInfo.userId; + application.UpdateTime = DateTime.Now; + + var isOk = await _db.Updateable(application).ExecuteCommandAsync(); + if (!(isOk > 0)) throw NCCException.Oh(ErrorCode.COM1003); + } + catch (Exception ex) + { + _logger.LogError(ex, "标记已领取失败"); + throw NCCException.Oh($"标记失败:{ex.Message}"); + } + } + + /// + /// 根据使用批次ID查询申请记录 + /// + /// + /// 根据使用批次ID查询对应的申请记录信息。兼容旧数据:如果该批次没有申请记录(旧数据),会返回success=false,data=null。 + /// + /// 示例请求: + /// ``` + /// GET /api/Extend/LqInventoryUsage/GetApplicationByBatchId?batchId=批次ID + /// ``` + /// + /// 参数说明: + /// - batchId: 使用批次ID(必填) + /// + /// 返回说明: + /// - 如果存在申请记录:返回完整的申请信息,包括审批状态、是否已领取、审批记录等 + /// - 如果不存在申请记录(旧数据):返回success=false,message="该批次没有对应的申请记录",data=null + /// + /// 使用批次ID + /// 申请记录信息 + /// 查询成功(可能没有申请记录,需要检查success字段) + /// 批次ID不能为空 + /// 服务器错误 + [HttpGet("GetApplicationByBatchId")] + public async Task GetApplicationByBatchIdAsync([FromQuery] string batchId) + { + try + { + if (string.IsNullOrWhiteSpace(batchId)) + { + throw NCCException.Oh("批次ID不能为空"); + } + + // 查询申请记录 + var application = await _db.Queryable() + .Where(x => x.UsageBatchId == batchId && x.IsEffective == StatusEnum.有效.GetHashCode()) + .FirstAsync(); + + if (application == null) + { + return new + { + success = false, + message = "该批次没有对应的申请记录", + data = (object)null + }; + } + + // 查询审批记录 + var approvalRecords = await _db.Queryable() + .Where(x => x.ApplicationId == application.Id) + .OrderBy(x => x.ApprovalTime) + .ToListAsync(); + + // 补充审批人姓名(如果审批记录中没有) + var approverIds = approvalRecords.Where(x => !string.IsNullOrEmpty(x.ApproverId)) + .Select(x => x.ApproverId) + .Distinct() + .ToList(); + + var approverDict = new Dictionary(); + if (approverIds.Any()) + { + var approvers = await _db.Queryable() + .Where(x => approverIds.Contains(x.Id)) + .Select(x => new { x.Id, x.RealName }) + .ToListAsync(); + approverDict = approvers.ToDictionary(k => k.Id, v => v.RealName ?? ""); + } + + return new + { + success = true, + data = new + { + id = application.Id, + usageBatchId = application.UsageBatchId, + applicationUserId = application.ApplicationUserId, + applicationUserName = application.ApplicationUserName, + applicationStoreId = application.ApplicationStoreId, + applicationTime = application.ApplicationTime, + approvalStatus = application.ApprovalStatus, + isReceived = application.IsReceived, + receiveTime = application.ReceiveTime, + receiveUser = application.ReceiveUser, + remarks = application.Remarks, + approvalRecords = approvalRecords.Select(x => new + { + id = x.Id, + approverId = x.ApproverId, + approverName = string.IsNullOrEmpty(x.ApproverName) && approverDict.ContainsKey(x.ApproverId) + ? approverDict[x.ApproverId] + : x.ApproverName, + approvalResult = x.ApprovalResult, + approvalOpinion = x.ApprovalOpinion, + approvalTime = x.ApprovalTime + }).ToList() + } + }; + } + catch (Exception ex) + { + _logger.LogError(ex, "查询申请记录失败"); + throw NCCException.Oh($"查询失败:{ex.Message}"); + } + } + + #endregion + + #region 门店领取统计 + + /// + /// 门店领取统计(按月份统计每个门店的领取总金额) + /// + /// + /// 统计指定月份每个门店已领取的库存使用申请的总金额。只统计审批通过且已领取的申请。 + /// + /// 示例请求: + /// ```json + /// POST /api/Extend/LqInventoryUsage/GetStoreReceiveStatistics + /// { + /// "year": 2025, + /// "month": 11, + /// "storeId": "门店ID(可选)" + /// } + /// ``` + /// + /// 参数说明: + /// - year: 统计年份(必填,范围:2020-2100) + /// - month: 统计月份(必填,范围:1-12) + /// - storeId: 门店ID(可选,不传则统计所有门店) + /// + /// 返回说明: + /// - 按门店分组统计 + /// - 每个门店包含:门店ID、门店名称、申请数量、领取总金额 + /// - 按总金额降序排列 + /// + /// 统计查询输入 + /// 门店领取统计列表 + /// 查询成功 + /// 输入参数错误 + /// 服务器错误 + [HttpPost("GetStoreReceiveStatistics")] + public async Task GetStoreReceiveStatisticsAsync([FromBody] StoreReceiveStatisticsInput input) + { + try + { + if (input == null) + { + throw NCCException.Oh("输入参数不能为空"); + } + + // 计算月份的开始和结束时间 + var startDate = new DateTime(input.Year, input.Month, 1); + var endDate = startDate.AddMonths(1).AddDays(-1).Date.AddHours(23).AddMinutes(59).AddSeconds(59); + + // 查询已领取的申请记录(审批通过且已领取) + var applicationQuery = _db.Queryable() + .Where(x => x.IsEffective == StatusEnum.有效.GetHashCode()) + .Where(x => x.ApprovalStatus == "已通过") + .Where(x => x.IsReceived == 1) + .Where(x => x.ReceiveTime >= startDate && x.ReceiveTime <= endDate); + + if (!string.IsNullOrWhiteSpace(input.StoreId)) + { + applicationQuery = applicationQuery.Where(x => x.ApplicationStoreId == input.StoreId); + } + + var applications = await applicationQuery.ToListAsync(); + + if (!applications.Any()) + { + return new + { + success = true, + data = new List(), + total = 0, + message = $"未找到{input.Year}年{input.Month}月的门店领取记录" + }; + } + + // 获取所有批次ID + var batchIds = applications.Select(x => x.UsageBatchId).Distinct().ToList(); + + // 查询这些批次的使用记录,计算总金额 + var usageRecords = await _db.Queryable() + .Where(x => batchIds.Contains(x.UsageBatchId)) + .Where(x => x.IsEffective == StatusEnum.有效.GetHashCode()) + .Select(x => new + { + x.UsageBatchId, + x.StoreId, + x.TotalAmount + }) + .ToListAsync(); + + // 按门店分组统计 + var storeStatistics = new Dictionary(); + + foreach (var application in applications) + { + var batchUsageRecords = usageRecords.Where(x => x.UsageBatchId == application.UsageBatchId).ToList(); + var storeId = application.ApplicationStoreId; + + if (string.IsNullOrWhiteSpace(storeId)) + { + // 如果没有申请门店ID,使用使用记录中的门店ID + storeId = batchUsageRecords.FirstOrDefault()?.StoreId; + } + + if (string.IsNullOrWhiteSpace(storeId)) + { + continue; + } + + if (!storeStatistics.ContainsKey(storeId)) + { + // 查询门店名称 + var store = await _db.Queryable() + .Where(x => x.Id == storeId) + .Select(x => new { x.Dm }) + .FirstAsync(); + + storeStatistics[storeId] = new StoreReceiveStatisticsItem + { + StoreId = storeId, + StoreName = store?.Dm ?? "未知门店", + ApplicationCount = 0, + TotalAmount = 0 + }; + } + + var totalAmount = batchUsageRecords.Sum(x => x.TotalAmount); + storeStatistics[storeId].ApplicationCount++; + storeStatistics[storeId].TotalAmount += totalAmount; + } + + // 转换为列表并按总金额降序排列 + var result = storeStatistics.Values + .OrderByDescending(x => x.TotalAmount) + .ToList(); + + return new + { + success = true, + data = result, + total = result.Count, + message = $"查询成功,共{result.Count}个门店" + }; + } + catch (Exception ex) + { + _logger.LogError(ex, "查询门店领取统计失败"); + throw NCCException.Oh($"查询失败:{ex.Message}"); + } + } + + /// + /// 门店领取统计项 + /// + private class StoreReceiveStatisticsItem + { + public string StoreId { get; set; } + public string StoreName { get; set; } + public int ApplicationCount { get; set; } + public decimal TotalAmount { get; set; } + } + + #endregion } } diff --git a/netcore/src/Modularity/Extend/NCC.Extend/LqMdMajorProjectTeacherAssignmentService.cs b/netcore/src/Modularity/Extend/NCC.Extend/LqMdMajorProjectTeacherAssignmentService.cs index ef86b5f..536b56b 100644 --- a/netcore/src/Modularity/Extend/NCC.Extend/LqMdMajorProjectTeacherAssignmentService.cs +++ b/netcore/src/Modularity/Extend/NCC.Extend/LqMdMajorProjectTeacherAssignmentService.cs @@ -248,7 +248,7 @@ namespace NCC.Extend /// 从上个月复制门店大项目部老师归属设置数据到目标月份 /// /// 示例请求: - /// POST /api/Extend/LqMdMajorProjectTeacherAssignment/CopyLastMonthData?targetYear=2025&targetMonth=02 + /// POST /api/Extend/LqMdMajorProjectTeacherAssignment/CopyLastMonthData?targetYear=2025&targetMonth=02 /// /// 业务逻辑: /// 1. 确定目标年份和月份(如果未指定,使用当前年月) diff --git a/netcore/src/Modularity/Extend/NCC.Extend/LqReimbursementApplicationService.cs b/netcore/src/Modularity/Extend/NCC.Extend/LqReimbursementApplicationService.cs index accc82e..3de354f 100644 --- a/netcore/src/Modularity/Extend/NCC.Extend/LqReimbursementApplicationService.cs +++ b/netcore/src/Modularity/Extend/NCC.Extend/LqReimbursementApplicationService.cs @@ -835,8 +835,15 @@ namespace NCC.Extend.LqReimbursementApplication // 如果存在"待审批"记录,说明可以审批,不需要抛出异常 // 如果不存在"待审批"记录,需要检查是否有"通过"或"不通过"的记录(不包括"退回",因为退回后可以重新审批) + // 注意:如果状态已经是"已通过",说明整个流程已完成,不允许再次审批 if (existingPendingApprovalRecord == null) { + // 如果申请状态已经是"已通过",不允许再次审批 + if (entity.ApprovalStatus == "已通过") + { + throw new Exception("该申请已经审批通过,无法再次审批"); + } + // 检查是否有"通过"或"不通过"的记录(不包括"退回") var completedRecord = await _db.Queryable() .Where(x => x.ApplicationId == id @@ -847,6 +854,7 @@ namespace NCC.Extend.LqReimbursementApplication if (completedRecord != null) { + // 如果申请状态还是"审批中",说明还有其他审批人未审批,当前用户已经审批过,不允许重复审批 throw new Exception("您已经审批过该节点"); } } diff --git a/sql/创建合同管理表结构.sql b/sql/创建合同管理表结构.sql new file mode 100644 index 0000000..fac0480 --- /dev/null +++ b/sql/创建合同管理表结构.sql @@ -0,0 +1,116 @@ +-- ============================================ +-- 合同管理系统表结构SQL +-- ============================================ +-- 说明:用于管理门店合同信息,自动生成月租明细,统计每个月每个门店的合同支付明细以及成本费用 +-- 执行时间:2025年 +-- ============================================ + +-- ============================================ +-- 1. 创建合同表(lq_contract) +-- ============================================ +CREATE TABLE IF NOT EXISTS `lq_contract` ( + `F_Id` varchar(50) NOT NULL COMMENT '主键ID', + `F_StoreId` varchar(50) NOT NULL COMMENT '门店ID(关联lq_mdxx.F_Id)', + `F_StoreName` varchar(200) NOT NULL COMMENT '店名(冗余字段,便于查询)', + `F_Title` varchar(200) NOT NULL COMMENT '标题', + `F_Category` varchar(100) DEFAULT NULL COMMENT '分类(string类型,自己填写)', + `F_TenantName` varchar(200) DEFAULT NULL COMMENT '户名', + `F_ContractStartDate` datetime NOT NULL COMMENT '合同起始日期', + `F_ContractEndDate` datetime NOT NULL COMMENT '合同结束日期', + `F_ReminderDays` int DEFAULT 0 COMMENT '提前多少天提醒', + `F_Deposit` decimal(18,2) DEFAULT 0.00 COMMENT '押金', + `F_NextPaymentDate` datetime DEFAULT NULL COMMENT '下次应交时间', + `F_MonthlyRent` decimal(18,2) NOT NULL COMMENT '月租', + `F_PaymentAmount` decimal(18,2) NOT NULL COMMENT '缴租金额(每次交租的金额,通常=月租×交租周期)', + `F_PaymentCycle` int NOT NULL COMMENT '交租周期(数字,表示几个月,如1、3、6等)', + `F_Remarks` varchar(1000) DEFAULT NULL COMMENT '备注', + `F_Attachment` varchar(500) DEFAULT NULL COMMENT '附件(存储附件路径或JSON)', + `F_CreateUser` varchar(50) NOT NULL COMMENT '创建人ID', + `F_CreateTime` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `F_UpdateUser` varchar(50) DEFAULT NULL COMMENT '更新人ID', + `F_UpdateTime` datetime DEFAULT NULL COMMENT '更新时间', + `F_IsEffective` int DEFAULT 1 COMMENT '是否有效(1-有效,0-无效)', + PRIMARY KEY (`F_Id`), + KEY `idx_store_id` (`F_StoreId`), + KEY `idx_contract_start_date` (`F_ContractStartDate`), + KEY `idx_contract_end_date` (`F_ContractEndDate`), + KEY `idx_next_payment_date` (`F_NextPaymentDate`), + KEY `idx_category` (`F_Category`), + KEY `idx_is_effective` (`F_IsEffective`), + KEY `idx_create_time` (`F_CreateTime`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='合同表'; + +-- ============================================ +-- 2. 创建月租明细表(lq_contract_rent_detail) +-- ============================================ +CREATE TABLE IF NOT EXISTS `lq_contract_rent_detail` ( + `F_Id` varchar(50) NOT NULL COMMENT '主键ID', + `F_ContractId` varchar(50) NOT NULL COMMENT '合同ID(关联lq_contract.F_Id)', + `F_PaymentMonth` datetime NOT NULL COMMENT '应缴月份(表示哪个月份,格式:YYYY-MM-01)', + `F_DueDate` datetime NOT NULL COMMENT '应缴日期(具体应缴日期)', + `F_DueAmount` decimal(18,2) NOT NULL COMMENT '应缴金额', + `F_IsPaid` int DEFAULT 0 COMMENT '是否已缴(0-未缴,1-已缴)', + `F_ActualPaymentDate` datetime DEFAULT NULL COMMENT '实际缴费时间', + `F_ActualPaymentAmount` decimal(18,2) DEFAULT NULL COMMENT '实际缴费金额', + `F_Remarks` varchar(500) DEFAULT NULL COMMENT '备注', + `F_CreateUser` varchar(50) NOT NULL COMMENT '创建人ID', + `F_CreateTime` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `F_UpdateUser` varchar(50) DEFAULT NULL COMMENT '更新人ID', + `F_UpdateTime` datetime DEFAULT NULL COMMENT '更新时间', + `F_IsEffective` int DEFAULT 1 COMMENT '是否有效(1-有效,0-无效)', + PRIMARY KEY (`F_Id`), + KEY `idx_contract_id` (`F_ContractId`), + KEY `idx_payment_month` (`F_PaymentMonth`), + KEY `idx_due_date` (`F_DueDate`), + KEY `idx_is_paid` (`F_IsPaid`), + KEY `idx_contract_payment_month` (`F_ContractId`, `F_PaymentMonth`), + KEY `idx_is_effective` (`F_IsEffective`), + KEY `idx_create_time` (`F_CreateTime`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='月租明细表'; + +-- ============================================ +-- 3. 添加外键约束(可选,根据实际需求决定是否添加) +-- ============================================ +-- 注意:如果添加外键约束,删除合同时需要先删除明细,或者使用级联删除 +-- 建议:不添加外键约束,在应用层控制数据一致性,更灵活 + +-- ALTER TABLE `lq_contract_rent_detail` +-- ADD CONSTRAINT `fk_contract_rent_detail_contract` +-- FOREIGN KEY (`F_ContractId`) REFERENCES `lq_contract` (`F_Id`) +-- ON DELETE CASCADE ON UPDATE CASCADE; + +-- ============================================ +-- 4. 数据示例说明 +-- ============================================ +-- 合同示例: +-- F_Id: '768041985045955845' +-- F_StoreId: '1649328471923847168' +-- F_StoreName: '绿纤总部' +-- F_Title: '门店租赁合同' +-- F_Category: '租赁合同' +-- F_TenantName: '张三' +-- F_ContractStartDate: '2025-01-01 00:00:00' +-- F_ContractEndDate: '2025-12-31 23:59:59' +-- F_ReminderDays: 7 +-- F_Deposit: 5000.00 +-- F_NextPaymentDate: '2025-01-25 00:00:00' +-- F_MonthlyRent: 1000.00 +-- F_PaymentAmount: 3000.00 +-- F_PaymentCycle: 3 +-- F_Remarks: '季度交租' +-- +-- 对应的月租明细(自动生成): +-- 明细1: F_PaymentMonth='2025-01-01', F_DueDate='2025-01-01', F_DueAmount=3000.00, F_IsPaid=0 +-- 明细2: F_PaymentMonth='2025-04-01', F_DueDate='2025-04-01', F_DueAmount=3000.00, F_IsPaid=0 +-- 明细3: F_PaymentMonth='2025-07-01', F_DueDate='2025-07-01', F_DueAmount=3000.00, F_IsPaid=0 +-- 明细4: F_PaymentMonth='2025-10-01', F_DueDate='2025-10-01', F_DueAmount=3000.00, F_IsPaid=0 + +-- ============================================ +-- SQL脚本执行完成 +-- ============================================ +-- 说明: +-- 1. lq_contract 表:存储合同基本信息 +-- 2. lq_contract_rent_detail 表:存储月租明细,根据合同自动生成 +-- 3. 删除合同时需要级联删除明细(在应用层实现) +-- 4. 更新合同时如果影响明细,需要重新生成明细 + diff --git a/sql/创建库存使用申请审批流程表.sql b/sql/创建库存使用申请审批流程表.sql new file mode 100644 index 0000000..7d1c43b --- /dev/null +++ b/sql/创建库存使用申请审批流程表.sql @@ -0,0 +1,102 @@ +-- 库存使用申请审批流程 - 数据库表结构 +-- 执行时间:2025年 +-- 说明:支持单节点审批流程,审批人可配置(财务老师或库管),审批通过后可标记是否已领取 + +-- 1. 库存使用申请表(申请记录) +CREATE TABLE IF NOT EXISTS `lq_inventory_usage_application` ( + `F_Id` varchar(50) NOT NULL COMMENT '申请编号', + `F_UsageBatchId` varchar(50) NOT NULL COMMENT '使用批次ID(关联lq_inventory_usage.F_UsageBatchId)', + `F_ApplicationUserId` varchar(50) NOT NULL COMMENT '申请人ID', + `F_ApplicationUserName` varchar(100) DEFAULT NULL COMMENT '申请人姓名', + `F_ApplicationStoreId` varchar(50) DEFAULT NULL COMMENT '申请门店ID', + `F_ApplicationTime` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '申请时间', + `F_NodeCount` int DEFAULT 1 COMMENT '节点数量(固定为1)', + `F_CurrentNodeOrder` int DEFAULT 0 COMMENT '当前审批节点(0-待审批,1-审批中,2-已完成)', + `F_CurrentNodeId` varchar(50) DEFAULT NULL COMMENT '当前节点ID', + `F_ApprovalStatus` varchar(20) DEFAULT '待审批' COMMENT '审批状态(待审批/审批中/已通过/未通过/已退回)', + `F_IsReceived` int DEFAULT 0 COMMENT '是否已领取(1-已领取,0-未领取)', + `F_ReceiveTime` datetime DEFAULT NULL COMMENT '领取时间', + `F_ReceiveUser` varchar(50) DEFAULT NULL COMMENT '领取人ID', + `F_Remarks` varchar(500) DEFAULT NULL COMMENT '备注', + `F_CreateTime` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `F_CreateUser` varchar(50) DEFAULT NULL COMMENT '创建人ID', + `F_UpdateTime` datetime DEFAULT NULL COMMENT '更新时间', + `F_UpdateUser` varchar(50) DEFAULT NULL COMMENT '更新人ID', + `F_IsEffective` int DEFAULT 1 COMMENT '是否有效(1-有效,0-无效)', + PRIMARY KEY (`F_Id`), + UNIQUE KEY `uk_usage_batch_id` (`F_UsageBatchId`), + KEY `idx_application_user_id` (`F_ApplicationUserId`), + KEY `idx_application_store_id` (`F_ApplicationStoreId`), + KEY `idx_current_node` (`F_CurrentNodeId`), + KEY `idx_approval_status` (`F_ApprovalStatus`), + KEY `idx_node_count` (`F_NodeCount`), + KEY `idx_create_time` (`F_CreateTime`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='库存使用申请表'; + +-- 2. 库存使用申请节点表(每个申请的节点配置,固定为1个节点) +CREATE TABLE IF NOT EXISTS `lq_inventory_usage_application_node` ( + `F_Id` varchar(50) NOT NULL COMMENT '节点编号', + `F_ApplicationId` varchar(50) NOT NULL COMMENT '申请ID', + `F_NodeOrder` int NOT NULL DEFAULT 1 COMMENT '节点顺序(固定为1)', + `F_NodeName` varchar(100) DEFAULT '审批' COMMENT '节点名称', + `F_ApprovalType` varchar(20) DEFAULT '会签' COMMENT '审批类型(会签/或签)', + `F_IsRequired` int DEFAULT 1 COMMENT '是否必审(1-必审,0-可选)', + `F_CreateTime` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + PRIMARY KEY (`F_Id`), + KEY `idx_application_id` (`F_ApplicationId`), + KEY `idx_node_order` (`F_ApplicationId`, `F_NodeOrder`), + UNIQUE KEY `uk_application_node_order` (`F_ApplicationId`, `F_NodeOrder`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='库存使用申请节点表'; + +-- 3. 库存使用申请节点审批人表(每个节点的审批人,在创建申请时指定) +CREATE TABLE IF NOT EXISTS `lq_inventory_usage_application_node_user` ( + `F_Id` varchar(50) NOT NULL COMMENT '记录编号', + `F_ApplicationId` varchar(50) NOT NULL COMMENT '申请ID', + `F_NodeId` varchar(50) NOT NULL COMMENT '节点编号', + `F_NodeOrder` int NOT NULL DEFAULT 1 COMMENT '节点顺序(固定为1)', + `F_UserId` varchar(50) NOT NULL COMMENT '审批人ID', + `F_UserName` varchar(100) DEFAULT NULL COMMENT '审批人姓名', + `F_SortOrder` int DEFAULT 0 COMMENT '排序', + `F_CreateTime` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + PRIMARY KEY (`F_Id`), + KEY `idx_application_id` (`F_ApplicationId`), + KEY `idx_node_id` (`F_NodeId`), + KEY `idx_user_id` (`F_UserId`), + KEY `idx_node_order` (`F_ApplicationId`, `F_NodeOrder`), + UNIQUE KEY `uk_application_node_user` (`F_ApplicationId`, `F_NodeId`, `F_UserId`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='库存使用申请节点审批人表'; + +-- 4. 审批记录表 +CREATE TABLE IF NOT EXISTS `lq_inventory_usage_approval_record` ( + `F_Id` varchar(50) NOT NULL COMMENT '记录编号', + `F_ApplicationId` varchar(50) NOT NULL COMMENT '申请ID', + `F_NodeId` varchar(50) NOT NULL COMMENT '节点编号', + `F_NodeOrder` int NOT NULL DEFAULT 1 COMMENT '节点顺序(固定为1)', + `F_ApproverId` varchar(50) NOT NULL COMMENT '审批人ID', + `F_ApproverName` varchar(100) DEFAULT NULL COMMENT '审批人姓名', + `F_ApprovalResult` varchar(20) NOT NULL COMMENT '审批结果(通过/不通过/退回)', + `F_ApprovalOpinion` varchar(500) DEFAULT NULL COMMENT '审批意见', + `F_ApprovalTime` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '审批时间', + `F_IsCurrentNode` int DEFAULT 0 COMMENT '是否当前节点(1-是,0-否)', + PRIMARY KEY (`F_Id`), + KEY `idx_application_id` (`F_ApplicationId`), + KEY `idx_node_id` (`F_NodeId`), + KEY `idx_approver_id` (`F_ApproverId`), + KEY `idx_node_order` (`F_ApplicationId`, `F_NodeOrder`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='库存使用申请审批记录表'; + +-- 5. 修改库存使用记录表,添加单价和合计金额字段 +ALTER TABLE `lq_inventory_usage` + ADD COLUMN `F_UnitPrice` decimal(18,2) DEFAULT 0.00 COMMENT '单价(从产品表F_Price获取)' AFTER `F_UsageQuantity`, + ADD COLUMN `F_TotalAmount` decimal(18,2) DEFAULT 0.00 COMMENT '合计金额(单价×数量)' AFTER `F_UnitPrice`, + ADD KEY `idx_unit_price` (`F_UnitPrice`), + ADD KEY `idx_total_amount` (`F_TotalAmount`); + +-- 6. 数据迁移:更新已有数据的单价和合计金额(从产品表获取价格) +UPDATE `lq_inventory_usage` u +INNER JOIN `lq_product` p ON u.`F_ProductId` = p.`F_Id` +SET u.`F_UnitPrice` = p.`F_Price`, + u.`F_TotalAmount` = p.`F_Price` * u.`F_UsageQuantity` +WHERE u.`F_UnitPrice` = 0 OR u.`F_UnitPrice` IS NULL; + + diff --git a/sql/库存管理审批功能相关表结构.sql b/sql/库存管理审批功能相关表结构.sql new file mode 100644 index 0000000..df39a92 --- /dev/null +++ b/sql/库存管理审批功能相关表结构.sql @@ -0,0 +1,202 @@ +-- ============================================ +-- 库存管理审批功能相关表结构SQL +-- ============================================ +-- 说明:为库存使用记录添加审批功能,包括申请记录、审批记录等 +-- 执行时间:2025年 +-- ============================================ + +-- ============================================ +-- 1. 修改库存使用记录表,添加单价和合计金额字段(如果不存在) +-- ============================================ +-- 说明:用于统计成本费用,单价从产品表获取,合计金额 = 单价 × 数量 + +-- 检查并添加单价字段 +SET @dbname = DATABASE(); +SET @tablename = 'lq_inventory_usage'; +SET @columnname = 'F_UnitPrice'; +SET @preparedStatement = (SELECT IF( + ( + SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS + WHERE + (TABLE_SCHEMA = @dbname) + AND (TABLE_NAME = @tablename) + AND (COLUMN_NAME = @columnname) + ) > 0, + 'SELECT 1', + CONCAT('ALTER TABLE ', @tablename, ' ADD COLUMN `', @columnname, '` decimal(18,2) DEFAULT 0.00 COMMENT ''单价(从产品表F_Price获取)'' AFTER `F_UsageQuantity`') +)); +PREPARE alterIfNotExists FROM @preparedStatement; +EXECUTE alterIfNotExists; +DEALLOCATE PREPARE alterIfNotExists; + +-- 检查并添加合计金额字段 +SET @columnname = 'F_TotalAmount'; +SET @preparedStatement = (SELECT IF( + ( + SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS + WHERE + (TABLE_SCHEMA = @dbname) + AND (TABLE_NAME = @tablename) + AND (COLUMN_NAME = @columnname) + ) > 0, + 'SELECT 1', + CONCAT('ALTER TABLE ', @tablename, ' ADD COLUMN `', @columnname, '` decimal(18,2) DEFAULT 0.00 COMMENT ''合计金额(单价×数量)'' AFTER `F_UnitPrice`') +)); +PREPARE alterIfNotExists FROM @preparedStatement; +EXECUTE alterIfNotExists; +DEALLOCATE PREPARE alterIfNotExists; + +-- 添加索引(如果不存在) +ALTER TABLE `lq_inventory_usage` + ADD INDEX IF NOT EXISTS `idx_unit_price` (`F_UnitPrice`), + ADD INDEX IF NOT EXISTS `idx_total_amount` (`F_TotalAmount`); + +-- 数据迁移:更新已有数据的单价和合计金额(从产品表获取价格) +UPDATE `lq_inventory_usage` u +INNER JOIN `lq_product` p ON u.`F_ProductId` = p.`F_Id` +SET u.`F_UnitPrice` = p.`F_Price`, + u.`F_TotalAmount` = p.`F_Price` * u.`F_UsageQuantity` +WHERE (u.`F_UnitPrice` = 0 OR u.`F_UnitPrice` IS NULL) AND p.`F_Price` IS NOT NULL; + +-- ============================================ +-- 2. 创建库存使用申请表(如果不存在) +-- ============================================ +CREATE TABLE IF NOT EXISTS `lq_inventory_usage_application` ( + `F_Id` varchar(50) NOT NULL COMMENT '申请编号', + `F_UsageBatchId` varchar(50) NOT NULL COMMENT '使用批次ID(关联lq_inventory_usage.F_UsageBatchId)', + `F_ApplicationUserId` varchar(50) NOT NULL COMMENT '申请人ID', + `F_ApplicationUserName` varchar(100) DEFAULT NULL COMMENT '申请人姓名', + `F_ApplicationStoreId` varchar(50) DEFAULT NULL COMMENT '申请门店ID', + `F_ApplicationTime` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '申请时间', + `F_NodeCount` int DEFAULT 1 COMMENT '节点数量(固定为1)', + `F_CurrentNodeOrder` int DEFAULT 0 COMMENT '当前审批节点(0-待审批,1-审批中,2-已完成)', + `F_CurrentNodeId` varchar(50) DEFAULT NULL COMMENT '当前节点ID', + `F_ApprovalStatus` varchar(20) DEFAULT '待审批' COMMENT '审批状态(待审批/审批中/已通过/未通过/已退回)', + `F_IsReceived` int DEFAULT 0 COMMENT '是否已领取(1-已领取,0-未领取)', + `F_ReceiveTime` datetime DEFAULT NULL COMMENT '领取时间', + `F_ReceiveUser` varchar(50) DEFAULT NULL COMMENT '领取人ID', + `F_Remarks` varchar(500) DEFAULT NULL COMMENT '备注', + `F_CreateTime` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `F_CreateUser` varchar(50) DEFAULT NULL COMMENT '创建人ID', + `F_UpdateTime` datetime DEFAULT NULL COMMENT '更新时间', + `F_UpdateUser` varchar(50) DEFAULT NULL COMMENT '更新人ID', + `F_IsEffective` int DEFAULT 1 COMMENT '是否有效(1-有效,0-无效)', + PRIMARY KEY (`F_Id`), + UNIQUE KEY `uk_usage_batch_id` (`F_UsageBatchId`), + KEY `idx_application_user_id` (`F_ApplicationUserId`), + KEY `idx_application_store_id` (`F_ApplicationStoreId`), + KEY `idx_current_node` (`F_CurrentNodeId`), + KEY `idx_approval_status` (`F_ApprovalStatus`), + KEY `idx_is_received` (`F_IsReceived`), + KEY `idx_create_time` (`F_CreateTime`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='库存使用申请表'; + +-- ============================================ +-- 3. 创建库存使用申请审批记录表(如果不存在) +-- ============================================ +CREATE TABLE IF NOT EXISTS `lq_inventory_usage_approval_record` ( + `F_Id` varchar(50) NOT NULL COMMENT '记录编号', + `F_ApplicationId` varchar(50) NOT NULL COMMENT '申请ID', + `F_NodeId` varchar(50) NOT NULL COMMENT '节点编号', + `F_NodeOrder` int NOT NULL DEFAULT 1 COMMENT '节点顺序(固定为1)', + `F_ApproverId` varchar(50) NOT NULL COMMENT '审批人ID', + `F_ApproverName` varchar(100) DEFAULT NULL COMMENT '审批人姓名', + `F_ApprovalResult` varchar(20) NOT NULL COMMENT '审批结果(通过/不通过/退回)', + `F_ApprovalOpinion` varchar(500) DEFAULT NULL COMMENT '审批意见', + `F_ApprovalTime` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '审批时间', + `F_IsCurrentNode` int DEFAULT 0 COMMENT '是否当前节点(1-是,0-否)', + PRIMARY KEY (`F_Id`), + KEY `idx_application_id` (`F_ApplicationId`), + KEY `idx_node_id` (`F_NodeId`), + KEY `idx_approver_id` (`F_ApproverId`), + KEY `idx_node_order` (`F_ApplicationId`, `F_NodeOrder`), + KEY `idx_approval_result` (`F_ApprovalResult`), + KEY `idx_approval_time` (`F_ApprovalTime`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='库存使用申请审批记录表'; + +-- ============================================ +-- 4. 检查并添加可能缺失的字段(兼容性处理) +-- ============================================ + +-- 检查 lq_inventory_usage_application 表是否有所需字段 +-- 如果表已存在但字段缺失,则添加字段 + +-- 检查并添加 F_IsReceived 字段(如果不存在) +SET @tablename = 'lq_inventory_usage_application'; +SET @columnname = 'F_IsReceived'; +SET @preparedStatement = (SELECT IF( + ( + SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS + WHERE + (TABLE_SCHEMA = @dbname) + AND (TABLE_NAME = @tablename) + AND (COLUMN_NAME = @columnname) + ) > 0, + 'SELECT 1', + CONCAT('ALTER TABLE ', @tablename, ' ADD COLUMN `', @columnname, '` int DEFAULT 0 COMMENT ''是否已领取(1-已领取,0-未领取)'' AFTER `F_ApprovalStatus`') +)); +PREPARE alterIfNotExists FROM @preparedStatement; +EXECUTE alterIfNotExists; +DEALLOCATE PREPARE alterIfNotExists; + +-- 检查并添加 F_ReceiveTime 字段(如果不存在) +SET @columnname = 'F_ReceiveTime'; +SET @preparedStatement = (SELECT IF( + ( + SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS + WHERE + (TABLE_SCHEMA = @dbname) + AND (TABLE_NAME = @tablename) + AND (COLUMN_NAME = @columnname) + ) > 0, + 'SELECT 1', + CONCAT('ALTER TABLE ', @tablename, ' ADD COLUMN `', @columnname, '` datetime DEFAULT NULL COMMENT ''领取时间'' AFTER `F_IsReceived`') +)); +PREPARE alterIfNotExists FROM @preparedStatement; +EXECUTE alterIfNotExists; +DEALLOCATE PREPARE alterIfNotExists; + +-- 检查并添加 F_ReceiveUser 字段(如果不存在) +SET @columnname = 'F_ReceiveUser'; +SET @preparedStatement = (SELECT IF( + ( + SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS + WHERE + (TABLE_SCHEMA = @dbname) + AND (TABLE_NAME = @tablename) + AND (COLUMN_NAME = @columnname) + ) > 0, + 'SELECT 1', + CONCAT('ALTER TABLE ', @tablename, ' ADD COLUMN `', @columnname, '` varchar(50) DEFAULT NULL COMMENT ''领取人ID'' AFTER `F_ReceiveTime`') +)); +PREPARE alterIfNotExists FROM @preparedStatement; +EXECUTE alterIfNotExists; +DEALLOCATE PREPARE alterIfNotExists; + +-- ============================================ +-- 5. 验证表结构 +-- ============================================ +-- 可以执行以下查询来验证表结构是否正确 + +-- 查看 lq_inventory_usage 表结构 +-- SELECT COLUMN_NAME, DATA_TYPE, IS_NULLABLE, COLUMN_DEFAULT, COLUMN_COMMENT +-- FROM INFORMATION_SCHEMA.COLUMNS +-- WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'lq_inventory_usage' +-- ORDER BY ORDINAL_POSITION; + +-- 查看 lq_inventory_usage_application 表结构 +-- SELECT COLUMN_NAME, DATA_TYPE, IS_NULLABLE, COLUMN_DEFAULT, COLUMN_COMMENT +-- FROM INFORMATION_SCHEMA.COLUMNS +-- WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'lq_inventory_usage_application' +-- ORDER BY ORDINAL_POSITION; + +-- 查看 lq_inventory_usage_approval_record 表结构 +-- SELECT COLUMN_NAME, DATA_TYPE, IS_NULLABLE, COLUMN_DEFAULT, COLUMN_COMMENT +-- FROM INFORMATION_SCHEMA.COLUMNS +-- WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'lq_inventory_usage_approval_record' +-- ORDER BY ORDINAL_POSITION; + +-- ============================================ +-- SQL脚本执行完成 +-- ============================================ + diff --git a/sql/库存管理审批功能表结构.sql b/sql/库存管理审批功能表结构.sql new file mode 100644 index 0000000..6f0af8c --- /dev/null +++ b/sql/库存管理审批功能表结构.sql @@ -0,0 +1,214 @@ +-- ============================================ +-- 库存管理审批功能相关表结构SQL +-- ============================================ +-- 说明:为库存使用记录添加审批功能,包括申请记录、审批记录等 +-- 执行时间:2025年 +-- 注意:本SQL只包含实际使用的表和字段,已删除未使用的节点审批人表 +-- ============================================ + +-- ============================================ +-- 1. 修改库存使用记录表,添加单价和合计金额字段(如果不存在) +-- ============================================ +-- 说明:用于统计成本费用,单价从产品表获取,合计金额 = 单价 × 数量 + +-- 检查并添加单价字段 +SET @dbname = DATABASE(); +SET @tablename = 'lq_inventory_usage'; +SET @columnname = 'F_UnitPrice'; +SET @preparedStatement = (SELECT IF( + ( + SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS + WHERE + (TABLE_SCHEMA = @dbname) + AND (TABLE_NAME = @tablename) + AND (COLUMN_NAME = @columnname) + ) > 0, + 'SELECT 1', + CONCAT('ALTER TABLE ', @tablename, ' ADD COLUMN `', @columnname, '` decimal(18,2) DEFAULT 0.00 COMMENT ''单价(从产品表F_Price获取)'' AFTER `F_UsageQuantity`') +)); +PREPARE alterIfNotExists FROM @preparedStatement; +EXECUTE alterIfNotExists; +DEALLOCATE PREPARE alterIfNotExists; + +-- 检查并添加合计金额字段 +SET @columnname = 'F_TotalAmount'; +SET @preparedStatement = (SELECT IF( + ( + SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS + WHERE + (TABLE_SCHEMA = @dbname) + AND (TABLE_NAME = @tablename) + AND (COLUMN_NAME = @columnname) + ) > 0, + 'SELECT 1', + CONCAT('ALTER TABLE ', @tablename, ' ADD COLUMN `', @columnname, '` decimal(18,2) DEFAULT 0.00 COMMENT ''合计金额(单价×数量)'' AFTER `F_UnitPrice`') +)); +PREPARE alterIfNotExists FROM @preparedStatement; +EXECUTE alterIfNotExists; +DEALLOCATE PREPARE alterIfNotExists; + +-- 添加索引(如果不存在) +-- 注意:MySQL 5.7+ 不支持 IF NOT EXISTS,使用存储过程或先检查 +-- 这里先检查索引是否存在,如果不存在则添加 +SET @indexname = 'idx_unit_price'; +SET @preparedStatement = (SELECT IF( + ( + SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS + WHERE + (TABLE_SCHEMA = @dbname) + AND (TABLE_NAME = @tablename) + AND (INDEX_NAME = @indexname) + ) > 0, + 'SELECT 1', + CONCAT('ALTER TABLE ', @tablename, ' ADD INDEX `', @indexname, '` (`F_UnitPrice`)') +)); +PREPARE alterIfNotExists FROM @preparedStatement; +EXECUTE alterIfNotExists; +DEALLOCATE PREPARE alterIfNotExists; + +SET @indexname = 'idx_total_amount'; +SET @preparedStatement = (SELECT IF( + ( + SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS + WHERE + (TABLE_SCHEMA = @dbname) + AND (TABLE_NAME = @tablename) + AND (INDEX_NAME = @indexname) + ) > 0, + 'SELECT 1', + CONCAT('ALTER TABLE ', @tablename, ' ADD INDEX `', @indexname, '` (`F_TotalAmount`)') +)); +PREPARE alterIfNotExists FROM @preparedStatement; +EXECUTE alterIfNotExists; +DEALLOCATE PREPARE alterIfNotExists; + +-- 数据迁移:更新已有数据的单价和合计金额(从产品表获取价格) +UPDATE `lq_inventory_usage` u +INNER JOIN `lq_product` p ON u.`F_ProductId` = p.`F_Id` +SET u.`F_UnitPrice` = COALESCE(p.`F_Price`, 0), + u.`F_TotalAmount` = COALESCE(p.`F_Price`, 0) * u.`F_UsageQuantity` +WHERE (u.`F_UnitPrice` = 0 OR u.`F_UnitPrice` IS NULL) AND p.`F_Price` IS NOT NULL; + +-- ============================================ +-- 2. 创建库存使用申请表(如果不存在) +-- ============================================ +CREATE TABLE IF NOT EXISTS `lq_inventory_usage_application` ( + `F_Id` varchar(50) NOT NULL COMMENT '申请编号', + `F_UsageBatchId` varchar(50) NOT NULL COMMENT '使用批次ID(关联lq_inventory_usage.F_UsageBatchId)', + `F_ApplicationUserId` varchar(50) NOT NULL COMMENT '申请人ID', + `F_ApplicationUserName` varchar(100) DEFAULT NULL COMMENT '申请人姓名', + `F_ApplicationStoreId` varchar(50) DEFAULT NULL COMMENT '申请门店ID', + `F_ApplicationTime` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '申请时间', + `F_NodeCount` int DEFAULT 1 COMMENT '节点数量(固定为1)', + `F_CurrentNodeOrder` int DEFAULT 0 COMMENT '当前审批节点(0-待审批,1-审批中,2-已完成)', + `F_CurrentNodeId` varchar(50) DEFAULT NULL COMMENT '当前节点ID', + `F_ApprovalStatus` varchar(20) DEFAULT '待审批' COMMENT '审批状态(待审批/审批中/已通过/未通过/已退回)', + `F_IsReceived` int DEFAULT 0 COMMENT '是否已领取(1-已领取,0-未领取)', + `F_ReceiveTime` datetime DEFAULT NULL COMMENT '领取时间', + `F_ReceiveUser` varchar(50) DEFAULT NULL COMMENT '领取人ID', + `F_Remarks` varchar(500) DEFAULT NULL COMMENT '备注', + `F_CreateTime` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `F_CreateUser` varchar(50) DEFAULT NULL COMMENT '创建人ID', + `F_UpdateTime` datetime DEFAULT NULL COMMENT '更新时间', + `F_UpdateUser` varchar(50) DEFAULT NULL COMMENT '更新人ID', + `F_IsEffective` int DEFAULT 1 COMMENT '是否有效(1-有效,0-无效)', + PRIMARY KEY (`F_Id`), + UNIQUE KEY `uk_usage_batch_id` (`F_UsageBatchId`), + KEY `idx_application_user_id` (`F_ApplicationUserId`), + KEY `idx_application_store_id` (`F_ApplicationStoreId`), + KEY `idx_current_node` (`F_CurrentNodeId`), + KEY `idx_approval_status` (`F_ApprovalStatus`), + KEY `idx_is_received` (`F_IsReceived`), + KEY `idx_create_time` (`F_CreateTime`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='库存使用申请表'; + +-- ============================================ +-- 3. 创建库存使用申请审批记录表(如果不存在) +-- ============================================ +CREATE TABLE IF NOT EXISTS `lq_inventory_usage_approval_record` ( + `F_Id` varchar(50) NOT NULL COMMENT '记录编号', + `F_ApplicationId` varchar(50) NOT NULL COMMENT '申请ID', + `F_NodeId` varchar(50) NOT NULL COMMENT '节点编号', + `F_NodeOrder` int NOT NULL DEFAULT 1 COMMENT '节点顺序(固定为1)', + `F_ApproverId` varchar(50) NOT NULL COMMENT '审批人ID', + `F_ApproverName` varchar(100) DEFAULT NULL COMMENT '审批人姓名', + `F_ApprovalResult` varchar(20) NOT NULL COMMENT '审批结果(通过/不通过/退回)', + `F_ApprovalOpinion` varchar(500) DEFAULT NULL COMMENT '审批意见', + `F_ApprovalTime` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '审批时间', + `F_IsCurrentNode` int DEFAULT 0 COMMENT '是否当前节点(1-是,0-否)', + PRIMARY KEY (`F_Id`), + KEY `idx_application_id` (`F_ApplicationId`), + KEY `idx_node_id` (`F_NodeId`), + KEY `idx_approver_id` (`F_ApproverId`), + KEY `idx_node_order` (`F_ApplicationId`, `F_NodeOrder`), + KEY `idx_approval_result` (`F_ApprovalResult`), + KEY `idx_approval_time` (`F_ApprovalTime`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='库存使用申请审批记录表'; + +-- ============================================ +-- 4. 检查并添加可能缺失的字段(兼容性处理) +-- ============================================ + +-- 检查 lq_inventory_usage_application 表是否有所需字段 +-- 如果表已存在但字段缺失,则添加字段 + +-- 检查并添加 F_IsReceived 字段(如果不存在) +SET @tablename = 'lq_inventory_usage_application'; +SET @columnname = 'F_IsReceived'; +SET @preparedStatement = (SELECT IF( + ( + SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS + WHERE + (TABLE_SCHEMA = @dbname) + AND (TABLE_NAME = @tablename) + AND (COLUMN_NAME = @columnname) + ) > 0, + 'SELECT 1', + CONCAT('ALTER TABLE ', @tablename, ' ADD COLUMN `', @columnname, '` int DEFAULT 0 COMMENT ''是否已领取(1-已领取,0-未领取)'' AFTER `F_ApprovalStatus`') +)); +PREPARE alterIfNotExists FROM @preparedStatement; +EXECUTE alterIfNotExists; +DEALLOCATE PREPARE alterIfNotExists; + +-- 检查并添加 F_ReceiveTime 字段(如果不存在) +SET @columnname = 'F_ReceiveTime'; +SET @preparedStatement = (SELECT IF( + ( + SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS + WHERE + (TABLE_SCHEMA = @dbname) + AND (TABLE_NAME = @tablename) + AND (COLUMN_NAME = @columnname) + ) > 0, + 'SELECT 1', + CONCAT('ALTER TABLE ', @tablename, ' ADD COLUMN `', @columnname, '` datetime DEFAULT NULL COMMENT ''领取时间'' AFTER `F_IsReceived`') +)); +PREPARE alterIfNotExists FROM @preparedStatement; +EXECUTE alterIfNotExists; +DEALLOCATE PREPARE alterIfNotExists; + +-- 检查并添加 F_ReceiveUser 字段(如果不存在) +SET @columnname = 'F_ReceiveUser'; +SET @preparedStatement = (SELECT IF( + ( + SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS + WHERE + (TABLE_SCHEMA = @dbname) + AND (TABLE_NAME = @tablename) + AND (COLUMN_NAME = @columnname) + ) > 0, + 'SELECT 1', + CONCAT('ALTER TABLE ', @tablename, ' ADD COLUMN `', @columnname, '` varchar(50) DEFAULT NULL COMMENT ''领取人ID'' AFTER `F_ReceiveTime`') +)); +PREPARE alterIfNotExists FROM @preparedStatement; +EXECUTE alterIfNotExists; +DEALLOCATE PREPARE alterIfNotExists; + +-- ============================================ +-- SQL脚本执行完成 +-- ============================================ +-- 说明: +-- 1. lq_inventory_usage 表:添加了 F_UnitPrice 和 F_TotalAmount 字段 +-- 2. lq_inventory_usage_application 表:创建申请记录表 +-- 3. lq_inventory_usage_approval_record 表:创建审批记录表 +-- 4. 注意:未使用节点审批人表(lq_inventory_usage_application_node_user),已删除相关实体 diff --git a/合同管理系统-前端调用说明.md b/合同管理系统-前端调用说明.md new file mode 100644 index 0000000..5a463ca --- /dev/null +++ b/合同管理系统-前端调用说明.md @@ -0,0 +1,792 @@ +# 合同管理系统 - 前端调用说明 + +## 📋 目录 +- [业务流程概述](#业务流程概述) +- [接口列表](#接口列表) +- [完整流程示例](#完整流程示例) +- [接口详细说明](#接口详细说明) +- [数据验证说明](#数据验证说明) +- [注意事项](#注意事项) + +## 🔄 业务流程概述 + +合同管理系统包含以下核心功能: + +1. **创建合同** - 录入合同信息,系统自动生成月租明细 +2. **查询合同** - 支持列表查询和详情查询 +3. **更新合同** - 修改合同信息,如果影响明细会自动重新生成 +4. **标记缴费** - 标记月租明细已缴费,系统自动更新下次应交时间 +5. **删除合同** - 删除合同及所有关联明细(逻辑删除) + +## 📡 接口列表 + +| 接口 | 方法 | 路径 | 说明 | +|------|------|------|------| +| 创建合同 | POST | `/api/Extend/LqContract/Create` | 创建合同并自动生成月租明细 | +| 更新合同 | PUT | `/api/Extend/LqContract/Update` | 更新合同信息,影响明细时自动重新生成 | +| 删除合同 | DELETE | `/api/Extend/LqContract/{id}` | 删除合同及所有明细(逻辑删除) | +| 获取合同列表 | GET | `/api/Extend/LqContract/GetList` | 分页查询合同列表,支持多条件筛选 | +| 获取合同详情 | GET | `/api/Extend/LqContract/GetInfo` | 根据合同ID获取详情,包含月租明细列表 | +| 获取月租明细列表 | GET | `/api/Extend/LqContract/GetRentDetails` | 根据合同ID获取所有月租明细 | +| 标记明细已缴费 | PUT | `/api/Extend/LqContract/MarkRentDetailPaid` | 标记某条明细已缴费,记录实际缴费信息 | +| 统计门店合同费用 | POST | `/api/Extend/LqContract/GetExpenseStatistics` | 统计某个门店指定月份的合同费用,支持按分类统计 | + +## 🚀 完整流程示例 + +### 步骤1:创建合同 + +**接口:** `POST /api/Extend/LqContract/Create` + +**请求示例:** +```javascript +const response = await request({ + url: '/api/Extend/LqContract/Create', + method: 'POST', + data: { + storeId: '1649328471923847168', // 门店ID(必填) + title: '门店租赁合同', // 标题(必填) + category: '租赁合同', // 分类(可选) + tenantName: '张三', // 户名(可选) + contractStartDate: '2025-01-01T00:00:00', // 合同起始日期(必填) + contractEndDate: '2025-12-31T23:59:59', // 合同结束日期(必填) + reminderDays: 7, // 提前提醒天数(可选,默认0) + deposit: 5000.00, // 押金(可选,默认0) + monthlyRent: 1000.00, // 月租(必填) + paymentAmount: 3000.00, // 缴租金额(必填,通常=月租×交租周期) + paymentCycle: 3, // 交租周期(必填,单位:月,如1、3、6等) + remarks: '季度交租', // 备注(可选) + attachment: '' // 附件(可选) + } +}); + +// 响应示例 +// { +// "code": 200, +// "msg": "操作成功", +// "data": null +// } +``` + +**说明:** +- 系统会自动根据合同信息生成月租明细 +- 生成规则:从合同起始日期开始,每隔 `paymentCycle` 个月生成一条明细 +- 应缴月份为每次交租对应的月份(格式:YYYY-MM-01) +- 应缴日期为应缴月份的第一天 +- 应缴金额等于 `paymentAmount` +- 系统会自动计算下次应交时间(最早未缴费明细的应缴日期 - 提前提醒天数) + +**示例:** +- 合同起始:2025-01-01 +- 合同结束:2025-12-31 +- 交租周期:3个月 +- 缴租金额:3000元 + +生成的明细: +- 2025-01-01,应缴金额:3000元(1-3月) +- 2025-04-01,应缴金额:3000元(4-6月) +- 2025-07-01,应缴金额:3000元(7-9月) +- 2025-10-01,应缴金额:3000元(10-12月) + +### 步骤2:查询合同列表 + +**接口:** `GET /api/Extend/LqContract/GetList` + +**请求示例:** +```javascript +const response = await request({ + url: '/api/Extend/LqContract/GetList', + method: 'GET', + params: { + currentPage: 1, // 当前页码(必填) + pageSize: 10, // 每页数量(必填) + sidx: 'createTime', // 排序字段(可选,默认createTime) + sort: 'desc', // 排序方式(可选,默认desc) + storeId: '1649328471923847168', // 门店ID(可选) + storeName: '绿纤总部', // 门店名称(可选,模糊查询) + category: '租赁合同', // 分类(可选) + title: '合同', // 标题(可选,模糊查询) + contractStartDateBegin: '2025-01-01', // 合同起始日期(开始)(可选) + contractStartDateEnd: '2025-12-31', // 合同起始日期(结束)(可选) + contractEndDateBegin: '2025-01-01', // 合同结束日期(开始)(可选) + contractEndDateEnd: '2025-12-31', // 合同结束日期(结束)(可选) + isEffective: 1 // 是否有效(可选,1-有效,0-无效) + } +}); + +// 响应示例 +// { +// "code": 200, +// "msg": "操作成功", +// "data": { +// "pagination": { +// "pageIndex": 1, +// "pageSize": 10, +// "total": 1 +// }, +// "list": [ +// { +// "id": "768081482374710533", +// "storeId": "1649328471923847168", +// "storeName": "绿纤总部", +// "title": "门店租赁合同", +// "category": "租赁合同", +// "tenantName": "张三", +// "contractStartDate": 1735660800000, +// "contractEndDate": 1767196799000, +// "reminderDays": 7, +// "deposit": 5000.00, +// "nextPaymentDate": 1735056000000, +// "monthlyRent": 1000.00, +// "paymentAmount": 3000.00, +// "paymentCycle": 3, +// "remarks": "季度交租", +// "attachment": "", +// "createUser": "admin", +// "createUserName": "管理员", +// "createTime": 1765290098000, +// "updateUser": "admin", +// "updateUserName": "管理员", +// "updateTime": 1765290098000, +// "isEffective": 1 +// } +// ] +// } +// } +``` + +### 步骤3:查询合同详情 + +**接口:** `GET /api/Extend/LqContract/GetInfo` + +**请求示例:** +```javascript +const response = await request({ + url: '/api/Extend/LqContract/GetInfo', + method: 'GET', + params: { + id: '768081482374710533' // 合同ID(必填) + } +}); + +// 响应示例 +// { +// "code": 200, +// "msg": "操作成功", +// "data": { +// "id": "768081482374710533", +// "storeId": "1649328471923847168", +// "storeName": "绿纤总部", +// "title": "门店租赁合同", +// "category": "租赁合同", +// "tenantName": "张三", +// "contractStartDate": 1735660800000, +// "contractEndDate": 1767196799000, +// "reminderDays": 7, +// "deposit": 5000.00, +// "nextPaymentDate": 1735056000000, +// "monthlyRent": 1000.00, +// "paymentAmount": 3000.00, +// "paymentCycle": 3, +// "remarks": "季度交租", +// "attachment": "", +// "createUser": "admin", +// "createUserName": "管理员", +// "createTime": 1765290098000, +// "updateUser": "admin", +// "updateUserName": "管理员", +// "updateTime": 1765290098000, +// "isEffective": 1, +// "rentDetails": [ +// { +// "id": "768081482571842821", +// "contractId": "768081482374710533", +// "paymentMonth": 1735660800000, +// "dueDate": 1735660800000, +// "dueAmount": 3000.00, +// "isPaid": 0, +// "actualPaymentDate": null, +// "actualPaymentAmount": null, +// "remarks": null, +// "createUser": "admin", +// "createUserName": "管理员", +// "createTime": 1765290098000, +// "updateUser": null, +// "updateUserName": "", +// "updateTime": null, +// "isEffective": 1 +// } +// // ... 更多明细 +// ] +// } +// } +``` + +### 步骤4:查询月租明细列表 + +**接口:** `GET /api/Extend/LqContract/GetRentDetails` + +**请求示例:** +```javascript +const response = await request({ + url: '/api/Extend/LqContract/GetRentDetails', + method: 'GET', + params: { + contractId: '768081482374710533' // 合同ID(必填) + } +}); + +// 响应示例 +// { +// "code": 200, +// "msg": "操作成功", +// "data": [ +// { +// "id": "768081482571842821", +// "contractId": "768081482374710533", +// "paymentMonth": 1735660800000, +// "dueDate": 1735660800000, +// "dueAmount": 3000.00, +// "isPaid": 0, +// "actualPaymentDate": null, +// "actualPaymentAmount": null, +// "remarks": null, +// "createUser": "admin", +// "createUserName": "管理员", +// "createTime": 1765290098000, +// "updateUser": null, +// "updateUserName": "", +// "updateTime": null, +// "isEffective": 1 +// } +// // ... 更多明细 +// ] +// } +``` + +### 步骤5:标记明细已缴费 + +**接口:** `PUT /api/Extend/LqContract/MarkRentDetailPaid` + +**请求示例:** +```javascript +const response = await request({ + url: '/api/Extend/LqContract/MarkRentDetailPaid', + method: 'PUT', + data: { + id: '768081482571842821', // 明细ID(必填) + actualPaymentDate: '2025-01-15T00:00:00', // 实际缴费时间(必填) + actualPaymentAmount: 3000.00, // 实际缴费金额(必填) + remarks: '已缴费' // 备注(可选) + } +}); + +// 响应示例 +// { +// "code": 200, +// "msg": "操作成功", +// "data": null +// } +``` + +**说明:** +- 标记成功后,系统会自动更新该明细的 `isPaid` 为 1 +- 系统会自动重新计算合同的下次应交时间(找到最早未缴费明细,计算:应缴日期 - 提前提醒天数) + +### 步骤6:更新合同 + +**接口:** `PUT /api/Extend/LqContract/Update` + +**请求示例:** +```javascript +const response = await request({ + url: '/api/Extend/LqContract/Update', + method: 'PUT', + data: { + id: '768081482374710533', // 合同ID(必填) + storeId: '1649328471923847168', // 门店ID(必填) + title: '门店租赁合同-已更新', // 标题(必填) + category: '租赁合同', // 分类(可选) + tenantName: '张三', // 户名(可选) + contractStartDate: '2025-01-01T00:00:00', // 合同起始日期(必填) + contractEndDate: '2025-12-31T23:59:59', // 合同结束日期(必填) + reminderDays: 7, // 提前提醒天数(可选) + deposit: 5000.00, // 押金(可选) + monthlyRent: 1000.00, // 月租(必填) + paymentAmount: 6000.00, // 缴租金额(必填) + paymentCycle: 6, // 交租周期(必填) + remarks: '半年交租', // 备注(可选) + attachment: '' // 附件(可选) + } +}); + +// 响应示例 +// { +// "code": 200, +// "msg": "操作成功", +// "data": null +// } +``` + +**说明:** +- 如果修改了以下字段,系统会重新生成月租明细: + - `contractStartDate`(合同起始日期) + - `contractEndDate`(合同结束日期) + - `paymentCycle`(交租周期) + - `paymentAmount`(缴租金额) +- 重新生成时,会先逻辑删除所有旧明细,然后生成新明细 +- 系统会自动重新计算下次应交时间 + +### 步骤7:删除合同 + +**接口:** `DELETE /api/Extend/LqContract/{id}` + +**请求示例:** +```javascript +const response = await request({ + url: '/api/Extend/LqContract/768081482374710533', + method: 'DELETE' +}); + +// 响应示例 +// { +// "code": 200, +// "msg": "操作成功", +// "data": null +// } +``` + +**说明:** +- 删除合同会同时逻辑删除该合同的所有月租明细 +- 删除后,合同和明细的 `isEffective` 字段会被设置为 0 +- 删除后的合同在列表查询中不会显示(默认只查询有效的合同) + +## 📝 接口详细说明 + +### 1. 创建合同 + +**接口地址:** `POST /api/Extend/LqContract/Create` + +**请求参数:** + +| 参数名 | 类型 | 必填 | 说明 | +|--------|------|------|------| +| storeId | string | ✅ | 门店ID(关联lq_mdxx.F_Id) | +| title | string | ✅ | 标题 | +| category | string | ❌ | 分类(string类型,自己填写) | +| tenantName | string | ❌ | 户名 | +| contractStartDate | datetime | ✅ | 合同起始日期 | +| contractEndDate | datetime | ✅ | 合同结束日期 | +| reminderDays | int | ❌ | 提前多少天提醒(默认0) | +| deposit | decimal | ❌ | 押金(默认0) | +| monthlyRent | decimal | ✅ | 月租 | +| paymentAmount | decimal | ✅ | 缴租金额(每次交租的金额,通常=月租×交租周期) | +| paymentCycle | int | ✅ | 交租周期(数字,表示几个月,如1、3、6等,范围1-12) | +| remarks | string | ❌ | 备注 | +| attachment | string | ❌ | 附件(存储附件路径或JSON) | + +**响应说明:** +- 成功:`{"code": 200, "msg": "操作成功", "data": null}` +- 失败:返回错误信息 + +**业务逻辑:** +1. 验证合同日期(起始日期必须小于结束日期) +2. 验证交租周期(必须在1-12个月之间) +3. 查询门店信息(获取店名) +4. 创建合同记录 +5. 自动生成月租明细(根据合同起始日期、结束日期、交租周期、缴租金额) +6. 计算下次应交时间(最早未缴费明细的应缴日期 - 提前提醒天数) + +### 2. 更新合同 + +**接口地址:** `PUT /api/Extend/LqContract/Update` + +**请求参数:** + +| 参数名 | 类型 | 必填 | 说明 | +|--------|------|------|------| +| id | string | ✅ | 合同ID | +| storeId | string | ✅ | 门店ID | +| title | string | ✅ | 标题 | +| category | string | ❌ | 分类 | +| tenantName | string | ❌ | 户名 | +| contractStartDate | datetime | ✅ | 合同起始日期 | +| contractEndDate | datetime | ✅ | 合同结束日期 | +| reminderDays | int | ❌ | 提前提醒天数 | +| deposit | decimal | ❌ | 押金 | +| monthlyRent | decimal | ✅ | 月租 | +| paymentAmount | decimal | ✅ | 缴租金额 | +| paymentCycle | int | ✅ | 交租周期 | +| remarks | string | ❌ | 备注 | +| attachment | string | ❌ | 附件 | + +**响应说明:** +- 成功:`{"code": 200, "msg": "操作成功", "data": null}` +- 失败:返回错误信息 + +**业务逻辑:** +1. 验证合同是否存在 +2. 验证合同日期和交租周期 +3. 判断是否需要重新生成明细(如果修改了合同起始日期、结束日期、交租周期或缴租金额) +4. 如果需要重新生成,先逻辑删除旧明细,再生成新明细 +5. 重新计算下次应交时间 + +### 3. 删除合同 + +**接口地址:** `DELETE /api/Extend/LqContract/{id}` + +**路径参数:** + +| 参数名 | 类型 | 必填 | 说明 | +|--------|------|------|------| +| id | string | ✅ | 合同ID | + +**响应说明:** +- 成功:`{"code": 200, "msg": "操作成功", "data": null}` +- 失败:返回错误信息 + +**业务逻辑:** +1. 验证合同是否存在 +2. 逻辑删除该合同的所有月租明细(设置 `isEffective = 0`) +3. 逻辑删除合同(设置 `isEffective = 0`) + +### 4. 获取合同列表 + +**接口地址:** `GET /api/Extend/LqContract/GetList` + +**请求参数:** + +| 参数名 | 类型 | 必填 | 说明 | +|--------|------|------|------| +| currentPage | int | ✅ | 当前页码 | +| pageSize | int | ✅ | 每页数量 | +| sidx | string | ❌ | 排序字段(默认createTime) | +| sort | string | ❌ | 排序方式(默认desc) | +| storeId | string | ❌ | 门店ID | +| storeName | string | ❌ | 门店名称(模糊查询) | +| category | string | ❌ | 分类 | +| title | string | ❌ | 标题(模糊查询) | +| contractStartDateBegin | datetime | ❌ | 合同起始日期(开始) | +| contractStartDateEnd | datetime | ❌ | 合同起始日期(结束) | +| contractEndDateBegin | datetime | ❌ | 合同结束日期(开始) | +| contractEndDateEnd | datetime | ❌ | 合同结束日期(结束) | +| isEffective | int | ❌ | 是否有效(1-有效,0-无效) | + +**响应说明:** +- 成功:返回分页数据,包含合同列表和分页信息 +- 失败:返回错误信息 + +### 5. 获取合同详情 + +**接口地址:** `GET /api/Extend/LqContract/GetInfo` + +**请求参数:** + +| 参数名 | 类型 | 必填 | 说明 | +|--------|------|------|------| +| id | string | ✅ | 合同ID | + +**响应说明:** +- 成功:返回合同详情,包含月租明细列表 +- 失败:返回错误信息 + +### 6. 获取月租明细列表 + +**接口地址:** `GET /api/Extend/LqContract/GetRentDetails` + +**请求参数:** + +| 参数名 | 类型 | 必填 | 说明 | +|--------|------|------|------| +| contractId | string | ✅ | 合同ID | + +**响应说明:** +- 成功:返回月租明细数组 +- 失败:返回错误信息 + +### 7. 标记明细已缴费 + +**接口地址:** `PUT /api/Extend/LqContract/MarkRentDetailPaid` + +**请求参数:** + +| 参数名 | 类型 | 必填 | 说明 | +|--------|------|------|------| +| id | string | ✅ | 明细ID | +| actualPaymentDate | datetime | ✅ | 实际缴费时间 | +| actualPaymentAmount | decimal | ✅ | 实际缴费金额 | +| remarks | string | ❌ | 备注 | + +**响应说明:** +- 成功:`{"code": 200, "msg": "操作成功", "data": null}` +- 失败:返回错误信息 + +**业务逻辑:** +1. 验证明细是否存在 +2. 验证明细是否已缴费(已缴费的不能重复标记) +3. 更新明细的缴费信息 +4. 重新计算合同的下次应交时间 + +### 8. 统计门店合同费用 + +**接口地址:** `POST /api/Extend/LqContract/GetExpenseStatistics` + +**请求参数:** + +| 参数名 | 类型 | 必填 | 说明 | +|--------|------|------|------| +| storeId | string | ✅ | 门店ID | +| year | int | ✅ | 统计年份(2020-2100) | +| month | int | ✅ | 统计月份(1-12) | +| categories | string[] | ❌ | 分类列表(可选,不传则统计所有分类,如:["租门店", "员工宿舍", "车辆", "场所"]) | + +**响应说明:** +- 成功:返回统计结果,包含总费用和按分类的费用明细 +- 失败:返回错误信息 + +**业务逻辑:** +1. 验证月份范围(1-12) +2. 查询门店信息 +3. 查询该门店在指定月份的月租明细(关联合同表获取分类信息) +4. 如果指定了分类,则只统计指定分类的明细 +5. 按分类分组统计,计算每个分类的费用总额 +6. 返回总费用和按分类的费用明细 + +**响应数据结构:** +- `storeId`: 门店ID +- `storeName`: 门店名称 +- `year`: 统计年份 +- `month`: 统计月份 +- `totalAmount`: 总费用(所有分类的费用总和) +- `categoryDetails`: 按分类统计的费用明细数组 + - `category`: 分类名称 + - `amount`: 该分类的费用总额 + - `detailCount`: 该分类的明细数量 + - `details`: 明细列表 + - `detailId`: 明细ID + - `contractId`: 合同ID + - `contractTitle`: 合同标题 + - `category`: 分类 + - `dueAmount`: 应缴金额 + - `isPaid`: 是否已缴(0-未缴,1-已缴) + - `actualPaymentAmount`: 实际缴费金额(如果已缴费) + +**使用示例:** +```javascript +// 统计某个门店2025年1月的所有合同费用 +const response = await request({ + url: '/api/Extend/LqContract/GetExpenseStatistics', + method: 'POST', + data: { + storeId: '1649328471923847168', + year: 2025, + month: 1 + } +}); + +// 只统计特定分类的费用(租门店、员工宿舍、车辆、场所) +const response2 = await request({ + url: '/api/Extend/LqContract/GetExpenseStatistics', + method: 'POST', + data: { + storeId: '1649328471923847168', + year: 2025, + month: 1, + categories: ['租门店', '员工宿舍', '车辆', '场所'] + } +}); +``` + +## 🔍 数据验证说明 + +### 月租明细生成规则 + +1. **生成时机:** + - 创建合同时自动生成 + - 更新合同时,如果修改了影响明细的字段,会重新生成 + +2. **生成规则:** + - 从合同起始日期开始,每隔 `paymentCycle` 个月生成一条明细 + - 应缴月份:每次交租对应的月份(格式:YYYY-MM-01) + - 应缴日期:应缴月份的第一天 + - 应缴金额:等于 `paymentAmount` + - 生成到合同结束日期为止 + +3. **示例:** + - 合同起始:2025-01-01 + - 合同结束:2025-12-31 + - 交租周期:3个月 + - 缴租金额:3000元 + + 生成的明细: + - 2025-01-01,应缴金额:3000元 + - 2025-04-01,应缴金额:3000元 + - 2025-07-01,应缴金额:3000元 + - 2025-10-01,应缴金额:3000元 + +### 下次应交时间计算规则 + +1. **计算时机:** + - 创建合同时自动计算 + - 更新合同时自动重新计算 + - 标记明细已缴费后自动重新计算 + +2. **计算规则:** + - 查找该合同未缴费的明细中,应缴日期最早的一条 + - 下次应交时间 = 最早应缴日期 - 提前提醒天数(`reminderDays`) + - 如果没有未缴费的明细,下次应交时间为 `null` + +3. **示例:** + - 最早未缴费明细的应缴日期:2025-01-01 + - 提前提醒天数:7天 + - 下次应交时间:2024-12-25(2025-01-01 - 7天) + +## ⚠️ 注意事项 + +1. **日期格式:** + - 所有日期字段使用 ISO 8601 格式:`YYYY-MM-DDTHH:mm:ss` + - 时间戳字段返回的是毫秒级时间戳(需要除以1000转换为秒) + +2. **金额精度:** + - 所有金额字段保留2位小数 + - 前端显示时注意格式化 + +3. **删除操作:** + - 删除是逻辑删除,不会物理删除数据 + - 删除后的合同在列表查询中默认不显示(`isEffective = 0`) + - 如果需要查询已删除的合同,可以设置 `isEffective = 0` + +4. **明细重新生成:** + - 更新合同时,如果修改了合同起始日期、结束日期、交租周期或缴租金额,会重新生成明细 + - 重新生成时,旧明细会被逻辑删除,新明细会重新生成 + - 如果旧明细中有已缴费的记录,重新生成后这些记录也会被删除 + +5. **数据一致性:** + - 系统会自动维护合同和明细的一致性 + - 删除合同时会自动删除所有明细 + - 更新合同时会自动处理明细的重新生成 + +6. **错误处理:** + - 所有接口都会返回标准的响应格式:`{"code": 200, "msg": "操作成功", "data": ...}` + - 如果发生错误,`code` 不为 200,`msg` 包含错误信息 + - 前端需要根据 `code` 判断操作是否成功 + +7. **权限控制:** + - 所有接口都需要在请求头中携带 `Authorization: Bearer {token}` + - Token 需要通过登录接口获取 + +8. **分页查询:** + - 列表查询接口支持分页 + - 默认按创建时间倒序排列 + - 可以通过 `sidx` 和 `sort` 参数自定义排序 + +### 8. 统计门店合同费用 + +**接口:** `POST /api/Extend/LqContract/GetExpenseStatistics` + +**请求示例:** +```javascript +const response = await request({ + url: '/api/Extend/LqContract/GetExpenseStatistics', + method: 'POST', + data: { + storeId: '1649328471923847168', // 门店ID(必填) + year: 2025, // 统计年份(必填) + month: 1, // 统计月份(必填,1-12) + categories: ['租门店', '员工宿舍', '车辆', '场所'] // 分类列表(可选,不传则统计所有分类) + } +}); + +// 响应示例 +// { +// "code": 200, +// "msg": "操作成功", +// "data": { +// "storeId": "1649328471923847168", +// "storeName": "绿纤总部", +// "year": 2025, +// "month": 1, +// "totalAmount": 6000.00, +// "categoryDetails": [ +// { +// "category": "租赁合同", +// "amount": 6000.00, +// "detailCount": 2, +// "details": [ +// { +// "detailId": "768081482571842821", +// "contractId": "768081482374710533", +// "contractTitle": "门店租赁合同", +// "category": "租赁合同", +// "dueAmount": 3000.00, +// "isPaid": 0, +// "actualPaymentAmount": null +// } +// ] +// } +// ] +// } +// } +``` + +**说明:** +- 统计该门店在指定月份的合同费用 +- 支持按分类筛选(如:租门店、员工宿舍、车辆、场所等) +- 返回总费用和按分类的费用明细 +- 每个分类包含该分类的费用总额、明细数量和明细列表 + +**使用场景:** +- 统计某个门店这个月的房租开销 +- 按分类查看不同类型的合同费用 +- 生成门店成本费用报表 + +## 📊 数据字段说明 + +### 合同字段 + +| 字段名 | 类型 | 说明 | +|--------|------|------| +| id | string | 合同ID | +| storeId | string | 门店ID | +| storeName | string | 店名(冗余字段) | +| title | string | 标题 | +| category | string | 分类 | +| tenantName | string | 户名 | +| contractStartDate | long | 合同起始日期(时间戳,毫秒) | +| contractEndDate | long | 合同结束日期(时间戳,毫秒) | +| reminderDays | int | 提前提醒天数 | +| deposit | decimal | 押金 | +| nextPaymentDate | long | 下次应交时间(时间戳,毫秒,可能为null) | +| monthlyRent | decimal | 月租 | +| paymentAmount | decimal | 缴租金额 | +| paymentCycle | int | 交租周期(月) | +| remarks | string | 备注 | +| attachment | string | 附件 | +| createUser | string | 创建人ID | +| createUserName | string | 创建人姓名 | +| createTime | long | 创建时间(时间戳,毫秒) | +| updateUser | string | 更新人ID | +| updateUserName | string | 更新人姓名 | +| updateTime | long | 更新时间(时间戳,毫秒,可能为null) | +| isEffective | int | 是否有效(1-有效,0-无效) | + +### 月租明细字段 + +| 字段名 | 类型 | 说明 | +|--------|------|------| +| id | string | 明细ID | +| contractId | string | 合同ID | +| paymentMonth | long | 应缴月份(时间戳,毫秒) | +| dueDate | long | 应缴日期(时间戳,毫秒) | +| dueAmount | decimal | 应缴金额 | +| isPaid | int | 是否已缴(0-未缴,1-已缴) | +| actualPaymentDate | long | 实际缴费时间(时间戳,毫秒,可能为null) | +| actualPaymentAmount | decimal | 实际缴费金额(可能为null) | +| remarks | string | 备注 | +| createUser | string | 创建人ID | +| createUserName | string | 创建人姓名 | +| createTime | long | 创建时间(时间戳,毫秒) | +| updateUser | string | 更新人ID | +| updateUserName | string | 更新人姓名 | +| updateTime | long | 更新时间(时间戳,毫秒,可能为null) | +| isEffective | int | 是否有效(1-有效,0-无效) | + diff --git a/合同管理系统-逻辑梳理.md b/合同管理系统-逻辑梳理.md new file mode 100644 index 0000000..f263b46 --- /dev/null +++ b/合同管理系统-逻辑梳理.md @@ -0,0 +1,230 @@ +# 合同管理系统 - 逻辑梳理 + +## 📋 需求概述 + +建立一个合同管理系统,用于管理门店合同信息,并自动生成月租明细,用于统计每个月每个门店的合同支付明细以及成本费用。 + +## 🗄️ 数据库表设计 + +### 1. 合同表(lq_contract) + +**字段说明:** + +| 字段名 | 类型 | 说明 | 必填 | +|--------|------|------|------| +| F_Id | VARCHAR(50) | 主键ID | ✅ | +| F_StoreId | VARCHAR(50) | 门店ID(关联lq_mdxx.F_Id) | ✅ | +| F_StoreName | VARCHAR(200) | 店名(冗余字段,便于查询) | ✅ | +| F_Title | VARCHAR(200) | 标题 | ✅ | +| F_Category | VARCHAR(100) | 分类(string类型,自己填写) | ❌ | +| F_TenantName | VARCHAR(200) | 户名 | ❌ | +| F_ContractStartDate | DATETIME | 合同起始日期 | ✅ | +| F_ContractEndDate | DATETIME | 合同结束日期 | ✅ | +| F_ReminderDays | INT | 提前多少天提醒 | ❌(默认0) | +| F_Deposit | DECIMAL(18,2) | 押金 | ❌(默认0) | +| F_NextPaymentDate | DATETIME | 下次应交时间 | ❌ | +| F_MonthlyRent | DECIMAL(18,2) | 月租 | ✅ | +| F_PaymentAmount | DECIMAL(18,2) | 缴租金额(每次交租的金额,通常=月租×交租周期) | ✅ | +| F_PaymentCycle | INT | 交租周期(数字,表示几个月,如1、3、6等) | ✅ | +| F_Remarks | VARCHAR(1000) | 备注 | ❌ | +| F_Attachment | VARCHAR(500) | 附件(存储附件路径或JSON) | ❌ | +| F_CreateUser | VARCHAR(50) | 创建人ID | ✅ | +| F_CreateTime | DATETIME | 创建时间 | ✅ | +| F_UpdateUser | VARCHAR(50) | 更新人ID | ❌ | +| F_UpdateTime | DATETIME | 更新时间 | ❌ | +| F_IsEffective | INT | 是否有效(1-有效,0-无效) | ✅(默认1) | + +**索引:** +- 主键:F_Id +- 门店ID索引:F_StoreId +- 合同起始日期索引:F_ContractStartDate +- 合同结束日期索引:F_ContractEndDate +- 下次应交时间索引:F_NextPaymentDate + +### 2. 月租明细表(lq_contract_rent_detail) + +**字段说明:** + +| 字段名 | 类型 | 说明 | 必填 | +|--------|------|------|------| +| F_Id | VARCHAR(50) | 主键ID | ✅ | +| F_ContractId | VARCHAR(50) | 合同ID(关联lq_contract.F_Id) | ✅ | +| F_PaymentMonth | DATETIME | 应缴月份(表示哪个月份,格式:YYYY-MM-01) | ✅ | +| F_DueDate | DATETIME | 应缴日期(具体应缴日期) | ✅ | +| F_DueAmount | DECIMAL(18,2) | 应缴金额 | ✅ | +| F_IsPaid | INT | 是否已缴(0-未缴,1-已缴) | ✅(默认0) | +| F_ActualPaymentDate | DATETIME | 实际缴费时间 | ❌ | +| F_ActualPaymentAmount | DECIMAL(18,2) | 实际缴费金额 | ❌ | +| F_Remarks | VARCHAR(500) | 备注 | ❌ | +| F_CreateUser | VARCHAR(50) | 创建人ID | ✅ | +| F_CreateTime | DATETIME | 创建时间 | ✅ | +| F_UpdateUser | VARCHAR(50) | 更新人ID | ❌ | +| F_UpdateTime | DATETIME | 更新时间 | ❌ | +| F_IsEffective | INT | 是否有效(1-有效,0-无效) | ✅(默认1) | + +**索引:** +- 主键:F_Id +- 合同ID索引:F_ContractId +- 应缴月份索引:F_PaymentMonth +- 应缴日期索引:F_DueDate +- 是否已缴索引:F_IsPaid +- 联合索引:(F_ContractId, F_PaymentMonth) - 用于查询某个合同的某个月份明细 + +## 🔄 业务流程逻辑 + +### 1. 创建合同时自动生成月租明细 + +**逻辑:** +1. 用户录入合同信息 +2. 系统根据以下信息自动生成月租明细: + - **合同起始日期**(F_ContractStartDate) + - **合同结束日期**(F_ContractEndDate) + - **交租周期**(F_PaymentCycle,单位:月) + - **缴租金额**(F_PaymentAmount,每次交租的金额) + +**生成规则:** +- 从合同起始日期开始,每隔 `F_PaymentCycle` 个月生成一条明细 +- 应缴月份:每次交租对应的月份(格式:YYYY-MM-01) +- 应缴日期:应缴月份的第一天(或根据业务规则设定) +- 应缴金额:等于 `F_PaymentAmount` +- 生成到合同结束日期为止 + +**示例:** +- 合同起始:2025-01-01 +- 合同结束:2025-12-31 +- 交租周期:3个月 +- 缴租金额:3000元 + +生成的明细: +- 2025-01-01,应缴金额:3000元(1-3月) +- 2025-04-01,应缴金额:3000元(4-6月) +- 2025-07-01,应缴金额:3000元(7-9月) +- 2025-10-01,应缴金额:3000元(10-12月) + +### 2. 计算下次应交时间 + +**逻辑:** +- 根据当前时间、提前多少天提醒(F_ReminderDays),计算下次应交时间(F_NextPaymentDate) +- 查找该合同未缴费的明细中,应缴日期最早的一条 +- 下次应交时间 = 最早应缴日期 - 提前提醒天数 + +**示例:** +- 当前时间:2025-01-15 +- 提前提醒天数:7天 +- 最早未缴费明细的应缴日期:2025-02-01 +- 下次应交时间 = 2025-02-01 - 7天 = 2025-01-25 + +### 3. 删除合同时级联删除明细 + +**逻辑:** +- 删除合同时,需要同时删除该合同的所有月租明细 +- 使用事务确保数据一致性 +- 物理删除或逻辑删除(设置 F_IsEffective = 0) + +### 4. 更新合同时的处理 + +**逻辑:** +- 如果修改了以下字段,需要重新生成月租明细: + - 合同起始日期 + - 合同结束日期 + - 交租周期 + - 缴租金额 +- 删除旧的明细,重新生成新的明细 +- 如果只是修改其他字段(如备注、附件等),不需要重新生成明细 + +## 📊 统计功能 + +### 1. 按月统计每个门店的合同支付明细 + +**查询逻辑:** +- 根据月份筛选月租明细表 +- 按门店分组统计 +- 统计字段: + - 门店ID、门店名称 + - 应缴金额合计 + - 已缴金额合计 + - 未缴金额合计 + - 明细数量 + +### 2. 成本费用统计 + +**查询逻辑:** +- 统计已缴费的明细 +- 按月份、门店分组 +- 用于成本费用核算 + +## 🔧 功能方法 + +### 1. 自动生成月租明细方法 + +**方法名:** `GenerateRentDetailsAsync(string contractId)` + +**逻辑:** +1. 查询合同信息 +2. 计算需要生成的明细数量 +3. 从合同起始日期开始,每隔交租周期生成一条明细 +4. 批量插入明细记录 + +### 2. 计算下次应交时间方法(匿名方法) + +**方法名:** `CalculateNextPaymentDate(string contractId)` + +**逻辑:** +1. 查询合同信息(获取提前提醒天数) +2. 查询该合同未缴费的明细,按应缴日期升序排列 +3. 取最早的一条明细 +4. 计算:下次应交时间 = 最早应缴日期 - 提前提醒天数 +5. 更新合同的 F_NextPaymentDate 字段 + +### 3. 删除合同方法 + +**方法名:** `DeleteContractAsync(string contractId)` + +**逻辑:** +1. 开启事务 +2. 删除该合同的所有月租明细(逻辑删除或物理删除) +3. 删除合同(逻辑删除或物理删除) +4. 提交事务 + +## ⚠️ 注意事项 + +1. **交租周期说明:** + - 1 = 每月交租 + - 3 = 每3个月交租(季度) + - 6 = 每6个月交租(半年) + - 12 = 每年交租 + +2. **缴租金额说明:** + - 缴租金额 = 月租 × 交租周期 + - 例如:月租1000元,交租周期3个月,则缴租金额 = 3000元 + +3. **应缴日期计算:** + - 建议:应缴日期 = 应缴月份的第一天 + - 或者:根据合同起始日期推算(如合同起始是每月15日,则应缴日期也是每月15日) + +4. **数据一致性:** + - 删除合同时必须级联删除明细 + - 更新合同时如果影响明细,需要重新生成 + +5. **性能考虑:** + - 明细表数据量可能较大,需要建立合适的索引 + - 批量生成明细时使用批量插入 + +## 📝 待确认问题 + +1. **应缴日期的计算规则:** + - 是固定为每月1日,还是根据合同起始日期推算? + - 例如:合同起始是2025-01-15,交租周期3个月,第一次应缴日期是2025-01-15还是2025-01-01? + +2. **删除方式:** + - 物理删除还是逻辑删除? + - 建议使用逻辑删除(设置 F_IsEffective = 0),保留历史数据 + +3. **附件存储方式:** + - 存储文件路径? + - 还是存储JSON格式的附件信息(多个附件)? + +4. **缴租金额的计算:** + - 是否自动计算:缴租金额 = 月租 × 交租周期? + - 还是允许手动输入(可能有不规则的情况)? + diff --git a/库存使用审批流程-前端调用说明.md b/库存使用审批流程-前端调用说明.md new file mode 100644 index 0000000..385d7fd --- /dev/null +++ b/库存使用审批流程-前端调用说明.md @@ -0,0 +1,442 @@ +# 库存使用审批流程 - 前端调用说明 + +## 📋 目录 +- [业务流程概述](#业务流程概述) +- [接口列表](#接口列表) +- [完整流程示例](#完整流程示例) +- [接口详细说明](#接口详细说明) +- [注意事项](#注意事项) + +## 🔄 业务流程概述 + +库存使用审批流程包含以下步骤: + +1. **创建使用记录并提交审批** - 批量创建库存使用记录,同时创建申请记录并提交审批 +2. **查询申请记录** - 根据批次ID查询申请记录,查看审批状态 +3. **审批申请** - 审批人(财务老师或库管)审批申请(通过/不通过) +4. **标记已领取** - 审批通过后,标记申请已领取 +5. **查询批次信息** - 查询批次详细信息,包括使用记录和申请记录 +6. **门店领取统计** - 按月份统计每个门店的领取总金额 + +## 📡 接口列表 + +| 接口 | 方法 | 路径 | 说明 | +|------|------|------|------| +| 批量创建使用记录 | POST | `/api/Extend/LqInventoryUsage/BatchCreate` | 创建使用记录并提交审批(审批人ID和申请门店ID必填) | +| 查询申请记录 | GET | `/api/Extend/LqInventoryUsage/GetApplicationByBatchId` | 根据批次ID查询申请记录 | +| 审批申请 | POST | `/api/Extend/LqInventoryUsage/Approve/{applicationId}` | 审批申请(通过/不通过) | +| 标记已领取 | PUT | `/api/Extend/LqInventoryUsage/MarkReceived/{applicationId}` | 标记申请已领取 | +| 查询批次信息 | GET | `/api/Extend/LqInventoryUsage/GetBatchInfo` | 查询批次详细信息 | +| 门店领取统计 | POST | `/api/Extend/LqInventoryUsage/GetStoreReceiveStatistics` | 按月份统计门店领取总金额 | + +## 🚀 完整流程示例 + +### 步骤1:创建使用记录并提交审批 + +**接口:** `POST /api/Extend/LqInventoryUsage/BatchCreate` + +**请求示例:** +```javascript +const response = await request({ + url: '/api/Extend/LqInventoryUsage/BatchCreate', + method: 'POST', + data: { + approverId: '13110190690', // 审批人ID(财务老师或库管,必填) + applicationStoreId: '1649328471923847168', // 申请门店ID(必填) + remarks: '测试审批流程', // 备注(可选) + usageItems: [ + { + productId: '763978766132184325', // 产品ID(必填) + storeId: '1649328471923847168', // 门店ID(必填) + usageTime: '2025-01-09T10:00:00', // 使用时间(必填) + usageQuantity: 10, // 使用数量(必填,必须大于0) + relatedConsumeId: '' // 关联消耗ID(可选) + }, + { + productId: '763979169120912645', + storeId: '1649328471923847168', + usageTime: '2025-01-09T10:00:00', + usageQuantity: 20, + relatedConsumeId: '' + } + ] + } +}); + +// 响应示例 +// { +// "code": 200, +// "msg": "操作成功", +// "data": { +// "batchId": "768041985045955845", // 批次ID,后续查询需要使用 +// "successCount": 2, +// "failCount": 0, +// "successIds": ["768041987361211653", "768041987361211654"], +// "failItems": [] +// } +// } +``` + +**说明:** +- 系统会自动计算单价(从产品表获取)和合计金额(单价×数量) +- 创建使用记录后会自动创建申请记录,状态为"审批中" +- 保存返回的 `batchId`,后续查询需要使用 + +### 步骤2:查询申请记录(可选) + +**接口:** `GET /api/Extend/LqInventoryUsage/GetApplicationByBatchId` + +**请求示例:** +```javascript +const response = await request({ + url: '/api/Extend/LqInventoryUsage/GetApplicationByBatchId', + method: 'GET', + params: { + batchId: '768041985045955845' // 批次ID + } +}); + +// 响应示例 +// { +// "code": 200, +// "msg": "操作成功", +// "data": { +// "success": true, +// "data": { +// "id": "768041987952608518", // 申请ID +// "usageBatchId": "768041985045955845", +// "applicationUserId": "admin", +// "applicationUserName": "管理员", +// "applicationStoreId": "1649328471923847168", +// "applicationTime": 1765280681000, +// "approvalStatus": "审批中", // 审批状态:待审批/审批中/已通过/未通过 +// "isReceived": 0, // 是否已领取:0-未领取,1-已领取 +// "receiveTime": null, +// "receiveUser": null, +// "remarks": "测试审批流程", +// "approvalRecords": [] // 审批记录列表 +// } +// } +// } + +// 注意:如果是旧数据(没有申请记录),返回: +// { +// "code": 200, +// "data": { +// "success": false, +// "message": "该批次没有对应的申请记录", +// "data": null +// } +// } +``` + +### 步骤3:审批申请 + +**接口:** `POST /api/Extend/LqInventoryUsage/Approve/{applicationId}` + +**请求示例(通过):** +```javascript +const response = await request({ + url: '/api/Extend/LqInventoryUsage/Approve/768041987952608518', + method: 'POST', + params: { + result: '通过', // 审批结果:通过/不通过 + opinion: '同意申请' // 审批意见(可选) + } +}); + +// 响应示例 +// { +// "code": 200, +// "msg": "操作成功", +// "data": null +// } +``` + +**请求示例(不通过):** +```javascript +const response = await request({ + url: '/api/Extend/LqInventoryUsage/Approve/768041987952608518', + method: 'POST', + params: { + result: '不通过', + opinion: '库存不足,暂不批准' + } +}); +``` + +**说明:** +- 只有状态为"审批中"的申请才能进行审批操作 +- 审批通过后,状态变为"已通过" +- 审批不通过后,状态变为"未通过" + +### 步骤4:标记已领取(审批通过后) + +**接口:** `PUT /api/Extend/LqInventoryUsage/MarkReceived/{applicationId}` + +**请求示例:** +```javascript +const response = await request({ + url: '/api/Extend/LqInventoryUsage/MarkReceived/768041987952608518', + method: 'PUT' +}); + +// 响应示例 +// { +// "code": 200, +// "msg": "操作成功", +// "data": null +// } +``` + +**说明:** +- 只有审批状态为"已通过"的申请才能标记为已领取 +- 标记后会记录领取时间和领取人 + +### 步骤5:查询批次信息 + +**接口:** `GET /api/Extend/LqInventoryUsage/GetBatchInfo` + +**请求示例:** +```javascript +const response = await request({ + url: '/api/Extend/LqInventoryUsage/GetBatchInfo', + method: 'GET', + params: { + batchId: '768041985045955845' // 批次ID + } +}); + +// 响应示例 +// { +// "code": 200, +// "msg": "操作成功", +// "data": { +// "batchId": "768041985045955845", +// "createTime": 1765280681000, +// "createUser": "admin", +// "createUserName": "管理员", +// "totalCount": 2, +// "effectiveCount": 2, +// "ineffectiveCount": 0, +// "totalUsageQuantity": 30, +// "totalUsageAmount": 220.00, // 总使用金额 +// "usageRecords": [ +// { +// "id": "768041987361211653", +// "productId": "763978766132184325", +// "productName": "卸妆油", +// "productPrice": 10.00, +// "storeId": "1649328471923847168", +// "storeName": "绿纤总部", +// "usageTime": 1736388000000, +// "usageQuantity": 10, +// "usageTotalValue": 100.00 // 该条记录的总金额 +// }, +// // ... 更多记录 +// ], +// "applicationInfo": { // 申请记录信息(如果是旧数据,此字段为null) +// "id": "768041987952608518", +// "applicationUserId": "admin", +// "applicationUserName": "管理员", +// "applicationStoreId": "1649328471923847168", +// "applicationTime": 1765280681000, +// "approvalStatus": "已通过", +// "isReceived": 1, +// "receiveTime": 1765280756000, +// "receiveUser": "admin", +// "remarks": "测试审批流程" +// } +// } +// } +``` + +**说明:** +- 兼容旧数据:如果该批次没有申请记录(旧数据),`applicationInfo` 字段为 `null` +- 包含该批次的所有使用记录详情 +- 包含申请记录信息(如果有) + +### 步骤6:门店领取统计(可选) + +**接口:** `POST /api/Extend/LqInventoryUsage/GetStoreReceiveStatistics` + +**请求示例:** +```javascript +const response = await request({ + url: '/api/Extend/LqInventoryUsage/GetStoreReceiveStatistics', + method: 'POST', + data: { + year: 2025, // 统计年份(必填) + month: 11, // 统计月份(必填,1-12) + storeId: '' // 门店ID(可选,不传则统计所有门店) + } +}); + +// 响应示例 +// { +// "code": 200, +// "msg": "操作成功", +// "data": { +// "success": true, +// "data": [ +// { +// "storeId": "1649328471923847168", +// "storeName": "绿纤总部", +// "applicationCount": 5, // 申请数量 +// "totalAmount": 1500.00 // 领取总金额 +// }, +// // ... 更多门店 +// ], +// "total": 10, +// "message": "查询成功,共10个门店" +// } +// } +``` + +**说明:** +- 只统计审批通过且已领取的申请 +- 按门店分组统计 +- 按总金额降序排列 + +## 📝 接口详细说明 + +### 1. 批量创建使用记录 + +**必填参数:** +- `approverId`: 审批人ID(财务老师或库管) +- `applicationStoreId`: 申请门店ID +- `usageItems`: 使用记录列表(至少一条) + - `productId`: 产品ID + - `storeId`: 门店ID + - `usageTime`: 使用时间 + - `usageQuantity`: 使用数量(必须大于0) + +**可选参数:** +- `batchId`: 批次ID(不传则自动生成) +- `remarks`: 备注 + +**自动计算:** +- `unitPrice`: 单价(从产品表获取) +- `totalAmount`: 合计金额(单价×数量) + +### 2. 查询申请记录 + +**参数:** +- `batchId`: 批次ID(必填) + +**返回说明:** +- 如果存在申请记录:返回完整的申请信息 +- 如果不存在申请记录(旧数据):返回 `success=false`,`data=null` + +### 3. 审批申请 + +**参数:** +- `applicationId`: 申请ID(路径参数) +- `result`: 审批结果(查询参数,必填,值:通过/不通过) +- `opinion`: 审批意见(查询参数,可选) + +**状态要求:** +- 只有状态为"审批中"的申请才能进行审批操作 + +### 4. 标记已领取 + +**参数:** +- `applicationId`: 申请ID(路径参数) + +**状态要求:** +- 只有审批状态为"已通过"的申请才能标记为已领取 + +### 5. 查询批次信息 + +**参数:** +- `batchId`: 批次ID(必填) + +**兼容性:** +- 兼容旧数据:如果该批次没有申请记录,`applicationInfo` 字段为 `null` + +### 6. 门店领取统计 + +**参数:** +- `year`: 统计年份(必填,范围:2020-2100) +- `month`: 统计月份(必填,范围:1-12) +- `storeId`: 门店ID(可选) + +## ⚠️ 注意事项 + +1. **审批人ID和申请门店ID必填** + - 创建使用记录时,`approverId` 和 `applicationStoreId` 必须传入 + - 系统会自动创建申请记录并提交审批 + +2. **兼容旧数据** + - 查询申请记录时,如果该批次没有申请记录(旧数据),会返回 `success=false` + - 查询批次信息时,如果该批次没有申请记录,`applicationInfo` 字段为 `null` + - 前端需要兼容这两种情况 + +3. **审批流程** + - 申请创建后,状态为"审批中" + - 只有"审批中"状态的申请才能进行审批操作 + - 审批通过后,状态变为"已通过" + - 审批不通过后,状态变为"未通过" + +4. **标记已领取** + - 只有"已通过"状态的申请才能标记为已领取 + - 标记后会记录领取时间和领取人 + +5. **单价和合计金额** + - 系统会自动计算单价(从产品表获取)和合计金额(单价×数量) + - 前端无需手动计算 + +6. **URL编码** + - 审批接口的参数如果包含中文,需要进行URL编码 + - 例如:`result=通过` 需要编码为 `result=%E9%80%9A%E8%BF%87` + +## 🔍 状态说明 + +### 审批状态(approvalStatus) +- `待审批`: 申请已创建,等待提交审批 +- `审批中`: 申请已提交,等待审批 +- `已通过`: 审批通过 +- `未通过`: 审批不通过 +- `已退回`: 申请被退回 + +### 领取状态(isReceived) +- `0`: 未领取 +- `1`: 已领取 + +## 📊 数据流程 + +``` +创建使用记录 → 创建申请记录(审批中) → 审批申请 → 标记已领取 + ↓ ↓ ↓ ↓ + 批次ID 申请ID 审批记录 领取记录 +``` + +## 🎯 前端页面建议 + +1. **创建使用记录页面** + - 表单包含:产品选择、门店选择、使用时间、使用数量 + - 必须选择审批人(财务老师或库管) + - 必须选择申请门店 + - 提交后显示批次ID + +2. **申请列表页面** + - 显示所有申请记录 + - 显示审批状态、是否已领取 + - 支持筛选:审批状态、是否已领取、门店等 + +3. **审批页面** + - 显示申请详情 + - 显示使用记录列表 + - 审批操作:通过/不通过,可填写审批意见 + +4. **批次详情页面** + - 显示批次基本信息 + - 显示使用记录列表(包含单价和合计金额) + - 显示申请记录信息(如果有) + - 兼容旧数据(没有申请记录的情况) + +5. **统计页面** + - 选择年份和月份 + - 显示每个门店的领取统计 + - 显示总金额、申请数量等 + -- libgit2 0.21.4