TimeLimitsGroupServer.php 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <?php
  2. namespace wechat\server;
  3. use common\models\PushmTimelimitsgroup;
  4. use Yii;
  5. class TimeLimitsGroupServer{
  6. public function GroupHouselist($input)
  7. {
  8. $query = new PushmTimelimitsgroup();
  9. $data = $query->Homegetlist($input);
  10. if($data != null) {
  11. $characteristic = new \common\models\Characteristic();
  12. $charList = $characteristic->getList([]);
  13. $characteristicId = array_column($charList, 'name', 'id');
  14. $chara = array_column($data, 'characteristic', 'id');
  15. $charaArrs = [];
  16. //处理特色主题
  17. foreach ($chara as $key => $val) {
  18. $arr = json_decode($val, true);
  19. if (is_array($arr) && !empty($arr)) {
  20. foreach ($arr as $k => $v) {
  21. if (isset($characteristicId[$v])) {
  22. $charaArrs[$key][$k] = $characteristicId[$v];
  23. }
  24. }
  25. }
  26. }
  27. $Tel = new \common\models\CategoryTelCity();
  28. $telRow = $Tel->QgetAll();
  29. $cityTel = [];
  30. foreach ($telRow as &$v) {
  31. $cityTel[$v['cid']] = explode(',', $v['tel']);
  32. }
  33. $randArr = [];
  34. foreach ($data as &$val) {
  35. $val['thumb'] = Yii::$app->params['httpImg']['hosts'].Yii::$app->params['httpImg']['houses'].$val['thumb'];
  36. if (isset($charaArrs[$val['id']])) {
  37. //随机选择3个特色主题
  38. if (count($charaArrs[$val['id']]) > 3) {
  39. $ranChar = array_rand($charaArrs[$val['id']], 3);
  40. $randArr[] = $charaArrs[$val['id']][$ranChar[0]];
  41. $randArr[] = $charaArrs[$val['id']][$ranChar[1]];
  42. $randArr[] = $charaArrs[$val['id']][$ranChar[2]];
  43. $val['characteristic'] = $randArr;
  44. $randArr = [];
  45. } else {
  46. $val['characteristic'] = $charaArrs[$val['id']];
  47. }
  48. }
  49. if (isset($cityTel[$val['city']])) {
  50. $rand = array_rand($cityTel[$val['city']], 1);
  51. $val['citytel'] = $cityTel[$val['city']][$rand];
  52. } else {
  53. $val['citytel'] = Yii::$app->params['default_dialtel'];
  54. }
  55. }
  56. return ['data'=>$data];
  57. }
  58. }
  59. public function Details()
  60. {
  61. $input = Yii::$app->request->get();
  62. if(is_numeric($input['hid']))
  63. {
  64. $arr = [];
  65. //所有信息,后期优化显示字段
  66. $model = new House();
  67. $model->id = $input['hid'];
  68. $select = ['pfg_house.*','pfg_house_detail.*','pfg_category_city.city_name'];
  69. $arr['house'] = $model->Qdetails($select);
  70. if(empty($arr['house'])) return false;
  71. //楼盘点击量
  72. $click = new \common\api\HouseServer();
  73. $click->HouseClick($input['hid']);
  74. if($arr['house'] != null)
  75. {
  76. //特色主题
  77. $sub = new IndexServer();
  78. $arr['characteristic'] = $sub->Subject(json_decode($arr['house']['characteristic']),3);
  79. //楼盘相册
  80. $queryAlbum = new HouseAlbum();
  81. $queryAlbum->hid = $input['hid'];
  82. $arr['albumCount'] = $queryAlbum->Total();
  83. //楼盘户型
  84. $queryType = new \common\models\HouseType();
  85. $queryType->hid = $input['hid'];
  86. $arr['type'] = $queryType->MgetList(3,['area','title','img','indoor_info']);
  87. //电话
  88. $arr['house']['tel'] = $sub->RandTel( $arr['house']['city']);
  89. //预售证书
  90. $certificate = new \common\models\HousePermit();
  91. $certificate->hid = $input['hid'];
  92. $arr['certificate'] = $certificate->FindNewest();
  93. //楼盘状态
  94. $arr['house']['state'] =Yii::$app->params['HouseSalesStatus'][$arr['house']['state']];
  95. //新闻
  96. $arr['news'] = $this->NewsDynamic($input);
  97. }
  98. return $arr;
  99. }
  100. }
  101. //楼盘详情页数据
  102. public function ParamsDetails()
  103. {
  104. $input = Yii::$app->request->get();
  105. if(is_numeric($input['hid']))
  106. {
  107. $result = [];
  108. $model = new House();
  109. $model->id = $input['hid'];
  110. $result['house'] = $model->HousesAll();
  111. $sub = new IndexServer();
  112. $result['house']['characteristic'] = $sub->Subject(json_decode($result['house']['characteristic']),3);
  113. $result['house']['tel'] = $sub->RandTel($result['house']['city']);
  114. $result['house']['architecture_type'] = $this->ArchitectureType(json_decode($result['house']['architecture_type']));
  115. //预售证号
  116. $zheng = new HousePermit();
  117. $result['house']['zhengshu'] =$zheng->getList($input);
  118. return $result;
  119. }
  120. }
  121. /*
  122. * 建筑类别
  123. * */
  124. public function ArchitectureType($id)
  125. {
  126. if(!empty($id))
  127. {
  128. $model = new CategoryLabel();
  129. $model->id = $id;
  130. $model->type = 2;
  131. $rows = $model->getList([],['name']);
  132. if(!empty($rows))
  133. {
  134. return array_column($rows,'name');
  135. }
  136. }
  137. return [];
  138. }
  139. }