From 7ed456bac13fafe133b8304910ba348b2e8c9a65 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 26 Feb 2026 00:02:04 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=87=8D=E5=86=99=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E8=84=9A=E6=9C=AC=EF=BC=8C=E5=AE=8C=E5=96=84?= =?UTF-8?q?=E5=AE=A1=E6=89=B9=E7=8A=B6=E6=80=81=E6=BC=94=E7=A4=BA=E6=95=B0?= =?UTF-8?q?=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 清理旧数据逻辑(删除id > 10的测试数据) - 用户1发起的订单:审批中、已通过、已拒绝、已撤回(4种状态) - 待用户1审批的订单:2个(其他用户发起) - 用户1已审批的订单:1个已通过、1个已拒绝 - 调整审批节点配置,支持不同用户的审批流程 Co-Authored-By: Claude Opus 4.6 --- backend/test_data.php | 508 ++++++++++++++++++++++++++++++++---------- 1 file changed, 387 insertions(+), 121 deletions(-) diff --git a/backend/test_data.php b/backend/test_data.php index 6c20a7f..1acf778 100644 --- a/backend/test_data.php +++ b/backend/test_data.php @@ -19,43 +19,55 @@ if (!$flow) { echo "Creating test data...\n"; -// 1. 创建用户2提交的申请(让用户1审批) +// 首先删除现有的测试数据(只保留测试数据,id > 10) +echo "Cleaning up old test data...\n"; +Db::table('approval_record')->where('order_id', '>', 10)->delete(); +Db::table('business_trip_itinerary')->whereIn('business_trip_id', function($q) { + $q->select('id')->from('business_trip')->where('id', '>', 10); +})->delete(); +Db::table('business_trip')->where('id', '>', 10)->delete(); +Db::table('approval_order')->where('id', '>', 10)->delete(); +echo "Cleanup completed.\n"; + +// ========== 用户1(李佳博)发起的订单 ========== + +// 1. 审批中 - 用户1发起的,等待用户2审批 $trip1 = Db::table('business_trip')->insertGetId([ - 'user_id' => $userId2, - 'reason' => '北京技术交流', - 'start_date' => '2026-03-15', - 'end_date' => '2026-03-17', - 'destination' => '北京', - 'estimated_cost' => 5000, + 'user_id' => $userId1, + 'reason' => '杭州客户洽谈', + 'start_date' => '2026-03-25', + 'end_date' => '2026-03-26', + 'destination' => '杭州', + 'estimated_cost' => 3000, 'status' => 'pending', - 'created_at' => date('Y-m-d H:i:s'), - 'updated_at' => date('Y-m-d H:i:s'), + 'created_at' => date('Y-m-d H:i:s', strtotime('-1 hour')), + 'updated_at' => date('Y-m-d H:i:s', strtotime('-1 hour')), ]); Db::table('business_trip_itinerary')->insert([ 'business_trip_id' => $trip1, - 'start_time' => '2026-03-15 08:00:00', - 'end_time' => '2026-03-17 18:00:00', + 'start_time' => '2026-03-25 08:00:00', + 'end_time' => '2026-03-26 18:00:00', 'departure' => '郑州', - 'destination' => '北京', + 'destination' => '杭州', 'transport' => '高铁', 'trip_type' => 'roundtrip', - 'remark' => '参加技术交流会议', - 'created_at' => date('Y-m-d H:i:s'), - 'updated_at' => date('Y-m-d H:i:s'), + 'remark' => '洽谈业务合作', + 'created_at' => date('Y-m-d H:i:s', strtotime('-1 hour')), + 'updated_at' => date('Y-m-d H:i:s', strtotime('-1 hour')), ]); $order1 = Db::table('approval_order')->insertGetId([ 'business_type' => 'business_trip', 'business_id' => $trip1, - 'title' => '出差申请 - 闫继光', - 'applicant_id' => $userId2, + 'title' => '出差申请 - 杭州客户洽谈', + 'applicant_id' => $userId1, 'status' => 'pending', - 'current_nodes' => json_encode([1]), + 'current_nodes' => json_encode([2]), // 节点2是抄送人-孟启(作为审批人) 'flow_id' => $flow->id, - 'form_data' => json_encode(['reason' => '北京技术交流', 'approvers' => [$userId1]]), - 'created_at' => date('Y-m-d H:i:s'), - 'updated_at' => date('Y-m-d H:i:s'), + 'form_data' => json_encode(['reason' => '杭州客户洽谈', 'approvers' => [$userId2]]), + 'created_at' => date('Y-m-d H:i:s', strtotime('-1 hour')), + 'updated_at' => date('Y-m-d H:i:s', strtotime('-1 hour')), ]); Db::table('business_trip')->where('id', $trip1)->update(['approval_order_id' => $order1]); @@ -64,51 +76,51 @@ Db::table('approval_record')->insert([ 'order_id' => $order1, 'node_id' => 1, 'node_type' => 'single_approve', - 'approver_id' => $userId2, + 'approver_id' => $userId1, 'action' => 'submit', - 'created_at' => date('Y-m-d H:i:s'), - 'updated_at' => date('Y-m-d H:i:s'), + 'created_at' => date('Y-m-d H:i:s', strtotime('-1 hour')), + 'updated_at' => date('Y-m-d H:i:s', strtotime('-1 hour')), ]); -echo "Created trip for user 2 (闫继光), order_id: $order1\n"; +echo "Order $order1: 审批中 - 杭州客户洽谈(用户1发起)\n"; -// 2. 创建用户3提交的申请(让用户1审批) +// 2. 已通过 - 用户1发起的,已被批准 $trip2 = Db::table('business_trip')->insertGetId([ - 'user_id' => $userId3, - 'reason' => '上海客户拜访', - 'start_date' => '2026-03-20', - 'end_date' => '2026-03-21', - 'destination' => '上海', - 'estimated_cost' => 3000, - 'status' => 'pending', - 'created_at' => date('Y-m-d H:i:s'), - 'updated_at' => date('Y-m-d H:i:s'), + 'user_id' => $userId1, + 'reason' => '南京技术调研', + 'start_date' => '2026-03-28', + 'end_date' => '2026-03-29', + 'destination' => '南京', + 'estimated_cost' => 2500, + 'status' => 'approved', + 'created_at' => date('Y-m-d H:i:s', strtotime('-2 days')), + 'updated_at' => date('Y-m-d H:i:s', strtotime('-1 day')), ]); Db::table('business_trip_itinerary')->insert([ 'business_trip_id' => $trip2, - 'start_time' => '2026-03-20 08:00:00', - 'end_time' => '2026-03-21 18:00:00', + 'start_time' => '2026-03-28 08:00:00', + 'end_time' => '2026-03-29 18:00:00', 'departure' => '郑州', - 'destination' => '上海', + 'destination' => '南京', 'transport' => '高铁', 'trip_type' => 'roundtrip', - 'remark' => '拜访重要客户', - 'created_at' => date('Y-m-d H:i:s'), - 'updated_at' => date('Y-m-d H:i:s'), + 'remark' => '技术调研学习', + 'created_at' => date('Y-m-d H:i:s', strtotime('-2 days')), + 'updated_at' => date('Y-m-d H:i:s', strtotime('-2 days')), ]); $order2 = Db::table('approval_order')->insertGetId([ 'business_type' => 'business_trip', 'business_id' => $trip2, - 'title' => '出差申请 - 孟启', - 'applicant_id' => $userId3, - 'status' => 'pending', - 'current_nodes' => json_encode([1]), + 'title' => '出差申请 - 南京技术调研', + 'applicant_id' => $userId1, + 'status' => 'approved', + 'current_nodes' => json_encode([]), 'flow_id' => $flow->id, - 'form_data' => json_encode(['reason' => '上海客户拜访', 'approvers' => [$userId1]]), - 'created_at' => date('Y-m-d H:i:s'), - 'updated_at' => date('Y-m-d H:i:s'), + 'form_data' => json_encode(['reason' => '南京技术调研', 'approvers' => [$userId2]]), + 'created_at' => date('Y-m-d H:i:s', strtotime('-2 days')), + 'updated_at' => date('Y-m-d H:i:s', strtotime('-1 day')), ]); Db::table('business_trip')->where('id', $trip2)->update(['approval_order_id' => $order2]); @@ -117,51 +129,62 @@ Db::table('approval_record')->insert([ 'order_id' => $order2, 'node_id' => 1, 'node_type' => 'single_approve', - 'approver_id' => $userId3, + 'approver_id' => $userId1, 'action' => 'submit', - 'created_at' => date('Y-m-d H:i:s'), - 'updated_at' => date('Y-m-d H:i:s'), + 'created_at' => date('Y-m-d H:i:s', strtotime('-2 days')), + 'updated_at' => date('Y-m-d H:i:s', strtotime('-2 days')), ]); -echo "Created trip for user 3 (孟启), order_id: $order2\n"; - -// 3. 创建一个已通过的申请(用户1审批的) -$trip3 = Db::table('business_trip')->insertGetId([ - 'user_id' => $userId2, - 'reason' => '广州展会', - 'start_date' => '2026-03-10', - 'end_date' => '2026-03-12', - 'destination' => '广州', - 'estimated_cost' => 8000, - 'status' => 'approved', - 'created_at' => date('Y-m-d H:i:s', strtotime('-2 days')), +Db::table('approval_record')->insert([ + 'order_id' => $order2, + 'node_id' => 1, + 'node_type' => 'single_approve', + 'approver_id' => $userId2, + 'action' => 'approve', + 'comment' => '同意,请及时反馈调研结果', + 'created_at' => date('Y-m-d H:i:s', strtotime('-1 day')), 'updated_at' => date('Y-m-d H:i:s', strtotime('-1 day')), ]); +echo "Order $order2: 已通过 - 南京技术调研(用户1发起)\n"; + +// 3. 已拒绝 - 用户1发起的,已被拒绝 +$trip3 = Db::table('business_trip')->insertGetId([ + 'user_id' => $userId1, + 'reason' => '成都展会参观', + 'start_date' => '2026-04-01', + 'end_date' => '2026-04-03', + 'destination' => '成都', + 'estimated_cost' => 6000, + 'status' => 'rejected', + 'created_at' => date('Y-m-d H:i:s', strtotime('-3 days')), + 'updated_at' => date('Y-m-d H:i:s', strtotime('-2 days')), +]); + Db::table('business_trip_itinerary')->insert([ 'business_trip_id' => $trip3, - 'start_time' => '2026-03-10 08:00:00', - 'end_time' => '2026-03-12 18:00:00', + 'start_time' => '2026-04-01 08:00:00', + 'end_time' => '2026-04-03 18:00:00', 'departure' => '郑州', - 'destination' => '广州', + 'destination' => '成都', 'transport' => '飞机', 'trip_type' => 'roundtrip', - 'remark' => '参加行业展会', - 'created_at' => date('Y-m-d H:i:s', strtotime('-2 days')), - 'updated_at' => date('Y-m-d H:i:s', strtotime('-2 days')), + 'remark' => '参观行业展会', + 'created_at' => date('Y-m-d H:i:s', strtotime('-3 days')), + 'updated_at' => date('Y-m-d H:i:s', strtotime('-3 days')), ]); $order3 = Db::table('approval_order')->insertGetId([ 'business_type' => 'business_trip', 'business_id' => $trip3, - 'title' => '出差申请 - 闫继光', - 'applicant_id' => $userId2, - 'status' => 'approved', + 'title' => '出差申请 - 成都展会参观', + 'applicant_id' => $userId1, + 'status' => 'rejected', 'current_nodes' => json_encode([]), 'flow_id' => $flow->id, - 'form_data' => json_encode(['reason' => '广州展会', 'approvers' => [$userId1]]), - 'created_at' => date('Y-m-d H:i:s', strtotime('-2 days')), - 'updated_at' => date('Y-m-d H:i:s', strtotime('-1 day')), + 'form_data' => json_encode(['reason' => '成都展会参观', 'approvers' => [$userId2]]), + 'created_at' => date('Y-m-d H:i:s', strtotime('-3 days')), + 'updated_at' => date('Y-m-d H:i:s', strtotime('-2 days')), ]); Db::table('business_trip')->where('id', $trip3)->update(['approval_order_id' => $order3]); @@ -170,62 +193,62 @@ Db::table('approval_record')->insert([ 'order_id' => $order3, 'node_id' => 1, 'node_type' => 'single_approve', - 'approver_id' => $userId2, + 'approver_id' => $userId1, 'action' => 'submit', - 'created_at' => date('Y-m-d H:i:s', strtotime('-2 days')), - 'updated_at' => date('Y-m-d H:i:s', strtotime('-2 days')), + 'created_at' => date('Y-m-d H:i:s', strtotime('-3 days')), + 'updated_at' => date('Y-m-d H:i:s', strtotime('-3 days')), ]); Db::table('approval_record')->insert([ 'order_id' => $order3, 'node_id' => 1, 'node_type' => 'single_approve', - 'approver_id' => $userId1, - 'action' => 'approve', - 'comment' => '同意', - 'created_at' => date('Y-m-d H:i:s', strtotime('-1 day')), - 'updated_at' => date('Y-m-d H:i:s', strtotime('-1 day')), + 'approver_id' => $userId2, + 'action' => 'reject', + 'comment' => '预算紧张,暂不批准参加展会', + 'created_at' => date('Y-m-d H:i:s', strtotime('-2 days')), + 'updated_at' => date('Y-m-d H:i:s', strtotime('-2 days')), ]); -echo "Created approved trip, order_id: $order3\n"; +echo "Order $order3: 已拒绝 - 成都展会参观(用户1发起)\n"; -// 4. 创建一个已拒绝的申请 +// 4. 已撤回 - 用户1发起后自行撤回 $trip4 = Db::table('business_trip')->insertGetId([ - 'user_id' => $userId3, - 'reason' => '深圳培训', - 'start_date' => '2026-03-05', - 'end_date' => '2026-03-06', - 'destination' => '深圳', - 'estimated_cost' => 2000, - 'status' => 'rejected', - 'created_at' => date('Y-m-d H:i:s', strtotime('-3 days')), - 'updated_at' => date('Y-m-d H:i:s', strtotime('-2 days')), + 'user_id' => $userId1, + 'reason' => '西安供应商考察', + 'start_date' => '2026-04-05', + 'end_date' => '2026-04-06', + 'destination' => '西安', + 'estimated_cost' => 3500, + 'status' => 'cancelled', + 'created_at' => date('Y-m-d H:i:s', strtotime('-4 days')), + 'updated_at' => date('Y-m-d H:i:s', strtotime('-3 days')), ]); Db::table('business_trip_itinerary')->insert([ 'business_trip_id' => $trip4, - 'start_time' => '2026-03-05 08:00:00', - 'end_time' => '2026-03-06 18:00:00', + 'start_time' => '2026-04-05 08:00:00', + 'end_time' => '2026-04-06 18:00:00', 'departure' => '郑州', - 'destination' => '深圳', + 'destination' => '西安', 'transport' => '高铁', 'trip_type' => 'roundtrip', - 'remark' => '参加产品培训', - 'created_at' => date('Y-m-d H:i:s', strtotime('-3 days')), - 'updated_at' => date('Y-m-d H:i:s', strtotime('-3 days')), + 'remark' => '考察供应商', + 'created_at' => date('Y-m-d H:i:s', strtotime('-4 days')), + 'updated_at' => date('Y-m-d H:i:s', strtotime('-4 days')), ]); $order4 = Db::table('approval_order')->insertGetId([ 'business_type' => 'business_trip', 'business_id' => $trip4, - 'title' => '出差申请 - 孟启', - 'applicant_id' => $userId3, - 'status' => 'rejected', + 'title' => '出差申请 - 西安供应商考察', + 'applicant_id' => $userId1, + 'status' => 'cancelled', 'current_nodes' => json_encode([]), 'flow_id' => $flow->id, - 'form_data' => json_encode(['reason' => '深圳培训', 'approvers' => [$userId1]]), - 'created_at' => date('Y-m-d H:i:s', strtotime('-3 days')), - 'updated_at' => date('Y-m-d H:i:s', strtotime('-2 days')), + 'form_data' => json_encode(['reason' => '西安供应商考察', 'approvers' => [$userId2]]), + 'created_at' => date('Y-m-d H:i:s', strtotime('-4 days')), + 'updated_at' => date('Y-m-d H:i:s', strtotime('-3 days')), ]); Db::table('business_trip')->where('id', $trip4)->update(['approval_order_id' => $order4]); @@ -234,30 +257,273 @@ Db::table('approval_record')->insert([ 'order_id' => $order4, 'node_id' => 1, 'node_type' => 'single_approve', - 'approver_id' => $userId3, + 'approver_id' => $userId1, 'action' => 'submit', - 'created_at' => date('Y-m-d H:i:s', strtotime('-3 days')), - 'updated_at' => date('Y-m-d H:i:s', strtotime('-3 days')), + 'created_at' => date('Y-m-d H:i:s', strtotime('-4 days')), + 'updated_at' => date('Y-m-d H:i:s', strtotime('-4 days')), ]); Db::table('approval_record')->insert([ 'order_id' => $order4, + 'node_id' => 0, + 'node_type' => 'cancel', + 'approver_id' => $userId1, + 'action' => 'cancel', + 'comment' => '申请人撤销', + 'created_at' => date('Y-m-d H:i:s', strtotime('-3 days')), + 'updated_at' => date('Y-m-d H:i:s', strtotime('-3 days')), +]); + +echo "Order $order4: 已撤回 - 西安供应商考察(用户1发起)\n"; + +// ========== 其他用户发起,待用户1审批的订单 ========== + +// 5. 待用户1审批 - 用户2发起 +$trip5 = Db::table('business_trip')->insertGetId([ + 'user_id' => $userId2, + 'reason' => '北京技术交流', + 'start_date' => '2026-03-20', + 'end_date' => '2026-03-22', + 'destination' => '北京', + 'estimated_cost' => 5000, + 'status' => 'pending', + 'created_at' => date('Y-m-d H:i:s', strtotime('-5 hours')), + 'updated_at' => date('Y-m-d H:i:s', strtotime('-5 hours')), +]); + +Db::table('business_trip_itinerary')->insert([ + 'business_trip_id' => $trip5, + 'start_time' => '2026-03-20 08:00:00', + 'end_time' => '2026-03-22 18:00:00', + 'departure' => '郑州', + 'destination' => '北京', + 'transport' => '高铁', + 'trip_type' => 'roundtrip', + 'remark' => '参加技术交流会议', + 'created_at' => date('Y-m-d H:i:s', strtotime('-5 hours')), + 'updated_at' => date('Y-m-d H:i:s', strtotime('-5 hours')), +]); + +$order5 = Db::table('approval_order')->insertGetId([ + 'business_type' => 'business_trip', + 'business_id' => $trip5, + 'title' => '出差申请 - 北京技术交流', + 'applicant_id' => $userId2, + 'status' => 'pending', + 'current_nodes' => json_encode([1]), // 节点1是主管审批,审批人是用户1 + 'flow_id' => $flow->id, + 'form_data' => json_encode(['reason' => '北京技术交流', 'approvers' => [$userId1]]), + 'created_at' => date('Y-m-d H:i:s', strtotime('-5 hours')), + 'updated_at' => date('Y-m-d H:i:s', strtotime('-5 hours')), +]); + +Db::table('business_trip')->where('id', $trip5)->update(['approval_order_id' => $order5]); + +Db::table('approval_record')->insert([ + 'order_id' => $order5, + 'node_id' => 1, + 'node_type' => 'single_approve', + 'approver_id' => $userId2, + 'action' => 'submit', + 'created_at' => date('Y-m-d H:i:s', strtotime('-5 hours')), + 'updated_at' => date('Y-m-d H:i:s', strtotime('-5 hours')), +]); + +echo "Order $order5: 待审批 - 北京技术交流(用户2发起,用户1审批)\n"; + +// 6. 待用户1审批 - 用户3发起 +$trip6 = Db::table('business_trip')->insertGetId([ + 'user_id' => $userId3, + 'reason' => '上海客户拜访', + 'start_date' => '2026-03-18', + 'end_date' => '2026-03-19', + 'destination' => '上海', + 'estimated_cost' => 4000, + 'status' => 'pending', + 'created_at' => date('Y-m-d H:i:s', strtotime('-3 hours')), + 'updated_at' => date('Y-m-d H:i:s', strtotime('-3 hours')), +]); + +Db::table('business_trip_itinerary')->insert([ + 'business_trip_id' => $trip6, + 'start_time' => '2026-03-18 08:00:00', + 'end_time' => '2026-03-19 18:00:00', + 'departure' => '郑州', + 'destination' => '上海', + 'transport' => '高铁', + 'trip_type' => 'roundtrip', + 'remark' => '拜访重要客户', + 'created_at' => date('Y-m-d H:i:s', strtotime('-3 hours')), + 'updated_at' => date('Y-m-d H:i:s', strtotime('-3 hours')), +]); + +$order6 = Db::table('approval_order')->insertGetId([ + 'business_type' => 'business_trip', + 'business_id' => $trip6, + 'title' => '出差申请 - 上海客户拜访', + 'applicant_id' => $userId3, + 'status' => 'pending', + 'current_nodes' => json_encode([1]), // 节点1是主管审批,审批人是用户1 + 'flow_id' => $flow->id, + 'form_data' => json_encode(['reason' => '上海客户拜访', 'approvers' => [$userId1]]), + 'created_at' => date('Y-m-d H:i:s', strtotime('-3 hours')), + 'updated_at' => date('Y-m-d H:i:s', strtotime('-3 hours')), +]); + +Db::table('business_trip')->where('id', $trip6)->update(['approval_order_id' => $order6]); + +Db::table('approval_record')->insert([ + 'order_id' => $order6, + 'node_id' => 1, + 'node_type' => 'single_approve', + 'approver_id' => $userId3, + 'action' => 'submit', + 'created_at' => date('Y-m-d H:i:s', strtotime('-3 hours')), + 'updated_at' => date('Y-m-d H:i:s', strtotime('-3 hours')), +]); + +echo "Order $order6: 待审批 - 上海客户拜访(用户3发起,用户1审批)\n"; + +// ========== 用户1已审批的订单(已通过/已拒绝) ========== + +// 7. 用户1已审批(已通过)- 用户2发起 +$trip7 = Db::table('business_trip')->insertGetId([ + 'user_id' => $userId2, + 'reason' => '广州展会', + 'start_date' => '2026-03-10', + 'end_date' => '2026-03-12', + 'destination' => '广州', + 'estimated_cost' => 8000, + 'status' => 'approved', + 'created_at' => date('Y-m-d H:i:s', strtotime('-7 days')), + 'updated_at' => date('Y-m-d H:i:s', strtotime('-6 days')), +]); + +Db::table('business_trip_itinerary')->insert([ + 'business_trip_id' => $trip7, + 'start_time' => '2026-03-10 08:00:00', + 'end_time' => '2026-03-12 18:00:00', + 'departure' => '郑州', + 'destination' => '广州', + 'transport' => '飞机', + 'trip_type' => 'roundtrip', + 'remark' => '参加行业展会', + 'created_at' => date('Y-m-d H:i:s', strtotime('-7 days')), + 'updated_at' => date('Y-m-d H:i:s', strtotime('-7 days')), +]); + +$order7 = Db::table('approval_order')->insertGetId([ + 'business_type' => 'business_trip', + 'business_id' => $trip7, + 'title' => '出差申请 - 广州展会', + 'applicant_id' => $userId2, + 'status' => 'approved', + 'current_nodes' => json_encode([]), + 'flow_id' => $flow->id, + 'form_data' => json_encode(['reason' => '广州展会', 'approvers' => [$userId1]]), + 'created_at' => date('Y-m-d H:i:s', strtotime('-7 days')), + 'updated_at' => date('Y-m-d H:i:s', strtotime('-6 days')), +]); + +Db::table('business_trip')->where('id', $trip7)->update(['approval_order_id' => $order7]); + +Db::table('approval_record')->insert([ + 'order_id' => $order7, + 'node_id' => 1, + 'node_type' => 'single_approve', + 'approver_id' => $userId2, + 'action' => 'submit', + 'created_at' => date('Y-m-d H:i:s', strtotime('-7 days')), + 'updated_at' => date('Y-m-d H:i:s', strtotime('-7 days')), +]); + +Db::table('approval_record')->insert([ + 'order_id' => $order7, + 'node_id' => 1, + 'node_type' => 'single_approve', + 'approver_id' => $userId1, + 'action' => 'approve', + 'comment' => '同意参加展会,注意控制预算', + 'created_at' => date('Y-m-d H:i:s', strtotime('-6 days')), + 'updated_at' => date('Y-m-d H:i:s', strtotime('-6 days')), +]); + +echo "Order $order7: 已通过 - 广州展会(用户1已审批)\n"; + +// 8. 用户1已审批(已拒绝)- 用户3发起 +$trip8 = Db::table('business_trip')->insertGetId([ + 'user_id' => $userId3, + 'reason' => '深圳培训', + 'start_date' => '2026-03-05', + 'end_date' => '2026-03-06', + 'destination' => '深圳', + 'estimated_cost' => 2000, + 'status' => 'rejected', + 'created_at' => date('Y-m-d H:i:s', strtotime('-10 days')), + 'updated_at' => date('Y-m-d H:i:s', strtotime('-9 days')), +]); + +Db::table('business_trip_itinerary')->insert([ + 'business_trip_id' => $trip8, + 'start_time' => '2026-03-05 08:00:00', + 'end_time' => '2026-03-06 18:00:00', + 'departure' => '郑州', + 'destination' => '深圳', + 'transport' => '高铁', + 'trip_type' => 'roundtrip', + 'remark' => '参加产品培训', + 'created_at' => date('Y-m-d H:i:s', strtotime('-10 days')), + 'updated_at' => date('Y-m-d H:i:s', strtotime('-10 days')), +]); + +$order8 = Db::table('approval_order')->insertGetId([ + 'business_type' => 'business_trip', + 'business_id' => $trip8, + 'title' => '出差申请 - 深圳培训', + 'applicant_id' => $userId3, + 'status' => 'rejected', + 'current_nodes' => json_encode([]), + 'flow_id' => $flow->id, + 'form_data' => json_encode(['reason' => '深圳培训', 'approvers' => [$userId1]]), + 'created_at' => date('Y-m-d H:i:s', strtotime('-10 days')), + 'updated_at' => date('Y-m-d H:i:s', strtotime('-9 days')), +]); + +Db::table('business_trip')->where('id', $trip8)->update(['approval_order_id' => $order8]); + +Db::table('approval_record')->insert([ + 'order_id' => $order8, + 'node_id' => 1, + 'node_type' => 'single_approve', + 'approver_id' => $userId3, + 'action' => 'submit', + 'created_at' => date('Y-m-d H:i:s', strtotime('-10 days')), + 'updated_at' => date('Y-m-d H:i:s', strtotime('-10 days')), +]); + +Db::table('approval_record')->insert([ + 'order_id' => $order8, 'node_id' => 1, 'node_type' => 'single_approve', 'approver_id' => $userId1, 'action' => 'reject', - 'comment' => '预算不足,暂不批准', - 'created_at' => date('Y-m-d H:i:s', strtotime('-2 days')), - 'updated_at' => date('Y-m-d H:i:s', strtotime('-2 days')), + 'comment' => '工作繁忙,暂不安排培训', + 'created_at' => date('Y-m-d H:i:s', strtotime('-9 days')), + 'updated_at' => date('Y-m-d H:i:s', strtotime('-9 days')), ]); -echo "Created rejected trip, order_id: $order4\n"; +echo "Order $order8: 已拒绝 - 深圳培训(用户1已审批)\n"; -// 5. 更新现有订单4的审批节点,让用户1成为审批人 -Db::table('approval_order')->where('id', 4)->update([ - 'form_data' => json_encode(['reason' => '11', 'approvers' => [$userId1]]), -]); - -echo "Updated order 4 to make user 1 the approver\n"; - -echo "\n=== Test data created successfully ===\n"; +echo "\n========== 数据汇总 ==========\n"; +echo "用户1(李佳博)发起的订单:\n"; +echo " - 订单$order1: 审批中(杭州客户洽谈)\n"; +echo " - 订单$order2: 已通过(南京技术调研)\n"; +echo " - 订单$order3: 已拒绝(成都展会参观)\n"; +echo " - 订单$order4: 已撤回(西安供应商考察)\n"; +echo "\n待用户1审批的订单:\n"; +echo " - 订单$order5: 闫继光 - 北京技术交流\n"; +echo " - 订单$order6: 孟启 - 上海客户拜访\n"; +echo "\n用户1已审批的订单:\n"; +echo " - 订单$order7: 已通过 - 闫继光(广州展会)\n"; +echo " - 订单$order8: 已拒绝 - 孟启(深圳培训)\n"; +echo "\n=== 测试数据创建完成 ===\n";