Esempio n. 1
0
 public function fetchMessageBody($messageid, $account)
 {
     /*----- 加载token文件 -----*/
     $tokenfile = WEB_PATH . 'lib/ebaylibrary/keys/keys_' . $account . '.php';
     if (!file_exists($tokenfile)) {
         //授权文件不存在
         self::$errCode = 10050;
         self::$errMsg = '账号授权文件不存在';
         return FALSE;
     }
     include_once '' . $tokenfile;
     /*----- 导出为全局变量 ugly code -----*/
     $GLOBALS['siteID'] = $siteID;
     $GLOBALS['production'] = $production;
     $GLOBALS['compatabilityLevel'] = $compatabilityLevel;
     $GLOBALS['devID'] = $devID;
     $GLOBALS['appID'] = $appID;
     $GLOBALS['certID'] = $certID;
     $GLOBALS['serverUrl'] = $serverUrl;
     $GLOBALS['userToken'] = $userToken;
     /*----- 导出为全局变量 -----*/
     /*----- 加载token文件 -----*/
     $getmsgobj = new GetMemberMessagesAPI($account);
     $responseXml = $getmsgobj->requestMessagesID($messageid);
     //var_dump($responseXml);exit;
     if (stristr($responseXml, 'HTTP 404') || $responseXml == '') {
         self::$errCode = 10051;
         self::$errMsg = '获取失败!';
         return FALSE;
     }
     $responseDoc = new DomDocument();
     $responseDoc->loadXML($responseXml);
     $data = XML_unserialize($responseXml);
     //print_r($data);exit;
     $Content = $data['GetMyMessagesResponse']['Messages']['Message']['Text'];
     if (empty($Content)) {
         self::$errCode = 10051;
         self::$errMsg = '获取失败!';
         return FALSE;
     }
     $date = date('Y-m-d', time());
     $filepath = MSGBODYSAVEPATH . $account . '/' . $date . '/' . $messageid . '.html';
     if (write_a_file(MSGREALPREFIX . $filepath, $Content) === false) {
         self::$errCode = 10052;
         self::$errMsg = 'message文件保存失败!';
         return FALSE;
     }
     return $filepath;
 }
Esempio n. 2
0
 /**
  * TrackWarnExportModel::exportTrackNumberInfo()
  * 导出跟踪号信息
  * @param string $condition 导出条件
  * @param integer $pagesize 每页数量
  * @return string 
  */
 public static function exportTrackNumberInfo($condition, $pagesize = 10000)
 {
     self::initDB();
     set_time_limit(600);
     ignore_user_abort(false);
     $totalnum = 0;
     $data = "";
     $sql = "SELECT count(*) AS totalnum FROM\n\t\t\t\t\t\t" . self::$prefix . self::$table . " AS a\n\t\t\t\t\t\tLEFT JOIN " . self::$prefix . self::$tab_track_channel . " AS b ON a.channelId = b.id\n\t\t\t\t\t\tLEFT JOIN " . self::$prefix . self::$tab_track_carrier . " AS c ON a.carrierId = c.id\n\t\t\t\t\t\tWHERE {$condition}";
     $query = self::$dbConn->query($sql);
     if ($query) {
         $res = self::$dbConn->fetch_array($query);
         $totalnum = intval($res['totalnum']);
     } else {
         self::$errCode = 10000;
         self::$errMsg = "获取数据失败";
         return false;
     }
     $pages = ceil($totalnum / $pagesize);
     $filename = 'track_number_info_' . $_SESSION[C('USER_AUTH_SYS_ID')];
     $statusList = C('TRACK_STATUS_DETAIL');
     $fileurl = WEB_URL . "temp/" . date('Ymd') . "/" . $filename . ".xls";
     $filepath = WEB_PATH . "html/temp/" . date('Ymd') . "/" . $filename . ".xls";
     for ($i = 0; $i < $pages; $i++) {
         $offset = $i * $pagesize;
         $idArr = array();
         $ids = '';
         $sql = "SELECT\n\t\t\t\t\t\ta.id\n\t\t\t\t\t\tFROM\n\t\t\t\t\t\t" . self::$prefix . self::$table . " AS a\n\t\t\t\t\t\tLEFT JOIN " . self::$prefix . self::$tab_track_channel . " AS b ON a.channelId = b.id\n\t\t\t\t\t\tLEFT JOIN " . self::$prefix . self::$tab_track_carrier . " AS c ON a.carrierId = c.id\n\t\t\t\t\t\tWHERE {$condition} LIMIT {$offset},{$pagesize}";
         $query = self::$dbConn->query($sql);
         $res = self::$dbConn->fetch_array_all($query);
         foreach ($res as $v) {
             array_push($idArr, $v['id']);
         }
         if (empty($idArr)) {
             self::$errCode = 10001;
             self::$errMsg = "获取数据失败";
             return false;
         } else {
             $ids = implode(",", $idArr);
         }
         $sql = "SELECT\n\t\t\t\t\t\t\t\t\tc.carrierNameCn,\n\t\t\t\t\t\t\t\t\tb.channelName,\n\t\t\t\t\t\t\t\t\ta.orderSn,\n\t\t\t\t\t\t\t\t\ta.recordId,\n\t\t\t\t\t\t\t\t\ta.carrierId,\n\t\t\t\t\t\t\t\t\ta.channelId,\n\t\t\t\t\t\t\t\t\ta.platAccount,\n\t\t\t\t\t\t\t\t\ta.platForm,\n\t\t\t\t\t\t\t\t\ta.trackNumber,\n\t\t\t\t\t\t\t\t\ta.weight,\n\t\t\t\t\t\t\t\t\ta.cost,\n\t\t\t\t\t\t\t\t\ta.scanTime,\n\t\t\t\t\t\t\t\t\ta.toCountry,\n\t\t\t\t\t\t\t\t\ta.lastEvent,\n\t\t\t\t\t\t\t\t\ta.lastPostion,\n\t\t\t\t\t\t\t\t\ta.lastTime,\n\t\t\t\t\t\t\t\t\ta.status\n\t\t\t\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t\t\t" . self::$prefix . self::$table . " AS a\n\t\t\t\t\t\t\t\t\tLEFT JOIN " . self::$prefix . self::$tab_track_channel . " AS b ON a.channelId = b.id\n\t\t\t\t\t\t\t\t\tLEFT JOIN " . self::$prefix . self::$tab_track_carrier . " AS c ON a.carrierId = c.id\n\t\t\t\t\t\t\t\t\tWHERE a.id IN({$ids})\n\t\t\t\t\t\t\t\t\tORDER BY scanTime DESC";
         $query = self::$dbConn->query($sql);
         $res = self::$dbConn->fetch_array_all($query);
         if ($i == 0) {
             $data = '<?xml version="1.0" encoding="UTF-8"?><Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:html="http://www.w3.org/TR/REC-html40"><Styles><Style ss:ID="sDT"><NumberFormat ss:Format="Short Date"/></Style></Styles><Worksheet ss:Name="Sheet1"><Table><Row><Cell><Data ss:Type="String">运输方式</Data></Cell><Cell><Data ss:Type="String">渠道</Data></Cell><Cell><Data ss:Type="String">订单编号</Data></Cell><Cell><Data ss:Type="String">订单号</Data></Cell><Cell><Data ss:Type="String">跟踪号</Data></Cell><Cell><Data ss:Type="String">重量</Data></Cell><Cell><Data ss:Type="String">价格</Data></Cell><Cell><Data ss:Type="String">发货时间</Data></Cell><Cell><Data ss:Type="String">发往国家</Data></Cell><Cell><Data ss:Type="String">跟踪事件</Data></Cell><Cell><Data ss:Type="String">跟踪位置</Data></Cell><Cell><Data ss:Type="String">跟踪时间</Data></Cell><Cell><Data ss:Type="String">跟踪状态</Data></Cell><Cell><Data ss:Type="String">收寄日期</Data></Cell><Cell><Data ss:Type="String">收寄地点</Data></Cell><Cell><Data ss:Type="String">互封日期</Data></Cell><Cell><Data ss:Type="String">互封地点</Data></Cell><Cell><Data ss:Type="String">直封日期</Data></Cell><Cell><Data ss:Type="String">直封地点</Data></Cell><Cell><Data ss:Type="String">平台帐号</Data></Cell><Cell><Data ss:Type="String">平台名称</Data></Cell></Row>' . "\n";
         }
         foreach ($res as $v) {
             $nodeList = TransOpenApiModel::getTrackNodeList($v['carrierId'], $v['channelId']);
             $detail = TransOpenApiModel::getTrackInfoLocal($v['trackNumber'], $v['carrierId']);
             $j = 0;
             $dates = array();
             $pos = array();
             foreach ($nodeList as $n) {
                 foreach ($detail as $val) {
                     $keys = explode(" ", $n['nodeKey']);
                     foreach ($keys as $key) {
                         if (strpos($val['event'], $key) !== false && !in_array($val['event'], array('未妥投'))) {
                             $dates[$j] = !empty($val['trackTime']) ? strftime("%Y-%m-%dT%H:%M:%S", $val['trackTime']) : '';
                             $pos[$j] = $val['postion'];
                             break;
                         }
                     }
                 }
                 $j++;
             }
             $data .= '<Row><Cell><Data ss:Type="String">' . $v['carrierNameCn'] . '</Data></Cell><Cell><Data ss:Type="String">' . $v['channelName'] . '</Data></Cell><Cell><Data ss:Type="Number">' . $v['orderSn'] . '</Data></Cell><Cell><Data ss:Type="String">' . $v['recordId'] . '</Data></Cell><Cell><Data ss:Type="String">' . $v['trackNumber'] . '</Data></Cell><Cell><Data ss:Type="Number">' . $v['weight'] . '</Data></Cell><Cell><Data ss:Type="Number">' . $v['cost'] . '</Data></Cell><Cell ss:StyleID="sDT"><Data ss:Type="DateTime">' . strftime("%Y-%m-%dT%H:%M:%S", $v['scanTime']) . '</Data></Cell><Cell><Data ss:Type="String">' . $v['toCountry'] . '</Data></Cell><Cell><Data ss:Type="String">' . $v['lastEvent'] . '</Data></Cell><Cell><Data ss:Type="String">' . $v['lastPostion'] . '</Data></Cell><Cell ss:StyleID="sDT"><Data ss:Type="DateTime">' . strftime("%Y-%m-%dT%H:%M:%S", $v['lastTime']) . '</Data></Cell><Cell><Data ss:Type="String">' . $statusList[$v['status']] . '</Data></Cell><Cell ss:StyleID="sDT"><Data ss:Type="DateTime">' . $dates[0] . '</Data></Cell><Cell><Data ss:Type="String">' . $pos[0] . '</Data></Cell><Cell ss:StyleID="sDT"><Data ss:Type="DateTime">' . $dates[1] . '</Data></Cell><Cell><Data ss:Type="String">' . $pos[1] . '</Data></Cell><Cell ss:StyleID="sDT"><Data ss:Type="DateTime">' . $dates[2] . '</Data></Cell><Cell><Data ss:Type="String">' . $pos[2] . '</Data></Cell><Cell><Data ss:Type="String">' . $v['platAccount'] . '</Data></Cell><Cell><Data ss:Type="String">' . $v['platForm'] . '</Data></Cell></Row>' . "\n";
         }
         if ($i == 0) {
             write_w_file($filepath, $data);
         } else {
             write_a_file($filepath, $data);
         }
         $data = "";
         unset($res);
         sleep(3);
     }
     $data = "</Table></Worksheet></Workbook>";
     write_a_file($filepath, $data);
     $zipFile = self::getXlsZip($filepath, $filename);
     if ($zipFile) {
         $fileurl = WEB_URL . $zipFile;
         $filepath = WEB_PATH . "html/" . $zipFile;
     }
     if (file_exists($filepath)) {
         return $fileurl;
     } else {
         return "fail";
     }
 }
Esempio n. 3
0
 /**
  * TrackInquiryAct::act_trackInfoEn()
  * 查询目的地跟踪信息
  * @param string $carrier 运输方式名称
  * @param string $tracknum 跟踪号
  * @param string $tracklan 语言
  * @return json string 
  */
 public function act_trackInfoEn()
 {
     $carrier = isset($_REQUEST['carrier']) ? post_check($_REQUEST['carrier']) : '';
     $tracknum = isset($_REQUEST['tracknum']) ? post_check($_REQUEST['tracknum']) : '';
     $tracklan = isset($_REQUEST['tracklan']) ? abs(intval($_REQUEST['tracklan'])) : 10000;
     $ip = getClientIP();
     $ipNum = sprintf('%u', ip2long($ip));
     if (in_array($carrier, array('美国邮政'))) {
         $tracklan = 10000;
     }
     if (empty($carrier)) {
         self::$errCode = 10000;
         self::$errMsg = "运输方式参数非法!";
         @write_a_file(self::$logFile, date('Y-m-d H:i:s') . "=====" . $ip . "=====" . $carrier . "=====" . $tracknum . "=====" . $tracklan . "=====event:" . self::$errMsg . "\n");
         return false;
     }
     if (empty($tracknum)) {
         self::$errCode = 10001;
         self::$errMsg = "跟踪号参数非法!";
         @write_a_file(self::$logFile, date('Y-m-d H:i:s') . "=====" . $ip . "=====" . $carrier . "=====" . $tracknum . "=====" . $tracklan . "=====event:" . self::$errMsg . "\n");
         return false;
     }
     //访问统计逻辑
     $data = array();
     $times = time();
     $maxcount = C("USER_MAX_COUNT");
     $exptime = C("USER_EXPIRES_TIME");
     $res = TrackInquiryModel::showIpStat($ipNum);
     $stats = isset($res['count']) ? $res['count'] : 0;
     $exptimes = isset($res['expires']) ? $res['expires'] : 0;
     $data['trackInfoEn'] = array();
     if ($stats > $maxcount && $exptimes > $times && !in_array($ip, array('183.233.230.2'), true)) {
         array_push($data['trackInfoEn'], array("postion" => "server", "event" => "{$ip}:Visits over", "trackTime" => date('Y-m-d H:i:s', time()), "stat" => 0));
         @write_a_file(self::$logFile, date('Y-m-d H:i:s') . "=====" . $ip . "=====" . $carrier . "=====" . $tracknum . "=====" . $tracklan . "=====event:Visits over\n");
         return $data;
         exit;
     }
     if (!$stats) {
         $res = TrackInquiryModel::updateStatInfo($ipNum, array("ip" => $ip, "count" => 1, "expires" => $times + $exptime, "ipNum" => $ipNum));
     } else {
         if ($exptimes < $times) {
             $res = TrackInquiryModel::updateStatInfo($ipNum, array("ip" => $ip, "count" => 1, "expires" => $times + $exptime, "ipNum" => $ipNum));
         } else {
             $res = TrackInquiryModel::updateStatInfo($ipNum, array("ip" => $ip, "count" => $stats + 1, "ipNum" => $ipNum));
         }
     }
     //查询跟踪信息并memcache
     $cacheName = md5("track_number_info" . $carrier . "_" . $tracknum . "_" . $tracklan);
     $memc_obj = new Cache(C('CACHEGROUP'));
     $trackInfo = $memc_obj->get_extral($cacheName);
     $trackInfo = @unserialize($trackInfo);
     if (!empty($trackInfo['trackInfo'])) {
         @write_a_file(self::$logFile, date('Y-m-d H:i:s') . "=====" . $ip . "=====" . $carrier . "=====" . $tracknum . "=====" . $tracklan . "=====event:memcache success\n");
         return $trackInfo;
     } else {
         $trackInfo = TrackInquiryModel::trackInfoEn($carrier, $tracknum, $tracklan);
         if (!in_array($trackInfo['trackInfoEn'][0]['event'], array('Time out', 'time out', 'No data', 'System Interface exceptions,Please try again!'))) {
             $isok = $memc_obj->set_extral($cacheName, serialize($trackInfo), 7200);
             if (!$isok) {
                 self::$errCode = 0;
                 self::$errMsg = 'memcache缓存出错!';
                 @write_a_file(self::$logFile, date('Y-m-d H:i:s') . "=====" . $ip . "=====" . $carrier . "=====" . $tracknum . "=====" . $tracklan . "=====event:" . self::$errMsg . "\n");
                 //return false;
             }
         }
         if (in_array($trackInfo['trackInfoEn'][0]['event'], array('Time out', 'time out'))) {
             @write_a_file(self::$logFile, date('Y-m-d H:i:s') . "=====" . $ip . "=====" . $carrier . "=====" . $tracknum . "=====" . $tracklan . "=====event:" . $trackInfo['trackInfo'][0]['event'] . "\n");
         }
         if ($trackInfo['trackInfoEn'][0]['postion'] == 'No data') {
             @write_a_file(self::$logFile, date('Y-m-d H:i:s') . "=====" . $ip . "=====" . $carrier . "=====" . $tracknum . "=====" . $tracklan . "=====event:" . $trackInfo['trackInfo'][0]['event'] . "\n");
         }
         if (empty($trackInfo['trackInfoEn'])) {
             @write_a_file(self::$logFile, date('Y-m-d H:i:s') . "=====" . $ip . "=====" . $carrier . "=====" . $tracknum . "=====" . $tracklan . "=====event:接口获取数据异常\n");
         }
         @write_a_file(self::$logFile, date('Y-m-d H:i:s') . "=====" . $ip . "=====" . $carrier . "=====" . $tracknum . "=====" . $tracklan . "=====event:api interface success\n");
         return $trackInfo;
     }
 }
Esempio n. 4
0
    /**
     * TransOpenApiModel::getTrackInfo()
     * 获取跟踪号追踪信息
     * @param string $tid 跟踪号
     * @param string $type 运输方式(如中国邮政,ems)
     * @return  json string;
     */
    public static function getTrackInfo($tid, $type, $lan = 10000)
    {
        $type = mb_convert_encoding($type, "GBK", "UTF-8");
        // $url 		= "http://202.103.191.212:8888/cgi-bin/GInfo.dll?EmmisTrackGenData&cemskind={$type}&cno={$tid}&lan={$lan}";
        $url = "http://121.40.69.217/cgi-bin/GInfo.dll?EmmisTrackGenData&cemskind={$type}&cno={$tid}&lan={$lan}";
        //$res		= file_get_contents($url);
        $header[] = "Content-type: text/html";
        $newdata = array();
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
        curl_setopt($ch, CURLOPT_TIMEOUT, 120);
        $res = curl_exec($ch);
        if (curl_errno($ch)) {
            $newdata['trackingEventList'] = array();
            $res = array('ReturnValue' => '错误信息:' . curl_error($ch) . ',请联系管理员谢谢!', 'errCode' => curl_errno($ch));
            return json_encode($res);
            exit;
        }
        curl_close($ch);
        if ($lan == 10000) {
            $res = str_replace('",","', '","', $res);
            $res = mb_convert_encoding($res, "GBK", "UTF-8");
        } else {
            //跟踪英文信息
            $newdata['trackingEventList'] = array();
            $data = substr($res, strpos($res, "<EMS_INFO>"));
            if ($data != '-1') {
                $data = mb_convert_encoding($data, "GBK", "UTF-8");
                $data = '<?xml version="1.0" encoding="UTF-8"?>
							<RESPONSE_INFO>
							' . $data . '
							</RESPONSE_INFO>';
                $data = json_encode(simplexml_load_string($data));
                $data = json_decode($data, true);
                $key = 0;
                foreach ($data['TRACK_DATA']['DATETIME'] as $v) {
                    array_push($newdata['trackingEventList'], array('date' => $data['TRACK_DATA']['DATETIME'][$key], 'place' => $data['TRACK_DATA']['PLACE'][$key], 'details' => $data['TRACK_DATA']['INFO'][$key]));
                    $key++;
                }
                $res = json_encode($newdata);
            }
        }
        //增加接口调用日志
        $logFile = WEB_PATH . "log/track_number_info/" . date('Y') . "/" . date('m') . "/" . date('Y-m-d') . ".log";
        $log = date('Y-m-d H:i:s') . "==={$url}==={$tid}==={$type}==={$lan}==={$res}\n";
        if (function_exists('write_a_file')) {
            write_a_file($logFile, $log);
        }
        return $res;
    }
Esempio n. 5
0
 /**
  * WedoApiModel::orderWedoExport()
  * 导出运德物流订单跟踪号信息
  * @param string $condition 导出条件
  * @param integer $pagesize 每页数量
  * @return string 
  */
 public static function orderWedoExport($condition, $pagesize = 10000)
 {
     self::initDB();
     $totalnum = 0;
     $data = "";
     $sql = "SELECT count(*) AS totalnum FROM\t" . self::$prefix . self::$wedo_order . " WHERE {$condition}";
     $query = self::$dbConn->query($sql);
     if ($query) {
         $res = self::$dbConn->fetch_array($query);
         $totalnum = intval($res['totalnum']);
     } else {
         self::$errCode = 10000;
         self::$errMsg = "获取数据失败";
         return "fail";
     }
     if ($totalnum == 0) {
         self::$errCode = 10001;
         self::$errMsg = "选择的时间范围类,没有数据需要导出!";
         return "fail";
     }
     $pages = ceil($totalnum / $pagesize);
     $filename = 'wedo_number_info_' . $_SESSION[C('USER_AUTH_SYS_ID')];
     $statusList = C('TRACK_STATUS_DETAIL');
     $fileurl = WEB_URL . "temp/" . $filename . ".xls";
     $filepath = WEB_PATH . "html/temp/" . $filename . ".xls";
     for ($i = 0; $i < $pages; $i++) {
         $offset = $i * $pagesize;
         $sql = "SELECT *\tFROM " . self::$prefix . self::$wedo_order . " WHERE {$condition} LIMIT {$offset},{$pagesize}";
         $query = self::$dbConn->query($sql);
         $res = self::$dbConn->fetch_array_all($query);
         if ($i == 0) {
             $data = '<?xml version="1.0" encoding="UTF-8"?><Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:html="http://www.w3.org/TR/REC-html40"><Styles><Style ss:ID="sDT"><NumberFormat ss:Format="Short Date"/></Style></Styles><Worksheet ss:Name="Sheet1"><Table><Row><Cell><Data ss:Type="String">订单号/交易号</Data></Cell><Cell><Data ss:Type="String">跟踪号</Data></Cell><Cell><Data ss:Type="String">发货时间</Data></Cell><Cell><Data ss:Type="String">发往国家</Data></Cell><Cell><Data ss:Type="String">店铺帐号</Data></Cell></Row>' . "\n";
         }
         foreach ($res as $v) {
             $data .= '<Row><Cell><Data ss:Type="String">' . $v['orderSn'] . '</Data></Cell><Cell><Data ss:Type="String">' . $v['trackNumber'] . '</Data></Cell><Cell ss:StyleID="sDT"><Data ss:Type="DateTime">' . strftime("%Y-%m-%dT%H:%M:%S", $v['scanTime']) . '</Data></Cell><Cell><Data ss:Type="String">' . $v['toCountry'] . '</Data></Cell><Cell><Data ss:Type="String">' . $v['platAccount'] . '</Data></Cell></Row>' . "\n";
         }
         if ($i == 0) {
             write_w_file($filepath, $data);
         } else {
             write_a_file($filepath, $data);
         }
         $data = "";
     }
     $data = "</Table></Worksheet></Workbook>";
     write_a_file($filepath, $data);
     if (file_exists($filepath)) {
         return $fileurl;
     } else {
         return "fail";
     }
 }
Esempio n. 6
0
 /**
  * TrackShipFeeAct::act_getShipFee()
  * 获取运费信息
  * @param string $addId 发货地址ID
  * @param string $country 国家
  * @param string $realWeight 重量
  * @return array;
  */
 public function act_getShipFee()
 {
     $realWeight = 0;
     $volWeight = 0;
     $noShip = array();
     $noShipId = "";
     $weightFlag = "";
     $addId = isset($_REQUEST["addId"]) ? abs(intval($_REQUEST["addId"])) : 0;
     $country = isset($_REQUEST["country"]) ? post_check(rawurldecode($_REQUEST["country"])) : 0;
     $weight = isset($_REQUEST["weight"]) ? post_check($_REQUEST["weight"]) : 0;
     $longs = isset($_REQUEST["longs"]) ? post_check($_REQUEST["longs"]) : '';
     $widths = isset($_REQUEST["widths"]) ? post_check($_REQUEST["widths"]) : '';
     $heights = isset($_REQUEST["heights"]) ? post_check($_REQUEST["heights"]) : '';
     $unit = isset($_REQUEST["unit"]) ? post_check($_REQUEST["unit"]) : '';
     $unitW = isset($_REQUEST["unitW"]) ? post_check($_REQUEST["unitW"]) : '';
     $apiToken = isset($_REQUEST["apiToken"]) ? post_check($_REQUEST["apiToken"]) : 'e19d2feabc0eb1705f69c6ea2d9d0e1d';
     $is_new = isset($_REQUEST["is_new"]) ? abs(intval($_REQUEST["is_new"])) : 0;
     $ip = getClientIP();
     if (!in_array($addId, array(1), true)) {
         self::$errCode = 10000;
         self::$errMsg = "The delivery address parameter error!";
         @write_a_file(self::$logFile, date('Y-m-d H:i:s') . "====={$ip}=={$addId}=={$country}=={$unit}=={$longs}=={$widths}=={$heights}=={$unitW}=={$weight}=====event:" . self::$errMsg . "\n");
         return false;
     }
     if (empty($country)) {
         self::$errCode = 10001;
         self::$errMsg = "Recipient countries parameter error!";
         @write_a_file(self::$logFile, date('Y-m-d H:i:s') . "====={$ip}=={$addId}=={$country}=={$unit}=={$longs}=={$widths}=={$heights}=={$unitW}=={$weight}=====event:" . self::$errMsg . "\n");
         return false;
     }
     if (!in_array($unit, array('CM', 'IN', 'M'), true)) {
         self::$errCode = 10002;
         self::$errMsg = "A unit of volume parameters error!";
         @write_a_file(self::$logFile, date('Y-m-d H:i:s') . "====={$ip}=={$addId}=={$country}=={$unit}=={$longs}=={$widths}=={$heights}=={$unitW}=={$weight}=====event:" . self::$errMsg . "\n");
         return false;
     }
     if (!in_array($unitW, array('KG', 'LB', 'OZ'), true)) {
         self::$errCode = 10003;
         self::$errMsg = "A unit of weight parameters error!";
         @write_a_file(self::$logFile, date('Y-m-d H:i:s') . "====={$ip}=={$addId}=={$country}=={$unit}=={$longs}=={$widths}=={$heights}=={$unitW}=={$weight}=====event:" . self::$errMsg . "\n");
         return false;
     }
     if (is_numeric($longs) && is_numeric($widths) && is_numeric($heights)) {
         if ($longs <= 0 || $widths <= 0 || $heights <= 0) {
             self::$errCode = 10004;
             self::$errMsg = "Size (L/W/H) parameter error!";
             @write_a_file(self::$logFile, date('Y-m-d H:i:s') . "====={$ip}=={$addId}=={$country}=={$unit}=={$longs}=={$widths}=={$heights}=={$unitW}=={$weight}=====event:" . self::$errMsg . "\n");
             return false;
         } else {
             if ($unit == 'CM') {
                 $volWeight = round($longs * $widths * $heights / 6000, 4);
             }
             if ($unit == 'IN') {
                 $volWeight = round($longs * 2.54 * ($widths * 2.54) * ($heights * 2.54) / 6000, 4);
             }
             if ($unit == 'M') {
                 $volWeight = round($longs * 100 * ($widths * 100) * ($heights * 100) / 6000, 4);
             }
         }
         //加入中国邮政(平邮、挂号)小包体积限制
         if ($unit == 'CM') {
             if ($longs + $widths + $heights > 110) {
                 $noShip[] = 1;
                 $noShip[] = 2;
             }
         }
         if ($unit == 'IN') {
             if (($longs + $widths + $heights) * 2.54 > 110) {
                 $noShip[] = 1;
                 $noShip[] = 2;
             }
         }
         if ($unit == 'M') {
             if (($longs + $widths + $heights) * 100 > 110) {
                 $noShip[] = 1;
                 $noShip[] = 2;
             }
         }
         if (!empty($noShip)) {
             $noShipId = implode(",", $noShip);
         }
     }
     if (is_numeric($weight)) {
         if ($weight <= 0) {
             self::$errCode = 10005;
             self::$errMsg = "The weight parameter error!";
             @write_a_file(self::$logFile, date('Y-m-d H:i:s') . "====={$ip}=={$addId}=={$country}=={$unit}=={$longs}=={$widths}=={$heights}=={$unitW}=={$weight}=====event:" . self::$errMsg . "\n");
             return false;
         } else {
             if ($unitW == 'KG') {
                 $weight = round($weight, 4);
             }
             if ($unitW == 'LB') {
                 $weight = round($weight * 0.4535924, 4);
             }
             if ($unitW == 'OZ') {
                 $weight = round($weight * 0.0283495, 4);
             }
         }
     }
     if ($volWeight > $weight) {
         $realWeight = $volWeight;
         $weightFlag = "volWeight";
     } else {
         $realWeight = $weight;
         $weightFlag = "realWeight";
     }
     if (empty($realWeight)) {
         self::$errCode = 10006;
         self::$errMsg = "Weight is 0, please check!";
         @write_a_file(self::$logFile, date('Y-m-d H:i:s') . "====={$ip}=={$addId}=={$country}=={$unit}=={$longs}=={$widths}=={$heights}=={$unitW}=={$weight}=====event:" . self::$errMsg . "\n");
         return false;
     }
     @write_a_file(self::$logFile, date('Y-m-d H:i:s') . "====={$ip}=={$addId}=={$country}=={$unit}=={$longs}=={$widths}=={$heights}=={$unitW}=={$weight}==体积重:{$volWeight}==实重:{$realWeight}\n");
     $key = md5($addId . $country . $realWeight);
     $cacheName = md5("track_ship_fee_" . $key);
     $memc_obj = new Cache(C('CACHEGROUP'));
     $shipFeeInfo = $memc_obj->get_extral($cacheName);
     if (!empty($shipFeeInfo) && empty($is_new)) {
         @write_a_file(self::$logFile, date('Y-m-d H:i:s') . "====={$ip}=={$addId}=={$country}=={$unit}=={$longs}=={$widths}=={$heights}=={$unitW}=={$weight}==体积重:{$volWeight}==实重:{$realWeight}===event:memcache ok\n");
         return unserialize($shipFeeInfo);
     } else {
         $shipFeeInfo = TrackShipFeeModel::calcOpenShipFee($addId, $country, $realWeight, '', '', $apiToken, $noShipId, $weightFlag);
         self::$errCode = TrackShipFeeModel::$errCode;
         self::$errMsg = TrackShipFeeModel::$errMsg;
         $isok = $memc_obj->set_extral($cacheName, serialize($shipFeeInfo), 7200);
         if (!$isok) {
             self::$errCode = 308;
             self::$errMsg = 'memcache缓存出错!';
             @write_a_file(self::$logFile, date('Y-m-d H:i:s') . "====={$ip}=={$addId}=={$country}=={$unit}=={$longs}=={$widths}=={$heights}=={$unitW}=={$weight}==体积重:{$volWeight}==实重:{$realWeight}===event:" . self::$errMsg . "\n");
             //return false;
         }
         @write_a_file(self::$logFile, date('Y-m-d H:i:s') . "====={$ip}=={$addId}=={$country}=={$unit}=={$longs}=={$widths}=={$heights}=={$unitW}=={$weight}==体积重:{$volWeight}==实重:{$realWeight}===event:api interface ok\n");
         return $shipFeeInfo;
     }
 }
Esempio n. 7
0
 public function GetMemberMessages($start, $end, $account, $type, $idlimit = FALSE)
 {
     $api_messages = new GetMemberMessagesAPI($account);
     $patch = MSGBODYSAVEPATH;
     $pcount = 0;
     while ($pcount++ < 50) {
         //一次最多抓取八页内容
         //             echo $pcount, "\n";continue;
         /*----- 抓取message并解析数据 -----*/
         $responseXml = $api_messages->request($start, $end, $pcount, $account);
         //发送抓取请求
         if (stristr($responseXml, 'HTTP 404') || $responseXml == '') {
             self::$errCode = 5001;
             self::$errMsg = '抓取数据失败 in code line --' . __LINE__;
             return FALSE;
         }
         //             echo $responseXml, "\n\n";
         $responseDoc = new DomDocument();
         $responseDoc->loadXML($responseXml);
         $data = XML_unserialize($responseXml);
         /*----- 抓取message并解析数据 -----*/
         /*----- 根据返回结果记录log -----*/
         $Ack = $data['GetMyMessagesResponse']['Ack'];
         if ($Ack == '' || $Ack != 'Success') {
             echo $responseXml;
             echo "\n" . '-- 获取数据失败 --' . $account . '  ' . $Ack . ' at line ' . __LINE__ . "\n";
             //                 $pcount++;
             continue;
         }
         $mctime = time();
         /* ----- 判断返回结果里面是否包含了message ----- */
         if (!is_array($data['GetMyMessagesResponse']['Messages']) || empty($data['GetMyMessagesResponse']['Messages']['Message'])) {
             $Trans = array();
         } else {
             $Trans = $data['GetMyMessagesResponse']['Messages']['Message'];
             $Sender = $data['GetMyMessagesResponse']['Messages']['Message']['Sender'];
             if ($Sender != '') {
                 $Trans = array();
                 $Trans[0] = $data['GetMyMessagesResponse']['Messages']['Message'];
             }
         }
         /* ----- 判断返回结果里面是否包含了message ----- */
         foreach ($Trans as $Transaction) {
             //循环抓取message内容
             $Read = $Transaction['Read'] ? 1 : 0;
             $HighPriority = $Transaction['HighPriority'];
             $Sender = $Transaction['Sender'];
             $MessageID = $Transaction['MessageID'];
             $RecipientUserID = $Transaction['RecipientUserID'];
             $Subject = str_rep($Transaction['Subject']);
             $MessageType = $Transaction['MessageType'];
             $Replied = $Transaction['Replied'];
             $ItemID = $Transaction['ItemID'];
             $ExternalMessageID = $Transaction['ExternalMessageID'];
             // 之前的id
             $ReceiveDate = $Transaction['ReceiveDate'];
             $ItemTitle = str_rep($Transaction['ItemTitle']);
             $createtime1 = strtotime($ReceiveDate);
             $date = date('Y-m-d', strtotime("{$ReceiveDate} + 8 hours"));
             if ($idlimit !== FALSE) {
                 if ($idlimit >= $MessageID) {
                     echo 'in limit -- ' . $MessageID . "\n";
                     continue;
                 }
             }
             $check_sql = "select id from msg_message where message_id='{$MessageID}' ";
             $res = $this->dbconn->query($check_sql);
             $checkresult = $this->dbconn->fetch_array_all($res);
             //获取结果集
             if (count($checkresult) == 0) {
                 //判断该message之前是否已经被抓取过了
                 if ($Replied == 'false') {
                     $responseXml = $api_messages->requestMessagesID($MessageID);
                     //                         echo $responseXml, "\n";
                     $www = $responseXml;
                     if (stristr($responseXml, 'HTTP 404') || $responseXml == '') {
                         self::$errCode = 5000;
                         self::$errMsg = '获取message信息失败 in code line ---' . __LINE__;
                         continue;
                     }
                     $responseDoc = new DomDocument();
                     $responseDoc->loadXML($responseXml);
                     $data = XML_unserialize($responseXml);
                     //print_r($data);exit;
                     $Content = $data['GetMyMessagesResponse']['Messages']['Message']['Text'];
                     $status = 0;
                     $forms = 0;
                     $classid = '0';
                     $case_sendid = '';
                     $disputeid = '';
                     $official = array('eBay', '*****@*****.**');
                     if (in_array($Sender, $official)) {
                         //系统邮件 不用理会
                         $classid = 415;
                         $forms = 2;
                     } else {
                         $first = substr($Sender, 0, 1);
                         $ss = "select id from msg_messagecategory where rules like '%{$first}%' and ebay_account ='{$account}'";
                         $rear = $this->dbconn->fetch_array_all($this->dbconn->query($ss));
                         if (count($rear) > 0) {
                             $classid = $rear[0]['id'];
                         } else {
                             $classid = -1;
                         }
                     }
                     //                         echo $classid, "\n";
                     if ($HighPriority == 'true') {
                         $forms = 3;
                     }
                     $filepath = $patch . $account . '/' . $date . '/' . $MessageID . '.html';
                     //文件存储路径
                     $sql = "INSERT INTO `msg_message` (`message_id` , `message_type` ,  `recipientid` ";
                     $sql .= ",  `sendid` , `subject` , `itemid` , ";
                     $sql .= "`title` , `createtime` ,  `add_time` , `ebay_account`,`classid`,`createtimestamp`,`status`,`forms`,`Read`,`ExternalMessageID`,`case_sendid`,`disputeid`, `filepath`)VALUES ('{$MessageID}', '{$MessageType}' ,";
                     $sql .= "  '{$RecipientUserID}' ,  '{$Sender}' , '{$Subject}' , '{$ItemID}' , ";
                     $sql .= "  '{$ItemTitle}' , '{$ReceiveDate}' , '{$mctime}', '{$account}','{$classid}','{$createtime1}','{$status}','{$forms}','{$Read}','{$ExternalMessageID}','{$case_sendid}','{$disputeid}', '{$filepath}') ";
                     if ($this->dbconn->query($sql)) {
                         echo "{$MessageID} Add Success" . "\n";
                         if (write_a_file(MSGREALPREFIX . $filepath, $Content) === false) {
                         }
                     } else {
                         echo "{$MessageID} Add Failure" . "\n";
                     }
                 }
             } else {
                 echo $MessageID . ' -- has exists' . "\n";
             }
         }
         if (count($Trans) < 199) {
             break;
         }
     }
 }
Esempio n. 8
0
 /**
  * TransOpenApiAct::openFixCarrierQueryNew()
  * 开放固定运输方式费用新接口
  * @param int $carrierId 运输方式ID
  * @param string $country 国家
  * @param float $weight 重量
  * @param string $postCode 邮政编码(预留)
  * @return array;
  */
 public function openFixCarrierQueryNew($carrierId, $weightFlag = '')
 {
     $country = isset($_REQUEST['country']) ? rawurldecode(trim($_REQUEST['country'])) : '';
     $weight = isset($_REQUEST['weight']) ? abs(floatval($_REQUEST['weight'])) : 0;
     $postCode = isset($_REQUEST['postCode']) ? trim($_REQUEST['postCode']) : '';
     $transitId = isset($_REQUEST['transitId']) ? intval($_REQUEST['transitId']) : 0;
     if (empty($carrierId)) {
         self::$errCode = 10000;
         self::$errMsg = '运输方式ID参数有误!';
         return false;
     }
     if (empty($country)) {
         self::$errCode = 10001;
         self::$errMsg = '国家参数有误!';
         return false;
     }
     if (empty($weight)) {
         self::$errCode = 10002;
         self::$errMsg = '重量参数有误!';
         return false;
     }
     $shipfee = 0;
     $data = array();
     $data['postCode'] = $postCode;
     //获取邮编如果有
     $data['transitId'] = $transitId;
     //获取转运中心ID如果有
     if (!in_array($carrierId, array(1, 2, 3, 4, 5, 6, 8, 9, 10, 62, 79, 80, 81, 83, 84, 85, 86, 87, 88, 89, 91, 92, 93, 95, 96, 97, 98))) {
         self::$errCode = 10001;
         self::$errMsg = '不支持的运输方式ID';
         return;
     }
     //中国邮政(平邮、挂号)体积没有超过110时,但体积重超过2KG,按实重1KG算
     // if(in_array($carrierId,array(1,2)) && $weight>2 && $weightFlag == 'volWeight') {
     // $weight			= 1;
     // }
     $shipfeeobj = new ShipfeeQueryModel();
     //小语种国家转标准国家
     $stdcountry = $shipfeeobj->translateMinorityLangToStd($country);
     if (empty($stdcountry)) {
         $stdcountry = $country;
     } else {
         $stdcountry = $stdcountry['countryName'];
     }
     //标准国家转运输方式国家
     $shcountryname = $shipfeeobj->translateStdCountryNameToShipCountryName($stdcountry, $carrierId);
     //某个运输方式下所有渠道信息
     $channel = $shipfeeobj->getChannelInfo($carrierId);
     $minship = 0;
     $res = array();
     //返回最优的(运输方式ID、渠道ID、折后价、折扣、原价)
     foreach ($channel as $v) {
         $shipfee = $shipfeeobj->calculateShipfee($v['channelAlias'], $weight, $shcountryname, $data);
         if ($shipfee['fee'] < $minship && !empty($shipfee['fee']) || empty($minship)) {
             $minship = empty($shipfee['fee']) ? 0 : $shipfee['fee'];
             $res['discount'] = empty($shipfee['discount']) ? 0 : $shipfee['discount'];
             $res['fee'] = $minship;
             $res['channelId'] = $v['id'];
             $res['totalFee'] = empty($shipfee['totalfee']) ? 0 : $shipfee['totalfee'];
             $res['level'] = empty($shipfee['level']) ? '' : $shipfee['level'];
             $res['exRate'] = empty($shipfee['exRate']) ? '' : $shipfee['exRate'];
             $res['country'] = $shcountryname;
         }
     }
     $rtn = array('fee' => $res['fee'], 'channelId' => $res['channelId'], 'discount' => $res['discount'], 'carrierId' => $carrierId, 'totalFee' => $res['totalFee'], 'country' => $res['country'], 'level' => $res['level'], 'exRate' => $res['exRate']);
     //增加接口调用日志
     $logFile = WEB_PATH . "log/fixShipFee/" . date('Y') . "/" . date('m') . "/" . date('Y-m-d') . ".log";
     $log = date('Y-m-d H:i:s') . "==={$carrierId}==={$country}==={$weight}==={$postCode}==={$transitId}===" . json_encode($rtn) . "\n";
     if (function_exists('write_a_file')) {
         @write_a_file($logFile, $log);
     }
     return $rtn;
 }
Esempio n. 9
0
    $xml_data .= "<collect><name><![CDATA[{$c_name}]]></name><postcode><![CDATA[{$c_postcode}]]></postcode><phone><![CDATA[{$c_phone}]]></phone><mobile><![CDATA[{$c_mobile}]]></mobile><country>{$c_country}</country><province><![CDATA[{$c_province}]]></province><city><![CDATA[{$c_city}]]></city><county><![CDATA[{$c_county}]]></county><company><![CDATA[{$c_company}]]></company><street><![CDATA[{$c_street}]]></street><email><![CDATA[{$c_email}]]></email></collect>";
    $xml_data .= "<receiver><name><![CDATA[{$r_name}]]></name><postcode><![CDATA[{$r_postcode}]]></postcode><phone><![CDATA[{$r_phone}]]></phone><mobile><![CDATA[{$r_mobile}]]></mobile><country><![CDATA[{$r_country}]]></country><province><![CDATA[{$r_province}]]></province><city><![CDATA[{$r_city}]]></city><street><![CDATA[{$r_street}]]></street></receiver>";
    $xml_data .= "<items>{$items}</items>";
    $xml_data .= "</order></orders>";
    $logs .= date('Y-m-d H:i:s', time()) . "===订单编号:{$orderid},发送的内容为:\n" . $xml_data . "\n";
    // exit;
    $app_ver = "international_eub_us_1.1";
    $app_key = "amazonacount_89d53589c3333ec2a0d39be87e2840d2";
    $url = "http://www.ems.com.cn/partner/api/public/p/order/";
    $rtn = get_eub_trackNumber($url, $xml_data) . "\n";
    $logs .= $rtn;
    $logs .= date('Y-m-d H:i:s', time()) . "===订单号{$orderid}申请跟踪号结束===\n\n";
    echo $logs;
}
$filename = SCRIPT_PATH . 'crontab/eub_tracknum/log/' . date('Y-m-d', time()) . '_tracknumber.txt';
write_a_file($filename, $logs);
exit;
//检查是否为组合料号
function check_combine($sku)
{
    global $dbConn;
    $sql = "SELECT sku,count FROM pc_sku_combine_relation WHERE combineSku = '{$sku}'";
    $query = $dbConn->query($sql);
    $res = $dbConn->fetch_array($query);
    if ($res) {
        return $res;
    } else {
        return false;
    }
}
//获取料号的信息
Esempio n. 10
0
function write_body_html($nn, $ebay_account)
{
    global $dbcon;
    $array_account = array('wellchange', 'elerose88', 'zealdora', 'choiceroad', 'cafase88', 'easytrade2099', 'easyshopping678', 'befashion', '360beauty', 'charmday88', 'easebon', 'estore2099', 'fiveseason88', 'voguebase55', 'dresslink', 'happydeal88', 'work4best', 'eshop2098', 'futurestar99');
    if (in_array($ebay_account, $array_account)) {
        if ($nn == '09') {
            $total = 31;
        } else {
            if ($nn == '10') {
                $total = 32;
            } else {
                $total = 10;
            }
        }
        for ($mm = 1; $mm < $total; $mm++) {
            if ($mm <= 9) {
                $mm = '0' . $mm;
            }
            $start_time = '2012-' . $nn . '-' . $mm . 'T00:00:00.000Z';
            $end_time = '2012-' . $nn . '-' . $mm . 'T23:59:59.000Z';
            $content = "select message_id,body,createtime from ebay_message where ebay_account = '{$ebay_account}' and createtime between '{$start_time}' and '{$end_time}'";
            $content = $dbcon->execute($content);
            $content = $dbcon->getResultArray($content);
            for ($kk = 0; $kk < count($content); $kk++) {
                $mid = $content[$kk]['message_id'];
                $body = $content[$kk]['body'];
                $date_time = $content[$kk]['createtime'];
                $date = date('Y-m-d', strtotime("{$date_time} + 8 hours"));
                $dir2 = '/home/html_include/ebay_message_body/' . $ebay_account . '/' . $date . '/' . $mid . '.html';
                write_a_file($dir2, $body);
            }
        }
    } else {
        if ($nn == '11') {
            for ($mm = 1; $mm < 10; $mm++) {
                if ($mm <= 9) {
                    $mm = '0' . $mm;
                }
                $start_time = '2012-' . $nn . '-' . $mm . 'T00:00:00.000Z';
                $end_time = '2012-' . $nn . '-' . $mm . 'T23:59:59.000Z';
                $content = "select message_id,body,createtime from ebay_message where ebay_account = '{$ebay_account}' and createtime between '{$start_time}' and '{$end_time}'";
                $content = $dbcon->execute($content);
                $content = $dbcon->getResultArray($content);
                for ($kk = 0; $kk < count($content); $kk++) {
                    $mid = $content[$kk]['message_id'];
                    $body = $content[$kk]['body'];
                    $date_time = $content[$kk]['createtime'];
                    $date = date('Y-m-d', strtotime("{$date_time} + 8 hours"));
                    $dir2 = '/home/html_include/ebay_message_body/' . $ebay_account . '/' . $date . '/' . $mid . '.html';
                    write_a_file($dir2, $body);
                }
            }
        }
    }
}
Esempio n. 11
0
    $platAccount = $v['platAccount'];
    if (!empty($toEmailSend)) {
        continue;
    }
    //格式化邮件内容
    $title = str_replace("<wedo:recordId>", $recordId, $email_title);
    $content = str_replace(array('<wedo:recordId>', '<wedo:userId>', '<wedo:markTime>', '<wedo:trackNum>', '<wedo:trackUrl>', '<wedo:userEmail>', '<wedo:userName>', '<wedo:sendTime>'), array($recordId, $toUserId, $markTime, $trackNum, $trackUrl, $userEmail, $userName, $sendTime), $email_body);
    $log .= date('Y-m-d H:i:s') . "==={$recordId}==={$toUserId}==={$toUserEmail}===";
    echo date('Y-m-d H:i:s') . "==={$recordId}==={$toUserId}==={$toUserEmail}===\n";
    //发邮件
    $emailData = array('smtpHost' => $smtpHost, 'smtpPort' => $smtpPort, 'smtpUser' => $smtpUser, 'smtpPwd' => $smtpPwd, 'title' => $title, 'content' => $content, 'toUserEmail' => $toUserEmail, 'toUserId' => $toUserId, 'userEmail' => $userEmail, 'userName' => $userName, 'trackNumber' => $trackNum, 'retryCount' => $retryCount);
    $result = TrackEmailStatModel::sendTrackEmail($emailData);
    $log .= "SES状态数据:" . json_encode($result) . "\n";
    print_r($result);
    $email_flag = $result['sendFlag'];
    $MessageId = $result['MessageId'];
    $RequestId = $result['RequestId'];
    //保存邮件发送记录
    $emailStat = array('trackNumber' => $trackNum, 'content' => $content, 'platAccount' => $platAccount, 'MessageId' => $MessageId, 'RequestId' => $RequestId, 'is_success' => $email_flag, 'addTime' => time());
    $stat_flag = TrackEmailStatModel::saveTrackEmail($emailStat);
    $log .= date('Y-m-d H:i:s') . "==={$i}/{$totals}==={$trackNum}===邮件发送状态:{$email_flag}===邮件记录状态:{$stat_flag}\n";
    echo date('Y-m-d H:i:s') . "===={$i}/{$totals}==={$trackNum}===邮件发送状态:{$email_flag}===邮件记录状态:{$stat_flag}\n";
    sleep($sleepTime);
    $i++;
}
$log .= date('Y-m-d H:i:s') . "==={$totals}封邮件已推送完毕!\n\n";
echo "\n\n" . date('Y-m-d H:i:s') . "==={$totals}封邮件已推送完毕!\n\n";
if (function_exists('write_a_file')) {
    write_a_file($logFile, $log);
}
exit;