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.

HTOrderOperation.class.php 44 KiB

3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194
  1. <?php
  2. require_once __DIR__.'/../HotelLib.php';
  3. class HTOrderOperation extends HotelLib
  4. {
  5. //渠道接单
  6. function getGetOrder($param){
  7. $order_id = $param['order_id'];
  8. $order_status = $param['order_status'];
  9. $channel_order_status = $param['channel_order_status'];
  10. $merge_status = $param['merge_status'];
  11. $user_id = $param['user_id'];
  12. $outside_order_no = $param['outside_order_no'];
  13. $interface_order_id = $param['interface_order_id'];
  14. $sql0 = "select count(*) as count from order_main
  15. where order_id = '$order_id' and order_status='$order_status' and channel_order_status='$channel_order_status'
  16. and order_valid_status = '1' and cancel_flag = '0'";
  17. writeLog(__FUNCTION__ . " sql= " . $sql0);
  18. $rowset = $this->DBTool->queryBySql($sql0);
  19. if($rowset['code'] != '0') return array('code'=> '1','info'=>'接口错误');
  20. $count = isset($rowset['rowset'][0]['count']) ? $rowset['rowset'][0]['count'] : 0;
  21. if($count == 0){
  22. return array('code'=>'1','info'=>'订单状态已改变,请重新刷新页面');
  23. }
  24. $this->DBTool->my_pdo->beginTransaction();
  25. $sql = "update order_main set channel_order_status = '551',
  26. update_time=now(),
  27. update_user_id='$user_id'
  28. where (order_id = '$order_id' or parent_order_id = '$order_id') and order_valid_status = '1' and cancel_flag ='0' ";
  29. writeLog(__FUNCTION__ . " sql= " . $sql);
  30. $res = $this->DBTool->execSql($sql);
  31. if ($res['code'] != '0') return array('code'=>'2','info'=>'渠道接单失败');
  32. $param_s = array(
  33. 'OrderID' => $outside_order_no,
  34. 'InterfaceConfirmNo' => '',
  35. 'OrderStatus' => '3',
  36. 'InterFaceSendID' => $interface_order_id,
  37. 'channelId' => '1'
  38. );
  39. $setFlag = $this->set($param_s);
  40. if($setFlag['code'] != '0') {
  41. $this->DBTool->my_pdo->rollBack();
  42. return array('code'=>'1','info'=>'渠道接单失败');
  43. }
  44. $this->DBTool->my_pdo->commit();
  45. $model = array(
  46. "user_id" => $user_id,
  47. "log_type" => 3,
  48. "hotel_id" => "0",
  49. "room_type" => "0",
  50. "log_desc" => "接受渠道订单",
  51. "order_id" => $order_id
  52. );
  53. $this->DBLog->insertLog($model, "接受渠道订单");
  54. $model = array(
  55. "user_id" => $user_id,
  56. "log_type" => 3,
  57. "hotel_id" => "0",
  58. "room_type" => "0",
  59. "log_desc" => "渠道发送确认单",
  60. "order_id" => $order_id
  61. );
  62. $this->DBLog->insertLog($model, "渠道发送确认单");
  63. return array('code'=>'0','info'=>'渠道接单成功');
  64. }
  65. //渠道拒单
  66. function getRefuseOrder($param){
  67. $order_id = $param['order_id'];
  68. $order_status = $param['order_status'];
  69. $channel_order_status = $param['channel_order_status'];
  70. $merge_status = $param['merge_status'];
  71. $user_id = $param['user_id'];
  72. $outside_order_no = $param['outside_order_no'];
  73. $interface_order_id = $param['interface_order_id'];
  74. $sql0 = "select count(*) as count from order_main
  75. where order_id = '$order_id' and order_status='$order_status' and channel_order_status='$channel_order_status'
  76. and order_valid_status = '1' and cancel_flag = '0'";
  77. $rowset = $this->DBTool->queryBySql($sql0);
  78. if($rowset['code'] != '0') return array('code'=> '1','info'=>'接口错误');
  79. $count = isset($rowset['rowset'][0]['count']) ? $rowset['rowset'][0]['count'] : 0;
  80. if($count == 0){
  81. return array('code'=>'1','info'=>'订单状态已改变,请重新刷新页面');
  82. }
  83. $this->DBTool->my_pdo->beginTransaction();
  84. if ($merge_status == '2'){//渠道 待处理 订单 待发单
  85. $sql = "update order_main set channel_order_status = '552',order_status = '148',order_level='2',order_valid_status='0',
  86. update_time = now(),
  87. update_user_id = '$user_id'
  88. where (order_id = '$order_id' or parent_order_id = '$order_id') and order_valid_status = '1' and cancel_flag = '0'";
  89. $res = $this->DBTool->execSql($sql);
  90. if($res['code']!="0")return array("code"=>"1","info"=>"渠道据单失败");
  91. $cancel_flag = 1;
  92. $sql1 = "CALL ht_cancel_order('" . $user_id . "','" . $order_id . "',$cancel_flag)";
  93. $res = $this->DBTool->execProcedure($sql1);
  94. } else if($merge_status == '3'){//渠道 待处理 订单 待安排
  95. $sql = "update order_main set channel_order_status = '552',
  96. update_time = now(),
  97. update_user_id = '$user_id'
  98. where (order_id = '$order_id' or parent_order_id = '$order_id') and order_valid_status = '1' and cancel_flag = '0'";
  99. $res = $this->DBTool->execSql($sql);
  100. } else {
  101. }
  102. writeLog(__FUNCTION__ . " sql= " . $sql);
  103. // $res = $this->DBTool->execSql($sql);
  104. if ($res['code'] == '0'){
  105. $param_s = array(
  106. 'OrderID' => $outside_order_no,
  107. 'InterfaceConfirmNo' => '',
  108. 'OrderStatus' => '4',
  109. 'InterFaceSendID' => $interface_order_id,
  110. 'channelId' => '1'
  111. );
  112. $setFlag = $this->set($param_s);
  113. if($setFlag['code'] != '0') {
  114. $this->DBTool->my_pdo->rollBack();
  115. return array('code'=>'1','info'=>'渠道拒单失败');
  116. }
  117. $this->DBTool->my_pdo->commit();
  118. $model = array(
  119. "user_id" => $user_id,
  120. "log_type" => 3,
  121. "hotel_id" => "0",
  122. "room_type" => "0",
  123. "log_desc" => "拒绝渠道订单",
  124. "order_id" => $order_id
  125. );
  126. $this->DBLog->insertLog($model, "拒绝渠道订单");
  127. return array('code'=>'0','info'=>'渠道拒单成功');
  128. }else {
  129. return array('code'=>'1','info'=>'渠道拒单失败');
  130. }
  131. }
  132. //渠道同意申请取消 包含取消
  133. function getAgreeApply($param){
  134. $order_id = $param['order_id'];
  135. $order_status = $param['order_status'];
  136. $channel_order_status = $param['channel_order_status'];
  137. $merge_status = $param['merge_status'];
  138. $user_id = $param['user_id'];
  139. $outside_order_no = $param['outside_order_no'];
  140. $interface_order_id = $param['interface_order_id'];
  141. $sql0 = "select count(*) as count from order_main
  142. where order_id = '$order_id' and order_status='$order_status' and channel_order_status='$channel_order_status'
  143. and order_valid_status = '1' and cancel_flag = '0'";
  144. $rowset = $this->DBTool->queryBySql($sql0);
  145. if($rowset['code'] != '0') return array('code'=> '1','info'=>'接口错误');
  146. $count = isset($rowset['rowset'][0]['count']) ? $rowset['rowset'][0]['count'] : 0;
  147. if($count == 0){
  148. return array('code'=>'1','info'=>'订单状态已改变,请重新刷新页面');
  149. }
  150. $this->DBTool->my_pdo->beginTransaction();
  151. $sql = "update order_main set channel_order_status = '563',order_status = '148',order_level='2',order_valid_status='0',
  152. update_time = now(),
  153. update_user_id = '$user_id'
  154. where (order_id = '$order_id' or parent_order_id = '$order_id') and order_valid_status = '1' and cancel_flag = '0'";
  155. writeLog(__FUNCTION__."$sql=".$sql);
  156. $res = $this -> DBTool -> execSql($sql);
  157. if($res['code'] != '0') return array("code"=>"1","info"=>"渠道同意申请取消失败");
  158. $cancel_flag = 1;
  159. $sql2 = "CALL ht_cancel_order('" . $user_id . "','" . $order_id . "',$cancel_flag)";
  160. $res = $this->DBTool->execProcedure($sql2);
  161. if($res['code'] != '0') return array("code"=>"1","info"=>"接口错误");
  162. // if($res['code'] == '0'){
  163. $param_s = array(
  164. 'OrderID' => $outside_order_no,
  165. 'InterfaceConfirmNo' => '',
  166. 'OrderStatus' => '3',
  167. 'InterFaceSendID' => $interface_order_id,
  168. 'channelId' => '1'
  169. );
  170. $setFlag = $this ->set($param_s);
  171. if($setFlag['code'] != '0'){
  172. $this -> DBTool -> my_pdo -> rollBack();
  173. return array('code'=>'1','info'=>'渠道同意申请取消失败');
  174. }
  175. $this -> DBTool -> my_pdo -> commit();
  176. $model = array(
  177. "user_id" => $user_id,
  178. "log_type" => 3,
  179. "hotel_id" => "0",
  180. "room_type" => "0",
  181. "log_desc" => "同意渠道取消",
  182. "order_id" => $order_id
  183. );
  184. $this->DBLog->insertLog($model, "同意渠道取消");
  185. $model = array(
  186. "user_id" => $user_id,
  187. "log_type" => 3,
  188. "hotel_id" => "0",
  189. "room_type" => "0",
  190. "log_desc" => "取消订单",
  191. "order_id" => $order_id
  192. );
  193. $this->DBLog->insertLog($model, "取消订单");
  194. return array('code'=>'0','info'=>'渠道同意申请取消成功');
  195. // } else {
  196. // return ['code'=>'1','info'=>'渠道同意申请取消失败'];
  197. // }
  198. }
  199. //渠道拒绝申请取消
  200. function getRefuseApply($param){
  201. $order_id = $param['order_id'];
  202. $order_status = $param['order_status'];
  203. $channel_order_status = $param['channel_order_status'];
  204. $merge_status = $param['merge_status'];
  205. $user_id = $param['user_id'];
  206. $outside_order_no = $param['outside_order_no'];
  207. $interface_order_id = $param['interface_order_id'];
  208. $sql0 = "select count(*) as count from order_main
  209. where order_id = '$order_id' and order_status='$order_status' and channel_order_status='$channel_order_status'
  210. and order_valid_status = '1' and cancel_flag = '0'";
  211. $rowset = $this->DBTool->queryBySql($sql0);
  212. if($rowset['code'] != '0') return array('code'=> '1','info'=>'接口错误');
  213. $count = isset($rowset['rowset'][0]['count']) ? $rowset['rowset'][0]['count'] : 0;
  214. if($count == 0){
  215. return array('code'=>'1','info'=>'订单状态已改变,请重新刷新页面');
  216. }
  217. $this->DBTool->my_pdo->beginTransaction();
  218. if($merge_status == '30'){
  219. $sql = "update order_main set channel_order_status = '554',order_status = '314',
  220. update_time = now(),
  221. update_user_id = '$user_id'
  222. where (order_id = '$order_id' or parent_order_id = '$order_id') and order_valid_status = '1' and cancel_flag = '0'";
  223. } else {
  224. $sql = "update order_main set channel_order_status = '554',
  225. update_time = now(),
  226. update_user_id = '$user_id'
  227. where (order_id = '$order_id' or parent_order_id = '$order_id') and order_valid_status = '1' and cancel_flag = '0'";
  228. }
  229. writeLog(__FUNCTION__."$sql=".$sql);
  230. $res = $this -> DBTool -> execSql($sql);
  231. if($res['code'] == '0'){
  232. $param_s = array(
  233. 'OrderID' => $outside_order_no,
  234. 'InterfaceConfirmNo' => '',
  235. 'OrderStatus' => '4',
  236. 'InterFaceSendID' => $interface_order_id,
  237. 'channelId' => '1'
  238. );
  239. $setFlag = $this ->set($param);
  240. if($setFlag['code'] != '0'){
  241. $this -> DBTool -> my_pdo -> rollBack();
  242. return array('code'=>'1','info'=>'渠道申请取消失败');
  243. }
  244. $this -> DBTool -> my_pdo -> commit();
  245. $model = array(
  246. "user_id" => $user_id,
  247. "log_type" => 3,
  248. "hotel_id" => "0",
  249. "room_type" => "0",
  250. "log_desc" => "拒绝渠道取消",
  251. "order_id" => $order_id
  252. );
  253. $this->DBLog->insertLog($model, "拒绝渠道取消");
  254. return array('code'=>'0','info'=>'渠道申请取消成功');
  255. } else {
  256. return array('code'=>'1','info'=>'渠道申请取消失败');
  257. }
  258. }
  259. //发单
  260. function getSendOrder($param){
  261. $order_id = $param['order_id'];
  262. $order_status = $param['order_status'];
  263. $channel_order_status = $param['channel_order_status'];
  264. $merge_status = $param['merge_status'];
  265. $user_id = $param['user_id'];
  266. $sql0 = "select count(*) as count from order_main
  267. where order_id = '$order_id' and order_status='$order_status' and channel_order_status='$channel_order_status'
  268. and order_valid_status = '1' and cancel_flag = '0'";
  269. $rowset = $this->DBTool->queryBySql($sql0);
  270. if($rowset['code'] != '0') return array('code'=> '1','info'=>'接口错误');
  271. $count = isset($rowset['rowset'][0]['count']) ? $rowset['rowset'][0]['count'] : 0;
  272. if($count == 0){
  273. return array('code'=>'1','info'=>'订单状态已改变,请重新刷新页面');
  274. }
  275. $sql = "update order_main set order_status = '198',
  276. update_time = now(),
  277. update_user_id = '$user_id'
  278. where (order_id = '$order_id' or parent_order_id = '$order_id') and order_valid_status = '1' and cancel_flag = '0'";
  279. writeLog(__FUNCTION__."$sql=".$sql);
  280. $res = $this -> DBTool -> execSql($sql);
  281. $model = array(
  282. "user_id" => $user_id,
  283. "log_type" => 3,
  284. "hotel_id" => "0",
  285. "room_type" => "0",
  286. "log_desc" => "发送确认单",
  287. "order_id" => $order_id
  288. );
  289. $this->DBLog->insertLog($model, "发单");
  290. return $res;
  291. }
  292. //确认单
  293. function getRightOrder($param){
  294. $order_id = $param['order_id'];
  295. $order_status = $param['order_status'];
  296. $channel_order_status = $param['channel_order_status'];
  297. $merge_status = $param['merge_status'];
  298. $user_id = $param['user_id'];
  299. $order_right_id = $param['order_right_id'];
  300. $docking = $param['docking'];
  301. $outside_order_no = $param['outside_order_no'];
  302. $interface_order_id = $param['interface_order_id'];
  303. $sql0 = "select count(*) as count from order_main
  304. where order_id = '$order_id' and order_status='$order_status' and channel_order_status='$channel_order_status'
  305. and order_valid_status = '1' and cancel_flag = '0'";
  306. $rowset = $this->DBTool->queryBySql($sql0);
  307. if($rowset['code'] != '0') return array('code'=> '1','info'=>'接口错误');
  308. $count = isset($rowset['rowset'][0]['count']) ? $rowset['rowset'][0]['count'] : 0;
  309. if($count == 0){
  310. return array('code'=>'1','info'=>'订单状态已改变,请重新刷新页面');
  311. }
  312. if($docking == '556'){//直连
  313. // $tt = '';
  314. // if($merge_status == '3'){
  315. $this->DBTool->my_pdo->beginTransaction();
  316. $tt = 'channel_order_status="551",';
  317. // }
  318. $sql = "update order_main set order_status = '314',order_confirm_code = '$order_right_id',$tt
  319. order_level = '0',update_time = now(),update_user_id = '$user_id' where (order_id = '$order_id' or parent_order_id = '$order_id')
  320. and order_valid_status = '1' and cancel_flag = '0'";
  321. writeLog(__FUNCTION__."$sql=".$sql);
  322. $res = $this -> DBTool -> execSql($sql);
  323. //渠道推送
  324. if ($res['code'] == '0'){
  325. $cancel_status = '';
  326. if($merge_status == '27' || $merge_status =='35'){
  327. $cancel_status = 4;
  328. }else{
  329. $cancel_status = 3;
  330. }
  331. $param_s = array(
  332. 'OrderID' => $outside_order_no,
  333. 'InterfaceConfirmNo' => '',
  334. 'OrderStatus' => $cancel_status,
  335. 'InterFaceSendID' => $interface_order_id,
  336. 'channelId' => '1'
  337. );
  338. $setFlag = $this->set($param_s);
  339. if($setFlag['code'] != '0') {
  340. $this->DBTool->my_pdo->rollBack();
  341. return array('code'=>'1','info'=>'确认失败');
  342. }
  343. $this->DBTool->my_pdo->commit();
  344. //记录日志
  345. if($merge_status == '3'){
  346. $model = array(
  347. "user_id" => $user_id,
  348. "log_type" => 3,
  349. "hotel_id" => "0",
  350. "room_type" => "0",
  351. "log_desc" => "接受取消订单",
  352. "order_id" => $order_id
  353. );
  354. $this->DBLog->insertLog($model, "接受取消订单");
  355. }else{
  356. }
  357. $model = array(
  358. "user_id" => $user_id,
  359. "log_type" => 3,
  360. "hotel_id" => "0",
  361. "room_type" => "0",
  362. "log_desc" => "确认订单,确认号{$order_right_id}",
  363. "order_id" => $order_id
  364. );
  365. $this->DBLog->insertLog($model, "确认单");
  366. return array('code'=>'0','info'=>'确认成功');
  367. } else {
  368. return array('code'=>'1','info'=>'确认失败');
  369. }
  370. }else{//录单
  371. $sql2 = "update order_main set order_status = '314',order_confirm_code = '$order_right_id',
  372. order_level = '0',update_time = now(),update_user_id = '$user_id' where (order_id = '$order_id' or parent_order_id = '$order_id')
  373. and order_valid_status = '1' and cancel_flag = '0'";
  374. writeLog(__FUNCTION__."sql=".$sql2);
  375. $res = $this -> DBTool -> execSql($sql2);
  376. $model = array(
  377. "user_id" => $user_id,
  378. "log_type" => 3,
  379. "hotel_id" => "0",
  380. "room_type" => "0",
  381. "log_desc" => "确认订单,确认号{$order_right_id}",
  382. "order_id" => $order_id
  383. );
  384. $this->DBLog->insertLog($model, "确认单");
  385. return $res;
  386. }
  387. }
  388. //取消单
  389. function getCancelOrder($param){
  390. $order_id = $param['order_id'];
  391. $order_status = $param['order_status'];
  392. $channel_order_status = $param['channel_order_status'];
  393. $merge_status = $param['merge_status'];
  394. $user_id = $param['user_id'];
  395. $docking = $param['docking'];
  396. $outside_order_no = $param['outside_order_no'];
  397. $interface_order_id = $param['interface_order_id'];
  398. $sql = "select count(*) as count from order_main
  399. where order_id = '$order_id' and order_status='$order_status' and channel_order_status='$channel_order_status'
  400. and order_valid_status = '1' and cancel_flag = '0'";
  401. $rowset = $this->DBTool->queryBySql($sql);
  402. if($rowset['code'] != '0') return array('code'=> '1','info'=>'接口错误');
  403. writeLog(__FUNCTION__."sql=".$sql);
  404. // $count = isset($rowset['rowset'][0]['count']) ? $rowset['rowset'][0]['count'] : 0;
  405. $count = $rowset['rowset'][0]['count'];
  406. if($count == 0){
  407. return array('code'=>'1','info'=>'订单状态已改变,请重新刷新页面');
  408. }
  409. if($docking =='556' && $merge_status == '27'){//直连 申请取消状态下的取消单
  410. $this->DBTool->my_pdo->beginTransaction();
  411. // $temp = '';
  412. // if ($merge_status == '27'){ //渠道 申请取消 订单 待安排
  413. $temp = 'channel_order_status = 563,';
  414. // }
  415. $sql1 = "update order_main set order_status= '148',order_level='2',order_valid_status='0',$temp
  416. update_time = now(),
  417. update_user_id = '$user_id'
  418. where (order_id = '$order_id' or parent_order_id = '$order_id') and order_valid_status = '1' and cancel_flag = '0'";
  419. $res = $this->DBTool->execSql($sql1);
  420. if($res['code']!="0")return array("code"=>"1","info"=>"取消单失败");
  421. $cancel_flag = 1;
  422. $sql2 = "CALL ht_cancel_order('" . $user_id . "','" . $order_id . "',$cancel_flag)";
  423. $res = $this->DBTool->execProcedure($sql2);
  424. if($res['code'] != '0') return array("code"=>"1","info"=>"取消单失败");
  425. $cancel_status = '';
  426. if($merge_status == '27'){
  427. $cancel_status = 3;
  428. }else{
  429. $cancel_status = 4;
  430. }
  431. $param_s = array(
  432. 'OrderID' => $outside_order_no,
  433. 'InterfaceConfirmNo' => '',
  434. 'OrderStatus' => $cancel_status,
  435. 'InterFaceSendID' => $interface_order_id,
  436. 'channelId' => '1'
  437. );
  438. $setFlag = $this->set($param_s);
  439. if($setFlag['code'] != '0'){
  440. $this -> DBTool -> my_pdo -> rollBack();
  441. return array('code'=>'1','info'=>'取消单失败');
  442. }
  443. $this -> DBTool -> my_pdo -> commit();
  444. if($merge_status == '27'){
  445. $model = array(
  446. "user_id" => $user_id,
  447. "log_type" => 3,
  448. "hotel_id" => "0",
  449. "room_type" => "0",
  450. "log_desc" => "拒绝取消订单",
  451. "order_id" => $order_id
  452. );
  453. $this->DBLog->insertLog($model, "拒绝取消订单");
  454. }
  455. $model = array(
  456. "user_id" => $user_id,
  457. "log_type" => 3,
  458. "hotel_id" => "0",
  459. "room_type" => "0",
  460. "log_desc" => "取消订单",
  461. "order_id" => $order_id
  462. );
  463. $this->DBLog->insertLog($model, "取消单");
  464. return array('code'=>'0','info'=>'取消单成功');
  465. }else{//录单
  466. $sql_1 = "update order_main set order_status= '148',order_level='2',order_valid_status='0',
  467. update_time = now(),
  468. update_user_id = '$user_id'
  469. where (order_id = '$order_id' or parent_order_id = '$order_id') and order_valid_status = '1' and cancel_flag = '0'";
  470. writeLog(__FUNCTION__."sql=".$sql_1);
  471. $res = $this->DBTool->execSql($sql_1);
  472. if($res['code']!="0")return array("code"=>"1","info"=>"取消单失败");
  473. $cancel_flag = 1;
  474. $sql_2 = "CALL ht_cancel_order('" . $user_id . "','" . $order_id . "',$cancel_flag)";
  475. $res = $this->DBTool->execProcedure($sql_2);
  476. $model = array(
  477. "user_id" => $user_id,
  478. "log_type" => 3,
  479. "hotel_id" => "0",
  480. "room_type" => "0",
  481. "log_desc" => "取消订单",
  482. "order_id" => $order_id
  483. );
  484. $this->DBLog->insertLog($model, "取消单");
  485. return $res;
  486. }
  487. }
  488. //退改
  489. function getRefundOrder($param){
  490. $order_id = $param['order_id'];
  491. $merge_status = $param['merge_status'];
  492. $user_id = $param['user_id'];
  493. $channel_order_status = $param['channel_order_status'];
  494. $order_status = $param['order_status'];
  495. $cancel_reason = $param['cancel_reason'];
  496. $sql = "select count(*) as count from order_main
  497. where order_id = '$order_id' and order_status='$order_status' and channel_order_status='$channel_order_status'
  498. and order_valid_status = '1' and cancel_flag = '0'";
  499. $rowset = $this->DBTool->queryBySql($sql);
  500. if($rowset['code'] != '0') return array('code'=> '1','info'=>'接口错误');
  501. $count = isset($rowset['rowset'][0]['count']) ? $rowset['rowset'][0]['count'] : 0;
  502. if($count == 0){
  503. return array('code'=>'1','info'=>'订单状态已改变,请重新刷新页面');
  504. }
  505. $sql1 = "update order_main set order_status = '382',
  506. update_time = now(),
  507. update_user_id = '$user_id'
  508. where (order_id = '$order_id' or parent_order_id = '$order_id') and order_valid_status = '1' and cancel_flag = '0'";
  509. writeLog(__FUNCTION__."sql=".$sql1);
  510. $res = $this -> DBTool -> execSql($sql1);
  511. if($res['code'] != '0') return array('code'=>'1','info'=>'退改失败');
  512. // $sql2 = "insert into order_comment(order_id,comment_type,comment_txt,create_user_id,create_time,update_user_id,update_time)
  513. // values('$order_id',2,'$cancel_reason','$user_id',now(),'$user_id',now())";
  514. $sql2 = "insert into order_ht_apply_bounce(order_id,reason,create_user_id,create_time,update_user_id,update_time) values ('$order_id','$cancel_reason','$user_id',now(),'$user_id',now())";
  515. $res = $this->DBTool->execSql($sql2);
  516. $model = array(
  517. "user_id" => $user_id,
  518. "log_type" => 3,
  519. "hotel_id" => "0",
  520. "room_type" => "0",
  521. "log_desc" => "发起退改,退改原因:{$cancel_reason}",
  522. "order_id" => $order_id
  523. );
  524. $this->DBLog->insertLog($model, "退改");
  525. return $res;
  526. }
  527. //取消退改
  528. function getCancelRefundOrder($param){
  529. $order_id = $param['order_id'];
  530. $merge_status = $param['merge_status'];
  531. $user_id = $param['user_id'];
  532. $channel_order_status = $param['channel_order_status'];
  533. $order_status = $param['order_status'];
  534. $sql = "select count(*) as count from order_main
  535. where order_id = '$order_id' and order_status='$order_status' and channel_order_status='$channel_order_status'
  536. and order_valid_status = '1' and cancel_flag = '0'";
  537. $rowset = $this->DBTool->queryBySql($sql);
  538. if($rowset['code'] != '0') return array('code'=> '1','info'=>'接口错误');
  539. $count = isset($rowset['rowset'][0]['count']) ? $rowset['rowset'][0]['count'] : 0;
  540. if($count == 0){
  541. return array('code'=>'1','info'=>'订单状态已改变,请重新刷新页面');
  542. }
  543. $sql1 = "update order_main set order_status = '314',
  544. update_time = now(),
  545. update_user_id = '$user_id'
  546. where (order_id = '$order_id' or parent_order_id = '$order_id') and order_valid_status = '1' and cancel_flag = '0'";
  547. writeLog(__FUNCTION__."sql=".$sql1);
  548. $res = $this -> DBTool -> execSql($sql1);
  549. $model = array(
  550. "user_id" => $user_id,
  551. "log_type" => 3,
  552. "hotel_id" => "0",
  553. "room_type" => "0",
  554. "log_desc" => "取消退改申请",
  555. "order_id" => $order_id
  556. );
  557. $this->DBLog->insertLog($model, "取消退改");
  558. return $res;
  559. }
  560. //退单
  561. function getRefundBill($param){
  562. $order_id = $param['order_id'];
  563. $merge_status = $param['merge_status'];
  564. $user_id = $param['user_id'];
  565. $channel_order_status = $param['channel_order_status'];
  566. $order_status = $param['order_status'];
  567. $sql = "select count(*) as count from order_main
  568. where order_id = '$order_id' and order_status='$order_status' and channel_order_status='$channel_order_status'
  569. and order_valid_status = '1' and cancel_flag = '0'";
  570. $rowset = $this->DBTool->queryBySql($sql);
  571. if($rowset['code'] != '0') return array('code'=> '1','info'=>'接口错误');
  572. $count = isset($rowset['rowset'][0]['count']) ? $rowset['rowset'][0]['count'] : 0;
  573. if($count == 0){
  574. return array('code'=>'1','info'=>'订单状态已改变,请重新刷新页面');
  575. }
  576. $sql1 = "update order_main set order_status = '564',
  577. update_time = now(),
  578. update_user_id = '$user_id'
  579. where (order_id = '$order_id' or parent_order_id = '$order_id') and order_valid_status = '1' and cancel_flag = '0'";
  580. writeLog(__FUNCTION__."sql=".$sql1);
  581. $res = $this -> DBTool -> execSql($sql1);
  582. $model = array(
  583. "user_id" => $user_id,
  584. "log_type" => 3,
  585. "hotel_id" => "0",
  586. "room_type" => "0",
  587. "log_desc" => "向供应商申请退单",
  588. "order_id" => $order_id
  589. );
  590. $this->DBLog->insertLog($model, "退单");
  591. return $res;
  592. }
  593. //同意退单
  594. function getAgreeRefundBill($param){
  595. $order_id = $param['order_id'];
  596. $merge_status = $param['merge_status'];
  597. $user_id = $param['user_id'];
  598. $channel_order_status = $param['channel_order_status'];
  599. $order_status = $param['order_status'];
  600. $outside_order_no = $param['outside_order_no'];
  601. $interface_order_id = $param['interface_order_id'];
  602. $docking = $param['docking'];
  603. $sql = "select count(*) as count from order_main
  604. where order_id = '$order_id' and order_status='$order_status' and channel_order_status='$channel_order_status'
  605. and order_valid_status = '1' and cancel_flag = '0'";
  606. $rowset = $this->DBTool->queryBySql($sql);
  607. if($rowset['code'] != '0') return array('code'=> '1','info'=>'接口错误');
  608. $count = isset($rowset['rowset'][0]['count']) ? $rowset['rowset'][0]['count'] : 0;
  609. if($count == 0){
  610. return array('code'=>'1','info'=>'订单状态已改变,请重新刷新页面');
  611. }
  612. if($docking == '556'){//直连
  613. $this->DBTool->my_pdo->beginTransaction();
  614. $sql1 = "update order_main set order_status='148',order_level='2',order_valid_status='0',channel_order_status = '563',
  615. update_time = now(),
  616. update_user_id = '$user_id'
  617. where (order_id = '$order_id' or parent_order_id = '$order_id') and order_valid_status = '1' and cancel_flag = '0'";
  618. writeLog(__FUNCTION__."sql=".$sql1);
  619. $res = $this -> DBTool -> execSql($sql1);
  620. if($res['code'] != '0') return array('code'=>'1','info'=>'同意退单失败');
  621. $cancel_flag = 4;
  622. $sql2 = "CALL ht_cancel_order('" . $user_id . "','" . $order_id . "',$cancel_flag)";
  623. $res = $this->DBTool->execProcedure($sql2);
  624. if($res['code'] != '0') return array("code"=>"1","info"=>"同意退单失败");
  625. $param_s = array(
  626. 'OrderID' => $outside_order_no,
  627. 'InterfaceConfirmNo' => '',
  628. 'OrderStatus' => '3',
  629. 'InterFaceSendID' => $interface_order_id,
  630. 'channelId' => '1'
  631. );
  632. $setFlag = $this ->set($param_s);
  633. if($setFlag['code'] != '0'){
  634. $this -> DBTool -> my_pdo -> rollBack();
  635. return array('code'=>'1','info'=>'同意退单失败');
  636. }
  637. $this -> DBTool -> my_pdo -> commit();
  638. $model = array(
  639. "user_id" => $user_id,
  640. "log_type" => 3,
  641. "hotel_id" => "0",
  642. "room_type" => "0",
  643. "log_desc" => "同意退单,订单已取消",
  644. "order_id" => $order_id
  645. );
  646. $this->DBLog->insertLog($model, "同意退单,订单已取消");
  647. $model = array(
  648. "user_id" => $user_id,
  649. "log_type" => 3,
  650. "hotel_id" => "0",
  651. "room_type" => "0",
  652. "log_desc" => "渠道同意退单",
  653. "order_id" => $order_id
  654. );
  655. $this->DBLog->insertLog($model, "渠道同意退单");
  656. return array('code'=>'0','info'=>'同意退单成功');
  657. }else{//录单
  658. $sql_1 = "update order_main set order_status = '148',order_level = '2',order_valid_status = '0',
  659. update_time = now(),
  660. update_user_id = '$user_id'
  661. where (order_id = '$order_id' or parent_order_id = '$order_id') and order_valid_status = '1' and cancel_flag = '0'";
  662. writeLog(__FUNCTION__."sql=".$sql_1);
  663. $res = $this -> DBTool -> execSql($sql_1);
  664. if($res['code'] != '0') return array('code'=>'1','info'=>'同意退单失败');
  665. $cancel_flag = 1;
  666. $sql_2 = "CALL ht_cancel_order('" . $user_id . "','" . $order_id . "',$cancel_flag)";
  667. $res = $this->DBTool->execProcedure($sql_2);
  668. $model = array(
  669. "user_id" => $user_id,
  670. "log_type" => 3,
  671. "hotel_id" => "0",
  672. "room_type" => "0",
  673. "log_desc" => "同意退单,订单已取消",
  674. "order_id" => $order_id
  675. );
  676. $this->DBLog->insertLog($model, "同意退单,订单已取消");
  677. return $res;
  678. }
  679. }
  680. //to do
  681. //拒绝退单
  682. function getRefuseRefundBill($param){
  683. $order_id = $param['order_id'];
  684. $merge_status = $param['merge_status'];
  685. $user_id = $param['user_id'];
  686. $channel_order_status = $param['channel_order_status'];
  687. $order_status = $param['order_status'];
  688. $outside_order_no = $param['outside_order_no'];
  689. $interface_order_id = $param['interface_order_id'];
  690. $docking = $param['docking'];
  691. $sql = "select count(*) as count from order_main
  692. where order_id = '$order_id' and order_status='$order_status' and channel_order_status='$channel_order_status'
  693. and order_valid_status = '1' and cancel_flag = '0'";
  694. $rowset = $this->DBTool->queryBySql($sql);
  695. if($rowset['code'] != '0') return array('code'=> '1','info'=>'接口错误');
  696. $count = isset($rowset['rowset'][0]['count']) ? $rowset['rowset'][0]['count'] : 0;
  697. if($count == 0){
  698. return array('code'=>'1','info'=>'订单状态已改变,请重新刷新页面');
  699. }
  700. if ($docking == '556'){//直连
  701. $this->DBTool->my_pdo->beginTransaction();
  702. $sql1 = "update order_main set order_status='314',channel_order_status = '554',
  703. update_time = now(),
  704. update_user_id = '$user_id'
  705. where (order_id = '$order_id' or parent_order_id = '$order_id') and order_valid_status = '1' and cancel_flag = '0'";
  706. writeLog(__FUNCTION__."sql=".$sql1);
  707. $res = $this -> DBTool -> execSql($sql1);
  708. if($res['code'] != '0') return array('code'=>'1','info'=>'拒绝退单失败');
  709. $param_s = array(
  710. 'OrderID' => $outside_order_no,
  711. 'InterfaceConfirmNo' => '',
  712. 'OrderStatus' => '4',
  713. 'InterFaceSendID' => $interface_order_id,
  714. 'channelId' => '1'
  715. );
  716. $setFlag = $this ->set($param_s);
  717. if($setFlag['code'] != '0'){
  718. $this -> DBTool -> my_pdo -> rollBack();
  719. return array('code'=>'1','info'=>'拒绝退单失败');
  720. }
  721. $this -> DBTool -> my_pdo -> commit();
  722. $model = array(
  723. "user_id" => $user_id,
  724. "log_type" => 3,
  725. "hotel_id" => "0",
  726. "room_type" => "0",
  727. "log_desc" => "渠道拒绝退单",
  728. "order_id" => $order_id
  729. );
  730. $this->DBLog->insertLog($model, "渠道拒绝退单");
  731. $model = array(
  732. "user_id" => $user_id,
  733. "log_type" => 3,
  734. "hotel_id" => "0",
  735. "room_type" => "0",
  736. "log_desc" => "拒绝退单",
  737. "order_id" => $order_id
  738. );
  739. $this->DBLog->insertLog($model, "拒绝退单");
  740. return array('code'=>'0','info'=>'拒绝退单成功');
  741. }else{ //录单
  742. $sql_1 = "update order_main set order_status = '314',
  743. update_time = now(),
  744. update_user_id = '$user_id'
  745. where (order_id = '$order_id' or parent_order_id = '$order_id') and order_valid_status = '1' and cancel_flag = '0'";
  746. writeLog(__FUNCTION__."$sql=".$sql_1);
  747. $res = $this -> DBTool -> execSql($sql_1);
  748. $model = array(
  749. "user_id" => $user_id,
  750. "log_type" => 3,
  751. "hotel_id" => "0",
  752. "room_type" => "0",
  753. "log_desc" => "拒绝退单",
  754. "order_id" => $order_id
  755. );
  756. $this->DBLog->insertLog($model, "拒绝退单");
  757. return $res;
  758. }
  759. }
  760. //批量发单
  761. function getBatchSendOrder($list_ary,$user_id){
  762. $res_ary = array();
  763. $res_ary['success']=array();
  764. $res_ary['error']=array();
  765. $res_ary['refresh']=array();
  766. $res_ary['cannot']=array();
  767. foreach ($list_ary as $key => $value) {
  768. writeLog(json_encode($value));
  769. $value['user_id'] = $user_id;
  770. $res = $this->sendOneOrder($value);
  771. if($res['code']=="0"){
  772. $res_ary['success'][]=$value['order_id'];
  773. }else if($res['code']=="1"){
  774. $res_ary['error'][]=$value['order_id'];
  775. }else if($res['code']=="2"){
  776. $res_ary['refresh'][]=$value['order_id'];
  777. }else if($res['code']=='3'){
  778. $res_ary['cannot'][]=$value['order_id'];
  779. }else{
  780. }
  781. }
  782. $count = count($res_ary['error']) + count($res_ary['refresh']) + count($res_ary['cannot']);
  783. $error_count = count($res_ary['error']);
  784. $refresh_count = count($res_ary['refresh']);
  785. $cannot_count = count($res_ary['cannot']);
  786. $res_ary['success'] = implode(',', $res_ary['success']);
  787. $res_ary['error'] = implode(',', $res_ary['error']);
  788. $res_ary['refresh'] = implode(',', $res_ary['refresh']);
  789. $res_ary['cannot'] = implode(',', $res_ary['cannot']);
  790. $t_str = '';
  791. if($error_count > 0){
  792. $t_str = $t_str.'有以下订单发单失败:'.$res_ary['error'].'\n';
  793. }
  794. if($refresh_count > 0){
  795. $t_str = $t_str.'有以下订单需要重新刷新订单状态:'.$res_ary['refresh'].'\n';
  796. }
  797. if($cannot_count > 0){
  798. $t_str = $t_str.'有以下订单无法进行发单操作:'.$res_ary['cannot'].'\n';
  799. }
  800. $data = array();
  801. if($count==0){
  802. $data['code']="0";
  803. $data['info']="批量操作成功";
  804. }else{
  805. $data['code']="1";
  806. $data['info']="失败";
  807. $data['success']=$res_ary['success'];
  808. $data['error']=$res_ary['error'];
  809. $data['refresh']=$res_ary['refresh'];
  810. $data['cannot']=$res_ary['cannot'];
  811. }
  812. return $data;
  813. }
  814. //单个发单
  815. function sendOneOrder($param){
  816. $order_id = $param['order_id'];
  817. $order_status = $param['order_status'];
  818. $channel_order_status = $param['channel_order_status'];
  819. $merge_status = $param['merge_status'];
  820. $user_id = $param['user_id'];
  821. $merge_status_arr = array("2","10","26","34","30");
  822. if(!in_array($merge_status, $merge_status_arr)){
  823. return array('code'=>'3','info'=>'不能发单');
  824. }
  825. $sql0 = "select count(*) as count from order_main
  826. where order_id = '$order_id' and order_status='$order_status' and channel_order_status='$channel_order_status'
  827. and order_valid_status = '1' and cancel_flag = '0'";
  828. writeLog('---'.$sql0);
  829. $rowset = $this->DBTool->queryBySql($sql0);
  830. if($rowset['code'] != '0') return array('code'=> '1','info'=>'接口错误');
  831. $count = isset($rowset['rowset'][0]['count']) ? $rowset['rowset'][0]['count'] : 0;
  832. if($count == 0){
  833. return array('code'=>'2','info'=>'订单状态已改变,请重新刷新页面');
  834. }
  835. $sql = "update order_main set order_status = '198',
  836. update_time = now(),
  837. update_user_id = '$user_id'
  838. where (order_id = '$order_id' or parent_order_id = '$order_id') and order_valid_status = '1' and cancel_flag = '0'";
  839. writeLog(__FUNCTION__."sql=".$sql);
  840. $res = $this -> DBTool -> execSql($sql);
  841. $model = array(
  842. "user_id" => $user_id,
  843. "log_type" => 3,
  844. "hotel_id" => "0",
  845. "room_type" => "0",
  846. "log_desc" => "发送确认单",
  847. "order_id" => $order_id
  848. );
  849. $this->DBLog->insertLog($model, "发单");
  850. return $res;
  851. }
  852. //批量确认
  853. function getBatchRightOrder($list_ary,$user_id){
  854. $res_ary = array();
  855. $res_ary['success']=array();
  856. $res_ary['error']=array();
  857. $res_ary['refresh']=array();
  858. $res_ary['cannot']=array();
  859. foreach ($list_ary as $key => $value) {
  860. $value['user_id'] = $user_id;
  861. $res = $this-> rightOneOrder($value);
  862. if($res['code']=="0"){
  863. $res_ary['success'][]=$value['order_id'];
  864. }else if($res['code']=="1"){
  865. $res_ary['error'][]=$value['order_id'];
  866. }else if($res['code']=="2"){
  867. $res_ary['refresh'][]=$value['order_id'];
  868. }else if($res['code']=='3'){
  869. $res_ary['cannot'][]=$value['order_id'];
  870. }else{
  871. }
  872. }
  873. $count = count($res_ary['error']) + count($res_ary['refresh']) + count($res_ary['cannot']);
  874. $error_count = count($res_ary['error']);
  875. $refresh_count = count($res_ary['refresh']);
  876. $cannot_count = count($res_ary['cannot']);
  877. $res_ary['success'] = implode(',', $res_ary['success']);
  878. $res_ary['error'] = implode(',', $res_ary['error']);
  879. $res_ary['refresh'] = implode(',', $res_ary['refresh']);
  880. $res_ary['cannot'] = implode(',', $res_ary['cannot']);
  881. $t_str = '';
  882. if($error_count > 0){
  883. $t_str = $t_str.'有以下订单确认失败:'.$res_ary['error'].'\n';
  884. }
  885. if($refresh_count > 0){
  886. $t_str = $t_str.'有以下订单需要重新刷新订单状态:'.$res_ary['refresh'].'\n';
  887. }
  888. if($cannot_count > 0){
  889. $t_str = $t_str.'有以下订单无法进行确认操作:'.$res_ary['cannot'].'\n';
  890. }
  891. $data = array();
  892. if($count==0){
  893. $data['code']="0";
  894. $data['info']="批量操作成功";
  895. }else{
  896. $data['code']="1";
  897. $data['info']=$t_str;
  898. $data['success']=$res_ary['success'];
  899. $data['error']=$res_ary['error'];
  900. $data['refresh']=$res_ary['refresh'];
  901. $data['cannot']=$res_ary['cannot'];
  902. }
  903. return $data;
  904. }
  905. //确认单个订单
  906. function rightOneOrder($param){
  907. $order_id = $param['order_id'];
  908. $order_status = $param['order_status'];
  909. $channel_order_status = $param['channel_order_status'];
  910. $merge_status = $param['merge_status'];
  911. $user_id = $param['user_id'];
  912. $order_right_id = $param['order_right_id'];
  913. $docking = $param['docking'];
  914. $outside_order_no = $param['outside_order_no'];
  915. $interface_order_id = $param['interface_order_id'];
  916. $merge_status_arr = array("3","11","27","35");
  917. if(!in_array($merge_status, $merge_status_arr)){
  918. return array('code'=>'3','info'=>'不能确认');
  919. }
  920. $sql0 = "select count(*) as count from order_main
  921. where order_id = '$order_id' and order_status='$order_status' and channel_order_status='$channel_order_status'
  922. and order_valid_status = '1' and cancel_flag = '0'";
  923. $rowset = $this->DBTool->queryBySql($sql0);
  924. if($rowset['code'] != '0') return array('code'=> '1','info'=>'接口错误');
  925. $count = isset($rowset['rowset'][0]['count']) ? $rowset['rowset'][0]['count'] : 0;
  926. if($count == 0){
  927. return array('code'=>'2','info'=>'订单状态已改变,请重新刷新页面');
  928. }
  929. if($docking == '556'){//直连
  930. $this->DBTool->my_pdo->beginTransaction();
  931. $tt = 'channel_order_status="551",';
  932. $sql = "update order_main set order_status = '314',order_confirm_code = '$order_right_id',$tt
  933. order_level = '0',update_time = now(),update_user_id = '$user_id' where (order_id = '$order_id' or parent_order_id = '$order_id')
  934. and order_valid_status = '1' and cancel_flag = '0'";
  935. writeLog(__FUNCTION__."$sql=".$sql);
  936. $res = $this -> DBTool -> execSql($sql);
  937. //渠道推送
  938. if ($res['code'] == '0'){
  939. $cancel_status = '';
  940. if($merge_status == '27' || $merge_status =='35'){
  941. $cancel_status = 4;
  942. }else{
  943. $cancel_status = 3;
  944. }
  945. $param_s = array(
  946. 'OrderID' => $outside_order_no,
  947. 'InterfaceConfirmNo' => '',
  948. 'OrderStatus' => $cancel_status,
  949. 'InterFaceSendID' => $interface_order_id,
  950. 'channelId' => '1'
  951. );
  952. $setFlag = $this->set($param_s);
  953. if($setFlag['code'] != '0') {
  954. $this->DBTool->my_pdo->rollBack();
  955. return array('code'=>'1','info'=>'确认失败');
  956. }
  957. $this->DBTool->my_pdo->commit();
  958. if($merge_status == '3'){
  959. $model = array(
  960. "user_id" => $user_id,
  961. "log_type" => 3,
  962. "hotel_id" => "0",
  963. "room_type" => "0",
  964. "log_desc" => "接受取消订单",
  965. "order_id" => $order_id
  966. );
  967. $this->DBLog->insertLog($model, "接受取消订单");
  968. }else{
  969. }
  970. $model = array(
  971. "user_id" => $user_id,
  972. "log_type" => 3,
  973. "hotel_id" => "0",
  974. "room_type" => "0",
  975. "log_desc" => "确认订单,确认号{$order_right_id}",
  976. "order_id" => $order_id
  977. );
  978. $this->DBLog->insertLog($model, "确认单");
  979. return array('code'=>'0','info'=>'确认成功');
  980. } else {
  981. return array('code'=>'1','info'=>'确认失败');
  982. }
  983. }else{//录单
  984. $sql2 = "update order_main set order_status = '314',order_confirm_code = '$order_right_id',
  985. order_level = '0',update_time = now(),update_user_id = '$user_id' where (order_id = '$order_id' or parent_order_id = '$order_id')
  986. and order_valid_status = '1' and cancel_flag = '0'";
  987. writeLog(__FUNCTION__."sql=".$sql2);
  988. $res = $this -> DBTool -> execSql($sql2);
  989. $model = array(
  990. "user_id" => $user_id,
  991. "log_type" => 3,
  992. "hotel_id" => "0",
  993. "room_type" => "0",
  994. "log_desc" => "确认订单,确认号{$order_right_id}",
  995. "order_id" => $order_id
  996. );
  997. $this->DBLog->insertLog($model, "确认单");
  998. return $res;
  999. }
  1000. }
  1001. function getCommentTxt($order_ids){
  1002. $ids = implode(",", $order_ids);
  1003. $sql = "select comment_txt,order_id from order_comment where order_id in ({$ids}) and cancel_flag = 0";
  1004. $data = $this->DBTool->queryBySql($sql);
  1005. if($data['code']!="0")return $data;
  1006. $arr = array();
  1007. foreach($data['rowset'] as $k => $v){
  1008. $arr[$v['order_id']][] = $v['comment_txt'];
  1009. }
  1010. return $arr;
  1011. }
  1012. public function set($param)
  1013. {
  1014. $url = 'http://demo.zhizhuchuxing.cn/hotel/set/set-order-status';
  1015. $return = $this -> httpsPostParam($url,$param);
  1016. return $return;
  1017. }
  1018. function httpsPostParam($url, $param = array())
  1019. {
  1020. $ch = curl_init(); // 初始化一个 cURL 对象
  1021. curl_setopt($ch, CURLOPT_URL, $url); // 设置需要抓取的URL
  1022. curl_setopt($ch, CURLOPT_HEADER, 0); // // 设置header
  1023. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // 设置cURL 参数,要求结果保存到字符串中还是输出到屏幕上。
  1024. // 如果你想PHP去做一个正规的HTTP POST,设置这个选项为一个非零值。这个POST是普通的 application/x-www-from-urlencoded 类型,多数被HTML表单使用。
  1025. curl_setopt($ch, CURLOPT_POST, 1);
  1026. curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($param)); // 传递一个作为HTTP “POST”操作的所有数据的字符串。//http_build_query:生成 URL-encode 之后的请求字符串
  1027. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  1028. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  1029. curl_setopt($ch, CURLOPT_HTTPHEADER, array(
  1030. 'Content-type:application/x-www-form-urlencoded;charset=utf-8'
  1031. ));
  1032. $rtn = curl_exec($ch); // 运行cURL,请求网页
  1033. if ($errno = curl_errno($ch)) {
  1034. return array('code'=>'1','info'=>'接口调用失败!');
  1035. }
  1036. curl_close($ch); // 关闭URL请求
  1037. // return json_decode($rtn, true); // 返回获取的数据
  1038. return array('code'=> '0','info'=> '对接成功');
  1039. }
  1040. }
  1041. ?>