connectChannelOpenid != $channel_openid) { $database = get_db_connect($this->table, hash_code($channel_openid)); $this->setTable($database['table']); $this->connect($database); $this->connectChannelOpenid = $channel_openid; } return $this; } /** * 根据渠道商ID,用户openid获取用户user_id * * @param $channel_id * @param $openid * @return bool|int */ public function getUserId($channel_id, $openid) { if (ApiService::instance()->checkApiOn()) { return UserService::instance()->getUserInfoByChannelOpenid($channel_id, $openid)->id; } $channel_openid = $channel_id . '_' . $openid; $res = $this->setConnect($channel_id, $openid)->where(['channel_openid' => $channel_openid])->find(); if ($res && isset($res['user_id'])) { return $res['user_id']; } return false; } }