From 68b8deb5c5197390118dff40979c2a8c8bae463c Mon Sep 17 00:00:00 2001
From: “wangming” <“wangming@antissoft.com”>
Date: Thu, 23 Oct 2025 18:15:24 +0800
Subject: [PATCH] 123213
---
netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqKdKdjlb/HealthCoachStatisticsOutput.cs | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqKdKdjlb/HealthCoachStatisticsQueryInput.cs | 36 ++++++++++++++++++++++++++++++++++++
netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqReport/BusinessStatisticsInput.cs | 25 +++++++++++++++++++++++++
netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqReport/BusinessStatisticsOutput.cs | 38 ++++++++++++++++++++++++++++++++++++++
netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqReport/CustomerTypeStatisticsInput.cs | 25 +++++++++++++++++++++++++
netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqReport/CustomerTypeStatisticsOutput.cs | 43 +++++++++++++++++++++++++++++++++++++++++++
netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqReport/ItemStatisticsInput.cs | 25 +++++++++++++++++++++++++
netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqReport/ItemStatisticsOutput.cs | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++
netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqReport/StorePerformanceComparisonInput.cs | 25 +++++++++++++++++++++++++
netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqReport/StorePerformanceComparisonOutput.cs | 43 +++++++++++++++++++++++++++++++++++++++++++
netcore/src/Modularity/Extend/NCC.Extend/LqKdKdjlbService.cs | 225 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
netcore/src/Modularity/Extend/NCC.Extend/LqReportService.cs | 526 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
netcore/src/Modularity/Extend/NCC.Extend/LqTkjlbService.cs | 108 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------------
13 files changed, 1218 insertions(+), 37 deletions(-)
create mode 100644 netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqKdKdjlb/HealthCoachStatisticsOutput.cs
create mode 100644 netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqKdKdjlb/HealthCoachStatisticsQueryInput.cs
create mode 100644 netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqReport/BusinessStatisticsInput.cs
create mode 100644 netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqReport/BusinessStatisticsOutput.cs
create mode 100644 netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqReport/CustomerTypeStatisticsInput.cs
create mode 100644 netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqReport/CustomerTypeStatisticsOutput.cs
create mode 100644 netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqReport/ItemStatisticsInput.cs
create mode 100644 netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqReport/ItemStatisticsOutput.cs
create mode 100644 netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqReport/StorePerformanceComparisonInput.cs
create mode 100644 netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqReport/StorePerformanceComparisonOutput.cs
diff --git a/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqKdKdjlb/HealthCoachStatisticsOutput.cs b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqKdKdjlb/HealthCoachStatisticsOutput.cs
new file mode 100644
index 0000000..43973dd
--- /dev/null
+++ b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqKdKdjlb/HealthCoachStatisticsOutput.cs
@@ -0,0 +1,83 @@
+namespace NCC.Extend.Entitys.Dto.LqKdKdjlb
+{
+ ///
+ /// 健康师统计输出
+ ///
+ public class HealthCoachStatisticsOutput
+ {
+ ///
+ /// 健康师ID
+ ///
+ public string employeeId { get; set; }
+
+ ///
+ /// 健康师姓名
+ ///
+ public string employeeName { get; set; }
+
+ ///
+ /// 门店ID
+ ///
+ public string storeId { get; set; }
+
+ ///
+ /// 门店名称
+ ///
+ public string storeName { get; set; }
+
+ ///
+ /// 事业部ID
+ ///
+ public string departmentId { get; set; }
+
+ ///
+ /// 事业部名称
+ ///
+ public string departmentName { get; set; }
+
+ ///
+ /// 邀约人数 - 统计该健康师在指定时间周期内邀约的客户数量(按客户去重)
+ ///
+ public int inviteCount { get; set; }
+
+ ///
+ /// 预约人数 - 统计该健康师在指定时间周期内预约的客户数量(按客户去重,无论预约状态)
+ ///
+ public int appointmentCount { get; set; }
+
+ ///
+ /// 到店人数 - 统计该健康师在指定时间周期内已确认到店的客户数量(按客户去重,仅统计状态为'已确认'的预约)
+ ///
+ public int visitCount { get; set; }
+
+ ///
+ /// 开单人数 - 统计该健康师在指定时间周期内开单的客户数量(按开单记录去重)
+ ///
+ public int billingCount { get; set; }
+
+ ///
+ /// 开单金额 - 统计该健康师在指定时间周期内的开单业绩总金额
+ ///
+ public decimal billingAmount { get; set; }
+
+ ///
+ /// 消耗金额 - 统计该健康师在指定时间周期内的消耗业绩总金额
+ ///
+ public decimal consumeAmount { get; set; }
+
+ ///
+ /// 人头 - 统计该健康师在指定时间周期内服务的唯一客户数量(按客户去重)
+ ///
+ public int headCount { get; set; }
+
+ ///
+ /// 人次 - 统计该健康师在指定时间周期内服务的客户人次(按客户+日期去重,同一客户不同天算多次)
+ ///
+ public int personCount { get; set; }
+
+ ///
+ /// 消耗项目数 - 统计该健康师在指定时间周期内消耗的项目总次数
+ ///
+ public int projectCount { get; set; }
+ }
+}
diff --git a/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqKdKdjlb/HealthCoachStatisticsQueryInput.cs b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqKdKdjlb/HealthCoachStatisticsQueryInput.cs
new file mode 100644
index 0000000..4dc317d
--- /dev/null
+++ b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqKdKdjlb/HealthCoachStatisticsQueryInput.cs
@@ -0,0 +1,36 @@
+using NCC.Common.Filter;
+using System;
+
+namespace NCC.Extend.Entitys.Dto.LqKdKdjlb
+{
+ ///
+ /// 健康师统计查询输入
+ ///
+ public class HealthCoachStatisticsQueryInput : PageInputBase
+ {
+ ///
+ /// 开始时间
+ ///
+ public DateTime? StartTime { get; set; }
+
+ ///
+ /// 结束时间
+ ///
+ public DateTime? EndTime { get; set; }
+
+ ///
+ /// 事业部ID
+ ///
+ public string DepartmentId { get; set; }
+
+ ///
+ /// 门店ID
+ ///
+ public string StoreId { get; set; }
+
+ ///
+ /// 健康师姓名
+ ///
+ public string EmployeeName { get; set; }
+ }
+}
diff --git a/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqReport/BusinessStatisticsInput.cs b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqReport/BusinessStatisticsInput.cs
new file mode 100644
index 0000000..76d0514
--- /dev/null
+++ b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqReport/BusinessStatisticsInput.cs
@@ -0,0 +1,25 @@
+using System;
+
+namespace NCC.Extend.Entitys.Dto.LqReport
+{
+ ///
+ /// 业务统计查询输入
+ ///
+ public class BusinessStatisticsInput
+ {
+ ///
+ /// 开始时间
+ ///
+ public DateTime? StartTime { get; set; }
+
+ ///
+ /// 结束时间
+ ///
+ public DateTime? EndTime { get; set; }
+
+ ///
+ /// 门店ID列表
+ ///
+ public string[] StoreIds { get; set; }
+ }
+}
diff --git a/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqReport/BusinessStatisticsOutput.cs b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqReport/BusinessStatisticsOutput.cs
new file mode 100644
index 0000000..5f59484
--- /dev/null
+++ b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqReport/BusinessStatisticsOutput.cs
@@ -0,0 +1,38 @@
+namespace NCC.Extend.Entitys.Dto.LqReport
+{
+ ///
+ /// 业务统计输出
+ ///
+ public class BusinessStatisticsOutput
+ {
+ ///
+ /// 开单总金额
+ ///
+ public decimal TotalBillingAmount { get; set; }
+
+ ///
+ /// 耗卡总金额
+ ///
+ public decimal TotalConsumeAmount { get; set; }
+
+ ///
+ /// 退卡总金额
+ ///
+ public decimal TotalRefundAmount { get; set; }
+
+ ///
+ /// 开单人数
+ ///
+ public int BillingCount { get; set; }
+
+ ///
+ /// 耗卡人数
+ ///
+ public int ConsumeCount { get; set; }
+
+ ///
+ /// 退卡人数
+ ///
+ public int RefundCount { get; set; }
+ }
+}
diff --git a/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqReport/CustomerTypeStatisticsInput.cs b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqReport/CustomerTypeStatisticsInput.cs
new file mode 100644
index 0000000..3dd09b9
--- /dev/null
+++ b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqReport/CustomerTypeStatisticsInput.cs
@@ -0,0 +1,25 @@
+using System;
+
+namespace NCC.Extend.Entitys.Dto.LqReport
+{
+ ///
+ /// 客户类型统计查询输入
+ ///
+ public class CustomerTypeStatisticsInput
+ {
+ ///
+ /// 开始时间
+ ///
+ public DateTime? StartTime { get; set; }
+
+ ///
+ /// 结束时间
+ ///
+ public DateTime? EndTime { get; set; }
+
+ ///
+ /// 门店ID列表
+ ///
+ public string[] StoreIds { get; set; }
+ }
+}
diff --git a/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqReport/CustomerTypeStatisticsOutput.cs b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqReport/CustomerTypeStatisticsOutput.cs
new file mode 100644
index 0000000..8d47268
--- /dev/null
+++ b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqReport/CustomerTypeStatisticsOutput.cs
@@ -0,0 +1,43 @@
+namespace NCC.Extend.Entitys.Dto.LqReport
+{
+ ///
+ /// 客户类型统计输出
+ ///
+ public class CustomerTypeStatisticsOutput
+ {
+ ///
+ /// 线索客户数量
+ ///
+ public int LeadCount { get; set; }
+
+ ///
+ /// 新客数量
+ ///
+ public int NewCustomerCount { get; set; }
+
+ ///
+ /// 散客数量
+ ///
+ public int CasualCustomerCount { get; set; }
+
+ ///
+ /// 会员数量
+ ///
+ public int MemberCount { get; set; }
+
+ ///
+ /// 拓客总人数
+ ///
+ public int TotalInviteCount { get; set; }
+
+ ///
+ /// 消耗人数(有消耗金额的)
+ ///
+ public int ConsumeCount { get; set; }
+
+ ///
+ /// 转化率(消耗人数/拓客人数)
+ ///
+ public decimal ConversionRate { get; set; }
+ }
+}
diff --git a/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqReport/ItemStatisticsInput.cs b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqReport/ItemStatisticsInput.cs
new file mode 100644
index 0000000..8321f0a
--- /dev/null
+++ b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqReport/ItemStatisticsInput.cs
@@ -0,0 +1,25 @@
+using System;
+
+namespace NCC.Extend.Entitys.Dto.LqReport
+{
+ ///
+ /// 品项统计查询输入
+ ///
+ public class ItemStatisticsInput
+ {
+ ///
+ /// 开始时间
+ ///
+ public DateTime? StartTime { get; set; }
+
+ ///
+ /// 结束时间
+ ///
+ public DateTime? EndTime { get; set; }
+
+ ///
+ /// 门店ID列表
+ ///
+ public string[] StoreIds { get; set; }
+ }
+}
diff --git a/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqReport/ItemStatisticsOutput.cs b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqReport/ItemStatisticsOutput.cs
new file mode 100644
index 0000000..f097db8
--- /dev/null
+++ b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqReport/ItemStatisticsOutput.cs
@@ -0,0 +1,53 @@
+namespace NCC.Extend.Entitys.Dto.LqReport
+{
+ ///
+ /// 品项统计输出
+ ///
+ public class ItemStatisticsOutput
+ {
+ ///
+ /// 品项ID
+ ///
+ public string ItemId { get; set; }
+
+ ///
+ /// 品项名称
+ ///
+ public string ItemName { get; set; }
+
+ ///
+ /// 品项编号
+ ///
+ public string ItemNumber { get; set; }
+
+ ///
+ /// 开单数量
+ ///
+ public int BillingCount { get; set; }
+
+ ///
+ /// 开单金额
+ ///
+ public decimal BillingAmount { get; set; }
+
+ ///
+ /// 消耗数量
+ ///
+ public int ConsumeCount { get; set; }
+
+ ///
+ /// 消耗金额
+ ///
+ public decimal ConsumeAmount { get; set; }
+
+ ///
+ /// 退卡数量
+ ///
+ public int RefundCount { get; set; }
+
+ ///
+ /// 退卡金额
+ ///
+ public decimal RefundAmount { get; set; }
+ }
+}
diff --git a/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqReport/StorePerformanceComparisonInput.cs b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqReport/StorePerformanceComparisonInput.cs
new file mode 100644
index 0000000..da2934e
--- /dev/null
+++ b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqReport/StorePerformanceComparisonInput.cs
@@ -0,0 +1,25 @@
+using System;
+
+namespace NCC.Extend.Entitys.Dto.LqReport
+{
+ ///
+ /// 门店业绩对比统计查询输入
+ ///
+ public class StorePerformanceComparisonInput
+ {
+ ///
+ /// 开始时间
+ ///
+ public DateTime? StartTime { get; set; }
+
+ ///
+ /// 结束时间
+ ///
+ public DateTime? EndTime { get; set; }
+
+ ///
+ /// 门店ID列表
+ ///
+ public string[] StoreIds { get; set; }
+ }
+}
diff --git a/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqReport/StorePerformanceComparisonOutput.cs b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqReport/StorePerformanceComparisonOutput.cs
new file mode 100644
index 0000000..c6c17bb
--- /dev/null
+++ b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqReport/StorePerformanceComparisonOutput.cs
@@ -0,0 +1,43 @@
+namespace NCC.Extend.Entitys.Dto.LqReport
+{
+ ///
+ /// 门店业绩对比统计输出
+ ///
+ public class StorePerformanceComparisonOutput
+ {
+ ///
+ /// 门店ID
+ ///
+ public string StoreId { get; set; }
+
+ ///
+ /// 门店名称
+ ///
+ public string StoreName { get; set; }
+
+ ///
+ /// 目标业绩
+ ///
+ public decimal TargetPerformance { get; set; }
+
+ ///
+ /// 实际开单业绩
+ ///
+ public decimal ActualPerformance { get; set; }
+
+ ///
+ /// 完成率(实际业绩/目标业绩)
+ ///
+ public decimal CompletionRate { get; set; }
+
+ ///
+ /// 差额(实际业绩-目标业绩)
+ ///
+ public decimal Difference { get; set; }
+
+ ///
+ /// 是否达标(实际业绩 >= 目标业绩)
+ ///
+ public bool IsTargetAchieved { get; set; }
+ }
+}
diff --git a/netcore/src/Modularity/Extend/NCC.Extend/LqKdKdjlbService.cs b/netcore/src/Modularity/Extend/NCC.Extend/LqKdKdjlbService.cs
index 342ec4d..7b141a3 100644
--- a/netcore/src/Modularity/Extend/NCC.Extend/LqKdKdjlbService.cs
+++ b/netcore/src/Modularity/Extend/NCC.Extend/LqKdKdjlbService.cs
@@ -2728,5 +2728,230 @@ namespace NCC.Extend.LqKdKdjlb
}
}
#endregion
+
+ #region 门店整体统计表
+ ///
+ /// 门店整体统计表
+ ///
+ ///
+ /// 统计每个健康师在指定时间周期内的各项数据指标
+ /// 包括:邀约人数、预约人数、到店人数、开单人数、开单金额、消耗金额、人头、人次、消耗项目数
+ ///
+ /// 示例请求:
+ /// ```json
+ /// {
+ /// "startTime": "2025-10-01",
+ /// "endTime": "2025-10-31",
+ /// "departmentId": "部门ID",
+ /// "storeId": "门店ID",
+ /// "employeeName": "健康师姓名"
+ /// }
+ /// ```
+ ///
+ /// 参数说明:
+ /// - startTime: 开始时间(可选,默认为当月1号)
+ /// - endTime: 结束时间(可选,默认为当前时间)
+ /// - departmentId: 事业部ID(可选)
+ /// - storeId: 门店ID(可选)
+ /// - employeeName: 健康师姓名(可选)
+ ///
+ /// 返回字段说明:
+ /// - EmployeeId: 健康师ID
+ /// - EmployeeName: 健康师姓名
+ /// - StoreId: 门店ID
+ /// - StoreName: 门店名称
+ /// - DepartmentId: 事业部ID
+ /// - DepartmentName: 事业部名称
+ /// - InviteCount: 邀约人数(按客户去重)
+ /// - AppointmentCount: 预约人数(按客户去重,无论预约状态)
+ /// - VisitCount: 到店人数(按客户去重,仅统计状态为'已确认'的预约)
+ /// - BillingCount: 开单人数(按开单记录去重)
+ /// - BillingAmount: 开单金额(开单业绩总金额)
+ /// - ConsumeAmount: 消耗金额(消耗业绩总金额)
+ /// - HeadCount: 人头(按客户去重)
+ /// - PersonCount: 人次(按客户+日期去重,同一客户不同天算多次)
+ /// - ProjectCount: 消耗项目数(项目总次数)
+ ///
+ /// 查询参数
+ /// 健康师统计数据列表
+ /// 成功返回统计数据
+ /// 参数错误
+ /// 服务器错误
+ [HttpGet("get-health-coach-statistics")]
+ public async Task GetHealthCoachStatistics([FromQuery] HealthCoachStatisticsQueryInput input)
+ {
+ try
+ {
+ // 设置默认时间范围(如果未提供,默认为当月)
+ var startTime = input.StartTime ?? new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
+ var endTime = input.EndTime ?? DateTime.Now;
+
+ // 构建SQL查询
+ var sql = $@"
+ SELECT
+ u.F_Id as EmployeeId,
+ u.F_REALNAME as EmployeeName,
+ u.F_MDID as StoreId,
+ md.dm as StoreName,
+ md.syb as DepartmentId,
+ dept.F_FullName as DepartmentName,
+
+ -- 邀约人数
+ COALESCE(invite_stats.InviteCount, 0) as InviteCount,
+
+ -- 预约人数(无论状态)
+ COALESCE(appointment_stats.AppointmentCount, 0) as AppointmentCount,
+
+ -- 到店人数(已确认状态)
+ COALESCE(visit_stats.VisitCount, 0) as VisitCount,
+
+ -- 开单人数和金额
+ COALESCE(billing_stats.BillingCount, 0) as BillingCount,
+ COALESCE(billing_stats.BillingAmount, 0) as BillingAmount,
+
+ -- 消耗相关统计
+ COALESCE(consume_stats.ConsumeAmount, 0) as ConsumeAmount,
+ COALESCE(consume_stats.HeadCount, 0) as HeadCount,
+ COALESCE(consume_stats.PersonCount, 0) as PersonCount,
+ COALESCE(consume_stats.ProjectCount, 0) as ProjectCount
+
+ FROM BASE_USER u
+ LEFT JOIN lq_mdxx md ON u.F_MDID = md.F_Id
+ LEFT JOIN base_organize dept ON md.syb = dept.F_Id
+
+ -- 邀约统计子查询
+ LEFT JOIN (
+ SELECT
+ yyr as EmployeeId,
+ COUNT(DISTINCT yykh) as InviteCount
+ FROM lq_yaoyjl
+ WHERE yyr IS NOT NULL
+ AND F_CreateTime >= @startTime
+ AND F_CreateTime <= @endTime
+ GROUP BY yyr
+ ) invite_stats ON u.F_Id = invite_stats.EmployeeId
+
+ -- 预约统计子查询
+ LEFT JOIN (
+ SELECT
+ yyr as EmployeeId,
+ COUNT(DISTINCT gk) as AppointmentCount
+ FROM lq_yyjl
+ WHERE yyr IS NOT NULL
+ AND F_CreateTime >= @startTime
+ AND F_CreateTime <= @endTime
+ GROUP BY yyr
+ ) appointment_stats ON u.F_Id = appointment_stats.EmployeeId
+
+ -- 到店统计子查询
+ LEFT JOIN (
+ SELECT
+ yyr as EmployeeId,
+ COUNT(DISTINCT gk) as VisitCount
+ FROM lq_yyjl
+ WHERE yyr IS NOT NULL
+ AND F_Status = '已确认'
+ AND F_CreateTime >= @startTime
+ AND F_CreateTime <= @endTime
+ GROUP BY yyr
+ ) visit_stats ON u.F_Id = visit_stats.EmployeeId
+
+ -- 开单统计子查询
+ LEFT JOIN (
+ SELECT
+ jkszh as EmployeeId,
+ COUNT(DISTINCT glkdbh) as BillingCount,
+ SUM(CAST(jksyj AS DECIMAL(18,2))) as BillingAmount
+ FROM lq_kd_jksyj
+ WHERE jkszh IS NOT NULL
+ AND F_IsEffective = 1
+ AND yjsj >= @startTime
+ AND yjsj <= @endTime
+ GROUP BY jkszh
+ ) billing_stats ON u.F_Id = billing_stats.EmployeeId
+
+ -- 消耗统计子查询
+ LEFT JOIN (
+ SELECT
+ jksyj.jkszh as EmployeeId,
+ SUM(jksyj.jksyj) as ConsumeAmount,
+ COUNT(DISTINCT hyhk.hy) as HeadCount,
+ COUNT(DISTINCT CONCAT(jksyj.jkszh, '_', hyhk.hy, '_', DATE(hyhk.hksj))) as PersonCount,
+ SUM(jksyj.F_kdpxNumber) as ProjectCount
+ FROM lq_xh_jksyj jksyj
+ INNER JOIN lq_xh_hyhk hyhk ON jksyj.glkdbh = hyhk.F_Id
+ WHERE jksyj.jkszh IS NOT NULL
+ AND jksyj.F_IsEffective = 1
+ AND hyhk.F_IsEffective = 1
+ AND hyhk.hksj >= @startTime
+ AND hyhk.hksj <= @endTime
+ GROUP BY jksyj.jkszh
+ ) consume_stats ON u.F_Id = consume_stats.EmployeeId
+
+ WHERE u.F_GW = '健康师'
+ ";
+
+ // 添加条件过滤
+ var conditions = new List();
+ var parameters = new List
+ {
+ new SugarParameter("@startTime", startTime),
+ new SugarParameter("@endTime", endTime)
+ };
+
+ if (!string.IsNullOrEmpty(input.DepartmentId))
+ {
+ conditions.Add("md.syb = @departmentId");
+ parameters.Add(new SugarParameter("@departmentId", input.DepartmentId));
+ }
+
+ if (!string.IsNullOrEmpty(input.StoreId))
+ {
+ conditions.Add("u.F_MDID = @storeId");
+ parameters.Add(new SugarParameter("@storeId", input.StoreId));
+ }
+
+ if (!string.IsNullOrEmpty(input.EmployeeName))
+ {
+ conditions.Add("u.F_REALNAME LIKE @employeeName");
+ parameters.Add(new SugarParameter("@employeeName", $"%{input.EmployeeName}%"));
+ }
+
+ if (conditions.Any())
+ {
+ sql += " AND " + string.Join(" AND ", conditions);
+ }
+
+ sql += " ORDER BY u.F_REALNAME";
+
+ // 执行查询
+ var allData = await _db.Ado.SqlQueryAsync(sql, parameters);
+
+ // 手动分页
+ var totalCount = allData.Count;
+ var pagedData = allData
+ .Skip((input.currentPage - 1) * input.pageSize)
+ .Take(input.pageSize)
+ .ToList();
+
+ // 直接返回分页结果
+ return new
+ {
+ list = pagedData,
+ pagination = new
+ {
+ pageIndex = input.currentPage,
+ pageSize = input.pageSize,
+ totalCount = totalCount
+ }
+ };
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "获取健康师统计数据失败");
+ throw NCCException.Oh($"获取健康师统计数据失败:{ex.Message}");
+ }
+ }
+ #endregion
}
}
diff --git a/netcore/src/Modularity/Extend/NCC.Extend/LqReportService.cs b/netcore/src/Modularity/Extend/NCC.Extend/LqReportService.cs
index 84375fd..99fca07 100644
--- a/netcore/src/Modularity/Extend/NCC.Extend/LqReportService.cs
+++ b/netcore/src/Modularity/Extend/NCC.Extend/LqReportService.cs
@@ -25,6 +25,8 @@ using NCC.Extend.Entitys.lq_jinsanjiao_user;
using NCC.Extend.Entitys.lq_kd_kdjlb;
using NCC.Extend.Entitys.lq_xh_hyhk;
using NCC.Extend.Entitys.lq_khxx;
+using NCC.Extend.Entitys.Dto.LqReport;
+using NCC.Extend.Entitys.Enum;
using SqlSugar;
namespace NCC.Extend
@@ -40,6 +42,12 @@ namespace NCC.Extend
private readonly IUserManager _userManager;
private readonly ILogger _logger;
+ ///
+ /// 构造函数
+ ///
+ /// 数据库客户端
+ /// 用户管理器
+ /// 日志记录器
public LqReportService(ISqlSugarClient db, IUserManager userManager, ILogger logger)
{
_db = db;
@@ -47,6 +55,8 @@ namespace NCC.Extend
_logger = logger;
}
+
+
#region 门店业绩报表
///
@@ -681,6 +691,522 @@ namespace NCC.Extend
}
}
+ ///
+ /// 获取业务统计数据
+ ///
+ ///
+ /// 统计指定时间范围内的开单、耗卡、退卡相关数据
+ /// 包括:开单总金额、耗卡总金额、退卡总金额、开单人数、耗卡人数、退卡人数
+ ///
+ /// 示例请求:
+ /// ```json
+ /// {
+ /// "startTime": "2025-10-01",
+ /// "endTime": "2025-10-31",
+ /// "storeIds": ["门店ID1", "门店ID2"]
+ /// }
+ /// ```
+ ///
+ /// 参数说明:
+ /// - startTime: 开始时间(可选,默认为当月1号)
+ /// - endTime: 结束时间(可选,默认为当前时间)
+ /// - storeIds: 门店ID列表(可选)
+ ///
+ /// 返回字段说明:
+ /// - TotalBillingAmount: 开单总金额
+ /// - TotalConsumeAmount: 耗卡总金额
+ /// - TotalRefundAmount: 退卡总金额
+ /// - BillingCount: 开单人数(按客户去重)
+ /// - ConsumeCount: 耗卡人数(按客户去重)
+ /// - RefundCount: 退卡人数(按客户去重)
+ ///
+ /// 查询参数
+ /// 业务统计数据
+ /// 成功返回统计数据
+ /// 参数错误
+ /// 服务器错误
+ [HttpPost("get-business-statistics")]
+ public async Task