/*
 Navicat Premium Data Transfer

 Source Server         : yunzhupaas
 Source Server Type    : MySQL
 Source Server Version : 80407
 Source Host           : mysql.szlecheng.cn:13306
 Source Schema         : yunzhupaas

 Target Server Type    : MySQL
 Target Server Version : 80407
 File Encoding         : 65001

 Date: 08/05/2026 14:47:50
*/

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for bc_billing_rule
-- ----------------------------
DROP TABLE IF EXISTS `bc_billing_rule`;
CREATE TABLE `bc_billing_rule`  (
  `rule_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '计费规则ID',
  `rule_code` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '计费规则编码',
  `rule_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '计费规则名称',
  `rule_type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '费用类别。枚举：\r\nRecurring=周期类：按固定时间周期收取的固定或可变费用。（如：月租金、年订阅费）\r\nFixed=固定金额：合同约定的、与时间或用量无关的确定金额。（如：一次性加盟费、保证金）\r\nUnitQty=单价 × 约定数量：合同已明确单价和约定数量（如：采购100台设备，单价5000元）\r\nUsage=单价 × 实际用量：合同只约定单价，费用按实际发生量结算。（如：云存储费，单价0.1元/GB/月）\r\nPercentage=比例/分成费用：以某个金额基数的约定比例计算。（如：按销售额的5%支付授权费）\r\nConditional=或有/条件费用：是否发生及金额取决于未来条件。（如：延期交付违约金，每天合同总额的0.1%）\r\nComposite=混合/套餐费用：固定费用与可变费用（用量/比例）的组合体。（如：套餐月费199元，含1000分钟，超量部分0.1元/分钟）',
  `is_active` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '是否启用。Y=启用、N=禁用',
  `contract_type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '适用的合同类型。枚举：Lease=租赁合同、Purchase=购买合同、Service=服务合同等（对应合同界面模版）',
  `calculation_logic` json NULL COMMENT '计费逻辑定义(JSON)',
  `remark` varchar(500) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '备注',
  `create_by` varchar(50) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '创建人ID',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `update_by` varchar(0) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '更新人ID',
  `f_tenant_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '租户id',
  `f_flow_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '流程id',
  `f_flow_task_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '流程任务主键',
  PRIMARY KEY (`rule_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '计费规则主表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of bc_billing_rule
-- ----------------------------

-- ----------------------------
-- Table structure for bc_billing_rule_modifier
-- ----------------------------
DROP TABLE IF EXISTS `bc_billing_rule_modifier`;
CREATE TABLE `bc_billing_rule_modifier`  (
  `modifier_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '修饰词ID',
  `rule_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '计费主规则ID',
  `modifier_type` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '修饰器类型。枚举：Tiered=阶梯、Bounded=保底封顶、Discount=折扣、Bundle=套餐、Couditional=条件',
  `modifier_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '修饰器名称，如：阶梯计价',
  `execution_order` int NULL DEFAULT 0 COMMENT '执行顺序',
  `modifier_config` json NOT NULL COMMENT '修饰器配置(JSON)',
  `condition_expression` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '生效条件表达式',
  `remark` varchar(500) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '备注',
  `create_by` varchar(50) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '创建人ID',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `update_by` varchar(0) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '更新人ID',
  `f_tenant_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '租户id',
  PRIMARY KEY (`modifier_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '计费规则修饰器表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of bc_billing_rule_modifier
-- ----------------------------

-- ----------------------------
-- Table structure for bc_billing_rule_param
-- ----------------------------
DROP TABLE IF EXISTS `bc_billing_rule_param`;
CREATE TABLE `bc_billing_rule_param`  (
  `param_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '参数ID',
  `rule_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '所属规则ID',
  `param_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '参数编码，如：unit_price, usage_field',
  `param_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '参数名称，如：单价, 用量字段',
  `param_type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '参数类型。枚举：Number=数字, String=字符, Date=日期, Boolean=布尔, Enum=枚举',
  `is_required` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '0' COMMENT '是否必填。Y=是、N=否',
  `default_value` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '默认值',
  `min_value` decimal(20, 4) NULL DEFAULT NULL COMMENT '最小值',
  `max_value` decimal(20, 4) NULL DEFAULT NULL COMMENT '最大值',
  `enum_values` json NULL COMMENT '枚举值选项，用于ENUM类型',
  `data_source` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '数据来源。枚举：Manual=手动填写，System=系统取值，API=第三方接口获取',
  `source_field` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '来源字段名',
  `seq_num` int NULL DEFAULT 0 COMMENT '显示顺序',
  `validation_rule` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '验证规则表达式',
  `description` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '参数描述',
  `remark` varchar(500) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '备注',
  `create_by` varchar(50) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '创建人ID',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `update_by` varchar(0) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '更新人ID',
  `f_tenant_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '租户id',
  PRIMARY KEY (`param_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '计费规则参数定义表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of bc_billing_rule_param
-- ----------------------------

-- ----------------------------
-- Table structure for bc_billing_rule_variable
-- ----------------------------
DROP TABLE IF EXISTS `bc_billing_rule_variable`;
CREATE TABLE `bc_billing_rule_variable`  (
  `variable_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '变量ID',
  `rule_id` bigint NOT NULL COMMENT '计费规则ID',
  `variable_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '变量名，如：usage_amount, contract_amount',
  `variable_type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '变量类型: INPUT, CONTEXT, CALCULATED',
  `source_type` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '来源类型: CONTRACT, SUBJECT, EXTERNAL, MANUAL',
  `source_path` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '来源路径',
  `data_type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '数据类型: NUMBER, STRING, DATE, BOOLEAN',
  `default_value` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '默认值',
  `refresh_interval` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '刷新间隔: REALTIME, DAILY, MONTHLY',
  `cache_ttl` int NULL DEFAULT NULL COMMENT '缓存时间(秒)',
  `validation_rule` json NULL COMMENT '验证规则',
  `remark` varchar(500) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '备注',
  `create_by` varchar(50) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '创建人ID',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `update_by` varchar(0) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '更新人ID',
  `f_tenant_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '租户id',
  PRIMARY KEY (`variable_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '计费规则变量映射表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of bc_billing_rule_variable
-- ----------------------------

SET FOREIGN_KEY_CHECKS = 1;
