作者 赵彬吉
... ... @@ -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;
... ...
... ... @@ -19,6 +19,7 @@ use App\Services\ProjectServer;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Redis;
/**
* Class SyncInquiryProject
... ... @@ -38,7 +39,7 @@ class SyncInquiryProject extends Command
*
* @var string
*/
protected $description = '同步询盘信息:项目以及对应路由,';
protected $description = '同步询盘信息:项目';
/**
* Create a new command instance.
... ... @@ -61,8 +62,6 @@ class SyncInquiryProject extends Command
$this->syncGloV5();
echo '开始同步v6' . PHP_EOL;
$this->syncGloV6();
echo '删除过期数据' . PHP_EOL;
$this->deleteExpire();
return true;
}
... ... @@ -72,73 +71,50 @@ class SyncInquiryProject extends Command
*/
public function syncGloV5()
{
$date = intval(date('Ymd'));
$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;
continue;
}
array_push($channel_tmp, $channel_id);
}
if ($channel_flag || empty($channel_tmp)) {
if (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']);
// 保存项目 以及 获取路由信息
$project = InquiryProject::saveProject($date, $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 路由或标题过长,无效记录');
try{
$result = http_get($route_domain . 'k_u_api.php');
if (empty($result)) {
$this->log('syncGloV5Route 未获取到路由信息:' . $project->id . ', 路由获取地址:' . $route_domain . 'k_u_api.php');
continue;
}
InquiryProjectRoute::saveProjectRoute($project_id, $title, $route);
file_put_contents(storage_path('logs/sync_inquiry_project_route/' . $project->id . '.json'), json_encode($result));
$this->pushTask($project->id);
} catch (\Exception $e) {
$this->log('syncGloV5Route 解析路径:' . $val . ', 错误信息:' . $e->getMessage());
echo 'syncGloV5Route 解析路径:' . $val . ', 错误信息:' . $e->getMessage() . PHP_EOL;
$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;
continue;
}
}
$ids = InquiryProject::where('date', '<', $date)->where('version', '<', InquiryProject::VERSION_SIX)->pluck('id')->toArray();
$this->deleteExpire($ids);
return true;
}
... ... @@ -148,6 +124,7 @@ class SyncInquiryProject extends Command
*/
public function syncGloV6()
{
$date = intval(date('Ymd'));
// 获取优化中台项目
$project = Project::leftJoin('gl_project_online_check', 'gl_project.id', '=', 'gl_project_online_check.project_id')
->where('gl_project.type', Project::TYPE_TWO)
... ... @@ -165,55 +142,40 @@ class SyncInquiryProject extends Command
// 过滤暂停优化项目, 映射类型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);
$project = InquiryProject::saveProject($date,InquiryProject::VERSION_SIX, $val->id, $val->title, $val->channel['channel_id'], $domains[$val->id]);
$this->pushTask($project->id);
}
$ids = InquiryProject::where('date', '<', $date)->where('version', '=', InquiryProject::VERSION_SIX)->pluck('id')->toArray();
$this->deleteExpire($ids);
return true;
}
/**
* 同步v6项目路由
* @param $project_id
* @param $origin_project_id
* 删除过期数据, 非当日更新数据, 都删除, 误删第二天再重新同步更新
* @param $ids
* @return bool
*/
public function syncGloV6Route($project_id, $origin_project_id)
public function deleteExpire($ids)
{
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');
if (empty($ids))
return true;
$project_num = InquiryProject::whereIn('id', $ids)->delete();
$project_route_num = InquiryProjectRoute::whereIn('project_id', $ids)->delete();
$this->log('删除过期项目数量:' . $project_num . ', 删除过期项目路由数量:' . $project_route_num);
return true;
}
/**
* 删除过期数据, 非当日更新数据, 都删除, 误删第二天再重新同步更新
* 往任务队列中生产数据
* @param $id
* @return bool
*/
public function deleteExpire()
public function pushTask($id)
{
$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);
Redis::lPush('sync_inquiry_project_route_task', $id);
return true;
}
... ...
<?php
/**
* Created by PhpStorm.
* User: zhl
* Date: 2025/2/18
* Time: 17:10
*/
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;
use Illuminate\Support\Facades\Redis;
/**
* Class SyncInquiryProjectRoute
* @package App\Console\Commands\Inquiry
*/
class SyncInquiryProjectRoute extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'sync_inquiry_project_route';
/**
* 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()
{
while (true) {
$sync_id = Redis::rpop('sync_inquiry_project_route_task');
if (empty($sync_id)) {
sleep(60);
continue;
}
$task = InquiryProject::where(['id' => $sync_id])->first();
if (empty($task))
continue;
// 同步对应项目路由, 以及删除过期路由
if ($task->version == InquiryProject::VERSION_SIX){
$this->syncGloV6Route($task);
} else {
$this->syncGloV5Route($task);
}
}
return true;
}
/**
* 同步v4 v5项目路由
* @param $task
* @return bool
*/
public function syncGloV5Route($task)
{
$date = intval(date('Ymd'));
$result = file_get_contents(storage_path('logs/sync_inquiry_project_route/' . $task->id . '.json'));
$result = json_decode($result, true);
if (empty($result)) {
// 未获取到数据 删除当前项目过期路由
$this->deleteExpire($task->id, $date);
$this->log('syncGloV5Route 未获取到路由信息:' . $task->id . ', 路由获取地址:' . ($task->is_split && $task->test_url ? $task->test_url : $task->main_url) . 'k_u_api.php');
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($task->id, $title, $route, $date);
} catch (\Exception $e) {
$this->log('syncGloV5Route 解析路径:' . $val . ', 错误信息:' . $e->getMessage());
echo 'syncGloV5Route 解析路径:' . $val . ', 错误信息:' . $e->getMessage() . PHP_EOL;
}
}
// 删除当前项目过期路由
$this->deleteExpire($task->id, $date);
return true;
}
/**
* 同步v6项目路由
* @param $task
* @return bool
*/
public function syncGloV6Route($task)
{
echo '同步项目ID:' . $task->id . PHP_EOL;
$date = intval(date('Ymd'));
ProjectServer::useProject($task->primary_id);
// TODO 产品分类标题、路由, 产品标题、路由, 同步到路由表
$category = Category::where('status', Category::STATUS_ACTIVE)->get(['title', 'route']);
foreach ($category as $key=>$val) {
InquiryProjectRoute::saveProjectRoute($task->id, $val->title, $val->route, $date);
}
// 产品数量会比较多, 所以使用分页 同步数据
$id = 0;
while (true) {
$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($task->id, $val->title, $val->route, $date);
}
}
DB::disconnect('custom_mysql');
// 删除当前项目过期路由
$this->deleteExpire($task->id, $date);
return true;
}
/**
* 删除过期数据, 非当前更新数据, 都删除, 误删第二天再重新同步更新
* @param $project_id
* @param $date
* @return bool
*/
public function deleteExpire($project_id, $date)
{
$project_route_num = InquiryProjectRoute::where(['project_id' => $project_id])->where('date', '<', $date)->delete();
$this->log('项目ID:' . $project_id . ', 删除过期路由数量:' . $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
... ...
... ... @@ -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 对象
... ...
<?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 Hashids\Hashids;
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(){
$this->copyMysql($old_project_id,$project_id);
}
public function copyProject($old_project_id){
$projectModel = new Project();
$data = $projectModel::where('id', $old_project_id)->first();
$data = $data->getAttributes();
$type = $data['type'];
$data['type'] = 0;
$data['status'] = 0;
$data['finish_remain_day'] = 0;
$data['title'] = $data['title'].'-copy';
$data['delete_status'] = 1;
unset($data['id'],$data['robots'],$data['is_translate_tag'],$data['is_translate'],$data['is_minor_languages'],$data['uptime']);
$project_id = $projectModel->insertGetId($data);
$hashids = new Hashids($data['from_order_id'], 13, 'abcdefghjkmnpqrstuvwxyz1234567890');
$projectModel->edit(['from_order_id'=>$hashids->encode($project_id)],['id'=>$project_id]);
//复制设置的模版
$settingTemplateModel = new Setting();
$settingData = $settingTemplateModel::where('project_id', $old_project_id)->first();
if(!empty($settingData)){
$data = [
'template_id' =>$settingData['template_id'],
'project_id' => $project_id
];
$settingTemplateModel->add($data);
}
return ['project_id'=>$project_id,'type'=>$type];
}
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;
}
}
... ... @@ -37,7 +37,7 @@ class Temp extends Command
public function handle()
{
$this->change_cname_projects_240();
}
/**
... ...
... ... @@ -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(){
... ...
... ... @@ -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);
... ...
... ... @@ -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();
... ...
... ... @@ -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);
}
}
... ...
... ... @@ -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){
... ... @@ -977,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 . ']不存在,请检查后再次提交');
... ... @@ -990,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();
... ... @@ -1002,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();
}
... ... @@ -1086,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);
}
... ...
... ... @@ -27,6 +27,7 @@ class InquiryProject extends Base
/**
* 保存项目信息
* @param $date
* @param $version
* @param $primary_id
* @param $project
... ... @@ -36,9 +37,8 @@ class InquiryProject extends Base
* @param string $test_domain
* @return InquiryProject
*/
public static function saveProject($version, $primary_id, $project, $channel, $domain, $is_split = 0, $test_domain = '')
public static function saveProject($date, $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;
... ...
... ... @@ -25,11 +25,11 @@ class InquiryProjectRoute extends Base
* @param int $project_id gl_inquiry_project 表ID
* @param $title
* @param $route
* @param $date
* @return InquiryProjectRoute
*/
public static function saveProjectRoute($project_id, $title, $route)
public static function saveProjectRoute($project_id, $title, $route, $date)
{
$date = date('Ymd');
$log = self::where(compact('project_id', 'title'))->first();
if ($log) {
$log->date = $date;
... ...
... ... @@ -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)
... ...