|
@@ -321,6 +321,71 @@ class Party extends Common
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 获取派对列表排序
|
|
|
+ */
|
|
|
+ public function getPartyList() {
|
|
|
+ try {
|
|
|
+ $thispage = $this->request->request('thispage',1,"intval"); // 当前页数
|
|
|
+ $pagenum = $this->request->request('pagenum',10,"intval"); // 每页显示条数0=不做分页
|
|
|
+ $type_id = $this->request->request('type_id'); // 派对类型
|
|
|
+ $room_type = $this->request->request('room_type',1); // 房间类型:1=派对,2=直播
|
|
|
+ $is_recommend = $this->request->request('is_recommend'); // 推荐0=否1=是
|
|
|
+ $all = $this->request->request('all'); // 全部分类0=否1=是
|
|
|
+ $index = $this->request->request('index',0); // 全部分类0=否1=是
|
|
|
+
|
|
|
+ $start = ($thispage-1)*$pagenum;
|
|
|
+ $end = $start+($pagenum-1);
|
|
|
+ // 获取排序
|
|
|
+ $redis = new Redis();
|
|
|
+ $redisconfig = config("redis");
|
|
|
+ $redis->connect($redisconfig["host"], $redisconfig["port"]);
|
|
|
+ if ($redisconfig['redis_pwd']) {
|
|
|
+ $redis->auth($redisconfig['redis_pwd']);
|
|
|
+ }
|
|
|
+ if($redisconfig['redis_selectdb'] > 0){
|
|
|
+ $redis->select($redisconfig['redis_selectdb']);
|
|
|
+ }
|
|
|
+ $redisPartyRankList = $redis->zRevRange($this->roomTypeArr[$room_type]."Rank",0,-1,true);
|
|
|
+
|
|
|
+ $partyModel = new \app\common\model\Party();
|
|
|
+ if(!$redisPartyRankList) {
|
|
|
+ $userModel = new \app\common\model\User();
|
|
|
+ // 直接从数据库获取所有数据
|
|
|
+ $where = [];
|
|
|
+ $where["a.status"] = 1;
|
|
|
+ $where["a.is_online"] = 1;
|
|
|
+ $where["a.room_type"] = $room_type;
|
|
|
+ $sqlPartyList = $partyModel->alias("a")->field("a.*,b.name as type_name")
|
|
|
+ ->join("hx_party_type b","a.party_type = b.id","left")->where($where)->select();
|
|
|
+ $userList = $userModel->field("id,nickname,avatar")->where(["status"=>"normal"])->select();
|
|
|
+ $userInfoArr = [];
|
|
|
+ if($userList) foreach($userList as $k => $v) $userInfoArr[$v["id"]] = $v;
|
|
|
+ if($sqlPartyList) {
|
|
|
+ foreach($sqlPartyList as $k => $v) {
|
|
|
+ // 加入缓存排序
|
|
|
+ $redis->zAdd($this->roomTypeArr[$room_type]."Rank", $v['party_hot'], $v["id"]);
|
|
|
+ // 设置冠名
|
|
|
+ $sqlPartyList[$k]["naming"] = isset($userInfoArr[$v["naming"]])?$userInfoArr[$v["naming"]]:[];
|
|
|
+ // 设置房主头像
|
|
|
+ $sqlPartyList[$k]["avatar"] = isset($userInfoArr[$v["user_id"]])?$userInfoArr[$v["user_id"]]["avatar"]:[];
|
|
|
+ // 加入缓存
|
|
|
+ $redis->set($this->roomTypeArr[$room_type]."_".$v["id"],json_encode($v));
|
|
|
+ }
|
|
|
+ $redisPartyRankList = $redis->zRevRange($this->roomTypeArr[$room_type]."Rank",0,-1,true);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if($redisPartyRankList) {
|
|
|
+ $resultInfo = $partyModel->getPatyInfoByPartyId($redisPartyRankList,$this->roomTypeArr[$room_type],$type_id,$is_recommend,$all,$start,$end,$index);
|
|
|
+ $this->success("获取成功!",$resultInfo);
|
|
|
+ }else{
|
|
|
+ $this->success("获取成功!",[]);
|
|
|
+ }
|
|
|
+ } catch (Exception $e) {;
|
|
|
+ $this->error($e->getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 获取派对用户排序
|
|
|
*/
|
|
|
public function getPartyUserRank() {
|