Commit 7e52dbb5 authored by liudong1993's avatar liudong1993

1

parent 1651da2e
......@@ -2,6 +2,7 @@
using Edu.Common.Enum;
using Edu.Common.Enum.System;
using Edu.Common.Enum.User;
using Edu.Common.Plugin;
using Edu.Model.CacheModel;
using Edu.Model.ViewModel.Customer;
using Edu.Model.ViewModel.Mall;
......@@ -651,7 +652,30 @@ namespace Edu.Module.User
/// <returns></returns>
public List<RB_Student_ViewModel> GetStudentInfoModule(int Student_Id, int Group_Id)
{
return studentRepository.GetStudentInfoRepository(Student_Id, Group_Id);
var list = studentRepository.GetStudentInfoRepository(Student_Id, Group_Id);
if (list.Where(x => x.ClassScrollType == 2).Any()) {
//有滚动开班的
string GuestIds = string.Join(",", list.Where(x => x.ClassScrollType == 2).Select(x => x.GuestId));
var glist = studentRepository.GetStudentClassNumber(GuestIds, Group_Id);
foreach (var item in list) {
item.CompleteHours = glist.Where(x => x.GuestId == item.GuestId).FirstOrDefault()?.CompleteHours ?? item.CompleteHours;
item.SuspendNum = Convert.ToInt32(item.TotalHours - item.CompleteHours);
item.ClassStatus = item.CompleteHours == 0 ? 1 : item.CompleteHours < item.TotalHours ? 2 : 3;
}
}
return list;
}
/// <summary>
/// 获取约课课程上课次数
/// </summary>
/// <param name="guestId"></param>
/// <param name="groupId"></param>
/// <returns></returns>
public RB_Student_ViewModel GetStudentClassNumber(int guestId, int groupId)
{
return studentRepository.GetStudentClassNumber(guestId.ToString(), groupId).FirstOrDefault();
}
/// <summary>
......@@ -1079,7 +1103,6 @@ namespace Edu.Module.User
return flag;
}
/// <summary>
/// 根据编号获取课程顾问跟进记录
/// </summary>
......@@ -1090,6 +1113,93 @@ namespace Edu.Module.User
var extModel = student_AdvisorRepository.GetEntity<RB_Student_Advisor_Extend>(Id);
return extModel;
}
#endregion
#region 离职转交
/// <summary>
/// 学员转交
/// </summary>
/// <param name="userId"></param>
/// <param name="receiveId"></param>
/// <param name="userInfo"></param>
/// <returns></returns>
public string SetUserLeaveStudentCareOf(int userId, int receiveId, UserInfo userInfo)
{
var eModel = accountModule.GetEmployeeInfo(userId);
var reModel = accountModule.GetEmployeeInfo(receiveId);
if (eModel == null || reModel == null) { return "转交人不存在"; }
if (reModel.IsLeave != 1) { return "转交人非在职状态,无法交接"; }
//获取学员负责人 / 服务人员
var list = studentRepository.GetUserStudentCareOf(userId, userInfo.Group_Id);
if (list.Any())
{
//查询所有的服务人员
var alist = student_AssistRepository.GetUserStudentAssistCareOf(userId, userInfo.Group_Id);
var trans = studentRepository.DbTransaction;
try
{
foreach (var item in list)
{
bool flag = true;
if (item.CreateBy == userId) {
Dictionary<string, object> keyValues = new Dictionary<string, object>() {
{ nameof(RB_Student_ViewModel.CreateBy), receiveId}
};
List<WhereHelper> wheres = new List<WhereHelper>() {
new WhereHelper(){
FiledName = nameof(RB_Student_ViewModel.StuId),
FiledValue = item.StuId,
OperatorEnum =OperatorEnum.Equal
}
};
flag = studentRepository.Update(keyValues, wheres, trans);
}
if (flag) {
var clist = alist.Where(x => x.StuId == item.StuId).ToList();
foreach (var qitem in clist) {
Dictionary<string, object> keyValues = new Dictionary<string, object>() {
{ nameof(RB_Student_Assist_Extend.AssistId),receiveId},
};
List<WhereHelper> wheres = new List<WhereHelper>() {
new WhereHelper(){
FiledName = nameof(RB_Student_Assist_Extend.Id),
FiledValue = qitem.Id,
OperatorEnum =OperatorEnum.Equal
}
};
flag = student_AssistRepository.Update(keyValues, wheres, trans);
}
}
if (flag) {
//插入日志
student_LogRepository.Insert(new Model.Entity.Customer.RB_Student_Log()
{
CreateBy = userInfo.Id,
CreateTime = DateTime.Now,
CreateType = 1,
Group_Id = userInfo.Group_Id,
LogContent = "离职转交客人负责人与服务人员,由【" + eModel.EmployeeName + "(" + userId + ")" + "】转交给【" + reModel.EmployeeName + "(" + receiveId + ")" + "】",
LogId = 0,
LogTitle = "离职转交学员",
LogType = Common.Enum.Log.StudentLogTypeEnum.BasicInfo,
StuId = item.StuId
}, trans);
}
}
studentRepository.DBSession.Commit();
}
catch (Exception ex)
{
LogHelper.Write(ex, "SetUserLeaveStudentCareOf");
studentRepository.DBSession.Rollback();
return "学员转交出错了,请联系管理员";
}
}
return "";
}
#endregion
}
}
......@@ -514,6 +514,19 @@ WHERE o.OrderState=1 and og.`Status`=0 and sog.`Status`=0 and og.GuestState <>2
return Get<RB_Student_ViewModel>(builder.ToString(), parameters).ToList();
}
/// <summary>
/// 获取学生课程的上课次数
/// </summary>
/// <param name="guestIds"></param>
/// <param name="groupId"></param>
/// <returns></returns>
public List<RB_Student_ViewModel> GetStudentClassNumber(string guestIds, int groupId) {
string sql = $@"SELECT GuestId,COUNT(0) as CompleteHours FROM rb_scroll_appointment
WHERE Group_Id ={groupId} and `Status`=0 and State =3 and AppointType =1 and GuestId in({guestIds})
GROUP BY GuestId";
return Get<RB_Student_ViewModel>(sql).ToList();
}
/// <summary>
/// 新增修改学员资料
/// </summary>
......@@ -1159,5 +1172,20 @@ WHERE A.Status=0
var list = Get<RB_Student_ViewModel>(builder.ToString()).ToList();
return list;
}
/// <summary>
/// 获取转交学员
/// </summary>
/// <param name="userId"></param>
/// <param name="group_Id"></param>
/// <returns></returns>
public List<RB_Student_ViewModel> GetUserStudentCareOf(int userId, int group_Id)
{
string sql = $@"SELECT s.* FROM rb_student s
LEFT JOIN rb_student_assist a on s.StuId = a.StuId and a.`Status` =0
WHERE s.`Status`=0 and s.Group_Id ={group_Id} and (s.CreateBy ={userId} or a.AssistId ={userId})
group by s.StuId";
return Get<RB_Student_ViewModel>(sql).ToList();
}
}
}
\ No newline at end of file
......@@ -111,11 +111,17 @@ namespace Edu.WebApi.Controllers.Applet
var courseModel = courseModule.GetCourseModule(LearningInfo.CourseId);
//获取课时信息
var guestModel = orderModule.GetOrderGusetHoursInfo(LearningInfo.GuestId, LearningInfo.ClassId);
decimal CompleteHours = guestModel?.CompleteHours ?? 0;
if (LearningInfo.ClassScrollType == 2) {
//约课 算下实时课耗
var gModel = studentModule.GetStudentClassNumber(LearningInfo.GuestId, userInfo.Group_Id);
CompleteHours = gModel?.CompleteHours ?? CompleteHours;
}
CourseInfo = new
{
State = 1,
TotalHours = guestModel?.TotalHours ?? 0,
CompleteHours = guestModel?.CompleteHours ?? 0,
CompleteHours = CompleteHours,
MakeUpHours= guestModel?.MakeUpHours??0,
AbsenceNum = guestModel?.AbsenceNum ?? 0,
LeaveNum = guestModel?.LeaveNum ?? 0,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment