作者 李宇航

合并分支 'lyh-server' 到 'master'

Lyh server



查看合并请求 !1998
@@ -13,16 +13,19 @@ use App\Console\Commands\Domain\DomainInfo; @@ -13,16 +13,19 @@ use App\Console\Commands\Domain\DomainInfo;
13 use App\Http\Logic\Aside\Project\ProjectLogic; 13 use App\Http\Logic\Aside\Project\ProjectLogic;
14 use App\Models\Ai\AiBlogAuthor; 14 use App\Models\Ai\AiBlogAuthor;
15 use App\Models\Com\NoticeLog; 15 use App\Models\Com\NoticeLog;
  16 +use App\Models\Com\V6WeeklyReport;
16 use App\Models\Project\AiBlogTask; 17 use App\Models\Project\AiBlogTask;
17 use App\Models\Project\DeployBuild; 18 use App\Models\Project\DeployBuild;
18 use App\Models\Project\DeployOptimize; 19 use App\Models\Project\DeployOptimize;
19 use App\Models\Project\OnlineCheck; 20 use App\Models\Project\OnlineCheck;
20 use App\Models\Project\Project; 21 use App\Models\Project\Project;
21 use App\Models\Project\ProjectAiSetting; 22 use App\Models\Project\ProjectAiSetting;
  23 +use App\Models\ProjectAssociation\ProjectAssociation;
22 use App\Models\RouteMap\RouteMap; 24 use App\Models\RouteMap\RouteMap;
23 use App\Models\Visit\Visit; 25 use App\Models\Visit\Visit;
24 use App\Models\WebSetting\WebLanguage; 26 use App\Models\WebSetting\WebLanguage;
25 use App\Models\WebSetting\WebSetting; 27 use App\Models\WebSetting\WebSetting;
  28 +use App\Models\Workchat\MessagePush;
26 use App\Services\AiBlogService; 29 use App\Services\AiBlogService;
27 use App\Services\ProjectServer; 30 use App\Services\ProjectServer;
28 use Illuminate\Console\Command; 31 use Illuminate\Console\Command;
@@ -46,117 +49,168 @@ class lyhDemo extends Command @@ -46,117 +49,168 @@ class lyhDemo extends Command
46 protected $description = '更新路由'; 49 protected $description = '更新路由';
47 50
48 public function handle(){ 51 public function handle(){
49 - $projectIds = DB::table('gl_project_ai_setting_copy1')  
50 - ->whereIn('mch_id', function ($query) {  
51 - $query->select('mch_id')  
52 - ->from('gl_project_ai_setting_copy1')  
53 - ->groupBy('mch_id')  
54 - ->havingRaw('COUNT(*) > 1');  
55 - })  
56 - ->pluck('project_id');  
57 - $projectIds[] = 811;  
58 - $projectIds[] = 1367;  
59 - $projectIds[] = 1370;  
60 - $projectIds[] = 2201;  
61 - $projectIds[] = 2260;  
62 - $projectIds[] = 2259;  
63 -// $aiSettingModel = new ProjectAiSetting();  
64 -// foreach ($projectIds as $item){  
65 -// $info = $aiSettingModel->read(['project_id'=>$item]);  
66 -// if($info === false){  
67 -// echo '项目id:'.$item.PHP_EOL;  
68 -// }else{  
69 -// $this->createAuthor($item,$info['mch_id'],$info['key']);  
70 -// }  
71 -// }  
72 -// return true;  
73 - $aiSettingModel = new ProjectAiSetting();  
74 - $aiSettingModel->del(['project_id'=>['in',$projectIds]]);  
75 - $projectModel = new Project();  
76 - $logic = new ProjectLogic();  
77 - $lists = $projectModel->list(['delete_status' => 0,'extend_type'=>0,'id'=>['in',$projectIds]], 'id', ['id']);  
78 - $title = [];  
79 - foreach ($lists as $val) {  
80 - //清空作者  
81 - ProjectServer::useProject($val['id']);  
82 - AiBlogAuthor::truncate();  
83 - $routeMapModel = new RouteMap();  
84 - $routeMapModel->del(['source'=>$routeMapModel::SOURCE_AI_BLOG_AUTHOR]);  
85 - DB::disconnect('custom_mysql');  
86 - //重新创建项目拉取作者  
87 - $info = $logic->getProjectInfo($val['id']);  
88 - $title[] = $info['company']?:$info['title'];  
89 - if(empty($info['main_lang_id'])){  
90 - $info['main_lang_id'] = 1;  
91 - }  
92 - if(empty($info['is_ai_blog'])){  
93 - $info['is_ai_blog'] = 1;  
94 - }  
95 -// try {  
96 - $this->setAiBlog($info['id'],$info['main_lang_id'],$info['is_ai_blog'] ?? 0,  
97 - $info['company']??"", $info['deploy_optimize']['company_en_name'] ?? '',  
98 - $info['deploy_optimize']['company_en_description'] ?? '',$info['is_ai_video'] ?? 0,$info['is_related_video'] ?? 0);  
99 -// }catch (\Exception $e){  
100 -// continue;  
101 -// }  
102 - 52 + $projectArr = [3257,1835,1834];
  53 + $v6WeekModel = new V6WeeklyReport();
  54 + foreach ($projectArr as $item){
  55 + $projectModel = new Project();
  56 + $latest = $v6WeekModel->formatQuery(['project_id'=>$item])->orderBy('id', 'desc')->first();
  57 + $list = $projectModel->read(['delete_status'=>0,'id'=>$item],['id','title','is_weekly_report','main_lang_id']);
  58 + $latest['main_lang_id'] = $list['main_lang_id'];
  59 + $latest['is_weekly_report'] = $list['is_weekly_report'];
  60 + $latest['title'] = $list['title'];
  61 + $this->workChatMessage($latest,$item);
103 } 62 }
104 return true; 63 return true;
105 } 64 }
106 - public function setAiBlog($project_id,$main_lang_id,$is_ai_blog,$company,$company_en_name,$company_en_description,$is_ai_video = 0,$is_related_video = 0){  
107 - if(empty($main_lang_id) || (empty($is_ai_blog) && empty($is_ai_video))){  
108 - echo '创建失败:'.$project_id.PHP_EOL;  
109 - }  
110 - $this->model = new Project();  
111 - $projectInfo = $this->model->read(['id'=>$project_id],['title','main_lang_id','company']);  
112 - $projectOptimize = DeployOptimize::where('project_id', $project_id)->first();  
113 - //获取项目主语种  
114 - $languageModel = new WebLanguage();  
115 - $languageInfo = $languageModel->read(['id'=>$main_lang_id],['short']);  
116 - if($languageInfo == false){  
117 - echo '创建失败:'.$project_id.PHP_EOL;  
118 - }  
119 - $aiSettingModel = new ProjectAiSetting();  
120 - $aiSettingInfo = $aiSettingModel->read(['project_id'=>$project_id]);  
121 - if($aiSettingInfo === false){  
122 - $aiBlogService = new AiBlogService();  
123 - $result = $aiBlogService->createProject($projectInfo['company']?:$projectInfo['title'],$languageInfo['short'],$company_en_description,$company_en_name,$is_related_video);  
124 - if(isset($result['status']) && $result['status'] == 200){  
125 - //查看当前项目是否已有记录  
126 - $resData = [  
127 - 'project_id'=>$project_id,  
128 - 'mch_id'=>$result['data']['mch_id'],  
129 - 'key'=>$result['data']['key'],  
130 - ];  
131 - $aiSettingModel->add($resData);  
132 - $this->createAuthor($project_id,$result['data']['mch_id'],$result['data']['key']); 65 + public function workChatMessage($data,$project_id){
  66 + $arr = [];
  67 + //项目是否有绑定群
  68 + $friend_id = ProjectAssociation::where('project_id', $project_id)
  69 + ->where('status', ProjectAssociation::STATUS_NORMAL)
  70 + ->where('binding_app', ProjectAssociation::ENTERPRISE_WECHAT)
  71 + ->value('friend_id');
  72 + if(!$friend_id){
  73 + echo date('Y-m-d H:i:s') . '没有绑定企微群:'.$project_id . PHP_EOL;
  74 + return false;
  75 + }
  76 + $content = '';
  77 + $content1 = '';
  78 + if(!empty($data['inquiry_total'])){
  79 + $content1 .= '项目共计已收到询盘 '.$data['inquiry_total'].'条,';
  80 + if(!empty($data['week_inquiry_total'])){
  81 + $content1 .= '本周新收 '.$data['week_inquiry_total'].' 封询盘。';
  82 + }
  83 + if(!empty($data['inquiry_country'])){
  84 + $data['inquiry_country'] = json_decode($data['inquiry_country'],true);
  85 + arsort($data['inquiry_country']);
  86 + $data['inquiry_country'] = array_slice($data['inquiry_country'], 0, 4, true);
  87 + $country = '';
  88 + foreach ($data['inquiry_country'] as $k => $v){
  89 + $country .= $k.',';
  90 + };
  91 + $country = trim($country,',');
  92 + if(!empty($country)){
  93 + $content1 .= '询盘主要来源于'.$country.'等国家地区。';
  94 + }
  95 + }
  96 + $content1 .= '如有高质量客户,请您密切关注与跟进;';
  97 + }
  98 + if(!empty($content1)){
  99 + $arr[] = $content1;
  100 + }
  101 + $content2 = '';
  102 + 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'])){
  103 + $content2 .= '项目截止目前';
  104 + if($data['main_lang_id'] == 8){
  105 + $title = 'Yandex';
133 }else{ 106 }else{
134 - echo '创建失败:'.$project_id.PHP_EOL; 107 + $title = '谷歌';
  108 + }
  109 + if(!empty($data['google_indexed_num'])){
  110 + $content2 .= $title.'收录量:'.$data['google_indexed_num'].'条,';
  111 + }
  112 + if(!empty($data['google_links_num'])){
  113 + //获取上一次的外链数
  114 + $latestRecord = V6WeeklyReport::where(['project_id'=>$project_id])->orderBy('id', 'desc')->first();
  115 + if(!empty($latestRecord)){
  116 + if($latestRecord['google_links_num'] != $data['google_links_num']){
  117 + $content2 .= '外链量:'.$data['google_links_num'].'条,';
  118 + }
  119 + }else{
  120 + $content2 .= '外链量:'.$data['google_links_num'].'条,';
  121 + }
  122 + }
  123 + if(!empty($data['keyword_home_num']) || !empty($data['keyword_three_num']) || !empty($data['keyword_five_num']) || !empty($data['keyword_ten_num'])){
  124 + $content2 .= $title.'搜索排名';
  125 + if(!empty($data['keyword_home_num'])){
  126 + $content2 .= '首页关键词数量为:'.$data['keyword_home_num'].'个,';
  127 + }
  128 + if(!empty($data['keyword_three_num'])){
  129 + $content2 .= '前三页关键词数量为:'.$data['keyword_three_num'].'个,';
  130 + }
  131 + if(!empty($data['keyword_five_num'])){
  132 + $content2 .= '前五页关键词数量为:'.$data['keyword_five_num'].'个,';
  133 + }
  134 + if(!empty($data['keyword_ten_num'])){
  135 + $content2 .= '前十页关键词数量为:'.$data['keyword_ten_num'].'个,';
  136 + }
135 } 137 }
136 - }else{  
137 - //有信息更新  
138 - if(($projectInfo['company'] != $company) || ($projectInfo['main_lang_id'] != $main_lang_id)  
139 - || ($projectOptimize['company_en_name'] != $company_en_name) || ($projectOptimize['company_en_description'] != $company_en_description)){  
140 - $aiBlogService = new AiBlogService();  
141 - $aiBlogService->mch_id = $aiSettingInfo['mch_id'];  
142 - $aiBlogService->key = $aiSettingInfo['key'];  
143 - $aiBlogService->updatedProject($projectInfo['company']?:$projectInfo['title'],$languageInfo['short'],$company_en_description,$company_en_name,$is_related_video); 138 + if(!empty($data['daily_average_num'])){
  139 + $content2 .= '本周日均访客量:'.$data['daily_average_num'].'+。';
144 } 140 }
  141 + $content2 .= PHP_EOL.'全球搜建议用户持续分析、选择、添加企业、产品、服务等相关关键词进行优化和监控,以覆盖更多相关排名和流量;';
145 } 142 }
146 - return true;  
147 - }  
148 -  
149 - public function createAuthor($project_id,$mch_id,$key){  
150 - //查看当前项目是否已经创建了作者  
151 - $aiBlogTaskModel = new AiBlogTask();  
152 - $aiBlogService = new AiBlogService();  
153 - $aiBlogService->mch_id = $mch_id;  
154 - $aiBlogService->key = $key;  
155 - $result = $aiBlogService->createAuthor();  
156 - if($result['status'] == 200){  
157 - //查看当前是否已有未执行的  
158 - $aiBlogTaskModel->add(['project_id'=>$project_id,'status'=>1,'type'=>1]); 143 + if(!empty($content2)){
  144 + $arr[] = $content2;
  145 + }
  146 + $content3 = '';
  147 + if(!empty($data['product_num']) || !empty($data['news_num']) || !empty($data['week_product_num']) || !empty($data['week_news_num'])){
  148 + if(!empty($data['product_num']) || !empty($data['news_num'])){
  149 + $content3 .= '项目截止目前';
  150 + if(!empty($data['product_num'])){
  151 + $content3 .= '发布产品:'.$data['product_num'].'条,';
  152 + }
  153 + if(!empty($data['news_num'])){
  154 + $content3 .= '发布新闻:'.$data['news_num'].'条。';
  155 + }
  156 + }
  157 + if(!empty($data['week_product_num']) || !empty($data['week_news_num'])){
  158 + $content3 .= '本周新增';
  159 + if(!empty($data['week_product_num'])){
  160 + $content3 .= '产品:'.$data['week_product_num'].'条,';
  161 + }
  162 + if(!empty($data['week_news_num'])){
  163 + $content3 .= '新闻:'.$data['week_news_num'].'条。';
  164 + }
  165 + }
  166 + $content3 .= PHP_EOL.'全球搜建议用户保持网站内容的持续更新与完善,可参考谷歌关于创建实用、可靠、以用户为中心的内容的相关建议:https://developers.google.com/search/docs/fundamentals/creating-helpful-content?hl=zh-cn;';
  167 + }
  168 + if(!empty($content3)){
  169 + $arr[] = $content3;
  170 + }
  171 + $content4 = '';
  172 + if(!empty($data['main_update_num'])){
  173 + $content4 .= '网站加载速度维护及主站页面更新'.$data['main_update_num'].'次。';
  174 + }
  175 + if(!empty($data['aggregation_update_num'])){
  176 + $content4 .= '聚合页主站页面更新'.$data['aggregation_update_num'].'次。';
  177 + }
  178 + if(!empty($data['minor_update_num'])){
  179 + $content4 .= '小语种站页面更新'.$data['minor_update_num'].'次。';
  180 + }
  181 + if(!empty($data['aggregation_minor_update_num'])){
  182 + $content4 .= '聚合页小语种站页面'.$data['aggregation_minor_update_num'].'次。';
  183 + }
  184 + if(!empty($content4)){
  185 + $content4 = PHP_EOL.'本周主要优化工作包括:TDK、H标签、Img标签等优化设置排查与进一步完善,Sitemap更新与网页收录提交,外链新增与排查。'.$content4;
  186 + }
  187 + if(!empty($content4)){
  188 + $arr[] = $content4;
  189 + }
  190 + if(empty($arr)){
  191 + return true;
  192 + }
  193 + foreach ($arr as $key => $val){
  194 + $content .= ($key+1).','.$val.PHP_EOL.PHP_EOL;
  195 + }
  196 + $tomorrowNineAM = date('Y-m-d 09:00:00', time());
  197 + if(empty($content)){
  198 + return true;
159 } 199 }
  200 + $tips = 'Tips:'.PHP_EOL.'1、全球搜V6.0系统提供网页TDK、H标签、Img标签等用户自定义编辑接口且辅以AI创作工具,用户可进一步对相关优化设置进行精细化优化与调整;'.PHP_EOL.'2、全球搜V6.0系统提供小语种页面精准校对翻译功能,用户可进一步对已翻译小语种页面进行人工翻译校对;'.PHP_EOL.'3、全球搜V6.0系统支持绑定Facebook、LinkedIn、X(原Twitter)等社媒账号,可一键同步转发网站上发布的产品和新闻至社媒账号动态,建议用户用起来哦;'.PHP_EOL.'4、如用户有较丰富的企业、产品、服务相关视频素材,全球搜建议用户及时创建YouTube主页,并在YouTube和网站相关网页上同步发布视频;';
  201 + $message = "【全球搜V6.0周报】" . PHP_EOL . $content . PHP_EOL . $tips;
  202 + $param = [
  203 + 'project_id'=>$project_id,
  204 + 'friend_id'=>$friend_id,
  205 + 'type'=>MessagePush::TYPE_WEEK,
  206 + 'content'=> $message,
  207 + 'ref_ids'=>'',
  208 + 'send_time'=>$tomorrowNineAM,
  209 + 'status'=>0,
  210 + ];
  211 + //写入一条推送消息 自动消费
  212 + $messagePushModel = new MessagePush();
  213 + $messagePushModel->add($param);
160 return true; 214 return true;
161 } 215 }
162 } 216 }
@@ -11,6 +11,7 @@ use App\Models\Inquiry\InquiryData; @@ -11,6 +11,7 @@ use App\Models\Inquiry\InquiryData;
11 use App\Models\Manage\Manage; 11 use App\Models\Manage\Manage;
12 use App\Models\User\User; 12 use App\Models\User\User;
13 use App\Models\WebSetting\WebLanguage; 13 use App\Models\WebSetting\WebLanguage;
  14 +use App\Services\HumanizeAiTextService;
14 use Illuminate\Support\Facades\Cache; 15 use Illuminate\Support\Facades\Cache;
15 use Illuminate\Support\Facades\Hash; 16 use Illuminate\Support\Facades\Hash;
16 17
@@ -160,5 +161,23 @@ class IndexController extends BaseController @@ -160,5 +161,23 @@ class IndexController extends BaseController
160 $this->response('success',Code::SUCCESS,['dynamic_password'=>$dynamic_password]); 161 $this->response('success',Code::SUCCESS,['dynamic_password'=>$dynamic_password]);
161 } 162 }
162 163
163 - 164 + /**
  165 + * @remark :去ai痕迹
  166 + * @name :notAiHumanizer
  167 + * @author :lyh
  168 + * @method :post
  169 + * @time :2025/5/21 9:08
  170 + */
  171 + public function notAiHumanizer(){
  172 + $this->request->validate([
  173 + 'text'=>'required',
  174 + 'lang'=>'required'
  175 + ],[
  176 + 'text.required' => '文本text不能为空',
  177 + 'lang.required' => '语种不能为空',
  178 + ]);
  179 + $service = new HumanizeAiTextService();
  180 + $data = $service->humanizer($this->param['text'],$this->param['lang']);
  181 + $this->response('success', Code::SUCCESS, $data);
  182 + }
164 } 183 }
@@ -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 }
  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 //会员管理