Commit 0dc3135a authored by liudong1993's avatar liudong1993

1

parent 83019887
......@@ -73,5 +73,10 @@ namespace Edu.Model.ViewModel.Sell
/// 总提成数
/// </summary>
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
decimal PeopleMoney = CommionList.Sum(x => x.PeopleNumMoney);
//开始拆分
var empData = sell_Achievements_EmpRepository.GetList(new RB_Sell_Achievements_Emp_ViewModel() { Type = 1, EmpId = CommionList.FirstOrDefault().UserId, PeriodsId = dmodel.PeriodId });
if (empData.Where(x => x.RuleId > 0).Any())
int ruleId = CommionList.FirstOrDefault()?.RuleId ?? 0;
if (ruleId > 0)
{
//查询规则
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>();
if (!string.IsNullOrEmpty(ruleModel.DeptAwardAllotRule))
{
......@@ -832,7 +831,7 @@ namespace Edu.Module.Course
string SchoolIds = string.Join(",", rulelist.Select(x => x.SchoolIds));
//查询 班级订单 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");
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>();//需要新增当月的
......@@ -879,7 +878,7 @@ namespace Edu.Module.Course
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();
string xforderIds = string.Join(",", xfOrderList);
string xforderIds = string.Join(",", xfOrderList.Select(x => x.OrderId));
var xfStuList = orderRepository.GetXFOrderFirstEnterList(userInfo.Group_Id, xforderIds);
foreach (var item in xfOrderList)
......@@ -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();
if (salelist.Any())
//var salelist = dlist.Where(x => x.OrderId == item.OrderId && x.UserId == AchModel.EmpId && x.UserType == AchModel.Type && x.IsDept == AchModel.IsDept).ToList();
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
{
......@@ -1878,34 +1877,39 @@ namespace Edu.Module.Course
}
}
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,
OrderId = item.OrderId,
CurrentPeriodMoney = 0,
IsFirstCommission = 1,
Remark = "未达到发放标准,待发提成:" + FirstMoney + ",待发人头奖励:" + AchModel.PeopleNumMoney,
ClassId = item.ClassId,
ClassType = classModel.ClassType,
PeriodId = 0,
Periods = month,
CommissionMoney = YFCommission,
StudentCount = item.GuestNum,
TotalHours = Convert.ToInt32(TotalHours),
TotalLearn = Convert.ToInt32(TotalLearn),
CurrentHours = -1,//这种首次发放提成的 没有课时消费
GiveOutMoney = 0,
FirstRate = 0,
DeductionMoney = 0,
IsDept = AchModel.IsDept,
UserType = AchModel.Type,
RelatedId = AchModel.Id,
PeopleNumMoney = 0,
IsCommonDept = AchModel.IsCommonDept,
OrderSaleMoney = AchModel.OrderSaleMoney
});
decimal FirstMoney = Math.Round(YFCommission * ruleModel.FirstRate / 100, 2, MidpointRounding.AwayFromZero);
CurrentList.Add(new RB_Sell_Achievements_Details_ViewModel()
{
UserId = AchModel.EmpId,
OrderId = item.OrderId,
CurrentPeriodMoney = 0,
IsFirstCommission = 1,
Remark = "未达到发放标准,待发提成:" + FirstMoney + ",待发人头奖励:" + AchModel.PeopleNumMoney,
ClassId = item.ClassId,
ClassType = classModel.ClassType,
PeriodId = 0,
Periods = month,
CommissionMoney = YFCommission,
StudentCount = item.GuestNum,
TotalHours = Convert.ToInt32(TotalHours),
TotalLearn = Convert.ToInt32(TotalLearn),
CurrentHours = -1,//这种首次发放提成的 没有课时消费
GiveOutMoney = 0,
FirstRate = 0,
DeductionMoney = 0,
IsDept = AchModel.IsDept,
UserType = AchModel.Type,
RelatedId = AchModel.Id,
PeopleNumMoney = 0,
IsCommonDept = AchModel.IsCommonDept,
OrderSaleMoney = AchModel.OrderSaleMoney
});
}
}
}
#endregion
......
......@@ -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
from RB_Sell_Achievements_Details r where {where} group by r.UserId,r.Depart_Id,r.School_Id,r.IsCommonDept";
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
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();
}
......
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