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
f78d44bf
Commit
f78d44bf
authored
Jul 17, 2021
by
万继龙
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' into 'test'
Develop See merge request bp/pay!18
parents
39f5ace8
b00132af
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
29 additions
and
18 deletions
+29
-18
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
start_daemon.sh
deploy/start_env/start_daemon.sh
+1
-1
cli.php
public/cli.php
+3
-10
No files found.
application/library/Helpers/Sdk.php
View file @
f78d44bf
...
...
@@ -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'=>
Logg
er::getTraceId(),
'X-REQUEST-ID'
=>
Trac
er
::
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'
]]);
}
...
...
application/library/Helpers/
Logg
er.php
→
application/library/Helpers/
Trac
er.php
View file @
f78d44bf
...
...
@@ -2,7 +2,7 @@
namespace
Helpers
;
class
Logg
er
{
class
Trac
er
{
const
DEBUG
=
1
;
const
INFO
=
2
;
...
...
application/services/pay/PayService.php
View file @
f78d44bf
...
...
@@ -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
conf/application.ini
View file @
f78d44bf
...
...
@@ -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]
...
...
daemon/Wallet.php
View file @
f78d44bf
...
...
@@ -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
];
...
...
deploy/start_env/start_daemon.sh
View file @
f78d44bf
...
...
@@ -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
}
...
...
public/cli.php
View file @
f78d44bf
...
...
@@ -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
)
);
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