$loop = true; $page = 1; $nowtime = time(); $account = trim($argv[1]); $minute = intval($argv[2]); include_once dirname(__DIR__) . "/common.php"; $accounts = M('Account')->getAccountNameByPlatformId(1); if (!in_array($account, $accounts)) { exit("{$argv[1]} is wrong!\n"); } if ($minute == 0) { exit("{$argv[2]} is minute, Must be greater than 0!\n"); } ################################## start 这里可以扩展时间分页 ################################## $ebay_start = date('Y-m-d\\TH:i:s', get_ebay_timestamp($nowtime - 60 * $minute)); $ebay_end = date('Y-m-d\\TH:i:s', get_ebay_timestamp($nowtime)); echo "\n<<<<=====[" . date('Y-m-d H:i:s', $nowtime) . "]系统【开始】同步账号【 {$account} 】订单 ====>>>>\n"; echo "\n\t-------同步订单范围From: {$ebay_start} To {$ebay_end} -------\n"; $ebaybutt = A('EbayButt'); $ebaybutt->setToken($account); $spiderlists = $ebaybutt->spiderOrderId($ebay_start, $ebay_end); //实例化队列 $rabbitMQ = E('RabbitMQ'); $rabbitMQ->connection('fetchorder'); $exchange = "ORDER_spiderOrderId_{$account}"; foreach ($spiderlists as $spiderlist) { if (M('Order')->checkEbayOrderidExists($spiderlist['ebay_orderid'])) { echo "\n\t-------订单抓取号【{$spiderlist['ebay_orderid']}】已经存在 -------\n"; continue; } echo "\n\t-------订单抓取号【{$spiderlist['ebay_orderid']}】抓取成功,并推送队列 -------\n";
//脚本参数检验 if ($argc < 4) { exit("Usage: /usr/bin/php\t{$argv['0']} eBayAccount \n"); } $nowtime = time(); $account = trim($argv[1]); $site = trim($argv[2]); $minute = intval($argv[3]); include_once dirname(__DIR__) . "/common.php"; error_reporting(E_ALL); $accounts = M('Account')->getAccountNameByPlatformId(11); if (!in_array($account, $accounts)) { exit("{$argv[1]} is wrong!\n"); } $starttime = date(DATE_ATOM, get_ebay_timestamp($nowtime - 60 * $minute)); $endtime = date(DATE_ATOM, get_ebay_timestamp($nowtime)); echo "\n<<<<=====[" . date('Y-m-d H:i:s', $nowtime) . "]系统【开始】同步账号【 {$account} 】订单 ====>>>>\n"; echo "\n\t-------同步订单范围From: {$starttime} To {$endtime} -------\n"; $amazonbutt = A('AmazonButt'); $amazonbutt->setToken($account, $site); $spiderlists = $amazonbutt->spiderOrderLists($starttime, $endtime); var_dump($spiderlists); if (empty($spiderlists)) { die('not found any order.'); } //插入订单 A('OrderAdd')->act_insertOrder($spiderlists); var_dump(A('OrderAdd')->act_getErrorMsg(), M('OrderAdd')->getAllRunSql()); echo "\n\t------- [耗时:" . ceil((time() - $nowtime) / 60) . "分钟] -------\n"; echo "\n<<<<=====[" . date('Y-m-d H:i:s') . "]系统【结束】同步账号【 {$account} 】订单=====>>>>\n"; exit;
$orderid_lists = sql_str2array($orderid_content); if (!empty($orderid_lists)) { foreach ($orderid_lists as $orderid_sql) { if (!$dbConn->execute($orderid_sql)) { $relost_order_ids .= $orderid_sql . "\n"; } else { $push_order_ids .= $orderid_sql . "\n"; } } if (!empty($relost_order_ids)) { write_lost_sql($lost_orderid_path, $relost_order_ids); } if (!empty($push_order_ids)) { write_lost_sql(str_replace('lost_sql.txt', 'push_success_sql.txt', $lost_orderid_path), $push_order_ids); } } $account = $__ebayaccount; $ebay_start = get_ebay_timestamp($cc - 60 * $__minute_range); //specific minutes agao $ebay_end = get_ebay_timestamp($cc); $ebay_start = date('Y-m-d\\TH:i:s', $ebay_start); $ebay_end = date('Y-m-d\\TH:i:s', $ebay_end); //程序计时器 $time_start = $cc; echo "\n=====[" . date('Y-m-d H:i:s', $time_start) . "]系统【开始】同步账号【 {$account} 】订单 ====>\n"; echo "同步订单范围From: {$ebay_start} To {$ebay_end} \n"; $api_goi->GetSellerOrdersID($ebay_start, $ebay_end, $account); $time_end = time(); echo "\n=====[耗时:" . ceil(($time_end - $time_start) / 60) . "分钟]====\n"; echo "\n<====[" . date('Y-m-d H:i:s', $time_end) . "]系统【结束】同步账号【 {$account} 】订单\n"; exit;