Browse Source

Default Changelist

yingzi 1 year ago
parent
commit
9d1d9df02e
1 changed files with 21 additions and 65 deletions
  1. 21 65
      app/api/controller/Pub.php

+ 21 - 65
app/api/controller/Pub.php

@@ -102,46 +102,6 @@ class Pub extends BaseController
         }
         return app('json')->success($data);
     }
-    /**
-     * 获取邀请人数排行榜
-     * @param Request $request
-     */
-    public function getInviteRankList(Request $request){
-        $post = UtilService::getMore([
-            ['page', 1],
-            ['pageSize', 50],
-        ], $request);
-        $post["pageSize"] = $post["pageSize"] > 50 ? 50 : (int)$post["pageSize"];
-        $post["page"]     = $post["page"] <= 0 ? 1 : (int)$post["page"];
-        $where = [];
-        $where[] = ["u.total_invites", ">", 0];
-        $totalCount = $this->alias("u")->where($where)->count();
-        $data = null;
-        if($totalCount > 0){
-            $data = $this
-                ->alias("u")
-                ->field("u.uid, u.nickname, u.avatar, u.total_invites, u.is_type_audit, u.ancestral_place") // 添加 is_type_audit 和 ancestral_place 字段
-                ->where($where)
-                ->order("u.total_invites", "desc") // 按照邀请人数倒序排列
-                ->page($post["page"], $post["pageSize"])
-                ->select();
-            if(!empty($data)){
-                $data = $data->toArray();
-            }
-            $infoAuditDb = new InfoAudit();
-            foreach($data as $k=>$v){
-                $item = $this->getShowTemplateItem($v["uid"]); // 获取用户模板详情
-                $infoData = $infoAuditDb->getItem(["status"=>1,"uid"=>$v["uid"]]);
-                if(!empty($infoData)){
-                    $item["is_type_audit"] = $infoData["is_type_audit"];
-                    $item["ancestral_place"] = $infoData["ancestral_place"];
-                }
-                $data[$k] = array_merge($v, $item);
-            }
-        }
-        $data = empty($data) ? [] : $data;
-        return ["list" => $data, "pageSize" => $post["pageSize"], "page" => $post["page"], "totalCount" => $totalCount];
-    }
     
     /**
      * 获取皮肤模板列表
@@ -345,34 +305,30 @@ class Pub extends BaseController
     }
 
     /**
-     * 名片浏览量排行榜
+     * 获取名片浏览量排行榜
      * @param Request $request
      */
-    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);
-        }
-        $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(),
-            ];
+    public function getCardLookCountRank(Request $request)
+    {
+        [$startTime, $endTime] = UtilService::getMore([
+            ['time', 0],
+            ['times', time()],
+        ], $request, true);
+        $list = (new UserModel)
+            -> where('card_look_count', '>', 0)
+            -> whereBetweenTime('update_time', [$startTime, $endTime])
+            -> 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'];
         }
-        return app('json')->success($rankList);
+        return app('json')->success(compact('list'));
     }