|
...
|
...
|
@@ -21,6 +21,7 @@ use Illuminate\Console\Command; |
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
use Illuminate\Support\Facades\Redis;
|
|
|
|
use Illuminate\Support\Str;
|
|
|
|
|
|
|
|
/**
|
|
...
|
...
|
@@ -172,22 +173,32 @@ class WebTrafficFix extends Command |
|
|
|
$date = $this->argument('date');
|
|
|
|
$need_num = $this->argument('need_num');
|
|
|
|
|
|
|
|
$project_list = $this->getProjectList($type);
|
|
|
|
// $project_list = $this->getProjectList($type);
|
|
|
|
// exit;
|
|
|
|
while (true) {
|
|
|
|
|
|
|
|
|
|
|
|
$project = Redis::rpop('web_traffic_fix');
|
|
|
|
if(empty($project)){
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
$project_list = [json_decode($project, true)];
|
|
|
|
foreach ($project_list as $project) {
|
|
|
|
ProjectServer::useProject($project['project_id']);
|
|
|
|
if($project['project_id'] <= 135){
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
// if($project['project_id'] <= 135){
|
|
|
|
// continue;
|
|
|
|
// }
|
|
|
|
echo 'project_id:' . $project['project_id'] . PHP_EOL;
|
|
|
|
Log::info('web_traffic_fix project_id:' . $project['project_id']);
|
|
|
|
$ip_num = DB::connection('custom_mysql')->table('gl_customer_visit')->whereDate('updated_date', $date)->count();
|
|
|
|
if($ip_num >= 30){
|
|
|
|
$ip_num = DB::connection('custom_mysql')->table('gl_customer_visit')->where('updated_date', $date)->count();
|
|
|
|
if ($ip_num >= 30) {
|
|
|
|
echo $ip_num . PHP_EOL;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
$randomTime = [];
|
|
|
|
for ($i=0;$i<$need_num-$ip_num;$i++){
|
|
|
|
for ($i = 0; $i < $need_num - $ip_num; $i++) {
|
|
|
|
$randomTime[] = Carbon::make($date)->addSeconds(rand(0, 86400))->toDateTimeString();
|
|
|
|
}
|
|
|
|
sort($randomTime);
|
|
...
|
...
|
@@ -195,7 +206,8 @@ class WebTrafficFix extends Command |
|
|
|
$project_urls = $this->getProductUrls($project['project_id']);
|
|
|
|
$project_urls['home'] = $project['domain'];
|
|
|
|
|
|
|
|
foreach ($randomTime as $time){
|
|
|
|
$data = [];
|
|
|
|
foreach ($randomTime as $time) {
|
|
|
|
//随机引流间隔
|
|
|
|
$res_sjjg = $this->get_rand($this->sjjg);
|
|
|
|
if ($res_sjjg == 1) {
|
|
...
|
...
|
@@ -207,10 +219,9 @@ class WebTrafficFix extends Command |
|
|
|
//随机客户端
|
|
|
|
$project['device_port'] = $this->get_rand($this->yddzb);
|
|
|
|
$project['user_agent'] = $project['device_port'] == 1 ? Arr::random($this->pc_ua) : Arr::random($this->mobile_ua);
|
|
|
|
|
|
|
|
$a = time();
|
|
|
|
$project['ip'] = $this->getIpAreas([$project['project_id']], $time)[0] ?? '';
|
|
|
|
|
|
|
|
foreach ($project['visit_urls'] as $url){
|
|
|
|
foreach ($project['visit_urls'] as $url) {
|
|
|
|
$time = Carbon::make($time)->addSeconds(rand(2, 15))->toDateTimeString();
|
|
|
|
$url_array = parse_url($project['domain']);
|
|
|
|
$referrer_url = $this->getReferer($project['ip']['ip_area'], $project['lang']);
|
|
...
|
...
|
@@ -226,14 +237,19 @@ class WebTrafficFix extends Command |
|
|
|
'referrer_url' => $referrer_url
|
|
|
|
],
|
|
|
|
];
|
|
|
|
$task = new SyncSubmitTask();
|
|
|
|
$task->data = json_encode($array);
|
|
|
|
$task->type = SyncSubmitTask::TYPE_VISIT;
|
|
|
|
$task->created_at = $time;
|
|
|
|
$task->status = 3;
|
|
|
|
$task->traffic = 1;
|
|
|
|
$task->save();
|
|
|
|
$data[] = [
|
|
|
|
'data' => json_encode($array),
|
|
|
|
'type' => SyncSubmitTask::TYPE_VISIT,
|
|
|
|
'created_at' => $time,
|
|
|
|
'updated_at' => $time,
|
|
|
|
'status' => 3,
|
|
|
|
'traffic' => 1,
|
|
|
|
'project_id' => $project['project_id'],
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
DB::table('gl_sync_submit_task_20240516')->insert($data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Log::info('web_traffic_fix finish');
|
|
...
|
...
|
@@ -279,7 +295,7 @@ class WebTrafficFix extends Command |
|
|
|
->get();
|
|
|
|
//其他地方在引流的域名
|
|
|
|
$other = DB::connection('projects_mysql')->table('projects')->where('switch', 1)->pluck('domain')->toArray();
|
|
|
|
$data = [];
|
|
|
|
|
|
|
|
foreach ($list as $project) {
|
|
|
|
$lang = WebLanguage::getLangById($project['main_lang_id']??1)['short'];
|
|
|
|
if(empty($project->domainInfo['domain'])){
|
|
...
|
...
|
@@ -289,13 +305,15 @@ class WebTrafficFix extends Command |
|
|
|
if(in_array($project->domainInfo['domain'], $other)){
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
$data[] = [
|
|
|
|
$data = [
|
|
|
|
'project_id' => $project['project_id'],
|
|
|
|
'domain' => 'https://' . $project->domainInfo['domain'] . '/',
|
|
|
|
'lang' => $lang
|
|
|
|
];
|
|
|
|
|
|
|
|
Redis::lpush('web_traffic_fix', json_encode($data));
|
|
|
|
}
|
|
|
|
return $data;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
...
|
...
|
@@ -355,19 +373,26 @@ class WebTrafficFix extends Command |
|
|
|
$main_countries = !empty($config->main_countries) ? explode(',',$config->main_countries) : [];
|
|
|
|
$filter_countries = !empty($config->filter_countries) ? explode(',',$config->filter_countries) : [];
|
|
|
|
|
|
|
|
//根据地区随机取该地区的IP
|
|
|
|
$ipdata = DB::table('gl_xunpan_ipdata')->whereIn('ip_area', $areas)
|
|
|
|
->where(function ($query) use ($main_countries, $filter_countries){
|
|
|
|
if($main_countries){
|
|
|
|
$query->whereIn('ip_area', $main_countries);
|
|
|
|
$areas = $main_countries;
|
|
|
|
}
|
|
|
|
|
|
|
|
if($filter_countries){
|
|
|
|
$query->whereNotIn('ip_area', $main_countries);
|
|
|
|
$areas2 = [];
|
|
|
|
foreach ($areas as $v){
|
|
|
|
if(!in_array($v, $filter_countries)){
|
|
|
|
$areas2[] = $v;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$areas = $areas2;
|
|
|
|
}
|
|
|
|
})->inRandomOrder()->first();
|
|
|
|
|
|
|
|
//根据地区随机取该地区的IP
|
|
|
|
$ipdata = DB::table('gl_xunpan_ipdata')->whereIn('ip_area', $areas)->inRandomOrder()->first();
|
|
|
|
if(!$ipdata){
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
$ipdata = (array)$ipdata ?: [];
|
|
|
|
$ipdata['diff'] = $time_zones[$ipdata['ip_area']];
|
|
|
|
$data[] = $ipdata;
|
...
|
...
|
|