['order_type', 'status'], 'like' => ['order_no'], ]; } /** * @notes 获取列表 * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public function lists(): array { $where = $this->searchWhere; // 处理患者关键词搜索 if (!empty($this->params['patient_keyword'])) { $where[] = ['patient_id', 'in', function ($query) { $query->table('user') ->where('nickname|mobile', 'like', '%' . $this->params['patient_keyword'] . '%') ->field('id'); }]; } // 处理创建时间范围 if (!empty($this->params['create_time_start'])) { $where[] = ['create_time', '>=', $this->params['create_time_start'] . ' 00:00:00']; } if (!empty($this->params['create_time_end'])) { $where[] = ['create_time', '<=', $this->params['create_time_end'] . ' 23:59:59']; } return Order::where($where) ->with(['patient', 'creator', 'details']) ->order(['create_time' => 'desc']) ->limit($this->limitOffset, $this->pageSize) ->select() ->toArray(); } /** * @notes 获取数量 * @return int */ public function count(): int { $where = $this->searchWhere; // 处理患者关键词搜索 if (!empty($this->params['patient_keyword'])) { $where[] = ['patient_id', 'in', function ($query) { $query->table('user') ->where('nickname|mobile', 'like', '%' . $this->params['patient_keyword'] . '%') ->field('id'); }]; } // 处理创建时间范围 if (!empty($this->params['create_time_start'])) { $where[] = ['create_time', '>=', $this->params['create_time_start'] . ' 00:00:00']; } if (!empty($this->params['create_time_end'])) { $where[] = ['create_time', '<=', $this->params['create_time_end'] . ' 23:59:59']; } return Order::where($where)->count(); } }