|
- <?php
- require_once '../php_include/Config.php';
- require_once '../php_include/class.db.inc';
- require_once '../php_include/disney.inc';
- require_once '../php_include/zizai_api.inc';
-
- date_default_timezone_set('PRC');
- $current_date = date("Y-m-d");
- if( $current_date >= "2016-09-01" ) {
- header("Location:http://sfx.zhizhuchuxing.com/");
- exit();
- }
- //DB
- $objDbh = new Db;
- $objDbh->setAccount(MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD, MYSQL_DB);
- $objDisney = new DbDisney($objDbh);
-
- if( !isset($_POST["gid"])) {
- header("Location:list.php?cc=".$_COOKIE["companycode"]);exit();
- }
- $base_org_info = $objDisney->getBaseOrgInfoFromCode( $_COOKIE["companycode"] );
- $base_org_name = false == $base_org_info ? "酒店" : $base_org_info["org_name"];
- $good_info=$objDisney->getGoodInfoFromId($_POST["gid"]);
- $order_serial_no = date("ymdHis").sprintf("%06d",rand( 1, 999999));
- $org_id = $base_org_info["org_id"];
- if( $good_info["good_type"] == 1 ) {
- $good_info["good_name"] = $_POST["gid"] == 15 ? $good_info["good_name"]."(回{$base_org_name})" : $base_org_name.$good_info["good_name"];
- if( isset($_ary_ticket_price1[$base_org_info["org_id"]]) && $good_id != 2 ) {
- $good_info["good_price"] = $good_id == 1 ? $_ary_ticket_price2[$base_org_info["org_id"]] : $_ary_ticket_price1[$base_org_info["org_id"]];
- }
- } else if( $good_info["good_type"] == 2 ) {
- $good_info["good_name"] = $_POST["gid"] == 3 ? "上海迪士尼乐园一日票" : "上海迪士尼乐园两日票";
- $good_price_array = $_POST["gid"] == 3 ? $_ary_disney_price1 : $_ary_disney_price2;
- }
-
- $order_user_id = 0;//need modify here
- if( isset($_COOKIE["opera_user_id"]) ) {
- $order_user_id = $_COOKIE["opera_user_id"];
- }
- $_POST["star_time"] = str_replace("年",".",$_POST["star_time"]);
- $_POST["star_time"] = str_replace("月",".",$_POST["star_time"]);
- $_POST["star_time"] = str_replace("日",".",$_POST["star_time"]);
- if( isset($_POST["end_time"]) && mb_strlen($_POST["end_time"]) > 0) {
- $_POST["end_time"] = str_replace("年",".",$_POST["end_time"]);
- $_POST["end_time"] = str_replace("月",".",$_POST["end_time"]);
- $_POST["end_time"] = str_replace("日",".",$_POST["end_time"]);
- }
-
- $start_day = "";
- $start_time = "";
- $end_day = "";
- $end_time = "";
- $start_day2 = "";
- $start_time2 = "";
- $end_day2 = "";
- $end_time2 = "";
- if( $good_info["good_type"] == 2 ) {
- //need modify here
- $start_day = sprintf( "%04d-%02d-%02d",substr($_POST["star_time"],0,4), substr($_POST["star_time"],5,2), substr($_POST["star_time"],8,2));
- $start_time = "";
- $end_day = "";
- $end_time = "";
- $order_price = $good_price_array[0] * $_POST["number2"] + $good_price_array[1] * $_POST["number3"] + $good_price_array[2] * $_POST["number4"];
-
- $prod_name = $good_info["good_name"].":";
- if( $_POST["number2"] > 0 ) { $prod_name .= $_ary_tickets_type[0]."×".$_POST["number2"]." "; }
- if( $_POST["number3"] > 0 ) { $prod_name .= $_ary_tickets_type[1]."×".$_POST["number3"]." "; }
- if( $_POST["number4"] > 0 ) { $prod_name .= $_ary_tickets_type[2]."×".$_POST["number4"]." "; }
- } else {
- $prod_name = $good_info["good_name"]."×".$_POST["number1"];
- $order_price = $good_info["good_price"] * $_POST["number1"];
- if( $good_info["good_type"] == 1 ) {
-
- $time_array1 = explode("-", $_POST["star_time"]);
- $start_time1_array = explode(".", $time_array1[0]);
- $start_day = sprintf( "%04d-%02d-%02d", $start_time1_array[0], $start_time1_array[1], $start_time1_array[2]);
- $start_time = $start_time1_array[3];
-
- if( isset($time_array1[1]) ) {
- $end_time1_array = explode(".", $time_array1[1]);
- $end_day = sprintf("%04d-%02d-%02d", $end_time1_array[0], $end_time1_array[1], $end_time1_array[2]);
- $end_time = $end_time1_array[3];
- }
- if( isset($_POST["end_time"]) ) {
- if( isset($time_array1[1]) ) {
- $time_array2 = explode("-", $_POST["end_time"]);
- $start_time2_array = explode(".", $time_array2[0]);
- $end_time2_array = explode(".", $time_array2[1]);
- $start_day2 = sprintf("%04d-%02d-%02d", $start_time2_array[0], $start_time2_array[1], $start_time2_array[2]);
- $end_day2 = sprintf("%04d-%02d-%02d", $end_time2_array[0], $end_time2_array[1], $end_time2_array[2]);
- $start_time2 = $start_time2_array[3];
- $end_time2 = $end_time2_array[3];
- } else {
- $end_time1_array = explode(".", $_POST["end_time"]);
- $end_day = sprintf("%04d-%02d-%02d", $end_time1_array[0], $end_time1_array[1], $end_time1_array[2]);
- $end_time = $end_time1_array[3];
- }
- }
- } else {
- $start_time_array = explode(".", $_POST["star_time"]);
- $start_day = sprintf( "%04d-%02d-%02d", $start_time_array[0], $start_time_array[1], $start_time_array[2]);
- $start_time = $start_time_array[3];
- }
- }
-
- $trade_no = "";
- $order_comment = "";
- //zizai check
- if( ($good_info["good_type"] == 2 || $good_info["good_type"] == 3) ) {
- if ($_POST["gid"] == 3) {
- $ticket_array = get_disney_info($start_day);
- } else if ($_POST["gid"] == 6) {
- $ticket_array = get_disney_info2($start_day);
- } else if ($_POST["gid"] >= 9 && $_POST["gid"] <= 14) {
- $start_week_day = date("w", strtotime($start_day));
- if ($start_week_day == 6 || $start_week_day == 0) {
- $ticket_array = get_disney_info3($start_day, $start_time);
- } else {
- $ticket_array = get_disney_info3($start_day);
- }
- }
- if ($ticket_array == false) {
- header("Location:sold_out.php?cc=" . $_COOKIE["companycode"]);
- exit();
- }
- $customer_txt = '{|' . $_POST["name"] . '|' . $_POST["phone"] . '|' . $_POST["idcard"] . '||}';
- $buy_prod_txt = "";
- if ($good_info["good_type"] == 2) {
- $base_prod_index = $_POST["gid"] == 3 ? 1 : 4;
- for ($number_index = 2; $number_index <= 4; $number_index++) {
- $post_index = "number" . $number_index;
- $ticket_index = $_ary_goods_zizai_index[$base_prod_index + $number_index];
- $buy_prod_info = $ticket_array[$ticket_index];
- if ($buy_prod_info["ticketcount"] < $_POST[$post_index]) {
- header("Location:sold_out.php?cc=" . $_COOKIE["companycode"]);
- exit();
- }
- $buy_prod_txt .= $buy_prod_info["ticketid"] . "P" . $_POST[$post_index] . "|";
- }
- } else {
- $ticket_index = $_ary_goods_zizai_index[$_POST["gid"]];
- $buy_prod_info = $ticket_array[$ticket_index];
- if ($buy_prod_info["ticketcount"] < $_POST["number1"]) {
- header("Location:sold_out.php?cc=" . $_COOKIE["companycode"]);
- exit();
- }
- $buy_prod_txt .= $buy_prod_info["ticketid"] . "P" . $_POST["number1"] . "|";
- }
- $result_info = lock(API_USER, API_PASSWORD, 15, $buy_prod_txt, $customer_txt, "", "", "");
- if ($result_info["code"] == 0) {
- $trade_no = $result_info["tradeno"];
- } else {
- header("Location:sold_out.php?cc=" . $_COOKIE["companycode"]);
- exit();
- }
- if ($trade_no != "" && $is_smartphone == false) {
- $result_info = eticket(API_USER, API_PASSWORD, $trade_no);
- if ($result_info["code"] == 0) {
- $order_comment = "已在自在自动下单,订单号:" . $trade_no;
- } else {
- $order_comment = "自在自动下单失败,失败原因:" . $result_info["info"];
- }
- }
- }
-
- $insert_order_array = array(
- "order_serial_no" => $order_serial_no,//test
- "org_id" => $org_id,//test
- "status" => 0,
- "is_payed" => 0,
- "pay_type" => 0,
- "pay_no" => "",
- "prod_id" =>$_POST["gid"],
- "prod_name" => $prod_name,
- "order_user_id" => $order_user_id,
- "create_time" => date('Y-m-d H:i:s'),
- "order_price" => $order_price,
- "afli_price" => 0,
- "comment" => $order_comment,
- "start_day" => $start_day,
- "start_time" => $start_time,
- "end_day" => $end_day,
- "end_time" => $end_time,
- "start_day2" => $start_day2,
- "start_time2" => $start_time2,
- "end_day2" => $end_day2,
- "end_time2" => $end_time2,
- "cus_name" => $_POST["name"],
- "cus_mobile" => $_POST["phone"],
- "cus_iden" => $_POST["idcard"],
- "outside_order_no" => $trade_no
- );
- $insert_result = $objDisney->insertNewOrder($insert_order_array);
- if( false == $insert_result ) {
- echo "预定失败";exit();
- }
- $last_order_info = $objDisney->getOrderInfoFromSN($order_serial_no);
- $insert_order_id = $last_order_info['id'];
- $insert_order_goods_array = array();
- $base_order_good_info = array(
- "order_id" => $insert_order_id,
- "good_id" => $_POST["gid"],
- "good_name" => $good_info["good_name"],
- "subtype" => 0,
- "good_per_price" => $good_info["good_price"],
- "good_num" => $_POST["number1"],
- "all_price" => $good_info["good_price"] * $_POST["number1"],
- "afli_price" => 0,
- "start_day" => $start_day,
- "start_time" => $start_time,
- "end_day" => $end_day,
- "end_time" => $end_time,
- "start_day2" => $start_day2,
- "start_time2" => $start_time2,
- "end_day2" => $end_day2,
- "end_time2" => $end_time2,
- );
- if( $good_info["good_type"] == 2 ) {
- for( $index_temp = 0; $index_temp < 3; $index_temp++ ) {
- $num_index = "number".($index_temp+2);
- if( $_POST[$num_index] <= 0) {
- continue;
- }
- $insert_array_temp = $base_order_good_info;
- $insert_array_temp["good_id"] =$_POST["gid"]+$index_temp;
- $insert_array_temp["good_name"] = $good_info["good_name"].$_ary_tickets_type[$index_temp];
- $insert_array_temp["good_per_price"] = $good_price_array[$index_temp];
- $insert_array_temp["good_num"] = $_POST[$num_index];
- $insert_array_temp["all_price"] = $insert_array_temp["good_per_price"] * $_POST[$num_index];
- $insert_array_temp["subtype"] = $index_temp;
- $insert_order_goods_array[] = $insert_array_temp;
- }
- } else {
- $insert_order_goods_array[] = $base_order_good_info;
- }
- $objDisney->insertOrderGoods($insert_order_goods_array);
- if( $is_smartphone == true ) {
- header("Location: pay.php?orderno=" . $order_serial_no);
- exit();
- } else {
- header("Location: paysuccess.php?orderno=" . $order_serial_no);
- exit();
- }
-
- ?>
|