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
f5c62c3b
Commit
f5c62c3b
authored
Mar 14, 2019
by
clone
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
账户余额
parent
b03c2e95
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
68 additions
and
0 deletions
+68
-0
AccountBalance.php
application/api/controller/AccountBalance.php
+21
-0
AccountBalanceService.php
application/api/service/AccountBalanceService.php
+8
-0
UAccountBalance.php
application/model/UAccountBalance.php
+19
-0
UAccountCheck.php
application/model/UAccountCheck.php
+19
-0
route.php
application/route.php
+1
-0
No files found.
application/api/controller/AccountBalance.php
View file @
f5c62c3b
...
...
@@ -21,6 +21,7 @@ class AccountBalance extends Basic{
}
/**
* 收益明细
* @return \think\Response
*/
public
function
userAccountBalanceList
()
...
...
@@ -42,4 +43,23 @@ class AccountBalance extends Basic{
return
$this
->
response
(
"200"
,
"success!"
,
$data
);
}
/**
* 账户余额
* @return \think\Response
*/
public
function
totalAccount
(){
$params
=
$this
->
params
;
/*$params = array(
"user_id" => 4
);*/
if
(
empty
(
$params
[
"user_id"
])){
return
$this
->
response
(
"101"
,
"请求参数错误"
);
}
$total
=
$this
->
s_account_balance
->
getAccountTotal
(
$params
[
"user_id"
]);
if
(
$total
<=
0
){
$total
=
0
;
}
return
$this
->
response
(
"200"
,
"success"
,[
"total"
=>
$total
]);
}
}
\ No newline at end of file
application/api/service/AccountBalanceService.php
View file @
f5c62c3b
...
...
@@ -80,5 +80,12 @@ class AccountBalanceService{
return
$referrer_res
;
}
public
function
getAccountTotal
(
$user_id
){
$balanceTotal
=
$this
->
m_account_balance
->
getBalanceTotal
(
$user_id
);
$accountCheckModel
=
new
UAccountCheck
();
$checkTotal
=
$accountCheckModel
->
getCheckTotal
(
$user_id
);
return
$balanceTotal
-
$checkTotal
;
}
}
\ No newline at end of file
application/model/UAccountBalance.php
View file @
f5c62c3b
...
...
@@ -81,5 +81,24 @@ class UAccountBalance extends Model
return
$result
;
}
/**
* @param $params
* @return int|string
*/
public
function
getBalanceTotal
(
$user_id
)
{
$where_arr
=
[];
if
(
!
empty
(
$user_id
))
{
$where_arr
[
'user_id'
]
=
$user_id
;
}
$where_arr
[
'status'
]
=
0
;
$result
=
$this
->
db_
->
field
(
"id"
)
->
where
(
$where_arr
)
->
sum
(
"money"
);
return
$result
;
}
}
application/model/UAccountCheck.php
View file @
f5c62c3b
...
...
@@ -43,4 +43,22 @@ class UAccountCheck extends Model{
->
count
();
return
$result
;
}
/**
* @param $params
* @return int|string
*/
public
function
getCheckTotal
(
$user_id
)
{
$where_arr
=
[];
if
(
!
empty
(
$user_id
))
{
$where_arr
[
'user_id'
]
=
$user_id
;
}
$where_arr
[
'status'
]
=
array
(
"in"
,
"0,1"
);;
$result
=
$this
->
db_
->
field
(
"id"
)
->
where
(
$where_arr
)
->
sum
(
"money"
);
return
$result
;
}
}
\ No newline at end of file
application/route.php
View file @
f5c62c3b
...
...
@@ -523,6 +523,7 @@ Route::group('api', [
'userAccountBalanceList'
=>
[
'api/AccountBalance/userAccountBalanceList'
,
[
'method'
=>
'get|post'
]],
//
'totalAccount'
=>
[
'api/AccountBalance/totalAccount'
,
[
'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