|
- <?php
- /*
- Author:XM
- Compeny:Spiders Travel
- */
- date_default_timezone_set('PRC');
- //检查订单出行提醒
- require_once __DIR__.'/../Common/Mysql.php';
- $can_sell_prod_list = "152690,152703, 152716, 152727,152251,152248,152745,152738,153146,153144,153122,153123";
- $pdo=conn1();
- $today = date("Y-m-d");
- $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 ";
- $result=$pdo->query($sql);
- if( $result == false ) {
- echo "查询失败!!14";exit();
- }
- $rowset=$result->fetchAll(PDO::FETCH_ASSOC);
- $result->closeCursor();
- $run_array = array();
- $line_id_array = array();
- $run_id_array = array();
- foreach( $rowset as $row_info ) {
- if( !in_array( $row_info["PROD_ID"], $line_id_array ) ) {
- $line_id_array[] = $row_info["PROD_ID"];
- }
- $run_id_array[] = $row_info["RUN_ID"];
- $run_array[$row_info["RUN_ID"]] = $row_info;
- }
-
- $sql = " SELECT * FROM opera_line WHERE LINE_ID IN(".implode(",",$line_id_array).") ";
- $result=$pdo->query($sql);
- if( $result == false ) {
- echo "查询失败!!32";exit();
- }
- $rowset=$result->fetchAll(PDO::FETCH_ASSOC);
- $result->closeCursor();
- $line_array = array();
- foreach( $rowset as $row_info ) {
- $line_array[$row_info["LINE_ID"]] = $row_info;
- }
-
- $sql = " SELECT * FROM run_bus WHERE RUN_ID IN(".implode( ",", $run_id_array).")";
- $result=$pdo->query($sql);
- if( $result == false ) {
- echo "查询失败!!44";exit();
- }
- $rowset=$result->fetchAll(PDO::FETCH_ASSOC);
- $result->closeCursor();
- foreach( $rowset as $row_info ) {
- $run_info = $run_array[$row_info["RUN_ID"]];
- if( !isset($run_info["can_buy"]) ) {
- $run_info["can_buy"] = 0;
- }
- $run_info["can_buy"] += ($row_info["SEAT_COUNT"]-$row_info["SALED_COUNT"]);
- $run_array[$row_info["RUN_ID"]] = $run_info;
- }
-
- $send_flag = 0;
- $send_run_array = array();
- foreach( $run_array as $run_info ) {
- if( $run_info["can_buy"] < 20 ) {
- $send_flag = 1;
- $send_run_array[] = $line_array[$run_info["PROD_ID"]]["LINE_NAME"]."(".$run_info["RUN_DATE"]." ".$run_info["RUN_TIME"].")剩余数:{$run_info["can_buy"]}";
- }
- }
- if( $send_flag == 1 ) {
- sendTelMessage("13816608252,13818775298,15001928066", "", "库存警报,以下线路库存小于20:".implode("/",$send_run_array),0);
- }
-
- exit;
|