作者 张关杰

Merge branch 'develop' of http://47.244.231.31:8099/zhl/globalso-v6 into bate

... ... @@ -220,7 +220,7 @@ class VideoTask extends Command
if (count($productIds)<7){
$product_all_id = Product::where("project_id", $project_id)->whereNotIn('id', $productIds)->where("status",Product::STATUS_ON)->pluck('id')->toArray();
$number = 40;
$product_id = array_rand($product_all_id, min(count($product_all_id, $number-count($productIds))));
$product_id = array_rand($product_all_id, min($product_all_id, $number-count($productIds)));
$randomData = Product::where("project_id", $project_id)->whereIn("id", $product_id)->get();
$products = $productsQuery->merge($randomData);
}else{
... ... @@ -229,7 +229,7 @@ class VideoTask extends Command
}else{
$product_all_id = Product::where("project_id", $project_id)->where("status",Product::STATUS_ON)->pluck('id')->toArray();
$number = 40;
$product_id = array_rand($product_all_id, min(count($product_all_id, $number-count($productIds))));
$product_id = array_rand($product_all_id, min($product_all_id, $number-count($productIds)));
$products = Product::where("project_id", $project_id)->whereIn("id", $product_id)->get();
}
}
... ...
... ... @@ -780,13 +780,30 @@ class ProjectUpdate extends Command
$image = $item['images'] ?? '';
}
$new_img = $this->source_download($image, $project_id, $domain, $web_url_domain, $home_url);
//描述
if (isset($item['description']) && $item['description']) {
//匹配描述资源
$source_list = $this->html_preg($item['description'], $project_id, $domain, $web_url_domain, $home_url);
if ($source_list) {
foreach ($source_list as $vs) {
if ($vs['download']) {
//需要下载资源
$down_url = $this->source_download($vs['url_complete'], $project_id, $domain, $web_url_domain, $home_url);
} else {
//已经下载过资源
$down_url = getImageUrl($vs['url_complete']);
}
$item['description'] = str_replace($vs['url'], $down_url, $item['description']);
}
}
}
$parent_id = $model->addReturnId([
'project_id' => $project_id,
'title' => $item['name'],
'image' => $new_img,
'pid' => $pid,
'keywords' => $item['keywords'] ?? '',
'describe' => $item['description'] ?? '',
'describe' => (isset($item['description']) && $item['description']) ? $item['description'] : '',
'original_id' => $item['id'],
'route' => $route
]);
... ... @@ -978,4 +995,101 @@ class ProjectUpdate extends Command
return $key . $i;
}
}
//正则匹配html资源
protected function html_preg($html, $project_id, $domain, $web_url_domain, $home_url)
{
$source = [];
if (!$html) {
return $source;
}
//image
preg_match_all('/<img\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $html, $result_img);
$img = $result_img[2] ?? [];
foreach ($img as $vi) {
$check_vi = $this->url_check($vi, $project_id, $domain, $web_url_domain, $home_url);
if ($check_vi && (!in_array($check_vi, $source))) {
$source[] = $check_vi;
}
}
//video
preg_match_all('/<source\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $html, $result_video);
$video = $result_video[2] ?? [];
foreach ($video as $vv) {
$check_vv = $this->url_check($vv, $project_id, $domain, $web_url_domain, $home_url);
if ($check_vv && (!in_array($check_vv, $source))) {
$source[] = $check_vv;
}
}
preg_match_all('/<video\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $html, $result_video_2);
$video_2 = $result_video_2[2] ?? [];
foreach ($video_2 as $vv2) {
$check_vv2 = $this->url_check($vv2, $project_id, $domain, $web_url_domain, $home_url);
if ($check_vv2 && (!in_array($check_vv2, $source))) {
$source[] = $check_vv2;
}
}
//a标签下载资源
preg_match_all('/<a\s+[^>]*?href\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $html, $result_a);
$down = $result_a[2] ?? [];
foreach ($down as $vd) {
$check_vd = $this->url_check($vd, $project_id, $domain, $web_url_domain, $home_url);
if ($check_vd && (!in_array($check_vd, $source))) {
$source[] = $check_vd;
}
}
return $source;
}
//判断资源是否需要下载
protected function url_check($url, $project_id, $domain, $web_url_domain, $home_url)
{
$url = trim($url);
if ($url) {
$url = str_replace('&quot;', '', $url);
$arr = parse_url($url);
$scheme = $arr['scheme'] ?? '';
$host = $arr['host'] ?? '';
$path = $arr['path'] ?? '';
$query = $arr['query'] ?? '';
$path_arr = explode('.', $path);
$path_end = end($path_arr);
if (
(empty($scheme) || $scheme == 'https' || $scheme == 'http')
&& (empty($host) || (strpos($web_url_domain, $host) !== false) || (strpos($home_url, $host) !== false))
&& $path
&& (substr($path, 0, 1) == '/')
&& (strpos($path, '.') !== false)
&& (strpos($path_end, 'html') === false)
&& (strpos($path_end, 'php') === false)
&& (strpos($path_end, 'com') === false)
&& (strpos($path_end, 'xml') === false)
) {
$source = CollectSource::where('project_id', $project_id)->where('origin', $url)->first();
if (!$source) {
return [
'download' => true,
'url' => $url,
'url_complete' => ($scheme ?: 'https') . '://' . $domain . $path . ($query ? '?' . $query : '')
];
} else {
return [
'download' => false,
'url' => $url,
'url_complete' => $source['target']
];
}
} else {
return false;
}
} else {
return false;
}
}
}
... ...
... ... @@ -19,13 +19,13 @@ class Kernel extends ConsoleKernel
$schedule->command('remain_day')->dailyAt('08:00')->withoutOverlapping(1); // 项目剩余服务时长
$schedule->command('rank_data_task')->everyMinute()->withoutOverlapping(1); // 排名数据更新任务
$schedule->command('rank_data')->dailyAt('07:00')->withoutOverlapping(1); // 排名数据,每天凌晨执行一次
$schedule->command('rank_data_speed')->dailyAt('01:00')->withoutOverlapping(1); // 排名数据-测速数据,每周一凌晨执行一次
$schedule->command('rank_data_external_links')->dailyAt('01:00')->withoutOverlapping(1); // 排名数据-外链,每周一凌晨执行一次
$schedule->command('rank_data_indexed_pages')->dailyAt('01:00')->withoutOverlapping(1); // 排名数据-页面收录,每周一凌晨执行一次
$schedule->command('rank_data_recomm_domain')->dailyAt('01:00')->withoutOverlapping(1); // 排名数据-引荐域名,每周一凌晨执行一次
$schedule->command('rank_data_speed')->dailyAt('01:10')->withoutOverlapping(1); // 排名数据-测速数据,每周一凌晨执行一次
$schedule->command('rank_data_external_links')->dailyAt('01:20')->withoutOverlapping(1); // 排名数据-外链,每周一凌晨执行一次
$schedule->command('rank_data_indexed_pages')->dailyAt('01:30')->withoutOverlapping(1); // 排名数据-页面收录,每周一凌晨执行一次
$schedule->command('rank_data_recomm_domain')->dailyAt('01:40')->withoutOverlapping(1); // 排名数据-引荐域名,每周一凌晨执行一次
$schedule->command('rank_data_week')->dailyAt('01:00')->withoutOverlapping(1); // 排名数据,每周一凌晨执行一次
// $schedule->command('share_user')->dailyAt('01:00')->withoutOverlapping(1); // 清除用户ayr_share数据,每天凌晨1点执行一次
$schedule->command('count')->dailyAt('01:00')->withoutOverlapping(1); //每天凌晨1点执行一次
$schedule->command('count')->dailyAt('00:30')->withoutOverlapping(1); //每天凌晨1点执行一次
$schedule->command('service_count')->dailyAt('01:00')->withoutOverlapping(1); //服务器使用情况,每天凌晨1点执行一次
$schedule->command('web_traffic 1')->everyThirtyMinutes(); // 引流 1-3个月的项目,半小时一次
$schedule->command('web_traffic 2')->cron('*/18 * * * *'); // 引流 4-8个月的项目,18分钟一次
... ... @@ -35,7 +35,7 @@ class Kernel extends ConsoleKernel
$schedule->command('forward_count')->monthlyOn(1,'01:00')->withoutOverlapping(1);//没月月初1号执行月统计转发询盘记录
$schedule->command('inquiry_delay')->everyMinute()->withoutOverlapping(1);//TODO::上线放开,转发询盘,每分钟执行一次
$schedule->command('inquiry_count')->dailyAt('01:00')->withoutOverlapping(1); // 询盘统计数据,每天凌晨执行一次
$schedule->command('domain_info')->dailyAt('01:00')->withoutOverlapping(1);// 更新域名|证书结束时间,每天凌晨1点执行一次
$schedule->command('domain_info')->dailyAt('01:20')->withoutOverlapping(1);// 更新域名|证书结束时间,每天凌晨1点执行一次
$schedule->command('last_inquiry')->dailyAt('04:00')->withoutOverlapping(1);// 最近一次询盘信息
// $schedule->command('update_progress')->everyThirtyMinutes()->withoutOverlapping(1);//监控更新
$schedule->command('update_seo_tdk_crontab')->dailyAt('00:00')->withoutOverlapping(1); //更新上线项目TDK
... ... @@ -43,8 +43,12 @@ class Kernel extends ConsoleKernel
// $schedule->command('project_file_pdf')->dailyAt('00:00')->withoutOverlapping(1); // 网站项目数据,生成PDF文件
$schedule->command('sync_manager')->dailyAt('01:00')->withoutOverlapping(1); //TODO::手机号码同步 每天执行一次
$schedule->command('recommended_suppliers')->dailyAt('01:00')->withoutOverlapping(1); //每天凌晨1点执行一次生成推荐商
$schedule->command('recommended_suppliers')->dailyAt('03:00')->withoutOverlapping(1); //每天凌晨1点执行一次生成推荐商
$schedule->command('notice_c')->dailyAt('02:00')->withoutOverlapping(1); //每天凌晨1点执行一次生成推荐商
// 每日推送视频任务
$schedule->command('video_task')->dailyAt('01:30')->withoutOverlapping(1);
// 每日推送已完成视频任务项目生成对应界面
$schedule->command('notice_c')->dailyAt('02:00')->withoutOverlapping(1);
}
/**
... ...
... ... @@ -111,9 +111,9 @@ class OptimizationReportController extends BaseController
*/
public function currentMonthCount($domain,$project_id){
// 获取当前月的开始时间
$startTime = date('Y-m-01 00:00:00', strtotime('2024-01'));
$startTime = date('Y-m-01', strtotime($this->param['date']));
// 获取当前月的结束时间
$endTime = date('Y-m-t 23:59:59', strtotime('2024-01'));
$endTime = date('Y-m-t', strtotime($this->param['date']));
$arr = [];
$arr = $this->inquiryCount($arr,$startTime,$endTime,$domain);
$arr = $this->flowCount($arr,$startTime,$endTime,$project_id);
... ...
... ... @@ -13,6 +13,7 @@ use App\Models\Product\Product;
use App\Models\Project\OnlineCheck;
use App\Models\Project\Project;
use App\Models\RouteMap\RouteMap;
use App\Models\User\User;
use App\Services\ProjectServer;
use Illuminate\Http\Request;
... ... @@ -98,4 +99,32 @@ class PrivateController extends BaseController
}
return $this->success($result);
}
/**
* 验证当前用户是否存在
* TODO 查询手机号码是否是项目用户, 如果升级项目未上线项目return false;
* @param Request $request
* @return false|string
*/
public function hasUser(Request $request)
{
// 获取数据,初始化信息
$mobile = trim($request->input('mobile'));
$result = ['mobile' => $mobile, 'v6_user' => false];
// 获取用户,验证用户
$project_ids = User::where(['mobile' => $mobile])->pluck('project_id')->toArray();
if (empty($project_ids))
return $this->success($result);
$projects = Project::whereIn('id', $project_ids)->where('delete_status', 0)->get();
foreach ($projects as $project) {
// 如果是升级项目 并且未上线状态,不算做有效用户
if ($project->is_upgrade == Project::IS_UPGRADE_TRUE && $project->type <= Project::TYPE_ONE)
continue;
$result['v6_user'] = true;
}
return $this->success($result);
}
}
\ No newline at end of file
... ...
... ... @@ -54,7 +54,7 @@ class TranslateLogic extends BaseLogic
if($info !== false){
$data_read = json_decode($info['data'],JSON_UNESCAPED_UNICODE);
foreach ($data_read as $k => $v){
$old_key[] = $k;
$old_key[] = trim($k);
$data[] = [$k => $v];
}
}
... ... @@ -83,26 +83,9 @@ class TranslateLogic extends BaseLogic
}
}
$data = $this->unique_multidimensional_array($data);
return $this->success($data);
}
/**
* @remark :多维数组去重
* @name :unique_multidimensional_array
* @author :lyh
* @method :post
* @time :2024/3/8 16:38
*/
public function unique_multidimensional_array($array) {
// 将多维数组转换为字符串并进行去重
$uniqueArray = array_map('json_encode', $array);
// 去除重复项
$uniqueArray = array_unique($uniqueArray);
// 将字符串转换回多维数组
$uniqueArray = array_map('json_decode', $uniqueArray);
return $uniqueArray;
}
/**
* @remark :获取图片列表
... ... @@ -199,10 +182,11 @@ class TranslateLogic extends BaseLogic
if(FALSE !== strpos($country_class, 'country-flag')) {
continue;
}
$need_tran[] = htmlspecialchars_decode(html_entity_decode($string));
$need_tran[] = trim(htmlspecialchars_decode(html_entity_decode($string)));
}
$need_tran[] = $description ? $description->attr['content'] : '';
$need_tran[] = $keywords ? $keywords->attr['content'] : '';
$need_tran = array_unique($need_tran);
return $need_tran;
}
... ...
... ... @@ -2,11 +2,12 @@
namespace App\Listeners;
use Illuminate\Contracts\Queue\ShouldQueue;
use App\Enums\Common\Common;
use Illuminate\Database\Events\QueryExecuted;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Redis;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Str;
/**
* 监听数据库sql执行事件
... ... @@ -47,6 +48,33 @@ class QueryListener
$log = $log.' [ RunTime:'.$event->time.'ms ] ';
Log::debug($log);
}
//监听9644这个api_no是TM咋个被改的
if (in_array(9644, $event->bindings) && Str::contains($event->sql, 'update') && Str::contains($event->sql, '`api_no` =')) {
//记录debug 根据这个溯源
$trace = debug_backtrace();
$traces = [];
foreach ($trace as $index => $caller) {
if ($index === 0) {
continue; // 跳过当前方法的调用信息
}
$file = $caller['file'];
$line = $caller['line'];
$class = $caller['class'];
$method = $caller['function'];
$traces[] = "Method $method called from $class in file $file at line $line\n";
}
//用户信息 哪个改的 还是脚本跑的
$token = request()->header('token');
Log::channel('test')->info('api_no updated', [
'sql' => $event->sql,
'bindings' => $event->bindings,
'route' => Route::current(),
'request' => request()->all(),
'a_info' => Cache::get(Common::MANAGE_TOKEN . $token),
'b_info' => Cache::get($token),
'trace' => $traces
]);
}
}catch (\Exception $exception){
Log::error('log sql error:'.$exception->getMessage());
}
... ...
... ... @@ -72,6 +72,12 @@ return [
'via' => \App\Factory\LogFormatterFactory::class,
'prefix' => 'rank_data',
],
//测试数据日志
'test' => [
'driver' => 'custom',
'via' => \App\Factory\LogFormatterFactory::class,
'prefix' => 'test',
],
'wechatside' => [
'driver' => 'custom',
'via' => \App\Factory\LogFormatterFactory::class,
... ...
... ... @@ -24,4 +24,7 @@ Route::get('get_project_route', [\App\Http\Controllers\Api\PrivateController::cl
Route::any('get_product_images', [\App\Http\Controllers\Api\ProductController::class, 'getImages'])->name('api.get_product_images');
Route::post('inquiry_submit', [\App\Http\Controllers\Api\InquiryController::class, 'submit'])->name('api.inquiry_submit');
Route::any('getOptimizationReport', [\App\Http\Controllers\Api\OptimizationReportController::class, 'getOptimizationReport'])->name('api.getOptimizationReport');
// 视频任务回调信息
Route::post('video_task_callback', [\App\Http\Controllers\Api\NoticeController::class, 'videoTaskCallback'])->name('api.video_task_callback');
// 验证是否为6.0用户
Route::any('has_user', [\App\Http\Controllers\Api\PrivateController::class, 'hasUser'])->name('api.has_user');
... ...