['phone', 'body'], '=' => ['status', 'type'], ]; } public function lists(): array { $lists = SmsLog::field('id,phone,body,sms_time,type,status,device_id,batch_id,create_time') ->where($this->searchWhere) ->limit($this->limitOffset, $this->limitLength) ->order('id', 'desc') ->select() ->toArray(); foreach ($lists as &$item) { $item['record_type_desc'] = $this->getRecordTypeDesc((int)$item['type']); $item['type_desc'] = $this->getActionTypeDesc((int)$item['type']); $item['status_desc'] = $this->getStatusDesc((int)$item['status']); } return $lists; } public function count(): int { return SmsLog::where($this->searchWhere)->count(); } private function getRecordTypeDesc(int $type): string { return $type >= 10 ? '来电' : '短信'; } private function getActionTypeDesc(int $type): string { return match ($type) { 1 => '接收', 2 => '发送', 11 => '来电已接', 13 => '来电未接', 15 => '来电拒接', default => '未知', }; } private function getStatusDesc(int $status): string { return match ($status) { 0 => '待验证', 1 => '已使用', 2 => '不适用', default => '未知', }; } }