Bläddra i källkod

漂流瓶完善

lizhen_gitee 3 år sedan
förälder
incheckning
7e7348510c
2 ändrade filer med 47 tillägg och 1 borttagningar
  1. 46 1
      application/api/controller/Piaoliuping.php
  2. 1 0
      application/extra/site.php

+ 46 - 1
application/api/controller/Piaoliuping.php

@@ -14,7 +14,52 @@ class Piaoliuping extends Api
 
     //捡一个
     public function getone(){
-        $rs = Db::name('piaoliuping')->where('user_id','NEQ',$this->auth->id)->orderRaw('rand()')->find();
+
+        //判断vip身份,限制每日捡的个数
+        $vip_endtime = model('wallet')->getWallet($this->auth->id,'vip_endtime');
+        if($vip_endtime < time()){
+
+            $plp_unvip_daysnum = config('site.plp_unvip_daysnum');
+            if($plp_unvip_daysnum > -1){
+
+                $starttime = strtotime(date('Y-m-d'));
+                $endtime = $starttime + 86399;
+
+                $where = [
+                    'user_id' => $this->auth->id,
+                    'createtime' => ['BETWEEN',[$starttime,$endtime]],
+                ];
+                $count = Db::name('piaoliuping_log')->where($where)->count('id');
+                if($count >= $plp_unvip_daysnum){
+                    $this->error('非vip每天只能捡3个');
+                }
+            }
+
+        }
+
+        //不能是自己发的
+        $map = [
+            'user_id' => ['NEQ',$this->auth->id],
+        ];
+
+        //不能重复
+        $log_list = Db::name('piaoliuping_log')->where('user_id',$this->auth->id)->column('plp_id');
+        if(!empty($log_list)){
+            $map['id'] = ['NOTIN',$log_list];
+        }
+
+        $rs = Db::name('piaoliuping')->where($map)->orderRaw('rand()')->find();
+
+        //记录查看记录
+        if(!empty($rs)){
+            $log_data = [
+                'user_id' => $this->auth->id,
+                'plp_id'  => $rs['id'],
+                'createtime' => time(),
+            ];
+            Db::name('piaoliuping_log')->insertGetId($log_data);
+        }
+
         $this->success('success',$rs);
     }
 

+ 1 - 0
application/extra/site.php

@@ -59,4 +59,5 @@ return array (
   'unlock_like_me' => '38',
   'intro_man_money' => '3',
   'intro_woman_money' => '4',
+  'plp_unvip_daysnum' => '0',
 );