|
|
|
@ -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() |
|
|
|
|
{ |
|
|
|
@ -646,4 +669,87 @@ WHERE A.OpenClassId = '{Id}' AND A.IsEnable = 1"; |
|
|
|
|
return ServiceResult.OprateSuccess("签到成功!"); |
|
|
|
|
} |
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
#region 邮件 |
|
|
|
|
/// <summary> |
|
|
|
|
/// 邮件 |
|
|
|
|
/// </summary> |
|
|
|
|
/// <param name="Id">开班ID</param> |
|
|
|
|
/// <returns></returns> |
|
|
|
|
public async Task<ServiceResult> Email(long Id) |
|
|
|
|
{ |
|
|
|
|
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 = stafffIds.Distinct().ToList(); |
|
|
|
|
|
|
|
|
|
var staffs = await Db.Queryable<Ghra_Staff>().Where(x => stafffIds.Contains(x.StaffID) && !string.IsNullOrEmpty(x.Email)).Select(x => new { x.StaffID, x.Email }).ToListAsync(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var courseName = await Db.Ado.GetStringAsync($"select CourseName from Ghre_CourseScene_V where id='{entity.LinkId}'"); |
|
|
|
|
|
|
|
|
|
var content = entity.NoticeContent + " </br>" |
|
|
|
|
+ $"开班编号: {entity.OpenClassNo}</br>" |
|
|
|
|
+ $"开班名称: {entity.OpenClassName}</br>" |
|
|
|
|
+ $"课程名称: {courseName}</br>" |
|
|
|
|
+ $"开班起止日期: {DateTimeHelper.ConvertToMiniuteString(entity.StartTime)}~{DateTimeHelper.ConvertToMiniuteString(entity.EndTime)}</br>" |
|
|
|
|
+ $"报名起止日期: {DateTimeHelper.ConvertToMiniuteString(entity.RegisterStartTime)}~{DateTimeHelper.ConvertToMiniuteString(entity.RegisterStartTime)}</br>" |
|
|
|
|
+ $"考试起止日期: {DateTimeHelper.ConvertToMiniuteString(entity.ExamStartTime)}~{DateTimeHelper.ConvertToMiniuteString(entity.ExamStartTime)}</br>"; |
|
|
|
|
for (int i = 0; i < staffs.Count; i++) |
|
|
|
|
{ |
|
|
|
|
#region 发送邮件 |
|
|
|
|
var mailOutbox = new Ghrs_MailOutbox(); |
|
|
|
|
mailOutbox.TOMail = staffs[i].Email; |
|
|
|
|
mailOutbox.MailTitle = "开班通知"; |
|
|
|
|
mailOutbox.MailBody = content; |
|
|
|
|
mailOutbox.MailPriority = 1; |
|
|
|
|
mailOutbox.ScheduleTime = DateTime.Now; |
|
|
|
|
mailOutbox.IsEnable = 1; |
|
|
|
|
mailOutbox.SortNo = 1; |
|
|
|
|
mailOutbox.CompanyID = 0; |
|
|
|
|
mailOutbox.IsDefault = 0; |
|
|
|
|
mailOutbox.CreateProg = "OpenClass"; |
|
|
|
|
var id1 = await Db.Insertable(mailOutbox).ExecuteReturnIdentityAsync(); |
|
|
|
|
#endregion |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var teacher = await Db.Queryable<Ghre_Teacher>().Where(x => x.Id == entity.TeacherId).FirstAsync(); |
|
|
|
|
if (teacher != null && teacher.Email.IsNotEmptyOrNull()) |
|
|
|
|
{ |
|
|
|
|
content = entity.TeacherNoticeContent + " </br>" |
|
|
|
|
+ $"开班编号: {entity.OpenClassNo}</br>" |
|
|
|
|
+ $"开班名称: {entity.OpenClassName}</br>" |
|
|
|
|
+ $"课程名称: {courseName}</br>" |
|
|
|
|
+ $"开班起止日期: {DateTimeHelper.ConvertToMiniuteString(entity.StartTime)}~{DateTimeHelper.ConvertToMiniuteString(entity.EndTime)}</br>" |
|
|
|
|
+ $"报名起止日期: {DateTimeHelper.ConvertToMiniuteString(entity.RegisterStartTime)}~{DateTimeHelper.ConvertToMiniuteString(entity.RegisterStartTime)}</br>" |
|
|
|
|
+ $"考试起止日期: {DateTimeHelper.ConvertToMiniuteString(entity.ExamStartTime)}~{DateTimeHelper.ConvertToMiniuteString(entity.ExamStartTime)}</br>"; |
|
|
|
|
|
|
|
|
|
#region 发送邮件 |
|
|
|
|
var mailOutbox = new Ghrs_MailOutbox(); |
|
|
|
|
mailOutbox.TOMail = teacher.Email; |
|
|
|
|
mailOutbox.MailTitle = "开班通知"; |
|
|
|
|
mailOutbox.MailBody = content; |
|
|
|
|
mailOutbox.MailPriority = 1; |
|
|
|
|
mailOutbox.ScheduleTime = DateTime.Now; |
|
|
|
|
mailOutbox.IsEnable = 1; |
|
|
|
|
mailOutbox.SortNo = 1; |
|
|
|
|
mailOutbox.CompanyID = 0; |
|
|
|
|
mailOutbox.IsDefault = 0; |
|
|
|
|
mailOutbox.CreateProg = "OpenClass"; |
|
|
|
|
await Db.Insertable(mailOutbox).ExecuteReturnIdentityAsync(); |
|
|
|
|
#endregion |
|
|
|
|
} |
|
|
|
|
return ServiceResult.OprateSuccess("发送成功!"); |
|
|
|
|
} |
|
|
|
|
#endregion |
|
|
|
|
} |