where([ ['id', 'in', $online], ['id', '<>', $kefu_id], ]) ->select() ->toArray(); return $lists; } /** * @notes 获取用户信息 * @param int $user_id * @return array|false * @author 段誉 * @date 2022/3/14 12:15 */ public static function getUserInfo(int $user_id) { try { $user = User::where(['id' => $user_id]) ->field([ 'id', 'sn', 'nickname', 'avatar', 'level', 'mobile', 'total_order_amount', 'birthday', 'register_source', 'create_time' ]) ->findOrEmpty() ->toArray(); if (empty($user)) { throw new \Exception('用户不存在'); } $user['level_name'] = UserLevel::where('id', $user['level'])->value('name', ''); $user['birthday'] = empty($user['birthday']) ? '-' : $user['birthday']; $user['mobile'] = empty($user['mobile']) ? '-' : substr_replace($user['mobile'], '****', 3, 4); $user['register_source'] = UserTerminalEnum::getTermInalDesc($user['register_source']); return $user; } catch (\Exception $e) { self::$error = $e->getMessage(); return false; } } /** * @notes 获取客服信息 * @param $id * @return array * @author 段誉 * @date 2022/3/14 12:15 */ public static function getKefuInfo(int $id): array { $result = Kefu::where(['id' => $id]) ->field(['id', 'nickname', 'avatar']) ->findOrEmpty() ->toArray(); $online = CommonChatLogic::getOnlineKefu(); $result['online'] = 0; if (in_array($result['id'], $online)) { $result['online'] = 1; } return $result; } /** * @notes 上传文件域名 * @return array * @author 段誉 * @date 2022/3/14 12:13 */ public static function getConfig(): array { return [ 'copyright' => ConfigService::get('shop', 'copyright', ''), 'favicon' => FileService::getFileUrl(ConfigService::get('shop', 'favicon')), 'base_domain' => FileService::getFileUrl(), 'ws_domain' => env('project.ws_domain', 'ws:127.0.0.1') ]; } }