PayrollManagementSystem/db/migration/V28__calc_template_definitions.sql
liuwenxin 2ac4c71106 fix(迁移): 恢复计提模板建表脚本及内置种子
清除误写入 SQL 文件的缓存内容与 NUL 字节。
恢复与 V28 对齐的表结构及五个内置模板。
2026-11-03 17:18:45 +08:00

25 lines
2.5 KiB
SQL
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

CREATE TABLE calc_template_definitions (
id BIGINT UNSIGNED NOT NULL COMMENT '主键ID' AUTO_INCREMENT,
template_code VARCHAR(32) NOT NULL COMMENT '模板编码,创建后不可修改;岗位表calc_template引用',
template_name VARCHAR(64) NOT NULL COMMENT '模板名称',
formula_type VARCHAR(32) NOT NULL COMMENT '公式骨架类型:linear_decay/fixed_profit/fixed_sales/manager_share/prepay_fixed,创建后不可修改',
params_json JSON NOT NULL COMMENT '骨架参数角色到参数编码的JSON映射',
description VARCHAR(255) NULL COMMENT '模板说明',
sort_order INTEGER NOT NULL DEFAULT 0 COMMENT '显示排序',
status TINYINT NOT NULL DEFAULT 1 COMMENT '状态:1启用0停用',
is_system TINYINT NOT NULL DEFAULT 0 COMMENT '是否系统模板:1内置(禁删、骨架与编码锁定)0自定义',
create_time DATETIME NOT NULL COMMENT '创建时间' DEFAULT CURRENT_TIMESTAMP,
update_time DATETIME NOT NULL COMMENT '更新时间' DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
CONSTRAINT pk_calc_template_definitions PRIMARY KEY (id),
CONSTRAINT uk_calc_template_definitions_template_code UNIQUE (template_code)
)ENGINE=InnoDB CHARSET=utf8mb4 COMMENT='计提公式模板定义表(页面可维护,骨架受控)' COLLATE utf8mb4_general_ci;
INSERT INTO calc_template_definitions
(template_code, template_name, formula_type, params_json, description, sort_order, status, is_system)
VALUES
('TPL_SALESPERSON_DECAY', '业务员个人户·天数线性递减', 'linear_decay', JSON_OBJECT('start','salesperson.rate.start','slope','salesperson.rate.slope','floor','salesperson.rate.floor','boundary','salesperson.days.boundary'), '分段:≤分界天数 = 起始 − 天数×斜率;>分界天数 = 下限', 10, 1, 1),
('TPL_MANAGER_SHARE', '营销经理·团队与全公司分成', 'manager_share', JSON_OBJECT('team','manager.share.team','company','manager.share.company'), '聚合:本团队业务员绩效×团队比例 + 全公司业务员绩效×公司比例', 20, 1, 1),
('TPL_ENTERPRISE_FIXED', '企业户·固定计提', 'fixed_profit', JSON_OBJECT('rate','enterprise.rate'), '乘法:折算毛利润额 × 固定计提比例', 30, 1, 1),
('TPL_INFO_SALES_FIXED', '信息员·销售额固定比例', 'fixed_sales', JSON_OBJECT('rate','info.rate'), '乘法:本人销售额 × 固定计提比例', 40, 1, 1),
('TPL_PREPAY_FIXED', '预付款·固定计提', 'prepay_fixed', JSON_OBJECT('rate','prepay.rate'), '乘法:预付回款额 × 预付比例', 50, 1, 1);