diff --git a/admin/src/app/api/customer_resources.ts b/admin/src/app/api/customer_resources.ts index e43e8779..1dae55ba 100644 --- a/admin/src/app/api/customer_resources.ts +++ b/admin/src/app/api/customer_resources.ts @@ -76,3 +76,15 @@ export function fpEdit(params: Record) { export function getWithCoachList(params: Record) { return request.get('customer_resources/coach_person', { params }) } + +export function getLogList(params: Record) { + return request.get('customer_resources/log_list', { params }) +} + +export function getStudentCoursesList(params: Record) { + return request.get('customer_resources/student_courses', { params }) +} + +export function getOrderTableList(params: Record) { + return request.get('customer_resources/order_table', { params }) +} diff --git a/admin/src/app/api/service_logs.js b/admin/src/app/api/service_logs.js new file mode 100644 index 00000000..9eec98b6 --- /dev/null +++ b/admin/src/app/api/service_logs.js @@ -0,0 +1,13 @@ +import request from '@/utils/request' + + +// USER_CODE_BEGIN -- service_logs +/** + * + * @param params + * @returns + */ +export function getServiceLogsList(params) { + return request.get(`service_logs/service_logs`, {params}) +} + diff --git a/admin/src/app/views/customer_resource_changes/customer_resource_changes.vue b/admin/src/app/views/customer_resource_changes/customer_resource_changes.vue index 2db80a27..8a2c8a4f 100644 --- a/admin/src/app/views/customer_resource_changes/customer_resource_changes.vue +++ b/admin/src/app/views/customer_resource_changes/customer_resource_changes.vue @@ -76,6 +76,12 @@ import { useRoute } from 'vue-router' const route = useRoute() const pageName = route.meta.title +const props = defineProps({ + value: Number +}) + +console.log(props.value); + let customerResourceChangesTable = reactive({ page: 1, limit: 10, @@ -83,7 +89,7 @@ let customerResourceChangesTable = reactive({ loading: true, data: [], searchParam: { - customer_resource_id: route.query.id, + customer_resource_id: props.value ? props.value : route.query.id, }, }) diff --git a/admin/src/app/views/customer_resources/components/UserProfile.vue b/admin/src/app/views/customer_resources/components/UserProfile.vue new file mode 100644 index 00000000..a7449c72 --- /dev/null +++ b/admin/src/app/views/customer_resources/components/UserProfile.vue @@ -0,0 +1,172 @@ + + + + + \ No newline at end of file diff --git a/admin/src/app/views/customer_resources/components/log.vue b/admin/src/app/views/customer_resources/components/log.vue new file mode 100644 index 00000000..d5c0fbf9 --- /dev/null +++ b/admin/src/app/views/customer_resources/components/log.vue @@ -0,0 +1,122 @@ + + + + + diff --git a/admin/src/app/views/customer_resources/components/order_table.vue b/admin/src/app/views/customer_resources/components/order_table.vue new file mode 100644 index 00000000..19d9b656 --- /dev/null +++ b/admin/src/app/views/customer_resources/components/order_table.vue @@ -0,0 +1,118 @@ + + + + + diff --git a/admin/src/app/views/customer_resources/components/student_courses.vue b/admin/src/app/views/customer_resources/components/student_courses.vue new file mode 100644 index 00000000..6c52cda9 --- /dev/null +++ b/admin/src/app/views/customer_resources/components/student_courses.vue @@ -0,0 +1,131 @@ + + + + + diff --git a/admin/src/app/views/customer_resources/customer_resources.vue b/admin/src/app/views/customer_resources/customer_resources.vue index fd0a598b..e8d0d138 100644 --- a/admin/src/app/views/customer_resources/customer_resources.vue +++ b/admin/src/app/views/customer_resources/customer_resources.vue @@ -127,6 +127,9 @@ 客户信息修改记录 + + 客户详情 + {{ t('edit') }} @@ -180,6 +183,7 @@ + @@ -195,6 +199,8 @@ import Fp from '@/app/views/customer_resources/components/fp.vue' import Order from '@/app/views/order_table/components/order-table-edit.vue' import Tc from '@/app/views/tc_dialog/tc_dialog.vue' + import User from '@/app/views/customer_resources/components/UserProfile.vue' + import { ArrowDown } from '@element-plus/icons-vue' import { getMemberLabelAll } from '@/app/api/member' @@ -244,6 +250,9 @@ case 'deleteEvent': deleteEvent(row.id) break + case 'UserProfile': + UserProfile(row) + break } } @@ -276,7 +285,8 @@ editOrderTableDialog.value.setFormData(row) editOrderTableDialog.value.showDialog = true } - + + const TcCustomerResourcesDialog : Record | null = ref(null) const tcEvent = (row : any) => { @@ -290,8 +300,13 @@ } + const UserProfileDialog : Record | null = ref(null) - + const UserProfile = (row : any) => { + UserProfileDialog.value.setFormData(row) + UserProfileDialog.value.showDialog = true + } + const searchFormRef = ref() // 选中数据 diff --git a/admin/src/app/views/school_approval/process/index.vue b/admin/src/app/views/school_approval/process/index.vue index e1e95ea6..cad1d932 100644 --- a/admin/src/app/views/school_approval/process/index.vue +++ b/admin/src/app/views/school_approval/process/index.vue @@ -52,9 +52,9 @@ > - + - + - - - - - - - - - + + + + + + + + + + + + + + + + +
getPage($data)); } + + /** * 客户资源详情 * @param int $id @@ -196,4 +198,31 @@ class CustomerResources extends BaseAdminController { return success((new CustomerResourcesService())->getResourceByCourse($schedule)); } + + + public function log_list() + { + $data = $this->request->params([ + ["customer_resource_id", ""] + ]); + return success((new CustomerResourcesService())->log_list($data)); + } + + public function student_courses() + { + $data = $this->request->params([ + ["customer_resource_id", ""] + ]); + return success((new CustomerResourcesService())->student_courses($data)); + } + + public function order_table() + { + $data = $this->request->params([ + ["customer_resource_id", ""] + ]); + return success((new CustomerResourcesService())->order_table($data)); + } + + } diff --git a/niucloud/app/adminapi/controller/school_approval/Process.php b/niucloud/app/adminapi/controller/school_approval/Process.php index cc67e5d8..01d37c3c 100644 --- a/niucloud/app/adminapi/controller/school_approval/Process.php +++ b/niucloud/app/adminapi/controller/school_approval/Process.php @@ -34,32 +34,32 @@ class Process extends BaseAdminController $page = input('page', 1); $limit = input('limit', 10); $status = input('approval_status', ''); - + $where = []; if ($status !== '') { - $where[] = ['approval_status', '=', $status]; + $where[] = ['a.approval_status', '=', $status]; } - + $process_name = input('process_name', ''); if (!empty($process_name)) { - $where[] = ['process_name', 'like', "%{$process_name}%"]; + $where[] = ['a.process_name', 'like', "%{$process_name}%"]; } - + // 我发起的审批 $applicant_id = input('applicant_id', 0); if (!empty($applicant_id)) { - $where[] = ['applicant_id', '=', $applicant_id]; + $where[] = ['a.applicant_id', '=', $applicant_id]; } - + // 待我审批的 $approver_id = input('approver_id', 0); if (!empty($approver_id)) { - $where[] = ['current_approver_id', '=', $approver_id]; - $where[] = ['approval_status', '=', 'pending']; + $where[] = ['a.current_approver_id', '=', $approver_id]; + $where[] = ['a.approval_status', '=', 'pending']; } - + $data = $this->service->getList($where, (int)$page, (int)$limit); - + return success($data); } @@ -72,12 +72,12 @@ class Process extends BaseAdminController if (empty($id)) { return fail('参数错误'); } - + $info = $this->service->getInfo((int)$id); if (empty($info)) { return fail('审批流程不存在'); } - + return success($info); } @@ -88,19 +88,19 @@ class Process extends BaseAdminController { $data = Request::only(['process_name', 'remarks']); $config_id = input('config_id', 0); - + // 验证参数 if (empty($data['process_name'])) { return fail('流程名称不能为空'); } - + if (empty($config_id)) { return fail('请选择审批流配置'); } - + // 设置申请人ID $data['applicant_id'] = $this->request->uid(); - + try { $process_id = $this->service->create($data, $config_id); return success(['id' => $process_id]); @@ -117,15 +117,15 @@ class Process extends BaseAdminController $process_id = input('process_id', 0); $status = input('status', ''); $remarks = input('remarks', ''); - + if (empty($process_id)) { return fail('参数错误'); } - + if (empty($status) || !in_array($status, ['approved', 'rejected'])) { return fail('请选择审批结果'); } - + try { $result = $this->service->approve((int)$process_id, $this->request->uid(), $status, $remarks); return success($result); @@ -140,11 +140,11 @@ class Process extends BaseAdminController public function cancel() { $process_id = input('process_id', 0); - + if (empty($process_id)) { return fail('参数错误'); } - + try { $result = $this->service->cancel($process_id, $this->request->uid()); return success($result); @@ -152,4 +152,4 @@ class Process extends BaseAdminController return fail($e->getMessage()); } } -} \ No newline at end of file +} diff --git a/niucloud/app/adminapi/controller/service_logs/ServiceLogs.php b/niucloud/app/adminapi/controller/service_logs/ServiceLogs.php new file mode 100644 index 00000000..f420285b --- /dev/null +++ b/niucloud/app/adminapi/controller/service_logs/ServiceLogs.php @@ -0,0 +1,39 @@ +request->params([ + ["name",""], + ["score",""] + ]); + return success((new ServiceLogsService())->getPage($data)); + } + +} diff --git a/niucloud/app/adminapi/controller/student_course_usage/StudentCourseUsage.php b/niucloud/app/adminapi/controller/student_course_usage/StudentCourseUsage.php index c9005c68..0ccad9ac 100644 --- a/niucloud/app/adminapi/controller/student_course_usage/StudentCourseUsage.php +++ b/niucloud/app/adminapi/controller/student_course_usage/StudentCourseUsage.php @@ -28,9 +28,9 @@ class StudentCourseUsage extends BaseAdminController */ public function lists(){ $data = $this->request->params([ - ["student_course_id",""], - ["used_hours",""], - ["usage_date",""] + ["emergency_contact",""], + ["student_name",""], + ["contact_phone",""] ]); return success((new StudentCourseUsageService())->getPage($data)); } @@ -87,5 +87,5 @@ class StudentCourseUsage extends BaseAdminController return success('DELETE_SUCCESS'); } - + } diff --git a/niucloud/app/adminapi/route/customer_resources.php b/niucloud/app/adminapi/route/customer_resources.php index 2be1d5cc..ecdfe098 100644 --- a/niucloud/app/adminapi/route/customer_resources.php +++ b/niucloud/app/adminapi/route/customer_resources.php @@ -47,6 +47,11 @@ Route::group('customer_resources', function () { Route::get('getResourceByCourse/:schedule/students', 'customer_resources.CustomerResources/getResourceByCourse'); + Route::get('log_list','customer_resources.CustomerResources/log_list'); + + Route::get('student_courses','customer_resources.CustomerResources/student_courses'); + + Route::get('order_table','customer_resources.CustomerResources/order_table'); })->middleware([ AdminCheckToken::class, AdminCheckRole::class, diff --git a/niucloud/app/adminapi/route/service_logs.php b/niucloud/app/adminapi/route/service_logs.php new file mode 100644 index 00000000..e4d15e1e --- /dev/null +++ b/niucloud/app/adminapi/route/service_logs.php @@ -0,0 +1,31 @@ +middleware([ + AdminCheckToken::class, + AdminCheckRole::class, + AdminLog::class +]); +// USER_CODE_END -- service diff --git a/niucloud/app/api/controller/apiController/ClassApi.php b/niucloud/app/api/controller/apiController/ClassApi.php index 83f4ec5b..24b8d248 100644 --- a/niucloud/app/api/controller/apiController/ClassApi.php +++ b/niucloud/app/api/controller/apiController/ClassApi.php @@ -12,7 +12,8 @@ namespace app\api\controller\apiController; use app\Request; -use app\service\api\apiService\CourseService; +use app\service\api\apiService\jlClassService; +use app\service\api\apiService\PhysicalTestService; use core\base\BaseApiService; @@ -21,22 +22,93 @@ use core\base\BaseApiService; * Class Personnel * @package app\api\controller\apiController */ -class ClassSpi extends BaseApiService +class ClassApi extends BaseApiService { //课程列表 public function jlClassList(Request $request){ $id = $this->member_id; - dd(111); - return success((new CourseService())->list($id,$data)); + $data = $this->request->params([ + ["name",''] + ]); + return success((new jlClassService())->list($id,$data)); + } + + //课程详情 + public function jlClassInfo(Request $request){ + $data = $this->request->params([ + ["class_id",0] + ]); + return success('获取成功',(new jlClassService())->info($data['class_id'])); } - //获取课程详情 - public function courseInfo(Request $request){ + //获取学员详情 + public function jlStudentsInfo(Request $request){ $data = $this->request->params([ - ["id",0] + ["students_id",0] ]); - return success('SUCCESS',(new CourseService())->info($data['id'])); + return success('获取成功',(new jlClassService())->jlStudentsInfo($data['students_id'])); + } + + //体测列表 + public function PhysicalTestList(Request $request){ + $data = $this->request->params([ + ["user_id",0] + ]); + return success('获取成功',(new jlClassService())->PhysicalTestList($data['user_id'])); + } + + //体测详情 + public function PhysicalTestInfo(Request $request) + { + $id = $request->param('survey_id', '');//体测报告的id + if (empty($id)) { + return fail('缺少参数'); + } + $where = [ + 'id' => $id, + ]; + $res = (new PhysicalTestService())->getInfo($where); + if(!$res['code']){ + return fail($res['msg']); + } + return success($res['data']); } + //添加作业-获取班级列表 + public function jlGetClassesList(Request $request) + { + return success((new jlClassService())->GetClassesList()); + } + + //添加作业-获取课程列表 + public function jlGetCoursesList(Request $request) + { + return success((new jlClassService())->GetCoursesList()); + } + + //添加作业-学员列表 + public function jlGetStudentList(Request $request) + { + return success((new jlClassService())->GetStudentList()); + } + + //添加作业 + public function addJlPublishJob(Request $request) + { + $data = $this->request->params([ + ["class_id",0], + ["classes_id_name",''], + ["content_text",''], + ["content_type",''], + ["course_id",0], + ["course_id_name",''], + ["student_id",''], + ["students_ids_name",''], + ["type",''], + ]); + return success('操作成功', (new jlClassService())->addPublishJob($data)); + } + + } diff --git a/niucloud/app/api/controller/apiController/Course.php b/niucloud/app/api/controller/apiController/Course.php index a4b7a69d..597c7104 100644 --- a/niucloud/app/api/controller/apiController/Course.php +++ b/niucloud/app/api/controller/apiController/Course.php @@ -33,6 +33,12 @@ class Course extends BaseApiService return success((new CourseService())->list($id,$data)); } + //班级课程列表 + public function classCourseList(Request $request){ + $id = $this->member_id; + return success((new CourseService())->classList($id)); + } + //获取课程详情 public function courseInfo(Request $request){ $data = $this->request->params([ diff --git a/niucloud/app/api/controller/apiController/CustomerResourcesAuth.php b/niucloud/app/api/controller/apiController/CustomerResourcesAuth.php new file mode 100644 index 00000000..1fd574ab --- /dev/null +++ b/niucloud/app/api/controller/apiController/CustomerResourcesAuth.php @@ -0,0 +1,119 @@ +param('phone', ''); //手机号 + $password = $request->param('password', ''); //密码 + $openid = $request->param('openid', ''); //微信小程序openid + + if (empty($phone)) { + return fail('请输入手机号'); + } + if (empty($password)) { + return fail('请输入密码'); + } + + $member_info = Member::where('mobile', $phone)->find();//查账户表信息是否存在 + + + if (!$member_info) { + return fail('账户手机号有误'); + } + + $customerResources = \app\model\customer_resources\CustomerResources::where('member_id', $member_info['member_id'])->find();//查客户资源表信息是否存在 + if (!$customerResources) { + return fail('账户信息有误'); + } + + //创建密码 + //$a = create_password($password); + //验证密码 + if (!check_password($password, $member_info->password)) { + return fail('手机号或密码不正确'); + } + + + $res = (new LoginService())->login($member_info, MemberLoginTypeDict::MOBILE); + if (!$res) { + return fail('账户信息有误'); + } + $res['user_type'] = '3';//用户类型|3=学员 + return success($res); + } + + //学生详情 + public function info(){ + $member_id = $this->member_id; + $where = [ + 'member_id'=>$member_id + ]; + $res = (new CustomerResourcesService())->getInfo($where); + if (!$res['code']) { + return fail($res['msg']); + } + return success($res['data']); + } + + //学生详情-修改 + public function edit(Request $request){ + $member_id = $this->member_id; + $where = [ + 'member_id'=>$member_id + ]; + $data = [ + 'headimg' => $request->param('headimg', ''), + 'name' => $request->param('name', ''), + 'gender' => $request->param('gender', ''), + 'age' => $request->param('age', ''), + 'phone_number' => $request->param('phone_number', ''), + ]; + + // 验证必填字段 + if (empty($data['name'])) { + return fail('姓名不能为空'); + } + if (empty($data['gender'])) { + return fail('性别不能为空'); + } + if (empty($data['age'])) { + return fail('年龄不能为空'); + } + if (empty($data['phone_number'])) { + return fail('手机号不能为空'); + } + + $res = (new CustomerResourcesService())->editInfo($where,$data); + if (!$res['code']) { + return fail($res['msg']); + } + return success([]); + } + +} diff --git a/niucloud/app/api/controller/apiController/PersonCourseSchedule.php b/niucloud/app/api/controller/apiController/PersonCourseSchedule.php new file mode 100644 index 00000000..df2731ee --- /dev/null +++ b/niucloud/app/api/controller/apiController/PersonCourseSchedule.php @@ -0,0 +1,42 @@ +param('resources_id', '');//客户资源ID + if (empty($resources_id)) { + return fail('缺少参数'); + } + + $where = [ + 'resources_id' => $resources_id, + ]; + + $res = (new PersonCourseScheduleService())->getList($where); + + return success($res); + } +} diff --git a/niucloud/app/api/controller/apiController/PhysicalTest.php b/niucloud/app/api/controller/apiController/PhysicalTest.php new file mode 100644 index 00000000..9c7bbe1e --- /dev/null +++ b/niucloud/app/api/controller/apiController/PhysicalTest.php @@ -0,0 +1,65 @@ +param('resource_id', '');//学生资源表id + if (empty($resource_id)) { + return fail('缺少参数'); + } + + $where = [ + 'resource_id' => $resource_id, + ]; + + $res = (new PhysicalTestService())->getList($where); + + return success($res); + } + + //详情 + public function info(Request $request) + { + $id = $request->param('id', '');//体测报告的id + + if (empty($id)) { + return fail('缺少参数'); + } + + $where = [ + 'id' => $id, + ]; + + $res = (new PhysicalTestService())->getInfo($where); + + if(!$res['code']){ + return fail($res['msg']); + } + + return success($res['data']); + } +} diff --git a/niucloud/app/api/controller/apiController/TeachingResearch.php b/niucloud/app/api/controller/apiController/TeachingResearch.php index b202071b..71cd1a5f 100644 --- a/niucloud/app/api/controller/apiController/TeachingResearch.php +++ b/niucloud/app/api/controller/apiController/TeachingResearch.php @@ -115,10 +115,15 @@ class TeachingResearch extends BaseApiService if ($resLessonTeaching['answers_num'] >= $res['number_answers']) { return fail('已超过答题次数', []); } else { + if (count($userRes['data']['cameus_dept_arr']) > 0) { + $campus_id = $userRes['data']['cameus_dept_arr'][0]['campus_id']; + } else { + $campus_id = 0; + } foreach ($result as &$v){ $v['user_id'] = $userRes['data']['id']; $v['question_id'] = $v['ids']; - $v['campus_id'] = 0; + $v['campus_id'] = $campus_id; $v['answer'] = $v['value']; $resEq = $ExamQuestions->where('id',$v['ids'])->find(); if ($resEq['correct_answer'] == $v['value']){ diff --git a/niucloud/app/api/controller/apiController/Test.php b/niucloud/app/api/controller/apiController/Test.php new file mode 100644 index 00000000..93490b91 --- /dev/null +++ b/niucloud/app/api/controller/apiController/Test.php @@ -0,0 +1,46 @@ +param('personnel_id', '');//员工人力资源表id(两个参数2选1) + $customer_resources_id = $request->param('customer_resources_id', '');//学生资源表id(两个参数2选1) + if (empty($personnel_id) && empty($customer_resources_id)) { + return fail('缺少参数'); + } + + $where = [ + 'personnel_id' => $personnel_id, + 'customer_resources_id' => $customer_resources_id, + ]; + + $res = (new ChatService())->getChatFriendsPage($where); + + return success($res); + } +} diff --git a/niucloud/app/api/controller/apiController/UserFeedback.php b/niucloud/app/api/controller/apiController/UserFeedback.php new file mode 100644 index 00000000..8ac04a98 --- /dev/null +++ b/niucloud/app/api/controller/apiController/UserFeedback.php @@ -0,0 +1,53 @@ +post('user_id', ''); // 用户ID(对应school_customer_resources表id) + $feedback_text = $request->post('feedback_text', ''); // 反馈内容 + $attachment_url = $request->post('attachment_url', null); // 附件URL(OSS对象存储),允许为空 + + + //验证必填 + if (empty($user_id) || empty($feedback_text)) { + return fail('必填参数不能为空'); + } + + $data = [ + 'user_id' => $user_id, + 'feedback_text' => $feedback_text, + 'attachment_url' => $attachment_url ?? null, + ]; + + $add = \app\model\user_feedback\UserFeedback::create($data); + + if (!$add) { + return fail('添加失败'); + } + + return success([]); + } +} diff --git a/niucloud/app/api/controller/upload/Upload.php b/niucloud/app/api/controller/upload/Upload.php index 1463faaf..b24b7733 100644 --- a/niucloud/app/api/controller/upload/Upload.php +++ b/niucloud/app/api/controller/upload/Upload.php @@ -33,7 +33,17 @@ class Upload extends BaseApiController ['file', 'file'], ]); $upload_service = new UploadService(); - return success($upload_service->image($data['file'],$extraData)); + + $res = $upload_service->image($data['file'],$extraData); + + $res['ext'] = ''; // 初始化文件扩展名 + $res['name'] = ''; // 初始化文件名称 + if (isset($res['url'])) { + $res['ext'] = pathinfo($res['url'], PATHINFO_EXTENSION); + $res['name'] = basename($res['url']); + } + + return success($res); } /** diff --git a/niucloud/app/api/route/route.php b/niucloud/app/api/route/route.php index f26b3824..79593a19 100644 --- a/niucloud/app/api/route/route.php +++ b/niucloud/app/api/route/route.php @@ -278,22 +278,30 @@ Route::group(function () { - - - - - - - - - - + //添加作业 + Route::get('class/jlPublishJob/add', 'apiController.classApi/addJlPublishJob'); + //添加作业-获取课程列表 + Route::get('class/jlGetStudentList/list', 'apiController.classApi/jlGetStudentList'); + //添加作业-获取课程列表 + Route::get('class/jlGetCoursesList/list', 'apiController.classApi/jlGetCoursesList'); + //添加作业-获取班级列表 + Route::get('class/jlGetClasses/list', 'apiController.classApi/jlGetClassesList'); + //体测报告-列表 + Route::get('class/physicalTest', 'apiController.classApi/PhysicalTestList'); + //体测报告-详情 + Route::get('class/physicalTest/info', 'apiController.classApi/PhysicalTestInfo'); + //获取学员详情 + Route::get('class/jlStudentsInfo', 'apiController.classApi/jlStudentsInfo'); + //班级课程列表 + Route::get('course/classCourseList', 'apiController.course/classCourseList'); //获取添加学员列表 Route::get('course/addStudentList', 'apiController.course/addStudentList'); Route::post('course/addStudent', 'apiController.course/addStudent'); Route::get('course/delStudentCourse', 'apiController.course/delStudentCourse'); //班级列表 Route::get('class/jlClassList', 'apiController.classApi/jlClassList'); + //班级详情 + Route::get('class/jlClassInfo', 'apiController.classApi/jlClassInfo'); //课程列表 Route::get('course/courseList', 'apiController.course/courseList'); //获取课程详情 @@ -314,10 +322,11 @@ Route::group(function () { //↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑-----员工端相关-----↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ -//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓-----用户端相关-----↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ +//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓-----学生用户端相关-----↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ //无需token验证的 Route::group(function () { -// Route::post('personnelLogin', 'login.Login/personnelLogin'); + //学生登录 + Route::post('customerResourcesAuth/login', 'apiController.CustomerResourcesAuth/login'); })->middleware(ApiChannel::class) ->middleware(ApiCheckToken::class) ->middleware(ApiLog::class); @@ -325,12 +334,42 @@ Route::group(function () { //需要token验证的 Route::group(function () { -// Route::get('personnel/info', 'apiController.Personnel/info'); + //员工端-上传图片 + Route::post('memberUploadImage', 'upload.Upload/image'); + //学生详情 + Route::get('customerResourcesAuth/info', 'apiController.CustomerResourcesAuth/info'); + //学生详情-修改 + Route::post('customerResourcesAuth/edit', 'apiController.CustomerResourcesAuth/edit'); + + //学生用户反馈-添加 + Route::post('userFeedback/add', 'apiController.UserFeedback/add'); + + //学生端-用户聊天-好友关系列表 + Route::get('xy/chat/getChatFriendsList', 'apiController.Chat/getChatFriendsList'); + //学生端-用户聊天-好友关系详情 + Route::get('xy/chat/getChatFriendsInfo', 'apiController.Chat/getChatFriendsInfo'); + //学生端-用户聊天-获取聊天记录 + Route::get('xy/chat/getChatMessagesList', 'apiController.Chat/getChatMessagesList'); + //学生端-用户聊天-发送聊天内容 + Route::post('xy/chat/sendChatMessages', 'apiController.Chat/sendChatMessages'); + + //学生端-体测报告-列表 + Route::get('xy/physicalTest', 'apiController.PhysicalTest/index'); + //学生端-体测报告-详情 + Route::get('xy/physicalTest/info', 'apiController.PhysicalTest/info'); + + //学生端-学生课程安排-列表 + Route::get('xy/personCourseSchedule', 'apiController.PersonCourseSchedule/index'); + //学生端-学生课程安排-详情 + Route::get('xy/personCourseSchedule/info', 'apiController.PersonCourseSchedule/info'); + + + })->middleware(ApiChannel::class) ->middleware(ApiCheckToken::class, true) ->middleware(ApiLog::class); -//↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑-----用户端相关-----↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ +//↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑-----学生用户端相关-----↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ //加载插件路由 diff --git a/niucloud/app/common.php b/niucloud/app/common.php index f1d57b3b..b043c134 100644 --- a/niucloud/app/common.php +++ b/niucloud/app/common.php @@ -1214,3 +1214,22 @@ function calculateChildHealthScore($age, $gender, $height, $weight) { // 四舍五入取整 return round($total_score); } + + +function get_dict_value($key,$value){ + $dict = new \app\model\dict\Dict(); + $field = 'id,name,key,dictionary,memo,create_time,update_time'; + + $info = $dict->field($field)->where([['key', '=', $key]])->findOrEmpty()->toArray(); + if($info['dictionary'] == null) + { + $info['dictionary'] = []; + } + + $map = []; + foreach ($info['dictionary'] as $item) { + $map[$item['value']] = $item['name']; + } + + return $map[$value]; +} diff --git a/niucloud/app/model/class_grade/ClassGrade.php b/niucloud/app/model/class_grade/ClassGrade.php index acff649b..8e8ce49f 100644 --- a/niucloud/app/model/class_grade/ClassGrade.php +++ b/niucloud/app/model/class_grade/ClassGrade.php @@ -13,6 +13,7 @@ namespace app\model\class_grade; use app\model\campus\Campus; use app\model\personnel\Personnel; +use app\model\class_personnel_rel\ClassPersonnelRel; use core\base\BaseModel; use think\model\concern\SoftDelete; use think\model\relation\HasMany; @@ -229,6 +230,16 @@ class ClassGrade extends BaseModel return $this->hasOne(Personnel::class, 'id', 'head_coach')->joinType('left')->withField('name,id')->bind(['head_coach_name'=>'name']); } + public function personnelAll(){ + return $this->hasOne(Personnel::class, 'id', 'head_coach')->joinType('left')->withField('head_img,id')->bind(['head_coach_head_img'=>'head_img']); + } + public function personnelName(){ + return $this->hasOne(Personnel::class, 'id', 'head_coach')->joinType('left')->withField('name,id')->bind(['head_coach_name'=>'name']); + } + + public function classPersonnelRel(){ + return $this->hasMany(ClassPersonnelRel::class, 'class_id', 'id'); + } } diff --git a/niucloud/app/model/class_personnel_rel/ClassPersonnelRel.php b/niucloud/app/model/class_personnel_rel/ClassPersonnelRel.php new file mode 100644 index 00000000..7644993d --- /dev/null +++ b/niucloud/app/model/class_personnel_rel/ClassPersonnelRel.php @@ -0,0 +1,57 @@ +hasOne(Student::class, 'id', 'source_id'); + } + + public function studentCourses(){ + return $this->hasOne(StudentCourses::class, 'student_id', 'source_id')->joinType('left')->withField('end_date,student_id')->bind(['end_date'=>'end_date']); + } + + public function studentCoursesInfo(){ + return $this->hasOne(StudentCourses::class, 'student_id', 'source_id'); + } + + +} diff --git a/niucloud/app/model/course/Course.php b/niucloud/app/model/course/Course.php index 2f9fc8d4..36992c8e 100644 --- a/niucloud/app/model/course/Course.php +++ b/niucloud/app/model/course/Course.php @@ -12,6 +12,7 @@ namespace app\model\course; use core\base\BaseModel; +use app\model\student_courses\StudentCourses; use think\model\concern\SoftDelete; use think\model\relation\HasMany; use think\model\relation\HasOne; @@ -85,7 +86,7 @@ class Course extends BaseModel $query->where("course_type", $value); } } - + /** * 搜索器:课程课程时长 * @param $value @@ -97,7 +98,7 @@ class Course extends BaseModel $query->where("duration", $value); } } - + /** * 搜索器:课程课时数量 * @param $value @@ -109,7 +110,7 @@ class Course extends BaseModel $query->where("session_count", $value); } } - + /** * 搜索器:课程单次逍客数量 * @param $value @@ -121,7 +122,7 @@ class Course extends BaseModel $query->where("single_session_count", $value); } } - + /** * 搜索器:课程课程价格 * @param $value @@ -133,7 +134,7 @@ class Course extends BaseModel $query->where("price", $value); } } - + /** * 搜索器:课程内部提醒课时 * @param $value @@ -145,7 +146,7 @@ class Course extends BaseModel $query->where("internal_reminder", $value); } } - + /** * 搜索器:课程客户提醒课时 * @param $value @@ -157,7 +158,7 @@ class Course extends BaseModel $query->where("customer_reminder", $value); } } - + /** * 搜索器:课程课程备注 * @param $value @@ -171,7 +172,10 @@ class Course extends BaseModel } - + public function studentCourses() + { + return $this->hasOne(StudentCourses::class, 'course_id', 'id'); + } diff --git a/niucloud/app/model/course_schedule/CourseSchedule.php b/niucloud/app/model/course_schedule/CourseSchedule.php index ec49b544..943e5c23 100644 --- a/niucloud/app/model/course_schedule/CourseSchedule.php +++ b/niucloud/app/model/course_schedule/CourseSchedule.php @@ -14,6 +14,8 @@ namespace app\model\course_schedule; use app\model\course\Course; use app\model\personnel\Personnel; use app\model\venue\Venue; +use app\model\campus\Campus; +use app\model\student_courses\StudentCourses; use core\base\BaseModel; use think\model\concern\SoftDelete; use think\model\relation\HasMany; @@ -102,4 +104,14 @@ class CourseSchedule extends BaseModel return $this->hasOne(Course::class, 'id', 'course_id'); } + public function campus() + { + return $this->hasOne(Campus::class, 'id', 'campus_id')->joinType('left')->withField('campus_name,id')->bind(['campus_name'=>'campus_name']); + } + + public function studentCourses() + { + return $this->hasOne(StudentCourses::class, 'course_id', 'course_id'); + } + } diff --git a/niucloud/app/model/customer_resources/CustomerResources.php b/niucloud/app/model/customer_resources/CustomerResources.php index 218f156d..ae42a928 100644 --- a/niucloud/app/model/customer_resources/CustomerResources.php +++ b/niucloud/app/model/customer_resources/CustomerResources.php @@ -89,6 +89,7 @@ class CustomerResources extends BaseModel 'updated_at' => '更新时间', 'deleted_at' => '逻辑删除时间', 'status' => '客户状态', + 'member_label' => '资源标签' ]; public function orderTable() @@ -162,6 +163,12 @@ class CustomerResources extends BaseModel return $this->hasMany(ResourceSharing::class, 'resource_id', 'id'); } + //一对一关联"用户账号登陆表" + public function memberHasOne() + { + return $this->hasOne(Member::class, 'member_id', 'member_id'); + } + diff --git a/niucloud/app/model/physical_test/PhysicalTest.php b/niucloud/app/model/physical_test/PhysicalTest.php index c81da6ec..61290480 100644 --- a/niucloud/app/model/physical_test/PhysicalTest.php +++ b/niucloud/app/model/physical_test/PhysicalTest.php @@ -81,6 +81,13 @@ class PhysicalTest extends BaseModel return $this->hasOne(CustomerResources::class, 'id', 'resource_id')->joinType('left')->withField('name,id')->bind(['resource_id_name'=>'name']); } + //获取学生资源一对一 + public function customerResourcesHasOne(){ + return $this->hasOne(CustomerResources::class, 'id', 'resource_id'); + } + + + public function student(){ return $this->hasOne(Student::class, 'id', 'student_id')->joinType('left')->withField('name,id')->bind(['student_id_name'=>'name']); } diff --git a/niucloud/app/model/service_logs/ServiceLogs.php b/niucloud/app/model/service_logs/ServiceLogs.php new file mode 100644 index 00000000..b0d2aafa --- /dev/null +++ b/niucloud/app/model/service_logs/ServiceLogs.php @@ -0,0 +1,44 @@ +hasOne(ClassGrade::class, 'id', 'class_id'); } + } diff --git a/niucloud/app/service/admin/customer_resources/CustomerResourcesService.php b/niucloud/app/service/admin/customer_resources/CustomerResourcesService.php index 326118fd..fa0625cf 100644 --- a/niucloud/app/service/admin/customer_resources/CustomerResourcesService.php +++ b/niucloud/app/service/admin/customer_resources/CustomerResourcesService.php @@ -15,6 +15,8 @@ use app\model\campus_person_role\CampusPersonRole; use app\model\course_schedule\CourseSchedule; use app\model\customer_resource_changes\CustomerResourceChanges; use app\model\customer_resources\CustomerResources; +use app\model\member\Member; +use app\model\member\MemberLabel; use app\model\order_table\OrderTable; use app\model\personnel\Personnel; use app\model\campus\Campus; @@ -22,6 +24,7 @@ use app\model\campus\Campus; use app\model\resource_sharing\ResourceSharing; use app\model\six_speed\SixSpeed; use app\model\six_speed_modification_log\SixSpeedModificationLog; +use app\model\student_courses\StudentCourses; use app\service\admin\member\MemberLabelService; use core\base\BaseAdminService; @@ -95,9 +98,21 @@ class CustomerResourcesService extends BaseAdminService return $this->pageQuery($search_model, function ($item, $key) { $item = $this->makeUp($item); + + $sixSpeed = new SixSpeed(); + $data = $sixSpeed->where(['resource_id' => $item['id']])->findOrEmpty()->toArray(); + $item['six'] = $data; + + $member = new Member(); + + $member_info = $member->where(['member_id' => $item['member_id']])->findOrEmpty()->toArray(); + $item['member_info'] = $member_info; }); } + + + /** * 获取客户资源信息 * @param int $id @@ -415,4 +430,149 @@ class CustomerResourcesService extends BaseAdminService return $all; } + + + + public function log_list(array $data = []) + { + $customer_resource_changes = new CustomerResourceChanges(); + $where = []; + if ($data['customer_resource_id']) { + $where[] = ['a.customer_resource_id', '=', $data['customer_resource_id']]; + } + + + + $search_model = $customer_resource_changes + ->alias("a") + ->join(['school_personnel' => 'b'], 'a.operator_id = b.id', 'left') + ->where($where) + ->field("a.*,b.name") + ->order("a.id asc"); + + + return $this->pageQuery($search_model, function ($item, $key) { + $fieldZhArr = CustomerResources::FieldZh; + $modified_fields = json_decode($item['modified_fields'], true); + $type = []; + foreach ($modified_fields as $key => $value) { + $type[] = $fieldZhArr[$value]; + } + $item['type'] = implode("
",$type); + + $old_values = json_decode($item['old_values'], true); + $new_values = json_decode($item['new_values'], true); + $values = []; + foreach ($old_values as $key => $value) { + + $old_value = $this->fields($key,$value); + $new_value = $this->fields($key,$new_values[$key]); + + $values[] = $old_value.'->'.$new_value; + } + + $item['values'] = implode("
",$values); + + + }); + } + + public function student_courses(array $data = []) + { + $studentCourses = new StudentCourses(); + $where = []; + if ($data['customer_resource_id']) { + $where[] = ['b.user_id', '=', $data['customer_resource_id']]; + } + + + + $search_model = $studentCourses + ->alias("a") + ->join(['school_student' => 'b'], 'a.student_id = b.id', 'left') + ->join(['school_course' => 'c'], 'a.course_id = c.id', 'left') + ->where($where) + ->field("a.*,c.course_name") + ->order("a.id desc"); + + + return $this->pageQuery($search_model, function ($item, $key) { + $item['total'] = $item['total_hours'] + $item['gift_hours']; + $item['used'] = $item['use_total_hours'] + $item['use_gift_hours']; + + $now = date('Y-m-d'); // 当前日期 + + if ($now < $item['start_date']) { + $item['status'] = '未进行'; + } elseif ($now > $item['end_date']) { + $item['status'] = '已结束'; + } else { + $item['status'] = '进行中'; + } + + }); + } + + + public function order_table(array $data = []) + { + $orderTable = new OrderTable(); + $where = []; + if ($data['customer_resource_id']) { + $where[] = ['a.resource_id', '=', $data['customer_resource_id']]; + } + + $search_model = $orderTable + ->alias("a") + ->join(['school_course' => 'b'], 'a.course_id = b.id', 'left') + ->where($where) + ->field("a.*,b.course_name") + ->order("a.id desc"); + + + return $this->pageQuery($search_model, function ($item, $key) { + $arr = ['cash' => '现金支付','scan_code' => '扫码支付','subscription' => '订阅支付']; + $item['type'] = $arr[$item['payment_type']]; + $item['order_status'] = $item['order_status'] == 'pending' ? '待支付' : '已支付'; + }); + } + + + public function fields($filed,$value){ + if(!$value){ + return '空'; + } + $campus = new Campus(); + $member_label = new MemberLabel(); + switch ($filed) { + case 'initial_intent': + return get_dict_value('preliminarycustomerintention',$value); + break; + case 'source': + return get_dict_value('source',$value); + break; + case 'purchasing_power': + return get_dict_value('customer_purchasing_power',$value); + break; + case 'cognitive_idea': + return get_dict_value('cognitive_concept',$value); + break; + case 'source_channel': + return get_dict_value('SourceChannel',$value); + break; + case 'status': + return get_dict_value('kh_status',$value); + break; + case 'member_label': + $label_name = $member_label->where('label_id','in',$value)->column('label_name'); + return implode("-",$label_name); + break; + case 'campus': + return $campus->where(['id' => $value])->value("campus_name"); + break; + default: + return $value; + } + } + } diff --git a/niucloud/app/service/admin/service_logs/ServiceLogsService.php b/niucloud/app/service/admin/service_logs/ServiceLogsService.php new file mode 100644 index 00000000..447f66fb --- /dev/null +++ b/niucloud/app/service/admin/service_logs/ServiceLogsService.php @@ -0,0 +1,60 @@ +model = new ServiceLogs(); + } + + /** + * 获取学员课时消费记录列表 + * @return array + */ + public function getPage(array $data = []) + { + $where = []; + if($data['name']){ + $where[] = ['b.name','like','%'.$data['name'].'%']; + } + + if($data['score']){ + $where[] = ['a.score','=',$data['score']]; + } + + $search_model = $this->model + ->alias("a") + ->join(['school_customer_resources' => 'b'],'a.resource_id = b.id','left') + ->join(['school_personnel' => 'c'],'a.staff_id = c.id','left') + ->join(['school_service' => 'd'],'a.service_id = d.id','left') + ->where($where) + ->field("a.*,b.name,c.name as staff_name,d.service_name,d.customer_confirmation") + ->order("a.id desc"); + $list = $this->pageQuery($search_model); + return $list; + } + + +} diff --git a/niucloud/app/service/admin/student_course_usage/StudentCourseUsageService.php b/niucloud/app/service/admin/student_course_usage/StudentCourseUsageService.php index 82435bbe..b4d7fc7d 100644 --- a/niucloud/app/service/admin/student_course_usage/StudentCourseUsageService.php +++ b/niucloud/app/service/admin/student_course_usage/StudentCourseUsageService.php @@ -31,15 +31,31 @@ class StudentCourseUsageService extends BaseAdminService /** * 获取学员课时消费记录列表 - * @param array $where * @return array */ - public function getPage(array $where = []) + public function getPage(array $data = []) { - $field = 'id,student_course_id,used_hours,usage_date,created_at,updated_at'; - $order = 'id desc'; - - $search_model = $this->model->withSearch(["id","student_course_id","used_hours","usage_date"], $where)->field($field)->order($order); + $where = []; + if($data['emergency_contact']){ + $where[] = ['c.emergency_contact','like','%'.$data['emergency_contact'].'%']; + } + + if($data['student_name']){ + $where[] = ['c.name','like','%'.$data['student_name'].'%']; + } + + if($data['contact_phone']){ + $where[] = ['c.contact_phone','=',$data['contact_phone']]; + } + + $search_model = $this->model + ->alias("a") + ->join(['school_student_courses' => 'b'],'a.student_course_id = b.id','left') + ->join(['school_student' => 'c'],'b.student_id = c.id','left') + ->join(['school_course' => 'd'],'b.course_id = d.id','left') + ->where($where) + ->field("a.*,c.name as student_name,c.emergency_contact,d.course_name,b.total_hours,ROUND(b.total_hours - b.use_total_hours) as sy_time,ROUND(b.gift_hours - b.use_gift_hours) as gift_hours") + ->order("a.id desc"); $list = $this->pageQuery($search_model); return $list; } @@ -94,6 +110,6 @@ class StudentCourseUsageService extends BaseAdminService return $res; } - + } diff --git a/niucloud/app/service/api/apiService/CommonService.php b/niucloud/app/service/api/apiService/CommonService.php index 1dde8cfd..1f0e82cf 100644 --- a/niucloud/app/service/api/apiService/CommonService.php +++ b/niucloud/app/service/api/apiService/CommonService.php @@ -54,6 +54,15 @@ class CommonService extends BaseApiService */ public function forgetPassword($phone, $new_password, $user_type){ if($user_type == 'personnel'){ + $data = SysUser::where('username', $phone)->find(); + if (!$data){ + $res = [ + 'code' => 0, + 'msg' => '用户不存在', + 'data' => [] + ]; + return $res; + } //重置员工(销售/教师)密码 $update = SysUser::where('username', $phone)->update([ 'password' => create_password($new_password),//创建密码 @@ -74,6 +83,15 @@ class CommonService extends BaseApiService } return $res; }else{ + $data = Member::where('username', $phone)->find(); + if (!$data){ + $res = [ + 'code' => 0, + 'msg' => '用户不存在', + 'data' => [] + ]; + return $res; + } //重置用户(学生)密码 $update = Member::where('username', $phone)->update([ 'password' => create_password($new_password),//创建密码 @@ -125,12 +143,18 @@ class CommonService extends BaseApiService } return [ + // 返回发生更改的字段名数组 'changed_fields' => $changedFields, + // 返回旧数据中的更改字段及其值 'old_values' => $oldChanges, + // 返回新数据中的更改字段及其值 'new_values' => $newChanges, + // 将 changed_fields 转换为 JSON 格式,保留中文字符 'changed_fields_json' => json_encode($changedFields, JSON_UNESCAPED_UNICODE), + // 将 old_changes 转换为 JSON 格式,保留中文字符 'old_values_json' => json_encode($oldChanges, JSON_UNESCAPED_UNICODE), + // 将 new_changes 转换为 JSON 格式,保留中文字符 'new_values_json' => json_encode($newChanges, JSON_UNESCAPED_UNICODE) ]; } diff --git a/niucloud/app/service/api/apiService/CourseService.php b/niucloud/app/service/api/apiService/CourseService.php index ddefbf3b..1484cd5e 100644 --- a/niucloud/app/service/api/apiService/CourseService.php +++ b/niucloud/app/service/api/apiService/CourseService.php @@ -50,9 +50,8 @@ class CourseService extends BaseApiService $query->select(); },'venue' => function($query) { $query->select(); - }]); + },'campus','studentCourses']); $list = $this->pageQuery($search_model); - $PersonCourseSchedule = new PersonCourseSchedule(); foreach ($list['data'] as $k => $v) { $student = Db::name('person_course_schedule') ->alias('pcs') @@ -93,7 +92,7 @@ class CourseService extends BaseApiService ->alias('sc') ->where('sc.course_id', $list['id']) ->join('school_student_course_usage sscu', 'sc.id = sscu.student_course_id') - ->field('sc.student_id,sc.end_date') + ->field('sc.student_id,sc.end_date,sc.end_date,sc.start_date,sc.course_id') ->select()->toArray(); foreach ($student_courses as &$v){ $student = Db::name('student') @@ -138,6 +137,44 @@ class CourseService extends BaseApiService } + public function classList($data) + { + $CourseSchedule = new CourseSchedule(); + $search_model = $CourseSchedule + ->where('coach_id', $data) + ->with(['course' => function($query) { + $query->with(['studentCourses' => function($query) { + $query->select(); + }]); + },'venue' => function($query) { + $query->select(); + },'coach' => function($query) { + $query->select(); + },'campus']); + $list = $this->pageQuery($search_model); + foreach ($list['data'] as &$v){ + $student = Db::name('person_course_schedule') + ->alias('pcs') + ->where('pcs.schedule_id', $v['id']) + ->join('school_student st', 'pcs.student_id = st.id') + ->join('school_customer_resources cr', 'st.user_id = cr.id') + ->join('school_member sm', 'cr.member_id = sm.member_id') + ->field('st.name, sm.headimg as avatar') + ->select(); + $v['student'] = $student; + } + foreach ($list['data'] as &$v) { + $student_courses = Db::name('student_courses') + ->alias('sc') + ->where('sc.course_id', $v['id']) + ->join('school_student_course_usage sscu', 'sc.id = sscu.student_course_id') + ->field('sc.student_id,sc.end_date,sc.end_date,sc.start_date,sc.course_id') + ->select()->toArray(); + $v['student_courses'] = $student_courses; + } + return $list; + } + //获取添加学员列表 public function StudentList($id) { diff --git a/niucloud/app/service/api/apiService/CustomerResourcesService.php b/niucloud/app/service/api/apiService/CustomerResourcesService.php index 142dec68..8b0ab131 100644 --- a/niucloud/app/service/api/apiService/CustomerResourcesService.php +++ b/niucloud/app/service/api/apiService/CustomerResourcesService.php @@ -36,6 +36,37 @@ class CustomerResourcesService extends BaseApiService parent::__construct(); } + //获取客户资源详情 + public function getInfo(array $where,string $field = '*'){ + $res = [ + 'code' => 0, + 'msg' => '操作失败', + 'data' => [] + ]; + $model = new CustomerResources(); + if(!empty($where['member_id'])){ + $model = $model->where('member_id', $where['member_id']); + } + $data = $model->field($field) + ->with([ + 'memberHasOne', + 'resourceSharingHasMany' + ]) + ->append([ + 'gender_name', + 'initial_intent_name' + ]) + ->find(); + if ($data){ + $data = $data->toArray(); + $res['code'] = 1; + $res['data'] = $data; + }else{ + $res['msg'] = '暂无数据'; + } + return $res; + } + //获取全部客户资源数据 public function getAll(array $where,string $field = '*') { @@ -280,6 +311,92 @@ class CustomerResourcesService extends BaseApiService } } + //客户资源(学生个人资料)-编辑 + public function editInfo(array $where, array $data) + { + + $res = [ + 'code' => 0, + 'msg' => '操作失败', + 'data' => [] + ]; + + if (!$where) { + $res['msg'] = '查询条件不能为空'; + return $res; + } + + $customer_resources_data = [ + 'name' => $data['name'], // 姓名 + 'gender' => $data['gender'], // 性别(male:男, female:女) + 'age' => $data['age'], // 年龄 + 'phone_number' => $data['phone_number'], // 手机号 + ]; + + $date = date('Y-m-d H:i:s'); + $customer_resources_data['updated_at'] = $date; + + //开启事物 + Db::startTrans(); + try { + $customer_resources = CustomerResources::where('member_id', $where['member_id'])->find(); + + if ($customer_resources) { + $customer_resources = $customer_resources->toArray(); + } + $update_1 = CustomerResources::where('id', $customer_resources['id'])->update($customer_resources_data);//客户资源表 + if (!$update_1) { + Db::rollback(); + return $res; + } + + //更新学生账户登录表 + $member_data = [ + 'username' => $data['phone_number'], + 'mobile' => $data['phone_number'], + 'update_time' => time() + ]; + if (!empty($data['headimg'])) { + $member_data['headimg'] = $data['headimg']; + } + $update_member = Member::where('member_id', $where['member_id'])->update($member_data); + if (!$update_member) { + Db::rollback(); + return $res; + } + + + //更近客户资源日志表 + $compareData = (new CommonService)->compareData($customer_resources, $customer_resources_data); + if ($compareData['changed_fields']) { + $data = [ + "customer_resource_id" => $customer_resources['id'],//客户资源的ID + "operator_id" => 0,//操作人的ID + "campus_id" => 0,//操作人校区的ID|如果这人有2校区就填0 + "modified_fields" => $compareData['changed_fields_json'],//修改的哪些字段 + "old_values" => $compareData['old_values_json'],//修改前的值 + "new_values" => $compareData['new_values_json'],//修改后的值 + ]; + + $id = CustomerResourceChanges::insertGetId($data); + if (!$id) { + Db::rollback(); + return $res; + } + } + + Db::commit(); + $res = [ + 'code' => 1, + 'msg' => '操作成功' + ]; + return $res; + } catch (\Exception $exception) { + Db::rollback(); + return $res; + } + } + //客户资源-获取客户资源修改记录列表 public function getCustomerResourceChangesEditLog(array $where) { diff --git a/niucloud/app/service/api/apiService/PersonCourseScheduleService.php b/niucloud/app/service/api/apiService/PersonCourseScheduleService.php new file mode 100644 index 00000000..8d5d7538 --- /dev/null +++ b/niucloud/app/service/api/apiService/PersonCourseScheduleService.php @@ -0,0 +1,98 @@ +getPageParam();//获取请求参数中的页码+分页数 + $page = $page_params['page']; + $limit = $page_params['limit']; + + $model = new PersonCourseSchedule(); + //判断有没有客户资源id + if (!empty($where['resources_id'])) { + $model = $model->where('resources_id', $where['resources_id']); + } + $schedule_id = $model->distinct(true)->column('schedule_id');//课程安排id + if(!$schedule_id){ + return []; + } + + $data = CourseSchedule::whereIn('id', $schedule_id) + ->order('course_date','desc') + ->with([ + 'venue',//场地 + 'campus',//校区 + 'course',//课程 + ]) + + ->paginate([ + 'list_rows' => $limit, + 'page' => $page, + ])->toArray(); + + + + return $data; + } + + //查询详情 + public function getTestInfo(array $where) + { + $model = new ChatFriends(); + //判断用没有员工id + if (!empty($where['personnel_id'])) { + $model = $model->where('personnel_id', $where['personnel_id']); + } + if (!empty($where['customer_resources_id'])) { + $model = $model->where('customer_resources_id', $where['customer_resources_id']); + } + $data = $model->find(); + + + if ($data) { + $data = $data->toArray(); + $res = [ + 'code' => 1, + 'msg' => '操作成功', + 'data' => $data + ]; + return $res; + } else { + $res = [ + 'code' => 0, + 'msg' => '暂无数据', + 'data' => [] + ]; + return $res; + } + } +} diff --git a/niucloud/app/service/api/apiService/PhysicalTestService.php b/niucloud/app/service/api/apiService/PhysicalTestService.php new file mode 100644 index 00000000..d72df915 --- /dev/null +++ b/niucloud/app/service/api/apiService/PhysicalTestService.php @@ -0,0 +1,115 @@ +getPageParam();//获取请求参数中的页码+分页数 + $page = $page_params['page']; + $limit = $page_params['limit']; + + $model = new PhysicalTest(); + //判断用没有员工id + if (!empty($where['resource_id'])) { + $model = $model->where('resource_id', $where['resource_id']); + } + + $data = $model + ->field($field) + ->order('id','desc') + ->append([ + 'customerResources' + ]) + ->with([ + 'customerResourcesHasOne' + ]) + ->paginate([ + 'list_rows' => $limit, + 'page' => $page, + ])->toArray(); + + + foreach ($data['data'] as &$v) { + $age = $v['age'];//年龄 + $gender = $v['customerResourcesHasOne']['gender'] == 'female' ? 2:1 ;//性别( 1:男,2:女) + $height = $v['height'];//身高 + $weight = $v['weight'];//体重 + $v['calculateChildHealthScore'] = calculateChildHealthScore($age, $gender, $height, $weight);//综合评分 + } + + return $data; + } + + //查询详情 + public function getInfo(array $where,string $field = '*') + { + $model = new PhysicalTest(); + //判断用没有体测报告id + if (!empty($where['id'])) { + $model = $model->where('id', $where['id']); + } + + $data = $model + ->field($field) + ->append([ + 'customerResources' + ]) + ->with([ + 'customerResourcesHasOne' + ]) + ->find(); + + + if ($data) { + $data = $data->toArray(); + + $age = $data['age'];//年龄 + $gender = $data['customerResourcesHasOne']['gender'] == 'female' ? 2 : 1;//性别( 1:男,2:女) + $height = $data['height'];//身高 + $weight = $data['weight'];//体重 + $data['calculateChildHealthScore'] = calculateChildHealthScore($age, $gender, $height, $weight);//综合评分 + + $res = [ + 'code' => 1, + 'msg' => '操作成功', + 'data' => $data + ]; + return $res; + } else { + $res = [ + 'code' => 0, + 'msg' => '暂无数据', + 'data' => [] + ]; + return $res; + } + } +} diff --git a/niucloud/app/service/api/apiService/TestService.php b/niucloud/app/service/api/apiService/TestService.php new file mode 100644 index 00000000..81629665 --- /dev/null +++ b/niucloud/app/service/api/apiService/TestService.php @@ -0,0 +1,95 @@ +getPageParam();//获取请求参数中的页码+分页数 + $page = $page_params['page']; + $limit = $page_params['limit']; + + $model = new ChatFriends(); + //判断用没有员工id + if (!empty($where['personnel_id'])) { + $model = $model->where('personnel_id', $where['personnel_id']); + } + + if (!empty($where['customer_resources_id'])) { + $model = $model->where('customer_resources_id', $where['customer_resources_id']); + } + + $data = $model + ->with([ + 'personnel', + 'customer', + ]) + ->paginate([ + 'list_rows' => $limit, + 'page' => $page, + ])->toArray(); + + return $data; + } + + //查询详情 + public function getTestInfo(array $where) + { + $model = new ChatFriends(); + //判断用没有员工id + if (!empty($where['personnel_id'])) { + $model = $model->where('personnel_id', $where['personnel_id']); + } + if (!empty($where['customer_resources_id'])) { + $model = $model->where('customer_resources_id', $where['customer_resources_id']); + } + $data = $model->find(); + + + if ($data) { + $data = $data->toArray(); + $res = [ + 'code' => 1, + 'msg' => '操作成功', + 'data' => $data + ]; + return $res; + } else { + $res = [ + 'code' => 0, + 'msg' => '暂无数据', + 'data' => [] + ]; + return $res; + } + } +} diff --git a/niucloud/app/service/api/apiService/jlClassService.php b/niucloud/app/service/api/apiService/jlClassService.php new file mode 100644 index 00000000..115420f4 --- /dev/null +++ b/niucloud/app/service/api/apiService/jlClassService.php @@ -0,0 +1,156 @@ +model = (new ClassGrade()); + } + + //列表 + public function list($id,$data) + { + $order = 'id desc'; + $where = []; + if ($data['name'] !== '') { + $where[] = ['name','like','%'.$data['name'].'%']; + } + $search_model = $this->model->where('head_coach', $id)->where($where)->order($order) + ->with(['classPersonnelRel' => function($query) { + $query->with(['student' => function($query) { + $query->with(['customerResources' => function($query) { + $query->with(['member' => function($query) { + $query->select(); + }]); + }]); + },'studentCourses']); + + },'personnelAll']); + $list = $this->pageQuery($search_model); + foreach ($list['data'] as &$v){ + if (count($v['classPersonnelRel']) > 0) { + $now = time(); + $count = 0; + foreach ($v['classPersonnelRel'] as $item) { + if (isset($item['end_date'])) { + $endTime = strtotime($item['end_date']); + if ($endTime > $now && $endTime <= $now + 7 * 86400) { + $count++; + } + } + } + $v['end_count'] = $count; + } else { + $v['end_count'] = 0; + } + } + return $list; + } + + + public function info($data) + { + $search_model = $this->model->where('id', $data) + ->with(['classPersonnelRel' => function($query) { + $query->with(['student' => function($query) { + $query->with(['customerResources' => function($query) { + $query->with(['member' => function($query) { + $query->select(); + }]); + }]); + },'studentCourses','studentCoursesInfo']); + },'personnelAll', 'personnelName']); + $list = $search_model->find(); + if (count($list['classPersonnelRel']) > 0) { + $now = time(); + $count = 0; + foreach ($list['classPersonnelRel'] as $item) { + if (isset($item['end_date'])) { + $endTime = strtotime($item['end_date']); + if ($endTime > $now && $endTime <= $now + 7 * 86400) { + $count++; + } + } + } + $v['end_count'] = $count; + } else { + $v['end_count'] = 0; + } + return $list; + } + + public function jlStudentsInfo($data) + { + $Student = new Student(); + $res = $Student->where('id',$data)->with(['customerResources' => function($query) { + $query->with(['member' => function($query) { + $query->select(); + }]); + }]); + $res = $res->find(); + return $res; + } + + public function PhysicalTestList($data) + { + $resource_id = $data; + $where = [ + 'resource_id' => $resource_id, + ]; + $physical_test = (new PhysicalTestService())->getList($where); + $res['physical_test'] = $physical_test; + return $res; + } + + public function GetClassesList() + { + $res = $this->model->where('status',1)->select()->toArray(); + return $res; + } + + public function GetCoursesList() + { + $Course = new Course(); + $res = $Course->select()->toArray(); + return $res; + } + + public function GetStudentList() + { + $Student = new Student(); + $res = $Student->where('status', 1)->select()->toArray(); + return $res; + } + + public function addPublishJob($data) + { + $Assignment = new Assignment(); + $res = $Assignment->create($data); + return $res; + } + + +} diff --git a/niucloud/app/service/school_approval/SchoolApprovalProcessService.php b/niucloud/app/service/school_approval/SchoolApprovalProcessService.php index f79a28d2..68f0e735 100644 --- a/niucloud/app/service/school_approval/SchoolApprovalProcessService.php +++ b/niucloud/app/service/school_approval/SchoolApprovalProcessService.php @@ -3,6 +3,7 @@ declare(strict_types=1); namespace app\service\school_approval; +use app\model\personnel\Personnel; use app\model\school_approval\SchoolApprovalConfig; use app\model\school_approval\SchoolApprovalConfigNode; use app\model\school_approval\SchoolApprovalParticipants; @@ -26,25 +27,28 @@ class SchoolApprovalProcessService */ public function getList(array $where = [], int $page = 1, int $limit = 10): array { - $field = 'id, process_name, applicant_id, application_time, current_approver_id, approval_status, approval_time, remarks, created_at, updated_at'; - $order = 'id desc'; - + $field = 'a.*,b.name as applicant_name,c.name as current_approver_name'; + $order = 'a.id desc'; + $list = (new SchoolApprovalProcess()) + ->alias("a") + ->join(['school_personnel' => 'b'],'a.applicant_id = b.id','left') + ->join(['school_personnel' => 'c'],'a.current_approver_id = c.id','left') ->where($where) ->field($field) ->order($order) ->page($page, $limit) ->select() ->toArray(); - + $count = (new SchoolApprovalProcess())->where($where)->count(); - + return [ 'list' => $list, 'count' => $count ]; } - + /** * 获取审批流程详情 * @param int $id @@ -52,14 +56,26 @@ class SchoolApprovalProcessService */ public function getInfo(int $id): array { - $info = (new SchoolApprovalProcess())->with(['participants'])->where(['id' => $id])->find(); + $info = (new SchoolApprovalProcess()) + ->alias("a") + ->join(['school_personnel' => 'b'],'a.applicant_id = b.id','left') + ->join(['school_personnel' => 'c'],'a.current_approver_id = c.id','left') + ->with(['participants']) + ->where(['a.id' => $id]) + ->field('a.*,b.name as applicant_name,c.name as current_approver_name') + ->find(); if (empty($info)) { return []; } - - return $info->toArray(); + $info = $info->toArray(); + $Personnel = new Personnel(); + foreach ($info['participants'] as $key => $value) { + $info['participants'][$key]['name'] = $Personnel->where(['id' => $value['participant_id']])->value('name'); + } + + return $info; } - + /** * 创建审批流程 * @param array $data @@ -76,7 +92,7 @@ class SchoolApprovalProcessService if (empty($config_info)) { throw new Exception('审批配置不存在'); } - + // 创建审批流程 $process = [ 'process_name' => $data['process_name'], @@ -86,9 +102,9 @@ class SchoolApprovalProcessService 'approval_status' => SchoolApprovalProcess::STATUS_PENDING, 'remarks' => $data['remarks'] ?? '' ]; - + $process_id = (new SchoolApprovalProcess())->insertGetId($process); - + // 创建审批参与人 $participants = []; foreach ($config_info['nodes'] as $sequence => $node) { @@ -103,22 +119,22 @@ class SchoolApprovalProcessService ]; } } - + if (!empty($participants)) { (new SchoolApprovalParticipants())->insertAll($participants); - + // 更新当前审批人为第一个审批人 $first_participant = (new SchoolApprovalParticipants()) ->where(['process_id' => $process_id]) ->order('sequence', 'asc') ->find(); - + if (!empty($first_participant)) { (new SchoolApprovalProcess())->where(['id' => $process_id]) ->update(['current_approver_id' => $first_participant['participant_id']]); } } - + Db::commit(); return $process_id; } catch (\Exception $e) { @@ -126,7 +142,7 @@ class SchoolApprovalProcessService throw new Exception($e->getMessage()); } } - + /** * 审批 * @param int $process_id 流程ID @@ -145,17 +161,17 @@ class SchoolApprovalProcessService if (empty($process_info)) { throw new Exception('审批流程不存在'); } - + // 检查是否当前审批人 if ($process_info['current_approver_id'] != $approver_id) { throw new Exception('您不是当前审批人'); } - + // 检查流程状态 if ($process_info['approval_status'] != SchoolApprovalProcess::STATUS_PENDING) { throw new Exception('该审批流程已完成'); } - + // 获取当前审批节点 $current_participant = (new SchoolApprovalParticipants()) ->where([ @@ -164,18 +180,18 @@ class SchoolApprovalProcessService 'status' => SchoolApprovalParticipants::STATUS_PENDING ]) ->find(); - + if (empty($current_participant)) { throw new Exception('审批节点信息错误'); } - + // 更新当前审批人状态 (new SchoolApprovalParticipants())->where(['id' => $current_participant['id']]) ->update([ 'status' => $status, 'remarks' => $remarks ]); - + // 如果拒绝,直接更新整个流程状态为拒绝 if ($status == SchoolApprovalParticipants::STATUS_REJECTED) { (new SchoolApprovalProcess())->where(['id' => $process_id]) @@ -184,11 +200,11 @@ class SchoolApprovalProcessService 'approval_time' => time(), 'remarks' => $remarks ]); - + Db::commit(); return true; } - + // 检查当前节点是否需要会签 $same_sequence_participants = (new SchoolApprovalParticipants()) ->where([ @@ -197,14 +213,14 @@ class SchoolApprovalProcessService 'status' => SchoolApprovalParticipants::STATUS_PENDING ]) ->select(); - + // 如果是会签且还有其他人未审批,则等待 if ($current_participant['sign_type'] == SchoolApprovalParticipants::SIGN_TYPE_AND && !$same_sequence_participants->isEmpty()) { // 不做任何处理,等待其他人审批 Db::commit(); return true; } - + // 获取下一个审批节点 $next_participant = (new SchoolApprovalParticipants()) ->where([ @@ -213,7 +229,7 @@ class SchoolApprovalProcessService ]) ->order('sequence', 'asc') ->find(); - + if (empty($next_participant)) { // 没有下一个审批人,流程结束,标记为已通过 (new SchoolApprovalProcess())->where(['id' => $process_id]) @@ -226,7 +242,7 @@ class SchoolApprovalProcessService (new SchoolApprovalProcess())->where(['id' => $process_id]) ->update(['current_approver_id' => $next_participant['participant_id']]); } - + Db::commit(); return true; } catch (\Exception $e) { @@ -234,7 +250,7 @@ class SchoolApprovalProcessService throw new Exception($e->getMessage()); } } - + /** * 撤销审批流程 * @param int $process_id 流程ID @@ -251,17 +267,17 @@ class SchoolApprovalProcessService if (empty($process_info)) { throw new Exception('审批流程不存在'); } - + // 检查是否申请人 if ($process_info['applicant_id'] != $applicant_id) { throw new Exception('您不是该流程的申请人'); } - + // 检查流程状态 if ($process_info['approval_status'] != SchoolApprovalProcess::STATUS_PENDING) { throw new Exception('该审批流程已完成,无法撤销'); } - + // 更新流程状态为已拒绝(撤销) (new SchoolApprovalProcess())->where(['id' => $process_id]) ->update([ @@ -269,7 +285,7 @@ class SchoolApprovalProcessService 'approval_time' => time(), 'remarks' => '申请人撤销' ]); - + // 更新所有待审批节点为已拒绝 (new SchoolApprovalParticipants())->where([ 'process_id' => $process_id, @@ -278,7 +294,7 @@ class SchoolApprovalProcessService 'status' => SchoolApprovalParticipants::STATUS_REJECTED, 'remarks' => '申请人撤销' ]); - + Db::commit(); return true; } catch (\Exception $e) { @@ -286,4 +302,4 @@ class SchoolApprovalProcessService throw new Exception($e->getMessage()); } } -} \ No newline at end of file +}