IndexServer.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: xiaofeng
  5. * Date: 2018/4/24
  6. * Time: 下午3:51
  7. */
  8. namespace frontend\server;
  9. use common\models\House;
  10. use common\models\ListNav;
  11. use common\models\Live;
  12. use common\models\News;
  13. use common\models\PushNews;
  14. use common\models\Vr;
  15. use Yii;
  16. use common\models\CategoryCity;
  17. use common\models\HousesPrice;
  18. use common\models\CategoryHousetype;
  19. use common\models\Characteristic;
  20. use common\models\PushRotation;
  21. use common\models\PushActivity;
  22. use common\models\PushChoice;
  23. use common\models\PushHousesale;
  24. use common\models\CityDetails;
  25. use common\models\PushCity;
  26. use common\models\PushNewscolumn;
  27. use common\models\NewKnowledgelabel;
  28. use yii\helpers\ArrayHelper;
  29. class IndexServer
  30. {
  31. //区域
  32. public function CityList()
  33. {
  34. if (Yii::$app->hostserver->hostId != 0) {
  35. $model = new \common\models\CategoryCity();
  36. $model->pid = Yii::$app->hostserver->hostId;
  37. $model->state = 1;
  38. $rows = $model->getList([]);
  39. } else {
  40. $model = new PushCity();
  41. $rows = $model->Homegetlist();
  42. }
  43. if (!empty($rows)) {
  44. return $rows;
  45. }
  46. }
  47. //价格
  48. public function PriceList()
  49. {
  50. $PriceModel = new HousesPrice();
  51. $PriceList = $PriceModel->getList([], ['price_short', 'price', 'id']);
  52. if ($PriceList != null) {
  53. return $PriceList;
  54. }
  55. }
  56. //户型
  57. public function HouseType()
  58. {
  59. $typeModel = new CategoryHousetype();
  60. $typeList = $typeModel->getList([], ['id', 'huxing_name']);
  61. if ($typeList != null) {
  62. return $typeList;
  63. }
  64. }
  65. //主题
  66. public function Subject()
  67. {
  68. $sub = new Characteristic();
  69. $input['page'] = 1;
  70. $input['limit'] = 15;
  71. $subList = $sub->getList($input, ['id', 'name']);
  72. if ($subList != null) {
  73. return $subList;
  74. }
  75. }
  76. //轮播图
  77. public function Lunbo($limit)
  78. {
  79. $model = new PushRotation();
  80. if (Yii::$app->hostserver->hostId != 0) {
  81. $model->city = Yii::$app->hostserver->hostId;
  82. }
  83. // $rows = $model->HomeGetListP();
  84. $rows = $model->getRoationChart( $limit);
  85. if ($rows != null) {
  86. $url = Yii::$app->params['httpImg']['host'] . Yii::$app->params['httpImg']['push_lb'];
  87. foreach ($rows as &$val) {
  88. $val['img'] = $url . $val['img'];
  89. }
  90. return $rows;
  91. }
  92. }
  93. //热门活动
  94. public function Hotactivity()
  95. {
  96. $model = new PushActivity();
  97. if (Yii::$app->hostserver->hostId != 0) {
  98. $model->city = Yii::$app->hostserver->hostId;
  99. }
  100. $rows = $model->HomeGetList();
  101. if ($rows != null) {
  102. $url = Yii::$app->params['httpImg']['host'] . Yii::$app->params['httpImg']['hot_activity'];
  103. foreach ($rows as &$val) {
  104. $val['img'] = $url . $val['img'];
  105. }
  106. // p($rows);
  107. return $rows;
  108. }
  109. }
  110. //本周精选
  111. public function Choice()
  112. {
  113. $model = new PushChoice();
  114. if (Yii::$app->hostserver->hostId != 0) {
  115. $model->city = Yii::$app->hostserver->hostId;
  116. }
  117. $rows = $model->HomeGetList();
  118. if ($rows != null) {
  119. $url = Yii::$app->params['httpImg']['host'] . Yii::$app->params['httpImg']['choice'];
  120. foreach ($rows as &$val) {
  121. $val['img'] = $url . $val['img'];
  122. }
  123. return $rows;
  124. }
  125. }
  126. public function HotHouse()
  127. {
  128. $model = new PushHousesale();
  129. $model->type = 1;
  130. if (Yii::$app->hostserver->hostId != 0) {
  131. $model->city = Yii::$app->hostserver->hostId;
  132. }
  133. $rows = $model->Homegetlist(4);
  134. if ($rows != null) {
  135. $zhuti = new \frontend\server\HouseServer();
  136. foreach ($rows as &$val) {
  137. $val['characteristic'] = $zhuti->Subject(json_decode($val['characteristic']), 2);
  138. $val['thumb'] = Yii::$app->params['httpImg']['hosts'] . Yii::$app->params['httpImg']['houses'] . $val['thumb'];
  139. }
  140. return $rows;
  141. }
  142. }
  143. public function CityInfo()
  144. {
  145. $model = new \common\models\PushSojourncity();
  146. $rows = $model->Homegetlist(10);
  147. if ($rows != null) {
  148. return $rows;
  149. }
  150. }
  151. /*
  152. *
  153. * */
  154. public function Characteristic()
  155. {
  156. $model = new \common\models\PushCharacteristic();
  157. $rows = $model->Homegetlist();
  158. if (!empty($rows)) {
  159. $url = Yii::$app->params['httpImg']['host'] . Yii::$app->params['httpImg']['characteristic'];
  160. foreach ($rows as &$val) {
  161. $val['img'] = $url . $val['img'];
  162. }
  163. return $rows;
  164. }
  165. }
  166. /*
  167. * 资讯
  168. * */
  169. public function newsColumn()
  170. {
  171. // $query = PushNewscolumn::find();
  172. // $query->select(['pfg_category_news.news_name','pfg_push_newscolumn.id','pfg_push_newscolumn.short','pfg_push_newscolumn.cid']);
  173. // $query->andWhere(['pfg_push_newscolumn.del'=>1]);
  174. // $query->andWhere(['pfg_push_newscolumn.is_show'=>1]);
  175. // $query->leftJoin('pfg_category_news','pfg_push_newscolumn.cid=pfg_category_news.id');
  176. // $query->limit = 3;
  177. // $data = $query->orderBy(['pfg_push_newscolumn.sort'=>SORT_ASC])->asArray()->all();
  178. // if(!empty($data))
  179. // {
  180. //
  181. // $id = array_column($data,'id');
  182. // $new = PushNews::find();
  183. // $new->select(['pfg_push_news.cid','pfg_news.id','pfg_news.subject','pfg_news.short_subject','pfg_news.thumb','pfg_news.open_time']);
  184. // $new->andWhere(['pfg_push_news.del'=>1]);
  185. // $new->andWhere(['pfg_push_news.is_show'=>1]);
  186. // $new->andWhere(['pfg_push_news.type'=>4]);
  187. // $new->andFilterWhere(['pfg_push_news.cid'=>$id]);
  188. // $new->leftJoin('pfg_news','pfg_push_news.nid=pfg_news.id');
  189. //// $new->limit = 10;
  190. // $a = $new->orderBy(['pfg_push_news.sort'=>SORT_ASC])->asArray()->all();
  191. // $arr = [];
  192. // foreach ($a as $val)
  193. // {
  194. // $arr[$val['cid']][] = $val;
  195. // }
  196. //
  197. // foreach ($data as &$val)
  198. // {
  199. // if(isset($arr[$val['id']]))
  200. // {
  201. // $val['data'] = $arr[$val['id']];
  202. // }
  203. //
  204. // }
  205. // return $data;
  206. // }
  207. //2020.7.2改版
  208. $hostId = Yii::$app->hostserver->hostId;
  209. $model = new News();
  210. $data = [];
  211. if ($hostId == 60) {
  212. $data[0] = $model->getNews(1, 2);
  213. $data[1] = $model->getNews(13, 4);
  214. $data[2] = $model->getNews(18, 7);
  215. $data[3] = $model->getNews(14, 6);
  216. $data[4] = $model->getNews(3, 4);
  217. } else {
  218. $data[0] = $model->getNews(14, 2);
  219. $data[1] = $model->getNews(15, 4);
  220. $data[2] = $model->getNews(1, 7);
  221. $data[3] = $model->getNews(13, 6);
  222. $data[4] = $model->getNews(3, 4);
  223. }
  224. return $data;
  225. }
  226. /*
  227. * 价格走势
  228. * */
  229. public function Pricetrend()
  230. {
  231. $model = new \common\models\PushCityprice();
  232. if (Yii::$app->hostserver->hostId != 0) {
  233. $model->city_id = \common\models\CategoryCity::find()->select(['id'])->andWhere(['pid' => Yii::$app->hostserver->hostId])->andWhere(['del' => 1])->column();
  234. }
  235. return $model->Homegetlist(20);
  236. }
  237. /**
  238. * 购房攻略
  239. */
  240. public function Goufang($type)
  241. {
  242. $model = new \common\models\PushNews();
  243. $model->type = $type;
  244. return $model->Homegetlist(8);
  245. }
  246. /**
  247. * 别墅专区
  248. */
  249. public function Villa()
  250. {
  251. $model = new \common\models\House();
  252. $model->del = 1;
  253. if (Yii::$app->hostserver->hostId != 0) {
  254. $model->city = Yii::$app->hostserver->hostId;
  255. }
  256. return $model->getVilla('pfg_house.id,pfg_house.name,pfg_house_detail.address,pfg_house_detail.longitude_latitude,pfg_house_detail.main_units,pfg_house_detail.price_unit,pfg_house.sale_price,pfg_house.thumb,pfg_category_city.city_name', 10);
  257. }
  258. //精选新房
  259. public function RecommendCat()
  260. {
  261. if (Yii::$app->hostserver->hostId == 0) {
  262. $model = new \common\models\PushRecommend();
  263. $model->city = Yii::$app->hostserver->hostId;
  264. // $model->state =1;
  265. return $model->getList(Yii::$app->request->get());
  266. } else {
  267. $model = new \common\models\CategoryCity();
  268. return $model->getSonCity(Yii::$app->hostserver->hostId);
  269. }
  270. }
  271. /**知识库 20181010 eit*/
  272. public function getKnowledgeBase()
  273. {
  274. $model = new NewKnowledgelabel();
  275. $model->pid = 0;
  276. $result = $model->getList([], 'id,pid,name', 2);
  277. $result = ArrayHelper::toArray($result);
  278. foreach ($result as $k => $v) {
  279. $model->pid = $v['id'];
  280. $arr = $model->getList([], 'id,pid,name', 1);
  281. $arr = ArrayHelper::toArray($arr);
  282. $result[$k]['child'] = $arr;
  283. }
  284. return $result;
  285. }
  286. //精选新房 根据地区获取1条地区
  287. public function RecommendCatOne()
  288. {
  289. $model = new \common\models\PushRecommend();
  290. $city = Yii::$app->hostserver->hostId;
  291. return $model->getCatOne($city);
  292. }
  293. public function getHomeHotHouse($limit = null)
  294. {
  295. return House::find()->select(['id', 'name'])->where(['del' => 1, 'is_view' => 1])->limit($limit)->orderBy(['is_push' => SORT_DESC, 'sort' => SORT_DESC, 'create_at' => SORT_DESC])->all();
  296. }
  297. public function getPushCity($limit)
  298. {
  299. $data = (new \common\models\ListNav())->getPcPushCityList(1, $limit);
  300. return $data;
  301. }
  302. public function getPushAerial($limit)
  303. {
  304. $list_id = 11;
  305. $data = (new \common\models\ListHouse())->getIndexPushHouse($list_id, $limit);
  306. foreach ($data as &$val) {
  307. if ($val['video_img']) {
  308. $val['thumb'] = Yii::$app->params['httpImg']['hosts'] . Yii::$app->params['httpImg']['house_video'] . $val['video_img'] . '/same';
  309. } else {
  310. $val['thumb'] = Yii::$app->params['httpImg']['hosts'] . Yii::$app->params['httpImg']['house'] . $val['thumb'] . '/same';
  311. }
  312. }
  313. return $data;
  314. }
  315. //2020.10.21v2改版首页VR全景看房楼盘
  316. public function getVrHouse($limit)
  317. {
  318. $data = (new \common\models\ListHouse())->getIndexPushHouse(10, $limit);
  319. $vrModel = new Vr();
  320. foreach ($data as &$val) {
  321. $row = $vrModel->getListAndVr(['hid' => $val['id']]);
  322. $val['thumb'] = Yii::$app->params['httpImg']['host'] . Yii::$app->params['httpImg']['video'] . $row[0]['img'];
  323. // $val['thumb'] = Yii::$app->params['httpImg']['hosts'] . Yii::$app->params['httpImg']['houses'] . $val['thumb'] . '/same';
  324. }
  325. return $data;
  326. }
  327. //2020.10.25v2改版自动或直播回放
  328. public function getVoluntarilylive($limit)
  329. {
  330. $data = (new Live())->getLiveHouseInfo($limit);
  331. // foreach ($data as &$val) {
  332. // $val['thumb'] = Yii::$app->params['httpImg']['hosts'] . Yii::$app->params['httpImg']['houses'] . $val['thumb'] . '/same';
  333. // }
  334. return $data;
  335. }
  336. //2020.10.25v2改版获取所有地区名称列表
  337. public function getAllCityList()
  338. {
  339. $model = new CategoryCity();
  340. $model->pid = 68;
  341. $model->state = 1;
  342. $data = $model->getList([], ['id', 'city_name']);
  343. return $data;
  344. }
  345. //2020.10.25v2改版获取推送资讯栏目
  346. public function getPushNews($limit)
  347. {
  348. $data = (new ListNav())->getPcListNews(2, $limit);
  349. return $data;
  350. }
  351. //2020.10.25v2改版获取推送热搜楼盘词
  352. public function getPushTitle($list_id, $limit)
  353. {
  354. $data = (new ListNav())->getPcPushTitle($list_id, $limit);
  355. return $data;
  356. }
  357. }