Commit 596ec1fd authored by liudong1993's avatar liudong1993

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

parents 58da0003 b381c550
using Edu.Common.Plugin;
namespace Edu.Common.Enum.Customer
{
/// <summary>
/// 同行分类枚举
/// </summary>
public enum CatetoryTypeEnum
{
/// <summary>
/// 企业
/// </summary>
[EnumField("企业")]
Company = 1,
/// <summary>
/// 学校
/// </summary>
[EnumField("学校")]
School = 2,
/// <summary>
/// 个人
/// </summary>
[EnumField("个人")]
Personal = 3,
/// <summary>
/// 其他
/// </summary>
[EnumField("其他")]
Other = 4,
}
}
......@@ -6,7 +6,7 @@ using VT.FW.DB;
namespace Edu.Model.Entity.Customer
{
/// <summary>
/// 同业客户管理实体类
/// 同业联系人实体类
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
......
using Edu.Common.Enum;
using Edu.Common.Enum.Customer;
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_Category
{
/// <summary>
/// 主键编号
/// </summary>
public int CategoryId { get; set; }
/// <summary>
/// 客户类型
/// </summary>
public CatetoryTypeEnum CatetoryType { get; set; }
/// <summary>
/// 客户名称
/// </summary>
public string CategoryName { 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; }
}
}
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_Category_Extend : RB_Customer_Category
{
}
}
......@@ -21,7 +21,7 @@ namespace Edu.Module.Customer
public class CustomerModule
{
/// <summary>
/// 同业客户管理仓储层对象
/// 同业客户联系人管理仓储层对象
/// </summary>
private readonly RB_CustomerRepository customerRepository = new RB_CustomerRepository();
/// <summary>
......@@ -51,6 +51,11 @@ namespace Edu.Module.Customer
/// </summary>
private readonly RB_EnterpriseRepository enterpriseRepository = new RB_EnterpriseRepository();
/// <summary>
/// 客户仓储层对象
/// </summary>
private readonly RB_Customer_CategoryRepository customer_CategoryRepository = new RB_Customer_CategoryRepository();
/// <summary>
/// 获取客户分页列表..
......@@ -101,10 +106,10 @@ namespace Edu.Module.Customer
{nameof(RB_Customer_Extend.WeChatNo),model.WeChatNo },
};
flag = customerRepository.Update(fileds, new WhereHelper(nameof(RB_Customer_Extend.CustomerId), model.CustomerId));
if (flag)
if (flag)
{
#region 操作记录
string LogContent = "后台修改同业信息:";
string LogContent = "后台修改同业信息:";
if (oldModel.CustomerName != model.CustomerName)
{
LogContent += "名称由'" + oldModel.CustomerName + "'修改为'" + model.CustomerName + "';";
......@@ -125,7 +130,7 @@ namespace Edu.Module.Customer
{
LogContent += "邮箱由'" + oldModel.Email + "'修改为'" + model.Email + "';";
}
if (oldModel.Address != model.Address)
{
LogContent += "地址由'" + oldModel.Address + "'修改为'" + model.Address + "';";
......@@ -167,11 +172,12 @@ namespace Edu.Module.Customer
model.ApproveState = 1;
model.ApproveId = 1;
model.ApproveTime = DateTime.Now;
model.Password = Common.DES.Encrypt(Common.Config.DefaultPwd);
model.Password = Common.DES.Encrypt(Common.Config.DefaultPwd);
var newId = customerRepository.Insert(model);
model.CustomerId = newId;
flag = newId > 0;
if (flag) {
if (flag)
{
//记录操作日志
changeLogRepository.Insert(new Model.Entity.Log.RB_User_ChangeLog()
{
......@@ -254,14 +260,16 @@ namespace Edu.Module.Customer
public List<RB_Customer_Extend> GetCustomerPageModule_V2(int pageIndex, int pageSize, out long rowsCount, RB_Customer_Extend query)
{
var list = customerRepository.GetCustomerPageRepository(pageIndex, pageSize, out rowsCount, query);
if (list.Any()) {
if (list.Any())
{
string customerIds = string.Join(",", list.Select(x => x.CustomerId));
//查询客户数量
var StuNumList = customerRepository.GetCustomerStuNum(customerIds, query.Group_Id);
//查询订单数量 及 交易额
var OrderNumList = customerRepository.GetCustomerOrderNum(customerIds, query.Group_Id);
foreach (var item in list) {
foreach (var item in list)
{
var stuModel = StuNumList.Where(x => x.CustomerId == item.CustomerId).FirstOrDefault();
var orderModel = OrderNumList.Where(x => x.CustomerId == item.CustomerId).FirstOrDefault();
item.StuNum = stuModel?.StuNum ?? 0;
......@@ -286,7 +294,8 @@ namespace Edu.Module.Customer
decimal NotSettlementMoney = customer_BalanceDetailRepository.GetMyNoSettlementCommission(customerId, type, group_Id);
decimal TotalMoney = cmodel.TotalCommission;
decimal SurplusMoney = cmodel.CommissionWithdrawal;
if (type == 2) {
if (type == 2)
{
//幸福存折
TotalMoney = cmodel.Client_Balance + RemitMoney;
SurplusMoney = cmodel.Client_Balance;
......@@ -310,14 +319,17 @@ namespace Edu.Module.Customer
/// <returns></returns>
public string SetCustomerCareOf(string customerIds, int empId, UserInfo userInfo)
{
var clist = customerRepository.GetCustomerListRepository(new RB_Customer_Extend() { Group_Id = userInfo.Group_Id, CustomerIds = customerIds });
foreach (var item in clist) {
if (item.CreateBy == empId) {
var clist = customerRepository.GetCustomerListRepository(new RB_Customer_Extend() { Group_Id = userInfo.Group_Id, CustomerIds = customerIds });
foreach (var item in clist)
{
if (item.CreateBy == empId)
{
return item.CustomerName + "的原跟进人员与接收人相同,无法转交";
}
}
var empName = UserReidsCache.GetUserLoginInfo(empId)?.AccountName ?? "";
foreach (var item in clist) {
foreach (var item in clist)
{
Dictionary<string, object> keyValues = new Dictionary<string, object>() {
{ nameof(RB_Customer_Extend.CreateBy), empId},
{ nameof(RB_Customer_Extend.UpdateTime), DateTime.Now},
......@@ -346,7 +358,8 @@ namespace Edu.Module.Customer
SourceId = item.CustomerId
});
}
else {
else
{
return item.CustomerName + "转交失败,请联系管理员";
}
}
......@@ -469,5 +482,86 @@ namespace Edu.Module.Customer
bool flag = enterpriseRepository.Update(fileds, new WhereHelper(nameof(RB_Enterprise_Extend.Id), Id));
return flag;
}
#region Category
/// <summary>
/// 获取同行分页列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="rowsCount"></param>
/// <param name="query"></param>
/// <returns></returns>
public List<RB_Customer_Category_Extend> GetCustomerCategoryPageModule(int pageIndex, int pageSize, out long rowsCount, RB_Customer_Category_Extend query)
{
var list = customer_CategoryRepository.GetCustomerCategoryPageRepository(pageIndex, pageSize, out rowsCount, query);
return list;
}
/// <summary>
/// 获取同行列表
/// </summary>
/// <returns></returns>
public List<RB_Customer_Category_Extend> GetCustomerCategoryListModule(RB_Customer_Category_Extend query)
{
var list = customer_CategoryRepository.GetCustomerCategoryListRepository(query);
return list;
}
/// <summary>
/// 新增修改同行
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public bool SetCustomerCategoryModule(RB_Customer_Category_Extend model)
{
bool flag = false;
if (model.CategoryId > 0)
{
Dictionary<string, object> fileds = new Dictionary<string, object>()
{
{ nameof(RB_Customer_Category_Extend.CategoryName),model.CategoryName},
{ nameof(RB_Customer_Category_Extend.CatetoryType),model.CatetoryType},
{ nameof(RB_Customer_Category_Extend.UpdateBy),model.UpdateBy},
{ nameof(RB_Customer_Category_Extend.UpdateTime),model.UpdateTime},
};
flag = customer_CategoryRepository.Update(fileds, new WhereHelper(nameof(RB_Customer_Category_Extend.CategoryId), model.CategoryId));
}
else
{
var newId = customer_CategoryRepository.Insert(model);
model.CategoryId = newId;
flag = newId > 0;
}
return flag;
}
/// <summary>
/// 根据编号获取同行信息
/// </summary>
/// <param name="CategoryId"></param>
/// <returns></returns>
public RB_Customer_Category_Extend GetCustomerCategoryModule(object CategoryId)
{
var extModel = customer_CategoryRepository.GetEntity<RB_Customer_Category_Extend>(CategoryId);
return extModel;
}
/// <summary>
/// 删除同行
/// </summary>
/// <param name="CategoryId"></param>
/// <returns></returns>
public bool RemoveCustomerCategoryModule(object CategoryId)
{
Dictionary<string, object> fileds = new Dictionary<string, object>()
{
{nameof(RB_Customer_Category_Extend.Status),(int)DateStateEnum.Delete }
};
bool flag = customer_CategoryRepository.Update(fileds, new WhereHelper(nameof(RB_Customer_Category_Extend.CategoryId), CategoryId));
return flag;
}
#endregion
}
}
......@@ -11,7 +11,7 @@ using VT.FW.DB.Dapper;
namespace Edu.Repository.Customer
{
/// <summary>
/// 同业客户管理仓储层
/// 同业客户联系人管理仓储层
/// </summary>
public class RB_CustomerRepository : BaseRepository<RB_Customer>
{
......
using Edu.Common.Enum;
using Edu.Model.Entity.Customer;
using Edu.Model.ViewModel.Customer;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using VT.FW.DB.Dapper;
namespace Edu.Repository.Customer
{
/// <summary>
/// 同行管理仓储层
/// </summary>
public class RB_Customer_CategoryRepository : BaseRepository<RB_Customer_Category>
{
/// <summary>
/// 获取同行分页列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="rowsCount"></param>
/// <param name="query"></param>
/// <returns></returns>
public List<RB_Customer_Category_Extend> GetCustomerCategoryPageRepository(int pageIndex, int pageSize, out long rowsCount, RB_Customer_Category_Extend query)
{
var parameters = new DynamicParameters();
StringBuilder builder = new StringBuilder();
builder.AppendFormat(@"
SELECT A.*
FROM RB_Customer_Category AS A
WHERE 1=1
");
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Customer_Category_Extend.Status), (int)DateStateEnum.Normal);
if (query != null)
{
if (query.Group_Id > 0)
{
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Customer_Category_Extend.Group_Id), query.Group_Id);
}
if (!string.IsNullOrEmpty(query.CategoryName))
{
builder.AppendFormat(" AND A.{0} LIKE @CategoryName ", nameof(RB_Customer_Category_Extend.CategoryName));
parameters.Add("CategoryName", "%" + query.CategoryName.Trim() + "%");
}
if (query.CatetoryType > 0)
{
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Customer_Category_Extend.CatetoryType), (int)query.CatetoryType);
}
}
builder.AppendFormat(" ORDER BY A.{0} DESC ", nameof(RB_Customer_Category_Extend.CategoryId));
return GetPage<RB_Customer_Category_Extend>(pageIndex, pageSize, out rowsCount, builder.ToString(), parameters).ToList();
}
/// <summary>
/// 获取同行列表
/// </summary>
/// <returns></returns>
public List<RB_Customer_Category_Extend> GetCustomerCategoryListRepository(RB_Customer_Category_Extend query)
{
var parameters = new DynamicParameters();
StringBuilder builder = new StringBuilder();
builder.AppendFormat(@"
SELECT A.*
FROM RB_Customer_Category AS A
WHERE 1=1
");
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Customer_Category_Extend.Status), (int)DateStateEnum.Normal);
if (query != null)
{
if (query.Group_Id > 0)
{
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Customer_Category_Extend.Group_Id), query.Group_Id);
}
if (!string.IsNullOrEmpty(query.CategoryName))
{
builder.AppendFormat(" AND A.{0} LIKE @CategoryName ", nameof(RB_Customer_Category_Extend.CategoryName));
parameters.Add("CategoryName", "%" + query.CategoryName.Trim() + "%");
}
if (query.CatetoryType > 0)
{
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Customer_Category_Extend.CatetoryType), (int)query.CatetoryType);
}
}
builder.AppendFormat(" ORDER BY A.{0} DESC ", nameof(RB_Customer_Category_Extend.CategoryId));
return Get<RB_Customer_Category_Extend>(builder.ToString(), parameters).ToList();
}
}
}
......@@ -776,5 +776,124 @@ namespace Edu.WebApi.Controllers.Customer
}
#endregion
#region 同行管理
/// <summary>
/// 获取同行分页列表
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetCustomerCategoryPage()
{
var userInfo = base.UserInfo;
var pageModel = JsonHelper.DeserializeObject<ResultPageModel>(RequestParm.Msg.ToString());
var query = new RB_Customer_Category_Extend()
{
Group_Id = base.UserInfo.Group_Id,
CategoryName = base.ParmJObj.GetStringValue("CategoryName"),
CatetoryType=(CatetoryTypeEnum)base.ParmJObj.GetInt("CatetoryType"),
};
query.CreateBy = userInfo.Id;
var list = customerModule.GetCustomerCategoryPageModule(pageModel.PageIndex, pageModel.PageSize, out long rowsCount, query);
List<object> result = new List<object>();
foreach (var item in list)
{
string CreateByName = UserReidsCache.GetUserLoginInfo(item.CreateBy)?.AccountName ?? "";
result.Add(new
{
item.CategoryId,
item.CategoryName,
CreateByName,
item.CatetoryType,
CatetoryTypeName = item.CatetoryType.ToName(),
CreateTime = Common.ConvertHelper.FormatTime(item.CreateTime),
});
}
pageModel.PageData = result;
pageModel.Count = rowsCount;
return ApiResult.Success(data: pageModel);
}
/// <summary>
/// 获取同行列表
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetCustomerCategoryList()
{
var userInfo = base.UserInfo;
var query = new RB_Customer_Category_Extend()
{
Group_Id = base.UserInfo.Group_Id,
CategoryName = base.ParmJObj.GetStringValue("CategoryName"),
CatetoryType = (CatetoryTypeEnum)base.ParmJObj.GetInt("CatetoryType"),
};
query.CreateBy = userInfo.Id;
var list = customerModule.GetCustomerCategoryListModule(query);
List<object> result = new List<object>();
foreach (var item in list)
{
string CreateByName = UserReidsCache.GetUserLoginInfo(item.CreateBy)?.AccountName ?? "";
result.Add(new
{
item.CategoryId,
item.CategoryName,
CreateByName,
item.CatetoryType,
CatetoryTypeName = item.CatetoryType.ToName(),
CreateTime = Common.ConvertHelper.FormatTime(item.CreateTime),
});
}
return ApiResult.Success(data: result);
}
/// <summary>
/// 新增修改同行
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult SetCustomerCategory()
{
var extModel = new RB_Customer_Category_Extend()
{
CategoryId=base.ParmJObj.GetInt("CategoryId"),
CategoryName = base.ParmJObj.GetStringValue("CategoryName"),
CatetoryType = (CatetoryTypeEnum)base.ParmJObj.GetInt("CatetoryType"),
};
extModel.Group_Id = base.UserInfo.Group_Id;
extModel.CreateBy = base.UserInfo.Id;
extModel.UpdateBy = base.UserInfo.Id;
extModel.CreateTime = DateTime.Now;
extModel.UpdateTime = DateTime.Now;
extModel.Status = Common.Enum.DateStateEnum.Normal;
bool flag = customerModule.SetCustomerCategoryModule(extModel);
return flag ? ApiResult.Success() : ApiResult.Failed();
}
/// <summary>
/// 根据编号获取同行
/// </summary>
/// <returns></returns>
public ApiResult GetCustomerCategory()
{
var CategoryId = base.ParmJObj.GetInt("CategoryId");
var extModel = customerModule.GetCustomerCategoryModule(CategoryId);
return ApiResult.Success(data: extModel);
}
/// <summary>
/// 根据编号删除同行信息
/// </summary>
/// <returns></returns>
public ApiResult RemoveCustomerCategory()
{
var CategoryId = base.ParmJObj.GetInt("CategoryId");
bool flag = customerModule.RemoveCustomerCategoryModule(CategoryId);
return flag ? ApiResult.Success() : ApiResult.Failed();
}
#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