276 lines
12 KiB
C#
276 lines
12 KiB
C#
using Microsoft.AspNetCore.Mvc;
|
|
using YLErp.Model.Enum;
|
|
using YLErp.Models.Tag;
|
|
using YLErp.Modules.BasicDataModule;
|
|
using YLErp.Modules.ClientModule;
|
|
using YLErp.Modules.SalesModule;
|
|
using YLErp.Modules.SystemModule;
|
|
using YLErp.Modules.TagModule;
|
|
|
|
namespace YLErp.Web.Controllers
|
|
{
|
|
public class clientApprovalController : BaseController
|
|
{
|
|
public IActionResult Index()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
[MyAuthorize("客户管理-客户审批")]
|
|
public ActionResult openingclientList()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
[MyAuthorize("客户管理-客户审批")]
|
|
public ActionResult editclientList()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
[HttpPost]
|
|
public JsonResult openingclientListQuery(ClientReq req)
|
|
{
|
|
req.CurUserClientIds = CurUser.GetClientIdsByCustomerManager();
|
|
req.OptType = "开户审批";
|
|
req.ApprovalStatus = "审批中";
|
|
if (req.ProcessStatus == "全部" || string.IsNullOrEmpty(req.ProcessStatus))
|
|
{
|
|
req.ProcessStatus = "未开户,已销户";
|
|
}
|
|
|
|
var sList = new ClientQueryService(CurUser).SearchOpeningProcessList(req);
|
|
var salesDic = new Lazy<Dictionary<int, string>>(() =>
|
|
{
|
|
return yldb.salesmen.Select(n => new { n.id, n.Name }).ToDictionary(n => n.id, m => m.Name);
|
|
});
|
|
var DerivativesInvestmentVarietiesDic = new Lazy<Dictionary<int, string>>(() =>
|
|
{
|
|
return ClientDataModel.GetAllDerivativesInvestmentVarieties().Select(n => new { n.Value, n.Text }).ToDictionary(n => int.Parse(n.Value), m => m.Text);
|
|
});
|
|
Dictionary<int, List<TagDto>> clientTagList = null;
|
|
if (sList != null && sList.rows != null && sList.rows.Any())
|
|
{
|
|
using var tagService = new TagService(CurUser);
|
|
clientTagList = tagService.GetTagByClientIds(sList.rows.Select(p => p.id).Distinct().ToList());
|
|
}
|
|
clientTagList ??= new Dictionary<int, List<TagDto>>();
|
|
|
|
var roles = ApprovalGradeDataService.getAllRoles();
|
|
foreach (var x in sList.rows)
|
|
{
|
|
x.TradingInstTypeName = DBModels.Enums.TradingInstTypeUtil.GetDesc(x.TradingInstType);
|
|
if (!string.IsNullOrWhiteSpace(x.DerivativesInvestmentVarieties))
|
|
{
|
|
var tempArray = x.DerivativesInvestmentVarieties.Split(',');
|
|
var DerivativesInvestmentVarietiesNames = new List<string>();
|
|
foreach (var item in tempArray)
|
|
{
|
|
if (int.TryParse(item, out var id) && id > 0
|
|
&& DerivativesInvestmentVarietiesDic.Value.TryGetValue(id, out var name) && !string.IsNullOrWhiteSpace(name))
|
|
{
|
|
DerivativesInvestmentVarietiesNames.Add(name);
|
|
}
|
|
}
|
|
if (DerivativesInvestmentVarietiesNames != null && DerivativesInvestmentVarietiesNames.Any())
|
|
{
|
|
x.DerivativesInvestmentVarieties = string.Join(",", DerivativesInvestmentVarietiesNames);
|
|
}
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(x.Seller))
|
|
{
|
|
var tempArray = x.Seller.Split(',');
|
|
var SalesmenNames = new List<string>();
|
|
foreach (var item in tempArray)
|
|
{
|
|
if (int.TryParse(item, out var id) && id > 0
|
|
&& salesDic.Value.TryGetValue(id, out var name) && !string.IsNullOrWhiteSpace(name))
|
|
{
|
|
SalesmenNames.Add(name);
|
|
}
|
|
}
|
|
if (SalesmenNames != null && SalesmenNames.Any())
|
|
{
|
|
x.Seller = string.Join(",", SalesmenNames);
|
|
}
|
|
}
|
|
x.CustomerNatureName = x.CustomerNature == null ? "" : Enum.Parse(typeof(CustomerNatureEnum), x.CustomerNature.Value.ToString()).ToString();
|
|
if (x.SalesDepartmentId == null)
|
|
{
|
|
x.SalesDepartment = "";
|
|
}
|
|
else
|
|
{
|
|
var department = DepartmentsController.GetDepartmentById(x.SalesDepartmentId.Value);
|
|
x.SalesDepartment = department == null ? "" : department.Name;
|
|
}
|
|
|
|
if (!PS.Config.Is格林大华)
|
|
{
|
|
if (!string.IsNullOrEmpty(x.CustomerManagerId))
|
|
{
|
|
if (x.CustomerManagerId.Contains(","))
|
|
{
|
|
var managerNames = new List<string>();
|
|
var CustomerManagerIds = x.CustomerManagerId.Split(',').ToList();
|
|
CustomerManagerIds.ForEach(a =>
|
|
{
|
|
var manager = UserBLL.GetById(Convert.ToInt32(a));
|
|
if (manager != null)
|
|
{
|
|
managerNames.Add(manager.Name);
|
|
}
|
|
});
|
|
x.CustomerManager = managerNames.Any() ? string.Join(",", managerNames) : string.Empty;
|
|
}
|
|
else
|
|
{
|
|
var manager = UserBLL.GetById(Convert.ToInt32(x.CustomerManagerId));
|
|
x.CustomerManager = manager == null ? "" : manager.Name;
|
|
}
|
|
}
|
|
}
|
|
|
|
x.HasDocuments = new ClientFileService(CurUser).hasDocments(x.id);
|
|
//拼装标签值
|
|
if (clientTagList.ContainsKey(x.id))
|
|
{
|
|
x.Tags = clientTagList[x.id];
|
|
x.OutputTags = TagService.GetOutputTagsStr(x.Tags);
|
|
}
|
|
}
|
|
return Json(sList);
|
|
}
|
|
|
|
[HttpPost]
|
|
public JsonResult editclientListQuery(ClientReq req)
|
|
{
|
|
req.CurUserClientIds = CurUser.GetClientIdsByCustomerManager();
|
|
req.OptType = "提交信息变更审批";
|
|
req.ApprovalStatus = "审批中";
|
|
|
|
req.ValueDate = valuedateBLL.ValueDate;
|
|
req.CheckContactExpired = true;
|
|
req.CurUserClientIds = CurUser.GetClientIdsByCustomerManager();
|
|
var service = new ClientQueryService(CurUser);
|
|
var sList = service.SearchEditclientList(req);
|
|
var appropriatenessAssessors = RoleRight.GetSystemUserByFunction("担任适当性评估人");
|
|
var salesDic = new Lazy<Dictionary<int, string>>(() =>
|
|
{
|
|
return yldb.salesmen.Select(n => new { n.id, n.Name }).ToDictionary(n => n.id, m => m.Name);
|
|
});
|
|
Dictionary<int, List<TagDto>> clientTagList = null;
|
|
if (sList != null && sList.rows != null && sList.rows.Any())
|
|
{
|
|
using var tagService = new TagService(CurUser);
|
|
clientTagList = tagService.GetTagByClientIds(sList.rows.Select(p => p.id).Distinct().ToList());
|
|
}
|
|
clientTagList ??= new Dictionary<int, List<TagDto>>();
|
|
|
|
var roles = ApprovalGradeDataService.getAllRoles();
|
|
|
|
foreach (var x in sList.rows)
|
|
{
|
|
if (AppHelper.UseFutureVersion("销售提成", "V2"))
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(x.Seller))
|
|
{
|
|
var tempArray = x.Seller.Split(',');
|
|
var SalesmenNames = new List<string>();
|
|
foreach (var item in tempArray)
|
|
{
|
|
if (int.TryParse(item, out var id) && id > 0
|
|
&& salesDic.Value.TryGetValue(id, out var name) && !string.IsNullOrWhiteSpace(name))
|
|
{
|
|
SalesmenNames.Add(name);
|
|
}
|
|
}
|
|
if (SalesmenNames != null && SalesmenNames.Any())
|
|
{
|
|
x.Seller = string.Join(",", SalesmenNames);
|
|
}
|
|
}
|
|
}
|
|
else if (!string.IsNullOrEmpty(x.Seller))
|
|
{
|
|
var tempArray = new List<int>();
|
|
if (x.Seller.Contains(","))
|
|
{
|
|
tempArray = x.Seller.Split(',').Select(a => Convert.ToInt32(a)).ToList();
|
|
}
|
|
else
|
|
{
|
|
if (int.TryParse(x.Seller, out var a))
|
|
{
|
|
tempArray.Add(Convert.ToInt32(x.Seller));
|
|
|
|
}
|
|
}
|
|
if (tempArray.Any())
|
|
{
|
|
var salesmanNames = new SalesmenDataService(CurUser).GetSalesNamesByIds(tempArray).Select(o => o.Name);
|
|
if (salesmanNames.Any())
|
|
{
|
|
x.Seller = string.Join(",", salesmanNames);
|
|
}
|
|
}
|
|
|
|
}
|
|
if (x.SalesDepartmentId == null)
|
|
{
|
|
x.SalesDepartment = "";
|
|
}
|
|
else
|
|
{
|
|
var department = DepartmentsController.GetDepartmentById(x.SalesDepartmentId.Value);
|
|
x.SalesDepartment = department == null ? "" : department.Name;
|
|
}
|
|
|
|
x.AppropriatenessAssessorName = appropriatenessAssessors.Where(y => y.Id == x.AppropriatenessAssessor).FirstOrDefault() == null ? "" : appropriatenessAssessors.Where(y => y.Id == x.AppropriatenessAssessor).FirstOrDefault().Name;
|
|
|
|
if (!PS.Config.Is格林大华)
|
|
{
|
|
if (!string.IsNullOrEmpty(x.CustomerManagerId))
|
|
{
|
|
if (x.CustomerManagerId.Contains(","))
|
|
{
|
|
var managerNames = new List<string>();
|
|
var CustomerManagerIds = x.CustomerManagerId.Split(',').ToList();
|
|
CustomerManagerIds.ForEach(a =>
|
|
{
|
|
var manager = UserBLL.GetById(Convert.ToInt32(a));
|
|
if (manager != null)
|
|
{
|
|
managerNames.Add(manager.Name);
|
|
}
|
|
});
|
|
x.CustomerManager = managerNames.Any() ? string.Join(",", managerNames) : string.Empty;
|
|
}
|
|
else
|
|
{
|
|
var manager = UserBLL.GetById(Convert.ToInt32(x.CustomerManagerId));
|
|
x.CustomerManager = manager == null ? "" : manager.Name;
|
|
}
|
|
}
|
|
}
|
|
|
|
var deadLine = ClientLinqExtendService.GetEvaluateDate(x.EvaluateDate, x.EvaluateOfValidity);
|
|
x.AssessmentExpired = deadLine.Date <= DateTime.Now.Date;
|
|
x.AssessmentExpiredWithinThreeDays = deadLine > DateTime.Now.Date && deadLine.Date <= DateTime.Now.Date.AddDays(30).Date;
|
|
x.AssessmentExpiredDate = deadLine.ToString("yyyy-MM-dd");
|
|
x.HasDocuments = new ClientFileService(CurUser).hasDocments(x.id);
|
|
|
|
//拼装标签值
|
|
if (clientTagList.ContainsKey(x.id))
|
|
{
|
|
x.Tags = clientTagList[x.id];
|
|
x.OutputTags = TagService.GetOutputTagsStr(x.Tags);
|
|
}
|
|
}
|
|
return Json(sList);
|
|
}
|
|
|
|
}
|
|
}
|