正在显示
41 个修改的文件
包含
1104 行增加
和
169 行删除
| @@ -75,13 +75,39 @@ class HtmlCollect extends Command | @@ -75,13 +75,39 @@ class HtmlCollect extends Command | ||
| 75 | $collect_info->status = CollectTask::STATUS_ING; | 75 | $collect_info->status = CollectTask::STATUS_ING; |
| 76 | $collect_info->save(); | 76 | $collect_info->save(); |
| 77 | 77 | ||
| 78 | + //获取站点正式和测试域名 | ||
| 79 | + $web_url_domain = $collect_info->domain; | ||
| 80 | + $home_url = $collect_info->domain; | ||
| 81 | + $url_web_config = 'https://' . $collect_info->domain . '/wp-content/cache/user_config.text'; | ||
| 82 | + $data_config = http_get($url_web_config, ['charset' => 'UTF-8']); | ||
| 83 | + if ($data_config) { | ||
| 84 | + $web_url_arr = parse_url($data_config['web_url_domain'] ?? ''); | ||
| 85 | + if (isset($web_url_arr['host'])) { | ||
| 86 | + $web_url_domain = $web_url_arr['host']; | ||
| 87 | + } | ||
| 88 | + | ||
| 89 | + $home_url_arr = parse_url($data_config['home_url'] ?? ''); | ||
| 90 | + if (isset($home_url_arr['host'])) { | ||
| 91 | + $home_url = $home_url_arr['host']; | ||
| 92 | + } | ||
| 93 | + } | ||
| 94 | + | ||
| 78 | //采集html页面,下载资源到本地并替换 | 95 | //采集html页面,下载资源到本地并替换 |
| 79 | try { | 96 | try { |
| 80 | - $html = file_get_contents('https://' . $collect_info->domain . $collect_info->route); | ||
| 81 | - $source_list = $this->html_preg($html, $project_id, $collect_info->domain); | 97 | + $opts = [ |
| 98 | + 'http' => [ | ||
| 99 | + 'header' => 'User-Agent:Mozilla/5.0 (Windows NT 6.2; WOW64; rv:32.0) Gecko/20100101 Firefox/32.0' | ||
| 100 | + ], | ||
| 101 | + 'ssl' => [ | ||
| 102 | + 'verify_peer' => false, | ||
| 103 | + 'verify_peer_name' => false, | ||
| 104 | + ] | ||
| 105 | + ]; | ||
| 106 | + $html = file_get_contents('https://' . $collect_info->domain . $collect_info->route, false, stream_context_create($opts)); | ||
| 107 | + $source_list = $this->html_preg($html, $project_id, $collect_info->domain, $web_url_domain, $home_url); | ||
| 82 | 108 | ||
| 83 | if ($source_list) { | 109 | if ($source_list) { |
| 84 | - $html = $this->upload_source($html, $source_list, $project_id); | 110 | + $html = $this->upload_source($html, $source_list, $project_id, $opts); |
| 85 | } | 111 | } |
| 86 | } catch (\Exception $e) { | 112 | } catch (\Exception $e) { |
| 87 | $collect_info->status = CollectTask::STATUS_FAIL; | 113 | $collect_info->status = CollectTask::STATUS_FAIL; |
| @@ -164,7 +190,7 @@ class HtmlCollect extends Command | @@ -164,7 +190,7 @@ class HtmlCollect extends Command | ||
| 164 | } | 190 | } |
| 165 | 191 | ||
| 166 | //正则匹配html资源 | 192 | //正则匹配html资源 |
| 167 | - protected function html_preg($html, $project_id, $domain) | 193 | + protected function html_preg($html, $project_id, $domain, $web_url_domain, $home_url) |
| 168 | { | 194 | { |
| 169 | $source = []; | 195 | $source = []; |
| 170 | 196 | ||
| @@ -176,7 +202,7 @@ class HtmlCollect extends Command | @@ -176,7 +202,7 @@ class HtmlCollect extends Command | ||
| 176 | preg_match_all('/<img\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $html, $result_img); | 202 | preg_match_all('/<img\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $html, $result_img); |
| 177 | $img = $result_img[2] ?? []; | 203 | $img = $result_img[2] ?? []; |
| 178 | foreach ($img as $vi) { | 204 | foreach ($img as $vi) { |
| 179 | - $check_vi = $this->url_check($vi, $project_id, $domain); | 205 | + $check_vi = $this->url_check($vi, $project_id, $domain, $web_url_domain, $home_url); |
| 180 | $check_vi && $source[] = $check_vi; | 206 | $check_vi && $source[] = $check_vi; |
| 181 | } | 207 | } |
| 182 | 208 | ||
| @@ -184,7 +210,7 @@ class HtmlCollect extends Command | @@ -184,7 +210,7 @@ class HtmlCollect extends Command | ||
| 184 | preg_match_all('/<script\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $html, $result_js); | 210 | preg_match_all('/<script\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $html, $result_js); |
| 185 | $js = $result_js[2] ?? []; | 211 | $js = $result_js[2] ?? []; |
| 186 | foreach ($js as $vj) { | 212 | foreach ($js as $vj) { |
| 187 | - $check_vj = $this->url_check($vj, $project_id, $domain); | 213 | + $check_vj = $this->url_check($vj, $project_id, $domain, $web_url_domain, $home_url); |
| 188 | $check_vj && $source[] = $check_vj; | 214 | $check_vj && $source[] = $check_vj; |
| 189 | } | 215 | } |
| 190 | 216 | ||
| @@ -192,7 +218,7 @@ class HtmlCollect extends Command | @@ -192,7 +218,7 @@ class HtmlCollect extends Command | ||
| 192 | preg_match_all('/<source\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $html, $result_video); | 218 | preg_match_all('/<source\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $html, $result_video); |
| 193 | $video = $result_video[2] ?? []; | 219 | $video = $result_video[2] ?? []; |
| 194 | foreach ($video as $vv) { | 220 | foreach ($video as $vv) { |
| 195 | - $check_vv = $this->url_check($vv, $project_id, $domain); | 221 | + $check_vv = $this->url_check($vv, $project_id, $domain, $web_url_domain, $home_url); |
| 196 | $check_vv && $source[] = $check_vv; | 222 | $check_vv && $source[] = $check_vv; |
| 197 | } | 223 | } |
| 198 | 224 | ||
| @@ -200,7 +226,7 @@ class HtmlCollect extends Command | @@ -200,7 +226,7 @@ class HtmlCollect extends Command | ||
| 200 | preg_match_all('/<link\s+[^>]*?href\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $html, $result_css); | 226 | preg_match_all('/<link\s+[^>]*?href\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $html, $result_css); |
| 201 | $css = $result_css[2] ?? []; | 227 | $css = $result_css[2] ?? []; |
| 202 | foreach ($css as $vc) { | 228 | foreach ($css as $vc) { |
| 203 | - $check_vc = $this->url_check($vc, $project_id, $domain); | 229 | + $check_vc = $this->url_check($vc, $project_id, $domain, $web_url_domain, $home_url); |
| 204 | $check_vc && $source[] = $check_vc; | 230 | $check_vc && $source[] = $check_vc; |
| 205 | } | 231 | } |
| 206 | 232 | ||
| @@ -208,7 +234,7 @@ class HtmlCollect extends Command | @@ -208,7 +234,7 @@ class HtmlCollect extends Command | ||
| 208 | preg_match_all("/url\(['\"]?(\s*[^>]+?)['\"]?\)/i", $html, $result_css_b); | 234 | preg_match_all("/url\(['\"]?(\s*[^>]+?)['\"]?\)/i", $html, $result_css_b); |
| 209 | $css_b = $result_css_b[1] ?? []; | 235 | $css_b = $result_css_b[1] ?? []; |
| 210 | foreach ($css_b as $vc_b) { | 236 | foreach ($css_b as $vc_b) { |
| 211 | - $check_vc_b = $this->url_check($vc_b, $project_id, $domain); | 237 | + $check_vc_b = $this->url_check($vc_b, $project_id, $domain, $web_url_domain, $home_url); |
| 212 | $check_vc_b && $source[] = $check_vc_b; | 238 | $check_vc_b && $source[] = $check_vc_b; |
| 213 | } | 239 | } |
| 214 | 240 | ||
| @@ -217,7 +243,7 @@ class HtmlCollect extends Command | @@ -217,7 +243,7 @@ class HtmlCollect extends Command | ||
| 217 | } | 243 | } |
| 218 | 244 | ||
| 219 | //判断资源是否需要下载 | 245 | //判断资源是否需要下载 |
| 220 | - protected function url_check($url, $project_id, $domain) | 246 | + protected function url_check($url, $project_id, $domain, $web_url_domain, $home_url) |
| 221 | { | 247 | { |
| 222 | if ($url) { | 248 | if ($url) { |
| 223 | $arr = parse_url($url); | 249 | $arr = parse_url($url); |
| @@ -227,11 +253,10 @@ class HtmlCollect extends Command | @@ -227,11 +253,10 @@ class HtmlCollect extends Command | ||
| 227 | $query = $arr['query'] ?? ''; | 253 | $query = $arr['query'] ?? ''; |
| 228 | 254 | ||
| 229 | if ( | 255 | if ( |
| 230 | - (strpos($host, '.globalso.') === false) && | ||
| 231 | - (strpos($host, '.goodao.') === false) && | ||
| 232 | - $path && (strpos($path, '.') !== false) | 256 | + (empty($host) || $host == $web_url_domain || $host == $home_url) |
| 257 | + && $path | ||
| 258 | + && (strpos($path, '.') !== false) | ||
| 233 | ) { | 259 | ) { |
| 234 | - | ||
| 235 | $source = CollectSource::where('project_id', $project_id)->where('origin', $url)->first(); | 260 | $source = CollectSource::where('project_id', $project_id)->where('origin', $url)->first(); |
| 236 | if (!$source) { | 261 | if (!$source) { |
| 237 | return [ | 262 | return [ |
| @@ -255,7 +280,7 @@ class HtmlCollect extends Command | @@ -255,7 +280,7 @@ class HtmlCollect extends Command | ||
| 255 | } | 280 | } |
| 256 | 281 | ||
| 257 | //下载并替换资源 | 282 | //下载并替换资源 |
| 258 | - protected function upload_source($html, $source, $project_id) | 283 | + protected function upload_source($html, $source, $project_id, $opts) |
| 259 | { | 284 | { |
| 260 | foreach ($source as $vs) { | 285 | foreach ($source as $vs) { |
| 261 | 286 | ||
| @@ -273,7 +298,7 @@ class HtmlCollect extends Command | @@ -273,7 +298,7 @@ class HtmlCollect extends Command | ||
| 273 | 298 | ||
| 274 | if (substr($new_source, -3, 3) == 'css') { | 299 | if (substr($new_source, -3, 3) == 'css') { |
| 275 | // 下载css文件中的资源 | 300 | // 下载css文件中的资源 |
| 276 | - $css_html = file_get_contents($vs['url_complete']); | 301 | + $css_html = file_get_contents($vs['url_complete'], false, stream_context_create($opts)); |
| 277 | preg_match_all("/url\(['\"](\s*[^>]+?)['\"]\)/i", $css_html, $result_css_source); | 302 | preg_match_all("/url\(['\"](\s*[^>]+?)['\"]\)/i", $css_html, $result_css_source); |
| 278 | $css_source = $result_css_source[1] ?? []; | 303 | $css_source = $result_css_source[1] ?? []; |
| 279 | 304 | ||
| @@ -290,6 +315,9 @@ class HtmlCollect extends Command | @@ -290,6 +315,9 @@ class HtmlCollect extends Command | ||
| 290 | if (!$vcs) { | 315 | if (!$vcs) { |
| 291 | continue; | 316 | continue; |
| 292 | } | 317 | } |
| 318 | + if (strpos($vcs, '.') === false) { | ||
| 319 | + continue; | ||
| 320 | + } | ||
| 293 | 321 | ||
| 294 | $source_info = CollectSource::where('project_id', $project_id)->where('origin', $vcs)->first(); | 322 | $source_info = CollectSource::where('project_id', $project_id)->where('origin', $vcs)->first(); |
| 295 | if ($source_info) { | 323 | if ($source_info) { |
| @@ -75,13 +75,38 @@ class HtmlLanguageCollect extends Command | @@ -75,13 +75,38 @@ class HtmlLanguageCollect extends Command | ||
| 75 | $collect_info->status = CollectTask::STATUS_ING; | 75 | $collect_info->status = CollectTask::STATUS_ING; |
| 76 | $collect_info->save(); | 76 | $collect_info->save(); |
| 77 | 77 | ||
| 78 | + $web_url_domain = $collect_info->domain; | ||
| 79 | + $home_url = $collect_info->domain; | ||
| 80 | + $url_web_config = 'https://' . $collect_info->domain . '/wp-content/cache/user_config.text'; | ||
| 81 | + $data_config = http_get($url_web_config, ['charset' => 'UTF-8']); | ||
| 82 | + if ($data_config) { | ||
| 83 | + $web_url_arr = parse_url($data_config['web_url_domain'] ?? ''); | ||
| 84 | + if (isset($web_url_arr['host'])) { | ||
| 85 | + $web_url_domain = $web_url_arr['host']; | ||
| 86 | + } | ||
| 87 | + | ||
| 88 | + $home_url_arr = parse_url($data_config['home_url'] ?? ''); | ||
| 89 | + if (isset($home_url_arr['host'])) { | ||
| 90 | + $home_url = $home_url_arr['host']; | ||
| 91 | + } | ||
| 92 | + } | ||
| 93 | + | ||
| 78 | //采集html页面,下载资源到本地并替换 | 94 | //采集html页面,下载资源到本地并替换 |
| 79 | try { | 95 | try { |
| 80 | - $html = file_get_contents('https://' . $collect_info->domain . $collect_info->route); | ||
| 81 | - $source_list = $this->html_preg($html, $project_id, $collect_info->domain); | 96 | + $opts = [ |
| 97 | + 'http' => [ | ||
| 98 | + 'header' => 'User-Agent:Mozilla/5.0 (Windows NT 6.2; WOW64; rv:32.0) Gecko/20100101 Firefox/32.0' | ||
| 99 | + ], | ||
| 100 | + 'ssl' => [ | ||
| 101 | + 'verify_peer' => false, | ||
| 102 | + 'verify_peer_name' => false, | ||
| 103 | + ] | ||
| 104 | + ]; | ||
| 105 | + $html = file_get_contents('https://' . $collect_info->domain . $collect_info->route, false, stream_context_create($opts)); | ||
| 106 | + $source_list = $this->html_preg($html, $project_id, $collect_info->domain, $web_url_domain, $home_url); | ||
| 82 | 107 | ||
| 83 | if ($source_list) { | 108 | if ($source_list) { |
| 84 | - $html = $this->upload_source($html, $source_list, $project_id); | 109 | + $html = $this->upload_source($html, $source_list, $project_id, $opts); |
| 85 | } | 110 | } |
| 86 | } catch (\Exception $e) { | 111 | } catch (\Exception $e) { |
| 87 | $collect_info->status = CollectTask::STATUS_FAIL; | 112 | $collect_info->status = CollectTask::STATUS_FAIL; |
| @@ -164,7 +189,7 @@ class HtmlLanguageCollect extends Command | @@ -164,7 +189,7 @@ class HtmlLanguageCollect extends Command | ||
| 164 | } | 189 | } |
| 165 | 190 | ||
| 166 | //正则匹配html资源 | 191 | //正则匹配html资源 |
| 167 | - protected function html_preg($html, $project_id, $domain) | 192 | + protected function html_preg($html, $project_id, $domain, $web_url_domain, $home_url) |
| 168 | { | 193 | { |
| 169 | $source = []; | 194 | $source = []; |
| 170 | 195 | ||
| @@ -176,7 +201,7 @@ class HtmlLanguageCollect extends Command | @@ -176,7 +201,7 @@ class HtmlLanguageCollect extends Command | ||
| 176 | preg_match_all('/<img\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $html, $result_img); | 201 | preg_match_all('/<img\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $html, $result_img); |
| 177 | $img = $result_img[2] ?? []; | 202 | $img = $result_img[2] ?? []; |
| 178 | foreach ($img as $vi) { | 203 | foreach ($img as $vi) { |
| 179 | - $check_vi = $this->url_check($vi, $project_id, $domain); | 204 | + $check_vi = $this->url_check($vi, $project_id, $domain, $web_url_domain, $home_url); |
| 180 | $check_vi && $source[] = $check_vi; | 205 | $check_vi && $source[] = $check_vi; |
| 181 | } | 206 | } |
| 182 | 207 | ||
| @@ -184,7 +209,7 @@ class HtmlLanguageCollect extends Command | @@ -184,7 +209,7 @@ class HtmlLanguageCollect extends Command | ||
| 184 | preg_match_all('/<script\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $html, $result_js); | 209 | preg_match_all('/<script\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $html, $result_js); |
| 185 | $js = $result_js[2] ?? []; | 210 | $js = $result_js[2] ?? []; |
| 186 | foreach ($js as $vj) { | 211 | foreach ($js as $vj) { |
| 187 | - $check_vj = $this->url_check($vj, $project_id, $domain); | 212 | + $check_vj = $this->url_check($vj, $project_id, $domain, $web_url_domain, $home_url); |
| 188 | $check_vj && $source[] = $check_vj; | 213 | $check_vj && $source[] = $check_vj; |
| 189 | } | 214 | } |
| 190 | 215 | ||
| @@ -192,7 +217,7 @@ class HtmlLanguageCollect extends Command | @@ -192,7 +217,7 @@ class HtmlLanguageCollect extends Command | ||
| 192 | preg_match_all('/<source\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $html, $result_video); | 217 | preg_match_all('/<source\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $html, $result_video); |
| 193 | $video = $result_video[2] ?? []; | 218 | $video = $result_video[2] ?? []; |
| 194 | foreach ($video as $vv) { | 219 | foreach ($video as $vv) { |
| 195 | - $check_vv = $this->url_check($vv, $project_id, $domain); | 220 | + $check_vv = $this->url_check($vv, $project_id, $domain, $web_url_domain, $home_url); |
| 196 | $check_vv && $source[] = $check_vv; | 221 | $check_vv && $source[] = $check_vv; |
| 197 | } | 222 | } |
| 198 | 223 | ||
| @@ -200,7 +225,7 @@ class HtmlLanguageCollect extends Command | @@ -200,7 +225,7 @@ class HtmlLanguageCollect extends Command | ||
| 200 | preg_match_all('/<link\s+[^>]*?href\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $html, $result_css); | 225 | preg_match_all('/<link\s+[^>]*?href\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $html, $result_css); |
| 201 | $css = $result_css[2] ?? []; | 226 | $css = $result_css[2] ?? []; |
| 202 | foreach ($css as $vc) { | 227 | foreach ($css as $vc) { |
| 203 | - $check_vc = $this->url_check($vc, $project_id, $domain); | 228 | + $check_vc = $this->url_check($vc, $project_id, $domain, $web_url_domain, $home_url); |
| 204 | $check_vc && $source[] = $check_vc; | 229 | $check_vc && $source[] = $check_vc; |
| 205 | } | 230 | } |
| 206 | 231 | ||
| @@ -208,7 +233,7 @@ class HtmlLanguageCollect extends Command | @@ -208,7 +233,7 @@ class HtmlLanguageCollect extends Command | ||
| 208 | preg_match_all("/url\(['\"]?(\s*[^>]+?)['\"]?\)/i", $html, $result_css_b); | 233 | preg_match_all("/url\(['\"]?(\s*[^>]+?)['\"]?\)/i", $html, $result_css_b); |
| 209 | $css_b = $result_css_b[1] ?? []; | 234 | $css_b = $result_css_b[1] ?? []; |
| 210 | foreach ($css_b as $vc_b) { | 235 | foreach ($css_b as $vc_b) { |
| 211 | - $check_vc_b = $this->url_check($vc_b, $project_id, $domain); | 236 | + $check_vc_b = $this->url_check($vc_b, $project_id, $domain, $web_url_domain, $home_url); |
| 212 | $check_vc_b && $source[] = $check_vc_b; | 237 | $check_vc_b && $source[] = $check_vc_b; |
| 213 | } | 238 | } |
| 214 | 239 | ||
| @@ -217,7 +242,7 @@ class HtmlLanguageCollect extends Command | @@ -217,7 +242,7 @@ class HtmlLanguageCollect extends Command | ||
| 217 | } | 242 | } |
| 218 | 243 | ||
| 219 | //判断资源是否需要下载 | 244 | //判断资源是否需要下载 |
| 220 | - protected function url_check($url, $project_id, $domain) | 245 | + protected function url_check($url, $project_id, $domain, $web_url_domain, $home_url) |
| 221 | { | 246 | { |
| 222 | if ($url) { | 247 | if ($url) { |
| 223 | $arr = parse_url($url); | 248 | $arr = parse_url($url); |
| @@ -227,11 +252,10 @@ class HtmlLanguageCollect extends Command | @@ -227,11 +252,10 @@ class HtmlLanguageCollect extends Command | ||
| 227 | $query = $arr['query'] ?? ''; | 252 | $query = $arr['query'] ?? ''; |
| 228 | 253 | ||
| 229 | if ( | 254 | if ( |
| 230 | - (strpos($host, '.globalso.') === false) && | ||
| 231 | - (strpos($host, '.goodao.') === false) && | ||
| 232 | - $path && (strpos($path, '.') !== false) | 255 | + (empty($host) || $host == $web_url_domain || $host == $home_url) |
| 256 | + && $path | ||
| 257 | + && (strpos($path, '.') !== false) | ||
| 233 | ) { | 258 | ) { |
| 234 | - | ||
| 235 | $source = CollectSource::where('project_id', $project_id)->where('origin', $url)->first(); | 259 | $source = CollectSource::where('project_id', $project_id)->where('origin', $url)->first(); |
| 236 | if (!$source) { | 260 | if (!$source) { |
| 237 | return [ | 261 | return [ |
| @@ -255,7 +279,7 @@ class HtmlLanguageCollect extends Command | @@ -255,7 +279,7 @@ class HtmlLanguageCollect extends Command | ||
| 255 | } | 279 | } |
| 256 | 280 | ||
| 257 | //下载并替换资源 | 281 | //下载并替换资源 |
| 258 | - protected function upload_source($html, $source, $project_id) | 282 | + protected function upload_source($html, $source, $project_id, $opts) |
| 259 | { | 283 | { |
| 260 | foreach ($source as $vs) { | 284 | foreach ($source as $vs) { |
| 261 | 285 | ||
| @@ -273,7 +297,7 @@ class HtmlLanguageCollect extends Command | @@ -273,7 +297,7 @@ class HtmlLanguageCollect extends Command | ||
| 273 | 297 | ||
| 274 | if (substr($new_source, -3, 3) == 'css') { | 298 | if (substr($new_source, -3, 3) == 'css') { |
| 275 | // 下载css文件中的资源 | 299 | // 下载css文件中的资源 |
| 276 | - $css_html = file_get_contents($vs['url_complete']); | 300 | + $css_html = file_get_contents($vs['url_complete'], false, stream_context_create($opts)); |
| 277 | preg_match_all("/url\(['\"](\s*[^>]+?)['\"]\)/i", $css_html, $result_css_source); | 301 | preg_match_all("/url\(['\"](\s*[^>]+?)['\"]\)/i", $css_html, $result_css_source); |
| 278 | $css_source = $result_css_source[1] ?? []; | 302 | $css_source = $result_css_source[1] ?? []; |
| 279 | 303 | ||
| @@ -290,6 +314,9 @@ class HtmlLanguageCollect extends Command | @@ -290,6 +314,9 @@ class HtmlLanguageCollect extends Command | ||
| 290 | if (!$vcs) { | 314 | if (!$vcs) { |
| 291 | continue; | 315 | continue; |
| 292 | } | 316 | } |
| 317 | + if (strpos($vcs, '.') === false) { | ||
| 318 | + continue; | ||
| 319 | + } | ||
| 293 | 320 | ||
| 294 | $source_info = CollectSource::where('project_id', $project_id)->where('origin', $vcs)->first(); | 321 | $source_info = CollectSource::where('project_id', $project_id)->where('origin', $vcs)->first(); |
| 295 | if ($source_info) { | 322 | if ($source_info) { |
| @@ -91,6 +91,13 @@ class ProjectUpdate extends Command | @@ -91,6 +91,13 @@ class ProjectUpdate extends Command | ||
| 91 | if ($data_language) { | 91 | if ($data_language) { |
| 92 | $language_list = array_column($data_language, 'short'); | 92 | $language_list = array_column($data_language, 'short'); |
| 93 | } | 93 | } |
| 94 | + //获取所有页面 | ||
| 95 | + $page_list = []; | ||
| 96 | + $url_page = 'https://' . $domain_arr['host'] . '/wp-content/cache/pages_list.json'; | ||
| 97 | + $data_page = http_get($url_page, ['charset' => 'UTF-8']); | ||
| 98 | + if ($data_page) { | ||
| 99 | + $page_list = array_column($data_page, 'path'); | ||
| 100 | + } | ||
| 94 | 101 | ||
| 95 | //设置数据库 | 102 | //设置数据库 |
| 96 | $project = ProjectServer::useProject($project_id); | 103 | $project = ProjectServer::useProject($project_id); |
| @@ -142,7 +149,7 @@ class ProjectUpdate extends Command | @@ -142,7 +149,7 @@ class ProjectUpdate extends Command | ||
| 142 | $id = $keyword['id']; | 149 | $id = $keyword['id']; |
| 143 | } | 150 | } |
| 144 | 151 | ||
| 145 | - CollectTask::_insert($item['url'], $project_id, RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $link_type, $language_list); | 152 | + CollectTask::_insert($item['url'], $project_id, RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $link_type, $language_list, $page_list); |
| 146 | } | 153 | } |
| 147 | } | 154 | } |
| 148 | } | 155 | } |
| @@ -274,7 +281,7 @@ class ProjectUpdate extends Command | @@ -274,7 +281,7 @@ class ProjectUpdate extends Command | ||
| 274 | $id = $product['id']; | 281 | $id = $product['id']; |
| 275 | } | 282 | } |
| 276 | 283 | ||
| 277 | - CollectTask::_insert($item['url'], $project_id, RouteMap::SOURCE_PRODUCT, $id, $link_type, $language_list); | 284 | + CollectTask::_insert($item['url'], $project_id, RouteMap::SOURCE_PRODUCT, $id, $link_type, $language_list, $page_list); |
| 278 | } | 285 | } |
| 279 | } | 286 | } |
| 280 | } | 287 | } |
| @@ -328,7 +335,7 @@ class ProjectUpdate extends Command | @@ -328,7 +335,7 @@ class ProjectUpdate extends Command | ||
| 328 | $id = $news['id']; | 335 | $id = $news['id']; |
| 329 | } | 336 | } |
| 330 | 337 | ||
| 331 | - CollectTask::_insert($item['url'], $project_id, $api_type == 'news' ? RouteMap::SOURCE_NEWS : RouteMap::SOURCE_BLOG, $id, $link_type, $language_list); | 338 | + CollectTask::_insert($item['url'], $project_id, $api_type == 'news' ? RouteMap::SOURCE_NEWS : RouteMap::SOURCE_BLOG, $id, $link_type, $language_list, $page_list); |
| 332 | } | 339 | } |
| 333 | } | 340 | } |
| 334 | } | 341 | } |
| @@ -376,7 +383,7 @@ class ProjectUpdate extends Command | @@ -376,7 +383,7 @@ class ProjectUpdate extends Command | ||
| 376 | $id = $custom['id']; | 383 | $id = $custom['id']; |
| 377 | } | 384 | } |
| 378 | 385 | ||
| 379 | - CollectTask::_insert($item['url'], $project_id, RouteMap::SOURCE_PAGE, $id, $link_type, $language_list); | 386 | + CollectTask::_insert($item['url'], $project_id, RouteMap::SOURCE_PAGE, $id, $link_type, $language_list, $page_list); |
| 380 | } | 387 | } |
| 381 | } | 388 | } |
| 382 | } | 389 | } |
app/Console/Commands/UpdateRoute.php
0 → 100644
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * @remark : | ||
| 4 | + * @name :UpdateRoute.php | ||
| 5 | + * @author :lyh | ||
| 6 | + * @method :post | ||
| 7 | + * @time :2023/11/20 15:07 | ||
| 8 | + */ | ||
| 9 | + | ||
| 10 | +namespace App\Console\Commands; | ||
| 11 | + | ||
| 12 | +use App\Models\Blog\Blog; | ||
| 13 | +use App\Models\Blog\BlogCategory; | ||
| 14 | +use App\Models\News\News; | ||
| 15 | +use App\Models\News\NewsCategory; | ||
| 16 | +use App\Models\Product\Category; | ||
| 17 | +use App\Models\Product\Keyword; | ||
| 18 | +use App\Models\Product\Product; | ||
| 19 | +use App\Models\Project\Project; | ||
| 20 | +use App\Models\RouteMap\RouteMap; | ||
| 21 | +use App\Services\ProjectServer; | ||
| 22 | +use Illuminate\Console\Command; | ||
| 23 | +use Illuminate\Support\Facades\DB; | ||
| 24 | + | ||
| 25 | +/** | ||
| 26 | + * @remark :更新所有项目的路由 | ||
| 27 | + * @name :UpdateRoute | ||
| 28 | + * @author :lyh | ||
| 29 | + * @method :post | ||
| 30 | + * @time :2023/11/20 15:08 | ||
| 31 | + */ | ||
| 32 | +class UpdateRoute extends Command | ||
| 33 | +{ | ||
| 34 | + /** | ||
| 35 | + * The name and signature of the console command. | ||
| 36 | + * | ||
| 37 | + * @var string | ||
| 38 | + */ | ||
| 39 | + protected $signature = 'update_route'; | ||
| 40 | + | ||
| 41 | + /** | ||
| 42 | + * The console command description. | ||
| 43 | + * | ||
| 44 | + * @var string | ||
| 45 | + */ | ||
| 46 | + protected $description = '更新路由'; | ||
| 47 | + | ||
| 48 | + /** | ||
| 49 | + * @remark :统一更新路由 | ||
| 50 | + * @name :handle | ||
| 51 | + * @author :lyh | ||
| 52 | + * @method :post | ||
| 53 | + * @time :2023/11/20 15:13 | ||
| 54 | + */ | ||
| 55 | + public function handle(){ | ||
| 56 | + $projectModel = new Project(); | ||
| 57 | + $lists = $projectModel->list(['is_upgrade'=>0,'type'=>['!=',0]]); | ||
| 58 | + foreach ($lists as $k => $v){ | ||
| 59 | + echo date('Y-m-d H:i:s') . ' start: 项目id为' . $v['id'] . PHP_EOL; | ||
| 60 | + ProjectServer::useProject($v['id']); | ||
| 61 | + $this->setProductRoute($v['id']); | ||
| 62 | + $this->setProductKeywordRoute($v['id']); | ||
| 63 | + $this->setBlogRoute($v['id']); | ||
| 64 | + $this->setNewsRoute($v['id']); | ||
| 65 | + $this->setBlogCateRoute($v['id']); | ||
| 66 | + $this->setNewsCateRoute($v['id']); | ||
| 67 | + DB::disconnect('custom_mysql'); | ||
| 68 | + } | ||
| 69 | + echo date('Y-m-d H:i:s') . ' end: 项目id为' . $v['id'] . PHP_EOL; | ||
| 70 | + } | ||
| 71 | + | ||
| 72 | + /** | ||
| 73 | + * @remark :设置路由 | ||
| 74 | + * @name :setRoute | ||
| 75 | + * @author :lyh | ||
| 76 | + * @method :post | ||
| 77 | + * @time :2023/11/20 15:30 | ||
| 78 | + */ | ||
| 79 | + public function setProductRoute($project_id){ | ||
| 80 | + $productModel = new Product(); | ||
| 81 | + $productList = $productModel->list(['status'=>['!=',2]],'id',['id','route']); | ||
| 82 | + foreach ($productList as $v){ | ||
| 83 | + $route = preg_replace('/-product.*/', '', $v['route']); | ||
| 84 | + $route = RouteMap::setRoute($route, RouteMap::SOURCE_PRODUCT, $v['id'], $project_id); | ||
| 85 | + $route = $route.'-product'; | ||
| 86 | + $productModel->edit(['route'=>$route],['id'=>$v['id']]); | ||
| 87 | + RouteMap::setRoute($route, RouteMap::SOURCE_PRODUCT, $v['id'], $project_id); | ||
| 88 | + } | ||
| 89 | + return true; | ||
| 90 | + } | ||
| 91 | + | ||
| 92 | + /** | ||
| 93 | + * @remark :设置路由 | ||
| 94 | + * @name :setRoute | ||
| 95 | + * @author :lyh | ||
| 96 | + * @method :post | ||
| 97 | + * @time :2023/11/20 15:30 | ||
| 98 | + */ | ||
| 99 | + public function setNewsRoute($project_id){ | ||
| 100 | + $newsModel = new News(); | ||
| 101 | + $newsList = $newsModel->list(['status'=>['!=',2]],'id',['id','url']); | ||
| 102 | + foreach ($newsList as $v){ | ||
| 103 | + RouteMap::setRoute($v['url'], RouteMap::SOURCE_NEWS, $v['id'], $project_id); | ||
| 104 | + } | ||
| 105 | + return true; | ||
| 106 | + } | ||
| 107 | + | ||
| 108 | + /** | ||
| 109 | + * @remark :设置路由 | ||
| 110 | + * @name :setRoute | ||
| 111 | + * @author :lyh | ||
| 112 | + * @method :post | ||
| 113 | + * @time :2023/11/20 15:30 | ||
| 114 | + */ | ||
| 115 | + public function setNewsCateRoute($project_id){ | ||
| 116 | + $newsCateModel = new NewsCategory(); | ||
| 117 | + $newsList = $newsCateModel->list([],'id',['id','alias']); | ||
| 118 | + foreach ($newsList as $v){ | ||
| 119 | + RouteMap::setRoute($v['alias'], RouteMap::SOURCE_NEWS_CATE, $v['id'], $project_id); | ||
| 120 | + } | ||
| 121 | + return true; | ||
| 122 | + } | ||
| 123 | + | ||
| 124 | + /** | ||
| 125 | + * @remark :设置路由 | ||
| 126 | + * @name :setRoute | ||
| 127 | + * @author :lyh | ||
| 128 | + * @method :post | ||
| 129 | + * @time :2023/11/20 15:30 | ||
| 130 | + */ | ||
| 131 | + public function setBlogRoute($project_id){ | ||
| 132 | + $blogModel = new Blog(); | ||
| 133 | + $blogList = $blogModel->list(['status'=>['!=',2]],'id',['id','url']); | ||
| 134 | + foreach ($blogList as $v){ | ||
| 135 | + RouteMap::setRoute($v['url'], RouteMap::SOURCE_BLOG, $v['id'], $project_id); | ||
| 136 | + } | ||
| 137 | + return true; | ||
| 138 | + } | ||
| 139 | + | ||
| 140 | + /** | ||
| 141 | + * @remark :设置路由 | ||
| 142 | + * @name :setRoute | ||
| 143 | + * @author :lyh | ||
| 144 | + * @method :post | ||
| 145 | + * @time :2023/11/20 15:30 | ||
| 146 | + */ | ||
| 147 | + public function setBlogCateRoute($project_id){ | ||
| 148 | + $blogCateModel = new BlogCategory(); | ||
| 149 | + $blogList = $blogCateModel->list([],'id',['id','alias']); | ||
| 150 | + foreach ($blogList as $v){ | ||
| 151 | + RouteMap::setRoute($v['alias'], RouteMap::SOURCE_BLOG_CATE, $v['id'], $project_id); | ||
| 152 | + } | ||
| 153 | + return true; | ||
| 154 | + } | ||
| 155 | + | ||
| 156 | + /** | ||
| 157 | + * @remark :设置路由 | ||
| 158 | + * @name :setRoute | ||
| 159 | + * @author :lyh | ||
| 160 | + * @method :post | ||
| 161 | + * @time :2023/11/20 15:30 | ||
| 162 | + */ | ||
| 163 | + public function setProductKeywordRoute($project_id){ | ||
| 164 | + $keywordModel = new Keyword(); | ||
| 165 | + $keywordList = $keywordModel->list([],'id',['id','route']); | ||
| 166 | + foreach ($keywordList as $v){ | ||
| 167 | + if(!ends_with($v['route'],'-tag')){ | ||
| 168 | + $route = $v['route'].'-tag'; | ||
| 169 | + $keywordModel->edit(['route'=>$route],['id'=>$v['id']]); | ||
| 170 | + RouteMap::setRoute($route, RouteMap::SOURCE_BLOG_CATE, $v['id'], $project_id); | ||
| 171 | + } | ||
| 172 | + } | ||
| 173 | + return true; | ||
| 174 | + } | ||
| 175 | +} |
| @@ -180,7 +180,8 @@ class UpdateSeoTdk extends Command | @@ -180,7 +180,8 @@ class UpdateSeoTdk extends Command | ||
| 180 | Redis::expire($cache_key, 120); | 180 | Redis::expire($cache_key, 120); |
| 181 | 181 | ||
| 182 | echo date('Y-m-d H:i:s') . '更新--' . $table . ': 项目id' . $project_id . ':id' . $v['id'] . PHP_EOL; | 182 | echo date('Y-m-d H:i:s') . '更新--' . $table . ': 项目id' . $project_id . ':id' . $v['id'] . PHP_EOL; |
| 183 | - | 183 | + $v = DB::connection('custom_mysql')->table($table)->where('id', $v['id'])->first(); |
| 184 | + $v = (array)$v; | ||
| 184 | $data = []; | 185 | $data = []; |
| 185 | $json_field = ''; | 186 | $json_field = ''; |
| 186 | foreach ($map as $ai_key => $field) { | 187 | foreach ($map as $ai_key => $field) { |
app/Console/Commands/UpdateSeoTdkCrontab.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Console\Commands; | ||
| 4 | + | ||
| 5 | +use App\Helper\Arr; | ||
| 6 | +use App\Helper\Common; | ||
| 7 | +use App\Helper\Gpt; | ||
| 8 | +use App\Helper\Translate; | ||
| 9 | +use App\Models\Ai\AiCommand; | ||
| 10 | +use App\Models\Mail\Mail; | ||
| 11 | +use App\Models\Project\DeployOptimize; | ||
| 12 | +use App\Models\Project\Project; | ||
| 13 | +use App\Models\Project\ProjectUpdateTdk; | ||
| 14 | +use App\Models\User\User; | ||
| 15 | +use App\Services\ProjectServer; | ||
| 16 | +use Illuminate\Console\Command; | ||
| 17 | +use Illuminate\Support\Facades\Cache; | ||
| 18 | +use Illuminate\Support\Facades\DB; | ||
| 19 | +use Illuminate\Support\Facades\Redis; | ||
| 20 | + | ||
| 21 | +/** | ||
| 22 | + * 初始化项目 | ||
| 23 | + * Class InitProject | ||
| 24 | + * @package App\Console\Commands | ||
| 25 | + * @author zbj | ||
| 26 | + * @date 2023/10/8 | ||
| 27 | + */ | ||
| 28 | +class UpdateSeoTdkCrontab extends Command | ||
| 29 | +{ | ||
| 30 | + /** | ||
| 31 | + * The name and signature of the console command. | ||
| 32 | + * | ||
| 33 | + * @var string | ||
| 34 | + */ | ||
| 35 | + protected $signature = 'update_seo_tdk_crontab'; | ||
| 36 | + | ||
| 37 | + /** | ||
| 38 | + * The console command description. | ||
| 39 | + * | ||
| 40 | + * @var string | ||
| 41 | + */ | ||
| 42 | + protected $description = '一键生成tdk'; | ||
| 43 | + | ||
| 44 | + /** | ||
| 45 | + * @return bool | ||
| 46 | + */ | ||
| 47 | + public function handle() | ||
| 48 | + { | ||
| 49 | + $project_ids = Project::where('type', Project::TYPE_TWO)->pluck('id')->toArray(); | ||
| 50 | + foreach ($project_ids as $project_id){ | ||
| 51 | + ProjectUpdateTdk::add_task($project_id); | ||
| 52 | + } | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | +} |
| @@ -6,6 +6,7 @@ use App\Enums\Common\Code; | @@ -6,6 +6,7 @@ use App\Enums\Common\Code; | ||
| 6 | use App\Enums\Common\Common; | 6 | use App\Enums\Common\Common; |
| 7 | use App\Http\Controllers\Aside\BaseController; | 7 | use App\Http\Controllers\Aside\BaseController; |
| 8 | use App\Http\Logic\Aside\Manage\MenuLogic; | 8 | use App\Http\Logic\Aside\Manage\MenuLogic; |
| 9 | +use App\Models\Inquiry\InquiryData; | ||
| 9 | use App\Models\Manage\Manage; | 10 | use App\Models\Manage\Manage; |
| 10 | use Illuminate\Support\Facades\Cache; | 11 | use Illuminate\Support\Facades\Cache; |
| 11 | use Illuminate\Support\Facades\Hash; | 12 | use Illuminate\Support\Facades\Hash; |
| @@ -71,4 +72,28 @@ class IndexController extends BaseController | @@ -71,4 +72,28 @@ class IndexController extends BaseController | ||
| 71 | $this->response('success'); | 72 | $this->response('success'); |
| 72 | } | 73 | } |
| 73 | 74 | ||
| 75 | + /** | ||
| 76 | + * @remark :同步询盘记录 | ||
| 77 | + * @name :sync_inquiry | ||
| 78 | + * @author :lyh | ||
| 79 | + * @method :post | ||
| 80 | + * @time :2023/11/16 9:51 | ||
| 81 | + */ | ||
| 82 | + public function sync_inquiry(){ | ||
| 83 | + $this->request->validate([ | ||
| 84 | + 'data' => 'required|array', | ||
| 85 | + 'identifying'=>'required', | ||
| 86 | + ], [ | ||
| 87 | + 'data.required' => '自定义询盘数据不为空', | ||
| 88 | + 'data.array' => '必须为数组', | ||
| 89 | + 'identifying.required' => '唯一标识不为空', | ||
| 90 | + ]); | ||
| 91 | + $inquiryModel = new InquiryData(); | ||
| 92 | + $rs = $inquiryModel->add($this->param); | ||
| 93 | + if($rs === false){ | ||
| 94 | + $this->response('error',Code::SYSTEM_ERROR); | ||
| 95 | + } | ||
| 96 | + $this->response('success'); | ||
| 97 | + } | ||
| 98 | + | ||
| 74 | } | 99 | } |
| @@ -13,6 +13,7 @@ use App\Enums\Common\Code; | @@ -13,6 +13,7 @@ use App\Enums\Common\Code; | ||
| 13 | use App\Http\Controllers\Aside\BaseController; | 13 | use App\Http\Controllers\Aside\BaseController; |
| 14 | use App\Models\ASide\APublicModel; | 14 | use App\Models\ASide\APublicModel; |
| 15 | use App\Models\Channel\Channel; | 15 | use App\Models\Channel\Channel; |
| 16 | +use App\Models\Domain\DomainInfo; | ||
| 16 | use App\Models\Manage\Manage; | 17 | use App\Models\Manage\Manage; |
| 17 | use App\Models\Project\OnlineCheck; | 18 | use App\Models\Project\OnlineCheck; |
| 18 | use App\Models\Project\Project; | 19 | use App\Models\Project\Project; |
| @@ -82,7 +83,6 @@ class OnlineController extends BaseController | @@ -82,7 +83,6 @@ class OnlineController extends BaseController | ||
| 82 | 'gl_project_deploy_optimize.assist_mid AS optimize_assist_mid', | 83 | 'gl_project_deploy_optimize.assist_mid AS optimize_assist_mid', |
| 83 | 'gl_project_deploy_optimize.tech_mid AS optimize_tech_mid', | 84 | 'gl_project_deploy_optimize.tech_mid AS optimize_tech_mid', |
| 84 | 'gl_project_deploy_optimize.domain AS domain', | 85 | 'gl_project_deploy_optimize.domain AS domain', |
| 85 | - 'gl_project_payment.amount AS amount', | ||
| 86 | ]; | 86 | ]; |
| 87 | return $select; | 87 | return $select; |
| 88 | } | 88 | } |
| @@ -127,9 +127,14 @@ class OnlineController extends BaseController | @@ -127,9 +127,14 @@ class OnlineController extends BaseController | ||
| 127 | * @time :2023/8/18 10:58 | 127 | * @time :2023/8/18 10:58 |
| 128 | */ | 128 | */ |
| 129 | public function searchParam(&$query){ | 129 | public function searchParam(&$query){ |
| 130 | - //搜索条件处理 | ||
| 131 | - if(isset($this->map['title'])){ | ||
| 132 | - $query = $query->where('gl_project.title','like','%'.$this->map['title'].'%'); | 130 | + if(!empty($this->map['search']) && !empty($this->map['search_type'])){ |
| 131 | + // 搜索域名 | ||
| 132 | + if($this->map['search_type'] == 'test_domain'){ | ||
| 133 | + $query->where('gl_project_deploy_build.test_domain','like','%'.$this->map['search'].'%'); | ||
| 134 | + } else { | ||
| 135 | + // 搜索名称 | ||
| 136 | + $query->where('gl_project.title', 'like', '%' . $this->map['search'] . '%'); | ||
| 137 | + } | ||
| 133 | } | 138 | } |
| 134 | $query = $query->where('gl_project.status',1);//TODO::已提交审核 | 139 | $query = $query->where('gl_project.status',1);//TODO::已提交审核 |
| 135 | return $query; | 140 | return $query; |
| @@ -103,6 +103,7 @@ class OptimizeController extends BaseController | @@ -103,6 +103,7 @@ class OptimizeController extends BaseController | ||
| 103 | 'gl_project.finish_remain_day AS finish_remain_day', | 103 | 'gl_project.finish_remain_day AS finish_remain_day', |
| 104 | 'gl_project.is_remain_today AS is_remain_today', | 104 | 'gl_project.is_remain_today AS is_remain_today', |
| 105 | 'gl_project.remain_day AS remain_day', | 105 | 'gl_project.remain_day AS remain_day', |
| 106 | + 'gl_project.robots AS robots', | ||
| 106 | 'gl_project_online_check.id AS online_check_id', | 107 | 'gl_project_online_check.id AS online_check_id', |
| 107 | 'gl_project_online_check.question AS question', | 108 | 'gl_project_online_check.question AS question', |
| 108 | 'gl_project_online_check.go_question AS go_question', | 109 | 'gl_project_online_check.go_question AS go_question', |
| @@ -224,4 +225,27 @@ class OptimizeController extends BaseController | @@ -224,4 +225,27 @@ class OptimizeController extends BaseController | ||
| 224 | } | 225 | } |
| 225 | $this->response('success'); | 226 | $this->response('success'); |
| 226 | } | 227 | } |
| 228 | + | ||
| 229 | + /** | ||
| 230 | + * @remark :设置开关 | ||
| 231 | + * @name :setRobots | ||
| 232 | + * @author :lyh | ||
| 233 | + * @method :post | ||
| 234 | + * @time :2023/11/20 9:42 | ||
| 235 | + */ | ||
| 236 | + public function setRobots(){ | ||
| 237 | + $this->request->validate([ | ||
| 238 | + 'robots'=>'required', | ||
| 239 | + 'project_id'=>'required', | ||
| 240 | + ],[ | ||
| 241 | + 'robots.required' => 'robots不能为空', | ||
| 242 | + 'project_id.required' => 'project_id不能为空', | ||
| 243 | + ]); | ||
| 244 | + $projectModel = new Project(); | ||
| 245 | + $rs = $projectModel->edit(['robots'=>$this->param['robots']],['id'=>$this->param['project_id']]); | ||
| 246 | + if($rs === false){ | ||
| 247 | + $this->response('系统错误,请联系管理员',Code::SYSTEM_ERROR); | ||
| 248 | + } | ||
| 249 | + $this->response('success'); | ||
| 250 | + } | ||
| 227 | } | 251 | } |
| @@ -14,6 +14,8 @@ use App\Http\Requests\Aside\Project\ProcessRecordsRequest; | @@ -14,6 +14,8 @@ use App\Http\Requests\Aside\Project\ProcessRecordsRequest; | ||
| 14 | use App\Http\Requests\Aside\Project\ProjectRequest; | 14 | use App\Http\Requests\Aside\Project\ProjectRequest; |
| 15 | use App\Models\ASide\APublicModel; | 15 | use App\Models\ASide\APublicModel; |
| 16 | use App\Models\Channel\Channel; | 16 | use App\Models\Channel\Channel; |
| 17 | +use App\Models\Channel\User; | ||
| 18 | +use App\Models\Channel\Zone; | ||
| 17 | use App\Models\Com\City; | 19 | use App\Models\Com\City; |
| 18 | use App\Models\Devops\ServerConfig; | 20 | use App\Models\Devops\ServerConfig; |
| 19 | use App\Models\Domain\DomainInfo; | 21 | use App\Models\Domain\DomainInfo; |
| @@ -204,6 +206,9 @@ class ProjectController extends BaseController | @@ -204,6 +206,9 @@ class ProjectController extends BaseController | ||
| 204 | if(isset($this->map['channel_id']) && !empty($this->map['channel_id'])){ | 206 | if(isset($this->map['channel_id']) && !empty($this->map['channel_id'])){ |
| 205 | $query->where('gl_project.channel','like','%"channel_id": "'.$this->map['channel_id'].'"%'); | 207 | $query->where('gl_project.channel','like','%"channel_id": "'.$this->map['channel_id'].'"%'); |
| 206 | } | 208 | } |
| 209 | + if(isset($this->map['user_id']) && !empty($this->map['user_id'])){ | ||
| 210 | + $query->where('gl_project.channel','like','%"user_id": "'.$this->map['channel_id'].'"%'); | ||
| 211 | + } | ||
| 207 | return $query; | 212 | return $query; |
| 208 | } | 213 | } |
| 209 | 214 | ||
| @@ -800,10 +805,72 @@ class ProjectController extends BaseController | @@ -800,10 +805,72 @@ class ProjectController extends BaseController | ||
| 800 | ],[ | 805 | ],[ |
| 801 | 'project_id.required' => 'project_id不能为空', | 806 | 'project_id.required' => 'project_id不能为空', |
| 802 | ]); | 807 | ]); |
| 803 | - | ||
| 804 | $token = $logic->getSiteToken($this->map); | 808 | $token = $logic->getSiteToken($this->map); |
| 805 | - | ||
| 806 | $this->response('success',Code::SUCCESS,['site_token' => $token]); | 809 | $this->response('success',Code::SUCCESS,['site_token' => $token]); |
| 810 | + } | ||
| 811 | + | ||
| 812 | + /** | ||
| 813 | + * @remark :单独保存其他项目配置 | ||
| 814 | + * @name :saveOtherProject | ||
| 815 | + * @author :lyh | ||
| 816 | + * @method :post | ||
| 817 | + * @time :2023/11/17 15:23 | ||
| 818 | + */ | ||
| 819 | + public function saveOtherProject(ProjectLogic $logic){ | ||
| 820 | + $this->request->validate([ | ||
| 821 | + 'id'=>'required', | ||
| 822 | + 'aicc'=>'required', | ||
| 823 | + 'hagro'=>'required', | ||
| 824 | + 'exclusive_aicc_day'=>'required', | ||
| 825 | + 'exclusive_hagro_day'=>'required', | ||
| 826 | + ],[ | ||
| 827 | + 'id.required' => 'id不能为空', | ||
| 828 | + 'aicc.required' => 'aicc是否开启不能为空', | ||
| 829 | + 'hagro.required' => 'hagro是否开启不能为空', | ||
| 830 | + 'exclusive_aicc_day.required' => '服务天数不能为空', | ||
| 831 | + 'exclusive_hagro_day.required' => '服务天数不能为空', | ||
| 832 | + ]); | ||
| 833 | + $logic->saveOtherProject(); | ||
| 834 | + $this->response('success'); | ||
| 835 | + } | ||
| 807 | 836 | ||
| 837 | + /** | ||
| 838 | + * @remark :获取其他项目配置 | ||
| 839 | + * @name :getOtherProject | ||
| 840 | + * @author :lyh | ||
| 841 | + * @method :post | ||
| 842 | + * @time :2023/11/17 15:23 | ||
| 843 | + */ | ||
| 844 | + public function getOtherProject(ProjectLogic $logic){ | ||
| 845 | + $this->request->validate([ | ||
| 846 | + 'id'=>'required', | ||
| 847 | + ],[ | ||
| 848 | + 'id.required' => 'id不能为空', | ||
| 849 | + ]); | ||
| 850 | + $info = $logic->getOtherProject(); | ||
| 851 | + $this->response('success',Code::SUCCESS,$info); | ||
| 852 | + } | ||
| 853 | + | ||
| 854 | + /** | ||
| 855 | + * @remark :获取渠道信息 | ||
| 856 | + * @name :getChannel | ||
| 857 | + * @author :lyh | ||
| 858 | + * @method :post | ||
| 859 | + * @time :2023/11/17 16:08 | ||
| 860 | + */ | ||
| 861 | + public function getChannel(){ | ||
| 862 | + $zoneModel = new Zone(); | ||
| 863 | + $zone_list = $zoneModel->list(); | ||
| 864 | + $channelModel = new Channel(); | ||
| 865 | + $channelUserModel = new User(); | ||
| 866 | + foreach ($zone_list as $k => $v){ | ||
| 867 | + $channel_list = $channelModel->list(['zone_id'=>$v['id']]); | ||
| 868 | + foreach ($channel_list as $k1 => $v1){ | ||
| 869 | + $user_list = $channelUserModel->list(['channel_id'=>$v1['id']]); | ||
| 870 | + $channel_list[$k1]['sub'] = $user_list; | ||
| 871 | + } | ||
| 872 | + $zone_list[$k]['sub'] = $channel_list; | ||
| 873 | + } | ||
| 874 | + $this->response('success',Code::SUCCESS,$zone_list); | ||
| 808 | } | 875 | } |
| 809 | } | 876 | } |
| @@ -24,7 +24,7 @@ class BlogController extends BaseController | @@ -24,7 +24,7 @@ class BlogController extends BaseController | ||
| 24 | * @time :2023/9/14 10:45 | 24 | * @time :2023/9/14 10:45 |
| 25 | */ | 25 | */ |
| 26 | public function lists(BlogModel $blogModel){ | 26 | public function lists(BlogModel $blogModel){ |
| 27 | - $filed = ['id','category_id','operator_id','status','created_at','label_id','image','updated_at','name','sort','url']; | 27 | + $filed = ['id','category_id','operator_id','status','created_at','label_id','image','updated_at','name','sort','url','release_at']; |
| 28 | $this->order = 'sort'; | 28 | $this->order = 'sort'; |
| 29 | $query = $blogModel->orderBy($this->order ,'desc')->orderBy('id','desc'); | 29 | $query = $blogModel->orderBy($this->order ,'desc')->orderBy('id','desc'); |
| 30 | $query = $this->searchParam($query); | 30 | $query = $this->searchParam($query); |
| @@ -16,7 +16,6 @@ use App\Helper\Common; | @@ -16,7 +16,6 @@ use App\Helper\Common; | ||
| 16 | use App\Helper\Translate; | 16 | use App\Helper\Translate; |
| 17 | use App\Helper\Wechat; | 17 | use App\Helper\Wechat; |
| 18 | use App\Http\Logic\Bside\User\UserLoginLogic; | 18 | use App\Http\Logic\Bside\User\UserLoginLogic; |
| 19 | -use App\Models\Channel\Channel; | ||
| 20 | use App\Models\Domain\DomainInfo; | 19 | use App\Models\Domain\DomainInfo; |
| 21 | use App\Models\Project\Project; | 20 | use App\Models\Project\Project; |
| 22 | use App\Models\Service\Service; | 21 | use App\Models\Service\Service; |
| @@ -25,9 +24,7 @@ use App\Models\User\DeptUser; | @@ -25,9 +24,7 @@ use App\Models\User\DeptUser; | ||
| 25 | use App\Models\User\ProjectRole; | 24 | use App\Models\User\ProjectRole; |
| 26 | use App\Models\User\User; | 25 | use App\Models\User\User; |
| 27 | use App\Utils\EncryptUtils; | 26 | use App\Utils\EncryptUtils; |
| 28 | -use App\Utils\LogUtils; | ||
| 29 | use Illuminate\Support\Facades\Cache; | 27 | use Illuminate\Support\Facades\Cache; |
| 30 | -use Illuminate\Support\Facades\Http; | ||
| 31 | use Mrgoon\AliSms\AliSms; | 28 | use Mrgoon\AliSms\AliSms; |
| 32 | 29 | ||
| 33 | class LoginController extends BaseController | 30 | class LoginController extends BaseController |
| @@ -302,4 +299,5 @@ class LoginController extends BaseController | @@ -302,4 +299,5 @@ class LoginController extends BaseController | ||
| 302 | } | 299 | } |
| 303 | return $data; | 300 | return $data; |
| 304 | } | 301 | } |
| 302 | + | ||
| 305 | } | 303 | } |
| @@ -110,4 +110,13 @@ class NavController extends BaseController | @@ -110,4 +110,13 @@ class NavController extends BaseController | ||
| 110 | $navLogic->navSort(); | 110 | $navLogic->navSort(); |
| 111 | $this->response('success'); | 111 | $this->response('success'); |
| 112 | } | 112 | } |
| 113 | + | ||
| 114 | + /** | ||
| 115 | + * 一键导入子菜单 | ||
| 116 | + * @author zbj | ||
| 117 | + * @date 2023/11/21 | ||
| 118 | + */ | ||
| 119 | + public function import(){ | ||
| 120 | + | ||
| 121 | + } | ||
| 113 | } | 122 | } |
| @@ -24,7 +24,7 @@ class NewsController extends BaseController | @@ -24,7 +24,7 @@ class NewsController extends BaseController | ||
| 24 | * @method | 24 | * @method |
| 25 | */ | 25 | */ |
| 26 | public function lists(NewsModel $news){ | 26 | public function lists(NewsModel $news){ |
| 27 | - $filed = ['id','category_id','operator_id','status','created_at','image','updated_at','name','sort','url']; | 27 | + $filed = ['id','category_id','operator_id','status','created_at','image','updated_at','name','sort','url', 'release_at']; |
| 28 | $this->order = 'sort'; | 28 | $this->order = 'sort'; |
| 29 | $query = $news->orderBy($this->order ,'desc')->orderBy('id','desc'); | 29 | $query = $news->orderBy($this->order ,'desc')->orderBy('id','desc'); |
| 30 | $query = $this->searchParam($query); | 30 | $query = $this->searchParam($query); |
| @@ -24,6 +24,10 @@ class WebSettingImageController extends BaseController | @@ -24,6 +24,10 @@ class WebSettingImageController extends BaseController | ||
| 24 | */ | 24 | */ |
| 25 | public function lists(WebSettingImage $webSettingImage){ | 25 | public function lists(WebSettingImage $webSettingImage){ |
| 26 | $list = $webSettingImage->list([],'id',['id','image','type']); | 26 | $list = $webSettingImage->list([],'id',['id','image','type']); |
| 27 | + foreach ($list as $k=>$v){ | ||
| 28 | + $v['image'] = getImageUrl($v['image']); | ||
| 29 | + $list[$k] = $v; | ||
| 30 | + } | ||
| 27 | $this->response('success',Code::SUCCESS,$list); | 31 | $this->response('success',Code::SUCCESS,$list); |
| 28 | } | 32 | } |
| 29 | 33 | ||
| @@ -35,17 +39,16 @@ class WebSettingImageController extends BaseController | @@ -35,17 +39,16 @@ class WebSettingImageController extends BaseController | ||
| 35 | * @time :2023/9/21 15:17 | 39 | * @time :2023/9/21 15:17 |
| 36 | */ | 40 | */ |
| 37 | public function save(WebSettingImage $webSettingImage){ | 41 | public function save(WebSettingImage $webSettingImage){ |
| 42 | + try { | ||
| 43 | + $webSettingImage->del(['project_id'=>$this->user['project_id']]); | ||
| 38 | foreach ($this->param['data'] as $v){ | 44 | foreach ($this->param['data'] as $v){ |
| 39 | - if(isset($v['id']) && !empty($v['id'])){ | ||
| 40 | - $rs = $webSettingImage->edit($v,['id'=>$v['id']]); | ||
| 41 | - }else{ | ||
| 42 | $v['project_id'] = $this->user['project_id']; | 45 | $v['project_id'] = $this->user['project_id']; |
| 43 | - $rs = $webSettingImage->add($v); | 46 | + $v['image'] = str_replace_url($v['image']); |
| 47 | + $webSettingImage->add($v); | ||
| 44 | } | 48 | } |
| 45 | - if($rs === false){ | 49 | + }catch (\Exception $e){ |
| 46 | $this->response('系统错误请联系管理员'); | 50 | $this->response('系统错误请联系管理员'); |
| 47 | } | 51 | } |
| 48 | - } | ||
| 49 | $this->response('success'); | 52 | $this->response('success'); |
| 50 | } | 53 | } |
| 51 | } | 54 | } |
| @@ -50,23 +50,6 @@ class BTemplateController extends BaseController | @@ -50,23 +50,6 @@ class BTemplateController extends BaseController | ||
| 50 | } | 50 | } |
| 51 | 51 | ||
| 52 | /** | 52 | /** |
| 53 | - * @remark :设置默认模板 | ||
| 54 | - * @name :setModuleTemplate | ||
| 55 | - * @author :lyh | ||
| 56 | - * @method :post | ||
| 57 | - * @time :2023/6/29 9:39 | ||
| 58 | - */ | ||
| 59 | - public function setPublicTemplate(BTemplateLogic $BTemplateLogic){ | ||
| 60 | - $this->request->validate([ | ||
| 61 | - 'template_id'=>['required'], | ||
| 62 | - ],[ | ||
| 63 | - 'template_id.required' => '模版ID不能为空', | ||
| 64 | - ]); | ||
| 65 | - $BTemplateLogic->setTemplate(); | ||
| 66 | - $this->response('success'); | ||
| 67 | - } | ||
| 68 | - | ||
| 69 | - /** | ||
| 70 | * @remark :保存编辑后的模板 | 53 | * @remark :保存编辑后的模板 |
| 71 | * @name :save | 54 | * @name :save |
| 72 | * @author :lyh | 55 | * @author :lyh |
| @@ -30,9 +30,8 @@ class VisualizationController extends BaseController | @@ -30,9 +30,8 @@ class VisualizationController extends BaseController | ||
| 30 | * @method :post | 30 | * @method :post |
| 31 | * @time :2023/11/15 10:26 | 31 | * @time :2023/11/15 10:26 |
| 32 | */ | 32 | */ |
| 33 | - public function info(Visualization $visualization){ | ||
| 34 | - //查看当前模板是否在可视化中保存 | ||
| 35 | - $info = $visualization->read(['source'=>$this->map['source']],['html','source','id','project_id']); | 33 | + public function info(VisualizationLogic $logic){ |
| 34 | + $info = $logic->getVisualizationInfo(); | ||
| 36 | if($info === false){ | 35 | if($info === false){ |
| 37 | $info = []; | 36 | $info = []; |
| 38 | } | 37 | } |
| @@ -47,13 +46,6 @@ class VisualizationController extends BaseController | @@ -47,13 +46,6 @@ class VisualizationController extends BaseController | ||
| 47 | * @time :2023/11/15 10:08 | 46 | * @time :2023/11/15 10:08 |
| 48 | */ | 47 | */ |
| 49 | public function save(VisualizationLogic $logic){ | 48 | public function save(VisualizationLogic $logic){ |
| 50 | - $this->request->validate([ | ||
| 51 | - 'source'=>'required', | ||
| 52 | - 'html'=>'required', | ||
| 53 | - ],[ | ||
| 54 | - 'source.required' => '类型不能为空', | ||
| 55 | - 'html.required' => 'html不能为空', | ||
| 56 | - ]); | ||
| 57 | $logic->saveVisualization(); | 49 | $logic->saveVisualization(); |
| 58 | $this->response('success'); | 50 | $this->response('success'); |
| 59 | } | 51 | } |
| @@ -74,7 +66,7 @@ class VisualizationController extends BaseController | @@ -74,7 +66,7 @@ class VisualizationController extends BaseController | ||
| 74 | 'source_id.required' => 'source_id不能为空', | 66 | 'source_id.required' => 'source_id不能为空', |
| 75 | ]); | 67 | ]); |
| 76 | $data = $logic->getHtml(); | 68 | $data = $logic->getHtml(); |
| 77 | - $this->response('success',Code::SUCCESS,['html'=>$data]); | 69 | + $this->response('success',Code::SUCCESS,$data); |
| 78 | } | 70 | } |
| 79 | 71 | ||
| 80 | /** | 72 | /** |
| @@ -84,6 +84,9 @@ class ProjectLogic extends BaseLogic | @@ -84,6 +84,9 @@ class ProjectLogic extends BaseLogic | ||
| 84 | if(isset($info['is_customized']) && $info['is_customized'] == 1){ | 84 | if(isset($info['is_customized']) && $info['is_customized'] == 1){ |
| 85 | $info['is_visualization'] = json_decode($info['is_visualization']); | 85 | $info['is_visualization'] = json_decode($info['is_visualization']); |
| 86 | } | 86 | } |
| 87 | + if(isset($info['deploy_build']['other_project']) && !empty($info['deploy_build']['other_project'])){ | ||
| 88 | + $info['deploy_build']['other_project']= json_decode($info['deploy_build']['other_project']); | ||
| 89 | + } | ||
| 87 | return $this->success($info); | 90 | return $this->success($info); |
| 88 | } | 91 | } |
| 89 | 92 | ||
| @@ -692,4 +695,31 @@ class ProjectLogic extends BaseLogic | @@ -692,4 +695,31 @@ class ProjectLogic extends BaseLogic | ||
| 692 | return $project->site_token; | 695 | return $project->site_token; |
| 693 | } | 696 | } |
| 694 | 697 | ||
| 698 | + /** | ||
| 699 | + * @remark :保存其他配置 | ||
| 700 | + * @name :saveOtherProject | ||
| 701 | + * @author :lyh | ||
| 702 | + * @method :post | ||
| 703 | + * @time :2023/11/17 15:26 | ||
| 704 | + */ | ||
| 705 | + public function saveOtherProject(){ | ||
| 706 | + $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); | ||
| 707 | + if($rs === false){ | ||
| 708 | + $this->fail('系统错误,请联系管理员'); | ||
| 709 | + } | ||
| 710 | + return $this->success($this->param); | ||
| 711 | + } | ||
| 712 | + | ||
| 713 | + /** | ||
| 714 | + * @remark :获取其他配置 | ||
| 715 | + * @name :getOtherProject | ||
| 716 | + * @author :lyh | ||
| 717 | + * @method :post | ||
| 718 | + * @time :2023/11/21 15:45 | ||
| 719 | + */ | ||
| 720 | + public function getOtherProject(){ | ||
| 721 | + $info = $this->model->read(['id'=>$this->param['id']],['aicc','hagro','exclusive_aicc_day','exclusive_hagro_day']); | ||
| 722 | + return $this->success($info); | ||
| 723 | + } | ||
| 724 | + | ||
| 695 | } | 725 | } |
| @@ -4,8 +4,11 @@ namespace App\Http\Logic\Aside\Template; | @@ -4,8 +4,11 @@ namespace App\Http\Logic\Aside\Template; | ||
| 4 | 4 | ||
| 5 | use App\Http\Logic\Aside\BaseLogic; | 5 | use App\Http\Logic\Aside\BaseLogic; |
| 6 | use App\Models\Service\Service as ServiceSettingModel; | 6 | use App\Models\Service\Service as ServiceSettingModel; |
| 7 | +use App\Models\Template\BTemplate; | ||
| 8 | +use App\Models\Template\BTemplateCommon; | ||
| 7 | use App\Models\Template\Template; | 9 | use App\Models\Template\Template; |
| 8 | use App\Models\Template\Setting; | 10 | use App\Models\Template\Setting; |
| 11 | +use App\Services\ProjectServer; | ||
| 9 | use Illuminate\Support\Facades\DB; | 12 | use Illuminate\Support\Facades\DB; |
| 10 | 13 | ||
| 11 | class ATemplateLogic extends BaseLogic | 14 | class ATemplateLogic extends BaseLogic |
| @@ -180,6 +183,8 @@ class ATemplateLogic extends BaseLogic | @@ -180,6 +183,8 @@ class ATemplateLogic extends BaseLogic | ||
| 180 | }else{ | 183 | }else{ |
| 181 | $rs = $bSettingModel->edit(['template_id'=>$this->param['template_id']],['id'=>$info['id']]); | 184 | $rs = $bSettingModel->edit(['template_id'=>$this->param['template_id']],['id'=>$info['id']]); |
| 182 | } | 185 | } |
| 186 | + $this->saveTemplate($this->param['project_id'],$this->param['template_id']); | ||
| 187 | + //保存一条装修数据 | ||
| 183 | if($rs === false){ | 188 | if($rs === false){ |
| 184 | $this->fail('error'); | 189 | $this->fail('error'); |
| 185 | } | 190 | } |
| @@ -187,6 +192,41 @@ class ATemplateLogic extends BaseLogic | @@ -187,6 +192,41 @@ class ATemplateLogic extends BaseLogic | ||
| 187 | } | 192 | } |
| 188 | 193 | ||
| 189 | /** | 194 | /** |
| 195 | + * @remark :设置模版保存装修首页记录 | ||
| 196 | + * @name :saveTemplate | ||
| 197 | + * @author :lyh | ||
| 198 | + * @method :post | ||
| 199 | + * @time :2023/11/17 11:04 | ||
| 200 | + */ | ||
| 201 | + public function saveTemplate($project_id,$template_id){ | ||
| 202 | + $templateInfo = $this->model->read(['id'=>$template_id]); | ||
| 203 | + ProjectServer::useProject($project_id); | ||
| 204 | + $bTemplateModel = new BTemplate(); | ||
| 205 | + $info = $bTemplateModel->read(['source'=>1,'template_id'=>$template_id]); | ||
| 206 | + if($info === false){ | ||
| 207 | + $data = [ | ||
| 208 | + 'source'=>1, 'source_id'=>0, 'template_id'=>$template_id, 'main_html'=>$templateInfo['main_html'], | ||
| 209 | + 'main_css'=>$templateInfo['main_css'], 'project_id'=>$project_id, | ||
| 210 | + ]; | ||
| 211 | + $bTemplateModel->add($data); | ||
| 212 | + } | ||
| 213 | + //保存一次公共头部信息 | ||
| 214 | + $bCommonTemplateModel = new BTemplateCommon(); | ||
| 215 | + $commonInfo = $bCommonTemplateModel->read(['template_id'=>$template_id,'type'=>1]); | ||
| 216 | + if($commonInfo === false){ | ||
| 217 | + $commonData = [ | ||
| 218 | + 'type'=>1, 'template_id'=>$template_id, 'head_html'=>$templateInfo['head_html'], | ||
| 219 | + 'head_css'=>$templateInfo['head_css'], 'footer_html'=>$templateInfo['footer_html'], | ||
| 220 | + 'footer_css'=>$templateInfo['footer_css'],'project_id'=>$project_id, | ||
| 221 | + 'other'=>str_replace('<header','',characterTruncation($templateInfo['html'],"/<link id=\"google-fonts-link\"(.*?)<header/s")) | ||
| 222 | + ]; | ||
| 223 | + $bCommonTemplateModel->add($commonData); | ||
| 224 | + } | ||
| 225 | + DB::disconnect('custom_mysql'); | ||
| 226 | + return $this->success(); | ||
| 227 | + } | ||
| 228 | + | ||
| 229 | + /** | ||
| 190 | * @remark :获取选择的模版 | 230 | * @remark :获取选择的模版 |
| 191 | * @name :getSettingInfo | 231 | * @name :getSettingInfo |
| 192 | * @author :lyh | 232 | * @author :lyh |
| @@ -47,8 +47,8 @@ class BTemplateLogic extends BaseLogic | @@ -47,8 +47,8 @@ class BTemplateLogic extends BaseLogic | ||
| 47 | */ | 47 | */ |
| 48 | public function publicTemplateLists($map,$page,$row,$order = 'created_at',$filed = ['id','name','image','url','created_at','status','deleted_status']){ | 48 | public function publicTemplateLists($map,$page,$row,$order = 'created_at',$filed = ['id','name','image','url','created_at','status','deleted_status']){ |
| 49 | $templateModel = new Template(); | 49 | $templateModel = new Template(); |
| 50 | - $map['deleted_status'] = 0; | ||
| 51 | - $map['status'] = 0; | 50 | + $map['deleted_status'] = BTemplate::STATUS; |
| 51 | + $map['status'] = BTemplate::STATUS; | ||
| 52 | $lists = $templateModel->lists($map,$page,$row,$order,$filed); | 52 | $lists = $templateModel->lists($map,$page,$row,$order,$filed); |
| 53 | return $this->success($lists); | 53 | return $this->success($lists); |
| 54 | } | 54 | } |
| @@ -222,32 +222,6 @@ class BTemplateLogic extends BaseLogic | @@ -222,32 +222,6 @@ class BTemplateLogic extends BaseLogic | ||
| 222 | return $commonInfo; | 222 | return $commonInfo; |
| 223 | } | 223 | } |
| 224 | 224 | ||
| 225 | - | ||
| 226 | - /** | ||
| 227 | - * @remark :设置模板 | ||
| 228 | - * @name :setTemplate | ||
| 229 | - * @author :lyh | ||
| 230 | - * @method :post | ||
| 231 | - * @time :2023/6/29 9:47 | ||
| 232 | - */ | ||
| 233 | - public function setTemplate(){ | ||
| 234 | - $bSettingModel = new Setting(); | ||
| 235 | - $info = $bSettingModel->read(['project_id'=>$this->user['project_id']]); | ||
| 236 | - if($info === false){ | ||
| 237 | - $param = [ | ||
| 238 | - 'project_id'=>$this->user['project_id'], | ||
| 239 | - 'template_id'=>$this->param['template_id'], | ||
| 240 | - ]; | ||
| 241 | - $rs = $bSettingModel->add($param); | ||
| 242 | - }else{ | ||
| 243 | - $rs = $bSettingModel->edit(['template_id'=>$this->param['template_id']],['project_id'=>$this->user['project_id']]); | ||
| 244 | - } | ||
| 245 | - if($rs === false){ | ||
| 246 | - $this->fail('error'); | ||
| 247 | - } | ||
| 248 | - return $this->success(); | ||
| 249 | - } | ||
| 250 | - | ||
| 251 | /** | 225 | /** |
| 252 | * @remark :保存修改后的模版 | 226 | * @remark :保存修改后的模版 |
| 253 | * @name :templateSave | 227 | * @name :templateSave |
| @@ -47,8 +47,10 @@ class CustomTemplateLogic extends BaseLogic | @@ -47,8 +47,10 @@ class CustomTemplateLogic extends BaseLogic | ||
| 47 | if($info === false){ | 47 | if($info === false){ |
| 48 | $this->fail('当前数据不存在'); | 48 | $this->fail('当前数据不存在'); |
| 49 | } | 49 | } |
| 50 | + if($info['is_visualization'] == 0 || $info['is_visualization'] == 1){ | ||
| 50 | $html = $this->getBodyHeaderFooter($info['html'],$info['html_style']); | 51 | $html = $this->getBodyHeaderFooter($info['html'],$info['html_style']); |
| 51 | $info['html'] = $this->getHeadFooter($html); | 52 | $info['html'] = $this->getHeadFooter($html); |
| 53 | + } | ||
| 52 | return $this->success($info); | 54 | return $this->success($info); |
| 53 | } | 55 | } |
| 54 | 56 | ||
| @@ -90,15 +92,16 @@ class CustomTemplateLogic extends BaseLogic | @@ -90,15 +92,16 @@ class CustomTemplateLogic extends BaseLogic | ||
| 90 | */ | 92 | */ |
| 91 | public function saveHtml(){ | 93 | public function saveHtml(){ |
| 92 | $html = $this->param['html']; | 94 | $html = $this->param['html']; |
| 95 | + $info = $this->model->read(['id'=>$this->param['id']],['id','is_visualization','url']); | ||
| 96 | + if($info['is_visualization'] == 0 || $info['is_visualization'] == 1){//非定制项目+可视化页面 | ||
| 93 | $this->saveCommonTemplate($html); | 97 | $this->saveCommonTemplate($html); |
| 94 | $this->param['html'] = characterTruncation($html,'/<main\b[^>]*>(.*?)<\/main>/s'); | 98 | $this->param['html'] = characterTruncation($html,'/<main\b[^>]*>(.*?)<\/main>/s'); |
| 95 | $this->param['html_style'] = characterTruncation($html,'/<style id="globalsojs-styles">(.*?)<\/style>/s'); | 99 | $this->param['html_style'] = characterTruncation($html,'/<style id="globalsojs-styles">(.*?)<\/style>/s'); |
| 100 | + } | ||
| 96 | $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); | 101 | $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); |
| 97 | if($rs === false){ | 102 | if($rs === false){ |
| 98 | $this->fail('系统错误,请联系管理'); | 103 | $this->fail('系统错误,请联系管理'); |
| 99 | } | 104 | } |
| 100 | - //TODO::通知网站更新 | ||
| 101 | - $info = $this->model->read(['id'=>$this->param['id']],['id','url']); | ||
| 102 | $data = ['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_PAGE, 'route'=>$info['url']]; | 105 | $data = ['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_PAGE, 'route'=>$info['url']]; |
| 103 | $this->updateNotify($data); | 106 | $this->updateNotify($data); |
| 104 | return $this->success(); | 107 | return $this->success(); |
| @@ -10,8 +10,14 @@ | @@ -10,8 +10,14 @@ | ||
| 10 | namespace App\Http\Logic\Bside\BTemplate; | 10 | namespace App\Http\Logic\Bside\BTemplate; |
| 11 | 11 | ||
| 12 | use App\Http\Logic\Bside\BaseLogic; | 12 | use App\Http\Logic\Bside\BaseLogic; |
| 13 | +use App\Models\Project\PageSetting; | ||
| 14 | +use App\Models\Service\Service as ServiceSettingModel; | ||
| 13 | use App\Models\Template\BTemplate; | 15 | use App\Models\Template\BTemplate; |
| 14 | use App\Models\Template\BTemplateCommon; | 16 | use App\Models\Template\BTemplateCommon; |
| 17 | +use App\Models\Template\BTemplateMain; | ||
| 18 | +use App\Models\Template\Setting; | ||
| 19 | +use App\Models\Template\Template; | ||
| 20 | +use App\Models\Template\TemplateTypeMain; | ||
| 15 | use App\Models\Visualization\Visualization; | 21 | use App\Models\Visualization\Visualization; |
| 16 | 22 | ||
| 17 | class VisualizationLogic extends BaseLogic | 23 | class VisualizationLogic extends BaseLogic |
| @@ -19,11 +25,56 @@ class VisualizationLogic extends BaseLogic | @@ -19,11 +25,56 @@ class VisualizationLogic extends BaseLogic | ||
| 19 | public function __construct() | 25 | public function __construct() |
| 20 | { | 26 | { |
| 21 | parent::__construct(); | 27 | parent::__construct(); |
| 22 | - $this->model = new Visualization(); | 28 | + $this->model = new BTemplateMain(); |
| 23 | $this->param = $this->requestAll; | 29 | $this->param = $this->requestAll; |
| 24 | } | 30 | } |
| 25 | 31 | ||
| 26 | /** | 32 | /** |
| 33 | + * @remark :获取代码块 | ||
| 34 | + * @name :getVisualizationInfo | ||
| 35 | + * @author :lyh | ||
| 36 | + * @method :post | ||
| 37 | + * @time :2023/11/17 14:44 | ||
| 38 | + */ | ||
| 39 | + public function getVisualizationInfo(){ | ||
| 40 | + $data = $this->getSource($this->param['type']); | ||
| 41 | + $source = $data['source']; | ||
| 42 | + $source_id = $data['source_id']; | ||
| 43 | + $type = $this->getType($source,$source_id); | ||
| 44 | + $typeArray = [1,3,5,7];//单页数据 | ||
| 45 | + if(in_array($type,$typeArray)){ | ||
| 46 | + $bTemplateModel = new BTemplate(); | ||
| 47 | + $info = $bTemplateModel->read(['source'=>$source,'source_id'=>$source_id,'template_id'=>0]); | ||
| 48 | + if($info === false){ | ||
| 49 | + $html = ''; | ||
| 50 | + }else{ | ||
| 51 | + $html = $info['html']; | ||
| 52 | + } | ||
| 53 | + }else{//模块数据 | ||
| 54 | + $bTemplateMainModel = new BTemplateMain(); | ||
| 55 | + $info = $bTemplateMainModel->read(['type'=>$type]); | ||
| 56 | + if($info === false){ | ||
| 57 | + $html = ''; | ||
| 58 | + }else{ | ||
| 59 | + $html = $info['main_html']; | ||
| 60 | + } | ||
| 61 | + } | ||
| 62 | + return $this->success(['html'=>$html]); | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + public function getSource($type){ | ||
| 66 | + $source_id = 0; | ||
| 67 | + if ($type == 2){$source = 2;$source_id = 1; | ||
| 68 | + }elseif ($type == 3){$source = 2; | ||
| 69 | + }elseif ($type == 4){$source = 3;$source_id = 1; | ||
| 70 | + }elseif ($type == 5){$source = 3; | ||
| 71 | + }elseif ($type == 6){$source = 4;$source_id = 1; | ||
| 72 | + }elseif ($type == 7){$source = 4; | ||
| 73 | + }else{$source = 1;} | ||
| 74 | + return ['source'=>$source,'source_id'=>$source_id]; | ||
| 75 | + } | ||
| 76 | + | ||
| 77 | + /** | ||
| 27 | * @remark :保存定制html | 78 | * @remark :保存定制html |
| 28 | * @name :saveHtml | 79 | * @name :saveHtml |
| 29 | * @author :lyh | 80 | * @author :lyh |
| @@ -32,11 +83,38 @@ class VisualizationLogic extends BaseLogic | @@ -32,11 +83,38 @@ class VisualizationLogic extends BaseLogic | ||
| 32 | */ | 83 | */ |
| 33 | public function saveVisualization(){ | 84 | public function saveVisualization(){ |
| 34 | try { | 85 | try { |
| 35 | - if(isset($this->param['id']) && !empty($this->param['id'])){ | ||
| 36 | - $this->model->edit($this->param,['id'=>$this->param['id']]); | 86 | + $sourceData = $this->getSource($this->param['type']); |
| 87 | + $source = $sourceData['source']; | ||
| 88 | + $source_id = $sourceData['source_id']; | ||
| 89 | + $type = $this->param['type']; | ||
| 90 | + $typeArray = [1,3,5,7];//单页数据 | ||
| 91 | + if(in_array($type,$typeArray)){ | ||
| 92 | + $bTemplateModel = new BTemplate(); | ||
| 93 | + $templateInfo = $bTemplateModel->read(['source'=>$source,'source'=>$source_id,'template_id'=>0]); | ||
| 94 | + if($templateInfo === false){ | ||
| 95 | + $data = [ | ||
| 96 | + 'html'=>$this->param['html'], | ||
| 97 | + 'project_id'=>$this->user['project_id'], | ||
| 98 | + 'source'=>$source, | ||
| 99 | + 'source_id'=>$source_id, | ||
| 100 | + ]; | ||
| 101 | + $bTemplateModel->add($data); | ||
| 37 | }else{ | 102 | }else{ |
| 38 | - $this->param['project_id'] = $this->user['project_id']; | ||
| 39 | - $this->model->add($this->param); | 103 | + $bTemplateModel->edit(['html'=>$this->param['html']],['id'=>$templateInfo['id']]); |
| 104 | + } | ||
| 105 | + }else{//模块数据 | ||
| 106 | + $bTemplateMainModel = new BTemplateMain(); | ||
| 107 | + $mainInfo = $bTemplateMainModel->read(['type'=>$type]); | ||
| 108 | + if($mainInfo === false){ | ||
| 109 | + $mainData = [ | ||
| 110 | + 'project_id'=>$this->user['project_id'], | ||
| 111 | + 'type'=>$type, | ||
| 112 | + 'main_html'=>$this->param['html'] | ||
| 113 | + ]; | ||
| 114 | + $bTemplateMainModel->add($mainData); | ||
| 115 | + }else{ | ||
| 116 | + $bTemplateMainModel->edit(['main_html'=>$this->param['html']],['id'=>$mainInfo['id']]); | ||
| 117 | + } | ||
| 40 | } | 118 | } |
| 41 | }catch (\Exception $e){ | 119 | }catch (\Exception $e){ |
| 42 | $this->fail('系统错误,请联系管理员'); | 120 | $this->fail('系统错误,请联系管理员'); |
| @@ -45,37 +123,145 @@ class VisualizationLogic extends BaseLogic | @@ -45,37 +123,145 @@ class VisualizationLogic extends BaseLogic | ||
| 45 | } | 123 | } |
| 46 | 124 | ||
| 47 | /** | 125 | /** |
| 48 | - * @remark :可视化装修获取html | 126 | + * @remark :定制页面支持可视化装修获取html |
| 49 | * @name :getHtml | 127 | * @name :getHtml |
| 50 | * @author :lyh | 128 | * @author :lyh |
| 51 | * @method :post | 129 | * @method :post |
| 52 | * @time :2023/11/15 11:30 | 130 | * @time :2023/11/15 11:30 |
| 53 | */ | 131 | */ |
| 54 | public function getHtml(){ | 132 | public function getHtml(){ |
| 133 | + $type = $this->getType($this->param['source'],$this->param['source_id']);//获取类型 | ||
| 134 | + $page_array = (array)$this->user['is_visualization']->page_array;//获取定制界面 | ||
| 135 | + //查看当前类型是否是定制界面 | ||
| 136 | + if(in_array($type,$page_array)){//是定制界面 | ||
| 137 | + if(in_array($type,[1,3,5,7])){//单页 | ||
| 138 | + $templateInfo = $this->getWebTemplate($this->param['source'],$this->param['source_id']);//查看当前定制单页是否有代码块 | ||
| 139 | + if($templateInfo === false){ | ||
| 140 | + $this->fail('请先上传定制代码块'); | ||
| 141 | + } | ||
| 142 | + return ['html'=>$templateInfo['html']]; | ||
| 143 | + }else{//模块页 | ||
| 144 | + $templateInfo = $this->getWebTemplate($this->param['source'],$this->param['source_id']);//查看当前页面是否可视化 | ||
| 145 | + if($templateInfo === false){//获取代码块 | ||
| 146 | + $bTemplateMainModel = new BTemplateMain(); | ||
| 147 | + $mainInfo = $bTemplateMainModel->read(['type'=>$type]); | ||
| 148 | + if($mainInfo === false){ | ||
| 149 | + $this->fail('请先上传定制代码块'); | ||
| 150 | + } | ||
| 151 | + return ['html'=>$mainInfo['main_html']]; | ||
| 152 | + } | ||
| 153 | + return ['html'=>$templateInfo['html']]; | ||
| 154 | + } | ||
| 155 | + }else{//非定制界面 | ||
| 156 | + $bSettingModel = new Setting(); | ||
| 157 | + $settingInfo = $bSettingModel->read(['project_id'=>$this->user['project_id']]); | ||
| 158 | + if($settingInfo === false){ | ||
| 159 | + $this->fail('请先选择模版'); | ||
| 160 | + } | ||
| 161 | + $templateInfo = $this->getWebTemplate($this->param['source'],$this->param['source_id'],$settingInfo['template_id']);//查看当前页面是否可视化 | ||
| 162 | + if($templateInfo === false){ | ||
| 163 | + //根据类型在获取中间部分 | ||
| 164 | + $mainData = $this->getCommonMain($this->param['source'],$this->param['source_id']); | ||
| 165 | + }else{ | ||
| 166 | + $mainData = [ | ||
| 167 | + 'main_html'=>$templateInfo['main_html'], | ||
| 168 | + 'main_css'=>$templateInfo['main_css'] | ||
| 169 | + ]; | ||
| 170 | + } | ||
| 171 | + //获取公共头部底部 | ||
| 172 | + $commonInfo = $this->getCommonPage($this->param['source'],$this->param['source_id'],$settingInfo['template_id']); | ||
| 173 | + //拼接数据 | ||
| 174 | + $html = $commonInfo['head_css'].$mainData['main_css'].$commonInfo['footer_css'].$commonInfo['other']. | ||
| 175 | + $commonInfo['head_html'].$mainData['main_html'].$commonInfo['footer_html']; | ||
| 176 | + $html = $this->getHeadFooter($html); | ||
| 177 | + return ['html'=>$html,'template_id'=>$settingInfo['template_id']]; | ||
| 178 | + } | ||
| 179 | + } | ||
| 180 | + | ||
| 181 | + /** | ||
| 182 | + * @remark :拼接获取公共头部底部 | ||
| 183 | + * @name :getHeadFooter | ||
| 184 | + * @author :lyh | ||
| 185 | + * @method :post | ||
| 186 | + * @time :2023/7/21 17:22 | ||
| 187 | + */ | ||
| 188 | + public function getHeadFooter($html){ | ||
| 189 | + //获取公共主题头部底部 | ||
| 190 | + $serviceSettingModel = new ServiceSettingModel(); | ||
| 191 | + $list = $serviceSettingModel->list(['type'=>2],'created_at'); | ||
| 192 | + //拼接html | ||
| 193 | + foreach ($list as $v){ | ||
| 194 | + if($v['key'] == 'head'){ | ||
| 195 | + $html = $v['values'].$html; | ||
| 196 | + } | ||
| 197 | + if($v['key'] == 'footer'){ | ||
| 198 | + $html = $html.$v['values']; | ||
| 199 | + } | ||
| 200 | + } | ||
| 201 | + return $html; | ||
| 202 | + } | ||
| 203 | + | ||
| 204 | + /** | ||
| 205 | + * @remark :获取可视化装修记录 | ||
| 206 | + * @name :getWebTemplate | ||
| 207 | + * @author :lyh | ||
| 208 | + * @method :post | ||
| 209 | + * @time :2023/11/16 11:21 | ||
| 210 | + */ | ||
| 211 | + public function getWebTemplate($source,$source_id,$template_id = 0){ | ||
| 55 | //查询可视化是否第一次保存 | 212 | //查询可视化是否第一次保存 |
| 56 | $bTemplateModel = new BTemplate(); | 213 | $bTemplateModel = new BTemplate(); |
| 57 | - $TemplateInfo = $bTemplateModel->read([ | ||
| 58 | - 'source'=>$this->param['source'], | 214 | + $param = [ |
| 215 | + 'source'=>$source, | ||
| 59 | 'project_id'=>$this->user['project_id'], | 216 | 'project_id'=>$this->user['project_id'], |
| 60 | - 'source_id'=>$this->param['source_id'], | ||
| 61 | - ]); | ||
| 62 | - if($this->param['source'] == 2){ | ||
| 63 | - if($this->param['source_id'] == 0){$source = 3;}else{$source = 2;} | 217 | + 'source_id'=>$source_id, |
| 218 | + 'template_id'=>$template_id | ||
| 219 | + ]; | ||
| 220 | + return $bTemplateModel->read($param); | ||
| 221 | + } | ||
| 222 | + | ||
| 223 | + /** | ||
| 224 | + * @remark :获取类型 | ||
| 225 | + * @name :getType | ||
| 226 | + * @author :lyh | ||
| 227 | + * @method :post | ||
| 228 | + * @time :2023/11/16 11:20 | ||
| 229 | + */ | ||
| 230 | + public function getType($source,$source_id){ | ||
| 231 | + $type = 1; | ||
| 232 | + if($source == 2){ | ||
| 233 | + if($source_id == 0){$type = 3;}else{$type = 2;} | ||
| 64 | } | 234 | } |
| 65 | - if($this->param['source'] == 3){ | ||
| 66 | - if($this->param['source_id'] == 0){$source = 5;}else{$source = 4;} | 235 | + if($source == 3){ |
| 236 | + if($source_id == 0){$type = 5;}else{$type = 4;} | ||
| 67 | } | 237 | } |
| 68 | - if($this->param['source'] == 4){ | ||
| 69 | - if($this->param['source_id'] == 0){$source = 7;}else{$source = 6;} | 238 | + if($source == 4){ |
| 239 | + if($source_id == 0){$type = 7;}else{$type = 6;} | ||
| 70 | } | 240 | } |
| 71 | - if($TemplateInfo === false){ | ||
| 72 | - $info = $this->model->read(['source'=>$source],['html','source','id','project_id']); | ||
| 73 | - if($info === false){ | ||
| 74 | - $this->fail('请先上传定制代码块'); | 241 | + return $type; |
| 75 | } | 242 | } |
| 76 | - return $info['html']; | 243 | + |
| 244 | + /** | ||
| 245 | + * @remark :获取设置的类型 | ||
| 246 | + * @name :getType | ||
| 247 | + * @author :lyh | ||
| 248 | + * @method :post | ||
| 249 | + * @time :2023/10/21 17:29 | ||
| 250 | + */ | ||
| 251 | + public function getSaveType($source,$source_id){ | ||
| 252 | + $type = 1;//首页公共头部底部 | ||
| 253 | + //查看页面是否设置自定义头部底部 | ||
| 254 | + if(isset($this->user['configuration']['is_head']) && ($this->user['configuration']['is_head'] != 0)) { | ||
| 255 | + $pageSettingModel = new PageSetting(); | ||
| 256 | + $pageInfo = $pageSettingModel->read(['project_id' => $this->user['project_id']]); | ||
| 257 | + if ($pageInfo !== false) { | ||
| 258 | + if ($source == 2) {if ($source_id != 0) {if ($pageInfo['product_details'] != 0) {$type = 2;}} else {if ($pageInfo['product_list'] != 0) {$type = 3;}}} | ||
| 259 | + if ($source == 3) {if ($source_id != 0) {if ($pageInfo['blog_details'] != 0) {$type = 4;}} else {if ($pageInfo['blog_list'] != 0) {$type = 5;}}} | ||
| 260 | + if ($source == 4) {if ($source_id != 0) {if ($pageInfo['news_details'] != 0) {$type = 6;}} else {if ($pageInfo['news_list'] != 0) {$type = 7;}}} | ||
| 261 | + if ($source == 5) {if ($pageInfo['polymerization'] != 0) {$type = 8;}} | ||
| 77 | } | 262 | } |
| 78 | - return $TemplateInfo['html']; | 263 | + } |
| 264 | + return $type; | ||
| 79 | } | 265 | } |
| 80 | 266 | ||
| 81 | /** | 267 | /** |
| @@ -86,26 +272,154 @@ class VisualizationLogic extends BaseLogic | @@ -86,26 +272,154 @@ class VisualizationLogic extends BaseLogic | ||
| 86 | * @time :2023/11/15 11:47 | 272 | * @time :2023/11/15 11:47 |
| 87 | */ | 273 | */ |
| 88 | public function saveHtml(){ | 274 | public function saveHtml(){ |
| 275 | + $page_array = (array)$this->user['is_visualization']->page_array; | ||
| 276 | + $type = $this->getType($this->param['source'],$this->param['source_id']); | ||
| 277 | + try { | ||
| 278 | + if(in_array($type,$page_array)){//定制页面 | ||
| 89 | $bTemplateModel = new BTemplate(); | 279 | $bTemplateModel = new BTemplate(); |
| 90 | $templateInfo = $bTemplateModel->read([ | 280 | $templateInfo = $bTemplateModel->read([ |
| 91 | 'source'=>$this->param['source'], | 281 | 'source'=>$this->param['source'], |
| 92 | 'project_id'=>$this->user['project_id'], | 282 | 'project_id'=>$this->user['project_id'], |
| 93 | 'source_id'=>$this->param['source_id'], | 283 | 'source_id'=>$this->param['source_id'], |
| 94 | ]); | 284 | ]); |
| 95 | - try { | ||
| 96 | if($templateInfo === false){ | 285 | if($templateInfo === false){ |
| 97 | $this->param['project_id'] = $this->user['project_id']; | 286 | $this->param['project_id'] = $this->user['project_id']; |
| 98 | $bTemplateModel->add($this->param); | 287 | $bTemplateModel->add($this->param); |
| 99 | }else{ | 288 | }else{ |
| 100 | $bTemplateModel->edit(['html'=>$this->param['html']],['source'=>$this->param['source'],'source_id'=>$this->param['source_id']]); | 289 | $bTemplateModel->edit(['html'=>$this->param['html']],['source'=>$this->param['source'],'source_id'=>$this->param['source_id']]); |
| 101 | } | 290 | } |
| 291 | + }else{ | ||
| 292 | + $bTemplateModel = new BTemplate(); | ||
| 293 | + $templateInfo = $bTemplateModel->read([ | ||
| 294 | + 'source'=>$this->param['source'], | ||
| 295 | + 'project_id'=>$this->user['project_id'], | ||
| 296 | + 'source_id'=>$this->param['source_id'], | ||
| 297 | + 'template_id'=>$this->param['template_id'], | ||
| 298 | + ]); | ||
| 299 | + $this->param['main_html'] = characterTruncation($this->param['html'],'/<main\b[^>]*>(.*?)<\/main>/s'); | ||
| 300 | + $this->param['main_css'] = characterTruncation($this->param['html'],'/<style id="globalsojs-styles">(.*?)<\/style>/s'); | ||
| 301 | + //保存头部 | ||
| 302 | + $this->saveCommonTemplate($this->param['html'],$this->param['source'],$this->param['source_id'],$this->param['template_id']); | ||
| 303 | + if($templateInfo === false){ | ||
| 304 | + $this->param['project_id'] = $this->user['project_id']; | ||
| 305 | + $bTemplateModel->add($this->param); | ||
| 306 | + }else{ | ||
| 307 | + $bTemplateModel->edit($this->param,['source'=>$this->param['source'],'source_id'=>$this->param['source_id']]); | ||
| 308 | + } | ||
| 309 | + } | ||
| 102 | }catch (\Exception $e){ | 310 | }catch (\Exception $e){ |
| 103 | - $this->fail('系统错误请联系管理员'); | 311 | + $this->fail('系统错误,请联系管理员'); |
| 104 | } | 312 | } |
| 105 | return $this->success(); | 313 | return $this->success(); |
| 106 | 314 | ||
| 107 | } | 315 | } |
| 108 | 316 | ||
| 317 | + /** | ||
| 318 | + * @remark :保存头部公共数据 | ||
| 319 | + * @name :saveCommonTemplate | ||
| 320 | + * @author :lyh | ||
| 321 | + * @method :post | ||
| 322 | + * @time :2023/10/13 14:27 | ||
| 323 | + */ | ||
| 324 | + public function saveCommonTemplate($html,$source,$source_id,$template_id){ | ||
| 325 | + $type = $this->getSaveType($source,$source_id); | ||
| 326 | + $templateCommonModel = new BTemplateCommon(); | ||
| 327 | + $info = $templateCommonModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>$type]); | ||
| 328 | + $data = [ | ||
| 329 | + 'head_html'=>characterTruncation($html,'/<header\b[^>]*>(.*?)<\/header>/s'), | ||
| 330 | + 'head_css'=>characterTruncation($html,'/<style id="globalsojs-header">(.*?)<\/style>/s'), | ||
| 331 | + 'footer_html'=>characterTruncation($html,'/<footer\b[^>]*>(.*?)<\/footer>/s'), | ||
| 332 | + 'footer_css'=>characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<\/style>/s'), | ||
| 333 | + ]; | ||
| 334 | + $other = str_replace('<header','',characterTruncation($html,"/<link id=\"google-fonts-link\"(.*?)<header/s")); | ||
| 335 | + if($info === false){ | ||
| 336 | + $data['template_id'] = $template_id; | ||
| 337 | + $data['project_id'] = $this->user['project_id']; | ||
| 338 | + $data['type'] = $type; | ||
| 339 | + $templateCommonModel->add($data); | ||
| 340 | + }else{ | ||
| 341 | + $templateCommonModel->edit($data,['id'=>$info['id']]); | ||
| 342 | + } | ||
| 343 | + //更新所有界面的other | ||
| 344 | + $templateCommonModel->edit(['other'=>$other],['project_id'=>$this->user['project_id']]); | ||
| 345 | + return $this->success(); | ||
| 346 | + } | ||
| 347 | + | ||
| 348 | + /** | ||
| 349 | + * @remark :获取中间公共部分 | ||
| 350 | + * @name :getCommonMain | ||
| 351 | + * @author :lyh | ||
| 352 | + * @method :post | ||
| 353 | + * @time :2023/10/24 15:58 | ||
| 354 | + */ | ||
| 355 | + public function getCommonMain($source,$source_id){ | ||
| 356 | + $data = []; | ||
| 357 | + if ($source == 2) {if ($source_id != 0) {$type = 2;} else {$type = 3;}} | ||
| 358 | + if ($source == 3) {if ($source_id != 0) {$type = 4;} else {$type = 5;}} | ||
| 359 | + if ($source == 4) {if ($source_id != 0) {$type = 6;} else {$type = 7;}} | ||
| 360 | + if ($source == 5) {$type = 8;} | ||
| 361 | + //查询有没有公共详情模板 | ||
| 362 | + $mainInfo = $this->model->read(['type'=>$type]); | ||
| 363 | + if($mainInfo === false){ | ||
| 364 | + $data['main_html'] = $this->getModule($type); | ||
| 365 | + $data['main_css'] = "<style id='globalsojs-styles'></style>"; | ||
| 366 | + }else{ | ||
| 367 | + $data['main_html'] = $mainInfo['main_html']; | ||
| 368 | + $data['main_css'] = $mainInfo['main_css']; | ||
| 369 | + } | ||
| 370 | + return $data; | ||
| 371 | + } | ||
| 109 | 372 | ||
| 373 | + /** | ||
| 374 | + * @remark :默认产品模块 | ||
| 375 | + * @name :getProductModule | ||
| 376 | + * @author :lyh | ||
| 377 | + * @method :post | ||
| 378 | + * @time :2023/7/27 15:08 | ||
| 379 | + */ | ||
| 380 | + public function getModule($type){ | ||
| 381 | + //获取公共主题头部底部 | ||
| 382 | + $mainModel = new TemplateTypeMain(); | ||
| 383 | + $info = $mainModel->read(['type'=>$type]); | ||
| 384 | + return $info['main_html']; | ||
| 385 | + } | ||
| 110 | 386 | ||
| 387 | + /** | ||
| 388 | + * @remark :根据类型获取公共头和底 | ||
| 389 | + * @name :getCommonPage | ||
| 390 | + * @author :lyh | ||
| 391 | + * @method :post | ||
| 392 | + * @time :2023/10/21 16:55 | ||
| 393 | + */ | ||
| 394 | + public function getCommonPage($source,$source_id,$template_id){ | ||
| 395 | + if(isset($this->user['configuration']['is_head']) && ($this->user['configuration']['is_head'] != 0)) { | ||
| 396 | + //查看页面是否设置自定义头部底部 | ||
| 397 | + $pageSettingModel = new PageSetting(); | ||
| 398 | + $pageInfo = $pageSettingModel->read(['project_id' => $this->user['project_id']]); | ||
| 399 | + if ($pageInfo != false) { | ||
| 400 | + $commonTemplateModel = new BTemplateCommon(); | ||
| 401 | + $data = [ | ||
| 402 | + 'template_id' => $template_id, | ||
| 403 | + 'project_id' => $this->user['project_id'] | ||
| 404 | + ]; | ||
| 405 | + if ($source == 2) {//产品页 | ||
| 406 | + if($source_id != 0){$data['type'] = 2;if ($pageInfo['product_details'] != 0) {$commonInfo = $commonTemplateModel->read($data);}} | ||
| 407 | + else {$data['type'] = 3;if ($pageInfo['product_list'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}} | ||
| 408 | + if ($source == 3) {//博客页 | ||
| 409 | + if ($source_id != 0) {$data['type'] = 4;if ($pageInfo['blog_details'] != 0) {$commonInfo = $commonTemplateModel->read($data);}} | ||
| 410 | + else {$data['type'] = 5;if ($pageInfo['blog_list'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}} | ||
| 411 | + if ($source == 4) {//新闻页 | ||
| 412 | + if ($source_id != 0) {$data['type'] = 6;if ($pageInfo['news_details'] != 0) {$commonInfo = $commonTemplateModel->read($data);}} | ||
| 413 | + else {$data['type'] = 7;if ($pageInfo['news_list'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}} | ||
| 414 | + if ($source == 5) {//聚合页 | ||
| 415 | + $data['type'] = 8;if ($pageInfo['polymerization'] != 0) {$commonInfo = $commonTemplateModel->read($data);}} | ||
| 416 | + } | ||
| 417 | + } | ||
| 418 | + //获取首页公共的头部和底部 | ||
| 419 | + if(!isset($commonInfo) || $commonInfo === false){ | ||
| 420 | + $commonTemplateModel = new BTemplateCommon(); | ||
| 421 | + $commonInfo = $commonTemplateModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>1]); | ||
| 422 | + } | ||
| 423 | + return $commonInfo; | ||
| 424 | + } | ||
| 111 | } | 425 | } |
| @@ -60,8 +60,9 @@ class ExtendLogic extends BaseLogic | @@ -60,8 +60,9 @@ class ExtendLogic extends BaseLogic | ||
| 60 | $info = $this->model->read(['key'=>$key.$i]); | 60 | $info = $this->model->read(['key'=>$key.$i]); |
| 61 | if($info !== false){ | 61 | if($info !== false){ |
| 62 | return $this->getKey($key,$i+1); | 62 | return $this->getKey($key,$i+1); |
| 63 | + }else{ | ||
| 64 | + return $key.$i; | ||
| 63 | } | 65 | } |
| 64 | - return $key; | ||
| 65 | } | 66 | } |
| 66 | 67 | ||
| 67 | /** | 68 | /** |
| @@ -54,15 +54,16 @@ class KeywordLogic extends BaseLogic | @@ -54,15 +54,16 @@ class KeywordLogic extends BaseLogic | ||
| 54 | $this->param = $this->handleSaveParam($this->param); | 54 | $this->param = $this->handleSaveParam($this->param); |
| 55 | if(isset($this->param['id']) && !empty($this->param['id'])){ | 55 | if(isset($this->param['id']) && !empty($this->param['id'])){ |
| 56 | $this->model->edit($this->param,['id'=>$this->param['id']]); | 56 | $this->model->edit($this->param,['id'=>$this->param['id']]); |
| 57 | + $id = $this->param['id']; | ||
| 57 | }else{ | 58 | }else{ |
| 58 | $this->param['project_id'] = $this->user['project_id']; | 59 | $this->param['project_id'] = $this->user['project_id']; |
| 59 | $this->param['created_at'] = date('Y-m-d H:i:s'); | 60 | $this->param['created_at'] = date('Y-m-d H:i:s'); |
| 60 | $this->param['updated_at'] = $this->param['created_at']; | 61 | $this->param['updated_at'] = $this->param['created_at']; |
| 61 | $id = $this->model->insertGetId($this->param); | 62 | $id = $this->model->insertGetId($this->param); |
| 63 | + } | ||
| 62 | //路由映射 | 64 | //路由映射 |
| 63 | $route = RouteMap::setRoute($this->param['title'], RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $this->user['project_id']); | 65 | $route = RouteMap::setRoute($this->param['title'], RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $this->user['project_id']); |
| 64 | $this->model->edit(['route'=>$route],['id'=>$id]); | 66 | $this->model->edit(['route'=>$route],['id'=>$id]); |
| 65 | - } | ||
| 66 | //清除缓存 | 67 | //清除缓存 |
| 67 | Common::del_user_cache('product_keyword',$this->user['project_id']); | 68 | Common::del_user_cache('product_keyword',$this->user['project_id']); |
| 68 | DB::commit(); | 69 | DB::commit(); |
| @@ -92,6 +93,12 @@ class KeywordLogic extends BaseLogic | @@ -92,6 +93,12 @@ class KeywordLogic extends BaseLogic | ||
| 92 | if(isset($param['keyword_video']) && !empty($param['keyword_video'])){ | 93 | if(isset($param['keyword_video']) && !empty($param['keyword_video'])){ |
| 93 | $param['keyword_video'] = Arr::a2s($param['keyword_video']); | 94 | $param['keyword_video'] = Arr::a2s($param['keyword_video']); |
| 94 | } | 95 | } |
| 96 | + if(!empty($param['related_news_ids'])){ | ||
| 97 | + $param['related_news_ids'] = Arr::arrToSet($param['related_news_ids']); | ||
| 98 | + } | ||
| 99 | + if(!empty($param['related_blog_ids'])){ | ||
| 100 | + $param['related_blog_ids'] = Arr::arrToSet($param['related_blog_ids']); | ||
| 101 | + } | ||
| 95 | return $param; | 102 | return $param; |
| 96 | } | 103 | } |
| 97 | 104 |
| @@ -51,8 +51,8 @@ class ProductLogic extends BaseLogic | @@ -51,8 +51,8 @@ class ProductLogic extends BaseLogic | ||
| 51 | $category_ids = $this->getLastCategoryArr($this->param['category_id']); | 51 | $category_ids = $this->getLastCategoryArr($this->param['category_id']); |
| 52 | $this->param['category_id'] = ','.implode(',',$category_ids).','; | 52 | $this->param['category_id'] = ','.implode(',',$category_ids).','; |
| 53 | } | 53 | } |
| 54 | - DB::connection('custom_mysql')->beginTransaction(); | ||
| 55 | - try { | 54 | +// DB::connection('custom_mysql')->beginTransaction(); |
| 55 | +// try { | ||
| 56 | if(isset($this->param['id']) && !empty($this->param['id'])){ | 56 | if(isset($this->param['id']) && !empty($this->param['id'])){ |
| 57 | $id = $this->param['id']; | 57 | $id = $this->param['id']; |
| 58 | //查看路由是否更新 | 58 | //查看路由是否更新 |
| @@ -68,11 +68,11 @@ class ProductLogic extends BaseLogic | @@ -68,11 +68,11 @@ class ProductLogic extends BaseLogic | ||
| 68 | CategoryRelated::saveRelated($id, $category_ids); | 68 | CategoryRelated::saveRelated($id, $category_ids); |
| 69 | //保存扩展字段 | 69 | //保存扩展字段 |
| 70 | $this->saveExtendInfo($id,$extend); | 70 | $this->saveExtendInfo($id,$extend); |
| 71 | - DB::connection('custom_mysql')->commit(); | ||
| 72 | - }catch (\Exception $e){ | ||
| 73 | - DB::connection('custom_mysql')->rollBack(); | ||
| 74 | - $this->fail('系统错误请联系管理员'); | ||
| 75 | - } | 71 | +// DB::connection('custom_mysql')->commit(); |
| 72 | +// }catch (\Exception $e){ | ||
| 73 | +// DB::connection('custom_mysql')->rollBack(); | ||
| 74 | +// $this->fail('系统错误请联系管理员'); | ||
| 75 | +// } | ||
| 76 | //通知更新 | 76 | //通知更新 |
| 77 | $this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_PRODUCT, 'route'=>$this->param['route']]); | 77 | $this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_PRODUCT, 'route'=>$this->param['route']]); |
| 78 | return $this->success(); | 78 | return $this->success(); |
| @@ -113,7 +113,7 @@ class ProductLogic extends BaseLogic | @@ -113,7 +113,7 @@ class ProductLogic extends BaseLogic | ||
| 113 | unset($v['title']); | 113 | unset($v['title']); |
| 114 | if($v['type'] == 3 || $v['type'] == 4){ | 114 | if($v['type'] == 3 || $v['type'] == 4){ |
| 115 | foreach ($v['values'] as $k1=>$v1){ | 115 | foreach ($v['values'] as $k1=>$v1){ |
| 116 | - $v1 = str_replace_url($v1); | 116 | + $v1['url'] = str_replace_url($v1['url']); |
| 117 | $v['values'][$k1] = $v1; | 117 | $v['values'][$k1] = $v1; |
| 118 | } | 118 | } |
| 119 | $v['values'] = json_encode($v['values']); | 119 | $v['values'] = json_encode($v['values']); |
| @@ -136,6 +136,16 @@ class ProductLogic extends BaseLogic | @@ -136,6 +136,16 @@ class ProductLogic extends BaseLogic | ||
| 136 | public function editList(){ | 136 | public function editList(){ |
| 137 | $this->param['category_id'] = $this->getLastCategory($this->param['category_id']); | 137 | $this->param['category_id'] = $this->getLastCategory($this->param['category_id']); |
| 138 | $this->param['keyword_id'] = $this->saveKeyword($this->param['keyword_id']); | 138 | $this->param['keyword_id'] = $this->saveKeyword($this->param['keyword_id']); |
| 139 | + if(isset($this->param['gallery']) && !empty($this->param['gallery'])){ | ||
| 140 | + foreach ($this->param['gallery'] as $k => $v){ | ||
| 141 | + $v['url'] = str_replace_url($v['url']); | ||
| 142 | + $this->param['gallery'][$k] = $v; | ||
| 143 | + } | ||
| 144 | + $this->param['thumb'] = Arr::a2s($this->param['gallery'][0] ?? []); | ||
| 145 | + $this->param['gallery'] = Arr::a2s($this->param['gallery'] ?? []); | ||
| 146 | + }else{ | ||
| 147 | + $this->param['thumb'] = Arr::a2s([]); | ||
| 148 | + } | ||
| 139 | $this->model->edit($this->param,['id'=>$this->param['id']]); | 149 | $this->model->edit($this->param,['id'=>$this->param['id']]); |
| 140 | return $this->success(); | 150 | return $this->success(); |
| 141 | } | 151 | } |
| @@ -191,6 +201,8 @@ class ProductLogic extends BaseLogic | @@ -191,6 +201,8 @@ class ProductLogic extends BaseLogic | ||
| 191 | } | 201 | } |
| 192 | $param['thumb'] = Arr::a2s($param['gallery'][0] ?? []); | 202 | $param['thumb'] = Arr::a2s($param['gallery'][0] ?? []); |
| 193 | $param['gallery'] = Arr::a2s($param['gallery'] ?? []); | 203 | $param['gallery'] = Arr::a2s($param['gallery'] ?? []); |
| 204 | + }else{ | ||
| 205 | + $param['thumb'] = Arr::a2s([]); | ||
| 194 | } | 206 | } |
| 195 | $param['attrs'] = Arr::a2s($param['attrs'] ?? []); | 207 | $param['attrs'] = Arr::a2s($param['attrs'] ?? []); |
| 196 | $param['attr_id'] = Arr::arrToSet($param['attr_id'] ?? ''); | 208 | $param['attr_id'] = Arr::arrToSet($param['attr_id'] ?? ''); |
| @@ -201,6 +201,7 @@ class UserLoginLogic | @@ -201,6 +201,7 @@ class UserLoginLogic | ||
| 201 | $info['upload_config'] = $project['upload_config']; | 201 | $info['upload_config'] = $project['upload_config']; |
| 202 | $info['image_max'] = $project['image_max']; | 202 | $info['image_max'] = $project['image_max']; |
| 203 | $info['configuration'] = $project['deploy_build']['configuration']; | 203 | $info['configuration'] = $project['deploy_build']['configuration']; |
| 204 | + $info['type'] = $project['type']; | ||
| 204 | if($info['is_customized'] == 1){ | 205 | if($info['is_customized'] == 1){ |
| 205 | $info['is_visualization'] = json_decode($project['is_visualization']); | 206 | $info['is_visualization'] = json_decode($project['is_visualization']); |
| 206 | } | 207 | } |
| @@ -34,6 +34,8 @@ class KeywordRequest extends FormRequest | @@ -34,6 +34,8 @@ class KeywordRequest extends FormRequest | ||
| 34 | 'seo_title'=>'max:200', | 34 | 'seo_title'=>'max:200', |
| 35 | 'seo_keywords'=>'max:200', | 35 | 'seo_keywords'=>'max:200', |
| 36 | 'seo_description'=>'max:200', | 36 | 'seo_description'=>'max:200', |
| 37 | + 'related_news_ids'=>'array|max:2', | ||
| 38 | + 'related_blog_ids'=>'array|max:2', | ||
| 37 | ]; | 39 | ]; |
| 38 | } | 40 | } |
| 39 | 41 | ||
| @@ -45,6 +47,8 @@ class KeywordRequest extends FormRequest | @@ -45,6 +47,8 @@ class KeywordRequest extends FormRequest | ||
| 45 | 'seo_title.max' => 'SEO标题不能超过200个字符', | 47 | 'seo_title.max' => 'SEO标题不能超过200个字符', |
| 46 | 'seo_keywords.max' => 'SEO关键词不能超过200个字符', | 48 | 'seo_keywords.max' => 'SEO关键词不能超过200个字符', |
| 47 | 'seo_description.max' => 'SEO描述不能超过200个字符', | 49 | 'seo_description.max' => 'SEO描述不能超过200个字符', |
| 50 | + 'related_news_ids.max' => '关联新闻不能超过两条', | ||
| 51 | + 'related_blog_ids.max' => '关联博客不能超过两条', | ||
| 48 | ]; | 52 | ]; |
| 49 | } | 53 | } |
| 50 | 54 |
| @@ -14,6 +14,14 @@ class Blog extends Base | @@ -14,6 +14,14 @@ class Blog extends Base | ||
| 14 | public function user(){ | 14 | public function user(){ |
| 15 | return $this->hasMany(User::class,'operator_id','id'); | 15 | return $this->hasMany(User::class,'operator_id','id'); |
| 16 | } | 16 | } |
| 17 | + | ||
| 18 | + public function getReleaseAtAttribute($value){ | ||
| 19 | + if(!$value){ | ||
| 20 | + return date('Y-m-d H:i:s', strtotime($this->getAttribute('created_at'))); | ||
| 21 | + } | ||
| 22 | + | ||
| 23 | + return $value; | ||
| 24 | + } | ||
| 17 | } | 25 | } |
| 18 | 26 | ||
| 19 | 27 |
| @@ -2,6 +2,7 @@ | @@ -2,6 +2,7 @@ | ||
| 2 | 2 | ||
| 3 | namespace App\Models\Channel; | 3 | namespace App\Models\Channel; |
| 4 | 4 | ||
| 5 | +use App\Models\Base; | ||
| 5 | use Illuminate\Database\Eloquent\Model; | 6 | use Illuminate\Database\Eloquent\Model; |
| 6 | use phpDocumentor\Reflection\Types\Self_; | 7 | use phpDocumentor\Reflection\Types\Self_; |
| 7 | 8 | ||
| @@ -11,7 +12,7 @@ use phpDocumentor\Reflection\Types\Self_; | @@ -11,7 +12,7 @@ use phpDocumentor\Reflection\Types\Self_; | ||
| 11 | * @author zbj | 12 | * @author zbj |
| 12 | * @date 2023/6/27 | 13 | * @date 2023/6/27 |
| 13 | */ | 14 | */ |
| 14 | -class Channel extends Model | 15 | +class Channel extends Base |
| 15 | { | 16 | { |
| 16 | //设置关联表名 | 17 | //设置关联表名 |
| 17 | protected $table = 'gl_channel'; | 18 | protected $table = 'gl_channel'; |
| @@ -2,6 +2,7 @@ | @@ -2,6 +2,7 @@ | ||
| 2 | 2 | ||
| 3 | namespace App\Models\Channel; | 3 | namespace App\Models\Channel; |
| 4 | 4 | ||
| 5 | +use App\Models\Base; | ||
| 5 | use Illuminate\Database\Eloquent\Model; | 6 | use Illuminate\Database\Eloquent\Model; |
| 6 | 7 | ||
| 7 | /** | 8 | /** |
| @@ -10,7 +11,7 @@ use Illuminate\Database\Eloquent\Model; | @@ -10,7 +11,7 @@ use Illuminate\Database\Eloquent\Model; | ||
| 10 | * @author zbj | 11 | * @author zbj |
| 11 | * @date 2023/6/27 | 12 | * @date 2023/6/27 |
| 12 | */ | 13 | */ |
| 13 | -class Zone extends Model | 14 | +class Zone extends Base |
| 14 | { | 15 | { |
| 15 | //设置关联表名 | 16 | //设置关联表名 |
| 16 | protected $table = 'gl_channel_zone'; | 17 | protected $table = 'gl_channel_zone'; |
| @@ -17,7 +17,7 @@ class CollectTask extends Base | @@ -17,7 +17,7 @@ class CollectTask extends Base | ||
| 17 | const STATUS_COM = 2; | 17 | const STATUS_COM = 2; |
| 18 | const STATUS_FAIL = 3; | 18 | const STATUS_FAIL = 3; |
| 19 | 19 | ||
| 20 | - public static function _insert($url, $project_id, $source, $source_id, $link_type = 0, $language_list = []) | 20 | + public static function _insert($url, $project_id, $source, $source_id, $link_type = 0, $language_list = [], $page_list = []) |
| 21 | { | 21 | { |
| 22 | if (!$url) { | 22 | if (!$url) { |
| 23 | return; | 23 | return; |
| @@ -35,10 +35,10 @@ class CollectTask extends Base | @@ -35,10 +35,10 @@ class CollectTask extends Base | ||
| 35 | ]; | 35 | ]; |
| 36 | 36 | ||
| 37 | $task = self::where($where)->first(); | 37 | $task = self::where($where)->first(); |
| 38 | - if (!$task) { | 38 | + $data = []; |
| 39 | $now = date('Y-m-d H:i:s'); | 39 | $now = date('Y-m-d H:i:s'); |
| 40 | - $data = [ | ||
| 41 | - [ | 40 | + if (!$task) { |
| 41 | + $data[] = [ | ||
| 42 | 'project_id' => $project_id, | 42 | 'project_id' => $project_id, |
| 43 | 'source' => $source, | 43 | 'source' => $source, |
| 44 | 'source_id' => $source_id, | 44 | 'source_id' => $source_id, |
| @@ -47,10 +47,10 @@ class CollectTask extends Base | @@ -47,10 +47,10 @@ class CollectTask extends Base | ||
| 47 | 'language' => '', | 47 | 'language' => '', |
| 48 | 'created_at' => $now, | 48 | 'created_at' => $now, |
| 49 | 'updated_at' => $now, | 49 | 'updated_at' => $now, |
| 50 | - ] | ||
| 51 | ]; | 50 | ]; |
| 51 | + } | ||
| 52 | 52 | ||
| 53 | - if ($link_type > 0 && $language_list) { | 53 | + if ($link_type > 0 && $language_list && in_array($url_arr['path'], $page_list)) { |
| 54 | $domain_arr = explode('.', $url_arr['host']); | 54 | $domain_arr = explode('.', $url_arr['host']); |
| 55 | foreach ($language_list as $v_lan) { | 55 | foreach ($language_list as $v_lan) { |
| 56 | if ($link_type == 1) { | 56 | if ($link_type == 1) { |
| @@ -77,5 +77,4 @@ class CollectTask extends Base | @@ -77,5 +77,4 @@ class CollectTask extends Base | ||
| 77 | 77 | ||
| 78 | self::insert($data); | 78 | self::insert($data); |
| 79 | } | 79 | } |
| 80 | - } | ||
| 81 | } | 80 | } |
app/Models/Inquiry/InquiryData.php
0 → 100644
| @@ -21,6 +21,7 @@ class BNav extends Base | @@ -21,6 +21,7 @@ class BNav extends Base | ||
| 21 | use SoftDeletes; | 21 | use SoftDeletes; |
| 22 | 22 | ||
| 23 | public $hidden = ['deleted_at']; | 23 | public $hidden = ['deleted_at']; |
| 24 | + public $appends = ['able_import']; | ||
| 24 | 25 | ||
| 25 | 26 | ||
| 26 | /** | 27 | /** |
| @@ -74,4 +75,19 @@ class BNav extends Base | @@ -74,4 +75,19 @@ class BNav extends Base | ||
| 74 | $value = getImageUrl($value); | 75 | $value = getImageUrl($value); |
| 75 | return $value; | 76 | return $value; |
| 76 | } | 77 | } |
| 78 | + | ||
| 79 | + /** | ||
| 80 | + * 是否支持一键导入 | ||
| 81 | + * @param $value | ||
| 82 | + * @return int | ||
| 83 | + * @author zbj | ||
| 84 | + * @date 2023/11/21 | ||
| 85 | + */ | ||
| 86 | + public function getAbleImportAttribute($value) | ||
| 87 | + { | ||
| 88 | + if(in_array($this->url, ['products','news','blogs'])){ | ||
| 89 | + return 1; | ||
| 90 | + } | ||
| 91 | + return 0; | ||
| 92 | + } | ||
| 77 | } | 93 | } |
| @@ -15,4 +15,12 @@ class News extends Base | @@ -15,4 +15,12 @@ class News extends Base | ||
| 15 | public static function getNumByProjectId($project_id){ | 15 | public static function getNumByProjectId($project_id){ |
| 16 | return self::where('project_id', $project_id)->where('status', 1)->count(); | 16 | return self::where('project_id', $project_id)->where('status', 1)->count(); |
| 17 | } | 17 | } |
| 18 | + | ||
| 19 | + public function getReleaseAtAttribute($value){ | ||
| 20 | + if(!$value){ | ||
| 21 | + return date('Y-m-d H:i:s', strtotime($this->getAttribute('created_at'))); | ||
| 22 | + } | ||
| 23 | + | ||
| 24 | + return $value; | ||
| 25 | + } | ||
| 18 | } | 26 | } |
| @@ -56,4 +56,30 @@ class Keyword extends Base | @@ -56,4 +56,30 @@ class Keyword extends Base | ||
| 56 | } | 56 | } |
| 57 | return $value; | 57 | return $value; |
| 58 | } | 58 | } |
| 59 | + | ||
| 60 | + /** | ||
| 61 | + * @param $value | ||
| 62 | + * @return array|mixed | ||
| 63 | + * @author zbj | ||
| 64 | + * @date 2023/11/21 | ||
| 65 | + */ | ||
| 66 | + public function getRelatedNewsIdsAttribute($value){ | ||
| 67 | + if(!empty($value)){ | ||
| 68 | + $value = Arr::setToArr($value); | ||
| 69 | + } | ||
| 70 | + return $value; | ||
| 71 | + } | ||
| 72 | + | ||
| 73 | + /** | ||
| 74 | + * @param $value | ||
| 75 | + * @return array|false|mixed|string[] | ||
| 76 | + * @author zbj | ||
| 77 | + * @date 2023/11/21 | ||
| 78 | + */ | ||
| 79 | + public function getRelatedBlogIdsAttribute($value){ | ||
| 80 | + if(!empty($value)){ | ||
| 81 | + $value = Arr::setToArr($value); | ||
| 82 | + } | ||
| 83 | + return $value; | ||
| 84 | + } | ||
| 59 | } | 85 | } |
| @@ -81,8 +81,10 @@ class Product extends Base | @@ -81,8 +81,10 @@ class Product extends Base | ||
| 81 | public function getThumbAttribute($value){ | 81 | public function getThumbAttribute($value){ |
| 82 | if(!empty($value)){ | 82 | if(!empty($value)){ |
| 83 | $value = json_decode($value,true); | 83 | $value = json_decode($value,true); |
| 84 | + if(!empty($value['url'])){ | ||
| 84 | $value['url'] = getImageUrl($value['url']); | 85 | $value['url'] = getImageUrl($value['url']); |
| 85 | } | 86 | } |
| 87 | + } | ||
| 86 | return $value; | 88 | return $value; |
| 87 | } | 89 | } |
| 88 | 90 | ||
| @@ -91,7 +93,9 @@ class Product extends Base | @@ -91,7 +93,9 @@ class Product extends Base | ||
| 91 | if(!empty($value)){ | 93 | if(!empty($value)){ |
| 92 | $value = Arr::s2a($value); | 94 | $value = Arr::s2a($value); |
| 93 | foreach ($value as $k => $v){ | 95 | foreach ($value as $k => $v){ |
| 96 | + if(!empty($v['url'])){ | ||
| 94 | $v['url'] = getImageUrl($v['url']); | 97 | $v['url'] = getImageUrl($v['url']); |
| 98 | + } | ||
| 95 | $value[$k] = $v; | 99 | $value[$k] = $v; |
| 96 | } | 100 | } |
| 97 | } | 101 | } |
| @@ -3,7 +3,10 @@ | @@ -3,7 +3,10 @@ | ||
| 3 | namespace App\Models\RouteMap; | 3 | namespace App\Models\RouteMap; |
| 4 | 4 | ||
| 5 | use App\Helper\Translate; | 5 | use App\Helper\Translate; |
| 6 | +use App\Http\Logic\Aside\Project\ProjectLogic; | ||
| 6 | use App\Models\Base; | 7 | use App\Models\Base; |
| 8 | +use App\Models\Project\Project; | ||
| 9 | +use App\Models\Template\BTemplate; | ||
| 7 | 10 | ||
| 8 | /** | 11 | /** |
| 9 | * 路由映射表 | 12 | * 路由映射表 |
| @@ -106,24 +109,30 @@ class RouteMap extends Base | @@ -106,24 +109,30 @@ class RouteMap extends Base | ||
| 106 | } | 109 | } |
| 107 | try { | 110 | try { |
| 108 | $route_map = self::where('project_id', $project_id)->where('source_id', $source_id)->where('source', $source)->first(); | 111 | $route_map = self::where('project_id', $project_id)->where('source_id', $source_id)->where('source', $source)->first(); |
| 112 | + //上线项目 不能修改链接了 | ||
| 113 | + if($route_map){ | ||
| 114 | + $project = ProjectLogic::instance()->getInfo($project_id); | ||
| 115 | + if($project['type'] !== Project::STATUS_ONE){ | ||
| 116 | + return $route_map->route; | ||
| 117 | + } | ||
| 118 | + } | ||
| 109 | if(!$route_map){ | 119 | if(!$route_map){ |
| 110 | $route_map = new self(); | 120 | $route_map = new self(); |
| 111 | $route_map->source = $source; | 121 | $route_map->source = $source; |
| 122 | + $route_map->source_id = $source_id; | ||
| 123 | + $route_map->project_id = $project_id; | ||
| 124 | + if ($source == self::SOURCE_PRODUCT_KEYWORD){ | ||
| 125 | + $route = self::setKeywordRoute($route); | ||
| 126 | + //查看当前路由是否存在 | ||
| 127 | + }elseif ($source == self::SOURCE_PRODUCT){ | ||
| 128 | + //产品单独处理路由 | ||
| 129 | + $route = self::setProductRoute($route); | ||
| 130 | + } | ||
| 131 | + } | ||
| 112 | if($source == self::SOURCE_NEWS){ | 132 | if($source == self::SOURCE_NEWS){ |
| 113 | $route_map->path = self::SOURCE_NEWS; | 133 | $route_map->path = self::SOURCE_NEWS; |
| 114 | - }elseif($source == self::SOURCE_NEWS_CATE){ | ||
| 115 | - $route_map->path = self::PATH_NEWS_CATE; | ||
| 116 | }elseif ($source == self::SOURCE_BLOG){ | 134 | }elseif ($source == self::SOURCE_BLOG){ |
| 117 | $route_map->path = self::SOURCE_BLOG; | 135 | $route_map->path = self::SOURCE_BLOG; |
| 118 | - }elseif ($source == self::SOURCE_BLOG_CATE){ | ||
| 119 | - $route_map->path = self::PATH_BLOG_CATE; | ||
| 120 | - }elseif ($source == self::SOURCE_PRODUCT_KEYWORD){ | ||
| 121 | - $route = $route.'-tag'; | ||
| 122 | - }elseif ($source == self::SOURCE_PRODUCT){ | ||
| 123 | - $route = $route.'-product'; | ||
| 124 | - } | ||
| 125 | - $route_map->source_id = $source_id; | ||
| 126 | - $route_map->project_id = $project_id; | ||
| 127 | } | 136 | } |
| 128 | $route_map->route = $route; | 137 | $route_map->route = $route; |
| 129 | $route_map->save(); | 138 | $route_map->save(); |
| @@ -135,6 +144,46 @@ class RouteMap extends Base | @@ -135,6 +144,46 @@ class RouteMap extends Base | ||
| 135 | 144 | ||
| 136 | 145 | ||
| 137 | /** | 146 | /** |
| 147 | + * @remark :产品新增单独处理路由 | ||
| 148 | + * @name :setProductRoute | ||
| 149 | + * @author :lyh | ||
| 150 | + * @method :post | ||
| 151 | + * @time :2023/11/21 18:48 | ||
| 152 | + */ | ||
| 153 | + public static function setProductRoute($route,$i = 0){ | ||
| 154 | + $route = $route.'-product'; | ||
| 155 | + $routeMapModel = new RouteMap(); | ||
| 156 | + $routeInfo = $routeMapModel->read(['route'=>$route]); | ||
| 157 | + if($routeInfo === false){ | ||
| 158 | + return $route; | ||
| 159 | + }else{ | ||
| 160 | + $i = $i + 1; | ||
| 161 | + $route = $route.'-'.$i; | ||
| 162 | + return self::setProductRoute($route,$i); | ||
| 163 | + } | ||
| 164 | + } | ||
| 165 | + | ||
| 166 | + /** | ||
| 167 | + * @remark :关键字新增单独处理路由 | ||
| 168 | + * @name :setProductRoute | ||
| 169 | + * @author :lyh | ||
| 170 | + * @method :post | ||
| 171 | + * @time :2023/11/21 18:48 | ||
| 172 | + */ | ||
| 173 | + public static function setKeywordRoute($route,$i = 0){ | ||
| 174 | + $route = $route.'-tag'; | ||
| 175 | + $routeMapModel = new RouteMap(); | ||
| 176 | + $routeInfo = $routeMapModel->read(['route'=>$route]); | ||
| 177 | + if($routeInfo === false){ | ||
| 178 | + return $route; | ||
| 179 | + }else{ | ||
| 180 | + $i = $i + 1; | ||
| 181 | + $route = $route.'-'.$i; | ||
| 182 | + return self::setProductRoute($route,$i); | ||
| 183 | + } | ||
| 184 | + } | ||
| 185 | + | ||
| 186 | + /** | ||
| 138 | * @param $route | 187 | * @param $route |
| 139 | * @param $project_id | 188 | * @param $project_id |
| 140 | * @return mixed | 189 | * @return mixed |
| @@ -13,7 +13,20 @@ use App\Models\Base; | @@ -13,7 +13,20 @@ use App\Models\Base; | ||
| 13 | class BTemplate extends Base | 13 | class BTemplate extends Base |
| 14 | { | 14 | { |
| 15 | const SOURCE_HOME = 1;//首页 | 15 | const SOURCE_HOME = 1;//首页 |
| 16 | - const SOURCE_PRODUCT = 2;//产品页 | 16 | + const SOURCE_PRODUCT = 2;//产品 |
| 17 | + const SOURCE_BLOG = 3;//博客 | ||
| 18 | + const SOURCE_NEWS = 4;//新闻详情页 | ||
| 19 | + const SOURCE_KEYWORD = 5;//聚合页 | ||
| 20 | + const STATUS = 0; | ||
| 21 | + | ||
| 22 | + const TYPE_ONE = 0; | ||
| 23 | + const TYPE_TWO = 0; | ||
| 24 | + const TYPE_THREE = 0; | ||
| 25 | + const TYPE_FOUR = 0; | ||
| 26 | + const TYPE_FIVE = 0; | ||
| 27 | + const TYPE_SIX = 0; | ||
| 28 | + const TYPE_SEVEN = 0; | ||
| 29 | + const TYPE_ = 0; | ||
| 17 | 30 | ||
| 18 | protected $table = 'gl_web_template'; | 31 | protected $table = 'gl_web_template'; |
| 19 | //连接数据库 | 32 | //连接数据库 |
| @@ -104,7 +104,11 @@ class CosService | @@ -104,7 +104,11 @@ class CosService | ||
| 104 | 'verify_peer_name' => false, | 104 | 'verify_peer_name' => false, |
| 105 | ] | 105 | ] |
| 106 | ]; | 106 | ]; |
| 107 | + try { | ||
| 107 | $body = file_get_contents($file_url,false,stream_context_create($opts)); | 108 | $body = file_get_contents($file_url,false,stream_context_create($opts)); |
| 109 | + }catch (\Exception $e){ | ||
| 110 | + return ''; | ||
| 111 | + } | ||
| 108 | 112 | ||
| 109 | try { | 113 | try { |
| 110 | $cosClient->putObject([ | 114 | $cosClient->putObject([ |
| @@ -172,6 +172,9 @@ Route::middleware(['aloginauth'])->group(function () { | @@ -172,6 +172,9 @@ Route::middleware(['aloginauth'])->group(function () { | ||
| 172 | Route::any('/tdkList', [Aside\Project\ProjectController::class, 'tdkList'])->name('admin.project_tdkList'); | 172 | Route::any('/tdkList', [Aside\Project\ProjectController::class, 'tdkList'])->name('admin.project_tdkList'); |
| 173 | Route::any('/copyProject', [Aside\Project\ProjectController::class, 'copyProject'])->name('admin.project_copyProject'); | 173 | Route::any('/copyProject', [Aside\Project\ProjectController::class, 'copyProject'])->name('admin.project_copyProject'); |
| 174 | Route::any('/site_token', [Aside\Project\ProjectController::class, 'site_token'])->name('admin.project_site_token'); | 174 | Route::any('/site_token', [Aside\Project\ProjectController::class, 'site_token'])->name('admin.project_site_token'); |
| 175 | + Route::any('/saveOtherProject', [Aside\Project\ProjectController::class, 'saveOtherProject'])->name('admin.project_saveOtherProject');//其他项目设置 | ||
| 176 | + Route::any('/getOtherProject', [Aside\Project\ProjectController::class, 'getOtherProject'])->name('admin.project_getOtherProject');//获取其他项目设置 | ||
| 177 | + Route::any('/getChannel', [Aside\Project\ProjectController::class, 'getChannel'])->name('admin.project_getChannel');//其他项目设置 | ||
| 175 | //获取关键词前缀和后缀 | 178 | //获取关键词前缀和后缀 |
| 176 | Route::prefix('keyword')->group(function () { | 179 | Route::prefix('keyword')->group(function () { |
| 177 | Route::any('/getKeywordPrefix', [Aside\Project\KeywordPrefixController::class, 'getKeywordPrefix'])->name('admin.keyword_getKeywordPrefix'); | 180 | Route::any('/getKeywordPrefix', [Aside\Project\KeywordPrefixController::class, 'getKeywordPrefix'])->name('admin.keyword_getKeywordPrefix'); |
| @@ -249,6 +252,7 @@ Route::middleware(['aloginauth'])->group(function () { | @@ -249,6 +252,7 @@ Route::middleware(['aloginauth'])->group(function () { | ||
| 249 | Route::any('/', [Aside\Optimize\OptimizeController::class, 'lists'])->name('admin.optimize_lists');//优化中台 | 252 | Route::any('/', [Aside\Optimize\OptimizeController::class, 'lists'])->name('admin.optimize_lists');//优化中台 |
| 250 | Route::any('/getAiPrefix', [Aside\Optimize\OptimizeController::class, 'getAiPrefix'])->name('admin.optimize_getAiPrefix');//获取Ai前后缀 | 253 | Route::any('/getAiPrefix', [Aside\Optimize\OptimizeController::class, 'getAiPrefix'])->name('admin.optimize_getAiPrefix');//获取Ai前后缀 |
| 251 | Route::any('/saveAiPrefix', [Aside\Optimize\OptimizeController::class, 'saveAiPrefix'])->name('admin.optimize_saveAiPrefix');//保存Ai前后缀 | 254 | Route::any('/saveAiPrefix', [Aside\Optimize\OptimizeController::class, 'saveAiPrefix'])->name('admin.optimize_saveAiPrefix');//保存Ai前后缀 |
| 255 | + Route::any('/setRobots', [Aside\Optimize\OptimizeController::class, 'setRobots'])->name('admin.optimize_setRobots');//设置robots开关 | ||
| 252 | }); | 256 | }); |
| 253 | 257 | ||
| 254 | //优化中台 | 258 | //优化中台 |
| @@ -343,6 +347,8 @@ Route::group([], function () { | @@ -343,6 +347,8 @@ Route::group([], function () { | ||
| 343 | Route::any('get_template_detail', [Aside\Template\ATemplateController::class, 'getTemplateDetail'])->name('admin.get_template_detail'); | 347 | Route::any('get_template_detail', [Aside\Template\ATemplateController::class, 'getTemplateDetail'])->name('admin.get_template_detail'); |
| 344 | 348 | ||
| 345 | Route::any('/collect', [Aside\Collect\CollectController::class, 'index'])->name('admin.collect'); | 349 | Route::any('/collect', [Aside\Collect\CollectController::class, 'index'])->name('admin.collect'); |
| 350 | + //同步询盘 | ||
| 351 | + Route::any('/sync_inquiry', [Aside\Com\IndexController::class, 'sync_inquiry'])->name('admin.sync_inquiry'); | ||
| 346 | }); | 352 | }); |
| 347 | 353 | ||
| 348 | 354 |
| @@ -301,8 +301,6 @@ Route::middleware(['bloginauth'])->group(function () { | @@ -301,8 +301,6 @@ Route::middleware(['bloginauth'])->group(function () { | ||
| 301 | Route::any('/publicTemplateLists', [\App\Http\Controllers\Bside\Template\BTemplateController::class, 'publicTemplateLists'])->name('template_publicTemplateLists'); | 301 | Route::any('/publicTemplateLists', [\App\Http\Controllers\Bside\Template\BTemplateController::class, 'publicTemplateLists'])->name('template_publicTemplateLists'); |
| 302 | //获取选中的主题模版 | 302 | //获取选中的主题模版 |
| 303 | Route::any('/getPublicTemplate', [\App\Http\Controllers\Bside\Template\BTemplateController::class, 'getPublicTemplate'])->name('template_getPublicTemplate'); | 303 | Route::any('/getPublicTemplate', [\App\Http\Controllers\Bside\Template\BTemplateController::class, 'getPublicTemplate'])->name('template_getPublicTemplate'); |
| 304 | - //设置默认主题模版 | ||
| 305 | - Route::any('/setPublicTemplate', [\App\Http\Controllers\Bside\Template\BTemplateController::class, 'setPublicTemplate'])->name('template_setPublicTemplate'); | ||
| 306 | //保存修改后的模版 | 304 | //保存修改后的模版 |
| 307 | Route::any('/save', [\App\Http\Controllers\Bside\Template\BTemplateController::class, 'save'])->name('template_save'); | 305 | Route::any('/save', [\App\Http\Controllers\Bside\Template\BTemplateController::class, 'save'])->name('template_save'); |
| 308 | //可视化保存获取数据类型 | 306 | //可视化保存获取数据类型 |
-
请 注册 或 登录 后发表评论