Browse Source

首页商品只弹一次

lizhen_gitee 2 months ago
parent
commit
c37aa37e10
1 changed files with 19 additions and 0 deletions
  1. 19 0
      application/api/controller/Index.php

+ 19 - 0
application/api/controller/Index.php

@@ -46,8 +46,19 @@ class Index extends Api
         $index_show_product = $productModel->field('id,image,title')->where($map)->find();
         $index_show_product = info_domain_image($index_show_product,['image']);
 
+        //登录之后,首页商品一天只弹一次
+        if($this->auth->isLogin()){
+
+            $key = date('Y-m-d').'-'.$this->auth->id;
+            if(cache($key) == 1){
+                $index_show_product = null;
+            }else{
+                cache($key,1,86400);
+            }
 
+        }
 
+        //
         $result = [
             'tag' => $tag,
             'sys' => $sys,
@@ -60,7 +71,15 @@ class Index extends Api
 
     }
 
+    public function test(){
+        $key = date('Y-m-d').'-'.$this->auth->id;
+        dump(cache($key));
+    }
 
+    public function clean(){
+        $key = date('Y-m-d').'-'.$this->auth->id;
+        cache($key,null);
+    }
 
 
 }