作者 赵彬吉
@@ -102,10 +102,10 @@ class DomainInfo extends Command @@ -102,10 +102,10 @@ class DomainInfo extends Command
102 $domain_array = parse_url($v['domain']); 102 $domain_array = parse_url($v['domain']);
103 $host = $domain_array['host'] ?? $domain_array['path']; 103 $host = $domain_array['host'] ?? $domain_array['path'];
104 $host_array = explode('.', $host); 104 $host_array = explode('.', $host);
105 - if($host_array[0] == 'www'){ 105 + if (count($host_array) <= 2) {
  106 + array_unshift($host_array, 'm');
  107 + } else {
106 $host_array[0] = 'm'; 108 $host_array[0] = 'm';
107 - }else{  
108 - array_unshift($host_array,'m');  
109 } 109 }
110 $amp_domain = implode('.', $host_array); 110 $amp_domain = implode('.', $host_array);
111 111
@@ -192,10 +192,10 @@ class DomainInfo extends Command @@ -192,10 +192,10 @@ class DomainInfo extends Command
192 $domain_array = parse_url($v['domain']); 192 $domain_array = parse_url($v['domain']);
193 $host = $domain_array['host'] ?? $domain_array['path']; 193 $host = $domain_array['host'] ?? $domain_array['path'];
194 $host_array = explode('.', $host); 194 $host_array = explode('.', $host);
195 - if($host_array[0] == 'www'){ 195 + if (count($host_array) <= 2) {
  196 + array_unshift($host_array, 'm');
  197 + } else {
196 $host_array[0] = 'm'; 198 $host_array[0] = 'm';
197 - }else{  
198 - array_unshift($host_array,'m');  
199 } 199 }
200 $amp_domain = implode('.', $host_array); 200 $amp_domain = implode('.', $host_array);
201 201
@@ -135,7 +135,7 @@ class MonthAllCount extends Command @@ -135,7 +135,7 @@ class MonthAllCount extends Command
135 ->where('updated_date','>=',$start.' 00:00:00') 135 ->where('updated_date','>=',$start.' 00:00:00')
136 ->where('updated_date','<=',$end.' 23:59:59')->count(); 136 ->where('updated_date','<=',$end.' 23:59:59')->count();
137 if($arr['ip'] != 0){ 137 if($arr['ip'] != 0){
138 - $arr['rate'] = round((($arr['month_total'] ?? 0) / $arr['ip']) * 10,2); 138 + $arr['rate'] = round((($arr['month_total'] ?? 0) / $arr['ip']) * 100,2);
139 } 139 }
140 return $arr; 140 return $arr;
141 } 141 }
@@ -158,7 +158,7 @@ class MonthCount extends Command @@ -158,7 +158,7 @@ class MonthCount extends Command
158 ->where('updated_date','>=',$start.' 00:00:00') 158 ->where('updated_date','>=',$start.' 00:00:00')
159 ->where('updated_date','<=',$end.' 23:59:59')->count(); 159 ->where('updated_date','<=',$end.' 23:59:59')->count();
160 if($arr['ip'] != 0){ 160 if($arr['ip'] != 0){
161 - $arr['rate'] = round((($arr['month_total'] ?? 0) / $arr['ip']) * 10,2); 161 + $arr['rate'] = round((($arr['month_total'] ?? 0) / $arr['ip']) * 100,2);
162 } 162 }
163 return $arr; 163 return $arr;
164 } 164 }
@@ -159,7 +159,7 @@ class MonthCountDate extends Command @@ -159,7 +159,7 @@ class MonthCountDate extends Command
159 ->where('updated_date','>=',$start.' 00:00:00') 159 ->where('updated_date','>=',$start.' 00:00:00')
160 ->where('updated_date','<=',$end.' 23:59:59')->count(); 160 ->where('updated_date','<=',$end.' 23:59:59')->count();
161 if($arr['ip'] != 0){ 161 if($arr['ip'] != 0){
162 - $arr['rate'] = round((($arr['month_total'] ?? 0) / $arr['ip']) * 10,2); 162 + $arr['rate'] = round((($arr['month_total'] ?? 0) / $arr['ip']) * 100,2);
163 } 163 }
164 return $arr; 164 return $arr;
165 } 165 }
@@ -135,7 +135,7 @@ class MonthProjectCount extends Command @@ -135,7 +135,7 @@ class MonthProjectCount extends Command
135 ->where('updated_date','>=',$start.' 00:00:00') 135 ->where('updated_date','>=',$start.' 00:00:00')
136 ->where('updated_date','<=',$end.' 23:59:59')->count(); 136 ->where('updated_date','<=',$end.' 23:59:59')->count();
137 if($arr['ip'] != 0){ 137 if($arr['ip'] != 0){
138 - $arr['rate'] = round(($arr['month_total'] / $arr['ip']) * 10,2); 138 + $arr['rate'] = round(($arr['month_total'] / $arr['ip']) * 100,2);
139 } 139 }
140 return $arr; 140 return $arr;
141 } 141 }
@@ -43,7 +43,7 @@ class SendProduct extends Command @@ -43,7 +43,7 @@ class SendProduct extends Command
43 */ 43 */
44 public function handle(){ 44 public function handle(){
45 $projectModel = new Project(); 45 $projectModel = new Project();
46 - $list = $projectModel->list(['deleted_status'=>0]); 46 + $list = $projectModel->list(['delete_status'=>0]);
47 $data = []; 47 $data = [];
48 foreach ($list as $v){ 48 foreach ($list as $v){
49 echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL; 49 echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
@@ -56,16 +56,19 @@ class SendProduct extends Command @@ -56,16 +56,19 @@ class SendProduct extends Command
56 $arr1 = $this->sendProduct(); 56 $arr1 = $this->sendProduct();
57 $arr2 = $this->sendBlog(); 57 $arr2 = $this->sendBlog();
58 $arr3 = $this->sendNews(); 58 $arr3 = $this->sendNews();
59 - $c_url = $domain.'api/update_page/';  
60 - $param = [  
61 - 'project_id' => $this->user['project_id'],  
62 - 'type' => 1,  
63 - 'route' => 3,  
64 - 'url' => array_merge($arr1,$arr2,$arr3),  
65 - 'language'=> [],  
66 - 'is_sitemap' => 0  
67 - ];  
68 - http_post($c_url, json_encode($param)); 59 + $url = array_merge((array)$arr1,(array)$arr2,(array)$arr3);
  60 + if(!empty($url)){
  61 + $c_url = $domain.'api/update_page/';
  62 + $param = [
  63 + 'project_id' => $v['id'],
  64 + 'type' => 1,
  65 + 'route' => 3,
  66 + 'url' => $url,
  67 + 'language'=> [],
  68 + 'is_sitemap' => 0
  69 + ];
  70 + http_post($c_url, json_encode($param));
  71 + }
69 //TODO::通知C端生成界面 72 //TODO::通知C端生成界面
70 DB::disconnect('custom_mysql'); 73 DB::disconnect('custom_mysql');
71 } 74 }
@@ -80,10 +83,10 @@ class SendProduct extends Command @@ -80,10 +83,10 @@ class SendProduct extends Command
80 * @time :2024/8/30 14:44 83 * @time :2024/8/30 14:44
81 */ 84 */
82 public function sendProduct(){ 85 public function sendProduct(){
83 - $start_date = date('Y-m-d H:i:s'); 86 + $start_date = date('Y-m-d 00:00:00');
84 $end_date = date('Y-m-d 23:59:59'); 87 $end_date = date('Y-m-d 23:59:59');
85 $productModel = new Product(); 88 $productModel = new Product();
86 - $arr = $productModel->formatQuery(['send_time'=>['between',[$start_date,$end_date]],'status'=>3])->pluck('route'); 89 + $arr = $productModel->formatQuery(['send_time'=>['between',[$start_date,$end_date]],'status'=>3])->pluck('route')->toArray();
87 $productModel->edit(['status'=>1],['send_time'=>['between',[$start_date,$end_date]],'status'=>3]); 90 $productModel->edit(['status'=>1],['send_time'=>['between',[$start_date,$end_date]],'status'=>3]);
88 return $arr; 91 return $arr;
89 } 92 }
@@ -96,10 +99,10 @@ class SendProduct extends Command @@ -96,10 +99,10 @@ class SendProduct extends Command
96 * @time :2024/8/30 15:19 99 * @time :2024/8/30 15:19
97 */ 100 */
98 public function sendBlog(){ 101 public function sendBlog(){
99 - $start_date = date('Y-m-d H:i:s'); 102 + $start_date = date('Y-m-d 00:00:00');
100 $end_date = date('Y-m-d 23:59:59'); 103 $end_date = date('Y-m-d 23:59:59');
101 $blogModel = new Blog(); 104 $blogModel = new Blog();
102 - $arr = $blogModel->formatQuery(['release_at'=>['between',[$start_date,$end_date]],'status'=>3])->pluck('url'); 105 + $arr = $blogModel->formatQuery(['release_at'=>['between',[$start_date,$end_date]],'status'=>3])->pluck('url')->toArray();
103 $blogModel->edit(['status'=>1],['release_at'=>['between',[$start_date,$end_date]],'status'=>3]); 106 $blogModel->edit(['status'=>1],['release_at'=>['between',[$start_date,$end_date]],'status'=>3]);
104 return $arr; 107 return $arr;
105 } 108 }
@@ -112,10 +115,10 @@ class SendProduct extends Command @@ -112,10 +115,10 @@ class SendProduct extends Command
112 * @time :2024/8/30 15:19 115 * @time :2024/8/30 15:19
113 */ 116 */
114 public function sendNews(){ 117 public function sendNews(){
115 - $start_date = date('Y-m-d H:i:s'); 118 + $start_date = date('Y-m-d 00:00:00');
116 $end_date = date('Y-m-d 23:59:59'); 119 $end_date = date('Y-m-d 23:59:59');
117 $newsModel = new News(); 120 $newsModel = new News();
118 - $arr = $newsModel->formatQuery(['release_at'=>['between',[$start_date,$end_date]],'status'=>3])->pluck('url'); 121 + $arr = $newsModel->formatQuery(['release_at'=>['between',[$start_date,$end_date]],'status'=>3])->pluck('url')->toArray();
119 $newsModel->edit(['status'=>1],['release_at'=>['between',[$start_date,$end_date]],'status'=>3]); 122 $newsModel->edit(['status'=>1],['release_at'=>['between',[$start_date,$end_date]],'status'=>3]);
120 return $arr; 123 return $arr;
121 } 124 }
1 <?php 1 <?php
  2 +/**
  3 + * @remark :
  4 + * @name :CopyProject.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2025/1/15 14:40
  8 + */
2 9
3 -namespace App\Jobs; 10 +namespace App\Console\Commands\Project;
4 11
5 -use App\Events\CopyProject;  
6 -use App\Events\UpdateHtml;  
7 -use App\Jobs\updateHtmlJob; 12 +use App\Models\Com\NoticeLog;
8 use App\Models\Project\After; 13 use App\Models\Project\After;
9 use App\Models\Project\DeployBuild; 14 use App\Models\Project\DeployBuild;
10 use App\Models\Project\DeployOptimize; 15 use App\Models\Project\DeployOptimize;
@@ -14,130 +19,191 @@ use App\Models\Template\Setting; @@ -14,130 +19,191 @@ use App\Models\Template\Setting;
14 use App\Models\User\User as UserModel; 19 use App\Models\User\User as UserModel;
15 use App\Services\ProjectServer; 20 use App\Services\ProjectServer;
16 use Hashids\Hashids; 21 use Hashids\Hashids;
17 -use Illuminate\Bus\Queueable;  
18 -use Illuminate\Contracts\Queue\ShouldQueue;  
19 -use Illuminate\Foundation\Bus\Dispatchable;  
20 -use Illuminate\Queue\InteractsWithQueue;  
21 -use Illuminate\Queue\SerializesModels; 22 +use Illuminate\Console\Command;
22 use Illuminate\Support\Facades\DB; 23 use Illuminate\Support\Facades\DB;
23 use Illuminate\Support\Facades\Log; 24 use Illuminate\Support\Facades\Log;
24 use Illuminate\Support\Facades\Schema; 25 use Illuminate\Support\Facades\Schema;
25 26
26 -class CopyProjectJob implements ShouldQueue 27 +class CopyProject extends Command
27 { 28 {
28 - use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;  
29 - public $tries = 3; // 可配置任务重试次数  
30 -  
31 - protected $param;  
32 -  
33 /** 29 /**
34 - * Create a new job instance. 30 + * The name and signature of the console command.
35 * 31 *
36 - * @param CopyImageFile $event  
37 - * @return void 32 + * @var string
38 */ 33 */
39 - public function __construct($data)  
40 - {  
41 - $this->param = $data;  
42 - }  
43 - 34 + protected $signature = 'copy_project';
44 35
45 /** 36 /**
46 - * Handle the event. 37 + * The console command description.
47 * 38 *
48 - * @param UpdateHtml $event  
49 - * @return void 39 + * @var string
50 */ 40 */
  41 + protected $description = 'copy--复制项目';
  42 +
51 public function handle() 43 public function handle()
52 { 44 {
53 $projectModel = new Project(); 45 $projectModel = new Project();
54 - DB::beginTransaction();  
55 - try {  
56 - $this->output('CopyProjectJob start, project_id: ' . $this->param['project_id']);  
57 - //复制初始项目  
58 - $data = $projectModel::where('id', $this->param['project_id'])->first();  
59 - $data = $data->getAttributes();  
60 - $type = $data['type'];  
61 - $data['type'] = 0;  
62 - $data['status'] = 0;  
63 - $data['finish_remain_day'] = 0;  
64 - $data['title'] = $data['title'].'-copy';  
65 - $data['delete_status'] = 1;  
66 - unset($data['id'],$data['robots'],$data['is_translate_tag'],$data['is_translate'],$data['is_minor_languages'],$data['uptime']);  
67 - $project_id = $projectModel->insertGetId($data);  
68 - $hashids = new Hashids($data['from_order_id'], 13, 'abcdefghjkmnpqrstuvwxyz1234567890');  
69 - $projectModel->edit(['from_order_id'=>$hashids->encode($project_id)],['id'=>$project_id]);  
70 - //复制设置的模版  
71 - $settingTemplateModel = new Setting();  
72 - $settingData = $settingTemplateModel::where('project_id', $this->param['project_id'])->first();  
73 - if(!empty($settingData)){  
74 - $data = [  
75 - 'template_id' =>$settingData['template_id'],  
76 - 'project_id' => $project_id  
77 - ];  
78 - $settingTemplateModel->add($data);  
79 - }  
80 - //复制部署表  
81 - $buildModel = new DeployBuild();  
82 - $buildData = $buildModel::where('project_id', $this->param['project_id'])->first();  
83 - if(!empty($buildData)){  
84 - $buildData = $buildData->getAttributes();  
85 - $buildData['project_id'] = $project_id;  
86 - $hashids = new Hashids('test_domain', 5, 'abcdefghjkmnpqrstuvwxyz1234567890');  
87 - $code = $hashids->encode($project_id);  
88 - $buildData['test_domain'] = 'https://v6-' . $code . '.globalso.site/';  
89 - unset($buildData['id']);  
90 - $buildModel->insert($buildData);  
91 - }  
92 - //复制优化表  
93 - $optimizeModel = new DeployOptimize();  
94 - $optimizeData = $optimizeModel::where('project_id', $this->param['project_id'])->first();  
95 - if(!empty($optimizeData)){  
96 - $optimizeData = $optimizeData->getAttributes();  
97 - unset($optimizeData['id'],$optimizeData['domain'],$optimizeData['backlink'],$optimizeData['ai_video']);  
98 - $optimizeData['project_id'] = $project_id;  
99 - $optimizeData['api_no'] = 0;  
100 - $optimizeModel->insert($optimizeData);  
101 - }  
102 - //复制付费表  
103 - $paymentModel = new Payment();  
104 - $paymentData = $paymentModel::where('project_id', $this->param['project_id'])->first();  
105 - if(!empty($paymentData)){  
106 - $paymentData = $paymentData->getAttributes();  
107 - unset($paymentData['id']);  
108 - $paymentData['project_id'] = $project_id;  
109 - $paymentModel->insert($paymentData);  
110 - }  
111 - //复制售后表  
112 - $afterModel = new After();  
113 - $afterData = $afterModel::where('project_id', $this->param['project_id'])->first();  
114 - if(!empty($afterData)){  
115 - $afterData = $afterData->getAttributes();  
116 - unset($afterData['id']);  
117 - $afterData['project_id'] = $project_id;  
118 - $afterModel->insert($afterData); 46 + while (true) {
  47 + $list = NoticeLog::where('type', NoticeLog::TYPE_COPY_PROJECT)->where('status', NoticeLog::STATUS_PENDING)->get();
  48 + if(empty($list)){
  49 + sleep(5);
  50 + continue;
119 } 51 }
120 - //复制用户  
121 - $userModel = new UserModel();  
122 - $userData = $userModel::where('project_id', $this->param['project_id'])->where('role_id',0)->first();  
123 - if(!empty($userData)){  
124 - $userData = $userData->getAttributes();  
125 - unset($userData['id']);  
126 - $userData['project_id'] = $project_id;  
127 - $userModel->insert($userData); 52 + foreach ($list as $item){
  53 + DB::beginTransaction();
  54 + try {
  55 + $old_project_id = $item['data']['project_id'];
  56 + $this->output('CopyProjectJob start, project_id: ' . $old_project_id);
  57 + $data = $this->copyProject($old_project_id);
  58 + $project_id = $data['project_id'];
  59 + $type = $data['type'];
  60 + $this->copyDeployBuild($old_project_id,$project_id);
  61 + $this->copyDeployOptimize($old_project_id,$project_id);
  62 + $this->copyPayment($old_project_id,$project_id);
  63 + $this->copyAfter($old_project_id,$project_id);
  64 + $this->copyUser($old_project_id,$project_id);
  65 + if($type != 0){
  66 + $this->copyMysql($old_project_id,$project_id);
  67 + }
  68 + //修改项目状态
  69 + $projectModel->edit(['delete_status'=>0],['id'=>$project_id]);
  70 + $this->output('CopyProjectJob end, old project_id: ' . $old_project_id . ', new project_id: ' . $project_id);
  71 + $item->status = NoticeLog::STATUS_SUCCESS;
  72 + $item->save();
  73 + DB::commit();
  74 + }catch (\Exception $e){
  75 + DB::rollBack();
  76 + echo 'error:' . $item['id'] . $e->getMessage() . PHP_EOL . date('Y-m-d H:i:s');
  77 + errorLog('项目初始化失败', $item, $e);
  78 + $item->status = NoticeLog::STATUS_FAIL;
  79 + $item->save();
  80 + }
128 } 81 }
129 - DB::commit();  
130 - }catch (\Exception $e){  
131 - DB::rollBack();  
132 - $this->output('CopyProjectJob error, error message: ' . $e->getMessage());  
133 - $this->fail('error');  
134 } 82 }
135 - if($type != 0){  
136 - $this->copyMysql($this->param['project_id'],$project_id); 83 + return true;
  84 + }
  85 +
  86 + public function copyProject($old_project_id){
  87 + $projectModel = new Project();
  88 + $data = $projectModel::where('id', $old_project_id)->first();
  89 + $data = $data->getAttributes();
  90 + $type = $data['type'];
  91 + $data['type'] = 0;
  92 + $data['status'] = 0;
  93 + $data['finish_remain_day'] = 0;
  94 + $data['title'] = $data['title'].'-copy';
  95 + $data['delete_status'] = 1;
  96 + unset($data['id'],$data['robots'],$data['is_translate_tag'],$data['is_translate'],$data['is_minor_languages'],$data['uptime']);
  97 + $project_id = $projectModel->insertGetId($data);
  98 + $hashids = new Hashids($data['from_order_id'], 13, 'abcdefghjkmnpqrstuvwxyz1234567890');
  99 + $projectModel->edit(['from_order_id'=>$hashids->encode($project_id)],['id'=>$project_id]);
  100 + //复制设置的模版
  101 + $settingTemplateModel = new Setting();
  102 + $settingData = $settingTemplateModel::where('project_id', $old_project_id)->first();
  103 + if(!empty($settingData)){
  104 + $data = [
  105 + 'template_id' =>$settingData['template_id'],
  106 + 'project_id' => $project_id
  107 + ];
  108 + $settingTemplateModel->add($data);
  109 + }
  110 + return ['project_id'=>$project_id,'type'=>$type];
  111 + }
  112 +
  113 + /**
  114 + * @remark :复制部署表
  115 + * @name :copyDeployBuild
  116 + * @author :lyh
  117 + * @method :post
  118 + * @time :2025/1/15 14:59
  119 + */
  120 + public function copyDeployBuild($old_project_id,$project_id){
  121 + //复制部署表
  122 + $buildModel = new DeployBuild();
  123 + $buildData = $buildModel::where('project_id', $old_project_id)->first();
  124 + if(!empty($buildData)){
  125 + $buildData = $buildData->getAttributes();
  126 + $buildData['project_id'] = $project_id;
  127 + $hashids = new Hashids('test_domain', 5, 'abcdefghjkmnpqrstuvwxyz1234567890');
  128 + $code = $hashids->encode($project_id);
  129 + $buildData['test_domain'] = 'https://v6-' . $code . '.globalso.site/';
  130 + unset($buildData['id']);
  131 + $buildModel->insert($buildData);
  132 + }
  133 + return true;
  134 + }
  135 +
  136 + /**
  137 + * @remark :复制优化表
  138 + * @name :copyDeployOptimize
  139 + * @author :lyh
  140 + * @method :post
  141 + * @time :2025/1/15 15:02
  142 + */
  143 + public function copyDeployOptimize($old_project_id,$project_id){
  144 + //复制优化表
  145 + $optimizeModel = new DeployOptimize();
  146 + $optimizeData = $optimizeModel::where('project_id', $old_project_id)->first();
  147 + if(!empty($optimizeData)){
  148 + $optimizeData = $optimizeData->getAttributes();
  149 + unset($optimizeData['id'],$optimizeData['domain'],$optimizeData['backlink'],$optimizeData['ai_video']);
  150 + $optimizeData['project_id'] = $project_id;
  151 + $optimizeData['api_no'] = 0;
  152 + $optimizeModel->insert($optimizeData);
  153 + }
  154 + return true;
  155 + }
  156 +
  157 + /**
  158 + * @remark :复制付费表
  159 + * @name :copyPayment
  160 + * @author :lyh
  161 + * @method :post
  162 + * @time :2025/1/15 15:03
  163 + */
  164 + public function copyPayment($old_project_id,$project_id){
  165 + //复制付费表
  166 + $paymentModel = new Payment();
  167 + $paymentData = $paymentModel::where('project_id', $old_project_id)->first();
  168 + if(!empty($paymentData)){
  169 + $paymentData = $paymentData->getAttributes();
  170 + unset($paymentData['id']);
  171 + $paymentData['project_id'] = $project_id;
  172 + $paymentModel->insert($paymentData);
  173 + }
  174 + return true;
  175 + }
  176 +
  177 + public function copyAfter($old_project_id,$project_id){
  178 + //复制售后表
  179 + $afterModel = new After();
  180 + $afterData = $afterModel::where('project_id',$old_project_id)->first();
  181 + if(!empty($afterData)){
  182 + $afterData = $afterData->getAttributes();
  183 + unset($afterData['id']);
  184 + $afterData['project_id'] = $project_id;
  185 + $afterModel->insert($afterData);
  186 + }
  187 + return true;
  188 + }
  189 +
  190 + /**
  191 + * @remark :复制user
  192 + * @name :copyUser
  193 + * @author :lyh
  194 + * @method :post
  195 + * @time :2025/1/15 15:04
  196 + */
  197 + public function copyUser($old_project_id,$project_id){
  198 + //复制用户
  199 + $userModel = new UserModel();
  200 + $userData = $userModel::where('project_id', $old_project_id)->where('role_id',0)->first();
  201 + if(!empty($userData)){
  202 + $userData = $userData->getAttributes();
  203 + unset($userData['id']);
  204 + $userData['project_id'] = $project_id;
  205 + $userModel->insert($userData);
137 } 206 }
138 - //修改项目状态  
139 - $projectModel->edit(['delete_status'=>0],['id'=>$project_id]);  
140 - $this->output('CopyProjectJob end, old project_id: ' . $this->param['project_id'] . ', new project_id: ' . $project_id);  
141 return true; 207 return true;
142 } 208 }
143 209
@@ -200,4 +266,5 @@ class CopyProjectJob implements ShouldQueue @@ -200,4 +266,5 @@ class CopyProjectJob implements ShouldQueue
200 Log::info($output); 266 Log::info($output);
201 return true; 267 return true;
202 } 268 }
  269 +
203 } 270 }
@@ -33,7 +33,7 @@ class Temp extends Command @@ -33,7 +33,7 @@ class Temp extends Command
33 33
34 public function handle() 34 public function handle()
35 { 35 {
36 - $this->create_all_amp_notify(); 36 +
37 } 37 }
38 38
39 /** 39 /**
@@ -437,10 +437,10 @@ class Temp extends Command @@ -437,10 +437,10 @@ class Temp extends Command
437 $domain_array = parse_url($domain); 437 $domain_array = parse_url($domain);
438 $host = $domain_array['host'] ?? $domain_array['path']; 438 $host = $domain_array['host'] ?? $domain_array['path'];
439 $host_array = explode('.', $host); 439 $host_array = explode('.', $host);
440 - if ($host_array[0] == 'www') {  
441 - $host_array[0] = 'm';  
442 - } else { 440 + if (count($host_array) <= 2) {
443 array_unshift($host_array, 'm'); 441 array_unshift($host_array, 'm');
  442 + } else {
  443 + $host_array[0] = 'm';
444 } 444 }
445 $amp_domain = implode('.', $host_array); 445 $amp_domain = implode('.', $host_array);
446 446
@@ -258,10 +258,14 @@ class ProjectController extends BaseController @@ -258,10 +258,14 @@ class ProjectController extends BaseController
258 */ 258 */
259 public function searchDept(&$query){ 259 public function searchDept(&$query){
260 if(!empty($this->map['dept_id'])){ 260 if(!empty($this->map['dept_id'])){
261 - $query->where(function ($subQuery) {  
262 - $subQuery->orwhere('gl_project_deploy_build.dept_id',$this->map['dept_id'])  
263 - ->orwhere('gl_project_deploy_optimize.dept_id',$this->map['dept_id']);  
264 - }); 261 + if($this->map['dept_id'] == 7 || $this->map['dept_id'] == 9){//7,9代表合并组H+F组
  262 + $query->whereIn('gl_project_deploy_build.dept_id', [7,9]);
  263 + }else{
  264 + $query->where(function ($subQuery) {
  265 + $subQuery->orwhere('gl_project_deploy_build.dept_id',$this->map['dept_id'])
  266 + ->orwhere('gl_project_deploy_optimize.dept_id',$this->map['dept_id']);
  267 + });
  268 + }
265 } 269 }
266 return $query; 270 return $query;
267 } 271 }
@@ -310,8 +314,8 @@ class ProjectController extends BaseController @@ -310,8 +314,8 @@ class ProjectController extends BaseController
310 $info = $managerHr->read(['manage_id'=>$this->manage['id']]); 314 $info = $managerHr->read(['manage_id'=>$this->manage['id']]);
311 //获取当前用户自己的项目 315 //获取当前用户自己的项目
312 $query->where(function ($subQuery) use ($info) { 316 $query->where(function ($subQuery) use ($info) {
313 - $subQuery->whereIn('gl_project.id',[1])//项目1+项目3默认显示  
314 - ->orWhere('gl_project_deploy_build.leader_mid', $info['id']) 317 + $subQuery->whereIn('gl_project.id', [1]) // 项目1 + 项目3默认显示
  318 + ->orWhere('gl_project_deploy_build.leader_mid', $info['id'])
315 ->orWhere('gl_project_deploy_build.manager_mid', $info['id']) 319 ->orWhere('gl_project_deploy_build.manager_mid', $info['id'])
316 ->orWhere('gl_project_deploy_build.designer_mid', $info['id']) 320 ->orWhere('gl_project_deploy_build.designer_mid', $info['id'])
317 ->orWhere('gl_project_deploy_build.tech_mid', $info['id']) 321 ->orWhere('gl_project_deploy_build.tech_mid', $info['id'])
@@ -321,9 +325,18 @@ class ProjectController extends BaseController @@ -321,9 +325,18 @@ class ProjectController extends BaseController
321 ->orWhere('gl_project_deploy_optimize.tech_mid', $info['id']) 325 ->orWhere('gl_project_deploy_optimize.tech_mid', $info['id'])
322 ->orWhere('gl_project_deploy_optimize.tech_leader', $info['id']) 326 ->orWhere('gl_project_deploy_optimize.tech_leader', $info['id'])
323 ->orWhere('gl_project_deploy_optimize.quality_mid', $info['id']) 327 ->orWhere('gl_project_deploy_optimize.quality_mid', $info['id'])
324 - ->orWhere('gl_project_deploy_optimize.design_mid', $info['id'])  
325 - ->orWhere('gl_project_deploy_build.dept_id', $info['belong_group'])  
326 - ->orWhere('gl_project_deploy_optimize.dept_id', $info['belong_group']); 328 + ->orWhere('gl_project_deploy_optimize.design_mid', $info['id']);
  329 + // 处理 dept_id 条件
  330 + if (in_array($info['belong_group'], [7, 9])) {
  331 + // 7, 9 代表合并组 H + F 组
  332 + $subQuery->orWhere(function ($innerQuery) {
  333 + $innerQuery->where('gl_project_deploy_build.dept_id', 7)
  334 + ->orWhere('gl_project_deploy_build.dept_id', 9);
  335 + });
  336 + } else {
  337 + $subQuery->orWhere('gl_project_deploy_build.dept_id', $info['belong_group'])
  338 + ->orWhere('gl_project_deploy_optimize.dept_id', $info['belong_group']);
  339 + }
327 }); 340 });
328 } 341 }
329 return $query; 342 return $query;
@@ -62,7 +62,11 @@ class RenewProjectController extends BaseController @@ -62,7 +62,11 @@ class RenewProjectController extends BaseController
62 } 62 }
63 //按类型搜索 63 //按类型搜索
64 $map['delete_status'] = 0; 64 $map['delete_status'] = 0;
65 - $map['type'] = ['in',[2,3,4]]; 65 + if(empty($param['type'])){
  66 + $map['type'] = ['in',[2,3,4]];
  67 + }else{
  68 + $map['type'] = $param['type'];
  69 + }
66 $map['remain_day'] = ['<=',15]; 70 $map['remain_day'] = ['<=',15];
67 return $map; 71 return $map;
68 } 72 }
@@ -67,7 +67,7 @@ class CNoticeController extends BaseController @@ -67,7 +67,7 @@ class CNoticeController extends BaseController
67 } 67 }
68 $lang_num = count($this->param['language']); 68 $lang_num = count($this->param['language']);
69 $keyword_num = (new Keyword())->counts(['route'=>['!=',null]]); 69 $keyword_num = (new Keyword())->counts(['route'=>['!=',null]]);
70 - $data_num = $this->productNum() + $this->CustomNum() + $this->newsNum() + $this->blogNum(); 70 + $data_num = $this->productNum() + $this->customNum() + $this->newsNum() + $this->blogNum();
71 $number = $keyword_num * 18 + $lang_num * $data_num; 71 $number = $keyword_num * 18 + $lang_num * $data_num;
72 if($number >= 450000){ 72 if($number >= 450000){
73 $this->response('success',Code::SUCCESS,['msg'=>'翻译数量过多, 大概页面数量:'.$number.', 磁盘空间占用可能会超过40G,请联系管理员操作!']); 73 $this->response('success',Code::SUCCESS,['msg'=>'翻译数量过多, 大概页面数量:'.$number.', 磁盘空间占用可能会超过40G,请联系管理员操作!']);
@@ -179,7 +179,7 @@ class CNoticeController extends BaseController @@ -179,7 +179,7 @@ class CNoticeController extends BaseController
179 * @method :post 179 * @method :post
180 * @time :2025/1/4 11:21 180 * @time :2025/1/4 11:21
181 */ 181 */
182 - public function CustomNum(){ 182 + public function customNum(){
183 $contentModel = new CustomModuleContent(); 183 $contentModel = new CustomModuleContent();
184 $number = $contentModel->counts(['status'=>0]); 184 $number = $contentModel->counts(['status'=>0]);
185 $settingModel = new SettingNum(); 185 $settingModel = new SettingNum();
@@ -263,10 +263,10 @@ class CNoticeController extends BaseController @@ -263,10 +263,10 @@ class CNoticeController extends BaseController
263 $domain_array = parse_url($domain); 263 $domain_array = parse_url($domain);
264 $host = $domain_array['host'] ?? $domain_array['path']; 264 $host = $domain_array['host'] ?? $domain_array['path'];
265 $host_array = explode('.',$host); 265 $host_array = explode('.',$host);
266 - if($host_array[0] == 'www'){ 266 + if (count($host_array) <= 2) {
  267 + array_unshift($host_array, 'm');
  268 + } else {
267 $host_array[0] = 'm'; 269 $host_array[0] = 'm';
268 - }else{  
269 - array_unshift($host_array,'m');  
270 } 270 }
271 $domain = implode('.',$host_array); 271 $domain = implode('.',$host_array);
272 } 272 }
@@ -50,7 +50,8 @@ class ExtensionModuleController extends BaseController @@ -50,7 +50,8 @@ class ExtensionModuleController extends BaseController
50 '4'=>'文件框', 50 '4'=>'文件框',
51 '5'=>'下拉框', 51 '5'=>'下拉框',
52 '6'=>'自动生成订单框', 52 '6'=>'自动生成订单框',
53 - '7'=>'创建时间' 53 + '7'=>'创建时间',
  54 + '8'=>'多级联动框'
54 ]; 55 ];
55 $this->response('success',Code::SUCCESS,$data); 56 $this->response('success',Code::SUCCESS,$data);
56 } 57 }
@@ -78,10 +79,10 @@ class ExtensionModuleController extends BaseController @@ -78,10 +79,10 @@ class ExtensionModuleController extends BaseController
78 if($info !== false){ 79 if($info !== false){
79 $v['is_use'] = 1; 80 $v['is_use'] = 1;
80 } 81 }
81 - $list[$k] = $v;  
82 if(!empty($v['data'])){ 82 if(!empty($v['data'])){
83 $v['data'] = json_decode($v['data'],true); 83 $v['data'] = json_decode($v['data'],true);
84 } 84 }
  85 + $list[$k] = $v;
85 } 86 }
86 $this->response('success',Code::SUCCESS,$list); 87 $this->response('success',Code::SUCCESS,$list);
87 } 88 }
@@ -193,10 +193,10 @@ class DomainInfoLogic extends BaseLogic @@ -193,10 +193,10 @@ class DomainInfoLogic extends BaseLogic
193 $domain_array = parse_url($info['domain']); 193 $domain_array = parse_url($info['domain']);
194 $host = $domain_array['host'] ?? $domain_array['path']; 194 $host = $domain_array['host'] ?? $domain_array['path'];
195 $host_array = explode('.',$host); 195 $host_array = explode('.',$host);
196 - if($host_array[0] == 'www'){ 196 + if (count($host_array) <= 2) {
  197 + array_unshift($host_array, 'm');
  198 + } else {
197 $host_array[0] = 'm'; 199 $host_array[0] = 'm';
198 - }else{  
199 - array_unshift($host_array,'m');  
200 } 200 }
201 $amp_domain = implode('.',$host_array); 201 $amp_domain = implode('.',$host_array);
202 if(!check_domain_record($amp_domain, $serversIpInfo)){ 202 if(!check_domain_record($amp_domain, $serversIpInfo)){
@@ -102,6 +102,7 @@ class ProjectLogic extends BaseLogic @@ -102,6 +102,7 @@ class ProjectLogic extends BaseLogic
102 $info['minor_languages'] = $this->getProjectMinorLanguages($id); 102 $info['minor_languages'] = $this->getProjectMinorLanguages($id);
103 //升级项目采集完成时间 103 //升级项目采集完成时间
104 $info['collect_time'] = $info['is_upgrade'] ? UpdateLog::getProjectUpdate($id) : ''; 104 $info['collect_time'] = $info['is_upgrade'] ? UpdateLog::getProjectUpdate($id) : '';
  105 +
105 return $this->success($info); 106 return $this->success($info);
106 } 107 }
107 108
@@ -754,7 +755,7 @@ class ProjectLogic extends BaseLogic @@ -754,7 +755,7 @@ class ProjectLogic extends BaseLogic
754 * @time :2023/11/8 14:23 755 * @time :2023/11/8 14:23
755 */ 756 */
756 public function copyProject(){ 757 public function copyProject(){
757 - CopyProjectJob::dispatch(['project_id'=>$this->param['project_id']]); 758 + NoticeLog::createLog(NoticeLog::TYPE_COPY_PROJECT, ['project_id' => $this->param['project_id']]);
758 return $this->success('项目复制中,请稍后前往初始化项目查看;'); 759 return $this->success('项目复制中,请稍后前往初始化项目查看;');
759 } 760 }
760 761
@@ -785,7 +786,9 @@ class ProjectLogic extends BaseLogic @@ -785,7 +786,9 @@ class ProjectLogic extends BaseLogic
785 public function saveOtherProject(){ 786 public function saveOtherProject(){
786 //获取当前数据详情 787 //获取当前数据详情
787 $projectInfo = $this->getProjectInfo($this->param['id']); 788 $projectInfo = $this->getProjectInfo($this->param['id']);
788 - //aicc if (($projectInfo['aicc'] == Project::TYPE_ZERO) && ($this->param['aicc'] == Project::TYPE_ONE)) 从关闭到开启状态才同步, 改成只要是开启状态就同步 789 + if(($projectInfo['created_at'] >= '2014-12-01 00:00:00')){//12月1号过后默认不开启
  790 + $this->param['aicc'] = Project::TYPE_ZERO;
  791 + }
789 if($this->param['aicc'] == Project::TYPE_ONE && !empty($this->param['exclusive_aicc_day'])){ 792 if($this->param['aicc'] == Project::TYPE_ONE && !empty($this->param['exclusive_aicc_day'])){
790 $data = [ 793 $data = [
791 'company_name'=>$projectInfo['company'], 794 'company_name'=>$projectInfo['company'],
@@ -426,6 +426,8 @@ class ProductLogic extends BaseLogic @@ -426,6 +426,8 @@ class ProductLogic extends BaseLogic
426 public function productDelete(){ 426 public function productDelete(){
427 DB::connection('custom_mysql')->beginTransaction(); 427 DB::connection('custom_mysql')->beginTransaction();
428 try { 428 try {
  429 + $columnModel = new Column();
  430 + $detailModel = new Detail();
429 $cateRelate = new CategoryRelated(); 431 $cateRelate = new CategoryRelated();
430 //删除扩展字段 432 //删除扩展字段
431 $extendInfoModel = new ExtendInfo(); 433 $extendInfoModel = new ExtendInfo();
@@ -441,6 +443,9 @@ class ProductLogic extends BaseLogic @@ -441,6 +443,9 @@ class ProductLogic extends BaseLogic
441 //删除关联表 443 //删除关联表
442 $cateRelate->del(['product_id'=>$id]); 444 $cateRelate->del(['product_id'=>$id]);
443 $extendInfoModel->del(['product_id'=>$id]); 445 $extendInfoModel->del(['product_id'=>$id]);
  446 + //删除描述
  447 + $columnModel->del(['product_id'=>$id]);
  448 + $detailModel->del(['product_id'=>$id]);
444 }else{ 449 }else{
445 $this->delRoute($id); 450 $this->delRoute($id);
446 //回收站 451 //回收站
@@ -692,7 +697,7 @@ class ProductLogic extends BaseLogic @@ -692,7 +697,7 @@ class ProductLogic extends BaseLogic
692 'attrs'=>Arr::a2s($info['attrs']), 697 'attrs'=>Arr::a2s($info['attrs']),
693 'attr_id'=>Arr::arrToSet($info['attr_id']), 698 'attr_id'=>Arr::arrToSet($info['attr_id']),
694 'category_id'=>!empty($info['category_id']) ? ','.Arr::arrToSet($info['category_id']).',' : '', 699 'category_id'=>!empty($info['category_id']) ? ','.Arr::arrToSet($info['category_id']).',' : '',
695 - 'keyword_id'=>'', 700 + 'keyword_id'=> '',
696 'intro'=>$info['intro'], 701 'intro'=>$info['intro'],
697 'content'=>$info['content'], 702 'content'=>$info['content'],
698 'describe'=>Arr::a2s($info['describe']), 703 'describe'=>Arr::a2s($info['describe']),
@@ -973,31 +978,41 @@ class ProductLogic extends BaseLogic @@ -973,31 +978,41 @@ class ProductLogic extends BaseLogic
973 } 978 }
974 //处理描述切换栏 979 //处理描述切换栏
975 $describe = []; 980 $describe = [];
976 - for ($i=11;$i<=20;$i+=2){  
977 - if(($data[$i]??'') && ($data[$i+1]??'')){  
978 - preg_match_all('/<img\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $data[$i+1], $result_desc);  
979 - if($result_desc[2]??[]){  
980 - foreach ($result_desc[2] as $vdesc_img){  
981 - $new_vdesc_img = check_remote_url_down($vdesc_img,$project_id,$domain,1);  
982 - $new_vdesc_img && $data[$i+1] = str_replace($vdesc_img,$new_vdesc_img,$data[$i+1]); 981 + if($data[11]??''){
  982 + $attr_desc = json_decode($data[11],true);
  983 + if(is_array($attr_desc)){
  984 + foreach ($attr_desc as $vd){
  985 + $desc_title = $vd['title'];
  986 + if(empty($desc_title)){
  987 + continue;
983 } 988 }
984 - }  
985 - preg_match_all('/<source\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $data[$i+1], $result_desc_video);  
986 - if($result_desc_video[2]??[]){  
987 - foreach ($result_desc_video[2] as $vdesc_video){  
988 - $new_vdesc_video = check_remote_url_down($vdesc_video,$project_id,$domain,1);  
989 - $new_vdesc_video && $data[$i+1] = str_replace($vdesc_video,$new_vdesc_video,$data[$i+1]); 989 +
  990 + $desc_text = $vd['text'];
  991 + if($desc_text){
  992 + preg_match_all('/<img\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $desc_text, $result_desc);
  993 + if($result_desc[2]??[]){
  994 + foreach ($result_desc[2] as $vdesc_img){
  995 + $new_vdesc_img = check_remote_url_down($vdesc_img,$project_id,$domain,1);
  996 + $new_vdesc_img && $desc_text = str_replace($vdesc_img,$new_vdesc_img,$desc_text);
  997 + }
  998 + }
  999 + preg_match_all('/<source\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $desc_text, $result_desc_video);
  1000 + if($result_desc_video[2]??[]){
  1001 + foreach ($result_desc_video[2] as $vdesc_video){
  1002 + $new_vdesc_video = check_remote_url_down($vdesc_video,$project_id,$domain,1);
  1003 + $new_vdesc_video && $desc_text = str_replace($vdesc_video,$new_vdesc_video,$desc_text);
  1004 + }
  1005 + }
990 } 1006 }
991 - }  
992 1007
993 - $describe[] = [  
994 - 'title' => $data[$i],  
995 - 'text' => $data[$i+1],  
996 - ];  
997 - }else{  
998 - break; 1008 + $describe[] = [
  1009 + 'title' => $desc_title,
  1010 + 'text' => $desc_text
  1011 + ];
  1012 + }
999 } 1013 }
1000 } 1014 }
  1015 +
1001 $id = $this->model->addReturnId( 1016 $id = $this->model->addReturnId(
1002 [ 1017 [
1003 'project_id' => $project_id, 1018 'project_id' => $project_id,
@@ -1062,8 +1077,8 @@ class ProductLogic extends BaseLogic @@ -1062,8 +1077,8 @@ class ProductLogic extends BaseLogic
1062 $cModel = new Column(); 1077 $cModel = new Column();
1063 $c_id = $cModel->addReturnId(['column_name'=>$describe_value['title'],'product_id'=>$id]); 1078 $c_id = $cModel->addReturnId(['column_name'=>$describe_value['title'],'product_id'=>$id]);
1064 $dataS = [ 1079 $dataS = [
1065 - 'product_id'=>$c_id,  
1066 - 'column_id'=>$id, 1080 + 'product_id'=>$id,
  1081 + 'column_id'=>$c_id,
1067 'text_type'=>1, 1082 'text_type'=>1,
1068 'title'=>$describe_value['title'] ?? '', 1083 'title'=>$describe_value['title'] ?? '',
1069 'sort'=>$describe_key + 1, 1084 'sort'=>$describe_key + 1,
@@ -77,7 +77,7 @@ class TranslateLogic extends BaseLogic @@ -77,7 +77,7 @@ class TranslateLogic extends BaseLogic
77 if($val == ' ' || $val == ''){ 77 if($val == ' ' || $val == ''){
78 continue; 78 continue;
79 } 79 }
80 - $val = str_replace(' ','',urldecode($val));//处理特殊字符 80 + $val = str_replace(' ','',$val);//处理特殊字符
81 $val = trim(str_replace(' ','',$val)); 81 $val = trim(str_replace(' ','',$val));
82 if (FALSE == in_array($val, $old_key)){ 82 if (FALSE == in_array($val, $old_key)){
83 $arr2[] = $val; 83 $arr2[] = $val;
@@ -13,6 +13,7 @@ class NoticeLog extends Base @@ -13,6 +13,7 @@ class NoticeLog extends Base
13 const TYPE_PROJECT = 'project'; 13 const TYPE_PROJECT = 'project';
14 const TYPE_RANK_DATA = 'rank_data'; 14 const TYPE_RANK_DATA = 'rank_data';
15 const TYPE_INIT_PROJECT = 'init_project'; 15 const TYPE_INIT_PROJECT = 'init_project';
  16 + const TYPE_COPY_PROJECT = 'copy_project';
16 const TYPE_INIT_KEYWORD = 'init_keyword'; 17 const TYPE_INIT_KEYWORD = 'init_keyword';
17 const DELETE_PRODUCT_CATEGORY = 'delete_product_category'; 18 const DELETE_PRODUCT_CATEGORY = 'delete_product_category';
18 const DELETE_BLOG_CATEGORY = 'delete_blog_category'; 19 const DELETE_BLOG_CATEGORY = 'delete_blog_category';
@@ -379,6 +379,12 @@ class Project extends Base @@ -379,6 +379,12 @@ class Project extends Base
379 //是否正式域名 379 //是否正式域名
380 if (!$project_id) { 380 if (!$project_id) {
381 $domainModel = new DomainInfoModel(); 381 $domainModel = new DomainInfoModel();
  382 +
  383 + //M站特殊域名处理
  384 + if($domain == 'm.sinophorus.com'){
  385 + $domain = 'en.sinophorus.com';
  386 + }
  387 +
382 $project_id = $domainModel->formatQuery(['domain'=>$domain,'status'=>1])->value('project_id'); 388 $project_id = $domainModel->formatQuery(['domain'=>$domain,'status'=>1])->value('project_id');
383 if (empty($project_id)) { 389 if (empty($project_id)) {
384 //是否小语种域名或amp站域名 390 //是否小语种域名或amp站域名
@@ -418,10 +418,10 @@ class BtRepository @@ -418,10 +418,10 @@ class BtRepository
418 $domain_array = parse_url($domain); 418 $domain_array = parse_url($domain);
419 $host = $domain_array['host'] ?? $domain_array['path']; 419 $host = $domain_array['host'] ?? $domain_array['path'];
420 $host_array = explode('.',$host); 420 $host_array = explode('.',$host);
421 - if($host_array[0] == 'www'){ 421 + if (count($host_array) <= 2) {
  422 + array_unshift($host_array, 'm');
  423 + } else {
422 $host_array[0] = 'm'; 424 $host_array[0] = 'm';
423 - }else{  
424 - array_unshift($host_array,'m');  
425 } 425 }
426 $host = implode('.',$host_array); 426 $host = implode('.',$host_array);
427 427