display(); } /** * 获取认证申请列表 */ public function getAuthList() { try { $page = I('get.page', 1, 'intval'); $pageSize = I('get.pageSize', 20, 'intval'); $keyword = I('get.keyword', '', 'trim'); $authStatus = I('get.auth_status', '', 'trim'); $healthStatus = I('get.health_status', '', 'trim'); $startTime = I('get.start_time', '', 'trim'); $endTime = I('get.end_time', '', 'trim'); $where = array(); // 关键词搜索(骑手姓名、手机号、身份证号) if (!empty($keyword)) { $where['_string'] = "(rider_name LIKE '%{$keyword}%' OR rider_phone LIKE '%{$keyword}%' OR id_card LIKE '%{$keyword}%')"; } // 实名认证状态筛选 if (!empty($authStatus)) { $where['auth_status'] = $authStatus; } // 健康证状态筛选 if (!empty($healthStatus)) { $where['health_status'] = $healthStatus; } // 时间筛选 if (!empty($startTime)) { $where['add_time'][] = array('egt', $startTime); } if (!empty($endTime)) { $where['add_time'][] = array('elt', $endTime . ' 23:59:59'); } $where['status'] = 1; $Rider = M('RiderInfo'); // 获取总数 $total = $Rider->where($where)->count(); // 获取列表数据 $list = $Rider->field('id, rider_name, rider_phone, id_card, id_card_front, id_card_back, auth_status, auth_remark, auth_time, health_cert, health_status, health_remark, health_time, add_time, rider_avatar') ->where($where) ->order('add_time DESC') ->page($page, $pageSize) ->select(); // 格式化数据 foreach ($list as &$item) { $item['create_time_format'] = $item['add_time']; $item['auth_time_format'] = $item['auth_time'] ? date('Y-m-d H:i:s', $item['auth_time']) : ''; $item['health_time_format'] = $item['health_time'] ? date('Y-m-d H:i:s', $item['health_time']) : ''; $item['auth_status_text'] = $this->getAuthStatusText($item['auth_status']); $item['health_status_text'] = $this->getHealthStatusText($item['health_status']); // 隐藏身份证号中间部分 if ($item['id_card']) { $item['id_card_masked'] = substr($item['id_card'], 0, 6) . '********' . substr($item['id_card'], -4); } } $result = array( 'code' => 0, 'msg' => 'success', 'data' => array( 'list' => $list, 'total' => $total, 'page' => $page, 'pageSize' => $pageSize ) ); $this->ajaxReturn($result); } catch (\Exception $e) { $this->ajaxReturn(array('code' => 1, 'msg' => $e->getMessage())); } } /** * 获取认证详情 */ public function getAuthDetail() { $id = I('get.id', 0, 'intval'); if (empty($id)) { $this->ajaxReturn(array('code' => 1, 'msg' => '参数错误')); } $detail = M('RiderInfo')->where(array('id' => $id, 'status' => 1))->find(); if (!$detail) { $this->ajaxReturn(array('code' => 1, 'msg' => '骑手不存在')); } // 格式化数据 $detail['create_time_format'] = $detail['add_time']; $detail['auth_time_format'] = $detail['auth_time'] ? date('Y-m-d H:i:s', $detail['auth_time']) : ''; $detail['health_time_format'] = $detail['health_time'] ? date('Y-m-d H:i:s', $detail['health_time']) : ''; $detail['auth_status_text'] = $this->getAuthStatusText($detail['auth_status']); $detail['health_status_text'] = $this->getHealthStatusText($detail['health_status']); // 获取审核管理员信息 if ($detail['auth_admin_id']) { $admin = M('Admin')->where(array('id' => $detail['auth_admin_id']))->find(); $detail['auth_admin_name'] = $admin ? $admin['username'] : ''; } if ($detail['health_admin_id']) { $admin = M('Admin')->where(array('id' => $detail['health_admin_id']))->find(); $detail['health_admin_name'] = $admin ? $admin['username'] : ''; } $this->ajaxReturn(array('code' => 0, 'msg' => 'success', 'data' => $detail)); } /** * 审核实名认证 */ public function auditAuth() { $id = I('post.id', 0, 'intval'); $status = I('post.status', 0, 'intval'); // 1=通过, 2=拒绝 $remark = I('post.remark', '', 'trim'); if (empty($id)) { $this->ajaxReturn(array('code' => 1, 'msg' => '参数错误')); } if (!in_array($status, [1, 2])) { $this->ajaxReturn(array('code' => 1, 'msg' => '审核状态错误')); } $Rider = M('RiderInfo'); $rider = $Rider->where(array('id' => $id, 'status' => 1))->find(); if (!$rider) { $this->ajaxReturn(array('code' => 1, 'msg' => '骑手不存在')); } if ($rider['auth_status'] != 0) { $this->ajaxReturn(array('code' => 1, 'msg' => '该申请已处理')); } // 更新认证状态 $updateData = array( 'auth_status' => $status, 'auth_remark' => $remark, 'auth_time' => time(), 'auth_admin_id' => session('admin_id') ); $result = $Rider->where(array('id' => $id))->save($updateData); if ($result) { // 记录审核日志 $logData = array( 'rider_id' => $id, 'type' => 'auth_audit', 'status' => $status, 'remark' => $remark, 'admin_id' => session('admin_id'), 'create_time' => time() ); M('RiderAuditLog')->add($logData); $this->ajaxReturn(array('code' => 0, 'msg' => '操作成功')); } else { $this->ajaxReturn(array('code' => 1, 'msg' => '操作失败')); } } /** * 审核健康证 */ public function auditHealth() { $id = I('post.id', 0, 'intval'); $status = I('post.status', 0, 'intval'); // 1=通过, 2=拒绝 $remark = I('post.remark', '', 'trim'); if (empty($id)) { $this->ajaxReturn(array('code' => 1, 'msg' => '参数错误')); } if (!in_array($status, [1, 2])) { $this->ajaxReturn(array('code' => 1, 'msg' => '审核状态错误')); } $Rider = M('RiderInfo'); $rider = $Rider->where(array('id' => $id, 'status' => 1))->find(); if (!$rider) { $this->ajaxReturn(array('code' => 1, 'msg' => '骑手不存在')); } if ($rider['health_status'] != 0) { $this->ajaxReturn(array('code' => 1, 'msg' => '该申请已处理')); } // 更新健康证状态 $updateData = array( 'health_status' => $status, 'health_remark' => $remark, 'health_time' => time(), 'health_admin_id' => session('admin_id') ); $result = $Rider->where(array('id' => $id))->save($updateData); if ($result) { // 记录审核日志 $logData = array( 'rider_id' => $id, 'type' => 'health_audit', 'status' => $status, 'remark' => $remark, 'admin_id' => session('admin_id'), 'create_time' => time() ); M('RiderAuditLog')->add($logData); $this->ajaxReturn(array('code' => 0, 'msg' => '操作成功')); } else { $this->ajaxReturn(array('code' => 1, 'msg' => '操作失败')); } } /** * 批量审核 */ public function batchAudit() { $ids = I('post.ids', '', 'trim'); $type = I('post.type', '', 'trim'); // auth=实名认证, health=健康证 $status = I('post.status', 0, 'intval'); // 1=通过, 2=拒绝 $remark = I('post.remark', '', 'trim'); if (empty($ids) || empty($type)) { $this->ajaxReturn(array('code' => 1, 'msg' => '参数错误')); } if (!in_array($status, [1, 2])) { $this->ajaxReturn(array('code' => 1, 'msg' => '审核状态错误')); } if (!in_array($type, ['auth', 'health'])) { $this->ajaxReturn(array('code' => 1, 'msg' => '审核类型错误')); } $idArray = explode(',', $ids); $idArray = array_filter(array_map('intval', $idArray)); if (empty($idArray)) { $this->ajaxReturn(array('code' => 1, 'msg' => '无效的ID列表')); } $Rider = M('RiderInfo'); $successCount = 0; foreach ($idArray as $id) { $rider = $Rider->where(array('id' => $id, 'status' => 1))->find(); if (!$rider) { continue; } // 检查是否已处理 if ($type == 'auth' && $rider['auth_status'] != 0) { continue; } if ($type == 'health' && $rider['health_status'] != 0) { continue; } // 更新状态 if ($type == 'auth') { $updateData = array( 'auth_status' => $status, 'auth_remark' => $remark, 'auth_time' => time(), 'auth_admin_id' => session('admin_id') ); } else { $updateData = array( 'health_status' => $status, 'health_remark' => $remark, 'health_time' => time(), 'health_admin_id' => session('admin_id') ); } $result = $Rider->where(array('id' => $id))->save($updateData); if ($result) { $successCount++; // 记录审核日志 $logData = array( 'rider_id' => $id, 'type' => $type . '_audit', 'status' => $status, 'remark' => $remark, 'admin_id' => session('admin_id'), 'create_time' => time() ); M('RiderAuditLog')->add($logData); } } $this->ajaxReturn(array('code' => 0, 'msg' => "成功处理{$successCount}条记录")); } /** * 导出认证数据 */ public function exportAuth() { $keyword = I('get.keyword', '', 'trim'); $authStatus = I('get.auth_status', '', 'trim'); $healthStatus = I('get.health_status', '', 'trim'); $startTime = I('get.start_time', '', 'trim'); $endTime = I('get.end_time', '', 'trim'); $where = array(); // 构建查询条件(与列表查询相同) if (!empty($keyword)) { $where['_string'] = "(rider_name LIKE '%{$keyword}%' OR rider_phone LIKE '%{$keyword}%' OR id_card LIKE '%{$keyword}%')"; } if (!empty($authStatus)) { $where['auth_status'] = $authStatus; } if (!empty($healthStatus)) { $where['health_status'] = $healthStatus; } if (!empty($startTime)) { $where['add_time'][] = array('egt', $startTime); } if (!empty($endTime)) { $where['add_time'][] = array('elt', $endTime . ' 23:59:59'); } $where['status'] = 1; // 获取数据 $list = M('RiderInfo')->field('id, rider_name, rider_phone, id_card, auth_status, auth_remark, auth_time, health_status, health_remark, health_time, add_time') ->where($where) ->order('add_time DESC') ->select(); // 设置Excel头部 header('Content-Type: application/vnd.ms-excel'); header('Content-Disposition: attachment;filename="rider_auth_' . date('YmdHis') . '.xls"'); header('Cache-Control: max-age=0'); // 输出Excel内容 echo '
| 骑手ID | '; echo '昵称 | '; echo '手机号 | '; echo '真实姓名 | '; echo '身份证号 | '; echo '实名认证状态 | '; echo '实名认证备注 | '; echo '实名认证时间 | '; echo '健康证状态 | '; echo '健康证备注 | '; echo '健康证审核时间 | '; echo '注册时间 | '; echo '
|---|---|---|---|---|---|---|---|---|---|---|---|
| ' . $item['id'] . ' | '; echo '' . $item['name'] . ' | '; echo '' . $item['phone'] . ' | '; echo '' . $item['real_name'] . ' | '; echo '' . ($item['id_card'] ? substr($item['id_card'], 0, 6) . '********' . substr($item['id_card'], -4) : '') . ' | '; echo '' . $this->getAuthStatusText($item['auth_status']) . ' | '; echo '' . $item['auth_remark'] . ' | '; echo '' . ($item['auth_time'] ? date('Y-m-d H:i:s', $item['auth_time']) : '') . ' | '; echo '' . $this->getHealthStatusText($item['health_status']) . ' | '; echo '' . $item['health_remark'] . ' | '; echo '' . ($item['health_time'] ? date('Y-m-d H:i:s', $item['health_time']) : '') . ' | '; echo '' . date('Y-m-d H:i:s', $item['create_time']) . ' | '; echo '