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
6d0f19ce
...
6d0f19ce827e9817fa05d0f55a55920e02f0f996
authored
2021-12-01 17:09:56 +0800
by
lemon
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
权益数据
1 parent
6fe52fec
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
114 additions
and
8 deletions
app/Helper/CacheKeyTools.php
app/Helper/Helpers.php
app/Models/Legal/Contract.php
app/Models/Legal/District.php
app/Services/MusicianSongService.php
composer.json
config/cache.php
app/Helper/CacheKeyTools.php
View file @
6d0f19c
...
...
@@ -41,4 +41,12 @@ class CacheKeyTools
{
return
config
(
'cache.key'
)[
'bills_settle_no'
];
}
/**
* @return mixed
*/
public
static
function
districts
()
{
return
config
(
'cache.key'
)[
'districts'
];
}
}
...
...
app/Helper/Helpers.php
0 → 100644
View file @
6d0f19c
<?php
if
(
!
function_exists
(
'data_diff'
))
{
/**
* Get the active class if the condition is not falsy
*
* @param $condition
* @param string $activeClass
* @param string $inactiveClass
*
* @return string
*/
function
data_diff
(
$origin
,
$target
)
{
$origin
=
new
DateTime
(
$origin
);
$target
=
new
DateTime
(
$target
);
$interval
=
$origin
->
diff
(
$target
);
$y
=
$interval
->
format
(
"%y"
);
$m
=
$interval
->
format
(
"%m"
);
$d
=
$interval
->
format
(
"%d"
);
$limit
=
''
;
if
(
!
empty
(
$y
))
{
$limit
.=
"
{
$y
}
年"
;}
if
(
!
empty
(
$m
))
{
$limit
.=
"
{
$m
}
个月"
;}
if
(
!
empty
(
$d
))
{
$limit
.=
"
{
$d
}
天"
;}
return
$limit
;
}
}
app/Models/Legal/Contract.php
View file @
6d0f19c
...
...
@@ -182,6 +182,34 @@ class Contract extends BaseModel
}
}
/**
* 授权区域区域
* @return string
*/
public
static
function
getDistrict
(
$district_id
)
{
if
(
empty
(
$district_id
))
return
''
;
$district_ids
=
explode
(
','
,
$district_id
);
$district_data
=
District
::
getDistricts
();
foreach
(
$district_ids
as
$id
)
{
$district
[]
=
$district_data
[
$id
]
??
''
;
}
return
join
(
'|'
,
array_filter
(
$district
));
}
/**
* 授权形式
* @param $is_exclusive
* @return string
*/
public
static
function
isExclusive
(
$is_exclusive
)
{
return
$is_exclusive
?
'独家'
:
'非独'
;
}
/**
* 分成
...
...
app/Models/Legal/District.php
0 → 100644
View file @
6d0f19c
<?php
namespace
App\Models\Legal
;
use
App\Helper\CacheKeyTools
;
use
App\Models\BaseModel
;
use
Illuminate\Support\Facades\Cache
;
/**
* Class District
* @package App\Models\Legal
*/
class
District
extends
BaseModel
{
/**
* @return array
*/
public
static
function
getDistricts
()
{
$key
=
CacheKeyTools
::
districts
();
if
(
!
$district
=
Cache
::
get
(
$key
))
{
$district
=
District
::
query
()
->
pluck
(
'name'
,
'id'
)
->
toArray
();
Cache
::
put
(
$key
,
$district
,
1440
);
}
return
$district
;
}
}
app/Services/MusicianSongService.php
View file @
6d0f19c
...
...
@@ -205,13 +205,15 @@ class MusicianSongService extends Service
$client
=
new
CosHelper
();
$res
=
SongStakeholder
::
query
()
->
where
(
'song_id'
,
$song_id
)
->
identify
()
->
with
([
'contract:id,cooperation_type'
,
'contract.stakeholderContract'
,
'contract.files'
,
'contract.files.fileInfo:id,key'
])
->
with
([
'contract:id,cooperation_type
,date_starting,date_ending,district_id,is_exclusive
'
,
'contract.stakeholderContract'
,
'contract.files'
,
'contract.files.fileInfo:id,key'
])
->
get
()
->
toArray
();
$contracts
=
[];
foreach
(
$res
as
$k
=>
$item
)
{
if
(
empty
(
$item
[
'contract'
]))
continue
;
$files
=
[];
if
(
!
empty
(
$item
[
'contract'
][
'files'
]))
{
...
...
@@ -235,11 +237,16 @@ class MusicianSongService extends Service
}
$contracts
[
$k
]
=
[
'contract_id'
=>
$item
[
'contract_id'
],
'files'
=>
$files
,
'cooperation_type'
=>
$item
[
'contract'
][
'cooperation_type'
]
??
''
,
'right'
=>
Contract
::
getModel
(
$item
[
'contract'
][
'cooperation_type'
]
??
''
,
$right
),
'role'
=>
array_unique
(
$role
),
'contract_id'
=>
$item
[
'contract_id'
],
'files'
=>
$files
,
'cooperation_type'
=>
$item
[
'contract'
][
'cooperation_type'
],
'right'
=>
Contract
::
getModel
(
$item
[
'contract'
][
'cooperation_type'
],
$right
),
'role'
=>
array_unique
(
$role
),
'date_starting'
=>
$item
[
'contract'
][
'date_starting'
],
'date_ending'
=>
is_null
(
$item
[
'contract'
][
'date_ending'
])
?
'永久'
:
$item
[
'contract'
][
'date_ending'
],
'limit'
=>
is_null
(
$item
[
'contract'
][
'date_ending'
])
?
'永久'
:
data_diff
(
$item
[
'contract'
][
'date_starting'
],
$item
[
'contract'
][
'date_ending'
]),
'district'
=>
Contract
::
getDistrict
(
$item
[
'contract'
][
'district_id'
]),
'exclusive'
=>
Contract
::
isExclusive
(
$item
[
'contract'
][
'is_exclusive'
]),
];
}
...
...
composer.json
View file @
6d0f19c
...
...
@@ -30,7 +30,10 @@
"App
\\
"
:
"app/"
,
"Database
\\
Factories
\\
"
:
"database/factories/"
,
"Database
\\
Seeders
\\
"
:
"database/seeders/"
}
},
"files"
:[
"app/Helper/Helpers.php"
]
},
"autoload-dev"
:
{
"psr-4"
:
{
...
...
config/cache.php
View file @
6d0f19c
...
...
@@ -112,7 +112,8 @@ return [
'bills_sync'
=>
'bills:sync'
,
'channelname'
=>
'channelname'
,
'bills_confirm'
=>
'serial:#serial_no#'
,
'bills_settle_no'
=>
'bills:settle:no'
'bills_settle_no'
=>
'bills:settle:no'
,
'districts'
=>
'districts'
,
]
];
...
...
Please
register
or
sign in
to post a comment