using CRM.Core.BLL.Util; using CRM.Core.Common.Layui; using CRM.Core.Model.Entity; using System; using System.Collections.Generic; using System.Linq; using System.Data; using System.Linq.Expressions; using CRM.Core.Model.Enum; using Newtonsoft.Json; using CRM.Core.Common; using System.Diagnostics; using System.ComponentModel; using System.Configuration; using System.Text; using WX.CRM.Common.StockHelper; namespace CRM.Core.BLL { public class StockPools_BL : DbContextRepository { private CACHE_BL cache_BL = new CACHE_BL(); public List GetList(ref Laypage pager, SearchStockPoolPageDto dto) { List result = new List(); var url = ConfigurationManager.AppSettings["StockPoolUrl"]; var appId = ConfigurationManager.AppSettings["StockPoolAppId"]; var secret = ConfigurationManager.AppSettings["StockPoolSecret"]; if (string.IsNullOrWhiteSpace(url) || string.IsNullOrWhiteSpace(appId) || string.IsNullOrWhiteSpace(secret)) { LogHelper.Error("请检查相关的股票池配置"); throw new Exception("请检查相关的股票池配置"); } ApiSignHelper apiSignHelper = new ApiSignHelper(appId, secret); url += "/api/Stock/StockPoolPage"; Dictionary param = new Dictionary(); if (!string.IsNullOrWhiteSpace(dto.StockName)) { param.Add("StockName", dto.StockName); } if (!string.IsNullOrWhiteSpace(dto.StockCode)) { param.Add("StockCode", dto.StockCode); } if (!string.IsNullOrWhiteSpace(dto.InduName)) { param.Add("InduName", dto.InduName); } if (!string.IsNullOrWhiteSpace(dto.ChosenDateStart)) { param.Add("ChosenDateStart", dto.ChosenDateStart); } if (!string.IsNullOrWhiteSpace(dto.ChosenDateEnd)) { param.Add("ChosenDateEnd", dto.ChosenDateEnd); } if (dto.Status.HasValue) { param.Add("Status", dto.Status); } param.Add("PageIndex", pager.page); param.Add("PageSize", pager.limit); var ret = apiSignHelper.GetApi>(url, param); if (ret.Code == -1) { throw new Exception(ret.Message); } pager.count = ret.Data.Total; result = ret.Data.Data.ToList(); return result; } public List GetReportList(ref Laypage pager, SearchStockAuditPageDto dto) { List result = new List(); var url = ConfigurationManager.AppSettings["StockPoolUrl"]; var appId = ConfigurationManager.AppSettings["StockPoolAppId"]; var secret = ConfigurationManager.AppSettings["StockPoolSecret"]; if (string.IsNullOrWhiteSpace(url) || string.IsNullOrWhiteSpace(appId) || string.IsNullOrWhiteSpace(secret)) { LogHelper.Error("请检查相关的股票池配置"); throw new Exception("请检查相关的股票池配置"); } ApiSignHelper apiSignHelper = new ApiSignHelper(appId, secret); url += "/api/Stock/StockAuditPage"; Dictionary param = new Dictionary(); if (!string.IsNullOrWhiteSpace(dto.ProductLineName)) { param.Add("ProductLineName", dto.ProductLineName); } if (!string.IsNullOrWhiteSpace(dto.ColumnName)) { param.Add("ColumnName", dto.ColumnName); } if (!string.IsNullOrWhiteSpace(dto.StockCode)) { param.Add("StockCode", dto.StockCode); } if (!string.IsNullOrWhiteSpace(dto.StockName)) { param.Add("StockName", dto.StockName); } if (dto.AuditType.HasValue) { param.Add("AuditType", dto.AuditType); } if (!string.IsNullOrWhiteSpace(dto.Operator)) { param.Add("Operator", dto.Operator); } if (!string.IsNullOrWhiteSpace(dto.AuditTimeStart)) { param.Add("AuditTimeStart", dto.AuditTimeStart); } if (!string.IsNullOrWhiteSpace(dto.AuditTimeEnd)) { param.Add("AuditTimeEnd", dto.AuditTimeEnd); } if (!string.IsNullOrWhiteSpace(dto.InduName)) { param.Add("InduName", dto.InduName); } if (dto.Status.HasValue) { param.Add("Status", dto.Status); } param.Add("PageIndex", pager.page); param.Add("PageSize", pager.limit); var ret = apiSignHelper.GetApi>(url, param); if (ret.Code != 0) { throw new Exception(ret.Message); } result = ret.Data.Data.ToList(); pager.count = ret.Data.Total; return result; } public void CheckStockPools(StockAuditOrRejectDto model) { var auditUrl = ConfigurationManager.AppSettings["StockPoolUrl"] + "/api/Stock/CheckPools"; var appId = ConfigurationManager.AppSettings["StockPoolAppId"]; var secret = ConfigurationManager.AppSettings["StockPoolSecret"]; if (string.IsNullOrWhiteSpace(auditUrl) || string.IsNullOrWhiteSpace(appId) || string.IsNullOrWhiteSpace(secret)) { LogHelper.Error("请检查相关的股票池配置"); throw new Exception("请检查相关的股票池配置"); } ApiSignHelper apiSignHelper = new ApiSignHelper(appId, secret); Dictionary pairs = new Dictionary(); var nowTime = DateTime.Now; pairs.Add("check", model.check); pairs.Add("checkUserName", model.checkUserName); pairs.Add("id", model.id); pairs.Add("remark", model.remark); var result = apiSignHelper.PostApi(auditUrl, pairs); if (result.Code == -1) { throw new Exception(result.Message); } } } public class ZxdStockPoolDto : StockPoolEntity { /// /// 最新价 /// public string Price { get; set; } /// /// 实时涨跌幅 /// public string ZdRatio { get; set; } } public class StockPoolEntity { /// /// 日期 /// public string CreateTime { get; set; } /// /// 股票代码 /// public string StockCode { get; set; } /// /// 股票名称 /// public string StockName { get; set; } /// /// 所属行业 /// public string InduName { get; set; } /// /// 入选日期 /// public string ChosenDate { get; set; } /// /// 入选价 /// public decimal ChosenPrice { get; set; } /// /// 入池方式 0自动 1手动 /// public int? ChosenType { get; set; } /// /// 状态 0正常 1禁用 /// public int? Status { get; set; } public string StatusName { get; set; } /// /// 操作人 /// public string Operator { get; set; } /// /// 更新时间 /// public string UpdateTime { get; set; } } public class ZxdStockAuditDto : StockAuditDto { public int Id { get; set; } /// /// 是否审核 0 未审核 1 审核通过 -1 驳回 /// public int? Audit { get; set; } public string AuditName { get; set; } /// /// 驳回原因 /// public string RejectedReasons { get; set; } public string RecommendedStockStr { get; set; } /// /// 审核人 /// public string Auditor { get; set; } public string Checker { get; set; } /// /// 操作时间 /// public DateTime? CheckTime { get; set; } } public class StockAuditDto { /// /// 报备ID(唯一编码) /// public string AuditId { get; set; } /// /// 产品线Id /// public int? ProductLineId { get; set; } /// /// 执业证书编号 /// public string PracticeId { get; set; } /// /// 产品线名称 /// public string ProductLineName { get; set; } /// /// 栏目ID /// public int? ColumnId { get; set; } /// /// 栏目名称 /// public string ColumnName { get; set; } /// /// 所属行业 /// public string InduName { get; set; } /// /// 股票代码 /// public string StockCode { get; set; } /// /// 股票名称 /// public string StockName { get; set; } /// /// 建议关注价格 /// public decimal? FocusOnPriceMin { get; set; } /// /// 建议关注价格 /// public decimal? FocusOnPriceMax { get; set; } /// /// 建议关注价格 /// public string FocusOnPriceName { get; set; } /// /// 预警价格 /// public decimal? WarningPriceMin { get; set; } /// /// 预警价格 /// public decimal? WarningPriceMax { get; set; } public string WarningPriceName { get; set; } /// /// 建议仓位 /// public decimal? RecommendedStock { get; set; } /// /// 建议理由 /// public string RecommendedReasons { get; set; } /// /// 来源类型 /// public string SourceType { get; set; } /// /// 来源 /// public string Source { get; set; } /// /// 操作人 /// public string Operator { get; set; } /// /// 报备方式 /// public int? AuditType { get; set; } public string AuditTypeName { get; set; } /// /// 报备时间 /// public DateTime? CreateTime { get; set; } public string CreateTimeName { get; set; } } /// /// 股票池筛选框 /// public class SearchStockPoolPageDto : SearchPageBase { /// /// 股票代码(支持逗号查询多个,例:909809,324234) /// public string StockCode { get; set; } /// /// 股票名称(模糊查询) /// public string StockName { get; set; } /// /// 股票所属行业 /// public string InduName { get; set; } /// /// 入选时间 /// public string ChosenDateStart { get; set; } /// /// 入选时间 /// public string ChosenDateEnd { get; set; } /// /// 股票状态 0正常 1禁用 /// public int? Status { get; set; } } public class SearchStockAuditPageDto { /// /// 产品线名称 /// public string ProductLineName { get; set; } /// /// 栏目名称 /// public string ColumnName { get; set; } /// /// 股票代码(支持逗号查询多个,例:909809,324234) /// public string StockCode { get; set; } /// /// 股票名称(模糊查询) /// public string StockName { get; set; } /// /// 报备类型 0 人工 1 AI /// public int? AuditType { get; set; } /// /// 报备人 /// public string Operator { get; set; } /// /// 报备时间 /// public string AuditTimeStart { get; set; } /// /// 报备时间 /// public string AuditTimeEnd { get; set; } /// /// 所属行业 /// public string InduName { get; set; } /// /// 状态 0已报备 1 已审核 -1 已驳回 /// public int? Status { get; set; } } public class SearchPageBase { /// /// 页数 /// public int PageIndex { get; set; } /// /// 分页大小 /// public int PageSize { get; set; } /// /// 排序字段,支持逗号隔开 /// public string Sort { get; set; } /// /// 升降序,Asc/Desc /// public string Order { get; set; } } /// /// 审核 驳回 /// public class StockAuditOrRejectDto { /// /// 报备号 /// public int? id { get; set; } /// /// 审核状态 -1审核拒绝,1审核通过 /// public int check { get; set; } /// /// 审核人 /// public string checkUserName { get; set; } /// /// 意见备注 /// public string remark { get; set; } } }