Commit 441b15c1 authored by liudong1993's avatar liudong1993

教育留学报表

parent dca355b8
......@@ -181,7 +181,7 @@ namespace Edu.Model.Entity.Finance
public int Rb_Group_Id { get; set; }
/// <summary>
/// 数据类型 1培训 2留学
/// 数据类型 1培训 2留学 3就业
/// </summary>
public int DateType { get; set; }
......
......@@ -14,6 +14,11 @@ namespace Edu.Model.ViewModel.Course
/// </summary>
public string ClassIds { get; set; }
/// <summary>
/// 项目ids
/// </summary>
public string SourceIds { get; set; }
/// <summary>
/// 讲师名称
/// </summary>
......
......@@ -13,6 +13,10 @@ namespace Edu.Model.ViewModel.Finance
[DB(ConnectionName = "DataStatisticsConnection")]
public class RB_Edu_RevenueReport_Extend : RB_Edu_RevenueReport
{
/// <summary>
/// 是否查询留学相关 1是
/// </summary>
public int IsSelectStuAbroad { get; set; }
/// <summary>
/// 开始时间
/// </summary>
......
......@@ -74,5 +74,15 @@ namespace Edu.Model.ViewModel.StudyAbroad
/// 留学就业编号查询使用
/// </summary>
public string QIds { get; set; }
/// <summary>
/// 开始时间
/// </summary>
public string StartTime { get; set; }
/// <summary>
/// 结束时间
/// </summary>
public string EndTime { get; set; }
}
}
......@@ -8,6 +8,7 @@ using Edu.Model.ViewModel.Course;
using Edu.Model.ViewModel.Finance;
using Edu.Repository.Course;
using Edu.Repository.Finance;
using Edu.Repository.StudyAbroad;
using Edu.Repository.User;
namespace Edu.Module.Finance
......@@ -97,6 +98,14 @@ namespace Edu.Module.Finance
/// 学校仓储层对象
/// </summary>
private readonly RB_SchoolRepository schoolRepository = new RB_SchoolRepository();
/// <summary>
/// 留学就业
/// </summary>
private readonly RB_StudyAbroadRepository studyAbroadRepository = new RB_StudyAbroadRepository();
/// <summary>
/// 供应商
/// </summary>
private readonly RB_SupplierRepository supplierRepository = new RB_SupplierRepository();
......@@ -295,7 +304,7 @@ namespace Edu.Module.Finance
{
string classIds = string.Join(",", classList.Select(x => x.ClassId));
//根据班级查询所有的订单列表
orderAllList = orderRepository.GetList(new RB_Order_ViewModel() { Group_Id = GroupId, ClassIds = classIds, Q_OrderState = 1 });
orderAllList = orderRepository.GetList(new RB_Order_ViewModel() { Group_Id = GroupId, ClassIds = classIds, OrderType = Common.Enum.Sale.OrderTypeEnum.CourseOrder, Q_OrderState = 1 });
//查询班级下所有的财务单据
FAllList = RB_FinanceRepository.GetDataStatisticsListThree(new RB_Finance_Extend() { TCIDStr = classIds, OrderSource = OrderResourceEnum.Education });
teacherBonusList = teaching_BonusDetailRepository.GetList(new RB_Teaching_BonusDetail_ViewModel { Group_Id = GroupId, ClassIds = classIds });
......@@ -403,6 +412,122 @@ namespace Edu.Module.Finance
}
}
#region 留学就业
//查询日期范围内所有的留学就业项目
var saList = studyAbroadRepository.GetStudyAbroadListExtRepository(new Model.ViewModel.StudyAbroad.RB_StudyAbroad_ViewModel() { Group_Id = GroupId, SaleState = Common.Enum.Sale.SaleStateEnum.Sell, StartTime = STime, EndTime = ETime });
if (saList.Any()) {
string saIds = string.Join(",", saList.Select(x => x.Id));
//根据班级查询所有的订单列表
orderAllList = orderRepository.GetList(new RB_Order_ViewModel() { Group_Id = GroupId, SourceIds = saIds, OrderType = Common.Enum.Sale.OrderTypeEnum.StudyabroadOrder, Q_OrderState = 1 });
//查询班级下所有的财务单据
FAllList = RB_FinanceRepository.GetDataStatisticsListThree(new RB_Finance_Extend() { TCIDStr = saIds, OrderSource = OrderResourceEnum.EducationStudy });
}
//排除取消/删除项目
oldlist = edu_RevenueReportRepository.GetList(new RB_Edu_RevenueReport_Extend() { StartTime = STime, EndTime = ETime, IsSelectStuAbroad = 1, Rb_Group_Id = GroupId });
delList = oldlist.Where(x => !saList.Select(y => y.Id).Contains(x.ClassId)).ToList();
if (delList.Any())
{
edu_RevenueReportRepository.DeleteBatch(delList);
}
foreach (var item in saList) {
try
{
Console.WriteLine("留学就业:" + item.Name + "|" + item.Id);
bool IsNew = false;//是否新增
var orderList = orderAllList.Where(x => x.SourceId == item.Id).ToList();
var financeList = FAllList.Where(x => x.TCID == item.Id).ToList();
var demodel = oldlist.Where(x => x.ClassId == item.Id).FirstOrDefault();
if (demodel == null)
{
IsNew = true;
//新增
demodel = new RB_Edu_RevenueReport_Extend()
{
Id = 0,
ClassId = item.Id,
Rb_Group_Id = GroupId,
SchoolId = item.School_Id,
SchoolName = item.SchoolName,
DateType = item.Type == 1 ? 2 : 3
};
}
#region 初始化数据
demodel.ClassBegins = item.CreateTime;
demodel.ClassName = item.Name;
demodel.ClassState = 0;
demodel.CourseId = 0;
demodel.CourseName = item.SupplierName;
demodel.TeacherId = 0;
demodel.TeacherName = item.Type == 1 ? "留学" : "就业";
demodel.SchoolId = item.School_Id;
demodel.SchoolName = item.SchoolName;
#endregion
#region 统计数据
#region 订单
demodel.YingShou = orderList.Sum(x => x.PreferPrice);
demodel.ShiShou = orderList.Sum(x => x.Income);
demodel.TuiKuan = orderList.Sum(x => x.Refund);
demodel.PingTaiShuiJin = orderList.Sum(x => x.PlatformTax);
demodel.ZaiTu = 0;//暂时在途未做
demodel.YouHui = orderList.Sum(x => x.DiscountMoney);
demodel.DaiShou = (demodel.YingShou - demodel.ShiShou + demodel.TuiKuan - demodel.PingTaiShuiJin - demodel.YouHui);
demodel.YiShou = -demodel.DaiShou;
demodel.GuestNum = orderList.Sum(x => x.GuestNum);
#endregion
#region 财务单据
//排序订单单据
var cfinanceList = financeList.Where(x => x.OrderID == 0 && x.Type == WFTempLateClassEnum.IN).ToList();
demodel.QTShouRu = cfinanceList.Where(y => y.Is_Cashier == 1).Sum(x => x.Money ?? 0);
demodel.QTShouRu -= cfinanceList.Where(x => x.Is_Cashier == 1 && x.Fee > 0).GroupBy(x => new { x.FrID, x.Fee }).Sum(x => x.Key.Fee ?? 0);
//支出
demodel.TiCheng = orderList.Where(x => x.IsCommissionGive == 1).Sum(x => x.CommissionMoney);//销售提成
demodel.ClassFee = 0;//老师提成 -留学暂定
demodel.JiXiaoMoney = 0;//绩效提成 -留学暂定
var ofinanceList = financeList.Where(x => x.Type == WFTempLateClassEnum.OUT).ToList();// 支出包括退款
demodel.QTZhiChu = ofinanceList.Sum(x => x.Money ?? 0);
demodel.YingFu = demodel.QTZhiChu + demodel.TiCheng + demodel.ClassFee + demodel.JiXiaoMoney;
#endregion
demodel.MaoLi = demodel.ShiShou - demodel.YingFu;
demodel.ShiJiLiRun = demodel.MaoLi + demodel.QTShouRu;
//毛利率
if (demodel.ShiShou != 0)
{
demodel.MaoLiRate = Math.Round(demodel.MaoLi / demodel.ShiShou * 100, 2, MidpointRounding.AwayFromZero);
}
if (demodel.GuestNum > 0)
{
//平均收入=实收+自费收入+其他收入+佣金收入(属于佣金的所有)/参团+单团报入
demodel.AverageIncome = Math.Round((demodel.ShiShou + demodel.QTShouRu) / demodel.GuestNum, 2, MidpointRounding.AwayFromZero);
//平均成本=应付/参团+单团报入
demodel.AverageCost = Math.Round((demodel.YingFu / demodel.GuestNum), 2, MidpointRounding.AwayFromZero);
}
//平均利润=平均收入-平均成本
demodel.AverageProfit = demodel.AverageIncome - demodel.AverageCost;
#endregion
if (IsNew)
{
edu_RevenueReportRepository.Insert(demodel);
}
else
{
edu_RevenueReportRepository.Update(demodel);
}
}
catch (Exception ex)
{
Console.WriteLine("留学就业:" + item.Name + "|" + item.Id + ",错误:" + ex.Message);
LogHelper.Write(ex, "SetEduRevenueReport");
}
}
#endregion
var fumodel = edu_UpdateRecordRepository.GetList(new RB_Report_UpdateRecord() { Type = 1 }).FirstOrDefault();
if (fumodel != null)
{
......
......@@ -35,6 +35,10 @@ namespace Edu.Repository.Course
{
where += $@" and o.{nameof(RB_Order_ViewModel.OrderId)} ={demodel.OrderId}";
}
if (demodel.OrderType > 0)
{
where += $@" and o.{nameof(RB_Order_ViewModel.OrderType)} ={(int)demodel.OrderType}";
}
if (demodel.ClassId > 0)
{
where += $@" and o.{nameof(RB_Order_ViewModel.ClassId)} ={demodel.ClassId}";
......@@ -47,6 +51,10 @@ namespace Edu.Repository.Course
{
where += $@" and o.{nameof(RB_Order_ViewModel.ClassId)} in({demodel.ClassIds})";
}
if (!string.IsNullOrEmpty(demodel.SourceIds))
{
where += $@" and o.{nameof(RB_Order_ViewModel.SourceId)} in({demodel.SourceIds})";
}
if (demodel.OrderState > 0)
{
where += $@" and o.{nameof(RB_Order_ViewModel.OrderState)} ={(int)demodel.OrderState}";
......
......@@ -33,6 +33,10 @@ namespace Edu.Repository.Finance
{
where += string.Format(" AND A." + nameof(RB_Edu_RevenueReport_Extend.DateType) + "=" + model.DateType);
}
if (model.IsSelectStuAbroad == 1)
{
where += string.Format(" AND A." + nameof(RB_Edu_RevenueReport_Extend.DateType) + " in(2,3)");
}
if (model.ClassId >0)
{
where += string.Format(" AND A." + nameof(RB_Edu_RevenueReport_Extend.ClassId) + "=" + model.ClassId);
......
......@@ -176,8 +176,9 @@ WHERE 1=1
var parameters = new DynamicParameters();
StringBuilder builder = new StringBuilder();
builder.AppendFormat(@"
SELECT A.*,IFNULL(B.`Name`,'') AS SupplierName,IFNULL(B.ContractUrl,'') AS ContractUrl
SELECT A.*,IFNULL(B.`Name`,'') AS SupplierName,IFNULL(B.ContractUrl,'') AS ContractUrl,IFNULL(C.SName,'') AS SchoolName
FROM RB_StudyAbroad AS A LEFT JOIN rb_supplier AS B ON A.SupplierId=B.Id
LEFT JOIN rb_school AS C ON A.School_Id=C.SId
WHERE 1=1
");
builder.AppendFormat(" AND A.{0}={1}", nameof(RB_StudyAbroad_ViewModel.Status), (int)DateStateEnum.Normal);
......@@ -216,6 +217,14 @@ WHERE 1=1
{
builder.AppendFormat(" AND A.{0}={1}", nameof(RB_StudyAbroad_ViewModel.Id), query.Id);
}
if (!string.IsNullOrEmpty(query.StartTime))
{
builder.AppendFormat(" AND A.{0} >='{1}'", nameof(RB_StudyAbroad_ViewModel.CreateTime), query.StartTime);
}
if (!string.IsNullOrEmpty(query.EndTime))
{
builder.AppendFormat(" AND A.{0} <='{1} 23:59:59'", nameof(RB_StudyAbroad_ViewModel.CreateTime), query.EndTime);
}
return Get<RB_StudyAbroad_ViewModel>(builder.ToString(), parameters).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