diff --git a/YLErpWeb/Areas/Admin/AdminContext.cs b/YLErpWeb/Areas/Admin/AdminContext.cs new file mode 100644 index 00000000..0520ef28 --- /dev/null +++ b/YLErpWeb/Areas/Admin/AdminContext.cs @@ -0,0 +1,17 @@ +namespace YLErp.Web.Areas.Admin +{ + public static class AdminContext + { + public static string AdminAuthValue { get; private set; } + + static AdminContext() + { + AdminAuthValue = Guid.NewGuid().ToString("N"); + } + + public static string NewAdminCookieValue() + { + return AdminAuthValue = Guid.NewGuid().ToString("N"); + } + } +} \ No newline at end of file diff --git a/YLErpWeb/Areas/Admin/Controllers/AdminBaseController.cs b/YLErpWeb/Areas/Admin/Controllers/AdminBaseController.cs new file mode 100644 index 00000000..e6bac57b --- /dev/null +++ b/YLErpWeb/Areas/Admin/Controllers/AdminBaseController.cs @@ -0,0 +1,152 @@ +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc.Filters; +using System.Text; +using YieldChain.Models; + +namespace YLErp.Web.Areas.Admin.Controllers +{ + [Authorize(policy: "yc_identity"), Area("Admin")] + public abstract class AdminBaseController : Controller + { + /// + /// JSON序列化时是否包括NULL值 + /// + protected virtual bool JsonIncludeNullValue { get; set; } + + #region ----HTTP响应---- + + /// + /// 返回JSON错误信息 + /// + protected JsonResult JsonError(string errmsg) + { + return JsonResp(1, errmsg); + } + + /// + /// 返回JSON错误信息 + /// + protected JsonResult JsonError(string errmsg, bool locale) + { + if (locale) + { + return JsonResp(1, errmsg); + } + return Json(new ApiResponseModel(1, errmsg)); + } + + /// + /// 返回JSON错误信息 + /// + protected JsonResult JsonError(int errcode, string errmsg) + { + return JsonResp(errcode, errmsg); + } + + /// + /// 返回JSON成功信息 + /// + protected JsonResult JsonSuccess(object resultData, string message = null) + { + return JsonResp(0, message, resultData); + } + + /// + /// 返回JSON格式的成功消息 + /// + protected JsonResult JsonSuccess() + { + return Json(new ApiResponseModel(0)); + } + + /// + /// 返回JSON格式的成功消息 + /// + protected JsonResult JsonSuccessMessage(string message) + { + return JsonResp(0, message); + } + + /// + /// 返回JSON格式的模型验证失败 + /// + protected JsonResult JsonModelError(string separator = "\\n\\n") + { + var sb = new StringBuilder(); + + foreach (var item in ModelState.Values) + { + if (item.Errors.Count > 0) + { + for (var i = item.Errors.Count - 1; i >= 0; i--) + { + if (sb.Length > 0) + { + sb.Append(separator); + } + + sb.Append(item.Errors[i].ErrorMessage); + } + } + } + + return JsonResp(2, sb.ToString()); + } + + /// + /// 返回JSON格式的消息 + /// + /// 0-无错误,其他-有错误发生 + /// 错误或成功消息 + /// 结果数据 + protected JsonResult JsonResp(int errcode, string message, object resultData = null) + { + return Json(new ApiResponseModel(errcode, message, resultData)); + } + + + #endregion + + UserInfo _curUser; + + protected UserInfo CurUser + { + get + { + if (User.Identity.IsAuthenticated) + { + if (_curUser != null) + { + return _curUser; + } + + _curUser = Server.CacheProvider.Get("loginUser^" + HttpContext.User.GetUserId()) as UserInfo; + + if (_curUser != null) + { + _curUser.UserFrom = OptUserFrom.WebUI; + return _curUser; + } + } + return new UserInfo { UserName = "系统", UserFrom = OptUserFrom.WebUI }; + } + } + + public override void OnActionExecuting(ActionExecutingContext context) + { + if (!CurUser.HasRight("系统管理-系统配置管理")) + { + if (Request.Headers["X-Requested-With"] == "XMLHttpRequest") + { + context.Result = JsonError("没有权限"); + } + else + { + context.Result = new ContentResult { Content = "您无权访问此页面。", ContentType = "text/plain; charset=utf-8" }; + } + } + + base.OnActionExecuting(context); + } + } +} \ No newline at end of file diff --git a/YLErpWeb/Areas/Admin/Controllers/DbUpdateController.cs b/YLErpWeb/Areas/Admin/Controllers/DbUpdateController.cs new file mode 100644 index 00000000..d21375d6 --- /dev/null +++ b/YLErpWeb/Areas/Admin/Controllers/DbUpdateController.cs @@ -0,0 +1,42 @@ +using YLErp.Modules.AppModule.UpgradModule; + +namespace YLErp.Web.Areas.Admin.Controllers +{ + public class DbUpdateController : AdminBaseController + { + public ActionResult Index() + { + return View(); + } + + /// + /// 加载所有数据库脚本升级列表 + /// + public JsonResult AjaxGetUpdateList() + { + var list = DbUpdateService.GetUpdateList(); + + return JsonSuccess(list); + } + + /// + /// 查看数据库脚本升级内容 + /// + public JsonResult AjaxGetUpdateContent(IEnumerable upKeyList) + { + var content = DbUpdateService.GetUpdateContent(upKeyList); + + return JsonSuccess(content); + } + + /// + /// 执行所选数据库脚本升级文件内容 + /// + public JsonResult AjaxExecuteUpdate(IEnumerable upKeyList, bool isUpdateDone = false) + { + var responseDtos = DbUpdateService.ExecuteUpdate(upKeyList, isUpdateDone); + + return JsonSuccess(responseDtos); + } + } +} \ No newline at end of file diff --git a/YLErpWeb/Areas/Admin/Controllers/HomeController.cs b/YLErpWeb/Areas/Admin/Controllers/HomeController.cs new file mode 100644 index 00000000..eaf8a839 --- /dev/null +++ b/YLErpWeb/Areas/Admin/Controllers/HomeController.cs @@ -0,0 +1,32 @@ +using YLErp.Providers; + +namespace YLErp.Web.Areas.Admin.Controllers +{ + public class HomeController : AdminBaseController + { + public ActionResult Index() + { + return View(); + } + + public ActionResult Logout() + { + MemoryCacheProvider.Default.Remove("myadminadmin"); + + return Redirect("/admin/Login"); + } + + public JsonResult AjaxRestart() + { + try + { + System.Diagnostics.Process.GetCurrentProcess().Kill(); + return Json("重启中..."); + } + catch (Exception ex) + { + return Json("重启失败:" + ex.Message); + } + } + } +} \ No newline at end of file diff --git a/YLErpWeb/Areas/Admin/Controllers/OtcConfigController.cs b/YLErpWeb/Areas/Admin/Controllers/OtcConfigController.cs new file mode 100644 index 00000000..353c4d91 --- /dev/null +++ b/YLErpWeb/Areas/Admin/Controllers/OtcConfigController.cs @@ -0,0 +1,290 @@ +using Newtonsoft.Json; +using Org.BouncyCastle.Asn1.Ocsp; +using YLErp.Commons; +using YLErp.Modules.AppModule; +using YLErp.Modules.EodModule.SettlementModule; +using YLErp.Web.App_Start.AppConfig; +using YLErp.Web.Areas.Admin.Models; + +namespace YLErp.Web.Areas.Admin.Controllers +{ + public class OtcConfigController : AdminBaseController + { + public ActionResult Index() + { + return AppConfig(); + } + + #region----AppConfig---- + + public ActionResult AppConfig() + { + var datas = DbContextFactory.GetYLDbContext().AppConfig.Where(n => n.PGroup == "ProjectConfig").ToArray(); + foreach (var data in datas) + { + if (data.PType == "string") + { + data.PGroup = "01"; + } + else if (data.PType == "text") + { + data.PGroup = "01"; + } + else if (data.PType == "bool") + { + data.PGroup = "11"; + } + else + { + data.PGroup = "02"; + } + } + datas = datas.OrderBy(n => n.PGroup).ThenBy(n => n.PName).ToArray(); + return View("AppConfig", datas); + } + + public JsonResult AjaxSaveAppConfig(string name, string value) + { + if (string.IsNullOrEmpty(name)) + { + return JsonError("保存失败,请求参数不能为空"); + } + if (!string.IsNullOrWhiteSpace(value)) + { + value = Uri.UnescapeDataString(value); + } + using (var db = DbContextFactory.GetYLDbContext()) + { + var data = db.AppConfig.FirstOrDefault(n => n.PGroup == "ProjectConfig" && n.PName == name); + if (data == null) + { + return JsonError("保存失败,没有找到配置数据"); + } + data.PValue = value; + PS.SetConfig(name, value); + db.SaveChanges(); + return JsonSuccess($"{DateTime.Now:yyyyMMdd HH:mm:ss}--保存成功--{data.PName}={data.PValue}"); + } + } + + public JsonResult AjaxResetAppConfig() + { + AppManager.ResetAppConfig(); + return JsonSuccess("刷新配置成功"); + } + + #endregion + + #region----OtcWebConfig--- + + public ActionResult WebConfig() + { + var list = AppHelper.GetConfigFieldAttributes(); + return View(list); + } + + public JsonResult AjaxSaveWebConfig(OtcAppConfig model) + { + if (model == null) + { + return JsonError("请求参数无效"); + } + var json = JsonHelper.Serialize(model); + AppHelper.ResetConfig(json); + return JsonSuccess(); + } + + #endregion + + #region----OtcFormat---- + + public ActionResult OtcFormat() + { + var viewModel = OtcFormatViewModel.CreateViewModel(OtcFormatHelper.FormatModel); + + return View(viewModel); + } + + /// + /// 保存配置 + /// + /// + /// 保存链路:写 DB(AppConfig.OtcFormatConfig) → 落盘 App_Data/Config/otcformat.js → 刷新内存。 + /// 注意:File.WriteAllText 只写当前节点磁盘。多节点部署下,未处理本次请求的节点文件不会更新, + /// 会造成"DB 正确但 /front/otcformat 返回旧值"。完整排查见 FrontController 类注释。 + /// + public JsonResult AjaxSaveOtcFormat(OtcFormatModel model) + { + if (model is null) + { + return JsonError("参数不能为空"); + } + + var json = JsonConvert.SerializeObject(model, Formatting.Indented); + + var service = new AppConfigService(OptUserInfo.SystemUser); + + service.SaveOtcFormatConfig(json); + + var path = Server.MapPath("~/App_Data/Config/otcformat.js"); + var jscode = "var main = main || {};\r\nmain.formatOptions= " + json + ";\r\n\r\n"; + System.IO.File.WriteAllText(path, jscode); + + OtcFormatHelper.Initialize(json); + + return JsonSuccess(); + } + + #endregion + + #region---SMTP Config---- + + public ActionResult SmtpConfig() + { + return View(AppManager.SmtpConfig); + } + + /// + /// 保存邮件发送配置 + /// + public JsonResult AjaxSaveSmtpConfig(SmtpConfigExt smtpConfig) + { + AppManager.ResetSmtpConfig(smtpConfig); + return JsonSuccessMessage("保存成功"); + } + + /// + /// 邮件发送测试 + /// + public JsonResult AjaxSendMailTest(string mailTo) + { + if (string.IsNullOrWhiteSpace(mailTo)) + { + return JsonError("发送邮件地址不能为空"); + } + LogFactory.GetLogger().Info($"邮件发送测试,mailTo={mailTo}"); + var error = EmailHelper.SendMail(mailTo, "邮件发送测试", "邮件发送测试"); + LogFactory.GetLogger().Info($"邮件发送测试完成,mailTo={mailTo},error={error}"); + if (string.IsNullOrWhiteSpace(error)) + { + return JsonSuccess(); + } + return JsonError(error); + } + + #endregion + + #region----MailTemplate---- + + public ActionResult MailTemplate() + { + return View(); + } + + public JsonResult AjaxGetMailTemplate(string emailType) + { + var data = new EmailTemplateService(CurUser).GetData(emailType); + return JsonSuccess(data ?? new EmailTemplate()); + } + + public JsonResult AjaxSaveMailTemplate(EmailTemplate data) + { + data.IsBodyHtml = true; + data.BodyTemplate = Uri.UnescapeDataString(data.BodyTemplate ?? string.Empty); + new EmailTemplateService(CurUser).SaveData(data); + return JsonSuccess("保存成功"); + } + + #endregion + + #region----收盘配置---- + + public ActionResult SettlementConfig() + { + var config = PS.Config.GetSettlementConfig(); + + return View(config); + } + + public JsonResult AjaxSaveSettlementConfig(Configuration.SettlementConfig config) + { + var json = config.ToJson(); + new AppConfigService(CurUser).SaveConfig("ProjectConfig", "Erp.SettlementConfig", json, "string", "收盘配置"); + PS.SetConfig("Erp.SettlementConfig", json); + return JsonSuccess(); + } + /// + /// 客户资金分买卖权结算重算 + /// + /// + public JsonResult AjaxClientBalanceReCalcBS(BalanceRecalcBSRequest request) + { + Task.Run(() => new EodClientBalanceCalcBS(CurUser).ClientBalanceReCalc(request.TradeDateStart,request.TradeDateEnd)); + return JsonSuccess(); + } + public JsonResult AjaxClientBalanceReCalcProcess() + { + EodClientBalanceCalcBS.thQueue.TryPeek(out EodClientBalanceReCalcModel result);//取出最新进度 + return JsonSuccess(result); + } + #endregion + + #region----登出---- + public ActionResult Logout() + { + return Redirect("/admin/Login"); + } + #endregion + + #region----交易要素配置---- + + public ActionResult TradePricingCfg() + { + return View(); + } + + #endregion + + #region----ClientEditConfig---- + + public ActionResult ClientEditConfig() + { + ViewData["config"] = YLErp.Modules.SystemModule.ClientEditConfigService.GetCurrentConfigJson(); + return View(); + } + + public ActionResult downClientEditConfig(string t) + { + string configJson; + + if ("def".Equals(t, StringComparison.OrdinalIgnoreCase)) + { + configJson = YLErp.Modules.SystemModule.ClientEditConfigService.GetDefaultConfigJson(); + } + else + { + configJson = YLErp.Modules.SystemModule.ClientEditConfigService.GetCurrentConfigJson(); + } + var buffer = System.Text.Encoding.UTF8.GetBytes(configJson); + return File(buffer, "application/javascript; charset=utf-8", "clientEditConfig.js"); + } + + public JsonResult AjaxSaveClientEditConfig(string config) + { + YLErp.Modules.SystemModule.ClientEditConfigService.SaveEditConfig(config); + + return JsonSuccess(); + } + + #endregion + + #region----结算报告配置---- + + public ActionResult TradeMarketReportCfg() + { + return View(); + } + + #endregion + } +} diff --git a/YLErpWeb/Areas/Admin/Controllers/OwnerInfoController.cs b/YLErpWeb/Areas/Admin/Controllers/OwnerInfoController.cs new file mode 100644 index 00000000..650b303e --- /dev/null +++ b/YLErpWeb/Areas/Admin/Controllers/OwnerInfoController.cs @@ -0,0 +1,42 @@ +using YLErp.Modules.ReportModule; + +namespace YLErp.Web.Areas.Admin.Controllers +{ + public class OwnerInfoController : AdminBaseController + { + // GET: Admin/Owner_info + public ActionResult Index() + { + return View(); + } + + public JsonResult GetOwnerInfo() + { + var sList = DbContextFactory.GetYLDbContext().Owner_Info.ToList(); + return Json(sList); + } + + public JsonResult PostOwnerInfo(Owner_info o) + { + var i = new Owner_infoService(CurUser).AddOrUpdate(o); + return Json(i); + } + + public ActionResult OwnerInfoEdit(int ID) + { + Owner_info v; + v = DbContextFactory.GetYLDbContext().Owner_Info.Find(ID); + if (v == null) + { + v = new Owner_info(); + } + return View(v); + } + + public JsonResult Deleteowner(int ID) + { + var i = new Owner_infoService(CurUser).Dele(ID); + return Json(i); + } + } +} \ No newline at end of file diff --git a/YLErpWeb/Areas/Admin/Controllers/ToolsController.cs b/YLErpWeb/Areas/Admin/Controllers/ToolsController.cs new file mode 100644 index 00000000..1a08a8cf --- /dev/null +++ b/YLErpWeb/Areas/Admin/Controllers/ToolsController.cs @@ -0,0 +1,70 @@ +using YLErp.Modules.ExchangeTradeModule; +using YLErp.Modules.SuperviseReportModule.ChangJiangReport.Service; +using YLErp.Modules.SystemModule; + +namespace YLErp.Web.Areas.Admin.Controllers +{ + public class ToolsController : AdminBaseController + { + public ActionResult Index() + { + return View(); + } + + /// + /// 重新初始化实时风险计算 + /// + public JsonResult AjaxResetTradeRiskCalcTaskRunner() + { + Modules.TradeRiskCalcModule.TradeRiskCalcTaskRunner.Reset(); + return JsonSuccess(); + } + + /// + /// 重置对冲交易持仓 + /// + public JsonResult AjaxResetTradePosition() + { + new ExchangeTradePositionService(CurUser).ResetExchangeTradePosition(); + return JsonSuccess(); + } + + public JsonResult AjaxResetsysUser() + { + var functionRightXmlFilePath = Server.MapPath("/App_Data/FunctionRight.xml"); + new SysFunctionService(CurUser).SyncFunctionRight(functionRightXmlFilePath); + BaseOUDAL.UserBLL.AddDefaultUser(); + FunctionHelper.Initialize(); + return JsonSuccess(); + } + + /// + /// 长江监管报告-场外业务持仓表 + /// + public JsonResult AjaxChangeJiangSuperviseReportPosition(ChangeJiangSuperviseReportPositionRequest req) + { + if (req == null) + { + return JsonError("参数不可为空"); + } + + if (req.Date == DateTime.MinValue) + { + return JsonError("未传入有效的结算日期"); + } + + var nv = YieldChain.Helpers.UrlHelper.ParseQueryString(PS.Config.ErpElement.Supervise_Position); + + var changes = new SuperviseReportPositionService(OptUserInfo.SystemUser).SaveReportData(req.Date.Date, nv?["敞口算法"], req.ClearExistings); + + return JsonSuccessMessage($"执行完成,共更新{changes}条"); + } + } + + public class ChangeJiangSuperviseReportPositionRequest + { + public DateTime Date { get; set; } + + public bool ClearExistings { get; set; } + } +} \ No newline at end of file diff --git a/YLErpWeb/Areas/Admin/Models/BalanceRecalcBSRequest.cs b/YLErpWeb/Areas/Admin/Models/BalanceRecalcBSRequest.cs new file mode 100644 index 00000000..a0031e97 --- /dev/null +++ b/YLErpWeb/Areas/Admin/Models/BalanceRecalcBSRequest.cs @@ -0,0 +1,9 @@ +namespace YLErp.Web.Areas.Admin.Models +{ + public class BalanceRecalcBSRequest + { + public DateTime? TradeDateStart { get; set; } + + public DateTime? TradeDateEnd { get; set; } + } +} diff --git a/YLErpWeb/Areas/Admin/Models/OtcFormatViewModel.cs b/YLErpWeb/Areas/Admin/Models/OtcFormatViewModel.cs new file mode 100644 index 00000000..d887b433 --- /dev/null +++ b/YLErpWeb/Areas/Admin/Models/OtcFormatViewModel.cs @@ -0,0 +1,60 @@ +using System.Reflection; + +namespace YLErp.Web.Areas.Admin.Models +{ + /// + /// + /// + public class OtcFormatViewModel + { + public IEnumerable SelectItems { get; set; } + + public static OtcFormatViewModel CreateViewModel(OtcFormatModel otcFormat) + { + if (otcFormat is null) + { + throw new System.ArgumentNullException(nameof(otcFormat)); + } + + var selectItems = GetSelectItems(otcFormat); + + return new OtcFormatViewModel { SelectItems = selectItems }; + } + + private static IEnumerable GetSelectItems(object obj, int depth = 0) + { + var flags = BindingFlags.Instance | BindingFlags.Public; + var properties = obj.GetType().GetProperties(flags); + var resultList = new List(properties.Length); + + foreach (var p in properties) + { + if (p.CanRead && p.CanWrite) + { + var attr = p.GetCustomAttribute(typeof(OtcFormatConfigAttribute)) as OtcFormatConfigAttribute; + + if (attr == null) + { + continue; + } + + var item = new SelectItemNest + { + Value = p.Name, + Text = attr.Label, + Tag = p.GetValue(obj) + }; + + if (depth == 0) + { + item.SelectItems = GetSelectItems(item.Tag, depth + 1); + } + + resultList.Add(item); + } + } + + return resultList; + } + } +} \ No newline at end of file diff --git a/YLErpWeb/Areas/Admin/Models/PluginViewModel.cs b/YLErpWeb/Areas/Admin/Models/PluginViewModel.cs new file mode 100644 index 00000000..0a8466ae --- /dev/null +++ b/YLErpWeb/Areas/Admin/Models/PluginViewModel.cs @@ -0,0 +1,9 @@ +namespace YLErp.Web.Areas.Admin.Models +{ + public class PluginViewModel + { + public IEnumerable Directories { get; set; } + + public IEnumerable Files { get; set; } + } +} \ No newline at end of file diff --git a/YLErpWeb/Areas/Admin/Models/ZTreeMenuItem.cs b/YLErpWeb/Areas/Admin/Models/ZTreeMenuItem.cs new file mode 100644 index 00000000..7f8b048f --- /dev/null +++ b/YLErpWeb/Areas/Admin/Models/ZTreeMenuItem.cs @@ -0,0 +1,37 @@ +using YLErp.Abstract; + +namespace YLErp.Web.Areas.Admin.Models +{ + public class ZTreeMenuItem : ITreeMenuItem + { + public string id { get; set; } + + public string name { get; set; } + + public bool open { get; set; } + + public List children { get; set; } + + public ITreeMenuItem AppendChild(string id, string name, string[] rights, + string url, string icon, string target) + { + var menu = new ZTreeMenuItem + { + id = id, + name = name, + open = false + }; + if (children == null) + { + children = new List(); + } + children.Add(menu); + return menu; + } + + public override string ToString() + { + return name; + } + } +} \ No newline at end of file diff --git a/YLErpWeb/Areas/Admin/Views/DbUpdate/Index.cshtml b/YLErpWeb/Areas/Admin/Views/DbUpdate/Index.cshtml new file mode 100644 index 00000000..168059b0 --- /dev/null +++ b/YLErpWeb/Areas/Admin/Views/DbUpdate/Index.cshtml @@ -0,0 +1,94 @@ +@{ + ViewData["Title"] = "数据库升级"; +} + +
+
+

数据库升级

+ + + + +
+
+
+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
版本数据库内容操作执行结果
{{item.Version}}{{item.DbSchema}}查看{{item.UpState<1?"执行更新":"重新执行"}}{{item.UpResult}}
+
+
+
+ + + +@section heads{ + +} +@section scripts{ + + + + + + +} diff --git a/YLErpWeb/Areas/Admin/Views/Home/Index.cshtml b/YLErpWeb/Areas/Admin/Views/Home/Index.cshtml new file mode 100644 index 00000000..e6268f0b --- /dev/null +++ b/YLErpWeb/Areas/Admin/Views/Home/Index.cshtml @@ -0,0 +1,35 @@ +@{ + ViewData["Title"] = "首页"; +} + +@section heads{ + + } +
+
+
+
当前版本
+
@(AppManager.Version)
+
+
+ +
+
启动时间
+
@(AppManager.StartTime)
+
+
+ + @foreach (var item in AppManager.GetSysInfo()) + { +
+
@(item.Key)
+
@(item.Message)
+
@(item.TimeStamp)
+
+
+ } +
+
diff --git a/YLErpWeb/Areas/Admin/Views/OtcConfig/AppConfig.cshtml b/YLErpWeb/Areas/Admin/Views/OtcConfig/AppConfig.cshtml new file mode 100644 index 00000000..94316835 --- /dev/null +++ b/YLErpWeb/Areas/Admin/Views/OtcConfig/AppConfig.cshtml @@ -0,0 +1,156 @@ +@model IEnumerable + +@{ + var id = 0; + ViewData["Title"] = "全局配置(AppConfig)"; +} + +@section heads{ + +} + +
+
+
+
+

修改后自动保存

+
+
+ +
+
+
+
+ +
+
+

全局配置(AppConfig)

+
+
+ @foreach (var item in Model) + { + id++; + var label = item.PName + "-" + item.Remark; +
+ @if (item.PType == "bool") + { + var val = item.PValue?.ToLowerInvariant(); + + } + else if (item.PType == "string" || item.PType == "int" || item.PType == "double") + { +
@(label)
+ + } + else if (item.PType == "text") + { +
@(label)
+ + } + else if (item.PType == "html") + { +
@(label)
+ +
+ +
+ } + else + { + IEnumerable names = null; + if (item.PType == "CompanyEnum") + { + names = Enum.GetNames(typeof(YLErp.Configuration.CompanyEnum)); + } + else if (item.PType == "ComponentVersion") + { + names = Enum.GetNames(typeof(YLErp.Configuration.ComponentVersion)); + } + else if (item.PType == "VolModeEnum") + { + names = Enum.GetNames(typeof(YLErp.Configuration.VolModeEnum)); + } + else if (item.PType == "VolSurfaceKeyDateShiftEnum") + { + names = Enum.GetNames(typeof(YLErp.Configuration.VolSurfaceKeyDateShiftEnum)); + } + else if (item.PType == "SmoothingDaycountMode") + { + names = Enum.GetNames(typeof(YLErp.Configuration.Enums.SmoothingDaycountMode)); + } + else if (item.PType == "ForwardTradePriceModel") + { + names = Enum.GetNames(typeof(YLErp.Configuration.Enums.ForwardTradePriceModel)); + } + else if (item.PType == "SaleMode") + { + names = Enum.GetNames(typeof(YLErp.Configuration.Enums.SaleMode)); + } + else if (item.PType == "OptionTypeAndBuySell") + { + names = Enum.GetNames(typeof(YLErp.Configuration.Enums.OptionTypeAndBuySell)); + } + else if (item.PType == "ForwardValueIsSupplyOrPay") + { + names = Enum.GetNames(typeof(YLErp.Configuration.Enums.ForwardValueIsSupplyOrPay)); + } + else if (item.PType == "ExchangeOptionVolType") + { + names = Enum.GetNames(typeof(YLErp.Configuration.Enums.ExchangeOptionVolType)); + } +
@(label)
+ if (names != null) + { + + } + } +
+ } +
+
+ + + +@section scripts{ + + + + +} diff --git a/YLErpWeb/Areas/Admin/Views/OtcConfig/ClientEditConfig.cshtml b/YLErpWeb/Areas/Admin/Views/OtcConfig/ClientEditConfig.cshtml new file mode 100644 index 00000000..c17fc67a --- /dev/null +++ b/YLErpWeb/Areas/Admin/Views/OtcConfig/ClientEditConfig.cshtml @@ -0,0 +1,64 @@ +@{ + ViewData["Title"] = "客户编辑页面配置"; +} + +
+
+

客户编辑页面配置

+ +
+
+
+ +
+

使用'meta_'前缀定义扩展属性,属性中不允许出现下划线

+

+ 列表配置: +
+ hidden代表是否要默认在列表中隐藏;如:hidden:true +
+ optionHide代表是否要在列配置中隐藏;如:optionHide:true +

+
+ +
+
+
+ +@section heads{ + + +} +@section scripts{ + + + + + + +} diff --git a/YLErpWeb/Areas/Admin/Views/OtcConfig/MailTemplate.cshtml b/YLErpWeb/Areas/Admin/Views/OtcConfig/MailTemplate.cshtml new file mode 100644 index 00000000..e62911ca --- /dev/null +++ b/YLErpWeb/Areas/Admin/Views/OtcConfig/MailTemplate.cshtml @@ -0,0 +1,87 @@ +@{ + ViewData["Title"] = "邮件模板配置"; +} + +
+
+

邮件模板配置

+
+
+
+ +
+
+ + +
+
+ +
+
+
+ +
+
+
+ +@section scripts{ + + + +} diff --git a/YLErpWeb/Areas/Admin/Views/OtcConfig/OtcFormat.cshtml b/YLErpWeb/Areas/Admin/Views/OtcConfig/OtcFormat.cshtml new file mode 100644 index 00000000..0342d14f --- /dev/null +++ b/YLErpWeb/Areas/Admin/Views/OtcConfig/OtcFormat.cshtml @@ -0,0 +1,88 @@ +@using YLErp.Commons +@using YLErp.Web.Areas.Admin.Models + +@model OtcFormatViewModel + +@{ + ViewData["Title"] = "OtcFormat配置"; + + var pageObj = new + { + AjaxSaveUrl = Url.Action("AjaxSaveOtcFormat") + }; +} + +@section heads{ + +} + +
+
+

OtcFormat配置

+
+
+ + @foreach (var item in Model.SelectItems) + { +
+
+

@(item.Text)

+
+
+ @foreach (var item2 in item.SelectItems) + { + var opt = (OtcFormatOption)item2.Tag; +
+
+ @(item2.Text): +
+
+ +
+
+ + + + +
+
+ } +
+
+ } + +
+ +
+
+
+ +@section scripts{ + + +} diff --git a/YLErpWeb/Areas/Admin/Views/OtcConfig/SettlementConfig.cshtml b/YLErpWeb/Areas/Admin/Views/OtcConfig/SettlementConfig.cshtml new file mode 100644 index 00000000..d4ff961c --- /dev/null +++ b/YLErpWeb/Areas/Admin/Views/OtcConfig/SettlementConfig.cshtml @@ -0,0 +1,170 @@ +@model YLErp.Configuration.SettlementConfig + +@{ + ViewData["Title"] = "收盘配置"; + + var pageObj = new + { + AjaxSaveUrl = Url.Action("AjaxSaveSettlementConfig"), + AjaxReCalcBuySell = Url.Action("AjaxClientBalanceReCalcBS"), + AjaxReCalcBuySellProcess=Url.Action("AjaxClientBalanceReCalcProcess"), + }; + + var allVolTypes = YLErp.Web.Models.SettlementViewModel.GetVolTypes(); + var checkedVolTypes = Model.VolTypes.Split(',').Where(n => !string.IsNullOrWhiteSpace(n)).ToArray(); +} + +@section heads{ + +} +
+
+

收盘配置

+
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ + +
+
+
+ +
+ @foreach (var item in allVolTypes) + { + var _checked = checkedVolTypes.Contains(item.Value) ? "checked" : ""; + + } +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ + + +
+
+
+ +
+ + + + +
+ +
+ +
+
+
+ +
+
+
+ +@section scripts{ + +} \ No newline at end of file diff --git a/YLErpWeb/Areas/Admin/Views/OtcConfig/SmtpConfig.cshtml b/YLErpWeb/Areas/Admin/Views/OtcConfig/SmtpConfig.cshtml new file mode 100644 index 00000000..fdda1dcc --- /dev/null +++ b/YLErpWeb/Areas/Admin/Views/OtcConfig/SmtpConfig.cshtml @@ -0,0 +1,162 @@ +@model YLErp.MailKit.SmtpConfig + +@{ + + ViewData["Title"] = "邮件发送配置"; + + var pageObj = new + { + Model = Model, + AjaxSaveSmtpConfig = Url.Action("AjaxSaveSmtpConfig"), + AjaxSendMailTest = Url.Action("AjaxSendMailTest") + }; +} + +@section heads{ + +} +
+
+

邮件发送配置

+
+
+
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ + + + +
+
+
+
+
+ +
+ +
+ +
+ +
+
+ + +
+ +
+ +
+
+ +
+ +
+ +
+ +
+ +
+
+ + + +
+ +
+ +
+
+
+
+ + +
+
+
+ +
+
+

邮件发送测试

+
+
+
+
+ 发送测试邮件到   + + +
+
+
+
+ +@section scripts{ + + +} \ No newline at end of file diff --git a/YLErpWeb/Areas/Admin/Views/OtcConfig/TradeMarketReportCfg.cshtml b/YLErpWeb/Areas/Admin/Views/OtcConfig/TradeMarketReportCfg.cshtml new file mode 100644 index 00000000..bf4b46ee --- /dev/null +++ b/YLErpWeb/Areas/Admin/Views/OtcConfig/TradeMarketReportCfg.cshtml @@ -0,0 +1,68 @@ +@{ + ViewData["Title"] = "结算报告配置"; + var nv = YieldChain.Helpers.UrlHelper.ParseQueryString(PS.Config.ErpElement.TradeMarketReportCfg); + var pageObj = new + { + Model = new + { + TradeMarketReportStartDate = nv?["开始日期"].TrimToNull() ?? "NONE", + }, + AjaxSaveConfigUrl = Url.Action("AjaxSaveAppConfig") + }; +} + +@section heads{ + +} +
+
+

结算报告配置

+
+
+
+
+ +
+ +
+
+
+
+ +
+
+
+ +@section scripts{ + + +} \ No newline at end of file diff --git a/YLErpWeb/Areas/Admin/Views/OtcConfig/TradePricingCfg.cshtml b/YLErpWeb/Areas/Admin/Views/OtcConfig/TradePricingCfg.cshtml new file mode 100644 index 00000000..6d6cd474 --- /dev/null +++ b/YLErpWeb/Areas/Admin/Views/OtcConfig/TradePricingCfg.cshtml @@ -0,0 +1,94 @@ +@{ + ViewData["Title"] = "交易要素配置"; + var nv = YieldChain.Helpers.UrlHelper.ParseQueryString(PS.Config.ErpElement.TradePricingCfg); + var pageObj = new + { + Model = new + { + TradeCloseVolatility = nv?["目标波动率"].TrimToNull() ?? "BidAsk", + NumOfSmoothingDays = nv?["平滑过渡天数"].TrimToNull() ?? "NONE", + ForwardPriceType = nv?["远期期初价类型"].TrimToNull() ??"期权行权价格" + }, + AjaxSaveConfigUrl = Url.Action("AjaxSaveAppConfig") + }; +} + +@section heads{ + +} +
+
+

交易要素配置(默认值)

+
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
累计期权交易要素配置
+
+
+ +
+ +
+
+
+
+ +
+
+
+ +@section scripts{ + + +} \ No newline at end of file diff --git a/YLErpWeb/Areas/Admin/Views/OtcConfig/WebConfig.cshtml b/YLErpWeb/Areas/Admin/Views/OtcConfig/WebConfig.cshtml new file mode 100644 index 00000000..cbb4e532 --- /dev/null +++ b/YLErpWeb/Areas/Admin/Views/OtcConfig/WebConfig.cshtml @@ -0,0 +1,125 @@ +@model IEnumerable + +@{ + ViewData["Title"] = "当前系统配置"; +} + +@section heads{ + +} + +
+
+

当前系统配置

+
+
+
+ @foreach (var attr in Model) + { + var label = attr.Description; +
+ @if (attr.FieldType == typeof(Boolean)) + { + + } + else if (attr.FieldType == typeof(String)) + { +
@(label)
+ if (!string.IsNullOrWhiteSpace(attr.DataMapString)) + { + + + } + else + { + + } + } + else if (attr.FieldType == typeof(int)) + { + if (attr.IsFlags && !string.IsNullOrWhiteSpace(attr.DataMapString)) + { + + var flags = int.Parse(attr.FieldValue); + var nv = YieldChain.Helpers.UrlHelper.ParseQueryString(attr.DataMapString); + foreach (var key in nv.AllKeys) + { + var chked = (int.Parse(nv[key]) & flags) > 0; + + } + + } + } +
+
+ } +
+
+ +
+
+
+@section scripts{ + +} diff --git a/YLErpWeb/Areas/Admin/Views/OwnerInfo/Index.cshtml b/YLErpWeb/Areas/Admin/Views/OwnerInfo/Index.cshtml new file mode 100644 index 00000000..55433df9 --- /dev/null +++ b/YLErpWeb/Areas/Admin/Views/OwnerInfo/Index.cshtml @@ -0,0 +1,87 @@ +@section scripts{ + +} + + + + + + + + + + + + + + + + + + + + + + + + + +
条件公司全称营业执照注册地址法人户名开户行账号大额行号联系人地址邮件电话传真操作
+ + + diff --git a/YLErpWeb/Areas/Admin/Views/OwnerInfo/OwnerInfoEdit.cshtml b/YLErpWeb/Areas/Admin/Views/OwnerInfo/OwnerInfoEdit.cshtml new file mode 100644 index 00000000..18d31001 --- /dev/null +++ b/YLErpWeb/Areas/Admin/Views/OwnerInfo/OwnerInfoEdit.cshtml @@ -0,0 +1,198 @@ +@model Owner_info +@{ + Layout = null; +} + + + + + + OwnerInfoEdit + + + + + + + + + + + + + + + + + + + +
+
+ +
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+ + + diff --git a/YLErpWeb/Areas/Admin/Views/Shared/_Layout.cshtml b/YLErpWeb/Areas/Admin/Views/Shared/_Layout.cshtml new file mode 100644 index 00000000..3ffd88c0 --- /dev/null +++ b/YLErpWeb/Areas/Admin/Views/Shared/_Layout.cshtml @@ -0,0 +1,162 @@ + +@{ + Layout = null; +} + + + + + + + + + + + + + + + + + + + 系统管理-@(ViewData["Title"]) + + + @RenderSection("heads", required: false) + + +
+
+
+
+
+ + 系统管理后台 + +
+ + + +
+ + + +
+
+
+ +
+
+ @RenderBody() +
+
+
+
+ + + + + + + + @RenderSection("scripts", required: false) + + diff --git a/YLErpWeb/Areas/Admin/Views/Tools/Index.cshtml b/YLErpWeb/Areas/Admin/Views/Tools/Index.cshtml new file mode 100644 index 00000000..c157f343 --- /dev/null +++ b/YLErpWeb/Areas/Admin/Views/Tools/Index.cshtml @@ -0,0 +1,90 @@ +@{ + ViewData["Title"] = "系统工具"; +} +@section heads{ + +} +
+
+

重新初始化实时风险运算

+
+
+ + +
+
+
+
+

重新初始化系统默认用户

+
+
+ +
+ + @if (PS.Config.Company == YLErp.Configuration.CompanyEnum.长江) + { +
+
+ +
+
+ 结算日期: + +
+
使用的结算数据来源由appconfig中的Supervise_Position配置决定
+
+ } +
+
+
+

定价日志

+
+
+ +
+
+ +@section scripts{ + + +} \ No newline at end of file diff --git a/YLErpWeb/Areas/Admin/Views/_ViewImports.cshtml b/YLErpWeb/Areas/Admin/Views/_ViewImports.cshtml new file mode 100644 index 00000000..6e5eee4e --- /dev/null +++ b/YLErpWeb/Areas/Admin/Views/_ViewImports.cshtml @@ -0,0 +1,5 @@ +@using YLErp +@using YLErp.Web +@using YLErp.Configuration +@using YLErp.Model.Enum +@using YLErp.DBModels \ No newline at end of file diff --git a/YLErpWeb/Areas/Admin/Views/_ViewStart.cshtml b/YLErpWeb/Areas/Admin/Views/_ViewStart.cshtml new file mode 100644 index 00000000..d727d4bf --- /dev/null +++ b/YLErpWeb/Areas/Admin/Views/_ViewStart.cshtml @@ -0,0 +1,3 @@ +@{ + Layout = "~/Areas/Admin/Views/Shared/_Layout.cshtml"; +} diff --git a/YLErpWeb/wwwroot/Scripts/admin/appconfig.js b/YLErpWeb/wwwroot/Scripts/admin/appconfig.js new file mode 100644 index 00000000..a5370554 --- /dev/null +++ b/YLErpWeb/wwwroot/Scripts/admin/appconfig.js @@ -0,0 +1,73 @@ +//保存配置 +function SaveValue(id, blEncodeURI) { + var $e = $('#config' + id); + var value = ''; + if ($e.is("select") || $e.attr("type") === "text" || $e.is("textarea")) { + value = $e.val(); + if (blEncodeURI) value = encodeURIComponent(value); + if ($e.data("value") === value) { + return; + } + } else if ($e.attr("type") === "checkbox") { + value = $e.prop("checked").toString(); + } + else { + alert("不支持"); + return; + } + + main.post(saveConfigValueUrl, { name: $e.attr("name"), value: value }).done(function (resp) { + $e.data("value", value); + $('#respMsg').text(resp.data); + }); +} + +function OnInputKeyDown(blEncodeURI) { + if (event.keyCode === 13) { + SaveValue(blEncodeURI); + } +} + +//重置配置 +function ResetConfig() { + main.post(resetConfigValueUrl).done(function (resp) { + $('#respMsg').text(resp.data); + }); +} + +var ueditor, ueditorConfigId; + +function showUeditorConfig(id, title) { + ueditorConfigId = id; + $('.modal-title', '#ueditorModal').text(title || '配置'); + $('#ueditorModal').modal('show'); +} + +function saveUeditorConfig() { + let cont = ueditor.getContent(); + $('#config' + ueditorConfigId).val(cont).blur(); + $('#ueditorModal').modal('hide'); +} + +$(function () { + $('#ueditorModal').on('shown.bs.modal', function () { + function insertHtml(editor) { + let content = $('#config' + ueditorConfigId).val() || ''; + ueditor.execCommand('insertHtml', content); + } + + if (ueditor) { + ueditor.reset(); + ueditor.setContent(''); + insertHtml(); + } else { + ueditor = UE.getEditor('editor', { + autoHeight: false, + wordCount: false, + autoHeightEnabled: false, + initialFrameHeight: 500 + }); + ueditor.ready(insertHtml); + } + }); +}); \ No newline at end of file diff --git a/YLErpWeb/wwwroot/Scripts/admin/dbupdate.js b/YLErpWeb/wwwroot/Scripts/admin/dbupdate.js new file mode 100644 index 00000000..60764f21 --- /dev/null +++ b/YLErpWeb/wwwroot/Scripts/admin/dbupdate.js @@ -0,0 +1,113 @@ + +var sqlViewer = CodeMirror.fromTextArea(document.getElementById('dbContentText'), { + mode: "text/x-mysql", + indentWithTabs: true, + smartIndent: true, + lineNumbers: true, + matchBrackets: true, + autofocus: true, + readOnly: true +}); + +var vue = new Vue({ + el: "#dbUpdateDiv", + data: { + updateList: [], + checkAll: false, + filter: { version: '', dbschema: '', upstate: '', versionItems: [] } + }, + mounted: function () { + this.getUpdateList(); + }, + methods: { + //获取升级列表列表 + getUpdateList() { + var thisObj = this; + main.post("/Admin/DbUpdate/AjaxGetUpdateList").done(function (resp) { + thisObj.checkAll = false; + thisObj.updateList = resp.data; + let verSet = new Set(); + Object.assign(thisObj.filter, { versionItems: [], dbschemaItems: [] }) + thisObj.updateList.forEach(x => { + x.checked = false; + verSet.add(x.Version); + }); + thisObj.filter.versionItems = Array.from(verSet); + }).fail(function () { + main.alert("加载失败"); + }); + }, + changeItemChecked() { + this.checkAll = this.updateList.every(x => x.checked); + }, + changeAllChecked() { + let checked = this.checkAll; + this.updateList.forEach(x => { + x.checked = checked; + }); + }, + //查看脚本内容 + viewUpdateContent(upkey) { + if (upkey) { + upkey = [upkey]; + } else { + upkey = this.updateList.filter(x => x.checked).map(x => x.UpKey); + if (!upkey.length) { + return main.alert("请至少选择一项!"); + } + } + main.post("/Admin/DbUpdate/AjaxGetUpdateContent", { upKeyList: upkey }).done(function (resp) { + sqlViewer.getDoc().setValue(resp.data); + $("#dbContentModal").modal('show'); + sqlViewer.refresh(); + }); + }, + //执行脚本内容 + executeUpdate(item) { + let confirmMsg, upkeyList, upMap = {}, isUpdateDone = item === "isUpdateDone"; + if (item && !isUpdateDone) { + upkeyList = [item.UpKey]; + upMap[item.UpKey] = item; + confirmMsg = item.UpState < 1 ? "确定要执行更新吗?" : "确定要重新执行吗?"; + } else { + upkeyList = this.updateList.filter(x => x.checked).map(x => { + upMap[x.UpKey] = x; return x.UpKey; + }); + if (!upkeyList.length) { + return main.alert("请至少选择一项!"); + } + confirmMsg = "确定要执行批量更新吗?"; + } + + main.confirm(confirmMsg, function () { + $("#waitMeModal").modal("show"); + let postData = { upKeyList: upkeyList, isUpdateDone: isUpdateDone }; + main.post("/Admin/DbUpdate/AjaxExecuteUpdate", postData).done(function (resp) { + resp.data.forEach(x => { + let item = upMap[x.UpKey]; + if (item) { + item.UpState = x.UpState; + item.UpResult = x.UpResult; + } + }); + }).always(() => { + $("#waitMeModal").modal("hide"); + }); + }); + }, + itemStatusClass(item) { + if (item.UpState < 0) { + return "text-danger"; + } + + if (item.UpState > 0) { + return "text-muted"; + } + }, + isShowItem(item) { + return (this.filter.version && item.Version !== this.filter.version) + || (this.filter.dbschema && item.DbSchema !== this.filter.dbschema) + || (this.filter.upstate == true && item.UpState > 0) ? "display:none" : "display:table-row"; + } + } +}); \ No newline at end of file