MallUser.php 973 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace addons\OperationCenter\common\models;
  3. use common\models\user\User;
  4. /**
  5. * MallUser class
  6. */
  7. class MallUser extends User
  8. {
  9. /**
  10. * @param string $key_word
  11. * @return array
  12. */
  13. public static function getUserIdByUserKeyWord(int $mall_id, string $key_word)
  14. {
  15. return static::find()
  16. ->select(['id'])
  17. ->andWhere(['mall_id' => $mall_id])
  18. ->andWhere([
  19. 'or',
  20. ['like', 'nickname', $key_word],
  21. ['like', 'mobile', $key_word],
  22. ])
  23. ->column();
  24. }
  25. /**
  26. * 获取推荐人ID
  27. *
  28. * @param integer $user_id
  29. * @return string|int|null|false the value of the first column in the first row of the query result.
  30. */
  31. public static function getParentId(int $user_id)
  32. {
  33. return static::find()
  34. ->where(['id' => $user_id])
  35. ->select('parent_id')
  36. ->scalar();
  37. }
  38. }