|
- <?php
- //Author:fuhc
- //Date:20160908
- //添加酒店产品
- require_once __DIR__ . '/../HotelLib.php';
-
- class HTHotelProductAction extends HotelLib
- {
-
- // 根据酒店名模糊查询
- function getInfo($key_word)
- {
- $sql = "select hotel_id,
- hotel_name,
- hotel_address
- from
- opera_hotel
- WHERE
- hotel_name
- LIKE
- '%$key_word%'
- AND
- cancel_flag=0";
- writeLog(__FUNCTION__ . " sql= " . $sql);
- $rowset = $this->DBTool->queryBySql($sql);
- $data['info'] = $rowset['info'];
- $data['code'] = $rowset['code'];
- $data['hotel_list'] = $rowset['rowset'];
- return $data;
- }
-
- // 根据酒店名模糊查询 有省市条件
- function fuzzySearchHotel($key_word, $area_id)
- {
-
- $sql = "select hotel_id,hotel_name,hotel_address from opera_hotel AS A LEFT JOIN
- base_area_view AS B ON A.area_id=B.area_id WHERE A.hotel_name LIKE '%$key_word%'
- AND (B.parent_area_id='$area_id' OR B.area_id='$area_id') AND A.cancel_flag=0";
- writeLog(__FUNCTION__ . " sql= " . $sql);
-
- $rowset = $this->DBTool->queryBySql($sql);
- $data['info'] = $rowset['info'];
- $data['code'] = $rowset['code'];
- $data['hotel_list'] = $rowset['rowset'];
- return $data;
- }
-
- //添加酒店产品
- function addHotelProduct($model)
- {
- $user_id = $model['user_id'];
- $earliest_checkin_time = $model['earliest_checkin_time'];
- $hotel_id = $model['hotel_id'];
- $supplier_id = $model['supplier_id'];
- $confirm_from = $model['confirm_from'];
- $principal = $model['principal']; // 运营负责人
- $procurement = $model['procurement'];
- $status = $model['status'];
-
-
- $data = ifNullParam(array($hotel_id, $confirm_from, $supplier_id, $procurement));
- if ($data['code'] != "0") {
- return $data;
- }
- $sql = "update opera_hotel set update_user_id={$user_id},
- earliest_checkin_time='{$earliest_checkin_time}',
- supplier_id={$supplier_id},
- hotel_status='$status',
- confirm_from={$confirm_from},
- purchase_name='{$procurement}',
- principal='{$principal}'
- where hotel_id={$hotel_id} and cancel_flag=0";
- writeLog(__FUNCTION__ . " sql= " . $sql);
- $result = $this->DBTool->execSql($sql);
- if ($result['code'] == "0") {
- $model = array(
- "user_id" => $user_id,
- "log_type" => 1,
- "hotel_id" => $hotel_id,
- "room_type" => 0,
- "log_desc" => "添加酒店产品"
- );
- $this->DBLog->insertLog($model, '添加酒店产品');
- }
-
- $data['code'] = $result['code'];
- $data['info'] = $result['info'];
- return $data;
- }
-
- //修改酒店产品
- function updateHotelProduct($model)
- {
- $user_id = $model['user_id'];
- //$room_type_sale = $model['room_type_sale'];
- $earliest_checkin_time = $model['earliest_checkin_time'];
- $hotel_id = $model['hotel_id'];
- $supplier_id = $model['supplier_id'];
- $confirm_from = $model['confirm_from'];
- $procurement = $model['procurement'];
- $principal = $model['principal']; //运营负责人
- $status = $model['hotel_status'];
-
- $a = isset($room_type_sale[0]) ? $room_type_sale[0] : "";
- if ($a == "," || $a == ",") {
- $data['code'] = "16";
- $data['info'] = "错误的请求参数";
- return $data;
- }
- $data = ifNullParam(array($hotel_id, $confirm_from, $supplier_id, $procurement));
- if ($data['code'] != "0") {
- return $data;
- }
- $sql = "update opera_hotel set update_user_id={$user_id},
- earliest_checkin_time='{$earliest_checkin_time}',
- supplier_id={$supplier_id},
- confirm_from={$confirm_from},
- hotel_status='$status',
- purchase_name='{$procurement}',
- principal='{$principal}'
- where hotel_id={$hotel_id} and cancel_flag=0";
- writeLog(__FUNCTION__ . " sql= " . $sql);
- $result = $this->DBTool->execSql($sql);
- if ($result['code'] == "0") {
- $model = array(
- "user_id" => $user_id,
- "log_type" => 1,
- "hotel_id" => $hotel_id,
- "room_type" => 0,
- "log_desc" => "修改酒店产品"
- );
- $this->DBLog->insertLog($model, '修改酒店产品');
- }
-
- $data['code'] = $result['code'];
- $data['info'] = $result['info'];
- return $data;
- }
-
- //进入页面得到列表 其实可以和下面搜索合并 搜索条件值没有默认给空就行
- function AllList($begin, $page_size, $hotel_name, $hotel_status, $user_id)
- {
- $sql = "select A.hotel_id,
- A.hotel_name,
- B.area_name,
- B.parent_area_name,
- S.supplier_name,
- P.purchaser_name,
- A.hotel_status,
- A.principal
- from opera_hotel as A
- LEFT JOIN base_area_view AS B ON A.area_id=B.area_id
- LEFT JOIN base_supplier AS S ON A.supplier_id=S.id
- LEFT JOIN base_supplier_purchase AS P ON A.PURCHASE_NAME=P.ID
- WHERE A.hotel_name LIKE '%$hotel_name%'
- AND A.hotel_status LIKE '%$hotel_status%'
- AND (A.hotel_status = 0 OR A.hotel_status =1)
- AND A.cancel_flag=0 ORDER BY
- A.CREATE_TIME desc limit $begin,$page_size";
- writeLog(__FUNCTION__ . " sql= " . $sql);
- $sqlcount = "select A.hotel_id,
- A.hotel_name,
- B.parent_area_name,
- B.area_name,
- S.supplier_name,
- P.purchaser_name,
- A.hotel_status,
- A.principal
- from opera_hotel as A
- LEFT JOIN base_area_view AS B ON A.area_id=B.area_id
- LEFT JOIN base_supplier AS S ON A.supplier_id=S.id
- LEFT JOIN base_supplier_purchase AS P ON A.PURCHASE_NAME=P.ID
- WHERE A.hotel_name LIKE '%$hotel_name%'
- AND A.hotel_status LIKE '%$hotel_status%'
- AND (A.hotel_status = 0 OR A.hotel_status =1)
- AND A.cancel_flag=0";
- writeLog(__FUNCTION__ . " sql= " . $sqlcount);
- $rest = $this->DBTool->queryBySql($sqlcount);
- $res = $this->DBTool->queryBySql($sql);
- $total = count($rest['rowset']);
- $total_page = ceil($total / $page_size);
- $data['total'] = $total;
- $data['total_page'] = $total_page;
- $data['code'] = $res['code'];
- $data['info'] = $res['info'];
- $data['rowset'] = $res['rowset'];
- // var_dump($data);
- return $data;
- }
-
- //搜索得到酒店列表
- function getHotelList($begin, $page_size, $area_id, $hotel_name, $hotel_status, $user_id)
- {
- //$page_size条数据
- $sql = "select A.hotel_id,
- A.hotel_name,
- B.parent_area_name,
- B.area_name,
- S.supplier_name,
- P.purchaser_name,
- A.hotel_status,
- A.principal
- from opera_hotel as A
- LEFT JOIN base_area_view AS B ON A.area_id=B.area_id
- LEFT JOIN base_supplier AS S ON A.supplier_id=S.id
- LEFT JOIN base_supplier_purchase AS P ON A.PURCHASE_NAME=P.ID
- WHERE A.hotel_name LIKE '%$hotel_name%'
- AND A.hotel_status LIKE '%$hotel_status%'
- AND (B.top_area_id='$area_id' OR B.parent_area_id='$area_id' OR B.area_id='$area_id')
- AND ($user_id = 1 or $user_id in (A.principal))
- AND A.cancel_flag=0
- ORDER BY A.CREATE_TIME desc limit $begin,$page_size";
- writeLog(__FUNCTION__ . " sql= " . $sql);
- //获取条数
- $sqlcount = "select A.hotel_id,
- A.hotel_name,
- B.parent_area_name,
- B.area_name,
- ifnull(S.supplier_name,''),
- P.purchaser_name,
- A.principal
- A.hotel_status from opera_hotel as A
- LEFT JOIN base_area_view AS B ON A.area_id=B.area_id
- LEFT JOIN base_supplier AS S ON A.supplier_id=S.id
- LEFT JOIN base_supplier_purchase AS P ON A.PURCHASE_NAME=P.ID
- WHERE A.hotel_name LIKE '%$hotel_name%'
- AND A.hotel_status LIKE '%$hotel_status%'
- AND (B.top_area_id='$area_id' OR B.parent_area_id='$area_id' OR B.area_id='$area_id')
- AND ($user_id = 1 or $user_id in (A.principal))
- AND A.cancel_flag=0";
- writeLog(__FUNCTION__ . " sql= " . $sqlcount);
- $res = $this->DBTool->queryBySql($sql);
- $rest = $this->DBTool->queryBySql($sqlcount);
- $total = count($rest['rowset']);
- $total_page = ceil($total / $page_size);
- $data['total'] = $total;
- $data['total_page'] = $total_page;
- $data['code'] = $res['code'];
- $data['info'] = $res['info'];
- $data['rowset'] = $res['rowset'];
- return $data;
- }
-
- //得到酒店信息
- function getUpHotelInfo($hotel_id)
- {
- $data = ifNullParam(array($hotel_id));
- if ($data['code'] != "0") {
- return $data;
- }
- $sql = "select A.hotel_id,A.hotel_name,A.earliest_checkin_time,(select parent_area_name_list from base_area_view where area_id=A.area_id) as hotel_area,A.supplier_id,A.confirm_from,
- ifnull((select purchaser_name from base_supplier_purchase where supplier_id=A.supplier_id and product_type=25 and cancel_flag=0),'') as purchaser_name,
- ifnull((select id from base_supplier_purchase where supplier_id=A.supplier_id and product_type=25 and cancel_flag=0),'') as purchaser_id,
- A.hotel_address ,A.hotel_status,A.principal from opera_hotel as A where A.hotel_id={$hotel_id} and A.cancel_flag=0";
- writeLog(__FUNCTION__ . " sql= " . $sql);
- $rowset = $this->DBTool->queryBySql($sql);
- $data['code'] = $rowset['code'];
- $data['info'] = $rowset['info'];
- if ($data['code'] != "0") {
- return $data;
- }
- $data['hotel_info'] = $rowset['rowset'][0];
- return $data;
- }
-
-
- }
-
-
- ?>
-
-
-
|