UserInfo.php 856 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace api\models\user;
  3. use common\enums\StatusEnum;
  4. use common\models\user\User;
  5. use common\models\user\UserInfo as UserUserInfo;
  6. /**
  7. * 用户详情
  8. * @package api\models
  9. */
  10. class UserInfo extends UserUserInfo
  11. {
  12. /**
  13. * 微信公众号Openid
  14. *
  15. * @param integer $mall_id
  16. * @param integer $user_id
  17. * @return string|int|null|false the value of the first column in the first row of the query result.
  18. */
  19. public static function getWechatOpenid(int $mall_id, int $user_id)
  20. {
  21. return static::find()
  22. ->where([
  23. 'user_id' => $user_id,
  24. 'mall_id' => $mall_id,
  25. 'status' => StatusEnum::ENABLED,
  26. 'platform' => User::TYPE_WECHAT,
  27. ])
  28. ->select(['openid'])
  29. ->cache(10)
  30. ->scalar();
  31. }
  32. }