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
e77ede5c
...
e77ede5c490e821bd15742ceb019fc3c80e726ff
authored
2021-12-01 13:40:52 +0800
by
lemon
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
授权发行歌曲指数统计
1 parent
1aedcc30
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
3 deletions
app/Http/Controllers/Musician/MusicianSongController.php
app/Services/MusicianSongService.php
routes/api.php
app/Http/Controllers/Musician/MusicianSongController.php
View file @
e77ede5
...
...
@@ -63,4 +63,13 @@ class MusicianSongController extends Controller
return
$this
->
musicianSongService
->
songRights
();
}
/**
* 指数统计
* @return \Illuminate\Http\JsonResponse
*/
public
function
releaseSongCnt
()
{
return
$this
->
musicianSongService
->
releaseSongCnt
();
}
}
...
...
app/Services/MusicianSongService.php
View file @
e77ede5
...
...
@@ -21,7 +21,6 @@ use Carbon\Carbon;
class
MusicianSongService
extends
Service
{
/**
* 分贝授权发行歌曲 - 绑定版权数据 - 对应的权益
* @return \Illuminate\Http\JsonResponse
*/
public
function
songRights
()
...
...
@@ -56,6 +55,48 @@ class MusicianSongService extends Service
return
Response
::
success
(
$data
);
}
/**
* 授权发行歌曲指数统计
* @return \Illuminate\Http\JsonResponse
*/
public
function
releaseSongCnt
()
{
$cnt
=
[
'favCnt'
=>
0.00
,
//收藏指数 - 月
'playCnt'
=>
0.00
,
//播放指数 - 月
'downloadCnt'
=>
0.00
,
//下载指数 - 月
'favCnt_week'
=>
0.00
,
//收藏指数 - 周
'playCnt_week'
=>
0.00
,
//播放指数 - 周
'downloadCnt_week'
=>
0.00
,
//下载指数 - 周
'favCnt_years'
=>
0.00
,
//收藏指数 - 年
'playCnt_years'
=>
0.00
,
//播放指数 - 年
'downloadCnt_years'
=>
0.00
//下载指数 - 年
];
$song_ids
=
array_filter
(
array_unique
(
SongStakeholder
::
query
()
->
identify
()
->
pluck
(
'song_id'
)
->
toArray
()));
if
(
empty
(
$song_ids
))
return
Response
::
success
(
$cnt
);
$res
=
SongsIp
::
query
()
->
with
(
'songsIpExt:song_ip_id,favCnt,playCnt,downloadCnt,favCnt_week,playCnt_week,downloadCnt_week,favCnt_years,playCnt_years,downloadCnt_years'
)
->
join
(
'songs as s'
,
'songs_ip.song_id'
,
'='
,
's.id'
)
->
where
(
'auth_channel'
,
1
)
->
whereIn
(
's.id'
,
$song_ids
)
->
select
([
's.id as sid'
,
'songs_ip.id as id'
,
'songs_ip.song_id'
])
->
get
();
foreach
(
$res
as
$item
)
{
if
(
empty
(
$item
->
songsIpExt
))
continue
;
$cnt
[
'favCnt'
]
=
bcadd
(
$cnt
[
'favCnt'
],
$item
->
songsIpExt
->
favCnt
,
2
);
$cnt
[
'playCnt'
]
=
bcadd
(
$cnt
[
'playCnt'
],
$item
->
songsIpExt
->
playCnt
,
2
);
$cnt
[
'downloadCnt'
]
=
bcadd
(
$cnt
[
'downloadCnt'
],
$item
->
songsIpExt
->
downloadCnt
,
2
);
$cnt
[
'favCnt_week'
]
=
bcadd
(
$cnt
[
'favCnt_week'
],
$item
->
songsIpExt
->
favCnt_week
,
2
);
$cnt
[
'playCnt_week'
]
=
bcadd
(
$cnt
[
'playCnt_week'
],
$item
->
songsIpExt
->
playCnt_week
,
2
);
$cnt
[
'downloadCnt_week'
]
=
bcadd
(
$cnt
[
'downloadCnt_week'
],
$item
->
songsIpExt
->
downloadCnt_week
,
2
);
$cnt
[
'favCnt_years'
]
=
bcadd
(
$cnt
[
'favCnt_years'
],
$item
->
songsIpExt
->
favCnt_years
,
2
);
$cnt
[
'playCnt_years'
]
=
bcadd
(
$cnt
[
'playCnt_years'
],
$item
->
songsIpExt
->
playCnt_years
,
2
);
$cnt
[
'downloadCnt_years'
]
=
bcadd
(
$cnt
[
'downloadCnt_years'
],
$item
->
songsIpExt
->
downloadCnt_years
,
2
);
}
return
Response
::
success
(
$cnt
);
}
/**
* 授权发行歌曲
...
...
routes/api.php
View file @
e77ede5
...
...
@@ -17,10 +17,10 @@ Route::group([], function (){
//首页-音乐人
Route
::
get
(
'musician_song'
,
'MusicianSongController@list'
);
Route
::
get
(
'musician_song/releaseSongCnt'
,
'MusicianSongController@releaseSongCnt'
);
Route
::
post
(
'musician_song/rights'
,
'MusicianSongController@songRights'
);
Route
::
get
(
'musician_song/{song_id}'
,
'MusicianSongController@detail'
);
Route
::
get
(
'musician_song/{song_id}/right'
,
'MusicianSongController@right'
);
Route
::
post
(
'musician_song/rights'
,
'MusicianSongController@songRights'
);
//经纪约列表
Route
::
get
(
'musician_treaty'
,
'MusicianTreatyController@list'
);
...
...
Please
register
or
sign in
to post a comment