Commit b95c3c34 authored by 黄奎's avatar 黄奎

新增课程报价相关

parent 5b6e6ddb
using Edu.Common.Plugin;
namespace Edu.Common.Enum.Course
{
/// <summary>
/// 课程价格优惠类型
/// </summary>
public enum CoursePriceDiscountEnum
{
/// <summary>
/// 买送
/// </summary>
[EnumField("买送")]
BuySend = 1,
/// <summary>
/// 单人报名优惠
/// </summary>
[EnumField("单人报名优惠")]
SingleJoin = 2,
/// <summary>
/// 两人报名优惠
/// </summary>
[EnumField("两人报名优惠")]
DoubleJoin =3,
/// <summary>
/// 续费报名优惠
/// </summary>
[EnumField("续费报名优惠")]
Renewal =4,
/// <summary>
/// 刷卡分期
/// </summary>
[EnumField("刷卡分期")]
Staging =5,
}
}
using Edu.Common.Enum;
using Edu.Common.Enum.Course;
using System;
using VT.FW.DB;
namespace Edu.Model.Entity.Course
{
/// <summary>
/// 课程优惠表实体类
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_Course_Preferential
{
/// <summary>
/// 主键编号
/// </summary>
public int Id { get; set; }
/// <summary>
/// 课程编号
/// </summary>
public int CourseId { get; set; }
/// <summary>
/// 优惠条件
/// </summary>
public string PreferentialTerms { get; set; }
/// <summary>
/// 销售返佣类型(0-百分比,1-固定金额)
/// </summary>
public int SaleCommissionType { get; set; }
/// <summary>
/// 销售返佣
/// </summary>
public decimal SaleCommissionMoney { get; set; }
/// <summary>
/// 同行返佣类型(0-百分比,1-固定金额)
/// </summary>
public int B2BCommissionType { get; set; }
/// <summary>
/// 同行返佣
/// </summary>
public decimal B2BCommissionMoney { get; set; }
/// <summary>
/// 课程价格优惠类型(见枚举)
/// </summary>
public CoursePriceDiscountEnum PriceDiscountType { get; set; }
/// <summary>
/// 购买人数
/// </summary>
public int BuyNum { get; set; }
/// <summary>
/// 赠送人数
/// </summary>
public int SendNum { get; set; }
/// <summary>
/// 优惠价格类型(0-百分比,1-固定金额)
/// </summary>
public int PriceType { get; set; }
/// <summary>
/// 优惠金额
/// </summary>
public decimal PriceMoney { get; set; }
/// <summary>
/// 创建人
/// </summary>
public int CreateBy { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public DateTime CreateTime { get; set; }
/// <summary>
/// 修改人
/// </summary>
public int UpdateBy { get; set; }
/// <summary>
/// 更新时间
/// </summary>
public DateTime? UpdateTime { get; set; }
/// <summary>
/// 学校Id
/// </summary>
public int School_Id { get; set; }
/// <summary>
/// 集团编号
/// </summary>
public int Group_Id { get; set; }
/// <summary>
/// 状态
/// </summary>
public DateStateEnum Status { get; set; }
}
}
......@@ -89,7 +89,10 @@ namespace Edu.Model.ViewModel.Course
/// </summary>
public List<RB_Class_Time_ViewModel> DefaultTimeList { get; set; }
/// <summary>
/// 课程优惠信息列表
/// </summary>
public List<RB_Course_Preferential_Extend> PreferentialList { get; set; }
/// <summary>
/// 开班开始时间
......@@ -134,7 +137,6 @@ namespace Edu.Model.ViewModel.Course
/// </summary>
public int OldClassId { get; set; }
/// <summary>
/// 班级最新计划Id
/// </summary>
......
using Edu.Model.Entity.Course;
using System;
using System.Collections.Generic;
using System.Text;
namespace Edu.Model.ViewModel.Course
{
/// <summary>
/// 课程优惠表扩展实体类
/// </summary>
public class RB_Course_Preferential_Extend: RB_Course_Preferential
{
/// <summary>
/// 课程编号
/// </summary>
public string QCourseIds { get; set; }
}
}
using Edu.Common.Enum;
using Edu.AOP.CustomerAttribute;
using Edu.Common.Enum;
using Edu.Model.ViewModel.Course;
using Edu.Repository.Course;
using System.Collections.Generic;
......@@ -67,6 +68,11 @@ namespace Edu.Module.Course
/// </summary>
private readonly RB_Course_StepPriceRepository course_StepPriceRepository = new RB_Course_StepPriceRepository();
/// <summary>
/// 课程优惠仓储层对象
/// </summary>
private readonly RB_Course_PreferentialRepository course_PreferentialRepository = new RB_Course_PreferentialRepository();
#region 课程管理
/// <summary>
......@@ -842,5 +848,141 @@ namespace Edu.Module.Course
return courseJobRepository.GetCourseJobPageListRepository(pageIndex, pageSize, out rowsCount, query);
}
#endregion
#region 课程优惠设置
/// <summary>
/// 获取课程优惠列表
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public List<RB_Course_Preferential_Extend> GetCoursePreferentialListModule(RB_Course_Preferential_Extend query)
{
return course_PreferentialRepository.GetCoursePreferentialListRepostory(query);
}
/// <summary>
/// 根据编号获取课程优惠信息
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
public RB_Course_Preferential_Extend GetCoursePreferentialModule(int Id)
{
return course_PreferentialRepository.GetCoursePreferentialListRepostory(new RB_Course_Preferential_Extend() { Id = Id })?.FirstOrDefault();
}
/// <summary>
/// 新增修改课程优惠
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public bool SetCoursePreferentialModule(RB_Course_Preferential_Extend model)
{
bool flag = false;
//买赠
if (model.PriceDiscountType == Common.Enum.Course.CoursePriceDiscountEnum.BuySend)
{
model.PriceType = 0;
model.PriceMoney = 0;
}
//非买赠
else
{
model.BuyNum = 0;
model.SendNum = 0;
}
if (model.Id > 0)
{
Dictionary<string, object> fileds = new Dictionary<string, object>()
{
{nameof(RB_Course_Preferential_Extend.PreferentialTerms),model.PreferentialTerms },
{nameof(RB_Course_Preferential_Extend.B2BCommissionType),model.B2BCommissionType },
{nameof(RB_Course_Preferential_Extend.B2BCommissionMoney),model.B2BCommissionMoney },
{nameof(RB_Course_Preferential_Extend.SaleCommissionType),model.SaleCommissionType },
{nameof(RB_Course_Preferential_Extend.SaleCommissionMoney),model.SaleCommissionMoney },
{nameof(RB_Course_Preferential_Extend.PriceDiscountType),model.PriceDiscountType },
{nameof(RB_Course_Preferential_Extend.BuyNum),model.BuyNum },
{nameof(RB_Course_Preferential_Extend.SendNum),model.SendNum },
{nameof(RB_Course_Preferential_Extend.PriceType),model.PriceType },
{nameof(RB_Course_Preferential_Extend.PriceMoney),model.PriceMoney },
{nameof(RB_Course_Preferential_Extend.UpdateBy),model.UpdateBy },
{nameof(RB_Course_Preferential_Extend.UpdateTime),model.UpdateTime },
};
flag = course_PreferentialRepository.Update(fileds, new WhereHelper(nameof(RB_Course_Preferential_Extend.Id), model.Id));
}
else
{
var newId = course_PreferentialRepository.Insert(model);
model.Id = newId;
flag = newId > 0;
}
return flag;
}
/// <summary>
/// 根据编删除课程优惠
/// </summary>
/// <param name="Id"></param>
/// <param name="status"></param>
/// <returns></returns>
public bool RemoveCoursePreferentialModule(int Id, int status)
{
Dictionary<string, object> fileds = new Dictionary<string, object>()
{
{nameof(RB_Course_Preferential_Extend.Status),status }
};
return course_PreferentialRepository.Update(fileds, new WhereHelper(nameof(RB_Course_Preferential_Extend.Id), Id));
}
/// <summary>
/// 批量新增修改课程优惠信息
/// </summary>
/// <param name="list"></param>
/// <returns></returns>
[TransactionCallHandler]
public virtual bool SetCoursePreferentialListModule(int CourseId, List<RB_Course_Preferential_Extend> list)
{
bool flag = false;
var oldList = GetCoursePreferentialListModule(new RB_Course_Preferential_Extend() { CourseId = CourseId });
//原来没有优惠数据
if (oldList == null || (oldList != null && oldList.Count == 0))
{
foreach (var item in list)
{
flag = course_PreferentialRepository.Insert(item) > 0;
}
}
//原来有优惠数据
else
{
if (list == null || (list != null && list.Count == 0))
{
flag = course_PreferentialRepository.DeleteCoursePreferentialRepostory(CourseId);
}
//找出差异的数据
var deleteList = oldList.Where(qitem => !list.Any(oldItem => qitem.Id == oldItem.Id)).ToList();
foreach (var dItem in deleteList)
{
if (dItem.Id > 0)
{
flag = course_PreferentialRepository.Delete(dItem.Id) > 0;
}
}
foreach (var priceItem in list)
{
if (priceItem.Id == 0)
{
flag = course_PreferentialRepository.Insert(priceItem) > 0;
}
else
{
flag = course_PreferentialRepository.Update(priceItem);
}
}
}
return flag;
}
#endregion
}
}
\ No newline at end of file
using Edu.Common.Enum;
using Edu.Model.Entity.Course;
using Edu.Model.ViewModel.Course;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Edu.Repository.Course
{
/// <summary>
/// 课程优惠仓储层
/// </summary>
public class RB_Course_PreferentialRepository : BaseRepository<RB_Course_Preferential>
{
/// <summary>
/// 获取课程优惠列表
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public List<RB_Course_Preferential_Extend> GetCoursePreferentialListRepostory(RB_Course_Preferential_Extend query)
{
StringBuilder builder = new StringBuilder();
builder.AppendFormat(@"
SELECT *
FROM RB_Course_Preferential
WHERE 1=1 ");
builder.AppendFormat(" AND {0}={1} ", nameof(RB_Course_Preferential_Extend.Status), (int)DateStateEnum.Normal);
if (query == null)
{
return new List<RB_Course_Preferential_Extend>();
}
else
{
if (query.Group_Id > 0)
{
builder.AppendFormat(" AND {0}={1} ", nameof(RB_Course_Preferential_Extend.Group_Id), query.Group_Id);
}
if (query.CourseId > 0)
{
builder.AppendFormat(" AND {0}={1} ", nameof(RB_Course_Preferential_Extend.CourseId), query.CourseId);
}
if (!string.IsNullOrEmpty(query.QCourseIds))
{
builder.AppendFormat(" AND {0} IN({1}) ", nameof(RB_Course_Preferential_Extend.CourseId), query.CourseId);
}
if (query.Id > 0)
{
builder.AppendFormat(" AND {0}={1} ", nameof(RB_Course_Preferential_Extend.Id), query.Id);
}
}
return Get<RB_Course_Preferential_Extend>(builder.ToString()).ToList();
}
/// <summary>
/// 根据课程编号删除优惠信息
/// </summary>
/// <param name="CourseId">课程编号</param>
/// <returns></returns>
public bool DeleteCoursePreferentialRepostory(int CourseId)
{
StringBuilder builder = new StringBuilder();
builder.AppendFormat(" DELETE FROM RB_Course_Preferential WHERE CourseId={0} ", CourseId);
return base.Execute(builder.ToString()) > 0;
}
}
}
using System;
using System.Collections.Generic;
using Edu.Cache.User;
using Edu.Common.API;
using Edu.Common.Enum.Course;
......@@ -744,5 +745,63 @@ namespace Edu.WebApi.Controllers.Course
return flag ? ApiResult.Success() : ApiResult.Failed();
}
#endregion
#region 课程优惠价格设置
/// <summary>
/// 获取课程优惠类型列表
/// </summary>
/// <returns></returns>
public ApiResult GetCoursePreferentialType()
{
var list = Common.Plugin.EnumHelper.EnumToList(typeof(CoursePriceDiscountEnum));
if (list != null && list.Count > 0)
{
list.Insert(0, new EnumItem()
{
Id = 0,
Name = "请选择"
});
}
return ApiResult.Success(data:list);
}
/// <summary>
/// 获取课程优惠价格列表
/// </summary>
/// <returns></returns>
public ApiResult GetCoursePreferentialList()
{
var CourseId = base.ParmJObj.GetInt("CourseId", 0);
var list = courseModule.GetCoursePreferentialListModule(new RB_Course_Preferential_Extend() { CourseId = CourseId });
return ApiResult.Success();
}
/// <summary>
/// 批量设置课程优惠价格
/// </summary>
/// <returns></returns>
public ApiResult SetBeatchCoursePreferential()
{
var CourseId = base.ParmJObj.GetInt("CourseId", 0);
var list = Common.Plugin.JsonHelper.DeserializeObject<List<RB_Course_Preferential_Extend>>(RequestParm.Msg.ToString());
if (list != null && list.Count > 0)
{
foreach (var extModel in list)
{
extModel.CreateTime = DateTime.Now;
extModel.CreateBy = base.UserInfo.Id;
extModel.UpdateBy = base.UserInfo.Id;
extModel.UpdateTime = DateTime.Now;
extModel.Group_Id = this.UserInfo.Group_Id;
extModel.School_Id = this.UserInfo.School_Id;
extModel.CourseId = CourseId;
}
}
var flag = courseModule.SetCoursePreferentialListModule(CourseId, list);
return flag ? ApiResult.Success() : ApiResult.Failed();
}
#endregion
}
}
\ No newline at end of file
......@@ -54,7 +54,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Edu.Module.OKR", "Edu.Module.OKR\Edu.Module.OKR.csproj", "{DA20EF60-D6D6-4EE3-950B-96F231A2F6F2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Edu.Test", "Edu.Test\Edu.Test.csproj", "{672E00D8-BF3A-43D0-81DF-A7A70E28DD92}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Edu.Test", "Edu.Test\Edu.Test.csproj", "{672E00D8-BF3A-43D0-81DF-A7A70E28DD92}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
......
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