作者 刘锟

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

... ... @@ -111,10 +111,19 @@ class AiBlogListTask extends Command
//获取项目域名
$domain = $domainModel->getProjectIdDomain($project_id);
if(!empty($domain)){
$url = $domain.'api/update_page/?project_id='.$project_id.'&route=7';
shell_exec('curl -k "'.$url.'"');
$c_url = $domain.'api/update_page/';
$param = [
'project_id' => $this->user['project_id'],
'type' => 1,
'route' => 3,
'url' => ['top-blog'],
'language'=> [],
'is_sitemap' => 0
];
$res = http_post($c_url, json_encode($param));
echo date('Y-m-d H:i:s').'通知成功:' . json_encode($res,JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . PHP_EOL;
}else{
echo '域名不存在:' . $project_id . PHP_EOL . date('Y-m-d H:i:s');
echo date('Y-m-d H:i:s').'域名不存在:' . $project_id . PHP_EOL;
}
return true;
}
... ...
... ... @@ -133,17 +133,6 @@ class AiBlogTask extends Command
}
/**
* @remark :g获取信息
* @name :getDetail
* @author :lyh
* @method :post
* @time :2025/3/19 17:24
*/
public function getDetail(){
}
/**
* @remark :获取任务id
* @name :getTaskId
* @author :lyh
... ...
... ... @@ -89,10 +89,11 @@ class LyhImportTest extends Command
continue;
}
if(empty($val[1])){
echo '跳过的名称:'.$val[1];
continue;
}
try {
$id = $categoryModel->addReturnId(['project_id'=>$project_id,'title'=>$val[1],'seo_title'=>$val[0],'seo_keyword'=>$val[2]]);
$id = $categoryModel->addReturnId(['project_id'=>$project_id,'title'=>$val[1],'seo_title'=>$val[0],'seo_des'=>$val[2],'sort'=>$val[3]]);
$pid = 0;
// if($val[2] != 0){
// //查询上级id
... ...
... ... @@ -11,11 +11,13 @@ namespace App\Console\Commands\LyhTest;
use App\Helper\Arr;
use App\Helper\Translate;
use App\Models\Ai\AiBlog;
use App\Models\Blog\Blog;
use App\Models\CustomModule\CustomModuleContent;
use App\Models\Product\CategoryRelated;
use App\Models\Product\Keyword;
use App\Models\Product\Product;
use App\Models\Project\AiBlogTask;
use App\Models\Project\DeployOptimize;
use App\Models\Project\Project;
use App\Models\RankData\RankDataLog;
... ... @@ -60,16 +62,38 @@ class UpdateRoute extends Command
* @method :post
* @time :2023/11/20 15:13
*/
public function handle(){
public function handle()
{
$projectModel = new Project();
$lists = $projectModel->list(['delete_status'=>0],'id',['id']);
foreach ($lists as $v){
echo date('Y-m-d H:i:s') . '执行项目的project_id:'.$v['id'] . PHP_EOL;
$lists = $projectModel->list(['delete_status' => 0], 'id', ['id']);
echo date('Y-m-d H:i:s') . '开始--------------' . PHP_EOL;
foreach ($lists as $v) {
ProjectServer::useProject($v['id']);
$this->updateSeo();
$this->getAiBlog($v['id']);
DB::disconnect('custom_mysql');
}
echo date('Y-m-d H:i:s') . '--------------结束' . PHP_EOL;
}
/**
* @remark :
* @name :getAiBlog
* @author :lyh
* @method :post
* @time :2025/3/21 17:45
*/
public function getAiBlog($project_id){
$aiBlogModel = new AiBlog();
$lists = $aiBlogModel->list(['updated_at'=>['<=','2025-03-21 00:00:00']]);
if(!empty($lists)){
$aiBlogTaskModel = new AiBlogTask();
foreach ($lists as $k => $v){
$aiBlogTaskModel->edit(['status'=>1],['task_id'=>$v['task_id']]);
}
echo date('Y-m-d H:i:s') . '有任务未执行的project_id:'.$project_id . PHP_EOL;
}
return true;
}
// $this->updateProjectOp();
// $projectModel = new Project();
... ... @@ -94,8 +118,8 @@ class UpdateRoute extends Command
// }
// DB::disconnect('custom_mysql');
// }
echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
}
// echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
// }
/**
* @remark :更新产品
... ...
<?php
/**
* @remark :
* @name :lyhDemo.php
* @author :lyh
* @method :post
* @time :2025/3/24 9:38
*/
namespace App\Console\Commands\LyhTest;
use App\Models\Project\AiBlogTask;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\DB;
class lyhDemo extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'lyh_demo';
/**
* The console command description.
*
* @var string
*/
protected $description = '更新路由';
public function handle(){
$aiBlogTaskModel = new AiBlogTask();
$lists = $aiBlogTaskModel->distinct()->pluck('project_id')->toArray();
foreach ($lists as $v){
echo '执行的项目id:'.$v;
Artisan::call('save_ai_blog_list', ['project_id' => $v]);
}
return true;
}
}
... ...
... ... @@ -225,6 +225,9 @@ class SyncProject extends Command
];
DB::beginTransaction();
try {
if(isset($data['deploy_build']['plan']) && ($data['deploy_build']['plan'] == 15)){
$data['project']['project_type'] = 1;//白帽版本
}
$id = $this->saveProject($data['project']);
$this->setPostId($data['deploy_build']['plan'],$id);
$this->savePayment($data['payment'],$id);
... ...
... ... @@ -556,12 +556,13 @@ class OptimizeController extends BaseController
]);
ProjectServer::useProject($this->param['project_id']);
$aiBlogModel = new AiBlog();
$list = $aiBlogModel->formatQuery(['anchor'=>['!=',null]])->pluck('route')->toArray();
$list = $aiBlogModel->formatQuery(['route'=>['!=',null]])->pluck('route')->toArray();
if(!empty($list)){
$domainModel = new DomainInfo();
$DomainInfo = $domainModel->read(['project_id'=>$this->param['project_id']]);
$DomainInfo['domain'] = $DomainInfo['domain'] ?? '';
foreach ($list as $k => $v){
$v = ('https://'.$DomainInfo['domain'] ?? ''.'/') . 'blog/' . $v;
$v = ('https://'.$DomainInfo['domain'].'/') . 'blog/' . $v;
$list[$k] = $v;
}
}
... ...
... ... @@ -12,41 +12,6 @@ use App\Models\Ai\AiBlogList;
class AiBlogController extends BaseController
{
/**
* @remark :获取详情
* @name :getInfo
* @author :lyh
* @method :post
* @time :2025/2/20 18:17
*/
public function getInfo(AiBlog $aiBlog){
$this->request->validate([
'id'=>['required'],
],[
'id.required' => '主键不能为空',
]);
$info = $aiBlog->read(['id'=>$this->param['id']]);
$info['image'] = getImageUrl($info['image']);
$this->response('success',Code::SUCCESS,$info);
}
/**
* @remark :获取详情数据
* @name :getAuthorInfo
* @author :lyh
* @method :post
* @time :2025/2/21 13:54
*/
public function getAuthorInfo(AiBlogAuthor $aiBlogAuthor){
$this->request->validate([
'id'=>['required'],
],[
'id.required' => '主键不能为空',
]);
$info = $aiBlogAuthor->read($this->map);
$info['image'] = getImageUrl($info['image']);
$this->response('success',Code::SUCCESS,$info);
}
/**
* @remark :获取ai博客列表
... ... @@ -70,6 +35,24 @@ class AiBlogController extends BaseController
}
/**
* @remark :获取详情
* @name :getInfo
* @author :lyh
* @method :post
* @time :2025/2/20 18:17
*/
public function getInfo(AiBlog $aiBlog){
$this->request->validate([
'id'=>['required'],
],[
'id.required' => '主键不能为空',
]);
$info = $aiBlog->read(['id'=>$this->param['id']]);
$info['image'] = getImageUrl($info['image']);
$this->response('success',Code::SUCCESS,$info);
}
/**
* @remark :发布任务
* @name :sendTask
* @author :lyh
... ... @@ -90,6 +73,19 @@ class AiBlogController extends BaseController
}
/**
* @remark :编辑Ai博客发布
* @name :save
* @author :lyh
* @method :post
* @time :2023/7/5 14:33
*/
public function save(AiBlogRequest $aiBlogRequest,AiBlogLogic $aiBlogLogic){
$aiBlogRequest->validated();
$aiBlogLogic->blogSave();
$this->response('success');
}
/**
* @remark :获取作者列表
* @name :getAiBlogAuthor
* @author :lyh
... ... @@ -110,20 +106,6 @@ class AiBlogController extends BaseController
}
/**
* @remark :编辑Ai博客发布
* @name :save
* @author :lyh
* @method :post
* @time :2023/7/5 14:33
*/
public function save(AiBlogRequest $aiBlogRequest,AiBlogLogic $aiBlogLogic){
$aiBlogRequest->validated();
$aiBlogLogic->blogSave();
$this->response('success');
}
/**
* @remark :编辑作者详情数据
* @name :saveBlogAuthor
* @author :lyh
... ... @@ -192,4 +174,22 @@ class AiBlogController extends BaseController
$info = $aiBlogList->read($this->map);
$this->response('success',Code::SUCCESS,$info);
}
/**
* @remark :获取详情数据
* @name :getAuthorInfo
* @author :lyh
* @method :post
* @time :2025/2/21 13:54
*/
public function getAuthorInfo(AiBlogAuthor $aiBlogAuthor){
$this->request->validate([
'id'=>['required'],
],[
'id.required' => '主键不能为空',
]);
$info = $aiBlogAuthor->read($this->map);
$info['image'] = getImageUrl($info['image']);
$this->response('success',Code::SUCCESS,$info);
}
}
... ...
... ... @@ -89,8 +89,6 @@ class CategoryController extends BaseController
public function get3283Lists($filed){
if(!isset($this->map['title'])){
$this->map['pid'] = $this->map['pid'] ?? 0;
}else{
$this->map['title'] = ['like','%'.$this->map['title'].'%'];
}
$list = $this->model->list($this->map,['sort','id'],$filed);
$template_id = $this->getTemplateId(BTemplate::SOURCE_PRODUCT,BTemplate::IS_LIST);//获取模版id
... ...
... ... @@ -27,6 +27,7 @@ use App\Models\Project\Project;
use App\Models\Project\ProjectAiSetting;
use App\Models\RouteMap\RouteMap;
use App\Services\AiBlogService;
use App\Services\GoogleKeywordInsightService;
use App\Services\ProjectServer;
use Illuminate\Support\Facades\DB;
... ... @@ -41,7 +42,8 @@ class TestController extends BaseController
*/
public function ceshi(){
//获取上一周询盘数量
$result = (new FormGlobalsoApi())->getDateInquiry($this->param['domain'],$this->param['start'],$this->param['end']);
$this->response('success',Code::SUCCESS,$result);
$service = new GoogleKeywordInsightService();
$list = $service->requestUrl('cnc');
$this->response('success',Code::SUCCESS,$list);
}
}
... ...
... ... @@ -48,6 +48,7 @@ use App\Models\User\ProjectRole;
use App\Models\User\User as UserModel;
use App\Models\WebSetting\WebLanguage;
use App\Services\AiBlogService;
use App\Services\DingService;
use App\Services\ProjectServer;
use App\Services\SyncService;
use App\Utils\LogUtils;
... ... @@ -157,6 +158,7 @@ class ProjectLogic extends BaseLogic
* @param :1->建站中 2->优化中 3->建站完成 6-》错误单
*/
public function projectSave(){
$this->checkAiBlog($this->param['main_lang_id'],$this->param['is_ai_blog'],$this->param['company'],$this->param['deploy_optimize']['company_en_name'] ?? '',$this->param['deploy_optimize']['company_en_description'] ?? '');
DB::beginTransaction();
try {
if($this->param['type'] == Project::TYPE_SEVEN){
... ... @@ -197,6 +199,22 @@ class ProjectLogic extends BaseLogic
}
/**
* @remark :开启白帽验证产数
* @name :checkAiBlog
* @author :lyh
* @method :post
* @time :2025/3/21 17:32
*/
public function checkAiBlog($main_lang_id,$is_ai_blog,$company,$company_en_name,$company_en_description){
if($is_ai_blog == 1){
if(empty($main_lang_id) || empty($company) || empty($company_en_name) || empty($company_en_description)){
$this->fail('开启ai_blog--请填写主语种+公司名称+公司英文名称+公司英文介绍');
}
}
return true;
}
/**
* @remark :开启AI博客后
* @name :setAiBlog
* @author :lyh
... ...
... ... @@ -6,10 +6,12 @@ use App\Helper\Translate;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\Ai\AiBlog;
use App\Models\Ai\AiBlogAuthor;
use App\Models\Com\Notify;
use App\Models\Project\AiBlogTask;
use App\Models\Project\ProjectAiSetting;
use App\Models\RouteMap\RouteMap;
use App\Services\AiBlogService;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Cache;
class AiBlogLogic extends BaseLogic
... ... @@ -60,10 +62,11 @@ class AiBlogLogic extends BaseLogic
$aiBlogService = new AiBlogService();
$aiBlogService->mch_id = $aiSettingInfo['mch_id'];
$aiBlogService->key = $aiSettingInfo['key'];
$res = $aiBlogService->updateDetail(['task_id'=>$this->param['task_id'],'title'=>$this->param['new_title'],'thumb'=>$this->param['image'],'route'=>$this->param['route'],'author_id'=>$this->param['author_id']]);
$aiBlogService->updateDetail(['task_id'=>$this->param['task_id'],'title'=>$this->param['new_title'],'thumb'=>$this->param['image'],'route'=>$this->param['route'],'author_id'=>$this->param['author_id']]);
}catch (\Exception $e){
$this->fail('保存失败,请联系管理员');
}
$this->sendHttpC([$this->param['route'],'top-blog']);
return $this->success();
}
... ... @@ -90,6 +93,7 @@ class AiBlogLogic extends BaseLogic
}catch (\Exception $e){
$this->fail('保存失败,请联系管理员');
}
$this->sendHttpC([$this->param['route'],'top-blog']);
return $this->success();
}
... ... @@ -108,12 +112,14 @@ class AiBlogLogic extends BaseLogic
$aiBlogService->mch_id = $aiSettingInfo['mch_id'];
$aiBlogService->key = $aiSettingInfo['key'];
$aiBlogService->route = generateRoute(Translate::tran($this->param['keyword'], 'en'));
$result = $aiBlogService->createTask($this->param['keyword'],2,'blog',$this->param['anchor'] ?? []);
$result = $aiBlogService->createTask($this->param['keyword'],2,'blog',$this->param['anchor'] ?? [],$this->param['title'] ?? '');
if($result['status'] == 200){
$aiBlogTaskModel = new AiBlogTask();
$aiBlogTaskModel->addReturnId(['project_id'=>$this->user['project_id'],'type'=>2,'task_id'=>$result['data']['task_id'],'status'=>1]);
$this->model->addReturnId(['keyword'=>$this->param['keyword'], 'status'=>1, 'task_id'=>$result['data']['task_id'],'project_id'=>$this->user['project_id'],'anchor'=>json_encode($this->param['anchor'] ?? [],true)
]);
}else{
@file_put_contents(storage_path('logs/lyh_error.log'), var_export($result, true) . PHP_EOL, FILE_APPEND);
}
return $this->success();
}
... ... @@ -130,20 +136,20 @@ class AiBlogLogic extends BaseLogic
$aiSettingInfo = $this->getProjectAiSetting();
$aiBlogService = new AiBlogService();
foreach ($this->param['ids'] as $id) {
$info = $this->model->read(['id'=>$id],['task_id']);
$info = $this->model->read(['id'=>$id],['task_id','route']);
$aiBlogService->mch_id = $aiSettingInfo['mch_id'];
$aiBlogService->key = $aiSettingInfo['key'];
$aiBlogService->delDetail($info['task_id']);
//删除路由映射
RouteMap::delRoute(RouteMap::SOURCE_AI_BLOG, $id, $this->user['project_id']);
$this->model->del(['id'=>$id]);
$this->curlDelRoute(['old_route'=>$info['route']]);
}
shell_exec('php artisan save_ai_blog_list '.$this->user['project_id'].' > /dev/null 2>&1 &');
Artisan::call('save_ai_blog_list', ['project_id' => $this->user['project_id']]);
}catch (\Exception $e){
$this->fail('删除失败');
}
return $this->success();
}
}
... ...
... ... @@ -36,6 +36,9 @@ class WebSettingLogic extends BaseLogic
* @time :2023/4/28 15:18
*/
public function setting_save(){
if(isset($this->param['is_custom_anchor'])){
$this->param['is_custom_anchor'] = json_encode($this->param['is_custom_anchor'],true);
}
//查看数据是否存在
$info = $this->model->read(['project_id'=>$this->user['project_id']]);
if($info === false){
... ...
... ... @@ -287,6 +287,7 @@ class UserLoginLogic
$info['file_cdn'] = $project['deploy_build']['file_cdn'];
$info['service_duration'] = $project['deploy_build']['service_duration'] ?? 0;
$info['is_comment'] = $project['deploy_build']['is_comment'] ?? 0;
$info['is_ai_blog_send'] = $project['deploy_optimize']['is_ai_blog_send'] ?? 0;
$info['remain_day'] = $project['remain_day'] ?? 0;
$info['project_created_at'] = $project['created_at'];
$info['type'] = $project['type'] ?? 1;
... ...
... ... @@ -115,7 +115,7 @@ class Project extends Base
12 => '俄语商务版',
14 => '俄语旗舰版',
13 => '体验版',
15 => '白帽 SEO'
15 => '白帽SEO方案'
];
}
... ...
... ... @@ -127,7 +127,7 @@ class RouteMap extends Base
public static function setRoute($title, $source, $source_id, $project_id = 0){
$route = self::generateRoute($title, $source, $source_id, $project_id);
if(!$route){
throw new \Exception('路由生成失败');
return time().$project_id;
}
try {
$route_map = self::where(['project_id' => $project_id, 'source' => $source, 'source_id'=>$source_id])->first();
... ...
... ... @@ -2,6 +2,7 @@
namespace App\Models\WebSetting;
use App\Helper\Arr;
use App\Models\Base;
use Illuminate\Support\Facades\Redis;
... ... @@ -35,4 +36,18 @@ class WebSetting extends Base
}
return json_decode(Redis::get("project_".$project->id."_web_setting"));
}
/**
* @remark :是否开启锚文本
* @name :getIsCustomAnchorAttribute
* @author :lyh
* @method :post
* @time :2025/3/24 15:07
*/
public function getIsCustomAnchorAttribute($value){
if(!empty($value)){
$value = Arr::s2a($value);
}
return $value;
}
}
... ...
... ... @@ -12,6 +12,7 @@ namespace App\Services;
use App\Helper\Translate;
use App\Models\Project\ProjectAiSetting;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Cache;
class AiBlogService
{
... ... @@ -36,6 +37,13 @@ class AiBlogService
}
}
/**
* @remark :设置路由
* @name :setRoute
* @author :lyh
* @method :post
* @time :2025/3/25 9:45
*/
public function setRoute($keyword)
{
$this->route = generateRoute(Translate::tran($keyword, 'en'));
... ... @@ -52,11 +60,7 @@ class AiBlogService
public function createProject($project_name,$language,$profile,$company){
$request_url = $this->url.'api/project/create';
$param = [
'mch_id'=>$this->mch_id,
'title'=>$project_name,
'language'=>$language,
'profile'=>$profile,
'company'=>$company,
'mch_id'=>$this->mch_id, 'title'=>$project_name, 'language'=>$language, 'profile'=>$profile, 'company'=>$company,
];
$this->sign = $this->generateSign($param,$this->key);
$param['sign'] = $this->sign;
... ... @@ -73,13 +77,7 @@ class AiBlogService
*/
public function updatedProject($project_name,$language,$profile,$company){
$request_url = $this->url.'api/project/save';
$param = [
'mch_id'=>$this->mch_id,
'title'=>$project_name,
'language'=>$language,
'profile'=>$profile,
'company'=>$company,
];
$param = ['mch_id'=>$this->mch_id, 'title'=>$project_name, 'language'=>$language, 'profile'=>$profile, 'company'=>$company];
$this->sign = $this->generateSign($param,$this->key);
$param['sign'] = $this->sign;
$result = http_post($request_url,json_encode($param,true));
... ... @@ -92,15 +90,14 @@ class AiBlogService
* @author :lyh
* @method :post
* @time :2025/2/13 14:39
* @param :type=(1作者2文章) keyword=关键词 subtype=blog url=回调url
* @param :type=(1作者2文章) keyword=关键词 subtype=blog url=回调url , $title = ''
*/
public function createTask($keyword,$type = 2,$subtype = 'Blog',$anchor = []){
public function createTask($keyword,$type = 2,$subtype = 'Blog',$anchor = [],$title = ''){
$request_url = $this->url.'api/task/create';
$param = [
'keyword'=>$keyword,
'type'=>$type,
'subtype'=>$subtype,
];
$param = ['keyword'=>$keyword, 'type'=>$type, 'subtype'=>$subtype];
if(!empty($title)){
$param['title'] = $title;
}
$param['anchor'] = $anchor;
$param['url'] = $this->route;
$param['mch_id'] = $this->mch_id;
... ... @@ -120,9 +117,7 @@ class AiBlogService
*/
public function createAuthor(){
$request_url = $this->url.'api/author/create';
$param = [
'mch_id'=>$this->mch_id,
];
$param = ['mch_id'=>$this->mch_id];
$this->sign = $this->generateSign($param,$this->key);
$param['sign'] = $this->sign;
$result = http_post($request_url,json_encode($param,true));
... ...
<?php
/**
* @remark :
* @name :GoogleKeywordInsightService.php
* @author :lyh
* @method :post
* @time :2025/3/25 11:36
*/
namespace App\Services;
/**
* @remark :google关键字扩展
* @name :GoogleKeywordInsightService
* @author :lyh
* @method :post
* @time :2025/3/25 11:38
*/
class GoogleKeywordInsightService
{
public $url = "";
/**
* @remark :请求数据
* @name :requestUrl
* @author :lyh
* @method :post
* @time :2025/3/25 11:36
*/
public function requestUrl($keyword){
$this->url = 'https://google-keyword-insight1.p.rapidapi.com/globalkey';
$url = $this->url.'/?keyword='.$keyword.'&lang=en';
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"x-rapidapi-host: google-keyword-insight1.p.rapidapi.com",
"x-rapidapi-key: d246239565mshc29088b58ff484dp17c0bdjsn2d28d03622c7"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
return "cURL Error #:" . $err;
} else {
return json_decode($response,true);
}
}
}
... ...