Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pay
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
bp
pay
Commits
b00132af
Commit
b00132af
authored
Jul 17, 2021
by
wanjilong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add: 优化同步钱包时间,3的幂进行同步
parent
1fdcf15d
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
25 additions
and
7 deletions
+25
-7
Sdk.php
application/library/Helpers/Sdk.php
+11
-5
Tracer.php
application/library/Helpers/Tracer.php
+1
-1
PayService.php
application/services/pay/PayService.php
+7
-0
application.ini
conf/application.ini
+2
-0
Wallet.php
daemon/Wallet.php
+4
-1
No files found.
application/library/Helpers/Sdk.php
View file @
b00132af
...
@@ -2,7 +2,8 @@
...
@@ -2,7 +2,8 @@
namespace
Helpers
;
namespace
Helpers
;
use
Api\PhpUtils\Log\FileLog
;
use
Api\PhpUtils\Log\FileLog
;
use
Api\PhpUtils\Http\Request
;
use
Helpers\Tracer
;
use
Api\PhpUtils\Http\HttpUtil
;
use
App\Exception\BaseException
;
use
App\Exception\BaseException
;
/**
/**
...
@@ -20,14 +21,14 @@ class Sdk {
...
@@ -20,14 +21,14 @@ class Sdk {
*/
*/
public
static
function
call
(
$url
,
$params
,
$headers
=
[])
{
public
static
function
call
(
$url
,
$params
,
$headers
=
[])
{
/*
/*
*/
$header
=
[
$header
=
[
'X-REQUEST-ID'=>
Logg
er::getTraceId(),
'X-REQUEST-ID'
=>
Trac
er
::
getTraceId
(),
];
];
$headers
=
array_merge
(
$headers
,
$header
);
$headers
=
array_merge
(
$headers
,
$header
);
*/
$data
=
HttpUtil
::
post
(
$url
,
$params
,
2000
,
1
,
$headers
);
$data
=
(
new
Request
())
->
post
(
$url
,
$params
,
2000
,
'json'
);
/*
/*
[
[
"http_code"=> 200,
"http_code"=> 200,
...
@@ -40,6 +41,11 @@ class Sdk {
...
@@ -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'
]))
{
if
(
!
empty
(
$data
[
'response'
][
'code'
]))
{
throw
new
BaseException
([
'msg'
=>
$data
[
'response'
][
'reason'
],
'code'
=>
$data
[
'response'
][
'code'
]]);
throw
new
BaseException
([
'msg'
=>
$data
[
'response'
][
'reason'
],
'code'
=>
$data
[
'response'
][
'code'
]]);
}
}
...
...
application/library/Helpers/
Logg
er.php
→
application/library/Helpers/
Trac
er.php
View file @
b00132af
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
namespace
Helpers
;
namespace
Helpers
;
class
Logg
er
{
class
Trac
er
{
const
DEBUG
=
1
;
const
DEBUG
=
1
;
const
INFO
=
2
;
const
INFO
=
2
;
...
...
application/services/pay/PayService.php
View file @
b00132af
...
@@ -324,9 +324,12 @@ class PayService
...
@@ -324,9 +324,12 @@ class PayService
}
catch
(
\Exception
$e
)
{
}
catch
(
\Exception
$e
)
{
//补偿处理
//补偿处理
$item
=
PayOrderItem
::
getMaster
(
'*'
,
[
'order_item_id'
=>
$order_item_id
]);
$time
=
$this
->
getNextTime
(
$item
[
'notify_account_times'
]);
//计算下次同步的时间
PayOrderItem
::
update
([
PayOrderItem
::
update
([
'notify_account_status'
=>
0
,
'notify_account_status'
=>
0
,
'notify_account_times[+]'
=>
1
,
'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
]);
],
[
'order_item_id'
=>
$order_item_id
,
'can_notify_account'
=>
1
]);
FileLog
::
error
(
'pay-service:wallet: 钱包同步失败'
,
json_encode
(
$wallet_list
,
JSON_UNESCAPED_UNICODE
),
$e
);
FileLog
::
error
(
'pay-service:wallet: 钱包同步失败'
,
json_encode
(
$wallet_list
,
JSON_UNESCAPED_UNICODE
),
$e
);
...
@@ -685,4 +688,8 @@ class PayService
...
@@ -685,4 +688,8 @@ class PayService
return
$maps
[
105
];
return
$maps
[
105
];
}
}
}
}
private
function
getNextTime
(
$times
=
0
)
{
return
time
()
+
pow
(
3
,
$times
+
1
);
}
}
}
\ No newline at end of file
conf/application.ini
View file @
b00132af
...
@@ -29,6 +29,8 @@ exception.user.msg = "error"
...
@@ -29,6 +29,8 @@ exception.user.msg = "error"
exception.sys.code
=
-1
exception.sys.code
=
-1
exception.sys.msg
=
"system error"
exception.sys.msg
=
"system error"
[trace]
trace.open
=
true
[prod : common : exception]
[prod : common : exception]
[pre : common : exception]
[pre : common : exception]
...
...
daemon/Wallet.php
View file @
b00132af
...
@@ -15,7 +15,10 @@ class Wallet implements DaemonServiceInterface
...
@@ -15,7 +15,10 @@ class Wallet implements DaemonServiceInterface
{
{
$where
[
'can_notify_account'
]
=
1
;
$where
[
'can_notify_account'
]
=
1
;
$where
[
'notify_account_times[<]'
]
=
5
;
$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
[
'ORDER'
]
=
[
'can_notify_account_time'
=>
'ASC'
];
$where
[
'LIMIT'
]
=
[
0
,
50
];
$where
[
'LIMIT'
]
=
[
0
,
50
];
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment