AjaxController.php
1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?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(),'');
}
}
}