25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

110 lines
3.3 KiB

  1. <?php
  2. namespace common\models;
  3. use yii\mongodb\ActiveRecord;
  4. class MHotel extends ActiveRecord {
  5. public static function collectionName()
  6. {
  7. return ['zzcx','hotel'];
  8. }
  9. public function attributes()
  10. {
  11. return [
  12. '_id',
  13. 'hotel_id',
  14. 'hotel_name',
  15. 'star_level',
  16. 'area_id',
  17. 'area_name',
  18. 'run_date',
  19. 'is_promotion',
  20. 'recommend_level',
  21. 'sale_label',
  22. 'hotel_label',
  23. 'hotel_image',
  24. 'business_area',
  25. 'brand',
  26. 'hotel_type',
  27. 'room_info',
  28. 'update_time',
  29. ];
  30. }
  31. public function rules()
  32. {
  33. return parent::rules(); // TODO: Change the autogenerated stub
  34. }
  35. /**
  36. * Function Description:获取酒店列表
  37. * Function Name: getHotelList
  38. * @param $params
  39. * @param $hotel_select_list
  40. *
  41. * @return array
  42. *
  43. * @author 娄梦宁
  44. */
  45. public function getHotelList($params,$hotel_select_list)
  46. {
  47. //获取数据有效性标志
  48. $mBaseUnique=new MBaseUnique();
  49. $time_stamp=$mBaseUnique::find()->select(['time_stamp'])->from('base_unique')->where(['type'=>1])->asArray()->one();
  50. $where=['and',
  51. ['=','time_stamp',$time_stamp['time_stamp']],
  52. ['=','area_id',$params['area_id']],
  53. ['>=','run_date',$params['start_date']],
  54. ['<','run_date',$params['end_date']],
  55. ];
  56. if($params['search_more']!=''){//名称,商圈,品牌
  57. $where[]=[
  58. 'or',
  59. ['like','hotel_name',$params['search_more']],
  60. ['like','business_area',$params['search_more']],
  61. ['like','brand',$params['search_more']],
  62. ];
  63. }
  64. if($params['hotel_label']!=''){//设施服务
  65. #处理拼接的标签,取出单标签like匹配字段
  66. $labels=explode(',',$params['hotel_label']);
  67. $label_where=['and'];
  68. foreach($labels as $val){
  69. $tmp_hotel_label=$hotel_select_list[3]['list'][$val]['name'];
  70. $label_where[]=['like','hotel_label',$tmp_hotel_label];
  71. }
  72. $where[]=$label_where;
  73. }
  74. if($params['brand']!='0'){//品牌
  75. $brand=explode(',',$params['brand']);
  76. $brand_where=['or'];
  77. foreach($brand as $val){
  78. $tmp_hotel_brand=$hotel_select_list[2]['list'][$val]['name'];
  79. $brand_where[]=['like','brand',$tmp_hotel_brand];
  80. }
  81. $where[]=$brand_where;
  82. }
  83. if($params['star_type']!='0')
  84. {#星级及类型
  85. if($params['star_type']=='1' || $params['star_type']=='2')
  86. {//星级
  87. if($params['star_type']=='1'){
  88. $where[]=['=','star_level','39'];
  89. }else{
  90. $where[]=['=','star_level','38'];
  91. }
  92. }else{//酒店类型
  93. $where[]=['=','hotel_type',$hotel_select_list['1']['list'][$params['star_type']]['name']];
  94. }
  95. }
  96. $result=self::find()
  97. ->from('hotel')
  98. ->where($where)
  99. ->asArray()
  100. ->all();
  101. return $result;
  102. }
  103. }