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
1aedcc30
...
1aedcc30d17b8332a12e176e8d7cc793cf022ece
authored
2021-11-30 16:33:26 +0800
by
lemon
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
歌曲绑定发行
1 parent
7b931681
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
56 additions
and
0 deletions
app/Http/Controllers/Musician/MusicianSongController.php
app/Models/Legal/Song.php
app/Services/MusicianSongService.php
routes/api.php
app/Http/Controllers/Musician/MusicianSongController.php
View file @
1aedcc3
...
...
@@ -54,4 +54,13 @@ class MusicianSongController extends Controller
return
$this
->
musicianSongService
->
right
(
$song_id
);
}
/**
* 歌曲权益
* @return \Illuminate\Http\JsonResponse
*/
public
function
songRights
()
{
return
$this
->
musicianSongService
->
songRights
();
}
}
...
...
app/Models/Legal/Song.php
View file @
1aedcc3
...
...
@@ -30,4 +30,12 @@ class Song extends BaseModel
return
$this
->
hasOne
(
SongFile
::
class
,
'song_id'
)
->
where
(
'type'
,
4
);
}
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
*/
public
function
contracts
()
{
return
$this
->
belongsToMany
(
Contract
::
class
,
'contract_song'
,
'song_id'
,
'contract_id'
);
}
}
...
...
app/Services/MusicianSongService.php
View file @
1aedcc3
...
...
@@ -21,6 +21,43 @@ use Carbon\Carbon;
class
MusicianSongService
extends
Service
{
/**
* 分贝授权发行歌曲 - 绑定版权数据 - 对应的权益
* @return \Illuminate\Http\JsonResponse
*/
public
function
songRights
()
{
$song_ids
=
array_filter
(
array_unique
(
SongStakeholder
::
query
()
->
identify
()
->
pluck
(
'song_id'
)
->
toArray
()));
if
(
empty
(
$song_ids
))
return
Response
::
success
();
$res
=
Song
::
query
()
->
with
([
'contractDetail'
])
->
whereIn
(
'id'
,
$song_ids
)
->
select
([
'id'
,
'custom_id'
])
->
get
()
->
toArray
();
$data
=
[];
foreach
(
$res
as
$item
)
{
if
(
in_array
(
$item
[
'custom_id'
],
$this
->
request
->
custom_ids
)
&&
!
empty
(
$item
[
'contract_detail'
]))
{
$role
=
[];
if
(
$clause_res
=
array_column
(
$item
[
'contract_detail'
],
'clause'
))
{
foreach
(
$clause_res
as
$clause_res_item
)
{
if
(
$clause
=
json_decode
(
$clause_res_item
))
{
foreach
(
$clause
as
$clause_item
)
{
if
(
in_array
(
$clause_item
->
stakeholder_id
,
$this
->
stakeholder_ids
))
{
$role
=
array_merge
(
$role
,
Contract
::
transformRole
(
$clause_item
->
right_type
));
}
}
}
}
}
$data
[
$item
[
'custom_id'
]]
=
$role
;
}
}
return
Response
::
success
(
$data
);
}
/**
* 授权发行歌曲
* @return \Illuminate\Http\JsonResponse
*/
...
...
routes/api.php
View file @
1aedcc3
...
...
@@ -20,6 +20,8 @@ Route::group([], function (){
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