<?php /** * 用户绑定信息 * @author solu */ class UserBindInfo extends Model { protected $tableName = 'user_bind_info'; protected $dbKey = 'dw_chat'; /** * 通过第三方账号获取用户id * @param string $account * @param string $type * * @return int */ public function getUserIdBy($account, $type = 'eos') { $userId = $this->objTable->getOne(compact('account', 'type'), ['_field' => 'user_id']); return $userId; } /** * 通过用户id获取第三方账号 * @param int $user_id * @param string $type * * @return string */ public function getAccountByUserId($user_id, $type = 'eos') { $account = $this->objTable->getOne(compact('user_id', 'type'), ['_field' => 'account']); return $account; } public function getUserIdByTgId($TgId) { $userId = $this->objTable->getOne(['account' => $TgId, 'type' => Account::TYPE_TG], ['_field' => 'user_id']); return intval($userId); } }