ContrastLabel.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: xiaofeng
  5. * Date: 2018/7/30
  6. * Time: 下午3:18
  7. * 对比楼盘需要转化的标签
  8. *
  9. */
  10. namespace backend\synchouse;
  11. use Yii;
  12. class ContrastLabel{
  13. //楼盘特色主题
  14. public function HouseCharacteristic($input)
  15. {
  16. if(!isset($input) || empty($input)) return false;
  17. $query = \common\models\Characteristic::find()->andWhere(['del'=>1]);
  18. if (is_string($input)) {
  19. $query->andWhere(['id' => json_decode($input, true)]);
  20. }
  21. if(is_array($input))
  22. {
  23. $query->andWhere(['name' => $input]);
  24. }
  25. $res = $query->asArray()->all();
  26. if(!empty($res))
  27. {
  28. return array_column($res,'name','id');
  29. }
  30. }
  31. //楼盘建筑类别architecture_type 2 楼盘物业类型type 1 楼盘标签 PropertyTag 3
  32. public function HouseAlllabel($input,$type)
  33. {
  34. if (!isset($input)) return false;
  35. $query = \common\models\CategoryLabel::find()->andWhere(['del' => 1]);
  36. if (is_string($input)) {
  37. $query->andWhere(['id' => json_decode($input, true)]);
  38. }
  39. if(is_array($input))
  40. {
  41. $query->andWhere(['name' => $input]);
  42. }
  43. $res = $query->andFilterWhere(['type'=>$type])->asArray()->all();
  44. if(!empty($res))
  45. {
  46. return array_column($res,'name','id');
  47. }
  48. }
  49. //热门楼盘
  50. public function HouseHot($hot)
  51. {
  52. //是否热门楼盘
  53. $hotArr = [1=>'非热门',2=>'非热门'];
  54. if(!isset($hot) || empty($hot)) return false;
  55. if(is_numeric($hot))
  56. {
  57. return $hotArr[$hot];
  58. }
  59. else
  60. {
  61. return array_flip($hotArr)[$hot];
  62. }
  63. }
  64. //主推楼盘
  65. public function HouseisPush($isPush)
  66. {
  67. //是否热门楼盘
  68. $is_pushArr = [1=>'否',2=>'是'];
  69. if(!isset($isPush) || empty($isPush)) return false;
  70. if(is_numeric($isPush))
  71. {
  72. return $is_pushArr[$isPush];
  73. }
  74. else
  75. {
  76. return array_flip($is_pushArr)[$isPush];
  77. }
  78. }
  79. //装修状况
  80. public function HouseFit($fit)
  81. {
  82. if(isset(Yii::$app->params['Housefit']))
  83. {
  84. $fitArr = Yii::$app->params['Housefit'];
  85. if(is_numeric($fit))
  86. {
  87. return $fitArr[$fit];
  88. }
  89. else
  90. {
  91. return array_flip($fitArr)[$fit];
  92. }
  93. }
  94. }
  95. //楼盘状态
  96. public function HouseState($state)
  97. {
  98. if(isset(Yii::$app->params['HouseSalesStatus']))
  99. {
  100. $stateArr = Yii::$app->params['HouseSalesStatus'];
  101. if(is_numeric($state))
  102. {
  103. return $stateArr[$state];
  104. }
  105. else
  106. {
  107. return array_flip($stateArr)[$state];
  108. }
  109. }
  110. }
  111. //区域
  112. public function HouseCity($city)
  113. {
  114. if(!isset($city) || empty($city)) return false;
  115. $query = \common\models\CategoryCity::find()->andWhere(['del'=>1]);
  116. if(is_numeric($city))
  117. {
  118. $query->andWhere(['id'=>$city]);
  119. }
  120. else
  121. {
  122. $query->andWhere(['city_name'=>$city]);
  123. }
  124. $res = $query->one();
  125. if(!empty($res['id']))
  126. {
  127. return $res;
  128. }
  129. }
  130. //数组处理
  131. public function addArrJson($arr)
  132. {
  133. if(!empty($arr) && is_array($arr))
  134. {
  135. return '["'.implode('","', array_values(array_flip($arr))).'"]';
  136. }
  137. }
  138. }