Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
blind-box-api
Overview
Overview
Details
Activity
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
haojie
blind-box-api
Commits
10edde57
Commit
10edde57
authored
Mar 09, 2023
by
haojie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
277efe9f
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
82 additions
and
34 deletions
+82
-34
app/Http/Controllers/API/BlindBox/BuyBlindBoxController.php
+4
-34
app/Jobs/CheckArrival.php
+78
-0
No files found.
app/Http/Controllers/API/BlindBox/BuyBlindBoxController.php
View file @
10edde57
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
use
App\Models\UserWallet
;
use
App\Models\UserWallet
;
use
App\Models\UseUser
;
use
App\Models\UseUser
;
use
Illuminate\Support\Facades\Log
;
use
Illuminate\Support\Facades\Log
;
use
Illuminate\Support\Facades\Redis
;
use
App\Jobs\CheckArrival
;
class
BuyBlindBoxController
class
BuyBlindBoxController
...
@@ -49,39 +49,9 @@ public function toBuy($address, $hash, $id, $invite_code, $Invitees_box_id)
...
@@ -49,39 +49,9 @@ public function toBuy($address, $hash, $id, $invite_code, $Invitees_box_id)
$address
=
SetAddress
::
query
()
->
first
();
$address
=
SetAddress
::
query
()
->
first
();
$to
=
$address
->
address
;
$to
=
$address
->
address
;
# 添加订单后--查询是否到账--最多检测20次
# 添加订单后
for
(
$i
=
1
;
$i
<=
10
;
$i
++
)
{
# 异步检查到账情况
$type
=
self
::
IntervalCheck
(
$hash
,
$price
->
price
,
$address
,
$to
);
dispatch
(
new
CheckArrival
(
$hash
,
$price
->
price
,
$address
,
$to
));
if
(
$type
)
{
break
;
}
sleep
(
1
);
}
}
/**
* 向redis发送请求
*/
public
function
IntervalCheck
(
$hash
,
$price
,
$address
,
$to
)
{
# 获取状态
$item
=
UserWallet
::
query
()
->
where
(
'hash'
,
$hash
)
->
first
([
'status'
]);
if
(
$item
->
status
==
1
)
{
return
true
;
}
# 获取交易
$obj
=
(
object
)[];
$obj
->
hash
=
$hash
;
$obj
->
notify_url
=
config
(
'address.callback'
);
$obj
->
retry
=
1
;
$obj
->
amount
=
$price
;
# 要转小写
$obj
->
form
=
strtolower
(
$address
);
# 保留一个旧的
$obj
->
old_form
=
$address
;
$obj
->
to
=
strtolower
(
$to
);
Redis
::
rpush
(
'pay_notify'
,
json_encode
(
$obj
));
return
false
;
}
}
/**
/**
...
...
app/Jobs/CheckArrival.php
0 → 100644
View file @
10edde57
<?php
namespace
App\Jobs
;
use
Illuminate\Bus\Queueable
;
use
Illuminate\Contracts\Queue\ShouldBeUnique
;
use
Illuminate\Contracts\Queue\ShouldQueue
;
use
Illuminate\Foundation\Bus\Dispatchable
;
use
Illuminate\Queue\InteractsWithQueue
;
use
Illuminate\Queue\SerializesModels
;
use
Illuminate\Support\Facades\Redis
;
use
App\Models\UserWallet
;
class
CheckArrival
implements
ShouldQueue
{
use
Dispatchable
,
InteractsWithQueue
,
Queueable
,
SerializesModels
;
public
string
$hash
;
public
int
$price
;
public
string
$address
;
public
string
$to
;
/**
* Create a new job instance.
*
* @return void
*/
public
function
__construct
(
string
$hash
,
int
$price
,
string
$address
,
string
$to
)
{
$this
->
hash
=
$hash
;
$this
->
price
=
$price
;
$this
->
address
=
$address
;
$this
->
to
=
$to
;
}
/**
* Execute the job.
*
* @return void
*/
public
function
handle
()
{
# 处理 支付到账模块
# 添加订单后--查询是否到账--最多检测20次
for
(
$i
=
1
;
$i
<=
10
;
$i
++
)
{
$type
=
self
::
IntervalCheck
(
$this
->
hash
,
$this
->
price
,
$this
->
address
,
$this
->
to
);
if
(
$type
)
{
break
;
}
sleep
(
1
);
}
}
/**
* 向redis发送请求
*/
public
function
IntervalCheck
(
$hash
,
$price
,
$address
,
$to
)
{
# 获取状态
$item
=
UserWallet
::
query
()
->
where
(
'hash'
,
$hash
)
->
first
([
'status'
]);
if
(
$item
->
status
==
1
)
{
return
true
;
}
# 获取交易
$obj
=
(
object
)[];
$obj
->
hash
=
$hash
;
$obj
->
notify_url
=
config
(
'address.callback'
);
$obj
->
retry
=
1
;
$obj
->
amount
=
$price
;
# 要转小写
$obj
->
form
=
strtolower
(
$address
);
# 保留一个旧的
$obj
->
old_form
=
$address
;
$obj
->
to
=
strtolower
(
$to
);
Redis
::
rpush
(
'pay_notify'
,
json_encode
(
$obj
));
return
false
;
}
}
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