BookUserService.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: z-yang
  5. * Date: 2019/1/10
  6. * Time: 11:30
  7. */
  8. namespace App\Modules\YunQi\Services;
  9. use App\Modules\YunQi\Models\BookUser;
  10. use Redis;
  11. class BookUserService
  12. {
  13. public static function getByUid($uid){
  14. return BookUser::where('uid',$uid)->select('id','uid','area','type')->first();
  15. }
  16. public static function updateUser($uid,$data){
  17. return BookUser::where('uid',$uid)->update($data);
  18. }
  19. public static function popUser($uid){
  20. Redis::srem('xx',$uid);
  21. }
  22. public static function isUserInRedis($uid){
  23. return Redis::SISMEMBER('key',$uid);
  24. }
  25. /**
  26. * 判断用户的区域是否已经获取
  27. * @param $uid
  28. * @return bool
  29. */
  30. public static function selectUser($uid){
  31. if(!self::isUserInRedis($uid)){
  32. return false;
  33. }
  34. $user = self::getByUid($uid);
  35. if(!$user)
  36. return false;
  37. if($user->area)
  38. return false;
  39. return true;
  40. }
  41. }