Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
projecttwo
Project
Project
Details
Activity
Releases
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
wangtao
projecttwo
Commits
48708b23
Commit
48708b23
authored
Jun 27, 2025
by
wangzhengwen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
资金统计
parent
e51aa794
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
0 deletions
+52
-0
User.php
app/api/controller/mine/User.php
+52
-0
No files found.
app/api/controller/mine/User.php
View file @
48708b23
...
@@ -52,6 +52,58 @@ class User extends BaseController
...
@@ -52,6 +52,58 @@ class User extends BaseController
$info_status
=
Db
::
name
(
'school'
)
->
where
(
'user_id'
,
$user
[
'id'
])
->
value
(
'status'
);
$info_status
=
Db
::
name
(
'school'
)
->
where
(
'user_id'
,
$user
[
'id'
])
->
value
(
'status'
);
}
}
$user
[
'info_status'
]
=
$info_status
;
$user
[
'info_status'
]
=
$info_status
;
if
(
$user
[
'role'
]
==
1
)
{
// 获取当前月份和上个月的起始和结束时间戳
$currentMonthStart
=
strtotime
(
date
(
'Y-m-01 00:00:00'
));
$currentMonthEnd
=
strtotime
(
date
(
'Y-m-t 23:59:59'
));
$lastMonthStart
=
strtotime
(
date
(
'Y-m-01 00:00:00'
,
strtotime
(
'-1 month'
)));
$lastMonthEnd
=
strtotime
(
date
(
'Y-m-t 23:59:59'
,
strtotime
(
'-1 month'
)));
// 本月收入 (类型为0-项目结算和2-后台手动增加)
$currentMonthIncome
=
UserMoneyLog
::
where
(
'user_id'
,
$user
[
'id'
])
->
whereIn
(
'type'
,
[
0
,
2
])
->
where
(
'money_type'
,
0
)
->
whereBetween
(
'createtime'
,
[
$currentMonthStart
,
$currentMonthEnd
])
->
sum
(
'money'
);
$user
[
'financial'
][
'current_month_income'
]
=
number_format
(
$currentMonthIncome
,
2
);
// 本月支出 (类型为1-提现)
$currentMonthExpense
=
abs
(
UserMoneyLog
::
where
(
'user_id'
,
$user
[
'id'
])
->
whereIn
(
'type'
,
[
1
])
->
where
(
'money_type'
,
0
)
->
whereBetween
(
'createtime'
,
[
$currentMonthStart
,
$currentMonthEnd
])
->
sum
(
'money'
));
$user
[
'financial'
][
'current_month_expense'
]
=
number_format
(
$currentMonthExpense
,
2
);
// 上月收入
$lastMonthIncome
=
UserMoneyLog
::
where
(
'user_id'
,
$user
[
'id'
])
->
whereIn
(
'type'
,
[
0
,
2
])
->
where
(
'money_type'
,
0
)
->
whereBetween
(
'createtime'
,
[
$lastMonthStart
,
$lastMonthEnd
])
->
sum
(
'money'
);
$user
[
'financial'
][
'lastMonthIncome'
]
=
number_format
(
$lastMonthIncome
,
2
);
// 上月支出
$lastMonthExpense
=
abs
(
UserMoneyLog
::
where
(
'user_id'
,
$user
[
'id'
])
->
whereIn
(
'type'
,
[
1
])
->
where
(
'money_type'
,
0
)
->
whereBetween
(
'createtime'
,
[
$lastMonthStart
,
$lastMonthEnd
])
->
sum
(
'money'
));
$user
[
'financial'
][
'lastMonthExpense'
]
=
number_format
(
$lastMonthExpense
,
2
);
// 计算较上月百分比
$user
[
'financial'
][
'income_change_percent'
]
=
$lastMonthIncome
!=
0
?
number_format
((
$currentMonthIncome
-
$lastMonthIncome
)
/
$lastMonthIncome
*
100
,
2
)
:
(
$currentMonthIncome
!=
0
?
'100.00'
:
'0.00'
);
$user
[
'financial'
][
'expense_change_percent'
]
=
$lastMonthExpense
!=
0
?
number_format
((
$currentMonthExpense
-
$lastMonthExpense
)
/
$lastMonthExpense
*
100
,
2
)
:
(
$currentMonthExpense
!=
0
?
'100.00'
:
'0.00'
);
}
return
$this
->
returnMsg
(
'操作成功'
,
1
,
$user
);
return
$this
->
returnMsg
(
'操作成功'
,
1
,
$user
);
}
}
...
...
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