权益数据
Showing
7 changed files
with
114 additions
and
8 deletions
| ... | @@ -41,4 +41,12 @@ class CacheKeyTools | ... | @@ -41,4 +41,12 @@ class CacheKeyTools |
| 41 | { | 41 | { |
| 42 | return config('cache.key')['bills_settle_no']; | 42 | return config('cache.key')['bills_settle_no']; |
| 43 | } | 43 | } |
| 44 | |||
| 45 | /** | ||
| 46 | * @return mixed | ||
| 47 | */ | ||
| 48 | public static function districts() | ||
| 49 | { | ||
| 50 | return config('cache.key')['districts']; | ||
| 51 | } | ||
| 44 | } | 52 | } | ... | ... |
app/Helper/Helpers.php
0 → 100644
| 1 | <?php | ||
| 2 | |||
| 3 | |||
| 4 | if (!function_exists('data_diff')) { | ||
| 5 | /** | ||
| 6 | * Get the active class if the condition is not falsy | ||
| 7 | * | ||
| 8 | * @param $condition | ||
| 9 | * @param string $activeClass | ||
| 10 | * @param string $inactiveClass | ||
| 11 | * | ||
| 12 | * @return string | ||
| 13 | */ | ||
| 14 | function data_diff($origin, $target) { | ||
| 15 | $origin = new DateTime($origin); | ||
| 16 | $target = new DateTime($target); | ||
| 17 | $interval = $origin->diff($target); | ||
| 18 | |||
| 19 | $y = $interval->format("%y"); | ||
| 20 | $m = $interval->format("%m"); | ||
| 21 | $d = $interval->format("%d"); | ||
| 22 | $limit = ''; | ||
| 23 | |||
| 24 | if (!empty($y)) {$limit .= "{$y}年";} | ||
| 25 | if (!empty($m)) {$limit .= "{$m}个月";} | ||
| 26 | if (!empty($d)) {$limit .= "{$d}天";} | ||
| 27 | |||
| 28 | return $limit; | ||
| 29 | } | ||
| 30 | } |
| ... | @@ -182,6 +182,34 @@ class Contract extends BaseModel | ... | @@ -182,6 +182,34 @@ class Contract extends BaseModel |
| 182 | } | 182 | } |
| 183 | } | 183 | } |
| 184 | 184 | ||
| 185 | /** | ||
| 186 | * 授权区域区域 | ||
| 187 | * @return string | ||
| 188 | */ | ||
| 189 | public static function getDistrict($district_id) | ||
| 190 | { | ||
| 191 | if (empty($district_id)) return ''; | ||
| 192 | |||
| 193 | $district_ids = explode(',', $district_id); | ||
| 194 | |||
| 195 | $district_data = District::getDistricts(); | ||
| 196 | |||
| 197 | foreach ($district_ids as $id) { | ||
| 198 | $district[] = $district_data[$id] ?? ''; | ||
| 199 | } | ||
| 200 | |||
| 201 | return join('|', array_filter($district)); | ||
| 202 | } | ||
| 203 | |||
| 204 | /** | ||
| 205 | * 授权形式 | ||
| 206 | * @param $is_exclusive | ||
| 207 | * @return string | ||
| 208 | */ | ||
| 209 | public static function isExclusive($is_exclusive) | ||
| 210 | { | ||
| 211 | return $is_exclusive ? '独家' : '非独'; | ||
| 212 | } | ||
| 185 | 213 | ||
| 186 | /** | 214 | /** |
| 187 | * 分成 | 215 | * 分成 | ... | ... |
app/Models/Legal/District.php
0 → 100644
| 1 | <?php | ||
| 2 | |||
| 3 | namespace App\Models\Legal; | ||
| 4 | |||
| 5 | use App\Helper\CacheKeyTools; | ||
| 6 | use App\Models\BaseModel; | ||
| 7 | use Illuminate\Support\Facades\Cache; | ||
| 8 | |||
| 9 | /** | ||
| 10 | * Class District | ||
| 11 | * @package App\Models\Legal | ||
| 12 | */ | ||
| 13 | class District extends BaseModel | ||
| 14 | { | ||
| 15 | /** | ||
| 16 | * @return array | ||
| 17 | */ | ||
| 18 | public static function getDistricts() | ||
| 19 | { | ||
| 20 | $key = CacheKeyTools::districts(); | ||
| 21 | |||
| 22 | if (!$district = Cache::get($key)) { | ||
| 23 | $district = District::query()->pluck('name','id')->toArray(); | ||
| 24 | Cache::put($key, $district, 1440); | ||
| 25 | } | ||
| 26 | |||
| 27 | return $district; | ||
| 28 | } | ||
| 29 | } |
| ... | @@ -205,13 +205,15 @@ class MusicianSongService extends Service | ... | @@ -205,13 +205,15 @@ class MusicianSongService extends Service |
| 205 | $client = new CosHelper(); | 205 | $client = new CosHelper(); |
| 206 | 206 | ||
| 207 | $res = SongStakeholder::query()->where('song_id', $song_id)->identify() | 207 | $res = SongStakeholder::query()->where('song_id', $song_id)->identify() |
| 208 | ->with(['contract:id,cooperation_type', 'contract.stakeholderContract', 'contract.files', 'contract.files.fileInfo:id,key']) | 208 | ->with(['contract:id,cooperation_type,date_starting,date_ending,district_id,is_exclusive', 'contract.stakeholderContract', 'contract.files', 'contract.files.fileInfo:id,key']) |
| 209 | ->get()->toArray(); | 209 | ->get()->toArray(); |
| 210 | 210 | ||
| 211 | $contracts = []; | 211 | $contracts = []; |
| 212 | 212 | ||
| 213 | foreach ($res as $k=>$item) { | 213 | foreach ($res as $k=>$item) { |
| 214 | 214 | ||
| 215 | if (empty($item['contract'])) continue; | ||
| 216 | |||
| 215 | $files = []; | 217 | $files = []; |
| 216 | 218 | ||
| 217 | if (!empty($item['contract']['files'])) { | 219 | if (!empty($item['contract']['files'])) { |
| ... | @@ -235,11 +237,16 @@ class MusicianSongService extends Service | ... | @@ -235,11 +237,16 @@ class MusicianSongService extends Service |
| 235 | } | 237 | } |
| 236 | 238 | ||
| 237 | $contracts[$k] = [ | 239 | $contracts[$k] = [ |
| 238 | 'contract_id'=>$item['contract_id'], | 240 | 'contract_id' => $item['contract_id'], |
| 239 | 'files' => $files, | 241 | 'files' => $files, |
| 240 | 'cooperation_type'=>$item['contract']['cooperation_type'] ?? '', | 242 | 'cooperation_type' => $item['contract']['cooperation_type'], |
| 241 | 'right'=> Contract::getModel($item['contract']['cooperation_type'] ?? '', $right), | 243 | 'right' => Contract::getModel($item['contract']['cooperation_type'], $right), |
| 242 | 'role'=> array_unique($role), | 244 | 'role' => array_unique($role), |
| 245 | 'date_starting' => $item['contract']['date_starting'], | ||
| 246 | 'date_ending' => is_null($item['contract']['date_ending']) ? '永久' : $item['contract']['date_ending'], | ||
| 247 | 'limit' => is_null($item['contract']['date_ending']) ? '永久' : data_diff($item['contract']['date_starting'], $item['contract']['date_ending']), | ||
| 248 | 'district' => Contract::getDistrict($item['contract']['district_id']), | ||
| 249 | 'exclusive' => Contract::isExclusive($item['contract']['is_exclusive']), | ||
| 243 | ]; | 250 | ]; |
| 244 | } | 251 | } |
| 245 | 252 | ... | ... |
| ... | @@ -30,7 +30,10 @@ | ... | @@ -30,7 +30,10 @@ |
| 30 | "App\\": "app/", | 30 | "App\\": "app/", |
| 31 | "Database\\Factories\\": "database/factories/", | 31 | "Database\\Factories\\": "database/factories/", |
| 32 | "Database\\Seeders\\": "database/seeders/" | 32 | "Database\\Seeders\\": "database/seeders/" |
| 33 | } | 33 | }, |
| 34 | "files":[ | ||
| 35 | "app/Helper/Helpers.php" | ||
| 36 | ] | ||
| 34 | }, | 37 | }, |
| 35 | "autoload-dev": { | 38 | "autoload-dev": { |
| 36 | "psr-4": { | 39 | "psr-4": { | ... | ... |
| ... | @@ -112,7 +112,8 @@ return [ | ... | @@ -112,7 +112,8 @@ return [ |
| 112 | 'bills_sync' => 'bills:sync', | 112 | 'bills_sync' => 'bills:sync', |
| 113 | 'channelname' => 'channelname', | 113 | 'channelname' => 'channelname', |
| 114 | 'bills_confirm' => 'serial:#serial_no#', | 114 | 'bills_confirm' => 'serial:#serial_no#', |
| 115 | 'bills_settle_no' => 'bills:settle:no' | 115 | 'bills_settle_no' => 'bills:settle:no', |
| 116 | 'districts' => 'districts', | ||
| 116 | ] | 117 | ] |
| 117 | 118 | ||
| 118 | ]; | 119 | ]; | ... | ... |
-
Please register or sign in to post a comment