|
- <?php
- /**
- * Created by PhpStorm.
- * User: Steven
- * Date: 2016/8/16
- * Time: 11:57
- */
- header("Content-type:text/html;charset=utf-8");
- require_once '../Common/Mysql.php';
- require_once '../Common/zizai_orderAPI.php';
- $current_time = date("Y-m-d H:i:s");
- $getOrderInfo = new orderService();
- $result = array();
-
- //$can_sell_array = array("shz101", "zsz101");
- $can_sell_array = array('HSHH01','HSPT01','HSHH02','HSPT02');
-
- $end_res_array = array(
- 'HSHH01' => array("黄山风景区南大门汤口镇","黄山市区自驾车旅游服务中心"),
- 'HSPT01' => array("黄山风景区南大门汤口镇","黄山市区自驾车旅游服务中心"),
- 'HSHH02' => array("黄浦集散站","上海南站","人民广场"),
- 'HSPT02' => array("黄浦集散站","上海南站","人民广场")
- );
-
- //获取所有可销售线路$ccode
- $return_result = $getOrderInfo->run_list(zizaiArgs::$USER);
- if ($return_result["code"] == 0) {
- $circuitry_list = $return_result["circuitry_list"]["circuitry"];
- }
-
- if (isset($circuitry_list['ccode'])) {
- $godate_array = $getOrderInfo->godate(zizaiArgs::$USER, $circuitry_list['ccode']);
- foreach ($godate_array['date_list']['godate'] as $godate) {
-
- if ($godate <= date("Y-m-d", strtotime("+21 days")) && $godate >= date("Y-m-d", strtotime("+2 days")) ) {
- $circuitry_list['godate'] = $godate;
- //获取班次的信息
- $runlist = $getOrderInfo->gorun(zizaiArgs::$USER, $circuitry_list['ccode'], $godate);
-
- //根据班次和时间获取所有的票种信息
- if (!isset($runlist['go_run_list']['run']['runid'])) {
- foreach ($runlist['go_run_list']['run'] as $key => $runInfo) {
- $ticketInfo = $getOrderInfo->ticket(zizaiArgs::$USER, $circuitry_list['ccode'], $runInfo['runid']);
- $runInfo['ticket_info'] = $ticketInfo['ticket_list']['ticket'];
- $runlist['go_run_list']['run'][$key] = $runInfo;
- }
- }
- $circuitry_list['runlist'] = $runlist['go_run_list']['run'];
- $result[] = $circuitry_list;
- }
- }
- } else {
- foreach ($circuitry_list as $circuitry) {
- if( !in_array($circuitry['ccode'],$can_sell_array) ) {continue;}
- //$result=$circuitry;
- $godate_array = $getOrderInfo->godate(zizaiArgs::$USER, $circuitry['ccode']); //获取指定线路可销售的运营日
- foreach ($godate_array['date_list']['godate'] as $godate) {
- if ($godate <= date("Y-m-d", strtotime("+21 days")) && $godate >= date("Y-m-d", strtotime("+2 days")) ) {
- $circuitry['godate'] = $godate;
- //获取班次的信息
- $runlist = $getOrderInfo->gorun(zizaiArgs::$USER, $circuitry['ccode'], $godate);
- //根据班次和时间获取所有的票种信息
- if (!isset($runlist['go_run_list']['run']['runid'])) {
- foreach ($runlist['go_run_list']['run'] as $key => $runInfo) {
- $ticketInfo = $getOrderInfo->ticket(zizaiArgs::$USER, $circuitry['ccode'], $runInfo['runid']);
- $runInfo['ticket_info'] = $ticketInfo['ticket_list']['ticket'];
- $runlist['go_run_list']['run'][$key] = $runInfo;
- }
- } else {
- $runInfo = $runlist['go_run_list']['run'];
- $ticketInfo = $getOrderInfo->ticket(zizaiArgs::$USER, $circuitry['ccode'], $runInfo['runid']);
- $runInfo['ticket_info'] = $ticketInfo['ticket_list']['ticket'];
- $runlist['go_run_list']['run'] = $runInfo;
- }
- $circuitry['runlist'] = $runlist['go_run_list']['run'];
- $result[] = $circuitry;
- }
- }
- }
- }
- foreach ($result as $lineInfo) {
- $org_id = 3;
- $line_code = $lineInfo['ccode'];
- $line_name = $lineInfo['cname'];
- $start_date = $lineInfo['godate'];
-
- $str_trip_pos = mb_strpos( $line_name, "旅游", 0,'utf-8' );
-
- $area = mb_substr($line_name, 0, $str_trip_pos, 'utf-8');
- if( mb_strpos( $line_name, "—", 0,'utf-8' ) != false ) {
- $area_arr = explode("—", $area);
- } else {
- $area_arr = explode("-", $area);
- }
- $start_area = $area_arr[0];
- $end_area = $area_arr[1];
- $end_res = $area_arr[1];
- $end_res = isset($end_res_array[$line_code]) ? $end_res_array[$line_code] : $area_arr[1];
- if( isset($lineInfo['runlist']['runid']) ) {
- $runInfo = $lineInfo['runlist'];
- insert_outside_run( $runInfo, $org_id, $line_code, $line_name, $start_date, $start_area, $end_area, $end_res, $current_time);
- } else {
- foreach ($lineInfo['runlist'] as $runInfo) {
- insert_outside_run( $runInfo, $org_id, $line_code, $line_name, $start_date, $start_area, $end_area, $end_res, $current_time);
- }
- }
- }
-
- function insert_outside_run( $runInfo, $org_id, $line_code, $line_name, $start_date, $start_area, $end_area, $end_res, $current_time) {
- $run_code = $runInfo['runid'];
- $start_time = $runInfo['runtime'];
- $start_res = $runInfo['runarea'];
- foreach ($runInfo['ticket_info'] as $ticketInfo) {
- if (isset($ticketInfo['ticketname'])) {
- $prod_code = $ticketInfo['ticketid'];
- $cus_price = $ticketInfo['ticketprice'];
- $mid_price = isset($ticketInfo['agentprice']) ? $ticketInfo['agentprice'] : $ticketInfo['ticketprice']*0.9;
- $remain_count = $ticketInfo['ticketcount'];
- $prod_name = $ticketInfo['ticketname'];
- if ($mid_price <= 0 || mb_strlen($prod_name) < 5) {
- continue;
- }
- if( is_array($end_res) ) {
- foreach( $end_res as $end_res_txt ) {
- $sql_insert = " INSERT INTO outside_run ( org_id, run_code, prod_code, prod_name, line_code, line_name, start_date, start_time, start_area, end_area, start_res, end_res, cus_price, mid_price, remain_count, cancel_flag,update_time) " .
- " VALUES ( {$org_id}, '{$run_code}', '{$prod_code}','{$prod_name}','{$line_code}','{$line_name}','{$start_date}', '{$start_time}', '{$start_area}', '{$end_area}', '{$start_res}', '{$end_res_txt}', {$cus_price}, {$mid_price}, {$remain_count}, 0,'{$current_time}' ) " .
- " ON DUPLICATE KEY UPDATE remain_count = {$remain_count},start_time='{$start_time}',update_time='{$current_time}' ";
- $pdo2 = conn();
- if (is_object($pdo2)) {
- $result = $pdo2->exec($sql_insert);
- }
- }
- } else {
- $sql_insert = " INSERT INTO outside_run ( org_id, run_code, prod_code, prod_name, line_code, line_name, start_date, start_time, start_area, end_area, start_res, end_res, cus_price, mid_price, remain_count, cancel_flag,update_time) " .
- " VALUES ( {$org_id}, '{$run_code}', '{$prod_code}','{$prod_name}','{$line_code}','{$line_name}','{$start_date}', '{$start_time}', '{$start_area}', '{$end_area}', '{$start_res}', '{$end_res}', {$cus_price}, {$mid_price}, {$remain_count}, 0,'{$current_time}' ) " .
- " ON DUPLICATE KEY UPDATE remain_count = {$remain_count},start_time='{$start_time}',update_time='{$current_time}' ";
- $pdo2 = conn();
- if (is_object($pdo2)) {
- $result = $pdo2->exec($sql_insert);
- }
- }
- }
- }
- }
-
-
-
|