Files
huangjingfen/pro_v3.5.1/help/migrations/fsgx_v1.sql
apple 76ccb24679 feat(fsgx): HJF queue merge, brokerage timing, cycle commission, points release
- Add HJF jobs, services, DAOs, models, admin/API controllers, release command
- Respect brokerage_timing (on_pay vs confirm); dispatch HjfOrderPayJob for queue goods
- Queue-only cycle commission and position index fix in StoreOrderCreateServices
- UserBill income types: frozen_points_brokerage, frozen_points_release
- Timer: fsgx_release_frozen_points -> PointsReleaseServices
- Agent tasks: no_assess filtering for direct/umbrella counts
- Migrations: queue_pool, points_release_log, fsgx_v1 checklist updates
- Admin/uniapp: crontab preset, membership level, user list, finance routes, docs

Made-with: Cursor
2026-03-24 11:59:09 +08:00

96 lines
6.2 KiB
SQL
Raw 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.
-- ============================================================
-- 范氏国香商城 fsgx 改造数据库迁移脚本
-- 执行顺序:按 Step 编号依次执行
-- ============================================================
-- Step 1: eb_store_product 新增报单商品标记字段
-- 注MySQL 5.7 不支持 ADD COLUMN IF NOT EXISTS重复执行会报错已存在时跳过即可
ALTER TABLE `eb_store_product`
ADD COLUMN `is_queue_goods` tinyint(1) NOT NULL DEFAULT 0 COMMENT '报单商品:1=是,0=否' AFTER `is_brokerage`;
-- Step 1b: eb_store_order 新增报单商品标记(冗余存储,加速佣金周期计数)
ALTER TABLE `eb_store_order`
ADD COLUMN `is_queue_goods` tinyint(1) NOT NULL DEFAULT 0 COMMENT '报单商品订单:1=是,0=否' AFTER `spread_two_uid`;
-- Step 2: eb_user 新增积分字段与不考核字段
ALTER TABLE `eb_user`
ADD COLUMN `frozen_points` int(11) NOT NULL DEFAULT 0 COMMENT '待释放积分' AFTER `integral`,
ADD COLUMN `available_points` int(11) NOT NULL DEFAULT 0 COMMENT '已释放积分' AFTER `frozen_points`,
ADD COLUMN `no_assess` tinyint(1) NOT NULL DEFAULT 0 COMMENT '不考核:1=是,0=否' AFTER `available_points`;
-- Step 2b: eb_agent_level 新增直推/伞下奖励积分字段 + 返佣比例展示字段
ALTER TABLE `eb_agent_level`
ADD COLUMN `direct_reward_points` int(11) NOT NULL DEFAULT 0 COMMENT '直推奖励积分' AFTER `two_brokerage`,
ADD COLUMN `umbrella_reward_points` int(11) NOT NULL DEFAULT 0 COMMENT '伞下奖励积分' AFTER `direct_reward_points`,
ADD COLUMN `one_brokerage_ratio` decimal(5,2) NOT NULL DEFAULT 0 COMMENT '一级返佣比例(上浮后)' AFTER `umbrella_reward_points`,
ADD COLUMN `two_brokerage_ratio` decimal(5,2) NOT NULL DEFAULT 0 COMMENT '二级返佣比例(上浮后)' AFTER `one_brokerage_ratio`;
-- Step 3: eb_system_timer 新增每日积分释放定时任务
-- type=4 表示"每天"cycle 格式为"小时/分钟"(如 2/0 = 凌晨2点整
-- 表中无 status 字段is_open 控制是否启用mark 无唯一索引,先删再插保证幂等
DELETE FROM `eb_system_timer` WHERE `mark` = 'fsgx_release_frozen_points';
INSERT INTO `eb_system_timer` (`name`, `title`, `mark`, `type`, `cycle`, `is_open`, `add_time`)
VALUES ('fsgx每日积分释放', 'fsgx每日释放待释放积分0.4‰转入可用积分)', 'fsgx_release_frozen_points', 4, '2/0', 1, UNIX_TIMESTAMP());
-- Step 4: eb_system_config 新增返佣周期配置键和提现手续费
-- 实际表字段value非 config_value、config_tab_id非 group_iddesc 为保留字需加反引号
-- 使用 DELETE+INSERT 保证幂等
DELETE FROM `eb_system_config` WHERE `menu_name` IN ('brokerage_cycle_count','brokerage_cycle_rates','brokerage_scope','brokerage_timing','extract_fee');
-- value 字段存储 JSON 编码后的值(与 save_basics 的 json_encode 行为一致)
-- 字符串类型:用双引号括起来,如 "queue_only";数字直接写;数组写 JSON 数组
INSERT INTO `eb_system_config` (`menu_name`, `info`, `config_tab_id`, `type`, `input_type`, `value`, `desc`, `sort`, `status`)
VALUES
('brokerage_cycle_count', '佣金周期人数', 0, 'text', 'input', '3', '推荐N人为一个周期循环计算各档佣金比例', 10, 1),
('brokerage_cycle_rates', '佣金分档比例(JSON)', 0, 'text', 'input', '[20,30,50]', '各档佣金比例JSON数组如[20,30,50]表示20%/30%/50%', 9, 1),
('brokerage_scope', '返佣范围', 0, 'text', 'input', '"queue_only"', '返佣范围all=所有商品 queue_only=仅报单商品', 8, 1),
('brokerage_timing', '佣金发放时机', 0, 'text', 'input', '"on_pay"', '发放时机on_pay=支付即发 on_confirm=确认收货后', 7, 1),
('extract_fee', '提现手续费率(%)', 0, 'text', 'input', '7', '提现时扣除的手续费百分比默认7%', 6, 1);
-- Step 5: 新建公排池表和积分释放日志表
CREATE TABLE IF NOT EXISTS `eb_queue_pool` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`uid` int(11) NOT NULL DEFAULT 0,
`order_id` varchar(50) NOT NULL DEFAULT '',
`amount` decimal(10,2) NOT NULL DEFAULT 3600.00,
`queue_no` int(11) NOT NULL DEFAULT 0,
`status` tinyint(1) NOT NULL DEFAULT 0,
`refund_time` int(11) NOT NULL DEFAULT 0,
`trigger_batch` int(11) NOT NULL DEFAULT 0,
`add_time` int(11) NOT NULL DEFAULT 0,
PRIMARY KEY (`id`),
UNIQUE KEY `uniq_queue_no` (`queue_no`),
INDEX `idx_uid` (`uid`),
INDEX `idx_status_add_time` (`status`, `add_time`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='公排池';
CREATE TABLE IF NOT EXISTS `eb_points_release_log` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`uid` int(11) NOT NULL DEFAULT 0,
`points` int(11) NOT NULL DEFAULT 0,
`pm` tinyint(1) NOT NULL DEFAULT 1,
`type` varchar(50) NOT NULL DEFAULT '',
`title` varchar(255) NOT NULL DEFAULT '',
`mark` varchar(500) NOT NULL DEFAULT '',
`status` varchar(30) NOT NULL DEFAULT 'frozen',
`order_id` varchar(50) NOT NULL DEFAULT '',
`release_date` date DEFAULT NULL,
`add_time` int(11) NOT NULL DEFAULT 0,
PRIMARY KEY (`id`),
INDEX `idx_uid_type` (`uid`, `type`),
INDEX `idx_uid_add_time` (`uid`, `add_time`),
INDEX `idx_release_date` (`release_date`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='积分释放明细日志';
-- Step 6: 更新分销等级升级任务配置(对齐验收清单)
DELETE FROM `eb_agent_level_task`;
INSERT INTO `eb_agent_level_task` (`level_id`, `name`, `type`, `number`, `is_must`, `sort`, `status`, `is_del`, `add_time`)
VALUES
(1, '直推人数>=1人', 8, 1, 1, 1, 1, 0, UNIX_TIMESTAMP()),
(2, '直推人数>=3人', 8, 3, 1, 1, 1, 0, UNIX_TIMESTAMP()),
(3, '直推人数>=10人', 8, 10, 1, 1, 1, 0, UNIX_TIMESTAMP()),
(3, '伞下队列订单>=30', 7, 30, 1, 2, 1, 0, UNIX_TIMESTAMP()),
(4, '直推人数>=30人', 8, 30, 1, 1, 1, 0, UNIX_TIMESTAMP()),
(4, '伞下队列订单>=100',7, 100, 1, 2, 1, 0, UNIX_TIMESTAMP());