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
59cb9053
Commit
59cb9053
authored
Mar 09, 2023
by
haojie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
到账检查
parent
de0f61d6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
22 deletions
+38
-22
app/Http/Controllers/API/BlindBox/BuyBlindBoxController.php
+33
-2
app/Http/Controllers/API/IndexController.php
+5
-20
No files found.
app/Http/Controllers/API/BlindBox/BuyBlindBoxController.php
View file @
59cb9053
...
...
@@ -4,9 +4,11 @@
namespace
App\Http\Controllers\API\BlindBox
;
use
App\Models\BlindBoxList
;
use
App\Models\SetAddress
;
use
App\Models\UserWallet
;
use
App\Models\UseUser
;
use
Illuminate\Support\Facades\Log
;
use
Illuminate\Support\Facades\Redis
;
class
BuyBlindBoxController
...
...
@@ -43,14 +45,43 @@ public function toBuy($address, $hash, $id, $invite_code, $Invitees_box_id)
# 创建订单
UserWallet
::
query
()
->
create
([
'user_address'
=>
$address
,
'status'
=>
0
,
'price'
=>
$price
->
price
,
'blind_box_id'
=>
$id
,
'hash'
=>
$hash
]);
}
$address
=
SetAddress
::
query
()
->
first
();
$to
=
$address
->
address
;
# 添加订单后--查询是否到账--最多检测20次
for
(
$i
=
1
;
$i
<=
10
;
$i
++
)
{
$type
=
self
::
IntervalCheck
(
$hash
,
$price
->
price
,
$address
,
$to
);
if
(
$type
)
{
break
;
}
sleep
(
1
);
}
}
/**
* 向redis发送请求
*/
public
function
IntervalCheck
()
public
function
IntervalCheck
(
$hash
,
$price
,
$address
,
$to
)
{
return
''
;
# 获取状态
$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/Http/Controllers/API/IndexController.php
View file @
59cb9053
...
...
@@ -122,6 +122,11 @@ public function useBuy(Request $request)
if
(
empty
(
$address
)
||
empty
(
$hash
)
||
empty
(
$id
))
{
return
$this
->
error
(
'缺少数据'
,
400
,
400
);
}
# 检查hash是否存在
$hashList
=
UserWallet
::
query
()
->
where
(
'hash'
,
$hash
)
->
first
();
if
(
$hashList
)
{
return
$this
->
error
(
'hash已存在'
,
400
,
400
);
}
$result
=
app
(
BuyBlindBoxController
::
class
)
->
toBuy
(
$address
,
$hash
,
$id
,
$invite_code
,
$Invitees_box_id
);
return
$this
->
success
(
'success'
,
$result
);
}
...
...
@@ -139,26 +144,6 @@ public function usePayCheck(Request $request)
{
# 提交redis
$hash
=
$request
->
input
(
'hash'
,
null
);
$amount
=
$request
->
input
(
'price'
,
null
);
$form
=
$request
->
input
(
'form'
,
null
);
# 先写死
$address
=
SetAddress
::
query
()
->
first
();
$to
=
$address
->
address
;
if
(
empty
(
$hash
)
||
empty
(
$amount
)
||
empty
(
$form
))
{
return
$this
->
error
(
'缺少数据'
,
400
,
400
);
}
# 获取交易
$obj
=
(
object
)[];
$obj
->
hash
=
$hash
;
$obj
->
notify_url
=
config
(
'address.callback'
);
$obj
->
retry
=
1
;
$obj
->
amount
=
$amount
;
# 要转小写
$obj
->
form
=
strtolower
(
$form
);
# 保留一个旧的
$obj
->
old_form
=
$form
;
$obj
->
to
=
strtolower
(
$to
);
Redis
::
rpush
(
'pay_notify'
,
json_encode
(
$obj
));
# 获取状态
$item
=
UserWallet
::
query
()
->
where
(
'hash'
,
$hash
)
->
first
([
'status'
]);
if
(
$item
->
status
==
1
)
{
...
...
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