You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ChooseProduct.class.php 2.8 KiB

3 years ago
12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. require_once __DIR__ . '/../HotelLib.php';
  3. /**
  4. * Created by PhpStorm.
  5. * User: luocj
  6. * Date: 2016/9/28
  7. * Time: 14:34
  8. */
  9. class getChooseProduct extends HotelLib
  10. {
  11. function getProductList($key_word, $room_name, $begin, $page_size)
  12. {
  13. /* $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
  14. opera_hotel_room a left join opera_hotel b on a.hotel_id = b.hotel_id where b.cancel_flag = 0
  15. 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";*/
  16. $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
  17. LEFT JOIN base_supplier d on b.supplier_id=d.ID
  18. 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
  19. 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";
  20. $sqlcount = "select count(1) as count from opera_hotel_room a left join opera_hotel b on a.hotel_id = b.hotel_id
  21. 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
  22. 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 ";
  23. $rowset = $this->DBTool->queryBySql($sql);
  24. $rowsetcount = $this->DBTool->queryBySql($sqlcount);
  25. $data = array();
  26. $data['code'] = $rowset['code'];
  27. $data['info'] = $rowset['info'];
  28. $total = $rowsetcount['rowset'][0]['count'];
  29. $total_page = ceil($total / $page_size);
  30. $data['total'] = $total;
  31. $data['total_page'] = (string)$total_page;
  32. $data['product_list'] = $rowset['rowset'];
  33. return $data;
  34. }
  35. }
  36. //$ChooseProduct = new getChooseProduct();
  37. //$data =$ChooseProduct ->getProductList('',1,5);
  38. //echo json_encode($data);
  39. //print_r($rowsetcount);