gq 7 years ago
parent
commit
0afdf747dc

+ 3 - 0
server/app/Http/Controllers/Api/V1/IndexController.php

xqd xqd
@@ -162,6 +162,8 @@ class IndexController extends Controller
                     'dream_id'=>$item->id,
                     'is_end'=>1,
                     'type_id'=>1,
+                    'attr_id'=>6,
+
                 ];
 //                给支持者发送消息
                 $support_dream = SupportDreamModel::where('dream_id',$item->id)->get();
@@ -219,6 +221,7 @@ class IndexController extends Controller
                         'dream_id'=>$item->dream_id,
                         'is_url'=>1,
                         'type_id'=>2,
+                        'attr_id'=>8,
                     ];
                 }
             }

+ 1 - 0
server/app/Http/Controllers/Api/V1/InteractionController.php

xqd
@@ -192,6 +192,7 @@ class InteractionController extends Controller
                 'message' => $message,
                 'is_url' => 1,
                 'type_id' => 1,
+                'attr_id' => 8,
                 'dream_id' => $dream_id,
                 'interaction_id' => $request->input('id'),
             ];

+ 45 - 8
server/app/Http/Controllers/Api/V1/MyController.php

xqd xqd xqd
@@ -233,7 +233,7 @@ class MyController extends Controller
     }
 
     /**
-     * @api {get} /api/my/dreamInfo 梦想消息
+     * @api {get} /api/my/dream_info 梦想消息
      * @apiDescription 梦想消息
      * @apiGroup My
      * @apiPermission Passport
@@ -254,16 +254,52 @@ class MyController extends Controller
      */
     public function dreamInfo()
     {
-//        梦想消息分为 支持 收藏 互动 提现 梦想暂停 结束
+//        梦想消息分为 1支持 2收藏 3互动 4提现 5梦想暂停 6结束
         $user = $this->getUser();
-        $data  =  SystemInfoModel::where('user_id',$user->id)->where('type_id',1)->orderBy('id','desc')->get();
-        foreach ($data as $item){   //访问接口  标记已读
-            $item->update(['is_read'=>0]);
-            $info = InteractionInfo::find($item->interaction_id);
-            $dream_id =empty($info) ? 0 : $info->dream_id;
-            $item->dreamid = $dream_id;
+        $data1  =  SystemInfoModel::where('to_user_id',$user->id)->where('type_id',1)->where('attr_id',1)->orderBy('id','desc')->get()->toArray();
+        $new_data1 = [] ;
+        if (count($data1) > 0) {
+            if (count($data1) >= 5) {
+                $data1[0]['message'] = "已经有".count($data1)."个人支持了你的梦想!";
+                $new_data1[] = $data1[0];
+            }else{
+                $new_data1 = $data1;
+            }
+        }
+        $data2  =  SystemInfoModel::where('to_user_id',$user->id)->where('type_id',1)->where('attr_id',2)->orderBy('id','desc')->get()->toArray();
+        $new_data2 = [] ;
+        if (count($data2) > 0) {
+            if (count($data2) >= 5) {
+                $data2[0]['message'] = "已经有".count($data2)."个人收藏了你的梦想!";
+                $new_data2[] = $data2[0];
+            }else{
+                $new_data2 = $data2;
+            }
         }
+        $data3  =  SystemInfoModel::where('to_user_id',$user->id)->where('type_id',1)->where('attr_id',3)->orderBy('id','desc')->get()->toArray();
+        $new_data3 = [] ;
+        if (count($data3) > 0) {
+            if (count($data3) >= 5) {
+                $data3[0]['message'] = "你的互动已经有".count($data3)."个留言啦!快点击看看!";
+                $new_data3[] = $data3[0];
+            }else{
+                $new_data3 = $data3;
+            }
+        }
+        $data456  =  SystemInfoModel::where('to_user_id',$user->id)->where('type_id',1)
+            ->where(function ($query) {
+                $query->where('attr_id',4)->orWhere('attr_id',5)->orWhere('attr_id',6);
+            })->orderBy('id','desc')->get()->toArray();
+
+        $data = array_merge($new_data1,$new_data2,$new_data3,$data456);
+        SystemInfoModel::where('to_user_id',$user->id)->where('type_id',1)->update(['is_read' => 1]);
         return $this->api($data);
+//        foreach ($data as $item){   //访问接口  标记已读
+//            $item->update(['is_read'=>0]);
+//            $info = InteractionInfo::find($item->interaction_id);
+//            $dream_id =empty($info) ? 0 : $info->dream_id;
+//            $item->dreamid = $dream_id;
+//        }
     }
     /**
      * @api {get} /api/my/sup_info 支持消息
@@ -1208,6 +1244,7 @@ class MyController extends Controller
             'dream_id'=>$dream_id,
             'type_id'=>2,
             'is_url'=>1,
+            'attr_id'=>9,
         ];
 
         $ok =SystemInfoModel::create($arr);