作者 刘锟

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

... ... @@ -7,21 +7,18 @@
* @time :2023/11/20 15:07
*/
namespace App\Console\Commands\Test;
namespace App\Console\Commands\LyhTest;
use App\Helper\Arr;
use App\Helper\Translate;
use App\Models\Blog\Blog;
use App\Models\CustomModule\CustomModuleCategory;
use App\Models\CustomModule\CustomModuleContent;
use App\Models\Product\CategoryRelated;
use App\Models\Product\Keyword;
use App\Models\Product\Product;
use App\Models\Project\ProcessRecords;
use App\Models\Project\Project;
use App\Models\RouteMap\RouteMap;
use App\Models\Template\BTemplate;
use App\Models\Template\Setting;
use App\Models\WebSetting\WebSetting;
use App\Services\ProjectServer;
use App\Utils\HttpUtils;
use GuzzleHttp\Exception\GuzzleException;
... ... @@ -61,46 +58,37 @@ class UpdateRoute extends Command
* @time :2023/11/20 15:13
*/
public function handle(){
$data = $this->ceshi();
echo date('Y-m-d H:i:s') . 'end'.json_encode($data) . PHP_EOL;
}
/**
* @remark :导入数据
* @name :importCustomModule
* @author :lyh
* @method :post
* @time :2025/2/24 14:44
*/
public function importCustomModule(){
}
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);
$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;
ProjectServer::useProject($v['id']);
$webSettingModel = new WebSetting();
$settingInfo = $webSettingModel->read(['project_id'=>$v['id']]);
if($settingInfo === false){
echo date('Y-m-d H:i:s') . '当前项目的设置数据不存在:'.$v['id'] . PHP_EOL;
continue;
}
if($settingInfo !== false){
if(empty($settingInfo['anchor_setting'])){
$settingInfo['anchor_setting'] = '["3","4","5"]';
}
} catch (\Exception | GuzzleException $e) {
errorLog('复制站点项目获取失败', [], $e);
return false;
if(empty($settingInfo['anchor_page_num'])){
$settingInfo['anchor_page_num'] = 1;
}
$data = [
'anchor_setting'=>$settingInfo['anchor_setting'],
'anchor_is_enable'=>1,
'anchor_page_num'=>$settingInfo['anchor_page_num'],
'anchor_keyword_is_enable'=>1
];
$webSettingModel->edit($data,['project_id'=>$v['id']]);
}
DB::disconnect('custom_mysql');
}
if ($api_no !== null) {
$data = collect($data)->where('apino', $api_no)->first();
return $data ?: [];
}
return $data;
echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
}
/**
* @remark :更新产品
* @name :updateProduct
... ...
... ... @@ -97,11 +97,11 @@ class UpdateSeoTdk extends Command
'ai_blog_meta_keywords' => 'seo_keyword',
'ai_blog_meta_description' => 'seo_description',
],
'gl_ai_blog_list' => [
'ai_blog_cat_title' => 'seo_title',
'ai_blog_cat_meta_keywords' => 'seo_keyword',
'ai_blog_cat_meta_description' => 'seo_description',
],
// 'gl_ai_blog_list' => [
// 'ai_blog_cat_title' => 'seo_title',
// 'ai_blog_cat_meta_keywords' => 'seo_keyword',
// 'ai_blog_cat_meta_description' => 'seo_description',
// ],
'gl_ai_blog_author' => [
'ai_blog_author_title' => 'seo_title',
'ai_blog_author_meta_keywords' => 'seo_keyword',
... ...
... ... @@ -9,9 +9,69 @@
namespace App\Http\Controllers\Bside\Ai;
use App\Enums\Common\Code;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Bside\Ai\AiVideoLogic;
use App\Models\Ai\AiVideo;
class AiVideoController extends BaseController
{
/**
* @remark :获取aiVideo列表
* @name :lists
* @author :lyh
* @method :post
* @time :2025/3/5 14:12
*/
public function lists(AiVideo $aiVideo){
$lists = $aiVideo->lists($this->map,$this->page,$this->row,'id',['id','keyword','new_title','route','image','task_id','status','created_at','updated_at']);
if(!empty($lists) && !empty($lists['list'])){
foreach ($lists['list'] as $k => $v){
$v['image'] = getImageUrl($v['image']);
if(!empty($v['route'])){
$v['route'] = $this->user['test_domain'] . 'video/' . $v['route'];
}
$lists['list'][$k] = $v;
}
}
$this->response('success',Code::SUCCESS,$lists);
}
/**
* @remark :获取详情
* @name :getInfo
* @author :lyh
* @method :post
* @time :2025/3/5 14:22
*/
public function getInfo(AiVideo $aiVideo){
$this->request->validate([
'id'=>['required'],
],[
'id.required' => '主键不能为空',
]);
$info = $aiVideo->read(['id'=>$this->param['id']]);
$info['image'] = getImageUrl($info['image']);
$this->response('success',Code::SUCCESS,$info);
}
/**
* @remark :发布任务
* @name :sendTask
* @author :lyh
* @method :post
* @time :2025/3/5 14:29
*/
public function sendTask(AiVideoLogic $aiVideoLogic){
$this->request->validate([
'keyword'=>['required'],
'type'=>['required'],
],[
'keyword.required' => '关键字不能为空',
'type.required' => '场景不能为空',
]);
//获取当前项目的ai_blog设置
$result = $aiVideoLogic->sendTask();
$this->response('success',Code::SUCCESS,$result);
}
}
... ...
... ... @@ -50,7 +50,7 @@ class ProductController extends BaseController
{
$filed = ['id', 'project_id', 'title', 'sort' ,'thumb' ,'product_type' , 'route' ,
'category_id', 'keyword_id', 'status', 'created_uid', 'is_upgrade' ,'created_at', 'updated_at','six_read'];
$this->order = $this->order ?? 'sort';
$this->order = $this->param['order'] ?? 'sort';
$query = $product->orderBy($this->order ,$this->order_type)->orderBy('id','desc');
$query = $this->searchParam($query);
$lists = $query->select($filed)->paginate($this->row, ['*'], 'page', $this->page);
... ...
<?php
namespace App\Http\Logic\Bside\Ai;
use App\Helper\Translate;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\Ai\AiBlogAuthor;
use App\Models\Ai\AiVideo;
use App\Models\Project\AiBlogTask;
use App\Models\Project\ProjectAiSetting;
use App\Models\RouteMap\RouteMap;
use App\Services\AiBlogService;
/**
* @remark :视频模块
* @name :AiVideoLogic
* @author :lyh
* @method :post
* @time :2025/3/5 14:11
*/
class AiVideoLogic extends BaseLogic
{
public function __construct()
{
parent::__construct();
$this->param = $this->requestAll;
$this->model = new AiVideo();
}
/**
* @remark :获取配置信息
* @name :getProjectAiSetting
* @author :lyh
* @method :post
* @time :2025/2/21 14:51
*/
public function getProjectAiSetting(){
$projectAiSettingModel = new ProjectAiSetting();
$aiSettingInfo = $projectAiSettingModel->read(['project_id'=>$this->user['project_id']]);
if($aiSettingInfo === false){
$this->fail('请先联系管理员开启Ai配置');
}
return $aiSettingInfo;
}
/**
* @remark :ai发布博客
* @name :blogSave
* @author :lyh
* @method :post
* @time :2023/7/5 14:46
*/
public function blogSave(){
try {
if(!empty($this->param['image'])){
$this->param['image'] = str_replace_url($this->param['image']);
}
$this->param['route'] = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_AI_BLOG, $this->param['id'], $this->user['project_id']);
$this->model->edit($this->param,['id'=>$this->param['id']]);
$aiSettingInfo = $this->getProjectAiSetting();
$aiBlogService = new AiBlogService();
$aiBlogService->mch_id = $aiSettingInfo['mch_id'];
$aiBlogService->key = $aiSettingInfo['key'];
$aiBlogService->updateDetail(['title'=>$this->param['new_title'],'thumb'=>$this->param['image'],'route'=>$this->param['route'],'author_id'=>$this->param['author_id']]);
}catch (\Exception $e){
$this->fail('保存失败,请联系管理员');
}
return $this->success();
}
/**
* @remark :编辑作者
* @name :saveAuthor
* @author :lyh
* @method :post
* @time :2025/2/21 14:46
*/
public function saveBlogAuthor(){
try {
$aiAuthorModel = new AiBlogAuthor();
if(!empty($this->param['image'])){
$this->param['image'] = str_replace_url($this->param['image']);
}
$this->param['route'] = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_AI_BLOG_AUTHOR, $this->param['id'], $this->user['project_id']);
$aiAuthorModel->edit($this->param,['id'=>$this->param['id']]);
$aiBlogService = new AiBlogService();
$aiBlogService->updateAuthorInfo(['author_id'=>$this->param['author_id'],'title'=>$this->param['title'],'picture'=>$this->param['image'],'description'=>$this->param['description']]);
}catch (\Exception $e){
$this->fail('保存失败,请联系管理员');
}
return $this->success();
}
/**
* @remark :发布任务
* @name :sendTask
* @author :lyh
* @method :post
* @time :2025/2/14 10:28
* @detail :type=2/生成文章 type=3/更新列表页记录
* @detail :status=1/待执行
*/
public function sendTask(){
$aiSettingInfo = $this->getProjectAiSetting();
$aiBlogService = new AiBlogService();
$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'],$this->param['type'],'video');
if($result['status'] == 200){
$aiBlogTaskModel = new AiBlogTask();
$aiBlogTaskModel->addReturnId(['project_id'=>$this->user['project_id'],'type'=>3,'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']]);
}
return $this->success();
}
/**
* @remark :删除
* @name :blogDelete
* @author :lyh
* @method :post
* @time :2025/2/20 18:21
*/
public function blogDelete(){
try {
$aiSettingInfo = $this->getProjectAiSetting();
$aiBlogService = new AiBlogService();
foreach ($this->param['ids'] as $id) {
$info = $this->model->read(['id'=>$id],['task_id']);
$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]);
}
shell_exec('php artisan save_ai_blog_list '.$this->user['project_id'].' > /dev/null 2>&1 &');
}catch (\Exception $e){
$this->fail('删除失败');
}
return $this->success();
}
}
... ...
... ... @@ -64,7 +64,7 @@ class WebSettingTextLogic extends BaseLogic
$this->param['anchor_keyword_is_enable'] = 0;
}
$data = [
'anchor_setting'=>$this->param['anchor_setting'],
'anchor_setting'=>$this->param['anchor_setting'] ?? [],
'anchor_is_enable'=>$this->param['anchor_is_enable'],
'anchor_num'=>$this->param['anchor_num'] ?? 0,
'anchor_page_num'=>$this->param['anchor_page_num'] ?? 0,
... ...
... ... @@ -37,7 +37,7 @@ class UserLoginLogic
*/
public function login(){
//先验证手机号是否在项目中存在
$info = $this->model->list(['mobile'=>$this->param['mobile'],'status'=>$this->model::STATUS_ZERO],['id','is_password']);
$info = $this->model->read(['mobile'=>$this->param['mobile'],'status'=>$this->model::STATUS_ZERO],['id','is_password','project_id']);
if($info === false){
$this->fail('当前用户不存在或者被禁用',Code::USER_REGISTER_ERROE);
}
... ...
<?php
/**
* @remark :
* @name :AiVideo.php
* @author :lyh
* @method :post
* @time :2025/3/5 14:03
*/
namespace App\Models\Ai;
use App\Models\Base;
/**
* @remark :ai视频
* @name :AiVideo
* @author :lyh
* @method :post
* @time :2025/3/5 14:04
*/
class AiVideo extends Base
{
protected $table = 'gl_ai_video';
}
... ...