Przeglądaj źródła

Default Changelist

yingzi 2 lat temu
rodzic
commit
a3da48eb66
1 zmienionych plików z 40 dodań i 0 usunięć
  1. 40 0
      app/api/controller/Pub.php

+ 40 - 0
app/api/controller/Pub.php

@@ -102,6 +102,46 @@ 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];
+    }
     
     /**
      * 获取皮肤模板列表