SyncChinaLog.php
1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?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(30)->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);
}
}