Commit 0a468820 authored by liudong1993's avatar liudong1993

新增学生时,自动创建学生账号

parent 4c05590e
......@@ -66,6 +66,18 @@ namespace Edu.Module.Course
/// 助教
/// </summary>
private readonly RB_AssistRepository assistRepository = new RB_AssistRepository();
/// <summary>
/// 学生
/// </summary>
private readonly RB_StudentRepository studentRepository = new RB_StudentRepository();
/// <summary>
/// 学生关联
/// </summary>
private readonly RB_Student_OrderGuestRepository student_OrderGuestRepository = new RB_Student_OrderGuestRepository();
/// <summary>
/// 账号
/// </summary>
private readonly RB_AccountRepository accountRepository = new RB_AccountRepository();
#region 日语培训
......@@ -459,6 +471,30 @@ namespace Edu.Module.Course
return orderList;
}
/// <summary>
/// 设置订单使用最新的班级价格
/// </summary>
/// <param name="orderId"></param>
/// <param name="userInfo"></param>
/// <returns></returns>
public bool SetClassOrderUseNewClassPrice(int orderId, UserInfo userInfo)
{
var demodel = orderRepository.GetEntity(orderId);
//查询班级信息
var classModel = classRepository.GetEntity(demodel.ClassId);
if (classModel == null)
{
return false;
}
List<RB_Class_StepPrice_ViewModel> spList = new List<RB_Class_StepPrice_ViewModel>();
if (classModel.IsStepPrice == 1)
{
spList = class_StepPriceRepository.GetClassStepPriceListRepository(new RB_Class_StepPrice_ViewModel() { ClassId = demodel.ClassId });
}
return true;
}
/// <summary>
/// 更新订单销售
/// </summary>
......@@ -804,6 +840,7 @@ namespace Edu.Module.Course
bool flag = order_GuestRepository.Update(gModel);
if (flag)
{
//记录日志
changeLogRepository.Insert(new Model.Entity.Log.RB_User_ChangeLog()
{
Id = 0,
......@@ -831,6 +868,79 @@ namespace Edu.Module.Course
bool flag = Id > 0;
if (flag)
{
var classmodel = classRepository.GetEntity(ordermodel.ClassId);
//验证账号是否存在
var accmodel = accountRepository.GetAccountListRepository(new RB_Account_ViewModel() { Group_Id = dmodel.Group_Id, AccountType = Common.Enum.User.AccountTypeEnum.Student, Account = dmodel.Mobile }).FirstOrDefault();
string LogContent = "新增学生名单【" + Id + "】";
if (accmodel != null)
{
student_OrderGuestRepository.Insert(new Model.Entity.User.RB_Student_OrderGuest()
{
Id = 0,
Account_Id = accmodel.Id,
ClassId = ordermodel.ClassId,
CreateBy = dmodel.CreateBy,
CreateTime = DateTime.Now,
GuestId = Id,
OrderId = dmodel.OrderId,
Status = DateStateEnum.Normal,
Student_Id = accmodel.AccountId
});
LogContent += ",添加学生账号关联【" + accmodel.Id + "】";
}
else
{
//创建学生账号
int StudentId = studentRepository.Insert(new Model.Entity.User.RB_Student()
{
StuId = 0,
AreaId = 0,
CityId = 0,
CreateBy = dmodel.CreateBy,
CreateTime = DateTime.Now,
Group_Id = dmodel.Group_Id,
IsDisable = 1,
ProviceId = 0,
School_Id = classmodel.School_Id,
Status = DateStateEnum.Normal,
StuBirth = null,
StuIcon = "",
StuName = dmodel.GuestName,
StuSex = dmodel.Sex - 1,
StuTel = dmodel.Mobile,
UpdateBy = dmodel.CreateBy,
UpdateTime = DateTime.Now
});
int AccountId = accountRepository.Insert(new Model.Entity.User.RB_Account()
{
Id = 0,
Account = dmodel.Mobile,
AccountId = StudentId,
AccountType = Common.Enum.User.AccountTypeEnum.Student,
AnnualLeaveDay = 0,
CreateBy = dmodel.CreateBy,
CreateTime = DateTime.Now,
Group_Id = dmodel.Group_Id,
School_Id = classmodel.School_Id,
Status = DateStateEnum.Normal,
UpdateBy = dmodel.UpdateBy,
UpdateTime = DateTime.Now,
Password = Common.DES.Encrypt(Common.Config.DefaultPwd)
});
student_OrderGuestRepository.Insert(new Model.Entity.User.RB_Student_OrderGuest()
{
Id = 0,
Account_Id = AccountId,
ClassId = ordermodel.ClassId,
CreateBy = dmodel.CreateBy,
CreateTime = DateTime.Now,
GuestId = Id,
OrderId = dmodel.OrderId,
Status = DateStateEnum.Normal,
Student_Id = StudentId
});
LogContent += ",自动创建学生账号【" + AccountId + "】";
}
changeLogRepository.Insert(new Model.Entity.Log.RB_User_ChangeLog()
{
Id = 0,
......@@ -838,7 +948,7 @@ namespace Edu.Module.Course
CreateBy = dmodel.CreateBy,
CreateTime = DateTime.Now,
Group_Id = dmodel.Group_Id,
LogContent = "新增学生名单【" + Id + "】",
LogContent = LogContent,
School_Id = dmodel.School_Id,
SourceId = dmodel.OrderId
});
......@@ -869,6 +979,22 @@ namespace Edu.Module.Course
if (flag)
{
var gmodel = order_GuestRepository.GetEntity(guestId);
//查询学生账号
//var sModel = student_OrderGuestRepository.GetStrOrderGuestListRepository(new RB_Student_OrderGuest_ViewModel() { OrderId = gmodel?.OrderId ?? 0, GuestId = guestId }).FirstOrDefault();
//if (sModel != null) {
// //更新账号表
// Dictionary<string, object> valuePairs = new Dictionary<string, object>() {
// { nameof(RB_Account_ViewModel.Status),DateStateEnum.Delete}
// };
// List<WhereHelper> wheres1 = new List<WhereHelper>() {
// new WhereHelper(){
// FiledName=nameof(RB_Account_ViewModel.Id),
// FiledValue=sModel.Account_Id,
// OperatorEnum=OperatorEnum.Equal
// }
// };
// accountRepository.Update(valuePairs, wheres1);
//}
changeLogRepository.Insert(new Model.Entity.Log.RB_User_ChangeLog()
{
Id = 0,
......
......@@ -544,8 +544,23 @@ namespace Edu.WebApi.Controllers.Course
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult SetClassOrderUseNewPrice() {
return ApiResult.Success();
public ApiResult SetClassOrderUseNewClassPrice()
{
var userInfo = base.UserInfo;
JObject parms = JObject.Parse(RequestParm.Msg.ToString());
int OrderId = parms.GetInt("OrderId", 0);
if (OrderId <= 0) {
return ApiResult.ParamIsNull();
}
bool flag = orderModule.SetClassOrderUseNewClassPrice(OrderId, userInfo);
if (flag)
{
return ApiResult.Success();
}
else {
return ApiResult.Failed();
}
}
#endregion
......@@ -602,7 +617,9 @@ namespace Edu.WebApi.Controllers.Course
if (string.IsNullOrEmpty(dmodel.GuestName)) {
return ApiResult.ParamIsNull("请输入客人姓名");
}
if (string.IsNullOrEmpty(dmodel.Mobile)) {
return ApiResult.ParamIsNull("请输入手机号码");
}
dmodel.GuestState = 1;
dmodel.Status = 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