SyncChinaLog.php 1.4 KB
<?php

namespace App\Console\Commands\Sync;

use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use App\Models\SyncSubmitTask\SyncSubmitTask;

/**
 * 渠道信息
 * Class ChannelInfo
 * @package App\Console\Commands
 * @author zbj
 * @date 2023/6/27
 */
class SyncChinaLog extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'sync_china_log';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '同步国内数据库访问及询盘';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    public function handle()
    {
        $list = DB::connection('mysql_sh')->table('gl_sync_submit_task')->where('status', 0)->limit(20)->get();
        $insert = [];
        $ids = [];
        foreach ($list as $item) {
            $ids[] = $item->id;
            $insert[] = [
                'type' => $item->type,
                'data' => $item->data,
                'created_at' => $item->created_at,
                'updated_at' => $item->updated_at,
            ];
        }

        DB::connection('mysql_sh')->table('gl_sync_submit_task')->whereIn('id', $ids)->update(['status' => 1]);

        SyncSubmitTask::insert($insert);
    }
}