Revert "refactor(risk-engine): ConditionJson 改为 RuleCondition 数组格式,精简 DTO 命名"

This reverts commit 3bf90e25ef.
This commit is contained in:
张名锐
2026-07-02 16:05:40 +08:00
parent d0e6b31d5c
commit 75dc6f182b
7 changed files with 107 additions and 112 deletions
@@ -4,7 +4,7 @@ CREATE TABLE `glms_risk_rule` (
`id` int NOT NULL AUTO_INCREMENT COMMENT '主键Id',
`RuleName` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '规则名称',
`RuleText` varchar(500) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '规则文本',
`ConditionJson` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '条件JSON(结构化模式, RuleCondition数组)',
`ConditionJson` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '条件JSON(结构化模式, FormulaCondition数组)',
`RuleExpr` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '规则表达式(自由文本模式, 类C#表达式)',
`Status` tinyint NOT NULL DEFAULT 1 COMMENT '状态: 1=Active, 2=Disabled, 3=Deleted',
`Version` int NOT NULL DEFAULT 1 COMMENT '版本号(乐观锁)',
@@ -21,9 +21,6 @@
-- 45=期初净价偏离度 46=期初收益率偏离度 47=期初价格偏离度
-- 48=利息端利率与FR007偏离度 49=利息端利率与借贷加权费率偏离度
-- 50=执行价偏离度 51=执行价 52=客户品种最低保证金率 53=参考价格
--
-- ConditionJson 精简设计:只存 VariableId/Operator/ThresholdType/Value/ThresholdVariableId
-- 展示字段(VariableName/VariableType/Unit/ThresholdVariableName)从变量接口关联获取
-- ============================================================
@@ -37,8 +34,9 @@ INSERT INTO `glms_risk_rule` (`RuleName`, `RuleText`, `ConditionJson`, `RuleExpr
('挂钩标的集中度超阈值',
'挂钩标的集中度超过阈值(默认30%)时触发审批',
JSON_ARRAY(JSON_OBJECT(
'VariableId', 24,
'Operator', '>', 'ThresholdType', 'Fixed', 'Value', 30
'VariableId', 24, 'VariableName', '挂钩标的集中度', 'VariableType', 'Numeric',
'Operator', '>', 'ThresholdType', 'fixed', 'Value', 30,
'ThresholdVariableId', JSON_TYPE(NULL), 'ThresholdVariableName', JSON_TYPE(NULL), 'Unit', '%'
)),
'calc.UnderlyingConcentration > 30',
1, 1, 0, 'SYSTEM', NOW());
@@ -49,9 +47,9 @@ INSERT INTO `glms_risk_rule` (`RuleName`, `RuleText`, `ConditionJson`, `RuleExpr
('挂钩标的到期日小于合约到期日',
'挂钩标的到期日早于合约到期日时禁止交易',
JSON_ARRAY(JSON_OBJECT(
'VariableId', 22,
'Operator', '<', 'ThresholdType', 'Variable',
'ThresholdVariableId', 3
'VariableId', 22, 'VariableName', '挂钩标的到期日', 'VariableType', 'Date',
'Operator', '<', 'ThresholdType', 'variable', 'Value', JSON_TYPE(NULL),
'ThresholdVariableId', 3, 'ThresholdVariableName', '合约到期日', 'Unit', JSON_TYPE(NULL)
)),
'market.UnderlyingMaturityDate < trade.ExerciseDate',
1, 1, 0, 'SYSTEM', NOW());
@@ -62,8 +60,9 @@ INSERT INTO `glms_risk_rule` (`RuleName`, `RuleText`, `ConditionJson`, `RuleExpr
('名义本金超阈值',
'合约名义本金超过阈值(默认1亿元)时触发审批',
JSON_ARRAY(JSON_OBJECT(
'VariableId', 1,
'Operator', '>', 'ThresholdType', 'Fixed', 'Value', 100000000
'VariableId', 1, 'VariableName', '合约名义本金', 'VariableType', 'Numeric',
'Operator', '>', 'ThresholdType', 'fixed', 'Value', 100000000,
'ThresholdVariableId', JSON_TYPE(NULL), 'ThresholdVariableName', JSON_TYPE(NULL), 'Unit', ''
)),
'trade.StockEqvNotional > 100000000',
1, 1, 0, 'SYSTEM', NOW());
@@ -74,8 +73,9 @@ INSERT INTO `glms_risk_rule` (`RuleName`, `RuleText`, `ConditionJson`, `RuleExpr
('保证金支付比例超阈值',
'保证金比例超过阈值(默认50%)时触发审批',
JSON_ARRAY(JSON_OBJECT(
'VariableId', 13,
'Operator', '>', 'ThresholdType', 'Fixed', 'Value', 50
'VariableId', 13, 'VariableName', '保证金比例', 'VariableType', 'Numeric',
'Operator', '>', 'ThresholdType', 'fixed', 'Value', 50,
'ThresholdVariableId', JSON_TYPE(NULL), 'ThresholdVariableName', JSON_TYPE(NULL), 'Unit', '%'
)),
'trade.MarginRate > 50',
1, 1, 0, 'SYSTEM', NOW());
@@ -86,8 +86,9 @@ INSERT INTO `glms_risk_rule` (`RuleName`, `RuleText`, `ConditionJson`, `RuleExpr
('保证金利率偏离',
'保证金利率不在配置区间内(默认2%~5%)时触发审批',
JSON_ARRAY(JSON_OBJECT(
'VariableId', 12,
'Operator', '不介于', 'ThresholdType', 'Fixed', 'Value', JSON_ARRAY(2, 5)
'VariableId', 12, 'VariableName', '保证金利率', 'VariableType', 'Numeric',
'Operator', '不介于', 'ThresholdType', 'fixed', 'Value', JSON_ARRAY(2, 5),
'ThresholdVariableId', JSON_TYPE(NULL), 'ThresholdVariableName', JSON_TYPE(NULL), 'Unit', '%'
)),
'!(client_marginrate.InitMarginRebateRate >= 2 && client_marginrate.InitMarginRebateRate <= 5)',
1, 1, 0, 'SYSTEM', NOW());
@@ -98,9 +99,9 @@ INSERT INTO `glms_risk_rule` (`RuleName`, `RuleText`, `ConditionJson`, `RuleExpr
('保证金收取比例低于最低标准',
'保证金比例低于客户品种最低保证金率时触发审批',
JSON_ARRAY(JSON_OBJECT(
'VariableId', 13,
'Operator', '<', 'ThresholdType', 'Variable',
'ThresholdVariableId', 52
'VariableId', 13, 'VariableName', '保证金比例', 'VariableType', 'Numeric',
'Operator', '<', 'ThresholdType', 'variable', 'Value', JSON_TYPE(NULL),
'ThresholdVariableId', 52, 'ThresholdVariableName', '客户品种最低保证金率', 'Unit', '%'
)),
'trade.MarginRate < config.MinMarginRate',
1, 1, 0, 'SYSTEM', NOW());
@@ -111,9 +112,9 @@ INSERT INTO `glms_risk_rule` (`RuleName`, `RuleText`, `ConditionJson`, `RuleExpr
('起息日早于当前日期',
'合约起息日早于当前日期时触发审批',
JSON_ARRAY(JSON_OBJECT(
'VariableId', 2,
'Operator', '<', 'ThresholdType', 'Variable',
'ThresholdVariableId', 21
'VariableId', 2, 'VariableName', '合约起息日', 'VariableType', 'Date',
'Operator', '<', 'ThresholdType', 'variable', 'Value', JSON_TYPE(NULL),
'ThresholdVariableId', 21, 'ThresholdVariableName', '当前日期', 'Unit', JSON_TYPE(NULL)
)),
'trade.StartDate < sys.CurrentDate',
1, 1, 0, 'SYSTEM', NOW());
@@ -124,8 +125,9 @@ INSERT INTO `glms_risk_rule` (`RuleName`, `RuleText`, `ConditionJson`, `RuleExpr
('支付日为银行间交易日',
'支付日为银行间交易日时触发审批',
JSON_ARRAY(JSON_OBJECT(
'VariableId', 38,
'Operator', '', 'ThresholdType', 'Fixed', 'Value', true
'VariableId', 38, 'VariableName', '支付日是否银行间交易日', 'VariableType', 'Boolean',
'Operator', '', 'ThresholdType', 'fixed', 'Value', true,
'ThresholdVariableId', JSON_TYPE(NULL), 'ThresholdVariableName', JSON_TYPE(NULL), 'Unit', JSON_TYPE(NULL)
)),
'calc.IsSettlementDateTradingDay == true',
1, 1, 0, 'SYSTEM', NOW());
@@ -136,8 +138,9 @@ INSERT INTO `glms_risk_rule` (`RuleName`, `RuleText`, `ConditionJson`, `RuleExpr
('到期日为银行间交易日',
'到期日为银行间交易日时触发审批',
JSON_ARRAY(JSON_OBJECT(
'VariableId', 36,
'Operator', '', 'ThresholdType', 'Fixed', 'Value', true
'VariableId', 36, 'VariableName', '到期日是否银行间交易日', 'VariableType', 'Boolean',
'Operator', '', 'ThresholdType', 'fixed', 'Value', true,
'ThresholdVariableId', JSON_TYPE(NULL), 'ThresholdVariableName', JSON_TYPE(NULL), 'Unit', JSON_TYPE(NULL)
)),
'calc.IsExerciseDateTradingDay == true',
1, 1, 0, 'SYSTEM', NOW());
@@ -148,8 +151,9 @@ INSERT INTO `glms_risk_rule` (`RuleName`, `RuleText`, `ConditionJson`, `RuleExpr
('平仓日为银行间交易日',
'平仓日为银行间交易日时触发审批',
JSON_ARRAY(JSON_OBJECT(
'VariableId', 37,
'Operator', '', 'ThresholdType', 'Fixed', 'Value', true
'VariableId', 37, 'VariableName', '平仓日是否银行间交易日', 'VariableType', 'Boolean',
'Operator', '', 'ThresholdType', 'fixed', 'Value', true,
'ThresholdVariableId', JSON_TYPE(NULL), 'ThresholdVariableName', JSON_TYPE(NULL), 'Unit', JSON_TYPE(NULL)
)),
'calc.IsUnwindDateTradingDay == true',
1, 1, 0, 'SYSTEM', NOW());
@@ -160,8 +164,9 @@ INSERT INTO `glms_risk_rule` (`RuleName`, `RuleText`, `ConditionJson`, `RuleExpr
('合约期限超阈值',
'合约期限超过阈值(默认365天)时触发审批',
JSON_ARRAY(JSON_OBJECT(
'VariableId', 26,
'Operator', '>', 'ThresholdType', 'Fixed', 'Value', 365
'VariableId', 26, 'VariableName', '合约期限', 'VariableType', 'Numeric',
'Operator', '>', 'ThresholdType', 'fixed', 'Value', 365,
'ThresholdVariableId', JSON_TYPE(NULL), 'ThresholdVariableName', JSON_TYPE(NULL), 'Unit', ''
)),
'calc.MaturityDays > 365',
1, 1, 0, 'SYSTEM', NOW());
@@ -172,8 +177,9 @@ INSERT INTO `glms_risk_rule` (`RuleName`, `RuleText`, `ConditionJson`, `RuleExpr
('债券类净价偏离',
'期初净价与上一收盘日中债估值净价偏离度超阈值(默认5%)时触发审批',
JSON_ARRAY(JSON_OBJECT(
'VariableId', 45,
'Operator', '>', 'ThresholdType', 'Fixed', 'Value', 5
'VariableId', 45, 'VariableName', '期初净价偏离度', 'VariableType', 'Numeric',
'Operator', '>', 'ThresholdType', 'fixed', 'Value', 5,
'ThresholdVariableId', JSON_TYPE(NULL), 'ThresholdVariableName', JSON_TYPE(NULL), 'Unit', '%'
)),
'Math.Abs(swap_position.PosiNetNoFeePrice - market.CBValuationNetPrice) / market.CBValuationNetPrice * 100 > 5',
1, 1, 0, 'SYSTEM', NOW());
@@ -184,8 +190,9 @@ INSERT INTO `glms_risk_rule` (`RuleName`, `RuleText`, `ConditionJson`, `RuleExpr
('债券类收益率偏离',
'期初收益率与上一收盘日中债估值收益率偏离度超阈值(默认5%)时触发审批',
JSON_ARRAY(JSON_OBJECT(
'VariableId', 46,
'Operator', '>', 'ThresholdType', 'Fixed', 'Value', 5
'VariableId', 46, 'VariableName', '期初收益率偏离度', 'VariableType', 'Numeric',
'Operator', '>', 'ThresholdType', 'fixed', 'Value', 5,
'ThresholdVariableId', JSON_TYPE(NULL), 'ThresholdVariableName', JSON_TYPE(NULL), 'Unit', '%'
)),
'Math.Abs(trade.InitYtm - market.CBValuationYtm) / market.CBValuationYtm * 100 > 5',
1, 1, 0, 'SYSTEM', NOW());
@@ -196,8 +203,9 @@ INSERT INTO `glms_risk_rule` (`RuleName`, `RuleText`, `ConditionJson`, `RuleExpr
('非债券类价格偏离',
'期初价格与上一日收盘价偏离度超阈值(默认5%)时触发审批',
JSON_ARRAY(JSON_OBJECT(
'VariableId', 47,
'Operator', '>', 'ThresholdType', 'Fixed', 'Value', 5
'VariableId', 47, 'VariableName', '期初价格偏离度', 'VariableType', 'Numeric',
'Operator', '>', 'ThresholdType', 'fixed', 'Value', 5,
'ThresholdVariableId', JSON_TYPE(NULL), 'ThresholdVariableName', JSON_TYPE(NULL), 'Unit', '%'
)),
'Math.Abs(trade.SpotPrice - market.LastClosePrice) / market.LastClosePrice * 100 > 5',
1, 1, 0, 'SYSTEM', NOW());
@@ -208,8 +216,9 @@ INSERT INTO `glms_risk_rule` (`RuleName`, `RuleText`, `ConditionJson`, `RuleExpr
('单一交易对手累计标的数量超阈值',
'对手方累计标的数量超过阈值(默认10个)时触发审批',
JSON_ARRAY(JSON_OBJECT(
'VariableId', 32,
'Operator', '>', 'ThresholdType', 'Fixed', 'Value', 10
'VariableId', 32, 'VariableName', '对手方累计标的数量', 'VariableType', 'Numeric',
'Operator', '>', 'ThresholdType', 'fixed', 'Value', 10,
'ThresholdVariableId', JSON_TYPE(NULL), 'ThresholdVariableName', JSON_TYPE(NULL), 'Unit', ''
)),
'calc.CounterpartyUnderlyingCount > 10',
1, 1, 0, 'SYSTEM', NOW());
@@ -221,12 +230,14 @@ INSERT INTO `glms_risk_rule` (`RuleName`, `RuleText`, `ConditionJson`, `RuleExpr
'多头方向支付固定端场景下,利息端利率与FR007偏离度超阈值(默认3%)时触发审批',
JSON_ARRAY(
JSON_OBJECT(
'VariableId', 41,
'Operator', '', 'ThresholdType', 'Fixed', 'Value', true
'VariableId', 41, 'VariableName', '多空方向为多头', 'VariableType', 'Boolean',
'Operator', '', 'ThresholdType', 'fixed', 'Value', true,
'ThresholdVariableId', JSON_TYPE(NULL), 'ThresholdVariableName', JSON_TYPE(NULL), 'Unit', JSON_TYPE(NULL)
),
JSON_OBJECT(
'VariableId', 48,
'Operator', '>', 'ThresholdType', 'Fixed', 'Value', 3
'VariableId', 48, 'VariableName', '利息端利率与FR007偏离度', 'VariableType', 'Numeric',
'Operator', '>', 'ThresholdType', 'fixed', 'Value', 3,
'ThresholdVariableId', JSON_TYPE(NULL), 'ThresholdVariableName', JSON_TYPE(NULL), 'Unit', '%'
)
),
'calc.IsLongDirection == true && Math.Abs(calc.InterestRate - market.FR007) / market.FR007 * 100 > 3',
@@ -239,12 +250,14 @@ INSERT INTO `glms_risk_rule` (`RuleName`, `RuleText`, `ConditionJson`, `RuleExpr
'空头方向场景下,利息端利率与借贷加权费率偏离度超阈值(默认2%)时触发审批',
JSON_ARRAY(
JSON_OBJECT(
'VariableId', 42,
'Operator', '', 'ThresholdType', 'Fixed', 'Value', true
'VariableId', 42, 'VariableName', '多空方向为空头', 'VariableType', 'Boolean',
'Operator', '', 'ThresholdType', 'fixed', 'Value', true,
'ThresholdVariableId', JSON_TYPE(NULL), 'ThresholdVariableName', JSON_TYPE(NULL), 'Unit', JSON_TYPE(NULL)
),
JSON_OBJECT(
'VariableId', 49,
'Operator', '>', 'ThresholdType', 'Fixed', 'Value', 2
'VariableId', 49, 'VariableName', '利息端利率与借贷加权费率偏离度', 'VariableType', 'Numeric',
'Operator', '>', 'ThresholdType', 'fixed', 'Value', 2,
'ThresholdVariableId', JSON_TYPE(NULL), 'ThresholdVariableName', JSON_TYPE(NULL), 'Unit', '%'
)
),
'calc.IsShortDirection == true && Math.Abs(calc.InterestRate - market.BondLendingRate) / market.BondLendingRate * 100 > 2',
@@ -256,8 +269,9 @@ INSERT INTO `glms_risk_rule` (`RuleName`, `RuleText`, `ConditionJson`, `RuleExpr
('账户授权收支方向不匹配',
'保证金收支方向与账户授权方向不匹配时禁止交易',
JSON_ARRAY(JSON_OBJECT(
'VariableId', 43,
'Operator', '', 'ThresholdType', 'Fixed', 'Value', true
'VariableId', 43, 'VariableName', '保证金收支方向为支付', 'VariableType', 'Boolean',
'Operator', '', 'ThresholdType', 'fixed', 'Value', true,
'ThresholdVariableId', JSON_TYPE(NULL), 'ThresholdVariableName', JSON_TYPE(NULL), 'Unit', JSON_TYPE(NULL)
)),
'calc.IsMarginPay == true',
1, 1, 0, 'SYSTEM', NOW());
@@ -268,8 +282,9 @@ INSERT INTO `glms_risk_rule` (`RuleName`, `RuleText`, `ConditionJson`, `RuleExpr
('执行价偏离超阈值',
'执行价与参考价格偏离度超阈值(默认5%)时触发审批',
JSON_ARRAY(JSON_OBJECT(
'VariableId', 50,
'Operator', '>', 'ThresholdType', 'Fixed', 'Value', 5
'VariableId', 50, 'VariableName', '执行价偏离度', 'VariableType', 'Numeric',
'Operator', '>', 'ThresholdType', 'fixed', 'Value', 5,
'ThresholdVariableId', JSON_TYPE(NULL), 'ThresholdVariableName', JSON_TYPE(NULL), 'Unit', '%'
)),
'Math.Abs(trade.StrikePrice - market.ReferencePrice) / market.ReferencePrice * 100 > 5',
1, 1, 0, 'SYSTEM', NOW());
@@ -1,11 +1,15 @@
namespace YLErp.Modules.RiskEngine.Dto
{
public class RuleCondition
public class FormulaCondition
{
public long VariableId { get; set; }
public string VariableName { get; set; }
public string VariableType { get; set; }
public string Operator { get; set; }
public string ThresholdType { get; set; }
public object Value { get; set; }
public long? ThresholdVariableId { get; set; }
public string ThresholdVariableName { get; set; }
public string Unit { get; set; }
}
}
@@ -0,0 +1,10 @@
using System.Collections.Generic;
namespace YLErp.Modules.RiskEngine.Dto
{
public class FormulaDefinition
{
public string LogicOperator { get; set; }
public List<FormulaCondition> Conditions { get; set; }
}
}
@@ -1,9 +0,0 @@
namespace YLErp.Modules.RiskEngine.Dto
{
public class RiskRuleSimpleItem
{
public long Id { get; set; }
public string RuleName { get; set; }
public string RuleText { get; set; }
}
}
+28 -32
View File
@@ -79,7 +79,6 @@ using YLErp.Modules.RiskEngine.Dto;
GetRuleVersions(long) 获取规则版本历史(从审计日志 SnapshotData 提取版本号)
BatchDeleteRules(List<long>) 批量删除规则(逐条保护检查,单事务)
GetRuleApplications(long) 获取规则关联的应用配置列表
GetAllRuleList() 获取所有启用规则(轻量字段,供应用配置下拉)
── 应用配置管理(9 个) ───────────────────────────────────────────
QueryApplicationList(QueryRiskApplicationReq) 查询应用列表(多条件筛选,内存关联规则名称)
@@ -260,22 +259,25 @@ namespace YLErp.Modules.RiskEngine
private void ValidateConditionJson(string conditionJson)
{
List<RuleCondition> conditions;
FormulaDefinition formula;
try
{
conditions = JsonConvert.DeserializeObject<List<RuleCondition>>(conditionJson);
formula = JsonConvert.DeserializeObject<FormulaDefinition>(conditionJson);
}
catch
{
throw new ServiceException("公式表达式 JSON 格式不合法");
}
if (conditions == null || conditions.Count == 0)
if (formula.Conditions == null || formula.Conditions.Count == 0)
throw new ServiceException("公式条件列表不能为空");
for (int i = 0; i < conditions.Count; i++)
if (formula.LogicOperator != "AND")
throw new ServiceException("当前仅支持 AND 逻辑运算符");
for (int i = 0; i < formula.Conditions.Count; i++)
{
var cond = conditions[i];
var cond = formula.Conditions[i];
var condLabel = $"条件{i + 1}";
var variableDef = DbContext.glms_risk_variable
@@ -287,7 +289,7 @@ namespace YLErp.Modules.RiskEngine
if (!validOperators.Contains(cond.Operator))
throw new ServiceException($"{condLabel}:操作符 '{cond.Operator}' 不适用于{GetDataTypeName(variableDef.DataType)}类型变量");
if (cond.ThresholdType == "Fixed")
if (cond.ThresholdType == "fixed")
{
if (cond.Value == null)
throw new ServiceException($"{condLabel}:固定阈值不能为空");
@@ -302,7 +304,7 @@ namespace YLErp.Modules.RiskEngine
throw new ServiceException($"{condLabel}:日期型变量的阈值必须为合法日期");
}
}
else if (cond.ThresholdType == "Variable")
else if (cond.ThresholdType == "variable")
{
if (!cond.ThresholdVariableId.HasValue)
throw new ServiceException($"{condLabel}:变量阈值引用的变量 ID 不能为空");
@@ -315,7 +317,7 @@ namespace YLErp.Modules.RiskEngine
}
else
{
throw new ServiceException($"{condLabel}:阈值类型 '{cond.ThresholdType}' 不合法,仅支持 Fixed/Variable");
throw new ServiceException($"{condLabel}:阈值类型 '{cond.ThresholdType}' 不合法,仅支持 fixed/variable");
}
}
}
@@ -443,15 +445,23 @@ namespace YLErp.Modules.RiskEngine
if (ruleName.Length > 200)
throw new ServiceException("规则名称长度不能超过200字符");
if (string.IsNullOrWhiteSpace(ruleExpr))
throw new ServiceException("规则表达式不能为空");
bool hasStructured = !string.IsNullOrWhiteSpace(conditionJson);
bool hasFreeText = !string.IsNullOrWhiteSpace(ruleExpr);
if (!string.IsNullOrWhiteSpace(conditionJson))
if (!hasStructured && !hasFreeText)
throw new ServiceException("公式表达式不能为空,请提供结构化条件或自由文本表达式");
if (hasStructured && hasFreeText)
throw new ServiceException("结构化条件和自由文本表达式不能同时提供,请选择其中一种模式");
if (hasStructured)
{
ValidateConditionJson(conditionJson);
}
ValidateRuleExpr(ruleExpr);
else
{
ValidateRuleExpr(ruleExpr);
}
}
private List<long> ParseRuleIds(string ruleIds)
@@ -833,20 +843,6 @@ namespace YLErp.Modules.RiskEngine
return result;
}
public List<RiskRuleSimpleItem> GetAllRuleList()
{
return DbContext.glms_risk_rule
.Where(r => r.Status == RiskRuleStatus.Active)
.OrderBy(r => r.id)
.Select(r => new RiskRuleSimpleItem
{
Id = r.id,
RuleName = r.RuleName,
RuleText = r.RuleText
})
.ToList();
}
#endregion
#region Application Management
@@ -1081,7 +1077,7 @@ namespace YLErp.Modules.RiskEngine
app.UpdateOptName = UserName;
app.UpdateDate = DateTime.Now;
WriteAuditLog("APP_UPDATE", "APPLICATION", applicationId, ResolveRuleNames(app.RuleIds),
WriteAuditLog("APPLICATION_UPDATE", "APPLICATION", applicationId, ResolveRuleNames(app.RuleIds),
$"修改应用配置:策略={req.ControlStrategy}, 触发时点={req.TriggerPoints}");
DbContext.SaveChanges();
@@ -1136,7 +1132,7 @@ namespace YLErp.Modules.RiskEngine
app.UpdateOptName = UserName;
app.UpdateDate = DateTime.Now;
WriteAuditLog("APP_DISABLE", "APPLICATION", applicationId, ResolveRuleNames(app.RuleIds), "停用应用配置");
WriteAuditLog("APPLICATION_DISABLE", "APPLICATION", applicationId, ResolveRuleNames(app.RuleIds), "停用应用配置");
DbContext.SaveChanges();
TryRefreshCache();
@@ -1163,7 +1159,7 @@ namespace YLErp.Modules.RiskEngine
app.UpdateOptName = UserName;
app.UpdateDate = DateTime.Now;
WriteAuditLog("APP_BATCH_ENABLE", "APPLICATION", app.id, ResolveRuleNames(app.RuleIds), "批量启用应用配置");
WriteAuditLog("APPLICATION_BATCH_ENABLE", "APPLICATION", app.id, ResolveRuleNames(app.RuleIds), "批量启用应用配置");
}
DbContext.SaveChanges();
@@ -1362,7 +1358,7 @@ namespace YLErp.Modules.RiskEngine
variable.UpdateOptName = UserName;
variable.UpdateDate = DateTime.Now;
WriteAuditLog("VAR_UPDATE", "VARIABLE", variableId, req.VariableName, $"修改变量:{variable.VariableName}");
WriteAuditLog("VARIABLE_UPDATE", "VARIABLE", variableId, req.VariableName, $"修改变量:{variable.VariableName}");
DbContext.SaveChanges();
InvalidateVariableCache();
@@ -221,27 +221,6 @@ namespace YLErp.Web.Controllers
}
}
[HttpGet("risk-rules/list")]
[MyAuthorize("风控规则查看")]
public JsonResult GetAllRiskRules()
{
try
{
var service = new RiskRuleService(CurUser);
var result = service.GetAllRuleList();
return Json(new { success = true, data = result });
}
catch (ServiceException ex)
{
return Json(new { success = false, message = ex.Message });
}
catch (Exception ex)
{
_logger.Error(ex, "查询规则下拉列表");
return Json(new { success = false, message = "系统异常,请联系管理员" });
}
}
#endregion
#region Application Management