Commit f78d44bf authored by 万继龙's avatar 万继龙

Merge branch 'develop' into 'test'

Develop

See merge request bp/pay!18
parents 39f5ace8 b00132af
......@@ -2,7 +2,8 @@
namespace Helpers;
use Api\PhpUtils\Log\FileLog;
use Api\PhpUtils\Http\Request;
use Helpers\Tracer;
use Api\PhpUtils\Http\HttpUtil;
use App\Exception\BaseException;
/**
......@@ -20,14 +21,14 @@ class Sdk {
*/
public static function call($url, $params, $headers = []) {
/*
/**/
$header = [
'X-REQUEST-ID'=>Logger::getTraceId(),
'X-REQUEST-ID'=>Tracer::getTraceId(),
];
$headers = array_merge($headers, $header);
*/
$data = (new Request())->post($url, $params,2000, 'json');
$data = HttpUtil::post($url, $params, 2000, 1, $headers);
/*
[
"http_code"=> 200,
......@@ -40,6 +41,11 @@ class Sdk {
]
*/
$isTrace = Application::app()->getConfig()->get('trace.open');
if($isTrace != false) {
FileLog::info('sdk api:', ['traceId'=>Tracer::getTraceId(), 'url'=>$url, 'req'=>$params, 'res'=>$data]);
}
if(!empty($data['response']['code'])) {
throw new BaseException(['msg'=>$data['response']['reason'], 'code'=>$data['response']['code']]);
}
......
......@@ -2,7 +2,7 @@
namespace Helpers;
class Logger {
class Tracer {
const DEBUG = 1;
const INFO = 2;
......
......@@ -324,9 +324,12 @@ class PayService
} catch (\Exception $e) {
//补偿处理
$item = PayOrderItem::getMaster('*', ['order_item_id' => $order_item_id]);
$time = $this->getNextTime($item['notify_account_times']); //计算下次同步的时间
PayOrderItem::update([
'notify_account_status' => 0,
'notify_account_times[+]' => 1,
'can_notify_account_time' => date('Y-m-d H:i:s', $time),
], ['order_item_id' => $order_item_id, 'can_notify_account' => 1]);
FileLog::error('pay-service:wallet: 钱包同步失败', json_encode($wallet_list, JSON_UNESCAPED_UNICODE), $e);
......@@ -685,4 +688,8 @@ class PayService
return $maps[105];
}
}
private function getNextTime($times = 0) {
return time() + pow(3, $times + 1);
}
}
\ No newline at end of file
......@@ -29,6 +29,8 @@ exception.user.msg = "error"
exception.sys.code = -1
exception.sys.msg = "system error"
[trace]
trace.open = true
[prod : common : exception]
[pre : common : exception]
......
......@@ -15,7 +15,10 @@ class Wallet implements DaemonServiceInterface
{
$where['can_notify_account'] = 1;
$where['notify_account_times[<]'] = 5;
$where['can_notify_account_time[>]'] = date('Y-m-d', time() - 3 * 86400);
$start = date('Y-m-d', time() - 2 * 86400);
$end = date('Y-m-d', time());
$where['can_notify_account_time[<>]'] = [$start, $end];
//$where['can_notify_account_time[>]'] = date('Y-m-d', time() - 3 * 86400);
$where['ORDER'] = ['can_notify_account_time'=>'ASC'];
$where['LIMIT'] = [0, 50];
......
......@@ -56,7 +56,7 @@ php api.go2yd.com/htdocs/Website/public/cli.php $2 $3
while true; do
is_master_on=$(pgrep -fc "$2")
is_master_on=$(pgrep -fc "$2 $1 master process")
if [[ ${is_master_on} -gt 0 ]]; then
if [[ ! -f "$start_done_file" ]]; then
touch ${start_done_file}
......
......@@ -7,8 +7,8 @@ ini_set("error_reporting",E_ALL);//显示所有错误
* cli bootstrap:application/BootstrapCli.php ( 在cli.ini中配置
* 默认模块:modules/cli
* 脚本位置:modules/cli/controllers/xxx.php
* 调用方式:php cli.php controller action "a=1&b=2"
* 测试脚本:php cli.php test index "a=1&b=2"
* 调用方式:php cli.php Wallet 2 sync_wallet
*
*/
if( !substr(php_sapi_name(), 0, 3) == 'cli' ) {
die;
......@@ -25,7 +25,7 @@ $application = new Yaf\Application( ROOT_PATH . "/conf/cli.ini");
/**
* 获取模块/控制器/方法
usage: php cli.php "t=Wallet&n=2&j=sync_wallet"
usage: php cli.php Wallet sync_wallet 2
usage: php cli.php Wallet 2 sync_wallet
*
*/
$module = "cli";
......@@ -35,15 +35,8 @@ $method = "run";
$param = [];
$param['t'] = $argv[1] ?? "Wallet";
$param['n'] = $argv[2] ?? 2;
$param['j'] = $argv[3] ?? "sync_wallet";
$_SERVER['SERVER_NAME'] = 'daemon.pay';
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
/*
if (!empty($argv[3]))
{
parse_str($argv[3], $param);
}
*/
$application->bootstrap()->getDispatcher()->dispatch( new Yaf\Request\Simple("", $module, $controller,$method,$param) );
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment