| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- <?php
- namespace App\Jobs\Manager\Process;
- use Illuminate\Bus\Queueable;
- use Illuminate\Contracts\Queue\ShouldBeUnique;
- use Illuminate\Contracts\Queue\ShouldQueue;
- use Illuminate\Foundation\Bus\Dispatchable;
- use Illuminate\Queue\InteractsWithQueue;
- use Illuminate\Queue\SerializesModels;
- use App\Facades\Servers\Logs\Log;
- use App\Models\Manager\WashConfig\ViolationStore as ViolationStoreModel;
- use App\Models\Manager\Process\ExecuteLog as ExecuteLogModel;
- use App\Jobs\Manager\Process\ViolationStoreDataJobs;
- /**
- * 数据清洗-违规挂网店铺配置队列
- * @author 唐远望
- * @version 1.0
- * @date 2025-12-11
- */
- class ViolationStoreJobs implements ShouldQueue
- {
- use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
- protected $message_data;
- /**
- * Create a new job instance.
- *
- * @return void
- */
- public function __construct(array $message_data)
- {
- $this->message_data = $message_data;
- }
- /**
- * Execute the job.
- *
- * @return void
- */
- public function handle()
- {
- try {
- $ViolationStoreModel = new ViolationStoreModel();
- $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;
- $is_admin = isset($this->message_data['is_admin']) ? $this->message_data['is_admin'] : 0;
- $company_id = isset($this->message_data['company_id']) ? $this->message_data['company_id'] : 0;
- if($page == 1){
- $ExecuteLogModel = new ExecuteLogModel();
- $insert_data =['company_id'=>$company_id,'name' =>'违规挂网店铺', 'code' => 'ViolationStoreJobs', 'admin_id' => $admin_id,'is_admin' => $is_admin];
- $executeLog_id=$ExecuteLogModel->addExecuteLog_content($insert_data);
- }
- $ViolationStoreModel = $ViolationStoreModel->leftjoin('washconfig_company_category', 'washconfig_company_category.id', '=', 'washconfig_violation_store.category_id')
- ->where('washconfig_violation_store.status', 0)->where('store_type', 1)->select(['washconfig_violation_store.*','washconfig_company_category.name as category_name']);
- if($company_id){
- $ViolationStoreModel = $ViolationStoreModel->where('washconfig_violation_store.company_id', $company_id);
- }
- $list_config_data = $ViolationStoreModel->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) {
- $message_data = [
- 'company_id' => $value['company_id'],
- 'id' => $value['id'],
- 'platform' => $value['platform'],
- 'store_name'=> $value['store_name'],
- 'store_type' => $value['store_type'],
- 'company_name' => $value['company_name'],
- 'social_credit_code' => $value['social_credit_code'],
- 'executeLog_id' => $executeLog_id,
- 'company_category_name' => $value['category_name'],
- 'specify_responsible_person' => $value['specify_responsible_person'],
- ];
- ViolationStoreDataJobs::dispatch($message_data);
- // ViolationStoreDataJobs::dispatchSync($message_data);
- }
- $now_message_data = [
- 'limit' => $limit,
- 'page' => $page + 1,
- 'executeLog_id' => $executeLog_id,
- ];
- ViolationStoreJobs::dispatch($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]);
- }
- }
|