-- 商家子客服：权限码初始化（部署后执行一次，或使用 python manage.py seed_merchant_staff）
-- 表 merchant_staff_permission

INSERT INTO merchant_staff_permission (perm_code, perm_name, sort_order, status, CreateTime, UpdateTime) VALUES
('staff_manage', '子客服管理', 0, 1, NOW(), NOW()),
('role_manage', '角色管理', 1, 1, NOW(), NOW()),
('wallet_allocate', '划额度', 2, 1, NOW(), NOW()),
('wallet_revoke', '收回额度', 3, 1, NOW(), NOW()),
('wallet_view', '查看额度', 4, 1, NOW(), NOW()),
('finance_view', '查看商家余额', 4, 1, NOW(), NOW()),
('order_dispatch', '派单发单', 5, 1, NOW(), NOW()),
('order_view_all', '查看全部订单', 6, 1, NOW(), NOW()),
('order_view_self', '只看自己派的单', 7, 1, NOW(), NOW()),
('order_detail', '订单详情', 8, 1, NOW(), NOW()),
('order_settle', '结单', 9, 1, NOW(), NOW()),
('order_refund_apply', '申请退款', 10, 1, NOW(), NOW()),
('order_cancel', '撤销订单', 11, 1, NOW(), NOW()),
('order_change_player', '换打手', 12, 1, NOW(), NOW()),
('penalty_apply', '申请罚单', 13, 1, NOW(), NOW()),
('penalty_manage', '改撤罚单', 14, 1, NOW(), NOW()),
('penalty_view', '查看罚单', 15, 1, NOW(), NOW()),
('staff_disable', '封禁解封客服', 16, 1, NOW(), NOW()),
('template_manage', '派单模板', 17, 1, NOW(), NOW()),
('audit_view', '操作日志', 18, 1, NOW(), NOW()),
('rank_view', '客服排行榜', 19, 1, NOW(), NOW()),
('im_chat', '订单IM', 20, 1, NOW(), NOW()),
('stats_view', '统计数据', 21, 1, NOW(), NOW())
ON DUPLICATE KEY UPDATE perm_name=VALUES(perm_name), sort_order=VALUES(sort_order);

-- 推荐：执行完 SQL 后运行
-- python manage.py seed_merchant_staff
-- 会自动创建系统角色模板及角色-权限关联
