Commit 2faac006 authored by liudong1993's avatar liudong1993

小程序 教师课程

parent 3606f2da
......@@ -32,6 +32,11 @@ namespace Mall.Model.Extend.Point
/// </summary>
public string UserName { get; set; }
/// <summary>
/// 用户头像
/// </summary>
public string UserPhoto { get; set; }
/// <summary>
/// 开始时间
/// </summary>
......
......@@ -50,7 +50,15 @@ namespace Mall.Model.Extend.Point
/// </summary>
public int IsFree { get; set; }
/// <summary>
/// 确认数量
/// </summary>
public int ConfirmNum { get; set; }
/// <summary>
/// 课程状态 1未上课 2已上课
/// </summary>
public int CourseStudyState { get; set; }
/// <summary>
/// 学习开始时间
......
......@@ -2,9 +2,14 @@
using System.Collections.Generic;
using System.Text;
using Mall.Model.Extend.Point;
using Mall.Repository.Education;
using Mall.Repository.Point;
using Mall.Repository.User;
using VT.FW.DB;
using System.Linq;
using Mall.Common;
using Mall.Common.API;
using Mall.Common.Plugin;
namespace Mall.Module.Education
{
......@@ -23,6 +28,10 @@ namespace Mall.Module.Education
private readonly RB_Point_CourseClassRepository pointCourseClassRepository = new RB_Point_CourseClassRepository();
private readonly RB_Point_TeacherCourseRepository pointTeacherCourseRepository = new RB_Point_TeacherCourseRepository();
private readonly RB_Point_TeacherCourseOrderRepository pointTeacherCourseOrderRepository = new RB_Point_TeacherCourseOrderRepository();
/// <summary>
/// 教育老师
/// </summary>
private readonly RB_Education_TeacherRepository education_TeacherRepository = new RB_Education_TeacherRepository();
#region 点数商品
......@@ -327,6 +336,89 @@ namespace Mall.Module.Education
}
#endregion
#region 教师列表
/// <summary>
/// 获取教师上课分页列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="count"></param>
/// <param name="demodel"></param>
/// <returns></returns>
public List<RB_Point_TeacherCourse_Extend> GetPointTeacherCoursePageList(int pageIndex, int pageSize, out long count, RB_Point_TeacherCourse_Extend demodel)
{
var list = pointTeacherCourseRepository.GetPointTeacherCoursePageList(pageIndex, pageSize, out count, demodel);
return list;
}
/// <summary>
/// 获取教师课程明细
/// </summary>
/// <param name="courseId"></param>
/// <param name="teacherId"></param>
/// <param name="userInfo"></param>
/// <returns></returns>
public ApiResult GetPointTeacherCourseDetail(int courseId, int teacherId, AppletUserInfo userInfo)
{
var model = pointTeacherCourseRepository.GetEntity(courseId);
if (model == null) { return ApiResult.Failed("课程不存在"); }
if (model.TeacherId != teacherId) { return ApiResult.Failed("您不是该课程教师,无法查看"); }
var classModel = pointCourseClassRepository.GetEntity(model.CourseClassId);
if (classModel == null) { return ApiResult.Failed("课程分类不存在"); }
//查询该课程下所有的订单
var orderList = pointTeacherCourseOrderRepository.GetNormalPointOrderList(new RB_Point_TeacherCourseOrder_Extend() { TenantId = userInfo.TenantId, CourseId = courseId });
return ApiResult.Success("", new
{
model.ID,
model.CourseClassId,
classModel.CourseClassType,
CourseClassTypeName = classModel.CourseClassType.GetEnumName(),
classModel.StudentNumType,
StudentNumTypeName = classModel.StudentNumType.GetEnumName(),
model.CourseName,
model.TeacherId,
StudyDate = model.StudyDate.ToString("yyyy-MM-dd"),
model.StudyStartDate,
model.StudyEndDate,
model.PointNum,
model.MinDuration,
model.StudyDuration,
DurationUnit = model.DurationUnit.GetEnumName(),
OrderList = orderList.Select(x=>new {
x.ID,
x.UserId,
x.UserName,
x.UserPhoto,
StudyDate = x.StudyDate.ToString("yyyy-MM-dd HH:mm"),
x.StudyDuration,
x.TotalStudyDuration,
DurationUnit = x.DurationUnit.GetEnumName(),
x.OrderStaus,
OrderStausName = x.OrderStaus.GetEnumName(),
x.IsSendRoom,
x.RoomInfo,
x.TotalPointNum,
x.ActualPointNum,
x.BasePointNum,
CreateDate = x.CreateDate.HasValue ? x.CreateDate.Value.ToString("yyyy-MM-dd HH:mm:ss") : "",
})
});
}
/// <summary>
/// 获取教师id
/// </summary>
/// <param name="tid"></param>
/// <param name="userId"></param>
/// <returns></returns>
public int GetUserTeacherId(int tid, int userId)
{
var model = education_TeacherRepository.GetTeacherList(new Model.Extend.Education.RB_Education_Teacher_Extend() { TenantId = tid, UserId = userId, TeacherStatus = 1 }).FirstOrDefault();
return model?.ID ?? 0;
}
#endregion
#region 在线课程分类
/// <summary>
......
......@@ -78,7 +78,7 @@ namespace Mall.Repository.Education
{
builder.Append($" AND a.{nameof(RB_Education_Teacher_Extend.TenantId)}={query.TenantId}");
}
if (query.TenantId > 0)
if (query.MallBaseId > 0)
{
builder.Append($" AND a.{nameof(RB_Education_Teacher_Extend.MallBaseId)}={query.MallBaseId}");
}
......
......@@ -41,7 +41,59 @@ namespace Mall.Repository.Point
return Get<RB_Point_TeacherCourseOrder_Extend>(sb.ToString()).ToList();
}
/// <summary>
/// 获取正常订单列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="rowsCount"></param>
/// <param name="where"></param>
/// <returns></returns>
public List<RB_Point_TeacherCourseOrder_Extend> GetNormalPointOrderList(RB_Point_TeacherCourseOrder_Extend where)
{
StringBuilder sb = new StringBuilder();
sb.Append($@"SELECT a.*,b.`Name` as UserName,b.Photo as UserPhoto
from RB_Point_TeacherCourseOrder as a
LEFT JOIN rb_member_user as b on a.UserId=b.Id
where a.state=0 and a.OrderStaus in(2,3,4)");
if (where != null)
{
if (where.TenantId > 0)
{
sb.AppendFormat(" and a.TenantId={0}", where.TenantId);
}
if (where.MallBaseId > 0)
{
sb.AppendFormat(" and a.MallBaseId={0}", where.MallBaseId);
}
if (where.ID > 0)
{
sb.AppendFormat(" and a.ID={0}", where.ID);
}
if (where.TeacherId > 0)
{
sb.AppendFormat(" and a.TeacherId={0}", where.TeacherId);
}
if (where.CourseId > 0)
{
sb.AppendFormat(" and a.CourseId={0}", where.CourseId);
}
if (where.UserId > 0)
{
sb.AppendFormat(" and a.UserId={0}", where.UserId);
}
if (!string.IsNullOrEmpty(where.StartTime))
{
sb.AppendFormat(" and a.CreateDate >='{0}'", where.StartTime);
}
if (!string.IsNullOrEmpty(where.EndTime))
{
sb.AppendFormat(" and a.CreateDate <='{0}'", where.EndTime + " 23:59:59");
}
}
sb.AppendFormat(" order by a.ID desc");
return Get<RB_Point_TeacherCourseOrder_Extend>(sb.ToString()).ToList();
}
/// <summary>
......
......@@ -118,5 +118,70 @@ LEFT JOIN rb_education_teacher as et on tc.TeacherId=et.ID
}
return GetPage<RB_Point_TeacherCourse_Extend>(pageIndex, pageSize, out rowsCount, sb.ToString()).ToList();
}
/// <summary>
/// 获取分页列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="count"></param>
/// <param name="where"></param>
/// <returns></returns>
public List<RB_Point_TeacherCourse_Extend> GetPointTeacherCoursePageList(int pageIndex, int pageSize, out long count, RB_Point_TeacherCourse_Extend where)
{
StringBuilder sb = new StringBuilder();
sb.Append($@"SELECT tc.*,cc.CourseClassType,cc.StudentNumType,cc.IsPublic,cc.IsFree,o.ConfirmNum,o.OrderNum
from RB_Point_TeacherCourse as tc
LEFT JOIN rb_point_courseclass as cc on tc.CourseClassId=cc.ID
left join (SELECT CourseId,SUM(case when OrderStaus =2 then 1 else 0 end) AS ConfirmNum,COUNT(0) AS OrderNum
FROM rb_point_teachercourseorder WHERE State =0 and OrderStaus in (2,3,4) GROUP BY CourseId) o on tc.ID =o.CourseId
where tc.state=0 and cc.state=0 ");
if (where != null)
{
if (where.TenantId > 0)
{
sb.AppendFormat(" and tc.TenantId={0}", where.TenantId);
}
if (where.MallBaseId > 0)
{
sb.AppendFormat(" and tc.MallBaseId={0}", where.MallBaseId);
}
if (where.MallBaseId > 0)
{
sb.AppendFormat(" and tc.MallBaseId={0}", where.MallBaseId);
}
if (where.CourseClassId > 0)
{
sb.AppendFormat(" and tc.CourseClassId={0}", where.CourseClassId);
}
if (where.TeacherId > 0)
{
sb.AppendFormat(" and tc.TeacherId={0}", where.TeacherId);
}
if (!string.IsNullOrEmpty(where.SelectStartTime))
{
sb.AppendFormat(" AND DATE_FORMAT(tc.{0},'%y-%m-%d')>=DATE_FORMAT('{1}','%y-%m-%d') ", nameof(RB_Point_TeacherCourse_Extend.StudyDate), where.SelectStartTime);
}
if (!string.IsNullOrEmpty(where.SelectEndTime))
{
sb.AppendFormat(" AND DATE_FORMAT(tc.{0},'%y-%m-%d')<=DATE_FORMAT('{1}','%y-%m-%d') ", nameof(RB_Point_TeacherCourse_Extend.StudyDate), where.SelectEndTime);
}
if (where.ID > 0)
{
sb.AppendFormat(" and tc.ID={0}", where.ID);
}
if (where.CourseStudyState > 0) {
if (where.CourseStudyState == 1)
{
sb.AppendFormat(" AND CONCAT(DATE_FORMAT(StudyDate,'%Y-%m-%d'),' ',StudyEndDate) >= '{1}' ", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
}
else if (where.CourseStudyState == 2)
{
sb.AppendFormat(" AND CONCAT(DATE_FORMAT(StudyDate,'%Y-%m-%d'),' ',StudyEndDate) < '{1}' ", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
}
}
}
return GetPage<RB_Point_TeacherCourse_Extend>(pageIndex, pageSize, out count, sb.ToString()).ToList();
}
}
}
......@@ -63,6 +63,71 @@ namespace Mall.WebApi.Controllers.Education
}
#endregion
#region 老师课程
/// <summary>
/// 获取老师课程列表分页列表
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetPointTeacherCoursePageList()
{
var parms = RequestParm;
var userInfo = AppletUserInfo;
ResultPageModel pagelist = JsonConvert.DeserializeObject<ResultPageModel>(RequestParm.msg.ToString());
RB_Point_TeacherCourse_Extend demodel = JsonConvert.DeserializeObject<RB_Point_TeacherCourse_Extend>(RequestParm.msg.ToString());
demodel.TenantId = userInfo.TenantId;
demodel.MallBaseId = userInfo.MallBaseId;
//根据userid 查询teacherid
int TeacherId = pointModule.GetUserTeacherId(userInfo.TenantId, userInfo.UserId);
if (TeacherId <= 0) { return ApiResult.Failed("不是教师,无法查询"); }
demodel.TeacherId = TeacherId;
var list = pointModule.GetPointTeacherCoursePageList(pagelist.pageIndex, pagelist.pageSize, out long count, demodel);
pagelist.count = Convert.ToInt32(count);
pagelist.pageData = list.Select(x => new
{
x.ID,
x.CourseClassId,
x.CourseClassType,
CourseClassTypeName = x.CourseClassType.GetEnumName(),
x.CourseName,
x.TeacherId,
StudyDate = x.StudyDate.ToString("yyyy-MM-dd"),
x.StudyStartDate,
x.StudyEndDate,
x.PointNum,
x.MinDuration,
x.StudyDuration,
DurationUnit = x.DurationUnit.GetEnumName(),
x.ConfirmNum,
x.OrderNum,
CreateDate = x.CreateDate.HasValue ? x.CreateDate.Value.ToString("yyyy-MM-dd HH:mm:ss") : "",
});
return ApiResult.Success("", pagelist);
}
/// <summary>
/// 获取老师课程明细
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetPointTeacherCourseDetail() {
var userInfo = AppletUserInfo;
var parms = JObject.Parse(RequestParm.msg.ToString());
int CourseId = parms.GetInt("CourseId", 0);//课程Id
if (CourseId <= 0) {
return ApiResult.ParamIsNull("课程id不存在,请核实后再试");
}
//根据userid 查询teacherid
int TeacherId = pointModule.GetUserTeacherId(userInfo.TenantId, userInfo.UserId);
if (TeacherId <= 0) { return ApiResult.Failed("不是教师,无法查询"); }
return pointModule.GetPointTeacherCourseDetail(CourseId, TeacherId, userInfo);
}
#endregion
#region 订单列表
/// <summary>
......@@ -154,6 +219,21 @@ namespace Mall.WebApi.Controllers.Education
});
}
/// <summary>
/// 获取商品版面类型枚举
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetOrderStausEnumList()
{
var list = EnumHelper.GetEnumList(typeof(Common.Enum.Point.OrderStausEnum));
return ApiResult.Success("", list.Select(x => new
{
Name = x.Key,
Id = Convert.ToInt32(x.Value)
}));
}
#endregion
}
}
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