Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 

116 righe
5.0 KiB

  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Redstop
  5. * Date: 2016/12/17
  6. * Time: 11:57
  7. */
  8. header("Content-type:text/html;charset=utf-8");
  9. require_once __DIR__.'/../Common/Mysql.php';
  10. require_once __DIR__.'/../Common/zizai_orderAPI.php';
  11. $current_time = date("Y-m-d H:i:s");
  12. $getOrderInfo = new orderService();
  13. $result = array();
  14. //$can_sell_array = array("shz101", "zsz101");
  15. $can_sell_array = array('cxpt001','cxpt002');
  16. $end_res_array = array(
  17. 'cxpt001' => "朱家尖慈航广场",
  18. 'cxpt002' => "黄浦集散站"
  19. );
  20. //获取所有可销售线路$ccode
  21. $circuitry_list = get_memcache('ZIZAI_TICKETS_CODE');
  22. foreach ($circuitry_list as $circuitry) {
  23. if( !in_array($circuitry['ccode'],$can_sell_array) ) {continue;}
  24. $godate = date("Y-m-d");
  25. $end_date = date("Y-m-d", strtotime("+14 days"));
  26. while ( $godate <= $end_date ) {
  27. $circuitry['godate'] = $godate;
  28. //获取班次的信息
  29. $runlist = $getOrderInfo->gorun(zizaiArgs::$USER, $circuitry['ccode'], $godate);
  30. if( false != $runlist && $runlist["code"] == 0 ) {
  31. //根据班次和时间获取所有的票种信息
  32. if (!isset($runlist['go_run_list']['run']['runid'])) {
  33. foreach ($runlist['go_run_list']['run'] as $key => $runInfo) {
  34. $ticketInfo = $getOrderInfo->ticket(zizaiArgs::$USER, $circuitry['ccode'], $runInfo['runid']);
  35. if( isset($ticketInfo['ticket_list']['ticket']["ticketid"]) ) {
  36. $runInfo['ticket_info'][] = $ticketInfo['ticket_list']['ticket'];
  37. } else {
  38. $runInfo['ticket_info'] = $ticketInfo['ticket_list']['ticket'];
  39. }
  40. $runlist['go_run_list']['run'][$key] = $runInfo;
  41. }
  42. } else {
  43. $runInfo = $runlist['go_run_list']['run'];
  44. $ticketInfo = $getOrderInfo->ticket(zizaiArgs::$USER, $circuitry['ccode'], $runInfo['runid']);
  45. if( isset($ticketInfo['ticket_list']['ticket']["ticketid"]) ) {
  46. $runInfo['ticket_info'][] = $ticketInfo['ticket_list']['ticket'];
  47. } else {
  48. $runInfo['ticket_info'] = $ticketInfo['ticket_list']['ticket'];
  49. }
  50. $runlist['go_run_list']['run'] = $runInfo;
  51. }
  52. $circuitry['runlist'] = $runlist['go_run_list']['run'];
  53. $result[] = $circuitry;
  54. }
  55. $godate = date("Y-m-d", strtotime( $godate." +1 days" ));
  56. }
  57. }
  58. foreach ($result as $lineInfo) {
  59. $org_id = 3;
  60. $line_code = $lineInfo['ccode'];
  61. $line_name = $lineInfo['cname'];
  62. $start_date = $lineInfo['godate'];
  63. if( $line_code == "cxpt001" ) {
  64. $area_arr = array("上海","舟山");
  65. } else{
  66. $area_arr = array("舟山","上海");
  67. }
  68. $start_area = $area_arr[0];
  69. $end_area = $area_arr[1];
  70. $end_res = $area_arr[1];
  71. $end_res = isset($end_res_array[$line_code]) ? $end_res_array[$line_code] : $area_arr[1];
  72. if( isset($lineInfo['runlist']['runid']) ) {
  73. $runInfo = $lineInfo['runlist'];
  74. insert_outside_run( $runInfo, $org_id, $line_code, $line_name, $start_date, $start_area, $end_area, $end_res, $current_time);
  75. } else {
  76. foreach ($lineInfo['runlist'] as $runInfo) {
  77. insert_outside_run( $runInfo, $org_id, $line_code, $line_name, $start_date, $start_area, $end_area, $end_res, $current_time);
  78. }
  79. }
  80. }
  81. function insert_outside_run( $runInfo, $org_id, $line_code, $line_name, $start_date, $start_area, $end_area, $end_res, $current_time) {
  82. $run_code = $runInfo['runid'];
  83. $start_time = $runInfo['runtime'];
  84. $start_res = $runInfo['runarea'];
  85. if( $start_res == "十六铺旅游集散中心" ) {
  86. return;
  87. }
  88. foreach ($runInfo['ticket_info'] as $ticketInfo) {
  89. if (isset($ticketInfo['ticketname'])) {
  90. $prod_code = $ticketInfo['ticketid'];
  91. $cus_price = $ticketInfo['ticketprice'];
  92. $mid_price = isset($ticketInfo['agentprice']) ? $ticketInfo['agentprice'] : $ticketInfo['ticketprice']*0.9;
  93. $remain_count = $ticketInfo['ticketcount'];
  94. $prod_name = $ticketInfo['ticketname'];
  95. if ($cus_price <= 0 || mb_strlen($prod_name) < 5) {
  96. continue;
  97. }
  98. $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) " .
  99. " 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}' ) " .
  100. " ON DUPLICATE KEY UPDATE remain_count = $remain_count,start_time='{$start_time}',update_time='{$current_time}' ";
  101. $pdo2 = conn();
  102. if (is_object($pdo2)) {
  103. $result = $pdo2->exec($sql_insert);
  104. }
  105. }
  106. }
  107. }