User.php 998 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace addons\YunfastPay\common\models;
  3. use common\models\user\User as UserModel;
  4. /**
  5. * 主商城会员model
  6. * @package addons\YunfastPay\common\models
  7. */
  8. class User extends UserModel
  9. {
  10. /**
  11. * @param integer $mall_id
  12. * @param string $keyword
  13. * @return static
  14. */
  15. public static function getUserModelByKeyword(int $mall_id, string $keyword, string $field = 'id')
  16. {
  17. return static::find()
  18. ->select($field)
  19. ->where(['mall_id' => $mall_id])
  20. ->andWhere([
  21. 'or',
  22. ['like', 'nickname', $keyword],
  23. ['like', 'mobile', $keyword],
  24. ]);
  25. }
  26. /**
  27. * @param integer $mall_id
  28. * @param string $keyword
  29. * @param string $field
  30. * @return array
  31. */
  32. public static function getUserIdsByKeyword(int $mall_id, string $keyword)
  33. {
  34. return static::getUserModelByKeyword(
  35. $mall_id, $keyword, 'id'
  36. )->column();
  37. }
  38. }