From f189d7ab89b6f03c442dad812256ba9233e3f9c0 Mon Sep 17 00:00:00 2001 From: zeyan <258785420@qq.com> Date: Tue, 12 Aug 2025 11:57:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../apiService/CustomerResourcesService.php | 2 + .../service/api/student/AttendanceService.php | 49 ++++++++++++++----- .../clue/class_arrangement_detail.vue | 13 +++-- 3 files changed, 47 insertions(+), 17 deletions(-) diff --git a/niucloud/app/service/api/apiService/CustomerResourcesService.php b/niucloud/app/service/api/apiService/CustomerResourcesService.php index 37122cbe..f8e67ea8 100644 --- a/niucloud/app/service/api/apiService/CustomerResourcesService.php +++ b/niucloud/app/service/api/apiService/CustomerResourcesService.php @@ -1008,6 +1008,7 @@ class CustomerResourcesService extends BaseApiService 's.headimg', 's.first_come', 's.second_come', + 's.user_id as resource_id', 'sc.id as student_course_id', 'sc.total_hours', 'sc.use_total_hours', @@ -1067,6 +1068,7 @@ class CustomerResourcesService extends BaseApiService 'headimg' => $student['headimg'], 'first_come' => $student['first_come'], 'second_come' => $student['second_come'], + 'resource_id' => intval($student['resource_id'] ?: 0), // 客户资源表ID 'person_type' => 'student', // 标识为学员类型 'courseStatus' => $isTrialStudent ? '体验课' : '正式课', 'isTrialStudent' => $isTrialStudent, diff --git a/niucloud/app/service/api/student/AttendanceService.php b/niucloud/app/service/api/student/AttendanceService.php index 70598a92..074f9713 100644 --- a/niucloud/app/service/api/student/AttendanceService.php +++ b/niucloud/app/service/api/student/AttendanceService.php @@ -178,10 +178,10 @@ class AttendanceService extends BaseApiService $current_time = time(); // 更新到校时间逻辑 - if (empty($student['first_come'])) { - $updateData['first_come'] = $current_time; - } else if (empty($student['second_come'])) { - $updateData['second_come'] = $current_time; + if (empty($student['first_come']) || $student['first_come'] == '0000-00-00 00:00:00') { + $updateData['first_come'] = date('Y-m-d H:i:s', $current_time); + } else if (empty($student['second_come']) || $student['second_come'] == '0000-00-00 00:00:00') { + $updateData['second_come'] = date('Y-m-d H:i:s', $current_time); } // 扣减体验课次数 @@ -387,16 +387,41 @@ class AttendanceService extends BaseApiService */ private function handleCustomerResourceCheckin($schedule) { - // 客户资源签到只需要更新状态,不涉及课时扣除 - // 状态已经在主流程中更新了,这里可以记录签到日志或其他业务逻辑 - - // 可以在这里添加客户资源的特殊处理逻辑 - // 比如记录体验课次数、更新客户跟进状态等 - + // 客户资源签到,需要检查是否为体验课学员并更新相关字段 + $student_id = $schedule['student_id']; $current_time = time(); - // 如果需要更新客户资源相关信息,可以在这里添加 - // 例如:更新体验课次数、最后上课时间等 + if (!empty($student_id)) { + // 查询学员信息 + $student = (new SchoolStudent()) + ->where('id', $student_id) + ->find(); + + if ($student) { + $updateData = []; + + // 更新到校时间逻辑 + if (empty($student['first_come']) || $student['first_come'] == '0000-00-00 00:00:00') { + $updateData['first_come'] = date('Y-m-d H:i:s', $current_time); + } else if (empty($student['second_come']) || $student['second_come'] == '0000-00-00 00:00:00') { + $updateData['second_come'] = date('Y-m-d H:i:s', $current_time); + } + + // 扣减体验课次数 + $trial_class_count = $student['trial_class_count'] ?: 0; + if ($trial_class_count > 0) { + $updateData['trial_class_count'] = $trial_class_count - 1; + } + + if (!empty($updateData)) { + $updateData['updated_at'] = date('Y-m-d H:i:s'); + $student->save($updateData); + } + + // 插入消课记录(体验课也需要记录) + $this->insertUsageRecord(0, $student_id, 1, $schedule); + } + } return true; } diff --git a/uniapp/pages-market/clue/class_arrangement_detail.vue b/uniapp/pages-market/clue/class_arrangement_detail.vue index 7af329b7..e7d4fe3a 100644 --- a/uniapp/pages-market/clue/class_arrangement_detail.vue +++ b/uniapp/pages-market/clue/class_arrangement_detail.vue @@ -320,7 +320,8 @@ phone: studentData.phone_number || '待获取', age: studentData.age || null, member_id: studentData.user_id || this.student_id, - resource_id: studentData.resource_id || this.resource_id, + student_id: studentData.student_id || this.student_id, // 学员表ID + resource_id: studentData.resource_id || this.resource_id, // 客户资源表ID is_formal_student: studentData.is_formal_student || false, course_info: studentData.course_info || [], student_course_id: studentData.student_course_id || null @@ -350,7 +351,8 @@ phone: '待获取', age: null, member_id: this.student_id, - resource_id: this.resource_id, + student_id: this.student_id, // 学员表ID + resource_id: this.resource_id, // 客户资源表ID is_formal_student: false, course_info: [], student_course_id: null @@ -436,7 +438,8 @@ phone: student.phone_number, age: student.age, member_id: student.member_id, - resource_id: student.id, + student_id: student.student_id || student.id, // 学员表ID + resource_id: student.resource_id || 0, // 客户资源表ID,如果没有则为0 is_formal_student: student.is_formal_student || false, course_info: student.course_info || [] })); @@ -514,7 +517,7 @@ // 构建添加学员的数据 const data = { - 'resources_id': this.selectedStudent.resource_id || this.resource_id, + 'resources_id': this.selectedStudent.resource_id || this.resource_id || 0, 'person_type': 'customer_resource', 'schedule_id': this.course_id, 'course_date': this.schedule_info.course_date, @@ -523,7 +526,7 @@ 'schedule_type': this.currentSlot.type === 'waiting' ? 2 : 1, 'course_type': this.currentSlot.type === 'waiting' ? 3 : parseInt(this.courseArrangement), 'remark': this.remarks, - 'student_id': this.selectedStudent.member_id, + 'student_id': this.selectedStudent.student_id || this.selectedStudent.id, }; try {