LiuJ 3 päivää sitten
vanhempi
sitoutus
2618394a3a
1 muutettua tiedostoa jossa 18 lisäystä ja 18 poistoa
  1. 18 18
      app/JsonRpc/WebsiteService.php

+ 18 - 18
app/JsonRpc/WebsiteService.php

@@ -731,7 +731,7 @@ class WebsiteService implements WebsiteServiceInterface
      */
     public function getAdminIndex(array $data): array
     {
-        var_dump("用户类型:", $data['type_id']);
+        var_dump("用户类型:", $data);
         switch ($data['type_id']) {
             case 4:
                 $result = Db::select('SELECT  DATE(created_at) AS date,COUNT(*) AS total_count FROM  letter_of_complaint  WHERE  created_at >= CURDATE() - INTERVAL 30 DAY  GROUP BY  DATE(created_at)  ORDER BY  date ASC;');
@@ -835,7 +835,7 @@ class WebsiteService implements WebsiteServiceInterface
                     ->where('admin_user_id', $user_id)
                     ->orderBy('updated_at', 'desc')
                     ->limit(5)
-                    ->get(['title', 'updated_at'])
+                    ->get(['id', 'title', 'updated_at'])
                     ->map(function ($item) use ($now) {
                         $item->class = '资讯';
                         $item->formatted_updated_at = $this->timeAgo($item->updated_at, $now);
@@ -846,7 +846,7 @@ class WebsiteService implements WebsiteServiceInterface
                 $good = Good::where('status', 1)
                     ->where('user_id', $user_id)
                     ->orderBy('updated_at', 'desc')
-                    ->get(['name as title', 'updated_at'])
+                    ->get(['id', 'name as title', 'updated_at'])
                     ->map(function ($item) use ($now) {
                         //去掉name的属性
                         $item->class = '商品';
@@ -857,7 +857,7 @@ class WebsiteService implements WebsiteServiceInterface
                     ->where('status', 1)
                     ->where('user_id', $user_id)
                     ->orderBy('updated_at', 'desc')
-                    ->get(['title', 'updated_at'])
+                    ->get(['id', 'title', 'updated_at'])
                     ->map(function ($item) use ($now) {
                         //去掉name的属性
                         $item->class = '书刊';
@@ -869,7 +869,7 @@ class WebsiteService implements WebsiteServiceInterface
                     ->where('status', 1)
                     ->where('user_id', $user_id)
                     ->orderBy('updated_at', 'desc')
-                    ->get(['name as title', 'updated_at'])
+                    ->get(['id', 'name as title', 'updated_at'])
                     ->map(function ($item) use ($now) {
                         //去掉name的属性
                         $item->class = '求职';
@@ -880,7 +880,7 @@ class WebsiteService implements WebsiteServiceInterface
                     ->where('status', 0)
                     ->where('user_id', $user_id)
                     ->orderBy('updated_at', 'desc')
-                    ->get(['title', 'updated_at'])
+                    ->get(['id', 'title', 'updated_at'])
                     ->map(function ($item) use ($now) {
                         //去掉name的属性
                         $item->class = '招聘';
@@ -894,7 +894,7 @@ class WebsiteService implements WebsiteServiceInterface
                     ->where('status', 1)
                     ->where('user_id', $user_id)
                     ->orderBy('updated_at', 'desc')
-                    ->get(['title', 'updated_at'])
+                    ->get(['id', 'title', 'updated_at'])
                     ->map(function ($item) use ($now) {
                         //去掉name的属性
                         $item->class = $item->type == 1 ? "通知" : "公告";
@@ -906,7 +906,7 @@ class WebsiteService implements WebsiteServiceInterface
                     ->where('status', 1)
                     ->where('user_id', $user_id)
                     ->orderBy('updated_at', 'desc')
-                    ->get(['title', 'updated_at'])
+                    ->get(['id', 'title', 'updated_at'])
                     ->map(function ($item) use ($now) {
                         //去掉name的属性
                         $item->class = "投诉";
@@ -930,7 +930,7 @@ class WebsiteService implements WebsiteServiceInterface
                     ->concat($jobrecruiting)
                     ->concat($notice)
                     ->concat($complaint)
-                    ->sortBy(function ($item) {
+                    ->sortByDesc(function ($item) {
                         return Carbon::createFromFormat('Y-m-d H:i:s', $item->updated_at);
                     });
                 // ->sortBy('updated_at');
@@ -947,7 +947,7 @@ class WebsiteService implements WebsiteServiceInterface
                     ->where('talk_type', 1)
                     ->orderBy('updated_at', 'desc')
                     ->limit(5)
-                    ->get(['content', 'updated_at'])
+                    ->get(['id', 'content', 'updated_at'])
                     ->map(function ($item) use ($now) {
                         $item->class = "单聊";
                         $item->formatted_updated_at = $this->timeAgo($item->updated_at, $now);
@@ -958,7 +958,7 @@ class WebsiteService implements WebsiteServiceInterface
                     ->where('talk_type', 2)
                     ->orderBy('updated_at', 'desc')
                     ->limit(5)
-                    ->get(['content', 'updated_at'])
+                    ->get(['id', 'content', 'updated_at'])
                     ->map(function ($item) use ($now) {
                         $item->class = "群聊";
                         $item->formatted_updated_at = $this->timeAgo($item->updated_at, $now);
@@ -968,10 +968,10 @@ class WebsiteService implements WebsiteServiceInterface
                 $topic_msg = ChatTopic::where('chat_topics.user_id', $user_id)
                     ->whereNotNull('chat_topics_reply.updated_at')
                     ->leftJoin('chat_topics_reply', 'chat_topics.id', '=', 'chat_topics_reply.topic_id')
-                    ->select('chat_topics.title as content', 'chat_topics_reply.updated_at as updated_at')
+                    ->select('chat_topics.id', 'chat_topics.title as content', 'chat_topics_reply.updated_at as updated_at')
                     ->orderBy('updated_at', 'desc')
                     ->limit(5)
-                    ->get(['content', 'updated_at'])
+                    ->get(['chat_topics.id', 'chat_topics.content', 'chat_topics.updated_at'])
                     ->map(function ($item) use ($now) {
                         $item->class = "话题";
                         $item->content = $item->content . '话题有回复了';
@@ -982,7 +982,7 @@ class WebsiteService implements WebsiteServiceInterface
                 $chat_msg = $chat_single_msg
                     ->concat($chat_group_msg)
                     ->concat($topic_msg)
-                    ->sortBy(function ($item) {
+                    ->sortByDesc(function ($item) {
                         return Carbon::createFromFormat('Y-m-d H:i:s', $item->updated_at);
                     })->values()->all();
 
@@ -996,7 +996,7 @@ class WebsiteService implements WebsiteServiceInterface
                     })
                     ->orderBy('updated_at', 'desc')
                     ->limit(5)
-                    ->get(['title', 'updated_at'])
+                    ->get(['id', 'title', 'updated_at'])
                     ->map(function ($item) use ($now) {
                         $item->class = "通知";
                         $item->formatted_updated_at = $this->timeAgo($item->updated_at, $now);
@@ -1010,7 +1010,7 @@ class WebsiteService implements WebsiteServiceInterface
                     })
                     ->orderBy('updated_at', 'desc')
                     ->limit(5)
-                    ->get(['title', 'updated_at'])
+                    ->get(['id', 'title', 'updated_at'])
                     ->map(function ($item) use ($now) {
                         $item->class = "投诉";
                         $item->formatted_updated_at = $this->timeAgo($item->updated_at, $now);
@@ -1020,14 +1020,14 @@ class WebsiteService implements WebsiteServiceInterface
 
                 $notice_msg = $notce_recieve_msg
                     ->concat($complaint_recieve_msg)
-                    ->sortBy(function ($item) {
+                    ->sortByDesc(function ($item) {
                         return Carbon::createFromFormat('Y-m-d H:i:s', $item->updated_at);
                     })->values()->all();
 
                 $res['notice_msg'] = $notice_msg;
                 // $res['article'] = $article;
                 $res['website']['count'] = Website::where([])->count();
-                $res['article']['count'] = Article::whereIn('status', [1])->where('admin_user_id', $user_id)->count() || [];
+                $res['article']['count'] = Article::whereIn('status', [1])->where('admin_user_id', $user_id)->count();
                 $res['category']['count'] = Category::where([])->count();
                 $res['good']['count'] =  Good::whereIn('status', [2])
                     ->where('user_id', $user_id)->count();