Commit e7c50011 authored by 黄奎's avatar 黄奎

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

parents 20d178bc 79ef765a
...@@ -425,5 +425,10 @@ namespace Edu.Model.Entity.Sell ...@@ -425,5 +425,10 @@ namespace Edu.Model.Entity.Sell
/// 內推续费返佣比例 /// 內推续费返佣比例
/// </summary> /// </summary>
public decimal InnerRecommendReNewRatio { get; set; } public decimal InnerRecommendReNewRatio { get; set; }
/// <summary>
/// 订单标识 1产品下单 2客户转订单
/// </summary>
public int OrderIdentify { get; set; }
} }
} }
...@@ -284,5 +284,15 @@ namespace Edu.Model.ViewModel.Sell ...@@ -284,5 +284,15 @@ namespace Edu.Model.ViewModel.Sell
/// 课程图标 /// 课程图标
/// </summary> /// </summary>
public string B2BIcon { get; set; } public string B2BIcon { get; set; }
/// <summary>
/// 预计正常返佣
/// </summary>
public decimal NormalCommission { get; set; }
/// <summary>
/// 预计续费返佣
/// </summary>
public decimal RenewCommission { get; set; }
} }
} }
\ No newline at end of file
...@@ -13,6 +13,7 @@ using Edu.Model.Entity.Course; ...@@ -13,6 +13,7 @@ using Edu.Model.Entity.Course;
using Edu.Model.Entity.Sell; using Edu.Model.Entity.Sell;
using Edu.Model.ViewModel.Contract; using Edu.Model.ViewModel.Contract;
using Edu.Model.ViewModel.Course; using Edu.Model.ViewModel.Course;
using Edu.Model.ViewModel.Customer;
using Edu.Model.ViewModel.EduTask; using Edu.Model.ViewModel.EduTask;
using Edu.Model.ViewModel.Grade; using Edu.Model.ViewModel.Grade;
using Edu.Model.ViewModel.Log; using Edu.Model.ViewModel.Log;
...@@ -23,6 +24,7 @@ using Edu.Model.ViewModel.StudyAbroad; ...@@ -23,6 +24,7 @@ using Edu.Model.ViewModel.StudyAbroad;
using Edu.Model.ViewModel.User; using Edu.Model.ViewModel.User;
using Edu.Repository.Contract; using Edu.Repository.Contract;
using Edu.Repository.Course; using Edu.Repository.Course;
using Edu.Repository.Customer;
using Edu.Repository.EduTask; using Edu.Repository.EduTask;
using Edu.Repository.Finance; using Edu.Repository.Finance;
using Edu.Repository.Grade; using Edu.Repository.Grade;
...@@ -114,6 +116,10 @@ namespace Edu.Module.Course ...@@ -114,6 +116,10 @@ namespace Edu.Module.Course
/// 学生 /// 学生
/// </summary> /// </summary>
private readonly RB_StudentRepository studentRepository = new RB_StudentRepository(); private readonly RB_StudentRepository studentRepository = new RB_StudentRepository();
/// <summary>
/// 同业返佣
/// </summary>
private readonly RB_Customer_BalanceDetailRepository customer_BalanceDetailRepository = new RB_Customer_BalanceDetailRepository();
/// <summary> /// <summary>
/// 学生关联 /// 学生关联
...@@ -381,6 +387,12 @@ namespace Edu.Module.Course ...@@ -381,6 +387,12 @@ namespace Edu.Module.Course
{ {
bool flag = false; bool flag = false;
message = ""; message = "";
var orderModel = new RB_Order();
if (demodel.OrderId > 0)
{
orderModel = orderRepository.GetEntity(demodel.OrderId);
demodel.OrderIdentify = orderModel.OrderIdentify;
}
//查询班级信息 //查询班级信息
var classModel = classRepository.GetEntity(demodel.ClassId); var classModel = classRepository.GetEntity(demodel.ClassId);
if (classModel == null) if (classModel == null)
...@@ -410,11 +422,36 @@ namespace Edu.Module.Course ...@@ -410,11 +422,36 @@ namespace Edu.Module.Course
#endregion #endregion
#region 计算订单优惠信息 #region 计算订单优惠信息
List<RB_Student_ViewModel> StuList = new List<RB_Student_ViewModel>(); List<RB_Student_ViewModel> StuList = new List<RB_Student_ViewModel>();
List<RB_Customer_BalanceDetail_ViewModel> BalanceList = new List<RB_Customer_BalanceDetail_ViewModel>();//返佣 幸福存折
//计算续费订单优惠 //计算续费订单优惠
if (demodel.JoinType == OrderJoinTypeEnum.RenewOrder && demodel.OrderId == 0) if (demodel.JoinType == OrderJoinTypeEnum.RenewOrder && demodel.OrderId == 0)
{ {
demodel.DiscountMoney = coursePrice * (courseModel.B2CReNewRatio / 100); demodel.DiscountMoney = coursePrice * (courseModel.B2CReNewRatio / 100);
demodel.SaleRemark = "续费报名优惠" + courseModel.B2CReNewRatio + "%"; demodel.SaleRemark = "续费报名优惠" + courseModel.B2CReNewRatio + "%";
if (demodel.CustomerId > 0) {
if (demodel.GuestNum > 0)
{
string Description = "续费返佣;课程售价:" + courseModel.SellPrice + ";优惠比例:" + courseModel.B2CReNewRatio + "%;返佣比例:" + courseModel.B2BReNewRatio + "%";
decimal RenewCommission = Math.Round(courseModel.SellPrice * (courseModel.B2CReNewRatio / 100) * (courseModel.B2BReNewRatio / 100) * demodel.GuestNum, 2, MidpointRounding.AwayFromZero);
BalanceList.Add(new RB_Customer_BalanceDetail_ViewModel()
{
Id = 0,
RebateType = 2,
CustomerId = demodel.CustomerId,
BalanceType = 1,
Money = RenewCommission,
Description = Description,
PeopleNum = demodel.GuestNum,
EmployeeId = demodel.EnterID,
Group_Id = demodel.Group_Id,
School_Id = demodel.School_Id,
ClassId = demodel.ClassId,
BalanceState = 2,
IsRemit = 2,
UpdateTime = DateTime.Now,
});
}
}
} }
else if ((demodel.JoinType == OrderJoinTypeEnum.Normal || demodel.JoinType == OrderJoinTypeEnum.InsertClass) && string.IsNullOrEmpty(demodel.StuIds)) else if ((demodel.JoinType == OrderJoinTypeEnum.Normal || demodel.JoinType == OrderJoinTypeEnum.InsertClass) && string.IsNullOrEmpty(demodel.StuIds))
{ {
...@@ -424,8 +461,34 @@ namespace Edu.Module.Course ...@@ -424,8 +461,34 @@ namespace Edu.Module.Course
message = "优惠金额不正确"; message = "优惠金额不正确";
return false; return false;
} }
if (demodel.CustomerId > 0)
{
//生成待返佣记录表
if (demodel.GuestNum > 0)
{
string Description = "首次返佣;课程售价:" + courseModel.SellPrice + ";优惠比例:" + courseModel.B2CRatio + "%;返佣比例:" + courseModel.B2BRebateRatio + "%";
decimal NormalCommission = Math.Round(courseModel.SellPrice * (courseModel.B2CRatio / 100) * (courseModel.B2BRebateRatio / 100) * demodel.GuestNum, 2, MidpointRounding.AwayFromZero);
BalanceList.Add(new RB_Customer_BalanceDetail_ViewModel()
{
Id = 0,
RebateType = 1,
CustomerId = demodel.CustomerId,
BalanceType = 1,
Money = NormalCommission,
Description = Description,
PeopleNum = demodel.GuestNum,
EmployeeId = demodel.EnterID,
Group_Id = demodel.Group_Id,
School_Id = demodel.School_Id,
ClassId = demodel.ClassId,
BalanceState = 2,
IsRemit = 2,
UpdateTime = DateTime.Now,
});
}
}
} }
else if (!string.IsNullOrEmpty(demodel.StuIds)) else if (!string.IsNullOrEmpty(demodel.StuIds) && demodel.OrderIdentify == 2)
{ {
//查询学生列表 //查询学生列表
StuList = studentRepository.GetStudentListRepository(new RB_Student_ViewModel() { Group_Id = demodel.Group_Id, StuIds = demodel.StuIds }); StuList = studentRepository.GetStudentListRepository(new RB_Student_ViewModel() { Group_Id = demodel.Group_Id, StuIds = demodel.StuIds });
...@@ -438,6 +501,10 @@ namespace Edu.Module.Course ...@@ -438,6 +501,10 @@ namespace Edu.Module.Course
message = "学生信息有误"; message = "学生信息有误";
return false; return false;
} }
if (StuList.FirstOrDefault().CustomerId != demodel.CustomerId) {
message = "同业信息有误";
return false;
}
var glist = order_GuestRepository.GetGuestListForMobile(StuList.Select(x => x.StuTel).ToList(), demodel.CustomerId, demodel.Group_Id); var glist = order_GuestRepository.GetGuestListForMobile(StuList.Select(x => x.StuTel).ToList(), demodel.CustomerId, demodel.Group_Id);
if (glist.Any()) { if (glist.Any()) {
foreach (var item in StuList) { foreach (var item in StuList) {
...@@ -454,6 +521,59 @@ namespace Edu.Module.Course ...@@ -454,6 +521,59 @@ namespace Edu.Module.Course
message = "优惠金额不正确"; message = "优惠金额不正确";
return false; return false;
} }
if (demodel.CustomerId > 0)
{
//生成待返佣记录表
decimal RenewCommission = 0, NormalCommission = 0;
if (RenewNum > 0)
{
string Description = "续费返佣;课程售价:" + courseModel.SellPrice + ";优惠比例:" + courseModel.B2CReNewRatio + "%;返佣比例:" + courseModel.B2BReNewRatio + "%";
RenewCommission = Math.Round(courseModel.SellPrice * (courseModel.B2CReNewRatio / 100) * (courseModel.B2BReNewRatio / 100) * RenewNum, 2, MidpointRounding.AwayFromZero);
BalanceList.Add(new RB_Customer_BalanceDetail_ViewModel()
{
Id = 0,
RebateType = 2,
CustomerId = demodel.CustomerId,
BalanceType = 1,
Money = RenewCommission,
Description = Description,
PeopleNum = RenewNum,
EmployeeId = demodel.EnterID,
Group_Id = demodel.Group_Id,
School_Id = demodel.School_Id,
ClassId = demodel.ClassId,
BalanceState = 2,
IsRemit = 2,
UpdateTime = DateTime.Now,
});
}
if (NormalNum > 0)
{
string Description = "首次返佣;课程售价:" + courseModel.SellPrice + ";优惠比例:" + courseModel.B2CRatio + "%;返佣比例:" + courseModel.B2BRebateRatio + "%";
NormalCommission = Math.Round(courseModel.SellPrice * (courseModel.B2CRatio / 100) * (courseModel.B2BRebateRatio / 100) * NormalNum, 2, MidpointRounding.AwayFromZero);
BalanceList.Add(new RB_Customer_BalanceDetail_ViewModel()
{
Id = 0,
RebateType = 1,
CustomerId = demodel.CustomerId,
BalanceType = 1,
Money = NormalCommission,
Description = Description,
PeopleNum = NormalNum,
EmployeeId = demodel.EnterID,
Group_Id = demodel.Group_Id,
School_Id = demodel.School_Id,
ClassId = demodel.ClassId,
BalanceState = 2,
IsRemit = 2,
UpdateTime = DateTime.Now,
});
}
if (demodel.NormalCommission != NormalCommission || demodel.RenewCommission != RenewCommission) {
message = "返佣金额不正确";
return false;
}
}
} }
//获取课程优惠 //获取课程优惠
...@@ -492,11 +612,6 @@ namespace Edu.Module.Course ...@@ -492,11 +612,6 @@ namespace Edu.Module.Course
demodel.EduOccupation = ""; demodel.EduOccupation = "";
demodel.GeneralOccupation = ""; demodel.GeneralOccupation = "";
} }
var orderModel = new RB_Order();
if (demodel.OrderId > 0)
{
orderModel = orderRepository.GetEntity(demodel.OrderId);
}
if (demodel.OrderId > 0) if (demodel.OrderId > 0)
{ {
int BNum = orderRepository.GetClassOrderPeopleNumRepository(demodel.ClassId.ToString()).FirstOrDefault()?.GuestNum ?? 0; int BNum = orderRepository.GetClassOrderPeopleNumRepository(demodel.ClassId.ToString()).FirstOrDefault()?.GuestNum ?? 0;
...@@ -686,6 +801,46 @@ namespace Edu.Module.Course ...@@ -686,6 +801,46 @@ namespace Edu.Module.Course
LogContent += $",销售备注由【{orderModel.SaleRemark}】修改为【{demodel.SaleRemark}】"; LogContent += $",销售备注由【{orderModel.SaleRemark}】修改为【{demodel.SaleRemark}】";
SaleRemark = demodel.SaleRemark; SaleRemark = demodel.SaleRemark;
} }
#region 幸福存折
//重置返佣 幸福存折
if (orderModel.CustomerId > 0 && BalanceList.Any())
{
var balanceList = customer_BalanceDetailRepository.GetCustomerBalanceDetailListRepository(new RB_Customer_BalanceDetail_ViewModel() { Group_Id = demodel.Group_Id, OrderId = demodel.OrderId });
foreach (var item in BalanceList)
{
var bmodel = balanceList.Where(x => x.RebateType == item.RebateType).FirstOrDefault();
if (bmodel == null)
{
item.OrderId = demodel.OrderId;
item.OrderSource = (int)demodel.OrderSource;
customer_BalanceDetailRepository.Insert(item);
}
else
{
Dictionary<string, object> keyValues1 = new Dictionary<string, object>() {
{ nameof(RB_Customer_BalanceDetail_ViewModel.Money), item.Money},
{ nameof(RB_Customer_BalanceDetail_ViewModel.Description), item.Description},
{ nameof(RB_Customer_BalanceDetail_ViewModel.UpdateTime), DateTime.Now},
{ nameof(RB_Customer_BalanceDetail_ViewModel.PeopleNum), item.PeopleNum}
};
List<WhereHelper> wheres1 = new List<WhereHelper>() {
new WhereHelper(){
FiledName = nameof(RB_Customer_BalanceDetail_ViewModel.Id),
FiledValue = item.Id,
OperatorEnum =OperatorEnum.Equal
}
};
customer_BalanceDetailRepository.Update(keyValues1, wheres1);
}
}
var delBList = balanceList.Where(x => !BalanceList.Select(y => y.RebateType).Contains(x.RebateType)).ToList();
foreach (var item in delBList)
{
customer_BalanceDetailRepository.Delete(item);
}
}
#endregion
} }
else else
{ {
...@@ -840,7 +995,7 @@ namespace Edu.Module.Course ...@@ -840,7 +995,7 @@ namespace Edu.Module.Course
#endregion #endregion
#region 插入学生名单(客户选择转订单) #region 插入学生名单(客户选择转订单)
if (flag && !string.IsNullOrEmpty(demodel.StuIds)) { if (flag && demodel.OrderIdentify == 2) {
foreach (var item in StuList) { foreach (var item in StuList) {
var guestModel = new RB_Order_Guest_ViewModel() var guestModel = new RB_Order_Guest_ViewModel()
{ {
...@@ -884,6 +1039,15 @@ namespace Edu.Module.Course ...@@ -884,6 +1039,15 @@ namespace Edu.Module.Course
}; };
SetOrderGuestInfo(guestModel, out string Nmessage); SetOrderGuestInfo(guestModel, out string Nmessage);
} }
//返佣幸福存折
if (demodel.CustomerId > 0 && BalanceList.Any()) {
foreach (var item in BalanceList)
{
item.OrderId = OrderId;
item.OrderSource = (int)demodel.OrderSource;
customer_BalanceDetailRepository.Insert(item);
}
}
} }
#endregion #endregion
......
...@@ -18,6 +18,7 @@ using Edu.Model.Entity.Contract; ...@@ -18,6 +18,7 @@ using Edu.Model.Entity.Contract;
using Edu.Model.Entity.Course; using Edu.Model.Entity.Course;
using Edu.Model.ViewModel.Contract; using Edu.Model.ViewModel.Contract;
using Edu.Common.Enum.Course; using Edu.Common.Enum.Course;
using Edu.Model.ViewModel.User;
namespace Edu.Module.Course namespace Edu.Module.Course
{ {
...@@ -298,5 +299,51 @@ namespace Edu.Module.Course ...@@ -298,5 +299,51 @@ namespace Edu.Module.Course
} }
return flag; return flag;
} }
/// <summary>
/// 获取客户转订单时客户的续费状态
/// </summary>
/// <param name="stuIds"></param>
/// <param name="userInfo"></param>
/// <param name="msg"></param>
/// <returns></returns>
public object GetOrderGuestRenewState(string stuIds, UserInfo userInfo, out string message)
{
message = "";
//查询学生列表
var StuList = studentRepository.GetStudentListRepository(new RB_Student_ViewModel() { Group_Id = userInfo.Group_Id, StuIds = stuIds });
//根据客人手机号码 验证是否是续费
if (StuList.Select(x => x.CustomerId).Distinct().Count() > 1)
{
message = "只能选择同一同行的客户报名";
return false;
}
int CustomerId = StuList.FirstOrDefault().CustomerId;
var glist = order_GuestRepository.GetGuestListForMobile(StuList.Select(x => x.StuTel).ToList(), CustomerId, userInfo.Group_Id);
if (glist.Any())
{
foreach (var item in StuList)
{
if (glist.Where(x => x.Mobile == item.StuTel).Any())
{
item.IsRenewGuest = 1;//是续费的
}
}
}
int RenewNum = glist.Select(x => x.Mobile).Distinct().Count();//续费订单数量
return new
{
CustomerId,
RenewNum,
StuList = StuList.Select(x => new
{
x.StuId,
x.StuName,
x.StuTel,
x.IsRenewGuest
})
};
}
} }
} }
\ No newline at end of file
...@@ -464,6 +464,27 @@ namespace Edu.WebApi.Controllers.Course ...@@ -464,6 +464,27 @@ namespace Edu.WebApi.Controllers.Course
})); }));
} }
/// <summary>
/// 获取客户转订单续费状态
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetOrderGuestRenewState() {
var userInfo = base.UserInfo;
string StuIds = base.ParmJObj.GetStringValue("StuIds");
if (string.IsNullOrEmpty(StuIds)) {
return ApiResult.ParamIsNull("请传递学生名单");
}
var Robj = orderModule.GetOrderGuestRenewState(StuIds, userInfo, out string msg);
if (msg == "")
{
return ApiResult.Success("", Robj);
}
else {
return ApiResult.Failed(msg);
}
}
/// <summary> /// <summary>
/// 新增修改订单 /// 新增修改订单
...@@ -503,7 +524,8 @@ namespace Edu.WebApi.Controllers.Course ...@@ -503,7 +524,8 @@ namespace Edu.WebApi.Controllers.Course
LessPrice = base.ParmJObj.GetDecimal("LessPrice"), LessPrice = base.ParmJObj.GetDecimal("LessPrice"),
PerLessMoney = base.ParmJObj.GetDecimal("PerLessMoney"), PerLessMoney = base.ParmJObj.GetDecimal("PerLessMoney"),
CustomerId = base.ParmJObj.GetInt("CustomerId"), CustomerId = base.ParmJObj.GetInt("CustomerId"),
StuIds = base.ParmJObj.GetStringValue("StuIds") StuIds = base.ParmJObj.GetStringValue("StuIds"),
OrderIdentify = base.ParmJObj.GetInt("OrderIdentify"),
}; };
var IsInsertClass = base.ParmJObj.GetInt("IsChaBan"); var IsInsertClass = base.ParmJObj.GetInt("IsChaBan");
if (IsInsertClass == 1) if (IsInsertClass == 1)
...@@ -526,7 +548,10 @@ namespace Edu.WebApi.Controllers.Course ...@@ -526,7 +548,10 @@ namespace Edu.WebApi.Controllers.Course
{ {
return ApiResult.ParamIsNull("请选择客人来源"); return ApiResult.ParamIsNull("请选择客人来源");
} }
if (demodel.OrderIdentify == 2 && string.IsNullOrEmpty(demodel.StuIds))
{
return ApiResult.ParamIsNull("请传递选择客户");
}
if (!string.IsNullOrEmpty(demodel.StuIds)) { if (!string.IsNullOrEmpty(demodel.StuIds)) {
int gNum = JsonHelper.DeserializeObject<List<int>>("[" + demodel.StuIds + "]").Count(); int gNum = JsonHelper.DeserializeObject<List<int>>("[" + demodel.StuIds + "]").Count();
if (demodel.GuestNum != gNum) { if (demodel.GuestNum != gNum) {
......
...@@ -696,6 +696,7 @@ namespace Edu.WebApi.Controllers.User ...@@ -696,6 +696,7 @@ namespace Edu.WebApi.Controllers.User
item.StuChannel, item.StuChannel,
StuChannelName= item.StuChannel.ToName(), StuChannelName= item.StuChannel.ToName(),
item.PlatformName, item.PlatformName,
item.CustomerId,
AssistList = item.AssistList.Select(qitem => new AssistList = item.AssistList.Select(qitem => new
{ {
qitem.Id, qitem.Id,
......
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