From 65e1ea9f1c805734dfb2964db4c4a45b43d81d38 Mon Sep 17 00:00:00 2001
From: “wangming” <“wangming@antissoft.com”>
Date: Tue, 28 Oct 2025 00:33:34 +0800
Subject: [PATCH] fix: 修复员工业绩统计和人次统计逻辑
---
antis-ncc-admin/.env.development | 4 ++--
netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqInventoryUsage/LqInventoryUsageListOutput.cs | 36 ++++++++++++++++++------------------
netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqStatistics/EmployeePerformanceStatisticsInput.cs | 22 ++++++++++++++++++++++
netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqStatistics/EmployeePerformanceStatisticsOutput.cs | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
netcore/src/Modularity/Extend/NCC.Extend/LqInventoryUsageService.cs | 69 +++++++++++++++++++++++++++++++++++----------------------------------
netcore/src/Modularity/Extend/NCC.Extend/LqStatisticsService.cs | 249 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
netcore/src/Modularity/Extend/NCC.Extend/LqXmzlService.cs | 24 ++++++++++++++++--------
7 files changed, 413 insertions(+), 64 deletions(-)
create mode 100644 netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqStatistics/EmployeePerformanceStatisticsInput.cs
create mode 100644 netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqStatistics/EmployeePerformanceStatisticsOutput.cs
diff --git a/antis-ncc-admin/.env.development b/antis-ncc-admin/.env.development
index 78e23e6..be31aec 100644
--- a/antis-ncc-admin/.env.development
+++ b/antis-ncc-admin/.env.development
@@ -2,6 +2,6 @@
VUE_CLI_BABEL_TRANSPILE_MODULES = true
# VUE_APP_BASE_API = 'http://lvqian.antissoft.com'
-VUE_APP_BASE_API = 'http://erp_test.lvqianmeiye.com'
-# VUE_APP_BASE_API = 'http://localhost:2011'
+# VUE_APP_BASE_API = 'http://erp_test.lvqianmeiye.com'
+VUE_APP_BASE_API = 'http://localhost:2011'
VUE_APP_BASE_WSS = 'ws://192.168.110.45:2011/websocket'
diff --git a/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqInventoryUsage/LqInventoryUsageListOutput.cs b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqInventoryUsage/LqInventoryUsageListOutput.cs
index 4f30762..3891c30 100644
--- a/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqInventoryUsage/LqInventoryUsageListOutput.cs
+++ b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqInventoryUsage/LqInventoryUsageListOutput.cs
@@ -10,91 +10,91 @@ namespace NCC.Extend.Entitys.Dto.LqInventoryUsage
///
/// 使用记录ID
///
- public string Id { get; set; }
+ public string id { get; set; }
///
/// 产品ID
///
- public string ProductId { get; set; }
+ public string productId { get; set; }
///
/// 产品名称
///
- public string ProductName { get; set; }
+ public string productName { get; set; }
///
/// 产品类别
///
- public string ProductCategory { get; set; }
+ public string productCategory { get; set; }
///
/// 产品价格
///
- public decimal ProductPrice { get; set; }
+ public decimal productPrice { get; set; }
///
/// 门店ID
///
- public string StoreId { get; set; }
+ public string storeId { get; set; }
///
/// 门店名称
///
- public string StoreName { get; set; }
+ public string storeName { get; set; }
///
/// 使用时间
///
- public DateTime UsageTime { get; set; }
+ public DateTime usageTime { get; set; }
///
/// 使用数量
///
- public int UsageQuantity { get; set; }
+ public int usageQuantity { get; set; }
///
/// 关联消耗ID
///
- public string RelatedConsumeId { get; set; }
+ public string relatedConsumeId { get; set; }
///
/// 创建人ID
///
- public string CreateUser { get; set; }
+ public string createUser { get; set; }
///
/// 创建人姓名
///
- public string CreateUserName { get; set; }
+ public string createUserName { get; set; }
///
/// 创建时间
///
- public DateTime CreateTime { get; set; }
+ public DateTime createTime { get; set; }
///
/// 更新人ID
///
- public string UpdateUser { get; set; }
+ public string updateUser { get; set; }
///
/// 更新人姓名
///
- public string UpdateUserName { get; set; }
+ public string updateUserName { get; set; }
///
/// 更新时间
///
- public DateTime? UpdateTime { get; set; }
+ public DateTime? updateTime { get; set; }
///
/// 是否有效(1:有效 0:无效)
///
- public int IsEffective { get; set; }
+ public int isEffective { get; set; }
///
/// 使用总价值
///
- public decimal UsageTotalValue { get; set; }
+ public decimal usageTotalValue { get; set; }
}
}
diff --git a/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqStatistics/EmployeePerformanceStatisticsInput.cs b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqStatistics/EmployeePerformanceStatisticsInput.cs
new file mode 100644
index 0000000..ebfd1b6
--- /dev/null
+++ b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqStatistics/EmployeePerformanceStatisticsInput.cs
@@ -0,0 +1,22 @@
+using System.ComponentModel.DataAnnotations;
+
+namespace NCC.Extend.Entitys.Dto.LqStatistics
+{
+ ///
+ /// 员工业绩统计查询输入参数
+ ///
+ public class EmployeePerformanceStatisticsInput
+ {
+ ///
+ /// 员工ID(必填)
+ ///
+ [Required(ErrorMessage = "员工ID不能为空")]
+ public string UserId { get; set; }
+
+ ///
+ /// 统计月份(格式:YYYYMM,如202510)
+ ///
+ [Required(ErrorMessage = "统计月份不能为空")]
+ public string StatisticsMonth { get; set; }
+ }
+}
diff --git a/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqStatistics/EmployeePerformanceStatisticsOutput.cs b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqStatistics/EmployeePerformanceStatisticsOutput.cs
new file mode 100644
index 0000000..f86697b
--- /dev/null
+++ b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqStatistics/EmployeePerformanceStatisticsOutput.cs
@@ -0,0 +1,73 @@
+namespace NCC.Extend.Entitys.Dto.LqStatistics
+{
+ ///
+ /// 员工业绩统计数据输出
+ ///
+ public class EmployeePerformanceStatisticsOutput
+ {
+ ///
+ /// 员工ID
+ ///
+ public string UserId { get; set; }
+
+ ///
+ /// 统计月份
+ ///
+ public string StatisticsMonth { get; set; }
+
+ ///
+ /// 拓客人数
+ ///
+ public int InvitationCount { get; set; }
+
+ ///
+ /// 邀约人数
+ ///
+ public int InviteCount { get; set; }
+
+ ///
+ /// 预约人数
+ ///
+ public int AppointmentCount { 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; }
+
+ ///
+ /// 人头(月度去重客户数)
+ ///
+ public int HeadCount { get; set; }
+
+ ///
+ /// 人次(日度去重客户数)
+ ///
+ public int PersonCount { get; set; }
+ }
+}
diff --git a/netcore/src/Modularity/Extend/NCC.Extend/LqInventoryUsageService.cs b/netcore/src/Modularity/Extend/NCC.Extend/LqInventoryUsageService.cs
index f4a181f..531e997 100644
--- a/netcore/src/Modularity/Extend/NCC.Extend/LqInventoryUsageService.cs
+++ b/netcore/src/Modularity/Extend/NCC.Extend/LqInventoryUsageService.cs
@@ -12,6 +12,7 @@ using NCC.Extend.Entitys.Dto.LqInventoryUsage;
using NCC.Extend.Entitys.Enum;
using NCC.Extend.Entitys.lq_inventory;
using NCC.Extend.Entitys.lq_inventory_usage;
+using NCC.Extend.Entitys.lq_mdxx;
using NCC.Extend.Interfaces.LqInventoryUsage;
using NCC.FriendlyException;
using NCC.System.Entitys.Permission;
@@ -184,23 +185,23 @@ namespace NCC.Extend
.WhereIF(input.IsEffective.HasValue, x => x.IsEffective == input.IsEffective.Value)
.Select(x => new LqInventoryUsageListOutput
{
- Id = x.Id,
- ProductId = x.ProductId,
- ProductName = "",
- ProductCategory = "",
- ProductPrice = 0,
- StoreId = x.StoreId,
- StoreName = "",
- UsageTime = x.UsageTime,
- UsageQuantity = x.UsageQuantity,
- RelatedConsumeId = x.RelatedConsumeId,
- CreateUser = x.CreateUser,
- CreateUserName = "",
- CreateTime = x.CreateTime,
- UpdateUser = x.UpdateUser,
- UpdateUserName = "",
- UpdateTime = x.UpdateTime,
- IsEffective = x.IsEffective
+ id = x.Id,
+ productId = x.ProductId,
+ productName = "",
+ productCategory = "",
+ productPrice = 0,
+ storeId = x.StoreId,
+ storeName = SqlFunc.Subqueryable().Where(u => u.Id == x.StoreId).Select(u => u.Dm),
+ usageTime = x.UsageTime,
+ usageQuantity = x.UsageQuantity,
+ relatedConsumeId = x.RelatedConsumeId,
+ createUser = x.CreateUser,
+ createUserName = "",
+ createTime = x.CreateTime,
+ updateUser = x.UpdateUser,
+ updateUserName = "",
+ updateTime = x.UpdateTime,
+ isEffective = x.IsEffective
})
.MergeTable()
.OrderBy(sidx + " " + input.sort)
@@ -209,30 +210,30 @@ namespace NCC.Extend
// 补充产品信息和用户信息
foreach (var item in data.list)
{
- if (!string.IsNullOrEmpty(item.ProductId))
+ if (!string.IsNullOrEmpty(item.productId))
{
- var product = await _db.Queryable().Where(p => p.Id == item.ProductId).FirstAsync();
+ var product = await _db.Queryable().Where(p => p.Id == item.productId).FirstAsync();
if (product != null)
{
- item.ProductName = product.ProductName;
- item.ProductCategory = product.ProductCategory;
- item.ProductPrice = product.Price;
+ item.productName = product.ProductName;
+ item.productCategory = product.ProductCategory;
+ item.productPrice = product.Price;
}
}
- if (!string.IsNullOrEmpty(item.StoreId))
+ if (!string.IsNullOrEmpty(item.storeId))
{
- var store = await _db.Queryable().Where(u => u.Id == item.StoreId).FirstAsync();
- item.StoreName = store?.RealName ?? "";
+ var store = await _db.Queryable().Where(u => u.Id == item.storeId).FirstAsync();
+ item.storeName = store?.RealName ?? "";
}
- if (!string.IsNullOrEmpty(item.CreateUser))
+ if (!string.IsNullOrEmpty(item.createUser))
{
- var createUser = await _db.Queryable().Where(u => u.Id == item.CreateUser).FirstAsync();
- item.CreateUserName = createUser?.RealName ?? "";
+ var createUser = await _db.Queryable().Where(u => u.Id == item.createUser).FirstAsync();
+ item.createUserName = createUser?.RealName ?? "";
}
- if (!string.IsNullOrEmpty(item.UpdateUser))
+ if (!string.IsNullOrEmpty(item.updateUser))
{
- var updateUser = await _db.Queryable().Where(u => u.Id == item.UpdateUser).FirstAsync();
- item.UpdateUserName = updateUser?.RealName ?? "";
+ var updateUser = await _db.Queryable().Where(u => u.Id == item.updateUser).FirstAsync();
+ item.updateUserName = updateUser?.RealName ?? "";
}
}
@@ -240,15 +241,15 @@ namespace NCC.Extend
if (!string.IsNullOrWhiteSpace(input.ProductName) || !string.IsNullOrWhiteSpace(input.ProductCategory))
{
data.list = data.list.Where(x =>
- (string.IsNullOrWhiteSpace(input.ProductName) || x.ProductName.Contains(input.ProductName)) &&
- (string.IsNullOrWhiteSpace(input.ProductCategory) || x.ProductCategory.Contains(input.ProductCategory))
+ (string.IsNullOrWhiteSpace(input.ProductName) || x.productName.Contains(input.ProductName)) &&
+ (string.IsNullOrWhiteSpace(input.ProductCategory) || x.productCategory.Contains(input.ProductCategory))
).ToList();
}
// 应用门店名称的过滤条件
if (!string.IsNullOrWhiteSpace(input.StoreName))
{
- data.list = data.list.Where(x => x.StoreName.Contains(input.StoreName)).ToList();
+ data.list = data.list.Where(x => x.storeName.Contains(input.StoreName)).ToList();
}
return PageResult.SqlSugarPageResult(data);
}
diff --git a/netcore/src/Modularity/Extend/NCC.Extend/LqStatisticsService.cs b/netcore/src/Modularity/Extend/NCC.Extend/LqStatisticsService.cs
index a824c65..797600e 100644
--- a/netcore/src/Modularity/Extend/NCC.Extend/LqStatisticsService.cs
+++ b/netcore/src/Modularity/Extend/NCC.Extend/LqStatisticsService.cs
@@ -2247,11 +2247,11 @@ namespace NCC.Extend.LqStatistics
GROUP BY jksyj.jkszh, hyhk.md
) headcount_stats ON jksyj.jkszh = headcount_stats.jkszh AND hyhk.md = headcount_stats.md
LEFT JOIN (
- -- 人次统计:日度去重到店数
+ -- 人次统计:日度去重客户数(每天同一个客户只算一次)
SELECT
jksyj.jkszh,
hyhk.md,
- COUNT(DISTINCT DATE(hyhk.hksj)) as F_PersonCount
+ COUNT(DISTINCT CONCAT(hyhk.hy, '-', DATE(hyhk.hksj))) as F_PersonCount
FROM lq_xh_jksyj jksyj
INNER JOIN lq_xh_hyhk hyhk ON jksyj.glkdbh = hyhk.F_Id AND hyhk.F_IsEffective = 1
WHERE jksyj.F_IsEffective = 1
@@ -3382,5 +3382,250 @@ namespace NCC.Extend.LqStatistics
#endregion
+ #region 员工业绩统计
+
+ ///
+ /// 获取员工业绩统计数据
+ ///
+ ///
+ /// 根据员工ID和月份统计员工的完整业绩数据
+ /// 包括:拓客人数、邀约人数、预约人数、开单、消耗、退卡、人头、人次
+ ///
+ /// 示例请求:
+ /// ```json
+ /// {
+ /// "userId": "员工ID",
+ /// "statisticsMonth": "202510"
+ /// }
+ /// ```
+ ///
+ /// 参数说明:
+ /// - userId: 员工ID(必填)
+ /// - statisticsMonth: 统计月份,格式YYYYMM(必填)
+ ///
+ /// 返回字段说明:
+ /// - UserId: 员工ID
+ /// - StatisticsMonth: 统计月份
+ /// - InvitationCount: 拓客人数
+ /// - InviteCount: 邀约人数
+ /// - AppointmentCount: 预约人数
+ /// - BillingCount: 开单数量
+ /// - BillingAmount: 开单金额
+ /// - ConsumeCount: 消耗数量
+ /// - ConsumeAmount: 消耗金额
+ /// - RefundCount: 退卡数量
+ /// - RefundAmount: 退卡金额
+ /// - HeadCount: 人头(月度去重客户数)
+ /// - PersonCount: 人次(日度去重客户数)
+ ///
+ /// 查询参数
+ /// 员工业绩统计数据
+ /// 成功返回统计数据
+ /// 参数错误
+ /// 服务器错误
+ [HttpPost("get-employee-performance-statistics")]
+ public async Task