|
- <?php
- //Author:fuhc
- //Date:20160921
- //新增子房型
-
- require_once __DIR__ . '/../HotelLib.php';
-
-
- class HTChildRoom extends HotelLib
- {
- // 添加子房型
- function addChildRoom($roomModel)
- {
- $sql = "CALL ht_run_sub_room_save(" . $roomModel['user_id'] . "," . $roomModel['hotel_id'] . "," . $roomModel['parent_room_type'] .
- ",'" . $roomModel['start_date'] . "','" . $roomModel['end_date'] . "','" . $roomModel['week_day'] .
- "'," . $roomModel['run_status'] . "," . $roomModel['price_buyout'] . "," . $roomModel['price_reserve'] . "," .
- $roomModel['price_inquiry'] . "," . $roomModel['person_limit'] .
- "," . $roomModel['breakfast'] . ",'" . $roomModel['room_name'] . "')";
- writeLog(__FUNCTION__ . " sql= " . $sql);
- $data_r = array();
- $data = array();
- $rowset = $this->DBTool->execProcedure($sql);
- $data_r['code'] = $rowset['code'];
- $data_r['info'] = $rowset['info'];
- $data_r['rowset'] = isset($rowset['rowset'][0]) ? $rowset['rowset'][0] : array();
- if ($data_r['code'] != "0") {
- $data['code'] = $data_r['code'];
- $data['info'] = $data_r['info'];
- return $data;
- }
- if ($data_r['rowset'][0]['errcode'] == "0") {
- $model = array(
- "user_id" => $roomModel['user_id'],
- "log_type" => 2,
- "hotel_id" => $roomModel['hotel_id'],
- "room_type" => $roomModel['parent_room_type'],
- "log_desc" => "添加子房型" . $roomModel["room_name"] . " 买断价:" . $roomModel['price_buyout'] . " 保留价:" . $roomModel['price_reserve'] . " 现询价:" . $roomModel['price_inquiry']
- );
- $this->DBLog->insertLog($model, '添加子房型');
- }
- $data['code'] = $data_r['rowset'][0]['errcode'];
- $data['info'] = $data_r['rowset'][0]['errinfo'];
- return $data;
- }
-
- // 根据酒店查询房型
- function getRoomByHotel($hotel_id)
- {
-
- $sql = "select room_type_all,room_type_sale from opera_hotel as A where A.hotel_id=" . $hotel_id . " and A.cancel_flag=0;";
-
- $rowset = $this->DBTool->queryBySql($sql);
- $data['code'] = $rowset['code'];
- $data['info'] = $rowset['info'];
- $data['rowset'] = $rowset['rowset'];
- if ($data['code'] != "0") {
- return $data;
- }
- $room_type_all = $data['rowset'][0]['room_type_all'];
- $room_type_all = $room_type_all == "" ? "0" : $room_type_all;
- $room_type_sale = $data['rowset'][0]['room_type_sale'];
- if ($room_type_sale == "") {
- $room_type_sale = "0";
- }
- // $sql="select res_id as room_id,res_name as room_name from base_resource where res_id in (".$room_type_all.") and cancel_flag=0;";
- $sql = "select res_id as room_id,res_name as room_name,
- case when res_id in (" . $room_type_sale . ") then 1 else 0 end as checked
- from base_resource where res_id in (" . $room_type_all . ") and cancel_flag=0;";
- writeLog(__FUNCTION__ . " sql=" . $sql);
- $data = array();
- $rowset = $this->DBTool->queryBySql($sql);
- $data['code'] = $rowset['code'];
- $data['info'] = $rowset['info'];
- $data['room_list'] = $rowset['rowset'];
- return $data;
- }
-
- // 修改子房型
- function updateChildRoom($Child)
- {
- $user_id = $Child['user_id'];
- $run_status = $Child['run_status'];
- $run_date = $Child['run_date'];
- $room_type = $Child['room_type'];
- $hotel_id = $Child['hotel_id'];
- $price_buyout = $Child['price_buyout'];
- $price_reserve = $Child['price_reserve'];
- $price_inquiry = $Child['price_inquiry'];
-
- // foreach ($Child as $v) {
- // if (empty($v)) {
- // $data['code'] = "16";
- // $data['info'] = "参数错误";
- // return $data;
- // }
- // }
-
- $sql = "update run_hotel_sub_room set update_user_id={$user_id},run_status={$run_status},
- BASE_PRICE_BUYOUT='{$price_buyout}' ,BASE_PRICE_RESERVE='{$price_reserve}' ,BASE_PRICE_INQUIRY='{$price_inquiry}'
- where run_date='{$run_date}' and room_type={$room_type} and hotel_id={$hotel_id} and BASE_ROOM_TYPE>0";
- writeLog(__FUNCTION__ . " sql= " . $sql);
- $data = array();
- $rowset = $this->DBTool->execSql($sql);
- if ($rowset['code'] == "0") {
- $desc = '修改子房型';
- $t = $run_status == "1" ? "开房" : "关房";
-
- $model = array(
- "user_id" => $user_id,
- "log_type" => 2,
- "hotel_id" => $hotel_id,
- "room_type" => $room_type,
- "log_desc" => $desc . $t . " 价格为 买断价:" . $Child['price_buyout'] . " 保留价:" . $Child['price_reserve'] . " 现询价:" . $Child['price_inquiry']
- );
- $this->DBLog->insertLog($model, '修改子房型');
- }
- $data['code'] = $rowset['code'];
- $data['info'] = $rowset['info'];
- return $data;
- }
-
- // 上
- function onLine($user_id, $room_type, $hotel_id)
- {
- $sql = "update run_hotel_sub_room set is_onsale=1,update_user_id={$user_id} where hotel_id={$hotel_id} and room_type={$room_type}";
- //上下线维度由原来的天 变为子房型。
- $sql2 = "update opera_hotel_room set is_onsale = 1,update_user_id = {$user_id} where hotel_id = {$hotel_id} and room_type = {$room_type}";
- writeLog('top sql= ' . $sql);
- $data = array();
- $rowset = $this->DBTool->execSql($sql);
- $this->DBTool->execSql($sql2);
- if ($rowset['code'] == "0") {
- $model = array(
- "user_id" => $user_id,
- "log_type" => 2,
- "hotel_id" => $hotel_id,
- "room_type" => $room_type,
- "log_desc" => "修改子房型" . "上线"
- );
- $this->DBLog->insertLog($model, '修改子房型');
- }
- $data['code'] = $rowset['code'];
- $data['info'] = $rowset['info'];
- return $data;
- }
-
- // 下
- function offLine($user_id, $room_type, $hotel_id)
- {
- $sql = "update run_hotel_sub_room set is_onsale=0,update_user_id={$user_id} where hotel_id={$hotel_id} and room_type={$room_type}";
- //上下线维度由原来的天 变为子房型。
- $sql2 = "update opera_hotel_room set is_onsale = 0,update_user_id = {$user_id} where hotel_id = {$hotel_id} and room_type = {$room_type}";
- writeLog('bottom sql= ' . $sql);
- $data = array();
- $rowset = $this->DBTool->execSql($sql);
- $this->DBTool->execSql($sql2);
- if ($rowset['code'] == "0") {
- $model = array(
- "user_id" => $user_id,
- "log_type" => 2,
- "hotel_id" => $hotel_id,
- "room_type" => $room_type,
- "log_desc" => "修改子房型" . "下线"
- );
- $this->DBLog->insertLog($model, '修改子房型');
- }
- $data['code'] = $rowset['code'];
- $data['info'] = $rowset['info'];
- return $data;
- }
-
- //查询基础房型ID
- function getBaseroomId($baseroomname)
- {
- $sql = "select res_id from base_resource WHERE res_type_id=26 AND res_name='$baseroomname' AND cancel_flag=0";
- writeLog(__FUNCTION__ . " sql= " . $sql);
- $rowset = $this->DBTool->queryBySql($sql);
- return $rowset['rowset'];
- }
-
- //根据查询条件 查出满足固定酒店和基础房型的并且没有库存的数据 如果有就不能删
- function getRoomName($res_id, $hotel_id)
- {
- $sql = "select id from run_hotel WHERE hotel_id='$hotel_id' AND parent_room_type=0 AND room_type='$res_id' AND total_count>saled_count";
- writeLog(__FUNCTION__ . " sql= " . $sql);
- $rowset = $this->DBTool->queryBySql($sql);
- return $rowset;
- }
-
- //删除子房型
- function doCancelChildRoom($user_id, $room_type, $hotel_id)
- {
- //只有所有订单均为已完成或已取消 才能删除该子房型
- $sql_count = "select count(1) as order_num from order_main where prod_id = $room_type and parent_prod_id = $hotel_id and cancel_flag = 0 and order_status in (145,313,198,382,314)";
- $res = $this->DBTool->queryBySql($sql_count);
- //只有下线的子房型才能删除
- $sql_is_onsale = "select is_onsale from opera_hotel_room where hotel_id ={$hotel_id} and room_type ={$room_type} limit 1";
- $res1 = $this->DBTool->queryBySql($sql_is_onsale);
- if ($res['rowset'][0]['order_num'] != 0) {
- $data['code'] = 5;
- $data['info'] = '只有当该子房型的所有订单均为已完成和已取消时才能删除该子房型';
- return $data;
- }
- if ($res1['rowset'][0]['is_onsale']!=0){
- $data['code'] = 6;
- $data['info'] = '只有该子房型下线后才能删除该子房型';
- return $data;
- }
-
-
- $sql = "update opera_hotel_room set cancel_flag = 1,update_user_id={$user_id} where hotel_id={$hotel_id} and room_type={$room_type}";
- writeLog(__FUNCTION__ . "sql=" . $sql);
- $rowset = $this->DBTool->execSql($sql);
- if ($rowset['code'] == "0") {
- $model = array(
- "user_id" => $user_id,
- "log_type" => 2,
- "hotel_id" => $hotel_id,
- "room_type" => $room_type,
- "log_desc" => "不显示该子房型"
- );
- $this->DBLog->insertLog($model, '不显示子房型');
- }
- $data['code'] = $rowset['code'];
- $data['info'] = $rowset['info'];
- return $data;
- }
-
- }
|