using Edu.AOP.CustomerAttribute;
using Edu.Common;
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.Contract;
using Edu.Model.ViewModel.Customer;
using Edu.Model.ViewModel.Mall;
using Edu.Model.ViewModel.Sell;
using Edu.Model.ViewModel.User;
using Edu.Repository.Contract;
using Edu.Repository.Customer;
using Edu.Repository.Mall;
using Edu.Repository.Reserve;
using Edu.Repository.Sell;
using Edu.Repository.System;
using Edu.Repository.User;
using Senparc.CO2NET.Extensions;
using Senparc.Weixin.Annotations;
using Senparc.Weixin.MP.AdvancedAPIs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using VT.FW.DB;
namespace Edu.Module.User
{
///
/// 学生处理类
///
public class StudentModule
{
///
/// 学生仓储层对象
///
private readonly RB_StudentRepository studentRepository = new RB_StudentRepository();
///
/// 日志
///
private readonly RB_Student_LogRepository student_LogRepository = new RB_Student_LogRepository();
///
/// 地区仓储层对象
///
private readonly RB_DestinationRepository destinationRepository = new RB_DestinationRepository();
///
/// 同业
///
private readonly RB_CustomerRepository customerRepository = new RB_CustomerRepository();
///
/// 账号处理类
///
private readonly AccountModule accountModule = new AccountModule();
///
/// 小程序用户仓储层对象 add by:W 2021-09-15
///
private readonly RB_Member_UserRepository member_UserRepository = new RB_Member_UserRepository();
///
/// 学员订单关联表仓储层
///
private readonly RB_Student_OrderGuestRepository student_OrderGuestRepository = new RB_Student_OrderGuestRepository();
///
/// 学员跟进
///
private readonly RB_Student_FollowRepository followRepository = new RB_Student_FollowRepository();
///
/// 学员协助人员仓储层对象
///
private readonly RB_Student_AssistRepository student_AssistRepository = new RB_Student_AssistRepository();
///
/// 学员到访仓储层对象
///
private readonly RB_Student_VisitRepository student_VisitRepository = new RB_Student_VisitRepository();
///
/// 学员试听课仓储层对象
///
private readonly RB_Visitor_ReserveRepository visitor_ReserveRepository = new RB_Visitor_ReserveRepository();
///
/// 客户阶段仓储层对象
///
private readonly RB_StageRepository stageRepository = new RB_StageRepository();
///
/// 学员类型仓储层对象
///
private readonly RB_Student_TypeRepository student_TypeRepository = new RB_Student_TypeRepository();
///
/// 学习目的仓储层对象
///
private readonly RB_LearningGoalsRepository learningGoalsRepository = new RB_LearningGoalsRepository();
///
/// 渠道仓储层对象
///
private readonly RB_ChannelRepository channelRepository = new RB_ChannelRepository();
///
/// 客户需求仓储层对象
///
private readonly RB_NeedsRepository needsRepository = new RB_NeedsRepository();
///
/// 学员约访仓储层对象
///
private readonly RB_Student_AppointmentRepository student_AppointmentRepository = new RB_Student_AppointmentRepository();
///
/// 课程顾问跟进配置仓储层对象
///
private readonly RB_Student_AdvisorConfigRepository student_AdvisorConfigRepository = new RB_Student_AdvisorConfigRepository();
///
/// 课程顾问跟进仓储层对象
///
private readonly RB_Student_AdvisorRepository student_AdvisorRepository = new RB_Student_AdvisorRepository();
///
/// 订单客人仓储层
///
private readonly RB_Order_GuestRepository order_GuestRepository = new RB_Order_GuestRepository();
///
/// 订单仓储层对象
///
private readonly RB_OrderRepository orderRepository = new RB_OrderRepository();
///
/// 订单拆分仓储层对象
///
private readonly RB_Order_SplitDetailsRepository splitDetailsRepository = new RB_Order_SplitDetailsRepository();
///
/// 订单备注
///
private readonly RB_Order_RemarkRepository order_RemarkRepository = new RB_Order_RemarkRepository();
///
/// 合同
///
private readonly RB_Education_ContractRepository education_ContractRepository = new RB_Education_ContractRepository();
///
/// 业绩提成
///
private readonly RB_Sell_Achievements_EmpRepository sell_Achievements_EmpRepository = new RB_Sell_Achievements_EmpRepository();
///
/// 订单返佣仓储层对象
///
private readonly RB_Order_ReturnComissionRepository returnComissionRepository = new RB_Order_ReturnComissionRepository();
///
/// 学员配置仓储层
///
private readonly RB_Student_ConfigRepository student_ConfigRepository = new RB_Student_ConfigRepository();
///
/// 账号管理仓储层对象
///
private readonly RB_AccountRepository accountRepository = new RB_AccountRepository();
///
/// 获取学生列表
///
///
///
public List GetStudentListModule(RB_Student_ViewModel query)
{
return studentRepository.GetStudentListRepository(query);
}
///
/// 获取学生分页列表
///
///
///
///
///
///
public List GetStudentPageListModule(int pageIndex, int pageSize, out long rowsCount, RB_Student_ViewModel query)
{
var list = studentRepository.GetStudentPageListRepository(pageIndex, pageSize, out rowsCount, query);
if (list != null && list.Count > 0)
{
//客户阶段列表
var stageList = stageRepository.GetStageListRepostory(new Model.Entity.System.RB_Stage()
{
Group_Id = list[0].Group_Id
});
//学员类型列表
var stuTypeList = student_TypeRepository.GetStudentTypeListRepository(new RB_Student_Type_Extend());
string stuIds = string.Join(",", list.Select(qitem => qitem.StuId));
//学员跟进
var followList = followRepository.GetStudentFollowListRepository(new RB_Student_Follow_Extend()
{
QStuIds = stuIds
});
//学员订单
var stuOrderList = student_OrderGuestRepository.GetStrOrderGuestListStaticRepository(new RB_Student_OrderGuest_ViewModel()
{
QStudentIds = stuIds
});
//本周新增
var stuList = studentRepository.GetCustomerStuWeekListRepository(new RB_Student_ViewModel()
{
CustomerId = query.CustomerId
});
//协助人员列表
var assistList = student_AssistRepository.GetStudentAssistListRepository(new RB_Student_Assist_Extend()
{
QStuIds = stuIds
});
//内部介绍人
List empIdList = Common.ConvertHelper.StringToList(string.Join(",", list.Where(qitem => qitem.CreateType == StuCreateTypeEnum.InternalIntroduction).Select(qitem => qitem.StuSourceId)));
List aIds = Common.ConvertHelper.StringToList(string.Join(",", assistList.Select(qitem => qitem.AssistId)));
List createBys = Common.ConvertHelper.StringToList(string.Join(",", list.Select(qitem => qitem.CreateBy)));
List accountList = new List();
if (aIds != null && aIds.Count > 0)
{
empIdList.AddRange(aIds);
}
if (createBys != null && createBys.Count > 0)
{
empIdList.AddRange(createBys);
}
if (empIdList != null && empIdList.Count > 0)
{
accountList = accountModule.GetAccountListExtModule(new RB_Account_ViewModel() { QIds = string.Join(",", empIdList) });
}
//学员到访统计
var visitList = student_VisitRepository.GetStudentVisitStatic_V2Repository(new RB_Student_Visit_Extend()
{
QStuIds = stuIds,
StartDate = query.StartTime,
EndDate = query.EndTime,
});
//学员试听统计
var stuReserveList = visitor_ReserveRepository.GetStuReserveStaticsListRepository(new Model.ViewModel.Reserve.RB_Visitor_Reserve_Extend()
{
QVisitor_Ids = stuIds
});
var provideList = list.Where(qitem => qitem.ProviceId > 0).Select(qitem => qitem.ProviceId).ToList();
var cityList = list.Where(qitem => qitem.CityId > 0).Select(qitem => qitem.CityId).ToList();
var areaList = list.Where(qitem => qitem.AreaId > 0).Select(qitem => qitem.AreaId).ToList();
List ids = new List();
if (provideList != null && provideList.Count > 0)
{
ids.AddRange(provideList);
}
if (cityList != null && cityList.Count > 0)
{
ids.AddRange(cityList);
}
if (areaList != null && areaList.Count > 0)
{
ids.AddRange(areaList);
}
string qIds = "";
if (ids != null && ids.Count > 0)
{
qIds = string.Join(",", ids);
}
else
{
qIds = "0";
}
var destinationList = destinationRepository.GetDestinationListRepository(new Model.ViewModel.System.RB_Destination_ViewModel() { Ids = qIds });
//同业录入列表
List customerList = new List();
List customerIdList = Common.ConvertHelper.StringToList(string.Join(",", list.Where(qitem => qitem.CreateType == StuCreateTypeEnum.CustomerInput).Select(qitem => qitem.StuSourceId)));
if (customerIdList != null && customerIdList.Count > 0)
{
customerList = customerRepository.GetCustomerListRepository(new RB_Customer_Extend()
{
CustomerIds = string.Join(",", customerIdList)
});
}
List transStudentList = new List();
//转介人列表
List transIdList = Common.ConvertHelper.StringToList(string.Join(",", list.Where(qitem => qitem.CreateType == StuCreateTypeEnum.TransIntroduction).Select(qitem => qitem.StuSourceId)));
if (transIdList != null && transIdList.Count > 0)
{
transStudentList = studentRepository.GetStudentListRepository(new RB_Student_ViewModel()
{
StuIds = string.Join(",", transIdList)
});
}
//学习目的
string goalIds = string.Join(",", list?.Where(qitem => !string.IsNullOrWhiteSpace(qitem.StuPurpose))?.Select(qitem => qitem.StuPurpose));
var goalList = learningGoalsRepository.GetLearningGoalsListRepository(new Model.ViewModel.System.RB_LearningGoals_Extend()
{
QGoalIds = goalIds
});
string channelIds = string.Join(",", list.Select(qitem => qitem.StuChannel));
var channelList = channelRepository.GetChannelListRepository(new Model.ViewModel.System.RB_Channel_Extend()
{
QChannelIds = channelIds
});
var needIds = string.Join(",", list.Select(qitem => qitem.StuNeeds));
var needList = needsRepository.GetNeedsListRepository(new Model.ViewModel.System.RB_Needs_Extend()
{
QNeedsId = needIds
});
//课程顾问跟进信息
List advisorList = student_AdvisorRepository.GetStudentAdvisorListRepository(new RB_Student_Advisor_Extend() { QStuIds = stuIds });
foreach (var item in list)
{
var tempOrderList = stuOrderList?.Where(qitem => qitem.Student_Id == item.StuId)?.ToList();
var tempFollow = followList?.Where(qitem => qitem.StuId == item.StuId)?.OrderByDescending(qitem => qitem.Id)?.FirstOrDefault();
item.followUpTime = Common.ConvertHelper.FormatTime(tempFollow?.CreateTime);
item.WeekCount = stuList?.Count() ?? 0;
item.TodayCount = stuList?.Where(qitem => Common.ConvertHelper.FormatDate(qitem.CreateTime) == Common.ConvertHelper.FormatDate(DateTime.Now))?.Count() ?? 0;
item.OrderCount = tempOrderList?.Count() ?? 0;
item.RenewOrderCount = tempOrderList?.Where(qitem => qitem.RenewState == 2)?.Count() ?? 0;
item.StuGuestState = tempOrderList?.OrderByDescending(qitem => qitem.OrderId)?.LastOrDefault()?.StuGuestState ?? 0;
item.AreaName = (destinationList?.FirstOrDefault(qitem => qitem.ID == item.ProviceId)?.Name ?? "")
+ "/" + (destinationList?.FirstOrDefault(qitem => qitem.ID == item.CityId)?.Name ?? "")
+ "/" + (destinationList?.FirstOrDefault(qitem => qitem.ID == item.AreaId)?.Name ?? "");
var tempAssistList = assistList?.Where(qitem => qitem.StuId == item.StuId)?.ToList();
foreach (var sItem in tempAssistList)
{
sItem.AssistName = accountList?.FirstOrDefault(qitem => qitem.Id == sItem.AssistId)?.AccountName ?? "";
}
item.AssistList = tempAssistList;
item.VisitCount = visitList?.FirstOrDefault(qitem => qitem.StuId == item.StuId)?.VisitCount ?? 0;
item.TrialLessonCount = stuReserveList?.FirstOrDefault(qitem => qitem.Visitor_Id == item.StuId)?.TrialLessonCount ?? 0;
if (item.CreateType == StuCreateTypeEnum.InternalIntroduction)
{
item.StuSourceIdName = accountList?.FirstOrDefault(qitem => qitem.Id == item.StuSourceId)?.AccountName ?? "";
}
else if (item.CreateType == StuCreateTypeEnum.CustomerInput)
{
var tempCustomer = customerList?.FirstOrDefault(qitem => qitem.CustomerId == item.StuSourceId);
item.StuSourceIdName = tempCustomer?.CustomerName ?? "";
if (tempCustomer != null)
{
if (tempCustomer.CustomerType == Common.Enum.Customer.CatetoryTypeEnum.Other)
{
item.EnterpriseName = tempCustomer?.EnterpriseName ?? "";
}
else
{
item.EnterpriseName = tempCustomer?.CategoryName ?? "";
}
}
else
{
item.EnterpriseName = "";
}
}
else if (item.CreateType == StuCreateTypeEnum.TransIntroduction)
{
item.StuSourceIdName = transStudentList?.FirstOrDefault(qitem => qitem.StuId == item.StuSourceId)?.StuName ?? "";
}
item.StuStageName = stageList?.FirstOrDefault(qitem => qitem.Id == item.StuStage)?.StageName ?? "";
item.StuTypeName = stuTypeList?.FirstOrDefault(qitem => qitem.Id == item.StuType)?.Name ?? "";
item.StuChannelName = channelList?.FirstOrDefault(qitem => qitem.Id == item.StuChannel)?.Name ?? "";
item.StuPurposeName = !string.IsNullOrWhiteSpace(item.StuPurpose) ? (string.Join(",", goalList?.Where(qitem => item.StuPurpose.Contains(qitem.Id.ToString()))?.Select(x => x.Name)) ?? "") : "";
item.StuNeedsName = needList?.FirstOrDefault(qitem => qitem.Id == item.StuNeeds)?.Name ?? "";
item.AdvisorList = advisorList?.Where(qitem => qitem.StuId == item.StuId)?.ToList() ?? new List();
item.CreateByName = accountList?.FirstOrDefault(qitem => qitem.Id == item.CreateBy)?.AccountName ?? "";
}
}
return list;
}
///
/// 检查学员是否存在资料库
///
///
/// 1-电话,2-QQ,3-微信号
///
public bool CheckStudentModule(RB_Student_ViewModel model, int Type)
{
List where = new List()
{
new WhereHelper(nameof(RB_Student_ViewModel.Group_Id),model.Group_Id),
new WhereHelper(nameof(RB_Student_ViewModel.Status),(int)DateStateEnum.Normal),
};
if (Type == 1)
{
where.Add(new WhereHelper(nameof(RB_Student_ViewModel.StuRealMobile), model.StuRealMobile));
}
if (Type == 2)
{
where.Add(new WhereHelper(nameof(RB_Student_ViewModel.QQ), model.QQ));
}
if (Type == 3)
{
where.Add(new WhereHelper(nameof(RB_Student_ViewModel.WeChatNo), model.WeChatNo));
}
if (model.StuId > 0)
{
where.Add(new WhereHelper()
{
FiledName = nameof(RB_Student_ViewModel.StuId),
FiledValue = model.StuId,
OperatorEnum = OperatorEnum.NotEqual
});
}
var NewId = studentRepository.Exists("StuId", where);
return NewId > 0;
}
///
/// 跟进电话号码获取学员信息
///
///
///
public RB_Student_ViewModel CheckExistsStuModule(RB_Student_ViewModel query)
{
var model = studentRepository.GetStuByTelRepository(query);
return model;
}
///
/// 添加修改学生
///
///
/// 来至于同业 1是
///
public bool SetStudentModule(RB_Student_ViewModel model, int fromApp = 0)
{
bool IsInsert = false;
if (model.StuId == 0) { IsInsert = true; }
bool flag = studentRepository.SetStudentRepository(model);
if (flag)
{
if (IsInsert && model.CustomerId > 0 && fromApp == 1)
{
var queryTargetWorkId = accountModule.GetWorkUserIdModule(model.CreateBy);
if (!string.IsNullOrEmpty(queryTargetWorkId))
{
var cmodel = customerRepository.GetEntity(model.CustomerId);
var path = $"/sale/visitorRegistrat?StuId={model.StuId}";
path = System.Web.HttpUtility.UrlEncode(path);
string markdownContent = $"`同业添加学生通知` \n>**概要信息** \n>同业名称:{cmodel.CustomerName}({cmodel.ContactNumber})\n>学生名称:{model.StuName}\n>学生电话:{model.StuTel}\n>请点击:[查看详情]({Common.Config.ErpUrl}/autologin?loginId={model.CreateBy}&target={path})";
Common.Message.PushMessageModel modelWork = new Common.Message.PushMessageModel()
{
CategoryId = Common.Enum.System.PushMessageCategoryEnum.B2BCustomerStu,
Content = markdownContent,
CoverImg = "",
CreateByName = "系统",
JumpUrl = "",
WorkMsgType = "markdown",
SendTime = DateTime.Now,
SendType = 0,
Title = "同业添加学生通知",
Platform = 5,
ReceiveId = queryTargetWorkId
};
List pushList = new List() { modelWork };
new Common.Message.MessageHelper().SendMessage(pushList);
}
}
}
return flag;
}
///
/// 修改客户阶段
///
///
///
///
///
public bool SetStudentStageModule(int StuId, int StuStage, int Uid)
{
return studentRepository.SetStudentStageRepository(StuId, StuStage, Uid);
}
///
/// 获取协助人员列表
///
///
///
public List GetStuAssistListModule(int StuId)
{
var list = student_AssistRepository.GetStudentAssistListRepository(new RB_Student_Assist_Extend()
{
StuId = StuId
});
return list;
}
///
/// 学员转交
///
/// 学员编号
/// 负责人
/// 操作人
///
public bool ForwardStudentModule(string StuIds, int CreateBy, int OperateId)
{
return studentRepository.ForwardStudentRepository(StuIds, CreateBy, OperateId);
}
///
/// 根据学生编号获取学生实体类
///
///
///
public RB_Student_ViewModel GetStudentModule(int StuId)
{
var extModel = studentRepository.GetEntity(StuId);
if (extModel != null && extModel.StuId > 0)
{
var assistList = student_AssistRepository.GetStudentAssistListRepository(new RB_Student_Assist_Extend()
{
StuId = extModel.StuId
});
//学员订单
var stuOrderList = student_OrderGuestRepository.GetStrOrderGuestListStaticRepository(new RB_Student_OrderGuest_ViewModel()
{
QStudentIds = extModel.StuId.ToString()
});
extModel.OrderCount = stuOrderList?.Count() ?? 0;
extModel.AssistList = assistList;
extModel.StuStageName = stageRepository.GetEntity(extModel.StuStage)?.StageName ?? "";
extModel.StuTypeName = student_TypeRepository.GetEntity(extModel.StuType)?.Name ?? "";
extModel.StuPurposeName = !string.IsNullOrWhiteSpace(extModel.StuPurpose) ? (string.Join(",", learningGoalsRepository.GetLearningGoalsListRepository(new Model.ViewModel.System.RB_LearningGoals_Extend { QGoalIds = extModel.StuPurpose }).Select(x => x.Name)) ?? "") : "";
extModel.StuChannelName = channelRepository.GetChannelExtEntityRepository(extModel.StuChannel)?.Name ?? "";
extModel.StuNeedsName = needsRepository.GetNeedsExtEntityRepository(extModel.StuNeeds)?.Name ?? "";
//if (extModel.CustomerId > 0)
//{
// extModel.CustomerName = customerRepository.GetEntity(extModel.CustomerId)?.CustomerName ?? "";
//}
if (extModel.StuSourceId > 0)
{
if (extModel.CreateType == StuCreateTypeEnum.CustomerInput)
{
var customerName = customerRepository.GetEntity(extModel.StuSourceId)?.CustomerName ?? "";
extModel.StuSourceIdName = customerName;
extModel.CustomerName = customerName;
}
else if (extModel.CreateType == StuCreateTypeEnum.EmployeeInput)
{
extModel.StuSourceIdName = accountModule.GetEmployeeInfo(extModel.StuSourceId)?.EmployeeName ?? "";
}
else if (extModel.CreateType == StuCreateTypeEnum.InternalIntroduction)
{
extModel.StuSourceIdName = accountModule.GetEmployeeInfo(extModel.StuSourceId)?.EmployeeName ?? "";
}
else if (extModel.CreateType == StuCreateTypeEnum.TransIntroduction)
{
extModel.StuSourceIdName = studentRepository.GetEntity(extModel.StuSourceId)?.StuName ?? "";
}
}
}
return extModel;
}
///
/// 更新学生状态
///
///
///
///
public bool RemoveStudentModule(int StuId, int Status)
{
bool flag = false;
var model = GetStudentModule(StuId);
if (model != null && model.StuId > 0)
{
Dictionary fileds = new Dictionary()
{
{nameof(RB_Student_ViewModel.Status), Status},
};
flag = studentRepository.Update(fileds, new WhereHelper(nameof(RB_Student_ViewModel.StuId), StuId));
var accountList = accountModule.GetAccountListExtModule(new RB_Account_ViewModel()
{
AccountId = model.StuId,
Account = model.StuTel,
AccountType = AccountTypeEnum.Student
});
if (accountList != null && accountList.Count > 0)
{
flag = accountModule.SetAccountStatusModule(new RB_Account_ViewModel()
{
AccountType = AccountTypeEnum.Student,
AccountId = model.StuId,
UpdateTime = DateTime.Now,
Status = (DateStateEnum)Status
});
}
}
return flag;
}
///
/// 更新学员【禁用、启用】
///
///
/// 0-禁用,1-启用
///
public bool UpdateStudentIsDisableModule(object StuId, int IsDisable)
{
bool flag;
Dictionary fileds = new Dictionary()
{
{nameof(RB_Student_ViewModel.IsDisable), IsDisable},
};
flag = studentRepository.Update(fileds, new WhereHelper(nameof(RB_Student_ViewModel.StuId), StuId));
return flag;
}
///
/// 创建学生账号
///
///
///
///
[TransactionCallHandler]
public virtual bool CreateStudentAccountModule(int StuId, UserInfo user)
{
bool flag = false;
var model = GetStudentModule(StuId);
if (model != null && model.StuId > 0)
{
var accountList = accountModule.GetAccountListExtModule(new RB_Account_ViewModel()
{
Account = model.StuTel,
AccountType = AccountTypeEnum.Student
});
if (accountList == null || (accountList != null && accountList.Count == 0))
{
flag = accountModule.SetAccountModule(new RB_Account_ViewModel()
{
Account = model.StuTel,
Password = Common.DES.Encrypt(Common.Config.DefaultPwd),
AccountType = AccountTypeEnum.Student,
AccountId = model.StuId,
CreateBy = user.Id,
UpdateBy = user.Id,
CreateTime = DateTime.Now,
UpdateTime = DateTime.Now,
Group_Id = model.Group_Id,
School_Id = model.School_Id,
Status = model.Status
});
}
}
return flag;
}
#region 学生兴趣爱好
///
/// 新增学生兴趣
///
///
///
public bool SetStudentInterest(RB_Student_ViewModel model)
{
if (model.StuId == 0)
{
return false;
}
else
{
Dictionary fileds = new Dictionary()
{
{nameof(RB_Student_ViewModel.Interest),model.Interest },
{nameof(RB_Student_ViewModel.JapanBaseInfo),(int)model.JapanBaseInfo },
{nameof(RB_Student_ViewModel.StuIcon),model.StuIcon.Trim() },
{nameof(RB_Student_ViewModel.StuSex),model.StuSex },
{nameof(RB_Student_ViewModel.UpdateTime),System.DateTime.Now }
};
return studentRepository.Update(fileds, new WhereHelper(nameof(RB_Student_ViewModel.StuId), model.StuId));
}
}
#endregion
///
/// 根据学生id获取同班账户,必须是未开班/学习中的
///
///
///
public List GetListByStudentId(int Student_Id, int Group_Id)
{
return studentRepository.GetListByStudentId(Student_Id, Group_Id);
}
///
/// 根据学生id获取学生的班级课程学校信息
///
///
///
public List GetStudentInfoModule(int Student_Id, int 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;
}
///
/// 获取约课课程上课次数
///
///
///
///
public RB_Student_ViewModel GetStudentClassNumber(int guestId, int groupId)
{
return studentRepository.GetStudentClassNumber(guestId.ToString(), groupId).FirstOrDefault();
}
///
/// 推送消息
///
///
/// 1-手机,2-QQ,3-微信
public void PushMessageModule(RB_Student_ViewModel model, int type)
{
var assistList = GetStuAssistListModule(model.StuId);
var customerModel = customerRepository.GetEntity(model.CustomerId);
string searchContent = model.StuTel + "(学员电话)";
if (type == 2)
{
searchContent = model.QQ + "(学员电话)";
}
if (type == 3)
{
searchContent = model.WeChatNo + "(学员微信)";
}
string createByName = accountModule.GetAccountListExtModule(new RB_Account_ViewModel()
{
Id = model.CreateBy
})?.FirstOrDefault()?.AccountName ?? "";
string markdownContent = $"`同业查重通知` \n>**概要信息** \n>同业名称:{customerModel?.CustomerName ?? ""}({customerModel?.ContactNumber ?? ""})\n>查询内容:{searchContent} \n>关联学员:{model.StuName}\n>";
markdownContent += $"关联同事:{createByName}\n> ";
Common.Message.PushMessageModel modelWork = new Common.Message.PushMessageModel()
{
CategoryId = PushMessageCategoryEnum.B2BCustomerStu,
Content = markdownContent,
CoverImg = "",
CreateByName = "系统",
JumpUrl = "",
WorkMsgType = "markdown",
SendTime = DateTime.Now,
SendType = 0,
Title = "同业查重通知",
Platform = 5,
};
if (customerModel != null && customerModel.CreateBy > 0)
{
var queryTargetWorkId = accountModule.GetWorkUserIdModule(customerModel.CreateBy);
modelWork.ReceiveId = queryTargetWorkId;
List pushList = new List() { modelWork };
new Common.Message.MessageHelper().SendMessage(pushList);
}
//if (assistList != null && assistList.Count > 0)
//{
// foreach (var item in assistList)
// {
// var queryTargetWorkId = accountModule.GetWorkUserIdModule(item.AssistId);
// modelWork.ReceiveId = queryTargetWorkId;
// Common.Message.MessageHelper.SendMessage(modelWork);
// }
//}
}
#region 小程序用户
///
/// 根据条件获取用户实体
///
///
///
public RB_Member_User_Extend GetMemberUserEntityModule(RB_Member_User_Extend query)
{
return member_UserRepository.GetMemberUserEntityRepository(query);
}
#endregion
///
/// 今日新名单
///
///
public object GetStudentTodayStaticModule(int createBy)
{
DateTime startTime = DateTime.Now.AddMonths(-1);
string startDate = Common.ConvertHelper.FormatDate(startTime);
var today = Common.ConvertHelper.FormatDate(DateTime.Now);
//今日新增名单
var addList = studentRepository.GetStudentStaticRepository(createBy.ToString(), startDate, today);
int days = (DateTime.Now - startTime).Days;
List