Merge remote-tracking branch 'origin/master' into akun
正在显示
19 个修改的文件
包含
269 行增加
和
106 行删除
| @@ -111,10 +111,19 @@ class AiBlogListTask extends Command | @@ -111,10 +111,19 @@ class AiBlogListTask extends Command | ||
| 111 | //获取项目域名 | 111 | //获取项目域名 |
| 112 | $domain = $domainModel->getProjectIdDomain($project_id); | 112 | $domain = $domainModel->getProjectIdDomain($project_id); |
| 113 | if(!empty($domain)){ | 113 | if(!empty($domain)){ |
| 114 | - $url = $domain.'api/update_page/?project_id='.$project_id.'&route=7'; | ||
| 115 | - shell_exec('curl -k "'.$url.'"'); | 114 | + $c_url = $domain.'api/update_page/'; |
| 115 | + $param = [ | ||
| 116 | + 'project_id' => $this->user['project_id'], | ||
| 117 | + 'type' => 1, | ||
| 118 | + 'route' => 3, | ||
| 119 | + 'url' => ['top-blog'], | ||
| 120 | + 'language'=> [], | ||
| 121 | + 'is_sitemap' => 0 | ||
| 122 | + ]; | ||
| 123 | + $res = http_post($c_url, json_encode($param)); | ||
| 124 | + echo date('Y-m-d H:i:s').'通知成功:' . json_encode($res,JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . PHP_EOL; | ||
| 116 | }else{ | 125 | }else{ |
| 117 | - echo '域名不存在:' . $project_id . PHP_EOL . date('Y-m-d H:i:s'); | 126 | + echo date('Y-m-d H:i:s').'域名不存在:' . $project_id . PHP_EOL; |
| 118 | } | 127 | } |
| 119 | return true; | 128 | return true; |
| 120 | } | 129 | } |
| @@ -133,17 +133,6 @@ class AiBlogTask extends Command | @@ -133,17 +133,6 @@ class AiBlogTask extends Command | ||
| 133 | } | 133 | } |
| 134 | 134 | ||
| 135 | /** | 135 | /** |
| 136 | - * @remark :g获取信息 | ||
| 137 | - * @name :getDetail | ||
| 138 | - * @author :lyh | ||
| 139 | - * @method :post | ||
| 140 | - * @time :2025/3/19 17:24 | ||
| 141 | - */ | ||
| 142 | - public function getDetail(){ | ||
| 143 | - | ||
| 144 | - } | ||
| 145 | - | ||
| 146 | - /** | ||
| 147 | * @remark :获取任务id | 136 | * @remark :获取任务id |
| 148 | * @name :getTaskId | 137 | * @name :getTaskId |
| 149 | * @author :lyh | 138 | * @author :lyh |
| @@ -89,10 +89,11 @@ class LyhImportTest extends Command | @@ -89,10 +89,11 @@ class LyhImportTest extends Command | ||
| 89 | continue; | 89 | continue; |
| 90 | } | 90 | } |
| 91 | if(empty($val[1])){ | 91 | if(empty($val[1])){ |
| 92 | + echo '跳过的名称:'.$val[1]; | ||
| 92 | continue; | 93 | continue; |
| 93 | } | 94 | } |
| 94 | try { | 95 | try { |
| 95 | - $id = $categoryModel->addReturnId(['project_id'=>$project_id,'title'=>$val[1],'seo_title'=>$val[0],'seo_keyword'=>$val[2]]); | 96 | + $id = $categoryModel->addReturnId(['project_id'=>$project_id,'title'=>$val[1],'seo_title'=>$val[0],'seo_des'=>$val[2],'sort'=>$val[3]]); |
| 96 | $pid = 0; | 97 | $pid = 0; |
| 97 | // if($val[2] != 0){ | 98 | // if($val[2] != 0){ |
| 98 | // //查询上级id | 99 | // //查询上级id |
| @@ -11,11 +11,13 @@ namespace App\Console\Commands\LyhTest; | @@ -11,11 +11,13 @@ namespace App\Console\Commands\LyhTest; | ||
| 11 | 11 | ||
| 12 | use App\Helper\Arr; | 12 | use App\Helper\Arr; |
| 13 | use App\Helper\Translate; | 13 | use App\Helper\Translate; |
| 14 | +use App\Models\Ai\AiBlog; | ||
| 14 | use App\Models\Blog\Blog; | 15 | use App\Models\Blog\Blog; |
| 15 | use App\Models\CustomModule\CustomModuleContent; | 16 | use App\Models\CustomModule\CustomModuleContent; |
| 16 | use App\Models\Product\CategoryRelated; | 17 | use App\Models\Product\CategoryRelated; |
| 17 | use App\Models\Product\Keyword; | 18 | use App\Models\Product\Keyword; |
| 18 | use App\Models\Product\Product; | 19 | use App\Models\Product\Product; |
| 20 | +use App\Models\Project\AiBlogTask; | ||
| 19 | use App\Models\Project\DeployOptimize; | 21 | use App\Models\Project\DeployOptimize; |
| 20 | use App\Models\Project\Project; | 22 | use App\Models\Project\Project; |
| 21 | use App\Models\RankData\RankDataLog; | 23 | use App\Models\RankData\RankDataLog; |
| @@ -60,16 +62,38 @@ class UpdateRoute extends Command | @@ -60,16 +62,38 @@ class UpdateRoute extends Command | ||
| 60 | * @method :post | 62 | * @method :post |
| 61 | * @time :2023/11/20 15:13 | 63 | * @time :2023/11/20 15:13 |
| 62 | */ | 64 | */ |
| 63 | - public function handle(){ | 65 | + public function handle() |
| 66 | + { | ||
| 64 | $projectModel = new Project(); | 67 | $projectModel = new Project(); |
| 65 | - $lists = $projectModel->list(['delete_status'=>0],'id',['id']); | ||
| 66 | - foreach ($lists as $v){ | ||
| 67 | - echo date('Y-m-d H:i:s') . '执行项目的project_id:'.$v['id'] . PHP_EOL; | 68 | + $lists = $projectModel->list(['delete_status' => 0], 'id', ['id']); |
| 69 | + echo date('Y-m-d H:i:s') . '开始--------------' . PHP_EOL; | ||
| 70 | + foreach ($lists as $v) { | ||
| 68 | ProjectServer::useProject($v['id']); | 71 | ProjectServer::useProject($v['id']); |
| 69 | - $this->updateSeo(); | 72 | + $this->getAiBlog($v['id']); |
| 70 | DB::disconnect('custom_mysql'); | 73 | DB::disconnect('custom_mysql'); |
| 71 | } | 74 | } |
| 75 | + echo date('Y-m-d H:i:s') . '--------------结束' . PHP_EOL; | ||
| 76 | + } | ||
| 77 | + /** | ||
| 78 | + * @remark : | ||
| 79 | + * @name :getAiBlog | ||
| 80 | + * @author :lyh | ||
| 81 | + * @method :post | ||
| 82 | + * @time :2025/3/21 17:45 | ||
| 83 | + */ | ||
| 84 | + public function getAiBlog($project_id){ | ||
| 85 | + $aiBlogModel = new AiBlog(); | ||
| 86 | + $lists = $aiBlogModel->list(['updated_at'=>['<=','2025-03-21 00:00:00']]); | ||
| 87 | + if(!empty($lists)){ | ||
| 72 | 88 | ||
| 89 | + $aiBlogTaskModel = new AiBlogTask(); | ||
| 90 | + foreach ($lists as $k => $v){ | ||
| 91 | + $aiBlogTaskModel->edit(['status'=>1],['task_id'=>$v['task_id']]); | ||
| 92 | + } | ||
| 93 | + echo date('Y-m-d H:i:s') . '有任务未执行的project_id:'.$project_id . PHP_EOL; | ||
| 94 | + } | ||
| 95 | + return true; | ||
| 96 | + } | ||
| 73 | 97 | ||
| 74 | // $this->updateProjectOp(); | 98 | // $this->updateProjectOp(); |
| 75 | // $projectModel = new Project(); | 99 | // $projectModel = new Project(); |
| @@ -94,8 +118,8 @@ class UpdateRoute extends Command | @@ -94,8 +118,8 @@ class UpdateRoute extends Command | ||
| 94 | // } | 118 | // } |
| 95 | // DB::disconnect('custom_mysql'); | 119 | // DB::disconnect('custom_mysql'); |
| 96 | // } | 120 | // } |
| 97 | - echo date('Y-m-d H:i:s') . 'end' . PHP_EOL; | ||
| 98 | - } | 121 | +// echo date('Y-m-d H:i:s') . 'end' . PHP_EOL; |
| 122 | +// } | ||
| 99 | 123 | ||
| 100 | /** | 124 | /** |
| 101 | * @remark :更新产品 | 125 | * @remark :更新产品 |
app/Console/Commands/LyhTest/lyhDemo.php
0 → 100644
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * @remark : | ||
| 4 | + * @name :lyhDemo.php | ||
| 5 | + * @author :lyh | ||
| 6 | + * @method :post | ||
| 7 | + * @time :2025/3/24 9:38 | ||
| 8 | + */ | ||
| 9 | + | ||
| 10 | +namespace App\Console\Commands\LyhTest; | ||
| 11 | + | ||
| 12 | +use App\Models\Project\AiBlogTask; | ||
| 13 | +use Illuminate\Console\Command; | ||
| 14 | +use Illuminate\Support\Facades\Artisan; | ||
| 15 | +use Illuminate\Support\Facades\DB; | ||
| 16 | + | ||
| 17 | +class lyhDemo extends Command | ||
| 18 | +{ | ||
| 19 | + /** | ||
| 20 | + * The name and signature of the console command. | ||
| 21 | + * | ||
| 22 | + * @var string | ||
| 23 | + */ | ||
| 24 | + protected $signature = 'lyh_demo'; | ||
| 25 | + | ||
| 26 | + /** | ||
| 27 | + * The console command description. | ||
| 28 | + * | ||
| 29 | + * @var string | ||
| 30 | + */ | ||
| 31 | + protected $description = '更新路由'; | ||
| 32 | + | ||
| 33 | + public function handle(){ | ||
| 34 | + $aiBlogTaskModel = new AiBlogTask(); | ||
| 35 | + $lists = $aiBlogTaskModel->distinct()->pluck('project_id')->toArray(); | ||
| 36 | + foreach ($lists as $v){ | ||
| 37 | + echo '执行的项目id:'.$v; | ||
| 38 | + Artisan::call('save_ai_blog_list', ['project_id' => $v]); | ||
| 39 | + } | ||
| 40 | + return true; | ||
| 41 | + } | ||
| 42 | +} |
| @@ -225,6 +225,9 @@ class SyncProject extends Command | @@ -225,6 +225,9 @@ class SyncProject extends Command | ||
| 225 | ]; | 225 | ]; |
| 226 | DB::beginTransaction(); | 226 | DB::beginTransaction(); |
| 227 | try { | 227 | try { |
| 228 | + if(isset($data['deploy_build']['plan']) && ($data['deploy_build']['plan'] == 15)){ | ||
| 229 | + $data['project']['project_type'] = 1;//白帽版本 | ||
| 230 | + } | ||
| 228 | $id = $this->saveProject($data['project']); | 231 | $id = $this->saveProject($data['project']); |
| 229 | $this->setPostId($data['deploy_build']['plan'],$id); | 232 | $this->setPostId($data['deploy_build']['plan'],$id); |
| 230 | $this->savePayment($data['payment'],$id); | 233 | $this->savePayment($data['payment'],$id); |
| @@ -556,12 +556,13 @@ class OptimizeController extends BaseController | @@ -556,12 +556,13 @@ class OptimizeController extends BaseController | ||
| 556 | ]); | 556 | ]); |
| 557 | ProjectServer::useProject($this->param['project_id']); | 557 | ProjectServer::useProject($this->param['project_id']); |
| 558 | $aiBlogModel = new AiBlog(); | 558 | $aiBlogModel = new AiBlog(); |
| 559 | - $list = $aiBlogModel->formatQuery(['anchor'=>['!=',null]])->pluck('route')->toArray(); | 559 | + $list = $aiBlogModel->formatQuery(['route'=>['!=',null]])->pluck('route')->toArray(); |
| 560 | if(!empty($list)){ | 560 | if(!empty($list)){ |
| 561 | $domainModel = new DomainInfo(); | 561 | $domainModel = new DomainInfo(); |
| 562 | $DomainInfo = $domainModel->read(['project_id'=>$this->param['project_id']]); | 562 | $DomainInfo = $domainModel->read(['project_id'=>$this->param['project_id']]); |
| 563 | + $DomainInfo['domain'] = $DomainInfo['domain'] ?? ''; | ||
| 563 | foreach ($list as $k => $v){ | 564 | foreach ($list as $k => $v){ |
| 564 | - $v = ('https://'.$DomainInfo['domain'] ?? ''.'/') . 'blog/' . $v; | 565 | + $v = ('https://'.$DomainInfo['domain'].'/') . 'blog/' . $v; |
| 565 | $list[$k] = $v; | 566 | $list[$k] = $v; |
| 566 | } | 567 | } |
| 567 | } | 568 | } |
| @@ -12,41 +12,6 @@ use App\Models\Ai\AiBlogList; | @@ -12,41 +12,6 @@ use App\Models\Ai\AiBlogList; | ||
| 12 | 12 | ||
| 13 | class AiBlogController extends BaseController | 13 | class AiBlogController extends BaseController |
| 14 | { | 14 | { |
| 15 | - /** | ||
| 16 | - * @remark :获取详情 | ||
| 17 | - * @name :getInfo | ||
| 18 | - * @author :lyh | ||
| 19 | - * @method :post | ||
| 20 | - * @time :2025/2/20 18:17 | ||
| 21 | - */ | ||
| 22 | - public function getInfo(AiBlog $aiBlog){ | ||
| 23 | - $this->request->validate([ | ||
| 24 | - 'id'=>['required'], | ||
| 25 | - ],[ | ||
| 26 | - 'id.required' => '主键不能为空', | ||
| 27 | - ]); | ||
| 28 | - $info = $aiBlog->read(['id'=>$this->param['id']]); | ||
| 29 | - $info['image'] = getImageUrl($info['image']); | ||
| 30 | - $this->response('success',Code::SUCCESS,$info); | ||
| 31 | - } | ||
| 32 | - | ||
| 33 | - /** | ||
| 34 | - * @remark :获取详情数据 | ||
| 35 | - * @name :getAuthorInfo | ||
| 36 | - * @author :lyh | ||
| 37 | - * @method :post | ||
| 38 | - * @time :2025/2/21 13:54 | ||
| 39 | - */ | ||
| 40 | - public function getAuthorInfo(AiBlogAuthor $aiBlogAuthor){ | ||
| 41 | - $this->request->validate([ | ||
| 42 | - 'id'=>['required'], | ||
| 43 | - ],[ | ||
| 44 | - 'id.required' => '主键不能为空', | ||
| 45 | - ]); | ||
| 46 | - $info = $aiBlogAuthor->read($this->map); | ||
| 47 | - $info['image'] = getImageUrl($info['image']); | ||
| 48 | - $this->response('success',Code::SUCCESS,$info); | ||
| 49 | - } | ||
| 50 | 15 | ||
| 51 | /** | 16 | /** |
| 52 | * @remark :获取ai博客列表 | 17 | * @remark :获取ai博客列表 |
| @@ -70,6 +35,24 @@ class AiBlogController extends BaseController | @@ -70,6 +35,24 @@ class AiBlogController extends BaseController | ||
| 70 | } | 35 | } |
| 71 | 36 | ||
| 72 | /** | 37 | /** |
| 38 | + * @remark :获取详情 | ||
| 39 | + * @name :getInfo | ||
| 40 | + * @author :lyh | ||
| 41 | + * @method :post | ||
| 42 | + * @time :2025/2/20 18:17 | ||
| 43 | + */ | ||
| 44 | + public function getInfo(AiBlog $aiBlog){ | ||
| 45 | + $this->request->validate([ | ||
| 46 | + 'id'=>['required'], | ||
| 47 | + ],[ | ||
| 48 | + 'id.required' => '主键不能为空', | ||
| 49 | + ]); | ||
| 50 | + $info = $aiBlog->read(['id'=>$this->param['id']]); | ||
| 51 | + $info['image'] = getImageUrl($info['image']); | ||
| 52 | + $this->response('success',Code::SUCCESS,$info); | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + /** | ||
| 73 | * @remark :发布任务 | 56 | * @remark :发布任务 |
| 74 | * @name :sendTask | 57 | * @name :sendTask |
| 75 | * @author :lyh | 58 | * @author :lyh |
| @@ -90,6 +73,19 @@ class AiBlogController extends BaseController | @@ -90,6 +73,19 @@ class AiBlogController extends BaseController | ||
| 90 | } | 73 | } |
| 91 | 74 | ||
| 92 | /** | 75 | /** |
| 76 | + * @remark :编辑Ai博客发布 | ||
| 77 | + * @name :save | ||
| 78 | + * @author :lyh | ||
| 79 | + * @method :post | ||
| 80 | + * @time :2023/7/5 14:33 | ||
| 81 | + */ | ||
| 82 | + public function save(AiBlogRequest $aiBlogRequest,AiBlogLogic $aiBlogLogic){ | ||
| 83 | + $aiBlogRequest->validated(); | ||
| 84 | + $aiBlogLogic->blogSave(); | ||
| 85 | + $this->response('success'); | ||
| 86 | + } | ||
| 87 | + | ||
| 88 | + /** | ||
| 93 | * @remark :获取作者列表 | 89 | * @remark :获取作者列表 |
| 94 | * @name :getAiBlogAuthor | 90 | * @name :getAiBlogAuthor |
| 95 | * @author :lyh | 91 | * @author :lyh |
| @@ -110,20 +106,6 @@ class AiBlogController extends BaseController | @@ -110,20 +106,6 @@ class AiBlogController extends BaseController | ||
| 110 | } | 106 | } |
| 111 | 107 | ||
| 112 | /** | 108 | /** |
| 113 | - * @remark :编辑Ai博客发布 | ||
| 114 | - * @name :save | ||
| 115 | - * @author :lyh | ||
| 116 | - * @method :post | ||
| 117 | - * @time :2023/7/5 14:33 | ||
| 118 | - */ | ||
| 119 | - public function save(AiBlogRequest $aiBlogRequest,AiBlogLogic $aiBlogLogic){ | ||
| 120 | - $aiBlogRequest->validated(); | ||
| 121 | - $aiBlogLogic->blogSave(); | ||
| 122 | - $this->response('success'); | ||
| 123 | - } | ||
| 124 | - | ||
| 125 | - | ||
| 126 | - /** | ||
| 127 | * @remark :编辑作者详情数据 | 109 | * @remark :编辑作者详情数据 |
| 128 | * @name :saveBlogAuthor | 110 | * @name :saveBlogAuthor |
| 129 | * @author :lyh | 111 | * @author :lyh |
| @@ -192,4 +174,22 @@ class AiBlogController extends BaseController | @@ -192,4 +174,22 @@ class AiBlogController extends BaseController | ||
| 192 | $info = $aiBlogList->read($this->map); | 174 | $info = $aiBlogList->read($this->map); |
| 193 | $this->response('success',Code::SUCCESS,$info); | 175 | $this->response('success',Code::SUCCESS,$info); |
| 194 | } | 176 | } |
| 177 | + | ||
| 178 | + /** | ||
| 179 | + * @remark :获取详情数据 | ||
| 180 | + * @name :getAuthorInfo | ||
| 181 | + * @author :lyh | ||
| 182 | + * @method :post | ||
| 183 | + * @time :2025/2/21 13:54 | ||
| 184 | + */ | ||
| 185 | + public function getAuthorInfo(AiBlogAuthor $aiBlogAuthor){ | ||
| 186 | + $this->request->validate([ | ||
| 187 | + 'id'=>['required'], | ||
| 188 | + ],[ | ||
| 189 | + 'id.required' => '主键不能为空', | ||
| 190 | + ]); | ||
| 191 | + $info = $aiBlogAuthor->read($this->map); | ||
| 192 | + $info['image'] = getImageUrl($info['image']); | ||
| 193 | + $this->response('success',Code::SUCCESS,$info); | ||
| 194 | + } | ||
| 195 | } | 195 | } |
| @@ -89,8 +89,6 @@ class CategoryController extends BaseController | @@ -89,8 +89,6 @@ class CategoryController extends BaseController | ||
| 89 | public function get3283Lists($filed){ | 89 | public function get3283Lists($filed){ |
| 90 | if(!isset($this->map['title'])){ | 90 | if(!isset($this->map['title'])){ |
| 91 | $this->map['pid'] = $this->map['pid'] ?? 0; | 91 | $this->map['pid'] = $this->map['pid'] ?? 0; |
| 92 | - }else{ | ||
| 93 | - $this->map['title'] = ['like','%'.$this->map['title'].'%']; | ||
| 94 | } | 92 | } |
| 95 | $list = $this->model->list($this->map,['sort','id'],$filed); | 93 | $list = $this->model->list($this->map,['sort','id'],$filed); |
| 96 | $template_id = $this->getTemplateId(BTemplate::SOURCE_PRODUCT,BTemplate::IS_LIST);//获取模版id | 94 | $template_id = $this->getTemplateId(BTemplate::SOURCE_PRODUCT,BTemplate::IS_LIST);//获取模版id |
| @@ -27,6 +27,7 @@ use App\Models\Project\Project; | @@ -27,6 +27,7 @@ use App\Models\Project\Project; | ||
| 27 | use App\Models\Project\ProjectAiSetting; | 27 | use App\Models\Project\ProjectAiSetting; |
| 28 | use App\Models\RouteMap\RouteMap; | 28 | use App\Models\RouteMap\RouteMap; |
| 29 | use App\Services\AiBlogService; | 29 | use App\Services\AiBlogService; |
| 30 | +use App\Services\GoogleKeywordInsightService; | ||
| 30 | use App\Services\ProjectServer; | 31 | use App\Services\ProjectServer; |
| 31 | use Illuminate\Support\Facades\DB; | 32 | use Illuminate\Support\Facades\DB; |
| 32 | 33 | ||
| @@ -41,7 +42,8 @@ class TestController extends BaseController | @@ -41,7 +42,8 @@ class TestController extends BaseController | ||
| 41 | */ | 42 | */ |
| 42 | public function ceshi(){ | 43 | public function ceshi(){ |
| 43 | //获取上一周询盘数量 | 44 | //获取上一周询盘数量 |
| 44 | - $result = (new FormGlobalsoApi())->getDateInquiry($this->param['domain'],$this->param['start'],$this->param['end']); | ||
| 45 | - $this->response('success',Code::SUCCESS,$result); | 45 | + $service = new GoogleKeywordInsightService(); |
| 46 | + $list = $service->requestUrl('cnc'); | ||
| 47 | + $this->response('success',Code::SUCCESS,$list); | ||
| 46 | } | 48 | } |
| 47 | } | 49 | } |
| @@ -48,6 +48,7 @@ use App\Models\User\ProjectRole; | @@ -48,6 +48,7 @@ use App\Models\User\ProjectRole; | ||
| 48 | use App\Models\User\User as UserModel; | 48 | use App\Models\User\User as UserModel; |
| 49 | use App\Models\WebSetting\WebLanguage; | 49 | use App\Models\WebSetting\WebLanguage; |
| 50 | use App\Services\AiBlogService; | 50 | use App\Services\AiBlogService; |
| 51 | +use App\Services\DingService; | ||
| 51 | use App\Services\ProjectServer; | 52 | use App\Services\ProjectServer; |
| 52 | use App\Services\SyncService; | 53 | use App\Services\SyncService; |
| 53 | use App\Utils\LogUtils; | 54 | use App\Utils\LogUtils; |
| @@ -157,6 +158,7 @@ class ProjectLogic extends BaseLogic | @@ -157,6 +158,7 @@ class ProjectLogic extends BaseLogic | ||
| 157 | * @param :1->建站中 2->优化中 3->建站完成 6-》错误单 | 158 | * @param :1->建站中 2->优化中 3->建站完成 6-》错误单 |
| 158 | */ | 159 | */ |
| 159 | public function projectSave(){ | 160 | public function projectSave(){ |
| 161 | + $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'] ?? ''); | ||
| 160 | DB::beginTransaction(); | 162 | DB::beginTransaction(); |
| 161 | try { | 163 | try { |
| 162 | if($this->param['type'] == Project::TYPE_SEVEN){ | 164 | if($this->param['type'] == Project::TYPE_SEVEN){ |
| @@ -197,6 +199,22 @@ class ProjectLogic extends BaseLogic | @@ -197,6 +199,22 @@ class ProjectLogic extends BaseLogic | ||
| 197 | } | 199 | } |
| 198 | 200 | ||
| 199 | /** | 201 | /** |
| 202 | + * @remark :开启白帽验证产数 | ||
| 203 | + * @name :checkAiBlog | ||
| 204 | + * @author :lyh | ||
| 205 | + * @method :post | ||
| 206 | + * @time :2025/3/21 17:32 | ||
| 207 | + */ | ||
| 208 | + public function checkAiBlog($main_lang_id,$is_ai_blog,$company,$company_en_name,$company_en_description){ | ||
| 209 | + if($is_ai_blog == 1){ | ||
| 210 | + if(empty($main_lang_id) || empty($company) || empty($company_en_name) || empty($company_en_description)){ | ||
| 211 | + $this->fail('开启ai_blog--请填写主语种+公司名称+公司英文名称+公司英文介绍'); | ||
| 212 | + } | ||
| 213 | + } | ||
| 214 | + return true; | ||
| 215 | + } | ||
| 216 | + | ||
| 217 | + /** | ||
| 200 | * @remark :开启AI博客后 | 218 | * @remark :开启AI博客后 |
| 201 | * @name :setAiBlog | 219 | * @name :setAiBlog |
| 202 | * @author :lyh | 220 | * @author :lyh |
| @@ -6,10 +6,12 @@ use App\Helper\Translate; | @@ -6,10 +6,12 @@ use App\Helper\Translate; | ||
| 6 | use App\Http\Logic\Bside\BaseLogic; | 6 | use App\Http\Logic\Bside\BaseLogic; |
| 7 | use App\Models\Ai\AiBlog; | 7 | use App\Models\Ai\AiBlog; |
| 8 | use App\Models\Ai\AiBlogAuthor; | 8 | use App\Models\Ai\AiBlogAuthor; |
| 9 | +use App\Models\Com\Notify; | ||
| 9 | use App\Models\Project\AiBlogTask; | 10 | use App\Models\Project\AiBlogTask; |
| 10 | use App\Models\Project\ProjectAiSetting; | 11 | use App\Models\Project\ProjectAiSetting; |
| 11 | use App\Models\RouteMap\RouteMap; | 12 | use App\Models\RouteMap\RouteMap; |
| 12 | use App\Services\AiBlogService; | 13 | use App\Services\AiBlogService; |
| 14 | +use Illuminate\Support\Facades\Artisan; | ||
| 13 | use Illuminate\Support\Facades\Cache; | 15 | use Illuminate\Support\Facades\Cache; |
| 14 | 16 | ||
| 15 | class AiBlogLogic extends BaseLogic | 17 | class AiBlogLogic extends BaseLogic |
| @@ -60,10 +62,11 @@ class AiBlogLogic extends BaseLogic | @@ -60,10 +62,11 @@ class AiBlogLogic extends BaseLogic | ||
| 60 | $aiBlogService = new AiBlogService(); | 62 | $aiBlogService = new AiBlogService(); |
| 61 | $aiBlogService->mch_id = $aiSettingInfo['mch_id']; | 63 | $aiBlogService->mch_id = $aiSettingInfo['mch_id']; |
| 62 | $aiBlogService->key = $aiSettingInfo['key']; | 64 | $aiBlogService->key = $aiSettingInfo['key']; |
| 63 | - $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']]); | 65 | + $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']]); |
| 64 | }catch (\Exception $e){ | 66 | }catch (\Exception $e){ |
| 65 | $this->fail('保存失败,请联系管理员'); | 67 | $this->fail('保存失败,请联系管理员'); |
| 66 | } | 68 | } |
| 69 | + $this->sendHttpC([$this->param['route'],'top-blog']); | ||
| 67 | return $this->success(); | 70 | return $this->success(); |
| 68 | } | 71 | } |
| 69 | 72 | ||
| @@ -90,6 +93,7 @@ class AiBlogLogic extends BaseLogic | @@ -90,6 +93,7 @@ class AiBlogLogic extends BaseLogic | ||
| 90 | }catch (\Exception $e){ | 93 | }catch (\Exception $e){ |
| 91 | $this->fail('保存失败,请联系管理员'); | 94 | $this->fail('保存失败,请联系管理员'); |
| 92 | } | 95 | } |
| 96 | + $this->sendHttpC([$this->param['route'],'top-blog']); | ||
| 93 | return $this->success(); | 97 | return $this->success(); |
| 94 | } | 98 | } |
| 95 | 99 | ||
| @@ -108,12 +112,14 @@ class AiBlogLogic extends BaseLogic | @@ -108,12 +112,14 @@ class AiBlogLogic extends BaseLogic | ||
| 108 | $aiBlogService->mch_id = $aiSettingInfo['mch_id']; | 112 | $aiBlogService->mch_id = $aiSettingInfo['mch_id']; |
| 109 | $aiBlogService->key = $aiSettingInfo['key']; | 113 | $aiBlogService->key = $aiSettingInfo['key']; |
| 110 | $aiBlogService->route = generateRoute(Translate::tran($this->param['keyword'], 'en')); | 114 | $aiBlogService->route = generateRoute(Translate::tran($this->param['keyword'], 'en')); |
| 111 | - $result = $aiBlogService->createTask($this->param['keyword'],2,'blog',$this->param['anchor'] ?? []); | 115 | + $result = $aiBlogService->createTask($this->param['keyword'],2,'blog',$this->param['anchor'] ?? [],$this->param['title'] ?? ''); |
| 112 | if($result['status'] == 200){ | 116 | if($result['status'] == 200){ |
| 113 | $aiBlogTaskModel = new AiBlogTask(); | 117 | $aiBlogTaskModel = new AiBlogTask(); |
| 114 | $aiBlogTaskModel->addReturnId(['project_id'=>$this->user['project_id'],'type'=>2,'task_id'=>$result['data']['task_id'],'status'=>1]); | 118 | $aiBlogTaskModel->addReturnId(['project_id'=>$this->user['project_id'],'type'=>2,'task_id'=>$result['data']['task_id'],'status'=>1]); |
| 115 | $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) | 119 | $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) |
| 116 | ]); | 120 | ]); |
| 121 | + }else{ | ||
| 122 | + @file_put_contents(storage_path('logs/lyh_error.log'), var_export($result, true) . PHP_EOL, FILE_APPEND); | ||
| 117 | } | 123 | } |
| 118 | return $this->success(); | 124 | return $this->success(); |
| 119 | } | 125 | } |
| @@ -130,20 +136,20 @@ class AiBlogLogic extends BaseLogic | @@ -130,20 +136,20 @@ class AiBlogLogic extends BaseLogic | ||
| 130 | $aiSettingInfo = $this->getProjectAiSetting(); | 136 | $aiSettingInfo = $this->getProjectAiSetting(); |
| 131 | $aiBlogService = new AiBlogService(); | 137 | $aiBlogService = new AiBlogService(); |
| 132 | foreach ($this->param['ids'] as $id) { | 138 | foreach ($this->param['ids'] as $id) { |
| 133 | - $info = $this->model->read(['id'=>$id],['task_id']); | 139 | + $info = $this->model->read(['id'=>$id],['task_id','route']); |
| 134 | $aiBlogService->mch_id = $aiSettingInfo['mch_id']; | 140 | $aiBlogService->mch_id = $aiSettingInfo['mch_id']; |
| 135 | $aiBlogService->key = $aiSettingInfo['key']; | 141 | $aiBlogService->key = $aiSettingInfo['key']; |
| 136 | $aiBlogService->delDetail($info['task_id']); | 142 | $aiBlogService->delDetail($info['task_id']); |
| 137 | //删除路由映射 | 143 | //删除路由映射 |
| 138 | RouteMap::delRoute(RouteMap::SOURCE_AI_BLOG, $id, $this->user['project_id']); | 144 | RouteMap::delRoute(RouteMap::SOURCE_AI_BLOG, $id, $this->user['project_id']); |
| 139 | $this->model->del(['id'=>$id]); | 145 | $this->model->del(['id'=>$id]); |
| 146 | + $this->curlDelRoute(['old_route'=>$info['route']]); | ||
| 140 | } | 147 | } |
| 141 | - shell_exec('php artisan save_ai_blog_list '.$this->user['project_id'].' > /dev/null 2>&1 &'); | 148 | + Artisan::call('save_ai_blog_list', ['project_id' => $this->user['project_id']]); |
| 142 | }catch (\Exception $e){ | 149 | }catch (\Exception $e){ |
| 143 | $this->fail('删除失败'); | 150 | $this->fail('删除失败'); |
| 144 | } | 151 | } |
| 145 | return $this->success(); | 152 | return $this->success(); |
| 146 | } | 153 | } |
| 147 | 154 | ||
| 148 | - | ||
| 149 | } | 155 | } |
| @@ -36,6 +36,9 @@ class WebSettingLogic extends BaseLogic | @@ -36,6 +36,9 @@ class WebSettingLogic extends BaseLogic | ||
| 36 | * @time :2023/4/28 15:18 | 36 | * @time :2023/4/28 15:18 |
| 37 | */ | 37 | */ |
| 38 | public function setting_save(){ | 38 | public function setting_save(){ |
| 39 | + if(isset($this->param['is_custom_anchor'])){ | ||
| 40 | + $this->param['is_custom_anchor'] = json_encode($this->param['is_custom_anchor'],true); | ||
| 41 | + } | ||
| 39 | //查看数据是否存在 | 42 | //查看数据是否存在 |
| 40 | $info = $this->model->read(['project_id'=>$this->user['project_id']]); | 43 | $info = $this->model->read(['project_id'=>$this->user['project_id']]); |
| 41 | if($info === false){ | 44 | if($info === false){ |
| @@ -287,6 +287,7 @@ class UserLoginLogic | @@ -287,6 +287,7 @@ class UserLoginLogic | ||
| 287 | $info['file_cdn'] = $project['deploy_build']['file_cdn']; | 287 | $info['file_cdn'] = $project['deploy_build']['file_cdn']; |
| 288 | $info['service_duration'] = $project['deploy_build']['service_duration'] ?? 0; | 288 | $info['service_duration'] = $project['deploy_build']['service_duration'] ?? 0; |
| 289 | $info['is_comment'] = $project['deploy_build']['is_comment'] ?? 0; | 289 | $info['is_comment'] = $project['deploy_build']['is_comment'] ?? 0; |
| 290 | + $info['is_ai_blog_send'] = $project['deploy_optimize']['is_ai_blog_send'] ?? 0; | ||
| 290 | $info['remain_day'] = $project['remain_day'] ?? 0; | 291 | $info['remain_day'] = $project['remain_day'] ?? 0; |
| 291 | $info['project_created_at'] = $project['created_at']; | 292 | $info['project_created_at'] = $project['created_at']; |
| 292 | $info['type'] = $project['type'] ?? 1; | 293 | $info['type'] = $project['type'] ?? 1; |
| @@ -127,7 +127,7 @@ class RouteMap extends Base | @@ -127,7 +127,7 @@ class RouteMap extends Base | ||
| 127 | public static function setRoute($title, $source, $source_id, $project_id = 0){ | 127 | public static function setRoute($title, $source, $source_id, $project_id = 0){ |
| 128 | $route = self::generateRoute($title, $source, $source_id, $project_id); | 128 | $route = self::generateRoute($title, $source, $source_id, $project_id); |
| 129 | if(!$route){ | 129 | if(!$route){ |
| 130 | - throw new \Exception('路由生成失败'); | 130 | + return time().$project_id; |
| 131 | } | 131 | } |
| 132 | try { | 132 | try { |
| 133 | $route_map = self::where(['project_id' => $project_id, 'source' => $source, 'source_id'=>$source_id])->first(); | 133 | $route_map = self::where(['project_id' => $project_id, 'source' => $source, 'source_id'=>$source_id])->first(); |
| @@ -2,6 +2,7 @@ | @@ -2,6 +2,7 @@ | ||
| 2 | 2 | ||
| 3 | namespace App\Models\WebSetting; | 3 | namespace App\Models\WebSetting; |
| 4 | 4 | ||
| 5 | +use App\Helper\Arr; | ||
| 5 | use App\Models\Base; | 6 | use App\Models\Base; |
| 6 | use Illuminate\Support\Facades\Redis; | 7 | use Illuminate\Support\Facades\Redis; |
| 7 | 8 | ||
| @@ -35,4 +36,18 @@ class WebSetting extends Base | @@ -35,4 +36,18 @@ class WebSetting extends Base | ||
| 35 | } | 36 | } |
| 36 | return json_decode(Redis::get("project_".$project->id."_web_setting")); | 37 | return json_decode(Redis::get("project_".$project->id."_web_setting")); |
| 37 | } | 38 | } |
| 39 | + | ||
| 40 | + /** | ||
| 41 | + * @remark :是否开启锚文本 | ||
| 42 | + * @name :getIsCustomAnchorAttribute | ||
| 43 | + * @author :lyh | ||
| 44 | + * @method :post | ||
| 45 | + * @time :2025/3/24 15:07 | ||
| 46 | + */ | ||
| 47 | + public function getIsCustomAnchorAttribute($value){ | ||
| 48 | + if(!empty($value)){ | ||
| 49 | + $value = Arr::s2a($value); | ||
| 50 | + } | ||
| 51 | + return $value; | ||
| 52 | + } | ||
| 38 | } | 53 | } |
| @@ -12,6 +12,7 @@ namespace App\Services; | @@ -12,6 +12,7 @@ namespace App\Services; | ||
| 12 | use App\Helper\Translate; | 12 | use App\Helper\Translate; |
| 13 | use App\Models\Project\ProjectAiSetting; | 13 | use App\Models\Project\ProjectAiSetting; |
| 14 | use Illuminate\Database\Eloquent\Model; | 14 | use Illuminate\Database\Eloquent\Model; |
| 15 | +use Illuminate\Support\Facades\Cache; | ||
| 15 | 16 | ||
| 16 | class AiBlogService | 17 | class AiBlogService |
| 17 | { | 18 | { |
| @@ -36,6 +37,13 @@ class AiBlogService | @@ -36,6 +37,13 @@ class AiBlogService | ||
| 36 | } | 37 | } |
| 37 | } | 38 | } |
| 38 | 39 | ||
| 40 | + /** | ||
| 41 | + * @remark :设置路由 | ||
| 42 | + * @name :setRoute | ||
| 43 | + * @author :lyh | ||
| 44 | + * @method :post | ||
| 45 | + * @time :2025/3/25 9:45 | ||
| 46 | + */ | ||
| 39 | public function setRoute($keyword) | 47 | public function setRoute($keyword) |
| 40 | { | 48 | { |
| 41 | $this->route = generateRoute(Translate::tran($keyword, 'en')); | 49 | $this->route = generateRoute(Translate::tran($keyword, 'en')); |
| @@ -52,11 +60,7 @@ class AiBlogService | @@ -52,11 +60,7 @@ class AiBlogService | ||
| 52 | public function createProject($project_name,$language,$profile,$company){ | 60 | public function createProject($project_name,$language,$profile,$company){ |
| 53 | $request_url = $this->url.'api/project/create'; | 61 | $request_url = $this->url.'api/project/create'; |
| 54 | $param = [ | 62 | $param = [ |
| 55 | - 'mch_id'=>$this->mch_id, | ||
| 56 | - 'title'=>$project_name, | ||
| 57 | - 'language'=>$language, | ||
| 58 | - 'profile'=>$profile, | ||
| 59 | - 'company'=>$company, | 63 | + 'mch_id'=>$this->mch_id, 'title'=>$project_name, 'language'=>$language, 'profile'=>$profile, 'company'=>$company, |
| 60 | ]; | 64 | ]; |
| 61 | $this->sign = $this->generateSign($param,$this->key); | 65 | $this->sign = $this->generateSign($param,$this->key); |
| 62 | $param['sign'] = $this->sign; | 66 | $param['sign'] = $this->sign; |
| @@ -73,13 +77,7 @@ class AiBlogService | @@ -73,13 +77,7 @@ class AiBlogService | ||
| 73 | */ | 77 | */ |
| 74 | public function updatedProject($project_name,$language,$profile,$company){ | 78 | public function updatedProject($project_name,$language,$profile,$company){ |
| 75 | $request_url = $this->url.'api/project/save'; | 79 | $request_url = $this->url.'api/project/save'; |
| 76 | - $param = [ | ||
| 77 | - 'mch_id'=>$this->mch_id, | ||
| 78 | - 'title'=>$project_name, | ||
| 79 | - 'language'=>$language, | ||
| 80 | - 'profile'=>$profile, | ||
| 81 | - 'company'=>$company, | ||
| 82 | - ]; | 80 | + $param = ['mch_id'=>$this->mch_id, 'title'=>$project_name, 'language'=>$language, 'profile'=>$profile, 'company'=>$company]; |
| 83 | $this->sign = $this->generateSign($param,$this->key); | 81 | $this->sign = $this->generateSign($param,$this->key); |
| 84 | $param['sign'] = $this->sign; | 82 | $param['sign'] = $this->sign; |
| 85 | $result = http_post($request_url,json_encode($param,true)); | 83 | $result = http_post($request_url,json_encode($param,true)); |
| @@ -92,15 +90,14 @@ class AiBlogService | @@ -92,15 +90,14 @@ class AiBlogService | ||
| 92 | * @author :lyh | 90 | * @author :lyh |
| 93 | * @method :post | 91 | * @method :post |
| 94 | * @time :2025/2/13 14:39 | 92 | * @time :2025/2/13 14:39 |
| 95 | - * @param :type=(1作者2文章) keyword=关键词 subtype=blog url=回调url | 93 | + * @param :type=(1作者2文章) keyword=关键词 subtype=blog url=回调url , $title = '' |
| 96 | */ | 94 | */ |
| 97 | - public function createTask($keyword,$type = 2,$subtype = 'Blog',$anchor = []){ | 95 | + public function createTask($keyword,$type = 2,$subtype = 'Blog',$anchor = [],$title = ''){ |
| 98 | $request_url = $this->url.'api/task/create'; | 96 | $request_url = $this->url.'api/task/create'; |
| 99 | - $param = [ | ||
| 100 | - 'keyword'=>$keyword, | ||
| 101 | - 'type'=>$type, | ||
| 102 | - 'subtype'=>$subtype, | ||
| 103 | - ]; | 97 | + $param = ['keyword'=>$keyword, 'type'=>$type, 'subtype'=>$subtype]; |
| 98 | + if(!empty($title)){ | ||
| 99 | + $param['title'] = $title; | ||
| 100 | + } | ||
| 104 | $param['anchor'] = $anchor; | 101 | $param['anchor'] = $anchor; |
| 105 | $param['url'] = $this->route; | 102 | $param['url'] = $this->route; |
| 106 | $param['mch_id'] = $this->mch_id; | 103 | $param['mch_id'] = $this->mch_id; |
| @@ -120,9 +117,7 @@ class AiBlogService | @@ -120,9 +117,7 @@ class AiBlogService | ||
| 120 | */ | 117 | */ |
| 121 | public function createAuthor(){ | 118 | public function createAuthor(){ |
| 122 | $request_url = $this->url.'api/author/create'; | 119 | $request_url = $this->url.'api/author/create'; |
| 123 | - $param = [ | ||
| 124 | - 'mch_id'=>$this->mch_id, | ||
| 125 | - ]; | 120 | + $param = ['mch_id'=>$this->mch_id]; |
| 126 | $this->sign = $this->generateSign($param,$this->key); | 121 | $this->sign = $this->generateSign($param,$this->key); |
| 127 | $param['sign'] = $this->sign; | 122 | $param['sign'] = $this->sign; |
| 128 | $result = http_post($request_url,json_encode($param,true)); | 123 | $result = http_post($request_url,json_encode($param,true)); |
app/Services/GoogleKeywordInsightService.php
0 → 100644
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * @remark : | ||
| 4 | + * @name :GoogleKeywordInsightService.php | ||
| 5 | + * @author :lyh | ||
| 6 | + * @method :post | ||
| 7 | + * @time :2025/3/25 11:36 | ||
| 8 | + */ | ||
| 9 | + | ||
| 10 | +namespace App\Services; | ||
| 11 | + | ||
| 12 | +/** | ||
| 13 | + * @remark :google关键字扩展 | ||
| 14 | + * @name :GoogleKeywordInsightService | ||
| 15 | + * @author :lyh | ||
| 16 | + * @method :post | ||
| 17 | + * @time :2025/3/25 11:38 | ||
| 18 | + */ | ||
| 19 | +class GoogleKeywordInsightService | ||
| 20 | +{ | ||
| 21 | + public $url = ""; | ||
| 22 | + | ||
| 23 | + /** | ||
| 24 | + * @remark :请求数据 | ||
| 25 | + * @name :requestUrl | ||
| 26 | + * @author :lyh | ||
| 27 | + * @method :post | ||
| 28 | + * @time :2025/3/25 11:36 | ||
| 29 | + */ | ||
| 30 | + public function requestUrl($keyword){ | ||
| 31 | + $this->url = 'https://google-keyword-insight1.p.rapidapi.com/globalkey'; | ||
| 32 | + $url = $this->url.'/?keyword='.$keyword.'&lang=en'; | ||
| 33 | + $curl = curl_init(); | ||
| 34 | + curl_setopt_array($curl, [ | ||
| 35 | + CURLOPT_URL => $url, | ||
| 36 | + CURLOPT_RETURNTRANSFER => true, | ||
| 37 | + CURLOPT_ENCODING => "", | ||
| 38 | + CURLOPT_MAXREDIRS => 10, | ||
| 39 | + CURLOPT_TIMEOUT => 30, | ||
| 40 | + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, | ||
| 41 | + CURLOPT_CUSTOMREQUEST => "GET", | ||
| 42 | + CURLOPT_HTTPHEADER => [ | ||
| 43 | + "x-rapidapi-host: google-keyword-insight1.p.rapidapi.com", | ||
| 44 | + "x-rapidapi-key: d246239565mshc29088b58ff484dp17c0bdjsn2d28d03622c7" | ||
| 45 | + ], | ||
| 46 | + ]); | ||
| 47 | + $response = curl_exec($curl); | ||
| 48 | + $err = curl_error($curl); | ||
| 49 | + curl_close($curl); | ||
| 50 | + if ($err) { | ||
| 51 | + return "cURL Error #:" . $err; | ||
| 52 | + } else { | ||
| 53 | + return json_decode($response,true); | ||
| 54 | + } | ||
| 55 | + } | ||
| 56 | +} |
-
请 注册 或 登录 后发表评论