You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
pdd-order-api/shell/move_process_goods_add.php

56 lines
1.4 KiB
PHP

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#!/alidata/server/php/bin/php
<?php
@ini_set('display_errors', '1');
error_reporting(E_ALL & ~E_NOTICE & ~E_WARNING);
$rootDir = dirname(dirname(__FILE__));
include $rootDir . '/zc-framework/zc.php';
Zc::import('zc.vendors.YwCurl');
$ywCurl = new YwCurl(array (
'useCookie' => false,
'timeOut' => 7200
));
function echoInfo($content) {
$content = date('Y-m-d H:i:s') . " $content\r\n";
echo $content;
}
$timerCode = 'timer/move_goods_add/process_goods_add';
$host = !empty($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'pdd.szchengji-inc.com';
$url = sprintf('http://%s/%s', $host, $timerCode);
echoInfo("start {$timerCode}, and the init url[{$url}]");
// curl获取远程数据
$ret = $ywCurl->get($url);
while (!empty($ret)) {
// 解析返回结果并构造下个shell 脚本
$data = json_decode($ret, true);
$action = $data['action'];
$nextUrl = $data['nextUrl'];
echoInfo("action is [{$action}], next page {$timerCode}, the url [{$nextUrl}]");
switch ($action) {
case 'wait':
usleep(mt_rand(2000000, 4000000));
$ret = $ywCurl->get($nextUrl);
break;
case 'next':
usleep(500000);
$ret = $ywCurl->get($nextUrl);
break;
case 'end':
echoInfo('action is end, set ret null, bye!');
$ret = null;
break;
default:
echoInfo('action is unknow, maybe something error, set ret null, bye!');
$ret = null;
break;
}
}
echoInfo("end {$timerCode}, bye!!");