|
- <?php
- //require_once '../../Common/Mysql.php';
- //echo '<PRE>';
- if (ALLOW_ORIGIN)
- header("Access-Control-Allow-Origin:*");
- //require_once '../../Common/Mysql.php';
- $user_id = $_COOKIE['user_id'];
- $order_from_org_id = isset($_COOKIE['org_id']) ? $_COOKIE['org_id'] : 0;
- $top_org_id = $_COOKIE['top_org_id'];
- if (!$user_id) {
- echo json_encode(array("code" => 1, "iflogin" => 1, "info" => "用户未登录"));
- exit;
- }
-
- $mem_theater_array = get_memcache('lion_threater_info');
- if( $mem_theater_array == false ) {
- echo json_encode(array("code" => 1, "info" => "系统维护中,当前不接受预订,请稍后再试"));
- exit;
- }
-
- $tic_info = false;
- if (isset($_POST)) {
- $date = isset($_POST['date_time']) ? $_POST['date_time'] : '0';
- /*
- if ($date <= '2016-10-23') {
- echo json_encode(array("code" => 1, "info" => "系统维护暂停售票"));
- exit;
- }
- */
- if (isset($_POST['get_tic'])) {
- $date = $_POST['get_tic'];
- $time = $_POST['time'];
- if( isset($mem_theater_array[$date][$time]) ) {
- $tic_info = $mem_theater_array[$date][$time];
- } else {
- echo json_encode(array("code" => 1, "info" => "该时间段无演出"));
- exit;
- }
- echo json_encode(array("code" => 0, "info" => $tic_info['tic_info'], 'price' => $tic_info['price']));
- exit;
- }
- if( $mem_theater_array[$date] == false ) {
- $date_get = isset($_POST['date_get']) ? $_POST['date_get'] : '999';
- if ($date_get == 0) {
- echo json_encode(array("code" => 0, "info" => "","list"=>array('15:00')));
- exit;
- } elseif ($date_get == 1) {
- echo json_encode(array("code" => 1, "info" => "周一没有演出", "list" => array()));
- exit;
- } elseif ($date_get <= 5) {
- echo json_encode(array("code" => 0, "info" => "", "list" => array('19:00')));
- exit;
- } elseif ($date_get == 6) {
- echo json_encode(array("code" => 0, "info" => "", "list" => array('13:30', '19:00')));
- exit;
- }
- } else {
- $time_list = array();
- $list_tic_day = $mem_theater_array[$date];
- foreach( $list_tic_day as $time_key => $tic_array_tmp ) {
- $time_list[] = $time_key;
- }
- echo json_encode(array("code" => 0, "info" => "","list"=>$time_list));
- exit;
- }
- $date = $_POST['date_time'];
- $time = $_POST['time'];
- $cust_name = $_POST['customer_name'];
- $cust_phone = $_POST['customer_phone'];
- $id_type = 150; // 150身份证 153 护照
- $customer_id = '';
- if (!isset($_POST['date_time']) || !isset($_POST['time'])) {
- $code = 1;
- $info = '';
- $massge = 'fail';
- $list = "";
- $json['code'] = $code;
- $json['info'] = $info;
- $json['massge'] = $massge;
- $json['list'] = $list;
- echo json_encode($json);
- die;
- }
- //票种和数量价格 prod_id=>票的数量
-
-
- $ticket = array(
- 'AA' => isset($_POST['AA']) ? $_POST['AA'] : 0,
- 'AB' => isset($_POST['AB']) ? $_POST['AB'] : 0,
- 'BB' => isset($_POST['BB']) ? $_POST['BB'] : 0,
- 'BA' => isset($_POST['BA']) ? $_POST['BA'] : 0,
- 'CA' => isset($_POST['CA']) ? $_POST['CA'] : 0,
- 'CB' => isset($_POST['CB']) ? $_POST['CB'] : 0,
- );
- $buy_array = array(
- '0' => isset($_POST['AA']) ? $_POST['AA'] : 0,
- '1' => isset($_POST['AB']) ? $_POST['AB'] : 0,
- '3' => isset($_POST['BB']) ? $_POST['BB'] : 0,
- '2' => isset($_POST['BA']) ? $_POST['BA'] : 0,
- '4' => isset($_POST['CA']) ? $_POST['CA'] : 0,
- '5' => isset($_POST['CB']) ? $_POST['CB'] : 0
-
- );
- $ticket_no_b = serialize($buy_array);
- }
- if( !isset($date) || $date == false || $date == "" ) {
- echo json_encode(array("code" => 1, "info" => '请选择演出时间'));
- exit ;
- }
- if( !isset($time) || $time == false || $time == "" ) {
- echo json_encode(array("code" => 1, "info" => '请选择演出时间'));
- exit ;
- }
- if(!isset($mem_theater_array[$date][$time])) {
- echo json_encode(array("code" => 1, "info" => "该时间段无演出"));
- exit;
- }
- if( $tic_info == false ) {
- $tic_info = $mem_theater_array[$date][$time];
- }
- //check ticket num
- foreach( $buy_array as $buy_key => $buy_count ) {
- $ticket_remain_count = $tic_info['tic_info'][$buy_key];
- if( $ticket_remain_count < $buy_count ) {
- echo json_encode(array("code" => 1, "info" => '预订票数超出余票数量' ));
- exit ;
- }
- }
-
- //$tic_buy = buy_lionking_ticket('魏意锡','18663582623','371521199011034631',$buy_array,'2016-8-13','13:30');
- $tic_buy = buy_lionking_ticket($cust_name, $cust_phone, $customer_id, $buy_array, $date, $time, $tic_info["ticket_array"]);
- if ($tic_buy == '-1' || $tic_buy == '0') {
-
- echo json_encode(array("code" => 1, "info" => '出票失败'));
- exit;
- }
-
- $pdo = conn();
- $sql = "select a.prod_id,a.prod_name,b.prod_price,b.prod_type_id "
- . "from opera_product a inner join opera_product_price b on a.prod_id = b.prod_id "
- . "where a.parent_id = 387544";
- $result = $pdo->query($sql);
- $rowset = $result->fetchAll(PDO::FETCH_ASSOC);
- $info = array();
- foreach ($rowset as $v) {
- $info[$v['prod_id']] = $v;
- }
- $sql_p = "select prod_id,prod_name "
- . " from opera_product "
- . " where prod_id = 387544";
- $result_p = $pdo->query($sql_p);
- $rowset_p = $result_p->fetchAll(PDO::FETCH_ASSOC);
- $info_p = $rowset_p[0];
- /**
- * 迪士尼票种信息
- * 152990 =>
- * array
- * 'prod_id' => string '152990' (length=6)
- * 'prod_name' => string '迪士尼门票(成人票)' (length=30)
- * 'prod_price' => string '20.00' (length=5)
- * 'prod_type_id' => string '262' (length=3)
- */
- $num = 0;
- $order_description = "";
- $price = 0;
- $return_info = '';
- //var_dump($info);die;
- foreach ($ticket as $k => $v) {
- $num += $v;
- if ($v) {
- switch ($k) {
- case 'AA':
- $price += $tic_info['price']['0'] * $v;
- $return_info .= ' AA区 × ' . $v;
- $order_description .= "迪士尼剧场AA区," . date('Y-m-d', time()) . "," . $v . "|";
- break;
- case 'AB':
- $price += $tic_info['price']['1'] * $v;
- $return_info .= ' AB区 × ' . $v;
- $order_description .= "迪士尼剧场AB区," . date('Y-m-d', time()) . "," . $v . "|";
- break;
- case 'BB':
- $price += $tic_info['price']['3'] * $v;
- $return_info .= ' BB区 × ' . $v;
- $order_description .= "迪士尼剧场BB区," . date('Y-m-d', time()) . "," . $v . "|";
- break;
- case 'BA':
- $price += $tic_info['price']['2'] * $v;
- $return_info .= ' BA区 × ' . $v;
- $order_description .= "迪士尼剧场BA区," . date('Y-m-d', time()) . "," . $v . "|";
- break;
- case 'CA':
- $price += $tic_info['price']['4'] * $v;
- $return_info .= ' CA区 × ' . $v;
- $order_description .= "迪士尼剧场CA区," . date('Y-m-d', time()) . "," . $v . "|";
- break;
- case 'CB':
- $price += $tic_info['price']['5'] * $v;
- $return_info .= ' CB区 × ' . $v;
- $order_description .= "迪士尼剧场CB区," . date('Y-m-d', time()) . "," . $v . "|";
- break;
- }
- }
- }
- if ($num <= 0) {
- $code = 1;
- $info = '';
- $massge = 'fail';
- $list = "";
- $json['code'] = $code;
- $json['info'] = $info;
- $json['massge'] = $massge;
- $json['list'] = $list;
- echo json_encode($json);
- die;
- }
- //支付方式
-
- if (isset($_COOKIE['login_type']) || $top_org_id == 0) {
- $pay_status = 145;
- $pay_type_id_1 = 278;
- } else {
- $pay_status = 146;
- $pay_type_id_1 = 275;
- }
-
-
- //订单插入需要的字段 id = order_id create_time update_time order_pay_satatus 0 未支付 order_description order_price order_prod_type
- // prod_name order_status customer_name customer_mobile customer_id_type customer_id _no
- // 至订单需要的之短 parent_order_id prod_id parent_prod_id prod_name parent_prod_name order_price
- $id_p = $order_id_p = getUniqeId1();
- $pay_main_id = getUniqeId1();
- $create_time = $update_time = date('Y-m-d H:i:s', time());
- $order_pay_status = 0;
- //查找数据库中关于迪士尼的信息
- $sql_in = " insert into order_main
- (`id`,
- `order_id`,
- `create_time`,`update_time`,
- `order_pay_status`,`order_description`,
- `order_price`,`order_prod_type`,`prod_name`,`order_status`,
- `customer_name`,`customer_mobile`,`customer_id_type`,`customer_id_no`,
- `order_book_status`,`PROD_START_STATION_TIME_MINUTES`,`prod_id`,`run_date`,`run_time`,`main_create_user_id`,`order_pay_main_id`,`outside_sale_org_id`,`outside_order_no`)
- values ('" . $id_p . "','". $order_id_p . "','" . $create_time . "','" . $update_time . "','0','" . $order_description . "','"
- . $price . "','259','" . $info_p['prod_name'] . "','" . $pay_status . "','"
- . $cust_name . "','" . $cust_phone . "','" . $id_type . "','" . $customer_id . "','1','0','" . $info_p['prod_id'] . "','" . $date . "','" . $time . "','" . $user_id . "','" . $pay_main_id . "','" . $order_from_org_id . "','" . $tic_buy . "')";
- for_insert($sql_in);
-
- $sql_pay = "insert INTO"
- . " `order_pay_main`(id,CREATe_user_id,CREATE_time,update_user_id,pay_total) "
- . "VALUES(" . $pay_main_id . "," . $user_id . ",'" . date('Y-m-d H-i-s', time()) . "'," . $user_id . "," . $price . ");"
- . "insert INTO `order_pay_detail`
- (id,CREATe_user_id,CREATE_time,update_user_id,pay_main_id,pay_type_id_1,pay_money)
- VALUES(" . $pay_main_id . "," . $user_id . ",'" . date('Y-m-d H-i-s', time()) . "'," . $user_id . "," . $pay_main_id . "," . $pay_type_id_1 . "," . $price . ");";
- for_insert($sql_pay);
-
- foreach ($ticket as $k => $v) {
- if ($v) {
- switch ($k) {
- case 'AA':
- for ($i = 1; $i <= $v; $i++) {
- $id = $order_id = getUniqeId1();
- $sql = " insert into order_main
- (`id`,
- `order_id`,
- `create_time`,`update_time`,
- `order_pay_status`,
- `order_prod_type`,`order_status`,
- `customer_name`,`customer_mobile`,`customer_id_type`,`customer_id_no`,
- `order_book_status`,`PROD_START_STATION_TIME_MINUTES`,`parent_order_id`,`prod_id`,`parent_prod_id`,`prod_name`,`parent_prod_name`,`order_price`,`run_date`,`run_time`,`order_pay_main_id`,`outside_sale_org_id`,`outside_order_no`,`main_create_user_id`)
- values ('" . $id . "','". $order_id . "','" . $create_time . "','" . $update_time . "','0','259','" . $pay_status . "','" . $cust_name . "','" . $cust_phone . "','" . $id_type . "','"
- . $customer_id . "','0','0','" . $id_p . "','" . $info['387545']['prod_id'] . "','" . $info_p['prod_id'] . "','" . $info['387545']['prod_name'] . "','" . $info_p['prod_name'] . "','" . $tic_info['price']['0'] . "','" . $date . "','" . $time . "','" . $pay_main_id . "','" . $order_from_org_id . "','" . $tic_buy . "','" . $user_id . "')";
- for_insert($sql);
- }
- break;
-
- case 'AB':
- for ($i = 1; $i <= $v; $i++) {
- $id = $order_id = getUniqeId1();
- $sql = " insert into order_main
- (`id`,
- `order_id`,
- `create_time`,`update_time`,
- `order_pay_status`,
- `order_prod_type`,`order_status`,
- `customer_name`,`customer_mobile`,`customer_id_type`,`customer_id_no`,
- `order_book_status`,`PROD_START_STATION_TIME_MINUTES`,`parent_order_id`,`prod_id`,`parent_prod_id`,`prod_name`,`parent_prod_name`,`order_price`,`run_date`,`run_time`,`order_pay_main_id`,`outside_sale_org_id`,`outside_order_no`,`main_create_user_id`)
- values ('" . $id . "','". $order_id . "','" . $create_time . "','" . $update_time . "','0','259','" . $pay_status . "','" . $cust_name . "','" . $cust_phone . "','" . $id_type . "','"
- . $customer_id . "','0','0','" . $id_p . "','" . $info['387546']['prod_id'] . "','" . $info_p['prod_id'] . "','" . $info['387546']['prod_name'] . "','" . $info_p['prod_name'] . "','" . $tic_info['price']['1'] . "','" . $date . "','" . $time . "','" . $pay_main_id . "','" . $order_from_org_id . "','" . $tic_buy . "','" . $user_id . "')";
- for_insert($sql);
- }
- break;
- case 'BB':
- for ($i = 1; $i <= $v; $i++) {
- $id = $order_id = getUniqeId1();
- $sql = " insert into order_main
- (`id`,
- `order_id`,
- `create_time`,`update_time`,
- `order_pay_status`,
- `order_prod_type`,`order_status`,
- `customer_name`,`customer_mobile`,`customer_id_type`,`customer_id_no`,
- `order_book_status`,`PROD_START_STATION_TIME_MINUTES`,`parent_order_id`,`prod_id`,`parent_prod_id`,`prod_name`,`parent_prod_name`,`order_price`,`run_date`,`run_time`,`order_pay_main_id`,`outside_sale_org_id`,`outside_order_no`,`main_create_user_id`)
- values ('" . $id . "','"
- . $order_id . "','" . $create_time . "','" . $update_time . "','0','259','" . $pay_status . "','" . $cust_name . "','" . $cust_phone . "','"
- . $id_type . "','" . $customer_id . "','0','0','" . $id_p . "','" . $info['387547']['prod_id'] . "','" . $info_p['prod_id'] . "','" . $info['387547']['prod_name'] . "','" . $info_p['prod_name'] . "','" . $tic_info['price']['3'] . "','" . $date . "','" . $time . "','" . $pay_main_id . "','" . $order_from_org_id . "','" . $tic_buy . "','" . $user_id . "')";
- for_insert($sql);
- }
- break;
- case 'BA':
- for ($i = 1; $i <= $v; $i++) {
- $id = $order_id = getUniqeId1();
- $sql = " insert into order_main
- (`id`,
- `order_id`,
- `create_time`,`update_time`,
- `order_pay_status`,
- `order_prod_type`,`order_status`,
- `customer_name`,`customer_mobile`,`customer_id_type`,`customer_id_no`,
- `order_book_status`,`PROD_START_STATION_TIME_MINUTES`,`parent_order_id`,`prod_id`,`parent_prod_id`,`prod_name`,`parent_prod_name`,`order_price`,`run_date`,`run_time`,`order_pay_main_id`,`outside_sale_org_id`,`outside_order_no`,`main_create_user_id`)
- values ('" . $id . "','". $order_id . "','" . $create_time . "','" . $update_time . "','0','259','" . $pay_status . "','" . $cust_name . "','" . $cust_phone . "','" . $id_type . "','"
- . $customer_id . "','0','0','" . $id_p . "','" . $info['387548']['prod_id'] . "','" . $info_p['prod_id'] . "','" . $info['387548']['prod_name'] . "','" . $info_p['prod_name'] . "','" . $tic_info['price']['2'] . "','" . $date . "','" . $time . "','" . $pay_main_id . "','" . $order_from_org_id . "','" . $tic_buy . "','" . $user_id . "')";
- for_insert($sql);
- }
- break;
- case 'CA':
- for ($i = 1; $i <= $v; $i++) {
- $id = $order_id = getUniqeId1();
- $sql = " insert into order_main
- (`id`,
- `order_id`,
- `create_time`,`update_time`,
- `order_pay_status`,
- `order_prod_type`,`order_status`,
- `customer_name`,`customer_mobile`,`customer_id_type`,`customer_id_no`,
- `order_book_status`,`PROD_START_STATION_TIME_MINUTES`,`parent_order_id`,`prod_id`,`parent_prod_id`,`prod_name`,`parent_prod_name`,`order_price`,`run_date`,`run_time`,`order_pay_main_id`,`outside_sale_org_id`,`outside_order_no`,`main_create_user_id`)
- values ('" . $id . "','". $order_id . "','" . $create_time . "','" . $update_time . "','0','259','" . $pay_status . "','" . $cust_name . "','" . $cust_phone . "','" . $id_type . "','"
- . $customer_id . "','0','0','" . $id_p . "','" . $info['387549']['prod_id'] . "','" . $info_p['prod_id'] . "','" . $info['387549']['prod_name'] . "','" . $info_p['prod_name'] . "','" . $tic_info['price']['4'] . "','" . $date . "','" . $time . "','" . $pay_main_id . "','" . $order_from_org_id . "','" . $tic_buy . "','" . $user_id . "')";
- for_insert($sql);
- }
- break;
- case 'CB':
- for ($i = 1; $i <= $v; $i++) {
- $id = $order_id = getUniqeId1();
- $sql = " insert into order_main
- (`id`,
- `order_id`,
- `create_time`,`update_time`,
- `order_pay_status`,
- `order_prod_type`,`order_status`,
- `customer_name`,`customer_mobile`,`customer_id_type`,`customer_id_no`,
- `order_book_status`,`PROD_START_STATION_TIME_MINUTES`,`parent_order_id`,`prod_id`,`parent_prod_id`,`prod_name`,`parent_prod_name`,`order_price`,`run_date`,`run_time`,`order_pay_main_id`,`outside_sale_org_id`,`outside_order_no`,`main_create_user_id`)
- values ('" . $id . "','". $order_id . "','" . $create_time . "','" . $update_time . "','0','259','" . $pay_status . "','" . $cust_name . "','" . $cust_phone . "','" . $id_type . "','"
- . $customer_id . "','0','0','" . $id_p . "','" . $info['387550']['prod_id'] . "','" . $info_p['prod_id'] . "','" . $info['387550']['prod_name'] . "','" . $info_p['prod_name'] . "','" . $tic_info['price']['5'] . "','" . $date . "','" . $time . "','" . $pay_main_id . "','" . $order_from_org_id . "','" . $tic_buy . "','" . $user_id . "')";
- for_insert($sql);
- }
- break;
- }
- }
- }
- function for_insert($sql)
- {
- // echo $sql;
- $pdo = conn();
- $re = $pdo->exec($sql);
- if ($re == 0) {
- echo json_encode(array("code" => 1, "info" => "error_sql=" . "$sql"));
- exit;
- }
- }
-
- if ($_COOKIE['top_org_id']) {
- true_buy_disney($tic_buy);
- } else {
- $sql = "INSERT into `disney_order`(order_id,yet,cust_name,cust_phone,customer_id,ticket_no,date,create_time,dis_the,time) VALUES(" . $id_p . ",1,'" . $cust_name . "','" . $cust_phone . "','" . $customer_id . "','" . $ticket_no_b . "','" . $date . "',null,1,'" . $time . "');";
- $result = $pdo->query($sql);
- //$rowset = $result -> fetchAll(PDO::FETCH_ASSOC);
- if (!$result) {
- echo json_encode(array("code" => 1, "info" => '下单失败'));
- exit;
- }
- }
- $list = array();
- $list['type'] = $info_p['prod_name'];
- $list['date'] = $date;
- $list['desc'] = $return_info;
- $list['price'] = $price;
- $list['name'] = $cust_name;
- $list['phone'] = $cust_phone;
- $list['order_id'] = $id_p;
- $code = 0;
- $info = '0';
- $massge = 'success';
- $json['code'] = $code;
- $json['info'] = $info;
- $json['order_id'] = $id_p;
- $json['massge'] = $massge;
- $json['list'] = $list;
- $json['ifdisney'] = 1;
- echo json_encode($json);
- die;
-
- function getUniqeId1()
- {
- $pdo = conn();
- $result = $pdo->query("select FUNC_GET_UNIQUE_ID('1','1') id");
- $rowset = $result->fetchAll(PDO::FETCH_ASSOC);
- return $rowset[0]['id'];
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|