This commit is contained in:
Your Name
2026-05-11 16:10:06 +08:00
parent 62d15efbaf
commit 15cf6324f6
8 changed files with 2349 additions and 19 deletions
@@ -0,0 +1,31 @@
-- 提成结算:核对记录 + 顺延结转(上期「确定业绩」时写入,下期统计自动并入订单池)
CREATE TABLE IF NOT EXISTS `zyt_commission_settlement_confirm` (
`id` int unsigned NOT NULL AUTO_INCREMENT,
`settlement_month` char(7) NOT NULL COMMENT '结算月 YYYY-MM',
`scope_channel_code` varchar(128) NOT NULL DEFAULT '' COMMENT '与查询渠道一致,空为全渠道',
`scope_dept_ids_key` varchar(255) NOT NULL DEFAULT '*' COMMENT '部门筛选键:* 或排序后的 id 逗号串',
`status` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0已保存核对 1已确定业绩',
`reconcile_note` varchar(500) NOT NULL DEFAULT '' COMMENT '核对备注',
`totals_json` text COMMENT '确定时汇总快照 JSON',
`confirmed_admin_id` int unsigned NOT NULL DEFAULT 0,
`confirmed_admin_name` varchar(64) NOT NULL DEFAULT '',
`confirmed_at` int unsigned NOT NULL DEFAULT 0 COMMENT '确定业绩时间戳',
`create_time` int unsigned NOT NULL DEFAULT 0,
`update_time` int unsigned NOT NULL DEFAULT 0,
PRIMARY KEY (`id`),
UNIQUE KEY `uk_scope` (`settlement_month`,`scope_channel_code`(64),`scope_dept_ids_key`(128))
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='提成结算核对/确定';
CREATE TABLE IF NOT EXISTS `zyt_commission_settlement_carry` (
`id` int unsigned NOT NULL AUTO_INCREMENT,
`prescription_order_id` int unsigned NOT NULL COMMENT '业务订单 tcm_prescription_order.id',
`target_settlement_month` char(7) NOT NULL COMMENT '计入哪个月结算池',
`source_settlement_month` char(7) NOT NULL COMMENT '从哪个月确定顺延出来',
`scope_channel_code` varchar(128) NOT NULL DEFAULT '',
`scope_dept_ids_key` varchar(255) NOT NULL DEFAULT '*',
`create_time` int unsigned NOT NULL DEFAULT 0,
PRIMARY KEY (`id`),
UNIQUE KEY `uk_carry` (`prescription_order_id`,`target_settlement_month`,`scope_channel_code`(64),`scope_dept_ids_key`(64)),
KEY `idx_target_scope` (`target_settlement_month`,`scope_channel_code`(32),`scope_dept_ids_key`(64)),
KEY `idx_source_scope` (`source_settlement_month`,`scope_channel_code`(32),`scope_dept_ids_key`(64))
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='提成顺延结转';
@@ -0,0 +1,101 @@
-- 提成结算业绩:独立页面 fans/commission-settlement + stats.commissionSettlement/* 接口权限
-- 与业绩看板 yeji 同父菜单(pid = 业绩看板菜单 id 293);幂等
INSERT INTO `zyt_system_menu`
(`pid`, `type`, `name`, `icon`, `sort`, `perms`, `paths`, `component`, `selected`, `params`, `is_show`, `is_disable`, `create_time`, `update_time`)
SELECT
y.pid,
'C',
'提成结算业绩',
'',
96,
'fans/commission-settlement',
'/fans/commission-settlement',
'fans/commission-settlement',
'',
'',
1,
0,
UNIX_TIMESTAMP(),
UNIX_TIMESTAMP()
FROM (SELECT pid FROM `zyt_system_menu` WHERE id = 293 LIMIT 1) AS y
WHERE EXISTS (SELECT 1 FROM `zyt_system_menu` WHERE id = 293)
AND NOT EXISTS (
SELECT 1 FROM `zyt_system_menu` m WHERE m.component = 'fans/commission-settlement'
);
SET @commission_cs_pid := (
SELECT id FROM `zyt_system_menu` WHERE component = 'fans/commission-settlement' ORDER BY id DESC LIMIT 1
);
INSERT INTO `zyt_system_menu`
(`pid`, `type`, `name`, `icon`, `sort`, `perms`, `paths`, `component`, `selected`, `params`, `is_show`, `is_disable`, `create_time`, `update_time`)
SELECT
@commission_cs_pid,
'A',
'提成结算-汇总',
'',
1,
'stats.commissionSettlement/overview',
'',
'',
'',
'',
1,
0,
UNIX_TIMESTAMP(),
UNIX_TIMESTAMP()
FROM (SELECT 1 AS `_`) AS `_exec`
WHERE @commission_cs_pid IS NOT NULL
AND NOT EXISTS (
SELECT 1 FROM `zyt_system_menu` m
WHERE m.pid = @commission_cs_pid AND m.perms = 'stats.commissionSettlement/overview'
);
INSERT INTO `zyt_system_menu`
(`pid`, `type`, `name`, `icon`, `sort`, `perms`, `paths`, `component`, `selected`, `params`, `is_show`, `is_disable`, `create_time`, `update_time`)
SELECT
@commission_cs_pid,
'A',
'提成结算-部门下拉',
'',
2,
'stats.commissionSettlement/deptOptions',
'',
'',
'',
'',
1,
0,
UNIX_TIMESTAMP(),
UNIX_TIMESTAMP()
FROM (SELECT 1 AS `_`) AS `_exec`
WHERE @commission_cs_pid IS NOT NULL
AND NOT EXISTS (
SELECT 1 FROM `zyt_system_menu` m
WHERE m.pid = @commission_cs_pid AND m.perms = 'stats.commissionSettlement/deptOptions'
);
INSERT INTO `zyt_system_menu`
(`pid`, `type`, `name`, `icon`, `sort`, `perms`, `paths`, `component`, `selected`, `params`, `is_show`, `is_disable`, `create_time`, `update_time`)
SELECT
@commission_cs_pid,
'A',
'提成结算-渠道下拉',
'',
3,
'stats.commissionSettlement/channelOptions',
'',
'',
'',
'',
1,
0,
UNIX_TIMESTAMP(),
UNIX_TIMESTAMP()
FROM (SELECT 1 AS `_`) AS `_exec`
WHERE @commission_cs_pid IS NOT NULL
AND NOT EXISTS (
SELECT 1 FROM `zyt_system_menu` m
WHERE m.pid = @commission_cs_pid AND m.perms = 'stats.commissionSettlement/channelOptions'
);
@@ -0,0 +1,101 @@
-- 提成结算:核对/确定业绩接口权限(挂在 fans/commission-settlement 页面菜单下)
SET @commission_cs_pid := (
SELECT id FROM `zyt_system_menu` WHERE component = 'fans/commission-settlement' ORDER BY id DESC LIMIT 1
);
INSERT INTO `zyt_system_menu`
(`pid`, `type`, `name`, `icon`, `sort`, `perms`, `paths`, `component`, `selected`, `params`, `is_show`, `is_disable`, `create_time`, `update_time`)
SELECT
@commission_cs_pid,
'A',
'提成结算-核对明细',
'',
11,
'stats.commissionSettlement/orderLines',
'',
'',
'',
'',
1,
0,
UNIX_TIMESTAMP(),
UNIX_TIMESTAMP()
FROM (SELECT 1 AS `_`) AS `_exec`
WHERE @commission_cs_pid IS NOT NULL
AND NOT EXISTS (
SELECT 1 FROM `zyt_system_menu` m
WHERE m.pid = @commission_cs_pid AND m.perms = 'stats.commissionSettlement/orderLines'
);
INSERT INTO `zyt_system_menu`
(`pid`, `type`, `name`, `icon`, `sort`, `perms`, `paths`, `component`, `selected`, `params`, `is_show`, `is_disable`, `create_time`, `update_time`)
SELECT
@commission_cs_pid,
'A',
'提成结算-确认状态',
'',
12,
'stats.commissionSettlement/confirmStatus',
'',
'',
'',
'',
1,
0,
UNIX_TIMESTAMP(),
UNIX_TIMESTAMP()
FROM (SELECT 1 AS `_`) AS `_exec`
WHERE @commission_cs_pid IS NOT NULL
AND NOT EXISTS (
SELECT 1 FROM `zyt_system_menu` m
WHERE m.pid = @commission_cs_pid AND m.perms = 'stats.commissionSettlement/confirmStatus'
);
INSERT INTO `zyt_system_menu`
(`pid`, `type`, `name`, `icon`, `sort`, `perms`, `paths`, `component`, `selected`, `params`, `is_show`, `is_disable`, `create_time`, `update_time`)
SELECT
@commission_cs_pid,
'A',
'提成结算-保存核对',
'',
13,
'stats.commissionSettlement/saveReconcile',
'',
'',
'',
'',
1,
0,
UNIX_TIMESTAMP(),
UNIX_TIMESTAMP()
FROM (SELECT 1 AS `_`) AS `_exec`
WHERE @commission_cs_pid IS NOT NULL
AND NOT EXISTS (
SELECT 1 FROM `zyt_system_menu` m
WHERE m.pid = @commission_cs_pid AND m.perms = 'stats.commissionSettlement/saveReconcile'
);
INSERT INTO `zyt_system_menu`
(`pid`, `type`, `name`, `icon`, `sort`, `perms`, `paths`, `component`, `selected`, `params`, `is_show`, `is_disable`, `create_time`, `update_time`)
SELECT
@commission_cs_pid,
'A',
'提成结算-确定业绩',
'',
14,
'stats.commissionSettlement/confirmFinalize',
'',
'',
'',
'',
1,
0,
UNIX_TIMESTAMP(),
UNIX_TIMESTAMP()
FROM (SELECT 1 AS `_`) AS `_exec`
WHERE @commission_cs_pid IS NOT NULL
AND NOT EXISTS (
SELECT 1 FROM `zyt_system_menu` m
WHERE m.pid = @commission_cs_pid AND m.perms = 'stats.commissionSettlement/confirmFinalize'
);