Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Cong.Zhao
/
musician-api.hikoon.com
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
d883c992
...
d883c9920d4577b55b608d6af0d93dc6bd5a8373
authored
2021-08-06 17:41:25 +0800
by
lemon
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
*
1 parent
efa0dbcd
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
15 deletions
app/Services/MusicianIncomeService.php
app/Services/MusicianIncomeService.php
View file @
d883c99
...
...
@@ -18,33 +18,43 @@ class MusicianIncomeService extends Service
*/
public
function
income
()
{
$start_month
=
$this
->
request
->
input
(
'start'
);
$end_month
=
$this
->
request
->
input
(
'end'
);
$res
=
StakeholderSongCollate
::
query
()
->
custom
(
$this
->
request
->
only
([
'song_id'
]))
->
identify
()
->
groupBy
(
'month'
)
->
orderBy
(
'month'
)
->
selectRaw
(
'month, sum(share_amount) as income'
)
->
get
()
->
toArray
();
->
groupBy
(
'month'
)
->
orderByDesc
(
'month'
)
->
selectRaw
(
'month, sum(share_amount) as income'
)
->
get
()
->
toArray
();
$stat_income
=
$months
=
[];
$total_income
=
'0.00'
;
if
(
empty
(
$res
))
{
return
Response
::
success
([
'list'
=>
$stat_income
,
'total_income'
=>
$total_income
]);
}
$months
[]
=
current
(
$res
)[
'month'
];
for
(
$i
=
1
;
$i
<
6
;
$i
++
)
{
$months
[]
=
date
(
'Ym'
,
strtotime
(
end
(
$months
)
.
'01 -1 month'
));
}
$stat_income
=
[];
$total_income
=
'0'
;
foreach
(
$res
as
$item
)
{
if
(
empty
(
$start_month
)
||
empty
(
$end_month
))
{
if
(
count
(
$stat_income
)
<
7
)
{
$stat_income
[]
=
$item
;
continue
;
}
break
;
}
else
{
if
(
$item
[
'month'
]
>=
$start_month
&&
$item
[
'month'
]
<=
$end_month
)
{
$stat_income
[]
=
$item
;
if
(
count
(
$stat_income
)
>=
6
)
break
;
$stat_income
[
$item
[
'month'
]]
=
$item
;
$total_income
=
bcadd
(
$total_income
,
$item
[
'income'
],
self
::
DECIMAL
);
}
}
$total_income
=
bcadd
(
$total_income
,
$item
->
income
,
self
::
DECIMAL
);
foreach
(
$months
as
$month
)
{
if
(
!
isset
(
$stat_income
[
$month
]))
{
$stat_income
[
$month
]
=
[
'month'
=>
$month
,
'income'
=>
0.00
];
}
}
return
Response
::
success
([
'list'
=>
$stat_income
,
'total_income'
=>
$total_income
]);
return
Response
::
success
([
'list'
=>
array_values
(
$stat_income
)
,
'total_income'
=>
$total_income
]);
}
/**
...
...
Please
register
or
sign in
to post a comment