123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- <?php
- /**
- * Created by PhpStorm.
- * User: xiaofeng
- * Date: 2018/7/30
- * Time: 下午3:18
- * 对比楼盘需要转化的标签
- *
- */
- namespace backend\synchouse;
- use Yii;
- class ContrastLabel{
- //楼盘特色主题
- public function HouseCharacteristic($input)
- {
- if(!isset($input) || empty($input)) return false;
- $query = \common\models\Characteristic::find()->andWhere(['del'=>1]);
- if (is_string($input)) {
- $query->andWhere(['id' => json_decode($input, true)]);
- }
- if(is_array($input))
- {
- $query->andWhere(['name' => $input]);
- }
- $res = $query->asArray()->all();
- if(!empty($res))
- {
- return array_column($res,'name','id');
- }
- }
- //楼盘建筑类别architecture_type 2 楼盘物业类型type 1 楼盘标签 PropertyTag 3
- public function HouseAlllabel($input,$type)
- {
- if (!isset($input)) return false;
- $query = \common\models\CategoryLabel::find()->andWhere(['del' => 1]);
- if (is_string($input)) {
- $query->andWhere(['id' => json_decode($input, true)]);
- }
- if(is_array($input))
- {
- $query->andWhere(['name' => $input]);
- }
- $res = $query->andFilterWhere(['type'=>$type])->asArray()->all();
- if(!empty($res))
- {
- return array_column($res,'name','id');
- }
- }
- //热门楼盘
- public function HouseHot($hot)
- {
- //是否热门楼盘
- $hotArr = [1=>'非热门',2=>'非热门'];
- if(!isset($hot) || empty($hot)) return false;
- if(is_numeric($hot))
- {
- return $hotArr[$hot];
- }
- else
- {
- return array_flip($hotArr)[$hot];
- }
- }
- //主推楼盘
- public function HouseisPush($isPush)
- {
- //是否热门楼盘
- $is_pushArr = [1=>'否',2=>'是'];
- if(!isset($isPush) || empty($isPush)) return false;
- if(is_numeric($isPush))
- {
- return $is_pushArr[$isPush];
- }
- else
- {
- return array_flip($is_pushArr)[$isPush];
- }
- }
- //装修状况
- public function HouseFit($fit)
- {
- if(isset(Yii::$app->params['Housefit']))
- {
- $fitArr = Yii::$app->params['Housefit'];
- if(is_numeric($fit))
- {
- return $fitArr[$fit];
- }
- else
- {
- return array_flip($fitArr)[$fit];
- }
- }
- }
- //楼盘状态
- public function HouseState($state)
- {
- if(isset(Yii::$app->params['HouseSalesStatus']))
- {
- $stateArr = Yii::$app->params['HouseSalesStatus'];
- if(is_numeric($state))
- {
- return $stateArr[$state];
- }
- else
- {
- return array_flip($stateArr)[$state];
- }
- }
- }
- //区域
- public function HouseCity($city)
- {
- if(!isset($city) || empty($city)) return false;
- $query = \common\models\CategoryCity::find()->andWhere(['del'=>1]);
- if(is_numeric($city))
- {
- $query->andWhere(['id'=>$city]);
- }
- else
- {
- $query->andWhere(['city_name'=>$city]);
- }
- $res = $query->one();
- if(!empty($res['id']))
- {
- return $res;
- }
- }
- //数组处理
- public function addArrJson($arr)
- {
- if(!empty($arr) && is_array($arr))
- {
- return '["'.implode('","', array_values(array_flip($arr))).'"]';
- }
- }
- }
|