xiaogang 4 yıl önce
ebeveyn
işleme
caae4862b9
2 değiştirilmiş dosya ile 11 ekleme ve 3 silme
  1. 1 1
      app/Models/UserVipLimit.php
  2. 10 2
      app/Services/HomeService.php

+ 1 - 1
app/Models/UserVipLimit.php

xqd
@@ -9,6 +9,6 @@ class UserVipLimit extends BaseModel
     protected $table = 'users_vip_limit';
     public $timestamps = false;
     protected $primaryKey="user_id";
-    protected $fillable = ['user_id', 'weixin','user','dynamic'];
+    protected $fillable = ['user_id', 'weixin','user','dynamic','user_detail','user_info'];
 
 }

+ 10 - 2
app/Services/HomeService.php

xqd xqd
@@ -13,6 +13,7 @@ use App\Models\UserComment;
 use App\Models\UserInfoModel;
 use App\Models\UserLikeModel;
 use App\Models\UserPhotoDestroy;
+use App\Models\UserVipLimit;
 use Illuminate\Support\Facades\Cache;
 use Illuminate\Support\Facades\DB;
 use Illuminate\Support\Facades\Redis;
@@ -68,8 +69,15 @@ class HomeService
         }else{
             //判断会员特权和普通用户
             if($user->is_vip==0){
-
-
+                $limit = UserVipLimit::query()->where('user_id',$user->id)->first();
+                if($limit->user_detail>=10){
+                    throw new Exception("非VIP用户每天只能看10个人");
+                }else{
+                    //如果当天没有看过这个人  增加记录
+                    if(!DB::table('users_look')->where(['user_id'=>$user->id,'look_id'=>$user_id])->whereBetween('atime',[date('Y-m-d 00:00:00'),date('Y-m-d 23:59:59')])->first()){
+                        UserVipLimit::query()->where('user_id',$user->id)->increment('user_detail',1);
+                    }
+                }
             }
         }