Commit 997c7c6f authored by 黄奎's avatar 黄奎

新增字段

parent 3f3b51e4
using System;
using Edu.Common.Enum.Course;
using System;
using System.Collections.Generic;
using System.Text;
using VT.FW.DB;
......@@ -27,15 +28,19 @@ namespace Edu.Model.Entity.Bonus
/// </summary>
public int OrderId { get; set; }
/// <summary>
/// 订单状态
/// </summary>
public OrderStateEnum OrderState { get; set; }
/// <summary>
/// 订单人数
/// </summary>
public int GuestNum { get; set; }
public int OrderGuestNum { get; set; }
/// <summary>
/// 订单金额
/// </summary>
public decimal OrderMoney { get; set; }
}
}
......@@ -296,5 +296,35 @@ namespace Edu.Model.Entity.Course
/// 返佣类型 1按课耗反 2付款返佣
/// </summary>
public int CommissionReType { get; set; }
/// <summary>
/// 直客首次报名返佣比例
/// </summary>
public decimal B2CRbRatio { get; set; }
/// <summary>
/// 直客首次报名返佣类型
/// </summary>
public CourseRebateSetEnum B2CRbRatioType { get; set; }
/// <summary>
/// 直客首次报名返佣类型值
/// </summary>
public decimal B2CRbRatioValue { get; set; }
/// <summary>
/// 直客续费返佣比例
/// </summary>
public decimal B2CRNRatio { get; set; }
/// <summary>
/// 直客续费返佣类型
/// </summary>
public CourseRebateSetEnum B2CRNRatioType { get; set; }
/// <summary>
/// 直客续费返佣类型值
/// </summary>
public decimal B2CRNRatioValue { get; set; }
}
}
\ No newline at end of file
......@@ -10,5 +10,9 @@ namespace Edu.Model.ViewModel.Bonus
/// </summary>
public class RB_Personnel_Bonus_Extend : RB_Personnel_Bonus
{
/// <summary>
/// 人头奖励详情列表
/// </summary>
public List<RB_Personnel_BonusDetail_Extend> DetailList { get; set; }
}
}
......@@ -1513,6 +1513,14 @@ namespace Edu.Module.Course
{nameof(RB_Course_ViewModel.TransIntroductceReNewRatioValue),courseModel.TransIntroductceReNewRatioValue },
{nameof(RB_Course_ViewModel.CommissionReType),courseModel.CommissionReType },
{nameof(RB_Course_ViewModel.B2CRbRatio),courseModel.B2CRbRatio },
{nameof(RB_Course_ViewModel.B2CRbRatioType),courseModel.B2CRbRatioType },
{nameof(RB_Course_ViewModel.B2CRbRatioValue),courseModel.B2CRbRatioValue },
{nameof(RB_Course_ViewModel.B2CRNRatio),courseModel.B2CRNRatio },
{nameof(RB_Course_ViewModel.B2CRNRatioType),courseModel.B2CRNRatioType },
{nameof(RB_Course_ViewModel.B2CRNRatioValue),courseModel.B2CRNRatioValue },
};
flag = courseRepository.Update(fileds, new WhereHelper(nameof(RB_Course_ViewModel.CourseId), courseModel.CourseId));
}
......
......@@ -814,7 +814,8 @@ namespace Edu.Module.Course
var newPreferPrice = orderModel.PreferPrice - backModel.RealityBackMoney;
Dictionary<string, object> orderFileds = new Dictionary<string, object>()
{
{nameof(RB_Order_ViewModel.PreferPrice),newPreferPrice }
{nameof(RB_Order_ViewModel.PreferPrice),newPreferPrice },
{nameof(RB_Order_ViewModel.OrderState),(int)OrderStateEnum.DropOut },
};
flag = orderRepository.Update(orderFileds, new WhereHelper(nameof(RB_Order_ViewModel.OrderId), backModel.OrderId));
#endregion
......
......@@ -6,6 +6,7 @@ using System.Collections.Generic;
using System.Text;
using System.Linq;
using Edu.Model.Entity.Bonus;
using Edu.Model.ViewModel.Bonus;
namespace Edu.Module.Course
{
......@@ -64,16 +65,70 @@ namespace Edu.Module.Course
Group_Id = GroupId
}, isGetDetail: true);
foreach (var item in planList)
{
var saleList = Common.ConvertHelper.StringToList(item.SaleIds);
foreach (var saleId in saleList)
{
bool isCalcReduce = true;
if (StartYear == CurrentYear && StartMoneh == CurrentMonth)
{
isCalcReduce = false;
}
CalcPersionBonusModule(item, GroupId, endDate, saleId, CurrentYear, CurrentMonth, isCalcReduce: isCalcReduce);
}
}
}
/// <summary>
/// 计算人员业绩
/// </summary>
/// <param name="item"></param>
/// <param name="GroupId"></param>
/// <param name="endDate"></param>
/// <param name="saleId"></param>
/// <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)
{
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;
//计算抵扣
if (isCalcReduce)
{
//查询销售已发放的奖励
var saleBonusList = personnel_BonusRepository.GetPersonnelBonusListRepository(new RB_Personnel_Bonus_Extend()
{
EmployeeId = saleId
});
foreach (var bItem in saleBonusList)
{
//查询此月份的订单列表
var curMonthOrderList = allOrderList?.Where(qitem => qitem.CreateTime.Year == bItem.YearNum && qitem.CreateTime.Month == bItem.MonthNum)?.ToList();
foreach (var dItem in bItem.DetailList)
{
Dictionary<string, object> detailFileds = new Dictionary<string, object>();
detailFileds.Clear();
var tempCurMonthOrder = curMonthOrderList?.FirstOrDefault(qitem => qitem.OrderId == dItem.OrderId);
if (dItem.OrderState != (tempCurMonthOrder?.OrderState))
{
detailFileds.Add(nameof(RB_Personnel_BonusDetail_Extend.OrderGuestNum), 0);
detailFileds.Add(nameof(RB_Personnel_BonusDetail_Extend.OrderMoney), tempCurMonthOrder.Income -tempCurMonthOrder.Refund-tempCurMonthOrder.PlatformTax);
}
if (detailFileds != null && detailFileds.Count > 0)
{
}
}
}
}
//首月不计算抵扣
else
{
var pModel = new RB_Personnel_Bonus()
{
Id = 0,
......@@ -94,17 +149,21 @@ namespace Edu.Module.Course
pModel.Id = newId;
foreach (var oItem in allOrderList)
{
var detail = new RB_Personnel_BonusDetail()
var detailModel = new RB_Personnel_BonusDetail()
{
Id = 0,
BonusId = pModel.Id,
OrderMoney = oItem.Income - oItem.Refund + oItem.PlatformTax,
GuestNum = oItem.GuestNum,
OrderId = oItem.OrderId,
OrderState=oItem.OrderState,
OrderMoney = oItem.Income - oItem.Refund - oItem.PlatformTax,
OrderGuestNum = oItem.GuestNum,
};
var newDetailId = personnel_BonusDetailRepository.Insert(detailModel);
detailModel.Id = newDetailId;
}
}
}
}
/// <summary>
/// 获取梯度奖励金额
......
......@@ -145,8 +145,7 @@ namespace Edu.Module.Customer
}
else
{
model.ApproveState = 0;
model.CustomerState = Common.Enum.Customer.CustomerStateEnum.NotActivation;
model.CustomerState = Common.Enum.Customer.CustomerStateEnum.Normal;
model.Password = Common.DES.Encrypt(Common.Config.DefaultPwd);
var newId = customerRepository.Insert(model);
model.CustomerId = newId;
......
......@@ -12,6 +12,11 @@ namespace Edu.Repository.Bonus
/// </summary>
public class RB_Personnel_BonusRepository : BaseRepository<RB_Personnel_Bonus>
{
/// <summary>
/// 员工人头奖励详情仓储层对象
/// </summary>
private readonly RB_Personnel_BonusDetailRepository personnel_BonusDetailRepository = new RB_Personnel_BonusDetailRepository();
/// <summary>
/// 获取员工人头奖励分页列表
/// </summary>
......@@ -46,5 +51,56 @@ WHERE 1=1
}
return GetPage<RB_Personnel_Bonus_Extend>(pageIndex,pageSize,out rowsCount,builder.ToString()).ToList();
}
/// <summary>
/// 获取员工人头奖励列表
/// </summary>
/// <param name="query"></param>
/// <param name="isGetDetail">true-查询详情</param>
/// <returns></returns>
public List<RB_Personnel_Bonus_Extend> GetPersonnelBonusListRepository(RB_Personnel_Bonus_Extend query,bool isGetDetail=false)
{
StringBuilder builder = new StringBuilder();
builder.AppendFormat(@"
SELECT A.*
FROM RB_Personnel_Bonus AS A
WHERE 1=1
");
if (query != null)
{
if (query.Group_Id > 0)
{
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Personnel_Bonus_Extend.Group_Id), query.Group_Id);
}
if (query.YearNum > 0)
{
builder.AppendFormat(" AND A.{0} IN({1}) ", nameof(RB_Personnel_Bonus_Extend.YearNum), query.YearNum);
}
if (query.MonthNum > 0)
{
builder.AppendFormat(" AND A.{0} IN({1}) ", nameof(RB_Personnel_Bonus_Extend.MonthNum), query.MonthNum);
}
if (query.EmployeeId > 0)
{
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Personnel_Bonus_Extend.EmployeeId), query.EmployeeId);
}
}
var list= Get<RB_Personnel_Bonus_Extend>(builder.ToString()).ToList();
if (list != null && list.Count > 0)
{
string ids = string.Join(",", list.Select(qitem => qitem.Id));
List<RB_Personnel_BonusDetail_Extend> detailsList = personnel_BonusDetailRepository.GetPersonnelBonusDetailListRepository(new RB_Personnel_BonusDetail_Extend()
{
QBonusIds = ids
});
foreach (var item in list)
{
item.DetailList = detailsList?.Where(qitem => qitem.BonusId == item.Id)?.ToList();
}
}
return list;
}
}
}
......@@ -1267,7 +1267,15 @@ namespace Edu.WebApi.Controllers.Course
TransIntroductceReNewRatioType = (CourseRebateSetEnum)courseObj.GetInt("TransIntroductceReNewRatioType"),
TransIntroductceReNewRatioValue = courseObj.GetDecimal("TransIntroductceReNewRatioValue"),
CommissionReType = courseObj.GetInt("CommissionReType")
CommissionReType = courseObj.GetInt("CommissionReType"),
B2CRbRatio=courseObj.GetDecimal("B2CRbRatio"),
B2CRbRatioType=(CourseRebateSetEnum)courseObj.GetInt("B2CRbRatioType"),
B2CRbRatioValue=courseObj.GetDecimal("B2CRbRatioValue"),
B2CRNRatio=courseObj.GetDecimal("B2CRNRatio"),
B2CRNRatioType= (CourseRebateSetEnum)courseObj.GetInt("B2CRNRatioType"),
B2CRNRatioValue=courseObj.GetDecimal("B2CRNRatioValue"),
};
var priceObj = base.ParmJObj.GetStringValue("priceList");
var list = new List<RB_Course_Preferential_Extend>();
......@@ -1361,6 +1369,14 @@ namespace Edu.WebApi.Controllers.Course
extModel.CommissionReType = courseModel.CommissionReType;
extModel.B2CRbRatio = courseModel.B2CRbRatio;
extModel.B2CRbRatioType = courseModel.B2CRbRatioType;
extModel.B2CRbRatioValue = courseModel.B2CRbRatioValue;
extModel.B2CRNRatio = courseModel.B2CRNRatio;
extModel.B2CRNRatioType = courseModel.B2CRNRatioType;
extModel.B2CRNRatioValue = courseModel.B2CRNRatioValue;
var flag = courseModule.SetCoursePreferentialListModule(extModel, list);
return flag ? ApiResult.Success() : ApiResult.Failed();
}
......
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