作者 赵彬吉
@@ -128,7 +128,7 @@ class AiBlogAutoPublish extends Command @@ -128,7 +128,7 @@ class AiBlogAutoPublish extends Command
128 public function createTask($keywords, $project_id, $frequency){ 128 public function createTask($keywords, $project_id, $frequency){
129 $keyword = $keywords[array_rand($keywords)]; 129 $keyword = $keywords[array_rand($keywords)];
130 $aiBlogService = new AiBlogService($project_id); 130 $aiBlogService = new AiBlogService($project_id);
131 - $result = $aiBlogService->setRoute($keyword)->createTask($keyword); 131 + $result = $aiBlogService->createTask($keyword);
132 if ($result['status'] == 200) { 132 if ($result['status'] == 200) {
133 $aiBlogTaskModel = new AiBlogTaskModel(); 133 $aiBlogTaskModel = new AiBlogTaskModel();
134 $next_auto_date = date('Y-m-d', strtotime('+' . mt_rand($frequency[0],$frequency[1]) . 'days')); //每3-6天自动发布 134 $next_auto_date = date('Y-m-d', strtotime('+' . mt_rand($frequency[0],$frequency[1]) . 'days')); //每3-6天自动发布
@@ -147,7 +147,7 @@ class AiVideoTask extends Command @@ -147,7 +147,7 @@ class AiVideoTask extends Command
147 if($route != $result['data']['url']){ 147 if($route != $result['data']['url']){
148 $aiVideoService->updateDetail(['url'=>$route,'task_id'=>$item['task_id']]); 148 $aiVideoService->updateDetail(['url'=>$route,'task_id'=>$item['task_id']]);
149 } 149 }
150 - $description = explode(",",$result['data']['content']); 150 + $description = explode(".",$result['data']['content']);
151 $saveData = [ 151 $saveData = [
152 'title'=>$result['data']['title'], 152 'title'=>$result['data']['title'],
153 'image'=>$result['data']['thumb'], 153 'image'=>$result['data']['thumb'],
@@ -10,13 +10,24 @@ @@ -10,13 +10,24 @@
10 namespace App\Console\Commands\LyhTest; 10 namespace App\Console\Commands\LyhTest;
11 11
12 use App\Console\Commands\Domain\DomainInfo; 12 use App\Console\Commands\Domain\DomainInfo;
  13 +use App\Http\Logic\Aside\Project\ProjectLogic;
  14 +use App\Models\Ai\AiBlog;
13 use App\Models\Ai\AiBlogAuthor; 15 use App\Models\Ai\AiBlogAuthor;
14 use App\Models\Com\NoticeLog; 16 use App\Models\Com\NoticeLog;
  17 +use App\Models\Com\V6WeeklyReport;
15 use App\Models\Project\AiBlogTask; 18 use App\Models\Project\AiBlogTask;
16 use App\Models\Project\DeployBuild; 19 use App\Models\Project\DeployBuild;
  20 +use App\Models\Project\DeployOptimize;
17 use App\Models\Project\OnlineCheck; 21 use App\Models\Project\OnlineCheck;
18 use App\Models\Project\Project; 22 use App\Models\Project\Project;
  23 +use App\Models\Project\ProjectAiSetting;
  24 +use App\Models\ProjectAssociation\ProjectAssociation;
  25 +use App\Models\RouteMap\RouteMap;
  26 +use App\Models\Visit\Visit;
  27 +use App\Models\WebSetting\WebLanguage;
19 use App\Models\WebSetting\WebSetting; 28 use App\Models\WebSetting\WebSetting;
  29 +use App\Models\Workchat\MessagePush;
  30 +use App\Services\AiBlogService;
20 use App\Services\ProjectServer; 31 use App\Services\ProjectServer;
21 use Illuminate\Console\Command; 32 use Illuminate\Console\Command;
22 use Illuminate\Support\Facades\Artisan; 33 use Illuminate\Support\Facades\Artisan;
@@ -40,19 +51,44 @@ class lyhDemo extends Command @@ -40,19 +51,44 @@ class lyhDemo extends Command
40 51
41 public function handle(){ 52 public function handle(){
42 $projectModel = new Project(); 53 $projectModel = new Project();
43 - $lists = $projectModel->list(['delete_status' => 0,'extend_type'=>0,'type'=>['in',[1,2,3,4]]], 'id', ['id']); 54 + $lists = $projectModel->list(['delete_status' => 0,'extend_type'=>0,'type'=>['in',[1,2,3,4,6]]], 'id', ['id']);
44 foreach ($lists as $val) { 55 foreach ($lists as $val) {
45 echo date('Y-m-d H:i:s') . '开始--项目的id:'. $val['id'] . PHP_EOL; 56 echo date('Y-m-d H:i:s') . '开始--项目的id:'. $val['id'] . PHP_EOL;
46 ProjectServer::useProject($val['id']); 57 ProjectServer::useProject($val['id']);
47 - try {  
48 - $settingModel = new WebSetting();  
49 - $settingModel->edit(['anchor_num'=>10],['id'=>1,'anchor_num'=>3]);  
50 - }catch (\Exception $e){  
51 - DB::disconnect('custom_mysql'); 58 + $aiBlogModel = new AiBlog();
  59 + $aiLists = $aiBlogModel->list(['status'=>2],'id',['id','seo_description']);
  60 + if(!empty($aiLists)){
  61 + foreach ($aiLists as $item){
  62 + if(!empty($item['seo_description'])){
  63 + //查看当前是否包含句号。
  64 + $result = $this->hasAnyPeriod($item['seo_description']);
  65 + if($result === false){
  66 + $text = $this->trimToLastFullWord($item['seo_description']);
  67 + }else{
  68 + $arr = explode('.',$item['seo_description']);
  69 + $text = $arr[0].'.';
  70 + }
  71 + $aiBlogModel->edit(['seo_description'=>$text],['id'=>$item['id']]);
  72 + }
  73 + }
52 } 74 }
53 DB::disconnect('custom_mysql'); 75 DB::disconnect('custom_mysql');
  76 + echo date('Y-m-d H:i:s') . '结束--项目的id:'. $val['id'] . PHP_EOL;
54 } 77 }
55 return true; 78 return true;
56 } 79 }
57 80
  81 + public function trimToLastFullWord($text) {
  82 + // 去掉结尾非字母数字字符
  83 + $text = rtrim($text);
  84 + // 如果最后一个单词被截断,就删除它
  85 + if (preg_match('/^(.*?\b)\w*$/', $text, $matches)) {
  86 + return $matches[1];
  87 + }
  88 + return trim($text); // fallback
  89 + }
  90 +
  91 + public function hasAnyPeriod($text) {
  92 + return strpos($text, '.') !== false || mb_strpos($text, '。') !== false;
  93 + }
58 } 94 }
@@ -41,22 +41,24 @@ class Temp extends Command @@ -41,22 +41,24 @@ class Temp extends Command
41 41
42 public function handle() 42 public function handle()
43 { 43 {
44 - $this->create_all_amp_notify(); 44 +
45 } 45 }
46 46
47 /** 47 /**
48 - * www.docareco.com批量设置301跳转 48 + * 批量设置301跳转
49 * @author Akun 49 * @author Akun
50 * @date 2025/04/21 16:12 50 * @date 2025/04/21 16:12
51 */ 51 */
52 public function setDomain301() 52 public function setDomain301()
53 { 53 {
54 - $domain_extend_config = DomainInfo::where('domain', 'www.docareco.com')->value('extend_config'); 54 + $domain = 'www.lvtopsun.com';
  55 +
  56 + $domain_extend_config = DomainInfo::where('domain', $domain)->value('extend_config');
55 57
56 $domain_origin_list = $domain_extend_config ? array_column($domain_extend_config, 'origin') : []; 58 $domain_origin_list = $domain_extend_config ? array_column($domain_extend_config, 'origin') : [];
57 59
58 //读取csv文件 60 //读取csv文件
59 - $file = 'C:\Users\Akun\Desktop\有排名网页-还未做301-4.21.csv'; 61 + $file = 'C:\Users\Akun\Desktop\广东绿达新能源有限公司设置301页面.csv';
60 $line_of_text = []; 62 $line_of_text = [];
61 try { 63 try {
62 $file_handle = fopen($file, 'r'); 64 $file_handle = fopen($file, 'r');
@@ -71,8 +73,8 @@ class Temp extends Command @@ -71,8 +73,8 @@ class Temp extends Command
71 if (count($line_of_text) > 1) { 73 if (count($line_of_text) > 1) {
72 foreach ($line_of_text as $k => $v) { 74 foreach ($line_of_text as $k => $v) {
73 if ($k > 0 && $v) { 75 if ($k > 0 && $v) {
74 - $origin = str_replace('https://www.docareco.com', '', $v[0]);  
75 - $target = str_replace('https://www.docareco.com', '', $v[1]); 76 + $origin = str_replace('https://'.$domain, '', $v[0]);
  77 + $target = str_replace('https://'.$domain, '', $v[1]);
76 78
77 if (!in_array($origin, $domain_origin_list)) { 79 if (!in_array($origin, $domain_origin_list)) {
78 $domain_extend_config[] = [ 80 $domain_extend_config[] = [
@@ -84,7 +86,7 @@ class Temp extends Command @@ -84,7 +86,7 @@ class Temp extends Command
84 } 86 }
85 } 87 }
86 88
87 - DomainInfo::where('domain', 'www.docareco.com')->update(['extend_config' => Arr::a2s($domain_extend_config)]); 89 + DomainInfo::where('domain', $domain)->update(['extend_config' => Arr::a2s($domain_extend_config)]);
88 90
89 $this->output('success'); 91 $this->output('success');
90 } 92 }
@@ -159,13 +159,15 @@ class NoticeController extends BaseController @@ -159,13 +159,15 @@ class NoticeController extends BaseController
159 159
160 //新增重定向任务 160 //新增重定向任务
161 $redirect_model = new DomainRedirectTask(); 161 $redirect_model = new DomainRedirectTask();
162 - $task_redirect_info = $redirect_model->read(['origin_domain'=>$origin_domain]); 162 + $task_redirect_info = $redirect_model->read(['origin_domain'=>$origin_domain],['id']);
163 if(!$task_redirect_info){ 163 if(!$task_redirect_info){
164 $redirect_model->add([ 164 $redirect_model->add([
165 'origin_domain'=> $origin_domain, 165 'origin_domain'=> $origin_domain,
166 'other_domain' => json_encode($other_domain), 166 'other_domain' => json_encode($other_domain),
167 'target_domain' => $target_domain 167 'target_domain' => $target_domain
168 ]); 168 ]);
  169 + }else{
  170 + $redirect_model->edit(['status'=>DomainRedirectTask::STATUS_UN],['id'=>$task_redirect_info['id']]);
169 } 171 }
170 172
171 return $this->success(); 173 return $this->success();
@@ -4,6 +4,7 @@ namespace App\Http\Controllers\Aside\Com; @@ -4,6 +4,7 @@ namespace App\Http\Controllers\Aside\Com;
4 4
5 use App\Enums\Common\Code; 5 use App\Enums\Common\Code;
6 use App\Enums\Common\Common; 6 use App\Enums\Common\Common;
  7 +use App\Helper\Translate;
7 use App\Http\Controllers\Aside\BaseController; 8 use App\Http\Controllers\Aside\BaseController;
8 use App\Http\Logic\Aside\Manage\MenuLogic; 9 use App\Http\Logic\Aside\Manage\MenuLogic;
9 use App\Http\Logic\Bside\User\UserLoginLogic; 10 use App\Http\Logic\Bside\User\UserLoginLogic;
@@ -11,6 +12,7 @@ use App\Models\Inquiry\InquiryData; @@ -11,6 +12,7 @@ use App\Models\Inquiry\InquiryData;
11 use App\Models\Manage\Manage; 12 use App\Models\Manage\Manage;
12 use App\Models\User\User; 13 use App\Models\User\User;
13 use App\Models\WebSetting\WebLanguage; 14 use App\Models\WebSetting\WebLanguage;
  15 +use App\Services\HumanizeAiTextService;
14 use Illuminate\Support\Facades\Cache; 16 use Illuminate\Support\Facades\Cache;
15 use Illuminate\Support\Facades\Hash; 17 use Illuminate\Support\Facades\Hash;
16 18
@@ -160,5 +162,35 @@ class IndexController extends BaseController @@ -160,5 +162,35 @@ class IndexController extends BaseController
160 $this->response('success',Code::SUCCESS,['dynamic_password'=>$dynamic_password]); 162 $this->response('success',Code::SUCCESS,['dynamic_password'=>$dynamic_password]);
161 } 163 }
162 164
  165 + /**
  166 + * @remark :去ai痕迹
  167 + * @name :notAiHumanizer
  168 + * @author :lyh
  169 + * @method :post
  170 + * @time :2025/5/21 9:08
  171 + */
  172 + public function notAiHumanizer(){
  173 + $this->request->validate([
  174 + 'text'=>'required',
  175 + 'lang'=>'required'
  176 + ],[
  177 + 'text.required' => '文本text不能为空',
  178 + 'lang.required' => '语种不能为空',
  179 + ]);
  180 + $service = new HumanizeAiTextService();
  181 + $data = $service->humanizer($this->param['text'],$this->param['lang']);
  182 + $this->response('success', Code::SUCCESS, $data);
  183 + }
163 184
  185 + /**
  186 + * @remark :翻译
  187 + * @name :stringTranslation
  188 + * @author :lyh
  189 + * @method :post
  190 + * @time :2025/5/21 9:31
  191 + */
  192 + public function stringTranslation(){
  193 + $data = Translate::translateSl($this->param['text']);
  194 + $this->response('success', Code::SUCCESS, $data);
  195 + }
164 } 196 }
@@ -1214,4 +1214,5 @@ class ProjectController extends BaseController @@ -1214,4 +1214,5 @@ class ProjectController extends BaseController
1214 $lists = $model->list(['status' => 1], 'id', ['id', 'industry_name'], 'asc'); 1214 $lists = $model->list(['status' => 1], 'id', ['id', 'industry_name'], 'asc');
1215 $this->response('success', Code::SUCCESS, $lists); 1215 $this->response('success', Code::SUCCESS, $lists);
1216 } 1216 }
  1217 +
1217 } 1218 }
@@ -68,12 +68,19 @@ class AggregationSettingController extends BaseController @@ -68,12 +68,19 @@ class AggregationSettingController extends BaseController
68 if($number > 1){ 68 if($number > 1){
69 $this->param['top_banner'] = array_slice($this->param['top_banner'], 1); 69 $this->param['top_banner'] = array_slice($this->param['top_banner'], 1);
70 } 70 }
  71 + }else{
  72 + if(empty($info['image'])){
  73 + $settingImageModel->edit(['image'=>reset($this->param['top_banner'])],['type'=>4,'project_id'=>$this->user['project_id']]);
  74 + if($number > 1){
  75 + $this->param['top_banner'] = array_slice($this->param['top_banner'], 1);
  76 + }
  77 + }
71 } 78 }
72 if($number > 3){ 79 if($number > 3){
73 $this->param['top_banner'] = array_slice($this->param['top_banner'], 0, 3); 80 $this->param['top_banner'] = array_slice($this->param['top_banner'], 0, 3);
74 } 81 }
75 - $this->param['top_banner'] = Arr::a2s($this->param['top_banner']);  
76 } 82 }
  83 + $this->param['top_banner'] = Arr::a2s($this->param['top_banner'] ?? []);
77 if(isset($this->param['foot_banner']) && !empty($this->param['foot_banner'])){ 84 if(isset($this->param['foot_banner']) && !empty($this->param['foot_banner'])){
78 $this->param['foot_banner'] = Arr::a2s($this->param['foot_banner']); 85 $this->param['foot_banner'] = Arr::a2s($this->param['foot_banner']);
79 } 86 }
@@ -99,7 +99,6 @@ class AiBlogService @@ -99,7 +99,6 @@ class AiBlogService
99 $param['title'] = $title; 99 $param['title'] = $title;
100 } 100 }
101 $param['anchor'] = $anchor; 101 $param['anchor'] = $anchor;
102 - $param['url'] = $this->route;  
103 $param['mch_id'] = $this->mch_id; 102 $param['mch_id'] = $this->mch_id;
104 $param['template_id'] = 1; 103 $param['template_id'] = 1;
105 $this->sign = $this->generateSign($param,$this->key); 104 $this->sign = $this->generateSign($param,$this->key);
  1 +<?php
  2 +/**
  3 + * Created by PhpStorm.
  4 + * User: zhl
  5 + * Date: 2025/5/20
  6 + * Time: 14:49
  7 + */
  8 +namespace App\Services;
  9 +
  10 +use Illuminate\Support\Facades\Http;
  11 +
  12 +/**
  13 + * AI去痕迹
  14 + * Class HumanizeAiTextService
  15 + * @package App\Services
  16 + */
  17 +class HumanizeAiTextService
  18 +{
  19 + /**
  20 + * 封装接口地址
  21 + */
  22 + const CMER_API = 'https://api.cmer.com/';
  23 +
  24 +
  25 + const DRIVER_HUMANIZE = 'humanize'; //3.9号停用 https://rapidapi.com/firdavscoder1/api/humanize1/playground/apiendpoint_4bdba3d9-c66a-4e3d-b1e9-ff307da08e96
  26 + const DRIVER_HUMANIZE_AI_TEXT = 'humanize-ai-text';
  27 +
  28 +
  29 +#=======================================================================================================================
  30 +#== AI生成内容 去除AI痕迹 ==
  31 +#== https://rapidapi.com/bilgisamapi-bilgisamapi-default/api/ai-content-detection-ai-detector-humanize-ai-text ==
  32 +#== https://rapidapi.com/firdavscoder1/api/humanize1/playground/apiendpoint_4bdba3d9-c66a-4e3d-b1e9-ff307da08e96 ==
  33 +#=======================================================================================================================
  34 +
  35 + /**
  36 + * 去AI痕迹 header
  37 + * @param $driver
  38 + * @return array
  39 + */
  40 + public function humanizeHeader($driver)
  41 + {
  42 + return [
  43 + 'apikey' => 'kWd7wQbEPUF0fr17dnt5NQLazfv44O9T',
  44 + 'X-CmerApi-Host' => $driver . '.p.cmer.com',
  45 + 'Content-Type' => 'application/json',
  46 + ];
  47 + }
  48 +
  49 + /**
  50 + * 去AI痕迹提交
  51 + * FIXME humanize:返回请求ID:request_id, 需要异步获取结果
  52 + * @param string $text
  53 + * @param string $lang
  54 + * @return array|mixed
  55 + */
  56 + public function humanizer($text, $lang)
  57 + {
  58 + $driver = self::DRIVER_HUMANIZE_AI_TEXT;
  59 + switch ($driver){
  60 + case self::DRIVER_HUMANIZE:
  61 + $action = 'humainzer/';
  62 + $readilibty = 'Marketing';
  63 + $mode = 'ENHANCED';
  64 + $params = compact('text', 'readilibty', 'mode');
  65 + $result = Http::withoutVerifying()->withHeaders($this->humanizeHeader($driver))->asForm()->post(self::CMER_API . $action, $params)->json();
  66 + break;
  67 + case self::DRIVER_HUMANIZE_AI_TEXT:
  68 + $action = 'humanizeContent?noqueue=1&language=' . $lang;
  69 + $params = compact('text');
  70 + $result = Http::withoutVerifying()->withHeaders($this->humanizeHeader($driver))->post(self::CMER_API . $action, $params)->json();
  71 + break;
  72 + default:
  73 + $result = [];
  74 + break;
  75 +
  76 + }
  77 + return $result;
  78 + }
  79 +
  80 + /**
  81 + * 去AI痕迹结果
  82 + * FIXME humanize:异步获取结果
  83 + * @param $request_id
  84 + * @return \Illuminate\Http\Client\Response
  85 + */
  86 + public function humanizerResult($request_id)
  87 + {
  88 + $action = 'result/';
  89 + $params = compact('request_id');
  90 + return Http::withoutVerifying()->withHeaders($this->humanizeHeader(self::DRIVER_HUMANIZE))->asForm()->post(self::CMER_API . $action, $params);
  91 + }
  92 +}
@@ -17,6 +17,7 @@ Route::middleware(['aloginauth'])->group(function () { @@ -17,6 +17,7 @@ Route::middleware(['aloginauth'])->group(function () {
17 Route::any('/sendNotify', [Aside\Com\CNoticeController::class, 'sendNotify'])->name('admin.sendNotify'); 17 Route::any('/sendNotify', [Aside\Com\CNoticeController::class, 'sendNotify'])->name('admin.sendNotify');
18 Route::any('/getCountry', [Aside\Com\CNoticeController::class, 'getCountry'])->name('admin.getCountry'); 18 Route::any('/getCountry', [Aside\Com\CNoticeController::class, 'getCountry'])->name('admin.getCountry');
19 Route::any('/getDynamicPassword', [Aside\Com\IndexController::class, 'getDynamicPassword'])->name('admin.getDynamicPassword'); 19 Route::any('/getDynamicPassword', [Aside\Com\IndexController::class, 'getDynamicPassword'])->name('admin.getDynamicPassword');
  20 + Route::any('/notAiHumanizer', [Aside\Com\IndexController::class, 'notAiHumanizer'])->name('admin.notAiHumanizer');
20 //会员相关 21 //会员相关
21 Route::prefix('user')->group(function () { 22 Route::prefix('user')->group(function () {
22 //会员管理 23 //会员管理
@@ -574,6 +575,7 @@ Route::middleware(['aloginauth'])->group(function () { @@ -574,6 +575,7 @@ Route::middleware(['aloginauth'])->group(function () {
574 //无需登录验证的路由组 575 //无需登录验证的路由组
575 Route::group([], function () { 576 Route::group([], function () {
576 Route::any('/login', [Aside\LoginController::class, 'login'])->name('admin.login.white'); 577 Route::any('/login', [Aside\LoginController::class, 'login'])->name('admin.login.white');
  578 + Route::any('/stringTranslation', [Aside\Com\IndexController::class, 'stringTranslation'])->name('admin.stringTranslation');
577 // Route::any('/image/{hash}/{w?}/{h?}', [\App\Http\Controllers\File\ImageController::class, 'index'])->name('admin.image_show'); 579 // Route::any('/image/{hash}/{w?}/{h?}', [\App\Http\Controllers\File\ImageController::class, 'index'])->name('admin.image_show');
578 Route::any('/file/{hash}', [\App\Http\Controllers\File\FileController::class, 'index'])->name('admin.file_show'); 580 Route::any('/file/{hash}', [\App\Http\Controllers\File\FileController::class, 'index'])->name('admin.file_show');
579 Route::any('/download_files', [\App\Http\Controllers\File\FileController::class, 'downLoad'])->name('admin.files_downLoad');//导出文件 581 Route::any('/download_files', [\App\Http\Controllers\File\FileController::class, 'downLoad'])->name('admin.files_downLoad');//导出文件