Commit 0dc3135a authored by liudong1993's avatar liudong1993

1

parent 83019887
...@@ -73,5 +73,10 @@ namespace Edu.Model.ViewModel.Sell ...@@ -73,5 +73,10 @@ namespace Edu.Model.ViewModel.Sell
/// 总提成数 /// 总提成数
/// </summary> /// </summary>
public decimal TotalMoney { get; set; } public decimal TotalMoney { get; set; }
/// <summary>
/// 使用规则ID
/// </summary>
public int RuleId { get; set; }
} }
} }
\ No newline at end of file
...@@ -340,12 +340,11 @@ namespace Edu.Module.Course ...@@ -340,12 +340,11 @@ namespace Edu.Module.Course
decimal PeopleMoney = CommionList.Sum(x => x.PeopleNumMoney); decimal PeopleMoney = CommionList.Sum(x => x.PeopleNumMoney);
//开始拆分 //开始拆分
int ruleId = CommionList.FirstOrDefault()?.RuleId ?? 0;
var empData = sell_Achievements_EmpRepository.GetList(new RB_Sell_Achievements_Emp_ViewModel() { Type = 1, EmpId = CommionList.FirstOrDefault().UserId, PeriodsId = dmodel.PeriodId }); if (ruleId > 0)
if (empData.Where(x => x.RuleId > 0).Any())
{ {
//查询规则 //查询规则
var ruleModel = sell_Achievements_RuleRepository.GetEntity<RB_Sell_Achievements_Rule_ViewModel>(empData.Where(x => x.RuleId > 0).FirstOrDefault().RuleId); var ruleModel = sell_Achievements_RuleRepository.GetEntity<RB_Sell_Achievements_Rule_ViewModel>(ruleId);
ruleModel.DeptAwardList = new List<DeptAllotModel>(); ruleModel.DeptAwardList = new List<DeptAllotModel>();
if (!string.IsNullOrEmpty(ruleModel.DeptAwardAllotRule)) if (!string.IsNullOrEmpty(ruleModel.DeptAwardAllotRule))
{ {
...@@ -832,7 +831,7 @@ namespace Edu.Module.Course ...@@ -832,7 +831,7 @@ namespace Edu.Module.Course
string SchoolIds = string.Join(",", rulelist.Select(x => x.SchoolIds)); string SchoolIds = string.Join(",", rulelist.Select(x => x.SchoolIds));
//查询 班级订单 1.尾款收齐 //查询 班级订单 1.尾款收齐
string SDate = "2024-09-01"; string SDate = "2024-01-01";
string EDate = Convert.ToDateTime(month + "-01").AddMonths(1).AddDays(-1).ToString("yyyy-MM-dd"); string EDate = Convert.ToDateTime(month + "-01").AddMonths(1).AddDays(-1).ToString("yyyy-MM-dd");
var orderList = orderRepository.GetAllAchievementsSendOrderList(userInfo.Group_Id, SDate, EDate, 1, "", SchoolIds, languageRuleList, 1);//查询所有的 var orderList = orderRepository.GetAllAchievementsSendOrderList(userInfo.Group_Id, SDate, EDate, 1, "", SchoolIds, languageRuleList, 1);//查询所有的
List<RB_Sell_Achievements_Emp_ViewModel> AchEmpList = new List<RB_Sell_Achievements_Emp_ViewModel>();//需要新增当月的 List<RB_Sell_Achievements_Emp_ViewModel> AchEmpList = new List<RB_Sell_Achievements_Emp_ViewModel>();//需要新增当月的
...@@ -879,7 +878,7 @@ namespace Edu.Module.Course ...@@ -879,7 +878,7 @@ namespace Edu.Module.Course
if (orderList.Where(x => x.JoinType == Common.Enum.Sale.OrderJoinTypeEnum.RenewOrder && x.Refund <= 0).Any()) if (orderList.Where(x => x.JoinType == Common.Enum.Sale.OrderJoinTypeEnum.RenewOrder && x.Refund <= 0).Any())
{ {
var xfOrderList = orderList.Where(x => x.JoinType == Common.Enum.Sale.OrderJoinTypeEnum.RenewOrder && x.Refund <= 0).ToList(); var xfOrderList = orderList.Where(x => x.JoinType == Common.Enum.Sale.OrderJoinTypeEnum.RenewOrder && x.Refund <= 0).ToList();
string xforderIds = string.Join(",", xfOrderList); string xforderIds = string.Join(",", xfOrderList.Select(x => x.OrderId));
var xfStuList = orderRepository.GetXFOrderFirstEnterList(userInfo.Group_Id, xforderIds); var xfStuList = orderRepository.GetXFOrderFirstEnterList(userInfo.Group_Id, xforderIds);
foreach (var item in xfOrderList) foreach (var item in xfOrderList)
...@@ -1830,10 +1829,10 @@ namespace Edu.Module.Course ...@@ -1830,10 +1829,10 @@ namespace Edu.Module.Course
{ {
//查询该订单 已发提成记录 //查询该订单 已发提成记录
//先查询销售的 //先查询销售的
var salelist = dlist.Where(x => x.OrderId == item.OrderId && x.UserId == AchModel.EmpId && x.UserType == AchModel.Type && x.IsDept == AchModel.IsDept).ToList(); //var salelist = dlist.Where(x => x.OrderId == item.OrderId && x.UserId == AchModel.EmpId && x.UserType == AchModel.Type && x.IsDept == AchModel.IsDept).ToList();
if (salelist.Any()) if (false)//salelist.Any())
{ {
SetCommissionNext(month, CheckList, CurrentList, item, classModel, TotalHours, YFCommission, salelist, AchModel, true); //SetCommissionNext(month, CheckList, CurrentList, item, classModel, TotalHours, YFCommission, salelist, AchModel, true);
} }
else else
{ {
...@@ -1878,34 +1877,39 @@ namespace Edu.Module.Course ...@@ -1878,34 +1877,39 @@ namespace Edu.Module.Course
} }
} }
else { else {
decimal FirstMoney = Math.Round(YFCommission * ruleModel.FirstRate / 100, 2, MidpointRounding.AwayFromZero);
CurrentList.Add(new RB_Sell_Achievements_Details_ViewModel() var salelist = dlist.Where(x => x.OrderId == item.OrderId && x.UserId == AchModel.EmpId && x.UserType == AchModel.Type && x.IsDept == AchModel.IsDept).ToList();
if (!salelist.Any())
{ {
UserId = AchModel.EmpId, decimal FirstMoney = Math.Round(YFCommission * ruleModel.FirstRate / 100, 2, MidpointRounding.AwayFromZero);
OrderId = item.OrderId, CurrentList.Add(new RB_Sell_Achievements_Details_ViewModel()
CurrentPeriodMoney = 0, {
IsFirstCommission = 1, UserId = AchModel.EmpId,
Remark = "未达到发放标准,待发提成:" + FirstMoney + ",待发人头奖励:" + AchModel.PeopleNumMoney, OrderId = item.OrderId,
CurrentPeriodMoney = 0,
ClassId = item.ClassId, IsFirstCommission = 1,
ClassType = classModel.ClassType, Remark = "未达到发放标准,待发提成:" + FirstMoney + ",待发人头奖励:" + AchModel.PeopleNumMoney,
PeriodId = 0,
Periods = month, ClassId = item.ClassId,
CommissionMoney = YFCommission, ClassType = classModel.ClassType,
StudentCount = item.GuestNum, PeriodId = 0,
TotalHours = Convert.ToInt32(TotalHours), Periods = month,
TotalLearn = Convert.ToInt32(TotalLearn), CommissionMoney = YFCommission,
CurrentHours = -1,//这种首次发放提成的 没有课时消费 StudentCount = item.GuestNum,
GiveOutMoney = 0, TotalHours = Convert.ToInt32(TotalHours),
FirstRate = 0, TotalLearn = Convert.ToInt32(TotalLearn),
DeductionMoney = 0, CurrentHours = -1,//这种首次发放提成的 没有课时消费
IsDept = AchModel.IsDept, GiveOutMoney = 0,
UserType = AchModel.Type, FirstRate = 0,
RelatedId = AchModel.Id, DeductionMoney = 0,
PeopleNumMoney = 0, IsDept = AchModel.IsDept,
IsCommonDept = AchModel.IsCommonDept, UserType = AchModel.Type,
OrderSaleMoney = AchModel.OrderSaleMoney RelatedId = AchModel.Id,
}); PeopleNumMoney = 0,
IsCommonDept = AchModel.IsCommonDept,
OrderSaleMoney = AchModel.OrderSaleMoney
});
}
} }
} }
#endregion #endregion
......
...@@ -235,8 +235,13 @@ from RB_Sell_Achievements_Details r where {where} order by r.Id asc"; ...@@ -235,8 +235,13 @@ from RB_Sell_Achievements_Details r where {where} order by r.Id asc";
} }
string sql = $@" select r.UserId,r.Depart_Id,r.School_Id,r.IsCommonDept,sum(r.StudentCount) as StudentCount,sum(r.CurrentPeriodMoney + r.DeductionMoney) as CurrentPeriodMoney,sum(r.PeopleNumMoney) as PeopleNumMoney string sql = $@" select r.UserId,r.Depart_Id,r.School_Id,r.IsCommonDept,p.RuleId,sum(r.StudentCount) as StudentCount,sum(r.CurrentPeriodMoney + r.DeductionMoney) as CurrentPeriodMoney,sum(r.PeopleNumMoney) as PeopleNumMoney
from RB_Sell_Achievements_Details r where {where} group by r.UserId,r.Depart_Id,r.School_Id,r.IsCommonDept"; from RB_Sell_Achievements_Details r
left join(
select e.OrderId,e.EmpId,max(e.RuleId) as RuleId from rb_sell_achievements_emp e group by e.OrderId,e.EmpId
) p on r.OrderId = p.OrderId and r.UserId = p.EmpId
where {where} group by r.UserId,r.Depart_Id,r.School_Id,r.IsCommonDept";
return Get<RB_Sell_Achievements_Details_ViewModel>(sql).ToList(); return Get<RB_Sell_Achievements_Details_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