|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207 |
- <?php
- //Author:fuhc
- //Date:20160908
- //添加酒店产品
- //请求方式 :GET POST 如何设置:eg:$op=isset($_REQUEST['op'])?$_REQUEST['op']:(isset($_REQUEST['op'])?$_REQUEST['op']:"-100");
- //请求地址: parm: [type=hotel_AddHotelProduct] [op=room/fuzzy/provinceCity/add] ...
- //op=fuzzy key_word="" area_id=""
- //op=addInfo hotel_id=1
-
- require_once "Api/ApiBase.php";
- require_once "Lib/Action/HTHotelProductAction.class.php";
- require_once "Lib/Action/HTChildRoom.class.php";
- require_once "Lib/Common/ProvinceCityLinkAction.class.php";
- require_once "Lib/Common/SupplierAction.class.php";
- require_once "Lib/Common/ConfirmFromOrg.class.php";
-
-
- class AddHotelProd extends ApiBase
- {
-
- public $addAction; // 添加酒店
- public $provCityLinkAction; // 省级联动
- public $childRoom; // 子房型
-
- function __construct()
- {
- parent::__construct();
- $this->addAction = new HTHotelProductAction;
- $this->provCityLinkAction = new ProvinceCityLinkAction;
- $this->childRoom = new HTChildRoom;
- }
-
- // 检索酒店
- function fuzzySearch()
- {
- $key_word = isset($_REQUEST['key_word']) ? $_REQUEST['key_word'] : ""; // 允许为空
- $area_id = isset($_REQUEST['area_id']) ? $_REQUEST['area_id'] : "0"; // 允许为空
- if ($area_id == "" || 0 == $area_id) {
- $data = $this->addAction->getInfo($key_word);
- } else {
- $data = $this->addAction->fuzzySearchHotel($key_word, $area_id);
- }
- return $data;
- }
-
- ////根据查询条件 查出满足固定酒店和基础房型的并且没有库存的数据 如果有就不能删
- function deletebaseroom()
- {
- $baseroomname = $_REQUEST['baseroomname'];
- $hotel_id = $_REQUEST['hotel_id'];
- @$baseroomid = $this->childRoom->getBaseroomId($baseroomname);
- @$res_id = $baseroomid[0]['res_id'];
- $info = $this->childRoom->getRoomName($res_id, $hotel_id);
- if ($info['code'] == 1) {
- $data['code'] = 1;
- $data['info'] = '参数错误';
- return $data;
- } else {
- if ($info['rowset']) {
- $data['code'] = 0;
- $data['mes'] = 0;
- $data['info'] = '有库存数据,不能删除';
- // var_dump($data);
- } else {
- $data['code'] = 1;
- $data['mes'] = 1;
- $data['info'] = '无库存,可以删除';
- }
- }
- return $data;
- }
-
- // 查询房型
- function getRoomByHotel()
- {
- $hotel_id = isset($_REQUEST['hotel_id']) ? $_REQUEST['hotel_id'] : ""; // 不允许为空
- $data = array();
- if (empty($hotel_id)) {
- $data['code'] = "16";
- $data['info'] = "错误的请求参数";
- return $data;
- }
- $roomList = $this->childRoom->getRoomByHotel($hotel_id);
- $data = $roomList;
- return $data;
- }
-
- // 省市联动
- function getProvinceCity()
- {
- $area_id = $area_id = isset($_REQUEST['area_id']) ? $_REQUEST['area_id'] : "0"; //默认为0
- if (empty($area_id)) {
- $area_id = "0";
- }
- $data = $this->provCityLinkAction->getProvinceCity($area_id);
- return $data;
- }
-
- // 添加酒店产品
- function addHotelProduct()
- {
-
- $user_id = $this->login_user_id;
- // var_dump($user_id);exit();
- $hotel_id = isset($_REQUEST['hotel_id']) ? $_REQUEST['hotel_id'] : ""; //不为空//为空
- $earliest_checkin_time = isset($_REQUEST['earliest_checkin_time']) ? $_REQUEST['earliest_checkin_time'] : ""; //为空
- $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'] : "";
- $status = $_REQUEST['status'];
- if (empty($hotel_id) && $hotel_id != "0") {
- $data['code'] = "16";
- $data['info'] = "错误的请求参数";
- return $data;
- }
- // foreach($room_type_sale as $char){
- // if($char!="," || "")
- // }
-
- $hotel_model = array(
- "user_id" => $user_id,
- "hotel_id" => $hotel_id,
- "earliest_checkin_time" => $earliest_checkin_time,
- "supplier_id" => $supplier_id,
- "confirm_from" => $confirm_from,
- "procurement" => $procurement,
- 'principal' => $principal,
- "status" => $status
- );
- $data = $this->addAction->addHotelProduct($hotel_model);
- return $data;
- }
-
- //得到供应商和发单主体
- 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;
- }
-
- //供应商的采购人
- 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;
- }
-
-
- }
-
- // 接口
- $op = isset($_REQUEST['op']) ? $_REQUEST['op'] : '';
- $addHotel = new AddHotelProd();
- $data = array();
- $data['code'] = "0";
- $data['info'] = "";
- if (empty($op)) {
- $data['code'] = "5";
- $data['info'] = "op操作参数异常";
- echo json_encode($data);
- exit();
- }
- if ($op == "fuzzy") { //检索酒店
- $data = $addHotel->fuzzySearch();
- } else if ($op == "room") { //
- $data = $addHotel->getRoomByHotel();
- } else if ($op == "provinceCity") {
- $data = $addHotel->getProvinceCity();
- } else if ($op == "add") {
- $data = $addHotel->addHotelProduct();
- } else if ($op == "supplier-confirm") {
- $data = $addHotel->getSupplierConfirm();
- } else if ($op == "deletebaseroom") {
- $data = $addHotel->deletebaseroom();
- } else if ($op == "selpurchase") {
- $data = $addHotel->getPurchaseNameBySupplier();
- } else {
- $data['code'] = "5";
- $data['info'] = "op操作参数异常";
- echo json_encode($data);
- exit();
- }
-
- echo json_encode($data);
-
|