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.
 
 
 
 

540 lines
21 KiB

  1. <?php
  2. require_once "Api/ApiBase.php";
  3. require_once "Lib/Action/HTOrderOperation.class.php";
  4. require_once "Api/order/HotelOrderList.php";
  5. class OrderOperation extends ApiBase
  6. {
  7. var $HTOrderOperation;
  8. function __construct()
  9. {
  10. parent::__construct();
  11. $this->HTOrderOperation = new HTOrderOperation();
  12. }
  13. function outJson()
  14. {
  15. $op = $this->_request('op');
  16. if ($op == 'excelOrder'){
  17. $this -> excelOrder();
  18. }else{
  19. $data = call_user_func(array(__CLASS__, $op));
  20. echo json_encode($data);
  21. }
  22. }
  23. //渠道接单
  24. function getOrder()
  25. {
  26. $order_id = $this->_request('order_id');
  27. $merge_status = $this->_request('merge_status');
  28. $user_id = $this->login_user_id;
  29. $order_status = $this->_request('order_status');
  30. $channel_order_status = $this->_request('channel_order_status');
  31. $outside_order_no = $this->_request('outside_order_no');
  32. $interface_order_id = $this->_request('interface_order_id');
  33. $param = array(
  34. 'order_id' => $order_id,
  35. 'merge_status' => $merge_status,
  36. 'user_id' => $user_id,
  37. 'channel_order_status' => $channel_order_status,
  38. 'order_status' => $order_status,
  39. 'outside_order_no' => $outside_order_no,
  40. 'interface_order_id' => $interface_order_id
  41. );
  42. $data = $this->HTOrderOperation->getGetOrder($param);
  43. return $data;
  44. }
  45. //渠道拒单
  46. function refuseOrder()
  47. {
  48. $order_id = $this->_request('order_id');
  49. $merge_status = $this->_request('merge_status');
  50. $user_id = $this->login_user_id;
  51. $order_status = $this->_request('order_status');
  52. $channel_order_status = $this->_request('channel_order_status');
  53. $outside_order_no = $this->_request('outside_order_no');
  54. $interface_order_id = $this->_request('interface_order_id');
  55. $param = array(
  56. 'order_id' => $order_id,
  57. 'merge_status' => $merge_status,
  58. 'user_id' => $user_id,
  59. 'channel_order_status' => $channel_order_status,
  60. 'order_status' => $order_status,
  61. 'outside_order_no' => $outside_order_no,
  62. 'interface_order_id' => $interface_order_id
  63. );
  64. $data = $this->HTOrderOperation->getRefuseOrder($param);
  65. return $data;
  66. }
  67. //渠道同意申请
  68. function agreeApply()
  69. {
  70. $order_id = $this->_request('order_id');
  71. $merge_status = $this->_request('merge_status');
  72. $user_id = $this->login_user_id;
  73. $order_status = $this->_request('order_status');
  74. $channel_order_status = $this->_request('channel_order_status');
  75. $outside_order_no = $this->_request('outside_order_no');
  76. $interface_order_id = $this->_request('interface_order_id');
  77. $param = array(
  78. 'order_id' => $order_id,
  79. 'merge_status' => $merge_status,
  80. 'user_id' => $user_id,
  81. 'channel_order_status' => $channel_order_status,
  82. 'order_status' => $order_status,
  83. 'outside_order_no' => $outside_order_no,
  84. 'interface_order_id' => $interface_order_id
  85. );
  86. $data = $this->HTOrderOperation->getAgreeApply($param);
  87. return $data;
  88. }
  89. //渠道拒绝申请
  90. function refuseApply()
  91. {
  92. $order_id = $this->_request('order_id');
  93. $merge_status = $this->_request('merge_status');
  94. $user_id = $this->login_user_id;
  95. $order_status = $this->_request('order_status');
  96. $channel_order_status = $this->_request('channel_order_status');
  97. $outside_order_no = $this->_request('outside_order_no');
  98. $interface_order_id = $this->_request('interface_order_id');
  99. $param = array(
  100. 'order_id' => $order_id,
  101. 'merge_status' => $merge_status,
  102. 'user_id' => $user_id,
  103. 'channel_order_status' => $channel_order_status,
  104. 'order_status' => $order_status,
  105. 'outside_order_no' => $outside_order_no,
  106. 'interface_order_id' => $interface_order_id
  107. );
  108. $data = $this->HTOrderOperation->getRefuseApply($param);
  109. return $data;
  110. }
  111. //发单
  112. function sendOrder()
  113. {
  114. $order_id = $this->_request('order_id');
  115. $merge_status = $this->_request('merge_status');
  116. $user_id = $this->login_user_id;
  117. $order_status = $this->_request('order_status');
  118. $channel_order_status = $this->_request('channel_order_status');
  119. $param = array(
  120. 'order_id' => $order_id,
  121. 'merge_status' => $merge_status,
  122. 'user_id' => $user_id,
  123. 'channel_order_status' => $channel_order_status,
  124. 'order_status' => $order_status
  125. );
  126. $data = $this->HTOrderOperation->getSendOrder($param);
  127. return $data;
  128. }
  129. //确认
  130. function rightOrder()
  131. {
  132. $order_id = $this->_request('order_id');
  133. $order_right_id = $this->_request('order_right_id');
  134. $merge_status = $this->_request('merge_status');
  135. $user_id = $this->login_user_id;
  136. $order_status = $this->_request('order_status');
  137. $channel_order_status = $this->_request('channel_order_status');
  138. $outside_order_no = $this->_request('outside_order_no');
  139. $interface_order_id = $this->_request('interface_order_id');
  140. $docking = $this->_request('docking');
  141. $param = array(
  142. 'order_id' => $order_id,
  143. 'order_right_id' => $order_right_id,
  144. 'merge_status' => $merge_status,
  145. 'user_id' => $user_id,
  146. 'channel_order_status' => $channel_order_status,
  147. 'order_status' => $order_status,
  148. 'outside_order_no' => $outside_order_no,
  149. 'interface_order_id' => $interface_order_id,
  150. 'docking' => $docking
  151. );
  152. $data = $this->HTOrderOperation->getRightOrder($param);
  153. return $data;
  154. }
  155. //取消单
  156. function cancelOrder()
  157. {
  158. $order_id = $this->_request('order_id');
  159. $merge_status = $this->_request('merge_status');
  160. $user_id = $this->login_user_id;
  161. $channel_order_status = $this->_request('channel_order_status');
  162. $order_status = $this->_request('order_status');
  163. $outside_order_no = $this->_request('outside_order_no');
  164. $interface_order_id = $this->_request('interface_order_id');
  165. $docking = $this->_request('docking');
  166. $param = array(
  167. 'order_id' => $order_id,
  168. 'merge_status' => $merge_status,
  169. 'user_id' => $user_id,
  170. 'channel_order_status' => $channel_order_status,
  171. 'order_status' => $order_status,
  172. 'outside_order_no' => $outside_order_no,
  173. 'interface_order_id' => $interface_order_id,
  174. 'docking' => $docking
  175. );
  176. $data = $this->HTOrderOperation->getCancelOrder($param);
  177. return $data;
  178. }
  179. //退改
  180. function refundOrder()
  181. {
  182. $order_id = $this->_request('order_id');
  183. $merge_status = $this->_request('merge_status');
  184. $user_id = $this->login_user_id;
  185. $channel_order_status = $this->_request('channel_order_status');
  186. $order_status = $this->_request('order_status');
  187. $cancel_reason = $this->_request('cancel_reason');
  188. $param = array(
  189. 'order_id' => $order_id,
  190. 'merge_status' => $merge_status,
  191. 'user_id' => $user_id,
  192. 'channel_order_status' => $channel_order_status,
  193. 'order_status' => $order_status,
  194. 'cancel_reason' => $cancel_reason
  195. );
  196. $data = $this->HTOrderOperation->getRefundOrder($param);
  197. return $data;
  198. }
  199. //取消退改
  200. function cancelRefundOrder()
  201. {
  202. $order_id = $this->_request('order_id');
  203. $merge_status = $this->_request('order_id');
  204. $user_id = $this->login_user_id;
  205. $channel_order_status = $this->_request('channel_order_status');
  206. $order_status = $this->_request('order_status');
  207. $param = array(
  208. 'order_id' => $order_id,
  209. 'merge_status' => $merge_status,
  210. 'user_id' => $user_id,
  211. 'channel_order_status' => $channel_order_status,
  212. 'order_status' => $order_status
  213. );
  214. $data = $this->HTOrderOperation->getCancelRefundOrder($param);
  215. return $data;
  216. }
  217. //退单
  218. function refundBill()
  219. {
  220. $order_id = $this->_request('order_id');
  221. $merge_status = $this->_request('merge_status');
  222. $user_id = $this->login_user_id;
  223. $channel_order_status = $this->_request('channel_order_status');
  224. $order_status = $this->_request('order_status');
  225. $param = array(
  226. 'order_id' => $order_id,
  227. 'merge_status' => $merge_status,
  228. 'user_id' => $user_id,
  229. 'channel_order_status' => $channel_order_status,
  230. 'order_status' => $order_status
  231. );
  232. $data = $this->HTOrderOperation->getRefundBill($param);
  233. return $data;
  234. }
  235. //同意退单
  236. function agreeRefundBill()
  237. {
  238. $order_id = $this->_request('order_id');
  239. $merge_status = $this->_request('merge_status');
  240. $user_id = $this->login_user_id;
  241. $channel_order_status = $this->_request('channel_order_status');
  242. $order_status = $this->_request('order_status');
  243. $outside_order_no = $this->_request('outside_order_no');
  244. $interface_order_id = $this->_request('interface_order_id');
  245. $docking = $this->_request('docking');
  246. $param = array(
  247. 'order_id' => $order_id,
  248. 'merge_status' => $merge_status,
  249. 'user_id' => $user_id,
  250. 'channel_order_status' => $channel_order_status,
  251. 'order_status' => $order_status,
  252. 'outside_order_no' => $outside_order_no,
  253. 'interface_order_id' => $interface_order_id,
  254. 'docking' => $docking
  255. );
  256. $data = $this->HTOrderOperation->getAgreeRefundBill($param);
  257. return $data;
  258. }
  259. //拒绝退单
  260. function refuseRefundBill()
  261. {
  262. $order_id = $this->_request('order_id');
  263. $merge_status = $this->_request('merge_status');
  264. $user_id = $this->login_user_id;
  265. $channel_order_status = $this->_request('channel_order_status');
  266. $order_status = $this->_request('order_status');
  267. $outside_order_no = $this->_request('outside_order_no');
  268. $interface_order_id = $this->_request('interface_order_id');
  269. $docking = $this->_request('docking');
  270. $param = array(
  271. 'order_id' => $order_id,
  272. 'merge_status' => $merge_status,
  273. 'user_id' => $user_id,
  274. 'channel_order_status' => $channel_order_status,
  275. 'order_status' => $order_status,
  276. 'outside_order_no' => $outside_order_no,
  277. 'interface_order_id' => $interface_order_id,
  278. 'docking' => $docking
  279. );
  280. $data = $this->HTOrderOperation->getRefuseRefundBill($param);
  281. return $data;
  282. }
  283. //批量发单
  284. function batchSendOrder(){
  285. $list_ary = $this->_request('list_ary');
  286. $list_ary = json_decode($list_ary,true);
  287. $user_id = $this->login_user_id;
  288. $data = $this->HTOrderOperation->getBatchSendOrder($list_ary,$user_id);
  289. return $data;
  290. }
  291. //批量确认
  292. function batchRightOrder(){
  293. $list_ary = $this->_request('list_ary');
  294. $list_ary = json_decode($list_ary,true);
  295. $user_id = $this->login_user_id;
  296. $data = $this->HTOrderOperation->getBatchRightOrder($list_ary,$user_id);
  297. return $data;
  298. }
  299. //批量导出
  300. function excelOrder(){
  301. $dict = $this->_request('dict');
  302. $dict = json_decode($dict,true);
  303. $date_type = $dict['date_type'];
  304. $start_date = $dict['start_date'];
  305. $end_date = $dict['end_date'];
  306. $province = $dict['province'];
  307. $city = $dict['city'];
  308. $hotel_name = $dict['hotel_name'];
  309. $org_id = $dict['org_id'];
  310. $confirm_number = $dict['confirm_number'];
  311. $more_search = $dict['more_search'];
  312. $current = $dict['current'];
  313. $page_size = $dict['pagesize'];
  314. $order_status = $dict['order_status'];
  315. $channel_order_status = $dict['channel_order_status'];
  316. $HTOrderList = new HTOrderList();
  317. $data = $HTOrderList -> getOrderList($date_type, $start_date, $end_date, $province, $city, $hotel_name, $order_status, $org_id, $more_search, $current, $page_size, $confirm_number,$channel_order_status);
  318. $res = $data['order_list'];
  319. $order_ids = array();
  320. foreach ($res as $key => $value) {
  321. $order_ids[] = $value['order_id'];
  322. }
  323. $comments = $this->HTOrderOperation->getCommentTxt($order_ids);
  324. // echo json_encode($comments);return;
  325. $objPHPExcel = new PHPExcel();
  326. /*以下是一些设置 ,作者 ,标题之类*/
  327. $objPHPExcel->getProperties()->setCreator("出行")
  328. ->setLastModifiedBy("出行")
  329. ->setTitle("数据EXCEL导出")
  330. ->setSubject("数据EXCEL导出")
  331. ->setDescription("备份数据")
  332. ->setKeywords("excel")
  333. ->setCategory("result file");
  334. /*以下就是对处理Excel里的数据, 横着取数据*/
  335. $objPHPExcel->setActiveSheetIndex(0)
  336. //Excel的第A列,uid是你查出数组的键值,下面以此类推
  337. ->setCellValue('A1', '订单编号')
  338. ->setCellValue('B1', '酒店')
  339. ->setCellValue('C1', '房型')
  340. ->setCellValue('D1', '预订时间')
  341. ->setCellValue('E1', '操作人')
  342. ->setCellValue('F1', '供应商')
  343. ->setCellValue('G1', '入住时间')
  344. ->setCellValue('H1', '离店时间')
  345. ->setCellValue('I1', '间夜数')
  346. ->setCellValue('J1', '确认号')
  347. ->setCellValue('K1', '客人姓名')
  348. ->setCellValue('L1', '客人电话')
  349. ->setCellValue('M1', '订单渠道')
  350. ->setCellValue('N1', '渠道订单号')
  351. ->setCellValue('O1', '订单金额')
  352. ->setCellValue('P1', '采购成本')
  353. ->setCellValue('Q1', '佣金')
  354. ->setCellValue('R1', '利润')
  355. ->setCellValue('S1', '支付方式')
  356. ->setCellValue('T1', '状态')
  357. ->setCellValue('U1', '订单备注')
  358. ->setCellValue('V1', '采购人')
  359. ->setCellValue('W1','运营人员');
  360. foreach ($res as $k => $row) {
  361. $number = $k + 2;
  362. $order_id = $row['order_id'];
  363. $obj = $HTOrderList->getPrice($order_id);
  364. $purchaser = $HTOrderList->getPurchaser($row['prod_supply_org_id']);
  365. $principal = $HTOrderList->getPrincipal($row['hotel_name']);
  366. $num = 0;
  367. // $base_price = 0;
  368. foreach ($obj as $v) {
  369. $num += $v['num'];
  370. // $base_price += $v['base_price'];
  371. }
  372. @$jianye = $num;
  373. //取出order_id->备注
  374. // echo $order_id;return;
  375. $comment_txt = isset($comments[$order_id])?$comments[$order_id]:array();
  376. $comment_txt = implode(';', $comment_txt);
  377. // $memo = $row['customer_memo'];
  378. // $notes = explode('||', $memo);
  379. // if (count($notes) > 0) {
  380. // $tmp = array();
  381. // foreach ($notes as $note) {
  382. // $item = explode('|', $note);
  383. // if (count($item) >= 3 && $item[3] != '') {
  384. // $tmp[] = $item[3];
  385. // }
  386. // }
  387. // $memo = implode(';', $tmp);
  388. // } else {
  389. // $memo = $notes[0];
  390. // }
  391. @$customer_memo = $comment_txt;
  392. @$total_commission = $row['total_commission'];
  393. @$outside_order_no = $row['outside_order_no'];
  394. @$prod_name = $row['prod_name'];
  395. @$profit_value = $row['profit_value'];
  396. @$hotel_name = $row['hotel_name'];
  397. @$create_time = $row['create_time'];
  398. @$user_name = $row['user_name'];
  399. @$prod_start_station_date = $row['prod_start_station_date'];
  400. @$prod_end_station_date = $row['prod_end_station_date'];
  401. @$order_confirm_code = $row['order_confirm_code'];
  402. @$prod_supply_org_name = $row['prod_supply_org_name'];
  403. @$customer_name = $row['customer_name'];
  404. @$customer_mobile = $row['customer_mobile'];
  405. @$org_name = $row['org_name'];
  406. @$order_price = $row['order_price'];
  407. @$base_price = $row['base_price'];
  408. @$order_pay_type = $row['order_pay_type'];
  409. @$order_status_name = $row['order_status_name'];
  410. @$purchaser_id = $purchaser['purchaser_id'];
  411. @$purchaser_name = $purchaser['purchaser_name'];
  412. //$objPHPExcel->getActiveSheet(0)->getStyle('F'.$num)->getAlignment()->setWrapText(true);
  413. //$objPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(50);
  414. $objPHPExcel->getActiveSheet()->getColumnDimension('A')->setAutoSize(true);
  415. $objPHPExcel->getActiveSheet()->getColumnDimension('B')->setAutoSize(true);
  416. $objPHPExcel->getActiveSheet()->getColumnDimension('C')->setAutoSize(true);
  417. $objPHPExcel->getActiveSheet()->getColumnDimension('D')->setAutoSize(true);
  418. $objPHPExcel->getActiveSheet()->getColumnDimension('E')->setAutoSize(true);
  419. $objPHPExcel->getActiveSheet()->getColumnDimension('F')->setAutoSize(true);
  420. $objPHPExcel->getActiveSheet()->getColumnDimension('J')->setAutoSize(true);
  421. $objPHPExcel->getActiveSheet()->getColumnDimension('H')->setAutoSize(true);
  422. $objPHPExcel->getActiveSheet()->getColumnDimension('I')->setAutoSize(true);
  423. $objPHPExcel->getActiveSheet()->getColumnDimension('J')->setAutoSize(true);
  424. $objPHPExcel->getActiveSheet()->getColumnDimension('K')->setAutoSize(true);
  425. $objPHPExcel->getActiveSheet()->getColumnDimension('L')->setAutoSize(true);
  426. $objPHPExcel->getActiveSheet()->getColumnDimension('M')->setAutoSize(true);
  427. $objPHPExcel->getActiveSheet()->getColumnDimension('N')->setAutoSize(true);
  428. $objPHPExcel->getActiveSheet()->getColumnDimension('O')->setAutoSize(true);
  429. $objPHPExcel->getActiveSheet()->getColumnDimension('P')->setAutoSize(true);
  430. $objPHPExcel->getActiveSheet()->getColumnDimension('Q')->setAutoSize(true);
  431. $objPHPExcel->getActiveSheet()->getColumnDimension('R')->setAutoSize(true);
  432. $objPHPExcel->getActiveSheet()->getColumnDimension('S')->setAutoSize(true);
  433. $objPHPExcel->getActiveSheet()->getColumnDimension('T')->setAutoSize(true);
  434. $objPHPExcel->setActiveSheetIndex(0)
  435. //Excel的第A列,uid是你查出数组的键值,下面以此类推
  436. ->setCellValue('A' . $number, $order_id)
  437. ->setCellValue('B' . $number, $hotel_name)
  438. ->setCellValue('C' . $number, $prod_name)
  439. ->setCellValue('D' . $number, $create_time)
  440. ->setCellValue('E' . $number, $user_name)
  441. ->setCellValue('F' . $number, $prod_supply_org_name)
  442. ->setCellValue('G' . $number, $prod_start_station_date)
  443. ->setCellValue('H' . $number, $prod_end_station_date)
  444. ->setCellValue('I' . $number, $jianye)
  445. ->setCellValue('J' . $number, $order_confirm_code)
  446. ->setCellValue('K' . $number, $customer_name)
  447. ->setCellValue('L' . $number, $customer_mobile)
  448. ->setCellValue('M' . $number, $org_name)
  449. ->setCellValue('N' . $number, $outside_order_no)
  450. ->setCellValue('O' . $number, $order_price)
  451. ->setCellValue('P' . $number, $base_price)
  452. ->setCellValue('Q' . $number, $total_commission)
  453. ->setCellValue('R' . $number, $profit_value)
  454. ->setCellValue('S' . $number, $order_pay_type)
  455. ->setCellValue('T' . $number, $order_status_name)
  456. ->setCellValue('U' . $number, $customer_memo)
  457. ->setCellValue('V' . $number, $purchaser_name)
  458. ->setCellValue('W' . $number, $principal);
  459. }
  460. // $str .= $order_id . "\t" .$hotel_name . "\t".$prod_name . "\t" . $create_time . "\t" . $user_name . "\t" . $prod_supply_org_name . "\t" . $prod_start_station_date . "\t" . $prod_end_station_date . "\t" . $jianye . "\t" . $order_confirm_code . "\t" . $customer_name . "\t". $customer_mobile . "\t" . $org_name . "\t". $outside_order_no . "\t" . $order_price . "\t". $base_price . "\t". $total_commission . "\t". $profit_value . "\t" . $order_pay_type . "\t" . $order_status_name ."\t" . $customer_memo . "\t\n";
  461. $objPHPExcel->getActiveSheet()->setTitle('User');
  462. $objPHPExcel->setActiveSheetIndex(0);
  463. $filename = '订单信息' . date('Y-m-d H:i:s', time()) . '.xls';
  464. header('Content-Type: application/vnd.ms-excel');
  465. header('Content-Disposition: attachment;filename=' . $filename);
  466. header('Cache-Control: max-age=0');
  467. $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
  468. $objWriter->save('php://output');
  469. }
  470. }
  471. $obj = new OrderOperation;
  472. $obj->outJson();