Commit 026cc2b1 authored by 黄奎's avatar 黄奎

页面修改

parent 1e38f1c1
using Edu.Model.Entity.User;
using Edu.Common.Enum.Course;
using Edu.Common.Enum.Sale;
using Edu.Model.Entity.User;
using System;
using System.Collections.Generic;
using System.Text;
......@@ -10,6 +12,29 @@ namespace Edu.Model.ViewModel.User
/// </summary>
public class RB_Student_OrderGuest_ViewModel: RB_Student_OrderGuest
{
/// <summary>
/// 学员表编号【查询使用】
/// </summary>
public string QStudentIds { get; set; }
/// <summary>
/// 班级名称
/// </summary>
public string ClassName { get; set; }
/// <summary>
/// 班级编号
/// </summary>
public string ClassNo { get; set; }
/// <summary>
/// 订单类型
/// </summary>
public OrderJoinTypeEnum StuJoinType { get; set; }
/// <summary>
/// 学员状态
/// </summary>
public GuestStateEnum StuGuestState { get; set; }
}
}
using Edu.Common;
using Edu.Common.Enum.Course;
using System;
namespace Edu.Model.ViewModel.User
......@@ -120,5 +121,25 @@ namespace Edu.Model.ViewModel.User
/// 学生id(rb_order_guest的id)
/// </summary>
public int GuestId { get; set; }
/// <summary>
/// 关键字搜索
/// </summary>
public string KeyWords { get; set; }
/// <summary>
/// 订单数量
/// </summary>
public int OrderCount { get; set; }
/// <summary>
/// 续费订单数量
/// </summary>
public int RenewOrderCount { get; set; }
/// <summary>
/// 学员状态
/// </summary>
public GuestStateEnum StuGuestState { get; set; }
}
}
\ No newline at end of file
......@@ -41,6 +41,11 @@ namespace Edu.Module.User
/// </summary>
private readonly RB_Member_UserRepository member_UserRepository = new RB_Member_UserRepository();
/// <summary>
/// 学员订单关联表仓储层
/// </summary>
private readonly RB_Student_OrderGuestRepository student_OrderGuestRepository = new RB_Student_OrderGuestRepository();
/// <summary>
/// 获取学生列表
......@@ -65,6 +70,11 @@ namespace Edu.Module.User
var list = studentRepository.GetStudentPageListRepository(pageIndex, pageSize, out rowsCount, query);
if (list != null && list.Count > 0)
{
string stuIds = string.Join(",", list.Select(qitem => qitem.StuId));
var stuOrderList = student_OrderGuestRepository.GetStrOrderGuestListRepository(new RB_Student_OrderGuest_ViewModel()
{
QStudentIds = 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();
......@@ -93,6 +103,10 @@ namespace Edu.Module.User
var destinationList = destinationRepository.GetDestinationListRepository(new Model.ViewModel.System.RB_Destination_ViewModel() { Ids = qIds });
foreach (var item in list)
{
var tempOrderList = stuOrderList?.Where(qitem => qitem.Student_Id == item.StuId)?.ToList();
item.OrderCount = tempOrderList?.Count() ?? 0;
item.RenewOrderCount = tempOrderList?.Where(qitem => qitem.StuJoinType == Common.Enum.Sale.OrderJoinTypeEnum.RenewOrder)?.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 ?? "");
......@@ -101,6 +115,21 @@ namespace Edu.Module.User
return list;
}
/// <summary>
/// 检查学员是否存在资料库
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public bool CheckStudentModule(RB_Student_ViewModel model)
{
List<WhereHelper> where = new List<WhereHelper>()
{
new WhereHelper(nameof(RB_Student_ViewModel.Group_Id),model.Group_Id),
new WhereHelper(nameof(RB_Student_ViewModel.StuTel),model.StuTel),
};
return studentRepository.Exists(where);
}
/// <summary>
/// 添加修改学生
/// </summary>
......
......@@ -97,6 +97,10 @@ WHERE 1=1
{
builder.AppendFormat(" AND t.{0}={1} ", nameof(RB_Student_ViewModel.School_Id), query.School_Id);
}
if (query.CustomerId > 0)
{
builder.AppendFormat(" AND t.{0}={1} ", nameof(RB_Student_ViewModel.CustomerId), query.CustomerId);
}
if (!string.IsNullOrWhiteSpace(query.StuName))
{
builder.AppendFormat(" AND t.{0} LIKE @StuName ", nameof(RB_Student_ViewModel.StuName));
......@@ -107,6 +111,11 @@ WHERE 1=1
builder.AppendFormat(" AND t.{0} LIKE @StuTel ", nameof(RB_Student_ViewModel.StuTel));
parameters.Add("StuTel", "%" + query.StuTel.Trim() + "%");
}
if (!string.IsNullOrWhiteSpace(query.KeyWords))
{
builder.AppendFormat(" AND (t.{0} LIKE @KeyWords OR t.{1} LIKE @KeyWords) ", nameof(RB_Student_ViewModel.StuName), nameof(RB_Student_ViewModel.StuTel));
parameters.Add("KeyWords", "%" + query.KeyWords.Trim() + "%");
}
if (query.ProviceId > 0)
{
builder.AppendFormat(" AND t.{0}={1} ", nameof(RB_Student_ViewModel.ProviceId), query.ProviceId);
......
......@@ -22,32 +22,39 @@ namespace Edu.Repository.User
{
StringBuilder builder = new StringBuilder();
builder.AppendFormat(@"
SELECT *
FROM RB_Student_OrderGuest
SELECT A.*,IFNULL(B.ClassName,'') AS ClassName,IFNULL(B.ClassNo,'') AS ClassNo,IFNULL(C.JoinType,0) AS StuJoinType,IFNULL(D.GuestState,0) AS StuGuestState
FROM RB_Student_OrderGuest AS A LEFT JOIN rb_class AS B ON A.ClassId=B.ClassId
LEFT JOIN rb_order AS C ON A.OrderId=C.OrderId
LEFT JOIN rb_order_guest AS D ON A.GuestId=D.Id
WHERE 1=1
");
builder.AppendFormat(" AND {0}={1} ", nameof(RB_Student_OrderGuest_ViewModel.Status), (int)DateStateEnum.Normal);
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Student_OrderGuest_ViewModel.Status), (int)DateStateEnum.Normal);
if (query != null)
{
if (query.ClassId > 0)
{
builder.AppendFormat(" AND {0}={1} ", nameof(RB_Student_OrderGuest_ViewModel.ClassId), query.ClassId);
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Student_OrderGuest_ViewModel.ClassId), query.ClassId);
}
if (query.OrderId > 0)
{
builder.AppendFormat(" AND {0}={1} ", nameof(RB_Student_OrderGuest_ViewModel.OrderId), query.OrderId);
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Student_OrderGuest_ViewModel.OrderId), query.OrderId);
}
if (query.GuestId > 0)
{
builder.AppendFormat(" AND {0}={1} ", nameof(RB_Student_OrderGuest_ViewModel.GuestId), query.GuestId);
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Student_OrderGuest_ViewModel.GuestId), query.GuestId);
}
if (query.Student_Id > 0)
{
builder.AppendFormat(" AND {0}={1} ", nameof(RB_Student_OrderGuest_ViewModel.Student_Id), query.Student_Id);
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Student_OrderGuest_ViewModel.Student_Id), query.Student_Id);
}
if (!string.IsNullOrEmpty(query.QStudentIds))
{
builder.AppendFormat(" AND A.{0} IN({1}) ", nameof(RB_Student_OrderGuest_ViewModel.Student_Id), query.QStudentIds);
}
if (query.Account_Id > 0)
{
builder.AppendFormat(" AND {0}={1} ", nameof(RB_Student_OrderGuest_ViewModel.Account_Id), query.Account_Id);
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Student_OrderGuest_ViewModel.Account_Id), query.Account_Id);
}
}
return Get<RB_Student_OrderGuest_ViewModel>(builder.ToString()).ToList();
......
......@@ -737,10 +737,53 @@ namespace Edu.WebApi.Controllers.User
extModel.Group_Id = customer.GroupId;
extModel.CustomerId = customer.CustomerId;
extModel.IsDisable = 1;
if (studentModule.CheckStudentModule(extModel))
{
return ApiResult.Failed("此学员手机号已绑定同行!请重新录入!");
}
bool flag = studentModule.SetStudentModule(extModel);
return flag ? ApiResult.Success() : ApiResult.Failed();
}
/// <summary>
/// 同业小程序获取客户列表(学生列表)
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult AppGetStudentPage()
{
var pageModel = Common.Plugin.JsonHelper.DeserializeObject<ResultPageModel>(RequestParm.Msg.ToString());
var query = new RB_Student_ViewModel()
{
KeyWords=base.ParmJObj.GetStringValue("KeyWords"),
};
var customer = base.AppletCustomerInfo;
query.Group_Id = customer.GroupId;
//query.CustomerId = customer.CustomerId;
var list = studentModule.GetStudentPageListModule(pageModel.PageIndex, pageModel.PageSize, out long rowsCount, query);
List<object> result = new List<object>();
foreach (var item in list)
{
result.Add(new
{
item.StuId,
item.StuIcon,
item.StuTel,
item.StuSex,
StuSexStr = item.StuSex == 0 ? "男" : "女",
item.StuName,
item.OrderCount,
item.RenewOrderCount,
item.StuGuestState,
StuGuestStateStr = item.StuGuestState.ToName(),
});
}
pageModel.Count = rowsCount;
pageModel.PageData = result;
return ApiResult.Success(data: pageModel);
}
/// <summary>
/// 获取学生实体
/// </summary>
......
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