['device_status'], ]; } /** * @notes 获取列表 * @return array */ public function lists(): array { $this->searchWhere[] = ['user_id', '=', $this->userId]; return AiWechatDevice::field('id,device_code,device_status,device_model,sdk_version,create_time') ->where($this->searchWhere) ->order('id', 'desc') ->limit($this->limitOffset, $this->limitLength) ->select() ->each(function ($item) { $item['wechat_id'] = AiWechat::where('device_code', $item['device_code'])->value('wechat_id') ?? ''; $item['device_status'] = 0; // 请求在线状态 $result = MessageLogic::getOnlineStatus($item['wechat_id'], $item['device_code'], 1); if ($result) { $item['device_status'] = MessageLogic::getReturnData(); $item->device_status = $item['device_status']; $item->save(); } }) ->toArray(); } /** * @notes 获取数量 * @return int */ public function count(): int { $this->searchWhere[] = ['user_id', '=', $this->userId]; return AiWechatDevice::where($this->searchWhere)->count(); } }