diff --git a/Framework/YLErp.Core/DBModels/Client.cs b/Framework/YLErp.Core/DBModels/Client.cs index 57c2d947..d55ae7f2 100644 --- a/Framework/YLErp.Core/DBModels/Client.cs +++ b/Framework/YLErp.Core/DBModels/Client.cs @@ -1216,6 +1216,13 @@ namespace YLErp.DBModels [DataChange] public string ManagerAbbreviation { get; set; } + + /// + /// 是否不再预警(0:预警,1:不预警) + /// + [DisplayName("是否不再预警")] + public bool? isWarning { get; set; } + } [NotMapped] diff --git a/Framework/YLErp.Core/DBModels/Enums/DerivativesInvestmentVarietiesEnum.cs b/Framework/YLErp.Core/DBModels/Enums/DerivativesInvestmentVarietiesEnum.cs index f2f425e3..cc86bc7c 100644 --- a/Framework/YLErp.Core/DBModels/Enums/DerivativesInvestmentVarietiesEnum.cs +++ b/Framework/YLErp.Core/DBModels/Enums/DerivativesInvestmentVarietiesEnum.cs @@ -2,9 +2,6 @@ { public enum DerivativesInvestmentVarietiesEnum { - 场外期权 = 1, - 场外互换 = 2, - 远期 = 3, - 其他 = 4 + 场外互换 = 2 } } diff --git a/Framework/YLErp.Core/DBModels/clientduty.cs b/Framework/YLErp.Core/DBModels/clientduty.cs index 6c198509..608639e4 100644 --- a/Framework/YLErp.Core/DBModels/clientduty.cs +++ b/Framework/YLErp.Core/DBModels/clientduty.cs @@ -184,6 +184,9 @@ namespace YLErp.DBModels /// 来源id主要用于编辑审批 /// public int? SourceId { get; set; } + [DisplayName("证件有效期")] + [DataChange] + public string AuthorizeEffectiveEndDateStr { get; set; } [NotMapped] public DateTime? IdCardEffectiveDate @@ -204,7 +207,25 @@ namespace YLErp.DBModels } set { value = this.IdCardEffectiveDate; } } - + [NotMapped] + public DateTime? AuthorizeEffectiveEndDate + { + get + { + DateTime date = new DateTime(); + if (!string.IsNullOrWhiteSpace(AuthorizeEffectiveEndDateStr) + && ( + DateTime.TryParseExact(AuthorizeEffectiveEndDateStr, "yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.AdjustToUniversal, out date) + || DateTime.TryParseExact(AuthorizeEffectiveEndDateStr, "yyyy/MM/dd", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.AdjustToUniversal, out date) + || DateTime.TryParse(AuthorizeEffectiveEndDateStr, out date)) + ) + { + return date; + } + return null; + } + set { value = this.AuthorizeEffectiveEndDate; } + } public string GetDataTraceKeyInfo() { return "客户联系人:" + ContactName; diff --git a/YLErpDAL/Modules/ClientModule/ClientWarningService.cs b/YLErpDAL/Modules/ClientModule/ClientWarningService.cs new file mode 100644 index 00000000..daa11163 --- /dev/null +++ b/YLErpDAL/Modules/ClientModule/ClientWarningService.cs @@ -0,0 +1,261 @@ +using MoreLinq; +using YLErp.BLL; + +namespace YLErp.Modules.ClientModule +{ + /// + /// 山证金衍 客户预警 + /// + public class ClientWarningService : ClientBaseService + { + public ClientWarningService(OptUserInfo userInfo) : base(userInfo) + { + + } + + public ClientWarningService(ClientBaseService baseService) : base(baseService) + { + } + + public string CheckedClient() + { + var query = DbContext.client.Where(x => x.ProcessStatus == "已开户" && x.isWarning != true); + + var clientdutys = (from duty in DbContext.clientduty.Where(x => x.ApprovalOrder < 1) + join client in query on duty.ClientId equals client.id + select duty).ToList(); + + var clients = query.ToList(); + + var expireDate = valuedateBLL.ValueDate; + var dueDate = valuedateBLL.ValueDate.AddMonths(3); + + if (clients.Where(x => x.LicenseValidTime < expireDate || x.EvaluateExpireDate < expireDate).Any() || clientdutys.Where(x => x.IdCardEffectiveDate < expireDate || x.AuthorizeEffectiveEndDate < expireDate).Any()) + { + return "已到期"; + } + else if (clients.Where(x => x.LicenseValidTime <= dueDate || x.EvaluateExpireDate <= dueDate).Any() || clientdutys.Where(x => x.IdCardEffectiveDate <= dueDate || x.AuthorizeEffectiveEndDate <= dueDate).Any()) + { + return "即将到期"; + } + else + { + return "无异常"; + } + } + + public List GetExpiresWarning(ExpireWarningReq req) + { + var list = new List(); + + var dueDate = valuedateBLL.ValueDate.AddMonths(3); + + var query1 = DbContext.client.Where(x => x.ProcessStatus == "已开户"); + if (!string.IsNullOrWhiteSpace(req.Number)) + { + query1 = query1.Where(x => x.Number.Contains(req.Number)); + } + if (!string.IsNullOrWhiteSpace(req.Name)) + { + query1 = query1.Where(x => x.Name.Contains(req.Name)); + } + + var query2 = from duty in DbContext.clientduty.Where(x => x.ApprovalOrder < 1) + join client in query1 on duty.ClientId equals client.id + select duty; + + var clients = query1.ToList(); + var clientdutys = query2.ToList(); + + var ids1 = clients.Where(x => x.LicenseValidTime <= dueDate || x.EvaluateExpireDate <= dueDate).Select(x => x.id).ToList(); + var ids2 = clientdutys.Where(x => x.IdCardEffectiveDate <= dueDate || x.AuthorizeEffectiveEndDate <= dueDate).Select(x => x.ClientId??0).ToList(); + ids1.AddRange(ids2); + var ids= ids1.Distinct().ToList(); + clients = clients.Where(x => ids.Contains(x.id)).ToList(); + + var datelast = new DateTime(3000, 12, 31); + + foreach (var c in clients) + { + var e = new ExpireWarning + { + LicenseValidTime = c.LicenseValidTime + }; + e.LicenseValidTimeStr = e.LicenseValidTime == datelast ? "长期有效" : e.LicenseValidTime?.ToString("yyyy-MM-dd"); + e.EvaluateExpireDate = c.EvaluateExpireDate; + e.EvaluateExpireDateStr = e.EvaluateExpireDate == datelast ? "长期有效" : e.EvaluateExpireDate?.ToString("yyyy-MM-dd"); + var dutys = clientdutys.Where(x => x.ClientId == c.id); + if (dutys.Any()) + { + e.IdCardEffectiveDate = dutys.Where(x => x.IdCardEffectiveDate != null).OrderBy(x => x.IdCardEffectiveDate).FirstOrDefault()?.IdCardEffectiveDate; + e.IdCardEffectiveDateStr = e.IdCardEffectiveDate == datelast ? "长期有效" : e.IdCardEffectiveDate?.ToString("yyyy-MM-dd"); + e.AuthorizeEffectiveEndDate = dutys.Where(x => x.AuthorizeEffectiveEndDate != null).OrderBy(x => x.AuthorizeEffectiveEndDate).FirstOrDefault()?.AuthorizeEffectiveEndDate; + e.AuthorizeEffectiveEndDateStr = e.AuthorizeEffectiveEndDate == datelast ? "长期有效" : e.AuthorizeEffectiveEndDate?.ToString("yyyy-MM-dd"); + } + e.EvaluateDate = c.EvaluateDate; + e.EvaluateDateStr = e.EvaluateDate?.ToString("yyyy-MM-dd"); + e.isWarning = c.isWarning ?? false; + e.id = c.id; + e.EncryptId = c.EncryptId; + e.Number = c.Number; + e.Name = c.Name; + list.Add(e); + } + + if (ids.Any()) + { + if (req.StartExpireDate != null && req.EndExpireDate != null) + { + list = list.Where(x => (x.LicenseValidTime >= req.StartExpireDate && x.LicenseValidTime <= req.EndExpireDate) || (x.EvaluateExpireDate >= req.StartExpireDate && x.EvaluateExpireDate <= req.EndExpireDate) || (x.IdCardEffectiveDate >= req.StartExpireDate && x.IdCardEffectiveDate <= req.EndExpireDate) || (x.AuthorizeEffectiveEndDate >= req.StartExpireDate && x.AuthorizeEffectiveEndDate <= req.EndExpireDate)).ToList(); + } + else + { + if (req.StartExpireDate != null) + { + list = list.Where(x => x.LicenseValidTime >= req.StartExpireDate || x.EvaluateExpireDate >= req.StartExpireDate || x.IdCardEffectiveDate >= req.StartExpireDate || x.AuthorizeEffectiveEndDate >= req.StartExpireDate).ToList(); + } + if (req.EndExpireDate != null) + { + list = list.Where(x => x.LicenseValidTime <= req.EndExpireDate || x.EvaluateExpireDate <= req.EndExpireDate || x.IdCardEffectiveDate <= req.EndExpireDate || x.AuthorizeEffectiveEndDate <= req.EndExpireDate).ToList(); + } + } + } + + return list; + } + + public void UpdateWarning(int id) + { + var client = DbContext.client.Find(id); + if (client != null) + { + client.isWarning = client.isWarning != true; + _ = DbContext.SaveChanges(); + } + } + + public ExpireWarningStatus GetExpireStatus() + { + var expires = GetExpiresWarning(new ExpireWarningReq()); + var ret = new ExpireWarningStatus + { + status = "无异常", + isExpire = 0, + isDue = 0, + isExpire_all = 0, + isDue_all = 0 + }; + + if (expires.Count() > 0) + { + var expirelist = expires.Where(x => x.LicenseValidTime < ret.ExpireDate || x.EvaluateExpireDate < ret.ExpireDate || x.IdCardEffectiveDate < ret.ExpireDate || x.AuthorizeEffectiveEndDate < ret.ExpireDate).ToList(); + var duelist = expires; + if (expirelist.Count() > 0) + { + var expireids = expirelist.Select(x => x.id).ToList(); + duelist = duelist.Where(x => !expireids.Contains(x.id)).ToList(); + ret.status = "已到期"; + ret.isExpire_all = expirelist.Count(); + if (expirelist.Where(x => x.isWarning == true).Count() > 0) + { + ret.isExpire = expirelist.Where(x => x.isWarning != true).Count(); + } + else + { + ret.isExpire = ret.isExpire_all; + } + } + if (duelist.Count() > 0) + { + ret.status = ret.status == "已到期" ? "已到期" : "即将到期"; + ret.isDue_all = duelist.Count(); + if (duelist.Where(x => x.isWarning == true).Count() > 0) + { + ret.isDue = duelist.Where(x => x.isWarning != true).Count(); + } + else + { + ret.isDue = ret.isDue_all; + } + } + } + return ret; + } + } + + public class ExpireWarning + { + public int id { get; set; } + + /// + /// 加密主键 + /// + public string? EncryptId { get; set; } + + public string? Number { get; set; } + + public string? Name { get; set; } + + public DateTime? LicenseValidTime { get; set; } + + public string? LicenseValidTimeStr { get; set; } + + public DateTime? EvaluateDate { get; set; } + + public string? EvaluateDateStr { get; set; } + + public DateTime? EvaluateExpireDate { get; set; } + + public string? EvaluateExpireDateStr { get; set; } + + public DateTime? IdCardEffectiveDate { get; set; } + + public string? IdCardEffectiveDateStr { get; set; } + + public DateTime? AuthorizeEffectiveEndDate { get; set; } + + public string? AuthorizeEffectiveEndDateStr { get; set; } + + public bool isWarning { get; set; } + } + + public class ExpireWarningReq + { + public string? Number { get; set; } + + public string? Name { get; set; } + + public DateTime? StartExpireDate { get; set; } + + public DateTime? EndExpireDate { get; set; } + } + + public class ExpireWarningStatus + { + public DateTime ExpireDate + { + get + { + return valuedateBLL.ValueDate; + } + } + + public DateTime DueDate + { + get + { + return valuedateBLL.ValueDate.AddMonths(3); + } + } + + public string? status { get; set; } + + public int? isExpire { get; set; } + + public int? isDue { get; set; } + + public int? isExpire_all { get; set; } + + public int? isDue_all { get; set; } + } +} diff --git a/YLErpDAL/Modules/SwapModule/SwapDealService.cs b/YLErpDAL/Modules/SwapModule/SwapDealService.cs index 544f2716..9e30f482 100644 --- a/YLErpDAL/Modules/SwapModule/SwapDealService.cs +++ b/YLErpDAL/Modules/SwapModule/SwapDealService.cs @@ -820,7 +820,7 @@ namespace YLErp.Modules.SwapModule unwindData.AnnualDays = tradeExtend == null ? 365 : tradeExtend.ExtendObj.AnnualDays; unwindData.CloseMethod = unwindQty == unwindData.PositionQty ? (int)CloseMethodEnum.全部平仓 : (int)CloseMethodEnum.部分平仓; unwindData.ClosePercent = unwindData.PositionQty == 0 ? 0 : unwindPercent; - unwindData.CloseNotionalValue = unwindData.PosiNotionalValue; + unwindData.CloseNotionalValue = unwindData.PosiNotionalValue* unwindPercent; unwindData.CloseQty = unwindQty; if (position != null) { @@ -850,7 +850,7 @@ namespace YLErp.Modules.SwapModule floatEvent.TradingFeePending = position.PosiTradingFeePending * unwindData.ClosePercent; var mergeClosePercent = mergeQty == 0 ? 0 : unwindQty / mergeQty; floatEvent.TradingFee = penddingFee * mergeClosePercent; - floatEvent.MarkClosePnl = (unwindPriceFee - position.PosiNetPrice) * unwindData.PosiNotionalValue * floatRatio * longRatio; + floatEvent.MarkClosePnl = (unwindPriceFee - position.PosiNetPrice) * unwindQty * floatRatio * longRatio; floatEvent.MarkClosePnl = decimal.Parse(floatEvent.MarkClosePnl.ToString("0.00")); floatEvent.TradingAmount = floatEvent.Quantity * floatEvent.ContractSize; floatEvent.OptLog = "流水自动"; @@ -858,7 +858,7 @@ namespace YLErp.Modules.SwapModule floatEvent.SetOpt(UserInfo); } unwindData.FlowEvents.Add(floatEvent); - var interestPositions = GetUnwindInterests(unwindData.ValueDate, unwindData.UnwindDate.Value, td.id, 1, (int)SwapEventTypeEnum.平仓); + var interestPositions = GetUnwindInterests(unwindData.ValueDate, unwindData.UnwindDate.Value, td.id, unwindPercent, (int)SwapEventTypeEnum.平仓); interestPositions.ForEach(item => { item.OptLog = "流水自动"; diff --git a/YLErpDAL/Modules/SystemModule/ClientDataModel.cs b/YLErpDAL/Modules/SystemModule/ClientDataModel.cs index 0f8ce8f4..0d00ea90 100644 --- a/YLErpDAL/Modules/SystemModule/ClientDataModel.cs +++ b/YLErpDAL/Modules/SystemModule/ClientDataModel.cs @@ -745,25 +745,10 @@ namespace YLErp.Modules.SystemModule public static List GetAllDerivativesInvestmentVarieties() { return new List { - new SelectItem - { - Text = DerivativesInvestmentVarietiesEnum.场外期权.ToString(), - Value = ((int)DerivativesInvestmentVarietiesEnum.场外期权).ToString() - }, new SelectItem { Text = DerivativesInvestmentVarietiesEnum.场外互换.ToString(), Value = ((int)DerivativesInvestmentVarietiesEnum.场外互换).ToString() - }, - new SelectItem - { - Text = DerivativesInvestmentVarietiesEnum.远期.ToString(), - Value = ((int)DerivativesInvestmentVarietiesEnum.远期).ToString() - }, - new SelectItem - { - Text = DerivativesInvestmentVarietiesEnum.其他.ToString(), - Value = ((int)DerivativesInvestmentVarietiesEnum.其他).ToString() } }; } @@ -1532,11 +1517,6 @@ namespace YLErp.Modules.SystemModule public static List GetAllDerivativesInvestmentVarietiesForCredit() { return new List { - new SelectItem - { - Text = DerivativesInvestmentVarietiesEnum.场外期权.ToString(), - Value = ((int)DerivativesInvestmentVarietiesEnum.场外期权).ToString() - }, new SelectItem { Text = DerivativesInvestmentVarietiesEnum.场外互换.ToString(), diff --git a/YLErpWeb/Controllers/clientController.cs b/YLErpWeb/Controllers/clientController.cs index 3eeeaebb..e000a5cb 100644 --- a/YLErpWeb/Controllers/clientController.cs +++ b/YLErpWeb/Controllers/clientController.cs @@ -95,7 +95,40 @@ namespace YLErp.Web.Controllers return View(); } + [MyAuthorize("客户管理-客户查看")] + public ActionResult ClientExpireWarningList() + { + return View(); + } + [MyAuthorize("客户管理-客户查看")] + public JsonResult ClientExpireWarningListJson(ExpireWarningReq req) + { + var sList = new ClientWarningService(CurUser).GetExpiresWarning(req); + return Json(sList); + } + + [MyAuthorize("客户管理-客户查看")] + public JsonResult CheckedClientWarning() + { + var expireWarningStatus = new ClientWarningService(CurUser).CheckedClient(); + return Json(expireWarningStatus); + } + + [MyAuthorize("客户管理-客户查看")] + public JsonResult ClientExpireWarningUpdate(string enid) + { + var intid = DataProtectHelper.DecryptInt(enid); + new ClientWarningService(CurUser).UpdateWarning(intid); + return JsonSuccess(""); + } + + [MyAuthorize("客户管理-客户查看")] + public JsonResult ClientExpireWarningStatusJson(string enid) + { + var expireWarningStatus = new ClientWarningService(CurUser).GetExpireStatus(); + return Json(expireWarningStatus); + } /// /// 导出客户人员信息 diff --git a/YLErpWeb/Views/client/ClientExpireWarningList.cshtml b/YLErpWeb/Views/client/ClientExpireWarningList.cshtml new file mode 100644 index 00000000..39f27c27 --- /dev/null +++ b/YLErpWeb/Views/client/ClientExpireWarningList.cshtml @@ -0,0 +1,37 @@ +@model List +@{ + ViewBag.Title = "客户信息"; + Layout = "~/Views/Shared/_InfoLayout.cshtml"; + var pageObj = new + { + ExpireDate = valuedateBLL.ValueDate, + DueDate = valuedateBLL.ValueDate.AddMonths(3), + }; +} +@section CSS{ + +} +@section JS{ + + + + + +} + + +
+
+
+ 筛选条件: + @Html.ShortInput("Number", "客户编号") + @Html.ShortInput("Name", "客户名称") + @Html.SearchDateRange("ExpireDate", "到期日期") + @MyControls.SearchBtn() +
+ @Html.Raw(JqGridSimple.OutTable()) + diff --git a/YLErpWeb/Views/client/ClientListV2.cshtml b/YLErpWeb/Views/client/ClientListV2.cshtml index 2b4a5451..e454a2d2 100644 --- a/YLErpWeb/Views/client/ClientListV2.cshtml +++ b/YLErpWeb/Views/client/ClientListV2.cshtml @@ -55,7 +55,10 @@ } - +
+ 到期预警   + +
@Html.ShortInput("Name", "客户名称") diff --git a/YLErpWeb/Views/client/_ClientDutyEdit.cshtml b/YLErpWeb/Views/client/_ClientDutyEdit.cshtml index fec453ac..24a87c24 100644 --- a/YLErpWeb/Views/client/_ClientDutyEdit.cshtml +++ b/YLErpWeb/Views/client/_ClientDutyEdit.cshtml @@ -83,6 +83,16 @@
+
+
+ + + +
+
+ +
+