授权发行歌曲指数统计
Showing
3 changed files
with
53 additions
and
3 deletions
| ... | @@ -63,4 +63,13 @@ class MusicianSongController extends Controller | ... | @@ -63,4 +63,13 @@ class MusicianSongController extends Controller |
| 63 | return $this->musicianSongService->songRights(); | 63 | return $this->musicianSongService->songRights(); |
| 64 | } | 64 | } |
| 65 | 65 | ||
| 66 | /** | ||
| 67 | * 指数统计 | ||
| 68 | * @return \Illuminate\Http\JsonResponse | ||
| 69 | */ | ||
| 70 | public function releaseSongCnt() | ||
| 71 | { | ||
| 72 | return $this->musicianSongService->releaseSongCnt(); | ||
| 73 | } | ||
| 74 | |||
| 66 | } | 75 | } | ... | ... |
| ... | @@ -21,7 +21,6 @@ use Carbon\Carbon; | ... | @@ -21,7 +21,6 @@ use Carbon\Carbon; |
| 21 | class MusicianSongService extends Service | 21 | class MusicianSongService extends Service |
| 22 | { | 22 | { |
| 23 | /** | 23 | /** |
| 24 | * 分贝授权发行歌曲 - 绑定版权数据 - 对应的权益 | ||
| 25 | * @return \Illuminate\Http\JsonResponse | 24 | * @return \Illuminate\Http\JsonResponse |
| 26 | */ | 25 | */ |
| 27 | public function songRights() | 26 | public function songRights() |
| ... | @@ -56,6 +55,48 @@ class MusicianSongService extends Service | ... | @@ -56,6 +55,48 @@ class MusicianSongService extends Service |
| 56 | return Response::success($data); | 55 | return Response::success($data); |
| 57 | } | 56 | } |
| 58 | 57 | ||
| 58 | /** | ||
| 59 | * 授权发行歌曲指数统计 | ||
| 60 | * @return \Illuminate\Http\JsonResponse | ||
| 61 | */ | ||
| 62 | public function releaseSongCnt() | ||
| 63 | { | ||
| 64 | $cnt = [ | ||
| 65 | 'favCnt' => 0.00, //收藏指数 - 月 | ||
| 66 | 'playCnt' => 0.00, //播放指数 - 月 | ||
| 67 | 'downloadCnt' => 0.00, //下载指数 - 月 | ||
| 68 | 'favCnt_week' => 0.00, //收藏指数 - 周 | ||
| 69 | 'playCnt_week' => 0.00, //播放指数 - 周 | ||
| 70 | 'downloadCnt_week' => 0.00, //下载指数 - 周 | ||
| 71 | 'favCnt_years' => 0.00, //收藏指数 - 年 | ||
| 72 | 'playCnt_years' => 0.00, //播放指数 - 年 | ||
| 73 | 'downloadCnt_years' => 0.00 //下载指数 - 年 | ||
| 74 | ]; | ||
| 75 | |||
| 76 | $song_ids = array_filter(array_unique(SongStakeholder::query()->identify()->pluck('song_id')->toArray())); | ||
| 77 | if (empty($song_ids)) return Response::success($cnt); | ||
| 78 | |||
| 79 | $res = SongsIp::query()->with('songsIpExt:song_ip_id,favCnt,playCnt,downloadCnt,favCnt_week,playCnt_week,downloadCnt_week,favCnt_years,playCnt_years,downloadCnt_years') | ||
| 80 | ->join('songs as s', 'songs_ip.song_id', '=', 's.id') | ||
| 81 | ->where('auth_channel', 1)->whereIn('s.id', $song_ids)->select(['s.id as sid', 'songs_ip.id as id', 'songs_ip.song_id'])->get(); | ||
| 82 | |||
| 83 | foreach ($res as $item) { | ||
| 84 | if (empty($item->songsIpExt)) continue; | ||
| 85 | |||
| 86 | $cnt['favCnt'] = bcadd($cnt['favCnt'], $item->songsIpExt->favCnt, 2); | ||
| 87 | $cnt['playCnt'] = bcadd($cnt['playCnt'], $item->songsIpExt->playCnt, 2); | ||
| 88 | $cnt['downloadCnt'] = bcadd($cnt['downloadCnt'], $item->songsIpExt->downloadCnt, 2); | ||
| 89 | $cnt['favCnt_week'] = bcadd($cnt['favCnt_week'], $item->songsIpExt->favCnt_week, 2); | ||
| 90 | $cnt['playCnt_week'] = bcadd($cnt['playCnt_week'], $item->songsIpExt->playCnt_week, 2); | ||
| 91 | $cnt['downloadCnt_week'] = bcadd($cnt['downloadCnt_week'], $item->songsIpExt->downloadCnt_week, 2); | ||
| 92 | $cnt['favCnt_years'] = bcadd($cnt['favCnt_years'], $item->songsIpExt->favCnt_years, 2); | ||
| 93 | $cnt['playCnt_years'] = bcadd($cnt['playCnt_years'], $item->songsIpExt->playCnt_years, 2); | ||
| 94 | $cnt['downloadCnt_years'] = bcadd($cnt['downloadCnt_years'], $item->songsIpExt->downloadCnt_years, 2); | ||
| 95 | } | ||
| 96 | |||
| 97 | return Response::success($cnt); | ||
| 98 | } | ||
| 99 | |||
| 59 | 100 | ||
| 60 | /** | 101 | /** |
| 61 | * 授权发行歌曲 | 102 | * 授权发行歌曲 | ... | ... |
| ... | @@ -17,10 +17,10 @@ Route::group([], function (){ | ... | @@ -17,10 +17,10 @@ Route::group([], function (){ |
| 17 | 17 | ||
| 18 | //首页-音乐人 | 18 | //首页-音乐人 |
| 19 | Route::get('musician_song', 'MusicianSongController@list'); | 19 | Route::get('musician_song', 'MusicianSongController@list'); |
| 20 | 20 | Route::get('musician_song/releaseSongCnt', 'MusicianSongController@releaseSongCnt'); | |
| 21 | Route::post('musician_song/rights', 'MusicianSongController@songRights'); | ||
| 21 | Route::get('musician_song/{song_id}', 'MusicianSongController@detail'); | 22 | Route::get('musician_song/{song_id}', 'MusicianSongController@detail'); |
| 22 | Route::get('musician_song/{song_id}/right', 'MusicianSongController@right'); | 23 | Route::get('musician_song/{song_id}/right', 'MusicianSongController@right'); |
| 23 | Route::post('musician_song/rights', 'MusicianSongController@songRights'); | ||
| 24 | 24 | ||
| 25 | //经纪约列表 | 25 | //经纪约列表 |
| 26 | Route::get('musician_treaty', 'MusicianTreatyController@list'); | 26 | Route::get('musician_treaty', 'MusicianTreatyController@list'); | ... | ... |
-
Please register or sign in to post a comment