*
Showing
5 changed files
with
36 additions
and
3 deletions
... | @@ -2,6 +2,7 @@ | ... | @@ -2,6 +2,7 @@ |
2 | 2 | ||
3 | namespace App\Models; | 3 | namespace App\Models; |
4 | 4 | ||
5 | use DateTimeInterface; | ||
5 | use Illuminate\Database\Eloquent\Builder; | 6 | use Illuminate\Database\Eloquent\Builder; |
6 | use Illuminate\Database\Eloquent\Factories\HasFactory; | 7 | use Illuminate\Database\Eloquent\Factories\HasFactory; |
7 | use Illuminate\Database\Eloquent\Model; | 8 | use Illuminate\Database\Eloquent\Model; |
... | @@ -14,6 +15,11 @@ class BaseModel extends Model | ... | @@ -14,6 +15,11 @@ class BaseModel extends Model |
14 | { | 15 | { |
15 | use HasFactory; | 16 | use HasFactory; |
16 | 17 | ||
18 | public function serializeDate(DateTimeInterface $date) | ||
19 | { | ||
20 | return $date->format('Y-m-d H:i:s'); | ||
21 | } | ||
22 | |||
17 | /** | 23 | /** |
18 | * @return string | 24 | * @return string |
19 | */ | 25 | */ | ... | ... |
app/Models/Legal/SongsIpExts.php
0 → 100644
1 | <?php | ||
2 | |||
3 | namespace App\Models\Legal; | ||
4 | |||
5 | use App\Models\BaseModel; | ||
6 | use Illuminate\Database\Eloquent\Factories\HasFactory; | ||
7 | |||
8 | /** | ||
9 | * Class SongsIpExts | ||
10 | * @package App\Models\Legal | ||
11 | */ | ||
12 | class SongsIpExts extends BaseModel | ||
13 | { | ||
14 | use HasFactory; | ||
15 | |||
16 | public $table = 'songs_ip_exts'; | ||
17 | |||
18 | } |
... | @@ -7,6 +7,7 @@ use App\Helper\Response; | ... | @@ -7,6 +7,7 @@ use App\Helper\Response; |
7 | use App\Models\Legal\Contract; | 7 | use App\Models\Legal\Contract; |
8 | use App\Models\Legal\Song; | 8 | use App\Models\Legal\Song; |
9 | use App\Models\Legal\SongsIp; | 9 | use App\Models\Legal\SongsIp; |
10 | use App\Models\Legal\SongsIpExts; | ||
10 | use App\Models\Legal\SongStakeholder; | 11 | use App\Models\Legal\SongStakeholder; |
11 | use App\Models\Legal\StakeholderSongCollate; | 12 | use App\Models\Legal\StakeholderSongCollate; |
12 | use Carbon\Carbon; | 13 | use Carbon\Carbon; |
... | @@ -31,9 +32,14 @@ class MusicianSongService extends Service | ... | @@ -31,9 +32,14 @@ class MusicianSongService extends Service |
31 | $songip_table = SongsIp::table(); | 32 | $songip_table = SongsIp::table(); |
32 | 33 | ||
33 | $res = Song::query()->join($songip_table, "{$song_table}.id", '=', "{$songip_table}.song_id") | 34 | $res = Song::query()->join($songip_table, "{$song_table}.id", '=', "{$songip_table}.song_id") |
34 | ->with(['contractDetail', 'coverResource'])->whereIn("{$songip_table}.song_id", $song_ids)->select(["{$song_table}.id", 'publish_song']) | 35 | ->with(['contractDetail', 'coverResource'])->whereIn("{$songip_table}.song_id", $song_ids)->select(["{$song_table}.id", "{$songip_table}.id as sp_id", 'publish_song']) |
35 | ->groupBy(["song_id"])->paginate($this->pageSize); | 36 | ->groupBy(["song_id"])->paginate($this->pageSize); |
36 | 37 | ||
38 | $sp_exts = []; | ||
39 | if ($sp_ids = array_column($res->items(), 'sp_id')) { | ||
40 | $sp_exts = SongsIpExts::query()->whereIn('song_ip_id', $sp_ids)->get()->keyBy('song_ip_id'); | ||
41 | } | ||
42 | |||
37 | foreach ($res as &$item) { | 43 | foreach ($res as &$item) { |
38 | 44 | ||
39 | list($name, $singer) = explode('|', $item->publish_song); | 45 | list($name, $singer) = explode('|', $item->publish_song); |
... | @@ -41,6 +47,7 @@ class MusicianSongService extends Service | ... | @@ -41,6 +47,7 @@ class MusicianSongService extends Service |
41 | $item->setAttribute('name', $name); | 47 | $item->setAttribute('name', $name); |
42 | $item->setAttribute('singer', $singer); | 48 | $item->setAttribute('singer', $singer); |
43 | $item->setAttribute('cover', empty($item->coverResource) ? '' : $item->coverResource->url); | 49 | $item->setAttribute('cover', empty($item->coverResource) ? '' : $item->coverResource->url); |
50 | $item->setAttribute('ext', $sp_exts[$item->sp_id] ?? []); | ||
44 | 51 | ||
45 | $tmp = $item->toArray(); | 52 | $tmp = $item->toArray(); |
46 | if (empty($tmp['contract_detail'])) { | 53 | if (empty($tmp['contract_detail'])) { | ... | ... |
... | @@ -2,7 +2,6 @@ | ... | @@ -2,7 +2,6 @@ |
2 | 2 | ||
3 | namespace App\Services; | 3 | namespace App\Services; |
4 | 4 | ||
5 | |||
6 | use App\Helper\Response; | 5 | use App\Helper\Response; |
7 | use App\Models\Legal\StakeholderIncomeByPayer; | 6 | use App\Models\Legal\StakeholderIncomeByPayer; |
8 | 7 | ||
... | @@ -60,7 +59,6 @@ class MusicianWithdrawService extends Service | ... | @@ -60,7 +59,6 @@ class MusicianWithdrawService extends Service |
60 | break; | 59 | break; |
61 | } | 60 | } |
62 | 61 | ||
63 | |||
64 | if (StakeholderIncomeByPayer::query()->whereIn('serial_no', $this->request->input('serial_no'))->update([ | 62 | if (StakeholderIncomeByPayer::query()->whereIn('serial_no', $this->request->input('serial_no'))->update([ |
65 | 'withdraw_status'=>$withdraw_status, | 63 | 'withdraw_status'=>$withdraw_status, |
66 | ])) { | 64 | ])) { |
... | @@ -69,4 +67,7 @@ class MusicianWithdrawService extends Service | ... | @@ -69,4 +67,7 @@ class MusicianWithdrawService extends Service |
69 | return Response::error(); | 67 | return Response::error(); |
70 | } | 68 | } |
71 | } | 69 | } |
70 | |||
71 | |||
72 | |||
72 | } | 73 | } | ... | ... |
-
Please register or sign in to post a comment