歌曲绑定发行
Showing
4 changed files
with
56 additions
and
0 deletions
| ... | @@ -54,4 +54,13 @@ class MusicianSongController extends Controller | ... | @@ -54,4 +54,13 @@ class MusicianSongController extends Controller |
| 54 | return $this->musicianSongService->right($song_id); | 54 | return $this->musicianSongService->right($song_id); |
| 55 | } | 55 | } |
| 56 | 56 | ||
| 57 | /** | ||
| 58 | * 歌曲权益 | ||
| 59 | * @return \Illuminate\Http\JsonResponse | ||
| 60 | */ | ||
| 61 | public function songRights() | ||
| 62 | { | ||
| 63 | return $this->musicianSongService->songRights(); | ||
| 64 | } | ||
| 65 | |||
| 57 | } | 66 | } | ... | ... |
| ... | @@ -30,4 +30,12 @@ class Song extends BaseModel | ... | @@ -30,4 +30,12 @@ class Song extends BaseModel |
| 30 | return $this->hasOne(SongFile::class, 'song_id')->where('type', 4); | 30 | return $this->hasOne(SongFile::class, 'song_id')->where('type', 4); |
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | /** | ||
| 34 | * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany | ||
| 35 | */ | ||
| 36 | public function contracts() | ||
| 37 | { | ||
| 38 | return $this->belongsToMany(Contract::class, 'contract_song', 'song_id', 'contract_id'); | ||
| 39 | } | ||
| 40 | |||
| 33 | } | 41 | } | ... | ... |
| ... | @@ -21,6 +21,43 @@ use Carbon\Carbon; | ... | @@ -21,6 +21,43 @@ use Carbon\Carbon; |
| 21 | class MusicianSongService extends Service | 21 | class MusicianSongService extends Service |
| 22 | { | 22 | { |
| 23 | /** | 23 | /** |
| 24 | * 分贝授权发行歌曲 - 绑定版权数据 - 对应的权益 | ||
| 25 | * @return \Illuminate\Http\JsonResponse | ||
| 26 | */ | ||
| 27 | public function songRights() | ||
| 28 | { | ||
| 29 | $song_ids = array_filter(array_unique(SongStakeholder::query()->identify()->pluck('song_id')->toArray())); | ||
| 30 | if (empty($song_ids)) return Response::success(); | ||
| 31 | |||
| 32 | $res = Song::query()->with(['contractDetail'])->whereIn('id', $song_ids)->select(['id', 'custom_id'])->get()->toArray(); | ||
| 33 | $data = []; | ||
| 34 | |||
| 35 | foreach ($res as $item) { | ||
| 36 | if (in_array($item['custom_id'], $this->request->custom_ids) && !empty($item['contract_detail'])) { | ||
| 37 | |||
| 38 | $role = []; | ||
| 39 | |||
| 40 | if ($clause_res = array_column($item['contract_detail'], 'clause')) { | ||
| 41 | foreach ($clause_res as $clause_res_item) { | ||
| 42 | if($clause = json_decode($clause_res_item)) { | ||
| 43 | foreach ($clause as $clause_item) { | ||
| 44 | if (in_array($clause_item->stakeholder_id, $this->stakeholder_ids)) { | ||
| 45 | $role = array_merge($role, Contract::transformRole($clause_item->right_type)); | ||
| 46 | } | ||
| 47 | } | ||
| 48 | } | ||
| 49 | } | ||
| 50 | } | ||
| 51 | |||
| 52 | $data[$item['custom_id']] = $role; | ||
| 53 | } | ||
| 54 | } | ||
| 55 | |||
| 56 | return Response::success($data); | ||
| 57 | } | ||
| 58 | |||
| 59 | |||
| 60 | /** | ||
| 24 | * 授权发行歌曲 | 61 | * 授权发行歌曲 |
| 25 | * @return \Illuminate\Http\JsonResponse | 62 | * @return \Illuminate\Http\JsonResponse |
| 26 | */ | 63 | */ | ... | ... |
| ... | @@ -20,6 +20,8 @@ Route::group([], function (){ | ... | @@ -20,6 +20,8 @@ Route::group([], function (){ |
| 20 | 20 | ||
| 21 | Route::get('musician_song/{song_id}', 'MusicianSongController@detail'); | 21 | Route::get('musician_song/{song_id}', 'MusicianSongController@detail'); |
| 22 | Route::get('musician_song/{song_id}/right', 'MusicianSongController@right'); | 22 | Route::get('musician_song/{song_id}/right', 'MusicianSongController@right'); |
| 23 | Route::post('musician_song/rights', 'MusicianSongController@songRights'); | ||
| 24 | |||
| 23 | //经纪约列表 | 25 | //经纪约列表 |
| 24 | Route::get('musician_treaty', 'MusicianTreatyController@list'); | 26 | Route::get('musician_treaty', 'MusicianTreatyController@list'); |
| 25 | //我的合约 | 27 | //我的合约 | ... | ... |
-
Please register or sign in to post a comment