Commit 5ac3a17b authored by liudong1993's avatar liudong1993

销售中心 我的订单

parent 76aca899
......@@ -85,5 +85,15 @@ namespace Edu.Model.ViewModel.Course
/// 开班结束时间
/// </summary>
public string OPEndTime { get; set; }
/// <summary>
/// 未收款
/// </summary>
public decimal DueInMoney { get; set; }
/// <summary>
/// 取消人数
/// </summary>
public int CancelNum { get; set; }
}
}
\ No newline at end of file
......@@ -61,6 +61,10 @@ namespace Edu.Module.Course
/// 教师
/// </summary>
private readonly RB_TeacherRepository teacherRepository = new RB_TeacherRepository();
/// <summary>
/// 助教
/// </summary>
private readonly RB_AssistRepository assistRepository = new RB_AssistRepository();
#region 日语培训
......@@ -424,6 +428,7 @@ namespace Edu.Module.Course
}
//获取班级教师
var tModel = teacherRepository.GetEntity(cModel.Teacher_Id);
var zModel = assistRepository.GetEntity(cModel.Assist_Id);
//获取订单列表
var orderList = orderRepository.GetList(new RB_Order_ViewModel() { Group_Id = groupId, ClassId = classId });
if (orderList.Any()) {
......@@ -445,7 +450,9 @@ namespace Edu.Module.Course
{
cModel.ClassName,
tModel?.TeacherName,
tModel?.TeacherIcon
tModel?.TeacherIcon,
zModel?.AssistName,
zModel?.AssistIcon
};
return orderList;
......@@ -910,6 +917,15 @@ namespace Edu.Module.Course
}
return orderList;
}
/// <summary>
/// 获取我的订单统计
/// </summary>
/// <param name="demodel"></param>
/// <returns></returns>
public RB_Order_ViewModel GetMyOrderStatistics(RB_Order_ViewModel demodel) {
return orderRepository.GetMyOrderStatistics(demodel);
}
#endregion
}
}
......@@ -180,10 +180,10 @@ where {where} order by {orderBy}
where += $@" and o.{nameof(RB_Order_ViewModel.PreferPrice)} > (o.{nameof(RB_Order_ViewModel.Income)} - o.{nameof(RB_Order_ViewModel.Refund)} + o.{nameof(RB_Order_ViewModel.DiscountMoney)}) ";
}
string orderBy = "";
string orderBy = " o.OrderId asc";
if (demodel.Q_OrderBy == 1)
{
orderBy = " o.Id asc";
orderBy = " o.OrderId asc";
}
else if (demodel.Q_OrderBy == 2)
{
......@@ -198,6 +198,93 @@ where {where} order by {orderBy}
return GetPage<RB_Order_ViewModel>(pageIndex, pageSize, out rowsCount, sql).ToList();
}
/// <summary>
/// 获取我的订单统计
/// </summary>
/// <param name="demodel"></param>
/// <returns></returns>
public RB_Order_ViewModel GetMyOrderStatistics(RB_Order_ViewModel demodel)
{
string where = $@" 1=1";
if (demodel.Group_Id > 0)
{
where += $@" and o.{nameof(RB_Order_ViewModel.Group_Id)} ={demodel.Group_Id}";
}
if (demodel.School_Id > 0)
{
where += $@" and o.{nameof(RB_Order_ViewModel.School_Id)} ={demodel.School_Id}";
}
if (demodel.OrderId > 0)
{
where += $@" and o.{nameof(RB_Order_ViewModel.OrderId)} ={demodel.OrderId}";
}
if (demodel.ClassId > 0)
{
where += $@" and o.{nameof(RB_Order_ViewModel.ClassId)} ={demodel.ClassId}";
}
if (demodel.OrderSource > 0)
{
where += $@" and o.{nameof(RB_Order_ViewModel.OrderSource)} ={(int)demodel.OrderSource}";
}
if (demodel.OrderForm > 0)
{
where += $@" and o.{nameof(RB_Order_ViewModel.OrderForm)} ={(int)demodel.OrderForm}";
}
if (demodel.EnterID > 0)
{
where += $@" and o.{nameof(RB_Order_ViewModel.EnterID)} ={demodel.EnterID}";
}
if (demodel.Dept_Id > 0)
{
where += $@" and o.{nameof(RB_Order_ViewModel.Dept_Id)} ={demodel.Dept_Id}";
}
if (!string.IsNullOrEmpty(demodel.ClassName))
{
where += $@" and c.{nameof(RB_Class.ClassName)} like '%{demodel.ClassName}%'";
}
if (!string.IsNullOrEmpty(demodel.GuestName))
{
where += $@" o.OrderId in (select OrderId from rb_order_guest where Status =0 and GuestName like '%{demodel.GuestName}%')";
}
if (demodel.CouseId > 0)
{
where += $@" and c.{nameof(RB_Class.CouseId)} ={demodel.CouseId}";
}
if (!string.IsNullOrEmpty(demodel.StartTime))
{
where += $@" and o.{nameof(RB_Order_ViewModel.CreateTime)} >='{demodel.StartTime}'";
}
if (!string.IsNullOrEmpty(demodel.EndTime))
{
where += $@" and o.{nameof(RB_Order_ViewModel.CreateTime)} <='{demodel.EndTime} 23:59:59'";
}
if (!string.IsNullOrEmpty(demodel.OPStartTime))
{
where += $@" and c.{nameof(RB_Class.OpenTime)} >='{demodel.OPStartTime}'";
}
if (!string.IsNullOrEmpty(demodel.OPEndTime))
{
where += $@" and c.{nameof(RB_Class.OpenTime)} <='{demodel.OPEndTime} 23:59:59'";
}
if (demodel.Q_NotCollect == 1)
{
where += $@" and o.{nameof(RB_Order_ViewModel.PreferPrice)} > (o.{nameof(RB_Order_ViewModel.Income)} - o.{nameof(RB_Order_ViewModel.Refund)} + o.{nameof(RB_Order_ViewModel.DiscountMoney)}) ";
}
string sql = $@" select SUM(CASE WHEN o.OrderState <> 3 THEN o.PreferPrice ELSE 0 END) AS PreferPrice,
SUM(CASE WHEN o.OrderState <> 3 THEN o.Income ELSE 0 END) AS Income,
SUM(CASE WHEN o.OrderState <> 3 THEN o.PreferPrice - o.Income + o.Refund - o.DiscountMoney ELSE 0 END) AS DueInMoney,
SUM(CASE WHEN o.OrderState <> 3 THEN o.GuestNum ELSE 0 END) AS GuestNum,
SUM(CASE WHEN o.OrderState = 3 THEN o.GuestNum ELSE 0 END) AS CancelNum,
SUM(CASE WHEN o.CommissionMoney <> -1 AND o.OrderState <> 3 THEN o.CommissionMoney ELSE 0 END) AS CommissionMoney,
SUM(CASE WHEN o.OrderState <> 3 THEN o.ExtraRewardMoney - o.ExtraDeductMoney ELSE 0 END) AS ExtraRewardMoney
from RB_Order o
left join rb_class c on o.ClassId = c.ClassId
where {where}
";
return Get<RB_Order_ViewModel>(sql).FirstOrDefault();
}
/// <summary>
/// 获取班级报名人数
/// </summary>
......
......@@ -49,6 +49,8 @@ namespace Edu.WebApi.Controllers.Course
x.TeacherName,
x.TeacherHead,
x.RoomName,
x.ClassStyle,
ClassStyleName = x.ClassStyle.ToName(),
OpenTime = x.OpenTime.ToString("yyyy年MM月dd日"),
EndOrderTime = x.EndOrderTime.HasValue ? x.EndOrderTime.Value.ToString("yyyy年MM月dd日") : "",
IsCanApply = x.EndOrderTime >= Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd")) && x.ClassPersion > x.OrderStudentCount ? 1 : 0,
......@@ -58,6 +60,7 @@ namespace Edu.WebApi.Controllers.Course
x.ClassPersion,
x.OutRemark,
x.OrderStudentCount,
SurplusNum = x.ClassPersion - x.OrderStudentCount,
ClassStepPriceList = x.ClassStepPriceList.Select(z => new
{
z.ClassStepPriceId,
......@@ -653,68 +656,81 @@ namespace Edu.WebApi.Controllers.Course
demodel.EnterID = userInfo.Id;
var orderList = orderModule.GetMyOrderPageList(pageModel.PageIndex, pageModel.PageSize, out long count, demodel);
var orderS = orderModule.GetMyOrderStatistics(demodel);
pageModel.Count = Convert.ToInt32(count);
pageModel.PageData = orderList.Select(x => new
{
x.OrderId,
x.ClassId,
x.TradeWay,
x.Class_Price,
x.Unit_Price,
x.GuestNum,
x.PreferPrice,
x.Income,
x.Refund,
x.DiscountMoney,
DueInMoney = x.PreferPrice - (x.Income - x.Refund + x.DiscountMoney),
x.OrderState,
OrderStateName = x.OrderState.ToName(),
x.EnterID,
EnterName = UserReidsCache.GetUserLoginInfo(x.EnterID)?.AccountName ?? "",
x.CommissionMoney,
x.ExtraRewardMoney,
x.ExtraDeductMoney,
x.IsCommissionGive,
CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"),
x.SaleRemark,
x.TeacherRemark,
x.RectorRemark,
x.DirectorRemark,
SaleRemarkList = x.SaleRemarkList.Select(z => new
{
z.Id,
z.Content,
CreateBy = UserReidsCache.GetUserLoginInfo(z.CreateBy)?.AccountName ?? "",
CreateTime = z.CreateTime.ToString("yyyy-MM-dd HH:mm:ss")
}),
TeacherRemarkList = x.TeacherRemarkList.Select(z => new
pageModel.PageData = new {
Statistics = new
{
z.Id,
z.Content,
CreateBy = UserReidsCache.GetUserLoginInfo(z.CreateBy)?.AccountName ?? "",
CreateTime = z.CreateTime.ToString("yyyy-MM-dd HH:mm:ss")
}),
RectorRemarkList = x.RectorRemarkList.Select(z => new
{
z.Id,
z.Content,
CreateBy = UserReidsCache.GetUserLoginInfo(z.CreateBy)?.AccountName ?? "",
CreateTime = z.CreateTime.ToString("yyyy-MM-dd HH:mm:ss")
}),
DirectorRemarkList = x.DirectorRemarkList.Select(z => new
{
z.Id,
z.Content,
CreateBy = UserReidsCache.GetUserLoginInfo(z.CreateBy)?.AccountName ?? "",
CreateTime = z.CreateTime.ToString("yyyy-MM-dd HH:mm:ss")
}),
GuestList = x.GuestList.Select(z => new
PreferPrice = orderS?.PreferPrice ?? 0,
Income = orderS?.Income ?? 0,
DueInMoney = orderS?.DueInMoney ?? 0,
GuestNum = orderS?.GuestNum ?? 0,
CancelNum = orderS?.CancelNum ?? 0,
CommissionMoney = orderS?.CommissionMoney ?? 0,
ExtraRewardMoney = orderS?.ExtraRewardMoney ?? 0
},
List = orderList.Select(x => new
{
z.Id,
z.GuestName,
z.GuestState
x.OrderId,
x.ClassId,
x.TradeWay,
x.Class_Price,
x.Unit_Price,
x.GuestNum,
x.PreferPrice,
x.Income,
x.Refund,
x.DiscountMoney,
DueInMoney = x.PreferPrice - (x.Income - x.Refund + x.DiscountMoney),
x.OrderState,
OrderStateName = x.OrderState.ToName(),
x.EnterID,
EnterName = UserReidsCache.GetUserLoginInfo(x.EnterID)?.AccountName ?? "",
x.CommissionMoney,
x.ExtraRewardMoney,
x.ExtraDeductMoney,
x.IsCommissionGive,
CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"),
x.SaleRemark,
x.TeacherRemark,
x.RectorRemark,
x.DirectorRemark,
SaleRemarkList = x.SaleRemarkList.Select(z => new
{
z.Id,
z.Content,
CreateBy = UserReidsCache.GetUserLoginInfo(z.CreateBy)?.AccountName ?? "",
CreateTime = z.CreateTime.ToString("yyyy-MM-dd HH:mm:ss")
}),
TeacherRemarkList = x.TeacherRemarkList.Select(z => new
{
z.Id,
z.Content,
CreateBy = UserReidsCache.GetUserLoginInfo(z.CreateBy)?.AccountName ?? "",
CreateTime = z.CreateTime.ToString("yyyy-MM-dd HH:mm:ss")
}),
RectorRemarkList = x.RectorRemarkList.Select(z => new
{
z.Id,
z.Content,
CreateBy = UserReidsCache.GetUserLoginInfo(z.CreateBy)?.AccountName ?? "",
CreateTime = z.CreateTime.ToString("yyyy-MM-dd HH:mm:ss")
}),
DirectorRemarkList = x.DirectorRemarkList.Select(z => new
{
z.Id,
z.Content,
CreateBy = UserReidsCache.GetUserLoginInfo(z.CreateBy)?.AccountName ?? "",
CreateTime = z.CreateTime.ToString("yyyy-MM-dd HH:mm:ss")
}),
GuestList = x.GuestList.Select(z => new
{
z.Id,
z.GuestName,
z.GuestState
})
})
});
};
return ApiResult.Success("", pageModel);
}
......
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