model = new EnrollStudentsModel; } /** * @title:创建统一查询条件 * @desc: 描述 * @param {date} {birthday} {} {出生日期} * @param {string} {keyword} {} {搜索关键词,可搜索学生姓名|前学校|家庭住址|籍贯} * @return {*} * @author: 系统开发 * @method: POST * @Date: 2024-12-10 17:45:55 */ private function createWhere() { $data = $this->request->param(); $where = []; $whereOr = []; if (!empty($data['org_ids'])) { $where[] = ['a.org_id', 'IN', $data['org_ids']]; } else { if ($this->userinfo && !$this->userinfo['is_developer']) { $org_ids = $this->userinfo['org_id']; //转为字符串 if ($org_ids !== 1) { if (is_array($org_ids)) { $org_ids = implode(',', $org_ids); } $data['org_ids'] = $org_ids; $where[] = ['a.org_id', 'IN', $data['org_ids']]; } } } if (!empty($data['keyword'])) { $keyword = $data['keyword']; $where[] = ['b.name|b.idcard', 'LIKE', "%$keyword%"]; } return ['where' => $where, 'whereOr' => $whereOr]; } /** * @title:查询数据列表 * @desc: 描述 * @param {date} {birthday} {} {出生日期} * @param {string} {keyword} {} {搜索关键词,可搜索学生姓名|前学校|家庭住址|籍贯} * @param {int} {pageNo} {0} {页码} * @param {int} {pageSize} {10} {每页数量} * @return {*} * @author: 系统开发 * @method: POST * @Date: 2024-12-10 17:45:55 */ public function getList(int $pageNo = 0, int $pageSize = 10) { $whereAry = $this->createWhere(); $fields = "a.*,b.grade_name,b.grade_code,b.former_city,b.former_school,b.guardian_ids,b.is_adjust,b.apply_uid,b.source ,b.name as student_name,b.sex,b.birthday,b.nation,b.prove_type,b.idcard,b.native_place,b.address,b.student_id,b.is_transfer,b.semester_date"; // ,c.name as student_name,c.sex,c.birthday,c.nation,c.prove_type,c.idcard,c.join_guardian,c.native_place,c.address if (!empty($pageNo)) { $res = JdfEnrollVolunteer::alias('a') ->join("jdf_enroll_students b", "a.enroll_id = b.enroll_id") ->field($fields) ->where($whereAry['where']) ->order('a.create_at asc') ->paginate(['page' => $pageNo, 'list_rows' => $pageSize]); return pageRes(1, '获取成功', $res->total(), $res->items()); } else { $list = JdfEnrollVolunteer::alias('a') ->join("jdf_enroll_students b", "a.enroll_id = b.enroll_id") ->field($fields) ->where($whereAry['where'])->select(); return res(1, '获取成功', $list); } } /** * @title:选择器数据 * @desc: 描述 * @return {*} * @author: 系统开发 * @method: POST * @Date: 2024-12-10 17:45:55 */ public function getTree($labelField = 'name') { $fields = ['id', $labelField]; $where = []; $list = $this->model->where($where)->field($fields)->select(); return res(1, "获取成功", $list); } /** * @title:查询信息 * @desc: 描述 * @param {int} {id} {} {信息ID} * @return {*} * @author: 系统开发 * @method: POST * @Date: 2024-12-10 17:45:55 */ public function getInfo(int $id = 0) { $info = $this->model->with([])->find($id); return res(1, '获取成功', $info); } /** * @title:新增/编辑信息 * @desc: 描述 * @param {int} {id} {} {主键ID,不传或传0表示新增,大于0表示修改} * @param {varchar} {name} {} {学生姓名} * @param {tinyint} {sex} {0} {学生性别} * @param {tinyint} {status} {0} {预约状态} * @param {int} {org_id} {0} {组织id} * @param {varchar} {former_school} {} {前学校} * @param {varchar} {address} {} {家庭住址} * @param {date} {birthday} {} {出生日期} * @param {int} {idcard} {0} {身份证} * @param {varchar} {native_place} {} {籍贯} * @param {int} {nation_id} {0} {民族} * @param {int} {guardian_id} {0} {监护人id} * @return {*} * @author: 系统开发 * @method: POST * @Date: 2024-12-10 17:45:55 */ public function doEdit() { $data = $this->request->param(); $res = $this->model->replace()->save($data); return res(1, '编辑成功'); } /** * @title:删除信息 * @desc: 描述 * @param {int} id {} {信息ID} * @return {*} * @author: 系统开发 * @method: POST * @Date: 2024-12-10 17:45:55 */ public function doDelete(int $id = 0) { $info = $this->model->find($id); $info->delete(); return res(1, '删除成功'); } /** * @title:获取可选项 * @desc: 描述 * @return {*} * @author: 系统开发 * @method: POST * @Date: 2024-12-10 17:45:55 */ public function getOptions() { $data = $this->request->param(); $res = (new platformAuth())->interfaceRequest('getSchool', $data); if (!$res['code']) return res(2, $res['msg'] ?? '获取失败', $res['data'] ?? ''); return res(1, "获取成功", $res['data']); } private $fieldList = [ 'index' => '序号', 'student_name' => '学生姓名', 'sex' => '学生性别', 'address' => '家庭住址', 'birthday' => '出生日期', 'prove_type' => '证件类型', 'idcard' => '证件号', 'grade_name' => '预读年级', 'num' => '第几志愿', 'name' => '志愿学校', 'former_city' => '现就读学校区域', 'former_school' => '现就读学校', 'semester_date' => '预约时间', 'is_transfer' => '预约类型', 'school_year' => '学年', ]; /** * @title:导出数据 * @desc: 描述 * @param {date} {birthday} {} {出生日期} * @param {string} {keyword} {} {搜索关键词,可搜索学生姓名|前学校|家庭住址|籍贯} * @return {*} * @author: 系统开发 * @method: POST * @Date: 2024-12-10 17:45:55 */ public function doExport() { $whereAry = $this->createWhere(); $fields = "a.*,b.grade_name,b.grade_code,b.former_city,b.former_school,b.guardian_ids,b.is_adjust,b.apply_uid,b.source ,b.name as student_name,b.sex,b.birthday,b.nation,b.prove_type,b.idcard,b.native_place,b.address,b.student_id,b.admit_schools,b.is_transfer,b.semester_date,b.school_year ,GROUP_CONCAT(CONCAT(c.name, ':', c.phone) ORDER BY c.name SEPARATOR ', ') as guardians_info"; $list = JdfEnrollVolunteer::alias('a') ->join("jdf_enroll_students b", "a.enroll_id = b.enroll_id") ->join("jdf_guardian c", "FIND_IN_SET(c.guardian_id, b.guardian_ids)") ->field($fields) ->order('a.create_at asc') ->where($whereAry['where'])->group('a.id')->select()->toArray(); $head = array_values($this->fieldList); // 最多可能的监护人数量,可根据实际情况调整 $maxGuardians = 2; for ($i = 1; $i <= $maxGuardians; $i++) { $head[] = "监护人{$i}"; $head[] = "电话"; } $body = []; foreach ($list as $key => $item) { $index = $key + 1; foreach ($this->fieldList as $k => $v) { if ($k == 'index') { $body[$index][] = $index; } else { $body[$index][] = isset($item[$k . '_txt']) ? (is_array($item[$k . '_txt']) ? implode(',', $item[$k . '_txt']) : $item[$k . '_txt']) : $item[$k]; } } // 处理监护人信息 $guardians = explode(', ', $item['guardians_info']); for ($i = 0; $i < $maxGuardians; $i++) { if (isset($guardians[$i])) { [$name, $phone] = explode(':', $guardians[$i]); $body[$index][] = $name; $body[$index][] = $phone; } else { $body[$index][] = ''; $body[$index][] = ""; } } } //创建文件夹 $basepath = 'uploads' . DS . 'download' . DS . date('Ymd'); $savepath = public_path() . $basepath; if (!is_dir($savepath)) { @mkdir($savepath, 0777, true); } //保存文件 $filename = time() . GetRandStr() . '.xls'; $path = $savepath . DS . $filename; $export_help = new \excel\MultiHeadExcel(); $export_help->export_help($body, $head, $path); //返回路径 $returnpath = WEBURL . DS . $basepath . DS . $filename; slog(1, '导出了enrollStudents'); return res(1, '获取成功', ['url' => $returnpath, 'name' => $filename]); } public function __call($name, $arguments) { return res(2, "方法{$name}不存在"); } /** * Desc :当前订单监护人列表 * User : zwq * Date : 2024-12-18 14:27 */ public function getGuardianList() { $guardian_ids = input('guardian_ids/s', ""); $enroll_id = input('enroll_id/d', 0); $student_id = input('student_id/d', 0); $list = JdfGuardian::where('guardian_id', 'in', $guardian_ids)->select()->each(function ($item) use ($enroll_id, $student_id) { if ($student_id && $student_id >= 0) { $item['relation'] = JdfGuardianRelation::where('student_id', $student_id) ->where('guardian_id', $item['guardian_id']) ->find(); } else { $item['relation'] = JdfGuardianRelation::where('enroll_id', $enroll_id) ->where('guardian_id', $item['guardian_id']) ->find(); } }); return res(1, '获取成功', $list); } /** * Desc :获取学段列表 * User : zwq * Date : 2024-12-12 16:37 */ public function getPeriodList() { $data = $this->request->param(); $res = EnrollHandle::getSchoolCode($data); if (!$res['code']) return res(2, $res['msg'] ?? '获取失败', $res['data'] ?? ''); return res(1, "保存成功", $res['data'] ?? ''); } /** * Desc :获取分类年级 * User : zwq * Date : 2024-12-12 16:37 */ public function getGrade() { $data = $this->request->param(); $res = (new platformAuth())->interfaceRequest('getGrade', $data); if (!$res['code']) return res(2, $res['msg'] ?? '获取失败', $res['data'] ?? ''); return res(1, "保存成功", $res['data'] ?? ''); } /** * Desc :获取学校列表 * User : zwq * Date : 2024-12-12 17:23 */ public function getSchoolList() { $data = $this->request->param(); $pageNo = input('pageNo/d', 1); $pageSize = input('pageSize/d', 10); $kw = input('keyword/s', ''); $where = []; if ($this->userinfo && !$this->userinfo['is_developer']) { $org_ids = $this->userinfo['org_id']; if ($org_ids !== 1) { //转为字符串 if (is_array($org_ids)) { $org_ids = implode(',', $org_ids); } $data['org_ids'] = $org_ids; $where[] = ['org_id', 'in', $org_ids]; } } if (!empty($kw)) { $where[] = ['name', 'like', '%' . $kw . '%']; } $res = (new platformAuth())->interfaceRequest('getSchoolCode', []); if (!$res['code']) return res(2, $res['msg'] ?? '查询失败', $res['data'] ?? ''); $codes = array_column($res['data'], 'code'); $where[] = ['type', 'in', $codes]; $where[] = ['status', '=', 1]; $field = 'org_id,name'; $list = Org::where($where)->field($field)->paginate(['page' => $pageNo, 'list_rows' => $pageSize]);; return pageRes(1, '获取成功', $list->total(), $list->items()); } /** * Desc :获取报名学校 * User : zwq * Date : 2025-01-13 16:59 * @return \think\response\Json */ public function getClassSchool() { $data = $this->request->param(); $res = EnrollHandle::getClassSchool($data); if (!$res['code']) return res(2, $res['msg'] ?? '获取失败', $res['data'] ?? ''); return res(1, "保存成功", $res['data'] ?? ''); } /** * Desc :获取全部省市县区列表 * User : zwq * Date : 2025-01-09 16:18 */ public function getAreaList() { $data = $this->request->param(); $res = (new platformAuth())->interfaceRequest('getArea', $data); if (!$res['code']) return res(2, $res['msg'] ?? '获取失败', $res['data'] ?? ''); return res(1, "保存成功", $res['data'] ?? ''); } /** * Desc :获取以前就读学校 * User : zwq * Date : 2025-01-09 16:18 */ public function getFormerSchool() { $data = $this->request->param(); $res = (new platformAuth())->interfaceRequest('getPreviousSchool', $data); if (!$res['code']) return res(2, $res['msg'] ?? '获取失败', $res['data'] ?? ''); return res(1, "获取成功", $res['data']); } /** * Desc :获取监护人关系列表 * User : zwq * Date : 2025-01-13 09:07 * @return \think\response\Json */ public function getRelationList() { $data = $this->request->param(); $res = (new platformAuth())->interfaceRequest('getDicPage', $data); if (!$res['code']) return res(2, $res['msg'] ?? '获取失败', $res['data'] ?? ''); return res(1, "获取成功", $res['data']); } /** * Desc :创建报名 * User : zwq * Date : 2024-12-17 10:57 */ public function createOrder() { $data = $this->request->param(); $res = EnrollHandle::createEnroll($this->userinfo, $data); if (!$res['code']) return res(2, $res['msg'] ?? '创建失败', $res['data'] ?? ''); return res(1, "保存成功", $res['data'] ?? ''); } /** * Desc :删除报名信息 * User : zwq * Date : 2025-02-07 09:54 */ public function deleteEnroll() { $data = $this->request->param(); $res = EnrollHandle::deleteEnroll($this->userinfo, $data); if (!$res['code']) return res(2, $res['msg'] ?? '创建失败', $res['data'] ?? ''); return res(1, "保存成功", $res['data'] ?? ''); } }