Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
token
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
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
wallet
token
Commits
cae4b465
Commit
cae4b465
authored
Aug 02, 2018
by
rlgy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
账单
parent
a6595101
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
114 additions
and
6 deletions
+114
-6
BillController.php
api/controllers/BillController.php
+32
-4
BillJob.php
api/job/BillJob.php
+28
-2
yii-queue.log
console/logs/yii-queue.log
+54
-0
No files found.
api/controllers/BillController.php
View file @
cae4b465
...
...
@@ -24,13 +24,40 @@ class BillController extends BaseController
$model
=
new
Bill
();
if
(
$model
->
load
(
$post
)
&&
$model
->
validate
())
{
$model
->
status
=
0
;
if
(
$model
->
save
(
false
))
{
//加入队列
Yii
::
$app
->
queue
->
push
(
new
BillJob
([
'id'
=>
$model
->
id
,
'txid'
=>
$model
->
txid
,
'chain'
=>
$model
->
chain
,
'from'
=>
$model
->
from
]));
return
[
'code'
=>
0
,
'message'
=>
'succeed'
];
try
{
if
(
$model
->
save
(
false
))
{
//加入队列
Yii
::
$app
->
queue
->
push
(
new
BillJob
([
'id'
=>
$model
->
id
,
'txid'
=>
$model
->
txid
,
'chain'
=>
$model
->
chain
,
'from'
=>
$model
->
from
]));
return
[
'code'
=>
0
,
'message'
=>
'succeed'
];
}
}
catch
(
\Exception
$exception
)
{
return
[
'code'
=>
$exception
->
getCode
(),
'message'
=>
'保存失败'
];
}
}
else
{
return
[
'code'
=>
-
1
,
'message'
=>
'数据验证失败'
];
}
}
public
function
actionBillList
()
{
$post
=
Yii
::
$app
->
request
->
post
();
$from
=
$post
[
'from'
]
??
''
;
$coinname
=
$post
[
'coinname'
]
??
''
;
$chain
=
$post
[
'chain'
]
??
''
;
$page
=
$post
[
'$page'
]
??
1
;
$limit
=
$post
[
'limit'
]
??
10
;
if
(
empty
(
$from
))
{
return
[
'code'
=>
-
1
,
'message'
=>
'数据不存在'
];
}
$condition
=
[
[
'from'
=>
$from
],
];
if
(
!
empty
(
$coinname
))
{
$condition
[]
=
[
'coinname'
=>
$coinname
];
}
if
(
!
empty
(
$chain
))
{
$condition
[]
=
[
'chain'
=>
$chain
];
}
return
Bill
::
getList
(
$page
,
$limit
,
$condition
);
}
}
\ No newline at end of file
api/job/BillJob.php
View file @
cae4b465
...
...
@@ -8,6 +8,9 @@
namespace
api\job
;
use
common\business\BrowerBusiness
;
use
common\models\pwallet\Bill
;
use
common\service\brower\Brower
;
use
yii\base\BaseObject
;
use
yii\queue\JobInterface
;
use
yii\queue\Queue
;
...
...
@@ -31,8 +34,31 @@ class BillJob extends BaseObject implements JobInterface
*/
public
function
execute
(
$queue
)
{
//todo 查询交易状态, 更改状态
$result
=
BrowerBusiness
::
getTransStatus
(
$this
->
chain
,
$this
->
txid
);
$f
=
false
;
if
(
$result
[
'code'
]
==
Brower
::
TRANS_OK
)
{
$model
=
Bill
::
findOne
(
$this
->
id
);
$model
->
status
=
1
;
$data
=
$result
[
'data'
]
??
null
;
if
(
$data
)
{
$model
->
height
=
$data
[
'height'
]
??
0
;
if
(
isset
(
$data
[
'blocktime'
])
&&
!
empty
(
$data
[
'blocktime'
]))
{
$model
->
blocktime
=
date
(
'Y-m-d H:i:s'
,
$data
[
'blocktime'
]);
}
}
if
(
$model
->
save
())
{
$f
=
true
;
}
}
elseif
(
$result
[
'code'
]
==
Brower
::
TRANS_FAIL
)
{
$model
=
Bill
::
findOne
(
$this
->
id
);
$model
->
status
=
-
1
;
if
(
$model
->
save
())
{
$f
=
true
;
}
}
if
(
!
$f
)
{
\Yii
::
$app
->
queue
->
delay
(
3
*
60
)
->
push
(
new
BillJob
([
'id'
=>
$this
->
id
,
'txid'
=>
$this
->
txid
,
'chain'
=>
$this
->
chain
,
'from'
=>
$this
->
from
]));
}
return
0
;
}
...
...
console/logs/yii-queue.log
0 → 100755
View file @
cae4b465
2018-07-31 01:24:11 [pid: 2434] - Worker is started
2018-07-31 01:24:11 [pid: 2434] - Worker is stopped (0:00:00)
2018-07-31 01:24:12 [pid: 2637] - Worker is started
2018-07-31 01:24:12 [pid: 2637] - Worker is stopped (0:00:00)
2018-07-31 01:24:13 [pid: 3244] - Worker is started
2018-07-31 01:24:13 [pid: 3244] - Worker is stopped (0:00:00)
2018-07-31 01:24:15 [pid: 3663] - Worker is started
2018-07-31 01:24:15 [pid: 3663] - Worker is stopped (0:00:00)
2018-07-31 01:24:18 [pid: 3711] - Worker is started
2018-07-31 01:24:18 [pid: 3711] - Worker is stopped (0:00:00)
2018-07-31 10:05:01 [pid: 2123] - Worker is started
2018-07-31 10:05:01 [pid: 2123] - Worker is stopped (0:00:00)
2018-07-31 10:05:02 [pid: 2219] - Worker is started
2018-07-31 10:05:02 [pid: 2219] - Worker is stopped (0:00:00)
2018-07-31 10:05:03 [pid: 2277] - Worker is started
2018-07-31 10:05:03 [pid: 2277] - Worker is stopped (0:00:00)
2018-07-31 10:05:05 [pid: 2691] - Worker is started
2018-07-31 10:05:05 [pid: 2691] - Worker is stopped (0:00:00)
2018-07-31 10:05:08 [pid: 2721] - Worker is started
2018-07-31 10:05:08 [pid: 2721] - Worker is stopped (0:00:00)
2018-08-01 01:05:20 [pid: 2388] - Worker is started
2018-08-01 01:05:20 [pid: 2388] - Worker is stopped (0:00:00)
2018-08-01 01:05:21 [pid: 3089] - Worker is started
2018-08-01 01:05:21 [pid: 3089] - Worker is stopped (0:00:00)
2018-08-01 01:05:22 [pid: 3230] - Worker is started
2018-08-01 01:05:22 [pid: 3230] - Worker is stopped (0:00:00)
2018-08-01 01:05:24 [pid: 3591] - Worker is started
2018-08-01 01:05:24 [pid: 3591] - Worker is stopped (0:00:00)
2018-08-01 01:05:27 [pid: 3684] - Worker is started
2018-08-01 01:05:27 [pid: 3684] - Worker is stopped (0:00:00)
2018-08-01 02:05:09 [pid: 2081] - Worker is started
2018-08-01 02:05:09 [pid: 2081] - Worker is stopped (0:00:00)
2018-08-01 02:05:11 [pid: 2182] - Worker is started
2018-08-01 02:05:11 [pid: 2182] - Worker is stopped (0:00:00)
2018-08-01 02:05:12 [pid: 2242] - Worker is started
2018-08-01 02:05:12 [pid: 2242] - Worker is stopped (0:00:00)
2018-08-01 02:05:14 [pid: 2488] - Worker is started
2018-08-01 02:05:14 [pid: 2488] - Worker is stopped (0:00:00)
2018-08-01 02:05:17 [pid: 2514] - Worker is started
2018-08-01 02:05:17 [pid: 2514] - Worker is stopped (0:00:00)
2018-08-02 01:24:36 [pid: 2099] - Worker is started
2018-08-02 01:24:36 [2] api\job\BillJob (attempt: 1, pid: 2099) - Started
2018-08-02 01:24:36 [2] api\job\BillJob (attempt: 1, pid: 2099) - Done (0.001 s)
2018-08-02 01:24:36 [3] api\job\BillJob (attempt: 1, pid: 2099) - Started
2018-08-02 01:24:36 [3] api\job\BillJob (attempt: 1, pid: 2099) - Done (0.001 s)
2018-08-02 01:24:36 [pid: 2099] - Worker is stopped (0:00:00)
2018-08-02 01:24:37 [pid: 3308] - Worker is started
2018-08-02 01:24:37 [pid: 3308] - Worker is stopped (0:00:00)
2018-08-02 01:24:38 [pid: 3324] - Worker is started
2018-08-02 01:24:38 [pid: 3324] - Worker is stopped (0:00:00)
2018-08-02 01:24:40 [pid: 3372] - Worker is started
2018-08-02 01:24:40 [pid: 3372] - Worker is stopped (0:00:00)
2018-08-02 01:24:43 [pid: 3445] - Worker is started
2018-08-02 01:24:43 [pid: 3445] - Worker is stopped (0:00:00)
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