Commit b86de482 authored by 黄奎's avatar 黄奎

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

parents 69e001bc 2da8453d
......@@ -58,6 +58,10 @@ namespace Edu.Module.Course
/// 同行返佣
/// </summary>
private readonly RB_Customer_BalanceDetailRepository customer_BalanceDetailRepository = new RB_Customer_BalanceDetailRepository();
/// <summary>
/// 订单返佣
/// </summary>
private readonly RB_Order_ReturnComissionRepository order_ReturnComissionRepository = new RB_Order_ReturnComissionRepository();
/// <summary>
/// 订单
......@@ -723,7 +727,12 @@ namespace Edu.Module.Course
}
//根据订单 查询同行返佣
string orderIds = string.Join(",", orderList.Select(x => x.OrderId));
var bdList = customer_BalanceDetailRepository.GetCustomerBalanceDetailListRepository(new Model.ViewModel.Customer.RB_Customer_BalanceDetail_ViewModel() { Group_Id = userInfo.Group_Id, QOrderIds = orderIds });
var bdList = order_ReturnComissionRepository.GetOrderReturnComissionListRepositpry(new RB_Order_ReturnComission_ViewModel() { GroupId = userInfo.Group_Id, QOrderIds = orderIds });
#region 验证订单是否已生成返佣 (必须有返佣数据 才能参与业绩提成)
var cbdOrderlist = bdList.Where(x => x.Status >= 0).Select(x => x.OrderId).ToList();
orderList = orderList.Where(x => cbdOrderlist.Contains(x.OrderId)).ToList();//都是已返佣的
#endregion
foreach (var item in rulelist.Where(x => x.Type == 3)) {
//老师适配规则
......@@ -746,7 +755,7 @@ namespace Edu.Module.Course
//计算老师业绩
decimal TotalYj = orderChildList.Sum(x => x.PreferPrice - x.DiscountMoney);
//计算订单累计返佣
decimal bdMoney = bdList.Where(x => orderChildList.Select(y => y.OrderId).Contains(x.OrderId) && x.BalanceType == 1).Sum(x => x.Money);
decimal bdMoney = bdList.Where(x => orderChildList.Select(y => y.OrderId).Contains(x.OrderId)).Sum(x => x.CommissionMoeny);
decimal YjMoney = TotalYj - bdMoney;//排除同行返佣
//根据业绩所在区间 查询比例
var rateModel = item.RateList.Where(x => x.StartValue < YjMoney && (x.EndValue >= YjMoney || x.EndValue == -1)).FirstOrDefault();
......@@ -755,7 +764,7 @@ namespace Edu.Module.Course
foreach (var qitem in orderChildList)
{
//当前订单的业绩
decimal bdCommission = bdList.Where(x => x.OrderId == qitem.OrderId && x.BalanceType == 1).Sum(x => x.Money);
decimal bdCommission = bdList.Where(x => x.OrderId == qitem.OrderId).Sum(x => x.CommissionMoeny);
decimal orderYj = qitem.PreferPrice - qitem.DiscountMoney - bdCommission;
AchEmpList.Add(new RB_Sell_Achievements_Emp_ViewModel()
{
......@@ -810,7 +819,7 @@ namespace Edu.Module.Course
//计算市场业绩
decimal TotalYj = orderChildList.Sum(x => x.PreferPrice - x.DiscountMoney);
//计算订单累计返佣
decimal bdMoney = bdList.Where(x => orderChildList.Select(y => y.OrderId).Contains(x.OrderId) && x.BalanceType == 1).Sum(x => x.Money);
decimal bdMoney = bdList.Where(x => orderChildList.Select(y => y.OrderId).Contains(x.OrderId)).Sum(x => x.CommissionMoeny);
//查询老师的提成
decimal teacherMoney = AchEmpList.Where(x => x.Type == 3 && orderChildList.Select(y => y.OrderId).Contains(x.OrderId)).Sum(x => x.PushMoney);
decimal YjMoney = TotalYj - bdMoney - teacherMoney;//排除同行返佣 老师的提成
......@@ -821,7 +830,7 @@ namespace Edu.Module.Course
foreach (var qitem in orderChildList)
{
//当前订单的业绩
decimal bdCommission = bdList.Where(x => x.OrderId == qitem.OrderId && x.BalanceType == 1).Sum(x => x.Money);
decimal bdCommission = bdList.Where(x => x.OrderId == qitem.OrderId).Sum(x => x.CommissionMoeny);
decimal tCommission = AchEmpList.Where(x => x.Type == 3 && x.OrderId == qitem.OrderId).Sum(x => x.PushMoney);
decimal orderYj = qitem.PreferPrice - qitem.DiscountMoney - bdCommission - tCommission;
AchEmpList.Add(new RB_Sell_Achievements_Emp_ViewModel()
......@@ -873,7 +882,7 @@ namespace Edu.Module.Course
//计算市场业绩
decimal TotalYj = orderChildList.Sum(x => x.PreferPrice - x.DiscountMoney);
//计算订单累计返佣
decimal bdMoney = bdList.Where(x => orderChildList.Select(y => y.OrderId).Contains(x.OrderId) && x.BalanceType == 1).Sum(x => x.Money);
decimal bdMoney = bdList.Where(x => orderChildList.Select(y => y.OrderId).Contains(x.OrderId)).Sum(x => x.CommissionMoeny);
//查询老师的提成
decimal teacherMoney = AchEmpList.Where(x => x.Type == 3 && orderChildList.Select(y => y.OrderId).Contains(x.OrderId)).Sum(x => x.PushMoney);
decimal YjMoney = TotalYj - bdMoney - teacherMoney;//排除同行返佣 老师的提成
......@@ -884,7 +893,7 @@ namespace Edu.Module.Course
foreach (var qitem in orderChildList)
{
//当前订单的业绩
decimal bdCommission = bdList.Where(x => x.OrderId == qitem.OrderId && x.BalanceType == 1).Sum(x => x.Money);
decimal bdCommission = bdList.Where(x => x.OrderId == qitem.OrderId).Sum(x => x.CommissionMoeny);
decimal tCommission = AchEmpList.Where(x => x.Type == 3 && x.OrderId == qitem.OrderId).Sum(x => x.PushMoney);
decimal orderYj = qitem.PreferPrice - qitem.DiscountMoney - bdCommission - tCommission;
AchEmpList.Add(new RB_Sell_Achievements_Emp_ViewModel()
......@@ -934,7 +943,7 @@ namespace Edu.Module.Course
//计算市场业绩
decimal TotalYj = sellOrderList.Sum(x => x.PreferPrice - x.DiscountMoney);
//计算订单累计返佣
decimal bdMoney = bdList.Where(x => sellOrderList.Select(y => y.OrderId).Contains(x.OrderId) && x.BalanceType == 1).Sum(x => x.Money);
decimal bdMoney = bdList.Where(x => sellOrderList.Select(y => y.OrderId).Contains(x.OrderId)).Sum(x => x.CommissionMoeny);
//查询老师的提成
decimal teacherMoney = AchEmpList.Where(x => x.Type == 3 && sellOrderList.Select(y => y.OrderId).Contains(x.OrderId)).Sum(x => x.PushMoney);
decimal YjMoney = TotalYj - bdMoney - teacherMoney;//排除同行返佣 老师的提成
......@@ -945,7 +954,7 @@ namespace Edu.Module.Course
foreach (var qitem in sellOrderList)
{
//当前订单的业绩
decimal bdCommission = bdList.Where(x => x.OrderId == qitem.OrderId && x.BalanceType == 1).Sum(x => x.Money);
decimal bdCommission = bdList.Where(x => x.OrderId == qitem.OrderId).Sum(x => x.CommissionMoeny);
decimal tCommission = AchEmpList.Where(x => x.Type == 3 && x.OrderId == qitem.OrderId).Sum(x => x.PushMoney);
decimal orderYj = qitem.PreferPrice - qitem.DiscountMoney - bdCommission - tCommission;
foreach (var emp in EmpList)
......@@ -992,7 +1001,7 @@ namespace Edu.Module.Course
//计算市场业绩
decimal TotalYj = consultantOrderList.Sum(x => x.PreferPrice - x.DiscountMoney);
//计算订单累计返佣
decimal bdMoney = bdList.Where(x => consultantOrderList.Select(y => y.OrderId).Contains(x.OrderId) && x.BalanceType == 1).Sum(x => x.Money);
decimal bdMoney = bdList.Where(x => consultantOrderList.Select(y => y.OrderId).Contains(x.OrderId)).Sum(x => x.CommissionMoeny);
//查询老师的提成
decimal teacherMoney = AchEmpList.Where(x => x.Type == 3 && consultantOrderList.Select(y => y.OrderId).Contains(x.OrderId)).Sum(x => x.PushMoney);
decimal YjMoney = TotalYj - bdMoney - teacherMoney;//排除同行返佣 老师的提成
......@@ -1003,7 +1012,7 @@ namespace Edu.Module.Course
foreach (var qitem in consultantOrderList)
{
//当前订单的业绩
decimal bdCommission = bdList.Where(x => x.OrderId == qitem.OrderId && x.BalanceType == 1).Sum(x => x.Money);
decimal bdCommission = bdList.Where(x => x.OrderId == qitem.OrderId).Sum(x => x.CommissionMoeny);
decimal tCommission = AchEmpList.Where(x => x.Type == 3 && x.OrderId == qitem.OrderId).Sum(x => x.PushMoney);
decimal orderYj = qitem.PreferPrice - qitem.DiscountMoney - bdCommission - tCommission;
foreach (var emp in EmpList)
......@@ -1859,7 +1868,7 @@ namespace Edu.Module.Course
}
//根据订单 查询同行返佣
string orderIds = string.Join(",", orderList.Select(x => x.OrderId));
var bdList = customer_BalanceDetailRepository.GetCustomerBalanceDetailListRepository(new Model.ViewModel.Customer.RB_Customer_BalanceDetail_ViewModel() { Group_Id = userInfo.Group_Id, QOrderIds = orderIds });
var bdList = order_ReturnComissionRepository.GetOrderReturnComissionListRepositpry(new RB_Order_ReturnComission_ViewModel() { GroupId = userInfo.Group_Id, QOrderIds = orderIds });
if (RuleModel!=null&&RuleModel.Type == 3)
{
......@@ -1889,7 +1898,7 @@ namespace Edu.Module.Course
//计算老师业绩
decimal TotalYj = orderChildList.Sum(x => x.PreferPrice - x.DiscountMoney);
//计算订单累计返佣
decimal bdMoney = bdList.Where(x => orderChildList.Select(y => y.OrderId).Contains(x.OrderId) && x.BalanceType == 1).Sum(x => x.Money);
decimal bdMoney = bdList.Where(x => orderChildList.Select(y => y.OrderId).Contains(x.OrderId)).Sum(x => x.CommissionMoeny);
decimal YjMoney = TotalYj - bdMoney;//排除同行返佣
//根据业绩所在区间 查询比例
var rateModel = item.RateList.Where(x => x.StartValue < YjMoney && (x.EndValue >= YjMoney || x.EndValue == -1)).FirstOrDefault();
......@@ -1898,7 +1907,7 @@ namespace Edu.Module.Course
foreach (var qitem in orderChildList)
{
//当前订单的业绩
decimal bdCommission = bdList.Where(x => x.OrderId == qitem.OrderId && x.BalanceType == 1).Sum(x => x.Money);
decimal bdCommission = bdList.Where(x => x.OrderId == qitem.OrderId).Sum(x => x.CommissionMoeny);
decimal orderYj = qitem.PreferPrice - qitem.DiscountMoney - bdCommission;
AchEmpList.Add(new RB_Sell_Achievements_Emp_ViewModel()
{
......@@ -1952,7 +1961,7 @@ namespace Edu.Module.Course
//计算老师业绩
decimal TotalYj = orderChildList.Sum(x => x.PreferPrice - x.DiscountMoney);
//计算订单累计返佣
decimal bdMoney = bdList.Where(x => orderChildList.Select(y => y.OrderId).Contains(x.OrderId) && x.BalanceType == 1).Sum(x => x.Money);
decimal bdMoney = bdList.Where(x => orderChildList.Select(y => y.OrderId).Contains(x.OrderId)).Sum(x => x.CommissionMoeny);
decimal YjMoney = TotalYj - bdMoney;//排除同行返佣
//根据业绩所在区间 查询比例
var rateModel = item.RateList.Where(x => x.StartValue < YjMoney && (x.EndValue >= YjMoney || x.EndValue == -1)).FirstOrDefault();
......@@ -1961,7 +1970,7 @@ namespace Edu.Module.Course
foreach (var qitem in orderChildList)
{
//当前订单的业绩
decimal bdCommission = bdList.Where(x => x.OrderId == qitem.OrderId && x.BalanceType == 1).Sum(x => x.Money);
decimal bdCommission = bdList.Where(x => x.OrderId == qitem.OrderId).Sum(x => x.CommissionMoeny);
decimal orderYj = qitem.PreferPrice - qitem.DiscountMoney - bdCommission;
AchEmpList.Add(new RB_Sell_Achievements_Emp_ViewModel()
{
......@@ -2017,7 +2026,7 @@ namespace Edu.Module.Course
//计算市场业绩
decimal TotalYj = orderChildList.Sum(x => x.PreferPrice - x.DiscountMoney);
//计算订单累计返佣
decimal bdMoney = bdList.Where(x => orderChildList.Select(y => y.OrderId).Contains(x.OrderId) && x.BalanceType == 1).Sum(x => x.Money);
decimal bdMoney = bdList.Where(x => orderChildList.Select(y => y.OrderId).Contains(x.OrderId)).Sum(x => x.CommissionMoeny);
//查询老师的提成
decimal teacherMoney = AchEmpList.Where(x => x.Type == 3 && orderChildList.Select(y => y.OrderId).Contains(x.OrderId)).Sum(x => x.PushMoney);
decimal YjMoney = TotalYj - bdMoney - teacherMoney;//排除同行返佣 老师的提成
......@@ -2028,7 +2037,7 @@ namespace Edu.Module.Course
foreach (var qitem in orderChildList)
{
//当前订单的业绩
decimal bdCommission = bdList.Where(x => x.OrderId == qitem.OrderId && x.BalanceType == 1).Sum(x => x.Money);
decimal bdCommission = bdList.Where(x => x.OrderId == qitem.OrderId).Sum(x => x.CommissionMoeny);
decimal tCommission = AchEmpList.Where(x => x.Type == 3 && x.OrderId == qitem.OrderId).Sum(x => x.PushMoney);
decimal orderYj = qitem.PreferPrice - qitem.DiscountMoney - bdCommission - tCommission;
AchEmpList.Add(new RB_Sell_Achievements_Emp_ViewModel()
......@@ -2081,7 +2090,7 @@ namespace Edu.Module.Course
//计算市场业绩
decimal TotalYj = orderChildList.Sum(x => x.PreferPrice - x.DiscountMoney);
//计算订单累计返佣
decimal bdMoney = bdList.Where(x => orderChildList.Select(y => y.OrderId).Contains(x.OrderId) && x.BalanceType == 1).Sum(x => x.Money);
decimal bdMoney = bdList.Where(x => orderChildList.Select(y => y.OrderId).Contains(x.OrderId)).Sum(x => x.CommissionMoeny);
//查询老师的提成
decimal teacherMoney = AchEmpList.Where(x => x.Type == 3 && orderChildList.Select(y => y.OrderId).Contains(x.OrderId)).Sum(x => x.PushMoney);
decimal YjMoney = TotalYj - bdMoney - teacherMoney;//排除同行返佣 老师的提成
......@@ -2092,7 +2101,7 @@ namespace Edu.Module.Course
foreach (var qitem in orderChildList)
{
//当前订单的业绩
decimal bdCommission = bdList.Where(x => x.OrderId == qitem.OrderId && x.BalanceType == 1).Sum(x => x.Money);
decimal bdCommission = bdList.Where(x => x.OrderId == qitem.OrderId).Sum(x => x.CommissionMoeny);
decimal tCommission = AchEmpList.Where(x => x.Type == 3 && x.OrderId == qitem.OrderId).Sum(x => x.PushMoney);
decimal orderYj = qitem.PreferPrice - qitem.DiscountMoney - bdCommission - tCommission;
AchEmpList.Add(new RB_Sell_Achievements_Emp_ViewModel()
......@@ -2143,7 +2152,7 @@ namespace Edu.Module.Course
//计算市场业绩
decimal TotalYj = sellOrderList.Sum(x => x.PreferPrice - x.DiscountMoney);
//计算订单累计返佣
decimal bdMoney = bdList.Where(x => sellOrderList.Select(y => y.OrderId).Contains(x.OrderId) && x.BalanceType == 1).Sum(x => x.Money);
decimal bdMoney = bdList.Where(x => sellOrderList.Select(y => y.OrderId).Contains(x.OrderId)).Sum(x => x.CommissionMoeny);
//查询老师的提成
decimal teacherMoney = AchEmpList.Where(x => x.Type == 3 && sellOrderList.Select(y => y.OrderId).Contains(x.OrderId)).Sum(x => x.PushMoney);
decimal YjMoney = TotalYj - bdMoney - teacherMoney;//排除同行返佣 老师的提成
......@@ -2154,7 +2163,7 @@ namespace Edu.Module.Course
foreach (var qitem in sellOrderList)
{
//当前订单的业绩
decimal bdCommission = bdList.Where(x => x.OrderId == qitem.OrderId && x.BalanceType == 1).Sum(x => x.Money);
decimal bdCommission = bdList.Where(x => x.OrderId == qitem.OrderId).Sum(x => x.CommissionMoeny);
decimal tCommission = AchEmpList.Where(x => x.Type == 3 && x.OrderId == qitem.OrderId).Sum(x => x.PushMoney);
decimal orderYj = qitem.PreferPrice - qitem.DiscountMoney - bdCommission - tCommission;
foreach (var emp in EmpList)
......@@ -2202,7 +2211,7 @@ namespace Edu.Module.Course
//计算市场业绩
decimal TotalYj = consultantOrderList.Sum(x => x.PreferPrice - x.DiscountMoney);
//计算订单累计返佣
decimal bdMoney = bdList.Where(x => consultantOrderList.Select(y => y.OrderId).Contains(x.OrderId) && x.BalanceType == 1).Sum(x => x.Money);
decimal bdMoney = bdList.Where(x => consultantOrderList.Select(y => y.OrderId).Contains(x.OrderId)).Sum(x => x.CommissionMoeny);
//查询老师的提成
decimal teacherMoney = AchEmpList.Where(x => x.Type == 3 && consultantOrderList.Select(y => y.OrderId).Contains(x.OrderId)).Sum(x => x.PushMoney);
decimal YjMoney = TotalYj - bdMoney - teacherMoney;//排除同行返佣 老师的提成
......@@ -2213,7 +2222,7 @@ namespace Edu.Module.Course
foreach (var qitem in consultantOrderList)
{
//当前订单的业绩
decimal bdCommission = bdList.Where(x => x.OrderId == qitem.OrderId && x.BalanceType == 1).Sum(x => x.Money);
decimal bdCommission = bdList.Where(x => x.OrderId == qitem.OrderId).Sum(x => x.CommissionMoeny);
decimal tCommission = AchEmpList.Where(x => x.Type == 3 && x.OrderId == qitem.OrderId).Sum(x => x.PushMoney);
decimal orderYj = qitem.PreferPrice - qitem.DiscountMoney - bdCommission - tCommission;
foreach (var emp in EmpList)
......
......@@ -58,7 +58,10 @@ namespace Edu.Repository.Sell
/// <returns></returns>
public List<RB_Order_ReturnComission_ViewModel> GetListBySetBatch(int groupId, int type)
{
var sql = "select a.* from rb_order_returncomission a left join rb_student_orderguest b on a.OrderId=b.OrderId and a.StuId=b.Student_Id left join rb_order_guest c on b.GuestId=c.Id where (c.CompleteHours/c.TotalHours)>=(a.CommissionReValue/100) and a.`Status`=0 and c.CreateTime<date_add(curdate(),interval -day(curdate())+1 day) and a.GroupId=@gid and a.CommissionType=@type";
var sql = @"select a.* from rb_order_returncomission a
left join rb_student_orderguest b on a.OrderId=b.OrderId and a.StuId=b.Student_Id
left join rb_order_guest c on b.GuestId=c.Id
where a.`Status`=0 and c.CreateTime<date_add(curdate(),interval -day(curdate())+1 day) and a.GroupId=@gid and a.CommissionType=@type";
DynamicParameters parameters = new DynamicParameters();
parameters.Add("gid", groupId);
......
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