Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tl_estate
Project
Project
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hujun
tl_estate
Commits
ebf6216b
Commit
ebf6216b
authored
Mar 14, 2019
by
clone
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
提现
parent
bff0bb5a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
75 additions
and
7 deletions
+75
-7
AccountBalance.php
application/api/controller/AccountBalance.php
+47
-7
AccountBalanceService.php
application/api/service/AccountBalanceService.php
+13
-0
UAccountCheck.php
application/model/UAccountCheck.php
+14
-0
route.php
application/route.php
+1
-0
No files found.
application/api/controller/AccountBalance.php
View file @
ebf6216b
<?php
namespace
app\api\controller
;
use
app\api\extend\Basic
;
use
app\api\service\AccountBalanceService
;
use
think\Request
;
...
...
@@ -10,7 +12,8 @@ use think\Request;
* Date: 2019/3/13
* Time: 10:17
*/
class
AccountBalance
extends
Basic
{
class
AccountBalance
extends
Basic
{
private
$s_account_balance
;
public
function
__construct
(
Request
$request
=
null
)
...
...
@@ -33,11 +36,11 @@ class AccountBalance extends Basic{
"user_phone" => '6471',
"user_id" => '111',
);*/
if
(
empty
(
$params
[
"user_id"
]))
{
if
(
empty
(
$params
[
"user_id"
]))
{
return
$this
->
response
(
"101"
,
"请求参数错误"
);
}
$data
=
$this
->
s_account_balance
->
getBalanceList
(
$params
);
if
(
count
(
$data
)
<=
0
)
{
if
(
count
(
$data
)
<=
0
)
{
return
$this
->
response
(
"200"
,
"null"
);
}
return
$this
->
response
(
"200"
,
"success!"
,
$data
);
...
...
@@ -47,19 +50,55 @@ class AccountBalance extends Basic{
* 账户余额
* @return \think\Response
*/
public
function
totalAccount
(){
public
function
totalAccount
()
{
$params
=
$this
->
params
;
/*$params = array(
"user_id" => 4
);*/
if
(
empty
(
$params
[
"user_id"
]))
{
if
(
empty
(
$params
[
"user_id"
]))
{
return
$this
->
response
(
"101"
,
"请求参数错误"
);
}
$total
=
$this
->
s_account_balance
->
getAccountTotal
(
$params
[
"user_id"
]);
if
(
$total
<=
0
)
{
if
(
$total
<=
0
)
{
$total
=
0
;
}
return
$this
->
response
(
"200"
,
"success"
,[
"total"
=>
$total
]);
return
$this
->
response
(
"200"
,
"success"
,
[
"total"
=>
$total
]);
}
/**
* 申请提现
* @return \think\Response
*/
public
function
applyForWithdraw
()
{
$params
=
$this
->
params
;
/*$params = array(
"user_id" => 4,
"money" => 11,
"user_phone"=> "11231",
"user_name" => "12312"
);*/
if
(
empty
(
$params
[
"user_id"
])
||
empty
(
$params
[
"money"
])
||
empty
(
$params
[
"user_phone"
]))
{
return
$this
->
response
(
"101"
,
"请求参数错误"
);
}
$user_id
=
$params
[
"user_id"
];
$user_phone
=
$params
[
"money"
];
$money
=
$params
[
"user_phone"
];
$user_name
=
$params
[
"user_name"
];
if
(
$money
<
30
)
{
return
$this
->
response
(
"101"
,
"提现金额不能小于30"
);
}
$total
=
$this
->
s_account_balance
->
getAccountTotal
(
$user_id
);
if
(
$money
>
$total
){
return
$this
->
response
(
"101"
,
"账户余额不足,请刷新后再提交!"
);
}
$result
=
$this
->
s_account_balance
->
addCheck
(
$user_id
,
$user_phone
,
$money
,
$user_name
);
if
(
$result
>
0
)
{
return
$this
->
response
(
"200"
,
"success"
);
}
return
$this
->
response
(
"101"
,
"申请提现异常"
);
}
}
\ No newline at end of file
application/api/service/AccountBalanceService.php
View file @
ebf6216b
...
...
@@ -87,5 +87,17 @@ class AccountBalanceService{
return
$balanceTotal
-
$checkTotal
;
}
public
function
addCheck
(
$user_id
,
$user_phone
,
$money
,
$user_name
){
$arr
=
array
(
"user_id"
=>
$user_id
,
"user_phone"
=>
$user_phone
,
"money"
=>
$money
,
"status"
=>
0
,
"user_name"
=>
$user_name
);
$accountCheckModel
=
new
UAccountCheck
();
return
$accountCheckModel
->
addCheck
(
$arr
);
}
}
\ No newline at end of file
application/model/UAccountCheck.php
View file @
ebf6216b
...
...
@@ -61,4 +61,17 @@ class UAccountCheck extends Model{
->
sum
(
"money"
);
return
$result
;
}
public
function
addCheck
(
$params
){
Db
::
startTrans
();
$id
=
0
;
try
{
$id
=
$this
->
db_
->
insertGetId
(
$params
);
Db
::
commit
();
return
$id
;
}
catch
(
\Exception
$e
)
{
Db
::
rollback
();
}
return
$id
;
}
}
\ No newline at end of file
application/route.php
View file @
ebf6216b
...
...
@@ -524,6 +524,7 @@ Route::group('api', [
'userAccountBalanceList'
=>
[
'api/AccountBalance/userAccountBalanceList'
,
[
'method'
=>
'get|post'
]],
//
'totalAccount'
=>
[
'api/AccountBalance/totalAccount'
,
[
'method'
=>
'post'
]],
'applyForWithdraw'
=>
[
'api/AccountBalance/applyForWithdraw'
,
[
'method'
=>
'post'
]],
]);
...
...
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