作者 刘锟

update

@@ -34,44 +34,63 @@ class Temp extends Command @@ -34,44 +34,63 @@ class Temp extends Command
34 */ 34 */
35 protected $description = '临时脚本'; 35 protected $description = '临时脚本';
36 36
37 - public function handle()  
38 - {  
39 - $domain_model = new DomainInfo();  
40 - $notify_model = new Notify();  
41 - $project_model = new Project();  
42 -  
43 - $domain_list = $domain_model->list(['amp_status' => 1]);  
44 - foreach ($domain_list as $info) {  
45 - if ($info['project_id'] > 0) {  
46 - $notify_info = $notify_model->read(['project_id' => $info['project_id'], 'type' => 3]);  
47 - if (!$notify_info) {  
48 -  
49 - $domain_array = parse_url($info['domain']);  
50 - $host = $domain_array['host'] ?? $domain_array['path'];  
51 - $host_array = explode('.', $host);  
52 - if (count($host_array) <= 2) {  
53 - array_unshift($host_array, 'm');  
54 - } else {  
55 - $host_array[0] = 'm';  
56 - }  
57 - $amp_domain = implode('.', $host_array);  
58 -  
59 - $project_info = $project_model->read(['id' => $info['project_id']]);  
60 -  
61 - $notify_model->add([  
62 - 'project_id' => $info['project_id'],  
63 - 'type' => 3,  
64 - 'data' => json_encode(['domain' => $amp_domain, 'url' => [], 'language' => []]),  
65 - 'server_id' => $project_info['serve_id'],  
66 - ]);  
67 - }  
68 - } 37 + public function handel(){
  38 + ProjectServer::useProject(1515);
  39 +
  40 + $products = Product::select(['id','content'])->get();
  41 +
  42 + foreach ($products as $product){
  43 + $content = $product->content;
  44 + $content = str_replace('<h1','<h2', $content);
  45 + $content = str_replace('</h1','</h2', $content);
  46 +
  47 + $product->content = $content;
  48 + $product->save();
  49 +
  50 + $this->output('productID:'.$product->id.',success');
69 } 51 }
  52 +
  53 + $this->output('end');
70 } 54 }
71 55
72 // public function handle() 56 // public function handle()
73 // { 57 // {
74 // $domain_model = new DomainInfo(); 58 // $domain_model = new DomainInfo();
  59 +// $notify_model = new Notify();
  60 +// $project_model = new Project();
  61 +//
  62 +// $domain_list = $domain_model->list(['amp_status' => 1]);
  63 +// foreach ($domain_list as $info) {
  64 +// if ($info['project_id'] > 0) {
  65 +// $notify_info = $notify_model->read(['project_id' => $info['project_id'], 'type' => 3]);
  66 +// if (!$notify_info) {
  67 +//
  68 +// $domain_array = parse_url($info['domain']);
  69 +// $host = $domain_array['host'] ?? $domain_array['path'];
  70 +// $host_array = explode('.', $host);
  71 +// if (count($host_array) <= 2) {
  72 +// array_unshift($host_array, 'm');
  73 +// } else {
  74 +// $host_array[0] = 'm';
  75 +// }
  76 +// $amp_domain = implode('.', $host_array);
  77 +//
  78 +// $project_info = $project_model->read(['id' => $info['project_id']]);
  79 +//
  80 +// $notify_model->add([
  81 +// 'project_id' => $info['project_id'],
  82 +// 'type' => 3,
  83 +// 'data' => json_encode(['domain' => $amp_domain, 'url' => [], 'language' => []]),
  84 +// 'server_id' => $project_info['serve_id'],
  85 +// ]);
  86 +// }
  87 +// }
  88 +// }
  89 +// }
  90 +
  91 +// public function handle()
  92 +// {
  93 +// $domain_model = new DomainInfo();
75 // $server_model = new ServerConfig(); 94 // $server_model = new ServerConfig();
76 // $project_model = new Project(); 95 // $project_model = new Project();
77 // 96 //