13283339616 %!s(int64=6) %!d(string=hace) años
padre
commit
f7a58f60bd
Se han modificado 1 ficheros con 31 adiciones y 0 borrados
  1. 31 0
      app/Api/V1/Controllers/FindsController.php

+ 31 - 0
app/Api/V1/Controllers/FindsController.php

@@ -17,6 +17,37 @@ class FindsController extends BaseController
17 17
     public function getFinds(Request $request)
18 18
     {
19 19
         $publish_info=VestPublish::getFindsInfo();
20
+        $token   = $request->headers->get('token');
21
+
22
+        if($token==''){
23
+            foreach($publish_info as $key=>$value){
24
+                $publish_info[$key]['is_collect']=0;
25
+            }
26
+        }else{
27
+            $user = DB::table('users')->where('token', $token)->first();
28
+            $tokendata= !empty($user) ? $user : null;
29
+            if(empty($tokendata) || ($token!=$tokendata->token && (($tokendata->last_login_time - 30 *86400) > time()))) {
30
+                foreach($publish_info as $key=>$value){
31
+                    $publish_info[$key]['is_collect']=0;
32
+                }
33
+            }else{
34
+                $user_id = Menu::getUserId($token);
35
+                //查询是否收藏过该商品  收藏过 - 取消收藏 ; 未收藏 - 进行收藏操作
36
+                $userArr=DB::table('users')->where('user_id',$user_id)->plucks('user_id');
37
+                $userArr=json_decode(json_encode($userArr),true);
38
+                $findArr=DB::table('users')->where('user_id',$user_id)->plucks('vest_publish_id');
39
+                $findArr=json_decode(json_encode($findArr),true);
40
+                $collectArr=array_combine($findArr,$userArr);
41
+                foreach($publish_info as $key=>$value){
42
+                    $publish_info[$key]['is_collect']=0;
43
+                    if(array_key_exists($value['id'],$collectArr)){
44
+                        $menu['is_collect']=1;
45
+                    }else{
46
+                        $menu['is_collect']=0;
47
+                    }
48
+                }
49
+            }
50
+        }
20 51
         if (empty($publish_info)){
21 52
             return $this->response->array(self::returnValue([], 1010));
22 53
         }