Files
anxinyan/server-api/tools/db_seed.php
wushumin 9aac78b8da first
2026-05-11 15:28:27 +08:00

332 lines
27 KiB
PHP

<?php
declare(strict_types=1);
require dirname(__DIR__) . '/vendor/autoload.php';
$dotenv = Dotenv\Dotenv::createImmutable(dirname(__DIR__));
$dotenv->safeLoad();
$dsn = sprintf(
'mysql:host=%s;port=%s;dbname=%s;charset=%s',
$_ENV['DB_HOST'] ?? '127.0.0.1',
$_ENV['DB_PORT'] ?? '3306',
$_ENV['DB_DATABASE'] ?? '',
$_ENV['DB_CHARSET'] ?? 'utf8mb4'
);
$pdo = new PDO(
$dsn,
$_ENV['DB_USERNAME'] ?? '',
$_ENV['DB_PASSWORD'] ?? '',
[
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
]
);
$tables = [
'shipping_warehouses',
'order_shipping_targets',
'material_tag_scan_logs', 'material_batch_download_logs', 'material_tag_codes', 'material_batches',
'enterprise_webhook_deliveries', 'enterprise_order_events', 'enterprise_customer_order_refs', 'enterprise_api_nonces', 'enterprise_customer_apps', 'enterprise_customers',
'user_api_tokens', 'sms_code_logs',
'admin_api_tokens', 'admin_role_permissions', 'admin_permissions', 'admin_role_relations', 'admin_roles', 'operation_logs', 'system_configs', 'admin_users',
'ticket_messages', 'tickets',
'user_messages', 'message_logs', 'message_rules', 'message_templates',
'upload_template_items', 'upload_templates',
'report_verifies', 'report_contents', 'reports',
'appraisal_task_key_points', 'appraisal_task_results', 'appraisal_task_reviews', 'appraisal_task_logs', 'appraisal_tasks',
'order_supplement_task_items', 'order_supplement_tasks', 'order_timelines', 'order_extras', 'order_products', 'orders',
'catalog_brand_categories', 'catalog_brands', 'catalog_categories',
'user_addresses', 'user_auths', 'users',
];
foreach ($tables as $table) {
$pdo->exec("TRUNCATE TABLE {$table}");
}
$now = date('Y-m-d H:i:s');
$userPasswordHash = password_hash('User@123456', PASSWORD_BCRYPT);
$adminPasswordHash = password_hash('Admin@123456', PASSWORD_BCRYPT);
$pdo->exec("
INSERT INTO users (id, nickname, avatar, mobile, password, status, created_at, updated_at) VALUES
(1, '安心验体验用户', '', '13800000000', '{$userPasswordHash}', 'enabled', '{$now}', '{$now}');
INSERT INTO user_addresses (id, user_id, consignee, mobile, province, city, district, detail_address, is_default, created_at, updated_at) VALUES
(1, 1, '安心验体验用户', '13800000000', '广东省', '深圳市', '南山区', '科技园测试路 88 号', 1, '{$now}', '{$now}');
INSERT INTO shipping_warehouses (id, warehouse_name, warehouse_code, warehouse_type, service_provider, receiver_name, receiver_mobile, province, city, district, detail_address, service_time, notice, supported_category_ids_json, service_area_provinces_json, service_area_cities_json, status, is_default, sort_order, remark, created_at, updated_at) VALUES
(1, '安心验鉴定中心', 'AXY-WH-DEFAULT', 'detection_center', 'anxinyan', '安心验鉴定中心', '400-800-1314', '广东省', '深圳市', '南山区', '科技园鉴定路 88 号 安心验收件中心', '周一至周日 09:30-18:30', '寄送前请确认订单信息完整,包裹内附上订单号可提升签收后的处理效率。', NULL, NULL, NULL, 'enabled', 1, 1, '默认仓库', '{$now}', '{$now}'),
(2, '中检合作鉴定中心', 'ZJ-WH-DEFAULT', 'detection_center', 'zhongjian', '中检合作鉴定中心', '400-800-1314', '广东省', '深圳市', '南山区', '科技园鉴定路 88 号 安心验中检收件中心', '周一至周日 09:30-18:30', '中检鉴定订单请优先附上鉴定单号,寄出后尽快填写运单号。', NULL, NULL, NULL, 'enabled', 1, 1, '默认仓库', '{$now}', '{$now}');
INSERT INTO catalog_categories (id, name, code, sort_order, is_enabled, need_shipping, supported_service_types, created_at, updated_at) VALUES
(1, '奢侈品箱包', 'luxury_bag', 1, 1, 1, JSON_ARRAY('anxinyan', 'zhongjian'), '{$now}', '{$now}'),
(2, '潮流鞋类', 'sneaker', 2, 1, 1, JSON_ARRAY('anxinyan', 'zhongjian'), '{$now}', '{$now}'),
(3, '腕表', 'watch', 3, 1, 1, JSON_ARRAY('anxinyan', 'zhongjian'), '{$now}', '{$now}'),
(4, '首饰配饰', 'jewelry', 4, 1, 1, JSON_ARRAY('anxinyan', 'zhongjian'), '{$now}', '{$now}'),
(5, '3C 数码', 'digital', 5, 1, 1, JSON_ARRAY('anxinyan'), '{$now}', '{$now}'),
(6, '高端美妆', 'beauty', 6, 1, 1, JSON_ARRAY('anxinyan'), '{$now}', '{$now}');
INSERT INTO catalog_brands (id, name, en_name, code, sort_order, is_enabled, supported_service_types, created_at, updated_at) VALUES
(1, 'Louis Vuitton', 'Louis Vuitton', 'lv', 1, 1, JSON_ARRAY('anxinyan', 'zhongjian'), '{$now}', '{$now}'),
(2, 'Nike', 'Nike', 'nike', 2, 1, JSON_ARRAY('anxinyan', 'zhongjian'), '{$now}', '{$now}'),
(3, 'Rolex', 'Rolex', 'rolex', 3, 1, JSON_ARRAY('anxinyan', 'zhongjian'), '{$now}', '{$now}');
INSERT INTO catalog_brand_categories (id, brand_id, category_id, created_at) VALUES
(1, 1, 1, '{$now}'),
(2, 2, 2, '{$now}'),
(3, 3, 3, '{$now}');
INSERT INTO upload_templates (id, name, code, scope_type, scope_id, service_provider, is_default, is_enabled, created_at, updated_at) VALUES
(1, '箱包上传模板-安心验', 'bag_upload_anxinyan', 'category', 1, 'anxinyan', 1, 1, '{$now}', '{$now}'),
(2, '箱包上传模板-中检', 'bag_upload_zhongjian', 'category', 1, 'zhongjian', 1, 1, '{$now}', '{$now}'),
(3, '鞋类上传模板-安心验', 'shoe_upload_anxinyan', 'category', 2, 'anxinyan', 1, 1, '{$now}', '{$now}'),
(4, '鞋类上传模板-中检', 'shoe_upload_zhongjian', 'category', 2, 'zhongjian', 1, 1, '{$now}', '{$now}'),
(5, '腕表上传模板-安心验', 'watch_upload_anxinyan', 'category', 3, 'anxinyan', 1, 1, '{$now}', '{$now}'),
(6, '腕表上传模板-中检', 'watch_upload_zhongjian', 'category', 3, 'zhongjian', 1, 1, '{$now}', '{$now}');
INSERT INTO upload_template_items (id, template_id, item_code, item_name, is_required, guide_text, sample_image_url, max_upload_count, sort_order, is_enabled, created_at, updated_at) VALUES
(1, 1, 'overall_front', '商品整体图', 1, '请拍摄商品整体外观,确保主体完整入镜。', '', 1, 1, 1, '{$now}', '{$now}'),
(2, 1, 'logo_detail', '品牌标识图', 1, '请拍摄 Logo 或标识位置,保证图像清晰无遮挡。', '', 1, 2, 1, '{$now}', '{$now}'),
(3, 1, 'serial_label', '编码 / 标签图', 1, '请拍摄商品编码、标签或序列信息,确保内容可辨认。', '', 1, 3, 1, '{$now}', '{$now}'),
(4, 1, 'hardware_detail', '做工细节图', 1, '请拍摄材质、走线、五金等关键细节位置。', '', 2, 4, 1, '{$now}', '{$now}'),
(5, 1, 'purchase_voucher', '购买凭证', 0, '如有订单截图、发票或购物凭证,可一并上传。', '', 2, 5, 1, '{$now}', '{$now}'),
(6, 1, 'special_detail', '特殊细节图', 0, '如存在疑问部位或瑕疵,可补充上传。', '', 2, 6, 1, '{$now}', '{$now}'),
(7, 2, 'overall_front', '商品整体图', 1, '请拍摄商品整体外观,确保主体完整入镜。', '', 1, 1, 1, '{$now}', '{$now}'),
(8, 2, 'logo_detail', '品牌标识图', 1, '请拍摄 Logo 或标识位置,保证图像清晰无遮挡。', '', 1, 2, 1, '{$now}', '{$now}'),
(9, 2, 'serial_label', '编码 / 标签图', 1, '请拍摄商品编码、标签或序列信息,确保内容可辨认。', '', 1, 3, 1, '{$now}', '{$now}'),
(10, 2, 'hardware_detail', '做工细节图', 1, '请拍摄材质、走线、五金等关键细节位置。', '', 2, 4, 1, '{$now}', '{$now}'),
(11, 2, 'purchase_voucher', '购买凭证', 0, '如有订单截图、发票或购物凭证,可一并上传。', '', 2, 5, 1, '{$now}', '{$now}'),
(12, 2, 'special_detail', '特殊细节图', 0, '如存在疑问部位或瑕疵,可补充上传。', '', 2, 6, 1, '{$now}', '{$now}'),
(13, 3, 'overall_pair', '鞋款整体图', 1, '请拍摄左右脚整体外观,确保鞋面、鞋底完整入镜。', '', 2, 1, 1, '{$now}', '{$now}'),
(14, 3, 'tongue_label', '鞋舌标签图', 1, '请拍摄鞋舌标签、尺码标及生产信息。', '', 2, 2, 1, '{$now}', '{$now}'),
(15, 3, 'insole_detail', '鞋垫与内里图', 1, '请拍摄鞋垫、内里走线和内侧印刷细节。', '', 2, 3, 1, '{$now}', '{$now}'),
(16, 3, 'sole_detail', '鞋底细节图', 1, '请补充鞋底纹路和磨损细节。', '', 2, 4, 1, '{$now}', '{$now}'),
(17, 3, 'box_label', '鞋盒标签图', 0, '如有鞋盒,请拍摄鞋盒侧标信息。', '', 1, 5, 1, '{$now}', '{$now}'),
(18, 3, 'purchase_voucher', '购买凭证', 0, '如有订单截图、小票或平台购买记录,可一并上传。', '', 2, 6, 1, '{$now}', '{$now}'),
(19, 4, 'overall_pair', '鞋款整体图', 1, '请拍摄左右脚整体外观,确保鞋面、鞋底完整入镜。', '', 2, 1, 1, '{$now}', '{$now}'),
(20, 4, 'tongue_label', '鞋舌标签图', 1, '请拍摄鞋舌标签、尺码标及生产信息。', '', 2, 2, 1, '{$now}', '{$now}'),
(21, 4, 'insole_detail', '鞋垫与内里图', 1, '请拍摄鞋垫、内里走线和内侧印刷细节。', '', 2, 3, 1, '{$now}', '{$now}'),
(22, 4, 'sole_detail', '鞋底细节图', 1, '请补充鞋底纹路和磨损细节。', '', 2, 4, 1, '{$now}', '{$now}'),
(23, 4, 'box_label', '鞋盒标签图', 0, '如有鞋盒,请拍摄鞋盒侧标信息。', '', 1, 5, 1, '{$now}', '{$now}'),
(24, 4, 'purchase_voucher', '购买凭证', 0, '如有订单截图、小票或平台购买记录,可一并上传。', '', 2, 6, 1, '{$now}', '{$now}'),
(25, 5, 'overall_front', '腕表整体图', 1, '请拍摄表盘正面与整体外观。', '', 1, 1, 1, '{$now}', '{$now}'),
(26, 5, 'back_case', '表背图', 1, '请拍摄表背刻字、结构和编码信息。', '', 1, 2, 1, '{$now}', '{$now}'),
(27, 5, 'movement_detail', '机芯 / 内部结构图', 0, '如方便展示机芯,请补充内部结构图。', '', 2, 3, 1, '{$now}', '{$now}'),
(28, 5, 'strap_buckle', '表带 / 表扣细节图', 1, '请拍摄表带材质、表扣刻字和连接处细节。', '', 2, 4, 1, '{$now}', '{$now}'),
(29, 5, 'purchase_voucher', '购买凭证', 0, '如有保卡、发票或购买记录,可一并上传。', '', 2, 5, 1, '{$now}', '{$now}'),
(30, 6, 'overall_front', '腕表整体图', 1, '请拍摄表盘正面与整体外观。', '', 1, 1, 1, '{$now}', '{$now}'),
(31, 6, 'back_case', '表背图', 1, '请拍摄表背刻字、结构和编码信息。', '', 1, 2, 1, '{$now}', '{$now}'),
(32, 6, 'movement_detail', '机芯 / 内部结构图', 0, '如方便展示机芯,请补充内部结构图。', '', 2, 3, 1, '{$now}', '{$now}'),
(33, 6, 'strap_buckle', '表带 / 表扣细节图', 1, '请拍摄表带材质、表扣刻字和连接处细节。', '', 2, 4, 1, '{$now}', '{$now}'),
(34, 6, 'purchase_voucher', '购买凭证', 0, '如有保卡、发票或购买记录,可一并上传。', '', 2, 5, 1, '{$now}', '{$now}');
INSERT INTO orders (id, order_no, appraisal_no, user_id, service_mode, service_provider, payment_status, order_status, display_status, estimated_finish_time, source_channel, source_customer_id, pay_amount, paid_at, created_at, updated_at) VALUES
(1, 'AXY202604200001', 'AXY-APP-20260420-0001', 1, 'physical', 'zhongjian', 'paid', 'pending_supplement', '等待您补充资料', '2026-04-21 18:00:00', 'mini_program', '', 199.00, '2026-04-20 09:12:00', '2026-04-20 09:12:00', '{$now}'),
(2, 'AXY202604190012', 'AXY-APP-20260419-0012', 1, 'physical', 'anxinyan', 'paid', 'in_first_review', '鉴定师处理中', '2026-04-20 20:00:00', 'h5', '', 99.00, '2026-04-19 13:02:00', '2026-04-19 13:02:00', '{$now}'),
(3, 'AXY202604180088', 'AXY-APP-20260418-0088', 1, 'physical', 'zhongjian', 'paid', 'completed', '报告已出具', '2026-04-18 20:00:00', 'enterprise_push', 'ENT-DEMO-001', 199.00, '2026-04-18 08:18:00', '2026-04-18 08:18:00', '{$now}');
INSERT INTO order_products (id, order_id, category_id, category_name, brand_id, brand_name, color, size_spec, serial_no, product_name, product_cover, created_at, updated_at) VALUES
(1, 1, 1, '奢侈品箱包', 1, 'Louis Vuitton', '老花', 'MM', '', 'Louis Vuitton 奢侈品箱包', '', '{$now}', '{$now}'),
(2, 2, 2, '潮流鞋类', 2, 'Nike', 'Chicago', '42', '', 'Nike 潮流鞋类', '', '{$now}', '{$now}'),
(3, 3, 3, '腕表', 3, 'Rolex', '银盘', '36mm', 'RX123456', 'Rolex 腕表', '', '{$now}', '{$now}');
INSERT INTO order_extras (id, order_id, purchase_channel, purchase_price, purchase_date, usage_status, condition_desc, has_accessories, accessories_json, remark, created_at, updated_at) VALUES
(1, 1, '专柜', 8500.00, '2026-03-01', 'light_use', '轻微使用痕迹', 1, JSON_ARRAY('防尘袋','包装盒'), '包身整体状态良好', '{$now}', '{$now}'),
(2, 2, '官网', 1699.00, '2026-02-15', 'light_use', '鞋底轻微磨损', 1, JSON_ARRAY('鞋盒','购买凭证'), '补充鞋标与鞋盒标签', '{$now}', '{$now}'),
(3, 3, '专柜', 52000.00, '2026-01-20', 'light_use', '整体状态良好', 1, JSON_ARRAY('表盒','保卡'), '用于正式报告展示', '{$now}', '{$now}');
INSERT INTO order_shipping_targets (id, order_id, warehouse_id, warehouse_name, warehouse_code, service_provider, receiver_name, receiver_mobile, province, city, district, detail_address, service_time, notice, created_at, updated_at) VALUES
(1, 1, 2, '中检合作鉴定中心', 'ZJ-WH-DEFAULT', 'zhongjian', '中检合作鉴定中心', '400-800-1314', '广东省', '深圳市', '南山区', '科技园鉴定路 88 号 安心验中检收件中心', '周一至周日 09:30-18:30', '中检鉴定订单请优先附上鉴定单号,寄出后尽快填写运单号。', '{$now}', '{$now}'),
(2, 2, 1, '安心验鉴定中心', 'AXY-WH-DEFAULT', 'anxinyan', '安心验鉴定中心', '400-800-1314', '广东省', '深圳市', '南山区', '科技园鉴定路 88 号 安心验收件中心', '周一至周日 09:30-18:30', '寄送前请确认订单信息完整,包裹内附上订单号可提升签收后的处理效率。', '{$now}', '{$now}'),
(3, 3, 2, '中检合作鉴定中心', 'ZJ-WH-DEFAULT', 'zhongjian', '中检合作鉴定中心', '400-800-1314', '广东省', '深圳市', '南山区', '科技园鉴定路 88 号 安心验中检收件中心', '周一至周日 09:30-18:30', '中检鉴定订单请优先附上鉴定单号,寄出后尽快填写运单号。', '{$now}', '{$now}');
INSERT INTO order_timelines (id, order_id, node_code, node_text, node_desc, operator_type, operator_id, occurred_at, created_at) VALUES
(1, 1, 'created', '下单成功', '订单已生成并完成支付', 'system', NULL, '2026-04-20 09:12:00', '{$now}'),
(2, 1, 'submitted', '资料已提交', '用户已完成首轮资料上传', 'user', 1, '2026-04-20 09:30:00', '{$now}'),
(3, 1, 'first_review', '鉴定中', '鉴定师正在进行专业判断', 'admin', 1, '2026-04-20 10:20:00', '{$now}'),
(4, 1, 'supplement', '待补资料', '鉴定师需要补充编码近照与五金细节图', 'admin', 1, '2026-04-20 11:16:00', '{$now}'),
(5, 2, 'created', '下单成功', '订单已生成并完成支付', 'system', NULL, '2026-04-19 13:02:00', '{$now}'),
(6, 2, 'submitted', '资料已提交', '用户已完成首轮资料上传', 'user', 1, '2026-04-19 13:18:00', '{$now}'),
(7, 2, 'received', '鉴定中心已收货', '商品已进入鉴定中心', 'system', NULL, '2026-04-19 15:10:00', '{$now}'),
(8, 2, 'first_review', '鉴定中', '鉴定师正在处理,预计 24 小时内出具报告', 'admin', 2, '2026-04-20 09:10:00', '{$now}'),
(9, 3, 'created', '下单成功', '订单已生成并完成支付', 'system', NULL, '2026-04-18 08:18:00', '{$now}'),
(10, 3, 'received', '鉴定中心已收货', '商品已进入鉴定中心', 'system', NULL, '2026-04-18 10:12:00', '{$now}'),
(11, 3, 'generating_report', '正在生成报告', '鉴定已完成,系统正在生成正式报告草稿', 'admin', 3, '2026-04-18 16:00:00', '{$now}'),
(12, 3, 'report_published', '报告已出具', '正式报告已生成并可查看', 'system', NULL, '2026-04-18 18:26:00', '{$now}');
INSERT INTO order_supplement_tasks (id, order_id, reason, deadline, status, created_by, created_at, updated_at) VALUES
(1, 1, '鉴定师需要补充编码近照与五金细节图,以继续完成判断。', '2026-04-21 18:00:00', 'pending', 1, '{$now}', '{$now}');
INSERT INTO order_supplement_task_items (id, task_id, item_code, item_name, guide_text, sample_image_url, is_required, created_at, updated_at) VALUES
(1, 1, 'serial_label', '编码 / 标签图', '请补充清晰近照,确保编码内容完整可辨认。', '', 1, '{$now}', '{$now}'),
(2, 1, 'hardware_detail', '五金细节图', '请避免反光与遮挡,完整拍摄边缘与刻印细节。', '', 1, '{$now}', '{$now}');
INSERT INTO appraisal_tasks (id, order_id, task_stage, service_provider, status, assignee_id, assignee_name, started_at, submitted_at, sla_deadline, is_overtime, created_at, updated_at) VALUES
(1, 1, 'first_review', 'zhongjian', 'processing', 1, '张师傅', '2026-04-20 10:20:00', NULL, '2026-04-21 18:00:00', 0, '{$now}', '{$now}'),
(2, 2, 'first_review', 'anxinyan', 'processing', 2, '李师傅', '2026-04-20 09:10:00', NULL, '2026-04-20 20:00:00', 0, '{$now}', '{$now}'),
(3, 3, 'first_review', 'zhongjian', 'completed', 3, '王师傅', '2026-04-18 14:10:00', '2026-04-18 16:00:00', '2026-04-18 20:00:00', 0, '{$now}', '{$now}');
INSERT INTO appraisal_task_results (id, task_id, order_id, result_status, result_text, result_desc, condition_grade, condition_desc, valuation_min, valuation_max, valuation_desc, internal_remark, external_remark, created_at, updated_at) VALUES
(1, 3, 3, 'authentic', '正品', '综合当前送检资料与商品特征判断,符合正品特征。', 'A', '整体状态良好,存在轻微使用痕迹。', 2800.00, 3200.00, '当前估值仅供参考,具体以市场流通情况为准。', '鉴定完成,可出正式报告。', '综合当前送检资料与商品特征判断,符合正品特征。', '{$now}', '{$now}');
INSERT INTO reports (id, report_no, order_id, appraisal_no, report_type, service_provider, institution_name, report_title, report_status, report_version, publish_time, created_at, updated_at) VALUES
(1, 'AXY-R-20260420-0001', 3, 'AXY-APP-20260418-0088', 'appraisal', 'zhongjian', '中检合作机构', '中检鉴定报告', 'published', 1, '2026-04-18 18:26:00', '{$now}', '{$now}');
");
$productSnapshot = json_encode([
'product_name' => 'Rolex 腕表',
'category_name' => '腕表',
'brand_name' => 'Rolex',
'color' => '银盘',
'size_spec' => '36mm',
], JSON_UNESCAPED_UNICODE);
$resultSnapshot = json_encode([
'result_status' => 'authentic',
'result_text' => '正品',
'result_desc' => '综合当前送检资料与商品特征判断,符合正品特征。',
], JSON_UNESCAPED_UNICODE);
$appraisalSnapshot = json_encode([
'service_provider' => 'zhongjian',
'institution_name' => '中检合作机构',
'appraiser_name' => '张师傅',
'reviewer_name' => '张师傅',
'appraisal_time' => '2026-04-18 16:00:00',
], JSON_UNESCAPED_UNICODE);
$valuationSnapshot = json_encode([
'condition_grade' => 'A',
'condition_desc' => '整体状态良好,存在轻微使用痕迹。',
'valuation_min' => 2800,
'valuation_max' => 3200,
'valuation_desc' => '当前估值仅供参考,具体以市场流通情况为准。',
], JSON_UNESCAPED_UNICODE);
$stmt = $pdo->prepare('INSERT INTO report_contents (id, report_id, product_snapshot_json, result_snapshot_json, appraisal_snapshot_json, valuation_snapshot_json, risk_notice_text, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)');
$stmt->execute([
1,
1,
$productSnapshot,
$resultSnapshot,
$appraisalSnapshot,
$valuationSnapshot,
'本报告基于送检商品及当前提交资料出具。若商品状态或所附资料发生变化,报告结论可能不再适用。',
$now,
$now,
]);
$stmt = $pdo->prepare('INSERT INTO report_verifies (id, report_id, report_no, verify_token, verify_qrcode_url, verify_url, verify_status, verify_count, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)');
$stmt->execute([
1,
1,
'AXY-R-20260420-0001',
'verify_axyr202604200001',
'',
'/api/app/verify?report_no=AXY-R-20260420-0001',
'valid',
0,
$now,
$now,
]);
$pdo->exec("
INSERT INTO message_templates (id, template_name, template_code, channel, event_code, title, content, is_enabled, created_at, updated_at) VALUES
(1, '下单成功通知', 'order_created_inbox', 'inbox', 'order_created', '订单提交成功', '您的鉴定订单已提交成功,可前往订单中心查看进度。', 1, '{$now}', '{$now}'),
(2, '待补资料通知', 'supplement_required_inbox', 'inbox', 'supplement_required', '请补充鉴定资料', '鉴定师需要您补充资料后继续处理,请尽快进入订单详情查看。', 1, '{$now}', '{$now}'),
(3, '报告已出具通知', 'report_published_inbox', 'inbox', 'report_published', '报告已出具', '您的正式报告已生成,可前往报告中心查看并完成验真。', 1, '{$now}', '{$now}');
INSERT INTO message_rules (id, event_code, channel, template_id, delay_seconds, dedupe_window, is_enabled, created_at, updated_at) VALUES
(1, 'order_created', 'inbox', 1, 0, 0, 1, '{$now}', '{$now}'),
(2, 'supplement_required', 'inbox', 2, 0, 0, 1, '{$now}', '{$now}'),
(3, 'report_published', 'inbox', 3, 0, 0, 1, '{$now}', '{$now}');
INSERT INTO message_logs (id, user_id, template_id, biz_type, biz_id, channel, status, fail_reason, sent_at, created_at, updated_at) VALUES
(1, 1, 1, 'order', 1, 'inbox', 'sent', '', '2026-04-20 09:12:00', '{$now}', '{$now}'),
(2, 1, 2, 'order', 1, 'inbox', 'sent', '', '2026-04-20 11:16:00', '{$now}', '{$now}'),
(3, 1, 3, 'report', 1, 'inbox', 'pending', '', NULL, '{$now}', '{$now}');
INSERT INTO user_messages (id, user_id, title, content, biz_type, biz_id, is_read, read_at, created_at, updated_at) VALUES
(1, 1, '订单提交成功', '您的鉴定订单已提交成功,可前往订单中心查看进度。', 'order', 1, 1, '2026-04-20 09:20:00', '{$now}', '{$now}'),
(2, 1, '请补充鉴定资料', '鉴定师需要您补充资料后继续处理,请尽快进入订单详情查看。', 'order', 1, 0, NULL, '{$now}', '{$now}'),
(3, 1, '报告已出具', '您的正式报告已生成,可前往报告中心查看并完成验真。', 'report', 1, 0, NULL, '{$now}', '{$now}');
INSERT INTO tickets (id, ticket_no, ticket_type, biz_type, biz_id, order_id, user_id, status, priority, assignee_id, title, content, closed_at, created_at, updated_at) VALUES
(1, 'TK202604200001', 'upload_issue', 'order', 1, 1, 1, 'processing', 'high', 1, '补图说明咨询', '用户反馈不确定编码标签该如何拍摄,希望客服提供拍摄建议。', NULL, '{$now}', '{$now}'),
(2, 'TK202604200002', 'report_issue', 'report', 1, 3, 1, 'pending', 'normal', NULL, '报告内容咨询', '用户希望了解估值说明与评级口径。', NULL, '{$now}', '{$now}');
INSERT INTO ticket_messages (id, ticket_id, sender_type, sender_id, content, attachments_json, created_at) VALUES
(1, 1, 'user', 1, '我不确定编码标签应该怎么拍,担心影响鉴定结果。', NULL, '2026-04-20 11:18:00'),
(2, 1, 'customer_service', 1, '您好,请优先拍摄标签整体区域,再补一张放大近照,保证编码内容完整可辨认。', NULL, '2026-04-20 11:25:00'),
(3, 2, 'user', 1, '请问 A 级和估值区间的口径是什么?', NULL, '2026-04-20 12:10:00'),
(4, 2, 'system', NULL, '工单已创建,等待客服跟进。', NULL, '2026-04-20 12:11:00');
");
$pdo->exec("
INSERT INTO admin_users (id, name, mobile, email, password, status, last_login_at, created_at, updated_at) VALUES
(1, '系统管理员', '13800138000', 'admin@anxinyan.local', '{$adminPasswordHash}', 'enabled', NULL, '{$now}', '{$now}');
INSERT INTO admin_roles (id, name, code, status, created_at, updated_at) VALUES
(1, '超级管理员', 'super_admin', 'enabled', '{$now}', '{$now}');
INSERT INTO admin_role_relations (id, admin_user_id, role_id, created_at) VALUES
(1, 1, 1, '{$now}');
INSERT INTO admin_permissions (id, name, code, module, action, created_at, updated_at) VALUES
(1, '查看工作台', 'dashboard.view', 'dashboard', 'view', '{$now}', '{$now}'),
(2, '管理订单', 'orders.manage', 'orders', 'manage', '{$now}', '{$now}'),
(3, '管理鉴定任务', 'appraisal_tasks.manage', 'appraisal_tasks', 'manage', '{$now}', '{$now}'),
(4, '管理商品资料', 'catalog.manage', 'catalog', 'manage', '{$now}', '{$now}'),
(5, '管理报告', 'reports.manage', 'reports', 'manage', '{$now}', '{$now}'),
(6, '管理消息', 'messages.manage', 'messages', 'manage', '{$now}', '{$now}'),
(7, '管理工单', 'tickets.manage', 'tickets', 'manage', '{$now}', '{$now}'),
(8, '管理用户', 'users.manage', 'users', 'manage', '{$now}', '{$now}'),
(9, '管理客户', 'customers.manage', 'customers', 'manage', '{$now}', '{$now}'),
(10, '管理仓库', 'warehouses.manage', 'warehouses', 'manage', '{$now}', '{$now}'),
(11, '管理物料', 'materials.manage', 'materials', 'manage', '{$now}', '{$now}'),
(12, '管理权限', 'access.manage', 'access', 'manage', '{$now}', '{$now}'),
(13, '管理系统配置', 'system.manage', 'system_config', 'manage', '{$now}', '{$now}');
INSERT INTO admin_role_permissions (id, role_id, permission_id, created_at) VALUES
(1, 1, 1, '{$now}'),
(2, 1, 2, '{$now}'),
(3, 1, 3, '{$now}'),
(4, 1, 4, '{$now}'),
(5, 1, 5, '{$now}'),
(6, 1, 6, '{$now}'),
(7, 1, 7, '{$now}'),
(8, 1, 8, '{$now}'),
(9, 1, 9, '{$now}'),
(10, 1, 10, '{$now}'),
(11, 1, 11, '{$now}'),
(12, 1, 12, '{$now}'),
(13, 1, 13, '{$now}');
INSERT INTO system_configs (id, config_group, config_key, config_value, remark, created_at, updated_at) VALUES
(1, 'mini_program', 'app_id', '', '后台系统配置', '{$now}', '{$now}'),
(2, 'mini_program', 'app_secret', '', '后台系统配置', '{$now}', '{$now}'),
(3, 'mini_program', 'original_id', '', '后台系统配置', '{$now}', '{$now}'),
(4, 'h5', 'app_id', '', '后台系统配置', '{$now}', '{$now}'),
(5, 'h5', 'app_secret', '', '后台系统配置', '{$now}', '{$now}'),
(6, 'h5', 'oauth_redirect_url', '', '后台系统配置', '{$now}', '{$now}'),
(7, 'h5', 'page_base_url', '', '后台系统配置', '{$now}', '{$now}'),
(8, 'payment', 'mch_id', '', '后台系统配置', '{$now}', '{$now}'),
(9, 'payment', 'api_v3_key', '', '后台系统配置', '{$now}', '{$now}'),
(10, 'payment', 'merchant_serial_no', '', '后台系统配置', '{$now}', '{$now}'),
(11, 'payment', 'merchant_private_key', '', '后台系统配置', '{$now}', '{$now}'),
(12, 'payment', 'platform_certificate_serial', '', '后台系统配置', '{$now}', '{$now}'),
(13, 'payment', 'notify_url', '', '后台系统配置', '{$now}', '{$now}'),
(14, 'sms', 'access_key_id', '', '后台系统配置', '{$now}', '{$now}'),
(15, 'sms', 'access_key_secret', '', '后台系统配置', '{$now}', '{$now}'),
(16, 'sms', 'sign_name', '', '后台系统配置', '{$now}', '{$now}'),
(17, 'sms', 'login_template_code', '', '后台系统配置', '{$now}', '{$now}'),
(18, 'sms', 'region_id', 'cn-hangzhou', '后台系统配置', '{$now}', '{$now}'),
(19, 'sms', 'endpoint', '', '后台系统配置', '{$now}', '{$now}'),
(20, 'user_settings', 'user_1', '{\"notify_order\":true,\"notify_report\":true,\"notify_supplement\":true,\"notify_ticket\":true,\"marketing_notify\":false,\"privacy_mode\":false}', '用户端设置偏好', '{$now}', '{$now}');
");
echo "SEED_OK\n";