You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

49 lines
2.5 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_api.inc';
  11. $pdo = conn1();
  12. $sql = " SELECT * FROM outside_ticket WHERE prod_code IN('SHDSN','SHDSN2') AND cancel_flag = 0 ORDER BY ticket_date DESC LIMIT 1 ";
  13. $result = $pdo->query($sql);
  14. $rowset = $result->fetchAll();
  15. $date = $rowset[0]["ticket_date"];
  16. $update_time = date("Y-m-d H:i:s");
  17. $end_date = date("Y-m-d", strtotime($date."+1 days"));
  18. while( $date <= $end_date ) {
  19. $godate = $date;
  20. $gotime = "";
  21. $disney1 = get_ticket_array(API_USER, API_PASSWORD, DISNEY_CODE1, $godate, $gotime);
  22. $disney2 = get_ticket_array(API_USER, API_PASSWORD, DISNEY_CODE2, $godate, $gotime);
  23. $pdo_insert = conn();
  24. if( $disney1 != false ) {
  25. foreach ($disney1 as $disney_info) {
  26. $prod_name = "迪士尼一日门票";
  27. $prod_code = DISNEY_CODE1;
  28. $insert_sql = " INSERT INTO outside_ticket (supplier_id,prod_name,prod_code, ticket_code, ticket_date, ticket_time, ticket_name, ticket_comment, ticket_num, ticket_price, agent_price, cancel_flag, update_time) " .
  29. " VALUES (3, '{$prod_name}', '{$prod_code}', '{$disney_info["ticketid"]}', '{$godate}', '', '{$disney_info["ticketname"]}', '', {$disney_info["ticketcount"]}, {$disney_info["ticketprice"]}, {$disney_info["agentprice"]}, 0, '{$update_time}' ) ON DUPLICATE KEY UPDATE ticket_num={$disney_info["ticketcount"]},update_time='{$update_time}';";
  30. $pdo_insert->exec($insert_sql);
  31. }
  32. }
  33. if( $disney1 != false ) {
  34. foreach ($disney2 as $disney_info) {
  35. $prod_name = "迪士尼两日门票";
  36. $prod_code = DISNEY_CODE2;
  37. $insert_sql = " INSERT INTO outside_ticket (supplier_id,prod_name,prod_code, ticket_code, ticket_date, ticket_time, ticket_name, ticket_comment, ticket_num, ticket_price, agent_price, cancel_flag, update_time) " .
  38. " VALUES (3, '{$prod_name}', '{$prod_code}', '{$disney_info["ticketid"]}', '{$godate}', '', '{$disney_info["ticketname"]}', '', {$disney_info["ticketcount"]}, {$disney_info["ticketprice"]}, {$disney_info["agentprice"]}, 0, '{$update_time}' ) ON DUPLICATE KEY UPDATE ticket_num={$disney_info["ticketcount"]},update_time='{$update_time}';";
  39. $pdo_insert->exec($insert_sql);
  40. }
  41. }
  42. $date = date("Y-m-d", strtotime($date." +1 days"));
  43. }
  44. exit();