公司员工新增领导与普通员工之分
This commit is contained in:
@@ -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<Prescription>, 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<Prescription>, 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<Prescription>, 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<Prescription>, 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<Prescription>, 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<Prescription>, IPrescriptionServ
|
||||
if (input.Person.IsEmployee)
|
||||
mappedEmployeeId = null;
|
||||
|
||||
var person = new Person
|
||||
var dbPerson = await Context.Queryable<Person>().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<Prescription>, IPrescriptionServ
|
||||
Name = pe.Name,
|
||||
Birthday = pe.Birthday,
|
||||
Height = pe.Height,
|
||||
RelationShip = pe.RelationShip
|
||||
RelationShip = pe.RelationShip,
|
||||
Type = pe.Type
|
||||
}).ToListAsync();
|
||||
}
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user