From 7855bf0414f0cc3bc486b44ed0f9a2ec86a5c6f9 Mon Sep 17 00:00:00 2001
From: “wangming” <“wangming@antissoft.com”>
Date: Thu, 23 Oct 2025 20:38:33 +0800
Subject: [PATCH] feat: 优化品项统计查询性能并新增营销活动统计功能
---
netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqPackageInfo/ActivityStatisticsInput.cs | 32 ++++++++++++++++++++++++++++++++
netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqPackageInfo/ActivityStatisticsOutput.cs | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
netcore/src/Modularity/Extend/NCC.Extend/LqPackageInfoService.cs | 158 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
netcore/src/Modularity/Extend/NCC.Extend/LqReportService.cs | 197 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------------------------
4 files changed, 379 insertions(+), 63 deletions(-)
create mode 100644 netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqPackageInfo/ActivityStatisticsInput.cs
create mode 100644 netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqPackageInfo/ActivityStatisticsOutput.cs
diff --git a/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqPackageInfo/ActivityStatisticsInput.cs b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqPackageInfo/ActivityStatisticsInput.cs
new file mode 100644
index 0000000..be246de
--- /dev/null
+++ b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqPackageInfo/ActivityStatisticsInput.cs
@@ -0,0 +1,32 @@
+using System;
+using System.ComponentModel.DataAnnotations;
+
+namespace NCC.Extend.Entitys.Dto.LqPackageInfo
+{
+ ///
+ /// 营销活动统计查询输入参数
+ ///
+ public class ActivityStatisticsInput
+ {
+ ///
+ /// 营销活动ID
+ ///
+ [Required(ErrorMessage = "营销活动ID不能为空")]
+ public string ActivityId { get; set; }
+
+ ///
+ /// 开始时间(可选,默认为活动开始时间)
+ ///
+ 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/LqPackageInfo/ActivityStatisticsOutput.cs b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqPackageInfo/ActivityStatisticsOutput.cs
new file mode 100644
index 0000000..2cc73dc
--- /dev/null
+++ b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqPackageInfo/ActivityStatisticsOutput.cs
@@ -0,0 +1,55 @@
+using System;
+
+namespace NCC.Extend.Entitys.Dto.LqPackageInfo
+{
+ ///
+ /// 营销活动统计输出结果
+ ///
+ public class ActivityStatisticsOutput
+ {
+ ///
+ /// 营销活动ID
+ ///
+ public string ActivityId { get; set; }
+
+ ///
+ /// 营销活动名称
+ ///
+ public string ActivityName { get; set; }
+
+ ///
+ /// 开单数量
+ ///
+ public int BillingCount { get; set; }
+
+ ///
+ /// 开单金额
+ ///
+ public decimal BillingAmount { get; set; }
+
+ ///
+ /// 退卡数量
+ ///
+ public int RefundCount { get; set; }
+
+ ///
+ /// 退卡金额
+ ///
+ public decimal RefundAmount { get; set; }
+
+ ///
+ /// 净开单数量(开单数量 - 退卡数量)
+ ///
+ public int NetBillingCount { get; set; }
+
+ ///
+ /// 净开单金额(开单金额 - 退卡金额)
+ ///
+ public decimal NetBillingAmount { get; set; }
+
+ ///
+ /// 退卡率(退卡数量 / 开单数量)
+ ///
+ public decimal RefundRate { get; set; }
+ }
+}
diff --git a/netcore/src/Modularity/Extend/NCC.Extend/LqPackageInfoService.cs b/netcore/src/Modularity/Extend/NCC.Extend/LqPackageInfoService.cs
index 709f452..2b4aff6 100644
--- a/netcore/src/Modularity/Extend/NCC.Extend/LqPackageInfoService.cs
+++ b/netcore/src/Modularity/Extend/NCC.Extend/LqPackageInfoService.cs
@@ -551,5 +551,163 @@ namespace NCC.Extend.LqPackageInfo
return output;
}
#endregion
+
+ #region 营销活动统计
+ ///
+ /// 获取营销活动统计数据
+ ///
+ ///
+ /// 统计指定营销活动的开单、退卡相关数据
+ /// 包括:开单数量、开单金额、退卡数量、退卡金额、净开单数量、净开单金额、退卡率
+ ///
+ /// 示例请求:
+ /// ```json
+ /// {
+ /// "activityId": "营销活动ID",
+ /// "startTime": "2025-10-01",
+ /// "endTime": "2025-10-31",
+ /// "storeIds": ["门店ID1", "门店ID2"]
+ /// }
+ /// ```
+ ///
+ /// 参数说明:
+ /// - activityId: 营销活动ID(必填)
+ /// - startTime: 开始时间(可选,默认为活动开始时间)
+ /// - endTime: 结束时间(可选,默认为活动结束时间)
+ /// - storeIds: 门店ID列表(可选)
+ ///
+ /// 返回字段说明:
+ /// - ActivityId: 营销活动ID
+ /// - ActivityName: 营销活动名称
+ /// - BillingCount: 开单数量
+ /// - BillingAmount: 开单金额
+ /// - RefundCount: 退卡数量
+ /// - RefundAmount: 退卡金额
+ /// - NetBillingCount: 净开单数量(开单数量 - 退卡数量)
+ /// - NetBillingAmount: 净开单金额(开单金额 - 退卡金额)
+ /// - RefundRate: 退卡率(退卡数量 / 开单数量)
+ ///
+ /// 查询参数
+ /// 营销活动统计数据
+ /// 成功返回统计数据
+ /// 参数错误
+ /// 服务器错误
+ [HttpPost("get-activity-statistics")]
+ public async Task