HTOrderOperation = new HTOrderOperation(); } function outJson() { $op = $this->_request('op'); if ($op == 'excelOrder'){ $this -> excelOrder(); }else{ $data = call_user_func(array(__CLASS__, $op)); echo json_encode($data); } } //渠道接单 function getOrder() { $order_id = $this->_request('order_id'); $merge_status = $this->_request('merge_status'); $user_id = $this->login_user_id; $order_status = $this->_request('order_status'); $channel_order_status = $this->_request('channel_order_status'); $outside_order_no = $this->_request('outside_order_no'); $interface_order_id = $this->_request('interface_order_id'); $param = array( 'order_id' => $order_id, 'merge_status' => $merge_status, 'user_id' => $user_id, 'channel_order_status' => $channel_order_status, 'order_status' => $order_status, 'outside_order_no' => $outside_order_no, 'interface_order_id' => $interface_order_id ); $data = $this->HTOrderOperation->getGetOrder($param); return $data; } //渠道拒单 function refuseOrder() { $order_id = $this->_request('order_id'); $merge_status = $this->_request('merge_status'); $user_id = $this->login_user_id; $order_status = $this->_request('order_status'); $channel_order_status = $this->_request('channel_order_status'); $outside_order_no = $this->_request('outside_order_no'); $interface_order_id = $this->_request('interface_order_id'); $param = array( 'order_id' => $order_id, 'merge_status' => $merge_status, 'user_id' => $user_id, 'channel_order_status' => $channel_order_status, 'order_status' => $order_status, 'outside_order_no' => $outside_order_no, 'interface_order_id' => $interface_order_id ); $data = $this->HTOrderOperation->getRefuseOrder($param); return $data; } //渠道同意申请 function agreeApply() { $order_id = $this->_request('order_id'); $merge_status = $this->_request('merge_status'); $user_id = $this->login_user_id; $order_status = $this->_request('order_status'); $channel_order_status = $this->_request('channel_order_status'); $outside_order_no = $this->_request('outside_order_no'); $interface_order_id = $this->_request('interface_order_id'); $param = array( 'order_id' => $order_id, 'merge_status' => $merge_status, 'user_id' => $user_id, 'channel_order_status' => $channel_order_status, 'order_status' => $order_status, 'outside_order_no' => $outside_order_no, 'interface_order_id' => $interface_order_id ); $data = $this->HTOrderOperation->getAgreeApply($param); return $data; } //渠道拒绝申请 function refuseApply() { $order_id = $this->_request('order_id'); $merge_status = $this->_request('merge_status'); $user_id = $this->login_user_id; $order_status = $this->_request('order_status'); $channel_order_status = $this->_request('channel_order_status'); $outside_order_no = $this->_request('outside_order_no'); $interface_order_id = $this->_request('interface_order_id'); $param = array( 'order_id' => $order_id, 'merge_status' => $merge_status, 'user_id' => $user_id, 'channel_order_status' => $channel_order_status, 'order_status' => $order_status, 'outside_order_no' => $outside_order_no, 'interface_order_id' => $interface_order_id ); $data = $this->HTOrderOperation->getRefuseApply($param); return $data; } //发单 function sendOrder() { $order_id = $this->_request('order_id'); $merge_status = $this->_request('merge_status'); $user_id = $this->login_user_id; $order_status = $this->_request('order_status'); $channel_order_status = $this->_request('channel_order_status'); $param = array( 'order_id' => $order_id, 'merge_status' => $merge_status, 'user_id' => $user_id, 'channel_order_status' => $channel_order_status, 'order_status' => $order_status ); $data = $this->HTOrderOperation->getSendOrder($param); return $data; } //确认 function rightOrder() { $order_id = $this->_request('order_id'); $order_right_id = $this->_request('order_right_id'); $merge_status = $this->_request('merge_status'); $user_id = $this->login_user_id; $order_status = $this->_request('order_status'); $channel_order_status = $this->_request('channel_order_status'); $outside_order_no = $this->_request('outside_order_no'); $interface_order_id = $this->_request('interface_order_id'); $docking = $this->_request('docking'); $param = array( 'order_id' => $order_id, 'order_right_id' => $order_right_id, 'merge_status' => $merge_status, 'user_id' => $user_id, 'channel_order_status' => $channel_order_status, 'order_status' => $order_status, 'outside_order_no' => $outside_order_no, 'interface_order_id' => $interface_order_id, 'docking' => $docking ); $data = $this->HTOrderOperation->getRightOrder($param); return $data; } //取消单 function cancelOrder() { $order_id = $this->_request('order_id'); $merge_status = $this->_request('merge_status'); $user_id = $this->login_user_id; $channel_order_status = $this->_request('channel_order_status'); $order_status = $this->_request('order_status'); $outside_order_no = $this->_request('outside_order_no'); $interface_order_id = $this->_request('interface_order_id'); $docking = $this->_request('docking'); $param = array( 'order_id' => $order_id, 'merge_status' => $merge_status, 'user_id' => $user_id, 'channel_order_status' => $channel_order_status, 'order_status' => $order_status, 'outside_order_no' => $outside_order_no, 'interface_order_id' => $interface_order_id, 'docking' => $docking ); $data = $this->HTOrderOperation->getCancelOrder($param); return $data; } //退改 function refundOrder() { $order_id = $this->_request('order_id'); $merge_status = $this->_request('merge_status'); $user_id = $this->login_user_id; $channel_order_status = $this->_request('channel_order_status'); $order_status = $this->_request('order_status'); $cancel_reason = $this->_request('cancel_reason'); $param = array( 'order_id' => $order_id, 'merge_status' => $merge_status, 'user_id' => $user_id, 'channel_order_status' => $channel_order_status, 'order_status' => $order_status, 'cancel_reason' => $cancel_reason ); $data = $this->HTOrderOperation->getRefundOrder($param); return $data; } //取消退改 function cancelRefundOrder() { $order_id = $this->_request('order_id'); $merge_status = $this->_request('order_id'); $user_id = $this->login_user_id; $channel_order_status = $this->_request('channel_order_status'); $order_status = $this->_request('order_status'); $param = array( 'order_id' => $order_id, 'merge_status' => $merge_status, 'user_id' => $user_id, 'channel_order_status' => $channel_order_status, 'order_status' => $order_status ); $data = $this->HTOrderOperation->getCancelRefundOrder($param); return $data; } //退单 function refundBill() { $order_id = $this->_request('order_id'); $merge_status = $this->_request('merge_status'); $user_id = $this->login_user_id; $channel_order_status = $this->_request('channel_order_status'); $order_status = $this->_request('order_status'); $param = array( 'order_id' => $order_id, 'merge_status' => $merge_status, 'user_id' => $user_id, 'channel_order_status' => $channel_order_status, 'order_status' => $order_status ); $data = $this->HTOrderOperation->getRefundBill($param); return $data; } //同意退单 function agreeRefundBill() { $order_id = $this->_request('order_id'); $merge_status = $this->_request('merge_status'); $user_id = $this->login_user_id; $channel_order_status = $this->_request('channel_order_status'); $order_status = $this->_request('order_status'); $outside_order_no = $this->_request('outside_order_no'); $interface_order_id = $this->_request('interface_order_id'); $docking = $this->_request('docking'); $param = array( 'order_id' => $order_id, 'merge_status' => $merge_status, 'user_id' => $user_id, 'channel_order_status' => $channel_order_status, 'order_status' => $order_status, 'outside_order_no' => $outside_order_no, 'interface_order_id' => $interface_order_id, 'docking' => $docking ); $data = $this->HTOrderOperation->getAgreeRefundBill($param); return $data; } //拒绝退单 function refuseRefundBill() { $order_id = $this->_request('order_id'); $merge_status = $this->_request('merge_status'); $user_id = $this->login_user_id; $channel_order_status = $this->_request('channel_order_status'); $order_status = $this->_request('order_status'); $outside_order_no = $this->_request('outside_order_no'); $interface_order_id = $this->_request('interface_order_id'); $docking = $this->_request('docking'); $param = array( 'order_id' => $order_id, 'merge_status' => $merge_status, 'user_id' => $user_id, 'channel_order_status' => $channel_order_status, 'order_status' => $order_status, 'outside_order_no' => $outside_order_no, 'interface_order_id' => $interface_order_id, 'docking' => $docking ); $data = $this->HTOrderOperation->getRefuseRefundBill($param); return $data; } //批量发单 function batchSendOrder(){ $list_ary = $this->_request('list_ary'); $list_ary = json_decode($list_ary,true); $user_id = $this->login_user_id; $data = $this->HTOrderOperation->getBatchSendOrder($list_ary,$user_id); return $data; } //批量确认 function batchRightOrder(){ $list_ary = $this->_request('list_ary'); $list_ary = json_decode($list_ary,true); $user_id = $this->login_user_id; $data = $this->HTOrderOperation->getBatchRightOrder($list_ary,$user_id); return $data; } //批量导出 function excelOrder(){ $dict = $this->_request('dict'); $dict = json_decode($dict,true); $date_type = $dict['date_type']; $start_date = $dict['start_date']; $end_date = $dict['end_date']; $province = $dict['province']; $city = $dict['city']; $hotel_name = $dict['hotel_name']; $org_id = $dict['org_id']; $confirm_number = $dict['confirm_number']; $more_search = $dict['more_search']; $current = $dict['current']; $page_size = $dict['pagesize']; $order_status = $dict['order_status']; $channel_order_status = $dict['channel_order_status']; $HTOrderList = new HTOrderList(); $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); $res = $data['order_list']; $order_ids = array(); foreach ($res as $key => $value) { $order_ids[] = $value['order_id']; } $comments = $this->HTOrderOperation->getCommentTxt($order_ids); // echo json_encode($comments);return; $objPHPExcel = new PHPExcel(); /*以下是一些设置 ,作者 ,标题之类*/ $objPHPExcel->getProperties()->setCreator("出行") ->setLastModifiedBy("出行") ->setTitle("数据EXCEL导出") ->setSubject("数据EXCEL导出") ->setDescription("备份数据") ->setKeywords("excel") ->setCategory("result file"); /*以下就是对处理Excel里的数据, 横着取数据*/ $objPHPExcel->setActiveSheetIndex(0) //Excel的第A列,uid是你查出数组的键值,下面以此类推 ->setCellValue('A1', '订单编号') ->setCellValue('B1', '酒店') ->setCellValue('C1', '房型') ->setCellValue('D1', '预订时间') ->setCellValue('E1', '操作人') ->setCellValue('F1', '供应商') ->setCellValue('G1', '入住时间') ->setCellValue('H1', '离店时间') ->setCellValue('I1', '间夜数') ->setCellValue('J1', '确认号') ->setCellValue('K1', '客人姓名') ->setCellValue('L1', '客人电话') ->setCellValue('M1', '订单渠道') ->setCellValue('N1', '渠道订单号') ->setCellValue('O1', '订单金额') ->setCellValue('P1', '采购成本') ->setCellValue('Q1', '佣金') ->setCellValue('R1', '利润') ->setCellValue('S1', '支付方式') ->setCellValue('T1', '状态') ->setCellValue('U1', '订单备注') ->setCellValue('V1', '采购人') ->setCellValue('W1','运营人员'); foreach ($res as $k => $row) { $number = $k + 2; $order_id = $row['order_id']; $obj = $HTOrderList->getPrice($order_id); $purchaser = $HTOrderList->getPurchaser($row['prod_supply_org_id']); $principal = $HTOrderList->getPrincipal($row['hotel_name']); $num = 0; // $base_price = 0; foreach ($obj as $v) { $num += $v['num']; // $base_price += $v['base_price']; } @$jianye = $num; //取出order_id->备注 // echo $order_id;return; $comment_txt = isset($comments[$order_id])?$comments[$order_id]:array(); $comment_txt = implode(';', $comment_txt); // $memo = $row['customer_memo']; // $notes = explode('||', $memo); // if (count($notes) > 0) { // $tmp = array(); // foreach ($notes as $note) { // $item = explode('|', $note); // if (count($item) >= 3 && $item[3] != '') { // $tmp[] = $item[3]; // } // } // $memo = implode(';', $tmp); // } else { // $memo = $notes[0]; // } @$customer_memo = $comment_txt; @$total_commission = $row['total_commission']; @$outside_order_no = $row['outside_order_no']; @$prod_name = $row['prod_name']; @$profit_value = $row['profit_value']; @$hotel_name = $row['hotel_name']; @$create_time = $row['create_time']; @$user_name = $row['user_name']; @$prod_start_station_date = $row['prod_start_station_date']; @$prod_end_station_date = $row['prod_end_station_date']; @$order_confirm_code = $row['order_confirm_code']; @$prod_supply_org_name = $row['prod_supply_org_name']; @$customer_name = $row['customer_name']; @$customer_mobile = $row['customer_mobile']; @$org_name = $row['org_name']; @$order_price = $row['order_price']; @$base_price = $row['base_price']; @$order_pay_type = $row['order_pay_type']; @$order_status_name = $row['order_status_name']; @$purchaser_id = $purchaser['purchaser_id']; @$purchaser_name = $purchaser['purchaser_name']; //$objPHPExcel->getActiveSheet(0)->getStyle('F'.$num)->getAlignment()->setWrapText(true); //$objPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(50); $objPHPExcel->getActiveSheet()->getColumnDimension('A')->setAutoSize(true); $objPHPExcel->getActiveSheet()->getColumnDimension('B')->setAutoSize(true); $objPHPExcel->getActiveSheet()->getColumnDimension('C')->setAutoSize(true); $objPHPExcel->getActiveSheet()->getColumnDimension('D')->setAutoSize(true); $objPHPExcel->getActiveSheet()->getColumnDimension('E')->setAutoSize(true); $objPHPExcel->getActiveSheet()->getColumnDimension('F')->setAutoSize(true); $objPHPExcel->getActiveSheet()->getColumnDimension('J')->setAutoSize(true); $objPHPExcel->getActiveSheet()->getColumnDimension('H')->setAutoSize(true); $objPHPExcel->getActiveSheet()->getColumnDimension('I')->setAutoSize(true); $objPHPExcel->getActiveSheet()->getColumnDimension('J')->setAutoSize(true); $objPHPExcel->getActiveSheet()->getColumnDimension('K')->setAutoSize(true); $objPHPExcel->getActiveSheet()->getColumnDimension('L')->setAutoSize(true); $objPHPExcel->getActiveSheet()->getColumnDimension('M')->setAutoSize(true); $objPHPExcel->getActiveSheet()->getColumnDimension('N')->setAutoSize(true); $objPHPExcel->getActiveSheet()->getColumnDimension('O')->setAutoSize(true); $objPHPExcel->getActiveSheet()->getColumnDimension('P')->setAutoSize(true); $objPHPExcel->getActiveSheet()->getColumnDimension('Q')->setAutoSize(true); $objPHPExcel->getActiveSheet()->getColumnDimension('R')->setAutoSize(true); $objPHPExcel->getActiveSheet()->getColumnDimension('S')->setAutoSize(true); $objPHPExcel->getActiveSheet()->getColumnDimension('T')->setAutoSize(true); $objPHPExcel->setActiveSheetIndex(0) //Excel的第A列,uid是你查出数组的键值,下面以此类推 ->setCellValue('A' . $number, $order_id) ->setCellValue('B' . $number, $hotel_name) ->setCellValue('C' . $number, $prod_name) ->setCellValue('D' . $number, $create_time) ->setCellValue('E' . $number, $user_name) ->setCellValue('F' . $number, $prod_supply_org_name) ->setCellValue('G' . $number, $prod_start_station_date) ->setCellValue('H' . $number, $prod_end_station_date) ->setCellValue('I' . $number, $jianye) ->setCellValue('J' . $number, $order_confirm_code) ->setCellValue('K' . $number, $customer_name) ->setCellValue('L' . $number, $customer_mobile) ->setCellValue('M' . $number, $org_name) ->setCellValue('N' . $number, $outside_order_no) ->setCellValue('O' . $number, $order_price) ->setCellValue('P' . $number, $base_price) ->setCellValue('Q' . $number, $total_commission) ->setCellValue('R' . $number, $profit_value) ->setCellValue('S' . $number, $order_pay_type) ->setCellValue('T' . $number, $order_status_name) ->setCellValue('U' . $number, $customer_memo) ->setCellValue('V' . $number, $purchaser_name) ->setCellValue('W' . $number, $principal); } // $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"; $objPHPExcel->getActiveSheet()->setTitle('User'); $objPHPExcel->setActiveSheetIndex(0); $filename = '订单信息' . date('Y-m-d H:i:s', time()) . '.xls'; header('Content-Type: application/vnd.ms-excel'); header('Content-Disposition: attachment;filename=' . $filename); header('Cache-Control: max-age=0'); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); $objWriter->save('php://output'); } } $obj = new OrderOperation; $obj->outJson();