Commit b00132af authored by wanjilong's avatar wanjilong

add: 优化同步钱包时间,3的幂进行同步

parent 1fdcf15d
......@@ -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];
......
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