Commit 8dfd01d3 authored by liudong1993's avatar liudong1993

1 甲鹤调整

parent 73060c8b
......@@ -122,6 +122,13 @@ namespace Edu.Education.Helper
IJobDetail job = JobBuilder.Create<CreateRevenueReport>()
.WithIdentity("job4", "group4")
.Build();
//ITrigger trigger = TriggerBuilder.Create()
// .WithIdentity("trigger4", "group4")
// .StartNow()
// .WithSimpleSchedule(x => x
// .WithIntervalInHours(11)
// .RepeatForever())
// .Build();
ICronTrigger trigger = (ICronTrigger)TriggerBuilder.Create()
.WithIdentity("trigger4", "group4")
.WithCronSchedule(CronExpression2)
......
......@@ -2,7 +2,7 @@
"ConnectionStrings": {
"DefaultConnection": "server=192.168.10.214;user id=reborn;password=Reborn@2018;database=reborn_edu;CharSet=utf8mb4; Convert Zero Datetime=true; ",
"DefaultConnectionPName": "MySql.Data.MySqlClient",
"FinanceConnection": "server=192.168.10.214;user id=reborn;password=Reborn@2018;database=reborn_finance;CharSet=utf8mb4; Convert Zero Datetime=true; ",
"FinanceConnection": "server=192.168.10.214;user id=reborn;password=Reborn@2018;database=test_finance;CharSet=utf8mb4; Convert Zero Datetime=true; ",
"FinanceConnectionPName": "MySql.Data.MySqlClient",
"DataStatisticsConnection": "server=192.168.10.214;user id=reborn;password=Reborn@2018;database=reborn_datastatistics;CharSet=utf8mb4; Convert Zero Datetime=true; ",
"DataStatisticsConnectionPName": "MySql.Data.MySqlClient",
......
......@@ -10,6 +10,7 @@ using Edu.Model.ViewModel.Course;
using Edu.Model.ViewModel.Finance;
using Edu.Model.ViewModel.Grade;
using Edu.Model.ViewModel.Sell;
using Edu.Repository.Bonus;
using Edu.Repository.Course;
using Edu.Repository.Finance;
using Edu.Repository.Grade;
......@@ -127,6 +128,10 @@ namespace Edu.Module.Finance
/// </summary>
private readonly RB_Sell_Achievements_EmpRepository sell_Achievements_EmpRepository = new RB_Sell_Achievements_EmpRepository();
/// <summary>
/// 业绩提成
/// </summary>
private readonly RB_Sell_Achievements_DetailsRepository sell_Achievements_DetailsRepository = new RB_Sell_Achievements_DetailsRepository();
/// <summary>
/// 订单返佣
/// </summary>
private readonly RB_Order_ReturnComissionRepository order_ReturnComissionRepository = new RB_Order_ReturnComissionRepository();
......@@ -158,6 +163,10 @@ namespace Edu.Module.Finance
/// 试听班级
/// </summary>
private readonly Repository.Reserve.RB_Reserve_ClassRepository reserve_ClassRepository = new Repository.Reserve.RB_Reserve_ClassRepository();
/// <summary>
/// 员工人头奖励详情仓储层对象
/// </summary>
private readonly RB_Personnel_BonusRepository personnel_BonusRepository = new RB_Personnel_BonusRepository();
......@@ -347,7 +356,7 @@ namespace Edu.Module.Finance
}
//查询日期范围内所有的班级
var classList = classRepository.GetClassAndCourseListRepository(new RB_Class_ViewModel() { Group_Id = GroupId, StartTime = STime, EndTime = ETime }).ToList();
var classList = classRepository.GetClassAndCourseListRepository(new RB_Class_ViewModel() { Group_Id = GroupId, StartTime = STime, EndTime = ETime, ClassScrollType = 0 }).ToList();
List<RB_Order_ViewModel> orderAllList = new List<RB_Order_ViewModel>();
List<RB_Finance_Extend> FAllList = new List<RB_Finance_Extend>();
List<RB_Teaching_BonusDetail_ViewModel> teacherBonusList = new List<RB_Teaching_BonusDetail_ViewModel>();
......@@ -390,6 +399,7 @@ namespace Edu.Module.Finance
Console.WriteLine("班级:" + item.ClassName + "|" + item.ClassId);
bool IsNew = false;//是否新增
var orderList = orderAllList.Where(x => x.ClassId == item.ClassId).ToList();
if (!orderList.Any()) { continue; }
var financeList = FAllList.Where(x => x.TCID == item.ClassId).ToList();
var demodel = oldlist.Where(x => x.ClassId == item.ClassId).FirstOrDefault();
if (demodel == null) {
......@@ -1319,8 +1329,9 @@ namespace Edu.Module.Finance
RB_SimpleReport IncomeReport = new RB_SimpleReport() { Year = Year, Abstract = "营业收入", Rb_Group_Id = GroupId, Sort = 1, BranchId = branchitem.SId, CostTypeIds = "" };
RB_SimpleReport OtherIncomeReport = new RB_SimpleReport() { Year = Year, Abstract = "其他收入", Rb_Group_Id = GroupId, Sort = 2, BranchId = branchitem.SId, CostTypeIds = "" };
RB_SimpleReport BonusReport = new RB_SimpleReport() { Year = Year, Abstract = "课时费", Rb_Group_Id = GroupId, Sort = 3, BranchId = branchitem.SId, CostTypeIds = "" };
RB_SimpleReport PerfReport = new RB_SimpleReport() { Year = Year, Abstract = "老师绩效", Rb_Group_Id = GroupId, Sort = 4, BranchId = branchitem.SId, CostTypeIds = "" };
RB_SimpleReport PerfReport = new RB_SimpleReport() { Year = Year, Abstract = "返佣", Rb_Group_Id = GroupId, Sort = 4, BranchId = branchitem.SId, CostTypeIds = "" };
RB_SimpleReport SellReport = new RB_SimpleReport() { Year = Year, Abstract = "销售提成", Rb_Group_Id = GroupId, Sort = 5, BranchId = branchitem.SId, CostTypeIds = "" };
RB_SimpleReport PeopleReport = new RB_SimpleReport() { Year = Year, Abstract = "人头奖励", Rb_Group_Id = GroupId, Sort = 5, BranchId = branchitem.SId, CostTypeIds = "" };
RB_SimpleReport OtherCostReport = new RB_SimpleReport() { Year = Year, Abstract = "其他成本", Rb_Group_Id = GroupId, Sort = 6, BranchId = branchitem.SId, CostTypeIds = "" };
RB_SimpleReport TotalReport = new RB_SimpleReport() { Year = Year, Abstract = "营业总毛利", Rb_Group_Id = GroupId, Sort = 7, BranchId = branchitem.SId, CostTypeIds = "" };
foreach (var month in shareList)
......@@ -1330,100 +1341,59 @@ namespace Edu.Module.Finance
#region 最新班级
List<int> ClassIdArr = new List<int>();
//List<int> ClassIdArr = new List<int>();
//首先根据签到表 查询出所有的班级 并分页
var list = class_CheckRepository.GetAllClassNowMonthStatistics(startTime, endTime, 0, "", branchitem.SId, GroupId);
if (list.Any())
{
ClassIdArr.AddRange(list.Select(x => x.ClassId));
}
//var list = class_CheckRepository.GetAllClassNowMonthStatistics(startTime, endTime, 0, "", branchitem.SId, GroupId);
//if (list.Any())
//{
// ClassIdArr.AddRange(list.Select(x => x.ClassId));
//}
//查询时间范围内 除订单外 班级下其他订单 的其他收入 + 其他成本支出
string datebaseStr = Config.ReadConfigKey("EduDateBase");//教育数据库
var financeList = RB_FinanceRepository.GetListForReportClass(new RB_Finance_Extend() { RB_Group_Id = GroupId, RB_Branch_Id = branchitem.SId, TCID = -2, sAduitDate = Convert.ToDateTime(startTime), eAduitDate = Convert.ToDateTime(endTime), FinanceType = 2, OrderSource = OrderResourceEnum.Education }, datebaseStr);
if (financeList.Any())
{
ClassIdArr.AddRange(financeList.Select(x => x.TCID ?? 0));
}
var financeList = RB_FinanceRepository.GetListForReportClass(new RB_Finance_Extend() { RB_Group_Id = GroupId, RB_Branch_Id = branchitem.SId, TCID = -2, sAduitDate = Convert.ToDateTime(startTime), eAduitDate = Convert.ToDateTime(endTime), FinanceType = 2, OrderSource = OrderResourceEnum.Education });
string STime = Convert.ToDateTime(startTime).AddMonths(-1).ToString("yyyy-MM-dd");
string ETime = Convert.ToDateTime(endTime).AddMonths(-1).ToString("yyyy-MM-dd");
var teacherBonusList = teaching_BonusDetailRepository.GetTeacherBonusForDate(GroupId, branchitem.SId, "", STime, ETime);//查询所有班级需要发放
if (teacherBonusList.Any())
{
ClassIdArr.AddRange(teacherBonusList.Select(x => x.ClassId));
}
var meritsProfitList = teaching_PerfRepository.GetTeacherPerfForDate(GroupId, branchitem.SId, "", startTime, endTime);
if (meritsProfitList.Any())
{
ClassIdArr.AddRange(meritsProfitList.Select(x => x.ClassId));
}
//var meritsProfitList = teaching_PerfRepository.GetTeacherPerfForDate(GroupId, branchitem.SId, "", startTime, endTime);
//if (meritsProfitList.Any())
//{
// ClassIdArr.AddRange(meritsProfitList.Select(x => x.ClassId));
//}
var saleList = sell_Commission_DetailsRepository.GetSellCommissionForDate(GroupId, branchitem.SId, "", STime, ETime);
if (saleList.Any())
{
ClassIdArr.AddRange(saleList.Select(x => x.ClassId));
}
ClassIdArr = ClassIdArr.Distinct().ToList();
List<RB_Class_ViewModel> CAlllist = new List<RB_Class_ViewModel>();
if (ClassIdArr.Any())
{
//再次查询所有的班级
CAlllist = classRepository.GetClassListRepository(new RB_Class_ViewModel() { Group_Id = GroupId, Q_ClassIds = string.Join(",", ClassIdArr) });
}
//查询课耗
//根据学生签到表 查询
var stulist = class_CheckRepository.GetStudentConsumptionHoursDetialList(0, branchitem.SId, 0, startTime, endTime, "", 0, "", GroupId);
decimal StuKHMoney = stulist.Sum(x => Math.Round(x.UnitPrice * x.CurrentDeductionHours, 6, MidpointRounding.AwayFromZero));
//课时费 提成 书本费收入(OtherIncome)
//查询课时费
decimal WBonusMoney = teacherBonusList.Sum(x => x.Money);
//查询业绩提成
decimal sellCommission = sell_Achievements_DetailsRepository.GetSellCommissionForDate(GroupId, branchitem.SId, STime, ETime);
decimal SellMoney = saleList.Sum(x => x.CurrentPeriodMoney);//销售提成
sellCommission += SellMoney;
//查询返佣
decimal ReturnMoney = order_ReturnComissionRepository.GetOrderReturnComissionForMonth(Convert.ToDateTime(startTime).ToString("yyyyMM") + "返佣", GroupId, branchitem.SId);
//查询书本费收入 暂存 1159 = 书本费科目
//当月的财务单据
var booklist = RZFinancelist.Where(x => x.CostTypeId == 1159 && ((x.Type == WFTempLateClassEnum.OUT && x.CreateDate.Value.ToString("yyyy-MM") == Convert.ToDateTime(startTime).ToString("yyyy-MM")) || (x.Type != WFTempLateClassEnum.OUT && x.TradeDate.Value.ToString("yyyy-MM") == Convert.ToDateTime(startTime).ToString("yyyy-MM"))) && x.RB_Branch_Id == branchitem.SId).ToList();
decimal bookIncome = booklist.Where(x => x.Type == WFTempLateClassEnum.IN).Sum(x => x.Money ?? 0) - booklist.Where(x => x.Type == WFTempLateClassEnum.OUT).Sum(x => x.Money ?? 0);
#region 单据
decimal OtherIncome = financeList.Where(y => y.Type == WFTempLateClassEnum.IN && y.Is_Cashier == 1 && y.OrderID <= 0).Sum(x => x.Money ?? 0);
decimal Fee = financeList.Where(x => x.Type == WFTempLateClassEnum.IN && x.Is_Cashier == 1 && x.OrderID <= 0 && x.Fee > 0).GroupBy(x => new { x.FrID, x.Fee }).Sum(x => x.Key.Fee ?? 0);
OtherIncome -= Fee;
decimal OtherCost = financeList.Where(y => y.Type == WFTempLateClassEnum.OUT && y.OrderID <= 0).Sum(x => x.Money ?? 0);//支出也要排除订单订单退款
bookIncome += OtherIncome;
#endregion
if (CAlllist.Any())
{
string classIds = string.Join(",", CAlllist.Select(x => x.ClassId));
//查询时间范围内 所有班级的学生上课金额
List<RB_Teaching_BonusDetail_ViewModel> StudentHoursList = new List<RB_Teaching_BonusDetail_ViewModel>();
//根据学生签到表 查询
var stulist = class_CheckRepository.GetStudentConsumptionHoursDetialList(0, -1, 0, startTime, endTime, "", 0, "", GroupId, classIds);
if (stulist.Any())
{
foreach (var item in stulist)
{
decimal UnitPrice = Math.Round(item.UnitPrice, 6, MidpointRounding.AwayFromZero);
StudentHoursList.Add(new RB_Teaching_BonusDetail_ViewModel
{
Date = item.ClassDate,
TimeBucket = item.StartDate + "~" + item.EndDate,
TeacherId = item.OrderGuestId,
TeacherName = item.GuestName,
ClassId = item.ClassId,
ClassName = item.ClassName,
ClassNo = item.ClassNo,
CouseId = item.CouseId,
CourseName = item.CourseName,
KSNum = item.CurrentDeductionHours,
Hours = 0,
HourMoney = 0,
UnitPrice = UnitPrice,
Money = Math.Round(item.UnitPrice * item.CurrentDeductionHours, 6, MidpointRounding.AwayFromZero)
});
}
}
//查询人头奖励
decimal PeopleBonus = personnel_BonusRepository.GetPersonnelBonusForMonth(Convert.ToDateTime(STime).ToString("yyyy-M"), GroupId, branchitem.SId);
foreach (var item in CAlllist)
{
#region 学生课耗
var slist = StudentHoursList.Where(x => x.ClassId == item.ClassId).ToList();
decimal TStuMoney = slist.Sum(x => x.Money);//上课总金额
#endregion
#region 提成
decimal BonusMoney = teacherBonusList.Where(x => x.ClassId == item.ClassId).FirstOrDefault()?.Money ?? 0;//老师课时费
decimal PerfMoney = meritsProfitList.Where(x => x.ClassId == item.ClassId).FirstOrDefault()?.Money ?? 0;//老师绩效
decimal SellMoney = saleList.Where(x => x.ClassId == item.ClassId).FirstOrDefault()?.CurrentPeriodMoney ?? 0;//销售提成
#endregion
#region 单据
var flist = financeList.Where(x => x.TCID == item.ClassId).ToList();
decimal OtherIncome = flist.Where(y => y.Type == WFTempLateClassEnum.IN && y.Is_Cashier == 1 && y.OrderID <= 0).Sum(x => x.Money ?? 0);
decimal Fee = flist.Where(x => x.Type == WFTempLateClassEnum.IN && x.Is_Cashier == 1 && x.OrderID <= 0 && x.Fee > 0).GroupBy(x => new { x.FrID, x.Fee }).Sum(x => x.Key.Fee ?? 0);
OtherIncome -= Fee;
decimal OtherCost = flist.Where(y => y.Type == WFTempLateClassEnum.OUT && y.OrderID <= 0).Sum(x => x.Money ?? 0);//支出也要排除订单订单退款
#endregion
UpdateClassReportDate(TotalReport, IncomeReport, OtherIncomeReport, BonusReport, PerfReport, SellReport, OtherCostReport, month, TStuMoney, BonusMoney, PerfMoney, SellMoney, OtherIncome, OtherCost);
}
}
UpdateClassReportDate(TotalReport, IncomeReport, OtherIncomeReport, BonusReport, PerfReport, SellReport, PeopleReport, OtherCostReport, month, StuKHMoney, WBonusMoney, ReturnMoney, sellCommission, bookIncome, OtherCost, PeopleBonus);
#endregion
#region 最新留学
......@@ -1435,7 +1405,7 @@ namespace Edu.Module.Finance
SourceIdArr.AddRange(lxOrderList.Select(x => x.SourceId).Distinct());
}
//财务单据 付款单制单那月就统计进那月, 王姐的需求 因为这个是按照月份分摊的
var lxFinanceList = RB_FinanceRepository.GetListForReportClass(new RB_Finance_Extend() { RB_Group_Id = GroupId, RB_Branch_Id = branchitem.SId, TCID = -3, sAduitDate = Convert.ToDateTime(startTime), eAduitDate = Convert.ToDateTime(endTime), FinanceType = 2, OrderSource = OrderResourceEnum.EducationStudy }, datebaseStr);
var lxFinanceList = RB_FinanceRepository.GetListForReportClass(new RB_Finance_Extend() { RB_Group_Id = GroupId, RB_Branch_Id = branchitem.SId, TCID = -3, sAduitDate = Convert.ToDateTime(startTime), eAduitDate = Convert.ToDateTime(endTime), FinanceType = 2, OrderSource = OrderResourceEnum.EducationStudy });
if (lxFinanceList.Any())
{
SourceIdArr.AddRange(lxFinanceList.Select(x => x.TCID ?? 0));
......@@ -1478,7 +1448,7 @@ namespace Edu.Module.Finance
#endregion
UpdateClassReportDate(TotalReport, IncomeReport, OtherIncomeReport, BonusReport, PerfReport, SellReport, OtherCostReport, month, ShiShou, ClassFee, JiXiaoMoney, TiCheng, QTShouRu, QTZhiChu);
UpdateClassReportDate(TotalReport, IncomeReport, OtherIncomeReport, BonusReport, PerfReport, SellReport, PeopleReport, OtherCostReport, month, ShiShou, ClassFee, JiXiaoMoney, TiCheng, QTShouRu, QTZhiChu, 0);
}
......@@ -1874,6 +1844,7 @@ namespace Edu.Module.Finance
SchoolReportList.Add(BonusReport);
SchoolReportList.Add(PerfReport);
SchoolReportList.Add(SellReport);
SchoolReportList.Add(PeopleReport);
SchoolReportList.Add(OtherCostReport);
SchoolReportList.Add(TotalReport);
SchoolReportList.Add(NotReport);
......@@ -1979,7 +1950,7 @@ namespace Edu.Module.Finance
/// <param name="SellMoney"></param>
/// <param name="OtherIncome"></param>
/// <param name="OtherCost"></param>
private static void UpdateClassReportDate(RB_SimpleReport TotalReport, RB_SimpleReport IncomeReport, RB_SimpleReport OtherIncomeReport, RB_SimpleReport BonusReport, RB_SimpleReport PerfReport, RB_SimpleReport SellReport, RB_SimpleReport OtherCostReport, string month, decimal TStuMoney, decimal BonusMoney, decimal PerfMoney, decimal SellMoney, decimal OtherIncome, decimal OtherCost)
private static void UpdateClassReportDate(RB_SimpleReport TotalReport, RB_SimpleReport IncomeReport, RB_SimpleReport OtherIncomeReport, RB_SimpleReport BonusReport, RB_SimpleReport PerfReport, RB_SimpleReport SellReport, RB_SimpleReport PeopleReport, RB_SimpleReport OtherCostReport, string month, decimal TStuMoney, decimal BonusMoney, decimal PerfMoney, decimal SellMoney, decimal OtherIncome, decimal OtherCost, decimal PeopleMoney)
{
switch (month)
{
......@@ -1989,8 +1960,9 @@ namespace Edu.Module.Finance
BonusReport.January += BonusMoney;
PerfReport.January += PerfMoney;
SellReport.January += SellMoney;
PeopleReport.January += PeopleMoney;
OtherCostReport.January += OtherCost;
TotalReport.January += TStuMoney + OtherIncome - BonusMoney - PerfMoney - SellMoney - OtherCost;
TotalReport.January += TStuMoney + OtherIncome - BonusMoney - PerfMoney - SellMoney - OtherCost - PeopleMoney;
break;
case "02":
IncomeReport.February += TStuMoney;
......@@ -1998,8 +1970,9 @@ namespace Edu.Module.Finance
BonusReport.February += BonusMoney;
PerfReport.February += PerfMoney;
SellReport.February += SellMoney;
PeopleReport.February += PeopleMoney;
OtherCostReport.February += OtherCost;
TotalReport.February += TStuMoney + OtherIncome - BonusMoney - PerfMoney - SellMoney - OtherCost;
TotalReport.February += TStuMoney + OtherIncome - BonusMoney - PerfMoney - SellMoney - OtherCost - PeopleMoney;
break;
case "03":
IncomeReport.March += TStuMoney;
......@@ -2007,8 +1980,9 @@ namespace Edu.Module.Finance
BonusReport.March += BonusMoney;
PerfReport.March += PerfMoney;
SellReport.March += SellMoney;
PeopleReport.March += PeopleMoney;
OtherCostReport.March += OtherCost;
TotalReport.March += TStuMoney + OtherIncome - BonusMoney - PerfMoney - SellMoney - OtherCost;
TotalReport.March += TStuMoney + OtherIncome - BonusMoney - PerfMoney - SellMoney - OtherCost - PeopleMoney;
break;
case "04":
IncomeReport.April += TStuMoney;
......@@ -2016,8 +1990,9 @@ namespace Edu.Module.Finance
BonusReport.April += BonusMoney;
PerfReport.April += PerfMoney;
SellReport.April += SellMoney;
PeopleReport.April += PeopleMoney;
OtherCostReport.April += OtherCost;
TotalReport.April += TStuMoney + OtherIncome - BonusMoney - PerfMoney - SellMoney - OtherCost;
TotalReport.April += TStuMoney + OtherIncome - BonusMoney - PerfMoney - SellMoney - OtherCost - PeopleMoney;
break;
case "05":
IncomeReport.May += TStuMoney;
......@@ -2025,8 +2000,9 @@ namespace Edu.Module.Finance
BonusReport.May += BonusMoney;
PerfReport.May += PerfMoney;
SellReport.May += SellMoney;
PeopleReport.May += PeopleMoney;
OtherCostReport.May += OtherCost;
TotalReport.May += TStuMoney + OtherIncome - BonusMoney - PerfMoney - SellMoney - OtherCost;
TotalReport.May += TStuMoney + OtherIncome - BonusMoney - PerfMoney - SellMoney - OtherCost - PeopleMoney;
break;
case "06":
IncomeReport.June += TStuMoney;
......@@ -2034,8 +2010,9 @@ namespace Edu.Module.Finance
BonusReport.June += BonusMoney;
PerfReport.June += PerfMoney;
SellReport.June += SellMoney;
PeopleReport.June += PeopleMoney;
OtherCostReport.June += OtherCost;
TotalReport.June += TStuMoney + OtherIncome - BonusMoney - PerfMoney - SellMoney - OtherCost;
TotalReport.June += TStuMoney + OtherIncome - BonusMoney - PerfMoney - SellMoney - OtherCost - PeopleMoney;
break;
case "07":
IncomeReport.July += TStuMoney;
......@@ -2043,8 +2020,9 @@ namespace Edu.Module.Finance
BonusReport.July += BonusMoney;
PerfReport.July += PerfMoney;
SellReport.July += SellMoney;
PeopleReport.July += PeopleMoney;
OtherCostReport.July += OtherCost;
TotalReport.July += TStuMoney + OtherIncome - BonusMoney - PerfMoney - SellMoney - OtherCost;
TotalReport.July += TStuMoney + OtherIncome - BonusMoney - PerfMoney - SellMoney - OtherCost - PeopleMoney;
break;
case "08":
IncomeReport.August += TStuMoney;
......@@ -2052,8 +2030,9 @@ namespace Edu.Module.Finance
BonusReport.August += BonusMoney;
PerfReport.August += PerfMoney;
SellReport.August += SellMoney;
PeopleReport.August += PeopleMoney;
OtherCostReport.August += OtherCost;
TotalReport.August += TStuMoney + OtherIncome - BonusMoney - PerfMoney - SellMoney - OtherCost;
TotalReport.August += TStuMoney + OtherIncome - BonusMoney - PerfMoney - SellMoney - OtherCost - PeopleMoney;
break;
case "09":
IncomeReport.September += TStuMoney;
......@@ -2061,8 +2040,9 @@ namespace Edu.Module.Finance
BonusReport.September += BonusMoney;
PerfReport.September += PerfMoney;
SellReport.September += SellMoney;
PeopleReport.September += PeopleMoney;
OtherCostReport.September += OtherCost;
TotalReport.September += TStuMoney + OtherIncome - BonusMoney - PerfMoney - SellMoney - OtherCost;
TotalReport.September += TStuMoney + OtherIncome - BonusMoney - PerfMoney - SellMoney - OtherCost - PeopleMoney;
break;
case "10":
IncomeReport.October += TStuMoney;
......@@ -2070,8 +2050,9 @@ namespace Edu.Module.Finance
BonusReport.October += BonusMoney;
PerfReport.October += PerfMoney;
SellReport.October += SellMoney;
PeopleReport.October += PeopleMoney;
OtherCostReport.October += OtherCost;
TotalReport.October += TStuMoney + OtherIncome - BonusMoney - PerfMoney - SellMoney - OtherCost;
TotalReport.October += TStuMoney + OtherIncome - BonusMoney - PerfMoney - SellMoney - OtherCost - PeopleMoney;
break;
case "11":
IncomeReport.November += TStuMoney;
......@@ -2079,8 +2060,9 @@ namespace Edu.Module.Finance
BonusReport.November += BonusMoney;
PerfReport.November += PerfMoney;
SellReport.November += SellMoney;
PeopleReport.November += PeopleMoney;
OtherCostReport.November += OtherCost;
TotalReport.November += TStuMoney + OtherIncome - BonusMoney - PerfMoney - SellMoney - OtherCost;
TotalReport.November += TStuMoney + OtherIncome - BonusMoney - PerfMoney - SellMoney - OtherCost - PeopleMoney;
break;
case "12":
IncomeReport.December += TStuMoney;
......@@ -2088,8 +2070,9 @@ namespace Edu.Module.Finance
BonusReport.December += BonusMoney;
PerfReport.December += PerfMoney;
SellReport.December += SellMoney;
PeopleReport.December += PeopleMoney;
OtherCostReport.December += OtherCost;
TotalReport.December += TStuMoney + OtherIncome - BonusMoney - PerfMoney - SellMoney - OtherCost;
TotalReport.December += TStuMoney + OtherIncome - BonusMoney - PerfMoney - SellMoney - OtherCost - PeopleMoney;
break;
}
}
......@@ -3188,34 +3171,34 @@ namespace Edu.Module.Finance
}
}
//查询试听课
var rclist = reserve_ClassRepository.GetTeacherHoursDetialList(userIds, schoolId, 0, startMonth, endMonth, groupId);
if (rclist.Any()) {
decimal ClassHourMinute = configModel.BasicMinutes;//课时分钟数
decimal Hours = Math.Round(1 * ClassHourMinute / 60, 2, MidpointRounding.AwayFromZero);//小时
foreach (var item in rclist) {
if (item.ClassHourFee > 0)
{
DateList.Add(new RB_Teaching_BonusDetail_ViewModel
{
Date = item.ClassDate,
TimeBucket = item.ClassTime + "~" + item.EndTime,
TeacherId = item.TeacherId,
TeacherName = item.TeacherName,
ClassId = item.ReserveClassId,
ClassName = "试听课",
CouseId = item.TrialLessonId,
CourseName = item.LessonName,
KSNum = 1,
Hours = Hours,
HourMoney = Math.Round(item.ClassHourFee / Hours, 2, MidpointRounding.AwayFromZero),
UnitPrice = item.ClassHourFee,
Money = item.ClassHourFee,
CouseClassify = 2
});
}
}
}
//查询试听课 2023-08-30 对试听课屏蔽 试听课不算课时费 算1%提成
//var rclist = reserve_ClassRepository.GetTeacherHoursDetialList(userIds, schoolId, 0, startMonth, endMonth, groupId);
//if (rclist.Any()) {
// decimal ClassHourMinute = configModel.BasicMinutes;//课时分钟数
// decimal Hours = Math.Round(1 * ClassHourMinute / 60, 2, MidpointRounding.AwayFromZero);//小时
// foreach (var item in rclist) {
// if (item.ClassHourFee > 0)
// {
// DateList.Add(new RB_Teaching_BonusDetail_ViewModel
// {
// Date = item.ClassDate,
// TimeBucket = item.ClassTime + "~" + item.EndTime,
// TeacherId = item.TeacherId,
// TeacherName = item.TeacherName,
// ClassId = item.ReserveClassId,
// ClassName = "试听课",
// CouseId = item.TrialLessonId,
// CourseName = item.LessonName,
// KSNum = 1,
// Hours = Hours,
// HourMoney = Math.Round(item.ClassHourFee / Hours, 2, MidpointRounding.AwayFromZero),
// UnitPrice = item.ClassHourFee,
// Money = item.ClassHourFee,
// CouseClassify = 2
// });
// }
// }
//}
//查询期间 学生的上课总课时 + 合同课时单价
var sTimeList = class_CheckRepository.GetStudentHoursList(groupId, userIds, startMonth, endMonth);
......@@ -3537,8 +3520,8 @@ namespace Edu.Module.Finance
var list = class_CheckRepository.GetTeacherConsumptionHoursDetialPageList(pageIndex, pageSize, out count, teacherId, schoolId, classId, startMonth, endMonth, groupId);
var rclist = new List<Model.ViewModel.Reserve.RB_Reserve_Class_Extend>();
if (pageSize == 1000 || pageSize == 10000) {
//查询试听课
rclist = reserve_ClassRepository.GetTeacherHoursDetialList(teacherId > 0 ? teacherId.ToString() : "", schoolId, 0, startMonth, endMonth, groupId);
//查询试听课 ld 2023-08-30 不查询试听课了,
//rclist = reserve_ClassRepository.GetTeacherHoursDetialList(teacherId > 0 ? teacherId.ToString() : "", schoolId, 0, startMonth, endMonth, groupId);
}
if (list.Any() || rclist.Any()) {
//班级类型查询
......@@ -4438,8 +4421,7 @@ namespace Edu.Module.Finance
ClassIdArr.AddRange(list.Select(x => x.ClassId));
}
//查询时间范围内 除订单外 班级下其他订单 的其他收入 + 其他成本支出
string datebaseStr = Config.ReadConfigKey("EduDateBase");//教育数据库
var financeList = RB_FinanceRepository.GetListForReportClass(new RB_Finance_Extend() { RB_Group_Id = userInfo.Group_Id, RB_Branch_Id = schoolId, TCID = -2, sAduitDate = Convert.ToDateTime(startTime), eAduitDate = Convert.ToDateTime(endTime), FinanceType = 2, OrderSource = OrderResourceEnum.Education }, datebaseStr);
var financeList = RB_FinanceRepository.GetListForReportClass(new RB_Finance_Extend() { RB_Group_Id = userInfo.Group_Id, RB_Branch_Id = schoolId, TCID = -2, sAduitDate = Convert.ToDateTime(startTime), eAduitDate = Convert.ToDateTime(endTime), FinanceType = 2, OrderSource = OrderResourceEnum.Education });
if (financeList.Any()) {
ClassIdArr.AddRange(financeList.Select(x => x.TCID ?? 0));
}
......@@ -4559,7 +4541,7 @@ namespace Edu.Module.Finance
SourceIdArr.AddRange(lxOrderList.Select(x => x.SourceId).Distinct());
}
//财务单据
var lxFinanceList = RB_FinanceRepository.GetListForReportClass(new RB_Finance_Extend() { RB_Group_Id = userInfo.Group_Id, RB_Branch_Id = schoolId, TCID = -2, sAduitDate = Convert.ToDateTime(startTime), eAduitDate = Convert.ToDateTime(endTime), FinanceType = 2, OrderSource = OrderResourceEnum.EducationStudy }, datebaseStr);
var lxFinanceList = RB_FinanceRepository.GetListForReportClass(new RB_Finance_Extend() { RB_Group_Id = userInfo.Group_Id, RB_Branch_Id = schoolId, TCID = -2, sAduitDate = Convert.ToDateTime(startTime), eAduitDate = Convert.ToDateTime(endTime), FinanceType = 2, OrderSource = OrderResourceEnum.EducationStudy });
if (lxFinanceList.Any())
{
SourceIdArr.AddRange(lxFinanceList.Select(x => x.TCID ?? 0));
......
......@@ -151,5 +151,21 @@ WHERE b.Group_Id ={groupId} and p.Periods in({string.Join(",", monthList)}) and
GROUP BY p.Periods,b.EmployeeId";
return Get<RB_Personnel_Bonus_Extend>(sql).ToList();
}
/// <summary>
/// 获取当月人头奖励
/// </summary>
/// <param name="month"></param>
/// <param name="groupId"></param>
/// <param name="schoolId"></param>
/// <returns></returns>
public decimal GetPersonnelBonusForMonth(string month, int groupId, int schoolId)
{
string sql = $@"SELECT SUM(b.CurRewardMoney + b.OpenBonus) as OpenBonus FROM rb_personnel_bonus b
INNER JOIN rb_personnel_period p on b.PeriodId = p.Id
WHERE b.Group_Id ={groupId} and b.School_Id ={schoolId} and p.Periods ='{month}' and (b.CurRewardMoney + b.OpenBonus)>0";
var obj = ExecuteScalar(sql);
return obj != null ? Convert.ToDecimal(obj) : 0;
}
}
}
\ No newline at end of file
......@@ -271,7 +271,7 @@ LEFT JOIN rb_travel_finance_relation as E ON A.FinanceId=E.FinanceId where 1=1 "
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public List<RB_Finance_Extend> GetListForReportClass(RB_Finance_Extend model, string datebaseStr)
public List<RB_Finance_Extend> GetListForReportClass(RB_Finance_Extend model)
{
StringBuilder where = new StringBuilder();
where.Append(" and b.Status in(1,2,5) and b.Is_Auto=0 ");
......@@ -313,7 +313,7 @@ LEFT JOIN rb_travel_finance_relation as E ON A.FinanceId=E.FinanceId where 1=1 "
}
if (model.RB_Branch_Id >= 0)
{
where.Append(" AND c.School_Id =" + model.RB_Branch_Id);
where.Append(" AND b.RB_Branch_Id =" + model.RB_Branch_Id);
}
if (model.OrderSource.HasValue)
{
......@@ -329,7 +329,6 @@ from rb_financedetail a INNER JOIN rb_finance as b on a.FinanceId=b.FrID and a.`
INNER JOIN rb_costtype AS D ON D.ID=a.CostTypeId
LEFT JOIN rb_tradeway as td ON b.FrID=td.FinanceId
LEFT JOIN rb_travel_finance_relation as E ON A.FinanceId=E.FinanceId
left join {datebaseStr}.rb_class c on c.ClassId = E.TCID
where 1=1 " + where);
return Get<RB_Finance_Extend>(builder.ToString() + " ORDER BY b.FrID DESC ").ToList();
}
......
......@@ -554,7 +554,7 @@ GROUP BY tt.TeacherId,tt.OrderGuestId
}
if (schoolId >= 0)
{
where += $@" and c.School_Id ={schoolId}";
where += $@" and case when cp.PlanType=2 then cp.School_Id ={schoolId} else c.School_Id ={schoolId} end";
}
if (classId > 0)
{
......@@ -599,7 +599,7 @@ ORDER BY p.ClassDate ASC
}
if (schoolId >= 0)
{
where += $@" and c.School_Id ={schoolId}";
where += $@" and case when cp.PlanType=2 then cp.School_Id ={schoolId} else c.School_Id ={schoolId} end";
}
if (classId > 0)
{
......@@ -649,11 +649,11 @@ ORDER BY p.ClassDate ASC
}
if (schoolId >= 0)
{
where += $@" and c.School_Id ={schoolId}";
where += $@" and case when cp.PlanType=2 then cp.School_Id ={schoolId} else c.School_Id ={schoolId} end";
}
if (classId > 0)
{
where += $@" and p.ClassId ={classId}";
where += $@" and case when cp.PlanType=2 then t2.ClassId ={classId} else p.ClassId ={classId} end";
}
if (!string.IsNullOrEmpty(studentName))
{
......@@ -726,15 +726,15 @@ ORDER BY tt.ClassDate ASC
}
if (schoolId >= 0)
{
where += $@" and c.School_Id ={schoolId}";
where += $@" and case when cp.PlanType=2 then cp.School_Id ={schoolId} else c.School_Id ={schoolId} end";
}
if (classId > 0)
{
where += $@" and p.ClassId ={classId}";
{
where += $@" and case when cp.PlanType=2 then t2.ClassId ={classId} else p.ClassId ={classId} end";
}
if (!string.IsNullOrEmpty(classIds) && classIds != "0")
{
where += $@" and p.ClassId in({classIds})";
where += $@" and case when cp.PlanType=2 then t2.ClassId in({classIds}) else p.ClassId in({classIds}) end";
}
if (!string.IsNullOrEmpty(studentName))
{
......@@ -793,8 +793,12 @@ ORDER BY tt.ClassDate ASC
public List<RB_Class_Check_ViewModel> GetClassLearnHoursList(int groupId, string classIds)
{
string sql = $@"SELECT t.ClassId,SUM(t.CurrentDeductionHours) AS CurrentDeductionHours FROM(
SELECT ClassId,ClassDate,ClassTimeId,MAX(CurrentDeductionHours) as CurrentDeductionHours
FROM rb_class_check WHERE `Status` =0 and Group_Id ={groupId} and ClassId in({classIds}) GROUP BY ClassId,ClassDate,ClassTimeId
SELECT case when cp.PlanType=2 then t2.ClassId else p.ClassId end as ClassId,p.ClassDate,p.ClassTimeId,MAX(p.CurrentDeductionHours) as CurrentDeductionHours
FROM rb_class_check p
INNER JOIN rb_class_time t on p.ClassTimeId = t.ClassTimeId
inner join rb_class_plan cp on t.ClassPlanId = cp.ClassPlanId
LEFT JOIN rb_order_guest t2 on p.OrderGuestId = t2.Id
WHERE p.`Status` =0 and p.Group_Id ={groupId} and case when cp.PlanType=2 then t2.ClassId in({classIds}) else p.ClassId in({classIds}) end GROUP BY case when cp.PlanType=2 then t2.ClassId else p.ClassId end,p.ClassDate,p.ClassTimeId
)t GROUP BY t.ClassId";
return Get<RB_Class_Check_ViewModel>(sql).ToList();
}
......@@ -821,9 +825,12 @@ SELECT tt.ClassId,tt.OrderGuestId,tt.CurrentDeductionHours
+ec.FirstClassFee + ec.SecondClassFee + ec.ThirdClassFee as TotalSub
,ec.FirstClassHours + ec.SecondClassHours + ec.ThirdClassHours as ClassHours
FROM(
SELECT p.ClassId,p.OrderGuestId,SUM(p.CurrentDeductionHours) as CurrentDeductionHours FROM rb_class_check p
WHERE p.`Status`=0 and p.Group_Id ={groupId} and p.ClassId in({classIds})
GROUP BY p.ClassId,p.OrderGuestId
SELECT case when cp.PlanType=2 then t2.ClassId else p.ClassId end as ClassId,p.OrderGuestId,SUM(p.CurrentDeductionHours) as CurrentDeductionHours FROM rb_class_check p
INNER JOIN rb_class_time t on p.ClassTimeId = t.ClassTimeId
inner join rb_class_plan cp on t.ClassPlanId = cp.ClassPlanId
LEFT JOIN rb_order_guest t2 on p.OrderGuestId = t2.Id
WHERE p.`Status`=0 and p.Group_Id ={groupId} and case when cp.PlanType=2 then t2.ClassId in({classIds}) else p.ClassId in({classIds}) end
GROUP BY case when cp.PlanType=2 then t2.ClassId else p.ClassId end,p.OrderGuestId
)tt
LEFT JOIN rb_education_contract ec on tt.OrderGuestId = ec.GuestId and ec.Status <>4
GROUP BY tt.ClassId,tt.OrderGuestId
......@@ -849,11 +856,11 @@ GROUP BY tt.ClassId,tt.OrderGuestId
string where = "";
if (classId > 0)
{
where += " and cc.ClassId =" + classId;
where += $@" and case when cp.PlanType=2 then t2.ClassId ={classId} else cc.ClassId ={classId} end";
}
if (schoolId >= 0)
{
where += " and c.School_Id =" + schoolId;
{
where += $@" and case when cp.PlanType=2 then cp.School_Id ={schoolId} else c.School_Id ={schoolId} end";
}
if (!string.IsNullOrEmpty(classNo))
{
......@@ -861,11 +868,15 @@ GROUP BY tt.ClassId,tt.OrderGuestId
}
string sql = $@"
SELECT q.ClassId,q.ClassNo,q.ClassName,SUM(q.CurrentDeductionHours) AS CurrentDeductionHours FROM(
SELECT cc.ClassId,cc.ClassDate,cc.ClassTimeId,MAX(cc.CurrentDeductionHours) as CurrentDeductionHours,
c.ClassName,c.ClassNo
SELECT case when cp.PlanType=2 then t2.ClassId else cc.ClassId end as ClassId,cc.ClassDate,cc.ClassTimeId,MAX(cc.CurrentDeductionHours) as CurrentDeductionHours,
case when cp.PlanType=2 then c2.ClassName else c.ClassName end as ClassName,case when cp.PlanType=2 then c2.ClassNo else c.ClassNo end as ClassNo
FROM rb_class_check cc
INNER JOIN rb_class_time t on cc.ClassTimeId = t.ClassTimeId
inner join rb_class_plan cp on t.ClassPlanId = cp.ClassPlanId
LEFT JOIN rb_order_guest t2 on cc.OrderGuestId = t2.Id
LEFT JOIN rb_class c on cc.ClassId = c.ClassId
WHERE cc.`Status` =0 and cc.Group_Id ={group_Id} and cc.ClassDate >='{startTime}' and cc.ClassDate <='{endTime} 23:59:59' {where} GROUP BY cc.ClassId,cc.ClassDate,cc.ClassTimeId)q GROUP BY q.ClassId";
LEFT JOIN rb_class c2 on t2.ClassId = c2.ClassId
WHERE cc.`Status` =0 and cc.Group_Id ={group_Id} and cc.ClassDate >='{startTime}' and cc.ClassDate <='{endTime} 23:59:59' {where} GROUP BY case when cp.PlanType=2 then t2.ClassId else cc.ClassId end,cc.ClassDate,cc.ClassTimeId)q GROUP BY q.ClassId";
return Get<RB_Class_Check_ViewModel>(sql).ToList();
}
......
......@@ -406,6 +406,22 @@ GROUP BY b.BatchName,r.OrderSourceId";
return Get<RB_Order_ReturnComission_ViewModel>(sql).ToList();
}
/// <summary>
/// 获取分月下累计返佣
/// </summary>
/// <param name="month"></param>
/// <param name="groupId"></param>
/// <returns></returns>
public decimal GetOrderReturnComissionForMonth(string month, int groupId,int schoolId)
{
string sql = $@"SELECT SUM(r.CommissionMoeny)as CommissionMoeny FROM rb_order_returncomission r
INNER JOIN rb_returnmoney_batch b on r.BatchId = b.Id
WHERE r.GroupId ={groupId} and r.SchoolId ={schoolId} and r.CommissionType =1 and b.BatchName ='{month}' and r.CommissionMoeny >0
";
var obj = ExecuteScalar(sql);
return obj != null ? Convert.ToDecimal(obj) : 0;
}
/// <summary>
/// 获取用户返佣列表
/// </summary>
......
......@@ -358,23 +358,19 @@ LEFT JOIN rb_sell_achievements_periods AS p ON r.PeriodId = p.Id where {where} "
/// <param name="startTime"></param>
/// <param name="endTime"></param>
/// <returns></returns>
public List<RB_Sell_Achievements_Details_ViewModel> GetSellCommissionForDate(int group_Id, int schoolId, string classIds, string startTime, string endTime)
public decimal GetSellCommissionForDate(int group_Id, int schoolId, string startTime, string endTime)
{
string where = "";
if (!string.IsNullOrEmpty(classIds)) {
where += $@" and d.ClassId in ({classIds})";
}
if (schoolId >= 0)
{
where = $@" and c.School_Id ={schoolId}";
where = $@" and d.School_Id ={schoolId}";
}
string sql = $@"SELECT d.ClassId,SUM(d.CurrentPeriodMoney + d.DeductionMoney) AS CurrentPeriodMoney FROM RB_Sell_Achievements_Details d
string sql = $@"SELECT SUM(d.CurrentPeriodMoney + d.DeductionMoney) AS CurrentPeriodMoney FROM RB_Sell_Achievements_Details d
INNER JOIN rb_sell_achievements_periods p on d.PeriodId = p.Id
left join rb_class c on d.ClassId = c.ClassId
WHERE p.Group_Id ={group_Id} {where} and STR_TO_DATE(CONCAT(p.Periods,'-01'),'%Y-%m-%d') >='{startTime}' and STR_TO_DATE(CONCAT(p.Periods,'-01'),'%Y-%m-%d') <='{endTime} 23:59:59'
GROUP BY d.ClassId";
return Get<RB_Sell_Achievements_Details_ViewModel>(sql).ToList();
WHERE p.Group_Id ={group_Id} {where} and STR_TO_DATE(CONCAT(p.Periods,'-01'),'%Y-%m-%d') >='{startTime}' and STR_TO_DATE(CONCAT(p.Periods,'-01'),'%Y-%m-%d') <='{endTime} 23:59:59'";
var obj = ExecuteScalar(sql);
return obj != null ? Convert.ToDecimal(obj) : 0;
}
}
}
......@@ -375,12 +375,11 @@ where {where}";
where = $@" and d.ClassId in ({classIds})";
}
if (schoolId >= 0) {
where = $@" and c.School_Id ={schoolId}";
where = $@" and d.School_Id ={schoolId}";
}
string sql = $@"SELECT d.ClassId,SUM(d.Money) AS Money FROM rb_teaching_bonusdetail d
INNER JOIN rb_teaching_bonus p on d.BonusId = p.Id
left join rb_class c on d.ClassId = c.ClassId
WHERE p.Group_Id ={group_Id} {where} and STR_TO_DATE(CONCAT(p.`Month`,'-01'),'%Y-%m-%d') >='{startTime}' and STR_TO_DATE(CONCAT(p.`Month`,'-01'),'%Y-%m-%d') <='{endTime} 23:59:59'
GROUP BY d.ClassId";
return Get<RB_Teaching_BonusDetail_ViewModel>(sql).ToList();
......
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