Browse Source

派对直播合并,删掉一些没用的

lizhen_gitee 3 years ago
parent
commit
8e5c847dfc
2 changed files with 5 additions and 233 deletions
  1. 5 49
      application/api/controller/Party.php
  2. 0 184
      application/index/controller/Test.php

+ 5 - 49
application/api/controller/Party.php

@@ -25,7 +25,7 @@ class Party extends Common
 
     public function __construct(Request $request = null)
     {
-        $this->roomTypeArr = [1=>"party",2=>"live"];
+        $this->roomTypeArr = [1=>"party",2=>"livebc"];
 
         parent::__construct($request);
     }
@@ -40,26 +40,6 @@ class Party extends Common
         $partyModel = new \app\common\model\Party();
 
         $user_id = $this->auth->id;
-        // 开直播时,判断当前用户是否为主播
-        /*if($room_type == 2) {
-            $anchorInfo = \app\common\model\UserAnchor::where(["user_id"=>$user_id])->find();
-
-            $anchorInfo || $this->error("您还未申请主播!");
-            $anchorInfo->status == 0 && $this->error("您的主播申请信息还未受理,请耐心等待!");
-            $anchorInfo->status == 2 && $this->error("您的主播申请未通过,请重新提交!");
-        }*/
-
-        // 1。实名认证
-        /*$userAuthInfo = \app\common\model\UserAuth::where(["user_id"=>$user_id])->find();
-        if($userAuthInfo) {
-            if($userAuthInfo->status == 0) {
-                $this->error("您的实名认证还在这审核中...,请耐心等待!");
-            } elseif($userAuthInfo->status == 2) {
-                $this->error("您的实名认证审核未通过,请重新审核!");
-            }
-        } else {
-            $this->error("请先申请实名认证!");
-        }*/
 
         //
         if($this->auth->idcard_status == -1){
@@ -72,23 +52,6 @@ class Party extends Common
             $this->error('您的实名认证审核未通过,请重新申请');
         }
 
-
-/*
-        if($room_type == 1) {
-            // 2。开厅申请
-            $authInfo = \app\common\model\GuildApply::where(["user_id"=>$user_id])->find();
-            if($authInfo) {
-                if($authInfo->status == 0) {
-                    $this->error("您的开厅申请还在这审核中...,请耐心等待!");
-                } elseif($authInfo->status == -1) {
-                    $this->error("您的开厅申请审核未通过,请重新审核!");
-                }
-            } else {
-                $this->error("请先申请开厅资质!");
-            }
-        }
-*/
-
         // 判断派对是否存在
         $redis = new Redis();
         $redisconfig = config("redis");
@@ -109,12 +72,9 @@ class Party extends Common
 
             $party_name = $this->auth->username."的房间"; // 派对名称
             $party_logo = "/assets/api/party_logo.png"; // 派对logo
-            $party_type = 0; // 派对类型(情感互动,心动点单 等)
             $party_notice = "请编辑房间公告"; // 派对公告
             $party_notice_detail = "请编辑房间公告内容!"; // 派对公告详情
-            if (!$party_name || !$party_logo || !$party_notice) {
-                $this->error(__('Invalid parameters'));
-            }
+
             $party_ids = $partyModel->column("party_id");
             // 创建派对ID (临时ID四位,派对数不超过8999)
             $party_id = $this->auth->getUinqueId(6,$party_ids);
@@ -128,7 +88,7 @@ class Party extends Common
             $data["party_hot"] = 0;
             $data["party_name"] = $party_name;
             $data["party_logo"] = $party_logo;
-            $data["party_type"] = $party_type;
+            $data["party_type"] = 0; // 派对类型(情感互动,心动点单 等)
             $data["party_notice"] = $party_notice;
             $data["party_notice_detail"] = $party_notice_detail;
             $data["is_online"] = 1;
@@ -140,11 +100,7 @@ class Party extends Common
                 $this->error("派对创建失败,请稍后重试!");
             }
             $data["id"] = $id;
-/*
-            if($room_type == 2) {
-                \app\common\model\User::update(["is_live"=>1],["id"=>$user_id]);
-            }
-*/
+
             $partyInfo = $partyModel->where(["id"=>$id])->find();
             $partyInfo["is_new"] = 1;
 
@@ -1388,7 +1344,7 @@ class Party extends Common
 
 
         if($party_id){
-            $partyInfo = \app\common\model\Party::field("user_id,platRate,guilderRate")->where(["id"=>$party_id])->find();
+            $partyInfo = \app\common\model\Party::field("user_id")->where(["id"=>$party_id])->find();
             if(!$partyInfo){
                 $this->error('不存在的语聊间');
             }

+ 0 - 184
application/index/controller/Test.php

@@ -41,190 +41,6 @@ class Test
         $redis->hDel("livebc_jewel_top3",$user_id);
     }
 
-    /**
-     * 全麦/单独赠送礼物
-     */
-    public function giveGiftToYou() {
-        // 接口防并发
-        if (!$this->apiLimit(1, 1000)) {
-            $this->error(__('Operation frequently'));
-        }
 
-        //
-        $user_ids = $this->request->request("user_id");// 赠送对象
-        $gift_id = $this->request->request("gift_id");// 礼物ID
-        $party_id = $this->request->request("party_id",0);// 派对ID
-        $number = $this->request->request("number");// 赠送数量
-        $room_type = 1; // 房间类型
-        $is_back = 0;// 是否背包赠送: 1=是,0=否
-        if (!$user_ids || !$gift_id || !$number)
-        {
-            $this->error(__('Invalid parameters'));
-        }
-
-        //
-        $user_id_arr = explode(',',$user_ids);
-        $userCount = count($user_id_arr);
-        $userauthid = $this->auth->id;
-
-
-        // 获取礼物信息
-        $giftInfo = Db::name('gift')->where('id',$gift_id)->find();
-        if (!$giftInfo) {$this->error("请选择礼物!");}
-        $giftValue = $giftInfo["value"] * $number;
-        $giftCountValue = $giftInfo["value"] * $number * $userCount;
-
-
-        // 判断当前用户余额
-        $user_gold = model('wallet')->getWallet($userauthid,'gold');
-        if($user_gold < $giftCountValue) {$this->error("您的金币余额不足!");}
-
-
-        if($party_id){
-            $partyInfo = \app\common\model\Party::field("user_id,platRate,guilderRate")->where(["id"=>$party_id])->find();
-            if(!$partyInfo){
-                $this->error('不存在的语聊间');
-            }
-        }
-
-        $returnData = [];
-        Db::startTrans();
-        try {
-            $redis = new Redis();
-            $redisconfig = config("redis");
-            $redis->connect($redisconfig["host"], $redisconfig["port"], 86400 * 31);
-
-            // 获取当天零点
-            $day = date("Ymd");
-            // 获取本周第一天
-            $weekday = $this->firstOfWeek(date("Y-m-d H:i:s"));
-            // 获取本月第一天
-            $monthday = date("Ym01");
-
-            $allVal = 0;
-            $i = 0;
-            foreach($user_id_arr as $user_id) {
-
-                // 添加礼物赠送记录表
-                $data = [];
-                $data["user_id"] = $userauthid;
-                $data["user_to_id"] = $user_id;
-                $data["party_id"] = $party_id;
-                $data["gift_id"] = $gift_id;
-                $data["gift_give_type"] = 2;
-                $data["gift_name"] = $giftInfo["name"];
-                $data["gift_gif_image"] = $giftInfo["image"];
-                $data["number"] = $number;
-                $data["price"] = $giftInfo["value"];
-                $data["value"] = $giftValue;
-
-                $data["createtime"] = time();
-                $log_id = Db::name('gift_user_party')->insertGetId($data);
-                if(!$log_id){
-                    Db::rollback();
-                    $this->error('赠送失败');
-                }
-
-                if($giftValue > 0){
-                    // 扣除当前用户钻石余额
-                    $wallet_rs = model('wallet')->lockChangeAccountRemain($userauthid,'gold',-$giftValue,51,'赠送礼物:'.$giftInfo["name"],'gift_user_party',$log_id);
-                    if($wallet_rs['status'] === false){
-                        Db::rollback();
-                        $this->error($wallet_rs['msg']);
-                    }
-
-
-                    // 添加赠送用户余额
-                    $money_to_gold = config('site.money_to_gold');
-                    $gift_plat_scale = config('site.gift_plat_scale');
-                    $giftmoney = bcdiv($giftValue,$money_to_gold,2);
-                    $money = bcdiv(bcmul($giftmoney,100 - $gift_plat_scale,2),100,2);
-
-                    $wallet_rs = model('wallet')->lockChangeAccountRemain($user_id,'money',$money,52,'获得礼物:'.$giftInfo["name"],'gift_user_party',$log_id);
-                    if($wallet_rs['status'] === false){
-                        Db::rollback();
-                        $this->error($wallet_rs['msg']);
-                    }
-                }
-
-
-                $res6 = true;
-
-                if ($res6) {
-                    $i++;
-                    if($party_id > 0) {
-                        // 添加redis记录做财富排行榜日榜用
-                        $redis->zIncrBy($this->roomTypeArr[$room_type] . "_jewel_get_" . $party_id . ":" . $day . "d", $giftValue, $user_id);
-                        // 添加redis记录做财富排行榜周榜用
-                        $redis->zIncrBy($this->roomTypeArr[$room_type] . "_jewel_get_" . $party_id . ":" . $weekday . "w", $giftValue, $user_id);
-                        // 添加redis记录做财富排行榜月榜用
-                        $redis->zIncrBy($this->roomTypeArr[$room_type] . "_jewel_get_" . $party_id . ":" . $monthday . "m", $giftValue, $user_id);
-                        // 添加redis记录做贡献排行榜日榜用
-                        $redis->zIncrBy($this->roomTypeArr[$room_type] . "_jewel_to_" . $party_id . ":" . $day . "d", $giftValue, $userauthid);
-                        // 添加redis记录做贡献排行榜周榜用
-                        $redis->zIncrBy($this->roomTypeArr[$room_type] . "_jewel_to_" . $party_id . ":" . $weekday . "w", $giftValue, $userauthid);
-                        // 添加redis记录做贡献排行榜月榜用
-                        $redis->zIncrBy($this->roomTypeArr[$room_type] . "_jewel_to_" . $party_id . ":" . $monthday . "m", $giftValue, $userauthid);
-
-                        // tcp 更新用户魅力值
-                        $this->updateUserCharm($party_id, $user_id, $giftValue);
-
-
-                    }
-
-                    $allVal = $allVal + $giftValue;
-
-                }
-            }
-
-            // 获取用户魅力值
-            $users = $redis->zRange("hourCharm_".$party_id,0,-1,true);
-            $u = [];
-            if($users) {
-                foreach($users as $k => $v) $u[] = [
-                    "user_id"=>$k,
-                    "charm"=>$this->changeW($v)
-                ];
-            }
-            $userCharm = $u;
-            // tcp 更新房间热度
-            $partyHot = $this->updatePartyHot($party_id, $allVal, $room_type);
-
-            // 如果是派对,则添加派对热度值记录做榜单统计
-            if($room_type == 1) {
-                $data = [];
-                $data["party_id"] = $party_id;
-                $data["hot"] = $allVal;
-                $data["createtime"] = time();
-                \app\common\model\PartyHot::insert($data);
-            }
-
-
-            // tcp 获取房间用户周前三名
-            $partyUserTop = $this->getPartyUserTop($party_id, $room_type);
-
-            if($i == $userCount) {
-                $returnData["userCharm"] = $userCharm;
-                $returnData["partyHot"] = $this->changeW($partyHot);
-                $returnData["partyUserTop"] = $partyUserTop;
-                $returnData["image"] = $giftInfo["image"];
-                $returnData["gif_image"] = $giftInfo["special"];
-
-                Db::commit();
-                $this->success("赠送成功!",$returnData);
-            } else {
-                $this->success("赠送失败!");
-            }
-        } catch (ValidateException $e) {
-            Db::rollback();
-            $this->error($e->getMessage());
-        } catch (PDOException $e) {
-            Db::rollback();
-            $this->error($e->getMessage());
-        } catch (Exception $e) {
-            Db::rollback();
-            $this->error($e->getMessage());
-        }
-    }
 
 }