Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
loveisland
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
刘小敏
loveisland
Commits
85eceb29
Commit
85eceb29
authored
May 11, 2026
by
刘小敏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
累计消费累计充值接口增加返回值
parent
e9845ba8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
3 deletions
+24
-3
WalletLog.php
addons/shopro/controller/user/WalletLog.php
+24
-3
No files found.
addons/shopro/controller/user/WalletLog.php
View file @
85eceb29
...
@@ -5,6 +5,7 @@ namespace addons\shopro\controller\user;
...
@@ -5,6 +5,7 @@ namespace addons\shopro\controller\user;
use
addons\shopro\controller\Common
;
use
addons\shopro\controller\Common
;
use
app\admin\model\shopro\user\WalletLog
as
UserWalletLogModel
;
use
app\admin\model\shopro\user\WalletLog
as
UserWalletLogModel
;
use
think\Cache
;
use
think\Cache
;
use
app\admin\model\shopro\user\User
as
UserModel
;
class
WalletLog
extends
Common
class
WalletLog
extends
Common
{
{
...
@@ -45,13 +46,19 @@ class WalletLog extends Common
...
@@ -45,13 +46,19 @@ class WalletLog extends Common
/**
/**
* 钱包统计( 累计充值 和 累计消费 )
* 钱包统计( 累计充值 和 累计消费 )
* @param string $type 钱包类型:money-余额, score-积分, commission-佣金(
默认money
)
* @param string $type 钱包类型:money-余额, score-积分, commission-佣金(
score
)
* @return array
* @return array
*/
*/
public
function
walletStats
()
public
function
walletStats
()
{
{
$user
=
auth_user
();
$user
=
auth_user
();
$type
=
$this
->
request
->
param
(
'type'
,
'score'
);
$type
=
$this
->
request
->
param
(
'type'
,
'score'
);
$date
=
$this
->
request
->
param
(
'date/a'
);
// 验证并设置默认时间范围
if
(
!
is_array
(
$date
)
||
count
(
$date
)
<
2
||
empty
(
$date
[
0
])
||
empty
(
$date
[
1
]))
{
$date
=
[
date
(
'0000-00-00 00:00:00'
),
date
(
'Y-m-d 23:59:59'
)];
}
// 验证钱包类型
// 验证钱包类型
if
(
!
in_array
(
$type
,
[
'money'
,
'score'
,
'commission'
]))
{
if
(
!
in_array
(
$type
,
[
'money'
,
'score'
,
'commission'
]))
{
...
@@ -75,23 +82,37 @@ class WalletLog extends Common
...
@@ -75,23 +82,37 @@ class WalletLog extends Common
->
where
(
'type'
,
$type
)
->
where
(
'type'
,
$type
)
->
where
(
'amount'
,
'>'
,
0
)
->
where
(
'amount'
,
'>'
,
0
)
->
whereIn
(
'event'
,
$rechargeEvents
[
$type
])
->
whereIn
(
'event'
,
$rechargeEvents
[
$type
])
->
whereTime
(
'createtime'
,
'between'
,
$date
)
->
sum
(
'amount'
)
?:
0
;
->
sum
(
'amount'
)
?:
0
;
// 累计消费(支出)
// 累计消费(支出)
$consume
=
UserWalletLogModel
::
where
(
'user_id'
,
$user
->
id
)
$consume
=
UserWalletLogModel
::
where
(
'user_id'
,
$user
->
id
)
->
where
(
'type'
,
$type
)
->
where
(
'type'
,
$type
)
->
where
(
'amount'
,
'<'
,
0
)
->
where
(
'amount'
,
'<'
,
0
)
->
whereTime
(
'createtime'
,
'between'
,
$date
)
->
sum
(
'amount'
)
?:
0
;
->
sum
(
'amount'
)
?:
0
;
//用户当前积分/余额/佣金
$user_info
=
UserModel
::
where
(
'id'
,
$user
->
id
)
->
find
();
$result
=
[
$result
=
[
'recharge'
=>
round
(
$recharge
,
2
),
'recharge'
=>
round
(
$recharge
,
2
),
'consume'
=>
round
(
abs
(
$consume
),
2
),
'consume'
=>
round
(
abs
(
$consume
),
2
),
'type'
=>
$type
'type'
=>
$type
,
'score'
=>
$user_info
->
score
,
'commission'
=>
$user_info
->
commission
,
'money'
=>
$user_info
->
money
,
];
];
}
catch
(
\Exception
$e
)
{
}
catch
(
\Exception
$e
)
{
$result
=
[
$result
=
[
'recharge'
=>
0
,
'recharge'
=>
0
,
'consume'
=>
0
,
'consume'
=>
0
,
'type'
=>
$type
'type'
=>
$type
,
'score'
=>
0
,
'commission'
=>
0
,
'money'
=>
0
,
];
];
}
}
...
...
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