'>70%', '60_70' => '60%~70%', '50_60' => '50%~60%', ]; /** * @notes 设置搜索条件 */ public function setSearch(): array { return [ '=' => ['run_date', 'action', 'assistant_id', 'batch_no', 'stat_month'], ]; } /** * @notes 获取列表 */ public function lists(): array { $rows = $this->buildQuery() ->order(['id' => 'desc']) ->limit($this->limitOffset, $this->limitLength) ->select() ->toArray(); foreach ($rows as &$row) { $ct = (int) ($row['create_time'] ?? 0); $row['create_time_text'] = $ct > 0 ? date('Y-m-d H:i:s', $ct) : ''; $row['action_text'] = (int) ($row['action'] ?? 0) === 1 ? '已分配' : '未分配'; $row['tier_text'] = self::TIER_LABELS[(string) ($row['tier'] ?? '')] ?? ''; $row['visit2_rate'] = $row['visit2_rate'] !== null ? (float) $row['visit2_rate'] : null; } unset($row); return $rows; } /** * @notes 获取数量 */ public function count(): int { return $this->buildQuery()->count(); } /** * @return \think\db\Query */ private function buildQuery() { $query = Db::name('tcm_diagnosis_auto_assign_log')->where($this->searchWhere); $keyword = trim((string) ($this->params['keyword'] ?? '')); if ($keyword !== '') { $query->where(function ($q) use ($keyword) { $q->whereLike('patient_name', '%' . $keyword . '%') ->whereOr('patient_phone', 'like', '%' . $keyword . '%') ->whereOr('assistant_name', 'like', '%' . $keyword . '%'); if (preg_match('/^\d+$/', $keyword) === 1 && (int) $keyword > 0) { $q->whereOr('diagnosis_id', '=', (int) $keyword); } }); } $startDate = trim((string) ($this->params['start_date'] ?? '')); if (preg_match('/^\d{4}-\d{2}-\d{2}$/', $startDate) === 1) { $query->where('run_date', '>=', $startDate); } $endDate = trim((string) ($this->params['end_date'] ?? '')); if (preg_match('/^\d{4}-\d{2}-\d{2}$/', $endDate) === 1) { $query->where('run_date', '<=', $endDate); } return $query; } }