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.
 
 
 
 

208 lines
7.0 KiB

  1. <?php
  2. //Author:fuhc
  3. //Date:20160908
  4. //添加酒店产品
  5. //请求方式 :GET POST 如何设置:eg:$op=isset($_REQUEST['op'])?$_REQUEST['op']:(isset($_REQUEST['op'])?$_REQUEST['op']:"-100");
  6. //请求地址: parm: [type=hotel_AddHotelProduct] [op=room/fuzzy/provinceCity/add] ...
  7. //op=fuzzy key_word="" area_id=""
  8. //op=addInfo hotel_id=1
  9. require_once "Api/ApiBase.php";
  10. require_once "Lib/Action/HTHotelProductAction.class.php";
  11. require_once "Lib/Action/HTChildRoom.class.php";
  12. require_once "Lib/Common/ProvinceCityLinkAction.class.php";
  13. require_once "Lib/Common/SupplierAction.class.php";
  14. require_once "Lib/Common/ConfirmFromOrg.class.php";
  15. class AddHotelProd extends ApiBase
  16. {
  17. public $addAction; // 添加酒店
  18. public $provCityLinkAction; // 省级联动
  19. public $childRoom; // 子房型
  20. function __construct()
  21. {
  22. parent::__construct();
  23. $this->addAction = new HTHotelProductAction;
  24. $this->provCityLinkAction = new ProvinceCityLinkAction;
  25. $this->childRoom = new HTChildRoom;
  26. }
  27. // 检索酒店
  28. function fuzzySearch()
  29. {
  30. $key_word = isset($_REQUEST['key_word']) ? $_REQUEST['key_word'] : ""; // 允许为空
  31. $area_id = isset($_REQUEST['area_id']) ? $_REQUEST['area_id'] : "0"; // 允许为空
  32. if ($area_id == "" || 0 == $area_id) {
  33. $data = $this->addAction->getInfo($key_word);
  34. } else {
  35. $data = $this->addAction->fuzzySearchHotel($key_word, $area_id);
  36. }
  37. return $data;
  38. }
  39. ////根据查询条件 查出满足固定酒店和基础房型的并且没有库存的数据 如果有就不能删
  40. function deletebaseroom()
  41. {
  42. $baseroomname = $_REQUEST['baseroomname'];
  43. $hotel_id = $_REQUEST['hotel_id'];
  44. @$baseroomid = $this->childRoom->getBaseroomId($baseroomname);
  45. @$res_id = $baseroomid[0]['res_id'];
  46. $info = $this->childRoom->getRoomName($res_id, $hotel_id);
  47. if ($info['code'] == 1) {
  48. $data['code'] = 1;
  49. $data['info'] = '参数错误';
  50. return $data;
  51. } else {
  52. if ($info['rowset']) {
  53. $data['code'] = 0;
  54. $data['mes'] = 0;
  55. $data['info'] = '有库存数据,不能删除';
  56. // var_dump($data);
  57. } else {
  58. $data['code'] = 1;
  59. $data['mes'] = 1;
  60. $data['info'] = '无库存,可以删除';
  61. }
  62. }
  63. return $data;
  64. }
  65. // 查询房型
  66. function getRoomByHotel()
  67. {
  68. $hotel_id = isset($_REQUEST['hotel_id']) ? $_REQUEST['hotel_id'] : ""; // 不允许为空
  69. $data = array();
  70. if (empty($hotel_id)) {
  71. $data['code'] = "16";
  72. $data['info'] = "错误的请求参数";
  73. return $data;
  74. }
  75. $roomList = $this->childRoom->getRoomByHotel($hotel_id);
  76. $data = $roomList;
  77. return $data;
  78. }
  79. // 省市联动
  80. function getProvinceCity()
  81. {
  82. $area_id = $area_id = isset($_REQUEST['area_id']) ? $_REQUEST['area_id'] : "0"; //默认为0
  83. if (empty($area_id)) {
  84. $area_id = "0";
  85. }
  86. $data = $this->provCityLinkAction->getProvinceCity($area_id);
  87. return $data;
  88. }
  89. // 添加酒店产品
  90. function addHotelProduct()
  91. {
  92. $user_id = $this->login_user_id;
  93. // var_dump($user_id);exit();
  94. $hotel_id = isset($_REQUEST['hotel_id']) ? $_REQUEST['hotel_id'] : ""; //不为空//为空
  95. $earliest_checkin_time = isset($_REQUEST['earliest_checkin_time']) ? $_REQUEST['earliest_checkin_time'] : ""; //为空
  96. $supplier_id = isset($_REQUEST['supplier_id']) ? $_REQUEST['supplier_id'] : ""; //不为空
  97. $confirm_from = isset($_REQUEST['confirm_from']) ? $_REQUEST['confirm_from'] : ""; //不为空
  98. $procurement = isset($_REQUEST['procurement']) ? $_REQUEST['procurement'] : ""; //不为空
  99. $principal = isset($_REQUEST['principal']) ? $_REQUEST['principal'] : "";
  100. $status = $_REQUEST['status'];
  101. if (empty($hotel_id) && $hotel_id != "0") {
  102. $data['code'] = "16";
  103. $data['info'] = "错误的请求参数";
  104. return $data;
  105. }
  106. // foreach($room_type_sale as $char){
  107. // if($char!="," || "")
  108. // }
  109. $hotel_model = array(
  110. "user_id" => $user_id,
  111. "hotel_id" => $hotel_id,
  112. "earliest_checkin_time" => $earliest_checkin_time,
  113. "supplier_id" => $supplier_id,
  114. "confirm_from" => $confirm_from,
  115. "procurement" => $procurement,
  116. 'principal' => $principal,
  117. "status" => $status
  118. );
  119. $data = $this->addAction->addHotelProduct($hotel_model);
  120. return $data;
  121. }
  122. //得到供应商和发单主体
  123. function getSupplierConfirm()
  124. {
  125. $supplierobj = new SupplierAction;
  126. $supplierList = $supplierobj->getHotelSupplierList();
  127. $data['code'] = $supplierList['code'];
  128. $data['info'] = $supplierList['info'];
  129. if ($data['code'] != "0") {
  130. return $data;
  131. }
  132. $data['supplier_list'] = $supplierList['supplier_list'];
  133. $confirmobj = new ConfirmFromOrg;
  134. $confirmOrgList = $confirmobj->getConfirmOrgList();
  135. $data['code'] = $confirmOrgList['code'];
  136. $data['info'] = $confirmOrgList['info'];
  137. $data['confirm_org_list'] = $confirmOrgList['confirm_org_list'];
  138. return $data;
  139. }
  140. //供应商的采购人
  141. function getPurchaseNameBySupplier()
  142. {
  143. $supplier_id = isset($_REQUEST['supplier_id']) ? $_REQUEST['supplier_id'] : ""; // 不为空
  144. if (empty($supplier_id) && $supplier_id != "0") {
  145. $data['code'] = "16";
  146. $data['info'] = "错误的请求参数";
  147. return $data;
  148. }
  149. $supplierobj = new SupplierAction;
  150. $purchaseNames = $supplierobj->getPurchaseNameBySupplier($supplier_id);
  151. $data = $purchaseNames;
  152. return $data;
  153. }
  154. }
  155. // 接口
  156. $op = isset($_REQUEST['op']) ? $_REQUEST['op'] : '';
  157. $addHotel = new AddHotelProd();
  158. $data = array();
  159. $data['code'] = "0";
  160. $data['info'] = "";
  161. if (empty($op)) {
  162. $data['code'] = "5";
  163. $data['info'] = "op操作参数异常";
  164. echo json_encode($data);
  165. exit();
  166. }
  167. if ($op == "fuzzy") { //检索酒店
  168. $data = $addHotel->fuzzySearch();
  169. } else if ($op == "room") { //
  170. $data = $addHotel->getRoomByHotel();
  171. } else if ($op == "provinceCity") {
  172. $data = $addHotel->getProvinceCity();
  173. } else if ($op == "add") {
  174. $data = $addHotel->addHotelProduct();
  175. } else if ($op == "supplier-confirm") {
  176. $data = $addHotel->getSupplierConfirm();
  177. } else if ($op == "deletebaseroom") {
  178. $data = $addHotel->deletebaseroom();
  179. } else if ($op == "selpurchase") {
  180. $data = $addHotel->getPurchaseNameBySupplier();
  181. } else {
  182. $data['code'] = "5";
  183. $data['info'] = "op操作参数异常";
  184. echo json_encode($data);
  185. exit();
  186. }
  187. echo json_encode($data);