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.
 
 
 
 

142 lines
5.4 KiB

  1. <?php
  2. //author:fuhc
  3. //date:20161021
  4. require_once "Api/ApiBase.php";
  5. require_once "Lib/Action/HTHotelProductAction.class.php";
  6. require_once "Lib/Action/HTChildRoom.class.php";
  7. require_once "Lib/Common/SupplierAction.class.php";
  8. require_once "Lib/Common/ConfirmFromOrg.class.php";
  9. class UpdateHotelProduct extends ApiBase
  10. {
  11. //得到供应商和发单主体
  12. private function getSupplierConfirm()
  13. {
  14. $supplierobj = new SupplierAction;
  15. $supplierList = $supplierobj->getHotelSupplierList();
  16. $data['code'] = $supplierList['code'];
  17. $data['info'] = $supplierList['info'];
  18. if ($data['code'] != "0") {
  19. return $data;
  20. }
  21. $data['supplier_list'] = $supplierList['supplier_list'];
  22. $confirmobj = new ConfirmFromOrg;
  23. $confirmOrgList = $confirmobj->getConfirmOrgList();
  24. $data['code'] = $confirmOrgList['code'];
  25. $data['info'] = $confirmOrgList['info'];
  26. $data['confirm_org_list'] = $confirmOrgList['confirm_org_list'];
  27. return $data;
  28. }
  29. //供应商的采购人
  30. private function getPurchaseNameBySupplier()
  31. {
  32. $supplier_id = isset($_REQUEST['supplier_id']) ? $_REQUEST['supplier_id'] : ""; // 不为空
  33. if (empty($supplier_id) && $supplier_id != "0") {
  34. $data['code'] = "16";
  35. $data['info'] = "错误的请求参数";
  36. return $data;
  37. }
  38. $supplierobj = new SupplierAction;
  39. $purchaseNames = $supplierobj->getPurchaseNameBySupplier($supplier_id);
  40. $data = $purchaseNames;
  41. return $data;
  42. }
  43. //得到修改的查询
  44. function getUpHotelInfo()
  45. {
  46. $hotel_id = isset($_REQUEST['hotel_id']) ? $_REQUEST['hotel_id'] : "";
  47. if (empty($hotel_id) && $hotel_id != "0") {
  48. $data['code'] = "16";
  49. $data['info'] = "错误的请求参数";
  50. return $data;
  51. }
  52. $action = new HTHotelProductAction;
  53. $rowset = $action->getUpHotelInfo($hotel_id);
  54. $data['code'] = $rowset['code'];
  55. $data['info'] = $rowset['info'];
  56. $data['hotel_info'] = $rowset['hotel_info'];
  57. $temparea = isset($rowset['hotel_info']['hotel_area']) ? $rowset['hotel_info']['hotel_area'] : "";
  58. $temparea = str_replace('}{', '-', $temparea);
  59. $temparea = str_replace('{', '', $temparea);
  60. $temparea = str_replace('}', '', $temparea);
  61. $data['hotel_info']['hotel_area'] = $temparea;
  62. $data['hotel_info']['principal'] = $rowset['hotel_info']['principal']; //运营负责人
  63. $childRoom = new HTChildRoom;
  64. $roomList = $childRoom->getRoomByHotel($hotel_id);
  65. $data['room_list'] = isset($roomList['room_list']) ? $roomList['room_list'] : array();
  66. $rowset = $this->getSupplierConfirm();
  67. $data['supplier_list'] = isset($rowset['supplier_list']) ? $rowset['supplier_list'] : array();
  68. $data['confirm_org_list'] = isset($rowset['confirm_org_list']) ? $rowset['confirm_org_list'] : array();
  69. return $data;
  70. }
  71. //修改
  72. function updateHotel()
  73. {
  74. $user_id = $this->login_user_id;
  75. $hotel_id = isset($_REQUEST['hotel_id']) ? $_REQUEST['hotel_id'] : ""; //不为空
  76. $room_type_sale = isset($_REQUEST['room_type_sale']) ? $_REQUEST['room_type_sale'] : ""; //为空
  77. $earliest_checkin_time = isset($_REQUEST['earliest_checkin_time']) ? $_REQUEST['earliest_checkin_time'] : ""; //为空
  78. $status = $_REQUEST['status'];
  79. $supplier_id = isset($_REQUEST['supplier_id']) ? $_REQUEST['supplier_id'] : ""; //不为空
  80. $confirm_from = isset($_REQUEST['confirm_from']) ? $_REQUEST['confirm_from'] : ""; //不为空
  81. $procurement = isset($_REQUEST['procurement']) ? $_REQUEST['procurement'] : ""; //不为空
  82. $principal = isset($_REQUEST['principal']) ? $_REQUEST['principal'] : ""; //运营负责人
  83. if (empty($hotel_id) && $hotel_id != "0") {
  84. $data['code'] = "16";
  85. $data['info'] = "错误的请求参数";
  86. return $data;
  87. }
  88. $a = isset($room_type_sale[0]) ? $room_type_sale[0] : "";
  89. if ($a == "," || $a == ",") {
  90. $data['code'] = "16";
  91. $data['info'] = "错误的请求参数";
  92. return $data;
  93. }
  94. $hotel_model = array(
  95. "user_id" => $user_id,
  96. "hotel_id" => $hotel_id,
  97. //"room_type_sale"=>$room_type_sale,
  98. "earliest_checkin_time" => $earliest_checkin_time,
  99. "supplier_id" => $supplier_id,
  100. "confirm_from" => $confirm_from,
  101. "procurement" => $procurement,
  102. 'principal' => $principal,
  103. "hotel_status" => $status
  104. );
  105. $action = new HTHotelProductAction;
  106. $data = $action->updateHotelProduct($hotel_model);
  107. return $data;
  108. }
  109. }
  110. // 接口
  111. $op = isset($_REQUEST['op']) ? $_REQUEST['op'] : "";
  112. $data = array();
  113. $data['code'] = "0";
  114. $data['info'] = "";
  115. if (empty($op)) {
  116. $data['code'] = "5";
  117. $data['info'] = "op操作参数异常";
  118. echo json_encode($data);
  119. exit();
  120. }
  121. $obj = new UpdateHotelProduct;
  122. if ($op == "up-select") {
  123. $data = $obj->getUpHotelInfo();
  124. } else if ($op == 'up-hotel') {
  125. $data = $obj->updateHotel();
  126. } else {
  127. $data['code'] = "5";
  128. $data['info'] = "op操作参数异常";
  129. echo json_encode($data);
  130. exit();
  131. }
  132. echo json_encode($data);