AjaxController.php 1.36 KB
<?php
namespace backend\controllers;

use Yii;
use common\components\cachekey\Parser;
use common\config\Params;
use common\models\Video;
/**
 * Ajax controller
 */
class AjaxController extends BaseController
{

    /**
     * 监听直播房间商品推送记录
     */
    public function actionPushgoodslog()
    {
        $log = Yii::$app->redisIm->rpop(Yii::$app->params['cache_prefix'].'push_goods_log');
        $this->renderJson(Yii::$app->params['success_code'],'',(string)$log);
    }
    
    /**
     * 将房间结束直播
     */
    public function actionStopliving()
    {
        $room_id = Yii::$app->request->get('room_id');

        /*//更新房间主表直播状态
        $living_status = Params::LIVE_END;
        $result = Yii::$app->db->createCommand()
            ->update('{{%room}}', ['living' => $living_status,'update_time'=>time()], ['room_id' => $room_id])
            ->execute();*/
        try {
            $model = new Video();
            $result = $model->setVideoStop($room_id);
            if($result){
                $this->renderJson(Yii::$app->params['success_code'],'结束成功',$room_id);
            }else{
                $this->renderJson(Yii::$app->params['failed_code'],'结束失败');
            }
        } catch (\Exception $e){
            $this->renderJson(Yii::$app->params['failed_code'],$e->getMessage(),'');
        }
    }
}