HomeController.php 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <?php
  2. namespace mobile\modules\live\controllers;
  3. use common\Helps\Time;
  4. use common\models\CategoryCity;
  5. use common\models\LiveHttprecord;
  6. use common\models\Sendcoderecord;
  7. use mobile\modules\live\base\BaseController;
  8. use Yii;
  9. use mobile\base\Help;
  10. use common\models\Live;
  11. use common\models\HouseType;
  12. use common\models\House;
  13. class HomeController extends BaseController
  14. {
  15. public $enableCsrfValidation = false;
  16. //楼盘直播评论---增加
  17. public function actionAddliveremark()
  18. {
  19. $input = Yii::$app->request->post();
  20. }
  21. public function actionGetlive()
  22. {
  23. $input = Yii::$app->request->get();
  24. if (!empty($input['city'])) {
  25. $cmodel = new \common\models\CategoryCity();
  26. $input['city'] = array_column($cmodel->GetAllSon($input['city']), 'id');
  27. }
  28. $lmodel = new Live();
  29. $data = $lmodel->showList($input);
  30. // p($data);die;
  31. if (!empty($data)) {
  32. foreach ($data as &$val) {
  33. $val['pid'] = CategoryCity::find()->select(['pid'])->andWhere(['del' => 1, 'id' => $val['city']])->asArray()->one()['pid'];
  34. if (!empty($val['pid'])) $val['house']['f'] = CategoryCity::find()->select(['id', 'city_name'])->andWhere(['del' => 1, 'id' => $val['pid']])->asArray()->one();
  35. $val['state'] = Time::getLiveState($val['video_url'], $val['time']);
  36. $house = House::findOne($val['hid']);
  37. if (!empty($house['area'])) {
  38. $val['swt'] = $house['area'];
  39. }else{
  40. $val['swt'] = $house['city'];
  41. }
  42. }
  43. return Help::JsonCode(Help::SUCCESS, '成功', $data);
  44. }
  45. return Help::JsonCode(Help::ERROR, '暂无数据');
  46. }
  47. public function actionDetail()
  48. {
  49. //获取模块内容
  50. $module = Yii::$app->hostserver->module;
  51. $input = Yii::$app->request->get();
  52. $model = new Live();
  53. // $htmodel = new HouseType();
  54. $res = $model::findOne($input['id']);
  55. if (empty($res)) $this->goBack('/live/');
  56. //直播状态
  57. $state = Time::getLiveState($res['video_url'], $res['time']);
  58. $typeGroup = array_column($res->houseInfo->houseTypesGroup, 'houseTypeName');
  59. // 去户型分组第一条数据的内容
  60. // $housetype = $htmodel::find()->andWhere(['hid'=>$res->hid,'type_id'=>$typeGroup[0]['id'],'del'=>1,'state'=>1])->asArray()->all();
  61. // if(!empty($housetype)){
  62. // array_walk($housetype,function(&$val){
  63. // $val['img'] = Yii::$app->params['httpImg']['hosts'] . Yii::$app->params['httpImg']['housetypes'] . $val['img'] . Yii::$app->params['pfgwatermark'];
  64. // });
  65. // }
  66. //推送直播--随机同一区域其他楼盘直播
  67. $pushLive = $model->getLiveBySameArea($res->city, $res->id);
  68. //记录浏览记录
  69. $server = new \common\api\HttpServer();
  70. $record = new LiveHttprecord();
  71. $record->Add($ip = Yii::$app->request->userIP, $vid = $input['id'], $url = $server->GetCurUrl());
  72. return $this->render($this->action->id, [
  73. 'module' => $module['module'],
  74. 'Data' => $res,
  75. 'pushLive' => $pushLive,
  76. 'info' => $res->houseInfo->housedetail->info,
  77. 'typeGroup' => $typeGroup,
  78. 'state' => $state
  79. // 'housetype'=>$housetype,
  80. ]);
  81. }
  82. public function actionRequesthousetype()
  83. {
  84. //获取模块内容
  85. $module = Yii::$app->hostserver->module;
  86. $input = Yii::$app->request->get();
  87. $htmodel = new HouseType();
  88. // 去户型分组第一条数据的内容
  89. $housetype = $htmodel::find()->andWhere(['hid' => $input['id'], 'type_id' => $input['value'], 'del' => 1, 'state' => 1])->asArray()->all();
  90. if (!empty($housetype)) {
  91. array_walk($housetype, function (&$val) {
  92. $val['img'] = Yii::$app->params['httpImg']['hosts'] . Yii::$app->params['httpImg']['housetypes'] . $val['img'] . Yii::$app->params['pfgwatermark'];
  93. });
  94. }
  95. if (!empty($housetype)) return Help::JsonCode(Help::SUCCESS, '成功', $housetype);
  96. return Help::JsonCode(Help::ERROR, '暂无数据');
  97. }
  98. public function actionSendcode()
  99. {
  100. $input = Yii::$app->request->post();
  101. $input['purpose'] = '视频播放验证';
  102. $smsServer = new \mobile\server\SendCode();
  103. return $smsServer->send($input);
  104. }
  105. public function actionCheckcode()
  106. {
  107. $input = Yii::$app->request->post();
  108. $session = Yii::$app->session;
  109. $skey = 'live_' . $input['mobile'];
  110. if (empty($session[$skey])) {
  111. return Help::JsonCode(Help::ERROR, '请输入正确手机号');
  112. }
  113. //验证码有效期5分钟
  114. if ($session[$skey]['expire_time'] < time()) {
  115. return Help::JsonCode(Help::ERROR, '验证码已失效');
  116. }
  117. if ($input['code'] != $session[$skey]['code']) {
  118. return Help::JsonCode(Help::ERROR, '验证码不正确');
  119. }
  120. Yii::$app->session->set('adopt', $input['mobile']);
  121. if (!empty(Yii::$app->session['adopt']) && !empty(Yii::$app->session[$skey])) {
  122. $record = Sendcoderecord::find()->andWhere(['mobilephone' => $input['mobile'], 'code' => $session[$skey]['code']])->one();
  123. $record->status = 2;
  124. $record->save();
  125. }
  126. return Help::JsonCode(Help::SUCCESS, '验证通过');//验证通过继续播放视频
  127. }
  128. }