message_data = $message_data; } /** * Execute the job. * * @return void */ public function handle() { try { $ConfigLowPriceGoodsModel = new ConfigLowPriceGoodsModel(); $LowPriceGoodsCompanyModel = new LowPriceGoodsCompanyModel(); $limit = isset($this->message_data['limit']) ? $this->message_data['limit'] : 50; $page = isset($this->message_data['page']) ? $this->message_data['page'] : 1; $executeLog_id = isset($this->message_data['executeLog_id']) ? $this->message_data['executeLog_id'] : 0; $admin_id = isset($this->message_data['admin_id']) ? $this->message_data['admin_id'] : 0; if ($page == 1) { $ExecuteLogModel = new ExecuteLogModel(); $insert_data = ['name' => '低价挂网商品', 'code' => 'LowPriceGoodsJobs', 'admin_id' => $admin_id]; $executeLog_id = $ExecuteLogModel->addExecuteLog_content($insert_data); } $list_config_data = $ConfigLowPriceGoodsModel->where('status', 0)->paginate($limit, ['*'], 'page', $page)->toarray(); if (!$list_config_data || empty($list_config_data['data'])) { return true; } $list_data = $list_config_data['data']; foreach ($list_data as $key => $value) { $company_data = $LowPriceGoodsCompanyModel->where('washconfig_lowprice_product_company.lowprice_product_logid', $value['id']) ->where('washconfig_violation_store.store_type', 1) ->join('washconfig_violation_store', 'washconfig_violation_store.id', '=', 'washconfig_lowprice_product_company.company_id') ->select(['washconfig_violation_store.id', 'washconfig_violation_store.social_credit_code', 'washconfig_lowprice_product_company.company_id'])->get()->toArray(); $social_credit_code = !empty($company_data) ? array_column($company_data, 'social_credit_code') : ''; $message_data = [ 'id' => $value['id'], 'platform' => $value['platform'], 'product_name' => $value['product_name'], 'product_specs' => $value['product_specs'], 'suggested_price' => $value['suggested_price'], 'store_scope' => $value['store_scope'], 'company_scope' => $value['company_scope'], 'social_credit_code' => $social_credit_code, 'executeLog_id' => $executeLog_id, ]; LowPriceGoodsDataJobs::dispatch($message_data); // LowPriceGoodsDataJobs::dispatchSync($message_data); } $now_message_data = [ 'limit' => $limit, 'page' => $page + 1, 'executeLog_id' => $executeLog_id, ]; $this->dispatchSync($now_message_data); } catch (\Exception $e) { Log::info('job_error', '数据清洗-低价挂网商品配置队列失败', ['data' => $this->message_data, 'error' => $e->getMessage()]); } } public function failed(\Throwable $exception) { Log::info('job_error', '数据清洗-低价挂网商品配置队列完全失败', ['data' => $this->message_data, 'error' => $exception]); } }