Commit 6334cdf3 authored by 黄奎's avatar 黄奎

新增同行幸福存折

parent 63546557
using System;
using System.Collections.Generic;
using System.Text;
using VT.FW.DB;
namespace Edu.Model.Entity.Customer
{
/// <summary>
/// 同行幸福存折实体类
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_Customer_BalanceDetail
{
/// <summary>
/// 客户幸福存折明细id
/// </summary>
public int Id { get; set; }
/// <summary>
/// 客户Id
/// </summary>
public int CustomerId { get; set; }
/// <summary>
/// 来源id
/// </summary>
public int SourceId { get; set; }
/// <summary>
/// 来源类型
/// </summary>
public int OrderSource { get; set; }
/// <summary>
/// 类型 1存入 2扣除
/// </summary>
public int Type { get; set; }
/// <summary>
/// 变更金额
/// </summary>
public decimal Money { get; set; }
/// <summary>
/// 描述
/// </summary>
public string Description { get; set; }
/// <summary>
/// 发生时间
/// </summary>
public DateTime UpdateTime { get; set; }
/// <summary>
/// 账户余额
/// </summary>
public decimal AccountMoney { get; set; }
/// <summary>
/// 报名人数
/// </summary>
public int PeopleNum { get; set; }
/// <summary>
/// 销售编号
/// </summary>
public int EmployeeId { get; set; }
/// <summary>
/// 集团编号
/// </summary>
public int Group_Id { get; set; }
/// <summary>
/// 校区编号
/// </summary>
public int School_Id { get; set; }
/// <summary>
/// 班级编号
/// </summary>
public int ClassId { get; set; }
}
}
using Edu.Model.Entity.Customer;
using System;
using System.Collections.Generic;
using System.Text;
namespace Edu.Model.ViewModel.Customer
{
/// <summary>
/// 客户幸福存折扩展实体类
/// </summary>
public class RB_Customer_BalanceDetail_ViewModel : RB_Customer_BalanceDetail
{
}
}
...@@ -62,91 +62,100 @@ namespace Edu.Module.Customer ...@@ -62,91 +62,100 @@ namespace Edu.Module.Customer
{ {
QTaskIds = Ids QTaskIds = Ids
}); });
if (detailsList != null && detailsList.Count > 0) ParsingSubTaskTarget(detailsList);
}
foreach (var item in list)
{
item.DetailsList = detailsList?.Where(qitem => qitem.TaskId == item.Id)?.ToList();
}
}
return list;
}
/// <summary>
/// 处理子任务
/// </summary>
/// <param name="detailsList"></param>
private void ParsingSubTaskTarget(List<RB_Customer_TaskDetails_Extend> detailsList)
{
if (detailsList != null && detailsList.Count > 0)
{
var groupList = detailsList.GroupBy(qitem => new { qitem.TaskType }).Select(qitem => new { qitem.Key.TaskType });
var courseList = new List<RB_Course_ViewModel>();
var cateList = new List<RB_Course_Category_ViewModel>();
var subjectList = new List<RB_Course_Subject_ViewModel>();
foreach (var item in groupList)
{
if (item.TaskType == Common.Enum.Customer.TaskTypeEnum.Course)
{ {
var groupList = detailsList.GroupBy(qitem => new { qitem.TaskType }).Select(qitem => new { qitem.Key.TaskType }); string courseIds = string.Join(",", detailsList.Where(qitem => qitem.TaskType == item.TaskType).Select(qitem => qitem.TargetId));
var courseList = new List<RB_Course_ViewModel>(); courseList = courseRepository.GetCourseListRepository(new RB_Course_ViewModel()
var cateList = new List<RB_Course_Category_ViewModel>();
var subjectList = new List<RB_Course_Subject_ViewModel>();
foreach (var item in groupList)
{ {
if (item.TaskType == Common.Enum.Customer.TaskTypeEnum.Course) QCourseIds = courseIds
{ });
string courseIds = string.Join(",", detailsList.Where(qitem => qitem.TaskType == item.TaskType).Select(qitem => qitem.TargetId)); }
courseList = courseRepository.GetCourseListRepository(new RB_Course_ViewModel() else if (item.TaskType == Common.Enum.Customer.TaskTypeEnum.CourseCate)
{ {
QCourseIds = courseIds string catdIds = string.Join(",", detailsList.Where(qitem => qitem.TaskType == item.TaskType).Select(qitem => qitem.TargetId));
}); cateList = course_CategoryRepository.GetCourseCategoryListRepository(new RB_Course_Category_ViewModel() { QCateIds = catdIds });
} }
else if (item.TaskType == Common.Enum.Customer.TaskTypeEnum.CourseCate) else if (item.TaskType == Common.Enum.Customer.TaskTypeEnum.CourseSuject)
{ {
string catdIds = string.Join(",", detailsList.Where(qitem => qitem.TaskType == item.TaskType).Select(qitem => qitem.TargetId)); string subjectIds = string.Join(",", detailsList.Where(qitem => qitem.TaskType == item.TaskType).Select(qitem => qitem.TargetId));
cateList = course_CategoryRepository.GetCourseCategoryListRepository(new RB_Course_Category_ViewModel() { QCateIds = catdIds }); subjectList = course_SubjectRepository.GetCourseSubjectListRepository(new RB_Course_Subject_ViewModel()
} {
else if (item.TaskType == Common.Enum.Customer.TaskTypeEnum.CourseSuject) QIds = subjectIds
{ });
string subjectIds = string.Join(",", detailsList.Where(qitem => qitem.TaskType == item.TaskType).Select(qitem => qitem.TargetId)); }
subjectList = course_SubjectRepository.GetCourseSubjectListRepository(new RB_Course_Subject_ViewModel() }
{
QIds = subjectIds
});
}
}
foreach (var item in detailsList) foreach (var item in detailsList)
{
item.TargetList = new List<object>();
if (item.TargetIdList != null && item.TargetIdList.Count > 0)
{
foreach (var subItem in item.TargetIdList)
{ {
item.TargetList = new List<object>(); switch (item.TaskType)
if (item.TargetIdList != null && item.TargetIdList.Count > 0)
{ {
foreach (var subItem in item.TargetIdList) case Common.Enum.Customer.TaskTypeEnum.Course:
{ var courseModel = courseList.Where(qitem => qitem.CourseId == subItem)?.FirstOrDefault();
switch (item.TaskType) if (courseModel != null)
{ {
case Common.Enum.Customer.TaskTypeEnum.Course: item.TargetList.Add(new
var courseModel = courseList.Where(qitem => qitem.CourseId == subItem)?.FirstOrDefault(); {
if (courseModel != null) TargetId = courseModel.CourseId,
{ TargetName = courseModel.CourseName
item.TargetList.Add(new });
{
TargetId=courseModel.CourseId,
TargetName=courseModel.CourseName
});
}
break;
case Common.Enum.Customer.TaskTypeEnum.CourseCate:
var cateModel = cateList.Where(qitem => qitem.CateId == subItem)?.FirstOrDefault();
if (cateModel != null)
{
item.TargetList.Add(new
{
TargetId = cateModel.CateId,
TargetName = cateModel.CateName
});
}
break;
case Common.Enum.Customer.TaskTypeEnum.CourseSuject:
var subjectModel = subjectList.Where(qitem => qitem.Id == subItem)?.FirstOrDefault();
if (subjectModel != null)
{
item.TargetList.Add(new
{
TargetId = subjectModel.Id,
TargetName = subjectModel.SubjectName
});
}
break;
} }
} break;
case Common.Enum.Customer.TaskTypeEnum.CourseCate:
var cateModel = cateList.Where(qitem => qitem.CateId == subItem)?.FirstOrDefault();
if (cateModel != null)
{
item.TargetList.Add(new
{
TargetId = cateModel.CateId,
TargetName = cateModel.CateName
});
}
break;
case Common.Enum.Customer.TaskTypeEnum.CourseSuject:
var subjectModel = subjectList.Where(qitem => qitem.Id == subItem)?.FirstOrDefault();
if (subjectModel != null)
{
item.TargetList.Add(new
{
TargetId = subjectModel.Id,
TargetName = subjectModel.SubjectName
});
}
break;
} }
} }
} }
} }
foreach (var item in list)
{
item.DetailsList = detailsList?.Where(qitem => qitem.TaskId == item.Id)?.ToList();
}
} }
return list;
} }
/// <summary> /// <summary>
...@@ -263,10 +272,12 @@ namespace Edu.Module.Customer ...@@ -263,10 +272,12 @@ namespace Edu.Module.Customer
var extModel = customer_TaskRepository.GetEntity<RB_Customer_Task_Extend>(Id); var extModel = customer_TaskRepository.GetEntity<RB_Customer_Task_Extend>(Id);
if (extModel != null) if (extModel != null)
{ {
extModel.DetailsList = detailsRepository.GetCustomerTaskDetailsListRepository(new RB_Customer_TaskDetails_Extend() var detailsList = detailsRepository.GetCustomerTaskDetailsListRepository(new RB_Customer_TaskDetails_Extend()
{ {
TaskId = extModel.Id TaskId = extModel.Id
}); });
ParsingSubTaskTarget(detailsList);
extModel.DetailsList = detailsList;
} }
return extModel; return extModel;
} }
......
using Edu.Model.Entity.Customer;
using Edu.Model.ViewModel.Customer;
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
namespace Edu.Repository.Customer
{
/// <summary>
/// 客户幸福存折仓储层
/// </summary>
public class RB_Customer_BalanceDetailRepository : BaseRepository<RB_Customer_BalanceDetail>
{
/// <summary>
/// 获取客户幸福存折分页列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="rowsCount"></param>
/// <param name="query"></param>
/// <returns></returns>
public List<RB_Customer_BalanceDetail_ViewModel> GetCustomerBalanceDetailPageRepository(int pageIndex, int pageSize, out long rowsCount, RB_Customer_BalanceDetail_ViewModel query)
{
StringBuilder builder = new StringBuilder();
builder.AppendFormat(@"
SELECT A.*
FROM RB_Customer_BalanceDetail AS A
WHERE 1=1
");
if (query != null)
{
if (query.Group_Id > 0)
{
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Customer_BalanceDetail_ViewModel.Group_Id), query.Group_Id);
}
if (query.CustomerId > 0)
{
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Customer_BalanceDetail_ViewModel.CustomerId), query.CustomerId);
}
}
return GetPage<RB_Customer_BalanceDetail_ViewModel>(pageIndex, pageSize, out rowsCount, builder.ToString()).ToList();
}
}
}
...@@ -46,8 +46,9 @@ namespace Edu.WebApi.Controllers.Customer ...@@ -46,8 +46,9 @@ namespace Edu.WebApi.Controllers.Customer
{ {
Group_Id = base.UserInfo.Group_Id, Group_Id = base.UserInfo.Group_Id,
CustomerName = base.ParmJObj.GetStringValue("CustomerName"), CustomerName = base.ParmJObj.GetStringValue("CustomerName"),
ApproveState=base.ParmJObj.GetInt("ApproveState"), ContactNumber = base.ParmJObj.GetStringValue("ContactNumber"),
QCustomerState=base.ParmJObj.GetInt("QCustomerState"), ApproveState = base.ParmJObj.GetInt("ApproveState"),
QCustomerState = base.ParmJObj.GetInt("QCustomerState"),
}; };
var list = customerModule.GetCustomerPageModule(pageModel.PageIndex, pageModel.PageSize, out long rowsCount, query); var list = customerModule.GetCustomerPageModule(pageModel.PageIndex, pageModel.PageSize, out long rowsCount, query);
foreach (var item in list) foreach (var item in list)
...@@ -194,22 +195,22 @@ namespace Edu.WebApi.Controllers.Customer ...@@ -194,22 +195,22 @@ namespace Edu.WebApi.Controllers.Customer
var model = new RB_Customer_Task_Extend() var model = new RB_Customer_Task_Extend()
{ {
Id = base.ParmJObj.GetInt("Id"), Id = base.ParmJObj.GetInt("Id"),
TaskName=base.ParmJObj.GetStringValue("TaskName"), TaskName = base.ParmJObj.GetStringValue("TaskName"),
TaskSubTitle=base.ParmJObj.GetStringValue("TaskSubTitle"), TaskSubTitle = base.ParmJObj.GetStringValue("TaskSubTitle"),
TaskKudo =base.ParmJObj.GetStringValue("TaskKudo"), TaskKudo = base.ParmJObj.GetStringValue("TaskKudo"),
TaskStartTime =base.ParmJObj.GetDateTime("TaskStartTime"), TaskStartTime = base.ParmJObj.GetDateTime("TaskStartTime"),
TaskEndTime=base.ParmJObj.GetDateTime("TaskEndTime"), TaskEndTime = base.ParmJObj.GetDateTime("TaskEndTime"),
TaskDesc=base.ParmJObj.GetStringValue("TaskDesc"), TaskDesc = base.ParmJObj.GetStringValue("TaskDesc"),
ExchangeEndTime=base.ParmJObj.GetDateTime("ExchangeEndTime"), ExchangeEndTime = base.ParmJObj.GetDateTime("ExchangeEndTime"),
}; };
string taskImageList = base.ParmJObj.GetStringValue("TaskImageList"); string taskImageList = base.ParmJObj.GetStringValue("TaskImageList");
List<string> imgList = new List<string>(); List<string> imgList = new List<string>();
if (!string.IsNullOrEmpty(taskImageList)) if (!string.IsNullOrEmpty(taskImageList))
{ {
imgList = JsonHelper.DeserializeObject<List<string>>(taskImageList); imgList = JsonHelper.DeserializeObject<List<string>>(taskImageList);
} }
model.TaskImage = JsonHelper.Serialize(imgList); model.TaskImage = JsonHelper.Serialize(imgList);
string taskKudoImgList = base.ParmJObj.GetStringValue("TaskKudoImgList"); string taskKudoImgList = base.ParmJObj.GetStringValue("TaskKudoImgList");
List<string> KudoImgList = new List<string>(); List<string> KudoImgList = new List<string>();
if (!string.IsNullOrEmpty(taskKudoImgList)) if (!string.IsNullOrEmpty(taskKudoImgList))
...@@ -246,8 +247,8 @@ namespace Edu.WebApi.Controllers.Customer ...@@ -246,8 +247,8 @@ namespace Edu.WebApi.Controllers.Customer
TaskId = jobj.GetInt("TaskId"), TaskId = jobj.GetInt("TaskId"),
TaskType = (TaskTypeEnum)jobj.GetInt("TaskType"), TaskType = (TaskTypeEnum)jobj.GetInt("TaskType"),
TargetId = string.Join(",", targetIds), TargetId = string.Join(",", targetIds),
TaskFinishType=jobj.GetInt("TaskFinishType"), TaskFinishType = jobj.GetInt("TaskFinishType"),
TaskFinishValue=jobj.GetDecimal("TaskFinishValue"), TaskFinishValue = jobj.GetDecimal("TaskFinishValue"),
}); });
} }
} }
...@@ -258,8 +259,8 @@ namespace Edu.WebApi.Controllers.Customer ...@@ -258,8 +259,8 @@ namespace Edu.WebApi.Controllers.Customer
} }
if (model.DetailsList != null) if (model.DetailsList != null)
{ {
var groupList= model.DetailsList.GroupBy(qitem => new { qitem.TaskType }) var groupList = model.DetailsList.GroupBy(qitem => new { qitem.TaskType })
.Select(qitem => new { qitem.Key.TaskType, TaskTypeCount = qitem.Count() }); .Select(qitem => new { qitem.Key.TaskType, TaskTypeCount = qitem.Count() });
foreach (var item in groupList) foreach (var item in groupList)
{ {
if (item.TaskTypeCount > 1) if (item.TaskTypeCount > 1)
...@@ -268,6 +269,33 @@ namespace Edu.WebApi.Controllers.Customer ...@@ -268,6 +269,33 @@ namespace Edu.WebApi.Controllers.Customer
} }
} }
} }
foreach (var item in model.DetailsList)
{
switch (item.TaskType)
{
case TaskTypeEnum.Course:
if (item.TargetIdList == null || (item.TargetIdList != null && item.TargetIdList.Count == 0))
{
return ApiResult.ParamIsNull(message: $"请选择【{item.TaskType.ToName()}】类型的任务条件!");
}
break;
case TaskTypeEnum.CourseCate:
if (item.TargetIdList == null || (item.TargetIdList != null && item.TargetIdList.Count == 0))
{
return ApiResult.ParamIsNull(message: $"请选择【{item.TaskType.ToName()}】类型的任务条件!");
}
break;
case TaskTypeEnum.CourseSuject:
if (item.TargetIdList == null || (item.TargetIdList != null && item.TargetIdList.Count == 0))
{
return ApiResult.ParamIsNull(message: $"请选择【{item.TaskType.ToName()}】类型的任务条件!");
}
break;
case TaskTypeEnum.GlobalUse:
item.TargetId = "";
break;
}
}
var flag = taskModule.SetCustomerTaskModule(model); var flag = taskModule.SetCustomerTaskModule(model);
return flag ? ApiResult.Success() : ApiResult.Failed(); 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