|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- <?php
- //author:fuhc
- //date:20161021
-
- require_once "Api/ApiBase.php";
- require_once "Lib/Action/HTHotelProductAction.class.php";
- require_once "Lib/Action/HTChildRoom.class.php";
- require_once "Lib/Common/SupplierAction.class.php";
- require_once "Lib/Common/ConfirmFromOrg.class.php";
-
-
- class UpdateHotelProduct extends ApiBase
- {
- //得到供应商和发单主体
- private function getSupplierConfirm()
- {
-
- $supplierobj = new SupplierAction;
- $supplierList = $supplierobj->getHotelSupplierList();
- $data['code'] = $supplierList['code'];
- $data['info'] = $supplierList['info'];
- if ($data['code'] != "0") {
- return $data;
- }
- $data['supplier_list'] = $supplierList['supplier_list'];
- $confirmobj = new ConfirmFromOrg;
- $confirmOrgList = $confirmobj->getConfirmOrgList();
- $data['code'] = $confirmOrgList['code'];
- $data['info'] = $confirmOrgList['info'];
- $data['confirm_org_list'] = $confirmOrgList['confirm_org_list'];
- return $data;
- }
-
- //供应商的采购人
- private function getPurchaseNameBySupplier()
- {
- $supplier_id = isset($_REQUEST['supplier_id']) ? $_REQUEST['supplier_id'] : ""; // 不为空
- if (empty($supplier_id) && $supplier_id != "0") {
- $data['code'] = "16";
- $data['info'] = "错误的请求参数";
- return $data;
- }
- $supplierobj = new SupplierAction;
- $purchaseNames = $supplierobj->getPurchaseNameBySupplier($supplier_id);
- $data = $purchaseNames;
- return $data;
- }
-
- //得到修改的查询
- function getUpHotelInfo()
- {
- $hotel_id = isset($_REQUEST['hotel_id']) ? $_REQUEST['hotel_id'] : "";
- if (empty($hotel_id) && $hotel_id != "0") {
- $data['code'] = "16";
- $data['info'] = "错误的请求参数";
- return $data;
- }
- $action = new HTHotelProductAction;
- $rowset = $action->getUpHotelInfo($hotel_id);
- $data['code'] = $rowset['code'];
- $data['info'] = $rowset['info'];
- $data['hotel_info'] = $rowset['hotel_info'];
- $temparea = isset($rowset['hotel_info']['hotel_area']) ? $rowset['hotel_info']['hotel_area'] : "";
- $temparea = str_replace('}{', '-', $temparea);
- $temparea = str_replace('{', '', $temparea);
- $temparea = str_replace('}', '', $temparea);
- $data['hotel_info']['hotel_area'] = $temparea;
- $data['hotel_info']['principal'] = $rowset['hotel_info']['principal']; //运营负责人
- $childRoom = new HTChildRoom;
- $roomList = $childRoom->getRoomByHotel($hotel_id);
- $data['room_list'] = isset($roomList['room_list']) ? $roomList['room_list'] : array();
- $rowset = $this->getSupplierConfirm();
- $data['supplier_list'] = isset($rowset['supplier_list']) ? $rowset['supplier_list'] : array();
- $data['confirm_org_list'] = isset($rowset['confirm_org_list']) ? $rowset['confirm_org_list'] : array();
- return $data;
- }
-
- //修改
- function updateHotel()
- {
- $user_id = $this->login_user_id;
- $hotel_id = isset($_REQUEST['hotel_id']) ? $_REQUEST['hotel_id'] : ""; //不为空
- $room_type_sale = isset($_REQUEST['room_type_sale']) ? $_REQUEST['room_type_sale'] : ""; //为空
- $earliest_checkin_time = isset($_REQUEST['earliest_checkin_time']) ? $_REQUEST['earliest_checkin_time'] : ""; //为空
- $status = $_REQUEST['status'];
- $supplier_id = isset($_REQUEST['supplier_id']) ? $_REQUEST['supplier_id'] : ""; //不为空
- $confirm_from = isset($_REQUEST['confirm_from']) ? $_REQUEST['confirm_from'] : ""; //不为空
- $procurement = isset($_REQUEST['procurement']) ? $_REQUEST['procurement'] : ""; //不为空
- $principal = isset($_REQUEST['principal']) ? $_REQUEST['principal'] : ""; //运营负责人
- if (empty($hotel_id) && $hotel_id != "0") {
- $data['code'] = "16";
- $data['info'] = "错误的请求参数";
- return $data;
- }
- $a = isset($room_type_sale[0]) ? $room_type_sale[0] : "";
- if ($a == "," || $a == ",") {
- $data['code'] = "16";
- $data['info'] = "错误的请求参数";
- return $data;
- }
- $hotel_model = array(
- "user_id" => $user_id,
- "hotel_id" => $hotel_id,
- //"room_type_sale"=>$room_type_sale,
- "earliest_checkin_time" => $earliest_checkin_time,
- "supplier_id" => $supplier_id,
- "confirm_from" => $confirm_from,
- "procurement" => $procurement,
- 'principal' => $principal,
- "hotel_status" => $status
- );
- $action = new HTHotelProductAction;
- $data = $action->updateHotelProduct($hotel_model);
- return $data;
- }
- }
-
- // 接口
- $op = isset($_REQUEST['op']) ? $_REQUEST['op'] : "";
- $data = array();
- $data['code'] = "0";
- $data['info'] = "";
- if (empty($op)) {
- $data['code'] = "5";
- $data['info'] = "op操作参数异常";
- echo json_encode($data);
- exit();
- }
- $obj = new UpdateHotelProduct;
- if ($op == "up-select") {
- $data = $obj->getUpHotelInfo();
- } else if ($op == 'up-hotel') {
- $data = $obj->updateHotel();
- } else {
- $data['code'] = "5";
- $data['info'] = "op操作参数异常";
- echo json_encode($data);
- exit();
- }
- echo json_encode($data);
-
|