Merge remote-tracking branch 'origin/master' into akun
正在显示
20 个修改的文件
包含
276 行增加
和
172 行删除
| @@ -55,7 +55,7 @@ class UpdateRoute extends Command | @@ -55,7 +55,7 @@ class UpdateRoute extends Command | ||
| 55 | */ | 55 | */ |
| 56 | public function handle(){ | 56 | public function handle(){ |
| 57 | $projectModel = new Project(); | 57 | $projectModel = new Project(); |
| 58 | - $list = $projectModel->list(['id'=>358]); | 58 | + $list = $projectModel->list(['id'=>687]); |
| 59 | $data = []; | 59 | $data = []; |
| 60 | foreach ($list as $v){ | 60 | foreach ($list as $v){ |
| 61 | echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL; | 61 | echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL; |
| @@ -7,6 +7,7 @@ use App\Models\Product\Category; | @@ -7,6 +7,7 @@ use App\Models\Product\Category; | ||
| 7 | use App\Models\Product\Product; | 7 | use App\Models\Product\Product; |
| 8 | use App\Models\Project\OnlineCheck; | 8 | use App\Models\Project\OnlineCheck; |
| 9 | use App\Models\Project\Project; | 9 | use App\Models\Project\Project; |
| 10 | +use App\Models\Project\WebTrafficConfig; | ||
| 10 | use App\Models\Template\BCustomTemplate; | 11 | use App\Models\Template\BCustomTemplate; |
| 11 | use App\Models\WebSetting\WebLanguage; | 12 | use App\Models\WebSetting\WebLanguage; |
| 12 | use App\Services\ProjectServer; | 13 | use App\Services\ProjectServer; |
| @@ -193,35 +194,35 @@ class WebTraffic extends Command | @@ -193,35 +194,35 @@ class WebTraffic extends Command | ||
| 193 | $need_project[] = $project; | 194 | $need_project[] = $project; |
| 194 | } | 195 | } |
| 195 | //随机访问ip | 196 | //随机访问ip |
| 196 | - $ips = $this->getIpAreas(count($need_project)); | 197 | + $ips = $this->getIpAreas(array_column($need_project, 'project_id')); |
| 197 | 198 | ||
| 198 | //特殊日期 降访问率 | 199 | //特殊日期 降访问率 |
| 199 | foreach ($need_project as $project_key => $project){ | 200 | foreach ($need_project as $project_key => $project){ |
| 201 | + if(empty($ips[$project_key]['ip'])){ | ||
| 202 | + Log::channel('traffic')->info('未获取到ip project_id:' . $project['project_id']); | ||
| 203 | + unset($need_project[$project_key]); | ||
| 204 | + continue; | ||
| 205 | + } | ||
| 200 | $diff = $ips[$project_key]['diff']; | 206 | $diff = $ips[$project_key]['diff']; |
| 201 | //当地时间 | 207 | //当地时间 |
| 202 | $w = date('w', strtotime($diff . 'hour')); | 208 | $w = date('w', strtotime($diff . 'hour')); |
| 203 | $date = date('m-d', strtotime($diff . 'hour')); | 209 | $date = date('m-d', strtotime($diff . 'hour')); |
| 204 | - //元旦节和圣诞节按照周六的比例处理 | ||
| 205 | - if(in_array($date, ['01-01', '12-25'])){ | ||
| 206 | - $w = 6; | ||
| 207 | - } | 210 | + |
| 211 | + //周五流量不变 周六周日下降20-30% 元旦圣诞下降30-50% | ||
| 208 | switch ($w){ | 212 | switch ($w){ |
| 209 | case 0: | 213 | case 0: |
| 210 | - //周日降70-80% | ||
| 211 | - $rate = rand(70, 80) * 10; | ||
| 212 | - $res = $this->get_rand([1000-$rate, $rate]); | ||
| 213 | - break; | ||
| 214 | - case 5: | ||
| 215 | - //周5降30-40% | ||
| 216 | - $rate = rand(30, 40) * 10; | ||
| 217 | - $res = $this->get_rand([1000-$rate, $rate]); | ||
| 218 | - break; | ||
| 219 | case 6: | 214 | case 6: |
| 220 | - //周6降60-70% | ||
| 221 | - $rate = rand(60, 70) * 10; | 215 | + //周日降20-30% |
| 216 | + $rate = rand(20, 30) * 10; | ||
| 222 | $res = $this->get_rand([1000-$rate, $rate]); | 217 | $res = $this->get_rand([1000-$rate, $rate]); |
| 223 | break; | 218 | break; |
| 224 | default: | 219 | default: |
| 220 | + //元旦圣诞下降30-50% | ||
| 221 | + if(in_array($date, ['01-01', '12-25'])){ | ||
| 222 | + $rate = rand(30, 50) * 10; | ||
| 223 | + $res = $this->get_rand([1000-$rate, $rate]); | ||
| 224 | + break; | ||
| 225 | + } | ||
| 225 | $res = 0; | 226 | $res = 0; |
| 226 | } | 227 | } |
| 227 | //不访问 | 228 | //不访问 |
| @@ -265,7 +266,7 @@ class WebTraffic extends Command | @@ -265,7 +266,7 @@ class WebTraffic extends Command | ||
| 265 | $page++; | 266 | $page++; |
| 266 | } | 267 | } |
| 267 | }catch (\Exception $e){ | 268 | }catch (\Exception $e){ |
| 268 | - Log::channel('traffic')->error($e->getMessage()); | 269 | + Log::channel('traffic')->error("line" . $e->getLine() . ',error:' . $e->getMessage(), $e->getTrace()); |
| 269 | } | 270 | } |
| 270 | } | 271 | } |
| 271 | 272 | ||
| @@ -298,22 +299,22 @@ class WebTraffic extends Command | @@ -298,22 +299,22 @@ class WebTraffic extends Command | ||
| 298 | ->where('gl_project.is_upgrade', 0) //非升级项目 | 299 | ->where('gl_project.is_upgrade', 0) //非升级项目 |
| 299 | ->where('gl_project.main_lang_id', '<>', $ru_lang_id) //非俄语站 | 300 | ->where('gl_project.main_lang_id', '<>', $ru_lang_id) //非俄语站 |
| 300 | ->where(function ($query) use ($type) { | 301 | ->where(function ($query) use ($type) { |
| 301 | - if($type == 1){ | ||
| 302 | - //1-3个月项目 | ||
| 303 | - $startTime = Carbon::now()->addMonths(-4)->toDateString(); | ||
| 304 | - $endTime = Carbon::now()->addMonths(-1)->toDateString(); | ||
| 305 | - $query->whereBetween('pdo.start_date', [$startTime,$endTime]); | ||
| 306 | - }elseif($type == 2){ | ||
| 307 | - //4-8个月项目 | ||
| 308 | - $startTime = Carbon::now()->addMonths(-9)->startOfDay()->toDateTimeString(); | ||
| 309 | - $endTime = Carbon::now()->addMonths(-4)->endOfDay()->toDateTimeString(); | ||
| 310 | - $query->whereBetween('pdo.start_date', [$startTime,$endTime]); | ||
| 311 | - }else{ | ||
| 312 | - //大于9个月项目 | ||
| 313 | - $startTime = Carbon::now()->addMonths(-9)->startOfDay()->toDateTimeString(); | ||
| 314 | - $query->where('pdo.start_date', '<', $startTime); | ||
| 315 | - } | ||
| 316 | - })->select(['pdo.project_id','gl_project.main_lang_id','gl_project.id'])->forPage($page, 500)->get(); | 302 | + if($type == 1){ |
| 303 | + //1-3个月项目 | ||
| 304 | + $startTime = Carbon::now()->addMonths(-4)->toDateString(); | ||
| 305 | + $endTime = Carbon::now()->addMonths(-1)->toDateString(); | ||
| 306 | + $query->whereBetween('pdo.start_date', [$startTime,$endTime]); | ||
| 307 | + }elseif($type == 2){ | ||
| 308 | + //4-8个月项目 | ||
| 309 | + $startTime = Carbon::now()->addMonths(-9)->startOfDay()->toDateTimeString(); | ||
| 310 | + $endTime = Carbon::now()->addMonths(-4)->endOfDay()->toDateTimeString(); | ||
| 311 | + $query->whereBetween('pdo.start_date', [$startTime,$endTime]); | ||
| 312 | + }else{ | ||
| 313 | + //大于9个月项目 | ||
| 314 | + $startTime = Carbon::now()->addMonths(-9)->startOfDay()->toDateTimeString(); | ||
| 315 | + $query->where('pdo.start_date', '<', $startTime); | ||
| 316 | + } | ||
| 317 | + })->select(['pdo.project_id','gl_project.main_lang_id','gl_project.id'])->forPage($page, 500)->get(); | ||
| 317 | //其他地方在引流的域名 | 318 | //其他地方在引流的域名 |
| 318 | $other = DB::connection('projects_mysql')->table('projects')->where('switch', 1)->pluck('domain')->toArray(); | 319 | $other = DB::connection('projects_mysql')->table('projects')->where('switch', 1)->pluck('domain')->toArray(); |
| 319 | $data = []; | 320 | $data = []; |
| @@ -368,7 +369,7 @@ class WebTraffic extends Command | @@ -368,7 +369,7 @@ class WebTraffic extends Command | ||
| 368 | /** | 369 | /** |
| 369 | * 获取地区IP | 370 | * 获取地区IP |
| 370 | */ | 371 | */ |
| 371 | - protected function getIpAreas($num) | 372 | + protected function getIpAreas($project_ids) |
| 372 | { | 373 | { |
| 373 | //本地时间为7-23点的地区 | 374 | //本地时间为7-23点的地区 |
| 374 | $h = date('H'); | 375 | $h = date('H'); |
| @@ -386,11 +387,26 @@ class WebTraffic extends Command | @@ -386,11 +387,26 @@ class WebTraffic extends Command | ||
| 386 | $time_zones[$v['name']] = $v['diff']; | 387 | $time_zones[$v['name']] = $v['diff']; |
| 387 | } | 388 | } |
| 388 | } | 389 | } |
| 389 | - //根据地区随机取该地区的IP | ||
| 390 | - $data = DB::table('gl_xunpan_ipdata')->whereIn('ip_area', $areas)->inRandomOrder()->limit($num)->get(); | ||
| 391 | - $data = Arr::s2a(Arr::a2s($data)); | ||
| 392 | - foreach ($data as &$item){ | ||
| 393 | - $item['diff'] = $time_zones[$item['ip_area']]; | 390 | + $data = []; |
| 391 | + foreach ($project_ids as $project_id){ | ||
| 392 | + //引流配置 | ||
| 393 | + $config = WebTrafficConfig::getCacheInfoByProjectId($project_id); | ||
| 394 | + $main_countries = !empty($config->main_countries) ? explode(',',$config->main_countries) : []; | ||
| 395 | + $filter_countries = !empty($config->filter_countries) ? explode(',',$config->filter_countries) : []; | ||
| 396 | + | ||
| 397 | + //根据地区随机取该地区的IP | ||
| 398 | + $ipdata = DB::table('gl_xunpan_ipdata')->whereIn('ip_area', $areas) | ||
| 399 | + ->where(function ($query) use ($main_countries, $filter_countries){ | ||
| 400 | + if($main_countries){ | ||
| 401 | + $query->whereIn('ip_area', $main_countries); | ||
| 402 | + } | ||
| 403 | + if($filter_countries){ | ||
| 404 | + $query->whereNotIn('ip_area', $main_countries); | ||
| 405 | + } | ||
| 406 | + })->inRandomOrder()->first(); | ||
| 407 | + $ipdata = (array)$ipdata ?: []; | ||
| 408 | + $ipdata['diff'] = $time_zones[$ipdata['ip_area']]; | ||
| 409 | + $data[] = $ipdata; | ||
| 394 | } | 410 | } |
| 395 | return $data; | 411 | return $data; |
| 396 | } | 412 | } |
| @@ -457,6 +473,9 @@ class WebTraffic extends Command | @@ -457,6 +473,9 @@ class WebTraffic extends Command | ||
| 457 | $v = $project_urls['home'] . $v; | 473 | $v = $project_urls['home'] . $v; |
| 458 | } | 474 | } |
| 459 | } | 475 | } |
| 476 | + | ||
| 477 | + Log::channel('traffic')->info('project_id:访问深度' . $res_sdzb, $url); | ||
| 478 | + | ||
| 460 | return array_unique(array_filter($url)); | 479 | return array_unique(array_filter($url)); |
| 461 | } | 480 | } |
| 462 | 481 |
| @@ -7,6 +7,7 @@ use App\Models\Product\Category; | @@ -7,6 +7,7 @@ use App\Models\Product\Category; | ||
| 7 | use App\Models\Product\Product; | 7 | use App\Models\Product\Product; |
| 8 | use App\Models\Project\OnlineCheck; | 8 | use App\Models\Project\OnlineCheck; |
| 9 | use App\Models\Project\Project; | 9 | use App\Models\Project\Project; |
| 10 | +use App\Models\Project\WebTrafficConfig; | ||
| 10 | use App\Models\Template\BCustomTemplate; | 11 | use App\Models\Template\BCustomTemplate; |
| 11 | use App\Models\WebSetting\WebLanguage; | 12 | use App\Models\WebSetting\WebLanguage; |
| 12 | use App\Services\ProjectServer; | 13 | use App\Services\ProjectServer; |
| @@ -229,35 +230,34 @@ class WebTrafficRussia extends Command | @@ -229,35 +230,34 @@ class WebTrafficRussia extends Command | ||
| 229 | $need_project[] = $project; | 230 | $need_project[] = $project; |
| 230 | } | 231 | } |
| 231 | //随机访问ip | 232 | //随机访问ip |
| 232 | - $ips = $this->getIpAreas(count($need_project)); | 233 | + $ips = $this->getIpAreas(array_column($need_project, 'project_id')); |
| 233 | 234 | ||
| 234 | //特殊日期 降访问率 | 235 | //特殊日期 降访问率 |
| 235 | foreach ($need_project as $project_key => $project){ | 236 | foreach ($need_project as $project_key => $project){ |
| 237 | + if(empty($ips[$project_key]['ip'])){ | ||
| 238 | + Log::channel('traffic')->info('未获取到ip project_id:' . $project['project_id']); | ||
| 239 | + unset($need_project[$project_key]); | ||
| 240 | + continue; | ||
| 241 | + } | ||
| 236 | $diff = $ips[$project_key]['diff']; | 242 | $diff = $ips[$project_key]['diff']; |
| 237 | //当地时间 | 243 | //当地时间 |
| 238 | $w = date('w', strtotime($diff . 'hour')); | 244 | $w = date('w', strtotime($diff . 'hour')); |
| 239 | $date = date('m-d', strtotime($diff . 'hour')); | 245 | $date = date('m-d', strtotime($diff . 'hour')); |
| 240 | - //元旦节和圣诞节按照周六的比例处理 | ||
| 241 | - if(in_array($date, ['01-01', '12-25'])){ | ||
| 242 | - $w = 6; | ||
| 243 | - } | 246 | + //周五流量不变 周六周日下降20-30% 元旦圣诞下降30-50% |
| 244 | switch ($w){ | 247 | switch ($w){ |
| 245 | case 0: | 248 | case 0: |
| 246 | - //周日降70-80% | ||
| 247 | - $rate = rand(70, 80) * 10; | ||
| 248 | - $res = $this->get_rand([1000-$rate, $rate]); | ||
| 249 | - break; | ||
| 250 | - case 5: | ||
| 251 | - //周5降30-40% | ||
| 252 | - $rate = rand(30, 40) * 10; | ||
| 253 | - $res = $this->get_rand([1000-$rate, $rate]); | ||
| 254 | - break; | ||
| 255 | case 6: | 249 | case 6: |
| 256 | - //周6降60-70% | ||
| 257 | - $rate = rand(60, 70) * 10; | 250 | + //周日降20-30% |
| 251 | + $rate = rand(20, 30) * 10; | ||
| 258 | $res = $this->get_rand([1000-$rate, $rate]); | 252 | $res = $this->get_rand([1000-$rate, $rate]); |
| 259 | break; | 253 | break; |
| 260 | default: | 254 | default: |
| 255 | + //元旦圣诞下降30-50% | ||
| 256 | + if(in_array($date, ['01-01', '12-25'])){ | ||
| 257 | + $rate = rand(30, 50) * 10; | ||
| 258 | + $res = $this->get_rand([1000-$rate, $rate]); | ||
| 259 | + break; | ||
| 260 | + } | ||
| 261 | $res = 0; | 261 | $res = 0; |
| 262 | } | 262 | } |
| 263 | //不访问 | 263 | //不访问 |
| @@ -301,7 +301,7 @@ class WebTrafficRussia extends Command | @@ -301,7 +301,7 @@ class WebTrafficRussia extends Command | ||
| 301 | $page++; | 301 | $page++; |
| 302 | } | 302 | } |
| 303 | }catch (\Exception $e){ | 303 | }catch (\Exception $e){ |
| 304 | - Log::channel('traffic')->error("ru:line" . $e->getLine() . ',error:' . $e->getMessage()); | 304 | + Log::channel('traffic')->error("ru:line" . $e->getLine() . ',error:' . $e->getMessage(), $e->getTrace()); |
| 305 | } | 305 | } |
| 306 | } | 306 | } |
| 307 | 307 | ||
| @@ -404,7 +404,7 @@ class WebTrafficRussia extends Command | @@ -404,7 +404,7 @@ class WebTrafficRussia extends Command | ||
| 404 | /** | 404 | /** |
| 405 | * 获取地区IP | 405 | * 获取地区IP |
| 406 | */ | 406 | */ |
| 407 | - protected function getIpAreas($num) | 407 | + protected function getIpAreas($project_ids) |
| 408 | { | 408 | { |
| 409 | //本地时间为7-23点的地区 | 409 | //本地时间为7-23点的地区 |
| 410 | $h = date('H'); | 410 | $h = date('H'); |
| @@ -431,11 +431,31 @@ class WebTrafficRussia extends Command | @@ -431,11 +431,31 @@ class WebTrafficRussia extends Command | ||
| 431 | } | 431 | } |
| 432 | 432 | ||
| 433 | $data = []; | 433 | $data = []; |
| 434 | - for ($i=0;$i<$num;$i++){ | ||
| 435 | - //ip国家占比 | ||
| 436 | - $ip_area = $this->get_rand($country_ratio); | 434 | + foreach ($project_ids as $project_id) { |
| 435 | + $project_country = $country_ratio; | ||
| 436 | + //引流配置 | ||
| 437 | + $config = WebTrafficConfig::getCacheInfoByProjectId($project_id); | ||
| 438 | + $main_countries = !empty($config->main_countries) ? explode(',',$config->main_countries) : []; | ||
| 439 | + $filter_countries = !empty($config->filter_countries) ? explode(',',$config->filter_countries) : []; | ||
| 440 | + //设置了主推的 | ||
| 441 | + if($main_countries){ | ||
| 442 | + foreach ($project_country as $k => $v){ | ||
| 443 | + if(!in_array($k, $main_countries)){ | ||
| 444 | + unset($project_country[$k]); | ||
| 445 | + } | ||
| 446 | + } | ||
| 447 | + } | ||
| 448 | + //设置了不推广 | ||
| 449 | + if($filter_countries){ | ||
| 450 | + foreach ($project_country as $k => $v){ | ||
| 451 | + if(in_array($k, $filter_countries)){ | ||
| 452 | + unset($project_country[$k]); | ||
| 453 | + } | ||
| 454 | + } | ||
| 455 | + } | ||
| 456 | + $ip_area = $this->get_rand($project_country); | ||
| 437 | $res = DB::table('gl_xunpan_ipdata')->where('ip_area', $ip_area)->inRandomOrder()->first(); | 457 | $res = DB::table('gl_xunpan_ipdata')->where('ip_area', $ip_area)->inRandomOrder()->first(); |
| 438 | - $res = (array)$res; | 458 | + $res = (array)$res ?: []; |
| 439 | $res['diff'] = $time_zones[$res['ip_area']]; | 459 | $res['diff'] = $time_zones[$res['ip_area']]; |
| 440 | $data[] = $res; | 460 | $data[] = $res; |
| 441 | } | 461 | } |
| @@ -504,6 +524,9 @@ class WebTrafficRussia extends Command | @@ -504,6 +524,9 @@ class WebTrafficRussia extends Command | ||
| 504 | $v = $project_urls['home'] . $v; | 524 | $v = $project_urls['home'] . $v; |
| 505 | } | 525 | } |
| 506 | } | 526 | } |
| 527 | + | ||
| 528 | + Log::channel('traffic')->info('project_id:访问深度' . $res_sdzb, $url); | ||
| 529 | + | ||
| 507 | return array_unique(array_filter($url)); | 530 | return array_unique(array_filter($url)); |
| 508 | } | 531 | } |
| 509 | 532 |
| @@ -7,6 +7,7 @@ use App\Models\Product\Category; | @@ -7,6 +7,7 @@ use App\Models\Product\Category; | ||
| 7 | use App\Models\Product\Product; | 7 | use App\Models\Product\Product; |
| 8 | use App\Models\Project\OnlineCheck; | 8 | use App\Models\Project\OnlineCheck; |
| 9 | use App\Models\Project\Project; | 9 | use App\Models\Project\Project; |
| 10 | +use App\Models\Project\WebTrafficConfig; | ||
| 10 | use App\Models\Template\BCustomTemplate; | 11 | use App\Models\Template\BCustomTemplate; |
| 11 | use App\Models\WebSetting\WebLanguage; | 12 | use App\Models\WebSetting\WebLanguage; |
| 12 | use App\Services\ProjectServer; | 13 | use App\Services\ProjectServer; |
| @@ -52,9 +53,6 @@ class WebTrafficRussiaSpecial extends Command | @@ -52,9 +53,6 @@ class WebTrafficRussiaSpecial extends Command | ||
| 52 | parent::__construct(); | 53 | parent::__construct(); |
| 53 | } | 54 | } |
| 54 | 55 | ||
| 55 | - protected $projects = [ | ||
| 56 | - 969 => 60, | ||
| 57 | - ]; | ||
| 58 | 56 | ||
| 59 | /** | 57 | /** |
| 60 | * 国家概率 | 58 | * 国家概率 |
| @@ -232,35 +230,34 @@ class WebTrafficRussiaSpecial extends Command | @@ -232,35 +230,34 @@ class WebTrafficRussiaSpecial extends Command | ||
| 232 | $need_project[] = $project; | 230 | $need_project[] = $project; |
| 233 | } | 231 | } |
| 234 | //随机访问ip | 232 | //随机访问ip |
| 235 | - $ips = $this->getIpAreas(count($need_project)); | 233 | + $ips = $this->getIpAreas(array_column($need_project, 'project_id')); |
| 236 | 234 | ||
| 237 | //特殊日期 降访问率 | 235 | //特殊日期 降访问率 |
| 238 | foreach ($need_project as $project_key => $project){ | 236 | foreach ($need_project as $project_key => $project){ |
| 237 | + if(empty($ips[$project_key]['ip'])){ | ||
| 238 | + Log::channel('traffic')->info('未获取到ip project_id:' . $project['project_id']); | ||
| 239 | + unset($need_project[$project_key]); | ||
| 240 | + continue; | ||
| 241 | + } | ||
| 239 | $diff = $ips[$project_key]['diff']; | 242 | $diff = $ips[$project_key]['diff']; |
| 240 | //当地时间 | 243 | //当地时间 |
| 241 | $w = date('w', strtotime($diff . 'hour')); | 244 | $w = date('w', strtotime($diff . 'hour')); |
| 242 | $date = date('m-d', strtotime($diff . 'hour')); | 245 | $date = date('m-d', strtotime($diff . 'hour')); |
| 243 | - //元旦节和圣诞节按照周六的比例处理 | ||
| 244 | - if(in_array($date, ['01-01', '12-25'])){ | ||
| 245 | - $w = 6; | ||
| 246 | - } | 246 | + //周五流量不变 周六周日下降20-30% 元旦圣诞下降30-50% |
| 247 | switch ($w){ | 247 | switch ($w){ |
| 248 | case 0: | 248 | case 0: |
| 249 | - //周日降70-80% | ||
| 250 | - $rate = rand(70, 80) * 10; | ||
| 251 | - $res = $this->get_rand([1000-$rate, $rate]); | ||
| 252 | - break; | ||
| 253 | - case 5: | ||
| 254 | - //周5降30-40% | ||
| 255 | - $rate = rand(30, 40) * 10; | ||
| 256 | - $res = $this->get_rand([1000-$rate, $rate]); | ||
| 257 | - break; | ||
| 258 | case 6: | 249 | case 6: |
| 259 | - //周6降60-70% | ||
| 260 | - $rate = rand(60, 70) * 10; | 250 | + //周日降20-30% |
| 251 | + $rate = rand(20, 30) * 10; | ||
| 261 | $res = $this->get_rand([1000-$rate, $rate]); | 252 | $res = $this->get_rand([1000-$rate, $rate]); |
| 262 | break; | 253 | break; |
| 263 | default: | 254 | default: |
| 255 | + //元旦圣诞下降30-50% | ||
| 256 | + if(in_array($date, ['01-01', '12-25'])){ | ||
| 257 | + $rate = rand(30, 50) * 10; | ||
| 258 | + $res = $this->get_rand([1000-$rate, $rate]); | ||
| 259 | + break; | ||
| 260 | + } | ||
| 264 | $res = 0; | 261 | $res = 0; |
| 265 | } | 262 | } |
| 266 | //不访问 | 263 | //不访问 |
| @@ -304,7 +301,7 @@ class WebTrafficRussiaSpecial extends Command | @@ -304,7 +301,7 @@ class WebTrafficRussiaSpecial extends Command | ||
| 304 | $page++; | 301 | $page++; |
| 305 | } | 302 | } |
| 306 | }catch (\Exception $e){ | 303 | }catch (\Exception $e){ |
| 307 | - Log::channel('traffic')->error("ru:line" . $e->getLine() . ',error:' . $e->getMessage()); | 304 | + Log::channel('traffic')->error("ru special:line" . $e->getLine() . ',error:' . $e->getMessage(), $e->getTrace()); |
| 308 | } | 305 | } |
| 309 | } | 306 | } |
| 310 | 307 | ||
| @@ -319,6 +316,9 @@ class WebTrafficRussiaSpecial extends Command | @@ -319,6 +316,9 @@ class WebTrafficRussiaSpecial extends Command | ||
| 319 | * 俄语站引流的项目 | 316 | * 俄语站引流的项目 |
| 320 | */ | 317 | */ |
| 321 | protected function getProjectList($page){ | 318 | protected function getProjectList($page){ |
| 319 | + //设置了特殊引流的项目 | ||
| 320 | + $projects = WebTrafficConfig::where('add_num', '>', 0)->pluck('add_num', 'project_id')->toArray(); | ||
| 321 | + | ||
| 322 | $ru_lang_id = WebLanguage::getIdByLang('ru'); | 322 | $ru_lang_id = WebLanguage::getIdByLang('ru'); |
| 323 | 323 | ||
| 324 | //推广项目 | 324 | //推广项目 |
| @@ -330,7 +330,7 @@ class WebTrafficRussiaSpecial extends Command | @@ -330,7 +330,7 @@ class WebTrafficRussiaSpecial extends Command | ||
| 330 | ->whereIn('gl_project.type', [Project::TYPE_TWO, Project::TYPE_FOUR]) | 330 | ->whereIn('gl_project.type', [Project::TYPE_TWO, Project::TYPE_FOUR]) |
| 331 | ->where('gl_project.is_upgrade', 0) //非升级项目 | 331 | ->where('gl_project.is_upgrade', 0) //非升级项目 |
| 332 | ->where('gl_project.main_lang_id', $ru_lang_id)// 俄语站 | 332 | ->where('gl_project.main_lang_id', $ru_lang_id)// 俄语站 |
| 333 | - ->whereIn('gl_project.id', array_keys($this->projects)) | 333 | + ->whereIn('gl_project.id', array_keys($projects)) |
| 334 | ->select(['pdo.project_id','gl_project.main_lang_id','gl_project.id'])->forPage($page, 500)->get(); | 334 | ->select(['pdo.project_id','gl_project.main_lang_id','gl_project.id'])->forPage($page, 500)->get(); |
| 335 | //其他地方在引流的域名 | 335 | //其他地方在引流的域名 |
| 336 | // $other = DB::connection('projects_mysql')->table('projects')->where('switch', 1)->pluck('domain')->toArray(); | 336 | // $other = DB::connection('projects_mysql')->table('projects')->where('switch', 1)->pluck('domain')->toArray(); |
| @@ -342,7 +342,7 @@ class WebTrafficRussiaSpecial extends Command | @@ -342,7 +342,7 @@ class WebTrafficRussiaSpecial extends Command | ||
| 342 | if(Cache::get('web_traffic_russia_special_' . $project['project_id'])){ | 342 | if(Cache::get('web_traffic_russia_special_' . $project['project_id'])){ |
| 343 | continue; | 343 | continue; |
| 344 | }else{ | 344 | }else{ |
| 345 | - $ttl = 24 * 60 * 60 / $this->projects[$project['project_id']]; | 345 | + $ttl = 24 * 60 * 60 / ($projects[$project['project_id']] / ($this->sjjg[0] / ($this->sjjg[0] + $this->sjjg[1]))); |
| 346 | Cache::put('web_traffic_russia_special_' . $project['project_id'], 1, $ttl); | 346 | Cache::put('web_traffic_russia_special_' . $project['project_id'], 1, $ttl); |
| 347 | } | 347 | } |
| 348 | 348 | ||
| @@ -396,7 +396,7 @@ class WebTrafficRussiaSpecial extends Command | @@ -396,7 +396,7 @@ class WebTrafficRussiaSpecial extends Command | ||
| 396 | /** | 396 | /** |
| 397 | * 获取地区IP | 397 | * 获取地区IP |
| 398 | */ | 398 | */ |
| 399 | - protected function getIpAreas($num) | 399 | + protected function getIpAreas($project_ids) |
| 400 | { | 400 | { |
| 401 | //本地时间为7-23点的地区 | 401 | //本地时间为7-23点的地区 |
| 402 | $h = date('H'); | 402 | $h = date('H'); |
| @@ -423,11 +423,31 @@ class WebTrafficRussiaSpecial extends Command | @@ -423,11 +423,31 @@ class WebTrafficRussiaSpecial extends Command | ||
| 423 | } | 423 | } |
| 424 | 424 | ||
| 425 | $data = []; | 425 | $data = []; |
| 426 | - for ($i=0;$i<$num;$i++){ | ||
| 427 | - //ip国家占比 | ||
| 428 | - $ip_area = $this->get_rand($country_ratio); | 426 | + foreach ($project_ids as $project_id) { |
| 427 | + $project_country = $country_ratio; | ||
| 428 | + //引流配置 | ||
| 429 | + $config = WebTrafficConfig::getCacheInfoByProjectId($project_id); | ||
| 430 | + $main_countries = !empty($config->main_countries) ? explode(',',$config->main_countries) : []; | ||
| 431 | + $filter_countries = !empty($config->filter_countries) ? explode(',',$config->filter_countries) : []; | ||
| 432 | + //设置了主推的 | ||
| 433 | + if($main_countries){ | ||
| 434 | + foreach ($project_country as $k => $v){ | ||
| 435 | + if(!in_array($k, $main_countries)){ | ||
| 436 | + unset($project_country[$k]); | ||
| 437 | + } | ||
| 438 | + } | ||
| 439 | + } | ||
| 440 | + //设置了不推广 | ||
| 441 | + if($filter_countries){ | ||
| 442 | + foreach ($project_country as $k => $v){ | ||
| 443 | + if(in_array($k, $filter_countries)){ | ||
| 444 | + unset($project_country[$k]); | ||
| 445 | + } | ||
| 446 | + } | ||
| 447 | + } | ||
| 448 | + $ip_area = $this->get_rand($project_country); | ||
| 429 | $res = DB::table('gl_xunpan_ipdata')->where('ip_area', $ip_area)->inRandomOrder()->first(); | 449 | $res = DB::table('gl_xunpan_ipdata')->where('ip_area', $ip_area)->inRandomOrder()->first(); |
| 430 | - $res = (array)$res; | 450 | + $res = (array)$res ?: []; |
| 431 | $res['diff'] = $time_zones[$res['ip_area']]; | 451 | $res['diff'] = $time_zones[$res['ip_area']]; |
| 432 | $data[] = $res; | 452 | $data[] = $res; |
| 433 | } | 453 | } |
| @@ -496,6 +516,9 @@ class WebTrafficRussiaSpecial extends Command | @@ -496,6 +516,9 @@ class WebTrafficRussiaSpecial extends Command | ||
| 496 | $v = $project_urls['home'] . $v; | 516 | $v = $project_urls['home'] . $v; |
| 497 | } | 517 | } |
| 498 | } | 518 | } |
| 519 | + | ||
| 520 | + Log::channel('traffic')->info('project_id:访问深度' . $res_sdzb, $url); | ||
| 521 | + | ||
| 499 | return array_unique(array_filter($url)); | 522 | return array_unique(array_filter($url)); |
| 500 | } | 523 | } |
| 501 | 524 |
| @@ -7,6 +7,7 @@ use App\Models\Product\Category; | @@ -7,6 +7,7 @@ use App\Models\Product\Category; | ||
| 7 | use App\Models\Product\Product; | 7 | use App\Models\Product\Product; |
| 8 | use App\Models\Project\OnlineCheck; | 8 | use App\Models\Project\OnlineCheck; |
| 9 | use App\Models\Project\Project; | 9 | use App\Models\Project\Project; |
| 10 | +use App\Models\Project\WebTrafficConfig; | ||
| 10 | use App\Models\Template\BCustomTemplate; | 11 | use App\Models\Template\BCustomTemplate; |
| 11 | use App\Models\WebSetting\WebLanguage; | 12 | use App\Models\WebSetting\WebLanguage; |
| 12 | use App\Services\ProjectServer; | 13 | use App\Services\ProjectServer; |
| @@ -53,20 +54,6 @@ class WebTrafficSpecial extends Command | @@ -53,20 +54,6 @@ class WebTrafficSpecial extends Command | ||
| 53 | parent::__construct(); | 54 | parent::__construct(); |
| 54 | } | 55 | } |
| 55 | 56 | ||
| 56 | - | ||
| 57 | - /** | ||
| 58 | - * 要增加引流的项目及腰增加的数量 | ||
| 59 | - * key 要引流的ID | ||
| 60 | - * value 每天要增加的流量 | ||
| 61 | - * @var array | ||
| 62 | - */ | ||
| 63 | - protected $projects = [ | ||
| 64 | - 509 => 30, | ||
| 65 | - 79 => 20, | ||
| 66 | - ]; | ||
| 67 | - | ||
| 68 | - | ||
| 69 | - | ||
| 70 | /** | 57 | /** |
| 71 | * google域名后缀 | 58 | * google域名后缀 |
| 72 | * @var string[] | 59 | * @var string[] |
| @@ -207,35 +194,34 @@ class WebTrafficSpecial extends Command | @@ -207,35 +194,34 @@ class WebTrafficSpecial extends Command | ||
| 207 | $need_project[] = $project; | 194 | $need_project[] = $project; |
| 208 | } | 195 | } |
| 209 | //随机访问ip | 196 | //随机访问ip |
| 210 | - $ips = $this->getIpAreas(count($need_project)); | 197 | + $ips = $this->getIpAreas(array_column($need_project, 'project_id')); |
| 211 | 198 | ||
| 212 | //特殊日期 降访问率 | 199 | //特殊日期 降访问率 |
| 213 | foreach ($need_project as $project_key => $project){ | 200 | foreach ($need_project as $project_key => $project){ |
| 201 | + if(empty($ips[$project_key]['ip'])){ | ||
| 202 | + Log::channel('traffic')->info('未获取到ip project_id:' . $project['project_id']); | ||
| 203 | + unset($need_project[$project_key]); | ||
| 204 | + continue; | ||
| 205 | + } | ||
| 214 | $diff = $ips[$project_key]['diff']; | 206 | $diff = $ips[$project_key]['diff']; |
| 215 | //当地时间 | 207 | //当地时间 |
| 216 | $w = date('w', strtotime($diff . 'hour')); | 208 | $w = date('w', strtotime($diff . 'hour')); |
| 217 | $date = date('m-d', strtotime($diff . 'hour')); | 209 | $date = date('m-d', strtotime($diff . 'hour')); |
| 218 | - //元旦节和圣诞节按照周六的比例处理 | ||
| 219 | - if(in_array($date, ['01-01', '12-25'])){ | ||
| 220 | - $w = 6; | ||
| 221 | - } | 210 | + //周五流量不变 周六周日下降20-30% 元旦圣诞下降30-50% |
| 222 | switch ($w){ | 211 | switch ($w){ |
| 223 | case 0: | 212 | case 0: |
| 224 | - //周日降70-80% | ||
| 225 | - $rate = rand(70, 80) * 10; | ||
| 226 | - $res = $this->get_rand([1000-$rate, $rate]); | ||
| 227 | - break; | ||
| 228 | - case 5: | ||
| 229 | - //周5降30-40% | ||
| 230 | - $rate = rand(30, 40) * 10; | ||
| 231 | - $res = $this->get_rand([1000-$rate, $rate]); | ||
| 232 | - break; | ||
| 233 | case 6: | 213 | case 6: |
| 234 | - //周6降60-70% | ||
| 235 | - $rate = rand(60, 70) * 10; | 214 | + //周日降20-30% |
| 215 | + $rate = rand(20, 30) * 10; | ||
| 236 | $res = $this->get_rand([1000-$rate, $rate]); | 216 | $res = $this->get_rand([1000-$rate, $rate]); |
| 237 | break; | 217 | break; |
| 238 | default: | 218 | default: |
| 219 | + //元旦圣诞下降30-50% | ||
| 220 | + if(in_array($date, ['01-01', '12-25'])){ | ||
| 221 | + $rate = rand(30, 50) * 10; | ||
| 222 | + $res = $this->get_rand([1000-$rate, $rate]); | ||
| 223 | + break; | ||
| 224 | + } | ||
| 239 | $res = 0; | 225 | $res = 0; |
| 240 | } | 226 | } |
| 241 | //不访问 | 227 | //不访问 |
| @@ -279,7 +265,7 @@ class WebTrafficSpecial extends Command | @@ -279,7 +265,7 @@ class WebTrafficSpecial extends Command | ||
| 279 | $page++; | 265 | $page++; |
| 280 | } | 266 | } |
| 281 | }catch (\Exception $e){ | 267 | }catch (\Exception $e){ |
| 282 | - Log::channel('traffic')->error($e->getMessage()); | 268 | + Log::channel('traffic')->error("special line" . $e->getLine() . ',error:' . $e->getMessage(), $e->getTrace()); |
| 283 | } | 269 | } |
| 284 | } | 270 | } |
| 285 | 271 | ||
| @@ -294,6 +280,9 @@ class WebTrafficSpecial extends Command | @@ -294,6 +280,9 @@ class WebTrafficSpecial extends Command | ||
| 294 | * 非俄语站的引流的项目 | 280 | * 非俄语站的引流的项目 |
| 295 | */ | 281 | */ |
| 296 | protected function getProjectList($page){ | 282 | protected function getProjectList($page){ |
| 283 | + //设置了特殊引流的项目 | ||
| 284 | + $projects = WebTrafficConfig::where('add_num', '>', 0)->pluck('add_num', 'project_id')->toArray(); | ||
| 285 | + | ||
| 297 | $ru_lang_id = WebLanguage::getIdByLang('ru'); | 286 | $ru_lang_id = WebLanguage::getIdByLang('ru'); |
| 298 | 287 | ||
| 299 | //推广项目 | 288 | //推广项目 |
| @@ -305,7 +294,7 @@ class WebTrafficSpecial extends Command | @@ -305,7 +294,7 @@ class WebTrafficSpecial extends Command | ||
| 305 | ->whereIn('gl_project.type', [Project::TYPE_TWO, Project::TYPE_FOUR]) | 294 | ->whereIn('gl_project.type', [Project::TYPE_TWO, Project::TYPE_FOUR]) |
| 306 | ->where('gl_project.is_upgrade', 0) //非升级项目 | 295 | ->where('gl_project.is_upgrade', 0) //非升级项目 |
| 307 | ->where('gl_project.main_lang_id', '<>', $ru_lang_id) //非俄语站 | 296 | ->where('gl_project.main_lang_id', '<>', $ru_lang_id) //非俄语站 |
| 308 | - ->whereIn('gl_project.id', array_keys($this->projects)) | 297 | + ->whereIn('gl_project.id', array_keys($projects)) |
| 309 | ->select(['pdo.project_id','gl_project.main_lang_id','gl_project.id'])->forPage($page, 500)->get(); | 298 | ->select(['pdo.project_id','gl_project.main_lang_id','gl_project.id'])->forPage($page, 500)->get(); |
| 310 | //其他地方在引流的域名 | 299 | //其他地方在引流的域名 |
| 311 | // $other = DB::connection('projects_mysql')->table('projects')->where('switch', 1)->pluck('domain')->toArray(); | 300 | // $other = DB::connection('projects_mysql')->table('projects')->where('switch', 1)->pluck('domain')->toArray(); |
| @@ -317,7 +306,7 @@ class WebTrafficSpecial extends Command | @@ -317,7 +306,7 @@ class WebTrafficSpecial extends Command | ||
| 317 | if(Cache::get('traffic_special_' . $project['project_id'])){ | 306 | if(Cache::get('traffic_special_' . $project['project_id'])){ |
| 318 | continue; | 307 | continue; |
| 319 | }else{ | 308 | }else{ |
| 320 | - $ttl = 24 * 60 * 60 / $this->projects[$project['project_id']]; | 309 | + $ttl = 24 * 60 * 60 / ($projects[$project['project_id']] / ($this->sjjg[0] / ($this->sjjg[0] + $this->sjjg[1]))); |
| 321 | Cache::put('traffic_special_' . $project['project_id'], 1, $ttl); | 310 | Cache::put('traffic_special_' . $project['project_id'], 1, $ttl); |
| 322 | } | 311 | } |
| 323 | 312 | ||
| @@ -371,7 +360,7 @@ class WebTrafficSpecial extends Command | @@ -371,7 +360,7 @@ class WebTrafficSpecial extends Command | ||
| 371 | /** | 360 | /** |
| 372 | * 获取地区IP | 361 | * 获取地区IP |
| 373 | */ | 362 | */ |
| 374 | - protected function getIpAreas($num) | 363 | + protected function getIpAreas($project_ids) |
| 375 | { | 364 | { |
| 376 | //本地时间为7-23点的地区 | 365 | //本地时间为7-23点的地区 |
| 377 | $h = date('H'); | 366 | $h = date('H'); |
| @@ -389,11 +378,26 @@ class WebTrafficSpecial extends Command | @@ -389,11 +378,26 @@ class WebTrafficSpecial extends Command | ||
| 389 | $time_zones[$v['name']] = $v['diff']; | 378 | $time_zones[$v['name']] = $v['diff']; |
| 390 | } | 379 | } |
| 391 | } | 380 | } |
| 392 | - //根据地区随机取该地区的IP | ||
| 393 | - $data = DB::table('gl_xunpan_ipdata')->whereIn('ip_area', $areas)->inRandomOrder()->limit($num)->get(); | ||
| 394 | - $data = Arr::s2a(Arr::a2s($data)); | ||
| 395 | - foreach ($data as &$item){ | ||
| 396 | - $item['diff'] = $time_zones[$item['ip_area']]; | 381 | + $data = []; |
| 382 | + foreach ($project_ids as $project_id){ | ||
| 383 | + //引流配置 | ||
| 384 | + $config = WebTrafficConfig::getCacheInfoByProjectId($project_id); | ||
| 385 | + $main_countries = !empty($config->main_countries) ? explode(',',$config->main_countries) : []; | ||
| 386 | + $filter_countries = !empty($config->filter_countries) ? explode(',',$config->filter_countries) : []; | ||
| 387 | + | ||
| 388 | + //根据地区随机取该地区的IP | ||
| 389 | + $ipdata = DB::table('gl_xunpan_ipdata')->whereIn('ip_area', $areas) | ||
| 390 | + ->where(function ($query) use ($main_countries, $filter_countries){ | ||
| 391 | + if($main_countries){ | ||
| 392 | + $query->whereIn('ip_area', $main_countries); | ||
| 393 | + } | ||
| 394 | + if($filter_countries){ | ||
| 395 | + $query->whereNotIn('ip_area', $main_countries); | ||
| 396 | + } | ||
| 397 | + })->inRandomOrder()->first(); | ||
| 398 | + $ipdata = (array)$ipdata ?: []; | ||
| 399 | + $ipdata['diff'] = $time_zones[$ipdata['ip_area']]; | ||
| 400 | + $data[] = $ipdata; | ||
| 397 | } | 401 | } |
| 398 | return $data; | 402 | return $data; |
| 399 | } | 403 | } |
| @@ -460,6 +464,9 @@ class WebTrafficSpecial extends Command | @@ -460,6 +464,9 @@ class WebTrafficSpecial extends Command | ||
| 460 | $v = $project_urls['home'] . $v; | 464 | $v = $project_urls['home'] . $v; |
| 461 | } | 465 | } |
| 462 | } | 466 | } |
| 467 | + | ||
| 468 | + Log::channel('traffic')->info('project_id:访问深度' . $res_sdzb, $url); | ||
| 469 | + | ||
| 463 | return array_unique(array_filter($url)); | 470 | return array_unique(array_filter($url)); |
| 464 | } | 471 | } |
| 465 | 472 |
| @@ -28,7 +28,7 @@ class DomainInfoController extends BaseController | @@ -28,7 +28,7 @@ class DomainInfoController extends BaseController | ||
| 28 | { | 28 | { |
| 29 | $domainModel = new DomainInfo(); | 29 | $domainModel = new DomainInfo(); |
| 30 | if(isset($this->map['domain']) && !empty($this->map['domain'])){ | 30 | if(isset($this->map['domain']) && !empty($this->map['domain'])){ |
| 31 | - $this->map['domain'] = ['like','%'.$this->map['domain'],'%']; | 31 | + $this->map['domain'] = ['like','%'.$this->map['domain'].'%']; |
| 32 | } | 32 | } |
| 33 | $lists = $domainModel->lists($this->map,$this->page,$this->row,$this->order); | 33 | $lists = $domainModel->lists($this->map,$this->page,$this->row,$this->order); |
| 34 | if(!empty($lists)){ | 34 | if(!empty($lists)){ |
| @@ -34,7 +34,7 @@ class NewsController extends BaseController | @@ -34,7 +34,7 @@ class NewsController extends BaseController | ||
| 34 | $lists = $query->select($filed)->paginate($this->row, ['*'], 'page', $this->page); | 34 | $lists = $query->select($filed)->paginate($this->row, ['*'], 'page', $this->page); |
| 35 | if(!empty($lists)){ | 35 | if(!empty($lists)){ |
| 36 | $lists = $lists->toArray(); | 36 | $lists = $lists->toArray(); |
| 37 | -// //获取当前项目的所有分类 | 37 | + //获取当前项目的所有分类 |
| 38 | $data = $this->getCategoryList(); | 38 | $data = $this->getCategoryList(); |
| 39 | //获取当前用户选择的模版 | 39 | //获取当前用户选择的模版 |
| 40 | $template_id = $this->getTemplateId(BTemplate::SOURCE_NEWS,BTemplate::IS_DETAIL);//获取模版id | 40 | $template_id = $this->getTemplateId(BTemplate::SOURCE_NEWS,BTemplate::IS_DETAIL);//获取模版id |
| @@ -433,8 +433,8 @@ class ProductController extends BaseController | @@ -433,8 +433,8 @@ class ProductController extends BaseController | ||
| 433 | * @time :2023/7/29 14:59 | 433 | * @time :2023/7/29 14:59 |
| 434 | */ | 434 | */ |
| 435 | public function copyProduct(ProductLogic $logic){ | 435 | public function copyProduct(ProductLogic $logic){ |
| 436 | - $rs = $logic->setCopyProduct(); | ||
| 437 | - $this->response('success',Code::SUCCESS,$rs); | 436 | + $data = $logic->setCopyProduct(); |
| 437 | + $this->response('success',Code::SUCCESS,$data); | ||
| 438 | } | 438 | } |
| 439 | 439 | ||
| 440 | /** | 440 | /** |
| @@ -227,7 +227,8 @@ class ProjectLogic extends BaseLogic | @@ -227,7 +227,8 @@ class ProjectLogic extends BaseLogic | ||
| 227 | $param['is_visualization'] = json_encode($param['is_visualization']); | 227 | $param['is_visualization'] = json_encode($param['is_visualization']); |
| 228 | } | 228 | } |
| 229 | } | 229 | } |
| 230 | - | 230 | + $param['upload_config'] = json_encode($param['upload_config'] ?? []); |
| 231 | + $param['web_traffic_config'] = json_encode($param['web_traffic_config'] ?? []); | ||
| 231 | $this->model->edit($param,['id'=>$param['id']]); | 232 | $this->model->edit($param,['id'=>$param['id']]); |
| 232 | Common::del_user_cache($this->model->getTable(),$param['id']); | 233 | Common::del_user_cache($this->model->getTable(),$param['id']); |
| 233 | return $this->success(); | 234 | return $this->success(); |
| @@ -123,30 +123,43 @@ class BTemplateLogLogic extends BaseLogic | @@ -123,30 +123,43 @@ class BTemplateLogLogic extends BaseLogic | ||
| 123 | $this->fail('当前数据不存在,或已被删除'); | 123 | $this->fail('当前数据不存在,或已被删除'); |
| 124 | } | 124 | } |
| 125 | if($this->user['is_customized'] != BTemplate::IS_VISUALIZATION){ | 125 | if($this->user['is_customized'] != BTemplate::IS_VISUALIZATION){ |
| 126 | - if(empty($info['other'])){ | ||
| 127 | - $footer_other = str_replace('<header','',characterTruncation($info['text'],'/<style id="globalsojs-footer">(.*?)<header/s')); | ||
| 128 | - $info['other'] = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', '', $footer_other); | ||
| 129 | - } | ||
| 130 | - $html = $info['head_css'].$info['main_css'].$info['footer_css'].$info['other']. | ||
| 131 | - $info['head_html'].$info['main_html'].$info['footer_html']; | ||
| 132 | - $serviceSettingModel = new ServiceSettingModel(); | ||
| 133 | - $list = $serviceSettingModel->list(['type'=>2],'created_at'); | ||
| 134 | - //拼接html | ||
| 135 | - foreach ($list as $v){ | ||
| 136 | - if($v['key'] == 'head'){ | ||
| 137 | - $html = $v['values'].$html; | ||
| 138 | - } | ||
| 139 | - if($v['key'] == 'footer'){ | ||
| 140 | - $html = $html.$v['values']; | ||
| 141 | - } | ||
| 142 | - } | 126 | + $html = $this->getTemplateHtml($info); |
| 143 | }else{ | 127 | }else{ |
| 144 | $page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面 | 128 | $page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面 |
| 145 | if (in_array(1, $page_array)) {//首页是定制界面 | 129 | if (in_array(1, $page_array)) {//首页是定制界面 |
| 146 | $html = $info['text']; | 130 | $html = $info['text']; |
| 131 | + }else{ | ||
| 132 | + $html = $this->getTemplateHtml($info); | ||
| 147 | } | 133 | } |
| 148 | } | 134 | } |
| 149 | return $this->success(['html'=>$html]); | 135 | return $this->success(['html'=>$html]); |
| 150 | } | 136 | } |
| 151 | 137 | ||
| 138 | + /** | ||
| 139 | + * @remark :生成界面 | ||
| 140 | + * @name :getTemplateHtml | ||
| 141 | + * @author :lyh | ||
| 142 | + * @method :post | ||
| 143 | + * @time :2024/4/3 17:11 | ||
| 144 | + */ | ||
| 145 | + public function getTemplateHtml($info){ | ||
| 146 | + if(empty($info['other'])){ | ||
| 147 | + $footer_other = str_replace('<header','',characterTruncation($info['text'],'/<style id="globalsojs-footer">(.*?)<header/s')); | ||
| 148 | + $info['other'] = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', '', $footer_other); | ||
| 149 | + } | ||
| 150 | + $html = $info['head_css'].$info['main_css'].$info['footer_css'].$info['other']. | ||
| 151 | + $info['head_html'].$info['main_html'].$info['footer_html']; | ||
| 152 | + $serviceSettingModel = new ServiceSettingModel(); | ||
| 153 | + $list = $serviceSettingModel->list(['type'=>2],'created_at'); | ||
| 154 | + //拼接html | ||
| 155 | + foreach ($list as $v){ | ||
| 156 | + if($v['key'] == 'head'){ | ||
| 157 | + $html = $v['values'].$html; | ||
| 158 | + } | ||
| 159 | + if($v['key'] == 'footer'){ | ||
| 160 | + $html = $html.$v['values']; | ||
| 161 | + } | ||
| 162 | + } | ||
| 163 | + return $this->success($html); | ||
| 164 | + } | ||
| 152 | } | 165 | } |
| @@ -50,7 +50,7 @@ class BlogLogic extends BaseLogic | @@ -50,7 +50,7 @@ class BlogLogic extends BaseLogic | ||
| 50 | DB::commit(); | 50 | DB::commit(); |
| 51 | }catch (\Exception $e){ | 51 | }catch (\Exception $e){ |
| 52 | DB::rollBack(); | 52 | DB::rollBack(); |
| 53 | - $this->fail('error'); | 53 | + $this->fail('系统错误,请联系管理员'); |
| 54 | } | 54 | } |
| 55 | $this->addUpdateNotify(RouteMap::SOURCE_BLOG,$route); | 55 | $this->addUpdateNotify(RouteMap::SOURCE_BLOG,$route); |
| 56 | $this->curlDelRoute(['new_route'=>$route]); | 56 | $this->curlDelRoute(['new_route'=>$route]); |
| @@ -137,8 +137,13 @@ class BlogLogic extends BaseLogic | @@ -137,8 +137,13 @@ class BlogLogic extends BaseLogic | ||
| 137 | DB::beginTransaction(); | 137 | DB::beginTransaction(); |
| 138 | try { | 138 | try { |
| 139 | foreach ($this->param['id'] as $id){ | 139 | foreach ($this->param['id'] as $id){ |
| 140 | - $this->delRoute($id); | ||
| 141 | - $this->model->del(['id'=>$id]); | 140 | + $info = $this->model->read(['id'=>$id],['id','status']); |
| 141 | + if($info['status'] != 2){ | ||
| 142 | + $this->model->edit(['status'=>2],['id'=>$id]); | ||
| 143 | + }else{ | ||
| 144 | + $this->delRoute($id); | ||
| 145 | + $this->model->del(['id' => $id]); | ||
| 146 | + } | ||
| 142 | } | 147 | } |
| 143 | DB::commit(); | 148 | DB::commit(); |
| 144 | }catch (Exception $e){ | 149 | }catch (Exception $e){ |
| @@ -5,6 +5,7 @@ namespace App\Http\Logic\Bside\HomeCount; | @@ -5,6 +5,7 @@ namespace App\Http\Logic\Bside\HomeCount; | ||
| 5 | 5 | ||
| 6 | use App\Http\Logic\Bside\BaseLogic; | 6 | use App\Http\Logic\Bside\BaseLogic; |
| 7 | use App\Models\RouteMap\RouteMap; | 7 | use App\Models\RouteMap\RouteMap; |
| 8 | +use App\Models\Template\BCustomTemplate; | ||
| 8 | use App\Models\Visit\Visit; | 9 | use App\Models\Visit\Visit; |
| 9 | use App\Models\Visit\VisitItem; | 10 | use App\Models\Visit\VisitItem; |
| 10 | use App\Models\HomeCount\Count; | 11 | use App\Models\HomeCount\Count; |
| @@ -117,7 +118,7 @@ class CountLogic extends BaseLogic | @@ -117,7 +118,7 @@ class CountLogic extends BaseLogic | ||
| 117 | public function with_data_count(){ | 118 | public function with_data_count(){ |
| 118 | $product_count = (new Product())->where(['project_id' => $this->user['project_id']])->count(); | 119 | $product_count = (new Product())->where(['project_id' => $this->user['project_id']])->count(); |
| 119 | $news_count = (new News())->where(['project_id' => $this->user['project_id']])->count(); | 120 | $news_count = (new News())->where(['project_id' => $this->user['project_id']])->count(); |
| 120 | - $page_count = (new RouteMap())->where(['project_id' => $this->user['project_id']])->count(); | 121 | + $page_count = (new BCustomTemplate())->where(['project_id' => $this->user['project_id'],'status'=>1])->count(); |
| 121 | $data = [ | 122 | $data = [ |
| 122 | 'product_count' => $product_count, | 123 | 'product_count' => $product_count, |
| 123 | 'news_count' => $news_count, | 124 | 'news_count' => $news_count, |
| @@ -167,8 +167,13 @@ class NewsLogic extends BaseLogic | @@ -167,8 +167,13 @@ class NewsLogic extends BaseLogic | ||
| 167 | DB::beginTransaction(); | 167 | DB::beginTransaction(); |
| 168 | try { | 168 | try { |
| 169 | foreach ($this->param['id'] as $id) { | 169 | foreach ($this->param['id'] as $id) { |
| 170 | - $this->delRoute($id); | ||
| 171 | - $this->model->del(['id' => $id]); | 170 | + $info = $this->model->read(['id'=>$id],['id','status']); |
| 171 | + if($info['status'] != 2){ | ||
| 172 | + $this->model->edit(['status'=>2],['id'=>$id]); | ||
| 173 | + }else{ | ||
| 174 | + $this->delRoute($id); | ||
| 175 | + $this->model->del(['id' => $id]); | ||
| 176 | + } | ||
| 172 | } | 177 | } |
| 173 | DB::commit(); | 178 | DB::commit(); |
| 174 | } catch (Exception $e) { | 179 | } catch (Exception $e) { |
| @@ -47,7 +47,6 @@ class ProductLogic extends BaseLogic | @@ -47,7 +47,6 @@ class ProductLogic extends BaseLogic | ||
| 47 | $this->param = $this->handleSaveParam($this->param); | 47 | $this->param = $this->handleSaveParam($this->param); |
| 48 | try { | 48 | try { |
| 49 | if(isset($this->param['id']) && !empty($this->param['id'])){ | 49 | if(isset($this->param['id']) && !empty($this->param['id'])){ |
| 50 | - | ||
| 51 | $is_upgrade = $this->param['is_upgrade'] ?? 0;//1:5.0数据 0:6.0 | 50 | $is_upgrade = $this->param['is_upgrade'] ?? 0;//1:5.0数据 0:6.0 |
| 52 | $six_read = $this->param['six_read'] ?? 0;//是否按6.0显示 | 51 | $six_read = $this->param['six_read'] ?? 0;//是否按6.0显示 |
| 53 | if($is_upgrade == 0 || $six_read == 1){ | 52 | if($is_upgrade == 0 || $six_read == 1){ |
| @@ -442,7 +441,7 @@ class ProductLogic extends BaseLogic | @@ -442,7 +441,7 @@ class ProductLogic extends BaseLogic | ||
| 442 | $this->model->edit(['route'=>$route],['id'=>$save_id]); | 441 | $this->model->edit(['route'=>$route],['id'=>$save_id]); |
| 443 | //同步可视化装修数据 | 442 | //同步可视化装修数据 |
| 444 | $this->copyTemplate($this->param['id'],$info['project_id'],$save_id); | 443 | $this->copyTemplate($this->param['id'],$info['project_id'],$save_id); |
| 445 | - return $this->success(); | 444 | + return $this->success(['id'=>$save_id]); |
| 446 | } | 445 | } |
| 447 | 446 | ||
| 448 | /** | 447 | /** |
| @@ -81,8 +81,6 @@ class RatingLogic extends BaseLogic | @@ -81,8 +81,6 @@ class RatingLogic extends BaseLogic | ||
| 81 | $str = trim($str,'&'); | 81 | $str = trim($str,'&'); |
| 82 | $url = "http://www.quanqiusou.cn/extend_api/api/service_score.php?postid=$postId&token=$token&ftype=$fType&$str"; | 82 | $url = "http://www.quanqiusou.cn/extend_api/api/service_score.php?postid=$postId&token=$token&ftype=$fType&$str"; |
| 83 | $rs = http_get($url,['charset=utf-8']); | 83 | $rs = http_get($url,['charset=utf-8']); |
| 84 | - @file_put_contents(storage_path('logs/lyh_error.log'), var_export($url, true) . PHP_EOL, FILE_APPEND); | ||
| 85 | - @file_put_contents(storage_path('logs/lyh_error.log'), var_export($rs, true) . PHP_EOL, FILE_APPEND); | ||
| 86 | return $rs; | 84 | return $rs; |
| 87 | } | 85 | } |
| 88 | } | 86 | } |
| @@ -4,6 +4,7 @@ namespace App\Models\Inquiry; | @@ -4,6 +4,7 @@ namespace App\Models\Inquiry; | ||
| 4 | 4 | ||
| 5 | use App\Helper\FormGlobalsoApi; | 5 | use App\Helper\FormGlobalsoApi; |
| 6 | use App\Models\Base; | 6 | use App\Models\Base; |
| 7 | +use App\Utils\LogUtils; | ||
| 7 | use Illuminate\Database\Eloquent\SoftDeletes; | 8 | use Illuminate\Database\Eloquent\SoftDeletes; |
| 8 | use Illuminate\Support\Facades\DB; | 9 | use Illuminate\Support\Facades\DB; |
| 9 | 10 | ||
| @@ -83,7 +84,10 @@ class InquiryFormData extends Base | @@ -83,7 +84,10 @@ class InquiryFormData extends Base | ||
| 83 | $data['message'].= "<br/>" . $k .': ' . $v; | 84 | $data['message'].= "<br/>" . $k .': ' . $v; |
| 84 | } | 85 | } |
| 85 | } | 86 | } |
| 86 | - !$has_file && (new FormGlobalsoApi())->submitInquiry($ip, $referer, $submit_at, $data); | 87 | + if(!$has_file) { |
| 88 | + $res = (new FormGlobalsoApi())->submitInquiry($ip, $referer, $submit_at, $data); | ||
| 89 | + LogUtils::info('询盘提交', $data, $res?: []); | ||
| 90 | + } | ||
| 87 | } | 91 | } |
| 88 | return true; | 92 | return true; |
| 89 | } | 93 | } |
| @@ -19,11 +19,6 @@ class Project extends Base | @@ -19,11 +19,6 @@ class Project extends Base | ||
| 19 | public static $projectLocationDangerous = 1; //危险项目 | 19 | public static $projectLocationDangerous = 1; //危险项目 |
| 20 | public static $storageTypeZero = 0; //默认腾讯压缩存储桶 | 20 | public static $storageTypeZero = 0; //默认腾讯压缩存储桶 |
| 21 | public static $storageTypeOne = 1; //非压缩存储桶 | 21 | public static $storageTypeOne = 1; //非压缩存储桶 |
| 22 | - | ||
| 23 | - public static $storageTypeZeroFileFix = "ecdn6.globalso.com"; //非压缩存储桶 | ||
| 24 | - public static $storageTypeOneFileFix = "ecdn6-nc.globalso.com"; //压缩存储桶 | ||
| 25 | - public static $projectLocationDangerousFileFix = "globalso-v6.s3.us-west-2.amazonaws.com"; //危险项目存储桶 | ||
| 26 | - | ||
| 27 | //项目标识集合 | 22 | //项目标识集合 |
| 28 | public static $blockItems = "blockitems"; //html循环项父级标识 | 23 | public static $blockItems = "blockitems"; //html循环项父级标识 |
| 29 | public static $blockAttrItems = "[blockitems]"; //html循环项父级属性标识 | 24 | public static $blockAttrItems = "[blockitems]"; //html循环项父级属性标识 |
| @@ -335,6 +330,14 @@ class Project extends Base | @@ -335,6 +330,14 @@ class Project extends Base | ||
| 335 | return $value; | 330 | return $value; |
| 336 | } | 331 | } |
| 337 | 332 | ||
| 333 | + public function getWebTrafficConfigAttribute($value) | ||
| 334 | + { | ||
| 335 | + if($value){ | ||
| 336 | + $value = Arr::s2a($value); | ||
| 337 | + } | ||
| 338 | + return $value; | ||
| 339 | + } | ||
| 340 | + | ||
| 338 | /** | 341 | /** |
| 339 | * 根据域名获取项目信息 | 342 | * 根据域名获取项目信息 |
| 340 | * @author zbj | 343 | * @author zbj |
| @@ -56,7 +56,7 @@ class RouteMap extends Base | @@ -56,7 +56,7 @@ class RouteMap extends Base | ||
| 56 | if(preg_match('/[\x{4e00}-\x{9fa5}]/u', $title)){ | 56 | if(preg_match('/[\x{4e00}-\x{9fa5}]/u', $title)){ |
| 57 | $title = Translate::tran($title, 'en'); | 57 | $title = Translate::tran($title, 'en'); |
| 58 | }else{ | 58 | }else{ |
| 59 | - if(!preg_match('/^[a-zA-Z\s]+$/', $title)){ | 59 | + if(!preg_match('/[a-zA-Z]/', $title)){ |
| 60 | $title = Translate::tran($title, 'en'); | 60 | $title = Translate::tran($title, 'en'); |
| 61 | } | 61 | } |
| 62 | } | 62 | } |
| @@ -872,19 +872,21 @@ class CreatePageService{ | @@ -872,19 +872,21 @@ class CreatePageService{ | ||
| 872 | { | 872 | { |
| 873 | $projectLocation = $project->project_location; | 873 | $projectLocation = $project->project_location; |
| 874 | $storageType = $project->storage_type; | 874 | $storageType = $project->storage_type; |
| 875 | + $cos = config('filesystems.disks.cos'); | ||
| 875 | if ($projectLocation == Project::$projectLocationZero){ | 876 | if ($projectLocation == Project::$projectLocationZero){ |
| 876 | //普通项目 | 877 | //普通项目 |
| 877 | if ($storageType == Project::$storageTypeZero){ | 878 | if ($storageType == Project::$storageTypeZero){ |
| 878 | //压缩项目 | 879 | //压缩项目 |
| 879 | - $html = str_replace(Project::$storageTypeOneFileFix,Project::$storageTypeZeroFileFix,$html); | 880 | + $html = str_replace($cos['cdn1'],$cos['cdn'],$html); |
| 880 | }else{ | 881 | }else{ |
| 881 | //非压缩项目 | 882 | //非压缩项目 |
| 882 | - $html = str_replace(Project::$storageTypeZeroFileFix,Project::$storageTypeOneFileFix,$html); | 883 | + $html = str_replace($cos['cdn'],$cos['cdn1'],$html); |
| 883 | } | 884 | } |
| 884 | }else{ | 885 | }else{ |
| 886 | + $s3 = config('filesystems.disks.s3'); | ||
| 885 | //危险项目 | 887 | //危险项目 |
| 886 | - $html = str_replace(Project::$storageTypeOneFileFix,Project::$projectLocationDangerousFileFix,$html); | ||
| 887 | - $html = str_replace(Project::$storageTypeZeroFileFix,Project::$projectLocationDangerousFileFix,$html); | 888 | + $html = str_replace($cos['cdn1'],$s3['cdn'],$html); |
| 889 | + $html = str_replace($cos['cdn'],$s3['cdn'],$html); | ||
| 888 | } | 890 | } |
| 889 | return $html; | 891 | return $html; |
| 890 | } | 892 | } |
| @@ -69,7 +69,8 @@ class SyncSubmitTaskService | @@ -69,7 +69,8 @@ class SyncSubmitTaskService | ||
| 69 | ]; | 69 | ]; |
| 70 | 70 | ||
| 71 | if(Str::contains($referer, $url)){ | 71 | if(Str::contains($referer, $url)){ |
| 72 | - $referer = pathinfo($referer,PATHINFO_DIRNAME); | 72 | + $referer = parse_url($referer); |
| 73 | + $referer = !empty($referer['host']) ? $referer['scheme'] . '://' . $referer['host'] . '/' : $referer['path']; | ||
| 73 | } | 74 | } |
| 74 | return $referer; | 75 | return $referer; |
| 75 | } | 76 | } |
-
请 注册 或 登录 后发表评论