using System; using System.Collections.Generic; using System.Linq; using System.Text; using Edu.Model.Entity.EduTask; using Edu.Model.Entity.Sell; using Edu.Model.ViewModel.EduTask; using Edu.Repository.Sell; using VT.FW.DB; namespace Edu.Repository.EduTask { public class RB_Student_StopClassRepository : BaseRepository { // /// 订单学员仓储层对象 /// private readonly RB_Order_GuestRepository order_GuestRepository = new RB_Order_GuestRepository(); /// /// 教务单据仓储层对象 /// private readonly RB_Education_ReceiptRepository education_ReceiptRepository = new RB_Education_ReceiptRepository(); /// /// 获取停课列表 /// /// /// public List GetStudentStopClassListRepository(RB_Student_StopClass_ViewModel query) { StringBuilder builder = new StringBuilder(); builder.AppendFormat(@" SELECT A.*,IFNULL(B.ClassName,'') AS ClassName FROM RB_Student_StopClass AS A LEFT JOIN rb_class AS B ON A.ClassId=B.ClassId WHERE 1=1 "); if (query != null) { if (!string.IsNullOrEmpty(query.Q_Student_StopClass_Ids)) { builder.AppendFormat(@" AND A.{0} IN ({1}) ", nameof(RB_Student_StopClass_ViewModel.Id), query.Q_Student_StopClass_Ids); } if (query.IsAuditThrough > -1) { builder.AppendFormat(@" AND A.{0} = ({1}) ", nameof(RB_Student_StopClass_ViewModel.IsAuditThrough), query.IsAuditThrough); } } return Get(builder.ToString()).ToList(); } /// /// 审核通过后更新申请表中的状态 /// /// /// 2审核通过 3 不通过 4 驳回 /// public bool UpdateStudentStopClass(object Id, int AuditStatus) { //查询当前调课信息 bool flag = false; var receiptModel = education_ReceiptRepository.GetEntity(Id); if (receiptModel == null || receiptModel.Id == 0) { return false; } if (receiptModel.ReceiptType != Common.Enum.Finance.ReceiptTypeEnum.StopClass) { return false; } var model = GetEntity(receiptModel.RelationId); if (model == null || model.Id == 0) { return false; } else //更新学生的信息 { if (AuditStatus == 2)//审核通过 { Dictionary keyValues = new Dictionary() { { nameof(RB_Student_StopClass_ViewModel.IsAuditThrough),1} }; List wheres = new List() { new WhereHelper(){ FiledName=nameof(RB_Student_StopClass_ViewModel.Id), FiledValue=model.Id, OperatorEnum=OperatorEnum.Equal } }; flag = Update(keyValues, wheres); } else { //拒绝or 不通过将状态改回之前的状态 Dictionary keyValues = new Dictionary() { { nameof(RB_Student_StopClass_ViewModel.IsAuditThrough),(AuditStatus-1)} }; List wheres = new List() { new WhereHelper(){ FiledName=nameof(RB_Student_StopClass_ViewModel.Id), FiledValue=model.Id, OperatorEnum=OperatorEnum.Equal } }; flag = Update(keyValues, wheres); if (flag) { Dictionary keyStudentValues = new Dictionary() { { nameof(RB_Order_Guest.GuestState),model.OldStudentStatus} }; List wheresStudnetn = new List() { new WhereHelper() { FiledName=nameof(RB_Order_Guest.Id), FiledValue=model.OrderGuestId, OperatorEnum=OperatorEnum.Equal } }; flag = order_GuestRepository.Update(keyStudentValues, wheresStudnetn); } } } return flag; } } }