*
Showing
1 changed file
with
3 additions
and
3 deletions
... | @@ -51,17 +51,17 @@ class DealSongIp extends Command | ... | @@ -51,17 +51,17 @@ class DealSongIp extends Command |
51 | 51 | ||
52 | foreach ($company_ids as $company_id) { | 52 | foreach ($company_ids as $company_id) { |
53 | 53 | ||
54 | SongsIp::query()->select(['id', 'song_id', 'custom_id'])->chunk(5000, function ($res) { | 54 | SongsIp::query()->select(['id', 'song_id', 'custom_id'])->chunk(2000, function ($res) { |
55 | 55 | ||
56 | $res = $res->toArray(); | 56 | $res = $res->toArray(); |
57 | $custom_ids = array_column($res, 'custom_id'); | 57 | $custom_ids = array_column($res, 'custom_id'); |
58 | 58 | ||
59 | if (!empty($custom_ids)) { | 59 | if (!empty($custom_ids)) { |
60 | $songs = Song::query()->whereIn('custom_id', $custom_ids)->select([])->get()->keyBy('custom_id')->toArray(); | 60 | $songs = Song::query()->whereIn('custom_id', $custom_ids)->select(['id', 'custom_id'])->get()->keyBy('custom_id')->toArray(); |
61 | 61 | ||
62 | foreach ($res as $item) { | 62 | foreach ($res as $item) { |
63 | if (isset($songs[$item['custom_id']])) { | 63 | if (isset($songs[$item['custom_id']])) { |
64 | SongsIp::query()->where(['id'=>$item['id']])->update(['song_id'=>$item['id']]); | 64 | SongsIp::query()->where(['id'=>$item['id']])->update(['song_id'=>$songs[$item['custom_id']]['id']]); |
65 | } else { | 65 | } else { |
66 | SongsIp::query()->where(['id'=>$item['id']])->update(['song_id'=>0]); | 66 | SongsIp::query()->where(['id'=>$item['id']])->update(['song_id'=>0]); |
67 | } | 67 | } | ... | ... |
-
Please register or sign in to post a comment