Commit 393a6596 authored by 黄奎's avatar 黄奎

页面修改

parent 9cd55296
...@@ -18,7 +18,7 @@ namespace Edu.Model.Entity.Customer ...@@ -18,7 +18,7 @@ namespace Edu.Model.Entity.Customer
public int CustomerId { get; set; } public int CustomerId { get; set; }
/// <summary> /// <summary>
/// 客户名称 /// 联系人
/// </summary> /// </summary>
public string CustomerName { get; set; } public string CustomerName { get; set; }
...@@ -208,14 +208,19 @@ namespace Edu.Model.Entity.Customer ...@@ -208,14 +208,19 @@ namespace Edu.Model.Entity.Customer
public string EnterpriseName { get; set; } public string EnterpriseName { get; set; }
/// <summary> /// <summary>
/// 同业类型 1企业 2学校 /// 同业类型(见枚举)
/// </summary> /// </summary>
public int CustomerType { get; set; } public CatetoryTypeEnum CustomerType { get; set; }
/// <summary> /// <summary>
/// 微信号码 /// 微信号码
/// </summary> /// </summary>
public string WeChatNo { get; set; } public string WeChatNo { get; set; }
/// <summary>
/// 客户分类编号
/// </summary>
public int CategoryId { get; set; }
} }
} }
\ No newline at end of file
...@@ -24,5 +24,10 @@ namespace Edu.Model.ViewModel.Customer ...@@ -24,5 +24,10 @@ namespace Edu.Model.ViewModel.Customer
/// 订单数量 /// 订单数量
/// </summary> /// </summary>
public int OrderCount { get; set; } public int OrderCount { get; set; }
/// <summary>
/// 订单金额
/// </summary>
public decimal OrderSales { get; set; }
} }
} }
...@@ -123,5 +123,15 @@ namespace Edu.Model.ViewModel.Customer ...@@ -123,5 +123,15 @@ namespace Edu.Model.ViewModel.Customer
/// 结束日期 /// 结束日期
/// </summary> /// </summary>
public string EndDate { get; set; } public string EndDate { get; set; }
/// <summary>
/// 客户编号
/// </summary>
public string QCategoryIds { get; set; }
/// <summary>
/// 同业名称
/// </summary>
public string CategoryName { get; set; }
} }
} }
...@@ -583,7 +583,7 @@ namespace Edu.Module.Course ...@@ -583,7 +583,7 @@ namespace Edu.Module.Course
else if ((int)m.OrderSourceType == 2) else if ((int)m.OrderSourceType == 2)
{ {
var customerModel = customerRepository.GetEntity(m.OrderSourceId); var customerModel = customerRepository.GetEntity(m.OrderSourceId);
if (customerModel.CustomerType == 1) if (customerModel.CustomerType == Common.Enum.Customer.CatetoryTypeEnum.Company)
{ {
if (courseModel.CommissionReType == 1) if (courseModel.CommissionReType == 1)
{ {
...@@ -1007,7 +1007,7 @@ namespace Edu.Module.Course ...@@ -1007,7 +1007,7 @@ namespace Edu.Module.Course
} }
if (orderModel.CustomerId != demodel.CustomerId) if (orderModel.CustomerId != demodel.CustomerId)
{ {
LogContent += $",关联同行由【{customerRepository.GetEntity(orderModel.CustomerId)?.CustomerName ?? ""}】修改为【{customerRepository.GetEntity(demodel.CustomerId)?.CustomerName ?? ""}】"; LogContent += $",关联同行联系人由【{customerRepository.GetEntity(orderModel.CustomerId)?.CustomerName ?? ""}】修改为【{customerRepository.GetEntity(demodel.CustomerId)?.CustomerName ?? ""}】";
} }
if (orderModel.GeneralOccupation != demodel.GeneralOccupation) if (orderModel.GeneralOccupation != demodel.GeneralOccupation)
{ {
......
...@@ -105,6 +105,7 @@ namespace Edu.Module.Customer ...@@ -105,6 +105,7 @@ namespace Edu.Module.Customer
{nameof(RB_Customer_Extend.CustomerType),model.CustomerType }, {nameof(RB_Customer_Extend.CustomerType),model.CustomerType },
{nameof(RB_Customer_Extend.UpdateTime),model.UpdateTime }, {nameof(RB_Customer_Extend.UpdateTime),model.UpdateTime },
{nameof(RB_Customer_Extend.WeChatNo),model.WeChatNo }, {nameof(RB_Customer_Extend.WeChatNo),model.WeChatNo },
{nameof(RB_Customer_Extend.CategoryId),model.CategoryId },
}; };
flag = customerRepository.Update(fileds, new WhereHelper(nameof(RB_Customer_Extend.CustomerId), model.CustomerId)); flag = customerRepository.Update(fileds, new WhereHelper(nameof(RB_Customer_Extend.CustomerId), model.CustomerId));
if (flag) if (flag)
...@@ -113,7 +114,7 @@ namespace Edu.Module.Customer ...@@ -113,7 +114,7 @@ namespace Edu.Module.Customer
string LogContent = "后台修改同业信息:"; string LogContent = "后台修改同业信息:";
if (oldModel.CustomerName != model.CustomerName) if (oldModel.CustomerName != model.CustomerName)
{ {
LogContent += "名称由'" + oldModel.CustomerName + "'修改为'" + model.CustomerName + "';"; LogContent += "联系人由'" + oldModel.CustomerName + "'修改为'" + model.CustomerName + "';";
} }
if (oldModel.ContactNumber != model.ContactNumber) if (oldModel.ContactNumber != model.ContactNumber)
{ {
...@@ -146,7 +147,7 @@ namespace Edu.Module.Customer ...@@ -146,7 +147,7 @@ namespace Edu.Module.Customer
} }
if (oldModel.CustomerType != model.CustomerType) if (oldModel.CustomerType != model.CustomerType)
{ {
LogContent += "类型由'" + (oldModel.CustomerType == 1 ? "企业" : "学校") + "'修改为'" + (model.CustomerType == 1 ? "企业" : "学校") + "';"; LogContent += "类型由'" + oldModel.CustomerType.ToName() + "'修改为'" + (model.CustomerType.ToName()) + "';";
} }
if (oldModel.WeChatNo != model.WeChatNo) if (oldModel.WeChatNo != model.WeChatNo)
{ {
...@@ -271,11 +272,11 @@ namespace Edu.Module.Customer ...@@ -271,11 +272,11 @@ namespace Edu.Module.Customer
foreach (var item in list) foreach (var item in list)
{ {
var stuModel = StuNumList.Where(x => x.CustomerId == item.CustomerId).FirstOrDefault(); var stuList = StuNumList.Where(x => x.CustomerId == item.CustomerId)?.ToList();
var orderModel = OrderNumList.Where(x => x.CustomerId == item.CustomerId).FirstOrDefault(); var orderList= OrderNumList.Where(x => x.CustomerId == item.CustomerId)?.ToList();
item.StuNum = stuModel?.StuNum ?? 0; item.StuNum = stuList?.Sum(qitem=>qitem.StuNum)??0;
item.OrderNum = orderModel?.OrderNum ?? 0; item.OrderNum = orderList?.Sum(qitem => qitem.OrderNum) ?? 0;
item.OrderSales = orderModel?.OrderSales ?? 0; item.OrderSales = orderList?.Sum(qitem => qitem.OrderSales) ?? 0;
} }
} }
return list; return list;
...@@ -501,31 +502,35 @@ namespace Edu.Module.Customer ...@@ -501,31 +502,35 @@ namespace Edu.Module.Customer
{ {
string Ids = string.Join(",", list.Select(qitem => qitem.CategoryId)); string Ids = string.Join(",", list.Select(qitem => qitem.CategoryId));
List<RB_Customer_Extend> customerLinkList = new List<RB_Customer_Extend>(); List<RB_Customer_Extend> customerLinkList = new List<RB_Customer_Extend>();
List<RB_Student_ViewModel> studentList = new List<RB_Student_ViewModel>(); List<RB_Customer_Extend> StuNumList = new List<RB_Customer_Extend>();
List<RB_Customer_Extend> OrderNumList = new List<RB_Customer_Extend>();
if (!string.IsNullOrEmpty(Ids)) if (!string.IsNullOrEmpty(Ids))
{ {
//联系人 //联系人
customerLinkList = customerRepository.GetCustomerListRepository(new RB_Customer_Extend() customerLinkList = customerRepository.GetCustomerListRepository(new RB_Customer_Extend()
{ {
QCategoryIds=Ids
}); });
//客户数量 if (customerLinkList != null && customerLinkList.Count > 0)
studentList= studentRepository.GetStudentListRepository(new RB_Student_ViewModel()
{ {
string customerIds = string.Join(",", customerLinkList.Select(qitem => qitem.CustomerId));
}); //查询客户数量
StuNumList = customerRepository.GetCustomerStuNum(customerIds, query.Group_Id);
//订单数量 //查询订单数量 及 交易额
OrderNumList = customerRepository.GetCustomerOrderNum(customerIds, query.Group_Id);
}
} }
foreach (var item in list) foreach (var item in list)
{ {
var tempLinkList = customerLinkList; var tempLinkList = customerLinkList?.Where(qitem=>qitem.CategoryId==item.CategoryId)?.ToList();
item.LinkManCount = tempLinkList?.Count() ?? 0; item.LinkManCount = tempLinkList?.Count() ?? 0;
var tempStuList = studentList; var stuList = StuNumList.Where(x => x.CategoryId == item.CategoryId)?.ToList();
item.OrderCount = 0; var orderList = OrderNumList.Where(x => x.CategoryId == item.CategoryId)?.ToList();
item.StudentCount = tempStuList?.Count() ?? 0; item.OrderCount = orderList?.Sum(qitem => qitem.OrderNum) ?? 0;
item.OrderSales= orderList?.Sum(qitem => qitem.OrderSales) ?? 0;
item.StudentCount = stuList?.Sum(qitem=>qitem.StuNum)??0;
} }
} }
return list; return list;
......
...@@ -28,8 +28,8 @@ namespace Edu.Repository.Customer ...@@ -28,8 +28,8 @@ namespace Edu.Repository.Customer
var parameters = new DynamicParameters(); var parameters = new DynamicParameters();
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.AppendFormat(@" builder.AppendFormat(@"
SELECT A.* SELECT A.*,IFNULL(B.CategoryName,'') AS CategoryName
FROM RB_Customer AS A FROM RB_Customer AS A LEFT JOIN rb_customer_category AS B ON A.CategoryId=B.CategoryId
WHERE 1=1 WHERE 1=1
"); ");
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Customer_Extend.Status), (int)DateStateEnum.Normal); builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Customer_Extend.Status), (int)DateStateEnum.Normal);
...@@ -152,6 +152,14 @@ WHERE 1=1 ...@@ -152,6 +152,14 @@ WHERE 1=1
{ {
builder.AppendFormat(" AND A.{0} in({1}) ", nameof(RB_Customer_Extend.CustomerId), query.CustomerIds); builder.AppendFormat(" AND A.{0} in({1}) ", nameof(RB_Customer_Extend.CustomerId), query.CustomerIds);
} }
if (query.CategoryId > 0)
{
builder.AppendFormat(" AND A.{0} in({1}) ", nameof(RB_Customer_Extend.CategoryId), query.CategoryId);
}
if (!string.IsNullOrEmpty(query.QCategoryIds))
{
builder.AppendFormat(" AND A.{0} in({1}) ", nameof(RB_Customer_Extend.CategoryId), query.QCategoryIds);
}
} }
return Get<RB_Customer_Extend>(builder.ToString(), parameters).ToList(); return Get<RB_Customer_Extend>(builder.ToString(), parameters).ToList();
} }
...@@ -165,8 +173,13 @@ WHERE 1=1 ...@@ -165,8 +173,13 @@ WHERE 1=1
/// <returns></returns> /// <returns></returns>
public List<RB_Customer_Extend> GetCustomerStuNum(string customerIds, int group_Id) public List<RB_Customer_Extend> GetCustomerStuNum(string customerIds, int group_Id)
{ {
string sql = $@"SELECT s.CustomerId,COUNT(0) as StuNum FROM rb_student s string sql = $@"
WHERE s.`Status`=0 and s.Group_Id ={group_Id} and s.CustomerId in({customerIds}) GROUP BY s.CustomerId"; SELECT s.CustomerId,C.CategoryId,COUNT(0) as StuNum
FROM rb_student s INNER JOIN rb_customer AS c ON (s.StuSourceId=C.CustomerId AND s.CreateType=2)
WHERE s.`Status`=0 and s.Group_Id ={group_Id}
and s.CustomerId in({customerIds})
GROUP BY s.CustomerId,C.CategoryId
";
return Get<RB_Customer_Extend>(sql).ToList(); return Get<RB_Customer_Extend>(sql).ToList();
} }
...@@ -178,8 +191,12 @@ WHERE s.`Status`=0 and s.Group_Id ={group_Id} and s.CustomerId in({customerIds}) ...@@ -178,8 +191,12 @@ WHERE s.`Status`=0 and s.Group_Id ={group_Id} and s.CustomerId in({customerIds})
/// <returns></returns> /// <returns></returns>
public List<RB_Customer_Extend> GetCustomerOrderNum(string customerIds, int group_Id) public List<RB_Customer_Extend> GetCustomerOrderNum(string customerIds, int group_Id)
{ {
string sql = $@"SELECT o.CustomerId, COUNT(0) as OrderNum, SUM(o.PreferPrice) as OrderSales FROM rb_order o string sql = $@"
WHERE o.OrderState in(1,2) and o.Group_Id ={group_Id} and o.CustomerId in({customerIds}) GROUP BY o.CustomerId"; SELECT o.CustomerId,C.CategoryId,COUNT(0) as OrderNum, SUM(o.PreferPrice) as OrderSales
FROM rb_order o INNER JOIN rb_customer AS c ON (o.CustomerId=C.CustomerId)
WHERE o.OrderState in(1,2) and o.Group_Id ={group_Id} and o.CustomerId in({customerIds})
GROUP BY o.CustomerId,C.CategoryId
";
return Get<RB_Customer_Extend>(sql).ToList(); return Get<RB_Customer_Extend>(sql).ToList();
} }
......
...@@ -97,8 +97,9 @@ namespace Edu.WebApi.Controllers.Customer ...@@ -97,8 +97,9 @@ namespace Edu.WebApi.Controllers.Customer
Account = base.ParmJObj.GetStringValue("Account"), Account = base.ParmJObj.GetStringValue("Account"),
Remark = base.ParmJObj.GetStringValue("Remark"), Remark = base.ParmJObj.GetStringValue("Remark"),
EnterpriseName = base.ParmJObj.GetStringValue("EnterpriseName"), EnterpriseName = base.ParmJObj.GetStringValue("EnterpriseName"),
CustomerType = base.ParmJObj.GetInt("CustomerType"), CustomerType = (CatetoryTypeEnum)base.ParmJObj.GetInt("CustomerType"),
WeChatNo = base.ParmJObj.GetStringValue("WeChatNo"), WeChatNo = base.ParmJObj.GetStringValue("WeChatNo"),
CategoryId=base.ParmJObj.GetInt("CategoryId"),
}; };
if (string.IsNullOrEmpty(model.CustomerName)) if (string.IsNullOrEmpty(model.CustomerName))
{ {
...@@ -858,12 +859,15 @@ namespace Edu.WebApi.Controllers.Customer ...@@ -858,12 +859,15 @@ namespace Edu.WebApi.Controllers.Customer
[HttpPost] [HttpPost]
public ApiResult SetCustomerCategory() public ApiResult SetCustomerCategory()
{ {
int CategoryId = base.ParmJObj.GetInt("CategoryId");
var extModel = new RB_Customer_Category_Extend() var extModel = new RB_Customer_Category_Extend()
{ {
CategoryId=base.ParmJObj.GetInt("CategoryId"), CategoryId= CategoryId,
CategoryName = base.ParmJObj.GetStringValue("CategoryName"), CategoryName = base.ParmJObj.GetStringValue("CategoryName"),
CatetoryType = (CatetoryTypeEnum)base.ParmJObj.GetInt("CatetoryType"), CatetoryType = (CatetoryTypeEnum)base.ParmJObj.GetInt("CatetoryType"),
}; };
var linkMan = base.ParmJObj.GetStringValue("linkMan");
var linkTel = base.ParmJObj.GetStringValue("linkTel");
extModel.Group_Id = base.UserInfo.Group_Id; extModel.Group_Id = base.UserInfo.Group_Id;
extModel.CreateBy = base.UserInfo.Id; extModel.CreateBy = base.UserInfo.Id;
extModel.UpdateBy = base.UserInfo.Id; extModel.UpdateBy = base.UserInfo.Id;
...@@ -871,6 +875,53 @@ namespace Edu.WebApi.Controllers.Customer ...@@ -871,6 +875,53 @@ namespace Edu.WebApi.Controllers.Customer
extModel.UpdateTime = DateTime.Now; extModel.UpdateTime = DateTime.Now;
extModel.Status = Common.Enum.DateStateEnum.Normal; extModel.Status = Common.Enum.DateStateEnum.Normal;
bool flag = customerModule.SetCustomerCategoryModule(extModel); bool flag = customerModule.SetCustomerCategoryModule(extModel);
if (flag && CategoryId <= 0)
{
var customerModel = new RB_Customer_Extend()
{
CustomerId = 0,
CustomerName = linkMan,
ContactNumber = linkTel,
Fax = "",
QQ = "",
Email = "",
Address = "",
Sex = 1,
Image = "",
CustomerSourceType = (int)extModel.CatetoryType,
CustomerSource = extModel.CategoryName,
CountryId = 0,
ProvinceId = 0,
CityId = 0,
DistrictId = 0,
LngLat = "",
Account = linkTel,
Remark = "",
EnterpriseName = "",
CustomerType = extModel.CatetoryType,
WeChatNo = "",
CategoryId= extModel.CategoryId,
};
if (string.IsNullOrEmpty(customerModel.CustomerName))
{
return ApiResult.ParamIsNull(message: "请填写客户名称!");
}
if (string.IsNullOrEmpty(customerModel.ContactNumber) && string.IsNullOrEmpty(customerModel.QQ) && string.IsNullOrEmpty(customerModel.WeChatNo))
{
return ApiResult.Failed("手机号码、QQ号码、微信号码至少填写一项!");
}
customerModel.Status = Common.Enum.DateStateEnum.Normal;
customerModel.CreateBy = base.UserInfo.Id;
customerModel.CreateTime = DateTime.Now;
customerModel.UpdateTime = DateTime.Now;
customerModel.Group_Id = base.UserInfo.Group_Id;
customerModel.School_Id = base.UserInfo.School_Id;
customerModel.ApproveState = 1;
customerModel.ApproveId = base.UserInfo.Id;
customerModel.ApproveTime = DateTime.Now;
customerModel.CustomerState = CustomerStateEnum.Normal;
customerModule.SetCustomerModule(customerModel);
}
return flag ? ApiResult.Success() : ApiResult.Failed(); return flag ? ApiResult.Success() : ApiResult.Failed();
} }
...@@ -879,6 +930,7 @@ namespace Edu.WebApi.Controllers.Customer ...@@ -879,6 +930,7 @@ namespace Edu.WebApi.Controllers.Customer
/// 根据编号获取同行 /// 根据编号获取同行
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
[HttpPost]
public ApiResult GetCustomerCategory() public ApiResult GetCustomerCategory()
{ {
var CategoryId = base.ParmJObj.GetInt("CategoryId"); var CategoryId = base.ParmJObj.GetInt("CategoryId");
...@@ -890,6 +942,7 @@ namespace Edu.WebApi.Controllers.Customer ...@@ -890,6 +942,7 @@ namespace Edu.WebApi.Controllers.Customer
/// 根据编号删除同行信息 /// 根据编号删除同行信息
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
[HttpPost]
public ApiResult RemoveCustomerCategory() public ApiResult RemoveCustomerCategory()
{ {
var CategoryId = base.ParmJObj.GetInt("CategoryId"); var CategoryId = base.ParmJObj.GetInt("CategoryId");
...@@ -897,6 +950,16 @@ namespace Edu.WebApi.Controllers.Customer ...@@ -897,6 +950,16 @@ namespace Edu.WebApi.Controllers.Customer
return flag ? ApiResult.Success() : ApiResult.Failed(); return flag ? ApiResult.Success() : ApiResult.Failed();
} }
/// <summary>
/// 获取客户类型列表
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetCatetoryTypeList()
{
var list = Common.Plugin.EnumHelper.EnumToList(typeof(CatetoryTypeEnum));
return ApiResult.Success(data: list);
}
#endregion #endregion
} }
} }
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