$item['name'], 'room_id' => $item['roomid'], 'cover_img' => $item['cover_img'], 'anchor_name' => $item['anchor_name'], 'live_status' => LiveEnum::getLiveStatus($item['live_status']), 'goods' => count($item['goods']), 'start_time' => date('Y-m-d H:i:s', $item['start_time']), 'end_time' => date('Y-m-d H:i:s', $item['end_time']) ]; } $list = [ 'lists' => $data, 'count' => $result['total'], 'page_no' => $limitOffset, 'page_size' => $limitLength, ]; return $list; } /** * @notes 创建直播间 * @param array $post * @return bool|string * @throws \EasyWeChat\Kernel\Exceptions\HttpException * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException * @throws \EasyWeChat\Kernel\Exceptions\RuntimeException * @throws \Psr\SimpleCache\InvalidArgumentException * @author cjhao * @date 2021/11/22 18:26 */ public function add(array $post) { try { WechatErrorEnum::wechatErrorMessage(); $data = [ 'name' => $post['name'], 'coverImg' => $post['cover_img'], 'startTime' => $post['start_time'], 'endTime' => $post['end_time'], 'anchorName' => $post['anchor_name'], 'anchorWechat' => $post['anchor_wechat'], 'subAnchorWechat' => $post['sub_anchor_wechat'] ?? '', 'createrWechat' => $post['anchor_wechat'], 'shareImg' => $post['share_img'], 'feedsImg' => $post['feeds_img'], 'type' => $post['type'], 'isFeedsPublic' => $post['is_feeds_public'], 'closeLike' => $post['close_like'], 'closeGoods' => $post['close_goods'], 'closeComment' => $post['close_comment'], 'closeReplay' => $post['close_replay'], 'closeShare' => $post['close_share'], 'closeKf' => $post['close_kf'], ]; $config = WeChatConfigService::getMnpConfig(); $app = Factory::miniProgram($config); $result = $app->broadcast->createLiveRoom($data); if (0 != $result['errcode']) { throw new WechatException($result['errmsg'],$result['errcode']); } return true; } catch (\Exception $e) { return $e->getMessage(); } } /** * @notes 删除直播间 * @param int $roomId * @return bool|string * @author cjhao * @date 2021/11/23 10:35 */ public function del(int $roomId) { try { $config = WeChatConfigService::getMnpConfig(); $app = Factory::miniProgram($config); $result = $app->broadcast->deleteLiveRoom(['id'=>$roomId]); if ($result['errcode'] != 0) { throw new WechatException($result['errmsg'],$result['errcode']); } return true; } catch (\Exception $e) { return $e->getMessage(); } } }