1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- <?php
- /**
- * Created by PhpStorm.
- * User: z-yang
- * Date: 2019/1/10
- * Time: 11:30
- */
- namespace App\Modules\YunQi\Services;
- use App\Modules\YunQi\Models\BookUser;
- use Redis;
- class BookUserService
- {
- public static function getByUid($uid){
- return BookUser::where('uid',$uid)->select('id','uid','area','type','bid','flag')->first();
- }
- public static function updateUser($uid,$data){
- return BookUser::where('uid',$uid)->update($data);
- }
- public static function popUser($uid){
- try{
- Redis::srem('YQ_USER_TEST_BOOK:USER',$uid);
- }catch (\Exception $e){}
- }
- public static function isUserInRedis($uid){
- return Redis::SISMEMBER('YQ_USER_TEST_BOOK:USER',$uid);
- }
- /**
- * 判断用户是否存在
- * @param $uid
- * @return bool
- */
- public static function selectUser($uid){
- if(!self::isUserInRedis($uid)){
- return null;
- }
- $user = self::getByUid($uid);
- return $user;
- }
- }
|