作者 刘锟

Merge remote-tracking branch 'origin/master' into akun

... ... @@ -17,7 +17,6 @@ yarn-error.log
/.idea
/.vscode
composer.lock
app/Console/Commands/Test/Demo.php
app/Console/Commands/Test/DataRecovery.php
/public/upload
/public/runtime
... ...
... ... @@ -39,7 +39,7 @@ class AiBlogTask extends Command
$aiBlogTaskModel = new AiBlogTaskModel();
while (true){
$info = $aiBlogTaskModel->where('status',1)->orderBy('id','asc')->first();
if($info === false){
if(empty($info)){
sleep(30);
continue;
}
... ... @@ -52,6 +52,11 @@ class AiBlogTask extends Command
$aiBlogService->key = $aiSettingInfo['key'];
$aiBlogService->task_id = $info['task_id'];
$result = $aiBlogService->getDetail();
if(!isset($result['status'])){
//修改任务状态
$aiBlogTaskModel->edit(['status'=>3],['id'=>$info['id']]);
continue;
}
if($result['status'] != 200){
sleep(10);
continue;
... ...
... ... @@ -62,7 +62,7 @@ class InquiryDelay extends Command
* @time :2023/7/13 14:39
*/
public function inquiryForward($post_data){
$url = 'https://form.globalso.com/api/external-interface/add/fa043f9cbec6b38f';
$url = 'https://www.globalso.site/api/external-interface/add/fa043f9cbec6b38f';
$post_data_new = [];
$post_data_new['refer'] = $post_data['url'];
$post_data_new['name'] = $post_data['name'];
... ...
... ... @@ -332,17 +332,7 @@ class RelayInquiry extends Command
try {
$res = false;
foreach ($ad_task as $task){
//需要多个ip访问的国家 随机2-5次访问,只有一次询盘
if (in_array($val->country_name, $this->multiple_ip_visit_country)) {
$times = mt_rand(2, 5); //随机次数
$inquiry_time = mt_rand(1, $times); //第几次询盘
$this->output('多次访问模拟:' . $times);
for ($i = 1; $i <= $times; $i++) {
$res += $this->relayDetail($task, $val, $inquiry_time == $i);
}
}else{
$res += $this->relayDetail($task, $val);
}
$res += $this->relayDetail($task, $val);
$res += $this->relayShopDetail($task, $val);
$res += $this->relayFobDetail($task, $val);
}
... ... @@ -405,7 +395,7 @@ class RelayInquiry extends Command
* @param $form
* @return bool
*/
public function relayDetail($task, $form, $is_inquiry = true)
public function relayDetail($task, $form)
{
$this->output('获取转发对象');
if(empty($task['target'] )){
... ... @@ -441,62 +431,76 @@ class RelayInquiry extends Command
}
$this->logChannel()->info('随机域名', array_column($random_data, 'url'));
foreach ($random_data as $item) {
//手机号过滤
$phone = $form->phone;
$filter_phone = $this->get_rand($this->filter_phone);
if($filter_phone == 0){
$phone = trim(str_replace("+", '', $phone));
}elseif($filter_phone == 1){
$phone = '';
$times = 1;
$inquiry_time = 1;
//需要多个ip访问的国家 随机2-5次访问,只有一次询盘
if (in_array($form->country_name, $this->multiple_ip_visit_country)) {
$times = mt_rand(2, 5); //随机次数
$inquiry_time = mt_rand(1, $times); //第几次询盘
$this->output('多次访问模拟:' . $times);
}
for ($i = 1; $i <= $times; $i++) {
$is_inquiry = $inquiry_time == $i;
//手机号过滤
$phone = $form->phone;
$filter_phone = $this->get_rand($this->filter_phone);
if($filter_phone == 0){
$phone = trim(str_replace("+", '', $phone));
}elseif($filter_phone == 1){
$phone = '';
}
// 推送站点
$domain = $item['url'];
$is_v6 = $item['is_v6'];
$re_website = 'https://' . $domain . '/';
//urls
list($urls, $lang, $inquiry_product_url) = $this->getUrls($is_v6, $domain, $re_website, $form, $task);
if(!$urls){
continue;
}
//ip
$ip_data = $this->getIpData($form->country_name);
$ip = $ip_data->ip;
$country_name = $ip_data->ip_area;
//message
list($message, $message_id, $msg_lang) = $this->getMessage($task, $form->message, $domain, $inquiry_product_url);
$lang = $lang ?: $msg_lang;
// 推送站点
$domain = $item['url'];
$is_v6 = $item['is_v6'];
$re_website = 'https://' . $domain . '/';
$this->output('获取转发设备信息');
// 客户端 头信息 来源
$device_port = $form->email ? '1' : '2'; //1 pc 2移动端
$user_agent = $form->email ? Arr::random($this->pc_ua) : Arr::random($this->mobile_ua);
$referrer = $this->getReferer($country_name, $lang);
$this->output('写入数据');
//urls
list($urls, $lang, $inquiry_product_url) = $this->getUrls($is_v6, $domain, $re_website, $form, $task);
if(!$urls){
continue;
}
$pre = 0;
$start_time = time();
$seconds = rand(300, 7200); // 开始时间 从5-2小时后开始
$exists = ReInquiryDetail::where('re_website', $domain)->where('email', $form->email)->first();
if($exists){
$this->output('转发站点邮件已存在');
continue;
}
// 写入推送详情
$re_detail = ReInquiryDetail::createInquiry($task['id'], $form->id, $domain, $country_name, $ip, $form->full_name, $form->email, $phone, $message, $message_id, $device_port,
$user_agent, $referrer, $urls, $is_v6, date('Y-m-d H:i:s', $start_time + $seconds));
foreach ($urls as $k=>$v){
$pre++;
$seconds += rand(5,60);
ReInquiryDetailLog::createInquiryLog($re_detail->id, ReInquiryDetailLog::TYPE_VISIT, $pre, $v, date('Y-m-d H:i:s', $start_time + $seconds));
// 最后一次访问询盘 加上询盘
if($is_inquiry && $k+1 >= count($urls)){
$seconds += rand(30,120);
//ip
$ip_data = $this->getIpData($form->country_name);
$ip = $ip_data->ip;
$country_name = $ip_data->ip_area;
//message
list($message, $message_id, $msg_lang) = $this->getMessage($task, $form->message, $domain, $inquiry_product_url);
$lang = $lang ?: $msg_lang;
$this->output('获取转发设备信息');
// 客户端 头信息 来源
$device_port = $form->email ? '1' : '2'; //1 pc 2移动端
$user_agent = $form->email ? Arr::random($this->pc_ua) : Arr::random($this->mobile_ua);
$referrer = $this->getReferer($country_name, $lang);
$this->output('写入数据');
$pre = 0;
$start_time = time();
$seconds = rand(300, 7200); // 开始时间 从5-2小时后开始
if($is_inquiry) {
$exists = ReInquiryDetail::where('re_website', $domain)->where('email', $form->email)->first();
if ($exists) {
$this->output('转发站点邮件已存在');
continue;
}
}
// 写入推送详情
$re_detail = ReInquiryDetail::createInquiry($task['id'], $form->id, $domain, $country_name, $ip, $form->full_name, $form->email, $phone, $message, $message_id, $device_port,
$user_agent, $referrer, $urls, $is_v6, date('Y-m-d H:i:s', $start_time + $seconds));
foreach ($urls as $k=>$v){
$pre++;
ReInquiryDetailLog::createInquiryLog($re_detail->id, ReInquiryDetailLog::TYPE_INQUIRY, $pre, $v, date('Y-m-d H:i:s', $start_time + $seconds));
$seconds += rand(5,60);
ReInquiryDetailLog::createInquiryLog($re_detail->id, ReInquiryDetailLog::TYPE_VISIT, $pre, $v, date('Y-m-d H:i:s', $start_time + $seconds));
// 最后一次访问询盘 加上询盘
if($is_inquiry && $k+1 >= count($urls)){
$seconds += rand(30,120);
$pre++;
ReInquiryDetailLog::createInquiryLog($re_detail->id, ReInquiryDetailLog::TYPE_INQUIRY, $pre, $v, date('Y-m-d H:i:s', $start_time + $seconds));
}
}
}
}
... ... @@ -601,16 +605,20 @@ class RelayInquiry extends Command
$form_message = $message;
$message_id = 0;
// TODO 当原始询盘内容长度大于15个字符, 直接发送原始内容。
// TODO 当原始询盘内容长度大于15个字符, 60%几率直接发送原始内容。
if (strlen($message) >= 15) {
//原内容非英语,转为对应语种
if (is_numeric($form_message)) { //数字会被识别为中文
$lang = 'en';
} else {
$translateSl = Translate::translateSl($form_message);
$lang = $translateSl['texts']['sl'] ?? 'en';
$not_use_probability = AiCommand::where('key', 'fb_inquiry_text')->value('not_use_probability');
$randomNumber = rand(0, 100);
if($randomNumber < $not_use_probability){
//原内容非英语,转为对应语种
if (is_numeric($form_message)) { //数字会被识别为中文
$lang = 'en';
} else {
$translateSl = Translate::translateSl($form_message);
$lang = $translateSl['texts']['sl'] ?? 'en';
}
return [$message, $message_id, $lang??''];
}
return [$message, $message_id, $lang??''];
}
//开启文案替换
... ...
<?php
/**
* Created by PhpStorm.
* User: zhl
* Date: 2025/2/17
* Time: 11:24
*/
namespace App\Console\Commands\Inquiry;
use App\Models\Channel\Channel;
use App\Models\Domain\DomainInfo;
use App\Models\Inquiry\InquiryProject;
use App\Models\Inquiry\InquiryProjectRoute;
use App\Models\Product\Category;
use App\Models\Product\Product;
use App\Models\Project\OnlineCheck;
use App\Models\Project\Project;
use App\Services\ProjectServer;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
/**
* Class SyncInquiryProject
* @package App\Console\Commands\Inquiry
*/
class SyncInquiryProject extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'sync_inquiry_project';
/**
* The console command description.
*
* @var string
*/
protected $description = '同步询盘信息:项目以及对应路由,';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* 同步优化项目及路由
* TODO 同步v4 v5 v6项目以及路由, 删除过期项目及路由
* @return bool
*/
public function handle()
{
echo '开始同步v5' . PHP_EOL;
$this->syncGloV5();
echo '开始同步v6' . PHP_EOL;
$this->syncGloV6();
echo '删除过期数据' . PHP_EOL;
$this->deleteExpire();
return true;
}
/**
* 同步v4 、 v5项目
* @return bool
*/
public function syncGloV5()
{
$result = http_get('https://www.quanqiusou.cn/extend_api/webs/globalso_v5_tg.php');
$channel = Channel::pluck('contact_mobile', 'id')->toArray();
foreach ($result as $key=>$val)
{
echo '同步项目:' . $val['postid'] . ' - ' . $val['company'] . PHP_EOL;
// 记录渠道商, 如果渠道有问题, 记录日志, 跳过当前项目, 处理数据后, 第二天再重新同步
$channel_flag = false;
$channel_tmp = [];
foreach ($val['agent'] as $v) {
$channel_id = array_search($v, $channel);
if (empty($channel_id)) {
$this->log('ERROR 代理商找不到不记录当前项目, 代理商手机号码:' . $v);
$channel_flag = true;
break;
}
array_push($channel_tmp, $channel_id);
}
if ($channel_flag || empty($channel_tmp)) {
$this->log('ERROR 代理商找不到不记录当前项目, 项目ID:' . $val['postid']);
continue;
}
// 保存项目 以及路由
$project = InquiryProject::saveProject($val['v'], $val['postid'], $val['company'], implode(',', $channel_tmp), $val['main_url'], $val['is_split'], $val['test_url']);
$route_domain = $val['is_split'] && $val['test_url'] ? $val['test_url'] : $val['main_url'];
$this->syncGloV5Route($project->id, $route_domain);
}
return true;
}
/**
* 同步v4 v5项目路由
* @param $project_id
* @param $route_domain
* @return bool
*/
public function syncGloV5Route($project_id, $route_domain)
{
try{
$result = http_get($route_domain . 'k_u_api.php');
if (empty($result)) {
$this->log('syncGloV5Route 未获取到路由信息:' . $project_id . ', 路由获取地址:' . $route_domain . 'k_u_api.php');
return false;
}
} catch (\Exception $e) {
$this->log('syncGloV5Route 未获取到路由信息:' . $project_id . ', 路由获取地址:' . $route_domain . 'k_u_api.php' . ', 错误信息:' . $e->getMessage());
echo 'syncGloV5Route 未获取到路由信息:' . $project_id . ', 路由获取地址:' . $route_domain . 'k_u_api.php' . ', 错误信息:' . $e->getMessage() . PHP_EOL;
return false;
}
foreach ($result as $key=>$val) {
try {
$tmp = explode('|', $val);
$url_tmp = parse_url($tmp[0]);
$route = trim($url_tmp['path'], '/');
$title = str_replace('+', ' ', $tmp[1]);
if (strlen($title) > 200 || strlen($route) > 200) {
$this->log('syncGloV5Route 路由或标题过长,无效记录');
continue;
}
InquiryProjectRoute::saveProjectRoute($project_id, $title, $route);
} catch (\Exception $e) {
$this->log('syncGloV5Route 解析路径:' . $val . ', 错误信息:' . $e->getMessage());
echo 'syncGloV5Route 解析路径:' . $val . ', 错误信息:' . $e->getMessage() . PHP_EOL;
}
}
return true;
}
/**
* 同步v6项目
* @return bool
*/
public function syncGloV6()
{
// 获取优化中台项目
$project = Project::leftJoin('gl_project_online_check', 'gl_project.id', '=', 'gl_project_online_check.project_id')
->where('gl_project.type', Project::TYPE_TWO)
->where('gl_project.extend_type', '!=', 5)
->where(function ($query) {
$query->orwhere('gl_project_online_check.qa_status', OnlineCheck::STATUS_ONLINE_TRUE)
->orwhere('gl_project.is_upgrade', Project::IS_UPGRADE_TRUE);
})
->limit(5)
->get(['gl_project.id', 'gl_project.title', 'gl_project.level', 'gl_project.channel']);
// 获取所有项目域名
$domains = DomainInfo::whereIn('project_id', $project->pluck('id')->toArray())->pluck('domain', 'project_id')->toArray();
foreach ($project as $key=>$val) {
echo '同步项目:' . $val->id . ' - ' . $val->title . PHP_EOL;
// 过滤暂停优化项目, 映射类型2, model没有定义常量
if (in_array(2, $val->level))
continue;
$project = InquiryProject::saveProject(InquiryProject::VERSION_SIX, $val->id, $val->title, $val->channel['channel_id'], $domains[$val->id]);
$this->syncGloV6Route($project->id, $val->id);
}
return true;
}
/**
* 同步v6项目路由
* @param $project_id
* @param $origin_project_id
* @return bool
*/
public function syncGloV6Route($project_id, $origin_project_id)
{
ProjectServer::useProject($origin_project_id);
// TODO 产品分类标题、路由, 产品标题、路由, 同步到路由表
$category = Category::where('status', Category::STATUS_ACTIVE)->get(['title', 'route']);
foreach ($category as $key=>$val) {
InquiryProjectRoute::saveProjectRoute($project_id, $val->title, $val->route);
}
// 产品数量会比较多, 所以使用分页 同步数据
$id = 0;
while (true) {
echo '同步项目路由:' . $id . PHP_EOL;
$product = Product::where('status', Product::STATUS_ON)->where('id', '>', $id)->orderBy('id', 'asc')->limit(1000)->get(['id', 'title', 'route']);
if ($product->isEmpty())
break;
foreach ($product as $key=>$val) {
$id = $val->id;
InquiryProjectRoute::saveProjectRoute($project_id, $val->title, $val->route);
}
}
DB::disconnect('custom_mysql');
return true;
}
/**
* 删除过期数据, 非当日更新数据, 都删除, 误删第二天再重新同步更新
* @return bool
*/
public function deleteExpire()
{
$date = intval(date('Ymd'));
$project_num = InquiryProject::where('date', '<', $date)->delete();
$project_route_num = InquiryProjectRoute::where('date', '<', $date)->delete();
$this->log('删除过期项目数量:' . $project_num . ', 删除过期路由数量:' . $project_route_num);
return true;
}
/**
* 输出日志到特定的文件内, 这个文件需要定时排除内容
* @param $message
* @return bool
*/
public function log($message)
{
$message = date('Y-m-d H:i:s') . ' ' . $message . PHP_EOL;
file_put_contents(storage_path('logs/zhl/output') . date('Y-m-d') . '.log', $message, FILE_APPEND);
return true;
}
}
\ No newline at end of file
... ...
... ... @@ -243,7 +243,7 @@ class postInquiry extends Command
'source' => 5,
];
$result = Http::withoutVerifying()->timeout(30)->post('https://form.globalso.com/api/external-interface/add/fa043f9cbec6b38f', $data);
$result = Http::withoutVerifying()->timeout(30)->post('https://www.globalso.site/api/external-interface/add/fa043f9cbec6b38f', $data);
$res = $result->json();
//兼容接口返回格式
if (!empty($res['data'][0]['status'])) {
... ... @@ -255,7 +255,7 @@ class postInquiry extends Command
$log->remark = mb_substr($res['message'] ?? '', 0, 200);
$log->save();
Log::channel('inquiry_relay')->error('inquiry_relay v4|v5 inquiry error', [$result->body(), 'https://form.globalso.com/api/external-interface/add/fa043f9cbec6b38f', $data]);
Log::channel('inquiry_relay')->error('inquiry_relay v4|v5 inquiry error', [$result->body(), 'https://www.globalso.site/api/external-interface/add/fa043f9cbec6b38f', $data]);
return false;
}
return true;
... ...
<?php
/**
* @remark :
* @name :CopyOldProject.php
* @author :lyh
* @method :post
* @time :2025/2/18 14:10
*/
namespace App\Console\Commands\Project;
use App\Services\ProjectServer;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Schema;
class CopyOldProject extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'copy_project_s {old_project_id} {project_id}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'copy--复制项目';
public function handle()
{
$old_project_id = $this->argument('old_project_id');
$this->output('CopyProjectJob start, old_project_id: ' . $old_project_id);
$project_id = $this->argument('project_id');
$this->output('CopyProjectJob start, project_id: ' . $project_id);
$this->copyMysql($old_project_id,$project_id);
return true;
}
//复制数据库
public function copyMysql($project_id,$new_project_id){
//切换数据库配置
$project = ProjectServer::useProject($new_project_id);
//创建数据库
ProjectServer::createDatabase($project);
//创建表
$this->initTable($project_id,$new_project_id);
}
/**
* @remark :创建数据库
* @name :initTable
* @author :lyh
* @method :post
* @time :2023/12/11 10:09
*/
public function initTable($project_id, $news_project_id)
{
// 设置源数据库
config(['database.connections.custom_tmp_mysql_copy.database' => 'gl_data_' . $project_id]);
$database_name = DB::connection('custom_tmp_mysql_copy')->getDatabaseName();
// 获取源数据库的所有表
$tables = Schema::connection('custom_tmp_mysql_copy')->getAllTables();
$tables = array_column($tables, 'Tables_in_' . $database_name);
foreach ($tables as $table) {
// 目标数据库是否存在该表
$has_table = Schema::connection('custom_mysql')->hasTable($table);
if ($has_table) {
// 1. 删除目标数据库中的表
DB::connection('custom_mysql')->statement("DROP TABLE IF EXISTS {$table}");
}
// 2. 重新创建表
$sql = DB::connection('custom_tmp_mysql_copy')->select("SHOW CREATE TABLE {$table}");
DB::connection('custom_mysql')->statement(get_object_vars($sql[0])['Create Table']);
// 3. 跳过指定的表
if (in_array($table, [
'gl_customer_visit',
'gl_customer_visit_item',
'gl_inquiry_other',
'gl_inquiry_form_data',
'gl_inquiry_form'
])) {
continue;
}
// 4. 重新插入数据
DB::connection('custom_mysql')->table($table)->insertUsing(
[], // 插入所有列
function ($query) use ($table, $project_id) {
$name = 'gl_data_' . $project_id . '.' . $table;
$query->select('*')->from("{$name}");
}
);
// 5. 更新 project_id(如果存在)
if (Schema::connection('custom_mysql')->hasColumn($table, 'project_id')) {
DB::connection('custom_mysql')->table($table)->update(['project_id' => $news_project_id]);
}
}
return true;
}
/**
* @param $message
* @return bool
*/
public function output($message)
{
$date = date('Y-m-d H:i:s');
$output = $date . ', ' . $message . PHP_EOL;
echo $output;
Log::info($output);
return true;
}
}
... ...
... ... @@ -224,29 +224,43 @@ class CopyProject extends Command
* @method :post
* @time :2023/12/11 10:09
*/
public function initTable($project_id,$news_project_id)
public function initTable($project_id, $news_project_id)
{
config(['database.connections.custom_tmp_mysql_copy.database' => 'gl_data_'.$project_id]);
// 设置源数据库
config(['database.connections.custom_tmp_mysql_copy.database' => 'gl_data_' . $project_id]);
$database_name = DB::connection('custom_tmp_mysql_copy')->getDatabaseName();
// 获取源数据库的所有表
$tables = Schema::connection('custom_tmp_mysql_copy')->getAllTables();
$tables = array_column($tables, 'Tables_in_' . $database_name);
foreach ($tables as $table) {
// 目标数据库是否存在该表
$has_table = Schema::connection('custom_mysql')->hasTable($table);
if (!$has_table) {
$sql = DB::connection('custom_tmp_mysql_copy')->select("SHOW CREATE TABLE {$table}");
DB::connection('custom_mysql')->statement(get_object_vars($sql[0])['Create Table']);
if ($has_table) {
// 1. 删除目标数据库中的表
DB::connection('custom_mysql')->statement("DROP TABLE IF EXISTS {$table}");
}
if($table == 'gl_customer_visit' || $table == 'gl_customer_visit_item' || $table == 'gl_inquiry_other' || $table == 'gl_inquiry_form_data' || $table == 'gl_inquiry_form'){
// 2. 重新创建表
$sql = DB::connection('custom_tmp_mysql_copy')->select("SHOW CREATE TABLE {$table}");
DB::connection('custom_mysql')->statement(get_object_vars($sql[0])['Create Table']);
// 3. 跳过指定的表
if (in_array($table, [
'gl_customer_visit',
'gl_customer_visit_item',
'gl_inquiry_other',
'gl_inquiry_form_data',
'gl_inquiry_form'
])) {
continue;
}
DB::connection('custom_mysql')->table($table)->truncate(); // 清空目标表数据
// 4. 重新插入数据
DB::connection('custom_mysql')->table($table)->insertUsing(
[], // 列名数组,留空表示插入所有列
function ($query) use ($table,$project_id) {
$name = 'gl_data_'.$project_id.'.'.$table;
[], // 插入所有列
function ($query) use ($table, $project_id) {
$name = 'gl_data_' . $project_id . '.' . $table;
$query->select('*')->from("{$name}");
}
);
// 5. 更新 project_id(如果存在)
if (Schema::connection('custom_mysql')->hasColumn($table, 'project_id')) {
DB::connection('custom_mysql')->table($table)->update(['project_id' => $news_project_id]);
}
... ...
... ... @@ -9,9 +9,13 @@
namespace App\Console\Commands\Project;
use App\Helper\Common;
use App\Models\Domain\DomainInfo;
use App\Models\Project\Project;
use App\Models\WebSetting\WebSettingSeo;
use App\Models\Product\Category;
use App\Models\Product\CategoryRelated;
use App\Models\Product\Detail;
use App\Models\Product\Product;
use App\Models\RouteMap\RouteMap;
use App\Services\ProjectServer;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
... ... @@ -25,7 +29,7 @@ class DownloadProject extends Command
*
* @var string
*/
protected $signature = 'downloads_project';
protected $signature = 'downloads_products';
/**
* The console command description.
... ... @@ -34,65 +38,95 @@ class DownloadProject extends Command
*/
protected $description = '导出项目数据';
// public function handle(){
// $projectModel = new Project();
// $data = $projectModel->formatQuery(['channel'=>['like','%"channel_id": "57"%'],'delete_status'=>0])->with(['deploy_optimize'])->get()->toArray();
// if(!empty($data)){
// $result = $this->exportData($data);
// }
// echo date('Y-m-d H:i:s') . ' ' . json_encode($result) . PHP_EOL;
// return $result;
//
// }
public function handle(){
$data = [];
$projectModel = new Project();
$projectList = $projectModel->formatQuery(['delete_status'=>0,'type'=>['in',[2,3]]])->with(['deploy_optimize'])->select(['id','status','type','title','remain_day'])->get()->toArray();;
foreach ($projectList as $v){
ProjectServer::useProject($v['id']);
$seoModel = new WebSettingSeo();
$seoInfo = $seoModel->read(['project_id'=>$v['id']]);
if($seoInfo === false){
$data[] = $v;
}else{
if(empty($seoInfo['single_page_suffix'])){
$data[] = $v;
ProjectServer::useProject(1225);
$data = $this->downloadProduct();
DB::disconnect('custom_mysql');
echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
return $this->exportData($data);
}
public function downloadProduct()
{
$product = new Product();
$filed = ['id', 'project_id', 'title' ,'thumb' , 'route' ,'intro','content',
'category_id', 'status'];
$this->order = 'sort';
$lists = $product->list(['status'=>1],'id',$filed);
if(!empty($lists)){
$cate_data = $this->getCategoryList();//分类
foreach ($lists as $k => $v){
$v['url'] = 'https://www.autsikinta.com/' . getRouteMap(RouteMap::SOURCE_PRODUCT,$v['id']);
$v['category_id_text'] = $this->categoryName($v['id'],$cate_data);
//ToDo::处理图片及文件
if(!empty($v['thumb']) && !empty($v['thumb']['url'])){
$v['images'] = getImageUrl($v['thumb']['url']);
}else{
$v['images'] = '';
}
$lists[$k] = $v;
}
DB::disconnect('custom_mysql');
}
return $this->exportData($data);
echo date('Y-m-d H:i:s') . '数据详情$v:'. json_encode($lists) . PHP_EOL;
return $lists;
}
public function categoryName($product_id,$data){
$cateRelatedModel = new CategoryRelated();
$category_id = $cateRelatedModel->where('product_id',$product_id)->pluck('cate_id')->toArray();
$category_name = '';
if(!empty($category_id) && !empty($data)){
foreach ($category_id as $v){
if(isset($data[$v])){
$category_name .= $data[$v].',';
}
}
$category_name = trim($category_name,',');
}
return $category_name;
}
/**
* @remark :获取所有分类
* @name :getCategoryList
* @author :lyh
* @method :post
* @time :2023/9/14 13:56
*/
public function getCategoryList(){
$data = Common::get_user_cache('product_category',1225);
if(empty($data)){
$categoryModel = new Category();
$data = [];
$cateList = $categoryModel->list(['project_id'=>1225],['id','title']);
if(!empty($cateList)){
foreach ($cateList as $value){
$data[$value['id']] = $value['title'];
}
}
Common::set_user_cache($data,'product_category',1225);
}
return $data;
}
public function exportData($data){
// 创建一个新的 Excel 电子表格实例
$spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();
// 添加表头
$sheet->setCellValue('A1', '项目ID');
$sheet->setCellValue('B1', '项目名称');
$sheet->setCellValue('C1', '域名');
$sheet->setCellValue('D1', '状态');
$sheet->setCellValue('E1', '剩余服务时间');
$sheet->setCellValue('A1', '产品名称');
$sheet->setCellValue('B1', '产品短描述');
$sheet->setCellValue('C1', '产品内容');
$sheet->setCellValue('D1', '产品路由');
$sheet->setCellValue('E1', '产品分类');
$sheet->setCellValue('F1', '产品状态');
$sheet->setCellValue('G1', '产品主图');
$rowCount = 2;
// $allData = $this->countAll();
foreach ($data as $v) {
$domain = (new DomainInfo())->getDomain($v['deploy_optimize']['domain'] ?? 0);
if($v['type'] == 1){
$status = '建站中';
}elseif ($v['type'] == 2){
$status = '优化中';
}elseif ($v['type'] == 3){
$status = '建站后';
}else{
$status = '';
}
$sheet->setCellValue('A' . $rowCount, $v['id']);
$sheet->setCellValue('B' . $rowCount, $v['title']);
$sheet->setCellValue('C' . $rowCount, $domain);
$sheet->setCellValue('D' . $rowCount, $status);
$sheet->setCellValue('E' . $rowCount, $v['remain_day']);
$sheet->setCellValue('A' . $rowCount, $v['title']);
$sheet->setCellValue('B' . $rowCount, $v['intro']);
$sheet->setCellValue('C' . $rowCount, $v['content']);
$sheet->setCellValue('D' . $rowCount, $v['url']);
$sheet->setCellValue('E' . $rowCount, $v['category_id_text']);
$sheet->setCellValue('F' . $rowCount, '发布中');
$sheet->setCellValue('G' . $rowCount, $v['images']);
$rowCount++;
}
// 创建一个新的 Excel Writer 对象
... ...
... ... @@ -199,17 +199,17 @@ class UpdateSeoTdk extends Command
}
$project_id = $task->project_id;
echo date('Y-m-d H:i:s') . ' start project_id: ' . $project_id . PHP_EOL;
echo getmypid() . ' ' . date('Y-m-d H:i:s') . ' start project_id: ' . $project_id . PHP_EOL;
try {
$this->project = ProjectServer::useProject($project_id);
$this->seo_tdk($project_id, $task->id);
DB::disconnect('custom_mysql');
}catch (\Exception $e){
echo date('Y-m-d H:i:s') . 'line: '. $e->getLine() .' error: ' . $project_id . '->' . $e->getMessage() . PHP_EOL;
echo getmypid() . ' ' . date('Y-m-d H:i:s') . 'line: '. $e->getLine() .' error: ' . $project_id . '->' . $e->getMessage() . PHP_EOL;
ProjectUpdateTdk::retry($task->id, $e->getMessage());
}
Cache::forget('project_deploy_optimize_info_' . $project_id);
echo date('Y-m-d H:i:s') . ' end project_id: ' . $project_id . PHP_EOL;
echo getmypid() . ' ' . date('Y-m-d H:i:s') . ' end project_id: ' . $project_id . PHP_EOL;
}
}
public function sendNotify($project_id, $route)
... ... @@ -234,7 +234,7 @@ class UpdateSeoTdk extends Command
'language'=> [],
];
http_post($url, json_encode($param));
echo '更新中请稍后, 更新完成将会发送站内信通知更新结果!'. PHP_EOL;
echo getmypid() . ' ' . '更新中请稍后, 更新完成将会发送站内信通知更新结果!'. PHP_EOL;
}
public function seo_tdk($project_id, $task_id)
{
... ... @@ -246,7 +246,7 @@ class UpdateSeoTdk extends Command
foreach ($this->maps as $table => $map) {
$total_page = DB::connection('custom_mysql')->table($table)->count();
$update[$table] = ['total_page'=>$total_page, 'title'=>0, 'keyword'=>0, 'des'=>0,'keyword_title'=>0,'keyword_content'=>0];
echo date('Y-m-d H:i:s') . '更新--' . $table . ': 项目id' . $project_id . PHP_EOL;
echo getmypid() . ' ' . date('Y-m-d H:i:s') . '更新--' . $table . ': 项目id' . $project_id . PHP_EOL;
$list = DB::connection('custom_mysql')->table($table)
->where(function ($query) use ($table, $map){
if($table == 'gl_product'){
... ... @@ -280,7 +280,7 @@ class UpdateSeoTdk extends Command
}
echo date('Y-m-d H:i:s') . '更新--' . $table . ': 项目id' . $project_id . ':id' . $v['id'] . PHP_EOL;
echo getmypid() . ' ' . date('Y-m-d H:i:s') . '更新--' . $table . ': 项目id' . $project_id . ':id' . $v['id'] . PHP_EOL;
$v = DB::connection('custom_mysql')->table($table)->where('id', $v['id'])->first();
$v = (array)$v;
$data = [];
... ... @@ -295,7 +295,7 @@ class UpdateSeoTdk extends Command
}
//已有值的 跳过
if ($value) {
echo $field.'已有值 跳过' . PHP_EOL;
echo getmypid() . ' ' . $field.'已有值 跳过' . PHP_EOL;
continue;
}
... ... @@ -335,8 +335,8 @@ class UpdateSeoTdk extends Command
}
else if ($table == 'gl_product_keyword' && $field == 'seo_title') {
# TODO 聚合页seo title 特殊处理 前缀_1 . 关键词 . 后缀_2
$prefix = $this->getPrefixKeyword($project_id, 'prefix', 1);
$suffix = $this->getPrefixKeyword($project_id, 'suffix', 2);
$prefix = $this->getPrefixKeyword($project_id, 'prefix', 1, $v[$this->topic_fields[$table]]);
$suffix = $this->getPrefixKeyword($project_id, 'suffix', 2, $v[$this->topic_fields[$table]]);
if (empty($prefix) || empty($suffix))
continue;
$seo_title = $prefix . ' ' . $v[$this->topic_fields[$table]] . ' ' . $suffix;
... ... @@ -423,7 +423,7 @@ class UpdateSeoTdk extends Command
if(strpos($prompt, '{topic}') !== false){
$topic = $data[$this->topic_fields[$table]] ?? '';
if(!$topic){
echo 'topic为空 跳过' . PHP_EOL;
echo getmypid() . ' ' . 'topic为空 跳过' . PHP_EOL;
return false;
}
$prompt = str_replace('{topic}', $topic, $prompt);
... ... @@ -432,7 +432,7 @@ class UpdateSeoTdk extends Command
if(strpos($prompt, '{keyword}') !== false) {
$keyword = $this->mainKeywords($project_id, 1);
if(!$keyword){
echo '核心关键词为空 跳过' . PHP_EOL;
echo getmypid() . ' ' . '核心关键词为空 跳过' . PHP_EOL;
return false;
}
$prompt = str_replace('{keyword}', $keyword, $prompt);
... ... @@ -441,7 +441,7 @@ class UpdateSeoTdk extends Command
if(strpos($prompt, '{company name}') !== false) {
$company_name = $this->companyName($project_id);
if(!$company_name){
echo '公司英文全称为空 跳过' . PHP_EOL;
echo getmypid() . ' ' . '公司英文全称为空 跳过' . PHP_EOL;
return false;
}
$prompt = str_replace('{company name}', $company_name, $prompt);
... ... @@ -450,7 +450,7 @@ class UpdateSeoTdk extends Command
if(strpos($prompt, '{company detail}') !== false) {
$company_detail = $this->companyName($project_id, 'company_detail');
if(!$company_detail){
echo '公司英文描述为空 跳过' . PHP_EOL;
echo getmypid() . ' ' . '公司英文描述为空 跳过' . PHP_EOL;
return false;
}
$prompt = str_replace('{company detail}', $company_detail, $prompt);
... ... @@ -460,7 +460,7 @@ class UpdateSeoTdk extends Command
foreach ($matches[0] as $key=>$val) {
$keyword = $this->getPrefixKeyword($project_id, 'prefix', $matches[1][$key]);
if(!$keyword){
echo '前缀关键词为空 跳过' . PHP_EOL;
echo getmypid() . ' ' . '前缀关键词为空 跳过' . PHP_EOL;
return false;
}
$prompt = str_replace($val, $keyword, $prompt);
... ... @@ -471,7 +471,7 @@ class UpdateSeoTdk extends Command
foreach ($matches[0] as $key=>$val) {
$keyword = $this->getPrefixKeyword($project_id, 'suffix', $matches[1][$key]);
if(!$keyword){
echo '前缀关键词为空 跳过' . PHP_EOL;
echo getmypid() . ' ' . '前缀关键词为空 跳过' . PHP_EOL;
return false;
}
$prompt = str_replace($val, $keyword, $prompt);
... ... @@ -482,7 +482,7 @@ class UpdateSeoTdk extends Command
if(strpos($prompt, '{core keywords 8}') !== false) {
$main_keyword = $this->mainKeywords($project_id, 8);
if(!$main_keyword){
echo '核心关键词为空 跳过' . PHP_EOL;
echo getmypid() . ' ' . '核心关键词为空 跳过' . PHP_EOL;
return false;
}
$prompt = str_replace('{core keywords 8}', $main_keyword, $prompt);
... ... @@ -499,12 +499,31 @@ class UpdateSeoTdk extends Command
* @param $num
* @return string
*/
public function getPrefixKeyword($project_id, $type, $num)
public function getPrefixKeyword($project_id, $type, $num, $topic='')
{
$str = '';
$info = $this->getDeployOptimize($project_id);
if (!empty($info['keyword_' . $type])) {
$fix_keyword = explode(",", $info['keyword_' . $type]);
//去掉标题存在的词
if ($topic) {
foreach ($fix_keyword as $k=>$keyword) {
//处理单词复数 s es ies ves
$keyword = rtrim($keyword, 'ves');
$keyword = rtrim($keyword, 'ies');
$keyword = rtrim($keyword, 'es');
$keyword = rtrim($keyword, 's');
$topic_words = explode(" ", $topic);
if($type == 'prefix' && Str::startsWith($topic_words[0], $keyword)){
unset($fix_keyword[$k]);
}
if($type == 'suffix' && Str::startsWith($topic_words[count($topic_words)-1], $keyword)){
unset($fix_keyword[$k]);
}
}
}
//随机取
shuffle($fix_keyword);
if (count($fix_keyword) < $num)
... ... @@ -592,6 +611,8 @@ class UpdateSeoTdk extends Command
$text = Gpt::instance()->openai_chat_qqs($prompt);
if (!$text) {
echo getmypid() . ' ' . '生成失败' . PHP_EOL;
$cache_key = "ai_error_times_{$project_id}_{$table}_{$id}";
if (!Cache::get($cache_key)) {
Cache::put($cache_key, 0, 7 * 24 * 3600);
... ...
<?php
/**
* Created by PhpStorm.
* User: zhl
* Date: 2023/2/7
* Time: 17:58
*/
namespace App\Console\Commands\Test;
use App\Helper\Arr;
use App\Helper\Translate;
use App\Mail\TextMail;
use App\Models\Blog\Blog;
use App\Models\Blog\BlogCategory;
use App\Models\Com\KeywordVideoTask;
use App\Models\Com\KeywordVideoTaskLog;
use App\Models\CustomModule\CustomModuleCategory;
use App\Models\CustomModule\CustomModuleContent;
use App\Models\CustomModule\CustomModuleExtentContent;
use App\Models\Devops\ServerConfig;
use App\Models\Devops\Servers;
use App\Models\Devops\ServersIp;
use App\Models\ExtentModule\ExtensionModuleValue;
use App\Models\File\File;
use App\Models\File\File as FileModel;
use App\Models\File\Image;
use App\Models\File\Image as ImageModel;
use App\Models\News\News;
use App\Models\News\NewsCategory;
use App\Models\Product\Keyword;
use App\Models\Product\KeywordRelated;
use App\Models\Product\Product;
use App\Models\Project\AutoEmailLog;
use App\Models\Project\DeployOptimize;
use App\Models\Project\MinorLanguages;
use App\Models\Project\Project;
use App\Models\Purchaser\Purchaser;
use App\Models\Purchaser\PurchaserInfo;
use App\Models\RouteMap\RouteMap;
use App\Models\Template\BCustomTemplate;
use App\Models\Template\BTemplateCom;
use App\Models\Template\Setting;
use App\Models\Template\Template;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Facades\Schema;
class Demo extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'demo';
/**
* The console command description.
*
* @var string
*/
protected $description = 'demo';
public function handle(){
// echo date('Y-m-d H:i:s') . 'project_id:' . PHP_EOL;
// ProjectServer::useProject(3092);
// $this->delProduct();
// DB::disconnect('custom_mysql');
// echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
return $this->projectList();
}
public function toQueue(){
$info = [
'email' => '1123736022@qq.com', // 收件人邮箱
'title' => '测试邮件', // 邮件标题
'content' => '这是来自163邮箱的测试邮件', // 邮件内容
];
Config::set('mail.mailers.smtp.host', 'smtp.163.com');
Config::set('mail.mailers.smtp.username', 'lyh103433@163.com');
Config::set('mail.mailers.smtp.password', 'BMf8B327Nhncunnb');
Config::set('mail.from.address', 'lyh103433@163.com');
Config::set('mail.from.name', 'lyh');
try {
$status = AutoEmailLog::STATUS_SUCCESS;
Mail::to([$info['email']])->send(new TextMail(['subject' => $info['title'], 'text' => $info['content']]));
} catch (\Exception $e) {
$status = AutoEmailLog::STATUS_ERROR;
$this->output('任务:' . $info['id'] . ' 邮箱' . $info['email'] . '发送失败,' . $e->getMessage());
}
return $status;
}
public function projectList(){
$data = '深圳澄通睿视科技有限公司, 日照源洋包装材料有限公司, 河北途铂机电设备有限责任公司, 宁波市海曙玖鼎纸制品有限公司, 青岛众瑞智能仪器有限公司, 河北新秋国际贸易有限公司, 江西乔森电气有限公司, 沧州艾斯克粉业制造有限公司, 上海希然化工科技有限公司, 石家庄中创进出口有限公司, 东光县恒创利纸箱机械有限公司2021, 天津正能管业有限公司, 河北帷幄纺织有限公司, 广东顺德宝绅源环保科技有限公司, 石家庄艾文尔生物科技有限公司, 浙江福俄电气有限公司, 深圳市嘉盛数据科技有限公司, 江西米德实业有限公司, 苏州稼瑞机械有限公司, 青岛卓亚塑料机械有限公司, 宁波中力螺栓制造有限公司, 中山市万格电器有限公司, 廊坊禹神节水灌溉技术有限公司, 山东索玛特制帽有限公司, 蓝启生物技术(深圳)有限公司, 南宁奥展五金紧固件有限公司, 河北茉悠科技有限公司, 莱科阀门(天津)有限公司, 四川零点自动化系统有限公司, 厦门市戴尔乐新能源汽车有限公司, 宁波爱克利浦电器有限公司, 扬州天定成玩具礼品有限公司, 宁波市金典照明电器有限公司, 杭州法埃姆斯钢构有限公司, 北京迪文科技有限公司, 无锡动为储能科技有限公司, 河北唐蕴生物科技有限公司, 绍兴苏尔黛纺织品有限公司, 河北祈强金属制品有限公司, 上池诊断科技(深圳)有限公司, 泉州市三颖超硬工具有限公司, 宁波杰广电子有限公司, 石家庄德烨管业有限公司, 山东凯特钻具有限公司, 北京思普瑞特科技发展有限公司, 广州市印科标识科技有限公司, 优之科技(深圳)有限公司, 南通赫美特国际贸易有限公司, 天津誉瑞特品科技有限公司, 河北坤焰建材科技有限公司, 绍兴睿博机械有限公司, 西安法斯拓进出口有限公司, 深圳市德诺威电子有限公司, 百润(中国)有限公司, 达时科科技有限责任公司, 陈海英, 四川蓉腾自动化设备有限公司, 石家庄晋吉建材科技有限公司, 石家庄安瑞科气体机械有限公司, 深圳市扬帆纸制品有限公司, 舟山威尔曼机械科技有限公司, 佰纳通科技(北京)有限公司, 宁波嘉佑行科技有限公司, 东莞市凯信脚轮有限公司, 宝鸡轩泰颜料科技有限公司, 东莞市华腾五金制品有限公司, 深圳市思锐宇光电有限公司, 东莞市奥彩数码科技有限公司, 上海垂普国际贸易有限公司, 扬州爱拓户外用品有限公司, 余姚市立鑫电子有限公司, 晋州市金昌盛化工有限公司, 广东阿酷达箱包科技有限公司, 泉州市杰斯特仪器设备有限公司, 三和长兴科技有限公司, 佛山市精一家具有限公司谷腾分公司, 天津市洁雅妇女卫生保健制品有限公司, 江西海瑞天然植物有限公司, 九江贝海玻纤有限公司(客户做新站), 瑞安市齐笙科技有限公司, 石家庄华圣方洲国际贸易有限公司, 深圳市方成教学设备有限公司, 连云港索娜斯贸易有限公司, 睿華電子有限公司, 扬州市极盛照明有限公司, 天津市实丰国际贸易有限责任公司, 厦门亚迅工贸有限公司, 威海旺展旅游用品有限公司, 宁波首安纸业有限公司, 浙江乐马电气有限公司, 广东金莱特智能科技有限公司, 河北科星药业有限公司, 宁波迈可森汽配有限公司, 邯郸市常岚紧固件制造有限公司, 宁波市晶艳贸易有限公司, 苏州荃华生物材料有限公司, 青岛洛城通信息科技有限公司, 合肥领派克机械设备有限公司, 广西绿城工贸有限公司, 一元电气科技有限公司【主站】, 立圣丰(厦门)纺织科技有限公司, 深圳市汉瑞通科技有限公司, 扬州市润芳塑胶包装材料有限公司, 扬州浩邦新能源科技有限公司项目2, 深圳市锦昊安科技有限公司, 四川途乐乐科技有限公司, 天津广大纸业股份有限公司, 西安禾为生物科技有限公司, 西安奥谷生物科技有限公司, 佛山市三水歌谷电器有限公司, 西安麦克斯农用化学有限公司, 瑞安市富锐思进出口有限公司(黑格客户), 北京新科以仁科技发展有限公司, 镇江市惠灵顿膜业有限公司';
$arr = explode(',',$data);
$projectModel = new Project();
$opModel = new DeployOptimize();
foreach ($arr as $k => $v){
$v = trim($v);
$info = $projectModel->read(['title'=>['like','%'.$v.'%']],['id']);
if($info === false){
echo date('Y-m-d H:i:s') . '未查询到的项目--'.$v . PHP_EOL;
}else{
$opInfo = $opModel->read(['project_id'=>$info['id']]);
if (strpos($opInfo['special'], '15') !== false) {
echo date('Y-m-d H:i:s') . '已包含' . PHP_EOL;
} else {
if(!empty($opInfo['special'])){
$special = ','.trim($opInfo['special'],',').',15,';
}else{
$special = ',15,';
}
$opModel->edit(['special'=>$special],['id'=>$opInfo['id']]);
echo date('Y-m-d H:i:s') . '未包含AI案例的project_id:'.$opInfo['project_id'] . PHP_EOL;
}
}
}
echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
return true;
}
/**
* @remark :删除product
* @name :delProduct
* @author :lyh
* @method :post
* @time :2025/1/10 9:35
*/
public function delProduct(){
$productModel = new Product();
$list = $productModel->list(['status'=>2]);
foreach ($list as $k => $v){
$routeModel = new RouteMap();
$routeModel->del(['source'=>'product','source_id'=>$v['id']]);
}
$productModel->del(['status'=>2]);
return true;
}
/**
* @remark :统计当前模版使用情况
* @name :countTemplate
* @author :lyh
* @method :post
* @time :2025/1/9 10:59
*/
public function countTemplate(){
$bSettingModel = new Setting();
$lists = $bSettingModel->list();
$templateModel = new Template();
foreach ($lists as $v){
echo date('Y-m-d H:i:s') . '执行的模版id:' .$v['template_id'] . PHP_EOL;
$templateModel->where(['id'=>$v['template_id']])->increment('number',1);
}
return true;
}
/**
* @remark :更新产品
* @name :getProduct
* @author :lyh
* @method :post
* @time :2024/11/27 15:40
*/
public function getProduct(){
$productModel = new Product();
$lists = $productModel->list(['status'=>['!=',3]]);
if(!empty($lists)){
foreach ($lists as $v){
if(!empty($v['keyword_video_id'])){
foreach ($v['keyword_video_id'] as $val){
$keywordRelaModel = new KeywordRelated();
echo date('Y-m-d H:i:s') . 'keyword_id :'.$val . 'product_id :'.$v['id'] . PHP_EOL;
$keywordRelaModel->edit(['type'=>2],['keyword_id'=>$val,'product_id'=>$v['id']]);
}
}
}
}
}
/**
* @remark :复制表及结构
* @name :copyProduct
* @author :lyh
* @method :post
* @time :2024/11/27 16:09
*/
public function copyProduct(){
$tableName = 'gl_product';
$copyTableName = 'gl_product_c';
if (Schema::connection('custom_mysql')->hasTable($copyTableName)) {
DB::connection('custom_mysql')->statement("DROP TABLE {$copyTableName}");
}
// 创建新表并复制数据
DB::connection('custom_mysql')->statement("CREATE TABLE {$copyTableName} LIKE {$tableName}");
DB::connection('custom_mysql')->statement("INSERT INTO {$copyTableName} SELECT * FROM {$tableName}");
}
/**
* @remark :保存供应商详情
* @name :savePurchaserInfo
* @author :lyh
* @method :post
* @time :2024/5/29 16:38
*/
public function savePurchaserInfo(){
$purchaserModel = new Purchaser();
$list = $purchaserModel->list();
foreach ($list as $val){
$project_id = $val['project_id'];
$keyword = $val['keyword'];
$data = json_decode($val['data'],JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
$purchaserInfoModel = new PurchaserInfo();
if(!empty($data)){
foreach ($data as $k =>$v){
$v['project_id'] = $project_id;
$v['keyword'] = $keyword;
$v['email'] = json_encode($v['email'] ?? [],JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
$v['mobile'] = json_encode($v['mobile'] ?? [],JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
$v['social_media'] = json_encode($v['social_media'] ?? [],JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
$v['image'] = str_replace('admin.hagro.cn','fob.ai.cc',$v['image'] ?? '');
$param = $v;
$info = $purchaserInfoModel->read(['keyword'=>$keyword,'buyer_id'=>$v['buyer_id'] ?? '','project_id'=>$project_id],['id']);
if($info === false){
echo date('Y-m-d H:i:s') . '执行新增 :' . PHP_EOL;
$purchaserInfoModel->add($param);
}else{
echo date('Y-m-d H:i:s') . '数据已存在 :'.$info['id'] . PHP_EOL;
}
}
}
}
return true;
}
}
... ... @@ -23,7 +23,10 @@ use App\Models\RouteMap\RouteMap;
use App\Models\Template\BTemplate;
use App\Models\Template\Setting;
use App\Services\ProjectServer;
use App\Utils\HttpUtils;
use GuzzleHttp\Exception\GuzzleException;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
... ... @@ -58,26 +61,36 @@ class UpdateRoute extends Command
* @time :2023/11/20 15:13
*/
public function handle(){
$projectModel = new Project();
$list = $projectModel->list(['delete_status'=>['=',0],'id'=>2902]);
foreach ($list as $v){
echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
ProjectServer::useProject($v['id']);
$this->getProduct();
DB::disconnect('custom_mysql');
}
echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
$data = $this->ceshi();
echo date('Y-m-d H:i:s') . 'end'.json_encode($data) . PHP_EOL;
}
public function ceshi($project_id){
$templateModel = new BTemplate();
$info = $templateModel->orderBy('id','desc')->first();
if(!empty($info)){
$webSettingModel = new Setting();
$webSettingModel->add(['template_id'=>$info->template_id,'project_id'=>$project_id]);
public function ceshi($api_no = null)
{
$key = 'extend_projects_list';
$data = Cache::get($key);
if (!$data) {
$api_url = 'http://api.quanqiusou.cn/google-rank/api/extend_projects.php';
try {
$data = HttpUtils::get($api_url, []);
if ($data) {
$data = Arr::s2a($data);
Cache::put($key, $data, 4 * 3600);
}
} catch (\Exception | GuzzleException $e) {
errorLog('复制站点项目获取失败', [], $e);
return false;
}
}
if ($api_no !== null) {
$data = collect($data)->where('apino', $api_no)->first();
return $data ?: [];
}
return $data;
}
/**
* @remark :更新产品
* @name :updateProduct
... ... @@ -111,11 +124,11 @@ class UpdateRoute extends Command
*/
public function custom_to_blogs(){
$customContentModel = new CustomModuleContent();
$lists = $customContentModel->list(['module_id'=>9]);
$lists = $customContentModel->list(['module_id'=>8]);
foreach ($lists as $k => $v){
$data = [
'name'=>$v['name'],
'category_id'=>',1,',
'category_id'=>',1,2,',
'remark'=>$v['remark'],
'text'=>$v['content'],
'url'=>$v['route'],
... ... @@ -123,7 +136,7 @@ class UpdateRoute extends Command
'seo_title'=>$v['seo_title'],
'seo_description'=>$v['seo_description'],
'seo_keywords'=>$v['seo_keywords'],
'project_id'=>1750,
'project_id'=>1462,
'operator_id'=>$v['operator_id'],
'create_id'=>$v['operator_id'],
'created_at'=>$v['created_at'],
... ... @@ -132,8 +145,8 @@ class UpdateRoute extends Command
];
$blogModel = new Blog();
$id = $blogModel->insertGetId($data);
RouteMap::setRoute($v['route'], RouteMap::SOURCE_BLOG, $id, 1750);
}
return true;
}
public function editProductAlt(){
... ...
... ... @@ -17,7 +17,7 @@ use GuzzleHttp\Exception\GuzzleException;
class FormGlobalsoApi
{
//接口地址
protected $url = 'https://form.globalso.com';
protected $url = 'https://www.globalso.site';
/**
* 设置询盘通知
... ... @@ -179,7 +179,7 @@ class FormGlobalsoApi
'num'=>15,
];
$queryString = http_build_query($data);
$url = "https://form.globalso.com/api/external-interface/domain_con/15243d63ed5a5738?".$queryString;
$url = "https://www.globalso.site/api/external-interface/domain_con/15243d63ed5a5738?".$queryString;
try {
$res = http_get($url,['charset=utf-8']);
} catch (\Exception | GuzzleException $e) {
... ... @@ -207,7 +207,7 @@ class FormGlobalsoApi
'sta_date'=>$month,
];
$queryString = http_build_query($data);
$url = 'https://form.globalso.com/api/external-interface/country_con/15243d63ed5a5738?'.$queryString;
$url = 'https://www.globalso.site/api/external-interface/country_con/15243d63ed5a5738?'.$queryString;
$res = http_get($url,['charset=utf-8']);
echo date('Y-m-d H:i:s') . '数据:'.json_encode($res) . PHP_EOL;
return $res;
... ...
... ... @@ -69,12 +69,23 @@ class Gpt
->withBody(json_encode($data, JSON_UNESCAPED_UNICODE), 'application/json')
->post($url);
$json = $result->json();
// $client = new \GuzzleHttp\Client();
// $result = $client->request('POST', $url, [
// 'proxy' => 'http://104.255.171.237:51395', // 代理服务器地址和端口号
// 'headers' => $this->header,
// 'json' => $data,
// 'verify' => false,
// ])->getBody()->getContents();
// $json = json_decode($result, true);
if (!isset($json['text']) || $json['code'] !==200) {
Log::error('openai_chat_qqs data:', $data);
Log::error('openai_chat_qqs result:' . (time() - $time), $json === null ? ['null'] : $json);
$json = [];
}
} catch (\Throwable $e) {
Log::error('openai_chat_qqs data:', $data);
Log::error('openai_chat_qqs time ' . (time() - $time) . ' error:' . $e->getMessage());
$json = [];
}
... ...
... ... @@ -501,7 +501,7 @@ if (!function_exists('getInquiryInformation')) {
{
$token = md5($domain . date("Y-m-d"));
$source = '1,3';
$url = "https://form.globalso.com/api/external-interface/country_con/15243d63ed5a5738?domain={$domain}&token={$token}&source={$source}&sta_date={$sta_date}";
$url = "https://www.globalso.site/api/external-interface/country_con/15243d63ed5a5738?domain={$domain}&token={$token}&source={$source}&sta_date={$sta_date}";
$client = new Client(['verify' => false]);
$http = $client->get($url);
$data = [];
... ...
... ... @@ -14,6 +14,8 @@ use App\Http\Controllers\Aside\BaseController;
use App\Http\Logic\Aside\Devops\ServersLogic;
use App\Models\Devops\Servers as ServersModel;
use App\Models\Devops\ServersIp;
use App\Models\Domain\DomainInfo;
use App\Models\Project\DeployOptimize;
use App\Models\Project\Project;
class ServersController extends BaseController
... ... @@ -59,6 +61,22 @@ class ServersController extends BaseController
}
unset($this->map['project_name']);
}
if(isset($this->map['domain']) && !empty($this->map['domain'])){
$domainModel = new DomainInfo();
$domainInfo = $domainModel->read(['domain'=>['like','%'.$this->map['domain'].'%']],['id','project_id']);
if($domainInfo !== false && !empty($domainInfo['project_id'])){
$projectModel = new Project();
$projectInfo = $projectModel->read(['id'=>$domainInfo['project_id']],['serve_id']);
if($projectInfo !== false){
$serversIpModel = new ServersIp();
$ipInfo = $serversIpModel->read(['id'=>$projectInfo['serve_id']],['servers_id']);
if($ipInfo !== false){
$this->map['id'] = $ipInfo['servers_id'];
}
}
}
unset($this->map['domain']);
}
$serversModel = new ServersModel();
$data = $serversModel->lists($this->map,$this->page,$this->row,$this->order);
$this->response('success',Code::SUCCESS,$data);
... ... @@ -76,7 +94,6 @@ class ServersController extends BaseController
'id'=>'required'
],[
'id.required' => '主键不能为空'
]);
$data = $serversLogic->infoServers();
$this->response('success',Code::SUCCESS,$data);
... ...
... ... @@ -34,10 +34,10 @@ class AiBlogController extends BaseController
* @time :2025/2/14 13:59
*/
public function getAiBlog(AiBlog $aiBlog){
$lists = $aiBlog->lists($this->map,$this->page,$this->row,'id',['id','new_title','task_id','status','created_at','updated_at']);
$lists = $aiBlog->lists($this->map,$this->page,$this->row,'id',['id','new_title','image','task_id','status','created_at','updated_at']);
if(!empty($lists) && !empty($lists['list'])){
foreach ($lists['list'] as $k => $v){
$v['image'] = getImageUrl($v['url'],$this->user['storage_type'],$this->user['project_location']);
$v['image'] = getImageUrl($v['image'],$this->user['storage_type'],$this->user['project_location']);
$lists['list'][$k] = $v;
}
}
... ... @@ -54,10 +54,12 @@ class AiBlogController extends BaseController
public function sendTask(AiBlogLogic $aiBlogLogic){
$this->request->validate([
'keyword'=>['required'],
'type'=>['required']
'type'=>['required'],
'route'=>['required']
],[
'keyword.required' => '关键字不能为空',
'type.required' => '场景不能为空',
'route.required' => '路由不能为空',
]);
//获取当前项目的ai_blog设置
$result = $aiBlogLogic->sendTask();
... ...
... ... @@ -121,6 +121,10 @@ class ComController extends BaseController
if($is_comment != 1){
$info['role_menu'] = trim(str_replace(',55,',',',','.$info['role_menu'].','),',');
}
$is_blogs = $this->getIsBlog();
if($is_blogs != 1){
$info['role_menu'] = trim(str_replace(',57,',',',','.$info['role_menu'].','),',');
}
$this->map = [
'status'=>0,
'is_role'=>0,
... ... @@ -165,6 +169,10 @@ class ComController extends BaseController
if($is_comment != 1){
$data[] = 55;
}
$is_ai_blog = $this->getIsAiBlog();
if($is_ai_blog != 1){
$data[] = 57;
}
if(!empty($data)){
$this->map['id'] = ['not in',$data];
}
... ... @@ -236,7 +244,7 @@ class ComController extends BaseController
public function getIsSubscribe(){
return $this->project['is_subscribe'];
return $this->project['is_subscribe'] ?? 0;
}
/**
... ... @@ -251,26 +259,33 @@ class ComController extends BaseController
}
/**
* @remark :是否开启了ai——blog
* @name :getIsAiBlog
* @author :lyh
* @method :post
* @time :2025/2/19 9:39
*/
public function getIsAiBlog(){
return $this->user['is_ai_blog'] ?? 0;
}
/**
* @name :登录用户编辑资料/修改密码
* @author :liyuhang
* @method
*/
public function edit_info(){
$this->request->validate([
// 'oldPassword'=>'required',
'password' => 'required',
'confirm'=>'required',
], [
// 'oldPassword.required' => '请输入原密码',
'password.required' => '请输入新密码',
'confirm.required' => '请再次输入新密码',
]);
//查询员密码是否正确
$userModel = new User();
$info = $userModel->read(['id'=>$this->user['id']]);
// if($info['password'] != base64_encode(md5($this->param['oldPassword']))){
// $this->response('原密码错误',Code::USER_ERROR);
// }
if($this->param['password'] != $this->param['confirm']){
$this->response('两次密码不一致');
}
... ... @@ -408,7 +423,6 @@ class ComController extends BaseController
*/
public function month_counts(){
shell_exec('php artisan month_project '.$this->user['project_id']);
// Artisan::call('month_project '.$this->user['project_id']);
$this->response('重新刷新中,请稍后刷新查询');
}
}
... ...
... ... @@ -77,6 +77,9 @@ class SuppliersController extends BaseController
if(isset($res['status_code']) && $res['status_code'] != 200){
$this->response($res['message'],Code::SYSTEM_ERROR);
}
if(isset($res['data']['image']) && !empty($res['data']['image'])){
$res['data']['image'] = str_replace('admin.hagro.cn','fob.ai.cc',$res['data']['image']??'');
}
return $this->success($res['data'] ?? []);
}
/**
... ... @@ -134,8 +137,12 @@ class SuppliersController extends BaseController
if(isset($this->param['position'])){
$param['position'] = $this->param['position'];
}
$res = $this->_action($api_url,$action_name,$param);
$this->response('success',Code::SUCCESS,$res);
try {
$res = $this->_action($api_url,$action_name,$param);
$this->response('success',Code::SUCCESS,$res);
}catch (\Exception $e){
$this->fail('请求失败,请联系管理员');
}
}
/**
... ... @@ -253,4 +260,5 @@ class SuppliersController extends BaseController
$res = $this->_action($api_url,$action_name,$param);
$this->response('success',Code::SUCCESS,$res);
}
}
... ...
... ... @@ -172,7 +172,7 @@ class InquiryInfoLogic extends BaseLogic
* @time :2023/7/13 14:39
*/
public function inquiryForward($post_data){
$url = 'https://form.globalso.com/api/external-interface/add/fa043f9cbec6b38f';
$url = 'https://www.globalso.site/api/external-interface/add/fa043f9cbec6b38f';
$post_data_new = [];
$post_data_new['refer'] = $post_data['url'];
$post_data_new['name'] = $post_data['name'];
... ...
... ... @@ -161,10 +161,10 @@ class ProjectLogic extends BaseLogic
$this->createProjectData($this->param);
//双向绑定服务器,需放到保存项目的上方
$this->setServers($this->param['serve_id'],$this->param['id']);
//保存项目信息
$this->saveProject($this->param);
//ai_blog
$this->setAiBlog($this->param['id'],$this->param['main_lang_id'],$this->param['is_ai_blog'],$this->param['title']);
//保存项目信息
$this->saveProject($this->param);
//保存建站部署信息
$this->saveProjectDeployBuild($this->param['deploy_build']);
//保存付费信息
... ... @@ -202,7 +202,7 @@ class ProjectLogic extends BaseLogic
return true;
}
$projectModel = new Project();
$projectInfo = $projectModel->read(['id'=>$project_id],['is_ai_blog','main_lang_id']);
$projectInfo = $projectModel->read(['id'=>$project_id],['title','is_ai_blog','main_lang_id','company']);
//获取项目主语种
$languageModel = new WebLanguage();
$languageInfo = $languageModel->read(['id'=>$main_lang_id],['short']);
... ... @@ -770,7 +770,6 @@ class ProjectLogic extends BaseLogic
* @time :2023/9/4 14:29
*/
public function editDomainStatus($domain,$project_id){
$projectOptimize = new DeployOptimize();
$optimizeInfo = $projectOptimize->read(['project_id'=>$project_id],['domain']);
if($optimizeInfo['domain'] == $domain){
... ... @@ -818,6 +817,12 @@ class ProjectLogic extends BaseLogic
* @time :2023/11/8 14:23
*/
public function copyProject(){
//查看当前是否有执行任务
$noticeModel = new NoticeLog();
$info = $noticeModel->read(['type'=>NoticeLog::TYPE_COPY_PROJECT,'status'=>0,'data'=>['like','%"'.$this->param['project_id'].'"%']]);
if($info !== false){
return $this->success('当前项目已在复制中');
}
NoticeLog::createLog(NoticeLog::TYPE_COPY_PROJECT, ['project_id' => $this->param['project_id']]);
return $this->success('项目复制中,请稍后前往初始化项目查看;');
}
... ... @@ -971,9 +976,7 @@ class ProjectLogic extends BaseLogic
public function saveWebTrafficConfig($config){
$config['main_countries'] = textareaToArr($config['main_countries']);
$config['filter_countries'] = textareaToArr($config['filter_countries']);
$ip_area = InquiryIP::getIpAreas();
foreach ($config['main_countries'] as $v) {
if (!in_array($v, $ip_area)) {
throw new AsideGlobalException(Code::SYSTEM_ERROR, '[' . $v . ']不存在,请检查后再次提交');
... ... @@ -984,11 +987,8 @@ class ProjectLogic extends BaseLogic
throw new AsideGlobalException(Code::SYSTEM_ERROR, '[' . $v . ']不存在,请检查后再次提交');
}
}
$config['main_countries'] = json_encode($config['main_countries']);
$config['filter_countries'] = json_encode($config['filter_countries']);
$model = WebTrafficConfig::where('project_id', $config['project_id'])->first();
if (!$model) {
$model = new WebTrafficConfig();
... ... @@ -996,9 +996,7 @@ class ProjectLogic extends BaseLogic
} else {
$model->edit($config, ['project_id' => $config['project_id']]);
}
Cache::forget(WebTrafficConfig::cacheKey($config['project_id']));
return $this->success();
}
... ... @@ -1080,6 +1078,4 @@ class ProjectLogic extends BaseLogic
}
return true;
}
}
... ...
... ... @@ -55,9 +55,7 @@ class AiBlogLogic extends BaseLogic
$aiBlogService = new AiBlogService();
$aiBlogService->mch_id = $aiSettingInfo['mch_id'];
$aiBlogService->key = $aiSettingInfo['key'];
if(!empty($this->param['route'])){
$aiBlogService->route = generateRoute(Translate::tran($this->param['route'], 'en'));
}
$aiBlogService->route = generateRoute(Translate::tran($this->param['route'], 'en'));
$result = $aiBlogService->createTask($this->param['keyword'],$this->param['type']);
if($result['status'] == 200){
$aiBlogTaskModel = new AiBlogTask();
... ...
... ... @@ -149,6 +149,11 @@ class CategoryLogic extends BaseLogic
}else{
$param['describe_image'] = json_encode([]);
}
if(isset($param['cate_tak']) && !empty($param['cate_tak'])){
$param['cate_tak'] = json_encode($param['cate_tak']);
}else{
$param['cate_tak'] = json_encode([]);;
}
return $this->success($param);
}
... ...
... ... @@ -262,6 +262,7 @@ class UserLoginLogic
$info['is_show_blog'] = $project['is_show_blog'];
$info['upload_config'] = $project['upload_config'];
$info['main_lang_id'] = $project['main_lang_id'];
$info['is_ai_blog'] = $project['is_ai_blog'];
$info['image_max'] = $project['image_max'];
$info['is_del_inquiry'] = $project['is_del_inquiry'] ?? 0;
$info['uptime_type'] = $this->getHistory($project);
... ...
... ... @@ -153,4 +153,16 @@ class DomainInfo extends Base
$value = Arr::s2a($value);
return $value;
}
public static function getCacheInfoByProjectId($project_id){
$cache_key = 'DOMAIN_INFO_BY_PROJECT_ID_' . $project_id;
$data = Cache::get($cache_key);
if(!$data){
$data = DomainInfo::where('project_id', $project_id)->first();
if($data){
Cache::put($cache_key, $data, 3600);
}
}
return $data;
}
}
... ...
<?php
/**
* Created by PhpStorm.
* User: zhl
* Date: 2025/2/17
* Time: 11:49
*/
namespace App\Models\Inquiry;
use App\Models\Base;
/**
* Class InquiryProject
* @package App\Models\Inquiry
*/
class InquiryProject extends Base
{
/**
* @var string 数据表
*/
protected $table = 'gl_inquiry_project';
// 对应系统版本号
const VERSION_FOUR = 4;
const VERSION_FIVE = 5;
const VERSION_SIX = 6;
/**
* 保存项目信息
* @param $version
* @param $primary_id
* @param $project
* @param $channel
* @param $domain
* @param int $is_split
* @param string $test_domain
* @return InquiryProject
*/
public static function saveProject($version, $primary_id, $project, $channel, $domain, $is_split = 0, $test_domain = '')
{
$date = date('Ymd');
$log = self::where(compact('version', 'primary_id'))->first();
if ($log) {
$log->date = $date;
$log->save();
return $log;
}
$self = new self();
$self->version = $version;
$self->primary_id = $primary_id;
$self->project = $project;
$self->channel = $channel;
$self->domain = $domain;
$self->is_split = $is_split;
$self->test_domain = $test_domain;
$self->date = $date;
$self->save();
return $self;
}
}
... ...
<?php
/**
* Created by PhpStorm.
* User: zhl
* Date: 2025/2/17
* Time: 15:04
*/
namespace App\Models\Inquiry;
use App\Models\Base;
/**
* Class InquiryProjectRoute
* @package App\Models\Inquiry
*/
class InquiryProjectRoute extends Base
{
/**
* @var string 数据表
*/
protected $table = 'gl_inquiry_project_route';
/**
* 保存路由信息
* @param int $project_id gl_inquiry_project 表ID
* @param $title
* @param $route
* @return InquiryProjectRoute
*/
public static function saveProjectRoute($project_id, $title, $route)
{
$date = date('Ymd');
$log = self::where(compact('project_id', 'title'))->first();
if ($log) {
$log->date = $date;
$log->save();
return $log;
}
$self = new self();
$self->project_id = $project_id;
$self->title = $title;
$self->route = $route;
$self->date = $date;
$self->save();
return $self;
}
}
... ...
... ... @@ -33,6 +33,19 @@ class Category extends Base
}
/**
* @remark :获取tdk
* @name :getCateTdkAttribute
* @author :lyh
* @method :post
* @time :2025/2/19 11:03
*/
public function getCateTdkAttribute($value){
if(!empty($value)){
$value = Arr::s2a($value);
}
return $value;
}
/**
* 根据产品分类获取分类列表和产品
*/
public static function getCategoryBySelfCategory($projectId,$routerMap)
... ...
... ... @@ -20,7 +20,6 @@ class Project extends Base
const DATABASE_NAME_FIX = 'gl_data_';
const CUSTOMIZED_ONE = 1;//定制项目
const DEMO_PROJECT_ID = 1;
const STATUS_ONE = 1;//审核通过
const TYPE_ZERO = 0;//初始导入项目
const TYPE_ONE = 1;//建站中
... ... @@ -29,10 +28,8 @@ class Project extends Base
const TYPE_FOUR = 4;//推广续费
const TYPE_FIVE = 5;//未续费网站
const TYPE_SIX = 6;//特殊推广项目
const TYPE_SEVEN = 7;//错误单
const MYSQL_ID = 2;//默认数据库id
const IS_UPGRADE_FALSE = 0;
const IS_UPGRADE_TRUE = 1;
... ... @@ -58,10 +55,11 @@ class Project extends Base
}
/**
* 项目分类
* 项目类型
* @return string[]
* @author zbj
* @date 2023/4/26
* @remark project表中(extend_type + type)的属性值
*/
public static function typeMap()
{
... ...
... ... @@ -23,7 +23,7 @@ class InquiryRelayService
{
$date = date('Y-m-d');
$token = md5($date . 'qqs');
$url = 'https://form.globalso.com/api/external-interface/echo_inquriy/d1483a8e57cb485a?date=' . $date . '&token=' . $token . '&type=2';
$url = 'https://www.globalso.site/api/external-interface/echo_inquriy/d1483a8e57cb485a?date=' . $date . '&token=' . $token . '&type=2';
$result = http_get($url);
return $result;
}
... ... @@ -105,4 +105,8 @@ class InquiryRelayService
curl_close($ch);
return $result;
}
########################################################################################################################
# 询盘结束, 同步项目及路由 #
########################################################################################################################
}
\ No newline at end of file
... ...
... ... @@ -29,7 +29,7 @@ class SyncService
public function projectAcceptAddress($project_id = 0)
{
try {
$url = 'https://form.globalso.com/api/globalsov6';
$url = 'https://www.globalso.site/api/globalsov6';
// 项目信息
$project = Project::with('deploy_build')->with('deploy_optimize')->where(['id'=>$project_id])->first();
// 不满足条件 不同步到表单系统
... ...
... ... @@ -75,7 +75,7 @@ class SyncSubmitTaskService
}
//域名 过滤国家或ip
$domain_info = DomainInfo::where('project_id', $project['id'])->first();
$domain_info = DomainInfo::getCacheInfoByProjectId($project['id']);
if(!empty($domain_info['not_allow_country'])){
$not_allow_countries = CountryCode::whereIn('id', $domain_info['not_allow_country'])->pluck('c_name')->toArray();
if(in_array($data['country'], $not_allow_countries)){
... ... @@ -88,9 +88,11 @@ class SyncSubmitTaskService
}
}
$time = time();
if(!ProjectServer::useProject($project['id'])){
return false;
}
echo date('Y-m-d H:i:s') . ' | useProject time:' . (time() - $time) . PHP_EOL;
$action = $task['type'];
... ... @@ -106,7 +108,7 @@ class SyncSubmitTaskService
}
$filed == 'email' && $action = 'subscribe';
}
$handler = new self();
return $handler->$action($data, $date, $task['id'], $task['traffic']);
}
... ... @@ -297,6 +299,17 @@ class SyncSubmitTaskService
if(!$ip){
return '';
}
// $client = new \GuzzleHttp\Client();
// $res = $client->request('GET', "http://ip.globalso.com?ip=".$ip, [
// 'proxy' => env('CURL_PROXY'), // 代理服务器地址和端口号
// ]);
// if($res->getStatusCode() == 200){
// return $res->getBody()->getContents();
// }else{
// return '';
// }
$res = Http::withoutVerifying()->get('http://ip.globalso.com', ['ip' => $ip]);
if($res->status() == 200){
return $res->body();
... ... @@ -334,7 +347,9 @@ class SyncSubmitTaskService
if($ip == "127.0.0.1"){
throw new InquiryFilterException('127.0.0.1过滤');
}
$time = time();
$country = self::getCountryByIp($ip);
echo date('Y-m-d H:i:s') . ' | getCountryByIp time:' . (time() - $time) . PHP_EOL;
//访问记录过滤国内
if ($type == SyncSubmitTask::TYPE_VISIT && $country == "中国" && !$project->is_record_china_visit){
throw new InquiryFilterException('中国内地过滤');
... ...