Commit b88f8427 authored by 黄奎's avatar 黄奎

页面修改

parent 170b242e
......@@ -14,5 +14,6 @@ namespace Edu.Model.ViewModel.Sell
/// 配置详细列表实体类
/// </summary>
public List<RB_Bouns_PlanDetail_Extend> DetailList { get; set; }
}
}
......@@ -10,5 +10,9 @@ namespace Edu.Model.ViewModel.Sell
/// </summary>
public class RB_Bouns_PlanDetail_Extend : RB_Bouns_PlanDetail
{
/// <summary>
/// 计划编号【查询使用】
/// </summary>
public string QPlanIds { get; set; }
}
}
using Edu.Model.ViewModel.Sell;
using Edu.Repository.Sell;
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using VT.FW.DB;
using Edu.Common.Enum;
namespace Edu.Module.Course
{
/// <summary>
/// 获取课程顾问、市场达标奖金配置处理类
/// </summary>
public class BonusConfigModule
{
/// <summary>
/// 获取课程顾问、市场达标奖金配置仓储层
/// </summary>
private readonly RB_Bonus_PlanRepository bonus_PlanRepository = new RB_Bonus_PlanRepository();
/// <summary>
/// 获取课程顾问、市场达标奖金配置阶梯仓储层
/// </summary>
private readonly RB_Bouns_PlanDetailRepository bouns_PlanDetailRepository = new RB_Bouns_PlanDetailRepository();
/// <summary>
/// 获取课程顾问、市场达标奖金配置分页列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="rowsCount"></param>
/// <param name="query"></param>
/// <returns></returns>
public List<RB_Bonus_PlanExtend> GetBounsPlanListRepository(int pageIndex, int pageSize, out long rowsCount, RB_Bonus_PlanExtend query)
{
var list = bonus_PlanRepository.GetBounsPlanListRepository(pageIndex, pageSize, out rowsCount, query);
if (list != null && list.Count>0)
{
string Ids = string.Join(",", list.Select(qitem => qitem.Id));
var detailsList = bouns_PlanDetailRepository.GetBounsPlanDetailListRepository(new RB_Bouns_PlanDetail_Extend()
{
QPlanIds = Ids
});
foreach (var item in list)
{
item.DetailList = detailsList?.Where(qitem => qitem.PlanId == item.Id)?.ToList();
}
}
return list;
}
/// <summary>
/// 新增修改课程顾问、市场达标奖金配置
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public bool SetBonusPlanModule(RB_Bonus_PlanExtend model)
{
bool flag = false;
if (model.Id > 0)
{
Dictionary<string, object> fileds = new Dictionary<string, object>()
{
{nameof(RB_Bonus_PlanExtend.PlanName),model.PlanName },
{nameof(RB_Bonus_PlanExtend.BasicSalary),model.BasicSalary },
{nameof(RB_Bonus_PlanExtend.OpenBonus),model.OpenBonus },
{nameof(RB_Bonus_PlanExtend.WorkAgeSalary),model.WorkAgeSalary },
{nameof(RB_Bonus_PlanExtend.ClueNumSalary),model.ClueNumSalary },
{nameof(RB_Bonus_PlanExtend.SaleIds),model.SaleIds },
{nameof(RB_Bonus_PlanExtend.UseCourseIds),model.UseCourseIds },
{nameof(RB_Bonus_PlanExtend.NotUseCourseIds),model.NotUseCourseIds },
{nameof(RB_Bonus_PlanExtend.UpdateBy),model.UpdateBy },
{nameof(RB_Bonus_PlanExtend.UpdateTime),model.UpdateTime },
{nameof(RB_Bonus_PlanExtend.School_Id),model.School_Id },
};
flag = bonus_PlanRepository.Update(fileds, new WhereHelper(nameof(RB_Bonus_PlanExtend.Id), model.Id));
}
else
{
var newId = bonus_PlanRepository.Insert(model);
model.Id = newId;
flag = newId > 0;
}
var oldList = bouns_PlanDetailRepository.GetBounsPlanDetailListRepository(new RB_Bouns_PlanDetail_Extend()
{
PlanId = model.Id
});
//以前没有阶梯人员信息【直接新增】
if (oldList == null || (oldList != null && oldList.Count == 0))
{
if (model.DetailList != null && model.DetailList.Count > 0)
{
foreach (var item in model.DetailList)
{
item.Status = DateStateEnum.Normal;
item.DetailId = 0;
item.PlanId = model.Id;
bouns_PlanDetailRepository.Insert(item);
}
}
}
else//以前有阶梯人员信息
{
//现在没有阶梯人员信息了【直接删除以前的阶梯人员】
if (model.DetailList == null || (model.DetailList != null && model.DetailList.Count == 0))
{
bouns_PlanDetailRepository.RemoveBounsPlanDetailByPlanIdRepository(model.Id);
}
//找出差异的数据
var deleteList = oldList.Where(qitem => !model.DetailList.Any(oldItem => qitem.DetailId == oldItem.DetailId)).ToList();
foreach (var dItem in deleteList)
{
if (dItem.DetailId > 0)
{
bouns_PlanDetailRepository.RemoveBounsPlanDetailByPlanIdRepository(dItem.PlanId, dItem.DetailId);
}
}
foreach (var priceItem in model.DetailList)
{
priceItem.PlanId = model.Id;
if (priceItem.DetailId == 0)
{
bouns_PlanDetailRepository.Insert(priceItem);
}
else
{
bouns_PlanDetailRepository.Update(priceItem);
}
}
}
return flag;
}
/// <summary>
/// 根据编号获取课程顾问、市场达标奖金配置
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
public RB_Bonus_PlanExtend GetBonusPlanModule(int Id)
{
var extModel = bonus_PlanRepository.GetEntity<RB_Bonus_PlanExtend>(Id);
if (extModel != null)
{
extModel.DetailList = bouns_PlanDetailRepository.GetBounsPlanDetailListRepository(new RB_Bouns_PlanDetail_Extend()
{
PlanId = extModel.Id
});
}
return extModel;
}
/// <summary>
/// 根据编号删除课程顾问、市场达标奖金配置
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
public bool RemoveBonusPlanModule(int Id)
{
Dictionary<string, object> fileds = new Dictionary<string, object>()
{
{nameof(RB_Bonus_PlanExtend.Status),(int)DateStateEnum.Delete }
};
bool flag = bonus_PlanRepository.Update(fileds, new WhereHelper(nameof(RB_Bonus_PlanExtend.Id), Id));
return flag;
}
}
}
......@@ -21,7 +21,7 @@ namespace Edu.Repository.Sell
/// <param name="rowsCount"></param>
/// <param name="query"></param>
/// <returns></returns>
public List<RB_Bonus_PlanExtend> GetBounsPlanDetailListRepository(int pageIndex,int pageSize,out long rowsCount,RB_Bonus_PlanExtend query)
public List<RB_Bonus_PlanExtend> GetBounsPlanListRepository(int pageIndex,int pageSize,out long rowsCount,RB_Bonus_PlanExtend query)
{
StringBuilder builder = new StringBuilder();
builder.AppendFormat(@"
......@@ -45,7 +45,7 @@ WHERE 1=1
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public List<RB_Bonus_PlanExtend> GetBounsPlanDetailListRepository(RB_Bonus_PlanExtend query)
public List<RB_Bonus_PlanExtend> GetBounsPlanListRepository(RB_Bonus_PlanExtend query)
{
StringBuilder builder = new StringBuilder();
builder.AppendFormat(@"
......
......@@ -33,8 +33,29 @@ WHERE 1=1
{
builder.AppendFormat(@" AND A.{0}={1} ", nameof(RB_Bouns_PlanDetail_Extend.PlanId), query.PlanId);
}
if (!string.IsNullOrEmpty(query.QPlanIds))
{
builder.AppendFormat(@" AND A.{0} IN({1}) ", nameof(RB_Bouns_PlanDetail_Extend.PlanId), query.QPlanIds);
}
}
return Get<RB_Bouns_PlanDetail_Extend>(builder.ToString()).ToList();
}
/// <summary>
/// 根据计划编号删除阶梯信息
/// </summary>
/// <param name="PlanId"></param>
/// <param name="DetailId"></param>
/// <returns></returns>
public bool RemoveBounsPlanDetailByPlanIdRepository(int PlanId,int DetailId=0)
{
string sql = string.Format(@" UPDATE RB_Bouns_PlanDetail SET Status=1 WHERE PlanId={0} ", PlanId);
if (DetailId > 0)
{
sql += string.Format(" AND DetailId={0} ", DetailId);
}
return base.Execute(sql) > 0;
}
}
}
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