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.
 
 
 
 

70 lines
2.2 KiB

  1. <?php
  2. /*
  3. Author:XM
  4. Compeny:Spiders Travel
  5. */
  6. date_default_timezone_set('PRC');
  7. //检查订单出行提醒
  8. require_once __DIR__.'/../Common/Mysql.php';
  9. $can_sell_prod_list = "152690,152703, 152716, 152727,152251,152248,152745,152738,153146,153144,153122,153123";
  10. $pdo=conn1();
  11. $today = date("Y-m-d");
  12. $sql = " SELECT * FROM run_main WHERE PROD_ID IN({$can_sell_prod_list}) AND RUN_DATE > '{$today}' AND RUN_STATUS = 138 ORDER BY RUN_DATE ";
  13. $result=$pdo->query($sql);
  14. if( $result == false ) {
  15. echo "查询失败!!14";exit();
  16. }
  17. $rowset=$result->fetchAll(PDO::FETCH_ASSOC);
  18. $result->closeCursor();
  19. $run_array = array();
  20. $line_id_array = array();
  21. $run_id_array = array();
  22. foreach( $rowset as $row_info ) {
  23. if( !in_array( $row_info["PROD_ID"], $line_id_array ) ) {
  24. $line_id_array[] = $row_info["PROD_ID"];
  25. }
  26. $run_id_array[] = $row_info["RUN_ID"];
  27. $run_array[$row_info["RUN_ID"]] = $row_info;
  28. }
  29. $sql = " SELECT * FROM opera_line WHERE LINE_ID IN(".implode(",",$line_id_array).") ";
  30. $result=$pdo->query($sql);
  31. if( $result == false ) {
  32. echo "查询失败!!32";exit();
  33. }
  34. $rowset=$result->fetchAll(PDO::FETCH_ASSOC);
  35. $result->closeCursor();
  36. $line_array = array();
  37. foreach( $rowset as $row_info ) {
  38. $line_array[$row_info["LINE_ID"]] = $row_info;
  39. }
  40. $sql = " SELECT * FROM run_bus WHERE RUN_ID IN(".implode( ",", $run_id_array).")";
  41. $result=$pdo->query($sql);
  42. if( $result == false ) {
  43. echo "查询失败!!44";exit();
  44. }
  45. $rowset=$result->fetchAll(PDO::FETCH_ASSOC);
  46. $result->closeCursor();
  47. foreach( $rowset as $row_info ) {
  48. $run_info = $run_array[$row_info["RUN_ID"]];
  49. if( !isset($run_info["can_buy"]) ) {
  50. $run_info["can_buy"] = 0;
  51. }
  52. $run_info["can_buy"] += ($row_info["SEAT_COUNT"]-$row_info["SALED_COUNT"]);
  53. $run_array[$row_info["RUN_ID"]] = $run_info;
  54. }
  55. $send_flag = 0;
  56. $send_run_array = array();
  57. foreach( $run_array as $run_info ) {
  58. if( $run_info["can_buy"] < 20 ) {
  59. $send_flag = 1;
  60. $send_run_array[] = $line_array[$run_info["PROD_ID"]]["LINE_NAME"]."(".$run_info["RUN_DATE"]." ".$run_info["RUN_TIME"].")剩余数:{$run_info["can_buy"]}";
  61. }
  62. }
  63. if( $send_flag == 1 ) {
  64. sendTelMessage("13816608252,13818775298,15001928066", "", "库存警报,以下线路库存小于20:".implode("/",$send_run_array),0);
  65. }
  66. exit;