作者 赵彬吉
正在显示 33 个修改的文件 包含 872 行增加612 行删除
... ... @@ -33,7 +33,7 @@ class UpgradeProjectCount extends Command
protected $description = '升级项目统计';
public function handle(){
$project_id = 555;
$project_id = 566;
ProjectServer::useProject($project_id);
$this->count($project_id);
DB::disconnect('custom_mysql');
... ...
... ... @@ -43,8 +43,10 @@ class DomainInfo extends Command
foreach ($list as $v){
if(empty($v['private_key']) || empty($v['private_cert'])){
//域名结束时间<2天时,重新生成
if(!empty($v['certificate_end_time']) && ($v['certificate_end_time'] > date('Y-m-d H:i:s',time() + 24*3600))){
$this->updatePrivate($v);
if(!empty($v['certificate_end_time'])){
if(($v['certificate_end_time'] > date('Y-m-d H:i:s',time() + 24*3600)) || ($v['certificate_end_time'] < date('Y-m-d H:i:s',time()))){
$this->updatePrivate($v);
}
}
}
$ssl = $this->updateDomainSsl($v['domain']);
... ... @@ -77,7 +79,6 @@ class DomainInfo extends Command
public function updatePrivate($param)
{
$url = 'https://' . $param['domain']. '/api/applySsl/';
$extend_config = json_decode($param['extend_config'], true);
$top_domain = $this->getTopDomain($param['domain']);
if ((empty($extend_config) || empty($extend_config[0]['origin'])) && $param['id'] != 3) {
$extend_config = [
... ... @@ -89,13 +90,14 @@ class DomainInfo extends Command
'type' => 1,
'route' => 1,
"domain" =>$param['domain'],
"rewrite"=> $extend_config,
"rewrite"=> $extend_config ?? [],
'other_domain' => [$top_domain, '*.' . $top_domain],
'private_key' => '',
'cert' => ''
];
$result = $this->curlRequest($url, $param);
Log::info('domain id: ' . $param['id'] . ', domain: ' . $param['domain'] . ', result: ' . var_export($result, true));
@file_put_contents(storage_path('logs/lyh_error.log'), var_export($result, true) . PHP_EOL, FILE_APPEND);
@file_put_contents(storage_path('logs/lyh_error.log'), var_export($param['domain'], true) . PHP_EOL, FILE_APPEND);
}
public static function getTopDomain ($url) {
... ...
... ... @@ -10,6 +10,7 @@
namespace App\Console\Commands\MonthlyCount;
use App\Helper\FormGlobalsoApi;
use App\Models\Com\UpdateOldInfo;
use App\Models\HomeCount\MonthCount;
use App\Models\Project\Project;
use App\Models\Visit\Visit;
... ... @@ -35,8 +36,10 @@ class UpgradeProjectCount extends Command
protected $description = '升级项目统计';
public function handle(){
$project_id = 555;
$url = 'www.sincoherenaesthetics.com';
$project_id = 566;
$oldModel = new UpdateOldInfo();
$info = $oldModel->read(['project_id'=>$project_id]);
$url = $info['old_domain_online'];
ProjectServer::useProject($project_id);
$this->count($project_id,$url);
... ... @@ -67,6 +70,14 @@ class UpgradeProjectCount extends Command
$arr['month_total'] = 0;
if(isset($res['data']['count'])){
$arr['month_total'] = $res['data']['count'];
//获取上一个的count
$previousMonth = date('Y-m', strtotime($v['month'] . ' -1 month'));
$previousInfo = $monthCountModel->read(['month'=>$previousMonth,'project_id'=>$project_id]);
if($previousInfo === false){
$arr['total'] = $arr['month_total'];
}else{
$arr['total'] = $res['data']['count'] + ($previousInfo['total'] ?? 0);
}
}
if(isset($res['data']['data'])){
$arr['country'] = json_encode($res['data']['data']);
... ...
<?php
namespace App\Console\Commands\Update;
use App\Models\Collect\CollectSource;
use App\Models\Collect\CollectTask;
use App\Models\Com\UpdateLog;
use App\Models\Com\UpdateOldInfo;
use App\Models\RouteMap\RouteMap;
use App\Services\CosService;
use App\Services\ProjectServer;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Redis;
/**
* 4.0,5.0升级到6.0,主站自定义页面采集
* Class ProjectImport
* @package App\Console\Commands
* @author Akun
* @date 2023/12/13 14:44
*/
class HtmlCustomCollect extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'project_html_custom_collect';
/**
* The console command description.
*
* @var string
*/
protected $description = '执行项目自定义html页面采集';
public function handle()
{
ini_set('memory_limit', '512M');
// $project_id = 437;
// $project_site = 'v6-1500k.globalso.site';
// $pages = [
// 'https://www.tourletent.com/project/b300-glamping-tent-in-china/',
// 'https://www.tourletent.com/project/lotus-bell-tent-in-australia/',
// 'https://www.tourletent.com/project/luxury-resort-in-china/',
// 'https://www.tourletent.com/project/canvas-safari-tent-inthailand/',
// 'https://www.tourletent.com/project/safari-tent-for-m8-in-mexcio/',
// 'https://www.tourletent.com/project/9m-pvc-dome-tent-in-canada/',
// 'https://www.tourletent.com/project/c900-hotel-tent-in-korea/',
// 'https://www.tourletent.com/project/safari-tent-in-guizhou/',
// 'https://www.tourletent.com/project/dome-tent-in-austin/',
// 'https://www.tourletent.com/project/safari-tent-in-italy/',
// 'https://www.tourletent.com/project/glass-igloo-in-china/',
// 'https://www.tourletent.com/project/tree-house-in-sichuan/'
// ];
// $project_id = 517;
// $project_site = 'v6-1gee9.globalso.site';
// $pages = [
// 'https://www.beifa.group/help/send-results/',
// 'https://www.beifa.group/help/terms-of-use/',
// 'https://www.beifa.group/help/position-3/',
// 'https://www.beifa.group/help/position-2/',
// 'https://www.beifa.group/help/position-1/',
// 'https://www.beifa.group/help/social-media/',
// 'https://www.beifa.group/help/globle-exibition-2/',
// 'https://www.beifa.group/help/job/',
// 'https://www.beifa.group/help/vr/',
// 'https://www.beifa.group/help/on-live-video/',
// 'https://www.beifa.group/help/honor/',
// 'https://www.beifa.group/help/certification/',
// 'https://www.beifa.group/help/quanity-control/',
// 'https://www.beifa.group/help/testing-center/',
// 'https://www.beifa.group/help/rd/',
// 'https://www.beifa.group/help/design-trend/',
// 'https://www.beifa.group/help/partner/',
// 'https://www.beifa.group/help/social-responsibility/',
// 'https://www.beifa.group/help/contact/',
// ];
$project_id = 546;
$project_site = 'v6-kx260.globalso.site';
$pages = [
'https://www.grechofiberglass.com/success_stories/',
'https://www.grechofiberglass.com/success_stories/achieving-transformative-improvements-for-polyurethane-exterior-insulation-panels-in-france/',
'https://www.grechofiberglass.com/success_stories/grechos-fiberglass-rebar-revolutionizing-canadian-construction-projects-with-unparalleled-quality/',
'https://www.grechofiberglass.com/success_stories/customer-from-the-uk-purchases-fiberglass-coated-mats-for-plasterboards-from-grecho/',
'https://www.grechofiberglass.com/success_stories/supplying-carbon-fiber-to-australian-surfboard-manufacturer/',
'https://www.grechofiberglass.com/success_stories/300g-chopped-strand-mat-for-composite-slates-shipped-to-malaysia/',
'https://www.grechofiberglass.com/success_stories/fiberglass-roving-for-pipewater-tank-shipped-to-russia/',
'https://www.grechofiberglass.com/success_stories/fiberglass-fleece-for-acoustic-ceiling-shipped-to-russia/',
'https://www.grechofiberglass.com/success_stories/600g-fiberglass-aluminum-foil-cloth-shipped-to-australia-for-pipe-heat-shielding/',
'https://www.grechofiberglass.com/success_stories/shipping-our-first-truck-of-fiberglass-tissue-in-2022/',
];
// $project_id = 586;
// $project_site = 'v6-m605x.globalso.site';
// $pages = [
// 'https://www.citymax-group.com/case/',
// 'https://www.citymax-group.com/case_catalog/crop-classification/',
// 'https://www.citymax-group.com/case_catalog/field-crops/',
// 'https://www.citymax-group.com/case_catalog/fruits/',
// 'https://www.citymax-group.com/case_catalog/vegetables/',
// 'https://www.citymax-group.com/case/report-on-use-of-citymax-products-on-grapes-2/',
// 'https://www.citymax-group.com/case/report-on-use-of-citymax-products-on-cucumber/',
// 'https://www.citymax-group.com/case/field-experiment-crop-lettuce/',
// ];
// $project_id = 626;
// $project_site = 'v6-m342g.globalso.site';
// $pages = [
// 'https://www.lecusostreetlight.com/project_catalog/project/',
// 'https://www.lecusostreetlight.com/project_catalog/project/page/2/',
// 'https://www.lecusostreetlight.com/project/560pcs-250w-smart-led-street-light-in-manila-city-philippines/',
// 'https://www.lecusostreetlight.com/project/3200pcs-8m-150w-solar-street-light-in-cebu-philippines/',
// 'https://lecusostreetlight.com/project/170pcs-100w-split-lithium-battery-solar-street-light-in-tanzania/',
// 'https://www.lecusostreetlight.com/project/250pcs-40w-sl-series-solar-street-light-in-kuwait/',
// 'https://www.lecusostreetlight.com/project/272pcs-8m-80w-solar-street-light-in-tanzania/',
// 'https://www.lecusostreetlight.com/project/185pcs-10m-120w-highway-solar-street-light-in-jordan/',
// 'https://www.lecusostreetlight.com/project/270pcs-9m-patterned-decorative-light-pole-with-150w-led-cobra-light-in-cambodia/',
// 'https://www.lecusostreetlight.com/project/48pcs-5m-24w-decorative-aluminium-pole-in-dubai-uae/',
// 'https://www.lecusostreetlight.com/project/105pcs-9m-100w-led-street-light-in-sri-lanka/',
// 'https://www.lecusostreetlight.com/project/45pcs-6m-hot-dip-galvanized-double-arm-street-light-pole-in-dubai-uae/',
// 'https://www.lecusostreetlight.com/project/356pcs-8m-100w-solar-street-light-in-ethiopia/',
// 'https://www.lecusostreetlight.com/project/52pcs-6m-30w-solar-led-street-light-with-gel-battery-in-poland/',
// 'https://www.lecusostreetlight.com/project/225pcs-6m-80w-solar-street-light-in-vietnam/',
// 'https://www.lecusostreetlight.com/project/450pcs-7m-60w-double-arm-solar-light-in-nigeria/',
// 'https://www.lecusostreetlight.com/project/100pcs-6m-50w-led-street-light-in-maldives/',
// 'https://www.lecusostreetlight.com/project/202pcs-6m-40w-3000k-solar-street-light-in-manila-philippines/',
// 'https://www.lecusostreetlight.com/project/245pcs-120w-smart-led-street-light-in-bangkok-thailand/',
// 'https://www.lecusostreetlight.com/project/170pcs-7m-50w-all-in-one-solar-light-in-davao-philippines/',
// 'https://www.lecusostreetlight.com/project/80pcs-9m-150w-led-street-light-in-iraq/',
// 'https://www.lecusostreetlight.com/project/252pcs-6m-40w-separate-solar-street-light-with-lithium-battery-in-thailand/',
// 'https://www.lecusostreetlight.com/project/198pcs-8m-80w-zc-series-all-in-two-solar-light-in-philippines/',
// 'https://www.lecusostreetlight.com/project/5m-30w-morden-led-garden-light-in-russian/',
// 'https://www.lecusostreetlight.com/project/135pcs-all-in-one-solar-street-light-in-uae-dubai-park/'
// ];
// $project_id = 633;
// $project_site = 'v6-ke5nz.globalso.site';
// $pages = [
// 'https://www.mach-sales.com/case_catalog/cases/',
// 'https://www.mach-sales.com/case_catalog/cases/page/2/',
// 'https://www.mach-sales.com/case_catalog/cases/page/3/',
// 'https://www.mach-sales.com/case/growing-with-customers-from-small-motors-to-big-drivers/',
// 'https://www.mach-sales.com/case/growing-together-with-customers-the-journey-of-intelligent-manufacturing-in-a-modernized-factory/',
// 'https://www.mach-sales.com/case/%e3%80%90growing-together-with-customers%e3%80%91-the-evolutionary-journey-of-a-baking-brand/',
// 'https://www.mach-sales.com/case/sumecs-footprints-in-belt-and-road-singapore/',
// 'https://www.mach-sales.com/case/sumecs-footprints-in-belt-and-road-southeast-asia/',
// 'https://www.mach-sales.com/case/naming-and-delivery-of-a-new-ship-1/',
// 'https://www.mach-sales.com/case/a-newly-signed-contract-cable-manufacturing-equipment/',
// 'https://www.mach-sales.com/case/its-amazing-that-the-glass-can-also-save-energy/',
// 'https://www.mach-sales.com/case/%e3%80%90grow-with-customers%e3%80%91better-service-for-papermaking-equipment-procurement/',
// 'https://www.mach-sales.com/case/expansion-of-blower-equipment-contributes-to-environmental-protection/',
// 'https://www.mach-sales.com/case/new-ship-type-new-contract/',
// 'https://www.mach-sales.com/case/new-arrival-introducing-the-latest-ship-model/',
// 'https://www.mach-sales.com/case/another-contract-signed-in-the-philippines/',
// 'https://www.mach-sales.com/case/the-road-to-going-global-is-supported-by-sumec-services/',
// 'https://www.mach-sales.com/case/sumec-textile-launches-sun-protection-series-in-collaboration-with-skechers-kids/',
// 'https://www.mach-sales.com/case/footwear-manufacturing-equipment-new-contract/',
// 'https://www.mach-sales.com/case/sumec-energy-company-has-successfully-signed-a-photovoltaic-component-supply-agreement-with-wattkraft-a-german-engineering-system-integrator/',
// 'https://www.mach-sales.com/case/sumec-technology-company-successfully-signed-a-contract-for-the-equipment-related-to-the-high-strength-particleboard-project/',
// 'https://www.mach-sales.com/case/%e3%80%90growing-together-with-our-customers%e3%80%91together-on-the-road-to-transformation/',
// 'https://www.mach-sales.com/case/new-signing/',
// 'https://www.mach-sales.com/case/complete-the-last-mile-equipment-procurement-from-around-the-world/',
// 'https://www.mach-sales.com/case/science-and-technology-to-rejuvenate-agriculture-this-plant-factory-is-not-simple/',
// 'https://www.mach-sales.com/case/new-cooperation-high-end-equipment-going-global/',
// 'https://www.mach-sales.com/case/a-new-cooperation-with-an-annual-output-of-40000-tons/',
// 'https://www.mach-sales.com/case/a-new-contract-cooperation-upgrades/',
// 'https://www.mach-sales.com/case/annual-output-of-50000-tons-this-bopp-film-production-line-was-officially-put-into-operation/',
// 'https://www.mach-sales.com/case/this-is-sumec-speed/',
// 'https://www.mach-sales.com/case/the-first-order-of-a-new-semiconductor-brand-equipment-direct-sales-bear-fruit-again/',
// 'https://www.mach-sales.com/case/sumec-touch-world-celebrates-its-5th-anniversary-with-well-known-suppliers/',
// 'https://www.mach-sales.com/case/from-traditional-agency-to-digital-service/',
// 'https://www.mach-sales.com/case/cooperation-win-win-and-starting-anew-sumec-creates-a-new-sample-of-strong-enterprise-cooperation/'
// ];
foreach ($pages as $page) {
$this->start_collect(urldecode($page), $project_id, $project_site);
}
}
protected function start_collect($page, $project_id, $project_site)
{
$page_arr = parse_url($page);
$domain = $page_arr['host'];
$path = $page_arr['path'];
//设置数据库
$project = ProjectServer::useProject($project_id);
if ($project) {
echo 'date:' . date('Y-m-d H:i:s') . ', project_id: ' . $project_id . ', page: ' . $page . ', collect start' . PHP_EOL;
//获取站点原始域名信息
$old_info = UpdateOldInfo::getOldDomain($project_id, $domain);
//采集html页面,下载资源到本地并替换
try {
$html = curl_c($page, false);
if ($html == '0') {
echo 'date:' . date('Y-m-d H:i:s') . ', project_id: ' . $project_id . ', page: ' . $page . ', error: no html' . PHP_EOL;
sleep(2);
return true;
}
//如果有base64图片,先替换掉,再进行资源匹配
$new_html = $html;
preg_match_all("/data:([^;]*);base64,(.*)?\"/", $new_html, $result_img);
$img_base64 = $result_img[2] ?? [];
foreach ($img_base64 as $v64) {
$new_html = str_replace($v64, '', $new_html);
}
//匹配资源链接
$source_list = $this->html_preg($new_html, $project_id, $domain, $old_info['web_url_domain'], $old_info['home_url']);
//下载资源
if ($source_list) {
$html = $this->upload_source($html, $source_list, $project_id, $domain, $old_info['web_url_domain'], $old_info['home_url']);
}
//替换域名
$html = str_replace($old_info['web_url_domain'], $project_site, $html);
$html = str_replace($old_info['home_url'], $project_site, $html);
//暂时隐藏小语种
// $html = str_replace('<div class="change-language ensemble">', '<div class="change-language ensemble" style="display: none">', $html);
// $html = str_replace('<div class="language_more">', '<div class="language_more" style="display: none">', $html);
//处理搜索
preg_match_all('/<form\s+[^>]*?action\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $html, $result_search);
$search = $result_search[2] ?? [];
foreach ($search as $vc) {
if((strpos($vc,'search.php') !== false) || (strpos($vc,'index.php') !== false)){
$html = str_replace($vc,'/search/',$html);
}
}
//增加统计代码
$html = str_replace('</body>', '<script src="https://ecdn6.globalso.com/public/customerVisit.min.js\"></script></body>', $html);
//html写入文件
$file_path = '/www/wwwroot/globalso-v6-c-glo/public/' . $project_site . $path;
if (!file_exists($file_path)) {
mkdir($file_path, 0777, true);
}
file_put_contents($file_path . 'index.html', $html);
chmod($file_path . 'index.html', 0777);
} catch (\Exception $e) {
echo 'date:' . date('Y-m-d H:i:s') . ', project_id: ' . $project_id . ', page: ' . $page . ', error: ' . $e->getMessage() . PHP_EOL;
sleep(2);
return true;
}
echo 'date:' . date('Y-m-d H:i:s') . ', project_id: ' . $project_id . ', page: ' . $page . ', collect end' . PHP_EOL;
} else {
echo 'date:' . date('Y-m-d H:i:s') . ', project_id: ' . $project_id . ', page: ' . $page . ', no project' . PHP_EOL;
}
//关闭数据库
DB::disconnect('custom_mysql');
sleep(2);
return true;
}
//正则匹配html资源
protected function html_preg($html, $project_id, $domain, $web_url_domain, $home_url)
{
$source = [];
if (!$html) {
return $source;
}
//image
preg_match_all('/<img\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $html, $result_img);
$img = $result_img[2] ?? [];
foreach ($img as $vi) {
$check_vi = $this->url_check($vi, $project_id, $domain, $web_url_domain, $home_url);
$check_vi && $source[] = $check_vi;
}
//js
preg_match_all('/<script\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $html, $result_js);
$js = $result_js[2] ?? [];
foreach ($js as $vj) {
$check_vj = $this->url_check($vj, $project_id, $domain, $web_url_domain, $home_url);
$check_vj && $source[] = $check_vj;
}
//video
preg_match_all('/<source\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $html, $result_video);
$video = $result_video[2] ?? [];
foreach ($video as $vv) {
$check_vv = $this->url_check($vv, $project_id, $domain, $web_url_domain, $home_url);
$check_vv && $source[] = $check_vv;
}
//css
preg_match_all('/<link\s+[^>]*?href\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $html, $result_css);
$css = $result_css[2] ?? [];
foreach ($css as $vc) {
$check_vc = $this->url_check($vc, $project_id, $domain, $web_url_domain, $home_url);
$check_vc && $source[] = $check_vc;
}
//css background
preg_match_all("/url\(['\"]?(\s*[^>]+?)['\"]?\)/i", $html, $result_css_b);
$css_b = $result_css_b[1] ?? [];
foreach ($css_b as $vc_b) {
$check_vc_b = $this->url_check($vc_b, $project_id, $domain, $web_url_domain, $home_url);
$check_vc_b && $source[] = $check_vc_b;
}
//a标签下载资源
preg_match_all('/<a\s+[^>]*?href\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $html, $result_a);
$down = $result_a[2] ?? [];
foreach ($down as $vd) {
$check_vd = $this->url_check($vd, $project_id, $domain, $web_url_domain, $home_url);
$check_vd && $source[] = $check_vd;
}
return $source;
}
//判断资源是否需要下载
protected function url_check($url, $project_id, $domain, $web_url_domain, $home_url)
{
if ($url) {
$url = str_replace('&quot;', '', $url);
$arr = parse_url($url);
$scheme = $arr['scheme'] ?? '';
$host = $arr['host'] ?? '';
$path = $arr['path'] ?? '';
$query = $arr['query'] ?? '';
$path_arr = explode('.', $path);
if (
(empty($scheme) || $scheme == 'https' || $scheme == 'http')
&& (empty($host) || (strpos($web_url_domain, $host) !== false) || (strpos($home_url, $host) !== false))
&& $path
&& (substr($path, 0, 1) == '/')
&& (strpos($path, '.') !== false)
&& (!in_array(end($path_arr), ['html', 'php', 'com', 'xml']))
) {
$source = CollectSource::where('project_id', $project_id)->where('origin', $url)->first();
if (!$source) {
return [
'download' => true,
'url' => $url,
'url_complete' => ($scheme ?: 'https') . '://' . ($host ?: $domain) . $path . ($query ? '?' . $query : '')
];
} else {
return [
'download' => false,
'url' => $url,
'url_complete' => $source['target']
];
}
} else {
return false;
}
} else {
return false;
}
}
//下载并替换资源
protected function upload_source($html, $source, $project_id, $domain, $web_url_domain, $home_url)
{
foreach ($source as $vs) {
if ($vs['download']) {
$new_source = CosService::uploadRemote($project_id, 'source', $vs['url_complete']);
if ($new_source) {
CollectSource::insert([
'project_id' => $project_id,
'origin' => $vs['url'],
'target' => $new_source,
'created_at' => date('Y-m-d H:i:s'),
'updated_at' => date('Y-m-d H:i:s'),
]);
$html = str_replace($vs['url'], getImageUrl($new_source), $html);
if (substr($new_source, -3, 3) == 'css' || substr($new_source, -2, 2) == 'js') {
$source_html = curl_c(getImageUrl($new_source), false);
if (substr($new_source, -3, 3) == 'css') {
preg_match_all("/url\(['\"]?(\s*[^>]+?)['\"]?\)/i", $source_html, $result_source);
} else {
preg_match_all("/[large|thumb]+URL:['\"]+(\s*[^>]+?)['\"]+,/i", $source_html, $result_source);
}
$js_css_source = $result_source[1] ?? [];
if ($js_css_source) {
foreach ($js_css_source as $vjs) {
$vjs_down = str_replace('&quot;', '', $vjs);
if (strpos($vjs_down, 'data:') !== false) {
//过滤二进制文件
continue;
}
if (strlen($vjs_down) > 255) {
//过滤太长文件
continue;
}
$vjs_down_arr = parse_url($vjs_down);
$vjs_down_host = $vjs_down_arr['host'] ?? '';
$cos = config('filesystems.disks.cos');
$cosCdn = $cos['cdn'];
if ($vjs_down_host && $vjs_down_host == $cosCdn) {
//过滤已经下载的
continue;
}
if (empty($vjs_down_host) && substr($vjs_down, 0, 1) != '/') {
//相对路径
$url_arr = explode('/', $vs['url']);
$url_arr[count($url_arr) - 1] = $vjs_down;
$vjs_down = implode('/', $url_arr);
}
$vjs_result = $this->url_check($vjs_down, $project_id, $domain, $web_url_domain, $home_url);
if (!$vjs_result) {
continue;
}
if ($vjs_result['download']) {
$new_vjs = CosService::uploadRemote($project_id, 'source', $vjs_result['url_complete']);
if ($new_vjs) {
CollectSource::insert([
'project_id' => $project_id,
'origin' => $vjs_result['url'],
'target' => $new_vjs,
'created_at' => date('Y-m-d H:i:s'),
'updated_at' => date('Y-m-d H:i:s'),
]);
$source_html = str_replace($vjs, getImageUrl($new_vjs), $source_html);
}
} else {
$source_html = str_replace($vjs, getImageUrl($vjs_result['url_complete']), $source_html);
}
}
CosService::uploadRemote($project_id, 'source', $new_source, $new_source, $source_html);
}
}
}
} else {
$html = str_replace($vs['url'], getImageUrl($vs['url_complete']), $html);
}
}
return $html;
}
}
... ... @@ -544,21 +544,15 @@ class ProjectUpdate extends Command
$url = $api_url . '?' . http_build_query(['w' => $api_type, 'page' => 1, 'pagesize' => 0]);
$data = curl_c($url);
if (isset($data['code']) && $data['code'] == 200) {
$category = $data['data']['category'] ?? [];
if (empty($category)) {
$route_model = new RouteMap();
$route_page = $route_model->read(['source' => 'page', 'route' => $custom_info['route']], 'id');
if (!$route_page) {
$category = [
[
'id' => 0,
'name' => $custom_info['route'],
'url' => '/' . $custom_info['route'],
'parent' => 0
]
];
}
}
$category = [
[
'id' => 0,
'name' => $custom_info['route'],
'url' => '/' . $custom_info['route'],
'parent' => 0,
'children' => $data['data']['category'] ?? []
]
];
$this->category_custom_insert($project_id, $custom_info['id'], $category, 0);
$count = $data['data']['count'] ?? 0;
... ...
... ... @@ -50,7 +50,7 @@ class UpdateProductCategory extends Command
public function handle(){
//获取所有项目
$projectModel = new Project();
$list = $projectModel->list(['type'=>['in',[1,2,3,4]]],'id',['id']);
$list = $projectModel->list(['id'=>['in',[218]]],'id',['id']);
echo date('Y-m-d H:i:s') . ' start: ' . json_encode($list) . PHP_EOL;
try {
foreach ($list as $v) {
... ... @@ -94,9 +94,8 @@ class UpdateProductCategory extends Command
if(!empty($cate_arr) && is_array($cate_arr)){
foreach ($cate_arr as $v){
$categoryModel = new Category();
$info = $categoryModel->read(['pid'=>$v],['id']);
if($info !== false){
//有下级时,跳过
$info = $categoryModel->read(['id'=>$v],['id']);
if($info === false){
continue;
}else{
//更新关联表
... ...
... ... @@ -10,11 +10,15 @@
namespace App\Console\Commands;
use App\Helper\Arr;
use App\Helper\Translate;
use App\Models\CustomModule\CustomModuleCategory;
use App\Models\CustomModule\CustomModuleContent;
use App\Models\Product\CategoryRelated;
use App\Models\Product\Keyword;
use App\Models\Product\Product;
use App\Models\Project\Project;
use App\Models\RouteMap\RouteMap;
use App\Models\Template\BTemplate;
use App\Services\ProjectServer;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
... ... @@ -51,7 +55,7 @@ class UpdateRoute extends Command
*/
public function handle(){
$projectModel = new Project();
$list = $projectModel->list(['id'=>209]);
$list = $projectModel->list(['id'=>426]);
foreach ($list as $v){
echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
ProjectServer::useProject($v['id']);
... ... @@ -60,11 +64,28 @@ class UpdateRoute extends Command
// $this->getRouteMap();
// $this->getProductCategory();
// $this->delRouteMap();
// $this->setCustomRoute($v['id']);
DB::disconnect('custom_mysql');
}
echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
}
public function setCustomRoute($project_id){
// $customModel = new CustomModuleContent();
// $list = $customModel->list();
// foreach ($list as $v){
// $route = RouteMap::setRoute($v['name'], RouteMap::SOURCE_MODULE, $v['id'], $project_id);
// $customModel->edit(['route'=>$route],['id'=>$v['id']]);
// }
$cateModel = new CustomModuleCategory();
$lists = $cateModel->list();
foreach ($lists as $v1){
$route = RouteMap::setRoute($v1['name'], RouteMap::SOURCE_MODULE_CATE, $v1['id'], $project_id);
$cateModel->edit(['route'=>$route],['id'=>$v1['id']]);
}
}
/**
* @remark :写入
* @name :getProductKeyword
... ... @@ -80,10 +101,15 @@ class UpdateRoute extends Command
if(!empty($v['route'])){
$tag = "-tag";
if (!(substr($v['route'], -strlen($tag)) === $tag)) {
$route = $v['route'].$tag;
// $route = Translate::tran($v['route'], 'en').$tag;
// 如果不是以 '-tag' 结尾,则拼接上 '-tag'
$route = $v['route'].$tag;
$route = RouteMap::setRoute($route, RouteMap::SOURCE_PRODUCT_KEYWORD, $v['id'], $v['project_id']);
$keywordModel->edit(['route'=>$route],['id'=>$v['id']]);
// }else{
// $route = Translate::tran($v['title'], 'en').$tag;
// $route = RouteMap::setRoute($route, RouteMap::SOURCE_PRODUCT_KEYWORD, $v['id'], $v['project_id']);
// $keywordModel->edit(['route'=>$route],['id'=>$v['id']]);
}
}else{
echo date('Y-m-d H:i:s') . 'id :'.$v['id'] . PHP_EOL;
... ...
... ... @@ -34,8 +34,10 @@ class PrivateController extends BaseController
$result = Project::select($field)->leftJoin('gl_project_deploy_optimize as b', 'gl_project.id', '=', 'b.project_id')
->leftJoin('gl_project_online_check as c', 'gl_project.id', '=', 'c.project_id')
->leftJoin('gl_domain_info as d', 'gl_project.id', '=', 'd.project_id')
->where('c.qa_status', '=', OnlineCheck::STATUS_ONLINE_TRUE)
->whereIn('gl_project.type', [Project::TYPE_TWO, Project::TYPE_FOUR])
->where(function ($subQuery) {
$subQuery->orwhere('c.qa_status', OnlineCheck::STATUS_ONLINE_TRUE)->orwhere('gl_project.is_upgrade', Project::IS_UPGRADE_TRUE);
})
->paginate($page_size)
->toArray();
return $this->success($result);
... ...
... ... @@ -9,7 +9,6 @@
namespace App\Http\Controllers\Aside\Com;
use App\Helper\Common;
use App\Http\Controllers\Bside\BaseController;
use App\Models\Com\UpdateLog;
use App\Models\Com\UpdateOldInfo;
... ... @@ -17,7 +16,6 @@ use App\Models\Domain\DomainInfo;
use App\Models\Project\ProjectUpdateTdk;
use App\Services\ProjectServer;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Redis;
/**
* @remark :b端网站更新相关
... ... @@ -105,12 +103,23 @@ class UpdateController extends BaseController
//关闭数据库
DB::disconnect('custom_mysql');
$update = ['collect_status' => 0];
if ($this->param['type'] == 2 && !$domain_info) {
$update['status'] = 0;
if ($domain_info) {
$old_info = UpdateOldInfo::where('project_id', $this->param['project_id'])->first();
if (!$old_info) {
$old_info = new UpdateOldInfo();
$old_info->project_id = $this->param['project_id'];
$old_info->link_type = 0;
$old_info->old_domain_online = $domain_info->domain;
}
$old_info->old_domain_test = $test_domain;
$old_info->save();
}
UpdateLog::where('project_id', $this->param['project_id'])->whereIn('api_type', ['post', 'page', 'news', 'blog'])->update($update);
UpdateLog::where('project_id', $this->param['project_id'])->whereNotIn('api_type', ['category', 'category_news', 'website_info', 'tag'])->update(['collect_status' => 0]);
if ($this->param['type'] == 2 && !$domain_info) {
UpdateLog::where('project_id', $this->param['project_id'])->whereNotIn('api_type', ['category', 'category_news'])->update(['status' => 0]);
}
$this->response('采集任务添加成功');
}
... ...
... ... @@ -65,6 +65,7 @@ class OnlineController extends BaseController
'gl_project.channel AS channel',
'gl_project.type AS type',
'gl_project.created_at AS created_at',
'gl_project.is_upgrade AS is_upgrade',
'gl_project_online_check.id AS online_check_id',
'gl_project_online_check.question AS question',
'gl_project_online_check.optimist_status AS optimist_status',
... ... @@ -145,6 +146,9 @@ class OnlineController extends BaseController
if(isset($this->map['all_status'])){
$query->where('gl_project_online_check.qa_status',$this->map['all_status']);
}
if(isset($this->map['is_upgrade'])){
$query->where('gl_project.is_upgrade',$this->map['is_upgrade']);
}
if(isset($this->map['optimist_status'])){
$query->where('gl_project_online_check.optimist_status',$this->map['optimist_status']);
}
... ...
... ... @@ -133,6 +133,7 @@ class OptimizeController extends BaseController
'gl_project.robots AS robots',
'gl_project.is_translate AS is_translate',
'gl_project.is_translate_tag AS is_translate_tag',
'gl_project.is_upgrade AS is_upgrade',
'gl_project_online_check.id AS online_check_id',
'gl_project_online_check.question AS question',
'gl_project_online_check.go_question AS go_question',
... ... @@ -191,6 +192,9 @@ class OptimizeController extends BaseController
if(isset($this->map['optimize_manager_mid']) && !empty($this->map['optimize_manager_mid'])){
$query = $query->where('gl_project_deploy_optimize.manager_mid','like','%'.$this->map['optimize_manager_mid'].'%');
}
if(isset($this->map['is_upgrade']) && !empty($this->map['is_upgrade'])){
$query = $query->where('gl_project.is_upgrade',$this->map['is_upgrade']);
}
if(isset($this->map['optimize_tech_mid']) && !empty($this->map['optimize_tech_mid'])){
$query = $query->where('gl_project_deploy_optimize.tech_mid','like','%'.$this->map['optimize_tech_mid'].'%');
}
... ...
... ... @@ -70,7 +70,7 @@ class AyrReleaseController extends BaseController
//参数处理
$this->param['mediaUrls'] = $ayrReleaseLogic->image_file_param($data);
//时间处理
$datetime = new \DateTime($this->param['schedule_date']);
$datetime = new \DateTime($this->param['schedule_date'] ?? date('Y-m-d H:i:s'));
$formattedTime = $datetime->format("Y-m-d\TH:i:s\Z");
//统一生成发布
$param = [
... ...
... ... @@ -176,9 +176,8 @@ class BlogController extends BaseController
}
/**
* @name :获取当前博客详情
* @author :liyuhang
* @method
* 获取当前博客详情
* @param BlogLogic $blogLogic
*/
public function info(BlogLogic $blogLogic){
$this->request->validate([
... ... @@ -187,15 +186,17 @@ class BlogController extends BaseController
'id.required' => 'ID不能为空'
]);
$info = $blogLogic->blogInfo();
$template_id = $this->getTemplateId(BTemplate::SOURCE_BLOG,BTemplate::IS_DETAIL);
$info['is_renovation'] = $this->getIsRenovation(BTemplate::SOURCE_BLOG,BTemplate::IS_DETAIL,$template_id, $info['id']);
$this->response('success',Code::SUCCESS,$info);
}
/**
* @remark :保存数据
* @name :save
* @author :lyh
* @method :post
* @time :2023/9/7 13:40
* 保存数据
* @param BlogRequest $request
* @param BlogLogic $blogLogic
*/
public function save(BlogRequest $request,BlogLogic $blogLogic){
$request->validated();
... ... @@ -275,4 +276,37 @@ class BlogController extends BaseController
$logic->setSort();
$this->response('success');
}
/**
* @remark :批量排序
* @name :allSort
* @author :lyh
* @method :post
* @time :2024/1/11 9:46
*/
public function allSort(BlogLogic $logic){
$logic->setAllSort();
$this->response('success');
}
/**
* @remark :批量设置产品分类及状态
* @name :batchSetCategory
* @author :lyh
* @method :post
* @time :2023/8/15 17:51
*/
public function batchSetCategory(BlogLogic $logic){
$this->request->validate([
'id'=>'required',
'category_id'=>'required',
'status'=>'required'
],[
'id.required' => '产品ID不能为空',
'category_id.required' => '分类ID不能为空',
'status.required'=>'状态不能为空'
]);
$logic->batchSetCategory();
$this->response('success');
}
}
... ...
... ... @@ -299,9 +299,4 @@ class LoginController extends BaseController
}
return $data;
}
public function ceshi(){
$ceshi = Translate::tran('Полностью Сварной Пластинчатый Теплообменник', 'en');
return $ceshi;
}
}
... ...
... ... @@ -154,18 +154,19 @@ class NewsController extends BaseController
/**
* @name :添加新闻时获取分类列表
* @author :liyuhang
* @method
* 添加新闻时获取分类列表
* @param NewsLogic $newsLogic
* @throws \App\Exceptions\BsideGlobalException
*/
public function get_category_list(NewsLogic $newsLogic){
$list = $newsLogic->news_get_category_list();
$this->response('success',Code::SUCCESS,$list);
}
/**
* @name :获取详情
* @author :liyuhang
* @method
* 获取新闻详情
* @param NewsLogic $newsLogic
* @throws \App\Exceptions\BsideGlobalException
*/
public function info(NewsLogic $newsLogic){
$this->request->validate([
... ... @@ -174,6 +175,10 @@ class NewsController extends BaseController
'id.required' => 'ID不能为空',
]);
$info = $newsLogic->newsInfo();
$template_id = $this->getTemplateId(BTemplate::SOURCE_NEWS,BTemplate::IS_DETAIL);//获取模版id
$info['is_renovation'] = $this->getIsRenovation(BTemplate::SOURCE_NEWS,BTemplate::IS_DETAIL,$template_id, $info['id']);
$this->response('success',Code::SUCCESS,$info);
}
... ... @@ -262,4 +267,38 @@ class NewsController extends BaseController
$newsLogic->setSort();
$this->response('success');
}
/**
* @remark :批量排序
* @name :allSort
* @author :lyh
* @method :post
* @time :2024/1/11 9:47
*/
public function allSort(NewsLogic $newsLogic){
$newsLogic->setAllSort();
$this->response('success');
}
/**
* @remark :批量设置产品分类及状态
* @name :batchSetCategory
* @author :lyh
* @method :post
* @time :2023/8/15 17:51
*/
public function batchSetCategory(NewsLogic $logic){
$this->request->validate([
'id'=>'required',
'category_id'=>'required',
'status'=>'required'
],[
'id.required' => '产品ID不能为空',
'category_id.required' => '分类ID不能为空',
'status.required'=>'状态不能为空'
]);
$logic->batchSetCategory();
$this->response('success');
}
}
... ...
... ... @@ -238,9 +238,13 @@ class ProductController extends BaseController
}
$v['keyword_id_text'] = trim($v['keyword_id_text'],',');
}
$v['status_text'] = Product::statusMap()[$v['status']] ?? '';
if(!empty($v['status'])){
$v['status_text'] = Product::statusMap()[$v['status']] ?? '';
}else{
$v['status_text'] = '';
}
//获取当前用户选择的模版
$v['video'] = json_decode($v['video']);
$v['video'] = json_decode($v['video'] ?? '');
$template_id = $this->getTemplateId(BTemplate::SOURCE_PRODUCT,BTemplate::IS_DETAIL);
$v['is_renovation'] = $this->getIsRenovation(BTemplate::SOURCE_PRODUCT,BTemplate::IS_DETAIL,$template_id,$v['id']);
$v['url'] = $this->user['domain'].$v['route'];
... ... @@ -421,4 +425,16 @@ class ProductController extends BaseController
$logic->setSort();
$this->response('success');
}
/**
* @remark :批量更新排序
* @name :allSort
* @author :lyh
* @method :post
* @time :2024/1/10 15:34
*/
public function allSort(ProductLogic $logic){
$logic->setAllSort();
$this->response('success');
}
}
... ...
<?php
/**
* @remark :
* @name :TranslateController.php
* @author :lyh
* @method :post
* @time :2024/1/12 9:39
*/
namespace App\Http\Controllers\Bside\Setting;
use App\Enums\Common\Code;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Bside\Setting\TranslateLogic;
use App\Models\WebSetting\WebLanguage;
class TranslateController extends BaseController
{
/**
* @remark :获取翻译校队列表
* @name :lists
* @author :lyh
* @method :post
* @time :2024/1/12 9:39
*/
public function lists(TranslateLogic $logic){
$this->request->validate([
'type'=>'required',
'language_id'=>'required',
'url'=>'required',
],[
'type.required' => 'type不能为空',
'language_id.required' => 'language_id不能为空',
'url.required' => 'url不能为空',
]);
$data = $logic->getTranslateList();
$this->response('success',Code::SUCCESS,$data);
}
/**
* @remark :图片列表
* @name :imageList
* @author :lyh
* @method :post
* @time :2024/1/12 11:18
*/
public function imageList(TranslateLogic $logic){
$this->request->validate([
'type'=>'required',
'language_id'=>'required',
'url'=>'required',
],[
'type.required' => 'type不能为空',
'language_id.required' => 'language_id不能为空',
'url.required' => 'url不能为空',
]);
$data = $logic->getTranslateImageList();
$this->response('success',Code::SUCCESS,$data);
}
/**
* @remark :保存数据
* @name :save
* @author :lyh
* @method :post
* @time :2024/1/12 11:19
*/
public function save(TranslateLogic $logic){
$this->request->validate([
'type'=>'required',
'language_id'=>'required',
'url'=>'required',
'alias'=>'required',
],[
'type.required' => 'type不能为空',
'language_id.required' => 'language_id不能为空',
'url.required' => 'url不能为空',
'alias.required' => 'url不能为空',
]);
$logic->translateSave();
$this->response('success');
}
}
... ...
... ... @@ -38,7 +38,7 @@ class InitHtmlController extends BaseController
'type.required' => '类型不能为空',
]);
$html = $logic->getDetailHtml();
$this->response('success',Code::SUCCESS,['html'=>$html]);
$this->response('success',Code::SUCCESS,$html);
}
/**
... ...
... ... @@ -116,7 +116,7 @@ class CustomModuleLogic extends BaseLogic
public function checkIsName($name,$id = 0){
$param['name'] = $name;
if(!empty($id)){
$param['id'] = ['id'=>['!=',$id],];
$param['id'] = ['id'=>['!=',$id]];
}
$info = (new CustomModule())->read($param);
if($info !== false){
... ...
... ... @@ -60,6 +60,12 @@ class CreateKeywordLogic extends BaseLogic
if($info !== false){
$this->fail('当前名称已存在');
}
}else{
$data['id'] = ['!=',$param['id']];
$info = $this->model->read($data);
if($info !== false){
$this->fail('当前名称已存在');
}
}
return $this->success($data);
}
... ...
... ... @@ -66,43 +66,118 @@ class BTemplateLogic extends BaseLogic
public function getTemplateHtml(){
$is_custom = $this->param['is_custom'] ?? 0;//是否为扩展模块
$is_list = $this->param['is_list'] ?? 0;//是否为列表页
$template_id = $this->getSettingTemplate($this->param['source'],$is_list);//设置的模版id
$templateInfo = $this->model->read([
'template_id'=>$template_id, 'source'=>$this->param['source'],
'project_id'=>$this->user['project_id'], 'source_id'=>$this->param['source_id'],
'is_custom'=>$is_custom, 'is_list'=>$is_list
]);
$template_id = $this->getSettingTemplate($this->param['source'],$is_list,$is_custom);//设置的模版id
$templateInfo = $this->webTemplateInfo($this->param['source'],$this->param['source_id'],$template_id,$is_custom,$is_list);
if($templateInfo === false){
if($this->user['is_customized'] == BTemplate::IS_VISUALIZATION){//处理定制页面初始数据
$html = $this->isCustomizedPage($this->param['source'],$is_list);//获取定制页面的html
if(!empty($html)){
return $this->success(['html'=>$html,'template_id'=>$template_id]);
$html = $this->customizedReturnHtml($this->param['source'],$template_id,$is_custom,$is_list);
if($html !== false){
return $this->success($html);
}
}
//非定制初始中间部分
$mainInfo = $this->getMAinHtml($this->param['source'],$is_custom,$is_list);//获取中间部分代码
}else{
if($templateInfo['type'] == BTemplate::ALL_HTML){//返回整个html代码
$type = $this->getCustomizedType($this->param['source'],$is_list);
$commonInfo = $this->getCustomizedCommonHtml($type);//获取定制头部
$html = $this->handleAllHtml($commonInfo,$templateInfo['html']);
return $this->success(['html'=>$html,'template_id'=>$template_id,'id'=>$templateInfo['id'],'updated_at'=>$templateInfo['updated_at']]);
return $this->getCustomizeAllHtml($templateInfo,$template_id,$is_custom,$is_list);
}
$mainInfo = ['main_html'=>$templateInfo['main_html'], 'main_css'=>$templateInfo['main_css']];
}
$commonInfo = $this->getCommonHtml($this->param['source'],$is_list,$template_id,$is_custom);//获取定制头部
$html = $commonInfo['head_css'].$mainInfo['main_css'].$commonInfo['footer_css'].$commonInfo['other'].
$commonInfo['head_html'].$mainInfo['main_html'].$commonInfo['footer_html'];
$commonInfo = $this->getCommonHtml($this->param['source'],$is_list,$template_id,$is_custom);//获取非定制头部
$html = $commonInfo['head_css'].$mainInfo['main_css'].$commonInfo['footer_css'].$commonInfo['other']. $commonInfo['head_html'].$mainInfo['main_html'].$commonInfo['footer_html'];
$html = $this->getHeadFooter($html);
$result = ['html'=>$html,'template_id'=>$template_id];
if($templateInfo !== false)
{
$result['id'] = $templateInfo['id'];
$result['updated_at'] = $templateInfo['updated_at'];
}
if($templateInfo !== false) {$result['id'] = $templateInfo['id'];$result['updated_at'] = $templateInfo['updated_at'];}
return $this->success($result);
}
/**
* @remark :获取整个html代码
* @name :getCustomizeAllHtml
* @author :lyh
* @method :post
* @time :2024/1/10 14:15
*/
public function getCustomizeAllHtml($templateInfo,$template_id,$is_custom,$is_list){
if($is_custom == BTemplate::IS_CUSTOM){
$commonInfo = $this->getCustomizedCommonHtml($this->param['source'],$is_custom,$is_list);//获取定制头部
$html = $this->handleAllHtml($commonInfo,$templateInfo['html']);
}else{
$type = $this->getCustomizedType($this->param['source'],$is_list);
$commonInfo = $this->getCustomizedCommonHtml($type,$is_custom,$is_list);//获取定制头部
$html = $this->handleAllHtml($commonInfo,$templateInfo['html']);
}
return $this->success(['html'=>$html,'template_id'=>$template_id,'id'=>$templateInfo['id'],'updated_at'=>$templateInfo['updated_at']]);
}
/**
* @remark :获取装修详情
* @name :webTemplateInfo
* @author :lyh
* @method :post
* @time :2024/1/10 13:43
*/
public function webTemplateInfo($source,$source_id,$template_id,$is_custom,$is_list){
$templateInfo = $this->model->read([
'template_id'=>$template_id, 'source'=>$source,
'project_id'=>$this->user['project_id'], 'source_id'=>$source_id,
'is_custom'=>$is_custom, 'is_list'=>$is_list
]);
return $this->success($templateInfo);
}
/**
* @remark :定制页面获取html
* @name :customizedReturnHtml
* @author :lyh
* @method :post
* @time :2024/1/10 13:46
*/
public function customizedReturnHtml($source,$template_id,$is_custom,$is_list){
//TODO::扩展模块定制单独处理
if($is_custom == BTemplate::IS_CUSTOM){
$customModuleModel = new CustomModule();
$info = $customModuleModel->read(['id'=>$source]);
if($info === false){
$this->fail('当前扩展模块不存在或已被删除');
}
//扩展模块定制
if($info['list_customized'] == BTemplate::IS_VISUALIZATION || $info['detail_customized'] == BTemplate::IS_VISUALIZATION){
$html = $this->customModuleCustomizeHtml($source,$is_list,$is_custom);
return $this->success(['html'=>$html,'template_id'=>$template_id]);
}
return false;
}
//TODO::默认模块定制
$html = $this->isCustomizedPage($source,$is_list,$is_custom);//获取定制页面的html
if(!empty($html)){
return $this->success(['html'=>$html,'template_id'=>$template_id]);
}
return false;
}
/**
* @remark :扩展模块定制html
* @name :customModuleInfo
* @author :lyh
* @method :post
* @time :2024/1/10 9:20
*/
public function customModuleCustomizeHtml($source,$is_list,$is_custom){
$bTemplateMainModel = new BTemplateMain();
//TODO::获取初始代码
$customHtmlInfo = $bTemplateMainModel->read(['type'=>$source,'is_list'=>$is_list,'is_custom'=>$is_custom]);
if($customHtmlInfo === false){
$this->fail('定制页面,请先上传代码块');
}
$commonInfo = $this->getCustomizedCommonHtml($source,$is_custom,$is_list);//获取定制头部
if($commonInfo !== false){
$customHtmlInfo['main_html'] = $this->handleAllHtml($commonInfo,$customHtmlInfo['main_html']);
}
return $customHtmlInfo['main_html'];
}
/**
* @remark :获取中间部分的html
* @name :getMAinHtml
* @author :lyh
... ... @@ -163,7 +238,7 @@ class BTemplateLogic extends BaseLogic
* @method :post
* @time :2023/12/13 10:55
*/
public function isCustomizedPage($source,$is_list)
public function isCustomizedPage($source,$is_list,$is_custom)
{
$type = $this->getCustomizedType($source, $is_list);//获取定制界面类型
//查看当前页面是否定制,是否开启可视化
... ... @@ -171,17 +246,17 @@ class BTemplateLogic extends BaseLogic
if (in_array($type, $page_array)) {//是定制界面
//TODO::获取初始代码
$bTemplateMainModel = new BTemplateMain();
$customHtmlInfo = $bTemplateMainModel->read(['type'=>$source,'is_list'=>$is_list]);
$customHtmlInfo = $bTemplateMainModel->read(['type'=>$source,'is_custom'=>$is_custom,'is_list'=>$is_list]);
if($customHtmlInfo === false){
$this->fail('定制页面,请先上传代码块');
}
$commonInfo = $this->getCustomizedCommonHtml($type);//获取定制头部
$commonInfo = $this->getCustomizedCommonHtml($type,$is_custom,$is_list);//获取定制头部
if($commonInfo !== false){
$customHtmlInfo['main_html'] = $this->handleAllHtml($commonInfo,$customHtmlInfo['main_html']);
}
return $customHtmlInfo['main_html'];
}
return [];
return false;
}
/**
... ... @@ -191,11 +266,13 @@ class BTemplateLogic extends BaseLogic
* @method :post
* @time :2023/12/29 13:13
*/
public function getCustomizedCommonHtml($type){
public function getCustomizedCommonHtml($type,$is_custom = 0,$is_list = 0){
$data = [
'template_id' => 0,
'project_id' => $this->user['project_id'],
'type'=>$type
'type'=>$type,
'is_custom'=>$is_custom,
'is_list'=>$is_list
];
$commonTemplateModel = new BTemplateCommon();
return $commonTemplateModel->read($data);
... ... @@ -241,14 +318,25 @@ class BTemplateLogic extends BaseLogic
* @method :post
* @time :2023/12/13 10:48
*/
public function getSettingTemplate($source,$is_list){
public function getSettingTemplate($source,$is_list,$is_custom){
$template_id = 0;
if($this->user['is_customized'] == BTemplate::IS_VISUALIZATION) {//定制项目
$type = $this->getCustomizedType($source, $is_list);//获取定制界面类型
//查看当前页面是否定制,是否开启可视化
$page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面
if (in_array($type, $page_array)) {//是定制界面
return $this->success($template_id);
if($is_custom == BTemplate::IS_CUSTOM){
$customModuleModel = new CustomModule();
$info = $customModuleModel->read(['id'=>$source]);
if($info === false){
$this->fail('当前扩展模块不存在或已被删除');
}
if($info['list_customized'] == BTemplate::IS_VISUALIZATION || $info['detail_customized'] == BTemplate::IS_VISUALIZATION){
return $this->success($template_id);
}
}else{
$type = $this->getCustomizedType($source, $is_list);//获取定制界面类型
//查看当前页面是否定制,是否开启可视化
$page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面
if (in_array($type, $page_array)) {//是定制界面
return $this->success($template_id);
}
}
}
$bSettingModel = new Setting();
... ... @@ -272,7 +360,8 @@ class BTemplateLogic extends BaseLogic
$data = [
'template_id' => $template_id,
'project_id' => $this->user['project_id'],
'type'=>$type
'type'=>$type,
'is_custom'=>0,
];
$commonTemplateModel = new BTemplateCommon();
$commonInfo = $commonTemplateModel->read($data);
... ... @@ -294,16 +383,10 @@ class BTemplateLogic extends BaseLogic
* @time :2023/6/29 11:05
*/
public function templateSave(){
//演示项目不允许修改
//TODO::演示项目不允许修改
$this->showProjectNoEdit($this->param['source']);
$this->param = $this->handleDefaultString($this->param);//设置默认数据
$templateInfo = $this->model->read([
'template_id'=>$this->param['template_id'],
'source'=>$this->param['source'],
'source_id'=>$this->param['source_id'],
'is_custom'=>$this->param['is_custom'],
'is_list'=>$this->param['is_list']
]);
$templateInfo = $this->webTemplateInfo($this->param['source'],$this->param['source_id'],$this->param['template_id'],$this->param['is_custom'],$this->param['is_list']);
if($templateInfo === false){//执行新增
$data = [
'source'=>$this->param['source'], 'source_id'=>$this->param['source_id'],'type'=>BTemplate::PAGE_HTML,
... ... @@ -311,7 +394,7 @@ class BTemplateLogic extends BaseLogic
'section_list_id'=>$this->param['section_list_id'],'is_custom'=>$this->param['is_custom'],
'is_list'=>$this->param['is_list']
];
$data = $this->handleVisualizationParam($this->param['html'],$this->param['source'],$this->param['is_list'],$data);
$data = $this->handleVisualizationParam($this->param['html'],$this->param['source'],$this->param['is_list'],$this->param['is_custom'],$data);
$this->model->add($data);
}else{//执行编辑
$condition = [
... ... @@ -322,7 +405,7 @@ class BTemplateLogic extends BaseLogic
$data = [
'section_list_id'=>$this->param['section_list_id']
];
$data = $this->handleVisualizationParam($this->param['html'],$this->param['source'],$this->param['is_list'],$data);
$data = $this->handleVisualizationParam($this->param['html'],$this->param['source'],$this->param['is_list'],$this->param['is_custom'],$data);
$this->model->edit($data,$condition);
}
//更新头部信息
... ... @@ -355,7 +438,7 @@ class BTemplateLogic extends BaseLogic
* @method :post
* @time :2023/12/15 10:59
*/
public function handleVisualizationParam($html,$source, $is_list,$data){
public function handleVisualizationParam($html,$source, $is_list,$is_custom,$data){
if($this->user['is_customized'] == BTemplate::IS_VISUALIZATION){//定制项目
$type = $this->getCustomizedType($source, $is_list);//获取定制界面类型
//查看当前页面是否定制,是否开启可视化
... ... @@ -364,6 +447,19 @@ class BTemplateLogic extends BaseLogic
$data['html'] = $html;
$data['type'] = BTemplate::ALL_HTML;
}else{
//TODO::扩展模块定制单独处理
if($is_custom == BTemplate::IS_CUSTOM){
$customModuleModel = new CustomModule();
$info = $customModuleModel->read(['id'=>$source]);
if($info === false){
$this->fail('当前扩展模块不存在或已被删除');
}
//todo::扩展模块(列表页/详情页)定制
if($info['list_customized'] == BTemplate::IS_VISUALIZATION || $info['detail_customized'] == BTemplate::IS_VISUALIZATION) {
$data['html'] = $html;
$data['type'] = BTemplate::ALL_HTML;
}
}
$mainInfo = $this->handleTemplateHtml($html);
$data['main_html'] = $mainInfo['main_html'];
$data['main_css'] = $mainInfo['main_css'];
... ... @@ -376,7 +472,6 @@ class BTemplateLogic extends BaseLogic
return $data;
}
/**
* @remark :保存公共头部底部
* @name :saveCommonHtml
... ... @@ -385,12 +480,20 @@ class BTemplateLogic extends BaseLogic
* @time :2023/12/13 17:05
*/
public function saveCommonHtml($html,$source,$is_list,$template_id,$is_custom){
//TODO::定制扩展模块单独处理
if($is_custom == BTemplate::IS_CUSTOM){
$code = $this->saveCustomModuleCommonHtml($html,$source,$is_custom,$is_list,$template_id);
if($code === false){
return $this->success();
}
}
//其他情况
$type = $this->getType($source,$is_list,$is_custom);//获取头部类型1-9(首页到自定义页面)
if($template_id == 0){//定制页面默认为独立头部
$type = $this->getCustomizedType($source,$is_list);//定制默认独立头部
}
$templateCommonModel = new BTemplateCommon();
$commonInfo = $templateCommonModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>$type]);//查看当前头部是否存在
$commonInfo = $templateCommonModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>$type,'is_custom'=>0]);//查看当前头部是否存在
$handleInfo = $this->handleCommonParam($html);
if($commonInfo === false){
$data = [
... ... @@ -411,6 +514,45 @@ class BTemplateLogic extends BaseLogic
}
/**
* @remark :扩展模块定制保存头部处理
* @name :saveCustomModuleCommonHtml
* @author :lyh
* @method :post
* @time :2024/1/10 11:33
*/
public function saveCustomModuleCommonHtml($html,$source,$is_custom,$is_list,$template_id){
$customModuleModel = new CustomModule();
$info = $customModuleModel->read(['id'=>$source]);
if($info === false){
$this->fail('当前扩展模块不存在或已被删除');
}
//todo::扩展模块(列表页/详情页)定制
if($info['list_customized'] == BTemplate::IS_VISUALIZATION || $info['detail_customized'] == BTemplate::IS_VISUALIZATION) {
$data = ['type'=>$source,'is_custom'=>$is_custom,'is_list'=>$is_list,'template_id'=>$template_id];
$templateCommonModel = new BTemplateCommon();
$commonInfo = $templateCommonModel->read($data);//查看当前头部是否存在
$handleInfo = $this->handleCommonParam($html);
if($commonInfo === false){
$data = [
'head_html'=>$handleInfo['head_html'], 'head_css'=>$handleInfo['head_css'],'other'=>$handleInfo['other'],
'footer_html'=>$handleInfo['footer_html'], 'footer_css'=>$handleInfo['footer_css'],
'type'=>$source,'template_id'=>$template_id, 'project_id'=>$this->user['project_id'],
'is_custom'=>$is_custom,'is_list'=>$is_list,
];
$templateCommonModel->add($data);
}else{
$data = [
'head_html'=>$handleInfo['head_html'], 'head_css'=>$handleInfo['head_css'],'other'=>$handleInfo['other'],
'footer_html'=>$handleInfo['footer_html'], 'footer_css'=>$handleInfo['footer_css'],
];
$templateCommonModel->edit($data,['id'=>$commonInfo['id']]);
}
return false;
}
return true;
}
/**
* @remark :演示项目不允许修改首页
* @name :showProject
* @author :lyh
... ... @@ -457,7 +599,7 @@ class BTemplateLogic extends BaseLogic
return $this->success($param);
}
/**
* @remark :保存时获取获取设置的类型
* @remark :(非定制)保存时获取获取设置的类型
* @name :getType
* @author :lyh
* @method :post
... ...
... ... @@ -38,6 +38,7 @@ class InitHtmlLogic extends BaseLogic
$template_id = $this->getTemplateId();
$is_custom = $this->param['is_custom'] ?? 0;//TODO::1:代表扩展模块
$is_list = $this->param['is_list'] ?? 0;//TODO::1:代表分类列表模块
$data = array();
//获取设置的默认中间部分
$bTemplateMainModel = new BTemplateMain();
$mainInfo = $bTemplateMainModel->read(['project_id'=>$this->user['project_id'],'type'=>$this->param['type'],'is_list'=>$is_list,'is_custom'=>$is_custom]);
... ... @@ -47,11 +48,14 @@ class InitHtmlLogic extends BaseLogic
}else{
$main_html = $mainInfo['main_html'];
$main_style = $mainInfo['main_css'];
$data['id'] = $mainInfo['id'];
$data['updated_at'] = $mainInfo['updated_at'];
}
$commonInfo = $this->getCommonHtml($this->param['type'],$is_list,$template_id,$is_custom); //获取头部
$html = $commonInfo['head_css'].$main_style.$commonInfo['footer_css'].$commonInfo['other'].$commonInfo['head_html'].$main_html.$commonInfo['footer_html'];
$html = $this->getHeadFooter($html);//组装数据
return $this->success($html);
$data['html'] = $html;
return $this->success($data);
}
/**
... ... @@ -259,14 +263,20 @@ class InitHtmlLogic extends BaseLogic
*/
public function getCustomizedHtml(){
$is_list = $this->param['is_list'] ?? 0;
$is_custom = $this->param['is_custom'] ?? 0;
$bTemplateMainModel = new BTemplateMain();
$info = $bTemplateMainModel->read(['type'=>$this->param['type'],'is_list'=>$is_list]);
$info = $bTemplateMainModel->read(['type'=>$this->param['type'],'is_custom'=>$is_custom,'is_list'=>$is_list]);
if($info === false){
$html = '';
}else{
$type = $this->getCustomizedType($this->param['type'],$is_list);
//扩展模块获取头部
if($is_custom == BTemplate::IS_CUSTOM){
$type = $this->param['type'];
}else{
$type = $this->getCustomizedType($this->param['type'],$is_list);
}
$commonTemplateModel = new BTemplateCommon();
$commonInfo = $commonTemplateModel->read(['template_id' => 0,'type'=>$type]);
$commonInfo = $commonTemplateModel->read(['template_id' => 0,'type'=>$type,'is_custom'=>$is_custom,'is_list'=>$is_list]);
if($commonInfo !== false){
$info['main_html'] = $this->handleAllHtml($commonInfo,$info['main_html']);
}
... ... @@ -303,21 +313,23 @@ class InitHtmlLogic extends BaseLogic
public function saveCustomizedHtml(){
try {
$is_list = $this->param['is_list'] ?? 0;
$is_custom = $this->param['is_custom'] ?? 0;
$bTemplateMainModel = new BTemplateMain();
$mainInfo = $bTemplateMainModel->read(['type'=>$this->param['type'],'is_list'=>$is_list]);
$mainInfo = $bTemplateMainModel->read(['type'=>$this->param['type'],'is_custom'=>$is_custom,'is_list'=>$is_list]);
if($mainInfo === false){
$mainData = [
'project_id'=>$this->user['project_id'],
'type'=>$this->param['type'],
'is_list'=>$is_list,
'main_html'=>$this->param['html']
'main_html'=>$this->param['html'],
'is_custom'=>$is_custom
];
$bTemplateMainModel->add($mainData);
}else{
$bTemplateMainModel->edit(['main_html'=>$this->param['html']],['id'=>$mainInfo['id']]);
}
//更新头部底部
$this->saveCustomizeCommon($this->param['html'],$this->param['type'],$is_list);
$this->saveCustomizeCommon($this->param['html'],$this->param['type'],$is_list,$is_custom);
}catch (\Exception $exception){
$this->fail('保存失败,请联系开发人员');
}
... ... @@ -331,16 +343,21 @@ class InitHtmlLogic extends BaseLogic
* @method :post
* @time :2024/1/6 10:29
*/
public function saveCustomizeCommon($html,$source,$is_list){
$type = $this->getCustomizedType($source,$is_list);
public function saveCustomizeCommon($html,$source,$is_list,$is_custom){
if($is_custom == BTemplate::IS_CUSTOM){
$type = $source;
}else{
$type = $this->getCustomizedType($source,$is_list);
}
$templateCommonModel = new BTemplateCommon();
$commonInfo = $templateCommonModel->read(['template_id'=>0,'type'=>$type]);//查看当前头部是否存在
$commonInfo = $templateCommonModel->read(['template_id'=>0,'type'=>$type,'is_custom'=>$is_custom,'is_list'=>$is_list]);//查看当前头部是否存在
$handleInfo = $this->handleCommonParam($html);
if($commonInfo === false){
$data = [
'head_html'=>$handleInfo['head_html'], 'head_css'=>$handleInfo['head_css'],
'footer_html'=>$handleInfo['footer_html'], 'footer_css'=>$handleInfo['footer_css'],
'type'=>$type,'template_id'=>0, 'project_id'=>$this->user['project_id'],
'is_custom'=>$is_custom,'is_list'=>$is_list
];
$templateCommonModel->add($data);
}else{
... ...
... ... @@ -234,6 +234,20 @@ class BlogLogic extends BaseLogic
}
/**
* @remark :
* @name :setAllSort
* @author :lyh
* @method :post
* @time :2024/1/10 15:40
*/
public function setAllSort(){
foreach ($this->param['data'] as $k => $v){
$this->model->edit(['sort'=>$v['sort']],['id'=>$v['id']]);
}
return $this->success();
}
/**
* 博客导入
* @param $project_id
* @param $user_id
... ... @@ -348,4 +362,32 @@ class BlogLogic extends BaseLogic
return false;
}
/**
* @remark :批量设置产品分类及状态
* @name :batchSetCategory
* @author :lyh
* @method :post
* @time :2023/8/15 17:53
*/
public function batchSetCategory(){
if(isset($this->param['category_id']) && !empty($this->param['category_id'])) {
DB::connection('custom_mysql')->beginTransaction();
$this->param['category_id'] = ','.implode(',',$this->param['category_id']).',';
try {
//批量
$param = [
'category_id'=>$this->param['category_id'],
'status'=>$this->param['status']
];
$this->model->edit($param,['id'=>['in',$this->param['id']]]);
DB::connection('custom_mysql')->commit();
//对应添加关联表
}catch (\Exception $e){
DB::connection('custom_mysql')->rollBack();
$this->fail('系统错误,请联系管理员');
}
}
return $this->success();
}
}
... ...
... ... @@ -250,6 +250,21 @@ class NewsLogic extends BaseLogic
}
/**
* @remark :
* @name :setAllSort
* @author :lyh
* @method :post
* @time :2024/1/10 15:40
*/
public function setAllSort(){
foreach ($this->param['data'] as $k => $v){
$this->model->edit(['sort'=>$v['sort']],['id'=>$v['id']]);
}
return $this->success();
}
/**
* @remark :删除路由
* @name :delRoute
* @author :lyh
... ... @@ -381,4 +396,32 @@ class NewsLogic extends BaseLogic
return false;
}
/**
* @remark :批量设置产品分类及状态
* @name :batchSetCategory
* @author :lyh
* @method :post
* @time :2023/8/15 17:53
*/
public function batchSetCategory(){
if(isset($this->param['category_id']) && !empty($this->param['category_id'])) {
DB::connection('custom_mysql')->beginTransaction();
$this->param['category_id'] = ','.implode(',',$this->param['category_id']).',';
try {
//批量
$param = [
'category_id'=>$this->param['category_id'],
'status'=>$this->param['status']
];
$this->model->edit($param,['id'=>['in',$this->param['id']]]);
DB::connection('custom_mysql')->commit();
//对应添加关联表
}catch (\Exception $e){
DB::connection('custom_mysql')->rollBack();
$this->fail('系统错误,请联系管理员');
}
}
return $this->success();
}
}
... ...
... ... @@ -599,6 +599,20 @@ class ProductLogic extends BaseLogic
}
/**
* @remark :
* @name :setAllSort
* @author :lyh
* @method :post
* @time :2024/1/10 15:40
*/
public function setAllSort(){
foreach ($this->param['data'] as $k => $v){
$this->model->edit(['sort'=>$v['sort']],['id'=>$v['id']]);
}
return $this->success();
}
/**
* 产品导入
* @param $project_id
* @param $user_id
... ... @@ -722,13 +736,11 @@ class ProductLogic extends BaseLogic
if($data[10]??''){
$seo_description = substr(strip_tags($data[10]),0,200);
}
$seo_mate = [
'title' => $seo_title,
'keyword' => $seo_keywords,
'description' => $seo_description
];
//处理参数
$attrs = [];
if($data[4]??''){
... ... @@ -746,10 +758,8 @@ class ProductLogic extends BaseLogic
}
}
}
//处理描述切换栏
$describe = [];
for ($i=11;$i<=20;$i+=2){
if(($data[$i]??'') && ($data[$i+1]??'')){
preg_match_all('/<img\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $data[$i+1], $result_desc);
... ... @@ -759,7 +769,6 @@ class ProductLogic extends BaseLogic
$new_vdesc_img && $data[$i+1] = str_replace($vdesc_img,$new_vdesc_img,$data[$i+1]);
}
}
preg_match_all('/<source\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $data[$i+1], $result_desc_video);
if($result_desc_video[2]??[]){
foreach ($result_desc_video[2] as $vdesc_video){
... ... @@ -776,7 +785,6 @@ class ProductLogic extends BaseLogic
break;
}
}
$id = $this->model->addReturnId(
[
'project_id' => $project_id,
... ... @@ -794,7 +802,6 @@ class ProductLogic extends BaseLogic
'status' => Product::STATUS_ON
]
);
//更新路由
if($route){
$route_map = RouteMap::where('project_id', $project_id)->where('source', RouteMap::SOURCE_PRODUCT)->where('source_id', $id)->first();
... ... @@ -810,17 +817,13 @@ class ProductLogic extends BaseLogic
}else{
$route = RouteMap::setRoute($data[0], RouteMap::SOURCE_PRODUCT, $id, $project_id);
}
$this->edit(['route' => $route], ['id' => $id]);
//关联分类
if($category_arr){
CategoryRelated::saveRelated($id, $category_arr);
}
return true;
}
return false;
}
}
... ...
... ... @@ -82,19 +82,19 @@ class RankDataLogic extends BaseLogic
$lang_data = $quanqiusou_api->getLangRankData($api_no);
$lang_data = Arr::setValueToKey($lang_data, 'language');
$data['langs'] = [];
foreach($project['deploy_optimize']['minor_languages']??[] as $lang){
$remain_day = $lang_data[$lang['tl']]['dabiao_day'] ?? 0;
$data['langs'][$lang['tl'] ?? ''] = [
'lang_text' => Translate::getTls($lang['tl'] ?? ''),
'keyword_num' => $lang['keywords'] ?? 0,
'reach_day' => $lang_data[$lang['tl']]['dabiao_day'] ?? 0,
'home_cnt' => $lang_data[$lang['tl']]['home_cnt'] ?? 0,
'remain_day' => ($lang['type']??0) == 1 ? $data['project']['remain_day'] : $lang['service_day'] - $remain_day,
'type' => $lang['type'] ?? 0, //1 项目关键词 项目天数 2 保证首页关键词 项目达标天数
];
if(isset($project['deploy_optimize']['minor_languages']) && !empty($project['deploy_optimize']['minor_languages']) && is_array($project['deploy_optimize']['minor_languages'])){
foreach($project['deploy_optimize']['minor_languages']??[] as $lang){
$remain_day = $lang_data[$lang['tl']]['dabiao_day'] ?? 0;
$data['langs'][$lang['tl'] ?? ''] = [
'lang_text' => Translate::getTls($lang['tl'] ?? ''),
'keyword_num' => $lang['keywords'] ?? 0,
'reach_day' => $lang_data[$lang['tl']]['dabiao_day'] ?? 0,
'home_cnt' => $lang_data[$lang['tl']]['home_cnt'] ?? 0,
'remain_day' => ($lang['type']??0) == 1 ? $data['project']['remain_day'] : $lang['service_day'] - $remain_day,
'type' => $lang['type'] ?? 0, //1 项目关键词 项目天数 2 保证首页关键词 项目达标天数
];
}
}
//测速
$data['speed'] = $speed['data'] ?? [];
... ...
<?php
/**
* @remark :
* @name :TranslateLogic.php
* @author :lyh
* @method :post
* @time :2024/1/12 9:42
*/
namespace App\Http\Logic\Bside\Setting;
use App\Enums\Common\Code;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\WebSetting\Proofreading;
use App\Models\WebSetting\Translate as TranslateModel;
use App\Models\WebSetting\WebLanguage;
use App\Helper\Translate;
use Illuminate\Support\Facades\DB;
class TranslateLogic extends BaseLogic
{
public function __construct()
{
parent::__construct();
$this->model = new TranslateModel();
$this->param = $this->requestAll;
}
/**
* @remark :
* @name :getTranslateList
* @author :lyh
* @method :post
* @time :2024/1/12 9:43
*/
public function getTranslateList(){
$languageInfo = $this->getLanguage($this->param['language_id']);
$info = $this->model->read(['url'=>$this->param['url'],'language_id'=>$this->param['language_id'],'type'=>$this->param['type']]);
//获取当前URl的所有文本内容
$new_key = $this->getUrlRead($this->param['url']);
if($info === false){
$data = [];
$translate_list = Translate::tran($new_key, $languageInfo['short']);
foreach ($new_key as $k=>$v){
$data[] = [
trim($v)=>$translate_list[$k],
];
}
return $this->response('success',Code::SUCCESS,$data);
}
$old_key = [];//key值组成数据
$data = json_decode($info['data'],true);
foreach ($data as $k => $v){
$old_key[] = $k;
}
$arr2 = array_values(array_diff($new_key, $old_key));
if(!empty($arr2)){
$translate_list = Translate::tran($arr2, $languageInfo['short']);
foreach ($arr2 as $k1=>$v1){
$data[] = [
trim($v1)=>$translate_list[$k1]
];
}
}
$this->response('success',Code::SUCCESS,$data);
}
/**
* @remark :获取图片列表
* @name :imageList
* @author :lyh
* @method :post
* @time :2023/11/23 17:29
*/
public function getTranslateImageList(){
$info = $this->model->read(['url'=>$this->param['url'],'language_id'=>$this->param['language_id'],'type'=>$this->param['type']]);
$data = [];
if($info === false){
$new_list = $this->getUrlImageRead($this->param['url']);
foreach ($new_list as $v){
$data[] = [
$v=>$v,
];
}
return $this->response('success',Code::SUCCESS,$data);
}
$new_list = $this->getUrlImageRead($this->param['url']);
$old_list = [];
$data = json_decode($info['data'],true);
foreach ($data as $k=>$v){
$old_list[] = $v;
$data[] = [
$k=>$v,
];
}
$arr2 = array_values(array_diff($new_list, $old_list));
if(!empty($arr2)){
foreach ($arr2 as $v1){
$data[] = [
$v1=>$v1
];
}
}
$this->response('success',Code::SUCCESS,$data);
}
/**
* @remark :获取语种信息
* @name :getLanguage
* @author :lyh
* @method :post
* @time :2024/1/12 9:45
*/
public function getLanguage($language_id){
//获取语种信息
$languageModel = new WebLanguage();
$languageInfo = $languageModel->read(['id'=>$language_id]);
if($languageInfo === false){
$this->fail('请选择语种');
}
return $this->success($languageInfo);
}
/**
* @remark :获取Url内容
* @name :getUrlRead
* @author :lyh
* @method :post
* @time :2023/11/22 10:02
*/
public function getUrlRead($url){
$contextOptions = [
'ssl' => [
'verify_peer' => false,
'verify_peer_name' => false,
],
];
$context = stream_context_create($contextOptions);
$sourceCode = file_get_contents($url, false, $context);
$pattern = '/<style\b[^>]*>(.*?)<\/style>/s'; // 定义匹配`<style>`标签及其内容的正则表达式
$strippedContent = preg_replace($pattern, '', $sourceCode); // 删除`<style>`标签及其内容
$pattern = '/<script\b[^>]*>(.*?)<\/script>/s'; // 定义匹配`<script>`标签及其内容的正则表达式
$strippedContent = preg_replace($pattern, '', $strippedContent); // 删除`<script>`标签及其内容
$pattern = '/<link\b[^>]*>/'; // 定义匹配 `<link>` 标签的正则表达式
$strippedContent = preg_replace($pattern, '', $strippedContent); // 删除 `<link>` 标签
$pattern = '/>([^<]+)</'; // 定义匹配中间内容不是标签的正则表达式
$matches = array();
preg_match_all($pattern, $strippedContent, $matches);
$textContentArray = array_filter($matches[1], function($item) {
return !empty(trim($item));
});
$data = [];
foreach ($textContentArray as $v){
$content = trim($v);
$trimmedString = preg_replace('/\s+/', ' ', $content);
$data[] = $trimmedString;
}
$data = array_values($data);
return $data;
}
/**
* @remark :获取Url内容
* @name :getUrlRead
* @author :lyh
* @method :post
* @time :2023/11/22 10:02
*/
public function getUrlImageRead($url){
$contextOptions = [
'ssl' => [
'verify_peer' => false,
'verify_peer_name' => false,
],
];
$pattern = '/<img.*?src="(.*?)".*?>/i';
$matches = array();
$context = stream_context_create($contextOptions);
$sourceCode = file_get_contents($url, false, $context);
preg_match_all($pattern, $sourceCode, $matches);
$textContentArray = $matches[1];
$data = [];
foreach ($textContentArray as $v){
if(!empty($v)){
$data[] = $v;
}
}
$uniqueArray = array_unique($data);
$data = array_values($uniqueArray);
return $data;
}
/**
* @name :(新增/更新多语言)save
* @author :lyh
* @method :post
* @time :2023/6/12 10:52
*/
public function translateSave(){
try {
$info = $this->model->read(['language_id'=>$this->param['language_id'],'url'=>$this->param['url'],'type'=>$this->param['type']]);
if($info === false){
$param = [
'type'=>1,
'project_id'=>$this->user['project_id'],
'url'=>$this->param['url'],
'language_id'=>$this->param['language_id'],
'alias'=>$this->param['alias'],
];
$param['data'] = json_encode($this->param['data'],true);
$this->model->add($param);
}else{
$data = json_encode($this->param['data'],true);
$this->model->edit(['data'=>$data],['language_id'=>$this->param['language_id'],'url'=>$this->param['url'],'type'=>$this->param['type']]);
}
}catch (\Exception $e){
$this->fail('系统错误请联系管理员');
}
$this->response('success');
}
}
... ...
... ... @@ -27,6 +27,7 @@ class AyrReleaseRequest extends FormRequest
'content'=>'required',
'share_id'=>'required',
'platforms'=>'required|array',
'schedule_date'=>'required'
];
}
... ...
... ... @@ -2,9 +2,10 @@
namespace App\Models\Com;
use App\Models\Base;
use Illuminate\Database\Eloquent\Model;
class UpdateOldInfo extends Model
class UpdateOldInfo extends Base
{
//设置关联表名
protected $table = 'gl_update_old_info';
... ...
... ... @@ -30,6 +30,10 @@ class Project extends Base
const TYPE_SEVEN = 7;//错误单
const MYSQL_ID = 2;//默认数据库id
const IS_UPGRADE_FALSE = 0;
const IS_UPGRADE_TRUE = 1;
/**
* 星级客户
* @return string[]
... ... @@ -81,6 +85,7 @@ class Project extends Base
9 => '星链网站(2年版)',
11 => '俄语标准版',
12 => '俄语商务版',
13 => '体验版'
];
}
... ...
<?php
/**
* @remark :
* @name :Translate.php
* @author :lyh
* @method :post
* @time :2024/1/12 9:38
*/
namespace App\Models\WebSetting;
use App\Models\Base;
class Translate extends Base
{
protected $table = 'gl_translate';
//连接数据库
protected $connection = 'custom_mysql';
}
... ...
... ... @@ -102,11 +102,11 @@ class ProjectServer
* @time :2023/9/19 14:45
*/
public static function saveInitParam($project_id){
// self::initGroup($project_id);
self::initGroup($project_id);
//初始化单页
// self::init404Page($project_id);
self::init404Page($project_id);
//初始化模块数据
// self::initModule($project_id);
self::initModule($project_id);
DB::disconnect('custom_mysql');
return true;
}
... ...
... ... @@ -74,6 +74,8 @@ Route::middleware(['bloginauth'])->group(function () {
Route::any('/del', [\App\Http\Controllers\Bside\News\NewsController::class, 'del'])->name('news_del');
Route::any('/status', [\App\Http\Controllers\Bside\News\NewsController::class, 'status'])->name('news_status');
Route::any('/sort', [\App\Http\Controllers\Bside\News\NewsController::class, 'sort'])->name('news_sort');
Route::any('/allSort', [\App\Http\Controllers\Bside\News\NewsController::class, 'allSort'])->name('news_allSort');
Route::any('/batchSetCategory', [\App\Http\Controllers\Bside\News\NewsController::class, 'batchSetCategory'])->name('news_batchSetCategory');
Route::any('/statusNum', [\App\Http\Controllers\Bside\News\NewsController::class, 'getStatusNumber'])->name('news_statusNum');
});
... ... @@ -89,6 +91,8 @@ Route::middleware(['bloginauth'])->group(function () {
Route::any('/del', [\App\Http\Controllers\Bside\Blog\BlogController::class, 'del'])->name('blog_del');
Route::any('/status', [\App\Http\Controllers\Bside\Blog\BlogController::class, 'status'])->name('blog_status');
Route::any('/sort', [\App\Http\Controllers\Bside\Blog\BlogController::class, 'sort'])->name('blog_sort');
Route::any('/allSort', [\App\Http\Controllers\Bside\Blog\BlogController::class, 'allSort'])->name('blog_allSort');
Route::any('/batchSetCategory', [\App\Http\Controllers\Bside\Blog\BlogController::class, 'batchSetCategory'])->name('blog_batchSetCategory');
Route::any('/statusNum', [\App\Http\Controllers\Bside\Blog\BlogController::class, 'getStatusNumber'])->name('blog_statusNum');
//分类
Route::any('/category/', [\App\Http\Controllers\Bside\Blog\BlogCategoryController::class, 'lists'])->name('blog_category_lists');
... ... @@ -172,7 +176,12 @@ Route::middleware(['bloginauth'])->group(function () {
Route::any('/save', [\App\Http\Controllers\Bside\Setting\ProofreadingController::class, 'save'])->name('web_proofreading_save');
Route::any('/saveImage', [\App\Http\Controllers\Bside\Setting\ProofreadingController::class, 'saveImage'])->name('web_proofreading_saveImage');
});
//新版翻译校队
Route::prefix('translate_check')->group(function () {//languageList
Route::any('/', [\App\Http\Controllers\Bside\Setting\TranslateController::class, 'lists'])->name('translate_check_lists');
Route::any('/imageList', [\App\Http\Controllers\Bside\Setting\TranslateController::class, 'imageList'])->name('translate_checkg_imageList');
Route::any('/save', [\App\Http\Controllers\Bside\Setting\TranslateController::class, 'save'])->name('translate_check_save');
});
//seo设置
Route::prefix('seo')->group(function () {
Route::any('/info', [\App\Http\Controllers\Bside\Setting\WebSettingSeoController::class, 'info'])->name('web_seo_info');
... ... @@ -204,6 +213,7 @@ Route::middleware(['bloginauth'])->group(function () {
Route::post('/save', [\App\Http\Controllers\Bside\Product\ProductController::class, 'save'])->name('product_save');
Route::post('/editList', [\App\Http\Controllers\Bside\Product\ProductController::class, 'editList'])->name('product_editList');
Route::post('/sort', [\App\Http\Controllers\Bside\Product\ProductController::class, 'sort'])->name('product_sort');
Route::post('/allSort', [\App\Http\Controllers\Bside\Product\ProductController::class, 'allSort'])->name('product_allSort');
Route::any('/delete', [\App\Http\Controllers\Bside\Product\ProductController::class, 'delete'])->name('product_delete');
Route::any('/statusNum', [\App\Http\Controllers\Bside\Product\ProductController::class, 'getStatusNumber'])->name('product_statusNum');
Route::any('/copyProduct', [\App\Http\Controllers\Bside\Product\ProductController::class, 'copyProduct'])->name('product_copyProduct');
... ...