|
@@ -219,13 +219,28 @@ class Index extends Api
|
|
//做防止重复处理,参照荔枝
|
|
//做防止重复处理,参照荔枝
|
|
public function pipei(){
|
|
public function pipei(){
|
|
|
|
|
|
- //检查剩余次数
|
|
|
|
|
|
+ //首页匹配功能开关
|
|
|
|
+ $index_pipei_switch = config('site.index_pipei_switch');
|
|
|
|
+ if($index_pipei_switch != 1){
|
|
|
|
+ $this->error('匹配功能维护中,请稍后再试');
|
|
|
|
+ }
|
|
|
|
|
|
//缓存,防重复
|
|
//缓存,防重复
|
|
$user_id = $this->auth->id;
|
|
$user_id = $this->auth->id;
|
|
- $user_id_redis = 'u_'.$user_id;
|
|
|
|
|
|
+ $user_id_redis = 'pipei_repeat_'.$user_id;
|
|
$redis_ids = json_decode(Cache::get($user_id_redis),true);
|
|
$redis_ids = json_decode(Cache::get($user_id_redis),true);
|
|
|
|
|
|
|
|
+ //首页匹配每天每人匹配次数
|
|
|
|
+ $is_vip = $this->is_vip($this->auth->id);
|
|
|
|
+ $times_limit = $is_vip == 1 ? config('site.pipei_oneday_vipuser_times') : config('site.index_pipei_oneday_user_times');
|
|
|
|
+
|
|
|
|
+ $times_limit_redis = 'pipei_times_limit_'.$user_id;
|
|
|
|
+ $user_times = Cache::get($times_limit_redis) ?: 0;
|
|
|
|
+
|
|
|
|
+ if($user_times >= $times_limit){
|
|
|
|
+ $this->error('今日已经超过匹配次数上限');
|
|
|
|
+ }
|
|
|
|
+
|
|
//where
|
|
//where
|
|
$where = [
|
|
$where = [
|
|
'user.id' => ['neq',$this->auth->id],
|
|
'user.id' => ['neq',$this->auth->id],
|
|
@@ -261,6 +276,10 @@ class Index extends Api
|
|
$redis_ids = [$result];
|
|
$redis_ids = [$result];
|
|
}
|
|
}
|
|
Cache::set($user_id_redis,json_encode($redis_ids));
|
|
Cache::set($user_id_redis,json_encode($redis_ids));
|
|
|
|
+
|
|
|
|
+ //设置次数
|
|
|
|
+ $second = strtotime(date('Y-m-d'))+86400 - time();
|
|
|
|
+ Cache::set($times_limit_redis,$user_times+1,$second);
|
|
}else{
|
|
}else{
|
|
Cache::rm($user_id_redis);
|
|
Cache::rm($user_id_redis);
|
|
}
|
|
}
|
|
@@ -287,14 +306,22 @@ class Index extends Api
|
|
public function test(){
|
|
public function test(){
|
|
//缓存,防重复
|
|
//缓存,防重复
|
|
$user_id = $this->auth->id;
|
|
$user_id = $this->auth->id;
|
|
- $user_id_redis = 'u_'.$user_id;
|
|
|
|
|
|
+ $user_id_redis = 'pipei_repeat_'.$user_id;
|
|
$redis_ids = json_decode(Cache::get($user_id_redis),true);
|
|
$redis_ids = json_decode(Cache::get($user_id_redis),true);
|
|
dump($redis_ids);
|
|
dump($redis_ids);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ $times_limit_redis = 'pipei_times_limit_'.$user_id;
|
|
|
|
+ $user_times = Cache::get($times_limit_redis) ?: 0;
|
|
|
|
+ dump($user_times);
|
|
}
|
|
}
|
|
public function testrm(){
|
|
public function testrm(){
|
|
$user_id = $this->auth->id;
|
|
$user_id = $this->auth->id;
|
|
- $user_id_redis = 'u_'.$user_id;
|
|
|
|
|
|
+ $user_id_redis = 'pipei_repeat_'.$user_id;
|
|
Cache::rm($user_id_redis);
|
|
Cache::rm($user_id_redis);
|
|
|
|
+
|
|
|
|
+ $times_limit_redis = 'pipei_times_limit_'.$user_id;
|
|
|
|
+ Cache::rm($times_limit_redis);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|