fix 逻辑调整
This commit is contained in:
@@ -21,12 +21,27 @@ public class AppointmentService : IAppointmentService
|
||||
_redisCache = redisCache;
|
||||
}
|
||||
|
||||
public async Task ReceiveAsync(AppointmentReceiveRequest request)
|
||||
public async Task ReceiveAsync(VisitorAppointmentReceiveRequest request)
|
||||
{
|
||||
var exists = await _dbContext.Queryable<VisitorAppointmentEntity>().Where(x => x.No == request.No).AnyAsync();
|
||||
exists.ThrowIfTrue("已经存在申请");
|
||||
|
||||
var id = await _dbContext.InsertReturnIdentityAsync(new VisitorAppointmentEntity
|
||||
var existsDoorArea = await _dbContext.Queryable<AppointmentAreaEntity>()
|
||||
.Where(x => x.TenantId == request.Factory)
|
||||
.Where(x => x.Name == request.ApplyDoorArea)
|
||||
.AnyAsync();
|
||||
|
||||
var existsWorkplace = true;
|
||||
if (request.IsEnterWorkplace)
|
||||
{
|
||||
var count = await _dbContext.Queryable<AppointmentAreaEntity>().Where(x => x.TenantId == request.Factory)
|
||||
.Where(x => request.ApplyWorkplaceAreas.Contains(x.Name))
|
||||
.CountAsync();
|
||||
|
||||
existsWorkplace = request.ApplyWorkplaceAreas.Count == count;
|
||||
}
|
||||
|
||||
var mst = new VisitorAppointmentEntity
|
||||
{
|
||||
Id = 0,
|
||||
CreatedBy = 0,
|
||||
@@ -45,10 +60,16 @@ public class AppointmentService : IAppointmentService
|
||||
DoorEnd = request.DoorEnd,
|
||||
Remark = request.Remark,
|
||||
IsEnterWorkplace = request.IsEnterWorkplace,
|
||||
ApplyWorkplaceArea = request.ApplyWorkplaceArea,
|
||||
ApplyWorkplaceAreas = request.ApplyWorkplaceAreas,
|
||||
WorkplaceStart = request.WorkplaceStart,
|
||||
WorkplaceEnd = request.WorkplaceEnd
|
||||
});
|
||||
};
|
||||
if (!existsDoorArea || !existsWorkplace)
|
||||
{
|
||||
mst.Status = VisitorAppointmentStatusEnumType.Obsolete;
|
||||
}
|
||||
|
||||
await _dbContext.InsertAsync(mst);
|
||||
|
||||
foreach (var item in request.Items)
|
||||
{
|
||||
@@ -90,7 +111,9 @@ public class AppointmentService : IAppointmentService
|
||||
Name = item.Name,
|
||||
Phone = item.Phone,
|
||||
Remark = item.Remark,
|
||||
Status = AppointmentDetailEnumType.Wait,
|
||||
Status = mst.Status == VisitorAppointmentStatusEnumType.Valid
|
||||
? VisitorAppointmentDetailStatusEnumType.Wait
|
||||
: VisitorAppointmentDetailStatusEnumType.Obsolete,
|
||||
LicensePlate = item.LicensePlate
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user