Browse Source

消费收礼排行和家族申请

zhangxiaobin 1 year ago
parent
commit
0b58808d90

+ 42 - 0
application/api/controller/Guild.php

@@ -4,6 +4,7 @@ namespace app\api\controller;
 
 use app\common\controller\Api;
 use think\Db;
+use think\Exception;
 use Redis;
 use app\api\controller\Tenim;
 
@@ -380,6 +381,47 @@ class Guild extends Api
     }
 
     /**
+     * 公会申请加入列表
+     */
+    public function guildJoinList() {
+        try {
+            $user_id = $this->auth->id;
+            // 获取公会信息
+            $guildInfo = model('Guild')->where(["user_id"=>$user_id])->find();
+            if(!$guildInfo) throw new Exception('公会信息获取失败!');
+            // 先获取申请列表
+            $where = [];
+            $where["guild_id"] = $guildInfo->id;
+            $where["status"] = 0;
+            $result = model('GuildJoinin')->field("id,user_id,user_avatar,user_nickname,guild_name,createtime")
+                ->with(['user'=>function($uQuery){
+                    $uQuery->field('id,is_online,onlinetime');
+                }])
+                ->where($where)->order("createtime","desc")->select();
+            if($result) {
+                foreach($result as $k => &$v) {
+                    $user = isset($v['user']) ? $v['user'] : [];
+                    $onlineText = '';
+                    if (!empty($user)) {
+                        if ($user['is_online'] == 1) {
+                            $onlineText = '在线';
+                        } else {
+                            $onlineTime = get_last_time($user['onlinetime']);
+                            $onlineText = $onlineTime.'在线';
+                        }
+                    }
+                    $v['online_text'] = $onlineText;
+                    $v['createtime'] = !empty($v["createtime"]) ? date("Y-m-d H:i", $v["createtime"]) : '';
+                    unset($v['user']);
+                }
+            }
+            $this->success("获取成功",$result);
+        } catch (Exception $e) {
+            $this->error($e->getMessage());
+        }
+    }
+
+    /**
      * 公会成员列表
      */
     public function guildMember() {

+ 99 - 0
application/api/controller/Index.php

@@ -177,6 +177,105 @@ class Index extends Api
     }
 
     /**
+     * 获取收礼排行
+     */
+    public function getUserGiftRank() {
+        $time = $this->request->request("time",0,"intval"); //时间筛选 1=小时榜,2=今日榜,3=本周榜,4=月榜
+        if(!in_array($time,[1,2,3,4])) {
+            $this->error("参数传入错误!");
+        }
+
+        $hour = strtotime(date("Y-m-d H:00:00"));
+        $today = strtotime(date("Y-m-d 00:00:00"));
+        $weekend = strtotime('monday this week');
+        $month = strtotime(date("Y-m-01 00:00:00"));
+        // 剩余时间
+        $thistime = time();
+        switch ($time) {
+            case 1:
+                $redtime = 3600-($thistime - $hour);
+                break;
+            case 2:
+                $redtime = 3600*24-($thistime - $today);
+                break;
+            case 3:
+                $redtime = 3600*24*7-($thistime - $weekend);
+                break;
+            case 4:
+                $monthend = mktime(23,59,59,date("m"),date("t"),date("Y"));
+                $redtime = ($monthend - $month)-($thistime - $month);
+                break;
+        }
+
+        $timeArr = [1=>$hour,2=>$today,3=>$weekend,4=>$month];
+        $where = [];
+        $where["a.createtime"] = ["gt",$timeArr[$time]];
+        $list = model('GiftUserParty')->alias("a")
+            ->field("sum(a.value) as total_price,u.avatar,u.nickname")
+            ->where($where)
+            ->join("hx_user u","u.id = a.user_id")
+            ->group("a.user_to_id")
+            ->order("total_price","desc")
+            ->limit(100)
+            ->select();
+
+        $data = [];
+        $data["redtime"] = $redtime;
+        $data["data"] = $list;
+        $this->success("获取成功!",$data);
+    }
+
+    /**
+     * 获取消费排行
+     */
+    public function getUserPayRank() {
+        $time = $this->request->request("time",0,"intval"); //时间筛选 1=小时榜,2=今日榜,3=本周榜,4=月榜
+        if(!in_array($time,[1,2,3,4])) {
+            $this->error("参数传入错误!");
+        }
+
+        $hour = strtotime(date("Y-m-d H:00:00"));
+        $today = strtotime(date("Y-m-d 00:00:00"));
+        $weekend = strtotime('monday this week');
+        $month = strtotime(date("Y-m-01 00:00:00"));
+        // 剩余时间
+        $thistime = time();
+        switch ($time) {
+            case 1:
+                $redtime = 3600-($thistime - $hour);
+                break;
+            case 2:
+                $redtime = 3600*24-($thistime - $today);
+                break;
+            case 3:
+                $redtime = 3600*24*7-($thistime - $weekend);
+                break;
+            case 4:
+                $monthend = mktime(23,59,59,date("m"),date("t"),date("Y"));
+                $redtime = ($monthend - $month)-($thistime - $month);
+                break;
+        }
+
+        $timeArr = [1=>$hour,2=>$today,3=>$weekend,4=>$month];
+        $where = [];
+        $where["a.type"] = ["in",[2,3,5,6]];//type:1=充值,2=买锤子,3=送礼物,4=声币换钻石,5=开贵族,6=买装扮,7=拒绝订单返还,8=完成订单收益
+        $where["a.createtime"] = ["gt",$timeArr[$time]];
+        $list = model('UserJewelLog')->alias("a")
+            ->field("sum(a.value) as total_price,u.avatar,u.nickname")
+            ->where($where)
+            ->join("hx_user u","u.id = a.user_id")
+            ->group("a.user_id")
+            ->order("total_price","desc")
+            ->limit(100)
+            ->select();
+
+        $data = [];
+        $data["redtime"] = $redtime;
+        $data["data"] = $list;
+        $this->success("获取成功!",$data);
+    }
+
+    /**
      * 获取派对热度排序
      */
     public function getPartyHotList() {

+ 4 - 0
application/common/model/GuildJoinin.php

@@ -14,4 +14,8 @@ class GuildJoinin extends Model
     // 定义时间戳字段名
     protected $createTime = 'createtime';
 
+    public function user()
+    {
+        return $this->hasOne('User', 'id', 'user_id',[],'LEFT');
+    }
 }