Commit 57c0292e authored by liudong1993's avatar liudong1993

1

parent eca6e582
......@@ -253,6 +253,14 @@ namespace Edu.Model.ViewModel.Contract
}
}
public decimal TotalClassHours2 { get; set; }
public decimal TotalCourseFee2 { get; set; }
public decimal TotalBookFee2 { get; set; }
public decimal TotalClassFee2 { get; set; }
public decimal TotalDiscountMoney2 { get; set; }
public decimal TotalSub2 { get; set; }
/// <summary>
/// 总课时数
/// </summary>
......
......@@ -3881,6 +3881,10 @@ namespace Edu.Module.Course
{
string orderIds = string.Join(",", list.Select(x => x.OrderId).Distinct());
string guestIds = string.Join(",", list.Select(x => x.GuestId).Distinct());
//查询 订单与客户
var orderList = orderRepository.GetOrderListRepository(new RB_Order_ViewModel { Group_Id = dmodel.Group_Id, QOrderIds = orderIds });
var orderGuestList = order_GuestRepository.GetSingleListRepository(new RB_Order_Guest_ViewModel() { Group_Id = dmodel.Group_Id, OrderGuestIds = guestIds });
//查询所有的财务单据
var flist = financeRepository.GetListSingle(new Model.ViewModel.Finance.RB_Finance_Extend() { RB_Group_Id = dmodel.Group_Id, FinanceType = 2, IsSelectNormal = 1, OrderIdStr = orderIds, GuestIdStr = guestIds });
if (flist.Any())
......@@ -3956,8 +3960,6 @@ namespace Edu.Module.Course
}
//查询所有学生的已上课时间
var stuTimeList = class_CheckRepository.GetClassGuestStudentTimeList(dmodel.Group_Id, guestIds, dmodel.XFStartTime, dmodel.XFEndTime);
//查询基础课时时长
//var configModel = class_ConfigRepository.GetClassConfigRepository(new RB_Class_Config_ViewModel() { Group_Id = dmodel.Group_Id });
//用户信息
var userIds = string.Join(",", list.Select(x => x.CreateBy).Distinct());
var alist = accountRepository.GetAccountListExtRepository(new Model.ViewModel.User.RB_Account_ViewModel() { QIds = userIds });
......@@ -3982,6 +3984,19 @@ namespace Edu.Module.Course
foreach (var item in list)
{
#region 根据订单赋值
var orderModel = orderList.Where(x => x.OrderId == item.OrderId).FirstOrDefault();
var guestModel = orderGuestList.Where(x => x.OrderId == item.OrderId).FirstOrDefault();
item.TotalClassHours2 = guestModel?.TotalHours ?? 0;
item.TotalDiscountMoney2 = orderModel?.DiscountMoney ?? 0;
item.TotalBookFee2 = orderModel?.TextbookFee ?? 0;
item.TotalClassFee2 = orderModel?.CoursewareFee ?? 0;
item.TotalSub2 = orderModel?.PreferPrice ?? 0;//总小计
item.TotalCourseFee2 = item.TotalSub2 - item.TotalBookFee2 - item.TotalClassFee2;
#endregion
if (item.SourceOrderId > 0)
{
item.SourceClassName = sourceTargetList?.Where(qitem => qitem.OrderId == item.SourceOrderId)?.FirstOrDefault()?.ClassName;
......@@ -3997,36 +4012,28 @@ namespace Edu.Module.Course
item.Expend = item.FinanceList.Where(x => x.Type == Common.Enum.Finance.WFTempLateClassEnum.OUT).Sum(x => (x.Money ?? 0) + (x.Fee ?? 0));//制单就算
#endregion
var stuModel = stuTimeList.Where(x => x.OrderGuestId == item.GuestId).FirstOrDefault();
//if (configModel == null || configModel.BasicMinutes <= 0)
//{
// item.UseClassHours = 0;
//}
//else
//{
// item.UseClassHours = (int)Math.Ceiling(Convert.ToDecimal(stuModel?.MinutesNum ?? 0) / configModel.BasicMinutes);// 已上课时 (暂时向上取整)
//}
item.UseClassHours = (stuModel?.CurrentDeductionHours ?? 0);
item.Unit_Price = 0;
item.UseCourseFee = 0;
if (item.TotalClassHours > 0)
if (item.TotalClassHours2 > 0)
{
if (item.TotalDiscountMoney > 0)
if (item.TotalDiscountMoney2 > 0)
{
item.Unit_Price = Math.Round((item.TotalCourseFee - (item.TotalDiscountMoney / item.TotalSub) * item.TotalCourseFee) / item.TotalClassHours, 6, MidpointRounding.AwayFromZero);//根据合同计算(包含优惠, 需减去课件费等)
item.UseCourseFee = Math.Round((Convert.ToDecimal(item.UseClassHours) / item.TotalClassHours) * (item.TotalCourseFee - (item.TotalDiscountMoney / item.TotalSub) * item.TotalCourseFee), 6, MidpointRounding.AwayFromZero);
item.Unit_Price = Math.Round((item.TotalCourseFee2 - (item.TotalDiscountMoney2 / item.TotalSub2) * item.TotalCourseFee2) / item.TotalClassHours2, 6, MidpointRounding.AwayFromZero);//根据合同计算(包含优惠, 需减去课件费等)
item.UseCourseFee = Math.Round((Convert.ToDecimal(item.UseClassHours) / item.TotalClassHours2) * (item.TotalCourseFee2 - (item.TotalDiscountMoney2 / item.TotalSub2) * item.TotalCourseFee2), 6, MidpointRounding.AwayFromZero);
}
else
{
item.Unit_Price = Math.Round(item.TotalCourseFee / item.TotalClassHours, 6, MidpointRounding.AwayFromZero);//根据合同计算(包含优惠, 需减去课件费等)
item.UseCourseFee = Math.Round((Convert.ToDecimal(item.UseClassHours) / item.TotalClassHours) * item.TotalCourseFee, 6, MidpointRounding.AwayFromZero);
item.Unit_Price = Math.Round(item.TotalCourseFee2 / item.TotalClassHours2, 6, MidpointRounding.AwayFromZero);//根据合同计算(包含优惠, 需减去课件费等)
item.UseCourseFee = Math.Round((Convert.ToDecimal(item.UseClassHours) / item.TotalClassHours2) * item.TotalCourseFee2, 6, MidpointRounding.AwayFromZero);
}
}
item.UseBookFee = item.TotalBookFee;
item.UseCoursewareFee = item.TotalClassFee;
if (item.TotalDiscountMoney > 0)
item.UseBookFee = item.TotalBookFee2;
item.UseCoursewareFee = item.TotalClassFee2;
if (item.TotalDiscountMoney2 > 0)
{
item.UseBookFee = Math.Round(item.TotalBookFee - (item.TotalDiscountMoney / item.TotalSub) * item.TotalBookFee, 6, MidpointRounding.AwayFromZero);//(优惠比例)
item.UseCoursewareFee = Math.Round(item.TotalClassFee - (item.TotalDiscountMoney / item.TotalSub) * item.TotalClassFee, 6, MidpointRounding.AwayFromZero);//(优惠比例)
item.UseBookFee = Math.Round(item.TotalBookFee2 - (item.TotalDiscountMoney2 / item.TotalSub2) * item.TotalBookFee2, 6, MidpointRounding.AwayFromZero);//(优惠比例)
item.UseCoursewareFee = Math.Round(item.TotalClassFee2 - (item.TotalDiscountMoney2 / item.TotalSub2) * item.TotalClassFee2, 6, MidpointRounding.AwayFromZero);//(优惠比例)
}
//用户信息
var amodel = alist.Where(x => x.Id == item.CreateBy).FirstOrDefault();
......
......@@ -427,7 +427,7 @@ namespace Edu.Module.Finance
demodel.SchoolId = item.School_Id;
demodel.SchoolName = item.SchoolName;
demodel.HoursNum = item.ClassHours;
demodel.HoursNum = orderList.Sum(x => x.ClassHours);
demodel.ConsumeNum = Convert.ToInt32(classHoursList.Where(x => x.ClassId == item.ClassId).FirstOrDefault()?.CurrentDeductionHours ?? 0);
demodel.ConsumeMoney = Math.Round(classStuList.Where(x => x.ClassId == item.ClassId).FirstOrDefault()?.UnitPrice ?? 0, 2, MidpointRounding.AwayFromZero);
#endregion
......
......@@ -130,8 +130,9 @@ namespace Edu.Repository.Sell
}
string sql = $@"
SELECT o.*,c.ClassName,c.ClassScrollType,t.TeacherName,t.TeacherIcon,IFNULL(course.CourseName,'') AS CourseName,c.OpenTime,IFNULL(course.ClassHours,0) AS ClassHours
SELECT o.*,c.ClassName,c.ClassScrollType,t.TeacherName,t.TeacherIcon,IFNULL(course.CourseName,'') AS CourseName,c.OpenTime,IFNULL(g.TotalHours,0) AS ClassHours
FROM RB_Order o
left join rb_order_guest g on o.OrderId = g.OrderId
LEFT JOIN rb_class c on o.ClassId = c.ClassId
LEFT JOIN rb_teacher t on c.Teacher_Id = t.TId
LEFT JOIN rb_course AS course ON (o.CourseId=course.CourseId AND o.CourseId>0 AND o.OrderType=1)
......
......@@ -1396,13 +1396,13 @@ namespace Edu.WebApi.Controllers.Finance
x.GuestId,
x.CreateByName,
x.CreateByPhoto,
x.TotalCourseFee,
x.TotalClassHours,
TotalUnitPrice = x.TotalClassHours > 0 ? Math.Round(x.TotalCourseFee / x.TotalClassHours, 2, MidpointRounding.AwayFromZero) : 0,
x.TotalBookFee,
x.TotalClassFee,
x.TotalSub,
x.TotalDiscountMoney,
TotalCourseFee = x.TotalCourseFee2,
TotalClassHours = x.TotalClassHours2,
TotalUnitPrice = x.TotalClassHours2 > 0 ? Math.Round(x.TotalCourseFee2 / x.TotalClassHours2, 2, MidpointRounding.AwayFromZero) : 0,
TotalBookFee = x.TotalBookFee2,
TotalClassFee = x.TotalClassFee2,
TotalSub = x.TotalSub2,
TotalDiscountMoney = x.TotalDiscountMoney2,
x.TotalMoney,
x.Status,
x.JoinType,
......@@ -1467,12 +1467,12 @@ namespace Edu.WebApi.Controllers.Finance
x.Expend,
x.UseBookFee,
x.UseCoursewareFee,
Progress = x.TotalClassHours > 0 ? Math.Round(Convert.ToDecimal(x.UseClassHours) / x.TotalClassHours * 100, 2, MidpointRounding.AwayFromZero) : 0,
Progress = x.TotalClassHours2 > 0 ? Math.Round(Convert.ToDecimal(x.UseClassHours) / x.TotalClassHours2 * 100, 2, MidpointRounding.AwayFromZero) : 0,
x.UseClassHours,
x.Unit_Price,
x.UseCourseFee,
x.AdjustPrice,
SurplusCourseHours = x.TotalClassHours - x.UseClassHours,
SurplusCourseHours = x.TotalClassHours2 - x.UseClassHours,
SurplusMoney = x.Income - x.Expend - x.UseBookFee - x.UseCoursewareFee - x.UseCourseFee - x.AdjustPrice
});
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