Commit a588e7ae authored by liudong1993's avatar liudong1993

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

parents b650a5cf 7e15a130
......@@ -59,6 +59,11 @@ namespace Edu.Model.ViewModel.Customer
}
/// <summary>
/// 审核状态
/// </summary>
public int QApproveState { get; set; }
/// <summary>
/// 审核人
/// </summary>
......
using Edu.Model.ViewModel.Sell;
using Edu.Repository.Bonus;
using Edu.Repository.Sell;
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using Edu.Model.Entity.Bonus;
namespace Edu.Module.Course
{
/// <summary>
/// 员工月度人头奖金处理类
/// </summary>
public class EmployeeBonusModule
{
/// <summary>
/// 课程顾问、市场达标奖金配置仓储层对象
/// </summary>
private readonly RB_Bonus_PlanRepository bonus_PlanRepository = new RB_Bonus_PlanRepository();
/// <summary>
/// 员工人头奖励仓储层对象
/// </summary>
private readonly RB_Personnel_BonusRepository personnel_BonusRepository = new RB_Personnel_BonusRepository();
/// <summary>
/// 员工人头奖励抵扣详情仓储层对象
/// </summary>
private readonly RB_Personnel_DeductionRepository personnel_DeductionRepository = new RB_Personnel_DeductionRepository();
/// <summary>
/// 员工人头奖励详情仓储层对象
/// </summary>
private readonly RB_Personnel_BonusDetailRepository personnel_BonusDetailRepository = new RB_Personnel_BonusDetailRepository();
/// <summary>
/// 订单仓储层对象
/// </summary>
private readonly RB_OrderRepository orderRepository = new RB_OrderRepository();
/// <summary>
/// 生成业绩
/// </summary>
public void CreateEmployeeBonusModule(int GroupId)
{
string endDate = "2021-12-31";
int CurrentYear = 2021;
int CurrentMonth = 12;
//人头配置列表
var planList= bonus_PlanRepository.GetBounsPlanListRepository(new RB_Bonus_PlanExtend() {
Group_Id=GroupId
},isGetDetail:true);
foreach (var item in planList)
{
var saleList = Common.ConvertHelper.StringToList(item.SaleIds);
foreach (var saleId in saleList)
{
var orderList = GetSaleOrderList(item, GroupId, endDate, saleId);
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;
var pModel = new RB_Personnel_Bonus()
{
Id = 0,
RewardType = item.PlanType,
YearNum = CurrentYear,
MonthNum = CurrentMonth,
EmployeeId=saleId,
CurGuestNum= curNum,
CurOrderMoney= curOrderMoney,
Group_Id =GroupId,
CurRewardMoney= GetStepAwardAmount(item, curNum),
CreateBy=0,
CreateTime=DateTime.Now,
UpdateBy=1,
UpdateTime=DateTime.Now,
};
var newId = personnel_BonusRepository.Insert(pModel);
pModel.Id = newId;
foreach (var oItem in orderList)
{
var detail = new RB_Personnel_BonusDetail()
{
Id = 0,
BonusId = pModel.Id
};
}
}
}
}
/// <summary>
/// 获取梯度奖励金额
/// </summary>
/// <param name="item"></param>
/// <param name="GuestNum"></param>
/// <returns></returns>
private decimal GetStepAwardAmount(RB_Bonus_PlanExtend item,int GuestNum)
{
decimal awardAmount = 0;
if (item != null && item.DetailList != null && item.DetailList.Count > 0)
{
for (var i = 0; i < item.DetailList.Count; i++)
{
var tempNum = item.DetailList[i];
if (tempNum.StartNum <= GuestNum && GuestNum <= tempNum.EndNum)
{
awardAmount = tempNum.Money;
}
}
}
return awardAmount;
}
/// <summary>
/// 获取当前人员订单列表
/// </summary>
/// <param name="item"></param>
/// <param name="GroupId"></param>
/// <param name="endDate"></param>
/// <param name="SaleId"></param>
/// <returns></returns>
private List<PersionOrderItem> GetSaleOrderList(RB_Bonus_PlanExtend item,int GroupId,string endDate,int SaleId)
{
List<PersionOrderItem> list = new List<PersionOrderItem>();
//所有当前人员订单列表
var orderList = orderRepository.GetAllBonusOrderListRepository(GroupId, endDate,SaleId);
//适用课程
if (!string.IsNullOrEmpty(item.UseCourseIds))
{
orderList = orderList?.Where(qitem => item.UseCourseIds.Contains(qitem.CourseId.ToString()))?.ToList();
}
//不适用课程
if (!string.IsNullOrEmpty(item.NotUseCourseIds))
{
orderList = orderList?.Where(qitem => !item.NotUseCourseIds.Contains(qitem.CourseId.ToString()))?.ToList();
}
//按照年份、月份统计订单人数和金额
var groupList = orderList
.GroupBy(qitem => new { qitem.CreateTime.Year, qitem.CreateTime.Month })
.Select(qitem => new
{
qitem.Key.Year,
qitem.Key.Month,
GuestNum=qitem.Sum(s=>s.GuestNum),
OrderMoney=qitem.Sum(s=>s.Income - s.Refund + s.PlatformTax)
});
foreach (var gItem in groupList)
{
list.Add(new PersionOrderItem()
{
Year = gItem.Year,
Month = gItem.Month,
GuestNum = gItem.GuestNum,
OrderMoney = gItem.OrderMoney
});
}
return list;
}
}
/// <summary>
/// 人员销售
/// </summary>
public class PersionOrderItem
{
/// <summary>
/// 年份
/// </summary>
public int Year { get; set; }
/// <summary>
/// 月份
/// </summary>
public int Month { get; set; }
/// <summary>
/// 人数
/// </summary>
public int GuestNum { get; set; }
/// <summary>
/// 订单金额
/// </summary>
public decimal OrderMoney { get; set; }
}
}
......@@ -41,23 +41,11 @@ namespace Edu.Module.Duty
/// </summary>
private readonly RB_Class_PlanRepository class_PlanRepository = new RB_Class_PlanRepository();
/// <summary>
/// 学生
/// </summary>
private readonly RB_StudentRepository studentRepository = new RB_StudentRepository();
/// <summary>
/// 学员日志仓储层对象
/// </summary>
private readonly RB_Student_LogRepository student_LogRepository = new RB_Student_LogRepository();
/// <summary>
/// 账号管理仓储层对象
/// </summary>
private readonly RB_AccountRepository accountRepository = new RB_AccountRepository();
/// <summary>
/// 获取访客约课分页列表
/// </summary>
......
......@@ -374,6 +374,18 @@ namespace Edu.Module.User
return flag;
}
/// <summary>
/// 修改客户阶段
/// </summary>
/// <param name="StuId"></param>
/// <param name="StuStage"></param>
/// <param name="Uid"></param>
/// <returns></returns>
public bool SetStudentStageModule(int StuId,int StuStage,int Uid)
{
return studentRepository.SetStudentStageRepository(StuId, StuStage, Uid);
}
/// <summary>
/// 获取协助人员列表
/// </summary>
......
......@@ -61,6 +61,17 @@ WHERE 1=1
{
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Customer_Extend.ApproveState), query.ApproveState);
}
if (query.QApproveState > 0)
{
if (query.QApproveState == 3)
{
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Customer_Extend.ApproveState), 0);
}
else
{
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Customer_Extend.ApproveState), query.QApproveState);
}
}
if (query.QCustomerState > 0)
{
switch (query.QCustomerState)
......
......@@ -14,6 +14,12 @@ namespace Edu.Repository.Sell
/// </summary>
public class RB_Bonus_PlanRepository : BaseRepository<RB_Bonus_Plan>
{
/// <summary>
/// 课程顾问、市场达标奖金配置阶梯仓储层对象
/// </summary>
private readonly RB_Bouns_PlanDetailRepository bouns_PlanDetailRepository = new RB_Bouns_PlanDetailRepository();
/// <summary>
/// 获取课程顾问、市场达标奖金配置分页列表
/// </summary>
......@@ -56,7 +62,7 @@ WHERE 1=1
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public List<RB_Bonus_PlanExtend> GetBounsPlanListRepository(RB_Bonus_PlanExtend query)
public List<RB_Bonus_PlanExtend> GetBounsPlanListRepository(RB_Bonus_PlanExtend query, bool isGetDetail = false)
{
StringBuilder builder = new StringBuilder();
builder.AppendFormat(@"
......@@ -76,7 +82,20 @@ WHERE 1=1
builder.AppendFormat(@" AND A.{0}={1} ", nameof(RB_Bonus_PlanExtend.PlanType), query.PlanType);
}
}
return Get<RB_Bonus_PlanExtend>(builder.ToString()).ToList();
var list= Get<RB_Bonus_PlanExtend>(builder.ToString()).ToList();
if (list != null && list.Count > 0 && isGetDetail)
{
string planIds = string.Join(",", list.Select(qitem => qitem.Id));
List<RB_Bouns_PlanDetail_Extend> detailList = bouns_PlanDetailRepository.GetBounsPlanDetailListRepository(new RB_Bouns_PlanDetail_Extend()
{
QPlanIds = planIds
});
foreach (var item in list)
{
item.DetailList = detailList?.Where(qitem => qitem.PlanId == item.Id)?.ToList();
}
}
return list;
}
}
}
using Edu.Common.Enum.Sale;
using Edu.Common.Enum.Course;
using Edu.Common.Enum.Sale;
using Edu.Model.Entity.Course;
using Edu.Model.Entity.Grade;
using Edu.Model.Entity.Sell;
......@@ -6,6 +7,7 @@ using Edu.Model.ViewModel.Sell;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Edu.Repository.Sell
{
......@@ -1173,5 +1175,40 @@ group by o.OrderId
return Get<RB_Order_ViewModel>(sql).ToList();
}
#endregion
/// <summary>
/// 获取所有人头奖金的订单列表
/// </summary>
/// <param name="group_Id">集团编号</param>
/// <param name="eDate">结束日期</param>
/// <returns></returns>
public List<RB_Order_ViewModel> GetAllBonusOrderListRepository(int group_Id, string eDate,int SaleId)
{
StringBuilder builder = new StringBuilder();
builder.AppendFormat(@"
SELECT o.*
FROM rb_order o
WHERE 1=1
");
builder.AppendFormat(" AND o.OrderState IN({0},{1}) ", (int)OrderStateEnum.Normal, (int)OrderStateEnum.DropOut);
builder.AppendFormat(" AND o.{0}={1} ", nameof(RB_Order_ViewModel.OrderType), (int)OrderTypeEnum.CourseOrder);
builder.AppendFormat(" AND o.CreateTime >= '2021-12-01' ");
//帐平
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);
}
if (!string.IsNullOrEmpty(eDate))
{
builder.AppendFormat(" AND o.CreateTime <= '{0} 23:59:59' ", eDate);
}
if (SaleId > 0)
{
builder.AppendFormat(" AND ( EnterID={0} OR CreateBy={0} ) ", SaleId);
}
builder.AppendFormat(" GROUP BY o.OrderId ");
return Get<RB_Order_ViewModel>(builder.ToString()).ToList();
}
}
}
......@@ -544,6 +544,38 @@ WHERE o.OrderState=1 and og.`Status`=0 and sog.`Status`=0 and og.GuestState=1 an
return flag;
}
/// <summary>
/// 修改客户阶段
/// </summary>
/// <param name="StuId"></param>
/// <param name="StuStage"></param>
/// <param name="Uid"></param>
/// <returns></returns>
public bool SetStudentStageRepository(int StuId,int StuStage,int Uid)
{
string logContent = "";
string logTitle = "";
bool flag = false;
var oldModel = base.GetEntity(StuId);
if (oldModel != null)
{
if (oldModel.StuStage != StuStage)
{
var oldName = stageRepository.GetEntity(oldModel.StuStage)?.StageName ?? "";
var newName = stageRepository.GetEntity(StuStage)?.StageName ?? "";
logContent += string.Format("客户阶段:由【{0}】=>【{1}】,", oldName, newName);
}
Dictionary<string, object> fileds = new Dictionary<string, object>()
{
{nameof(RB_Student_ViewModel.StuStage),StuStage }
};
flag = base.Update(fileds, new WhereHelper(nameof(RB_Student_ViewModel.StuId), StuId));
student_LogRepository.AddStuLogRepository(oldModel.StuId, Common.Enum.Log.StudentLogTypeEnum.BasicInfo, logTitle, logContent, Uid, CreateType: 1);
}
return flag;
}
/// <summary>
/// 学员转交
/// </summary>
......
......@@ -54,6 +54,7 @@ namespace Edu.WebApi.Controllers.Customer
ContactNumber = base.ParmJObj.GetStringValue("ContactNumber"),
ApproveState = base.ParmJObj.GetInt("ApproveState"),
QCustomerState = base.ParmJObj.GetInt("QCustomerState"),
QApproveState=base.ParmJObj.GetInt("QApproveState")
};
var list = customerModule.GetCustomerPageModule(pageModel.PageIndex, pageModel.PageSize, out long rowsCount, query);
foreach (var item in list)
......
......@@ -10,6 +10,7 @@ using Edu.Common.Plugin;
using Edu.Model.CacheModel;
using Edu.Model.ViewModel.System;
using Edu.Model.ViewModel.User;
using Edu.Module.Course;
using Edu.Module.Duty;
using Edu.Module.Public;
using Edu.Module.System;
......@@ -49,12 +50,16 @@ namespace Edu.WebApi.Controllers.User
/// </summary>
private readonly TeacherModule teacherModule = new TeacherModule();
private readonly EmployeeBonusModule employeeBonusModule = new EmployeeBonusModule();
[HttpGet]
[HttpPost]
[AllowAnonymous]
public ApiResult Test()
{
new DutyPlanModule().TransVisitorToStu();
//new DutyPlanModule().TransVisitorToStu();
var userInfo = base.UserInfo;
employeeBonusModule.CreateEmployeeBonusModule(userInfo.Group_Id);
return ApiResult.Success();
}
......
......@@ -105,11 +105,6 @@ namespace Edu.WebApi.Controllers.User
/// </summary>
private readonly DutyPlanModule dutyPlanModule = AOP.AOPHelper.CreateAOPObject<DutyPlanModule>();
/// <summary>
/// 同业处理类对象
/// </summary>
private readonly CustomerModule customerModule = new CustomerModule();
#region 用户账户管理
/// <summary>
......@@ -867,6 +862,23 @@ namespace Edu.WebApi.Controllers.User
return flag ? ApiResult.Success(data: extModel) : ApiResult.Failed();
}
/// <summary>
/// 修改客户阶段
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult SetStudentStage()
{
var StuId = base.ParmJObj.GetInt("StuId");
var StuStage = base.ParmJObj.GetInt("StuStage");
if (StuStage > 0)
{
var flag = studentModule.SetStudentStageModule(StuId, StuStage, base.UserInfo.Id);
return flag ? ApiResult.Success() : ApiResult.Failed();
}
return ApiResult.Failed(message:"请选择客户阶段");
}
/// <summary>
/// 检查学员手机号码是否存在
/// </summary>
......
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