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
{
//检查学员是否存在有效订单
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)
{
var commissionModel = new RB_Order_ReturnComission_ViewModel()
{
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, item.CourseId, model.PreferPrice - model.DiscountMoney);
}
else if (model.OrderType == OrderTypeEnum.StudyabroadOrder)
{
FormatOrderCommissionByStudyabrad(ref commissionModel, model.SourceId, 0);
}
returnComissionRepository.Insert(commissionModel);
}
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
else if (model.OrderType == OrderTypeEnum.StudyabroadOrder)
{
var commissionModel = new RB_Order_ReturnComission_ViewModel()
{
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);
FormatOrderCommissionByStudyabrad(ref commissionModel, model.SourceId, 0);
}
returnComissionRepository.Insert(commissionModel);
});
}
}
......@@ -689,8 +656,14 @@ namespace Edu.Module.Course
public void FormatOrderCommissionByCourse(ref RB_Order_ReturnComission_ViewModel m, int courseId, decimal orderIncome)
{
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)
{
var sellPrice = courseModel.SellPrice * ((100 - (m.CommissionType == 1 ? courseModel.B2CRatio : courseModel.B2CReNewRatio)) / 100);
......
......@@ -142,7 +142,7 @@ namespace Edu.Module.Course
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.TotalClassHours = guestModel.TotalHours;
orderModel.Class_Price = guestModel.ClassUnitPrice;
orderModel.Unit_Price = guestModel.ClassUnitPrice;
decimal backMoney = orderRepository.CalcBackMoneyRepository(orderModel, courseModel, FinishHours, out decimal classHourPrice);
var obj = new
{
......
......@@ -603,7 +603,8 @@ WHERE 1=1
var teacherModel = accountRepository.GetAccountListExtRepository(new Model.ViewModel.User.RB_Account_ViewModel()
{
AccountId = (classModel?.Teacher_Id ?? 0),
AccountType = Common.Enum.User.AccountTypeEnum.Teacher
AccountType = Common.Enum.User.AccountTypeEnum.Teacher,
IsSelectLevelNor = 1
})?.FirstOrDefault();
teacherId = teacherModel?.Id ?? 0;
}
......@@ -632,7 +633,8 @@ WHERE 1=1
var headmaster = accountRepository.GetAccountListExtRepository(new Model.ViewModel.User.RB_Account_ViewModel()
{
Post_Id = Common.Config.SchoolPostId,
Group_Id = GroupId
Group_Id = GroupId,
IsSelectLevelNor = 1
})?.FirstOrDefault();
var headmasterId = (headmaster?.Id ?? 0);
return headmasterId;
......@@ -648,7 +650,8 @@ WHERE 1=1
var headmaster = accountRepository.GetAccountListExtRepository(new Model.ViewModel.User.RB_Account_ViewModel()
{
Post_Id = Common.Config.JiaoWuZhang,
Group_Id = GroupId
Group_Id = GroupId,
IsSelectLevelNor = 1
})?.FirstOrDefault();
var jiaoWuZhangId = (headmaster?.Id ?? 0);
return jiaoWuZhangId;
......@@ -666,7 +669,8 @@ WHERE 1=1
var list = accountRepository.GetAccountListExtRepository(new Model.ViewModel.User.RB_Account_ViewModel()
{
Group_Id = GroupId,
QPostIds = PostId
QPostIds = PostId,
IsSelectLevelNor = 1
});
if (list != null && list.Count > 0)
{
......
......@@ -670,18 +670,29 @@ GROUP BY ClassId;";
/// <returns></returns>
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;
//预计退款金额
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;
}
......
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