作者 lyh

gx脚本锚文本数量

@@ -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,121 +49,164 @@ class lyhDemo extends Command @@ -46,121 +49,164 @@ 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 - $data = [];  
64 - $aiSettingModel = new ProjectAiSetting();  
65 - foreach ($projectIds as $item){  
66 - $info = $aiSettingModel->read(['project_id'=>$item]);  
67 - if($info === false){  
68 - echo 'error项目id:'.$item.PHP_EOL;  
69 - }else{  
70 - //获取对应的task_id  
71 - echo '项目id:'.$item.PHP_EOL;  
72 - $aiBlogTask = new AiBlogTask();  
73 - $aiBlogTask->edit(['status'=>1],['type'=>2,'project_id'=>$item]);  
74 - } 52 + $projectArr = [3257,1835,1834];
  53 + $v6WeekModel = new V6WeeklyReport();
  54 + foreach ($projectArr as $item){
  55 + $latest = $v6WeekModel->formatQuery(['project_id'=>$item])->orderBy('id', 'desc')->first()->toArray();
  56 + dd($latest);
  57 + $this->workChatMessage($latest);
75 } 58 }
76 -// return true;  
77 -// $aiSettingModel = new ProjectAiSetting();  
78 -// $aiSettingModel->del(['project_id'=>['in',$projectIds]]);  
79 -// $projectModel = new Project();  
80 -// $logic = new ProjectLogic();  
81 -// $lists = $projectModel->list(['delete_status' => 0,'extend_type'=>0,'id'=>['in',$projectIds]], 'id', ['id']);  
82 -// $title = [];  
83 -// foreach ($lists as $val) {  
84 -// //清空作者  
85 -// ProjectServer::useProject($val['id']);  
86 -// AiBlogAuthor::truncate();  
87 -// $routeMapModel = new RouteMap();  
88 -// $routeMapModel->del(['source'=>$routeMapModel::SOURCE_AI_BLOG_AUTHOR]);  
89 -// DB::disconnect('custom_mysql');  
90 -// //重新创建项目拉取作者  
91 -// $info = $logic->getProjectInfo($val['id']);  
92 -// $title[] = $info['company']?:$info['title'];  
93 -// if(empty($info['main_lang_id'])){  
94 -// $info['main_lang_id'] = 1;  
95 -// }  
96 -// if(empty($info['is_ai_blog'])){  
97 -// $info['is_ai_blog'] = 1;  
98 -// }  
99 -//// try {  
100 -// $this->setAiBlog($info['id'],$info['main_lang_id'],$info['is_ai_blog'] ?? 0,  
101 -// $info['company']??"", $info['deploy_optimize']['company_en_name'] ?? '',  
102 -// $info['deploy_optimize']['company_en_description'] ?? '',$info['is_ai_video'] ?? 0,$info['is_related_video'] ?? 0);  
103 -// }catch (\Exception $e){  
104 -// continue;  
105 -// }  
106 -  
107 -// }  
108 return true; 59 return true;
109 } 60 }
110 - 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){  
111 - if(empty($main_lang_id) || (empty($is_ai_blog) && empty($is_ai_video))){  
112 - echo '创建失败:'.$project_id.PHP_EOL;  
113 - }  
114 - $this->model = new Project();  
115 - $projectInfo = $this->model->read(['id'=>$project_id],['title','main_lang_id','company']);  
116 - $projectOptimize = DeployOptimize::where('project_id', $project_id)->first();  
117 - //获取项目主语种  
118 - $languageModel = new WebLanguage();  
119 - $languageInfo = $languageModel->read(['id'=>$main_lang_id],['short']);  
120 - if($languageInfo == false){  
121 - echo '创建失败:'.$project_id.PHP_EOL;  
122 - }  
123 - $aiSettingModel = new ProjectAiSetting();  
124 - $aiSettingInfo = $aiSettingModel->read(['project_id'=>$project_id]);  
125 - if($aiSettingInfo === false){  
126 - $aiBlogService = new AiBlogService();  
127 - $result = $aiBlogService->createProject($projectInfo['company']?:$projectInfo['title'],$languageInfo['short'],$company_en_description,$company_en_name,$is_related_video);  
128 - if(isset($result['status']) && $result['status'] == 200){  
129 - //查看当前项目是否已有记录  
130 - $resData = [  
131 - 'project_id'=>$project_id,  
132 - 'mch_id'=>$result['data']['mch_id'],  
133 - 'key'=>$result['data']['key'],  
134 - ];  
135 - $aiSettingModel->add($resData);  
136 - $this->createAuthor($project_id,$result['data']['mch_id'],$result['data']['key']); 61 + public function workChatMessage($data,$project_id){
  62 + $arr = [];
  63 + //项目是否有绑定群
  64 + $friend_id = ProjectAssociation::where('project_id', $project_id)
  65 + ->where('status', ProjectAssociation::STATUS_NORMAL)
  66 + ->where('binding_app', ProjectAssociation::ENTERPRISE_WECHAT)
  67 + ->value('friend_id');
  68 + if(!$friend_id){
  69 + echo date('Y-m-d H:i:s') . '没有绑定企微群:'.$project_id . PHP_EOL;
  70 + return false;
  71 + }
  72 + $content = '';
  73 + $content1 = '';
  74 + if(!empty($data['inquiry_total'])){
  75 + $content1 .= '项目共计已收到询盘 '.$data['inquiry_total'].'条,';
  76 + if(!empty($data['week_inquiry_total'])){
  77 + $content1 .= '本周新收 '.$data['week_inquiry_total'].' 封询盘。';
  78 + }
  79 + if(!empty($data['inquiry_country'])){
  80 + $data['inquiry_country'] = json_decode($data['inquiry_country'],true);
  81 + arsort($data['inquiry_country']);
  82 + $data['inquiry_country'] = array_slice($data['inquiry_country'], 0, 4, true);
  83 + $country = '';
  84 + foreach ($data['inquiry_country'] as $k => $v){
  85 + $country .= $k.',';
  86 + };
  87 + $country = trim($country,',');
  88 + if(!empty($country)){
  89 + $content1 .= '询盘主要来源于'.$country.'等国家地区。';
  90 + }
  91 + }
  92 + $content1 .= '如有高质量客户,请您密切关注与跟进;';
  93 + }
  94 + if(!empty($content1)){
  95 + $arr[] = $content1;
  96 + }
  97 + $content2 = '';
  98 + 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'])){
  99 + $content2 .= '项目截止目前';
  100 + if($data['main_lang_id'] == 8){
  101 + $title = 'Yandex';
137 }else{ 102 }else{
138 - echo '创建失败:'.$project_id.PHP_EOL; 103 + $title = '谷歌';
  104 + }
  105 + if(!empty($data['google_indexed_num'])){
  106 + $content2 .= $title.'收录量:'.$data['google_indexed_num'].'条,';
  107 + }
  108 + if(!empty($data['google_links_num'])){
  109 + //获取上一次的外链数
  110 + $latestRecord = V6WeeklyReport::where(['project_id'=>$project_id])->orderBy('id', 'desc')->first();
  111 + if(!empty($latestRecord)){
  112 + if($latestRecord['google_links_num'] != $data['google_links_num']){
  113 + $content2 .= '外链量:'.$data['google_links_num'].'条,';
  114 + }
  115 + }else{
  116 + $content2 .= '外链量:'.$data['google_links_num'].'条,';
  117 + }
  118 + }
  119 + if(!empty($data['keyword_home_num']) || !empty($data['keyword_three_num']) || !empty($data['keyword_five_num']) || !empty($data['keyword_ten_num'])){
  120 + $content2 .= $title.'搜索排名';
  121 + if(!empty($data['keyword_home_num'])){
  122 + $content2 .= '首页关键词数量为:'.$data['keyword_home_num'].'个,';
  123 + }
  124 + if(!empty($data['keyword_three_num'])){
  125 + $content2 .= '前三页关键词数量为:'.$data['keyword_three_num'].'个,';
  126 + }
  127 + if(!empty($data['keyword_five_num'])){
  128 + $content2 .= '前五页关键词数量为:'.$data['keyword_five_num'].'个,';
  129 + }
  130 + if(!empty($data['keyword_ten_num'])){
  131 + $content2 .= '前十页关键词数量为:'.$data['keyword_ten_num'].'个,';
  132 + }
139 } 133 }
140 - }else{  
141 - //有信息更新  
142 - if(($projectInfo['company'] != $company) || ($projectInfo['main_lang_id'] != $main_lang_id)  
143 - || ($projectOptimize['company_en_name'] != $company_en_name) || ($projectOptimize['company_en_description'] != $company_en_description)){  
144 - $aiBlogService = new AiBlogService();  
145 - $aiBlogService->mch_id = $aiSettingInfo['mch_id'];  
146 - $aiBlogService->key = $aiSettingInfo['key'];  
147 - $aiBlogService->updatedProject($projectInfo['company']?:$projectInfo['title'],$languageInfo['short'],$company_en_description,$company_en_name,$is_related_video); 134 + if(!empty($data['daily_average_num'])){
  135 + $content2 .= '本周日均访客量:'.$data['daily_average_num'].'+。';
148 } 136 }
  137 + $content2 .= PHP_EOL.'全球搜建议用户持续分析、选择、添加企业、产品、服务等相关关键词进行优化和监控,以覆盖更多相关排名和流量;';
149 } 138 }
150 - return true;  
151 - }  
152 -  
153 - public function createAuthor($project_id,$mch_id,$key){  
154 - //查看当前项目是否已经创建了作者  
155 - $aiBlogTaskModel = new AiBlogTask();  
156 - $aiBlogService = new AiBlogService();  
157 - $aiBlogService->mch_id = $mch_id;  
158 - $aiBlogService->key = $key;  
159 - $result = $aiBlogService->createAuthor();  
160 - if($result['status'] == 200){  
161 - //查看当前是否已有未执行的  
162 - $aiBlogTaskModel->add(['project_id'=>$project_id,'status'=>1,'type'=>1]); 139 + if(!empty($content2)){
  140 + $arr[] = $content2;
  141 + }
  142 + $content3 = '';
  143 + if(!empty($data['product_num']) || !empty($data['news_num']) || !empty($data['week_product_num']) || !empty($data['week_news_num'])){
  144 + if(!empty($data['product_num']) || !empty($data['news_num'])){
  145 + $content3 .= '项目截止目前';
  146 + if(!empty($data['product_num'])){
  147 + $content3 .= '发布产品:'.$data['product_num'].'条,';
  148 + }
  149 + if(!empty($data['news_num'])){
  150 + $content3 .= '发布新闻:'.$data['news_num'].'条。';
  151 + }
  152 + }
  153 + if(!empty($data['week_product_num']) || !empty($data['week_news_num'])){
  154 + $content3 .= '本周新增';
  155 + if(!empty($data['week_product_num'])){
  156 + $content3 .= '产品:'.$data['week_product_num'].'条,';
  157 + }
  158 + if(!empty($data['week_news_num'])){
  159 + $content3 .= '新闻:'.$data['week_news_num'].'条。';
  160 + }
  161 + }
  162 + $content3 .= PHP_EOL.'全球搜建议用户保持网站内容的持续更新与完善,可参考谷歌关于创建实用、可靠、以用户为中心的内容的相关建议:https://developers.google.com/search/docs/fundamentals/creating-helpful-content?hl=zh-cn;';
  163 + }
  164 + if(!empty($content3)){
  165 + $arr[] = $content3;
  166 + }
  167 + $content4 = '';
  168 + if(!empty($data['main_update_num'])){
  169 + $content4 .= '网站加载速度维护及主站页面更新'.$data['main_update_num'].'次。';
  170 + }
  171 + if(!empty($data['aggregation_update_num'])){
  172 + $content4 .= '聚合页主站页面更新'.$data['aggregation_update_num'].'次。';
  173 + }
  174 + if(!empty($data['minor_update_num'])){
  175 + $content4 .= '小语种站页面更新'.$data['minor_update_num'].'次。';
  176 + }
  177 + if(!empty($data['aggregation_minor_update_num'])){
  178 + $content4 .= '聚合页小语种站页面'.$data['aggregation_minor_update_num'].'次。';
  179 + }
  180 + if(!empty($content4)){
  181 + $content4 = PHP_EOL.'本周主要优化工作包括:TDK、H标签、Img标签等优化设置排查与进一步完善,Sitemap更新与网页收录提交,外链新增与排查。'.$content4;
  182 + }
  183 + if(!empty($content4)){
  184 + $arr[] = $content4;
  185 + }
  186 + if(empty($arr)){
  187 + return true;
  188 + }
  189 + foreach ($arr as $key => $val){
  190 + $content .= ($key+1).','.$val.PHP_EOL.PHP_EOL;
  191 + }
  192 + $tomorrowNineAM = date('Y-m-d 09:00:00', time());
  193 + if(empty($content)){
  194 + return true;
163 } 195 }
  196 + $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和网站相关网页上同步发布视频;';
  197 + $message = "【全球搜V6.0周报】" . PHP_EOL . $content . PHP_EOL . $tips;
  198 + $param = [
  199 + 'project_id'=>$project_id,
  200 + 'friend_id'=>$friend_id,
  201 + 'type'=>MessagePush::TYPE_WEEK,
  202 + 'content'=> $message,
  203 + 'ref_ids'=>'',
  204 + 'send_time'=>$tomorrowNineAM,
  205 + 'status'=>0,
  206 + ];
  207 + //写入一条推送消息 自动消费
  208 + $messagePushModel = new MessagePush();
  209 + $messagePushModel->add($param);
164 return true; 210 return true;
165 } 211 }
166 } 212 }