|
...
|
...
|
@@ -18,6 +18,7 @@ use App\Services\ProjectServer; |
|
|
|
use Illuminate\Console\Command;
|
|
|
|
use Illuminate\Database\QueryException;
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
use Illuminate\Support\Str;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 测试
|
|
...
|
...
|
@@ -57,65 +58,52 @@ class Test extends Command |
|
|
|
*/
|
|
|
|
public function handle()
|
|
|
|
{
|
|
|
|
$projects = Project::all();
|
|
|
|
foreach ($projects as $project){
|
|
|
|
echo "project " . $project->id;
|
|
|
|
|
|
|
|
if(!ProjectServer::useProject($project->id)){
|
|
|
|
echo '-->' . '未配置数据库' . PHP_EOL;
|
|
|
|
continue;
|
|
|
|
$domains = DB::table('gl_customer_visit')->groupBy('domain')->select('domain')->pluck('domain')->toArray();
|
|
|
|
foreach($domains as $domain){
|
|
|
|
if(!Str::contains($domain, 'globalso.site')){
|
|
|
|
$this->sync($domain);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function sync($domain){
|
|
|
|
echo date('Y-m-d H:i:s') . "同步项目{$domain}" . PHP_EOL;
|
|
|
|
if(!Str::startsWith($domain,'www.')){
|
|
|
|
$domain = 'www.'.$domain;
|
|
|
|
}
|
|
|
|
$project_id = DomainInfo::where('domain', $domain)->value('project_id');
|
|
|
|
if(!$project_id){
|
|
|
|
echo date('Y-m-d H:i:s') . "项目{$domain}不存在" . PHP_EOL;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if(!ProjectServer::useProject($project_id)){
|
|
|
|
echo date('Y-m-d H:i:s') . "项目{$domain}数据库配置无效" . PHP_EOL;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
$visit = 0;
|
|
|
|
$visit_item = 0;
|
|
|
|
$list = DB::table('gl_customer_visit')->whereIn('domain', [$domain, str_replace('www.','',$domain)])->get();
|
|
|
|
foreach ($list as $v){
|
|
|
|
$v = (array) $v;
|
|
|
|
|
|
|
|
$items = DB::table('gl_customer_visit_item')->where('customer_visit_id', $v['id'])->get();
|
|
|
|
|
|
|
|
unset($v['id']);
|
|
|
|
$id = DB::connection('custom_mysql')->table('gl_customer_visit')->insertGetId($v);
|
|
|
|
|
|
|
|
try {
|
|
|
|
$page = BCustomTemplate::where('url', '404')->first();
|
|
|
|
if(!$page){
|
|
|
|
$page = new BCustomTemplate();
|
|
|
|
}
|
|
|
|
$page->project_id = $project->id;
|
|
|
|
$page->name = '404';
|
|
|
|
$page->status = 1;
|
|
|
|
$page->url = '404';
|
|
|
|
$page->html = '<main>
|
|
|
|
<section data-section="section" data-screen="screen-large" class="section-404-wrap-block section-block-error404"
|
|
|
|
id="sectionIdyxqu938">
|
|
|
|
<div class="layout" data-unable="demo01-error404">
|
|
|
|
<img src="https://ecdn6.globalso.com/upload/m/image_other/2023-10/6528a87e594db30162.png" />
|
|
|
|
</div>
|
|
|
|
<p style="text-align: center">SORRY. THE PAGE HAS EITHER MOVED OR CANNOT BE FOUND.</p>
|
|
|
|
<style>
|
|
|
|
.section-block-error404 .layout {
|
|
|
|
height: 700px;
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: center;
|
|
|
|
}
|
|
|
|
.section-block-error404 img {
|
|
|
|
width: 400px;
|
|
|
|
}
|
|
|
|
@media only screen and (max-width:500) {
|
|
|
|
.section-block-error404 img {
|
|
|
|
max-width: 100%;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
<script>
|
|
|
|
</script>
|
|
|
|
</section>
|
|
|
|
</main>';
|
|
|
|
$page->html_style = '<style id="globalsojs-styles"></style>';
|
|
|
|
$page->description = 'Sorry. The page has either moved or cannot be found.';
|
|
|
|
$page->title = '404-Page not found';
|
|
|
|
$page->save();
|
|
|
|
$visit++;
|
|
|
|
|
|
|
|
$domain = (new DomainInfo())->getDomain($project['deploy_optimize']['domain']);
|
|
|
|
$url = $domain.'api/delHtml/?project_id='.$project->id.'&route=404';
|
|
|
|
curlGet($url);
|
|
|
|
}catch (QueryException | \Exception $e){
|
|
|
|
echo '-->' . $e->getMessage() . PHP_EOL;
|
|
|
|
continue;
|
|
|
|
$data = [];
|
|
|
|
foreach ($items as $item){
|
|
|
|
$item = (array) $item;
|
|
|
|
unset($item['id']);
|
|
|
|
$item['customer_visit_id'] = $id;
|
|
|
|
$data[] = $item;
|
|
|
|
$visit_item++;
|
|
|
|
}
|
|
|
|
echo '-->成功:' . PHP_EOL;
|
|
|
|
DB::connection('custom_mysql')->table('gl_customer_visit_item')->insert($data);
|
|
|
|
}
|
|
|
|
echo date('Y-m-d H:i:s') . "visit:{$visit};item:{$visit_item}" . PHP_EOL;exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
} |
...
|
...
|
|