gq 7 jaren geleden
bovenliggende
commit
f80e274f2c

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

xqd
@@ -399,7 +399,7 @@ class DreamController extends Controller
                 //        生成二维码
                 $info['transaction_id'] = date('YmdHis') . mt_rand(1000, 9999);
                 $info['code'] = 'WECHATPAY_' . $info['transaction_id'];
-                $code_url = env('APP_URL').'/user/meet?dream_id='.$dream_id;
+                $code_url = env('APP_URL').'/api/user/meet?dream_id='.$dream_id;
                 $code_path = public_path('qrcodes/'.$info['code'].'.png');
                 \QrCode::format('png')->size(500)->generate($code_url,$code_path);
                 $code =  env('APP_URL').'/qrcodes/'.$info['code'].'.png';

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

xqd
@@ -46,7 +46,8 @@ class IndexController extends Controller
      *      {
      *          "id": 3,
      *          "user_id": 1,
-     *          "other_user_id": 2,
+     *          "other_user_id": 2,   被关注者
+     *          "dream_id": 2,        最近动态梦想id 0表示没有动态
      *          "dream_number": 1,    >0 表示有最新动态
      *          "created_at": null,
      *          "updated_at": null,

+ 18 - 3
server/app/Http/Controllers/Api/V1/InteractionController.php

xqd xqd xqd xqd
@@ -3,10 +3,13 @@
 namespace App\Http\Controllers\Api\V1;
 
 use App\Models\CommentInfoModel;
+use App\Models\DreamInfoModel;
 use App\Models\InteractionInfo;
 use App\Models\ReplyCommentsInfo;
 use App\Models\SystemInfoModel;
 use App\Models\UserCareDream;
+use App\Models\UserCareUser;
+use App\Models\UserInfoModel;
 use Illuminate\Http\Request;
 use App\Services\Base\ErrorCode;
 use App\Helper\JpushHelper;
@@ -75,6 +78,9 @@ class InteractionController extends Controller
         if ($ok) {
 //            收藏梦想最新动态加一
             UserCareDream::where('dream_id',$dream_id)->increment('interaction_number',1);
+            $dream_user_id = DreamInfoModel::find($dream_id)->user_id;
+            UserCareUser::where('other_user_id',$dream_user_id)->update(['dream_id'=>$dream_id,'dream_number','1']);
+//            UserCareUser::where('dream_id',$dream_id)->increment('interaction_number',1);
             return $this->api('');
         }else{
             return $this->error(ErrorCode::SAVE_USER_FAILED);
@@ -90,6 +96,7 @@ class InteractionController extends Controller
      * @apiPermission Passport
      * @apiVersion 0.1.0
      * @apiParam {int} id                   动态ID不存在
+     * @apiParam {int}   [comment_user_id]          //已经评论者id
      * @apiParam {string} content           内容不能为空
      * @apiSuccessExample {json} Success-Response:
      * HTTP/1.1 200 OK
@@ -133,9 +140,17 @@ class InteractionController extends Controller
         $is_read = 1;
         $data = compact('user_id','user_avatar','user_nickname','interaction_id','content','is_read');*/
 
-        $data['to_user_id'] = InteractionInfo::find($request->id)->dream->user_id;
-        $data['to_user_avatar'] = InteractionInfo::find($request->id)->dream->user_avatar;
-        $data['to_user_nickname'] = InteractionInfo::find($request->id)->dream->user_nickname;
+//        $data['to_user_id'] = InteractionInfo::find($request->id)->dream->user_id;
+//        $data['to_user_avatar'] = InteractionInfo::find($request->id)->dream->user_avatar;
+//        $data['to_user_nickname'] = InteractionInfo::find($request->id)->dream->user_nickname;
+        if (!empty($request->input('comment_user_id'))) {
+            $to_user = UserInfoModel::find($request->input('comment_user_id'));
+            if (!empty($to_user)){
+                $data['comment_info_id'] = $request->input('comment_user_id');
+                $data['to_user_avatar'] = $to_user->avatar;
+                $data['to_user_nickname'] = $to_user->nickname;
+            }
+        }
 
         $data['user_id'] = $user->id;
         $data['user_avatar'] =$user->avatar;

+ 1 - 0
server/app/Models/UserCareUser.php

xqd
@@ -11,6 +11,7 @@ class UserCareUser extends Model
         'user_id',
         'other_user_id',
         'dream_number',
+        'dream_id',
     ];
 
     public function other_user()

+ 32 - 0
server/database/migrations/2017_09_25_164501_add_dream_id_to_user_care_user.php

xqd
@@ -0,0 +1,32 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class AddDreamIdToUserCareUser extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('user_care_user', function (Blueprint $table) {
+            $table->string('dream_id')->default(0)->comment('最近动态梦想id')->after('other_user_id');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('user_care_user', function (Blueprint $table) {
+            //
+        });
+    }
+}