Merge branch 'master' of http://47.244.231.31:8099/zhl/globalso-v6
正在显示
16 个修改的文件
包含
461 行增加
和
60 行删除
| @@ -11,7 +11,6 @@ namespace App\Console\Commands\Domain; | @@ -11,7 +11,6 @@ namespace App\Console\Commands\Domain; | ||
| 11 | 11 | ||
| 12 | use Illuminate\Console\Command; | 12 | use Illuminate\Console\Command; |
| 13 | use App\Models\Domain\DomainInfo as DomainInfoModel; | 13 | use App\Models\Domain\DomainInfo as DomainInfoModel; |
| 14 | -use Illuminate\Support\Facades\Log; | ||
| 15 | 14 | ||
| 16 | class DomainInfo extends Command | 15 | class DomainInfo extends Command |
| 17 | { | 16 | { |
| @@ -36,37 +35,106 @@ class DomainInfo extends Command | @@ -36,37 +35,106 @@ class DomainInfo extends Command | ||
| 36 | * @method :post | 35 | * @method :post |
| 37 | * @time :2023/9/11 15:09 | 36 | * @time :2023/9/11 15:09 |
| 38 | */ | 37 | */ |
| 39 | - public function handle(){ | 38 | + public function handle() |
| 39 | + { | ||
| 40 | + //更新域名到期时间 | ||
| 41 | + $this->startUpdateDomain(); | ||
| 42 | + | ||
| 43 | + //主站证书到期更新 | ||
| 44 | + $this->startUpdateCert(); | ||
| 45 | + | ||
| 46 | + //AMP站证书到期更新 | ||
| 47 | + $this->startUpdateAmpCert(); | ||
| 48 | + | ||
| 49 | + return true; | ||
| 50 | + } | ||
| 51 | + | ||
| 52 | + /** | ||
| 53 | + * 更新域名到期时间 | ||
| 54 | + * @author Akun | ||
| 55 | + * @date 2024/02/26 10:26 | ||
| 56 | + */ | ||
| 57 | + public function startUpdateDomain() | ||
| 58 | + { | ||
| 40 | $domainModel = new DomainInfoModel(); | 59 | $domainModel = new DomainInfoModel(); |
| 41 | - $map = ['status'=>['!=',2]]; | ||
| 42 | - $list = $domainModel->list($map); | ||
| 43 | - foreach ($list as $v){ | ||
| 44 | - if(empty($v['private_key']) || empty($v['private_cert'])){ | ||
| 45 | - //域名结束时间<2天时,重新生成 | ||
| 46 | - if(!empty($v['certificate_end_time'])){ | ||
| 47 | - if(($v['certificate_end_time'] > date('Y-m-d H:i:s',time() + 24*3600)) || ($v['certificate_end_time'] < date('Y-m-d H:i:s',time()))){ | ||
| 48 | - $this->updatePrivate($v); | ||
| 49 | - } | ||
| 50 | - } | ||
| 51 | - } | ||
| 52 | - $ssl = $this->updateDomainSsl($v['domain']); | 60 | + $list = $domainModel->where('status', '!=', 2)->where(function ($query) { |
| 61 | + $query->whereNull('domain_end_time')->orWhere('domain_end_time', '<', date('Y-m-d H:i:s')); | ||
| 62 | + })->get()->toArray(); | ||
| 63 | + foreach ($list as $v) { | ||
| 53 | $time = $this->updateDomain($v['domain']); | 64 | $time = $this->updateDomain($v['domain']); |
| 54 | - if(!empty($time['start']) && !empty($time['end'])){ | ||
| 55 | - $data = [ | ||
| 56 | - 'certificate_start_time'=>$ssl['from'], | ||
| 57 | - 'certificate_end_time'=>$ssl['to'], | ||
| 58 | - 'domain_start_time'=>$time['start'], | ||
| 59 | - 'domain_end_time'=>$time['end'] | ||
| 60 | - ]; | ||
| 61 | - }else{ | ||
| 62 | - $data = [ | ||
| 63 | - 'domain_start_time'=>$time['start'], | ||
| 64 | - 'domain_end_time'=>$time['end'] | ||
| 65 | - ]; | 65 | + $data = [ |
| 66 | + 'domain_start_time' => $time['start'], | ||
| 67 | + 'domain_end_time' => $time['end'] | ||
| 68 | + ]; | ||
| 69 | + | ||
| 70 | + $domainModel->edit($data, ['id' => $v['id']]); | ||
| 71 | + } | ||
| 72 | + } | ||
| 73 | + | ||
| 74 | + /** | ||
| 75 | + * 主站证书到期更新 | ||
| 76 | + * @author Akun | ||
| 77 | + * @date 2024/02/26 10:26 | ||
| 78 | + */ | ||
| 79 | + public function startUpdateCert() | ||
| 80 | + { | ||
| 81 | + $domainModel = new DomainInfoModel(); | ||
| 82 | + $end_day = date('Y-m-d H:i:s', time() + 2 * 24 * 3600);//2天后到期 | ||
| 83 | + $list = $domainModel->where('status', '!=', 2)->where(function ($query) use ($end_day) { | ||
| 84 | + $query->whereNull('certificate_end_time')->orWhere('certificate_end_time', '<', $end_day); | ||
| 85 | + })->get()->toArray(); | ||
| 86 | + foreach ($list as $v) { | ||
| 87 | + //更新证书到期时间 | ||
| 88 | + $data = []; | ||
| 89 | + $ssl = $this->updateDomainSsl($v['domain']); | ||
| 90 | + $ssl['from'] && $data['certificate_start_time'] = $ssl['from']; | ||
| 91 | + $ssl['to'] && $data['certificate_end_time'] = $ssl['to']; | ||
| 92 | + | ||
| 93 | + $domainModel->edit($data, ['id' => $v['id']]); | ||
| 94 | + | ||
| 95 | + if ($v['type'] == 1 && ($data['certificate_end_time'] ?? '') < $end_day) { | ||
| 96 | + //申请免费证书 | ||
| 97 | + $this->updatePrivate($v); | ||
| 98 | + } | ||
| 99 | + } | ||
| 100 | + } | ||
| 101 | + | ||
| 102 | + /** | ||
| 103 | + * AMP站证书到期更新 | ||
| 104 | + * @author Akun | ||
| 105 | + * @date 2024/02/26 10:26 | ||
| 106 | + */ | ||
| 107 | + public function startUpdateAmpCert() | ||
| 108 | + { | ||
| 109 | + $domainModel = new DomainInfoModel(); | ||
| 110 | + $end_day = date('Y-m-d H:i:s', time() + 2 * 24 * 3600);//2天后到期 | ||
| 111 | + $list = $domainModel->where('status', '!=', 2)->where('amp_status', 1)->where(function ($query) use ($end_day) { | ||
| 112 | + $query->whereNull('amp_certificate_end_time')->orWhere('amp_certificate_end_time', '<', $end_day); | ||
| 113 | + })->get()->toArray(); | ||
| 114 | + foreach ($list as $v) { | ||
| 115 | + //更新amp站点证书到期时间 | ||
| 116 | + $domain_array = parse_url($v['domain']); | ||
| 117 | + $host = $domain_array['host'] ?? $domain_array['path']; | ||
| 118 | + $host_array = explode('.', $host); | ||
| 119 | + if (count($host_array) <= 2) { | ||
| 120 | + array_unshift($host_array, 'm'); | ||
| 121 | + } else { | ||
| 122 | + $host_array[0] = 'm'; | ||
| 123 | + } | ||
| 124 | + $amp_domain = implode('.', $host_array); | ||
| 125 | + | ||
| 126 | + $data = []; | ||
| 127 | + $ssl = $this->updateDomainSsl($amp_domain); | ||
| 128 | + $ssl['from'] && $data['amp_certificate_start_time'] = $ssl['from']; | ||
| 129 | + $ssl['to'] && $data['amp_certificate_start_time'] = $ssl['to']; | ||
| 130 | + | ||
| 131 | + $domainModel->edit($data, ['id' => $v['id']]); | ||
| 132 | + | ||
| 133 | + if ($v['amp_type'] == 1 && ($data['amp_certificate_start_time'] ?? '') < $end_day) { | ||
| 134 | + //申请免费证书 | ||
| 135 | + $this->updateAmpPrivate($v['domain']); | ||
| 66 | } | 136 | } |
| 67 | - $domainModel->edit($data,['id'=>$v['id']]); | ||
| 68 | } | 137 | } |
| 69 | - return 1; | ||
| 70 | } | 138 | } |
| 71 | 139 | ||
| 72 | /** | 140 | /** |
| @@ -78,7 +146,7 @@ class DomainInfo extends Command | @@ -78,7 +146,7 @@ class DomainInfo extends Command | ||
| 78 | */ | 146 | */ |
| 79 | public function updatePrivate($param) | 147 | public function updatePrivate($param) |
| 80 | { | 148 | { |
| 81 | - $url = 'https://' . $param['domain']. '/api/applySsl/'; | 149 | + $url = 'https://' . $param['domain'] . '/api/applySsl/'; |
| 82 | $top_domain = $this->getTopDomain($param['domain']); | 150 | $top_domain = $this->getTopDomain($param['domain']); |
| 83 | if ((empty($extend_config) || empty($extend_config[0]['origin'])) && $param['id'] != 3) { | 151 | if ((empty($extend_config) || empty($extend_config[0]['origin'])) && $param['id'] != 3) { |
| 84 | $extend_config = [ | 152 | $extend_config = [ |
| @@ -89,21 +157,40 @@ class DomainInfo extends Command | @@ -89,21 +157,40 @@ class DomainInfo extends Command | ||
| 89 | 'project_id' => $param['project_id'], | 157 | 'project_id' => $param['project_id'], |
| 90 | 'type' => 1, | 158 | 'type' => 1, |
| 91 | 'route' => 1, | 159 | 'route' => 1, |
| 92 | - "domain" =>$param['domain'], | ||
| 93 | - "rewrite"=> $extend_config ?? [], | 160 | + "domain" => $param['domain'], |
| 161 | + "rewrite" => $extend_config ?? [], | ||
| 94 | 'other_domain' => [$top_domain, '*.' . $top_domain], | 162 | 'other_domain' => [$top_domain, '*.' . $top_domain], |
| 95 | 'private_key' => '', | 163 | 'private_key' => '', |
| 96 | 'cert' => '' | 164 | 'cert' => '' |
| 97 | ]; | 165 | ]; |
| 98 | - $result = $this->curlRequest($url, $param); | 166 | + return $this->curlRequest($url, $param); |
| 99 | } | 167 | } |
| 100 | 168 | ||
| 101 | - public static function getTopDomain ($url) { | 169 | + /** |
| 170 | + * 更新证书 | ||
| 171 | + * @param $domain | ||
| 172 | + * @return array | ||
| 173 | + * @author Akun | ||
| 174 | + * @date 2024/02/26 10:25 | ||
| 175 | + */ | ||
| 176 | + public function updateAmpPrivate($domain) | ||
| 177 | + { | ||
| 178 | + $url = 'https://' . $domain . '/api/createSiteAmp/'; | ||
| 179 | + $param = [ | ||
| 180 | + "domain" => $domain, | ||
| 181 | + 'private_key' => '', | ||
| 182 | + 'cert' => '' | ||
| 183 | + ]; | ||
| 184 | + return $this->curlRequest($url, $param); | ||
| 185 | + } | ||
| 186 | + | ||
| 187 | + public static function getTopDomain($url) | ||
| 188 | + { | ||
| 102 | $url = strtolower($url); //首先转成小写 | 189 | $url = strtolower($url); //首先转成小写 |
| 103 | $url = mb_ereg_replace('^( | )+', '', trim($url)); | 190 | $url = mb_ereg_replace('^( | )+', '', trim($url)); |
| 104 | $url = mb_ereg_replace('( | )+$', '', $url); | 191 | $url = mb_ereg_replace('( | )+$', '', $url); |
| 105 | if (!preg_match('/^(http:\/\/|https)/', $url)) { | 192 | if (!preg_match('/^(http:\/\/|https)/', $url)) { |
| 106 | - $url = "https://".$url; | 193 | + $url = "https://" . $url; |
| 107 | } | 194 | } |
| 108 | $hosts = parse_url($url); | 195 | $hosts = parse_url($url); |
| 109 | $host = $hosts['host'] ?? ''; | 196 | $host = $hosts['host'] ?? ''; |
| @@ -117,10 +204,10 @@ class DomainInfo extends Command | @@ -117,10 +204,10 @@ class DomainInfo extends Command | ||
| 117 | $preg = '/[\w].+\.(com|net|org|gov|edu|co|ne)\.[\w]/'; | 204 | $preg = '/[\w].+\.(com|net|org|gov|edu|co|ne)\.[\w]/'; |
| 118 | if (($n > 2) && preg_match($preg, $host)) { | 205 | if (($n > 2) && preg_match($preg, $host)) { |
| 119 | //双后缀取后3位 | 206 | //双后缀取后3位 |
| 120 | - $host = $data[$n - 3].'.'.$data[$n - 2].'.'.$data[$n - 1]; | 207 | + $host = $data[$n - 3] . '.' . $data[$n - 2] . '.' . $data[$n - 1]; |
| 121 | } else { | 208 | } else { |
| 122 | //非双后缀取后两位 | 209 | //非双后缀取后两位 |
| 123 | - $host = $data[$n - 2].'.'.$data[$n - 1]; | 210 | + $host = $data[$n - 2] . '.' . $data[$n - 1]; |
| 124 | } | 211 | } |
| 125 | return $host; | 212 | return $host; |
| 126 | } | 213 | } |
| @@ -155,30 +242,33 @@ class DomainInfo extends Command | @@ -155,30 +242,33 @@ class DomainInfo extends Command | ||
| 155 | * @method :post | 242 | * @method :post |
| 156 | * @time :2023/9/11 15:07 | 243 | * @time :2023/9/11 15:07 |
| 157 | */ | 244 | */ |
| 158 | - public function updateDomainSsl($domain){ | 245 | + public function updateDomainSsl($domain) |
| 246 | + { | ||
| 159 | try { | 247 | try { |
| 160 | $context = stream_context_create([ | 248 | $context = stream_context_create([ |
| 161 | 'ssl' => [ | 249 | 'ssl' => [ |
| 162 | 'capture_peer_cert' => true, | 250 | 'capture_peer_cert' => true, |
| 163 | 'capture_peer_cert_chain' => false, | 251 | 'capture_peer_cert_chain' => false, |
| 252 | + 'verify_peer' => false, | ||
| 253 | + 'verify_peer_name' => false | ||
| 164 | ], | 254 | ], |
| 165 | ]); | 255 | ]); |
| 166 | - $stream = stream_socket_client('ssl://'.$domain.':443', $errno, $errstr, 30, STREAM_CLIENT_CONNECT, $context); | ||
| 167 | - if(!$stream) { | 256 | + $stream = stream_socket_client('ssl://' . $domain . ':443', $errno, $errstr, 30, STREAM_CLIENT_CONNECT, $context); |
| 257 | + if (!$stream) { | ||
| 168 | die("Failed to connect: $errno - $errstr"); | 258 | die("Failed to connect: $errno - $errstr"); |
| 169 | } | 259 | } |
| 170 | $remote_cert = stream_context_get_params($stream)['options']['ssl']['peer_certificate']; | 260 | $remote_cert = stream_context_get_params($stream)['options']['ssl']['peer_certificate']; |
| 171 | - if(!$remote_cert) { | 261 | + if (!$remote_cert) { |
| 172 | die("Failed to retrieve certificate"); | 262 | die("Failed to retrieve certificate"); |
| 173 | } | 263 | } |
| 174 | $valid_from = date('Y-m-d H:i:s', openssl_x509_parse($remote_cert)['validFrom_time_t']); | 264 | $valid_from = date('Y-m-d H:i:s', openssl_x509_parse($remote_cert)['validFrom_time_t']); |
| 175 | $valid_to = date('Y-m-d H:i:s', openssl_x509_parse($remote_cert)['validTo_time_t']); | 265 | $valid_to = date('Y-m-d H:i:s', openssl_x509_parse($remote_cert)['validTo_time_t']); |
| 176 | fclose($stream); | 266 | fclose($stream); |
| 177 | - }catch (\Exception $e){ | 267 | + } catch (\Exception $e) { |
| 178 | $valid_from = ''; | 268 | $valid_from = ''; |
| 179 | $valid_to = ''; | 269 | $valid_to = ''; |
| 180 | } | 270 | } |
| 181 | - return ['from'=>$valid_from,'to'=>$valid_to]; | 271 | + return ['from' => $valid_from, 'to' => $valid_to]; |
| 182 | } | 272 | } |
| 183 | 273 | ||
| 184 | /** | 274 | /** |
| @@ -188,15 +278,16 @@ class DomainInfo extends Command | @@ -188,15 +278,16 @@ class DomainInfo extends Command | ||
| 188 | * @method :post | 278 | * @method :post |
| 189 | * @time :2023/9/11 15:11 | 279 | * @time :2023/9/11 15:11 |
| 190 | */ | 280 | */ |
| 191 | - public function updateDomain($domain){ | ||
| 192 | - $url = 'http://openai.waimaoq.com/v1/whois_api?domain='.$domain; | 281 | + public function updateDomain($domain) |
| 282 | + { | ||
| 283 | + $url = 'http://openai.waimaoq.com/v1/whois_api?domain=' . $domain; | ||
| 193 | $response = http_get($url); | 284 | $response = http_get($url); |
| 194 | $start = date('Y-m-d H:i:s'); | 285 | $start = date('Y-m-d H:i:s'); |
| 195 | $end = date('Y-m-d H:i:s'); | 286 | $end = date('Y-m-d H:i:s'); |
| 196 | - if($response['code'] == 200){ | 287 | + if ($response['code'] == 200) { |
| 197 | $start = $response['text']['creation_date']; | 288 | $start = $response['text']['creation_date']; |
| 198 | $end = $response['text']['expiration_date']; | 289 | $end = $response['text']['expiration_date']; |
| 199 | } | 290 | } |
| 200 | - return ['start'=>$start,'end'=>$end]; | 291 | + return ['start' => $start, 'end' => $end]; |
| 201 | } | 292 | } |
| 202 | } | 293 | } |
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * Created by PhpStorm. | ||
| 4 | + * User: zhl | ||
| 5 | + * Date: 2024/02/26 | ||
| 6 | + * Time: 10:13 | ||
| 7 | + */ | ||
| 8 | +namespace App\Console\Commands\KeywordInVideo; | ||
| 9 | + | ||
| 10 | +use App\Console\Commands\Model; | ||
| 11 | +use App\Console\Commands\TaskSub; | ||
| 12 | +use App\Models\Com\KeywordVideoTask; | ||
| 13 | +use App\Models\Com\KeywordVideoTaskLog; | ||
| 14 | +use App\Models\Product\Keyword; | ||
| 15 | +use App\Services\ProjectServer; | ||
| 16 | +use Illuminate\Console\Command; | ||
| 17 | +use Illuminate\Support\Facades\Http; | ||
| 18 | +use Illuminate\Support\Facades\Log; | ||
| 19 | + | ||
| 20 | +class VideoTask extends Command | ||
| 21 | +{ | ||
| 22 | + /** | ||
| 23 | + * The name and signature of the console command. | ||
| 24 | + * | ||
| 25 | + * @var string | ||
| 26 | + */ | ||
| 27 | + protected $signature = 'video_task'; | ||
| 28 | + | ||
| 29 | + /** | ||
| 30 | + * The console command description. | ||
| 31 | + * | ||
| 32 | + * @var string | ||
| 33 | + */ | ||
| 34 | + protected $description = '视频推广任务'; | ||
| 35 | + | ||
| 36 | + /** | ||
| 37 | + * Create a new command instance. | ||
| 38 | + * | ||
| 39 | + * @return void | ||
| 40 | + */ | ||
| 41 | + public function __construct() | ||
| 42 | + { | ||
| 43 | + parent::__construct(); | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + /** | ||
| 47 | + * @var int 最大子任务 | ||
| 48 | + */ | ||
| 49 | + public $max_sub_task = 800; | ||
| 50 | + | ||
| 51 | + /** | ||
| 52 | + * @return bool | ||
| 53 | + */ | ||
| 54 | + public function handle() | ||
| 55 | + { | ||
| 56 | + Log::info('开始视频推广任务'); | ||
| 57 | + $this->createSubTask(); | ||
| 58 | + $this->sendSubTask(); | ||
| 59 | + Log::info('结束视频推广任务'); | ||
| 60 | + return true; | ||
| 61 | + } | ||
| 62 | + | ||
| 63 | + /** | ||
| 64 | + * 创建子任务 | ||
| 65 | + * TODO 获取需要生成子任务的项目,获取项目中未生成视频的关键词,通过关键词生成初始化子任务 | ||
| 66 | + * @return bool | ||
| 67 | + */ | ||
| 68 | + public function createSubTask() | ||
| 69 | + { | ||
| 70 | + $sub_task_num = $this->max_sub_task; | ||
| 71 | + while (true) { | ||
| 72 | + if ($sub_task_num <= 0){ | ||
| 73 | + break; | ||
| 74 | + } | ||
| 75 | + $task_project = KeywordVideoTask::where(['status' => KeywordVideoTask::STATUS_OPEN])->orderBy('sort', 'desc')->first(); | ||
| 76 | + if (empty($task_project)){ | ||
| 77 | + break; | ||
| 78 | + } | ||
| 79 | + ProjectServer::useProject($task_project->project_id); | ||
| 80 | + $keyword = $this->getProjectKeyword(); | ||
| 81 | + // 已经没有需要生成视频的关键词 | ||
| 82 | + if (FALSE == $keyword->isEmpty()) { | ||
| 83 | + $task_project->status = KeywordVideoTask::STATUS_CLOSE; | ||
| 84 | + $task_project->save(); | ||
| 85 | + continue; | ||
| 86 | + } | ||
| 87 | + foreach ($keyword as $val) { | ||
| 88 | + $log = KeywordVideoTaskLog::where(['project_id' => $task_project->project_id, 'keyword_id' => $val->id])->first(); | ||
| 89 | + if ($log){ | ||
| 90 | + continue; | ||
| 91 | + } | ||
| 92 | + $array = [ | ||
| 93 | + 'project_id' => $task_project->project_id, | ||
| 94 | + 'keyword_id' => $val->id, | ||
| 95 | + 'keyword' => $val->title, | ||
| 96 | + 'data' => json_encode(['url' => '', 'description' => '', 'images' => [], 'keywords' => []]), | ||
| 97 | + 'status' => KeywordVideoTaskLog::STATUS_INIT, | ||
| 98 | + 'updated_at' => date('Y-m-d H:i:s'), | ||
| 99 | + 'created_at' => date('Y-m-d H:i:s'), | ||
| 100 | + ]; | ||
| 101 | + KeywordVideoTaskLog::insert($array); | ||
| 102 | + $sub_task_num--; | ||
| 103 | + } | ||
| 104 | + $task_project->status = KeywordVideoTask::STATUS_CLOSE; | ||
| 105 | + $task_project->save(); | ||
| 106 | + } | ||
| 107 | + return true; | ||
| 108 | + } | ||
| 109 | + | ||
| 110 | + /** | ||
| 111 | + * 发送子任务 | ||
| 112 | + * @return bool | ||
| 113 | + */ | ||
| 114 | + public function sendSubTask() | ||
| 115 | + { | ||
| 116 | + $subTask = KeywordVideoTaskLog::where(['status' => TaskSub::STATUS_INIT])->orderBy('id', 'asc')->limit($this->max_sub_task)->get(); | ||
| 117 | + if ($subTask->isEmpty()) | ||
| 118 | + return true; | ||
| 119 | + foreach ($subTask as $val) { | ||
| 120 | + $task_id = 'v6-' . uniqid(); | ||
| 121 | + $data = [ | ||
| 122 | + 'project_data' => [ | ||
| 123 | + 'tag_url' => '', | ||
| 124 | + 'title' => '', | ||
| 125 | + 'keywords' => [], | ||
| 126 | + 'description' => '', | ||
| 127 | + 'images' => '' | ||
| 128 | + ], | ||
| 129 | + 'task_id' => $task_id, | ||
| 130 | + 'callback_url' => '', | ||
| 131 | + ]; | ||
| 132 | + $result = Http::post('http://216.250.255.116:7866/create_task', $data); | ||
| 133 | + | ||
| 134 | + $val->task_id = $task_id; | ||
| 135 | + $val->status = STATUS_RUNING::STATUS_RUNING; | ||
| 136 | + $val->request_result = $result; | ||
| 137 | + $val->save(); | ||
| 138 | + } | ||
| 139 | + return true; | ||
| 140 | + } | ||
| 141 | + | ||
| 142 | + /** | ||
| 143 | + * 获取未生成页面的关键词 | ||
| 144 | + * @return mixed | ||
| 145 | + */ | ||
| 146 | + public function getProjectKeyword() | ||
| 147 | + { | ||
| 148 | + $keyword = Keyword::where('video', null)->whereNotNull('keyword_content')->inRandomOrder()->take(100)->get(); | ||
| 149 | + return $keyword; | ||
| 150 | + } | ||
| 151 | + | ||
| 152 | + /** | ||
| 153 | + * 获取需要处理的任务 | ||
| 154 | + * @return int | ||
| 155 | + */ | ||
| 156 | + public function getTaskProject() | ||
| 157 | + { | ||
| 158 | +// $task_project = Model::where(['status' => Model::STATUS_OPEN])->orderBy('sort', 'desc')->first(); | ||
| 159 | + $project_id = 110; | ||
| 160 | + return $project_id; | ||
| 161 | + } | ||
| 162 | +} |
| @@ -11,6 +11,7 @@ namespace App\Console\Commands\MonthlyCount; | @@ -11,6 +11,7 @@ namespace App\Console\Commands\MonthlyCount; | ||
| 11 | 11 | ||
| 12 | use App\Helper\FormGlobalsoApi; | 12 | use App\Helper\FormGlobalsoApi; |
| 13 | use App\Models\Com\UpdateOldInfo; | 13 | use App\Models\Com\UpdateOldInfo; |
| 14 | +use App\Models\Domain\DomainInfo; | ||
| 14 | use App\Models\HomeCount\MonthCount; | 15 | use App\Models\HomeCount\MonthCount; |
| 15 | use App\Models\Project\Project; | 16 | use App\Models\Project\Project; |
| 16 | use App\Models\Visit\Visit; | 17 | use App\Models\Visit\Visit; |
| @@ -39,7 +40,13 @@ class UpgradeProjectCount extends Command | @@ -39,7 +40,13 @@ class UpgradeProjectCount extends Command | ||
| 39 | $project_id = $this->argument('project_id'); | 40 | $project_id = $this->argument('project_id'); |
| 40 | $oldModel = new UpdateOldInfo(); | 41 | $oldModel = new UpdateOldInfo(); |
| 41 | $info = $oldModel->read(['project_id'=>$project_id]); | 42 | $info = $oldModel->read(['project_id'=>$project_id]); |
| 42 | - $url = $info['old_domain_online']; | 43 | + if($info !== false){ |
| 44 | + $url = $info['old_domain_online']; | ||
| 45 | + }else{ | ||
| 46 | + $domainModel = new DomainInfo(); | ||
| 47 | + $info = $domainModel->read(['project_id'=>$project_id]); | ||
| 48 | + $url = $info['domain']; | ||
| 49 | + } | ||
| 43 | ProjectServer::useProject($project_id); | 50 | ProjectServer::useProject($project_id); |
| 44 | $this->count($project_id,$url); | 51 | $this->count($project_id,$url); |
| 45 | DB::disconnect('custom_mysql'); | 52 | DB::disconnect('custom_mysql'); |
| @@ -139,11 +139,14 @@ class IndexController extends BaseController | @@ -139,11 +139,14 @@ class IndexController extends BaseController | ||
| 139 | $product_image = []; | 139 | $product_image = []; |
| 140 | foreach ($productList as $k => $v){ | 140 | foreach ($productList as $k => $v){ |
| 141 | $image = []; | 141 | $image = []; |
| 142 | - $image['title'] = $v['title']; | ||
| 143 | if(!empty($v['thumb']) && !empty($v['thumb']['url'])){ | 142 | if(!empty($v['thumb']) && !empty($v['thumb']['url'])){ |
| 144 | $image['image'] = getImageUrl($v['thumb']['url']); | 143 | $image['image'] = getImageUrl($v['thumb']['url']); |
| 144 | + $image['title'] = $v['title']; | ||
| 145 | + $product_image[] = $image; | ||
| 146 | + } | ||
| 147 | + if(count($product_image) > 6){ | ||
| 148 | + break; | ||
| 145 | } | 149 | } |
| 146 | - $product_image[] = $image; | ||
| 147 | } | 150 | } |
| 148 | $data = [ | 151 | $data = [ |
| 149 | 'title'=>$keywordInfo['title'], | 152 | 'title'=>$keywordInfo['title'], |
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * @remark : | ||
| 4 | + * @name :KeywordVideoController.php | ||
| 5 | + * @author :lyh | ||
| 6 | + * @method :post | ||
| 7 | + * @time :2024/2/26 9:23 | ||
| 8 | + */ | ||
| 9 | + | ||
| 10 | +namespace App\Http\Controllers\Aside\Com; | ||
| 11 | + | ||
| 12 | +use App\Enums\Common\Code; | ||
| 13 | +use App\Http\Controllers\Aside\BaseController; | ||
| 14 | +use App\Models\Com\KeywordVideoTask; | ||
| 15 | + | ||
| 16 | +class KeywordVideoController extends BaseController | ||
| 17 | +{ | ||
| 18 | + /** | ||
| 19 | + * @remark :任务列表 | ||
| 20 | + * @name :lists | ||
| 21 | + * @author :lyh | ||
| 22 | + * @method :post | ||
| 23 | + * @time :2024/2/26 11:36 | ||
| 24 | + */ | ||
| 25 | + public function lists(){ | ||
| 26 | + $keywordModel = new KeywordVideoTask(); | ||
| 27 | + $lists = $keywordModel->lists($this->map,$this->page,$this->row); | ||
| 28 | + $this->response('success',Code::SUCCESS,$lists); | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | + /** | ||
| 32 | + * @remark :创建关键字任务池子 | ||
| 33 | + * @name :saveKeyword | ||
| 34 | + * @author :lyh | ||
| 35 | + * @method :post | ||
| 36 | + * @time :2024/2/26 9:24 | ||
| 37 | + */ | ||
| 38 | + public function createKeywordTask(){ | ||
| 39 | + $this->request->validate([ | ||
| 40 | + 'project_id'=>'required', | ||
| 41 | + 'number'=>'required' | ||
| 42 | + ], [ | ||
| 43 | + 'project_id.required' => '项目唯一标识不为空', | ||
| 44 | + 'number.required' => 'number不为空', | ||
| 45 | + ]); | ||
| 46 | + $keywordModel = new KeywordVideoTask(); | ||
| 47 | + $rs = $keywordModel->add($this->param); | ||
| 48 | + if($rs === false){ | ||
| 49 | + $this->response('添加失败',Code::SYSTEM_ERROR); | ||
| 50 | + } | ||
| 51 | + $this->response('success'); | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + /** | ||
| 55 | + * @remark :修改项目 | ||
| 56 | + * @name :editSort | ||
| 57 | + * @author :lyh | ||
| 58 | + * @method :post | ||
| 59 | + * @time :2024/2/26 11:35 | ||
| 60 | + */ | ||
| 61 | + public function edit(){ | ||
| 62 | + $this->request->validate([ | ||
| 63 | + 'id'=>'required' | ||
| 64 | + ], [ | ||
| 65 | + 'id.required' => '主键标识不为空', | ||
| 66 | + ]); | ||
| 67 | + $keywordModel = new KeywordVideoTask(); | ||
| 68 | + $rs = $keywordModel->edit(['sort'=>$this->param['sort']],['id'=>$this->param['id']]); | ||
| 69 | + if($rs === false){ | ||
| 70 | + $this->response('编辑失败',Code::SYSTEM_ERROR); | ||
| 71 | + } | ||
| 72 | + $this->response('success'); | ||
| 73 | + } | ||
| 74 | +} |
| @@ -15,7 +15,7 @@ use App\Rules\Ids; | @@ -15,7 +15,7 @@ use App\Rules\Ids; | ||
| 15 | use Illuminate\Http\Request; | 15 | use Illuminate\Http\Request; |
| 16 | 16 | ||
| 17 | /** | 17 | /** |
| 18 | - * Class KeywordController | 18 | + * Class KeywordVideoController |
| 19 | * @package App\Http\Controllers\Bside | 19 | * @package App\Http\Controllers\Bside |
| 20 | * @author zbj | 20 | * @author zbj |
| 21 | * @date 2023/4/15 | 21 | * @date 2023/4/15 |
| @@ -52,6 +52,12 @@ class UserLogic extends BaseLogic | @@ -52,6 +52,12 @@ class UserLogic extends BaseLogic | ||
| 52 | //验证一个项目是否只有一个超级管理员 | 52 | //验证一个项目是否只有一个超级管理员 |
| 53 | $this->verifyRole($this->param); | 53 | $this->verifyRole($this->param); |
| 54 | if (isset($this->param['id']) && !empty($this->param['id'])) { | 54 | if (isset($this->param['id']) && !empty($this->param['id'])) { |
| 55 | + $info = $this->model->read(['id'=>$this->param['id']]); | ||
| 56 | + if($info['role_id'] == 0){ | ||
| 57 | + //更新项目信息 | ||
| 58 | + $projectModel = new Project(); | ||
| 59 | + $projectModel->edit(['lead_name'=>$this->param['name'],'mobile'=>$this->param['mobile']],['id'=>$info['project_id']]); | ||
| 60 | + } | ||
| 55 | $this->param = $this->editPassword($this->param); | 61 | $this->param = $this->editPassword($this->param); |
| 56 | $rs = $this->model->edit($this->param, ['id' => $this->param['id']]); | 62 | $rs = $this->model->edit($this->param, ['id' => $this->param['id']]); |
| 57 | } else { | 63 | } else { |
| @@ -147,7 +147,7 @@ class CountLogic extends BaseLogic | @@ -147,7 +147,7 @@ class CountLogic extends BaseLogic | ||
| 147 | public function referrer_count(){ | 147 | public function referrer_count(){ |
| 148 | $customerVisitModel = new Visit(); | 148 | $customerVisitModel = new Visit(); |
| 149 | $data = $customerVisitModel->select('referrer_url', DB::raw('COUNT(*) as count')) | 149 | $data = $customerVisitModel->select('referrer_url', DB::raw('COUNT(*) as count')) |
| 150 | - ->groupBy('referrer_url')->where(['domain'=>$this->user['domain']]) | 150 | + ->groupBy('referrer_url')->where(['domain'=>trim(str_replace('https://','',$this->user['domain']),'/')]) |
| 151 | ->orderByDesc('count')->limit(9)->get()->toArray(); | 151 | ->orderByDesc('count')->limit(9)->get()->toArray(); |
| 152 | $total = $customerVisitModel->count(); | 152 | $total = $customerVisitModel->count(); |
| 153 | if(!empty($data)){ | 153 | if(!empty($data)){ |
| @@ -30,6 +30,7 @@ class MonthCountLogic extends BaseLogic | @@ -30,6 +30,7 @@ class MonthCountLogic extends BaseLogic | ||
| 30 | */ | 30 | */ |
| 31 | public function getCountLists($map,$order = 'created_at',$filed = ['*']){ | 31 | public function getCountLists($map,$order = 'created_at',$filed = ['*']){ |
| 32 | $map['project_id'] = $this->user['project_id']; | 32 | $map['project_id'] = $this->user['project_id']; |
| 33 | + $new = $this->currentMonthCount(); | ||
| 33 | $lists = $this->model->list($map,$order,$filed,'desc',10); | 34 | $lists = $this->model->list($map,$order,$filed,'desc',10); |
| 34 | if(isset($this->project['is_record_china_visit']) && ($this->project['is_record_china_visit'] == 0)){ | 35 | if(isset($this->project['is_record_china_visit']) && ($this->project['is_record_china_visit'] == 0)){ |
| 35 | foreach ($lists as $k => $v){ | 36 | foreach ($lists as $k => $v){ |
| @@ -44,10 +45,11 @@ class MonthCountLogic extends BaseLogic | @@ -44,10 +45,11 @@ class MonthCountLogic extends BaseLogic | ||
| 44 | } | 45 | } |
| 45 | } | 46 | } |
| 46 | $v['source_country'] = json_encode(array_values($source_country)); | 47 | $v['source_country'] = json_encode(array_values($source_country)); |
| 48 | + $v['total'] = $new['total'] ?? $v['total']; | ||
| 47 | $lists[$k] = $v; | 49 | $lists[$k] = $v; |
| 48 | } | 50 | } |
| 49 | } | 51 | } |
| 50 | - $lists['new'] = $this->currentMonthCount(); | 52 | + $lists['new'] = $new; |
| 51 | return $this->success($lists); | 53 | return $this->success($lists); |
| 52 | } | 54 | } |
| 53 | 55 | ||
| @@ -151,6 +153,7 @@ class MonthCountLogic extends BaseLogic | @@ -151,6 +153,7 @@ class MonthCountLogic extends BaseLogic | ||
| 151 | $source = DB::connection('custom_mysql')->table('gl_customer_visit') | 153 | $source = DB::connection('custom_mysql')->table('gl_customer_visit') |
| 152 | ->select('referrer_url', DB::raw('COUNT(*) as count')) | 154 | ->select('referrer_url', DB::raw('COUNT(*) as count')) |
| 153 | ->groupBy('referrer_url') | 155 | ->groupBy('referrer_url') |
| 156 | + ->where('referrer_url','!=','') | ||
| 154 | ->whereBetween('updated_date', [$startTime,$endTime]) | 157 | ->whereBetween('updated_date', [$startTime,$endTime]) |
| 155 | ->orderByDesc('count')->limit(10)->get()->toArray(); | 158 | ->orderByDesc('count')->limit(10)->get()->toArray(); |
| 156 | $arr['source'] = $source; | 159 | $arr['source'] = $source; |
| @@ -12,6 +12,7 @@ namespace App\Http\Logic\Bside\Scoring; | @@ -12,6 +12,7 @@ namespace App\Http\Logic\Bside\Scoring; | ||
| 12 | use App\Http\Logic\Bside\BaseLogic; | 12 | use App\Http\Logic\Bside\BaseLogic; |
| 13 | use App\Models\Scoring\RatingQuestion; | 13 | use App\Models\Scoring\RatingQuestion; |
| 14 | use App\Models\Scoring\ScoringSystem; | 14 | use App\Models\Scoring\ScoringSystem; |
| 15 | +use AWS\CRT\Log; | ||
| 15 | 16 | ||
| 16 | class RatingLogic extends BaseLogic | 17 | class RatingLogic extends BaseLogic |
| 17 | { | 18 | { |
| @@ -77,6 +78,9 @@ class RatingLogic extends BaseLogic | @@ -77,6 +78,9 @@ class RatingLogic extends BaseLogic | ||
| 77 | } | 78 | } |
| 78 | $str = trim($str,'&'); | 79 | $str = trim($str,'&'); |
| 79 | $url = "http://www.quanqiusou.cn/extend_api/api/service_score.php?postid=$postId&token=$token&ftype=$fType&$str"; | 80 | $url = "http://www.quanqiusou.cn/extend_api/api/service_score.php?postid=$postId&token=$token&ftype=$fType&$str"; |
| 80 | - return http_get($url,['charset=utf-8']); | 81 | + $rs = http_get($url,['charset=utf-8']); |
| 82 | + @file_put_contents(storage_path('logs/lyh_error.log'), var_export($url, true) . PHP_EOL, FILE_APPEND); | ||
| 83 | + @file_put_contents(storage_path('logs/lyh_error.log'), var_export($rs, true) . PHP_EOL, FILE_APPEND); | ||
| 84 | + return $rs; | ||
| 81 | } | 85 | } |
| 82 | } | 86 | } |
| @@ -228,11 +228,13 @@ class TranslateLogic extends BaseLogic | @@ -228,11 +228,13 @@ class TranslateLogic extends BaseLogic | ||
| 228 | */ | 228 | */ |
| 229 | public function translateSave(){ | 229 | public function translateSave(){ |
| 230 | $data = []; | 230 | $data = []; |
| 231 | - //处理传递的data | ||
| 232 | - foreach ($this->param['data'] as $k => $v){ | ||
| 233 | - if(!empty($v) && is_array($v)){ | ||
| 234 | - foreach ($v as $text => $translate){ | ||
| 235 | - $data[$text] = $translate; | 231 | + if(!empty($this->param['data'])){ |
| 232 | + //处理传递的data | ||
| 233 | + foreach ($this->param['data'] as $k => $v){ | ||
| 234 | + if(!empty($v) && is_array($v)){ | ||
| 235 | + foreach ($v as $text => $translate){ | ||
| 236 | + $data[$text] = $translate; | ||
| 237 | + } | ||
| 236 | } | 238 | } |
| 237 | } | 239 | } |
| 238 | } | 240 | } |
| @@ -160,7 +160,7 @@ class CopyProjectJob implements ShouldQueue | @@ -160,7 +160,7 @@ class CopyProjectJob implements ShouldQueue | ||
| 160 | $sql = DB::connection('custom_tmp_mysql_copy')->select("SHOW CREATE TABLE {$table}"); | 160 | $sql = DB::connection('custom_tmp_mysql_copy')->select("SHOW CREATE TABLE {$table}"); |
| 161 | DB::connection('custom_mysql')->statement(get_object_vars($sql[0])['Create Table']); | 161 | DB::connection('custom_mysql')->statement(get_object_vars($sql[0])['Create Table']); |
| 162 | } | 162 | } |
| 163 | - DB::connection('custom_mysql')->table($table)->truncate(); // 清空目标表数据 | 163 | +// DB::connection('custom_mysql')->table($table)->truncate(); // 清空目标表数据 |
| 164 | DB::connection('custom_mysql')->table($table)->insertUsing( | 164 | DB::connection('custom_mysql')->table($table)->insertUsing( |
| 165 | [], // 列名数组,留空表示插入所有列 | 165 | [], // 列名数组,留空表示插入所有列 |
| 166 | function ($query) use ($table,$project_id) { | 166 | function ($query) use ($table,$project_id) { |
| @@ -40,7 +40,7 @@ class CollectTask extends Base | @@ -40,7 +40,7 @@ class CollectTask extends Base | ||
| 40 | 'project_id' => $project_id, | 40 | 'project_id' => $project_id, |
| 41 | 'source' => $source, | 41 | 'source' => $source, |
| 42 | 'source_id' => $source_id, | 42 | 'source_id' => $source_id, |
| 43 | - 'domain' => $url_arr['host'] ?? $domain, | 43 | + 'domain' => $domain, |
| 44 | 'route' => substr($url_arr['path'], 0, 1) == '/' ? $url_arr['path'] : '/' . $url_arr['path'], | 44 | 'route' => substr($url_arr['path'], 0, 1) == '/' ? $url_arr['path'] : '/' . $url_arr['path'], |
| 45 | 'language' => '', | 45 | 'language' => '', |
| 46 | 'created_at' => $now, | 46 | 'created_at' => $now, |
app/Models/Com/KeywordVideoTask.php
0 → 100644
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * @remark : | ||
| 4 | + * @name :KeywordVideoTask.php | ||
| 5 | + * @author :lyh | ||
| 6 | + * @method :post | ||
| 7 | + * @time :2024/2/26 9:33 | ||
| 8 | + */ | ||
| 9 | + | ||
| 10 | +namespace App\Models\Com; | ||
| 11 | + | ||
| 12 | +use App\Models\Base; | ||
| 13 | + | ||
| 14 | +class KeywordVideoTask extends Base | ||
| 15 | +{ | ||
| 16 | + const STATUS_OPEN = 0; | ||
| 17 | + const STATUS_CLOSE = 1;//停止 | ||
| 18 | + | ||
| 19 | + protected $table = 'gl_promotion_keyword_task'; | ||
| 20 | +} |
app/Models/Com/KeywordVideoTaskLog.php
0 → 100644
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * @remark : | ||
| 4 | + * @name :KeywordVideoTask.php | ||
| 5 | + * @author :lyh | ||
| 6 | + * @method :post | ||
| 7 | + * @time :2024/2/26 9:33 | ||
| 8 | + */ | ||
| 9 | + | ||
| 10 | +namespace App\Models\Com; | ||
| 11 | + | ||
| 12 | +use App\Models\Base; | ||
| 13 | + | ||
| 14 | +class KeywordVideoTaskLog extends Base | ||
| 15 | +{ | ||
| 16 | + const STATUS_INIT = 0; | ||
| 17 | + const STATUS_RUNING = 0; | ||
| 18 | + | ||
| 19 | + protected $table = 'gl_keyword_video_task_log'; | ||
| 20 | +} |
| @@ -326,6 +326,15 @@ Route::middleware(['aloginauth'])->group(function () { | @@ -326,6 +326,15 @@ Route::middleware(['aloginauth'])->group(function () { | ||
| 326 | Route::any('/del', [\App\Http\Controllers\Aside\CustomModule\CustomModuleController::class, 'del'])->name('custom_del'); | 326 | Route::any('/del', [\App\Http\Controllers\Aside\CustomModule\CustomModuleController::class, 'del'])->name('custom_del'); |
| 327 | }); | 327 | }); |
| 328 | 328 | ||
| 329 | + /** | ||
| 330 | + * 生成视频的项目 | ||
| 331 | + */ | ||
| 332 | + Route::prefix('keyword_video')->group(function () { | ||
| 333 | + Route::any('/', [Aside\Com\KeywordVideoController::class, 'lists'])->name('promotion_keyword_lists'); | ||
| 334 | + Route::any('/createKeywordTask', [Aside\Com\KeywordVideoController::class, 'createKeywordTask'])->name('promotion_keyword_createKeywordTask'); | ||
| 335 | + Route::any('/edit', [Aside\Com\KeywordVideoController::class, 'edit'])->name('promotion_keyword_edit'); | ||
| 336 | + }); | ||
| 337 | + | ||
| 329 | // 公共主题模版 | 338 | // 公共主题模版 |
| 330 | Route::prefix('template')->group(function () { | 339 | Route::prefix('template')->group(function () { |
| 331 | Route::any('/', [Aside\Template\ATemplateController::class, 'lists'])->name('admin.ATemplate_lists'); | 340 | Route::any('/', [Aside\Template\ATemplateController::class, 'lists'])->name('admin.ATemplate_lists'); |
-
请 注册 或 登录 后发表评论