|
@@ -215,6 +215,34 @@ class Index extends Api
|
|
|
$this->success(1,$list);
|
|
|
}
|
|
|
|
|
|
+ //匹配配置
|
|
|
+ public function pipei_config(){
|
|
|
+ $result = [
|
|
|
+ 'index_pipei_switch' => config('site.index_pipei_switch'), //匹配开关
|
|
|
+ ];
|
|
|
+
|
|
|
+ //首页匹配每天每人匹配次数
|
|
|
+ $user_id = $this->auth->id;
|
|
|
+ $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($times_limit > -1){
|
|
|
+ $remain_times = $times_limit - $user_times;
|
|
|
+ if($remain_times < 0){
|
|
|
+ $remain_times = 0;
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ $remain_times = -1;
|
|
|
+ }
|
|
|
+
|
|
|
+ $result['remain_times'] = $remain_times;
|
|
|
+
|
|
|
+ $this->success(1,$result);
|
|
|
+ }
|
|
|
+
|
|
|
//匹配
|
|
|
//做防止重复处理,参照荔枝
|
|
|
public function pipei(){
|
|
@@ -237,7 +265,7 @@ class Index extends Api
|
|
|
$times_limit_redis = 'pipei_times_limit_'.$user_id;
|
|
|
$user_times = Cache::get($times_limit_redis) ?: 0;
|
|
|
|
|
|
- if($times_limit > 0 && $user_times >= $times_limit){
|
|
|
+ if($times_limit > -1 && $user_times >= $times_limit){
|
|
|
$this->error('今日已超匹配上限'.$times_limit.'次');
|
|
|
}
|
|
|
|