作者 赵彬吉
... ... @@ -40,7 +40,7 @@ class AiBlogTask extends Command
while (true){
$info = $aiBlogTaskModel->where('status',1)->orderBy('id','asc')->first();
if($info === false){
sleep(20);
sleep(30);
continue;
}
$info = $info->toArray();
... ...
<?php
namespace App\Console\Commands\DayCount;
use App\Models\Inquiry\InquiryInfo;
use Illuminate\Console\Command;
/**
* @remark :
* @class :InquiryDelay.php
* @author :lyh
* @time :2023/7/14 10:16
*/
class InquiryDelay extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'inquiry_delay';
/**
* The console command description.
*
* @var string
*/
protected $description = '延时询盘转发(暂时弃用)';
/**
* @remark :延时询盘转发
* @name :handle
* @author :lyh
* @method :post
* @time :2023/7/14 10:17
*/
public function handle()
{
$inquiryInfoModel = new InquiryInfo();
$param = $inquiryInfoModel->formatQuery(['status'=>$inquiryInfoModel::STATUS_FOUR])->orderBy('send_time','asc')->first();
if(!empty($param)){
$time = date('Y-m-d H:i:s');
if($time >= $param['send_time']){
$data = [];
//TODO::处理转发的url
$arr_url = explode(',',$param['forward_url']);
foreach ($arr_url as $v){
$data['url'] = $v;
$this->inquiryForward($data);
}
$inquiryInfoModel->edit(['status'=>$inquiryInfoModel::STATUS_THREE],['id'=>$param['id']]);
}
}
return true;
}
/**
* @remark :询盘转发
* @name :inquiryForward
* @author :lyh
* @method :post
* @time :2023/7/13 14:39
*/
public function inquiryForward($post_data){
$url = 'https://form.globalso.com/api/external-interface/add/fa043f9cbec6b38f';
$post_data_new = [];
$post_data_new['refer'] = $post_data['url'];
$post_data_new['name'] = $post_data['name'];
$post_data_new['email'] = $post_data['email'];
$post_data_new['phone'] = $post_data['phone'];
$post_data_new['ip'] = $post_data['ip'];
$post_data_new['message'] = $post_data['message'];
$post_data_new['submit_time'] = date('Y-m-d H:i:s',time()+20);
$token = md5($post_data_new['refer'].$post_data_new['name'].$post_data_new['ip'].date("Y-m-d",time()));
$post_data_new['token'] = $token;
$header = array(
'CLIENT-IP: '.$post_data['ip'],
'X-FORWARDED-FOR: '.$post_data['ip']
);
return http_post($url,$post_data_new,$header);
}
}
... ... @@ -71,76 +71,95 @@ class SyncInquiryRelay extends Command
*/
public function getInquirySzcm()
{
$max_origin_key = InquiryInfo::where('type', 4)->orderBy('origin_key', 'desc')->value('origin_key');
$max_origin_key = InquiryInfo::where('type', InquiryInfo::TYPE_SPIDER)->orderBy('origin_key', 'desc')->value('origin_key');
if ($max_origin_key) {
$start_id = $max_origin_key + 1;
} else {
$start_id = 65029;
}
// TODO 由于该渠道数据不规则, 可能某个ID获取不到数据, 无法判断是因为已经没有数据了, 还是因为解析问题导致, 所以当未获取到数据时, 多向后取几次数据, 连续几次没有数据, 就认为已经获取到最大数据。
$service = new InquiryRelayService();
$pre = 0;
while ($start_id > 0) {
$result = $service->getInquirySzcm($start_id);
if (empty($result) && $pre <= 3) {
$start_id++;
$pre++;
continue;
}
if ($result) {
$this->saveDate($result, 4);
$start_id += 1;
} else {
$start_id = 0;
$this->saveDate($result, InquiryInfo::TYPE_SPIDER);
$start_id++;
$pre = 0;
}
if ($pre > 3)
break;
}
return true;
}
/**
* 询盘数据入库
* @param $data
* @param $type
* @return bool
*/
public function saveDate($data, $type)
{
$model = new InquiryInfo();
$message_sign = md5($data['name'] . $data['email'] . $data['phone'] . $data['ip'] . $data['time']);
$inquiry_info = $model->where('message_sign', $message_sign)->first();
if (!$inquiry_info) {
//没有IP,根据submit_country获取
if (empty($data['ip']) && isset($data['submit_country']) && $data['submit_country']) {
$chinese_name = DB::table('gl_world_country_city')->where('pid', 0)->where('iso2', $data['submit_country'])->value('chinese_name');
$data['ip'] = $this->getIpData($chinese_name);
}
if ($inquiry_info)
return true;
//获取country
$country = '';
if ($data['ip']) {
$country = file_get_contents("http://ip.globalso.com?ip=" . $data['ip']);
}
//没有IP,根据submit_country获取
if (empty($data['ip']) && isset($data['submit_country']) && $data['submit_country']) {
$chinese_name = DB::table('gl_world_country_city')->where('pid', 0)->where('iso2', $data['submit_country'])->value('chinese_name');
$data['ip'] = $this->getIpData($chinese_name);
}
//翻译message
$message_cn = '';
$re_message_trans = Translate::translate($data['message'], 'zh');
if (isset($re_message_trans[0]['code']) && $re_message_trans[0]['code'] == 200) {
$message_cn = $re_message_trans[0]['texts'];
}
//获取country
$country = '';
if ($data['ip']) {
$country = file_get_contents("http://ip.globalso.com?ip=" . $data['ip']);
}
//获取页面上title和keywords
$html = curl_c($data['refer'], false);
//翻译message
$message_cn = '';
$re_message_trans = Translate::translate($data['message'], 'zh');
if (isset($re_message_trans[0]['code']) && $re_message_trans[0]['code'] == 200) {
$message_cn = $re_message_trans[0]['texts'];
}
if (empty($data['title'])) {
preg_match_all('/<title>([\w\W]*?)<\/title>/', $html, $matches);
if (!empty($matches[1])) {
$data['title'] = substr($matches[1][0], 0, 255);
}
}
//获取页面上title和keywords
$html = curl_c($data['refer'], false);
$keywords = '';
preg_match_all('/<meta\s+[^>]*?name=[\'|\"]keywords[\'|\"]\s+[^>]*?content=[\'|\"]([\w\W]*?)[\'|\"]/', $html, $matches);
if (empty($data['title'])) {
preg_match_all('/<title>([\w\W]*?)<\/title>/', $html, $matches);
if (!empty($matches[1])) {
$keywords = substr($matches[1][0], 0, 255);
$data['title'] = substr($matches[1][0], 0, 255);
}
}
if (empty($data['origin_key'])) {
$data['origin_key'] = 0;
}
$keywords = '';
preg_match_all('/<meta\s+[^>]*?name=[\'|\"]keywords[\'|\"]\s+[^>]*?content=[\'|\"]([\w\W]*?)[\'|\"]/', $html, $matches);
if (!empty($matches[1])) {
$keywords = substr($matches[1][0], 0, 255);
}
if (empty($data['image'])) {
$data['image'] = '';
}
if (empty($data['origin_key'])) {
$data['origin_key'] = 0;
}
$model->createInquiry($data['name'], $data['phone'], $data['email'], $data['ip'], $country, $data['message'], $message_cn, $type, $data['time'], $data['refer'], $data['title'], $keywords, $message_sign, $data['origin_key'], $data['image']);
if (empty($data['image'])) {
$data['image'] = '';
}
$model->createInquiry($data['name'], $data['phone'], $data['email'], $data['ip'], $country, $data['message'], $message_cn, $type, $data['time'], $data['refer'], $data['title'], $keywords, $message_sign, $data['origin_key'], $data['image']);
return true;
}
/**
... ...
... ... @@ -477,6 +477,17 @@ class UpdateSeoTdk extends Command
$prompt = str_replace($val, $keyword, $prompt);
}
}
// 多个核心关键词
if(strpos($prompt, '{core keywords 8}') !== false) {
$main_keyword = $this->mainKeywords($project_id, 8);
if(!$main_keyword){
echo '核心关键词为空 跳过' . PHP_EOL;
return false;
}
$prompt = str_replace('{core keywords 8}', $main_keyword, $prompt);
}
$prompt .= '.Please answer in ' . $this->getLang();
return $prompt;
}
... ...
... ... @@ -12,10 +12,12 @@ use App\Models\Product\Keyword;
use App\Models\Product\KeywordRelated;
use App\Models\Product\Product;
use App\Models\Project\Project;
use App\Models\Project\ProjectUpdateTdk;
use App\Models\WebSetting\WebLanguage;
use App\Services\BatchExportService;
use App\Services\ProjectServer;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
class Temp extends Command
{
... ... @@ -35,7 +37,43 @@ class Temp extends Command
public function handle()
{
$this->create_update_keyword_page();
$this->check_no_cname_projects();
}
/**
* 2025-02-05 日以来的项目,重写tdk(keyword_title)
* @author Akun
* @date 2025/02/15 10:58
*/
public function product_keyword_rewrite()
{
$products = ProjectUpdateTdk::where('created_at', '>=', '2025-02-05 00:00:00')->pluck('project_id')->toArray();
$products_ids = array_unique($products);
$success_json = file_get_contents(storage_path('logs/lk/success.log'));
$success = json_decode($success_json, true) ?: [];
foreach ($products_ids as $project_id) {
if (in_array($project_id, $success)) {
$this->output($project_id . ' | 已执行,跳过');
continue;
}
ProjectServer::useProject($project_id);
DB::connection('custom_mysql')->table('gl_product_keyword')->update(['keyword_title' => '']);
try {
ProjectUpdateTdk::add_task($project_id);
} catch (\Exception $e) {
$this->output($project_id . ' | ' . $e->getMessage());
}
DB::disconnect('custom_mysql');
array_push($success, $project_id);
file_put_contents(storage_path('logs/lk/success.log'), json_encode($success));
}
$this->output('success');
}
/**
... ... @@ -342,8 +380,8 @@ class Temp extends Command
*/
public function check_no_cname_projects()
{
$server_id = 15;
$server_name = '美服1';
$server_id = 1;
$server_name = '硅谷云服务器';
$server_ip_model = new ServersIp();
... ... @@ -575,7 +613,7 @@ class Temp extends Command
*/
public function create_update_keyword_page()
{
$ids_arr = ["46","83","91","150","190","206","219","221","232","233","238","287","290","299","319","321","353","356","388","389","456","457","475","491","518","535","554","600","624","650","728","732","783","807","835","881","896","913","947","1001","1320","1336","1373","1424","1442","1455","1466","1505","1584","1597","1617","1682","1770","1816","1824","1835","1860","1870","1896","1913","1989","1991","1992","2022","2037","2059","2060","2062","2104","2115","2129","2131","2135","2191","2204","2217","2245","2257","2287","2309","2313","2330","2336","2337","2338","2351","2391","2418","2423","2435","2462","2496","2504","2505","2660","2768","2811","2874","3157"];
$ids_arr = ["46", "83", "91", "150", "190", "206", "219", "221", "232", "233", "238", "287", "290", "299", "319", "321", "353", "356", "388", "389", "456", "457", "475", "491", "518", "535", "554", "600", "624", "650", "728", "732", "783", "807", "835", "881", "896", "913", "947", "1001", "1320", "1336", "1373", "1424", "1442", "1455", "1466", "1505", "1584", "1597", "1617", "1682", "1770", "1816", "1824", "1835", "1860", "1870", "1896", "1913", "1989", "1991", "1992", "2022", "2037", "2059", "2060", "2062", "2104", "2115", "2129", "2131", "2135", "2191", "2204", "2217", "2245", "2257", "2287", "2309", "2313", "2330", "2336", "2337", "2338", "2351", "2391", "2418", "2423", "2435", "2462", "2496", "2504", "2505", "2660", "2768", "2811", "2874", "3157"];
$project_list = Project::select(['id', 'serve_id'])->whereIn('id', $ids_arr)->get();
$domain_model = new DomainInfo();
... ...
... ... @@ -367,16 +367,16 @@ class ProjectUpdate extends Command
'six_read' => 1,
'route' => $route
]);
if(!empty($content)){
if (!empty($content)) {
$data_s = [
'product_id'=>$id,
'column_id'=>1,
'text_type'=>1,
'title'=>'product detail',
'sort'=>1,
'content'=>json_encode(['content'=>$content ?? ''],JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),
'created_at'=>date('Y-m-d H:i:s'),
'updated_at'=>date('Y-m-d H:i:s')
'product_id' => $id,
'column_id' => 1,
'text_type' => 1,
'title' => 'product detail',
'sort' => 1,
'content' => json_encode(['content' => $content ?? ''], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),
'created_at' => date('Y-m-d H:i:s'),
'updated_at' => date('Y-m-d H:i:s')
];
$detailModel = new Detail();
$detailModel->insert($data_s);
... ... @@ -407,18 +407,18 @@ class ProjectUpdate extends Command
'sort' => $item['sort'] ?? 0,
'files' => $files,
], ['id' => $id]);
if(!empty($content)){
if (!empty($content)) {
$detailModel = new Detail();
$detailModel->del(['product_id'=>$id,'column_id'=>1]);
$detailModel->del(['product_id' => $id, 'column_id' => 1]);
$data_s = [
'product_id'=>$id,
'column_id'=>1,
'text_type'=>1,
'title'=>'product detail',
'sort'=>1,
'content'=>json_encode(['content'=>$content ?? ''],JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),
'created_at'=>date('Y-m-d H:i:s'),
'updated_at'=>date('Y-m-d H:i:s')
'product_id' => $id,
'column_id' => 1,
'text_type' => 1,
'title' => 'product detail',
'sort' => 1,
'content' => json_encode(['content' => $content ?? ''], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),
'created_at' => date('Y-m-d H:i:s'),
'updated_at' => date('Y-m-d H:i:s')
];
$detailModel->insert($data_s);
}
... ... @@ -706,14 +706,20 @@ class ProjectUpdate extends Command
$route = $this->get_url_route($item['url'] ?? '');
if ($route) {
//分类
$category_custom = $category_model->read(['route' => $custom_info['route']], 'id');
$category_model_id = $category_custom ? $category_custom['id'] : 0;
$category_id = '';
if ($item['category'] ?? []) {
$category_arr = $category_model->list(['original_id' => ['in', array_column($item['category'], 'id')]]);
$category_id = implode(',', array_column($category_arr, 'id'));
$category_id_arr = array_column($category_arr, 'id');
if ($category_model_id > 0 && (!in_array($category_model_id, $category_id_arr))) {
array_push($category_id_arr, $category_model_id);
}
$category_id = implode(',', $category_id_arr);
} else {
$category_custom = $category_model->read(['route' => $custom_info['route']], 'id');
if ($category_custom) {
$category_id = $category_custom['id'];
if ($category_model_id > 0) {
$category_id = $category_model_id;
}
}
if ($category_id) {
... ...
... ... @@ -20,13 +20,11 @@ class Kernel extends ConsoleKernel
$schedule->command('template_label')->dailyAt('01:00')->withoutOverlapping(1);//最新模块
$schedule->command('popular_template_label')->dailyAt('01:30')->withoutOverlapping(1);//热门模块
// $schedule->command('inspire')->hourly();
// $schedule->command('remain_day')->dailyAt('09:30')->withoutOverlapping(1); // 项目剩余服务时长
$schedule->command('rank_data_task')->everyMinute()->withoutOverlapping(1); // 排名数据更新任务
$schedule->command('service_count')->dailyAt('01:00')->withoutOverlapping(1); //服务器使用情况,每天凌晨1点执行一次
// $schedule->command('web_traffic_special')->everyMinute()->withoutOverlapping(1); // 特殊引流
// $schedule->command('web_traffic_russia_special')->everyMinute()->withoutOverlapping(1); // 特殊引流
$schedule->command('sync_channel')->dailyAt('06:00')->withoutOverlapping(1); // 渠道信息,每天执行一次
// $schedule->command('inquiry_delay')->everyMinute()->withoutOverlapping(1);//TODO::上线放开,转发询盘,每分钟执行一次
$schedule->command('inquiry_count')->dailyAt('01:00')->withoutOverlapping(1); // 询盘统计数据,每天凌晨执行一次
// $schedule->command('domain_info')->dailyAt('01:20')->withoutOverlapping(1);// 更新域名|证书结束时间,每天凌晨1点执行一次
$schedule->command('share_user')->dailyAt('01:20')->withoutOverlapping(1);// 每天凌晨1点执行一次
... ...
... ... @@ -35,6 +35,12 @@ class AiBlogController extends BaseController
*/
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']);
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']);
$lists['list'][$k] = $v;
}
}
$this->response('success',Code::SUCCESS,$lists);
}
... ...
... ... @@ -12,7 +12,6 @@ namespace App\Http\Controllers\Bside\BCom;
use App\Enums\Common\Code;
use App\Helper\Arr;
use App\Http\Controllers\Bside\BaseController;
use App\Jobs\UpdatePageJob;
use App\Models\Blog\Blog;
use App\Models\Blog\BlogCategory;
use App\Models\Com\NoticeLog;
... ...
... ... @@ -34,10 +34,11 @@ class KeywordPrefixLogic extends BaseLogic
$data = [
'project_id'=>$this->param['project_id'] ?? 0,
'keyword'=>$v,
'type'=>$this->param['type']
'type'=>$this->param['type'],
];
$prefixInfo = $this->model->read($data);
if($prefixInfo == false){
$data['remark'] = $this->param['remark'] ?? '';
$this->model->add($data);
}
}
... ...
... ... @@ -99,6 +99,9 @@ class ProjectLogic extends BaseLogic
if(isset($info['deploy_build']['other_project']) && !empty($info['deploy_build']['other_project'])){
$info['deploy_build']['other_project']= json_decode($info['deploy_build']['other_project']);
}
if(isset($info['project_keyword']['operator_log']) && !empty($info['project_keyword']['operator_log'])){
$info['project_keyword']['operator_log'] = json_decode($info['project_keyword']['operator_log']);
}
//is_product:"0",is_news:"0",is_blogs:"0",is_module:"0"
//获取小语种
$info['minor_languages'] = $this->getProjectMinorLanguages($id);
... ... @@ -439,6 +442,9 @@ class ProjectLogic extends BaseLogic
'customer_keywords'=>$project_keyword['customer_keywords'] ?? '',
'search_keywords'=>$project_keyword['search_keywords'] ?? '',
];
if(isset($project_keyword['operator_log']) && !empty($project_keyword['operator_log'])){
$data['operator_log'] = json_encode($project_keyword['operator_log'] ?? []);
}
if($info === false){
$data['project_id'] = $project_id;
$projectKeywordModel->addReturnId($data);
... ...
... ... @@ -28,8 +28,11 @@ class AiBlogLogic extends BaseLogic
* @time :2023/7/5 14:46
*/
public function blogSave(){
$this->param['project_id'] = $this->user['project_id'];
$rs = $this->model->add($this->param);
if(!empty($this->param['image'])){
$this->param['image'] = str_replace_url($this->param['image']);
}
$this->param['route'] = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_PRODUCT, $this->param['id'], $this->user['project_id']);
$rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
if($rs === false){
$this->fail('error');
}
... ... @@ -57,15 +60,13 @@ class AiBlogLogic extends BaseLogic
}
$result = $aiBlogService->createTask($this->param['keyword'],$this->param['type']);
if($result['status'] == 200){
try {
$aiBlogTaskModel = new AiBlogTask();
$aiBlogTaskModel->addReturnId(['project_id'=>$this->user['project_id'],'task_id'=>$result['data']['task_id'],'status'=>$result['data']['status']]);
$aiBlogModel = new AiBlog();
$aiBlogModel->addReturnId(['keyword'=>$this->param['keyword'], 'status'=>$result['data']['status'], 'task_id'=>$result['data']['task_id'],'project_id'=>$this->user['project_id'],
]);
}catch (\Exception $e){
$this->fail('请求ai_blog失败,请联系管理员');
}
$aiBlogTaskModel = new AiBlogTask();
$aiBlogTaskModel->addReturnId(['project_id'=>$this->user['project_id'],'task_id'=>$result['data']['task_id'],'status'=>$result['data']['status']]);
$aiBlogModel = new AiBlog();
$aiBlogId = $aiBlogModel->addReturnId(['keyword'=>$this->param['keyword'], 'status'=>$result['data']['status'], 'task_id'=>$result['data']['task_id'],'project_id'=>$this->user['project_id'],
]);
$route = RouteMap::setRoute($aiBlogService->route, RouteMap::SOURCE_AI_BLOG, $aiBlogId, $this->user['project_id']);
$aiBlogModel->edit(['route'=>$route],['id'=>$aiBlogId]);
}
return $this->success();
}
... ...
... ... @@ -33,6 +33,8 @@ class RouteMap extends Base
const SOURCE_NEWS_CATE = 'news_category';
//自定义模块
const SOURCE_MODULE = 'module';
const SOURCE_AI_BLOG = 'ai_blog';
//自定义模块分类
const SOURCE_MODULE_CATE = 'module_category';
... ...