get([],["ownerStoragePriceModels"],false,true))->chunk(50); $month = date('Y-m-d'); foreach ($chunks as $owners){ $date = date('Y-m-d H:i:s'); $createOwnerAreaReport = []; foreach ($owners as $owner){ if (!$owner->ownerStoragePriceModels)continue; foreach ($owner->ownerStoragePriceModels as $model){ $createOwnerAreaReport[] = [ "owner_id" => $owner->id, "counting_month" => $month, "user_owner_group_id" => $owner->user_owner_group_id, "created_at" => $date, "owner_storage_price_model_id" => $model->id, ]; } } DB::table("owner_area_reports")->insert($createOwnerAreaReport); LogService::log(__METHOD__,"客户管理-定时生成盘点记录",json_encode($createOwnerAreaReport)); } } }