From 15b1f5674b2f49a2c5507f1a0c70570a7ab1dd8c Mon Sep 17 00:00:00 2001 From: "1213317725@qq.com" <1213317725@qq.com> Date: Thu, 18 Sep 2025 17:55:41 +0800 Subject: [PATCH] 1 --- .../apiController/CustomerResources.php | 40 +- niucloud/app/api/controller/member/Member.php | 1 + .../controller/student/StudentController.php | 72 +- niucloud/app/api/route/member.php | 2 + niucloud/app/api/route/student.php | 4 + niucloud/app/listener/personnel/Student.php | 14 +- .../CustomerResourcesService.php | 6 +- .../PersonCourseScheduleService.php | 13 + .../physical_test/PhysicalTestService.php | 4 +- .../api/apiService/PersonnelService.php | 88 +- .../app/service/api/member/MemberService.php | 32 +- .../service/api/student/StudentService.php | 196 +- uniapp/api/member.js | 6 + .../coach/my/teaching_management_info.vue | 144 +- uniapp/pages-market/clue/add_clues.vue | 16 +- .../clue/class_arrangement_detail.vue | 3 +- uniapp/pages-market/clue/clue_info.vue | 3488 +++++++++-------- uniapp/pages-market/clue/edit_clues.vue | 10 +- uniapp/pages-market/clue/index.vue | 26 +- uniapp/pages-student/schedule/index.vue | 1 + 20 files changed, 2229 insertions(+), 1937 deletions(-) diff --git a/niucloud/app/api/controller/apiController/CustomerResources.php b/niucloud/app/api/controller/apiController/CustomerResources.php index 18ef87c6..e8883d1f 100644 --- a/niucloud/app/api/controller/apiController/CustomerResources.php +++ b/niucloud/app/api/controller/apiController/CustomerResources.php @@ -29,7 +29,7 @@ class CustomerResources extends BaseApiService * school_customer_resources: male/female/other * school_student: 1/2/0 */ - private function convertGender($gender) + private function convertGender($gender) { switch ($gender) { case 'male': @@ -66,15 +66,15 @@ class CustomerResources extends BaseApiService $date = date('Y-m-d'); $param = $request->param(); $promised_visit_time = $request->param('promised_visit_time', ''); - if ($promised_visit_time) { - $promised_visit_time = date('Y-m-d H:i:s', strtotime($promised_visit_time)); - } +// if ($promised_visit_time) { +// $promised_visit_time = date('Y-m-d H:i:s', strtotime($promised_visit_time)); +// } $optional_class_time = $request->param('optional_class_time', ''); - if ($optional_class_time) { - $optional_class_time = date('Y-m-d H:i:s', strtotime($optional_class_time)); - } +// if ($optional_class_time) { +// $optional_class_time = date('Y-m-d H:i:s', strtotime($optional_class_time)); +// } $personnel = new Personnel(); $role_id = $personnel->alias("a") ->join(['school_campus_person_role' => 'b'], 'a.id = b.person_id', 'left') @@ -143,7 +143,7 @@ class CustomerResources extends BaseApiService // 获取当前登录人的staff_id $staff_id = $request->param('staff_id', 0); - + $res = (new CustomerResourcesService())->addData($customer_resources_data, $six_speed_data, $student_data, $staff_id, $role_id); if (!$res['code']) { return fail($res['msg']); @@ -157,15 +157,15 @@ class CustomerResources extends BaseApiService $customer_resources_id = $request->param('id', '');//客户资源表id $promised_visit_time = $request->param('promised_visit_time', ''); - if ($promised_visit_time) { - $promised_visit_time = date('Y-m-d H:i:s', strtotime($promised_visit_time)); - } +// if ($promised_visit_time) { +// $promised_visit_time = date('Y-m-d H:i:s', strtotime($promised_visit_time)); +// } $optional_class_time = $request->param('optional_class_time', ''); - if ($optional_class_time) { - $optional_class_time = date('Y-m-d H:i:s', strtotime($optional_class_time)); - } +// if ($optional_class_time) { +// $optional_class_time = date('Y-m-d H:i:s', strtotime($optional_class_time)); +// } if (empty($customer_resources_id)) { @@ -291,11 +291,11 @@ class CustomerResources extends BaseApiService public function getGiftRecordList(Request $request) { $resource_id = $request->param('resource_id', ''); - + if (empty($resource_id)) { return fail('缺少客户资源ID'); } - + $res = (new CustomerResourcesService())->getGiftRecordList(['resource_id' => $resource_id]); if (!$res['code']) { return fail($res['msg']); @@ -307,11 +307,11 @@ class CustomerResources extends BaseApiService public function getStudentLabel(Request $request) { $id = $request->param('id', ''); - + if (empty($id)) { return fail('缺少标签ID'); } - + $res = (new CustomerResourcesService())->getStudentLabel(['label_id' => $id]); if (!$res['code']) { return fail($res['msg']); @@ -350,11 +350,11 @@ class CustomerResources extends BaseApiService { $resource_id = $request->param('resource_id', ''); $student_id = $request->param('student_id', ''); - + if (empty($resource_id) && empty($student_id)) { return fail('缺少必要参数'); } - + $where = [ 'resource_id' => $resource_id, 'student_id' => $student_id diff --git a/niucloud/app/api/controller/member/Member.php b/niucloud/app/api/controller/member/Member.php index c0a029f1..04f330cd 100644 --- a/niucloud/app/api/controller/member/Member.php +++ b/niucloud/app/api/controller/member/Member.php @@ -212,4 +212,5 @@ class Member extends BaseApiController public function get_classes_list(){ return success(( new MemberService() )->get_classes_list()); } + } diff --git a/niucloud/app/api/controller/student/StudentController.php b/niucloud/app/api/controller/student/StudentController.php index 3f690036..09fa6378 100644 --- a/niucloud/app/api/controller/student/StudentController.php +++ b/niucloud/app/api/controller/student/StudentController.php @@ -9,6 +9,8 @@ namespace app\api\controller\student; +use app\Request; +use app\service\api\apiService\PersonnelService; use app\service\api\parent\ParentService; use app\service\api\student\StudentService; use core\base\BaseController; @@ -29,9 +31,9 @@ class StudentController extends BaseController try { $service = new StudentService(); $result = $service->getStudentList(); - + return success($result, '获取学员列表成功'); - + } catch (\Exception $e) { return fail($e->getMessage()); } @@ -74,7 +76,7 @@ class StudentController extends BaseController 'list' => $studentList, 'total' => count($studentList) ], '获取学员列表成功'); - + } catch (\Exception $e) { return fail($e->getMessage()); } @@ -97,9 +99,9 @@ class StudentController extends BaseController try { $service = new StudentService(); $result = $service->getStudentSummary($data['student_id']); - + return success($result, '获取学员概览成功'); - + } catch (\Exception $e) { return fail($e->getMessage()); } @@ -122,9 +124,9 @@ class StudentController extends BaseController try { $service = new StudentService(); $result = $service->getStudentInfoWithPhysicalTest($data['student_id']); - + return success($result, '获取学员信息成功'); - + } catch (\Exception $e) { return fail($e->getMessage()); } @@ -158,9 +160,9 @@ class StudentController extends BaseController try { $service = new StudentService(); $result = $service->updateStudentInfo($data); - + return success($result, '更新学员信息成功'); - + } catch (\Exception $e) { return fail($e->getMessage()); } @@ -183,9 +185,9 @@ class StudentController extends BaseController try { $service = new StudentService(); $result = $service->uploadAvatar($data['student_id']); - + return success($result, '头像上传成功'); - + } catch (\Exception $e) { return fail($e->getMessage()); } @@ -242,9 +244,9 @@ class StudentController extends BaseController try { $service = new StudentService(); $result = $service->getCourseScheduleList($data); - + return success($result, '获取课程安排成功'); - + } catch (\Exception $e) { return fail($e->getMessage()); } @@ -267,9 +269,9 @@ class StudentController extends BaseController try { $service = new StudentService(); $result = $service->getCourseScheduleDetail($data['schedule_id']); - + return success($result, '获取课程详情成功'); - + } catch (\Exception $e) { return fail($e->getMessage()); } @@ -294,9 +296,9 @@ class StudentController extends BaseController try { $service = new StudentService(); $result = $service->requestCourseLeave($data); - + return success($result, '请假申请成功'); - + } catch (\Exception $e) { return fail($e->getMessage()); } @@ -335,11 +337,41 @@ class StudentController extends BaseController try { $service = new StudentService(); $result = $service->getCourseStatistics($data); - + return success($result, '获取课程统计成功'); - + } catch (\Exception $e) { return fail($e->getMessage()); } } -} \ No newline at end of file + + public function is_pass(Request $request){ + //获取员工信息 + $old_password = $request->param('password',''); + if(empty($old_password)){ + return fail('请输入旧密码'); + } + $res = (new StudentService())->checkMemberOldPwd($old_password); + if(!$res['code']){ + return fail('旧密码不正确'); + } + return success($res['data']); + } + + public function set_pass(Request $request){ + $new_password = $request->param('old_password',''); + $password = $request->param('password',''); + + + if($new_password != $password){ + return fail('二次密码输入不正确'); + } + + + $res = (new StudentService())->updatePassword($new_password); + if(!$res['code']){ + return fail('旧密码不正确'); + } + return success($res['data']); + } +} diff --git a/niucloud/app/api/route/member.php b/niucloud/app/api/route/member.php index efd26eb3..875cbfad 100644 --- a/niucloud/app/api/route/member.php +++ b/niucloud/app/api/route/member.php @@ -131,6 +131,8 @@ Route::group('member', function () { //员工工资详情 Route::get('salary/info/:id', 'member.Salary/info'); + + })->middleware(ApiChannel::class) ->middleware(ApiPersonnelCheckToken::class, true) ->middleware(ApiLog::class); diff --git a/niucloud/app/api/route/student.php b/niucloud/app/api/route/student.php index 17dfb97f..94cf71f9 100644 --- a/niucloud/app/api/route/student.php +++ b/niucloud/app/api/route/student.php @@ -35,6 +35,10 @@ Route::group('student', function () { Route::get('contract/download', 'student.StudentContract/downloadContract'); Route::get('contract/download-file', 'student.StudentContract/downloadFile'); Route::get('student-info', 'student.StudentContract/getStudentInfo'); + + Route::post('is_pass', 'app\api\controller\student\StudentController@is_pass'); + Route::post('set_pass', 'app\api\controller\student\StudentController@set_pass'); + })->middleware(['ApiCheckToken']); // 体测数据管理 diff --git a/niucloud/app/listener/personnel/Student.php b/niucloud/app/listener/personnel/Student.php index 2d66d3c4..bab1e306 100644 --- a/niucloud/app/listener/personnel/Student.php +++ b/niucloud/app/listener/personnel/Student.php @@ -49,13 +49,17 @@ class Student $studentCourses = new StudentCourses(); $student_course_usage = new StudentCourseUsage(); $schedule_info = $courseSchedule->where(['id' => $data['schedule_id']])->find(); + $studentCourses_info = $studentCourses->where(['student_id' => $data['student_id'], 'course_id' => $schedule_info['course_id']])->find(); - $student_course_usage->insert([ - 'student_course_id' => $studentCourses_info['id'], - 'used_hours' => $studentCourses_info['single_session_count'], - 'usage_date' => date("Y-m-d") - ]); + if($studentCourses_info){ + $student_course_usage->insert([ + 'student_course_id' => $studentCourses_info['id'], + 'used_hours' => $studentCourses_info['single_session_count'], + 'usage_date' => date("Y-m-d") + ]); + } + } diff --git a/niucloud/app/service/admin/customer_resources/CustomerResourcesService.php b/niucloud/app/service/admin/customer_resources/CustomerResourcesService.php index c61c4a8e..a84dc765 100644 --- a/niucloud/app/service/admin/customer_resources/CustomerResourcesService.php +++ b/niucloud/app/service/admin/customer_resources/CustomerResourcesService.php @@ -232,7 +232,7 @@ class CustomerResourcesService extends BaseAdminService $personnel = new Personnel(); $data['consultant'] = $personnel->where(['sys_user_id' => $this->uid])->value("id"); if(!$data['consultant']){ - return fail("操作失败"); + return fail("超级管理员不允许修改资源"); } if ($this->model->where([ @@ -685,11 +685,11 @@ class CustomerResourcesService extends BaseAdminService if (empty($data['resource_id'])) { return []; } - + // 使用API服务层的方法 $api_service = new \app\service\api\apiService\CustomerResourcesService(); $result = $api_service->getGiftRecordList(['resource_id' => $data['resource_id']]); - + if ($result['code']) { return $result['data']; } else { diff --git a/niucloud/app/service/admin/person_course_schedule/PersonCourseScheduleService.php b/niucloud/app/service/admin/person_course_schedule/PersonCourseScheduleService.php index 998c0279..45116fc4 100644 --- a/niucloud/app/service/admin/person_course_schedule/PersonCourseScheduleService.php +++ b/niucloud/app/service/admin/person_course_schedule/PersonCourseScheduleService.php @@ -236,4 +236,17 @@ class PersonCourseScheduleService extends BaseAdminService $customerResourcesModel = new CustomerResources(); return $customerResourcesModel->select()->toArray(); } + + public function xk(int $id) + { + $data = $this->model->where([['id', '=', $id]])->find()->toArray(); + + + event('Student', [ + 'event_type' => 'xiaoke', + 'data' => $data + ]); + return true; + } + } diff --git a/niucloud/app/service/admin/physical_test/PhysicalTestService.php b/niucloud/app/service/admin/physical_test/PhysicalTestService.php index 6e54e800..7ea81883 100644 --- a/niucloud/app/service/admin/physical_test/PhysicalTestService.php +++ b/niucloud/app/service/admin/physical_test/PhysicalTestService.php @@ -39,7 +39,7 @@ class PhysicalTestService extends BaseAdminService */ public function getPage(array $where = []) { - $field = 'id,resource_id,student_id,height,weight,coach_id,created_at,updated_at,seated_forward_bend,sit_ups,push_ups,flamingo_balance,thirty_sec_jump,standing_long_jump,agility_run,balance_beam,tennis_throw,ten_meter_shuttle_run,physical_test_report'; + $field = '*'; $order = 'id desc'; $search_model = $this->model->withSearch(["resource_id","student_id"], $where)->with(['customerResources','student','personnel'])->field($field)->order($order); @@ -55,7 +55,7 @@ class PhysicalTestService extends BaseAdminService */ public function getInfo(int $id) { - $field = 'id,resource_id,student_id,height,weight,coach_id,created_at,updated_at,seated_forward_bend,sit_ups,push_ups,flamingo_balance,thirty_sec_jump,standing_long_jump,agility_run,balance_beam,tennis_throw,ten_meter_shuttle_run,physical_test_report'; + $field = '*'; $info = $this->model->field($field)->where([['id', "=", $id]])->with(['customerResources','student','personnel'])->findOrEmpty()->toArray(); return $info; diff --git a/niucloud/app/service/api/apiService/PersonnelService.php b/niucloud/app/service/api/apiService/PersonnelService.php index 85e66246..54e6e561 100644 --- a/niucloud/app/service/api/apiService/PersonnelService.php +++ b/niucloud/app/service/api/apiService/PersonnelService.php @@ -12,6 +12,7 @@ namespace app\service\api\apiService; use app\model\campus_person_role\CampusPersonRole; +use app\model\customer_resources\CustomerResources; use app\model\departments\Departments; use app\model\member\Member; use app\model\personnel\Personnel; @@ -263,6 +264,9 @@ class PersonnelService extends BaseApiService return $res; } + + + //设置新密码 public function edidPassword($phone, $new_password, $key_value) { @@ -445,9 +449,9 @@ class PersonnelService extends BaseApiService } // 检查是否使用审批流程 - if (isset($data['use_approval']) && $data['use_approval'] && + if (isset($data['use_approval']) && $data['use_approval'] && isset($data['approval_config_id']) && $data['approval_config_id'] > 0) { - + // 启动审批流程 $approvalService = new \app\service\school_approval\SchoolApprovalProcessService(); $processData = [ @@ -638,7 +642,7 @@ class PersonnelService extends BaseApiService { $prefix = 'EMP'; $date = date('Ymd'); - + // 查询今天已生成的最大编号 $maxNumber = $this->model ->where('employee_number', 'like', $prefix . $date . '%') @@ -736,7 +740,7 @@ class PersonnelService extends BaseApiService $roleNameStr = implode(',', $roleNames); $roleKeyStr = implode(',', $roleKeys); - + // 根据角色名称分类 $personnelData = [ 'id' => $personnel['person_id'], @@ -752,35 +756,35 @@ class PersonnelService extends BaseApiService $isCoach = false; $isEducation = false; $isAssistant = false; - + // 检查是否为教练类角色 - if (stripos($roleNameStr, '教练') !== false || + if (stripos($roleNameStr, '教练') !== false || stripos($roleNameStr, '教师') !== false || stripos($roleNameStr, '主教') !== false || stripos($roleKeyStr, 'coach') !== false || stripos($roleKeyStr, 'teacher') !== false) { $isCoach = true; } - + // 检查是否为教务类角色 if (stripos($roleNameStr, '教务') !== false || stripos($roleKeyStr, 'education') !== false || stripos($roleKeyStr, 'academic') !== false) { $isEducation = true; } - + // 检查是否为助教类角色 if (stripos($roleNameStr, '助教') !== false || stripos($roleNameStr, '助理') !== false || stripos($roleKeyStr, 'assistant') !== false) { $isAssistant = true; } - + // 如果没有明确的角色分类,则作为通用人员添加到所有列表 if (!$isCoach && !$isEducation && !$isAssistant) { $isCoach = $isEducation = $isAssistant = true; } - + // 根据分类结果添加到对应列表 if ($isCoach) { $coachList[] = $personnelData; @@ -820,10 +824,10 @@ class PersonnelService extends BaseApiService { try { $where = []; - + // 查询条件:dept_id=2(教练部门) $campusPersonWhere = ['dept_id' => 2]; - + // 校区筛选 if (!empty($data['campus_id'])) { $campusPersonWhere['campus_id'] = $data['campus_id']; @@ -837,7 +841,7 @@ class PersonnelService extends BaseApiService // 查询符合条件的教练人员ID $coachPersonIds = CampusPersonRole::where($campusPersonWhere) ->column('person_id'); - + if (empty($coachPersonIds)) { return [ 'code' => 1, @@ -845,36 +849,36 @@ class PersonnelService extends BaseApiService 'data' => [] ]; } - + // 构建人员表查询条件 $where[] = ['id', 'in', $coachPersonIds]; - + // 姓名关键词搜索 if (!empty($data['keyword'])) { $where[] = ['name', 'like', '%' . $data['keyword'] . '%']; } - + // 状态筛选,默认获取有效教练 if (isset($data['status'])) { $where[] = ['status', '=', $data['status']]; } - + // 只获取未逻辑删除的教练 $where[] = ['deleted_at', '=', 0]; - + $coachList = $this->model ->where($where) ->field('id, name, head_img, phone, employee_number') ->order('create_time DESC') ->select() ->toArray(); - + return [ 'code' => 1, 'msg' => '获取成功', 'data' => $coachList ]; - + } catch (\Exception $e) { return [ 'code' => 0, @@ -920,30 +924,30 @@ class PersonnelService extends BaseApiService { try { $where = []; - + // 查询销售部门(dept_id=3)下的所有角色ID -// $salesRoleIds = SysRole::where('dept_id', 3) -// ->where('status', 1) -// ->column('role_id'); -// -// if (empty($salesRoleIds)) { -// return [ -// 'code' => 1, -// 'msg' => '暂无销售部门角色', -// 'data' => [] -// ]; -// } -// -// // 构建校区人员角色关系查询条件 -// $campusPersonWhere = [ -// ['role_id', 'in', $salesRoleIds] -// ]; - + $salesRoleIds = SysRole::where('dept_id', 3) + ->where('status', 1) + ->column('role_id'); + + if (empty($salesRoleIds)) { + return [ + 'code' => 1, + 'msg' => '暂无销售部门角色', + 'data' => [] + ]; + } + + // 构建校区人员角色关系查询条件 + $campusPersonWhere = [ + ['role_id', 'in', $salesRoleIds] + ]; + // 根据传入的校区进行筛选 if (!empty($campus)) { $campusPersonWhere[] = ['campus_id', '=', $campus]; } - + // 查询符合条件的销售人员ID $salesPersonIds = CampusPersonRole::where($campusPersonWhere) ->column('person_id'); @@ -955,7 +959,7 @@ class PersonnelService extends BaseApiService 'data' => [] ]; } - + // 从personnel表中获取人员信息,包含姓名和电话 $salesPersonnel = $this->model ->whereIn('id', $salesPersonIds) @@ -964,13 +968,13 @@ class PersonnelService extends BaseApiService ->order('create_time DESC') ->select() ->toArray(); - + return [ 'code' => 1, 'msg' => '获取成功', 'data' => $salesPersonnel ]; - + } catch (\Exception $e) { return [ 'code' => 0, diff --git a/niucloud/app/service/api/member/MemberService.php b/niucloud/app/service/api/member/MemberService.php index 8081fd77..12e47611 100644 --- a/niucloud/app/service/api/member/MemberService.php +++ b/niucloud/app/service/api/member/MemberService.php @@ -378,7 +378,7 @@ class MemberService extends BaseApiService { // 添加调试日志 Log::debug('MemberService/student_list - 接收参数: ' . json_encode($data)); - + // 创建查询构建器 $student_courses = new StudentCourses(); $query = $student_courses @@ -389,22 +389,22 @@ class MemberService extends BaseApiService ->join(['school_member' => 'f'],'f.member_id = e.member_id',"left") ->join(['school_resource_sharing' => 'g'],'g.resource_id = e.id',"left") ->where("a.main_coach_id = {$this->member_id} OR a.education_id = {$this->member_id} OR find_in_set('{$this->member_id}', a.assistant_ids) "); - + // 基础条件:到期时间筛选 if(isset($data['type']) && $data['type'] == "daoqi"){ $query->where('a.end_date', 'between', [date('Y-m-d', strtotime('-6 days')), date('Y-m-d')]); } - + // 处理课时数量查询 (gift_hours + total_hours - use_total_hours - use_gift_hours = lessonCount) if (!empty($data['lessonCount'])) { $query->whereRaw("(a.gift_hours + a.total_hours - a.use_total_hours - a.use_gift_hours) = {$data['lessonCount']}"); } - + // 处理课程ID查询 if (!empty($data['courseId']) && $data['courseId'] !== 'null') { $query->where('a.course_id', '=', $data['courseId']); } - + // 处理姓名查询(模糊匹配) if (!empty($data['name'])) { Log::debug('MemberService/student_list - 添加姓名查询条件: ' . $data['name']); @@ -412,15 +412,15 @@ class MemberService extends BaseApiService Log::debug('MemberService/student_list - 姓名匹配模式: ' . $namePattern); $query->where('e.name', 'like', $namePattern); } - - // 处理手机号查询(模糊匹配) + + // 处理手机号查询(模糊匹配) if (!empty($data['phone'])) { Log::debug('MemberService/student_list - 添加手机号查询条件: ' . $data['phone']); $phonePattern = '%' . $data['phone'] . '%'; Log::debug('MemberService/student_list - 手机号匹配模式: ' . $phonePattern); $query->where('e.phone_number', 'like', $phonePattern); } - + // 处理请假次数查询 if (!empty($data['leaveCount'])) { $person_course_schedule = new PersonCourseSchedule(); @@ -430,35 +430,35 @@ class MemberService extends BaseApiService ->group('resources_id') ->having("COUNT(*) = {$data['leaveCount']}") ->column('resources_id'); - + if (empty($leave_resource_ids)) { // 如果没有满足请假次数的资源,返回空结果 Log::debug('MemberService/student_list - 没有满足请假次数的资源,返回空结果'); return []; } - + $query->where('e.id', 'in', $leave_resource_ids); } - + // 处理班级ID查询 if (!empty($data['classId']) && $data['classId'] !== 'null') { $class_resources_rel = new ClassResourcesRel(); $class_resource_ids = $class_resources_rel ->where(['class_id' => $data['classId']]) ->column('resource_id'); - + if (empty($class_resource_ids)) { // 如果班级下没有资源,返回空结果 Log::debug('MemberService/student_list - 班级下没有资源,返回空结果'); return []; } - + $query->where('e.id', 'in', $class_resource_ids); } - + // 记录生成的SQL(仅用于调试) Log::debug('MemberService/student_list - SQL: ' . $query->buildSql()); - + $list = $query->field(" b.id,e.name,c.campus_name as campus, a.total_hours,a.gift_hours,a.use_total_hours,a.use_gift_hours,a.end_date,f.headimg as avatar,g.id as resource_sharing_id, @@ -468,7 +468,7 @@ class MemberService extends BaseApiService $result = $list ? $list->toArray() : []; Log::debug('MemberService/student_list - 查询结果数量: ' . count($result)); - + return $result; } diff --git a/niucloud/app/service/api/student/StudentService.php b/niucloud/app/service/api/student/StudentService.php index 0a944408..105a23a2 100644 --- a/niucloud/app/service/api/student/StudentService.php +++ b/niucloud/app/service/api/student/StudentService.php @@ -9,6 +9,8 @@ use app\model\customer_resources\CustomerResources; use app\model\student\Student; use app\model\member\Member; use app\model\student_label\StudentLabel; +use app\model\sys\SysUser; +use think\facade\Cache; use think\facade\Db; use core\base\BaseService; use core\exception\CommonException; @@ -26,7 +28,7 @@ class StudentService extends BaseService { // 获取当前登录用户ID $customerId = $this->getUserId(); - + // 通过客户资源表获取user_id $customerResource = (new CustomerResources())->where('id', $customerId)->find(); if (!$customerResource) { @@ -46,10 +48,10 @@ class StudentService extends BaseService $student['age'] = $this->calculateAge($student['birthday']); $student['gender_text'] = $student['gender'] == 1 ? '男' : '女'; $student['headimg'] = $student['headimg'] ? get_image_url($student['headimg']) : ''; - + // 添加student_id字段,确保前端能正确获取学员ID $student['student_id'] = $student['id']; - + // 获取学员课时统计信息 $courseStats = $this->getStudentCourseStats($student['id']); $student['course_stats'] = $courseStats; @@ -85,11 +87,11 @@ class StudentService extends BaseService // 获取课程统计信息 $courseStats = $this->getStudentCourseStats($studentId); - + // 获取预约资格信息 $bookingService = new \app\service\api\student\CourseBookingService(); $qualification = $bookingService->checkStudentQualification($studentId); - + return [ 'student_id' => $student['id'], 'name' => $student['name'], @@ -134,10 +136,10 @@ class StudentService extends BaseService } $studentData = $student->toArray(); - + // 处理图片URL $studentData['headimg'] = $studentData['headimg'] ? get_image_url($studentData['headimg']) : ''; - + // 计算年龄 $studentData['age'] = $this->calculateAge($studentData['birthday']); $studentData['gender_text'] = $studentData['gender'] == 1 ? '男' : '女'; @@ -208,7 +210,7 @@ class StudentService extends BaseService public function updateStudentInfo($data) { $studentId = $data['student_id']; - + // 验证学员权限 $this->checkStudentPermission($studentId); @@ -217,7 +219,7 @@ class StudentService extends BaseService ->where('id', $studentId) ->where('deleted_at', 0) ->find(); - + if (!$student) { throw new CommonException('学员信息不存在'); } @@ -225,7 +227,7 @@ class StudentService extends BaseService // 允许更新的字段 $allowedFields = ['name', 'gender', 'birthday', 'emergency_contact', 'contact_phone', 'note', 'headimg']; $updateData = []; - + foreach ($allowedFields as $field) { if (isset($data[$field]) && $data[$field] !== '') { $updateData[$field] = $data[$field]; @@ -244,7 +246,7 @@ class StudentService extends BaseService $result = Db::table('school_student') ->where('id', $studentId) ->update($updateData); - + if ($result === false) { throw new CommonException('更新学员信息失败'); } @@ -317,17 +319,17 @@ class StudentService extends BaseService private function calculateAge($birthday) { if (!$birthday) return 0; - + $birthTime = strtotime($birthday); if (!$birthTime) return 0; - + $age = date('Y') - date('Y', $birthTime); - + // 如果还没过生日,年龄减1 if (date('md') < date('md', $birthTime)) { $age--; } - + return max(0, $age); } @@ -339,18 +341,18 @@ class StudentService extends BaseService private function calculateAgeFromBirthday($birthday) { if (!$birthday) return 0; - + $birthTime = strtotime($birthday); if (!$birthTime) return 0; - + $today = new \DateTime(); $birthDate = new \DateTime($birthday); - + $interval = $today->diff($birthDate); - + $years = $interval->y; $months = $interval->m; - + // 将月份转换为小数,如3岁11个月 = 3.11 return $years + ($months / 100); } @@ -363,7 +365,7 @@ class StudentService extends BaseService public function addChild($data) { $customerId = $this->getUserId(); - + // 创建学员数据 $studentData = [ 'user_id' => $customerId, @@ -383,7 +385,7 @@ class StudentService extends BaseService try { // 插入学员数据 $studentId = Db::table('school_student')->insertGetId($studentData); - + if (!$studentId) { throw new CommonException('添加孩子失败'); } @@ -394,7 +396,7 @@ class StudentService extends BaseService 'gender_text' => $data['gender'] == 1 ? '男' : '女', 'age' => $this->calculateAge($data['birthday']) ]; - + } catch (\Exception $e) { throw new CommonException('添加孩子失败:' . $e->getMessage()); } @@ -414,22 +416,22 @@ class StudentService extends BaseService ['pcs.deleted_at', '=', 0], ['cs.deleted_at', '=', 0] ]; - + // 日期筛选 if (!empty($params['date'])) { $where[] = ['cs.course_date', '=', $params['date']]; } - + // 日期范围筛选 if (!empty($params['start_date']) && !empty($params['end_date'])) { $where[] = ['cs.course_date', 'between', [$params['start_date'], $params['end_date']]]; } - + // 状态筛选 if (isset($params['status']) && $params['status'] !== '') { $where[] = ['pcs.status', '=', $params['status']]; } - + // 查询课程安排数据,联合两个表 $scheduleList = Db::table('school_person_course_schedule pcs') ->leftJoin('school_course_schedule cs', 'pcs.schedule_id = cs.id') @@ -464,12 +466,12 @@ class StudentService extends BaseService ->order('cs.course_date desc, cs.start_time desc') ->select() ->toArray(); - + // 处理数据格式 foreach ($scheduleList as &$schedule) { // 状态处理 $schedule['status_text'] = $this->getScheduleStatusText($schedule['status']); - + // 时间处理 if (!$schedule['start_time'] || !$schedule['end_time']) { // 如果没有具体时间,从time_slot中解析 @@ -478,20 +480,20 @@ class StudentService extends BaseService $schedule['start_time'] = $times[0] ?? '09:00'; $schedule['end_time'] = $times[1] ?? '10:00'; } - + $schedule['time_slot'] = $schedule['start_time'] . '-' . $schedule['end_time']; $schedule['duration'] = $schedule['duration'] ?: 60; - + // 准备事项(模拟数据,实际可从课程信息中获取) $schedule['preparation_items'] = $this->getCoursePreparationItems($schedule['course_name']); } - + return [ 'list' => $scheduleList, 'total' => count($scheduleList) ]; } - + /** * 获取课程安排详情 * @param int $scheduleId @@ -536,23 +538,23 @@ class StudentService extends BaseService TIMESTAMPDIFF(MINUTE, cs.start_time, cs.end_time) as duration ') ->find(); - + if (!$schedule) { throw new CommonException('课程安排不存在'); } - + // 验证权限 $this->checkStudentPermission($schedule['student_id']); - + // 处理数据格式 $schedule['status_text'] = $this->getScheduleStatusText($schedule['status']); $schedule['time_slot'] = $schedule['start_time'] . '-' . $schedule['end_time']; $schedule['duration'] = $schedule['duration'] ?: 60; $schedule['preparation_items'] = $this->getCoursePreparationItems($schedule['course_name']); - + return $schedule; } - + /** * 申请课程请假 * @param array $data @@ -562,41 +564,41 @@ class StudentService extends BaseService { $scheduleId = $data['schedule_id']; $reason = $data['reason'] ?? ''; - + // 查询课程安排 $schedule = Db::table('school_person_course_schedule') ->where('id', $scheduleId) ->where('deleted_at', 0) ->find(); - + if (!$schedule) { throw new CommonException('课程安排不存在'); } - + // 验证权限 $this->checkStudentPermission($schedule['student_id']); - + // 检查课程状态 if ($schedule['status'] != 0) { // 0-待上课 throw new CommonException('当前课程状态不允许请假'); } - + // 获取对应的课程安排信息来检查时间 $courseSchedule = Db::table('school_course_schedule') ->where('id', $schedule['schedule_id']) ->find(); - + if ($courseSchedule) { // 检查请假时间限制(上课前6小时) $courseDateTime = $courseSchedule['course_date'] . ' ' . $courseSchedule['start_time']; $courseTimestamp = strtotime($courseDateTime); $currentTimestamp = time(); - + if ($courseTimestamp - $currentTimestamp < 6 * 3600) { throw new CommonException('上课前6小时内不允许请假'); } } - + // 更新状态为请假 $result = Db::table('school_person_course_schedule') ->where('id', $scheduleId) @@ -605,16 +607,16 @@ class StudentService extends BaseService 'cancel_reason' => $reason, 'updated_at' => date('Y-m-d H:i:s') ]); - + if ($result === false) { throw new CommonException('请假申请失败'); } - + // TODO: 发送消息通知相关人员 - + return true; } - + /** * 获取课程状态文本 * @param int $status @@ -624,14 +626,14 @@ class StudentService extends BaseService { $statusMap = [ 0 => '待上课', - 1 => '已完成', + 1 => '已完成', 2 => '请假', 3 => '取消' ]; - + return $statusMap[$status] ?? '未知状态'; } - + /** * 获取课程准备事项 * @param string $courseName @@ -650,7 +652,7 @@ class StudentService extends BaseService '儿童游泳' => ['泳衣', '泳帽', '游泳镜', '毛巾'], '暑季特训营' => ['运动服装', '防晒用品', '充足水分', '能量补充食品'] ]; - + return $preparationMap[$courseName] ?? ['运动服装', '运动鞋', '毛巾', '水杯']; } @@ -689,10 +691,10 @@ class StudentService extends BaseService // 有效课程 = total_hours + gift_hours $totalValidHours = $totalHours + $giftHours; - + // 已使用 = use_total_hours + use_gift_hours $usedHours = $useTotalHours + $useGiftHours; - + // 剩余课时数 = total_hours + gift_hours - use_total_hours - use_gift_hours $remainingHours = $totalValidHours - $usedHours; @@ -714,7 +716,7 @@ class StudentService extends BaseService if ($memberId) { return $memberId; } - + // 如果没有中间件设置,尝试解析token $token = request()->header('token'); if ($token) { @@ -729,7 +731,7 @@ class StudentService extends BaseService throw new CommonException('用户未登录或token无效'); } } - + // 如果都没有,抛出异常 throw new CommonException('用户未登录'); } @@ -756,19 +758,19 @@ class StudentService extends BaseService $studentId = $params['student_id']; $startDate = $params['start_date']; $endDate = $params['end_date']; - + // 构建查询条件 $where = [ ['pcs.student_id', '=', $studentId], ['pcs.deleted_at', '=', 0], ['cs.deleted_at', '=', 0] ]; - + // 日期筛选 if (!empty($startDate) && !empty($endDate)) { $where[] = ['cs.course_date', 'between', [$startDate, $endDate]]; } - + // 查询课程安排数据 $scheduleList = Db::table('school_person_course_schedule pcs') ->leftJoin('school_course_schedule cs', 'pcs.schedule_id = cs.id') @@ -776,13 +778,13 @@ class StudentService extends BaseService ->field('pcs.status') ->select() ->toArray(); - + // 统计各状态数量 $totalCourses = count($scheduleList); $completedCourses = 0; $scheduledCourses = 0; $cancelledCourses = 0; - + foreach ($scheduleList as $schedule) { switch ($schedule['status']) { case 1: // 已完成 @@ -797,7 +799,7 @@ class StudentService extends BaseService break; } } - + return [ 'total_courses' => $totalCourses, 'completed_courses' => $completedCourses, @@ -805,4 +807,68 @@ class StudentService extends BaseService 'cancelled_courses' => $cancelledCourses ]; } -} \ No newline at end of file + + public function checkMemberOldPwd(string $old_passowrd) + { + $res = [ + 'code' => 0, + 'msg' => '操作失败', + 'data' => [] + ]; + $customerResources = new CustomerResources(); + + $personnel_id = $this->getUserId(); + $member = new Member(); + $phone = $customerResources->where('id', $personnel_id)->value('phone_number'); + + $password = $customerResources->where('id', $personnel_id)->value('password'); + + if (!check_password($old_passowrd, $password)) { + $res['msg'] = '旧密码错误'; + return $res; + } + $res['code'] = 1; + $res['msg'] = '密码正确'; + $res['data'] = [ + 'key_value' => $this->setEditPasswordKey($phone) + ]; + return $res; + } + + public function updatePassword($new_password){ + $customerResources = new CustomerResources(); + + $personnel_id = $this->getUserId(); + + $update = $customerResources->where('id', $personnel_id)->update([ + 'password' => create_password($new_password) + ]); + if (!$update) { + $res = [ + 'code' => 0, + 'msg' => '操作失败', + 'data' => [] + ]; + } else { + $res = [ + 'code' => 1, + 'msg' => '操作成功', + 'data' => [] + ]; + } + return $res; + } + + public function setEditPasswordKey(string $phone) + { + $key_name = 'edit_password_' . $phone; + //生成字符串,存入cache中 + //check_password()//验证 + //create_password()//创建 + + $key_value = create_password($key_name); + // 缓存在3600秒之后过期 + Cache::set($key_name, $key_value, 3600); + return $key_value; + } +} diff --git a/uniapp/api/member.js b/uniapp/api/member.js index 737a986b..047ac87c 100644 --- a/uniapp/api/member.js +++ b/uniapp/api/member.js @@ -149,4 +149,10 @@ export default { async getSalaryInfo(data = {}) { return await http.get(`/member/salary/info/${data.id}`); }, + async is_pass(data = {}) { + return await http.post('/student/is_pass', data) + }, + async set_pass(data = {}) { + return await http.post('/student/set_pass', data) + }, } \ No newline at end of file diff --git a/uniapp/pages-coach/coach/my/teaching_management_info.vue b/uniapp/pages-coach/coach/my/teaching_management_info.vue index d20a284a..75006210 100644 --- a/uniapp/pages-coach/coach/my/teaching_management_info.vue +++ b/uniapp/pages-coach/coach/my/teaching_management_info.vue @@ -191,8 +191,9 @@ export default { if (url.startsWith('http://') || url.startsWith('https://')) { return url; } + // 如果是相对路径,添加基础URL - return 'http://localhost:20080' + (url.startsWith('/') ? url : '/' + url); + return 'https://api.hnhbty.cn' + (url.startsWith('/') ? url : '/' + url); }, // 图片预览 @@ -204,75 +205,92 @@ export default { }, // 文件下载 - downloadFile(url) { - uni.showLoading({ - title: '下载中...' - }); - - uni.downloadFile({ - url: url, - success: (res) => { - if (res.statusCode === 200) { - // 获取文件扩展名 - const extension = this.getFileExtension(url); - const fileName = this.getFileName(url); - - // 保存到相册或文档 - if (['jpg', 'jpeg', 'png', 'gif', 'webp'].includes(extension.toLowerCase())) { - // 图片文件保存到相册 - uni.saveImageToPhotosAlbum({ - filePath: res.tempFilePath, - success: () => { - uni.showToast({ - title: '保存成功', - icon: 'success' - }); - }, - fail: (error) => { - console.error('保存图片失败:', error); - uni.showToast({ - title: '保存失败', - icon: 'none' - }); - } +downloadFile(url) { + uni.showLoading({ + title: '下载中...' + }); + + // 判断平台 + // #ifdef H5 + // H5 浏览器处理 + const link = document.createElement('a'); + link.href = url; + link.download = this.getFileName(url); // 自动取文件名 + document.body.appendChild(link); + link.click(); + document.body.removeChild(link); + + uni.hideLoading(); + uni.showToast({ + title: '开始下载', + icon: 'success' + }); + // #endif + + // #ifndef H5 + // 小程序 / App 走 uni.downloadFile + uni.downloadFile({ + url: url, + success: (res) => { + if (res.statusCode === 200) { + const extension = this.getFileExtension(url); + + if (['jpg', 'jpeg', 'png', 'gif', 'webp'].includes(extension.toLowerCase())) { + // 保存图片 + uni.saveImageToPhotosAlbum({ + filePath: res.tempFilePath, + success: () => { + uni.showToast({ + title: '保存成功', + icon: 'success' }); - } else { - // 其他文件类型,打开文档 - uni.openDocument({ - filePath: res.tempFilePath, - showMenu: true, - success: () => { - console.log('打开文档成功'); - }, - fail: (error) => { - console.error('打开文档失败:', error); - uni.showToast({ - title: '无法打开文件', - icon: 'none' - }); - } + }, + fail: (error) => { + console.error('保存图片失败:', error); + uni.showToast({ + title: '保存失败', + icon: 'none' + }); + } + }); + } else { + // 打开其他文件 + uni.openDocument({ + filePath: res.tempFilePath, + showMenu: true, + success: () => { + console.log('打开文档成功'); + }, + fail: (error) => { + console.error('打开文档失败:', error); + uni.showToast({ + title: '无法打开文件', + icon: 'none' }); } - } else { - uni.showToast({ - title: '下载失败', - icon: 'none' - }); - } - }, - fail: (error) => { - console.error('下载失败:', error); - uni.showToast({ - title: '下载失败', - icon: 'none' }); - }, - complete: () => { - uni.hideLoading(); } + } else { + uni.showToast({ + title: '下载失败', + icon: 'none' + }); + } + }, + fail: (error) => { + console.error('下载失败:', error); + uni.showToast({ + title: '下载失败', + icon: 'none' }); }, - + complete: () => { + uni.hideLoading(); + } + }); + // #endif +}, + // 获取文件名 getFileName(url) { if (!url) return ''; diff --git a/uniapp/pages-market/clue/add_clues.vue b/uniapp/pages-market/clue/add_clues.vue index 964eba74..e78390da 100644 --- a/uniapp/pages-market/clue/add_clues.vue +++ b/uniapp/pages-market/clue/add_clues.vue @@ -390,12 +390,24 @@ :bottomBorder='false' > - + + + diff --git a/uniapp/pages-market/clue/class_arrangement_detail.vue b/uniapp/pages-market/clue/class_arrangement_detail.vue index e7d4fe3a..cacd63a4 100644 --- a/uniapp/pages-market/clue/class_arrangement_detail.vue +++ b/uniapp/pages-market/clue/class_arrangement_detail.vue @@ -485,7 +485,8 @@ }); return; } - + + console.log(this.selectedStudent); // 2. 检查学员信息是否完整 if (!this.selectedStudent.name || !this.selectedStudent.phone) { uni.showToast({ diff --git a/uniapp/pages-market/clue/clue_info.vue b/uniapp/pages-market/clue/clue_info.vue index b7bb25ba..b6a91913 100644 --- a/uniapp/pages-market/clue/clue_info.vue +++ b/uniapp/pages-market/clue/clue_info.vue @@ -1,1043 +1,1101 @@ \ No newline at end of file diff --git a/uniapp/pages-market/clue/edit_clues.vue b/uniapp/pages-market/clue/edit_clues.vue index 03f96109..d8ac24f7 100644 --- a/uniapp/pages-market/clue/edit_clues.vue +++ b/uniapp/pages-market/clue/edit_clues.vue @@ -165,12 +165,18 @@ - + + + + + + @@ -309,7 +315,7 @@ - + diff --git a/uniapp/pages-market/clue/index.vue b/uniapp/pages-market/clue/index.vue index a280bad9..912ea8f0 100644 --- a/uniapp/pages-market/clue/index.vue +++ b/uniapp/pages-market/clue/index.vue @@ -18,10 +18,10 @@ - + 新资源 - +