作者 刘锟

update

... ... @@ -34,44 +34,63 @@ class Temp extends Command
*/
protected $description = '临时脚本';
public function handle()
{
$domain_model = new DomainInfo();
$notify_model = new Notify();
$project_model = new Project();
$domain_list = $domain_model->list(['amp_status' => 1]);
foreach ($domain_list as $info) {
if ($info['project_id'] > 0) {
$notify_info = $notify_model->read(['project_id' => $info['project_id'], 'type' => 3]);
if (!$notify_info) {
$domain_array = parse_url($info['domain']);
$host = $domain_array['host'] ?? $domain_array['path'];
$host_array = explode('.', $host);
if (count($host_array) <= 2) {
array_unshift($host_array, 'm');
} else {
$host_array[0] = 'm';
}
$amp_domain = implode('.', $host_array);
public function handel(){
ProjectServer::useProject(1515);
$project_info = $project_model->read(['id' => $info['project_id']]);
$products = Product::select(['id','content'])->get();
$notify_model->add([
'project_id' => $info['project_id'],
'type' => 3,
'data' => json_encode(['domain' => $amp_domain, 'url' => [], 'language' => []]),
'server_id' => $project_info['serve_id'],
]);
}
}
foreach ($products as $product){
$content = $product->content;
$content = str_replace('<h1','<h2', $content);
$content = str_replace('</h1','</h2', $content);
$product->content = $content;
$product->save();
$this->output('productID:'.$product->id.',success');
}
$this->output('end');
}
// public function handle()
// {
// $domain_model = new DomainInfo();
// $notify_model = new Notify();
// $project_model = new Project();
//
// $domain_list = $domain_model->list(['amp_status' => 1]);
// foreach ($domain_list as $info) {
// if ($info['project_id'] > 0) {
// $notify_info = $notify_model->read(['project_id' => $info['project_id'], 'type' => 3]);
// if (!$notify_info) {
//
// $domain_array = parse_url($info['domain']);
// $host = $domain_array['host'] ?? $domain_array['path'];
// $host_array = explode('.', $host);
// if (count($host_array) <= 2) {
// array_unshift($host_array, 'm');
// } else {
// $host_array[0] = 'm';
// }
// $amp_domain = implode('.', $host_array);
//
// $project_info = $project_model->read(['id' => $info['project_id']]);
//
// $notify_model->add([
// 'project_id' => $info['project_id'],
// 'type' => 3,
// 'data' => json_encode(['domain' => $amp_domain, 'url' => [], 'language' => []]),
// 'server_id' => $project_info['serve_id'],
// ]);
// }
// }
// }
// }
// public function handle()
// {
// $domain_model = new DomainInfo();
// $server_model = new ServerConfig();
// $project_model = new Project();
//
... ...