Commit d4e0eb08 authored by 黄奎's avatar 黄奎

页面修改

parent 8c199dce
......@@ -17,6 +17,11 @@ namespace Edu.Model.Entity.Bonus
/// </summary>
public int Id { get; set; }
/// <summary>
/// 期数编号
/// </summary>
public int PeriodId { get; set; }
/// <summary>
/// 关联方案编号
/// </summary>
......
using System;
using System.Collections.Generic;
using System.Text;
using VT.FW.DB;
namespace Edu.Model.Entity.Bonus
{
/// <summary>
/// 人头奖金发放期数实体类
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_Personnel_Period
{
/// <summary>
/// 主键编号
/// </summary>
public int Id { get; set; }
/// <summary>
/// 名称
/// </summary>
public string Name { get; set; }
/// <summary>
/// 期数
/// </summary>
public string Periods { get; set; }
/// <summary>
/// 创建人
/// </summary>
public int CreateBy { get; set; }
/// <summary>
/// 创建日期
/// </summary>
public DateTime CreateTime { get; set; }
/// <summary>
/// 累计金额
/// </summary>
public decimal SumPrice { get; set; }
/// <summary>
/// 集团编号
/// </summary>
public int Group_Id { get; set; }
/// <summary>
/// 关联财务单据ids
/// </summary>
public string Financials { get; set; }
/// <summary>
/// 已发放人员的列表
/// </summary>
public string EmpIds { get; set; }
/// <summary>
/// 期数备注
/// </summary>
public string Remark { get; set; }
}
}
......@@ -19,5 +19,10 @@ namespace Edu.Model.ViewModel.Bonus
/// 是否查询未平账
/// </summary>
public int IsNoBalance { get; set; }
/// <summary>
/// 查询员工编号
/// </summary>
public string QEmployeeIds { get; set; }
}
}
using Edu.Model.Entity.Bonus;
using System;
using System.Collections.Generic;
using System.Text;
namespace Edu.Model.ViewModel.Bonus
{
/// <summary>
/// 人头奖金发放期数扩展实体类
/// </summary>
public class RB_Personnel_Period_Extend : RB_Personnel_Period
{
}
}
......@@ -10,6 +10,8 @@ using Edu.Model.ViewModel.Bonus;
using Edu.Common.Plugin;
using VT.FW.DB;
using Edu.Repository.User;
using Edu.Model.CacheModel;
using Edu.AOP.CustomerAttribute;
namespace Edu.Module.Course
{
......@@ -53,11 +55,23 @@ namespace Edu.Module.Course
/// </summary>
private readonly RB_StudentRepository studentRepository = new RB_StudentRepository();
/// <summary>
/// 员工人头奖金仓储层对象
/// </summary>
private readonly RB_Personnel_PeriodRepository personnel_PeriodRepository = new RB_Personnel_PeriodRepository();
/// <summary>
/// 生成业绩
/// </summary>
public void CreateEmployeeBonusModule(int GroupId,string sDate="")
/// <param name="userInfo"></param>
/// <param name="sDate"></param>
/// <param name="message"></param>
/// <returns></returns>
[TransactionCallHandler]
public virtual bool CreateEmployeeBonusModule(UserInfo userInfo, string sDate="",out string message)
{
message = "";
bool flag = false;
DateTime d1 = DateTime.Now;
if (!string.IsNullOrEmpty(sDate))
{
......@@ -71,21 +85,44 @@ namespace Edu.Module.Course
string startDate = Common.ConvertHelper.FormatDate(d1);
DateTime endTime = d1.AddMonths(1).AddDays(-1);
string endDate = Common.ConvertHelper.FormatDate(endTime);
var empPeriod = new RB_Personnel_Period()
{
Name= string.Format("{0}-{1}期人头奖励", endTime.Year,endTime.Month),
Periods= string.Format("{0}-{1}", endTime.Year, endTime.Month),
CreateBy=userInfo.Id,
CreateTime=DateTime.Now,
SumPrice=0,
Group_Id=userInfo.Group_Id,
Financials="",
EmpIds="",
Remark="",
};
var newId= personnel_PeriodRepository.Insert(empPeriod);
empPeriod.Id = newId;
flag = newId > 0;
if (flag)
{
//人头配置列表
var planList = bonus_PlanRepository.GetBounsPlanListRepository(new RB_Bonus_PlanExtend()
{
Group_Id = GroupId
Group_Id = userInfo.Group_Id
}, isGetDetail: true);
if (planList == null || (planList != null && planList.Count <= 0))
{
flag= false;
message = "请先配置市场人员和课程顾问的提成配置";
return flag;
}
foreach (var item in planList)
{
var saleList = Common.ConvertHelper.StringToList(item.SaleIds);
foreach (var saleId in saleList)
{
CalcPersionBonusModule(item, GroupId, startDate, endDate, saleId);
CalcPersionBonusModule(empPeriod,item, userInfo.Group_Id, startDate, endDate, saleId);
}
}
}
return flag;
}
/// <summary>
......@@ -101,7 +138,7 @@ namespace Edu.Module.Course
//查询销售已发放的奖励
var saleBonusList = personnel_BonusRepository.GetPersonnelBonusListRepository(new RB_Personnel_Bonus_Extend()
{
EmployeeId = orderModel.EnterID,
QEmployeeIds = orderModel.EnterID.ToString()+","+(orderModel?.CourseConsultantId??0).ToString(),
YearNum=orderModel.CreateTime.Year,
MonthNum=orderModel.CreateTime.Month,
});
......@@ -167,7 +204,7 @@ namespace Edu.Module.Course
/// <param name="GroupId"></param>
/// <param name="endDate"></param>
/// <param name="saleId"></param>
private void CalcPersionBonusModule(RB_Bonus_PlanExtend item, int GroupId,string startDate,string endDate, int saleId)
private void CalcPersionBonusModule(RB_Personnel_Period period,RB_Bonus_PlanExtend item, int GroupId,string startDate,string endDate, int saleId)
{
var orderList = GetSaleOrderList(item, GroupId, endDate, saleId, out List<RB_Order_ViewModel> allOrderList);
var curNum = orderList?.Sum(qitem => qitem.GuestNum) ?? 0;
......@@ -189,6 +226,7 @@ namespace Edu.Module.Course
var pModel = new RB_Personnel_Bonus()
{
Id = 0,
PeriodId=period.Id,
PlanId = item.Id,
PlanType = item.PlanType,
YearNum = Convert.ToDateTime(startDate).Year,
......@@ -252,7 +290,7 @@ namespace Edu.Module.Course
CreateBy = 1,
CreateTime = DateTime.Now,
DeductionMoney= tempChaE,
DeductionContent = "抵扣" + sItem.YearNum + "年" + sItem.MonthNum + "月的待抵扣金额" + tempChaE,
DeductionContent = "抵扣" + sItem.YearNum + "年" + sItem.MonthNum + "月超出金额" + tempChaE+"元.",
};
personnel_DeductionRepository.Insert(deductionModel);
Dictionary<string, object> fileds = new Dictionary<string, object>()
......
......@@ -85,6 +85,10 @@ WHERE 1=1
{
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Personnel_Bonus_Extend.EmployeeId), query.EmployeeId);
}
if (!string.IsNullOrEmpty(query.QEmployeeIds))
{
builder.AppendFormat(" AND A.{0} IN({1}) ", nameof(RB_Personnel_Bonus_Extend.EmployeeId), query.QEmployeeIds);
}
if (query.PlanType > 0)
{
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Personnel_Bonus_Extend.PlanType), query.PlanType);
......
using Edu.Model.Entity.Bonus;
using Edu.Model.ViewModel.Bonus;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Edu.Repository.Bonus
{
/// <summary>
/// 人头奖金发放期数仓储层
/// </summary>
public class RB_Personnel_PeriodRepository : BaseRepository<RB_Personnel_Period>
{
/// <summary>
/// 获取人头奖金期数分页列表
/// </summary>
/// <param name="pageIdex"></param>
/// <param name="pageSize"></param>
/// <param name="rowsCount"></param>
/// <param name="query"></param>
/// <returns></returns>
public List<RB_Personnel_Period_Extend> GetPersonnelPeriodPageRepository(int pageIdex, int pageSize, out long rowsCount, RB_Personnel_Period_Extend query)
{
StringBuilder builder = new StringBuilder();
builder.AppendFormat(@"
SELECT A.*
FROM RB_Personnel_Period AS A
WHERE 1=1
");
if (query != null)
{
if (query.Group_Id > 0)
{
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Personnel_Period_Extend.Group_Id), query.Group_Id);
}
}
builder.AppendFormat(" ORDER BY A.{0} DESC ", nameof(RB_Personnel_Period_Extend.Id));
return GetPage<RB_Personnel_Period_Extend>(pageIdex, pageSize, out rowsCount, builder.ToString()).ToList();
}
}
}
\ No newline at end of file
......@@ -26,6 +26,12 @@ namespace Edu.WebApi.Controllers.Bonus
/// </summary>
private readonly BonusConfigModule bonusConfigModule = new BonusConfigModule();
/// <summary>
/// 员工人头奖励仓储层对象
/// </summary>
private readonly EmployeeBonusModule employeeBonusModule = AOP.AOPHelper.CreateAOPObject<EmployeeBonusModule>();
#region 人头奖励配置
/// <summary>
/// 获取课程顾问、市场达标奖金配置分页列表
/// </summary>
......@@ -81,7 +87,7 @@ namespace Edu.WebApi.Controllers.Bonus
var query = new RB_Bonus_PlanExtend()
{
Id = base.ParmJObj.GetInt("Id"),
PlanType=base.ParmJObj.GetInt("PlanType"),
PlanType = base.ParmJObj.GetInt("PlanType"),
PlanName = base.ParmJObj.GetStringValue("PlanName"),
BasicSalary = base.ParmJObj.GetDecimal("BasicSalary"),
OpenBonus = base.ParmJObj.GetDecimal("OpenBonus"),
......@@ -90,7 +96,7 @@ namespace Edu.WebApi.Controllers.Bonus
SaleIds = base.ParmJObj.GetStringValue("SaleIds"),
UseCourseIds = base.ParmJObj.GetStringValue("UseCourseIds"),
NotUseCourseIds = base.ParmJObj.GetStringValue("NotUseCourseIds"),
MonthGoalMoney=base.ParmJObj.GetDecimal("MonthGoalMoney"),
MonthGoalMoney = base.ParmJObj.GetDecimal("MonthGoalMoney"),
};
query.CreateBy = base.UserInfo.Id;
query.UpdateBy = base.UserInfo.Id;
......@@ -148,5 +154,37 @@ namespace Edu.WebApi.Controllers.Bonus
var flag = bonusConfigModule.RemoveBonusPlanModule(Id);
return flag ? ApiResult.Success() : ApiResult.Failed();
}
#endregion
#region 员工人头奖励
/// <summary>
/// 生成员工人头奖励
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult CreateEmpBonus()
{
var userInfo = base.UserInfo;
var startDate = base.ParmJObj.GetStringValue("StartDate");
bool flag= employeeBonusModule.CreateEmployeeBonusModule(userInfo, startDate,out string message);
return flag ? ApiResult.Success() : ApiResult.Failed(message: message);
}
/// <summary>
/// 订单金额发生改变
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult ChangeOrder()
{
//订单改变
var OrderId = base.ParmJObj.GetInt("OrderId");
employeeBonusModule.ChangeEmployeeBonusModule(OrderId);
return ApiResult.Success();
}
#endregion
}
}
......@@ -57,21 +57,6 @@ namespace Edu.WebApi.Controllers.User
[AllowAnonymous]
public ApiResult Test()
{
//new DutyPlanModule().TransVisitorToStu();
var userInfo = base.UserInfo;
var startDate = base.ParmJObj.GetStringValue("StartDate");
employeeBonusModule.CreateEmployeeBonusModule(100000, startDate);
return ApiResult.Success();
}
[HttpGet]
[HttpPost]
[AllowAnonymous]
public ApiResult ChenageOrder()
{
var OrderId = base.ParmJObj.GetInt("OrderId");
employeeBonusModule.ChangeEmployeeBonusModule(OrderId);
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