瀏覽代碼

讲解设置直播间属性

lizhen_gitee 3 月之前
父節點
當前提交
55ed8c6740
共有 2 個文件被更改,包括 37 次插入0 次删除
  1. 17 0
      addons/shopro/controller/goods/Liveroom.php
  2. 20 0
      application/utils/Service/Tencent/TencentIm.php

+ 17 - 0
addons/shopro/controller/goods/Liveroom.php

@@ -177,6 +177,22 @@ class Liveroom extends Common
         $this->check_auth($room_no,$user['id']);
 
         $goods_id = input('goods_id',0,'intval');
+        $is_top = input('is_top',0,'intval');
+
+        //取消讲解
+        if($is_top == 0){
+            Db::name('live_room_goods')->where('room_no',$room_no)->update(['is_top'=>0]);
+
+            //修改房间属性
+            $top_good[] = [
+                'key' => 'top_good',
+                'value' => json_encode((object)[]),
+            ];
+            $im = new TencentIm();
+            $im->modify_group_attr($room_no,$top_good);
+
+            $this->success('操作成功');
+        }
 
         //直播间商品
         $check = Db::name('live_room_goods')->where('room_no',$room_no)->where('goods_id',$goods_id)->where('status','up')->find();
@@ -228,6 +244,7 @@ class Liveroom extends Common
         $room_no = input('room_no','','trim');
 
         $im = new TencentIm();
+//        $im->delete_group_attr($room_no,'jiangjie');
         $im->get_group_attr($room_no);
         dump($im->getData());
     }

+ 20 - 0
application/utils/Service/Tencent/TencentIm.php

@@ -539,6 +539,26 @@ class TencentIm extends Module
         return $this->success('获取成功', $res);
     }
 
+    /**
+     * 删除群属性
+     * @param int $room_no
+     */
+    public function delete_group_attr( $room_no,$key)
+    {
+        $data     = [
+            'GroupId'   => (string)$room_no,// 群组 ID
+            'GroupAttr' => [[
+                'key' => $key,//属性 key
+            ]],
+        ];
+        $res  = $this->postJson('/v4/group_open_http_svc/delete_group_attr', $data);
+        if (empty($res['ActionStatus']) || $res['ActionStatus'] != 'OK') {
+            return $this->error(!empty($res['ErrorInfo']) ? $res['ErrorInfo'] : 'im error', $res ?? []);
+        }
+
+        return $this->success('获取成功', $res);
+    }
+
     // 下载最近消息记录
     public function get_history($MsgTime,$ChatType = 1)
     {