作者 刘锟

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

... ... @@ -67,6 +67,10 @@ class AiBlogAuthorTask extends Command
sleep(10);
continue;
}
if(empty($result['data'])){
sleep(20);
continue;
}
//保存当前项目ai_blog数据
ProjectServer::useProject($info['project_id']);
$this->saveAiBlogAuthor($result['data'] ?? [],$info['project_id']);
... ... @@ -109,16 +113,19 @@ class AiBlogAuthorTask extends Command
return true;
}
$aiBlogAuthorModel = new AiBlogAuthor();
foreach ($data as $v){
$param = [
'author_id'=>$v['id'],
'title'=>$v['title'],
'image'=>str_replace_url($v['picture']),
'description'=>$v['description'],
];
$id = $aiBlogAuthorModel->addReturnId($param);
$route = RouteMap::setRoute($v['title'], RouteMap::SOURCE_AI_BLOG_AUTHOR, $id, $project_id);
$aiBlogAuthorModel->edit(['route'=>$route],['id'=>$id]);
$info = $aiBlogAuthorModel->count(['project_id'=>$project_id]);
if($info === false){
foreach ($data as $v){
$param = [
'author_id'=>$v['id'],
'title'=>$v['title'],
'image'=>str_replace_url($v['picture']),
'description'=>$v['description'],
];
$id = $aiBlogAuthorModel->addReturnId($param);
$route = RouteMap::setRoute($v['route'] ?? $v['title'], RouteMap::SOURCE_AI_BLOG_AUTHOR, $id, $project_id);
$aiBlogAuthorModel->edit(['route'=>$route],['id'=>$id]);
}
}
return true;
}
... ...
... ... @@ -77,6 +77,8 @@ class AiBlogListTask extends Command
ProjectServer::useProject($v['project_id']);
$aiBlogListModel = new AiBlogList();
if(!empty($saveData)){
//写一条路由信息
RouteMap::setRoute('top-blog',RouteMap::SOURCE_AI_BLOG_LIST,0,$v['project_id']);
$aiBlogListModel->truncate();
$aiBlogListModel->insertAll($saveData);
}
... ...
... ... @@ -11,6 +11,7 @@ use App\Helper\Common;
use App\Helper\Gpt;
use App\Helper\Translate;
use App\Models\Ai\AiCommand;
use App\Models\Inquiry\ReInquiryConfig;
use App\Models\Inquiry\ReInquiryDetail;
use App\Models\Inquiry\ReInquiryDetailLog;
use App\Models\Inquiry\ReInquiryForm;
... ... @@ -353,6 +354,19 @@ class RelayInquiry extends Command
{
//通用过滤规则
$config = InquiryFilterConfig::getCacheInfoByProjectId(Project::DEMO_PROJECT_ID);
//FB询盘的全局过滤规则
$fb_config = ReInquiryConfig::getDefaultConfigCache(ReInquiryConfig::TYPE_FILTER_WORDS);
$fb_config['filter_contents'] = array_filter(explode("\r\n", $fb_config['filter_contents']?:''));
$fb_config['filter_emails'] = array_filter(explode("\r\n", $fb_config['filter_emails']?:''));
$fb_config['filter_mobiles'] = array_filter(explode("\r\n", $fb_config['filter_mobiles']?:''));
$fb_config['filter_names'] = array_filter(explode("\r\n", $fb_config['filter_names']?:''));
$config['filter_contents'] = array_unique(array_merge($fb_config['filter_contents'],$config['filter_contents']));
$config['filter_emails'] = array_unique(array_merge($fb_config['filter_emails'],$config['filter_emails']));
$config['filter_mobiles'] = array_unique(array_merge($fb_config['filter_mobiles'],$config['filter_mobiles']));
$config['filter_names'] = array_unique(array_merge($fb_config['filter_names'],$config['filter_names']));
//过滤内容
if(!empty($data['message']) && !empty($config['filter_contents'])) {
foreach ($config['filter_contents'] as $filter_content) {
... ...
... ... @@ -7,17 +7,13 @@
* @time :2024/9/26 14:19
*/
namespace App\Console\Commands\Project;
namespace App\Console\Commands\LyhTest;
use App\Helper\Common;
use App\Models\Domain\DomainInfo;
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\Models\Visit\Visit;
use App\Models\Visit\VisitItem;
use App\Services\ProjectServer;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
... ... @@ -41,7 +37,7 @@ class DownloadProject extends Command
protected $description = '导出项目数据';
public function handle(){
ProjectServer::useProject(1225);
ProjectServer::useProject(1646);
echo date('Y-m-d H:i:s') . 'start' . PHP_EOL;
$data = $this->downloadProduct();
DB::disconnect('custom_mysql');
... ... @@ -52,23 +48,23 @@ class DownloadProject extends Command
public function downloadProduct()
{
$product = new Product();
$filed = ['id', 'project_id', 'title' ,'thumb' , 'route' ,'intro','content',
'category_id', 'status','seo_mate'];
// $filed = ['id', 'project_id', 'title' ,'thumb' , 'route' ,'intro','content',
// 'category_id', 'status','seo_mate'];
$filed = ['id','title'];
$this->order = 'sort';
$lists = $product->list(['status'=>1],'id',$filed);
if(!empty($lists)){
$cate_data = $this->getCategoryList();//分类
// $cate_data = $this->getCategoryList();//分类
foreach ($lists as $k => $v){
echo date('Y-m-d H:i:s') . '产品id:'.$v['id'] . PHP_EOL;
$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'] = '';
}
$v['seo_mate'] = json_encode($v['seo_mate']);
// $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;
}
}
... ... @@ -149,23 +145,27 @@ class DownloadProject extends Command
$sheet = $spreadsheet->getActiveSheet();
// 添加表头
$sheet->setCellValue('A1', '产品名称');
$sheet->setCellValue('B1', '产品短描述');
$sheet->setCellValue('C1', '产品内容');
$sheet->setCellValue('D1', '产品路由');
$sheet->setCellValue('E1', '产品分类');
$sheet->setCellValue('F1', '产品状态');
$sheet->setCellValue('G1', '产品主图');
$sheet->setCellValue('H1', '产品TDK');
// $sheet->setCellValue('B1', '产品短描述');
// $sheet->setCellValue('C1', '产品内容');
// $sheet->setCellValue('D1', '产品路由');
// $sheet->setCellValue('E1', '产品分类');
// $sheet->setCellValue('F1', '产品状态');
// $sheet->setCellValue('G1', '产品主图');
// $sheet->setCellValue('H1', '产品seo_title');
// $sheet->setCellValue('I1', '产品seo_keyword');
// $sheet->setCellValue('J1', '产品seo_title');
$rowCount = 2;
foreach ($data as $v) {
$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']);
$sheet->setCellValue('H' . $rowCount, $v['seo_mate']);
// $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']);
// $sheet->setCellValue('H' . $rowCount, $v['seo_mate']['title']);
// $sheet->setCellValue('I' . $rowCount, $v['seo_mate']['keyword']);
// $sheet->setCellValue('J' . $rowCount, $v['seo_mate']['description']);
$rowCount++;
}
// 创建一个新的 Excel Writer 对象
... ...
<?php
/**
* @remark :
* @name :LyhImportTest.php
* @author :lyh
* @method :post
* @time :2025/2/24 14:52
*/
namespace App\Console\Commands\LyhTest;
use App\Models\CustomModule\CustomModuleCategory;
use App\Models\CustomModule\CustomModuleContent;
use App\Models\CustomModule\CustomModuleExtentContent;
use App\Models\RouteMap\RouteMap;
use App\Services\ProjectServer;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
class LyhImportTest extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'lyh_import_test';
/**
* The console command description.
*
* @var string
*/
protected $description = '导入数据';
public $data = 'GBP201,Rectifier/Bridge Rectifier,GBP,-,100,2,1.10 ,1,60,5,250,-55~+150,-,Active,';
/**
* @remark :统一更新路由
* @name :handle
* @author :lyh
* @method :post
* @time :2023/11/20 15:13
*/
public function handle(){
ProjectServer::useProject(2837);
echo date('Y-m-d H:i:s') . 'start' . PHP_EOL;
$this->importCustomModule($this->data);
DB::disconnect('custom_mysql');
echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
}
/**
* @remark :导入扩展模块数据
* @name :importCustomModule
* @author :lyh
* @method :post
* @time :2025/2/24 14:54
*/
public function importCustomModule($text,$project_id = 2837){
$customContentModel = new CustomModuleContent();
$customCategoryModel = new CustomModuleCategory();;
$customExtendContentTModel = new CustomModuleExtentContent();
$data = explode("\n", $text);
foreach ($data as $k => $item){
$item = trim($item,',');
//按照逗号转为数组
$array = explode(",", $item);
//添加分类
if(empty($array[0])){
continue;
}
//添加内容
$contentId = $customContentModel->addReturnId(['name'=>$array[0],'module_id'=>2,'project_id'=>$project_id]);
echo date('Y-m-d H:i:s') . '当前扩展数据id:'. $contentId . PHP_EOL;
//注册路由
$route = RouteMap::setRoute($array[0], RouteMap::SOURCE_MODULE,
$contentId, $project_id);
$customContentModel->edit(['route'=>$route],['id'=>$contentId]);
if(!empty($array[1])){
$categoryId = ',';
$cateArr = explode('/',$array[1]);
foreach ($cateArr as $cateV){
$cateInfo = $customCategoryModel->read(['name'=>$cateV,'module_id'=>2,'project_id'=>$project_id]);
if($cateInfo !== false){
$categoryId .= $cateInfo['id'].',';
}
}
$customContentModel->edit(['category_id'=>$categoryId],['id'=>$contentId]);
}
$saveData = [
['key'=>'pd_extended_field_1', 'type'=>1, 'values'=>$array[2], 'content_id'=>$contentId, 'project_id'=>$project_id, 'module_id'=>2, 'created_at'=>date('Y-m-d H:i:s'), 'updated_at'=>date('Y-m-d H:i:s')],
['key'=>'pd_extended_field_2', 'type'=>1, 'values'=>$array[4], 'content_id'=>$contentId, 'project_id'=>$project_id, 'module_id'=>2, 'created_at'=>date('Y-m-d H:i:s'), 'updated_at'=>date('Y-m-d H:i:s')],
['key'=>'pd_extended_field_3', 'type'=>1, 'values'=>$array[5], 'content_id'=>$contentId, 'project_id'=>$project_id, 'module_id'=>2, 'created_at'=>date('Y-m-d H:i:s'), 'updated_at'=>date('Y-m-d H:i:s')],
['key'=>'pd_extended_field_4', 'type'=>1, 'values'=>$array[3], 'content_id'=>$contentId, 'project_id'=>$project_id, 'module_id'=>2, 'created_at'=>date('Y-m-d H:i:s'), 'updated_at'=>date('Y-m-d H:i:s')],
['key'=>'pd_extended_field_5', 'type'=>1, 'values'=>$array[8], 'content_id'=>$contentId, 'project_id'=>$project_id, 'module_id'=>2, 'created_at'=>date('Y-m-d H:i:s'), 'updated_at'=>date('Y-m-d H:i:s')],
['key'=>'pd_extended_field_6', 'type'=>1, 'values'=>$array[6], 'content_id'=>$contentId, 'project_id'=>$project_id, 'module_id'=>2, 'created_at'=>date('Y-m-d H:i:s'), 'updated_at'=>date('Y-m-d H:i:s')],
['key'=>'pd_extended_field_7', 'type'=>1, 'values'=>$array[9], 'content_id'=>$contentId, 'project_id'=>$project_id, 'module_id'=>2, 'created_at'=>date('Y-m-d H:i:s'), 'updated_at'=>date('Y-m-d H:i:s')],
['key'=>'pd_extended_field_8', 'type'=>1, 'values'=>$array[10], 'content_id'=>$contentId, 'project_id'=>$project_id, 'module_id'=>2, 'created_at'=>date('Y-m-d H:i:s'), 'updated_at'=>date('Y-m-d H:i:s')],
['key'=>'pd_extended_field_9', 'type'=>1, 'values'=>$array[11], 'content_id'=>$contentId, 'project_id'=>$project_id, 'module_id'=>2, 'created_at'=>date('Y-m-d H:i:s'), 'updated_at'=>date('Y-m-d H:i:s')],
['key'=>'pd_extended_field_10', 'type'=>1, 'values'=>$array[12], 'content_id'=>$contentId, 'project_id'=>$project_id, 'module_id'=>2, 'created_at'=>date('Y-m-d H:i:s'), 'updated_at'=>date('Y-m-d H:i:s')],
['key'=>'pd_extended_field_11', 'type'=>1, 'values'=>$array[13], 'content_id'=>$contentId, 'project_id'=>$project_id, 'module_id'=>2, 'created_at'=>date('Y-m-d H:i:s'), 'updated_at'=>date('Y-m-d H:i:s')],
['key'=>'pd_extended_field_12', 'type'=>1, 'values'=>$array[14] ?? '', 'content_id'=>$contentId, 'project_id'=>$project_id, 'module_id'=>2, 'created_at'=>date('Y-m-d H:i:s'), 'updated_at'=>date('Y-m-d H:i:s')],
['key'=>'pd_extended_field_13', 'type'=>1, 'values'=>$array[7], 'content_id'=>$contentId, 'project_id'=>$project_id, 'module_id'=>2, 'created_at'=>date('Y-m-d H:i:s'), 'updated_at'=>date('Y-m-d H:i:s')],
];
$customExtendContentTModel->insert($saveData);
}
}
}
... ...
... ... @@ -16,13 +16,16 @@ use App\Models\HomeCount\Count;
use App\Models\News\News;
use App\Models\Product\Product;
use App\Models\Project\Project;
use App\Models\ProjectAssociation\ProjectAssociation;
use App\Models\RankData\ExternalLinks;
use App\Models\RankData\RankData;
use App\Models\RankData\RankWeek;
use App\Models\Workchat\MessagePush;
use App\Services\ProjectServer;
use Carbon\Carbon;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
class WeekProject extends Command
{
... ... @@ -97,8 +100,10 @@ class WeekProject extends Command
$data['keyword_ten_num'] = $rankInfo['first_ten_pages_num'] ?? 0;
$productModel = new Product();
$data['product_num'] = $productModel->counts(['status'=>1]) ?? 0;
$data['week_product_num'] = $productModel->counts(['status'=>1,'created_at'=>['between',[$startOfLastWeek,$endOfLastWeek]]]) ?? 0;
$newsModel = new News();
$data['news_num'] = $newsModel->counts(['status'=>1]) ?? 0;
$data['week_news_num'] = $newsModel->counts(['status'=>1,'created_at'=>['between',[$startOfLastWeek,$endOfLastWeek]]]) ?? 0;
$blogModel = new Blog();
$data['blog_num'] = $blogModel->counts(['status'=>1]) ?? 0;
$notifyModel = new Notify();
... ... @@ -117,4 +122,81 @@ class WeekProject extends Command
$v6WeeklyReportModel->add($data);
return true;
}
/**
* @remark :推送消息
* @name :workChatMessage
* @author :lyh
* @method :post
* @time :2025/2/26 10:15
*/
public function workChatMessage($data,$project_id){
//项目是否有绑定群
$friend_id = ProjectAssociation::where('project_id', $project_id)
->where('status', ProjectAssociation::STATUS_NORMAL)
->where('binding_app', ProjectAssociation::ENTERPRISE_WECHAT)
->value('friend_id');
if(!$friend_id){
echo date('Y-m-d H:i:s') . '没有绑定企微群:'.$project_id . PHP_EOL;
return false;
}
$content1 = '';
if(!empty($data['inquiry_total'])){
$content1 .= '项目共计已收到询盘 '.$data['inquiry_total'].'条,';
if(!empty($data['week_inquiry_total'])){
$content1 .= '本周新收 '.$data['week_inquiry_total'].' 封询盘。';
}
if(!empty($data['inquiry_country'])){
$data['inquiry_country'] = json_decode($data['inquiry_country']);
arsort($data);
$data['inquiry_country'] = array_slice($data, 0, 4, true);
$country = '';
foreach ($data['inquiry_country'] as $k => $v){
$country .= $k.'、';
};
trim($country,'、');
$content1 = '询盘主要来源于'.$country.'等国家地区';
}
$content1 .= '如有高质量客户,请您密切关注与跟进;';
}
$content2 = '';
if(!empty($data['google_indexed_num']) || !empty($data['google_links_num']) || !empty($data['keyword_home_num']) || !empty($data['keyword_three_num']) || !empty($data['keyword_five_num']) || !empty($data['keyword_ten_num']) || !empty($data['daily_average_num'])){
$content2 .= '项目截止目前';
if(!empty($data['google_indexed_num'])){
$content2 .= '谷歌收录量:'.$data['google_indexed_num'].'条,';
}
if(!empty($data['google_links_num'])){
$content2 .= '外链量:'.$data['google_links_num'].'条,';
}
if(!empty($data['keyword_home_num'])){
$content2 .= '谷歌搜索排名首页关键词数量为:'.$data['keyword_home_num'].'个,';
}
if(!empty($data['keyword_three_num'])){
$content2 .= '前三页关键词数量为:'.$data['keyword_three_num'].'个,';
}
if(!empty($data['keyword_five_num'])){
$content2 .= '前五页关键词数量为:'.$data['keyword_five_num'].'个,';
}
if(!empty($data['keyword_ten_num'])){
$content2 .= '前十页关键词数量为:'.$data['keyword_ten_num'].'个,';
}
if(!empty($data['daily_average_num'])){
$content2 .= '本周日均访客量:'.$data['daily_average_num'].'+。';
}
$content2 .= '全球搜建议用户持续分析、选择、添加企业、产品、服务等相关关键词进行优化和监控,以覆盖更多相关排名和流量;';
}
$content3 = '';
if(!empty($data['product_num']) || !empty($data['news_num']) || !empty($data['week_product_num']) || !empty($data['week_news_num'])){
}
$param = [
'project_id'=>$project_id,
'friend_id'=>$friend_id,
'type'=>MessagePush::TYPE_WEEK,
'content'=>'',
];
//写入一条推送消息 自动消费
$messagePushModel = new MessagePush();
}
}
... ...
... ... @@ -241,8 +241,16 @@ class UpdateSeoTdk extends Command
$notify_master = $notify_keyword = false;
//更新统计
$update = [];
$ai_commands = AiCommand::where('is_batch', 1)->select('key', 'scene', 'ai')->get()->toArray();
//AI指令 是否有定制指令
$ai_commands = AiCommand::where('is_batch', 1)->where('project_id', 0)->select('key', 'scene', 'ai')->get()->toArray();
$project_ai_commands = AiCommand::where('is_batch', 1)->where('project_id', $project_id)->select('key', 'scene', 'ai')->get()->toArray();
$ai_commands = Arr::setValueToKey($ai_commands, 'key');
$project_ai_commands = Arr::setValueToKey($project_ai_commands, 'key');
foreach ($ai_commands as $k => $ai_command){
if(!empty($project_ai_commands[$k])){
$ai_commands[$k] = $project_ai_commands[$k];
}
}
foreach ($this->maps as $table => $map) {
$total_page = DB::connection('custom_mysql')->table($table)->count();
$update[$table] = ['total_page'=>$total_page, 'title'=>0, 'keyword'=>0, 'des'=>0,'keyword_title'=>0,'keyword_content'=>0];
... ... @@ -505,7 +513,7 @@ class UpdateSeoTdk extends Command
$info = $this->getDeployOptimize($project_id);
if (!empty($info['keyword_' . $type])) {
$fix_keyword = explode(",", $info['keyword_' . $type]);
$fix_keyword = array_filter($fix_keyword);
//去掉标题存在的词
if ($topic) {
foreach ($fix_keyword as $k=>$keyword) {
... ...
... ... @@ -67,6 +67,16 @@ class UpdateRoute extends Command
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)
{
... ...
... ... @@ -1097,6 +1097,7 @@ function getPrefixKeyword($project_id, $type, $num)
$info = getDeployOptimize($project_id);
if (!empty($info['keyword_' . $type])) {
$fix_keyword = explode(",", $info['keyword_' . $type]);
$fix_keyword = array_filter($fix_keyword);
//随机取
shuffle($fix_keyword);
if (count($fix_keyword) < $num)
... ...
... ... @@ -98,7 +98,7 @@ class AdsController extends BaseController
$item['cost'] = ReInquiryCost::getCostByAdIds($item['ad_id']);
}
$result['relay_site_total'] = $relay_site_total;
$result['default_ai_param'] = ReInquiryConfig::getDefaultConfigCache();
$result['default_ai_param'] = ReInquiryConfig::getDefaultConfigCache(ReInquiryConfig::TYPE_AI_PARAM);
return $this->response('success', Code::SUCCESS, $result);
}
... ... @@ -388,8 +388,9 @@ class AdsController extends BaseController
* @author zbj
* @date 2025/2/12
*/
public function fbAdsDefaultSet(){
$config = ReInquiryConfig::get();
public function fbAdsDefaultSet(Request $request){
$type = $request->input('type')?: ReInquiryConfig::TYPE_AI_PARAM;
$config = ReInquiryConfig::where('type', $type)->get();
if($this->request->isMethod('get')){
return $this->response('success', Code::SUCCESS, $config);
}
... ... @@ -397,7 +398,7 @@ class AdsController extends BaseController
DB::beginTransaction();
try {
foreach ($config as $item){
if(empty($this->param[$item->key])){
if($type == ReInquiryConfig::TYPE_AI_PARAM && empty($this->param[$item->key])){
throw new \Exception($item->title . '不能为空!');
}
$item->content = $this->param[$item->key];
... ... @@ -418,7 +419,7 @@ class AdsController extends BaseController
* @date 2025/2/12
*/
public function fbAdsSetBatch(){
$config = ReInquiryConfig::find($this->param['id']);
$config = ReInquiryConfig::where('type', ReInquiryConfig::TYPE_AI_PARAM)->where('id', $this->param['id'])->first();
if(!$config){
return $this->response('配置不存在', Code::USER_ERROR, []);
}
... ...
... ... @@ -9,6 +9,7 @@ use App\Http\Requests\Bside\Ai\AiBlogRequest;
use App\Models\Ai\AiBlog;
use App\Models\Ai\AiBlogAuthor;
use App\Models\Ai\AiBlogList;
use App\Models\RouteMap\RouteMap;
use App\Services\AiBlogService;
use App\Services\ProjectServer;
use Illuminate\Support\Facades\DB;
... ... @@ -59,10 +60,13 @@ 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','image','task_id','status','created_at','updated_at']);
$lists = $aiBlog->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'] . 'blog/' . $v['route'];
}
$lists['list'][$k] = $v;
}
}
... ... @@ -99,6 +103,13 @@ class AiBlogController extends BaseController
public function getAiBlogAuthor(AiBlogAuthor $aiBlogAuthor){
$field = ['id','route','author_id','title','image','created_at','updated_at'];
$lists = $aiBlogAuthor->lists($this->map,$this->page,$this->row,'id',$field);
if(!empty($lists) && !empty($lists['list'])){
foreach ($lists['list'] as $k => $v){
$v['image'] = getImageUrl($v['image']);
$v['route'] = $this->user['test_domain'] . 'user/' . $v['route'];
$lists['list'][$k] = $v;
}
}
$this->response('success',Code::SUCCESS,$lists);
}
... ... @@ -143,7 +154,7 @@ class AiBlogController extends BaseController
public function delete(AiBlogLogic $aiBlogLogic)
{
$this->request->validate([
'ids'=>['required', new Ids()]
'ids'=>['required'],
],[
'ids.required' => 'ID不能为空'
]);
... ... @@ -160,6 +171,14 @@ class AiBlogController extends BaseController
*/
public function getAiBlogList(AiBlogList $aiBlogList){
$lists = $aiBlogList->lists($this->map,$this->page,$this->row,'id',['id','route','created_at','updated_at']);
if(!empty($lists) && !empty($lists['list'])){
foreach ($lists['list'] as $k => $v){
if(!empty($v['route'])){
$v['route'] = $this->user['test_domain'] . 'blog/' . $v['route'];
}
$lists['list'][$k] = $v;
}
}
$this->response('success',Code::SUCCESS,$lists);
}
... ...
... ... @@ -37,12 +37,26 @@ class AiCommandLogic extends BaseLogic
*/
public function ai_add(){
$condition = [
'key'=>$this->param['key']
'key'=>$this->param['key'],
'project_id'=>$this->param['project_id']??0,
];
$info = $this->model->read($condition);
if($info !== false){
$this->fail('当前指令已存在');
}
if($condition['project_id']){
$where = [
'key'=>$this->param['key'],
'project_id'=>0,
'is_batch'=>1,
];
$valid_key = $this->model->read($where);
if(!$valid_key){
$this->fail('指令字段不正确');
}
$this->param['is_batch'] = 1;
}
$this->param['operator_id'] = $this->manager['id'];
$this->param['create_id'] = $this->manager['id'];
$rs = $this->model->add($this->param);
... ... @@ -61,12 +75,25 @@ class AiCommandLogic extends BaseLogic
public function ai_edit(){
$condition = [
'id'=>['!=',$this->param['id']],
'key'=>$this->param['key']
'key'=>$this->param['key'],
'project_id'=>$this->param['project_id']??0,
];
$info = $this->model->read($condition);
if($info !== false){
$this->fail('当前编辑的指令key已存在');
}
if($condition['project_id']){
$where = [
'key'=>$this->param['key'],
'project_id'=>0,
'is_batch'=>1,
];
$valid_key = $this->model->read($where);
if(!$valid_key){
$this->fail('指令字段不正确');
}
$this->param['is_batch'] = 1;
}
$rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
if($rs === false){
$this->fail('error');
... ...
... ... @@ -248,7 +248,7 @@ class ProjectLogic extends BaseLogic
public function createAuthor($project_id,$mch_id,$key){
//查看当前项目是否已经创建了作者
$aiBlogTaskModel = new AiBlogTask();
$count = $aiBlogTaskModel->counts();
$count = $aiBlogTaskModel->counts(['project_id'=>$project_id]);
if($count > 0){
return true;
}
... ...
... ... @@ -55,7 +55,7 @@ class AiBlogLogic extends BaseLogic
$aiBlogService = new AiBlogService();
$aiBlogService->mch_id = $aiSettingInfo['mch_id'];
$aiBlogService->key = $aiSettingInfo['key'];
$aiBlogService->updateDetail(['title'=>$this->param['title'],'thumb'=>$this->param['image'],'route'=>$this->param['route'],'author_id'=>$this->param['author_id']]);
$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('保存失败,请联系管理员');
}
... ... @@ -99,7 +99,7 @@ class AiBlogLogic extends BaseLogic
$aiBlogService = new AiBlogService();
$aiBlogService->mch_id = $aiSettingInfo['mch_id'];
$aiBlogService->key = $aiSettingInfo['key'];
$aiBlogService->route = generateRoute(Translate::tran($this->param['route'], 'en'));
$aiBlogService->route = generateRoute(Translate::tran($this->param['keyword'], 'en'));
$result = $aiBlogService->createTask($this->param['keyword'],$this->param['type']);
if($result['status'] == 200){
$aiBlogTaskModel = new AiBlogTask();
... ...
... ... @@ -26,7 +26,11 @@ class AiCommandLogic extends BaseLogic
* @date 2023/11/22
*/
public function getPrompt($is_batch = 0){
$ai_command = $this->model->where('key', $this->param['key'])->first();
//是否有项目指令
$ai_command = $this->model->where('key', $this->param['key'])->where('project_id', $this->project['id'])->first();
if(!$ai_command){
$ai_command = $this->model->where('key', $this->param['key'])->where('project_id', 0)->first();
}
if(!$ai_command){
$this->fail('指令不存在');
}
... ...
... ... @@ -488,6 +488,7 @@ class RankDataLogic extends BaseLogic
$without_project_ids = []; //不用处理排名的项目
$without_extension_project_ids = [658]; //是否达标只统计主词的
$extension_project_ids = [354]; //扩展词也到达标的
$compliance_project_ids = [2163]; //直接达标处理的
$ceaseProjectId = [
47,
354,
... ... @@ -575,6 +576,9 @@ class RankDataLogic extends BaseLogic
if(in_array($project_id, $extension_project_ids)){
$is_compliance = $first_page_extension_num >= $keyword_num;
}
if(in_array($project_id, $compliance_project_ids)){
$is_compliance = 1; //直接达标处理
}
if ($keyword_num && $type == Project::TYPE_TWO && $is_compliance) {
Log::channel('rank_data')->info('项目' . $project_id . ':关键词达标'. $keyword_num .' - ' . $first_page_num . ' - ' . $first_page_without_extension_num);
//项目表更新
... ...
... ... @@ -60,11 +60,15 @@ class WebSettingTextLogic extends BaseLogic
DB::beginTransaction();
try {
//更新描文本设置
if($this->param['anchor_is_enable'] == 0){
$this->param['anchor_keyword_is_enable'] = 0;
}
$data = [
'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
'anchor_page_num'=>$this->param['anchor_page_num'] ?? 0,
'anchor_keyword_is_enable'=>$this->param['anchor_keyword_is_enable'] ?? 0
];
$web_setting->edit($data,['project_id'=>$this->user['project_id']]);
$this->model->del(['project_id'=>$this->user['project_id']]);
... ...
... ... @@ -24,18 +24,14 @@ class AiBlogRequest extends FormRequest
public function rules()
{
return [
'keywords'=>'required',
'new_title'=>'required',
'text'=>'required',
];
}
public function messages()
{
return [
'keywords.required' => '关键字不能为空',
'new_title.required' => '新标题不能为空',
'text.required' => '内容不能为空',
];
}
}
... ...
... ... @@ -15,21 +15,23 @@ use Illuminate\Support\Facades\Cache;
*/
class ReInquiryConfig extends Base
{
const TYPE_AI_PARAM = 'ai_param';
const TYPE_FILTER_WORDS = 'filter_words';
//设置关联表名
protected $table = 'gl_re_inquiry_config';
public static function getDefaultConfigCache(){
public static function getDefaultConfigCache($type){
$cache_key = 'ReInquiryDefaultConfigCache';
$data = Cache::get($cache_key);
if(!$data){
$data = self::pluck('content', 'key');
$data = self::all();
if($data){
Cache::put($cache_key, $data);
}
}
return $data;
return $data->where('type', $type)->pluck('content', 'key');
}
public static function delCache(){
... ...
... ... @@ -92,6 +92,6 @@ class ReInquiryTask extends Base
public function getAiParamAttribute($value)
{
return Arr::s2a($value) ?: ReInquiryConfig::getDefaultConfigCache();
return Arr::s2a($value) ?: ReInquiryConfig::getDefaultConfigCache(ReInquiryConfig::TYPE_AI_PARAM);
}
}
... ...
... ... @@ -35,6 +35,7 @@ class RouteMap extends Base
const SOURCE_MODULE = 'module';
const SOURCE_AI_BLOG = 'ai_blog';
const SOURCE_AI_BLOG_AUTHOR = 'ai_blog_author';//ai博客作者
const SOURCE_AI_BLOG_LIST = 'ai_blog_list';
//自定义模块分类
const SOURCE_MODULE_CATE = 'module_category';
... ...
... ... @@ -25,7 +25,7 @@ class MessagePush extends Base
const STATUS_ERROR = 9;
const TYPE_INQUIRY = 'inquiry';
const TYPE_WEEK = 'week';
//设置关联表名
/**
* @var mixed
... ...