Commit 7006ee43 authored by liudong1993's avatar liudong1993

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

parents 710eebe4 1bfa60b4
......@@ -47,24 +47,23 @@ namespace Edu.Module.Course
/// </summary>
private readonly RB_OrderRepository orderRepository = new RB_OrderRepository();
/// <summary>
/// 开始月份
/// </summary>
private int StartYear = 2021;
/// <summary>
/// 结束月份
/// </summary>
private int StartMoneh = 11;
/// <summary>
/// 生成业绩
/// </summary>
public void CreateEmployeeBonusModule(int GroupId)
public void CreateEmployeeBonusModule(int GroupId,string startDate="")
{
DateTime d1 = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
d1 = new DateTime(2021, 11, 1);
DateTime d1 = DateTime.Now;
if (!string.IsNullOrEmpty(startDate))
{
var tempDate = Convert.ToDateTime(startDate);
d1 = new DateTime(tempDate.Year, tempDate.Month, 1);
}
else
{
d1 = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
}
DateTime endTime = d1.AddMonths(1).AddDays(-1);
int CurrentYear = endTime.Year;
int CurrentMonth = endTime.Month;
string endDate = Common.ConvertHelper.FormatDate(endTime);
......@@ -94,19 +93,23 @@ namespace Edu.Module.Course
/// <param name="CurrentYear"></param>
/// <param name="CurrentMonth"></param>
/// <param name="isCalcReduce">true-计算抵扣,false-不计算</param>
private void CalcPersionBonusModule(RB_Bonus_PlanExtend item, int GroupId, string endDate, int saleId, int CurrentYear, int CurrentMonth, bool isCalcReduce = false)
private void CalcPersionBonusModule(RB_Bonus_PlanExtend item, int GroupId, string endDate, int saleId,int CurrentYear, int CurrentMonth, bool isCalcReduce = false)
{
var orderList = GetSaleOrderList(item, GroupId, endDate, saleId, out List<RB_Order_ViewModel> allOrderList);
var curNum = orderList?.Where(qitem => qitem.Year == CurrentYear && qitem.Month == CurrentMonth)?.Sum(qitem => qitem.GuestNum) ?? 0;
var curOrderMoney = orderList?.Where(qitem => qitem.Year == CurrentYear && qitem.Month == CurrentMonth)?.Sum(qitem => qitem.OrderMoney) ?? 0;
int DeductionNum = 0;
decimal DeductionMoney = 0;
//查询销售已发放的奖励
var saleBonusList = personnel_BonusRepository.GetPersonnelBonusListRepository(new RB_Personnel_Bonus_Extend()
{
EmployeeId = saleId
EmployeeId = saleId,
RewardType=item.PlanType,
});
if (saleBonusList != null && saleBonusList.Count > 0)
{
//计算抵扣
foreach (var bItem in saleBonusList)
{
//查询此月份的订单列表
......@@ -132,9 +135,8 @@ namespace Edu.Module.Course
}
}
}
}
else
{
//新增当月的人头奖励
var pModel = new RB_Personnel_Bonus()
{
Id = 0,
......@@ -150,10 +152,14 @@ namespace Edu.Module.Course
CreateTime = DateTime.Now,
UpdateBy = 1,
UpdateTime = DateTime.Now,
DeductionNum= DeductionNum,
DeductionMoney= DeductionMoney,
};
pModel.IsReach = pModel.CurOrderMoney > item.MonthGoalMoney ? 1 : 0;
var newId = personnel_BonusRepository.Insert(pModel);
pModel.Id = newId;
foreach (var oItem in allOrderList)
foreach (var oItem in allOrderList.Where(qitem=>qitem.CreateTime.Year==CurrentYear&&qitem.CreateTime.Month==CurrentMonth))
{
var detailModel = new RB_Personnel_BonusDetail()
{
......@@ -168,7 +174,6 @@ namespace Edu.Module.Course
detailModel.Id = newDetailId;
}
}
}
/// <summary>
......@@ -225,7 +230,7 @@ namespace Edu.Module.Course
qitem.Key.Year,
qitem.Key.Month,
GuestNum = qitem.Sum(s => s.GuestNum),
OrderMoney = qitem.Sum(s => s.Income - s.Refund + s.PlatformTax)
OrderMoney = qitem.Sum(s => s.Income - s.Refund - s.PlatformTax)
});
foreach (var gItem in groupList)
......
......@@ -85,6 +85,10 @@ WHERE 1=1
{
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Personnel_Bonus_Extend.EmployeeId), query.EmployeeId);
}
if (query.RewardType > 0)
{
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Personnel_Bonus_Extend.RewardType), query.RewardType);
}
}
var list= Get<RB_Personnel_Bonus_Extend>(builder.ToString()).ToList();
if (list != null && list.Count > 0)
......
......@@ -1197,7 +1197,7 @@ WHERE 1=1
builder.AppendFormat(" AND o.PreferPrice = (o.Income - o.Refund + o.DiscountMoney + o.PlatformTax) ");
if (group_Id > 0)
{
builder.AppendFormat(" o.Group_Id ={0} ", group_Id);
builder.AppendFormat(" AND o.Group_Id ={0} ", group_Id);
}
if (!string.IsNullOrEmpty(eDate))
{
......
......@@ -59,7 +59,8 @@ namespace Edu.WebApi.Controllers.User
{
//new DutyPlanModule().TransVisitorToStu();
var userInfo = base.UserInfo;
employeeBonusModule.CreateEmployeeBonusModule(userInfo.Group_Id);
var startDate = base.ParmJObj.GetStringValue("StartDate");
employeeBonusModule.CreateEmployeeBonusModule(100000, startDate);
return ApiResult.Success();
}
......
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