attempts()); if ($job->attempts() > 1) { $job->delete(); $this->failed($data); } $arrary = $data['data']; //读取excel $excel_data = SpreadsheetExcelService::instance()->_import($arrary['path'], $arrary['sql'], $arrary['where'], 1); if (!$excel_data) return false; unset($excel_data[0]); $product_type = 0; if ($data['type_id'] == 12) { $product_type = 98; //供应链 } try { foreach ($excel_data as $datum) { Queue::push(ImportProductJob::class,['data'=>$datum,'mer_id'=>$data['mer_id'],'product_type'=>$product_type]); // $StoreOrderRepository->setProduct(); } } catch (\Exception $e) { $job->delete(); $datas['product_id'] = $product_id ?? 0; $datas['mer_id'] = $data['mer_id']; $datas['store_name'] = $datum['value']['store_name']; $datas['content'] = $e->getMessage() . 'line:' . $e->getLine(); $this->create_product_import_log($datas, 0); } } public function failed($data) { Log::error('读取excel失败:' . json_encode($data)); // TODO: Implement failed() method. } public function create_product_import_log($data, $status = 1) { $data = [ 'product_id' => $data['product_id'] ?? 0, 'mer_id' => $data['mer_id'], 'name' => $data['store_name'], 'content' => $data['content'] ?? '', 'status' => $status, 'create_time' => date('Y-m-d H:i:s'), ]; Db::name('store_product_import')->insert($data); } }