|
...
|
...
|
@@ -2,30 +2,21 @@ |
|
|
|
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
|
|
|
|
use App\Http\Logic\Aside\Project\DomainInfoLogic;
|
|
|
|
use App\Models\Com\UpdateNotify;
|
|
|
|
use App\Models\Devops\DevopsTask as DevopsTaskModel;
|
|
|
|
use App\Models\Devops\DevopsTaskLog;
|
|
|
|
|
|
|
|
|
|
|
|
use App\Models\Domain\DomainInfo;
|
|
|
|
use App\Models\File\File;
|
|
|
|
use App\Models\File\Image;
|
|
|
|
use App\Models\Product\CategoryRelated;
|
|
|
|
use App\Models\Product\Product;
|
|
|
|
use App\Models\HomeCount\Count;
|
|
|
|
use App\Models\Project\Project;
|
|
|
|
use App\Models\RouteMap\RouteMap;
|
|
|
|
use App\Models\Template\BCustomTemplate;
|
|
|
|
use App\Services\ProjectServer;
|
|
|
|
use Illuminate\Console\Command;
|
|
|
|
use Illuminate\Database\QueryException;
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
use Illuminate\Support\Str;
|
|
|
|
use mysql_xdevapi\Exception;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 测试
|
|
|
|
* Class Traffic
|
|
|
|
* Class Test
|
|
|
|
* @package App\Console\Commands
|
|
|
|
* @author zbj
|
|
|
|
* @date 2023/5/18
|
|
|
|
* @date 2023/4/25
|
|
|
|
*/
|
|
|
|
class Test extends Command
|
|
|
|
{
|
|
...
|
...
|
@@ -41,7 +32,7 @@ class Test extends Command |
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $description = '测试';
|
|
|
|
protected $description = '';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new command instance.
|
|
...
|
...
|
@@ -58,52 +49,48 @@ class Test extends Command |
|
|
|
*/
|
|
|
|
public function handle()
|
|
|
|
{
|
|
|
|
$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);
|
|
|
|
}
|
|
|
|
$projects = Project::all();
|
|
|
|
foreach ($projects as $project){
|
|
|
|
echo "project " . $project->id;
|
|
|
|
if(!ProjectServer::useProject($project->id)){
|
|
|
|
echo '未配置数据库' . PHP_EOL;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
$list = Count::where('pv_num', 0)->get();
|
|
|
|
foreach ($list as $v){
|
|
|
|
$v->pv_num = $this->pv_num($v['date']);
|
|
|
|
//ip统计
|
|
|
|
$v->ip_num = $this->ip_num($v['date']);
|
|
|
|
$v->save();
|
|
|
|
echo $v['date'] . ':' . $v->pv_num .':'. $v->ip_num . PHP_EOL;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function sync($domain){
|
|
|
|
echo date('Y-m-d H:i:s') . "同步项目{$domain}" . PHP_EOL;
|
|
|
|
if(!Str::startsWith($domain,'www.')){
|
|
|
|
$domain = 'www.'.$domain;
|
|
|
|
}catch (\Exception $e){
|
|
|
|
echo '保存失败' . $e->getMessage() . PHP_EOL;
|
|
|
|
}
|
|
|
|
$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;
|
|
|
|
echo "finish";
|
|
|
|
}
|
|
|
|
$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);
|
|
|
|
|
|
|
|
$visit++;
|
|
|
|
|
|
|
|
$data = [];
|
|
|
|
foreach ($items as $item){
|
|
|
|
$item = (array) $item;
|
|
|
|
unset($item['id']);
|
|
|
|
$item['customer_visit_id'] = $id;
|
|
|
|
$data[] = $item;
|
|
|
|
$visit_item++;
|
|
|
|
}
|
|
|
|
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;
|
|
|
|
/**
|
|
|
|
* @name :(统计pv)pv_num
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/6/14 15:40
|
|
|
|
*/
|
|
|
|
public function pv_num($yesterday){
|
|
|
|
$pv = DB::connection('custom_mysql')->table('gl_customer_visit_item')->whereDate('updated_date', $yesterday)->count();
|
|
|
|
return $pv;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @name :(统计ip)ip_num
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/6/14 15:40
|
|
|
|
*/
|
|
|
|
public function ip_num($yesterday){
|
|
|
|
$ip = DB::connection('custom_mysql')->table('gl_customer_visit')->whereDate('updated_date', $yesterday)->count();
|
|
|
|
return $ip;
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|