gq 7 年之前
父節點
當前提交
86d04a5f8d

+ 1 - 2
server/app/Console/Commands/DreamDJS.php

xqd
@@ -46,8 +46,7 @@ class DreamDJS extends Command
     public function handle()
     {
         //执行逻辑
-        Log::info('hello xiaoqiang-----------------------');
-
+        Log::info('------------通知消息begin-----------');
 
         $end_dream_info = DreamInfoModel::with('user')->where('end_time','<',date('Y-m-d H:i:s'))->get();
         if (count($end_dream_info)>0) {

+ 44 - 0
server/app/Console/Commands/refurbish.php

xqd
@@ -0,0 +1,44 @@
+<?php
+
+namespace App\Console\Commands;
+
+use Illuminate\Console\Command;
+use Illuminate\Support\Facades\Log;
+
+class refurbish extends Command
+{
+    /**
+     * The name and signature of the console command.
+     *
+     * @var string
+     */
+//    自动加载页面数据
+    protected $signature = 'refurbish';
+
+    /**
+     * The console command description.
+     *
+     * @var string
+     */
+    protected $description = '自动刷新';
+
+    /**
+     * Create a new command instance.
+     *
+     * @return void
+     */
+    public function __construct()
+    {
+        parent::__construct();
+    }
+
+    /**
+     * Execute the console command.
+     *
+     * @return mixed
+     */
+    public function handle()
+    {
+        Log::info('i miss you ');
+    }
+}

+ 3 - 0
server/app/Console/Kernel.php

xqd xqd
@@ -14,6 +14,7 @@ class Kernel extends ConsoleKernel
      */
     protected $commands = [
         \App\Console\Commands\DreamDJS::class,
+        \App\Console\Commands\refurbish::class,
     ];
 
     /**
@@ -28,6 +29,8 @@ class Kernel extends ConsoleKernel
         //          ->hourly();
         $schedule->command('DreamDJS')
             ->everyMinute();
+        $schedule->command('refurbish')
+            ->everyMinute();
     }
 
     /**

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

xqd xqd
@@ -110,9 +110,6 @@ class IndexController extends Controller
     {
         $login_user = $this->getUser();
         $id = $login_user->id;
-//        访问首页时 当用户的梦想结束时通知用户
-//        $this->systemInfo($id);
-
         $arr1 =DreamInfoModel::orderBy('score','desc')->limit(30)->select('id')->get()->toArray();
         $id_arr1 = array_column($arr1,'id');
         $arr2 =DreamInfoModel::orderBy('score','desc')->offset(15)->limit(120)->select('id')->get()->toArray();
@@ -148,92 +145,6 @@ class IndexController extends Controller
 
     }
 
-    public function systemInfo($id)
-    {
-        $user = UserInfoModel::find($id);
-        $end_dream_info = DreamInfoModel::where('user_id',$id)->where('end_time','>',date('Y-m-d H:i:s'))->get();
-        if (count($end_dream_info)>0) {
-            foreach ($end_dream_info as $item){
-                $message = "你的梦想《".$item->name."》已结束,点击了解接下来的步骤";
-                $arr = [
-                    'user_id'=>0,
-                    'message'=>$message,
-                    'to_user_id'=>$id,
-                    'dream_id'=>$item->id,
-                    'is_end'=>1,
-                    'type_id'=>1,
-                    'attr_id'=>6,
-
-                ];
-                SystemInfoModel::firstOrCreate($arr);
-//                给支持者发送消息
-                $support_dream = SupportDreamModel::where('dream_id',$item->id)->get();
-                $top = [] ;
-                foreach ($support_dream as $item2) {
-                    if (!array_key_exists($item2->user_id,$top)) {
-                        $top[$item2->user_id] = $item2->score;
-                    }else{
-                        $top[$item2->user_id] += $item2->score;
-                    }
-                }
-                arsort($top);
-                $new_arr = array_values($top);
-                foreach ($top as $k => $v) {
-                    $key = array_search($v,$new_arr);
-                    $message = $item->name."已经结束啦!谢谢你的支持,你可是他的第".($key+1)."支持者哦!";
-                    if (empty($key)) { //最大支持者
-                        $message = "恭喜你成为《".$item->name."》的《梦主》!
-                       ";
-                         $info =  $user->nickname."会以你提供的微信/电话联系你约好时间地点亲自感谢你给予的支持和鼓励。如果你不希望见面或
-                        不想要梦想者拥有你的联系方式,请按《不需要见面》的按钮或联系客服。";
-                        $arr2 = [
-                            'user_id'=>$item->user_id,
-                            'info'=>$info,
-                            'message'=>$message,
-                            'to_user_id'=>$k,
-                            'dream_id'=>$item->id,
-                            'is_end'=>1,
-                            'is_url'=>1,
-                            'type_id'=>2,
-                            'is_max'=>1,
-                        ];
-                    }else{
-                        $arr2 = [
-                            'user_id'=>0,
-                            'message'=>$message,
-                            'to_user_id'=>$k,
-                            'dream_id'=>$item->id,
-                            'is_end'=>1,
-                            'is_url'=>1,
-                            'type_id'=>2,
-                        ];
-                    }
-                    SystemInfoModel::firstOrCreate($arr2);
-                }
-            }
-//            2   我关注的梦想倒计时 通知消息
-            $dreams = UserCareDream::where('user_id',$id)->with('dreams')->get();
-            foreach ($dreams as $item) {
-                if (date('Y-m-d',strtotime($item->dreams->end_time)) == date('Y-m-d',time()+1*24*3600)) {
-                    $message = $item->name.'过1天就要结束啦!';
-                    $arr3 = [
-                        'user_id'=>0,
-                        'message'=>$message,
-                        'to_user_id'=>$id,
-                        'dream_id'=>$item->dream_id,
-                        'is_url'=>1,
-                        'type_id'=>2,
-                        'attr_id'=>8,
-                    ];
-                    SystemInfoModel::firstOrCreate($arr3);
-                }
-            }
-           /* if (!empty($arr2)) {
-                SystemInfoModel::insert($arr2);
-            }*/
-        }
-    }
-
     /**
      * @api {get}  /api/index/search 搜索
      * @apiDescription 搜索

+ 3 - 2
server/app/Http/Controllers/Api/V1/MyController.php

xqd xqd
@@ -328,7 +328,8 @@ class MyController extends Controller
         $user = $this->getUser();
         $data8  =  SystemInfoModel::where('to_user_id',$user->id)->where('type_id',2)->where('attr_id',8)->orderBy('id','desc')->get()->toArray();
 //        计算interaction_id出现的次数
-        $count = array_count_values(array_column($data8,"interaction_id"));
+//        dd(array_column($data8,"interaction_id"));
+        $count = array_count_values(array_filter(array_column($data8,"interaction_id")));
         $new_data8 = [] ;
         if (!empty($count)) {
             foreach ($count as $interaction_id => $value) {
@@ -355,7 +356,7 @@ class MyController extends Controller
                 }
             }
         }
-        $data9  =  SystemInfoModel::where('to_user_id',$user->id)->where('type_id',2)->where('attr_id','!=',8)->orderBy('id','desc')->get()->toArray();
+        $data9  =  SystemInfoModel::with('user')->where('to_user_id',$user->id)->where('type_id',2)->where('attr_id','!=',8)->orderBy('id','desc')->get()->toArray();
         $data = array_merge($new_data8,$data9);
         SystemInfoModel::where('to_user_id',$user->id)->where('type_id',2)->update(['is_read' => 1]);
         return $this->api($data);