Przeglądaj źródła

Default Changelist

yingzi 1 rok temu
rodzic
commit
3dd7bab811
1 zmienionych plików z 25 dodań i 16 usunięć
  1. 25 16
      app/api/controller/Pub.php

+ 25 - 16
app/api/controller/Pub.php

@@ -306,25 +306,34 @@ class Pub extends BaseController
     }
 
     /**
-     * 获取名片浏览量排行榜
+     * 名片浏览量排行榜
      * @param Request $request
      */
-    public function getCardLookCountRank(Request $request)
-    {
-        $list = (new UserModel)
-            ->where('card_look_count', '>', 0)
-            ->order('card_look_count', 'DESC')
-            ->limit(6)
-            ->field('uid, nickname, avatar, card_look_count')
-            ->select()
-            ->toArray();
-        foreach ($list as &$item) {
-            $template = (new UserModel)->getApiWorkerList($item['uid']);
-            $item['template_id'] = $template['id'];
-            $item['template_name'] = $template['name'];
-            $item['template_image'] = $template['image'];
+    public function getCardLookCountRank(Request $request) {
+        $time = $request->param('time', time());
+        $list = (new UserModel)->where('card_look_count', '>', 0);
+        if ($time > 0) {
+            $list = $list->whereTime('regtime', '>=', $time);
         }
-        return app('json')->success(compact('list'));
+        $list = $list->order('card_look_count', 'desc')->select();
+        $rankList = [];
+        foreach ($list as $key => $value) {
+            $userInfo = (new UserModel)->where('uid', $value['uid'])->find();
+            $auth = (new InfoAudit)->where('uid',$value['uid'])->find();
+            $template = $this->getShowTemplateItem($value['uid']);
+            $rankList[] = [
+                'rank' => $key + 1,
+                'uid' => $value['uid'],
+                'name' => $userInfo['name'],
+                'avatar' => $userInfo['avatar'],
+                'card_look_count' => $value['card_look_count']*18,
+                'template' => $template,
+                'is_type_audit'=>$auth['status']==1?1:0,
+                'ancestral_place'=>$auth['ancestral_place'],
+                'auth_info' => $auth->toArray(),
+            ];
+        }
+        return app('json')->success($rankList);
     }