|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297 |
- <?php
- require_once "Api/ApiBase.php";
- require_once "Lib/Action/ModifyHotelOrder.class.php";
- require_once "Lib/Action/MakeHotelOrder.class.php";
- require_once "Lib/Common/word.php";
-
- /**
- * Created by PhpStorm.
- * User: luocj
- * Date: 2016/10/18
- * Time: 10:25
- */
- date_default_timezone_set('PRC'); //设置中国时区
- class ModifyHTOrder extends ApiBase
- {
- //订单信息
- function order_list()
- {
- $order_id = isset($_REQUEST['order_id']) ? $_REQUEST['order_id'] : "";
- $ModifyHotelOrder = new ModifyHotelOrder();
- $data = $ModifyHotelOrder->getOrderInfo($order_id);
- return $data;
- }
-
- //可用库存
- function stockList()
- {
- $start_date = isset($_POST['start_date']) ? $_POST['start_date'] : (isset($_GET['start_date']) ? $_GET['start_date'] : "");
- $end_date = isset($_POST['end_date']) ? $_POST['end_date'] : (isset($_GET['end_date']) ? $_GET['end_date'] : "");
- $hotel_id = isset($_POST['hotel_id']) ? $_POST['hotel_id'] : (isset($_GET['hotel_id']) ? $_GET['hotel_id'] : "");
- $room_type = isset($_POST['room_type']) ? $_POST['room_type'] : (isset($_GET['room_type']) ? $_GET['room_type'] : "");
- $org_id = isset($_POST['org_id']) ? $_POST['org_id'] : (isset($_GET['org_id']) ? $_GET['org_id'] : "");
- $parent_room_type = isset($_POST['parent_room_type']) ? $_POST['parent_room_type'] : (isset($_GET['parent_room_type']) ? $_GET['parent_room_type'] : "");
- $obj = new MakeHotelOrder;
- $data = $obj->getRoomStock($hotel_id, $parent_room_type, $room_type, $org_id, $start_date, $end_date);
- return $data;
-
- }
-
-
- function order_status()
- {
- $order_id = isset($_REQUEST['order_id']) ? $_REQUEST['order_id'] : "";
- if ($order_id == "") {
- $data['code'] = "16";
- $data['info'] = "缺少订单号";
- return $data;
- }
- $ModifyHotelOrder = new ModifyHotelOrder();
- $data = $ModifyHotelOrder->getOrderStatus($order_id);
- return $data;
- }
-
- /*
- * 修改订单
- */
- function modify_order()
- {
- $user_id = $this->login_user_id;
- $hotel_id = isset($_POST['hotel_id']) ? $_POST['hotel_id'] : (isset($_GET['hotel_id']) ? $_GET['hotel_id'] : "");
- $room_type = isset($_POST['room_type']) ? $_POST['room_type'] : (isset($_GET['room_type']) ? $_GET['room_type'] : "");
- $org_id = isset($_POST['org_id']) ? $_POST['org_id'] : (isset($_GET['org_id']) ? $_GET['org_id'] : "");
- $org_num = isset($_POST['org_num']) ? $_POST['org_num'] : (isset($_GET['org_num']) ? $_GET['org_num'] : "");
- $room_list = isset($_POST['room_list']) ? $_POST['room_list'] : (isset($_GET['room_list']) ? $_GET['room_list'] : "");
- $cus_list = isset($_POST['cus_list']) ? $_POST['cus_list'] : (isset($_GET['cus_list']) ? $_GET['cus_list'] : "");
- $checkin_time = isset($_POST['checkin_time']) ? $_POST['checkin_time'] : (isset($_GET['checkin_time']) ? $_GET['checkin_time'] : "");
- $if_cancel = isset($_REQUEST['if_cancel']) ? $_REQUEST['if_cancel'] : '0';
- $order_id = isset($_REQUEST['order_id']) ? $_REQUEST['order_id'] : '0';
- $benefit = isset($_REQUEST['benefit']) ? $_REQUEST['benefit'] : '';
- $total_commission = isset($_REQUEST['total_commission']) ? $_REQUEST['total_commission'] : '';
- $logList = isset($_REQUEST['logList']) ? $_REQUEST['logList'] : '';
- $ModifyHotelOrder = new ModifyHotelOrder();
- $data = $ModifyHotelOrder->getModifyOrderList($user_id, $hotel_id, $room_type, $org_id, $org_num, $room_list, $cus_list, $checkin_time, $if_cancel, $benefit, $total_commission, $order_id, $logList);
-
- // $MakeOrder = new MakeHotelOrder();
- // $data = $MakeOrder->makeOrderList($user_id, $hotel_id, $room_type, $org_id, $org_num, $room_list, $cus_list, $checkin_time, $if_cancel, $benefit, $total_commission, $order_id);
-
- return $data;
- }
-
- // public function export(){
- // $A=new ModifyHotelOrder();
- // $res=$A->getO();
- // $str = "姓名\t性别\t年龄\t\n";
- // $str = iconv('utf-8','gb2312',$str);
- // foreach($res as $row){
- // @$name = iconv('utf-8','gb2312',$row['HOTEL_ID']);
- // @$sex = iconv('utf-8','gb2312',$row['HOTEL_NAME']);
- // $str .= $name."\t".$sex."\t".$row['AREA_ID']."\t\n";
- // }
- // $filename = date('Ymd').'.xls';
- // self::exportExcel($filename,$str);
- // }
- //
- // function exportExcel($filename,$content){
- // header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
- // header("Content-Type: application/vnd.ms-execl");
- // header("Content-Type: application/force-download");
- // header("Content-Type: application/download");
- // header("Content-Disposition: attachment; filename=".$filename);
- // header("Content-Transfer-Encoding: binary");
- // header("Pragma: no-cache");
- // header("Expires: 0");
- //
- // echo $content;
- // }
- public function export()
- {
- $user_id = $this->login_user_id;
- $order_id = isset($_REQUEST['order_id']) ? $_REQUEST['order_id'] : "";
- $ModifyHotelOrder = new ModifyHotelOrder();
- $data = $ModifyHotelOrder->getBookInfo($order_id);
- $user_name = $ModifyHotelOrder->getTrueName($user_id);
- //判断是否修改单
- $res = $ModifyHotelOrder->isUpdate($order_id);
- if ($data['hotel_order_detail'][0]['order_status'] == 148||$data['hotel_order_detail'][0]['order_status']==383) {
- $type = "酒店取消单";
- } else {
- if ($res['rowset']) {
- $type = "酒店修改单";
- } else {
- $type = "酒店确认单";
- }
- }
- @$info = $data['hotel_order_detail'][0];
- $memo = $info['customer_memo'];
- $notes = explode('||', $memo);
- if (count($notes) > 0) {
- $tmp = array();
- foreach ($notes as $note) {
- $item = explode('|', $note);
- if (count($item) >= 3 && $item[2] == 0 && $item[3] != '') {
- $tmp[] = $item[3];
- }
- }
- $memo = implode(';', $tmp);
- } else {
- $memo = $notes[0];
- }
- @$customer_memo = $memo;
- $obj = $ModifyHotelOrder->getPrice($order_id);
- $mes = '';
- $total_price = 0;
- foreach ($obj as $v) {
- @$mes .= "<div>" . $v['prod_start_station_date'] . ' ' . '数量:' . $v['num'] . '间' . ' ' . '结算价:' . ($v['base_price']/$v['num']) . '元/间' . "</div>";
- @$total_price += $v['base_price'];
- }
- $message = $mes . '订单总计:' . $total_price . '元';
- $date = date("Y-m-d", time());
- $head_org_name = '';
- if ($info['org_id'] == 1) {
- $head_org_name = "上海南顺";
- } elseif ($info['org_id'] == 2) {
- $head_org_name = '上海蜘蛛行';
- } elseif ($info['org_id'] == 3) {
- $head_org_name = '上海自在';
- } elseif ($info['org_id'] == 4) {
- $head_org_name = '杭州启程';
- } elseif ($info['org_id'] == 5) {
- $head_org_name = '杭州倒计时';
- }
- $word = new word();
- $html = "<!DOCTYPE html>
- <html lang=\"en\">
- <head>
- <meta charset=\"UTF - 8\">
- <title>{$type}</title>
- </head>
- <style>
- td {
- padding: 6px; height: 45px;
- }
- </style>
- <body style=\"margin: 0 auto;width: 800px;font-family: 宋体\">
- <div>
- <!--头部-->
- <div style=\"width: 100%;text-align: center;margin-top: 15px;\">
- <span style=\"font-family: 宋体;font-size: 42px;font-weight: 600;\">{$head_org_name}{$type}</span></div>
- </div>
- <!--body部-->
- <div style=\"margin-top: 30px;\">
- <table border=\"2\" cellpadding=\"0\" cellspacing=\"0\"
- style=\"width: 100%;height: 100%; border-color: #a9c6c9;border-collapse: collapse;\">
- <tr>
- <th style=\"padding: 4px; height: 45px;font-size: 16px;width: 120px;\">订单号:</th>
- <td style=\"padding: 4px; height: 45px;font-size: 16px;text-align: center;\">{$order_id}</td>
- <th style=\"padding: 4px; height: 45px;font-size: 16px;width: 120px;\">付款方式:</th>
- <td style=\"padding: 4px; height: 45px;font-size: 16px;text-align: center;\">{$info['type_name']} {$info['type_time']}</td>
- </tr>
- <tr>
- <th style=\"padding: 4px; height: 45px;font-size: 16px;width: 120px;\">发 自:</th>
- <td colspan=\"3\" style=\"padding: 4px; height: 45px;font-size: 16px;text-align: center;font-weight: 600;\">{$info['org_name']}</td>
- </tr>
- <tr>
- <th style=\"padding: 4px; height: 45px;font-size: 16px;width: 120px;\">传 真:</th>
- <td style=\"padding: 4px; height: 45px;font-size: 16px;text-align: center;\">021-33280184</td>
- <th style=\"padding: 4px; height: 45px;font-size: 16px;width: 120px;\">电 话:</th>
- <td style=\"padding: 4px; height: 45px;font-size: 16px;text-align: center;\">021-33280578</td>
- </tr>
- </table>
- <div style='height: 60px;'> </div>
- <table border=\"2\" cellpadding=\"0\" cellspacing=\"0\"
- style=\"width: 100%;height: 100%; border-color: #a9c6c9;border-collapse: collapse;\">
- <tr >
- <th style=\"padding: 4px; height: 45px;font-size: 16px;width: 120px;\">预订房型:</th>
- <td colspan=\"3\" style=\"padding: 4px; height: 45px;font-size: 16px;text-align: center;font-weight: 600;\">{$info['hotel_name']} {$info['product_name']}</td>
- </tr>
- <tr>
- <th style=\"padding: 4px; height: 45px;font-size: 16px;width: 120px;\">客人姓名:</th>
- <td colspan=\"3\" style=\"padding: 4px; height: 45px;font-size: 16px;text-align: center;\">{$info['customer_name']}</td>
- </tr>
- <tr>
- <th style=\"padding: 4px; height: 50px;font-size: 16px;width: 120px;\">结算总价:</th>
- <td style=\"padding: 4px; height: 50px;font-size: 16px;\"> {$total_price}元</td>
- <th style=\"padding: 4px; height: 50px;font-size: 16px;width: 120px;\">客人电话:</th>
- <td style=\"padding: 4px; height: 50px;font-size: 16px;\"> {$info['customer_mobile']}</td>
- </tr>
- <tr>
- <th style=\"padding: 4px; height: 45px;font-size: 16px;width: 120px;\">入住日期:</th>
- <td style=\"padding: 4px; height: 45px;font-size: 16px;font-weight: 600;\"> {$info['start_date']}</td>
- <th style=\"padding: 4px; height: 45px;font-size: 16px;width: 120px;\">离店日期:</th>
- <td style=\"padding: 4px; height: 45px;font-size: 16px;font-weight: 600;\"> {$info['end_date']}</td>
- </tr>
- <tr style=\"height: 70px;\">
- <th style=\"padding: 4px; height: 45px;font-size: 16px;width: 120px;\">备 注:</th>
- <td colspan=\"3\" style=\"padding: 4px; height: 45px;font-size: 16px;text-align: center;\">{$customer_memo}</td>
- </tr>
- <tr>
- <th style=\"padding: 4px; height: 45px;font-size: 16px;width: 120px;\">酒店确认号:</th>
- <td style=\"padding: 4px; height: 45px;font-size: 16px;\"> {$info['order_confirm_code']}</td>
- <th style=\"padding: 4px; height: 45px;font-size: 16px;width: 120px;\">确认人:</th>
- <td style=\"padding: 4px; height: 45px;font-size: 16px;\"> </td>
- </tr>
- <tr style=\"height: 170px;\">
- <td colspan=\"4\" style=\"line-height: 20px; font-size: 16px;padding-left: 20px; padding-right: 20px;word-break:break-all\">{$message}</td>
- </tr>
- </table>
- <div style=\"height:50px;padding: 20px;float: right;\"><br>
- <table>
- <tr >
- <td style=\"width: 71%;\"></td>
- <td style=\"font-size: 16px;font-weight: 600;\">操作人:</td><td style=\"font-size: 16px;\">{$user_name['true_name']}</td>
- </tr>
- <tr >
- <td style=\"width: 71%\"></td>
- <td style=\"font-weight: 600;font-size: 16px;\">操作日期:</td><td style=\"font-size: 16px;\">{$date}</td>
- </tr>
- </table>
- <!-- <span style=\"font-weight: 600;font-size: 13px;\">操 作 人:</span><span style=\"font-size: 13px;\">王海顺</span><br><br>
- <span style=\"font-weight: 600;margin-top: 5px;font-size: 13px;\">操作日期12:</span><span style=\"font-size: 13px;\">2016-12-12</span>-->
- </div>
- </div>
- <div style=\"padding: 20px;width:800px;text-align: center;margin-top: 55px;\">
- <span style=\"font-size: 12px;color: darkgray\">* {$info['org_name']} 电话:021-33280578 传真:021-33280184</span>
- </div>
- </div>
- </div>
- </body>
- </html>";
- // var_dump($message);
- $word->start();
- $filename = $head_org_name . $type . date('m-d h:i', time()) . ".doc";
- echo $html;
- $word->save($filename);
- header('Content-type: application/word');
- header("Content-Disposition: attachment; filename={$filename}");
- // @readfile($filename,0777);
- ob_flush();
- flush();
- exit();
- }
- }
-
- $op = isset($_REQUEST['op']) ? $_REQUEST['op'] : "";
- $data = array();
- $data['code'] = "0";
- $data['info'] = "";
-
- if ($op == "") {
- $data['code'] = "5";
- $data['info'] = "缺少必要参数";
- echo json_encode($data);
- exit();
- }
- $obj = new ModifyHTOrder();
- if ($op == "order_list") {
- $data = $obj->order_list();
- } elseif ($op == "order_status") {
- $data = $obj->order_status();
- } else if ($op == "modify_order") {
- $data = $obj->modify_order();
- } else if ($op == 'export') {
- $date = $obj->export();
- } else if ($op == 'stock_list') {
- $data = $obj->stockList();
- }
- echo json_encode($data);
|