Commit 9da69faa 9da69faa43fa9c9c4c50013caf2f17e329d97e4d by lemon

*

1 parent 1a525e07
......@@ -51,17 +51,17 @@ class DealSongIp extends Command
foreach ($company_ids as $company_id) {
SongsIp::query()->select(['id', 'song_id', 'custom_id'])->chunk(5000, function ($res) {
SongsIp::query()->select(['id', 'song_id', 'custom_id'])->chunk(2000, function ($res) {
$res = $res->toArray();
$custom_ids = array_column($res, 'custom_id');
if (!empty($custom_ids)) {
$songs = Song::query()->whereIn('custom_id', $custom_ids)->select([])->get()->keyBy('custom_id')->toArray();
$songs = Song::query()->whereIn('custom_id', $custom_ids)->select(['id', 'custom_id'])->get()->keyBy('custom_id')->toArray();
foreach ($res as $item) {
if (isset($songs[$item['custom_id']])) {
SongsIp::query()->where(['id'=>$item['id']])->update(['song_id'=>$item['id']]);
SongsIp::query()->where(['id'=>$item['id']])->update(['song_id'=>$songs[$item['custom_id']]['id']]);
} else {
SongsIp::query()->where(['id'=>$item['id']])->update(['song_id'=>0]);
}
......