| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- <?php
- namespace App\Jobs\ReportStatistics\Reception;
- use App\Servers\DB\DbService;
- use Illuminate\Bus\Queueable;
- use Illuminate\Contracts\Queue\ShouldQueue;
- use Illuminate\Foundation\Bus\Dispatchable;
- use Illuminate\Queue\InteractsWithQueue;
- use Illuminate\Queue\SerializesModels;
- use App\Models\Manager\LiveOnlinePeople as Model;
- use App\Facades\Servers\Logs\Log;
- /**
- * 数据上报任务
- *
- */
- class LiveOnlinePeopleJobs implements ShouldQueue
- {
- use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
- protected $recordData;
- /**
- * Create a new job instance.
- *
- * @return void
- */
- public function __construct(array $recordData)
- {
- $this->recordData = $recordData;
- }
- /**
- * Execute the job.
- *
- * @return void
- */
- public function handle()
- {
- try {
- // 接收参数
- $recordData = $this->recordData;
- // 切换数据
- $result = (new DbService())->getConnectionNameByCompanyId($recordData['company_id']);
- // 错误提示
- if( isset($result['error']) ) {
- // 返回结果
- Log::error('live_online_people_jobs',$result['error'],$recordData);
- return 0;
- }
- // 查询
- $result = (new Model())::query()->upsert($recordData,'id');
- // 返回结果
- if( !$result ) Log::error('live_online_people_jobs','写入失败',$recordData);
- // 返回结果
- return 0;
- } catch (\Throwable $th) {
- // 返回结果
- Log::error('live_online_people_jobs',$th->getMessage(),$recordData);
- // 返回结果
- return 0;
- }
- }
- }
|