|
@@ -21,6 +21,7 @@ use Illuminate\Console\Command; |
|
@@ -21,6 +21,7 @@ use Illuminate\Console\Command; |
|
21
|
use Illuminate\Database\Eloquent\Model;
|
21
|
use Illuminate\Database\Eloquent\Model;
|
|
22
|
use Illuminate\Support\Facades\DB;
|
22
|
use Illuminate\Support\Facades\DB;
|
|
23
|
use Illuminate\Support\Facades\Log;
|
23
|
use Illuminate\Support\Facades\Log;
|
|
|
|
24
|
+use Illuminate\Support\Facades\Redis;
|
|
24
|
use Illuminate\Support\Str;
|
25
|
use Illuminate\Support\Str;
|
|
25
|
|
26
|
|
|
26
|
/**
|
27
|
/**
|
|
@@ -172,22 +173,32 @@ class WebTrafficFix extends Command |
|
@@ -172,22 +173,32 @@ class WebTrafficFix extends Command |
|
172
|
$date = $this->argument('date');
|
173
|
$date = $this->argument('date');
|
|
173
|
$need_num = $this->argument('need_num');
|
174
|
$need_num = $this->argument('need_num');
|
|
174
|
|
175
|
|
|
175
|
- $project_list = $this->getProjectList($type);
|
176
|
+ // $project_list = $this->getProjectList($type);
|
|
|
|
177
|
+ // exit;
|
|
|
|
178
|
+ while (true) {
|
|
176
|
|
179
|
|
|
|
|
180
|
+
|
|
|
|
181
|
+ $project = Redis::rpop('web_traffic_fix');
|
|
|
|
182
|
+ if(empty($project)){
|
|
|
|
183
|
+
|
|
|
|
184
|
+ break;
|
|
|
|
185
|
+ }
|
|
|
|
186
|
+ $project_list = [json_decode($project, true)];
|
|
177
|
foreach ($project_list as $project) {
|
187
|
foreach ($project_list as $project) {
|
|
178
|
ProjectServer::useProject($project['project_id']);
|
188
|
ProjectServer::useProject($project['project_id']);
|
|
179
|
- if($project['project_id'] <= 135){
|
|
|
|
180
|
- continue;
|
|
|
|
181
|
- }
|
189
|
+ // if($project['project_id'] <= 135){
|
|
|
|
190
|
+ // continue;
|
|
|
|
191
|
+ // }
|
|
182
|
echo 'project_id:' . $project['project_id'] . PHP_EOL;
|
192
|
echo 'project_id:' . $project['project_id'] . PHP_EOL;
|
|
183
|
Log::info('web_traffic_fix project_id:' . $project['project_id']);
|
193
|
Log::info('web_traffic_fix project_id:' . $project['project_id']);
|
|
184
|
- $ip_num = DB::connection('custom_mysql')->table('gl_customer_visit')->whereDate('updated_date', $date)->count();
|
|
|
|
185
|
- if($ip_num >= 30){
|
194
|
+ $ip_num = DB::connection('custom_mysql')->table('gl_customer_visit')->where('updated_date', $date)->count();
|
|
|
|
195
|
+ if ($ip_num >= 30) {
|
|
|
|
196
|
+ echo $ip_num . PHP_EOL;
|
|
186
|
continue;
|
197
|
continue;
|
|
187
|
}
|
198
|
}
|
|
188
|
|
199
|
|
|
189
|
$randomTime = [];
|
200
|
$randomTime = [];
|
|
190
|
- for ($i=0;$i<$need_num-$ip_num;$i++){
|
201
|
+ for ($i = 0; $i < $need_num - $ip_num; $i++) {
|
|
191
|
$randomTime[] = Carbon::make($date)->addSeconds(rand(0, 86400))->toDateTimeString();
|
202
|
$randomTime[] = Carbon::make($date)->addSeconds(rand(0, 86400))->toDateTimeString();
|
|
192
|
}
|
203
|
}
|
|
193
|
sort($randomTime);
|
204
|
sort($randomTime);
|
|
@@ -195,7 +206,8 @@ class WebTrafficFix extends Command |
|
@@ -195,7 +206,8 @@ class WebTrafficFix extends Command |
|
195
|
$project_urls = $this->getProductUrls($project['project_id']);
|
206
|
$project_urls = $this->getProductUrls($project['project_id']);
|
|
196
|
$project_urls['home'] = $project['domain'];
|
207
|
$project_urls['home'] = $project['domain'];
|
|
197
|
|
208
|
|
|
198
|
- foreach ($randomTime as $time){
|
209
|
+ $data = [];
|
|
|
|
210
|
+ foreach ($randomTime as $time) {
|
|
199
|
//随机引流间隔
|
211
|
//随机引流间隔
|
|
200
|
$res_sjjg = $this->get_rand($this->sjjg);
|
212
|
$res_sjjg = $this->get_rand($this->sjjg);
|
|
201
|
if ($res_sjjg == 1) {
|
213
|
if ($res_sjjg == 1) {
|
|
@@ -207,10 +219,9 @@ class WebTrafficFix extends Command |
|
@@ -207,10 +219,9 @@ class WebTrafficFix extends Command |
|
207
|
//随机客户端
|
219
|
//随机客户端
|
|
208
|
$project['device_port'] = $this->get_rand($this->yddzb);
|
220
|
$project['device_port'] = $this->get_rand($this->yddzb);
|
|
209
|
$project['user_agent'] = $project['device_port'] == 1 ? Arr::random($this->pc_ua) : Arr::random($this->mobile_ua);
|
221
|
$project['user_agent'] = $project['device_port'] == 1 ? Arr::random($this->pc_ua) : Arr::random($this->mobile_ua);
|
|
210
|
-
|
222
|
+ $a = time();
|
|
211
|
$project['ip'] = $this->getIpAreas([$project['project_id']], $time)[0] ?? '';
|
223
|
$project['ip'] = $this->getIpAreas([$project['project_id']], $time)[0] ?? '';
|
|
212
|
-
|
|
|
|
213
|
- foreach ($project['visit_urls'] as $url){
|
224
|
+ foreach ($project['visit_urls'] as $url) {
|
|
214
|
$time = Carbon::make($time)->addSeconds(rand(2, 15))->toDateTimeString();
|
225
|
$time = Carbon::make($time)->addSeconds(rand(2, 15))->toDateTimeString();
|
|
215
|
$url_array = parse_url($project['domain']);
|
226
|
$url_array = parse_url($project['domain']);
|
|
216
|
$referrer_url = $this->getReferer($project['ip']['ip_area'], $project['lang']);
|
227
|
$referrer_url = $this->getReferer($project['ip']['ip_area'], $project['lang']);
|
|
@@ -226,14 +237,19 @@ class WebTrafficFix extends Command |
|
@@ -226,14 +237,19 @@ class WebTrafficFix extends Command |
|
226
|
'referrer_url' => $referrer_url
|
237
|
'referrer_url' => $referrer_url
|
|
227
|
],
|
238
|
],
|
|
228
|
];
|
239
|
];
|
|
229
|
- $task = new SyncSubmitTask();
|
|
|
|
230
|
- $task->data = json_encode($array);
|
|
|
|
231
|
- $task->type = SyncSubmitTask::TYPE_VISIT;
|
|
|
|
232
|
- $task->created_at = $time;
|
|
|
|
233
|
- $task->status = 3;
|
|
|
|
234
|
- $task->traffic = 1;
|
|
|
|
235
|
- $task->save();
|
240
|
+ $data[] = [
|
|
|
|
241
|
+ 'data' => json_encode($array),
|
|
|
|
242
|
+ 'type' => SyncSubmitTask::TYPE_VISIT,
|
|
|
|
243
|
+ 'created_at' => $time,
|
|
|
|
244
|
+ 'updated_at' => $time,
|
|
|
|
245
|
+ 'status' => 3,
|
|
|
|
246
|
+ 'traffic' => 1,
|
|
|
|
247
|
+ 'project_id' => $project['project_id'],
|
|
|
|
248
|
+ ];
|
|
|
|
249
|
+ }
|
|
|
|
250
|
+
|
|
236
|
}
|
251
|
}
|
|
|
|
252
|
+ DB::table('gl_sync_submit_task_20240516')->insert($data);
|
|
237
|
}
|
253
|
}
|
|
238
|
}
|
254
|
}
|
|
239
|
Log::info('web_traffic_fix finish');
|
255
|
Log::info('web_traffic_fix finish');
|
|
@@ -279,7 +295,7 @@ class WebTrafficFix extends Command |
|
@@ -279,7 +295,7 @@ class WebTrafficFix extends Command |
|
279
|
->get();
|
295
|
->get();
|
|
280
|
//其他地方在引流的域名
|
296
|
//其他地方在引流的域名
|
|
281
|
$other = DB::connection('projects_mysql')->table('projects')->where('switch', 1)->pluck('domain')->toArray();
|
297
|
$other = DB::connection('projects_mysql')->table('projects')->where('switch', 1)->pluck('domain')->toArray();
|
|
282
|
- $data = [];
|
298
|
+
|
|
283
|
foreach ($list as $project) {
|
299
|
foreach ($list as $project) {
|
|
284
|
$lang = WebLanguage::getLangById($project['main_lang_id']??1)['short'];
|
300
|
$lang = WebLanguage::getLangById($project['main_lang_id']??1)['short'];
|
|
285
|
if(empty($project->domainInfo['domain'])){
|
301
|
if(empty($project->domainInfo['domain'])){
|
|
@@ -289,13 +305,15 @@ class WebTrafficFix extends Command |
|
@@ -289,13 +305,15 @@ class WebTrafficFix extends Command |
|
289
|
if(in_array($project->domainInfo['domain'], $other)){
|
305
|
if(in_array($project->domainInfo['domain'], $other)){
|
|
290
|
continue;
|
306
|
continue;
|
|
291
|
}
|
307
|
}
|
|
292
|
- $data[] = [
|
308
|
+ $data = [
|
|
293
|
'project_id' => $project['project_id'],
|
309
|
'project_id' => $project['project_id'],
|
|
294
|
'domain' => 'https://' . $project->domainInfo['domain'] . '/',
|
310
|
'domain' => 'https://' . $project->domainInfo['domain'] . '/',
|
|
295
|
'lang' => $lang
|
311
|
'lang' => $lang
|
|
296
|
];
|
312
|
];
|
|
|
|
313
|
+
|
|
|
|
314
|
+ Redis::lpush('web_traffic_fix', json_encode($data));
|
|
297
|
}
|
315
|
}
|
|
298
|
- return $data;
|
316
|
+ return true;
|
|
299
|
}
|
317
|
}
|
|
300
|
|
318
|
|
|
301
|
/**
|
319
|
/**
|
|
@@ -355,19 +373,26 @@ class WebTrafficFix extends Command |
|
@@ -355,19 +373,26 @@ class WebTrafficFix extends Command |
|
355
|
$main_countries = !empty($config->main_countries) ? explode(',',$config->main_countries) : [];
|
373
|
$main_countries = !empty($config->main_countries) ? explode(',',$config->main_countries) : [];
|
|
356
|
$filter_countries = !empty($config->filter_countries) ? explode(',',$config->filter_countries) : [];
|
374
|
$filter_countries = !empty($config->filter_countries) ? explode(',',$config->filter_countries) : [];
|
|
357
|
|
375
|
|
|
358
|
- //根据地区随机取该地区的IP
|
|
|
|
359
|
- $ipdata = DB::table('gl_xunpan_ipdata')->whereIn('ip_area', $areas)
|
|
|
|
360
|
- ->where(function ($query) use ($main_countries, $filter_countries){
|
|
|
|
361
|
if($main_countries){
|
376
|
if($main_countries){
|
|
362
|
- $query->whereIn('ip_area', $main_countries);
|
377
|
+ $areas = $main_countries;
|
|
363
|
}
|
378
|
}
|
|
|
|
379
|
+
|
|
364
|
if($filter_countries){
|
380
|
if($filter_countries){
|
|
365
|
- $query->whereNotIn('ip_area', $main_countries);
|
381
|
+ $areas2 = [];
|
|
|
|
382
|
+ foreach ($areas as $v){
|
|
|
|
383
|
+ if(!in_array($v, $filter_countries)){
|
|
|
|
384
|
+ $areas2[] = $v;
|
|
|
|
385
|
+ }
|
|
|
|
386
|
+ }
|
|
|
|
387
|
+ $areas = $areas2;
|
|
366
|
}
|
388
|
}
|
|
367
|
- })->inRandomOrder()->first();
|
389
|
+
|
|
|
|
390
|
+ //根据地区随机取该地区的IP
|
|
|
|
391
|
+ $ipdata = DB::table('gl_xunpan_ipdata')->whereIn('ip_area', $areas)->inRandomOrder()->first();
|
|
368
|
if(!$ipdata){
|
392
|
if(!$ipdata){
|
|
369
|
continue;
|
393
|
continue;
|
|
370
|
}
|
394
|
}
|
|
|
|
395
|
+
|
|
371
|
$ipdata = (array)$ipdata ?: [];
|
396
|
$ipdata = (array)$ipdata ?: [];
|
|
372
|
$ipdata['diff'] = $time_zones[$ipdata['ip_area']];
|
397
|
$ipdata['diff'] = $time_zones[$ipdata['ip_area']];
|
|
373
|
$data[] = $ipdata;
|
398
|
$data[] = $ipdata;
|