gq 7 年之前
父節點
當前提交
9353dfff55

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

xqd
@@ -30,7 +30,7 @@ class Controller extends BaseController
         $this->middleware('auth:api', [
             'except' => [
                 'upload', 'getCode', 'login', 'wechatLogin', 'alipayNotify', 'wechatpayNotify',
-                'download',  'test'
+                'download',  'test','store'
             ]
         ]);
 

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

xqd xqd xqd
@@ -6,6 +6,7 @@ use App\Models\CommentInfoModel;
 use App\Models\DreamInfoModel;
 use App\Models\InteractionInfo;
 use App\Models\ReplyCommentsInfo;
+use App\Models\SupportDreamModel;
 use App\Models\SystemInfoModel;
 use App\Models\UserCareDream;
 use App\Models\UserCareUser;
@@ -48,6 +49,7 @@ class InteractionController extends Controller
      */
     public function store(Request $request)
     {
+        $user = $this->getUser();
         $validator = \Validator::make($request->all(),
             [
                 'id'  => 'required',
@@ -76,6 +78,21 @@ class InteractionController extends Controller
         $data['video'] = $request->video;
         $ok = InteractionInfo::create($data);
         if ($ok) {
+            //        新的互动应该有消息通知《支持者》
+            $support_user = SupportDreamModel::where('dream_id',$dream_id)->get();
+            if (!empty(count($support_user))) {
+                $user_ids = array_column($support_user->toArray(),'user_id');
+                foreach ($user_ids as $user_id) {
+                    $arr['user_id']=$user->id;
+                    $arr['to_user_id']=$user_id;
+                    $arr['message']='您支持的梦想又有新的动态啦';
+                    $arr['interaction_id']=$ok->id;
+                    $arr['dream_id']=$dream_id;
+                    SystemInfoModel::create($arr);
+//            长连接
+                    $this->jPush($arr['message'],'',$user_id);
+                }
+            }
 //            收藏梦想最新动态加一
             UserCareDream::where('dream_id',$dream_id)->increment('interaction_number',1);
             $dream_user_id = DreamInfoModel::find($dream_id)->user_id;

+ 2 - 0
server/app/Models/SystemInfoModel.php

xqd
@@ -35,6 +35,8 @@ class SystemInfoModel extends BaseModel
                            'message',
                            'to_user_id',
                            'is_read',
+                           'interaction_id',
+                           'dream_id',
                           ];
 
     public function user()

+ 33 - 0
server/database/migrations/2017_10_25_102420_add_dream_id_and_interaction_id_to_system_info_table.php

xqd
@@ -0,0 +1,33 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class AddDreamIdAndInteractionIdToSystemInfoTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('system_info', function (Blueprint $table) {
+            $table->integer('dream_id')->nullable()->after('is_read');
+            $table->integer('interaction_id')->nullable()->after('is_read');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('system_info', function (Blueprint $table) {
+            //
+        });
+    }
+}