Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
杨树贤
/
ic_server_welfare
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
60020b50
authored
Oct 10, 2019
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
确认提现任务
parent
25c86ee2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
63 additions
and
6 deletions
app/Http/Controllers/ExchangesTask.php
app/Http/Controllers/UserExchangesController.php
app/Models/UserExchange.php
common
routes/web.php
storage/laravels.json
storage/laravels.pid
app/Http/Controllers/ExchangesTask.php
View file @
60020b50
...
...
@@ -26,14 +26,11 @@ class ExchangesTask extends Task
//验证这个订单是否充值,防止重复提现
$Redis
=
new
RedisModel
();
$Cache
=
$Redis
->
hsetnx
(
'ic_user_exchanges'
,
$this
->
data
[
'id'
]
.
'_'
.
$this
->
data
[
'user_id'
]
,
1
);
Log
::
error
(
'进来了'
);
Log
::
error
(
$Cache
);
if
(
!
$Cache
)
return
true
;
try
{
DB
::
beginTransaction
();
Log
::
error
(
'事务'
);
//先修改提现记录状态
$UserExchangModel
=
new
UserExchange
();
$Exchang
=
[
...
...
app/Http/Controllers/UserExchangesController.php
View file @
60020b50
...
...
@@ -218,4 +218,24 @@ class UserExchangesController extends Controller
return
$this
->
Export
(
ErrorCode
(
100
,
5
),
'提现失败'
);
}
}
/**
* 确认提现接口
* @param Request $request
* @param UserExchange $userExchange
* @return false|string
*/
public
function
confirm
(
Request
$request
,
UserExchange
$userExchange
)
{
$exchangeId
=
$request
->
get
(
'exchange_id'
);
$userId
=
$request
->
get
(
'user_id'
);
//查询该次兑换对应的兑换
$result
=
$userExchange
->
confirmExchange
(
$exchangeId
,
$userId
);
if
(
!
$result
)
{
return
$this
->
Export
(
ErrorCode
(
22
,
5
),
'确认兑现失败'
);
}
return
$this
->
Export
(
0
,
'ok'
);
}
}
\ No newline at end of file
app/Models/UserExchange.php
View file @
60020b50
...
...
@@ -150,4 +150,41 @@ class UserExchange extends Model
return
$result
;
}
//确认用户兑换
public
function
confirmExchange
(
$exchangeId
,
$userId
)
{
$userExchange
=
DB
::
table
(
'user_exchanges'
)
->
where
(
'id'
,
$exchangeId
)
->
first
();
if
(
$userExchange
)
{
//先判断状态,如果是已经兑换的,直接返回失败
if
(
$userExchange
->
status
!=
0
)
{
return
false
;
}
//判断该兑换是否属于该用户,不属于直接返回失败
if
(
$userExchange
->
user_id
!=
$userId
)
{
return
false
;
}
//如果是未兑换的,则要去进行提现的异步任务
$data
=
(
array
)
$userExchange
;
if
(
$data
[
'amount'
]
<
20
&&
$data
[
'type'
]
==
2
)
{
$ic_exchange_settings
[
'amount'
]
=
$data
[
'amount'
];
$Task
=
new
ExchangesTask
(
$data
,
$ic_exchange_settings
);
$Task
->
delay
(
5
);
$result
=
Task
::
deliver
(
$Task
);
if
(
!
$result
)
{
ErrorLog
(
ErrorCode
(
1
,
9
),
'提现任务推送失败,提现ID:'
.
$data
[
'id'
]);
return
false
;
}
Log
::
info
(
'进行提现任务投递成功'
);
return
true
;
}
else
{
//如果是大于20块的,需要审核,这步就什么都不做
return
true
;
}
}
else
{
return
false
;
}
}
}
\ No newline at end of file
common
@
6a492b76
Subproject commit
8428774c731bbcd89366d7d698daf57579f0b53b
Subproject commit
6a492b76f3938205ed9d94cd12b81d66feea657d
routes/web.php
View file @
60020b50
...
...
@@ -61,6 +61,7 @@ $router->post('/user_exchanges/add', 'UserExchangesController@store');
$router
->
post
(
'/user_exchanges/audit'
,
'UserExchangesController@audit'
);
$router
->
post
(
'/user_exchanges/list'
,
'UserExchangesController@index'
);
$router
->
post
(
'/user_exchanges/update'
,
'UserExchangesController@update'
);
$router
->
post
(
'/user_exchanges/exchange/confirm'
,
'UserExchangesController@confirm'
);
$router
->
post
(
'/user_exchanges/batchAuditReject'
,
'UserExchangesController@batchAuditReject'
);
...
...
storage/laravels.json
View file @
60020b50
This diff is collapsed.
Click to expand it.
storage/laravels.pid
View file @
60020b50
7163
\ No newline at end of file
21975
\ No newline at end of file
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