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.
 
 
 
 

547 lines
26 KiB

  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: fuhc
  5. * Date: 2017/4/14
  6. * Time: 11:42
  7. */
  8. //修改酒店订单
  9. require_once __DIR__ . '/../HotelLib.php';
  10. require_once __DIR__ . '/MakeHotelOrder.class.php';
  11. class HTUpdateOrderLevelLib extends HotelLib
  12. {
  13. // order_level 对酒店订单:订单操作状态(0:确认单 1:修改单 2:取消单)
  14. //1.入住需求
  15. //1.1修改入住需求 //用的原来的修改订单接口
  16. function orderUpdateCheckIn($param)
  17. {
  18. $MakeOrderLib = new MakeHotelOrder();
  19. $user_id = $param['user_id'];
  20. $hotel_id = $param['hotel_id'];
  21. $room_type = $param['room_type'];
  22. $org_id = $param['org_id'];
  23. $org_num = $param['org_num'];
  24. $room_list = $param['room_list'];
  25. $room_count = $param['room_count'];
  26. $cus_list = $param['cus_list'];
  27. $checkin_time = $param['checkin_time'];
  28. $start_date = $param['start_date'];
  29. $end_start = $param['end_date'];
  30. $if_cancel = $param['if_cancel'];
  31. $benefit = $param['benefit'];
  32. $total_commission = $param['total_commission'];
  33. $order_id = $param['order_id'];
  34. $org_name = $this->orgNameGet($org_id);
  35. $old_room_count = $this->roomCountGet($order_id);
  36. $sql = "SELECT A.PARENT_PROD_ID AS hotel_id,
  37. A.PROD_ID AS room_type,
  38. A.OUTSIDE_ORDER_NO AS outside_order_no,
  39. A.PROD_START_STATION_DATE AS start_date,
  40. A.PROD_END_STATION_DATE AS end_date,
  41. A.OUTSIDE_SALE_ORG_ID AS outside_sale_org_id,
  42. B.SUPPLIER_NAME as supplier_name
  43. FROM ORDER_MAIN AS A
  44. INNER JOIN BASE_SUPPLIER AS B ON B.ID = A.OUTSIDE_SALE_ORG_ID
  45. WHERE A.ORDER_ID = '{$order_id}'
  46. AND A.ORDER_VALID_STATUS=1
  47. AND A.CANCEL_FLAG = 0 LIMIT 1";
  48. $order = $this->DBTool->queryBySql($sql);
  49. $log_arr = array();
  50. if ($order['code'] != "0") return $order;
  51. // $log="修改入住需求:修改订单渠道【{$old_supplier_name}】为【{$org_name}】;
  52. // 修改渠道订单号【{$old_outside_order_no}】为【{$org_num}】;
  53. // 修改入住日期【{$old_start_date}】为【{$start_date}】;修改间夜数【{$old_room_count}】为【{$room_count}】";
  54. $old_hotel_id = $order['rowset'][0]['hotel_id'];
  55. $old_room_type = $order['rowset'][0]['room_type'];
  56. $old_outside_order_no = $order['rowset'][0]['outside_order_no'];
  57. $old_start_date = $order['rowset'][0]['start_date'];
  58. $old_end_date = $order['rowset'][0]['end_date'];
  59. $old_outside_sale_org_id = $order['rowset'][0]['outside_sale_org_id'];
  60. $old_supplier_name = $order['rowset'][0]['supplier_name'];
  61. $log_arr[] = $org_name == $old_supplier_name ? "" : "修改订单渠道【{$old_supplier_name}】为【{$org_name}】;";
  62. $log_arr[] = $org_num == $old_outside_order_no ? "" : "修改渠道订单号【{$old_outside_order_no}】为【{$org_num}】;";
  63. $log_arr[] = $start_date == $old_start_date ? "" : "修改入住日期【{$old_start_date}】为【{$start_date}】;";
  64. $log_arr[] = $room_count == $old_room_count ? "" : "修改间夜数【{$old_room_count}】为【{$room_count}】;";
  65. if (count($log_arr) <= 0) return array("code" => "0", "info" => "没有修改任务内容");
  66. if (count($log_arr) > 0) array_unshift($log_arr, "修改入住需求:");
  67. $rowset = $MakeOrderLib->makeOrderList($user_id, $hotel_id, $room_type, $org_id, $org_num, $room_list, $cus_list, $checkin_time, $if_cancel, $benefit, $total_commission, $order_id);
  68. if ($rowset['code'] != "0") return $rowset;
  69. // $sql = "SELECT PROD_ID, PARENT_PROD_ID FROM ORDER_MAIN WHERE ORDER_ID = $order_id AND CANCEL_FLAG=0";
  70. // $order = $this->DBTool->queryBySql($sql);
  71. $log = implode('', $log_arr);
  72. writeLog("log---log---" . $log);
  73. $model = array(
  74. "user_id" => $user_id,
  75. "log_type" => 3,
  76. "hotel_id" => $hotel_id,
  77. "room_type" => $room_type,
  78. "log_desc" => $log,
  79. "order_id" => $order_id
  80. );
  81. $this->DBLog->insertLog($model, '修改订单');
  82. if ($order_id != 0) {
  83. $this->setMemcache($order_id, 313);
  84. }
  85. $data['code'] = $rowset['code'];
  86. $data['info'] = $rowset['info'];
  87. return $data;
  88. }
  89. //1.1.1获取库存
  90. function stockGetList($param)
  91. {
  92. $hotel_id = $param['hotel_id'];
  93. $parent_room_type = $param['parent_room_type'];
  94. $room_type = $param['room_type'];
  95. $org_id = $param['org_id'];
  96. $start_date = $param['start_date'];
  97. $end_date = $param['end_date'];
  98. $nullP = ifNullParam(array($hotel_id, $parent_room_type, $room_type, $org_id, $start_date, $end_date));
  99. if ($nullP['code'] != "0") return $nullP;
  100. $sql = "CALL ht_get_room_stock({$hotel_id},{$parent_room_type},{$room_type},{$org_id},'{$start_date}','{$end_date}')";
  101. writeLog(__FUNCTION__ . " sql= " . $sql);
  102. $rowset = $this->DBTool->execProcedure($sql);
  103. $data['code'] = $rowset['code'];
  104. $data['info'] = $rowset['info'];
  105. $data['price_info_list'] = isset($rowset['rowset'][0]) ? $rowset['rowset'][0] : array();
  106. $data['stock_list'] = isset($rowset['rowset'][1]) ? $rowset['rowset'][1] : array();
  107. $data['order_list'] = $rowset['rowset'];
  108. return $data;
  109. }
  110. //1.2修改销售价
  111. function orderUpdateXSJ($param)
  112. {
  113. $order_id = $param['order_id'];
  114. $user_id = $param['user_id'];
  115. $room_list = $param['room_list'];
  116. $data = array();
  117. try {
  118. $this->DBTool->my_pdo->beginTransaction();
  119. //得到订单 是 录单还是直连
  120. // 556:直连 557:录单
  121. $order_property = $this->orderPropertyGet($order_id);
  122. $docking_type = $order_property['docking_type'];
  123. if ("556" == $docking_type) throw new PDOException("事务异常-直连订单不允许修改销售价");
  124. foreach ($room_list as $k => $v) {
  125. $order_price = $v['order_price'];
  126. $run_date = $v['run_date'];
  127. // if(''==trim($order_price))return array("code"=>"50orderUpdateXSJ","info"=>"参数错误!");
  128. // if(''==trim($run_date))return array("code"=>"50orderUpdateXSJ","info"=>"参数错误!");
  129. //根据修改的值从数据库中查询是否存在 若存在,则说明没有进行修改
  130. $sql_0 = "select count(*) as count from order_main
  131. where parent_order_id = '{$order_id}'
  132. and run_date = '{$run_date}'
  133. and order_price = '{$order_price}'
  134. and order_valid_status = 1
  135. and cancel_flag=0 limit 1";
  136. $data_0 = $this->DBTool->queryBySql($sql_0);
  137. if ($data_0['code'] != "0") throw new PDOException("事务异常");
  138. $count_0 = isset($data_0['rowset'][0]['count']) ? $data_0['rowset'][0]['count'] : "1";
  139. if ("1" == $count_0) return array("code" => "0", "info" => "您没有进行修改");
  140. //原来的销售价
  141. $sql_0_1 = "SELECT ORDER_PRICE AS old_order_price FROM order_main where parent_order_id = '{$order_id}'
  142. and run_date = '{$run_date}'
  143. and order_valid_status = 1
  144. and cancel_flag=0 limit 1";
  145. $data_0_0 = $this->DBTool->queryBySql($sql_0_1);
  146. $old_order_price = $data_0_0['rowset'][0]['old_order_price'];
  147. $sql_1 = "select ({$order_price}-base_price) as profit_value from order_main where parent_order_id = '{$order_id}'
  148. and run_date = '{$run_date}'
  149. and order_valid_status = 1
  150. and cancel_flag=0 limit 1";
  151. $data_1 = $this->DBTool->queryBySql($sql_1);
  152. $profit_value = 0;
  153. if ("0" == $data_1['code']) $profit_value = isset($data_1['rowset'][0]['profit_value']) ? $data_1['rowset'][0]['profit_value'] : "0";
  154. if ("0" != $data_1['code']) throw new PDOException("事务异常");
  155. //更改销售价和利润
  156. $sql_2 = "update order_main
  157. set order_price = '{$order_price}',
  158. profit_value=$profit_value,
  159. update_time = now(),
  160. update_user_id = '{$user_id}'
  161. where parent_order_id = '{$order_id}'
  162. and run_date = '{$run_date}'
  163. and order_valid_status = 1
  164. and cancel_flag=0";
  165. $data = $this->DBTool->execSql($sql_2);
  166. if ($data['code'] != "0") throw new PDOException("事务异常");
  167. //3.更改主订单的销售总价
  168. //3.1查到子订单销售单价的总和
  169. $sql_3_1 = "SELECT
  170. SUM(ORDER_PRICE) AS sum_order_price,
  171. SUM(PROFIT_VALUE) AS sum_profit_value
  172. FROM ORDER_MAIN
  173. WHERE PARENT_ORDER_ID = '{$order_id}'
  174. AND ORDER_VALID_STATUS = 1
  175. AND CANCEL_FLAG = 0 LIMIT 1";
  176. $rowset = $this->DBTool->queryBySql($sql_3_1);
  177. if ($rowset['code'] != "0") throw new PDOException("事务异常");
  178. $sum_order_price = isset($rowset['rowset'][0]['sum_order_price']) ? $rowset['rowset'][0]['sum_order_price'] : "-1";
  179. $sum_profit_value = isset($rowset['rowset'][0]['sum_profit_value']) ? $rowset['rowset'][0]['sum_profit_value'] : "-1";
  180. //3.2将销售单价总和更改到主订单
  181. $sql_3_2 = "UPDATE ORDER_MAIN
  182. SET ORDER_PRICE = '{$sum_order_price}',
  183. PROFIT_VALUE = '{$sum_profit_value}',
  184. UPDATE_USER_ID = '{$user_id}',
  185. UPDATE_TIME = NOW()
  186. WHERE ORDER_ID = '{$order_id}'
  187. AND ORDER_VALID_STATUS = 1
  188. AND CANCEL_FLAG = 0";
  189. $rowset = $this->DBTool->execSql($sql_3_2);
  190. if ($rowset['code'] != "0") throw new PDOException("事务异常");
  191. $model = array(
  192. "user_id" => $user_id,
  193. "log_type" => 3,
  194. "hotel_id" => "0",
  195. "room_type" => "0",
  196. "log_desc" => "修改销售价:修改【{$run_date}】销售价【{$old_order_price}】为【{$order_price}】",
  197. "order_id" => $order_id
  198. );
  199. $this->DBLog->insertLog($model, "修改订单");
  200. }
  201. $this->DBTool->my_pdo->commit();
  202. } catch (PDOException $ex) {
  203. $data['code'] = "17";
  204. $data['info'] = "事务异常";
  205. $this->DBTool->my_pdo->rollBack();
  206. }
  207. return $data;
  208. }
  209. //1.3修改采购价
  210. function orderUpdateCGJ($param)
  211. {
  212. $order_id = $param['order_id'];
  213. $user_id = $param['user_id'];
  214. $cus_list = $param['cus_list'];
  215. $data = array();
  216. try {
  217. $this->DBTool->my_pdo->beginTransaction();
  218. foreach ($cus_list as $k => $v) {
  219. $base_price = $v['base_price'];
  220. $run_date = $v['run_date'];
  221. //根据修改的值从数据库中查询是否存在 若存在,则说明没有进行修改
  222. $sql_0 = "select count(*) as count
  223. from order_main
  224. where parent_order_id = '{$order_id}'
  225. and run_date = '{$run_date}'
  226. and base_price = '{$base_price}'
  227. and order_valid_status = 1
  228. and cancel_flag = 0 limit 1";
  229. $data_0 = $this->DBTool->queryBySql($sql_0);
  230. if ($data_0['code'] != "0") throw new PDOException("事务异常11");
  231. $count_0 = $data_0['rowset'][0]['count'];
  232. if ("1" == $count_0) return array("code" => "0", "info" => "您没有进行修改");
  233. //原来的成本价
  234. $sql_0_1 = "SELECT BASE_PRICE AS old_base_price from order_main where parent_order_id = '{$order_id}'
  235. and run_date = '{$run_date}'
  236. and order_valid_status = 1
  237. and cancel_flag=0";
  238. writeLog($sql_0_1);
  239. $data_0_1 = $this->DBTool->queryBySql($sql_0_1);
  240. $old_base_price = $data_0_1['rowset'][0]['old_base_price'];
  241. $sql_1 = "select (order_price - {$base_price}) as profit_value from order_main where parent_order_id = '{$order_id}'
  242. and run_date = '{$run_date}'
  243. and order_valid_status = 1
  244. and cancel_flag=0";
  245. $data_1 = $this->DBTool->queryBySql($sql_1);
  246. $profit_value = 0;
  247. if ("0" == $data_1['code']) $profit_value = isset($data_1['rowset'][0]['profit_value']) ? $data_1['rowset'][0]['profit_value'] : "0";
  248. if ("0" != $data_1['code']) throw new PDOException("事务异常22");
  249. $status_arr1 = array("198", "382"); //需要生成修改单
  250. $cstr = "";
  251. $order_property = $this->orderPropertyGet($order_id);
  252. $order_status = $order_property['order_status'];
  253. $status_agree_update_arr = array("313", "198", "382"); //待发单-待安排-退改中
  254. if (!in_array($order_status, $status_agree_update_arr)) throw new PDOException("事务异常-目前只有待发单-待安排-退改中状态的订单允许进行修改");
  255. if (in_array($order_status, $status_arr1)) {
  256. $cstr = "order_level = '1',";
  257. $sql = "UPDATE ORDER_MAIN
  258. SET ORDER_LEVEL='1'
  259. WHERE (ORDER_ID = '{$order_id}' OR PARENT_ORDER_ID = '{$order_id}')
  260. and order_valid_status = 1
  261. and cancel_flag=0";
  262. writeLog("fuhc-" . $sql);
  263. $res = $this->DBTool->execSql($sql);
  264. if ($res['code'] != "0") throw new PDOException("事务异常cc");
  265. }
  266. $sql = "update order_main
  267. set base_price = '{$base_price}',
  268. profit_value=$profit_value,
  269. update_time = now(),{$cstr}
  270. update_user_id = '{$user_id}'
  271. where parent_order_id = '{$order_id}'
  272. and run_date = '{$run_date}'
  273. and order_valid_status = 1
  274. and cancel_flag=0";
  275. writeLog(__FUNCTION__ . "修改采购价 sql = 【" . $sql . "】");
  276. $data = $this->DBTool->execSql($sql);
  277. if ($data['code'] != "0") throw new PDOException("事务异常33");
  278. //3.更新主订单的成本价和利润
  279. //3.1查到子订单成本价和利润
  280. $sql_3_1 = "SELECT
  281. SUM(BASE_PRICE) AS sum_base_price,
  282. SUM(PROFIT_VALUE) AS sum_profit_value
  283. FROM ORDER_MAIN
  284. WHERE PARENT_ORDER_ID = '{$order_id}'
  285. AND ORDER_VALID_STATUS = 1
  286. AND CANCEL_FLAG = 0 LIMIT 1";
  287. $rowset = $this->DBTool->queryBySql($sql_3_1);
  288. if ($rowset['code'] != "0") throw new PDOException("事务异常44");
  289. $sum_base_price = isset($rowset['rowset'][0]['sum_base_price']) ? $rowset['rowset'][0]['sum_base_price'] : "-1";
  290. $sum_profit_value = isset($rowset['rowset'][0]['sum_profit_value']) ? $rowset['rowset'][0]['sum_profit_value'] : "-1";
  291. //3.2将销售单价总和更改到主订单
  292. $sql_3_2 = "UPDATE ORDER_MAIN
  293. SET BASE_PRICE = '{$sum_base_price}',
  294. PROFIT_VALUE = '{$sum_profit_value}',
  295. UPDATE_USER_ID = '{$user_id}',
  296. UPDATE_TIME = NOW()
  297. WHERE ORDER_ID = '{$order_id}'
  298. AND ORDER_VALID_STATUS = 1
  299. AND CANCEL_FLAG = 0";
  300. $rowset = $this->DBTool->execSql($sql_3_2);
  301. if ($rowset['code'] != "0") throw new PDOException("事务异常55");
  302. $model = array(
  303. "user_id" => $user_id,
  304. "log_type" => 3,
  305. "hotel_id" => "0",
  306. "room_type" => "0",
  307. "log_desc" => "修改采购价:修改【{$run_date}】采购价【{$old_base_price}】为【{$base_price}】",
  308. "order_id" => $order_id
  309. );
  310. $this->DBLog->insertLog($model, "修改订单");
  311. }
  312. $this->DBTool->my_pdo->commit();
  313. } catch (PDOException $ex) {
  314. $data['code'] = "17";
  315. $data['info'] = $ex->getMessage();
  316. $this->DBTool->my_pdo->rollBack();
  317. }
  318. return $data;
  319. }
  320. //修改客人信息
  321. function customerUpdate($param)
  322. {
  323. $order_id = $param['order_id'];
  324. $customer_name = $param['customer_name'];
  325. $customer_mobile = $param['customer_mobile'];
  326. $user_id = isset($param['user_id']) ? $param['user_id'] : "0";
  327. //原来的客人信息
  328. $sql_0 = "SELECT CUSTOMER_NAME AS customer_name,
  329. CUSTOMER_MOBILE as customer_mobile,
  330. ORDER_STATUS AS order_status
  331. FROM ORDER_MAIN
  332. WHERE ORDER_ID = '{$order_id}'
  333. AND ORDER_VALID_STATUS = 1
  334. AND CANCEL_FLAG = 0 LIMIT 1";
  335. $data = $this->DBTool->queryBySql($sql_0);
  336. $old_customer = $data['rowset'][0];
  337. $order_status = $data['rowset'][0]['order_status'];
  338. if ($old_customer['customer_name'] == $customer_name && $old_customer['customer_mobile'] == $customer_mobile) {
  339. return array("code" => "0", "info" => "客人信息没有修改");
  340. }
  341. $status_arr1 = array("198", "382");
  342. $cstr = "";
  343. if (in_array($order_status, $status_arr1)) {
  344. $cstr = "order_level = '1',";
  345. }
  346. $sql = "update order_main
  347. set customer_name = '$customer_name',
  348. customer_mobile = '$customer_mobile',
  349. update_user_id = '$user_id',{$cstr}
  350. update_time = now()
  351. where (parent_order_id = '$order_id' or order_id = '$order_id')
  352. and order_valid_status=1
  353. and cancel_flag = 0";
  354. writeLog(__FUNCTION__ . "修改客人信息 sql=" . $sql);
  355. $rowset = $this->DBTool->execSql($sql);
  356. $model = array(
  357. "user_id" => $user_id,
  358. "log_type" => 3,
  359. "hotel_id" => "0",
  360. "room_type" => "0",
  361. "log_desc" => "修改客人信息:修改客人信息【{$old_customer['customer_name']},{$old_customer['customer_mobile']}】为【{$customer_name},{$customer_mobile}】",
  362. "order_id" => $order_id
  363. );
  364. $this->DBLog->insertLog($model, '修改订单');
  365. return $rowset;
  366. }
  367. //新增订单备注
  368. function commentAdd($param)
  369. {
  370. $order_id = $param['order_id'];
  371. $comment_type = $param['comment_type'];
  372. if (!in_array($comment_type, array("0", "1"))) return array("code" => "20", "info" => "备注类型应为内部或公共!");
  373. $comment_txt = trim($param['comment_txt']);
  374. $user_id = isset($param['user_id']) ? $param['user_id'] : "0";
  375. $rowset = array();
  376. try {
  377. $this->DBTool->my_pdo->beginTransaction();
  378. $sql1 = "insert into order_comment (order_id,comment_type,comment_txt,create_user_id,create_time,update_user_id,update_time)
  379. values('$order_id','$comment_type','$comment_txt','$user_id',now(),'$user_id',now())";
  380. //0:内部备注
  381. $log = '';
  382. if ("0" == $comment_type) {
  383. writeLog(__FUNCTION__ . "sql1=[" . $sql1 . "]");
  384. $rowset = $this->DBTool->execSql($sql1);
  385. if ($rowset['code'] != "0") throw new PDOException("事务异常22");
  386. $log = "添加备注:【内部备注】【{$comment_txt}】";
  387. }
  388. //1:公共备注
  389. $sql2 = "";
  390. if ("1" == $comment_type) {
  391. //大兵哥说公共备注也不生成修改单 2017/4/21
  392. // $order_property = $this->orderPropertyGet($order_id);
  393. // $order_status = $order_property['order_status'];
  394. // $status_agree_update_arr = ["313","198","201"]; //待发单-待安排-退改中
  395. // if(!in_array($order_status,$status_agree_update_arr))throw new PDOException("事务异常-目前只有待发单-待安排-退改中状态的订单允许进行修改");
  396. // $status_arr1 = ["198", "201"]; //需要生成修改单
  397. // if (in_array($order_status, $status_arr1)) {
  398. // $sql2 = "update order_main
  399. // set order_level = 1,
  400. // update_user_id = '$user_id',
  401. // update_time = now()
  402. // where (parent_order_id = $order_id or order_id = $order_id)
  403. // and order_valid_status=1
  404. // and cancel_flag = 0";
  405. // $rowset = $this->DBTool->execSql($sql1);
  406. // if($rowset['code']!="0")throw new PDOException("事务异常55");
  407. // $rowset = $this->DBTool->execSql($sql2);
  408. // if($rowset['code']!="0")throw new PDOException("事务异常33");
  409. // }else{
  410. $rowset = $this->DBTool->execSql($sql1);
  411. if ($rowset['code'] != "0") throw new PDOException("事务异常44");
  412. // }
  413. writeLog(__FUNCTION__ . "sql1=[" . $sql1 . "]sql2=[" . $sql2 . "]");
  414. $log = "添加备注:【公共备注】【{$comment_txt}】";
  415. }
  416. $model = array(
  417. "user_id" => $user_id,
  418. "log_type" => 3,
  419. "hotel_id" => "0",
  420. "room_type" => "0",
  421. "log_desc" => $log,
  422. "order_id" => $order_id
  423. );
  424. $this->DBLog->insertLog($model, '修改订单');
  425. $this->DBTool->my_pdo->commit();
  426. } catch (PDOException $ex) {
  427. $data['code'] = "17";
  428. $data['info'] = $ex->getMessage();
  429. $this->DBTool->my_pdo->rollBack();
  430. }
  431. return $rowset;
  432. }
  433. //删除订单备注
  434. function commentDel($param)
  435. {
  436. $order_id = $param['order_id'];
  437. $comment_id = $param['comment_id'];
  438. $user_id = isset($param['user_id']) ? $param['user_id'] : "0";
  439. $sql_0 = "SELECT COMMENT_TXT as comment_txt,
  440. COMMENT_TYPE as comment_type,
  441. CASE COMMENT_TYPE WHEN 0 THEN '内部备注'
  442. WHEN 1 THEN '公共备注' END AS comment_type_desc
  443. FROM ORDER_COMMENT WHERE ID ='{$comment_id}' AND CANCEL_FLAG = 0 LIMIT 1";
  444. $comment = $this->DBTool->queryBySql($sql_0);
  445. $old_comment_txt = $comment['rowset'][0]['comment_txt'];
  446. $old_comment_type_desc = $comment['rowset'][0]['comment_type_desc'];
  447. $sql = "UPDATE ORDER_COMMENT
  448. SET CANCEL_FLAG=1,
  449. UPDATE_USER_ID='$user_id',
  450. UPDATE_TIME=NOW()
  451. WHERE ID = $comment_id AND CANCEL_FLAG=0";
  452. writeLog(__FUNCTION__ . "sql=[" . $sql . "]");
  453. $rowset = $this->DBTool->execSql($sql);
  454. $model = array(
  455. "user_id" => $user_id,
  456. "log_type" => 3,
  457. "hotel_id" => "0",
  458. "room_type" => "0",
  459. "log_desc" => "删除备注:【{$old_comment_type_desc}】【{$old_comment_txt}】",
  460. "order_id" => $order_id
  461. );
  462. $this->DBLog->insertLog($model, '修改订单');
  463. return $rowset;
  464. }
  465. //根据订单号得到订单当前状态,是录单或直连
  466. private function orderPropertyGet($order_id)
  467. {
  468. $sql = "select order_status,docking_type
  469. from order_main
  470. where order_id = '{$order_id}'
  471. and order_valid_status = 1
  472. and cancel_flag = 0 limit 1";
  473. $data = $this->DBTool->queryBySql($sql);
  474. return $data[0];
  475. }
  476. //根据父订单号统计房间数量
  477. private function roomCountGet($order_id)
  478. {
  479. $sql = "SELECT COUNT(*) AS room_count FROM ORDER_MAIN
  480. WHERE PARENT_ORDER_ID = '{$order_id}'
  481. AND ORDER_VALID_STATUS = 1
  482. AND CANCEL_FLAG = 0 LIMIT 1";
  483. $rowset = $this->DBTool->queryBySql($sql);
  484. return $rowset['rowset'][0]['room_count'];
  485. }
  486. //根据渠道id得到渠道名称
  487. private function orgNameGet($id)
  488. {
  489. $sql = "SELECT SUPPLIER_NAME AS supplier_name
  490. FROM base_supplier
  491. WHERE ID = '{$id}' AND CANCEL_FLAG = 0";
  492. $rowset = $this->DBTool->queryBySql($sql);
  493. return $rowset['rowset'][0]['supplier_name'];
  494. }
  495. }