UserBindInfo.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. /**
  3. * 用户绑定信息
  4. * @author solu
  5. */
  6. class UserBindInfo extends Model {
  7. protected $tableName = 'user_bind_info';
  8. protected $dbKey = 'dw_chat';
  9. /**
  10. * 通过第三方账号获取用户id
  11. * @param string $account
  12. * @param string $type
  13. *
  14. * @return int
  15. */
  16. public function getUserIdBy($account, $type = 'eos') {
  17. $userId = $this->objTable->getOne(compact('account', 'type'), ['_field' => 'user_id']);
  18. return $userId;
  19. }
  20. /**
  21. * 通过用户id获取第三方账号
  22. * @param int $user_id
  23. * @param string $type
  24. *
  25. * @return string
  26. */
  27. public function getAccountByUserId($user_id, $type = 'eos') {
  28. $account = $this->objTable->getOne(compact('user_id', 'type'), ['_field' => 'account']);
  29. return $account;
  30. }
  31. public function getUserIdByTgId($TgId) {
  32. $userId = $this->objTable->getOne(['account' => $TgId, 'type' => Account::TYPE_TG], ['_field' => 'user_id']);
  33. return intval($userId);
  34. }
  35. }