PushFreshcityhouse.php 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: xiaofeng
  5. * Date: 2018/5/21
  6. * Time: 下午5:18
  7. */
  8. namespace common\models;
  9. class PushFreshcityhouse extends Common
  10. {
  11. public function rules()
  12. {
  13. return [
  14. ['city_id','number','message'=>'请输入正确的区域信息'],
  15. ['hid','number','message'=>'请输入正确的楼盘信息'],
  16. ['sort','number','message'=>'排序只能是数字'],
  17. ['sort','number','max'=>10000],
  18. ];
  19. }
  20. public function attributeLabels()
  21. {
  22. return [
  23. 'city_id'=>'区域',
  24. ];
  25. }
  26. public function Authenticator($input)
  27. {
  28. $this->load($input,'');
  29. if(!$this->validate()) return $this->errors;
  30. return $this;
  31. }
  32. public function FindById($id)
  33. {
  34. return self::findOne($id);
  35. }
  36. public function getList($input)
  37. {
  38. $query = self::find();
  39. $query->select(['pfg_house.name','pfg_push_freshcityhouse.is_show','pfg_push_freshcityhouse.create_at','pfg_push_freshcityhouse.sort','pfg_push_freshcityhouse.id']);
  40. $query->andWhere(['pfg_push_freshcityhouse.del'=>$this->setDel]);
  41. // if(!empty($input['city_name']))
  42. // {
  43. // $query->andWhere(['like','pfg_category_city.city_name',$input['city_name']]);
  44. // }
  45. if(!empty($input['city_id']))
  46. {
  47. $query->andWhere(['pfg_push_freshcityhouse.city_id'=>$input['city_id']]);
  48. }
  49. $query->leftJoin('pfg_house','pfg_push_freshcityhouse.hid=pfg_house.id');
  50. if(!empty($input['page']))
  51. {
  52. $query->limit = $input['limit'];
  53. $query->offset = ($input['page']-1 )* $input['limit'];
  54. }
  55. return $query->orderBy(['pfg_push_freshcityhouse.create_at'=>SORT_DESC])->asArray()->all();
  56. }
  57. public function WhereColumn($query)
  58. {
  59. }
  60. public function Total()
  61. {
  62. $query = self::find();
  63. $query->andWhere(['pfg_push_freshcityhouse.del'=>$this->setDel]);
  64. $query->andWhere(['pfg_push_freshcityhouse.city_id'=>$this->city_id]);
  65. $query->leftJoin('pfg_house','pfg_push_freshcityhouse.hid=pfg_house.id');
  66. return $query->count();
  67. }
  68. public function Homegetlist()
  69. {
  70. $query = self::find();
  71. $query->select(['pfg_house.id','pfg_category_city.id as cid','pfg_house.name','pfg_category_city.city_name','pfg_house.sale_price','pfg_house_detail.price_unit','pfg_house.thumb']);
  72. $query->andWhere(['pfg_push_freshcityhouse.del'=>$this->setDel]);
  73. $query->andWhere(['pfg_push_freshcityhouse.city_id'=>$this->city_id]);
  74. $query->andWhere(['pfg_push_freshcityhouse.is_show'=>1]);
  75. $query->leftJoin('pfg_house','pfg_push_freshcityhouse.hid=pfg_house.id');
  76. $query->leftJoin('pfg_category_city','pfg_push_freshcityhouse.city_id=pfg_category_city.id');
  77. $query->leftJoin('pfg_house_detail','pfg_house.id=pfg_house_detail.hid');
  78. $query->orderBy(['pfg_push_freshcityhouse.sort'=>SORT_ASC]);
  79. $query->limit = 3;
  80. return $query->asArray()->all();
  81. }
  82. }