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.

HTHotelProductAction.class.php 11 KiB

3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. <?php
  2. //Author:fuhc
  3. //Date:20160908
  4. //添加酒店产品
  5. require_once __DIR__ . '/../HotelLib.php';
  6. class HTHotelProductAction extends HotelLib
  7. {
  8. // 根据酒店名模糊查询
  9. function getInfo($key_word)
  10. {
  11. $sql = "select hotel_id,
  12. hotel_name,
  13. hotel_address
  14. from
  15. opera_hotel
  16. WHERE
  17. hotel_name
  18. LIKE
  19. '%$key_word%'
  20. AND
  21. cancel_flag=0";
  22. writeLog(__FUNCTION__ . " sql= " . $sql);
  23. $rowset = $this->DBTool->queryBySql($sql);
  24. $data['info'] = $rowset['info'];
  25. $data['code'] = $rowset['code'];
  26. $data['hotel_list'] = $rowset['rowset'];
  27. return $data;
  28. }
  29. // 根据酒店名模糊查询 有省市条件
  30. function fuzzySearchHotel($key_word, $area_id)
  31. {
  32. $sql = "select hotel_id,hotel_name,hotel_address from opera_hotel AS A LEFT JOIN
  33. base_area_view AS B ON A.area_id=B.area_id WHERE A.hotel_name LIKE '%$key_word%'
  34. AND (B.parent_area_id='$area_id' OR B.area_id='$area_id') AND A.cancel_flag=0";
  35. writeLog(__FUNCTION__ . " sql= " . $sql);
  36. $rowset = $this->DBTool->queryBySql($sql);
  37. $data['info'] = $rowset['info'];
  38. $data['code'] = $rowset['code'];
  39. $data['hotel_list'] = $rowset['rowset'];
  40. return $data;
  41. }
  42. //添加酒店产品
  43. function addHotelProduct($model)
  44. {
  45. $user_id = $model['user_id'];
  46. $earliest_checkin_time = $model['earliest_checkin_time'];
  47. $hotel_id = $model['hotel_id'];
  48. $supplier_id = $model['supplier_id'];
  49. $confirm_from = $model['confirm_from'];
  50. $principal = $model['principal']; // 运营负责人
  51. $procurement = $model['procurement'];
  52. $status = $model['status'];
  53. $data = ifNullParam(array($hotel_id, $confirm_from, $supplier_id, $procurement));
  54. if ($data['code'] != "0") {
  55. return $data;
  56. }
  57. $sql = "update opera_hotel set update_user_id={$user_id},
  58. earliest_checkin_time='{$earliest_checkin_time}',
  59. supplier_id={$supplier_id},
  60. hotel_status='$status',
  61. confirm_from={$confirm_from},
  62. purchase_name='{$procurement}',
  63. principal='{$principal}'
  64. where hotel_id={$hotel_id} and cancel_flag=0";
  65. writeLog(__FUNCTION__ . " sql= " . $sql);
  66. $result = $this->DBTool->execSql($sql);
  67. if ($result['code'] == "0") {
  68. $model = array(
  69. "user_id" => $user_id,
  70. "log_type" => 1,
  71. "hotel_id" => $hotel_id,
  72. "room_type" => 0,
  73. "log_desc" => "添加酒店产品"
  74. );
  75. $this->DBLog->insertLog($model, '添加酒店产品');
  76. }
  77. $data['code'] = $result['code'];
  78. $data['info'] = $result['info'];
  79. return $data;
  80. }
  81. //修改酒店产品
  82. function updateHotelProduct($model)
  83. {
  84. $user_id = $model['user_id'];
  85. //$room_type_sale = $model['room_type_sale'];
  86. $earliest_checkin_time = $model['earliest_checkin_time'];
  87. $hotel_id = $model['hotel_id'];
  88. $supplier_id = $model['supplier_id'];
  89. $confirm_from = $model['confirm_from'];
  90. $procurement = $model['procurement'];
  91. $principal = $model['principal']; //运营负责人
  92. $status = $model['hotel_status'];
  93. $a = isset($room_type_sale[0]) ? $room_type_sale[0] : "";
  94. if ($a == "," || $a == ",") {
  95. $data['code'] = "16";
  96. $data['info'] = "错误的请求参数";
  97. return $data;
  98. }
  99. $data = ifNullParam(array($hotel_id, $confirm_from, $supplier_id, $procurement));
  100. if ($data['code'] != "0") {
  101. return $data;
  102. }
  103. $sql = "update opera_hotel set update_user_id={$user_id},
  104. earliest_checkin_time='{$earliest_checkin_time}',
  105. supplier_id={$supplier_id},
  106. confirm_from={$confirm_from},
  107. hotel_status='$status',
  108. purchase_name='{$procurement}',
  109. principal='{$principal}'
  110. where hotel_id={$hotel_id} and cancel_flag=0";
  111. writeLog(__FUNCTION__ . " sql= " . $sql);
  112. $result = $this->DBTool->execSql($sql);
  113. if ($result['code'] == "0") {
  114. $model = array(
  115. "user_id" => $user_id,
  116. "log_type" => 1,
  117. "hotel_id" => $hotel_id,
  118. "room_type" => 0,
  119. "log_desc" => "修改酒店产品"
  120. );
  121. $this->DBLog->insertLog($model, '修改酒店产品');
  122. }
  123. $data['code'] = $result['code'];
  124. $data['info'] = $result['info'];
  125. return $data;
  126. }
  127. //进入页面得到列表 其实可以和下面搜索合并 搜索条件值没有默认给空就行
  128. function AllList($begin, $page_size, $hotel_name, $hotel_status, $user_id)
  129. {
  130. $sql = "select A.hotel_id,
  131. A.hotel_name,
  132. B.area_name,
  133. B.parent_area_name,
  134. S.supplier_name,
  135. P.purchaser_name,
  136. A.hotel_status,
  137. A.principal
  138. from opera_hotel as A
  139. LEFT JOIN base_area_view AS B ON A.area_id=B.area_id
  140. LEFT JOIN base_supplier AS S ON A.supplier_id=S.id
  141. LEFT JOIN base_supplier_purchase AS P ON A.PURCHASE_NAME=P.ID
  142. WHERE A.hotel_name LIKE '%$hotel_name%'
  143. AND A.hotel_status LIKE '%$hotel_status%'
  144. AND (A.hotel_status = 0 OR A.hotel_status =1)
  145. AND A.cancel_flag=0 ORDER BY
  146. A.CREATE_TIME desc limit $begin,$page_size";
  147. writeLog(__FUNCTION__ . " sql= " . $sql);
  148. $sqlcount = "select A.hotel_id,
  149. A.hotel_name,
  150. B.parent_area_name,
  151. B.area_name,
  152. S.supplier_name,
  153. P.purchaser_name,
  154. A.hotel_status,
  155. A.principal
  156. from opera_hotel as A
  157. LEFT JOIN base_area_view AS B ON A.area_id=B.area_id
  158. LEFT JOIN base_supplier AS S ON A.supplier_id=S.id
  159. LEFT JOIN base_supplier_purchase AS P ON A.PURCHASE_NAME=P.ID
  160. WHERE A.hotel_name LIKE '%$hotel_name%'
  161. AND A.hotel_status LIKE '%$hotel_status%'
  162. AND (A.hotel_status = 0 OR A.hotel_status =1)
  163. AND A.cancel_flag=0";
  164. writeLog(__FUNCTION__ . " sql= " . $sqlcount);
  165. $rest = $this->DBTool->queryBySql($sqlcount);
  166. $res = $this->DBTool->queryBySql($sql);
  167. $total = count($rest['rowset']);
  168. $total_page = ceil($total / $page_size);
  169. $data['total'] = $total;
  170. $data['total_page'] = $total_page;
  171. $data['code'] = $res['code'];
  172. $data['info'] = $res['info'];
  173. $data['rowset'] = $res['rowset'];
  174. // var_dump($data);
  175. return $data;
  176. }
  177. //搜索得到酒店列表
  178. function getHotelList($begin, $page_size, $area_id, $hotel_name, $hotel_status, $user_id)
  179. {
  180. //$page_size条数据
  181. $sql = "select A.hotel_id,
  182. A.hotel_name,
  183. B.parent_area_name,
  184. B.area_name,
  185. S.supplier_name,
  186. P.purchaser_name,
  187. A.hotel_status,
  188. A.principal
  189. from opera_hotel as A
  190. LEFT JOIN base_area_view AS B ON A.area_id=B.area_id
  191. LEFT JOIN base_supplier AS S ON A.supplier_id=S.id
  192. LEFT JOIN base_supplier_purchase AS P ON A.PURCHASE_NAME=P.ID
  193. WHERE A.hotel_name LIKE '%$hotel_name%'
  194. AND A.hotel_status LIKE '%$hotel_status%'
  195. AND (B.top_area_id='$area_id' OR B.parent_area_id='$area_id' OR B.area_id='$area_id')
  196. AND ($user_id = 1 or $user_id in (A.principal))
  197. AND A.cancel_flag=0
  198. ORDER BY A.CREATE_TIME desc limit $begin,$page_size";
  199. writeLog(__FUNCTION__ . " sql= " . $sql);
  200. //获取条数
  201. $sqlcount = "select A.hotel_id,
  202. A.hotel_name,
  203. B.parent_area_name,
  204. B.area_name,
  205. ifnull(S.supplier_name,''),
  206. P.purchaser_name,
  207. A.principal
  208. A.hotel_status from opera_hotel as A
  209. LEFT JOIN base_area_view AS B ON A.area_id=B.area_id
  210. LEFT JOIN base_supplier AS S ON A.supplier_id=S.id
  211. LEFT JOIN base_supplier_purchase AS P ON A.PURCHASE_NAME=P.ID
  212. WHERE A.hotel_name LIKE '%$hotel_name%'
  213. AND A.hotel_status LIKE '%$hotel_status%'
  214. AND (B.top_area_id='$area_id' OR B.parent_area_id='$area_id' OR B.area_id='$area_id')
  215. AND ($user_id = 1 or $user_id in (A.principal))
  216. AND A.cancel_flag=0";
  217. writeLog(__FUNCTION__ . " sql= " . $sqlcount);
  218. $res = $this->DBTool->queryBySql($sql);
  219. $rest = $this->DBTool->queryBySql($sqlcount);
  220. $total = count($rest['rowset']);
  221. $total_page = ceil($total / $page_size);
  222. $data['total'] = $total;
  223. $data['total_page'] = $total_page;
  224. $data['code'] = $res['code'];
  225. $data['info'] = $res['info'];
  226. $data['rowset'] = $res['rowset'];
  227. return $data;
  228. }
  229. //得到酒店信息
  230. function getUpHotelInfo($hotel_id)
  231. {
  232. $data = ifNullParam(array($hotel_id));
  233. if ($data['code'] != "0") {
  234. return $data;
  235. }
  236. $sql = "select A.hotel_id,A.hotel_name,A.earliest_checkin_time,(select parent_area_name_list from base_area_view where area_id=A.area_id) as hotel_area,A.supplier_id,A.confirm_from,
  237. ifnull((select purchaser_name from base_supplier_purchase where supplier_id=A.supplier_id and product_type=25 and cancel_flag=0),'') as purchaser_name,
  238. ifnull((select id from base_supplier_purchase where supplier_id=A.supplier_id and product_type=25 and cancel_flag=0),'') as purchaser_id,
  239. A.hotel_address ,A.hotel_status,A.principal from opera_hotel as A where A.hotel_id={$hotel_id} and A.cancel_flag=0";
  240. writeLog(__FUNCTION__ . " sql= " . $sql);
  241. $rowset = $this->DBTool->queryBySql($sql);
  242. $data['code'] = $rowset['code'];
  243. $data['info'] = $rowset['info'];
  244. if ($data['code'] != "0") {
  245. return $data;
  246. }
  247. $data['hotel_info'] = $rowset['rowset'][0];
  248. return $data;
  249. }
  250. }
  251. ?>