|
|
|
@ -1,4 +1,5 @@ |
|
|
|
|
using MongoDB.Driver.Linq; |
|
|
|
|
using System.Collections.Generic; |
|
|
|
|
|
|
|
|
|
namespace Tiobon.Core.Services; |
|
|
|
|
|
|
|
|
@ -9,12 +10,14 @@ public class Ghre_OpenClassServices : BaseServices<Ghre_OpenClass, Ghre_OpenClas |
|
|
|
|
{ |
|
|
|
|
private readonly IGhre_OpenClassStaffServices _ghre_OpenClassStaffServices; |
|
|
|
|
private readonly IGhre_OpenClassFeeServices _ghre_OpenClassFeeServices; |
|
|
|
|
private readonly IGhre_StaffGroupServices _ghre_StaffGroupServices; |
|
|
|
|
private readonly IGhre_OpenClassScheduleServices _ghre_OpenClassScheduleServices; |
|
|
|
|
private readonly IBaseRepository<Ghre_OpenClass> _dal; |
|
|
|
|
public Ghre_OpenClassServices(ICaching caching, |
|
|
|
|
IBaseRepository<Ghre_OpenClass> dal, |
|
|
|
|
IGhre_OpenClassStaffServices ghre_OpenClassStaffServices, |
|
|
|
|
IGhre_OpenClassFeeServices ghre_OpenClassFeeServices, |
|
|
|
|
IGhre_StaffGroupServices ghre_StaffGroupServices, |
|
|
|
|
IGhre_OpenClassScheduleServices ghre_OpenClassScheduleServices) |
|
|
|
|
{ |
|
|
|
|
this._dal = dal; |
|
|
|
@ -23,6 +26,7 @@ public class Ghre_OpenClassServices : BaseServices<Ghre_OpenClass, Ghre_OpenClas |
|
|
|
|
_ghre_OpenClassStaffServices = ghre_OpenClassStaffServices; |
|
|
|
|
_ghre_OpenClassFeeServices = ghre_OpenClassFeeServices; |
|
|
|
|
_ghre_OpenClassScheduleServices = ghre_OpenClassScheduleServices; |
|
|
|
|
_ghre_StaffGroupServices = ghre_StaffGroupServices; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public override async Task<ServicePageResult<Ghre_OpenClassDto>> QueryFilterPage(QueryBody filter, string condition, bool? IsEnable = true) |
|
|
|
@ -117,6 +121,7 @@ public class Ghre_OpenClassServices : BaseServices<Ghre_OpenClass, Ghre_OpenClas |
|
|
|
|
|
|
|
|
|
prefixTemp = prefixTemp + "K"; |
|
|
|
|
entity.OpenClassNo = await GenerateContinuousSequence("Ghre_OpenClass", "OpenClassNo", prefixTemp, prefixTemp.Length + 4, 4); |
|
|
|
|
|
|
|
|
|
var result = await base.Add(entity); |
|
|
|
|
|
|
|
|
|
if (entity.Schedules != null && entity.Schedules.Any()) |
|
|
|
@ -224,7 +229,25 @@ public class Ghre_OpenClassServices : BaseServices<Ghre_OpenClass, Ghre_OpenClas |
|
|
|
|
|
|
|
|
|
public async Task<ServiceResult> InsertStaff(long Id, List<int> staffIds) |
|
|
|
|
{ |
|
|
|
|
var staffIds1 = await Db.Queryable<Ghre_OpenClassStaff>().Where(x => x.OpenClassId == Id).Select(s => s.StaffId).ToListAsync(); |
|
|
|
|
var entity = await base.QueryById(Id); |
|
|
|
|
var stafffIds = new List<int>(); |
|
|
|
|
if (entity.StaffGroupId.IsNotEmptyOrNull()) |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
var staffGroups = await _ghre_StaffGroupServices.QueryStaff(entity.StaffGroupId.Value, new QueryBody(), "", true); |
|
|
|
|
|
|
|
|
|
stafffIds = staffGroups.result.DT_TableDataT1.Select(x => x.StaffID).ToList(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var staffIds1 = await Db.Queryable<Ghre_OpenClassStaff>().Where(x => x.OpenClassId == Id && x.StaffId != null).Select(s => s.StaffId.Value).ToListAsync(); |
|
|
|
|
|
|
|
|
|
stafffIds.AddRange(staffIds1); |
|
|
|
|
stafffIds.AddRange(staffIds); |
|
|
|
|
stafffIds = stafffIds.Distinct().ToList(); |
|
|
|
|
|
|
|
|
|
if (stafffIds.Count > entity.StudentCount) |
|
|
|
|
throw new Exception($"学员人数上限是:{entity.StudentCount}!"); |
|
|
|
|
|
|
|
|
|
var inserts = staffIds.Where(x => !staffIds1.Contains(x)) |
|
|
|
|
.Select(x => new InsertGhre_OpenClassStaffInput() |
|
|
|
|
{ |
|
|
|
|