From aa50e569f0eea97b80c783f1872b991c6f387f86 Mon Sep 17 00:00:00 2001
From: fuenmao <980740792@qq.com>
Date: Thu, 2 Apr 2026 13:56:25 +0800
Subject: [PATCH] =?UTF-8?q?=E5=85=AC=E5=8F=B8=E5=91=98=E5=B7=A5=E6=96=B0?=
=?UTF-8?q?=E5=A2=9E=E9=A2=86=E5=AF=BC=E4=B8=8E=E6=99=AE=E9=80=9A=E5=91=98?=
=?UTF-8?q?=E5=B7=A5=E4=B9=8B=E5=88=86?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
SimpleAdmin.Application/Entity/Person.cs | 3 +
.../Prescription/Dto/PrescriptionDtos.cs | 6 +-
.../Prescription/PrescriptionService.cs | 68 +++++++++++++------
.../Services/Statistics/StatisticsService.cs | 25 ++++++-
4 files changed, 78 insertions(+), 24 deletions(-)
diff --git a/SimpleAdmin.Application/Entity/Person.cs b/SimpleAdmin.Application/Entity/Person.cs
index a98c0e0..a9735c5 100644
--- a/SimpleAdmin.Application/Entity/Person.cs
+++ b/SimpleAdmin.Application/Entity/Person.cs
@@ -39,5 +39,8 @@ namespace SimpleAdmin.Application.Entity
/// 单位 cm,保留两位小数
[SugarColumn(ColumnDescription = "身高(cm)", IsNullable = true)]
public decimal? Height { get; set; }
+
+ [SugarColumn(ColumnDescription = "1领导,2普通员工,3其他", IsNullable = true)]
+ public int? Type { get; set; }
}
}
diff --git a/SimpleAdmin.Application/Services/Prescription/Dto/PrescriptionDtos.cs b/SimpleAdmin.Application/Services/Prescription/Dto/PrescriptionDtos.cs
index fee9868..b0c00d7 100644
--- a/SimpleAdmin.Application/Services/Prescription/Dto/PrescriptionDtos.cs
+++ b/SimpleAdmin.Application/Services/Prescription/Dto/PrescriptionDtos.cs
@@ -1,4 +1,4 @@
-// Copyright (c) 2022-Now 少林寺驻北固山办事处大神父王喇嘛
+// Copyright (c) 2022-Now 少林寺驻北固山办事处大神父王喇嘛
//
// SimpleAdmin 基于 Apache License Version 2.0 协议发布,可用于商业项目,但必须遵守以下补充条款:
// 1.请不要删除和修改根目录下的LICENSE文件。
@@ -44,6 +44,7 @@ namespace SimpleAdmin.Application.Services.Prescription.Dto
public DateTime CreateTime { get; set; }
public decimal TotalMedicineCost { get; set; }
+ public int? Type { get; set; }
}
// 辅助类:存储FIFO计算所需的入库记录信息
@@ -89,6 +90,7 @@ namespace SimpleAdmin.Application.Services.Prescription.Dto
public string EmployeeName { get; set; }
public long? RelationShip { get; set; }
public string RelationShipName { get; set; }
+ public int? Type { get; set; }
}
// 处方药材DTO
@@ -131,6 +133,7 @@ namespace SimpleAdmin.Application.Services.Prescription.Dto
/// 当 EmployeeIsTemp 为 true 或者前端直接传了员工名字时,后端可用此字段创建员工
///
public string EmployeeName { get; set; }
+ public int? Type { get; set; }
}
// 处方药材输入DTO
public class PrescriptionHerbInputDto
@@ -150,6 +153,7 @@ namespace SimpleAdmin.Application.Services.Prescription.Dto
public decimal? Height { get; set; }
public long? RelationShip { get; set; }
+ public int? Type { get; set; }
}
// 关系类型DTO
diff --git a/SimpleAdmin.Application/Services/Prescription/PrescriptionService.cs b/SimpleAdmin.Application/Services/Prescription/PrescriptionService.cs
index f9ad682..2506eea 100644
--- a/SimpleAdmin.Application/Services/Prescription/PrescriptionService.cs
+++ b/SimpleAdmin.Application/Services/Prescription/PrescriptionService.cs
@@ -1,4 +1,4 @@
-// Copyright (c) 2022-Now 少林寺驻北固山办事处大神父王喇嘛
+// Copyright (c) 2022-Now 少林寺驻北固山办事处大神父王喇嘛
//
// SimpleAdmin 基于 Apache License Version 2.0 协议发布,可用于商业项目,但必须遵守以下补充条款:
// 1.请不要删除和修改根目录下的LICENSE文件。
@@ -213,7 +213,8 @@ public class PrescriptionService : DbRepository, IPrescriptionServ
CreateTime = p.CreateTime.Value,
EmployeeName = emp.Name,
CanEdit = false,
- TotalMedicineCost = 0
+ TotalMedicineCost = 0,
+ Type = pe.Type
}).ToPagedListAsync(input.PageNum, input.PageSize);
if (!prescriptionPage.List.Any()) return prescriptionPage;
// 获取当前页所有处方的 Id
@@ -294,8 +295,8 @@ public class PrescriptionService : DbRepository, IPrescriptionServ
item.CanEdit = true;
}
//all += item.TotalMedicineCost;
- // 家属加价 10%
- if (item.PersonType == PersonType.Relative)
+ // 家属和普通员工加价 10%
+ if (item.PersonType == PersonType.Relative || item.Type == 2)
{
item.TotalMedicineCost = Math.Round(item.TotalMedicineCost * 1.1m, 2, MidpointRounding.AwayFromZero);
}
@@ -369,13 +370,14 @@ public class PrescriptionService : DbRepository, IPrescriptionServ
.Select((p, pe) => new
{
Id = p.Id,
- IsRelative = pe.EmployeeId != null
+ IsRelative = pe.EmployeeId != null,
+ Type = pe.Type
})
.ToListAsync();
// 明确转换 key 为 long(处理 nullable)
var personInfoDict = personTmp
- .ToDictionary(x => Convert.ToInt64(x.Id), x => x.IsRelative);
+ .ToDictionary(x => Convert.ToInt64(x.Id), x => new { x.IsRelative, x.Type });
// 7) FIFO 成本计算(按时间顺序已由 allIdsLong 保持)
foreach (var pidObj in allIdsLong)
@@ -402,9 +404,11 @@ public class PrescriptionService : DbRepository, IPrescriptionServ
// 处方级别保留 4 位小数
presCost = Math.Round(presCost, 4, MidpointRounding.AwayFromZero);
- // 家属加价 10%(若字典缺失,默认不是家属)
- var isRelative = personInfoDict.TryGetValue(pid, out var rel) && rel;
- if (isRelative)
+ // 家属和普通员工加价 10%
+ personInfoDict.TryGetValue(pid, out var personInfo);
+ var isRelative = personInfo?.IsRelative ?? false;
+ var isOrdinary = personInfo?.Type == 2;
+ if (isRelative || isOrdinary)
{
presCost = Math.Round(presCost * 1.1m, 2, MidpointRounding.AwayFromZero);
}
@@ -554,7 +558,8 @@ public class PrescriptionService : DbRepository, IPrescriptionServ
EmployeeId = person.EmployeeId,
EmployeeName = employee?.Name,
RelationShip = person.RelationShip,
- RelationShipName = RelationShipName.FirstOrDefault(t => t.Id == person.RelationShip)?.Name
+ RelationShipName = RelationShipName.FirstOrDefault(t => t.Id == person.RelationShip)?.Name,
+ Type = person.Type
},
DiagnosisResult = prescription.DiagnosisResult,
UserMedicinaAdvice = prescription.UserMedicinaAdvice,
@@ -689,16 +694,38 @@ public class PrescriptionService : DbRepository, IPrescriptionServ
if (input.Person.IsEmployee)
mappedEmployeeId = null;
- var person = new Person
+ var dbPerson = await Context.Queryable().FirstAsync(p => p.Id == personId);
+ if (dbPerson != null)
{
- Id = personId,
- Name = input.Person?.Name,
- Birthday = input.Person?.Birthday,
- Height = input.Person?.Height,
- RelationShip = input.Person?.RelationShip,
- EmployeeId = mappedEmployeeId
- };
- await Context.Storageable(person).ExecuteCommandAsync();
+ dbPerson.Name = input.Person?.Name ?? dbPerson.Name;
+ dbPerson.Birthday = input.Person?.Birthday ?? dbPerson.Birthday;
+ dbPerson.Height = input.Person?.Height ?? dbPerson.Height;
+ dbPerson.RelationShip = input.Person?.RelationShip ?? dbPerson.RelationShip;
+ dbPerson.EmployeeId = mappedEmployeeId;
+ if (input.Person != null && input.Person.IsEmployee)
+ {
+ dbPerson.Type = input.Person?.Type;
+ }
+ else
+ {
+ dbPerson.Type = null;
+ }
+ await Context.Updateable(dbPerson).ExecuteCommandAsync();
+ }
+ else
+ {
+ var person = new Person
+ {
+ Id = personId,
+ Name = input.Person?.Name,
+ Birthday = input.Person?.Birthday,
+ Height = input.Person?.Height,
+ RelationShip = input.Person?.RelationShip,
+ EmployeeId = mappedEmployeeId,
+ Type = input.Person.IsEmployee ? input.Person?.Type : null
+ };
+ await Context.Insertable(person).ExecuteCommandAsync();
+ }
// ---------- 4. 处方保存/编辑逻辑----------
Prescription prescription;
@@ -831,7 +858,8 @@ public class PrescriptionService : DbRepository, IPrescriptionServ
Name = pe.Name,
Birthday = pe.Birthday,
Height = pe.Height,
- RelationShip = pe.RelationShip
+ RelationShip = pe.RelationShip,
+ Type = pe.Type
}).ToListAsync();
}
///
diff --git a/SimpleAdmin.Application/Services/Statistics/StatisticsService.cs b/SimpleAdmin.Application/Services/Statistics/StatisticsService.cs
index 870b41f..4391105 100644
--- a/SimpleAdmin.Application/Services/Statistics/StatisticsService.cs
+++ b/SimpleAdmin.Application/Services/Statistics/StatisticsService.cs
@@ -28,7 +28,8 @@ public class StatisticsService : DbRepository, IStatisticsService
{
p.Id,
p.PersonId,
- IsRelative = pe.EmployeeId != null
+ IsRelative = pe.EmployeeId != null,
+ Type = pe.Type
})
.ToListAsync();
@@ -75,6 +76,11 @@ public class StatisticsService : DbRepository, IStatisticsService
familyCost += Math.Round(cost * 1.1m, 2, MidpointRounding.AwayFromZero);
familyQty++;
}
+ else if (pInfo.Type == 2)
+ {
+ staffCost += Math.Round(cost * 1.1m, 2, MidpointRounding.AwayFromZero);
+ staffQty++;
+ }
else
{
staffCost += Math.Round(cost, 2, MidpointRounding.AwayFromZero);
@@ -176,7 +182,8 @@ public class StatisticsService : DbRepository, IStatisticsService
p.Id,
p.VisitDate,
p.CreateTime,
- IsRelative = pe.EmployeeId != null
+ IsRelative = pe.EmployeeId != null,
+ Type = pe.Type
})
.ToListAsync();
@@ -276,6 +283,12 @@ public class StatisticsService : DbRepository, IStatisticsService
monthlyFamilyCost[month] += cost;
monthlyFamilyQty[month]++;
}
+ else if (pInfo.Type == 2)
+ {
+ cost = Math.Round(cost * 1.1m, 2, MidpointRounding.AwayFromZero);
+ monthlyStaffCost[month] += cost;
+ monthlyStaffQty[month]++;
+ }
else
{
cost = Math.Round(cost, 2, MidpointRounding.AwayFromZero);
@@ -337,7 +350,8 @@ public class StatisticsService : DbRepository, IStatisticsService
{
p.Id,
p.PersonId,
- IsRelative = pe.EmployeeId != null
+ IsRelative = pe.EmployeeId != null,
+ Type = pe.Type
})
.ToListAsync();
@@ -418,6 +432,11 @@ public class StatisticsService : DbRepository, IStatisticsService
familyCost += Math.Round(cost * 1.1m, 2, MidpointRounding.AwayFromZero);
familyQty++;
}
+ else if (pInfo.Type == 2)
+ {
+ staffCost += Math.Round(cost * 1.1m, 2, MidpointRounding.AwayFromZero);
+ staffQty++;
+ }
else
{
staffCost += Math.Round(cost, 2, MidpointRounding.AwayFromZero);