From 1f96867ec452904a46d535433d9012f382b5c995 Mon Sep 17 00:00:00 2001
From: “wangming” <“wangming@antissoft.com”>
Date: Tue, 28 Oct 2025 16:54:45 +0800
Subject: [PATCH] feat: 新增消耗目标业绩和完成率统计
---
netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqReport/BusinessStatisticsOutput.cs | 10 ++++++++++
netcore/src/Modularity/Extend/NCC.Extend/LqReportService.cs | 27 ++++++++++++++++++++++++++-
2 files changed, 36 insertions(+), 1 deletion(-)
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
index 5f59484..42f175c 100644
--- a/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqReport/BusinessStatisticsOutput.cs
+++ b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqReport/BusinessStatisticsOutput.cs
@@ -34,5 +34,15 @@ namespace NCC.Extend.Entitys.Dto.LqReport
/// 退卡人数
///
public int RefundCount { get; set; }
+
+ ///
+ /// 消耗目标业绩(所有门店xhyj字段的总和)
+ ///
+ public decimal TargetConsumeAmount { get; set; }
+
+ ///
+ /// 消耗完成率(耗卡总金额 / 消耗目标业绩 * 100)
+ ///
+ public decimal ConsumeCompletionRate { get; set; }
}
}
diff --git a/netcore/src/Modularity/Extend/NCC.Extend/LqReportService.cs b/netcore/src/Modularity/Extend/NCC.Extend/LqReportService.cs
index d440254..7156934 100644
--- a/netcore/src/Modularity/Extend/NCC.Extend/LqReportService.cs
+++ b/netcore/src/Modularity/Extend/NCC.Extend/LqReportService.cs
@@ -721,6 +721,8 @@ namespace NCC.Extend
/// - BillingCount: 开单人数(按客户去重)
/// - ConsumeCount: 耗卡人数(按客户去重)
/// - RefundCount: 退卡人数(按客户去重)
+ /// - TargetConsumeAmount: 消耗目标业绩(所有门店xhyj字段的总和)
+ /// - ConsumeCompletionRate: 消耗完成率(百分比)
///
/// 查询参数
/// 业务统计数据
@@ -811,6 +813,27 @@ namespace NCC.Extend
var refundCount = Convert.ToInt32(refundResult?.FirstOrDefault()?.refund_count ?? 0);
var refundAmount = Convert.ToDecimal(refundResult?.FirstOrDefault()?.refund_amount ?? 0m);
+ // 第四步:获取消耗目标业绩(所有门店xhyj字段的总和)
+ var targetSql = "SELECT COALESCE(SUM(CAST(md.xhyj AS DECIMAL(18,2))), 0) as target_consume_amount FROM lq_mdxx md WHERE 1=1";
+ object targetParameters = null;
+
+ if (input.StoreIds != null && input.StoreIds.Any())
+ {
+ targetSql += " AND md.F_Id IN @storeIds";
+ targetParameters = new { storeIds = input.StoreIds };
+ }
+
+ var targetResult = await _db.Ado.SqlQueryAsync(targetSql, targetParameters);
+ var targetConsumeAmount = Convert.ToDecimal(targetResult?.FirstOrDefault()?.target_consume_amount ?? 0m);
+
+ // 计算消耗完成率
+ var consumeCompletionRate = 0m;
+ if (targetConsumeAmount > 0)
+ {
+ consumeCompletionRate = (consumeAmount / targetConsumeAmount) * 100m;
+ consumeCompletionRate = decimal.Round(consumeCompletionRate, 2);
+ }
+
var result = new BusinessStatisticsOutput
{
TotalBillingAmount = billingAmount,
@@ -818,7 +841,9 @@ namespace NCC.Extend
TotalRefundAmount = refundAmount,
BillingCount = billingCount,
ConsumeCount = consumeCount,
- RefundCount = refundCount
+ RefundCount = refundCount,
+ TargetConsumeAmount = targetConsumeAmount,
+ ConsumeCompletionRate = consumeCompletionRate
};
return result;
--
libgit2 0.21.4