|
- <?php
- require_once __DIR__ . '/../HotelLib.php';
-
- /**
- * Created by PhpStorm.
- * User: luocj
- * Date: 2016/9/28
- * Time: 14:34
- */
- class getChooseProduct extends HotelLib
- {
- function getProductList($key_word, $room_name, $begin, $page_size)
- {
- /* $sql = "select a.hotel_id as hotel_id,a.room_name,a.parent_room_type,a.room_type,b.earliest_checkin_time,b.hotel_name from
- opera_hotel_room a left join opera_hotel b on a.hotel_id = b.hotel_id where b.cancel_flag = 0
- and b.hotel_name like '%$key_word%' and instr(b.room_type_sale,a.parent_room_type) > 0 order by a.hotel_id, a.update_time DESC limit $begin,$page_size";*/
- $sql = "select a.hotel_id as hotel_id,c.all_count as all_count,a.room_name,a.parent_room_type,a.room_type,b.earliest_checkin_time,b.hotel_name,a.is_onsale,d.supplier_name from opera_hotel_room a left join opera_hotel b on a.hotel_id = b.hotel_id
- LEFT JOIN base_supplier d on b.supplier_id=d.ID
- left join (select parent_prod_id,prod_id,count(1) as all_count from order_main a where a.ORDER_PROD_TYPE = 26 and cancel_flag= 0 and DATE_SUB(CURDATE(), INTERVAL 30 DAY) <= date(run_date) group by parent_prod_id,prod_id) c on a.HOTEL_ID=c.parent_prod_id and a.ROOM_TYPE = c.prod_id
- where a.cancel_flag=0 and b.cancel_flag = 0 and b.hotel_name like '%$key_word%'and a.room_name like '%$room_name%' and a.is_onsale=1 and instr(b.room_type_sale,a.parent_room_type) > 0 order by a.hotel_id,all_count desc limit $begin,$page_size";
- $sqlcount = "select count(1) as count from opera_hotel_room a left join opera_hotel b on a.hotel_id = b.hotel_id
- left join (select parent_prod_id,prod_id,count(1) as all_count from order_main a where a.ORDER_PROD_TYPE = 26 and cancel_flag= 0 and DATE_SUB(CURDATE(), INTERVAL 30 DAY) <= date(run_date) group by parent_prod_id,prod_id) c on a.HOTEL_ID=c.parent_prod_id and a.ROOM_TYPE = c.prod_id
- where a.cancel_flag=0 and b.cancel_flag = 0 and b.hotel_name like '%$key_word%' and a.room_name like '%$room_name%' and a.is_onsale=1 and instr(b.room_type_sale,a.parent_room_type) > 0 order by a.hotel_id,c.all_count desc ";
- $rowset = $this->DBTool->queryBySql($sql);
- $rowsetcount = $this->DBTool->queryBySql($sqlcount);
- $data = array();
- $data['code'] = $rowset['code'];
- $data['info'] = $rowset['info'];
- $total = $rowsetcount['rowset'][0]['count'];
- $total_page = ceil($total / $page_size);
- $data['total'] = $total;
- $data['total_page'] = (string)$total_page;
- $data['product_list'] = $rowset['rowset'];
- return $data;
- }
- }
- //$ChooseProduct = new getChooseProduct();
- //$data =$ChooseProduct ->getProductList('',1,5);
- //echo json_encode($data);
- //print_r($rowsetcount);
|