Commit 3692b400 authored by 吴春's avatar 吴春

Merge branch 'master' of http://gitlab.oytour.com/Kui2/education

parents 065557b4 9ef8c07b
...@@ -464,62 +464,29 @@ namespace Edu.Module.Course ...@@ -464,62 +464,29 @@ namespace Edu.Module.Course
{ {
//检查学员是否存在有效订单 //检查学员是否存在有效订单
int orderCount = studentRepository.GetStudentOrderCount(x.StuId); int orderCount = studentRepository.GetStudentOrderCount(x.StuId);
if (model.OrderCourseList != null && model.OrderCourseList.Any()) var commissionModel = new RB_Order_ReturnComission_ViewModel()
{ {
foreach (var item in model.OrderCourseList) Id = 0,
{ OrderId = model.OrderId,
var commissionModel = new RB_Order_ReturnComission_ViewModel() OrderSourceType = x.CreateType,
{ OrderSourceId = x.CreateType == StuCreateTypeEnum.EmployeeInput ? x.CreateBy : (x.CreateType == StuCreateTypeEnum.CustomerInput ? x.CustomerId : x.StuSourceId),
Id = 0, Status = -1, //下单默认为不可返佣,等待付款完成后更新为待返佣
OrderId = model.OrderId, UnionCashOutId = 0,
OrderSourceType = x.CreateType, StuId = x.StuId,
OrderSourceId = x.CreateType == StuCreateTypeEnum.EmployeeInput ? x.CreateBy : (x.CreateType == StuCreateTypeEnum.CustomerInput ? x.CustomerId : x.StuSourceId), CommissionType = orderCount == 0 ? 1 : 2,
Status = -1, //下单默认为不可返佣,等待付款完成后更新为待返佣 SchoolId = model.School_Id,
UnionCashOutId = 0, GroupId = model.Group_Id,
StuId = x.StuId, Remark = "",
CommissionType = orderCount == 0 ? 1 : 2, };
SchoolId = model.School_Id, if (model.OrderType == OrderTypeEnum.CourseOrder)
GroupId = model.Group_Id, {
Remark = "", FormatOrderCommissionByCourse(ref commissionModel, model.CourseId, model.PreferPrice - model.DiscountMoney);
};
if (model.OrderType == OrderTypeEnum.CourseOrder)
{
FormatOrderCommissionByCourse(ref commissionModel, item.CourseId, model.PreferPrice - model.DiscountMoney);
}
else if (model.OrderType == OrderTypeEnum.StudyabroadOrder)
{
FormatOrderCommissionByStudyabrad(ref commissionModel, model.SourceId, 0);
}
returnComissionRepository.Insert(commissionModel);
}
} }
else else if (model.OrderType == OrderTypeEnum.StudyabroadOrder)
{ {
var commissionModel = new RB_Order_ReturnComission_ViewModel() FormatOrderCommissionByStudyabrad(ref commissionModel, model.SourceId, 0);
{
Id = 0,
OrderId = model.OrderId,
OrderSourceType = x.CreateType,
OrderSourceId = x.CreateType == StuCreateTypeEnum.EmployeeInput ? x.CreateBy : (x.CreateType == StuCreateTypeEnum.CustomerInput ? x.CustomerId : x.StuSourceId),
Status = -1, //下单默认为不可返佣,等待付款完成后更新为待返佣
UnionCashOutId = 0,
StuId = x.StuId,
CommissionType = orderCount == 0 ? 1 : 2,
SchoolId = model.School_Id,
GroupId = model.Group_Id,
Remark = "",
};
if (model.OrderType == OrderTypeEnum.CourseOrder)
{
FormatOrderCommissionByCourse(ref commissionModel, model.CourseId, model.PreferPrice - model.DiscountMoney);
}
else if (model.OrderType == OrderTypeEnum.StudyabroadOrder)
{
FormatOrderCommissionByStudyabrad(ref commissionModel, model.SourceId, 0);
}
returnComissionRepository.Insert(commissionModel);
} }
returnComissionRepository.Insert(commissionModel);
}); });
} }
} }
...@@ -689,8 +656,14 @@ namespace Edu.Module.Course ...@@ -689,8 +656,14 @@ namespace Edu.Module.Course
public void FormatOrderCommissionByCourse(ref RB_Order_ReturnComission_ViewModel m, int courseId, decimal orderIncome) public void FormatOrderCommissionByCourse(ref RB_Order_ReturnComission_ViewModel m, int courseId, decimal orderIncome)
{ {
var courseModel = courseRepository.GetEntity(courseId); var courseModel = courseRepository.GetEntity(courseId);
//首先查询一下 订单是否关联多课程
var orderCourseList = order_CourseRepository.GetOrderCourseListRepository(new RB_Order_Course() { Group_Id = m.GroupId, OrderId = m.OrderId }, "");
if (orderCourseList.Any() && orderCourseList.Count() > 1) {
//取最高等级的课程
var courseList = courseRepository.GetCourseListRepository(new RB_Course_ViewModel() { Group_Id = m.GroupId, QCourseIds = string.Join(",", orderCourseList.Select(x => x.CourseId)) });
courseModel = courseList.OrderByDescending(x => x.CourseRate).FirstOrDefault();
}
if (courseModel != null) if (courseModel != null)
{ {
var sellPrice = courseModel.SellPrice * ((100 - (m.CommissionType == 1 ? courseModel.B2CRatio : courseModel.B2CReNewRatio)) / 100); var sellPrice = courseModel.SellPrice * ((100 - (m.CommissionType == 1 ? courseModel.B2CRatio : courseModel.B2CReNewRatio)) / 100);
......
...@@ -142,7 +142,7 @@ namespace Edu.Module.Course ...@@ -142,7 +142,7 @@ namespace Edu.Module.Course
var guestModel = order_GuestRepository.GetEntity(backModel.GuestId); var guestModel = order_GuestRepository.GetEntity(backModel.GuestId);
//orderModel.CommissionMoney = returnComissionRepository.GetOrderReturnComissionListRepositpry(new RB_Order_ReturnComission_ViewModel() { GroupId = orderModel.Group_Id, QOrderIds = orderModel.OrderId.ToString() }).Sum(x => x.CommissionMoeny); //orderModel.CommissionMoney = returnComissionRepository.GetOrderReturnComissionListRepositpry(new RB_Order_ReturnComission_ViewModel() { GroupId = orderModel.Group_Id, QOrderIds = orderModel.OrderId.ToString() }).Sum(x => x.CommissionMoeny);
orderModel.TotalClassHours = guestModel.TotalHours; orderModel.TotalClassHours = guestModel.TotalHours;
orderModel.Class_Price = guestModel.ClassUnitPrice; orderModel.Unit_Price = guestModel.ClassUnitPrice;
decimal backMoney = orderRepository.CalcBackMoneyRepository(orderModel, courseModel, FinishHours, out decimal classHourPrice); decimal backMoney = orderRepository.CalcBackMoneyRepository(orderModel, courseModel, FinishHours, out decimal classHourPrice);
var obj = new var obj = new
{ {
......
...@@ -603,7 +603,8 @@ WHERE 1=1 ...@@ -603,7 +603,8 @@ WHERE 1=1
var teacherModel = accountRepository.GetAccountListExtRepository(new Model.ViewModel.User.RB_Account_ViewModel() var teacherModel = accountRepository.GetAccountListExtRepository(new Model.ViewModel.User.RB_Account_ViewModel()
{ {
AccountId = (classModel?.Teacher_Id ?? 0), AccountId = (classModel?.Teacher_Id ?? 0),
AccountType = Common.Enum.User.AccountTypeEnum.Teacher AccountType = Common.Enum.User.AccountTypeEnum.Teacher,
IsSelectLevelNor = 1
})?.FirstOrDefault(); })?.FirstOrDefault();
teacherId = teacherModel?.Id ?? 0; teacherId = teacherModel?.Id ?? 0;
} }
...@@ -632,7 +633,8 @@ WHERE 1=1 ...@@ -632,7 +633,8 @@ WHERE 1=1
var headmaster = accountRepository.GetAccountListExtRepository(new Model.ViewModel.User.RB_Account_ViewModel() var headmaster = accountRepository.GetAccountListExtRepository(new Model.ViewModel.User.RB_Account_ViewModel()
{ {
Post_Id = Common.Config.SchoolPostId, Post_Id = Common.Config.SchoolPostId,
Group_Id = GroupId Group_Id = GroupId,
IsSelectLevelNor = 1
})?.FirstOrDefault(); })?.FirstOrDefault();
var headmasterId = (headmaster?.Id ?? 0); var headmasterId = (headmaster?.Id ?? 0);
return headmasterId; return headmasterId;
...@@ -648,7 +650,8 @@ WHERE 1=1 ...@@ -648,7 +650,8 @@ WHERE 1=1
var headmaster = accountRepository.GetAccountListExtRepository(new Model.ViewModel.User.RB_Account_ViewModel() var headmaster = accountRepository.GetAccountListExtRepository(new Model.ViewModel.User.RB_Account_ViewModel()
{ {
Post_Id = Common.Config.JiaoWuZhang, Post_Id = Common.Config.JiaoWuZhang,
Group_Id = GroupId Group_Id = GroupId,
IsSelectLevelNor = 1
})?.FirstOrDefault(); })?.FirstOrDefault();
var jiaoWuZhangId = (headmaster?.Id ?? 0); var jiaoWuZhangId = (headmaster?.Id ?? 0);
return jiaoWuZhangId; return jiaoWuZhangId;
...@@ -666,7 +669,8 @@ WHERE 1=1 ...@@ -666,7 +669,8 @@ WHERE 1=1
var list = accountRepository.GetAccountListExtRepository(new Model.ViewModel.User.RB_Account_ViewModel() var list = accountRepository.GetAccountListExtRepository(new Model.ViewModel.User.RB_Account_ViewModel()
{ {
Group_Id = GroupId, Group_Id = GroupId,
QPostIds = PostId QPostIds = PostId,
IsSelectLevelNor = 1
}); });
if (list != null && list.Count > 0) if (list != null && list.Count > 0)
{ {
......
...@@ -670,18 +670,29 @@ GROUP BY ClassId;"; ...@@ -670,18 +670,29 @@ GROUP BY ClassId;";
/// <returns></returns> /// <returns></returns>
public decimal CalcBackMoneyRepository(RB_Order orderModel, RB_Course courseModel, decimal FinishHours, out decimal newClassHourPrice) public decimal CalcBackMoneyRepository(RB_Order orderModel, RB_Course courseModel, decimal FinishHours, out decimal newClassHourPrice)
{ {
newClassHourPrice = 0;
//课时单价 //课时单价
decimal classHourPrice = orderModel.Class_Price; decimal classHourPrice = orderModel.Unit_Price;
newClassHourPrice = classHourPrice; newClassHourPrice = classHourPrice;
//预计退款金额 //预计退款金额
decimal backMoney = 0; decimal backMoney = 0;
//违约金
//decimal breakContractPrice = (orderModel.TotalClassHours - FinishHours) * classHourPrice * Convert.ToDecimal(0.1);
//可退总金额
decimal OrderMoney = orderModel.Income + orderModel.PlatformTax - orderModel.Refund - orderModel.CoursewareFee - orderModel.TextbookFee;
backMoney = OrderMoney / orderModel.GuestNum - FinishHours * classHourPrice;// - breakContractPrice; 违约金 先排除 if (orderModel.CreateTime >= Convert.ToDateTime("2024-09-01"))
{
//违约金
decimal breakContractPrice = (orderModel.TotalClassHours - FinishHours) * classHourPrice * Convert.ToDecimal(0.1);
//可退总金额
decimal OrderMoney = orderModel.Income + orderModel.PlatformTax - orderModel.Refund - orderModel.CoursewareFee - orderModel.TextbookFee;
backMoney = OrderMoney / orderModel.GuestNum - FinishHours * classHourPrice - breakContractPrice;
}
else
{
//违约金
decimal breakContractPrice = (orderModel.TotalClassHours - FinishHours) * classHourPrice * Convert.ToDecimal(0.1);
//可退总金额
decimal OrderMoney = orderModel.Income + orderModel.PlatformTax - orderModel.Refund;
backMoney = OrderMoney / orderModel.GuestNum - FinishHours * classHourPrice - breakContractPrice;
}
return backMoney; return backMoney;
} }
......
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