作者 赵彬吉
... ... @@ -23,7 +23,7 @@ class UpgradeProjectCount extends Command
*
* @var string
*/
protected $signature = 'upgrade_count';
protected $signature = 'upgrade_count {project_id}';
/**
* The console command description.
... ... @@ -33,7 +33,7 @@ class UpgradeProjectCount extends Command
protected $description = '升级项目统计';
public function handle(){
$project_id = 769;
$project_id = $this->argument('project_id');
ProjectServer::useProject($project_id);
$this->count($project_id);
DB::disconnect('custom_mysql');
... ... @@ -100,7 +100,8 @@ class UpgradeProjectCount extends Command
* @time :2023/6/14 15:40
*/
public function pv_num($day){
$pv = DB::connection('custom_mysql')->table('gl_customer_visit_item')->whereDate('updated_date', $day)->count();
//$pv = DB::connection('custom_mysql')->table('gl_customer_visit_item')->whereDate('updated_date', $day)->count();
$pv = DB::connection('custom_mysql')->table('gl_customer_visit')->whereDate('updated_date', $day)->sum('depth');
return $pv;
}
... ...
... ... @@ -51,7 +51,7 @@ class DomainInfo extends Command
}
$ssl = $this->updateDomainSsl($v['domain']);
$time = $this->updateDomain($v['domain']);
if(!empty($time['start']) && !!empty($time['end'])){
if(!empty($time['start']) && !empty($time['end'])){
$data = [
'certificate_start_time'=>$ssl['from'],
'certificate_end_time'=>$ssl['to'],
... ...
... ... @@ -26,7 +26,7 @@ class UpgradeProjectCount extends Command
*
* @var string
*/
protected $signature = 'upgrade_month_count';
protected $signature = 'upgrade_month_count {project_id}';
/**
* The console command description.
... ... @@ -36,13 +36,12 @@ class UpgradeProjectCount extends Command
protected $description = '升级项目统计';
public function handle(){
$project_id = 769;
$project_id = $this->argument('project_id');
$oldModel = new UpdateOldInfo();
$info = $oldModel->read(['project_id'=>$project_id]);
$url = $info['old_domain_online'];
ProjectServer::useProject($project_id);
$this->count($project_id,$url);
DB::disconnect('custom_mysql');
}
... ...
... ... @@ -16,6 +16,8 @@ use App\Models\Manage\BelongingGroup;
use App\Models\Manage\Dept;
use App\Models\Manage\EntryPosition;
use App\Models\Manage\ManageHr;
use App\Models\Project\Project;
use App\Models\WebSetting\WebSettingService;
use App\Services\ProjectServer;
use App\Services\SyncService;
use GuzzleHttp\Client;
... ... @@ -76,187 +78,200 @@ class Demo extends Command
/**
* @return bool
*/
public function handle()
{
return $this->domain();
$result = app(SyncService::class)->projectAcceptAddress(1);
dd($result);
$data = [
'key' => 'productkey_keyword',
'keywords' => 'apple watch'
];
$result = Common::send_openai_msg('v2/openai_chat', $data);
dd();
$string = 'demo.globalso.site/';
$domain_array = parse_url($string);
$domain = $domain_array['host'] ?? $domain_array['path'];
dd($domain);
$data = [];
dd(isset($data['a']['b']));
$url = 'https://demo.globalso.site/';
$action = 'api/updateHtmlNotify/';
$data = [
'project_id' => 1,
'type' => 1,
'route' => 1
];;
$method = 'GET';
$result = $this->curlRequest($url . $action, $data, $method);
dd($result);
$context = stream_context_create([
'ssl' => [
'capture_peer_cert' => true,
'capture_peer_cert_chain' => false,
],
]);
$stream = stream_socket_client('ssl://oa.quanqiusou.cn:443', $errno, $errstr, 30, STREAM_CLIENT_CONNECT, $context);
if(!$stream) {
die("Failed to connect: $errno - $errstr");
}
$remote_cert = stream_context_get_params($stream)['options']['ssl']['peer_certificate'];
if(!$remote_cert) {
die("Failed to retrieve certificate");
}
$valid_from = date('Y-m-d H:i:s', openssl_x509_parse($remote_cert)['validFrom_time_t']);
$valid_to = date('Y-m-d H:i:s', openssl_x509_parse($remote_cert)['validTo_time_t']);
fclose($stream);
echo "Certificate Valid From: $valid_from<br>";
echo "Certificate Valid To: $valid_to<br>";
dd('end');
$dept_array = [
'品牌部',
'综合部',
'渠道部',
'广告推广部',
'AICC运营部',
'黑格运营部',
'直营运营部',
'直营销售部',
'深圳跨境部',
'外贸部',
'研发部',
'技术部',
'售后部',
];
foreach ($dept_array as $v) {
$dept = Dept::where(['title' => $v])->first();
if (FALSE == empty($dept))
continue;
$dept = new Dept();
$dept->title = $v;
$dept->save();
}
// dd('dept end');
$dept_map = Dept::pluck('title', 'id')->toArray();
$belonging_map = BelongingGroup::pluck('name', 'id')->toArray();
// dd($belonging_map);
$filename = storage_path('logs/oa_hr.txt');
$string = file_get_contents($filename);
$data = explode("\r\n", $string);
$data = array_filter($data);
$dept = '';
foreach ($data as $k=>$v) {
// var_dump($v) . PHP_EOL;
if ($k == 1)
continue;
$tmp = explode("\t", $v);
if (count($tmp) == 3) {
$dept = $tmp[0] ? : $dept;
$position = $tmp[1];
$name = $tmp[2];
} else if (count($tmp) == 2) {
$position = $tmp[0];
$name = $tmp[1];
} else {
Log::info($v . PHP_EOL);
continue;
}
// Log::info($dept . '---' . $position . '---' . $name . PHP_EOL);
// continue;
$dept_id = array_search($dept, $dept_map);
$belonging_id = 17;
if (FALSE !== strpos($dept,'技术部')) {
$belonging_string = str_replace('技术部', '', $dept);
if ($belonging_string) {
$belonging_string = $belonging_string . '组';
$belonging_id = array_search($belonging_string, $belonging_map);
}
$dept_tmp = '技术部';
$dept_id = array_search($dept_tmp, $dept_map);
}
if (FALSE !== strpos($dept,'售后')) {
$belonging_string = str_replace('售后', '', $dept);
if ($belonging_string)
$belonging_id = array_search($belonging_string, $belonging_map);
$dept_tmp = '售后部';
$dept_id = array_search($dept_tmp, $dept_map);
}
$position_log = EntryPosition::where(['name' => $position])->first();
if (empty($position_log)) {
$position_log = new EntryPosition();
$position_log->name = $position;
$position_log->save();
}
$position_id = $position_log->id;
$hr = ManageHr::where(['name' => $name])->first();
if (empty($hr)) {
Log::info($k . '-' . $name . '-' . $dept . '-' . $dept_id . '-' . $position . '-' . $position_id);
continue;
}
$hr->belong_group = $belonging_id;
$hr->dept_id = $dept_id;
$hr->entry_position = $position_id;
$hr->save();
echo $k . '-' . $name . '-' . $dept . '-' . $dept_id . '-' . $position . '-' . $position_id . '-' . '组' . '-' . $belonging_id . PHP_EOL;
}
dd('end');
exit;
// public function handle()
// {
// return $this->domain();
// $result = app(SyncService::class)->projectAcceptAddress(1);
// dd($result);
// $data = [
// 'key' => 'productkey_keyword',
// 'keywords' => 'apple watch'
// ];
// $result = Common::send_openai_msg('v2/openai_chat', $data);
// dd();
// $string = 'demo.globalso.site/';
// $domain_array = parse_url($string);
// $domain = $domain_array['host'] ?? $domain_array['path'];
// dd($domain);
// $data = [];
// dd(isset($data['a']['b']));
// $url = 'https://demo.globalso.site/';
// $action = 'api/updateHtmlNotify/';
// $data = [
// 'project_id' => 1,
// 'type' => 1,
// 'route' => 1
// ];;
// $method = 'GET';
// $result = $this->curlRequest($url . $action, $data, $method);
// dd($result);
//
// $context = stream_context_create([
// 'ssl' => [
// 'capture_peer_cert' => true,
// 'capture_peer_cert_chain' => false,
// ],
// ]);
//
// $stream = stream_socket_client('ssl://oa.quanqiusou.cn:443', $errno, $errstr, 30, STREAM_CLIENT_CONNECT, $context);
//
// if(!$stream) {
// die("Failed to connect: $errno - $errstr");
// }
//
// $remote_cert = stream_context_get_params($stream)['options']['ssl']['peer_certificate'];
//
// if(!$remote_cert) {
// die("Failed to retrieve certificate");
// }
//
// $valid_from = date('Y-m-d H:i:s', openssl_x509_parse($remote_cert)['validFrom_time_t']);
// $valid_to = date('Y-m-d H:i:s', openssl_x509_parse($remote_cert)['validTo_time_t']);
//
// fclose($stream);
//
// echo "Certificate Valid From: $valid_from<br>";
// echo "Certificate Valid To: $valid_to<br>";
//
// dd('end');
// $dept_array = [
// '品牌部',
// '综合部',
// '渠道部',
// '广告推广部',
// 'AICC运营部',
// '黑格运营部',
// '直营运营部',
// '直营销售部',
// '深圳跨境部',
// '外贸部',
// '研发部',
// '技术部',
// '售后部',
// ];
// foreach ($dept_array as $v) {
// $dept = Dept::where(['title' => $v])->first();
// if (FALSE == empty($dept))
// continue;
// $dept = new Dept();
// $dept->title = $v;
// $dept->save();
// }
//// dd('dept end');
// $dept_map = Dept::pluck('title', 'id')->toArray();
// $belonging_map = BelongingGroup::pluck('name', 'id')->toArray();
//// dd($belonging_map);
//
// $filename = storage_path('logs/oa_hr.txt');
// $string = file_get_contents($filename);
// $data = explode("\r\n", $string);
// $data = array_filter($data);
// $dept = '';
// foreach ($data as $k=>$v) {
//// var_dump($v) . PHP_EOL;
// if ($k == 1)
// continue;
// $tmp = explode("\t", $v);
// if (count($tmp) == 3) {
// $dept = $tmp[0] ? : $dept;
// $position = $tmp[1];
// $name = $tmp[2];
// } else if (count($tmp) == 2) {
// $position = $tmp[0];
// $name = $tmp[1];
// } else {
// Log::info($v . PHP_EOL);
// continue;
// }
//
//
//// Log::info($dept . '---' . $position . '---' . $name . PHP_EOL);
//// continue;
//
// $dept_id = array_search($dept, $dept_map);
// $belonging_id = 17;
// if (FALSE !== strpos($dept,'技术部')) {
// $belonging_string = str_replace('技术部', '', $dept);
// if ($belonging_string) {
// $belonging_string = $belonging_string . '组';
// $belonging_id = array_search($belonging_string, $belonging_map);
// }
//
// $dept_tmp = '技术部';
// $dept_id = array_search($dept_tmp, $dept_map);
// }
// if (FALSE !== strpos($dept,'售后')) {
// $belonging_string = str_replace('售后', '', $dept);
// if ($belonging_string)
// $belonging_id = array_search($belonging_string, $belonging_map);
// $dept_tmp = '售后部';
// $dept_id = array_search($dept_tmp, $dept_map);
// }
//
// $position_log = EntryPosition::where(['name' => $position])->first();
// if (empty($position_log)) {
// $position_log = new EntryPosition();
// $position_log->name = $position;
// $position_log->save();
// }
// $position_id = $position_log->id;
//
// $hr = ManageHr::where(['name' => $name])->first();
// if (empty($hr)) {
// Log::info($k . '-' . $name . '-' . $dept . '-' . $dept_id . '-' . $position . '-' . $position_id);
// continue;
// }
//
// $hr->belong_group = $belonging_id;
// $hr->dept_id = $dept_id;
// $hr->entry_position = $position_id;
// $hr->save();
// echo $k . '-' . $name . '-' . $dept . '-' . $dept_id . '-' . $position . '-' . $position_id . '-' . '组' . '-' . $belonging_id . PHP_EOL;
//
// }
// dd('end');
// exit;
//
// if (($handle = fopen($filename, 'r')) !== false) {
// while (($data = fgetcsv($handle, 1000, ',')) !== false) {
// // 处理每行数据
// Log::info(var_export($data, true));
// }
// fclose($handle);
// }
// exit;
//
// $group = BelongingGroup::get();
// dd($group->toArray());
// $domain = parse_url('https//:dev.golbalso.site/');
// dd($domain);
// echo time() . PHP_EOL;
// $blogModel = new Image();
// $list = $blogModel->list();
// echo time() . PHP_EOL;
// dd(count($list));
//
// return;
// preg_match_all("/\@include\(\"([a-z0-9_]+)\"\)/i",'
//@include("asdf")@include("")@include("asdtrw2erf")
// ',$include);
//
// print_r($include);
// }
if (($handle = fopen($filename, 'r')) !== false) {
while (($data = fgetcsv($handle, 1000, ',')) !== false) {
// 处理每行数据
Log::info(var_export($data, true));
public function handle(){
$projectModel = new Project();
$list = $projectModel->list(['delete_status'=>0]);
foreach ($list as $v){
ProjectServer::useProject($v['id']);
$webSettingServiceModel = new WebSettingService();
$info = $webSettingServiceModel->read(['values'=>['like','%+86%']]);
if($info !== false){
echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
}
fclose($handle);
DB::disconnect('custom_mysql');
}
exit;
$group = BelongingGroup::get();
dd($group->toArray());
$domain = parse_url('https//:dev.golbalso.site/');
dd($domain);
echo time() . PHP_EOL;
$blogModel = new Image();
$list = $blogModel->list();
echo time() . PHP_EOL;
dd(count($list));
return;
preg_match_all("/\@include\(\"([a-z0-9_]+)\"\)/i",'
@include("asdf")@include("")@include("asdtrw2erf")
',$include);
print_r($include);
}
public function printMessage()
{
$client = new Client();
... ...
... ... @@ -122,7 +122,7 @@ class ProjectUpdate extends Command
$data = curl_c($url);
if (isset($data['code']) && $data['code'] == 200) {
$items = $data['data'] ?? [];
$this->category_insert($project_id, $items, 0);
$this->category_insert($project_id, $items, 0, $domain_arr['host'], $web_url_domain, $home_url);
} else {
return true;
}
... ... @@ -737,7 +737,7 @@ class ProjectUpdate extends Command
}
//产品多级分类入库
protected function category_insert($project_id, $items, $pid = 0)
protected function category_insert($project_id, $items, $pid, $domain, $web_url_domain, $home_url)
{
$model = new Category();
foreach ($items as $item) {
... ... @@ -747,9 +747,17 @@ class ProjectUpdate extends Command
if (!$parent) {
try {
$item['name'] = $this->special2str($item['name'] ?? '');
//图片
if (is_array($item['images'] ?? '')) {
$image = $item['images'][0] ?? '';
} else {
$image = $item['images'] ?? '';
}
$new_img = $this->source_download($image, $project_id, $domain, $web_url_domain, $home_url);
$parent_id = $model->addReturnId([
'project_id' => $project_id,
'title' => $item['name'],
'image' => $new_img,
'pid' => $pid,
'keywords' => $item['keywords'] ?? '',
'describe' => $item['description'] ?? '',
... ... @@ -766,7 +774,7 @@ class ProjectUpdate extends Command
}
if (!empty($item['children'] ?? [])) {
$this->category_insert($project_id, $item['children'], $parent_id);
$this->category_insert($project_id, $item['children'], $parent_id, $domain, $web_url_domain, $home_url);
}
}
}
... ...
... ... @@ -55,7 +55,7 @@ class UpdateRoute extends Command
*/
public function handle(){
$projectModel = new Project();
$list = $projectModel->list(['is_upgrade'=>0,'delete_status'=>0,'id'=>['<',500]]);
$list = $projectModel->list(['id'=>264]);
$data = [];
foreach ($list as $v){
echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
... ...
... ... @@ -291,7 +291,7 @@ class WebTraffic extends Command
}else{
//大于9个月项目
$startTime = Carbon::now()->addMonths(-9)->startOfDay()->toDateTimeString();
$query->whereBetween('pdo.start_date', '<', $startTime);
$query->where('pdo.start_date', '<', $startTime);
}
})->select('pdo.project_id')->forPage($page, 500)->get();
//其他地方在引流的域名
... ...
... ... @@ -727,7 +727,7 @@ class Translate
* @return \Illuminate\Http\Client\Response
* @time 2022/3/30 15:58
*/
public static function translate($texts, $tls)
public static function translate($texts, $tls, $sl = 'auto')
{
$action = 'translates';
if (is_string($texts)) {
... ... @@ -738,7 +738,7 @@ class Translate
}
$data = [
'texts' => $texts,
'sl' => 'auto',
'sl' => $sl,
'tls' => $tls,
];
return http_post(self::$url.$action, json_encode($data),self::$header);
... ...
... ... @@ -6,9 +6,16 @@ use App\Enums\Common\Code;
use App\Enums\Common\Common;
use App\Http\Controllers\Aside\BaseController;
use App\Http\Logic\Aside\Manage\MenuLogic;
use App\Models\Domain\DomainInfo;
use App\Models\Inquiry\InquiryData;
use App\Models\Manage\Manage;
use App\Models\Product\Keyword;
use App\Models\Product\Product;
use App\Models\Project\Project;
use App\Models\RouteMap\RouteMap;
use App\Services\ProjectServer;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Hash;
/**
... ... @@ -96,4 +103,56 @@ class IndexController extends BaseController
$this->response('success');
}
/**
* @remark :根据关键字获取产品主图
* @name :getKeywordList
* @author :lyh
* @method :post
* @time :2024/2/23 16:28
*/
public function getKeywordImage(){
$arr = explode('/',trim(str_replace('https://', '', $this->param['url']),'/'));
if(empty($arr) || !is_array($arr)){
$this->response('当前项目不存在..',Code::SYSTEM_ERROR);
}
$domainModel = new DomainInfo();
$domainInfo = $domainModel->read(['domain'=>$arr[0]]);
if($domainInfo === false){
$this->response('当前项目不存在.',Code::SYSTEM_ERROR);
}
ProjectServer::useProject($domainInfo['project_id']);
$routeMapModel = new RouteMap();
$routeInfo = $routeMapModel->read(['route'=>$arr[1]]);
if($domainInfo === false){
$this->response('当前路由不存在.',Code::SYSTEM_ERROR);
}
$keywordModel = new Keyword();
$keywordInfo = $keywordModel->read(['id'=>$routeInfo['source_id']]);
$count = Product::where('keyword_id','like' ,'%,'.$keywordInfo['id'].',%')->count();
$productModel = new Product();
if($count < 5){
$productList = $productModel->list([],'sort',['thumb','title']);
//获取7个产品主图
}else{
$productList = $productModel->list(['keyword_id'=>['like','%,'.$keywordInfo['id'].',%']],['thumb','title']);
}
$product_image = [];
foreach ($productList as $k => $v){
$image = [];
$image['title'] = $v['title'];
if(!empty($v['thumb']) && !empty($v['thumb']['url'])){
$image['image'] = getImageUrl($v['thumb']['url']);
}
$product_image[] = $image;
}
$data = [
'title'=>$keywordInfo['title'],
'keyword_title'=>$keywordInfo['keyword_title'],
'keyword_content'=>$keywordInfo['keyword_content'],
'product_list'=>$product_image
];
DB::disconnect('custom_mysql');
$this->response('success',Code::SUCCESS,$data);
}
}
... ...
... ... @@ -213,7 +213,7 @@ class OptimizeController extends BaseController
if(isset($this->map['level']) && !empty($this->map['level'])){
$query = $query->whereRaw("FIND_IN_SET(?, gl_project.level) > 0", [$this->map['level']]);
}
if(isset($this->map['online_updated_at']) && !empty($this->map['online_updated_at'])){
if(isset($this->map['online_updated_at']) && !empty($this->map['online_updated_at']) && is_array($this->map['online_updated_at'])){
$query = $query->whereBetween('gl_project_deploy_optimize.updated_at', $this->map['online_updated_at']);
}
if(isset($this->map['special'])){
... ...
... ... @@ -26,7 +26,6 @@ class ATemplateController extends BaseController
*/
public function lists(ATemplateLogic $aTemplateLogic){
$filed = ['id','name','image','url','status','sort','deleted_status','test_model','created_at','project_id'];
$this->map['test_model'] = 0;
$lists = $aTemplateLogic->aTemplateList($this->map,$this->page,$this->row,$this->order,$filed);
if(!empty($lists) && !empty($lists['list'])){
foreach ($lists['list'] as $k => $v){
... ...
... ... @@ -300,4 +300,28 @@ class ComController extends BaseController
}
$this->response('success',Code::SUCCESS,['url'=>$url_link]);
}
/**
* @remark :根据手机号码,获取当前号码拥有的所有项目
* @name :getMobileProject
* @author :lyh
* @method :post
* @time :2024/2/22 9:32
*/
public function getMobileProject(){
$data = [];
$userModel = new User();
$list = $userModel->list(['mobile'=>$this->user['mobile'],'project_id'=>['!=',$this->user['project_id']]],'id',['id','project_id']);
if(!empty($list)){
$projectModel = new Project();
foreach ($list as $k => $v){
$projectInfo = $projectModel->read(['id'=>$v['project_id']],['id','company']);
//获取当前项目详情
$data[] = ['project_id'=>$projectInfo['id'],'company'=>$projectInfo['company']];
}
}
//登录选择项目的有效时间
Cache::add('login-project-'.$this->user['mobile'],1,300);
$this->response('success',Code::SUCCESS,$data);
}
}
... ...
<?php
/**
* @remark :
* @name :MonthReportController.php
* @author :lyh
* @method :post
* @time :2024/2/2 15:01
*/
namespace App\Http\Controllers\Bside\BCom;
use App\Enums\Common\Code;
use App\Http\Controllers\Bside\BaseController;
use App\Models\HomeCount\MonthCount;
class MonthReportController extends BaseController
{
/**
* @remark :获取项目当前所有月份
* @name :getMonth
* @author :lyh
* @method :post
* @time :2024/2/2 15:14
*/
public function getMonth(){
$monthCountModel = new MonthCount();
$this->map['project_id'] = $this->user['project_id'];
$month = $monthCountModel->formatQuery($this->map)->pluck('month')->unique()->toArray();
$this->response('success',Code::SUCCESS,$month);
}
/**
* @remark :月报告详情
* @name :monthReportInfo
* @author :lyh
* @method :post
* @time :2024/2/2 15:02
*/
public function monthReportInfo(){
$monthCountModel = new MonthCount();
$this->map['project_id'] = $this->user['project_id'];
$info = $monthCountModel->read($this->map);
foreach ($info as $k => $v){
if(!empty($v['source_country'])){
$v['source_country'] = json_decode($v['source_country']);
}
if(!empty($v['referrer_port'])){
$v['referrer_port'] = json_decode($v['referrer_port']);
}
if(!empty($v['referrer_url'])){
$v['referrer_url'] = json_decode($v['referrer_url']);
}
if(!empty($v['source'])){
$v['source'] = json_decode($v['source']);
}
if(!empty($v['country'])){
$v['country'] = json_decode($v['country']);
}
$lists[$k] = $v;
}
$this->response('success',Code::SUCCESS,$info);
}
}
... ...
... ... @@ -94,11 +94,6 @@ class KeywordController extends BaseController
* @time :2023/8/23 16:57
*/
public function info(Request $request, KeywordLogic $logic){
$request->validate([
'id'=>'required'
],[
'id.required' => 'ID不能为空'
]);
$data = $logic->getKeywordInfo();
if($data !== false){
$data = $this->handleReturnInfo($data);
... ...
... ... @@ -17,6 +17,7 @@ use App\Models\Product\ExtendInfo;
use App\Models\Product\Keyword;
use App\Models\Product\KeywordRelated;
use App\Models\Product\Product;
use App\Models\RouteMap\RouteMap;
use App\Models\Template\Setting;
use App\Models\Template\BTemplate;
use App\Models\User\User;
... ... @@ -58,7 +59,7 @@ class ProductController extends BaseController
$template_id = $this->getTemplateId(BTemplate::SOURCE_PRODUCT,BTemplate::IS_DETAIL);//获取模版id
$userModel = new User();
foreach ($lists['list'] as $k=>$v){
$v['url'] = $this->user['domain'].$v['route'].'/';
$v['url'] = $this->user['domain'] . getRouteMap(RouteMap::SOURCE_PRODUCT,$v['id']);;
$v['category_id_text'] = $this->categoryName($v['category_id'],$cate_data);
$v['keyword_id_text'] = $this->keywordName($v['keyword_id'],$key_data);
$v['created_uid_text'] = $userModel->getName($v['created_uid']);
... ...
<?php
/**
* @remark :
* @name :UpdateHtml.php
* @author :lyh
* @method :post
* @time :2024/2/2 10:11
*/
namespace App\Http\Controllers\Html;
use App\Http\Controllers\Controller;
use App\Models\Com\NoticeLog;
use App\Models\Project\Project;
use App\Models\RouteMap\RouteMap;
use App\Models\Service\Service as ServiceSettingModel;
use App\Models\Template\BTemplate;
use App\Services\ProjectServer;
use Illuminate\Support\Facades\DB;
class UpdateHtml extends Controller
{
protected $param;
protected $project_id;
public function __construct($data){
$this->param = $data;//Todo::传递的参数
$this->project_id = $data['project_id'];
}
/**
* @remark :更新界面
* @name :updateHtml
* @author :lyh
* @method :post
* @time :2024/2/2 10:12
*/
public function updateHtml(){
ProjectServer::useProject($this->project_id);
if(isset($this->param['route']) && $this->param['route'] == 'all'){
//TODO::更新所有界面
}else{
//TODO::更新单页
$routeMapModel = new RouteMap();
}
DB::disconnect('custom_mysql');
}
/**
* @remark :获取页面是否为 定制/非定制 页面
* @name :getPageHtmlIsCustomized
* @param :source:类型;is_list:是否为列表页 1:列表页面
* @author :lyh
* @method :post
* @time :2024/2/2 11:03
*/
public function getPageHtmlIsCustomized($source,$is_list){
$type = $this->getCustomizedType($source, $is_list);//获取定制界面类型
//查看当前页面是否定制,是否开启可视化
$page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面
if (in_array($type, $page_array)) {//是定制界面
return BTemplate::IS_VISUALIZATION;
}
return BTemplate::IS_NO_VISUALIZATION;
}
/**
* @remark :获取头部底部公共部分代码
* @name :getTemplateCommon
* @author :lyh
* @method :post
* @time :2024/2/2 11:02
*/
public function getTemplateCommon(){
}
/**
* @remark :获取装修中间内容
* @name :getTemplateMainHtml
* @author :lyh
* @method :post
* @time :2024/2/2 11:01
*/
public function getTemplateMainHtml(){
}
/**
* @remark :获取项目详情
* @name :getProjectInfo
* @author :lyh
* @method :post
* @time :2024/2/2 10:50
*/
public function getProjectInfo($project_id){
$projectModel = new Project();
$info = $projectModel->read(['id'=>$project_id],['id','is_customized']);
return $info;
}
/**
* @remark :拼接获取公共头部底部
* @name :getHeadFooter
* @author :lyh
* @method :post
* @time :2023/7/21 17:22
*/
public function getHeadFooter($html){
//获取公共主题头部底部
$serviceSettingModel = new ServiceSettingModel();
$list = $serviceSettingModel->list(['type'=>2],'created_at');
//拼接html
foreach ($list as $v){
if($v['key'] == 'head'){
$html = $v['values'].$html;
}
if($v['key'] == 'footer'){
$html = $html.$v['values'];
}
}
return $html;
}
}
... ... @@ -43,6 +43,10 @@ class DomainInfoLogic extends BaseLogic
if(isset($this->param['id']) && !empty($this->param['id'])){
$rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
}else{
//查看域名是否以WWW开头
if (strpos($this->param['domain'], 'www.') === 0) {
$this->param['other_domain'] = json_encode([str_replace('www', '*', $this->param['domain']),str_replace('www.', '', $this->param['domain'])]);
}
$rs = $this->model->add($this->param);
}
if($rs === false){
... ... @@ -185,6 +189,48 @@ class DomainInfoLogic extends BaseLogic
}
/**
* 编辑amp网站证书
* @param $initDomain
* @param $domain
* @return array
* @throws \App\Exceptions\AsideGlobalException
* @throws \App\Exceptions\BsideGlobalException
* @author Akun
* @date 2024/02/22 14:58
*/
public function setAmpDomainSsl($initDomain,$domain)
{
if($this->param['amp_type'] == 2){
if(empty($this->param['amp_key'])){
$this->fail('AMP站点证书KEY值不能为空');
}
if(empty($this->param['amp_cert'])){
$this->fail('AMP站点证书cert值不能为空');
}
}
$api_url = 'http://'.$initDomain.'/api/createSiteAmp';
$api_param = [
'domain' => $domain,
'private_key' => $this->param['amp_key']??'',
'cert' => $this->param['amp_cert']??''
];
try {
$rs = HttpUtils::get($api_url, $api_param);
$rs = json_decode($rs, true);
if(isset($rs['status']) && $rs['status'] == 200){
return $this->success();
}else{
$this->fail($rs['message']??'');
}
} catch (\Exception | GuzzleException $e) {
errorLog('创建AMP站点', $api_param, $e);
$this->fail('编辑AMP站点证书失败');
}
return $this->success();
}
/**
* @remark :保存证书相关配置
* @name :sslSave
* @author :lyh
... ... @@ -218,6 +264,22 @@ class DomainInfoLogic extends BaseLogic
}
}
//如果要开通amp站点,判断m域名是否已经解析
if(isset($this->param['amp_status']) && $this->param['amp_status'] == 1){
$domain_array = parse_url($info['domain']);
$host = $domain_array['host'] ?? $domain_array['path'];
$host_array = explode('.',$host);
if(count($host_array) <= 2){
array_unshift($host_array,'m');
}else{
$host_array[0] = 'm';
}
$amp_domain = implode('.',$host_array);
if(!$this->check_cname($amp_domain, $server_info)){
$this->fail('AMP站点域名' . $amp_domain . '未解析至目标服务器');
}
}
//保存301跳转数据+其他域名
$data = [
'other_domain'=>json_encode($this->param['other_domain'] ?? []),
... ... @@ -225,10 +287,20 @@ class DomainInfoLogic extends BaseLogic
'type'=>$this->param['type'],
'private_key' => $this->param['key'] ?? '',
'private_cert' => $this->param['cert'] ?? '',
'amp_status' => $this->param['amp_status'] ?? 0,
'amp_type' => $this->param['amp_type'] ?? 0,
'amp_private_key' => $this->param['amp_key'] ?? '',
'amp_private_cert' => $this->param['amp_cert'] ?? '',
];
$this->model->edit($data,['id'=>$this->param['id']]);
//生成证书
$this->setDomainSsl($server_info['init_domain'],$info['domain'],$this->param['extend_config'] ?? [],$this->param['other_domain'] ?? []);
//amp站点生成证书
if($data['amp_status']){
$this->setAmpDomainSsl($server_info['init_domain'],$info['domain']);
}
return $this->success();
}
... ...
... ... @@ -156,13 +156,14 @@ class ProjectLogic extends BaseLogic
$this->syncImageFile($this->param['project_location'],$this->param['id']);
//创建站点
// $this->createSite($this->param);
(new SyncService())->projectAcceptAddress($this->param['id']);
}
DB::commit();
}catch (\Exception $e){
DB::rollBack();
$this->fail('保存失败,请联系管理员');
}
(new SyncService())->projectAcceptAddress($this->param['id']);
return $this->success();
}
... ... @@ -373,7 +374,7 @@ class ProjectLogic extends BaseLogic
'company' => $param['company'],
'lead_name' => $param['lead_name'],
'mobile' => $param['mobile'],
'qq' => $param['qq'],
'qq' => $param['qq'] ?? '',
'channel' => json_encode($param['channel']),
'requirement' => $param['requirement'],
'cooperate_date' => $param['cooperate_date'],
... ...
... ... @@ -70,8 +70,7 @@ class AyrReleaseLogic extends BaseLogic
$arr[] = $v;
}
}
@file_put_contents(storage_path('logs/lyh_error.log'), var_export($arr, true) . PHP_EOL, FILE_APPEND);
return $this->success($arr);
return $this->success($arr);
}
}
... ...
... ... @@ -331,7 +331,10 @@ class BTemplateLogic extends BaseLogic
if($info === false){
$this->fail('当前扩展模块不存在或已被删除');
}
if($info['list_customized'] == BTemplate::IS_VISUALIZATION || $info['detail_customized'] == BTemplate::IS_VISUALIZATION){
if($info['list_customized'] == BTemplate::IS_VISUALIZATION && $is_list == BTemplate::IS_LIST){
return $this->success($template_id);
}
if($info['detail_customized'] == BTemplate::IS_VISUALIZATION && $is_list == BTemplate::IS_DETAIL){
return $this->success($template_id);
}
}else{
... ... @@ -367,9 +370,6 @@ class BTemplateLogic extends BaseLogic
'type'=>$type,
'is_custom'=>0,
];
if($this->user['project_id'] == 427){
@file_put_contents(storage_path('logs/lyh_error.log'), var_export($data, true) . PHP_EOL, FILE_APPEND);
}
$commonTemplateModel = new BTemplateCommon();
$commonInfo = $commonTemplateModel->read($data);
if($commonInfo === false){
... ...
... ... @@ -173,8 +173,12 @@ class BaseLogic extends Logic
$data['project_id'] = $this->user['project_id'];
$str = http_build_query($data);
$url = $this->user['domain'].'api/delHtml/?'.$str;
// shell_exec($url);
curlGet($url);
$rs = shell_exec('curl -k "'.$url.'"');
// if($this->user['project_id'] == 177){
// @file_put_contents(storage_path('logs/lyh_error.log'), var_export($url, true) . PHP_EOL, FILE_APPEND);
// @file_put_contents(storage_path('logs/lyh_error.log'), var_export($rs, true) . PHP_EOL, FILE_APPEND);
// }
// curlGet($url);
return $this->success();
}
}
... ...
... ... @@ -96,7 +96,11 @@ class CountLogic extends BaseLogic
];
$data = $rankDataModel->read($param,['first_num','first_page_num','first_three_pages_num','first_five_pages_num','first_ten_pages_num']);
if($data === false){
$data = [];
$param['updated_date'] = Carbon::yesterday()->toDateString();
$data = $rankDataModel->read($param,['first_num','first_page_num','first_three_pages_num','first_five_pages_num','first_ten_pages_num']);
if($data === false){
$data = [];
}
}
return $this->success($data);
}
... ...
... ... @@ -42,16 +42,19 @@ class WebSettingServiceLogic extends BaseLogic
$this->param['data'] = Common::uniqueMultiArray($this->param['data']);
//删除以前的数据
$this->model->del(['project_id'=>$this->user['project_id']]);
$data = [];
foreach ($this->param['data'] as $k => $v){
if(!isset($v['values']) || empty($v['values'])){
$v['values'] = '';
if(isset($v['values']) && empty($v['values'])){
$v['project_id'] = $this->user['project_id'];
$v['created_at'] = date('Y-m-d H:i:s');
$v['updated_at'] = date('Y-m-d H:i:s');
$data[] = $v;
}
$v['project_id'] = $this->user['project_id'];
$v['created_at'] = date('Y-m-d H:i:s');
$v['updated_at'] = date('Y-m-d H:i:s');
$this->param['data'][$k] = $v;
}
$this->model->insert($this->param['data']);
if(!empty($data)){
$this->model->insert($data);
}
DB::commit();
}catch (\Exception $e){
DB::rollBack();
... ...
... ... @@ -386,4 +386,5 @@ class UserLoginLogic
throw new AsideGlobalException($code, $message);
}
}
... ...
... ... @@ -57,9 +57,12 @@ class CopyProjectJob implements ShouldQueue
$data = $data->getAttributes();
$type = $data['type'];
$data['type'] = 0;
$data['status'] = 0;
$data['title'] = $data['title'].'-copy';
unset($data['id']);
$project_id = $projectModel->insertGetId($data);
$hashids = new Hashids($data['from_order_id'], 13, 'abcdefghjkmnpqrstuvwxyz1234567890');
$projectModel->edit(['from_order_id'=>$hashids->encode($project_id)],['id'=>$project_id]);
//复制部署表
$buildModel = new DeployBuild();
$buildData = $buildModel::where('project_id', $this->param['project_id'])->first();
... ...
... ... @@ -55,6 +55,8 @@ class RouteMap extends Base
public static function generateRoute($title, $source, $source_id, $project_id){
if(preg_match('/[\x{4e00}-\x{9fa5}]/u', $title)){
$title = Translate::tran($title, 'en');
}elseif (preg_match('/[а-яА-Я]/u', $title)) {
$title = Translate::tran($title, 'en');
}
$i=1;
$sign = generateRoute($title);
... ...
... ... @@ -67,7 +67,6 @@ class AmazonS3Service
public function syncImageFiles($files)
{
$file_content = curl_c($files,false);
@file_put_contents(storage_path('logs/lyh_error.log'), var_export($file_content, true) . PHP_EOL, FILE_APPEND);
$key = str_replace_url($files);
try {
$result = $this->s3->putObject([
... ...
<?php
/**
* Created by PhpStorm.
* User: zhl
* Date: 2024/2/19
* Time: 15:46
*/
namespace App\Services;
class CreateHtmlService
{
public function __construct(){}
/**
* 返回最终需要的HTML
* @return string
*/
public function getHtml($project, $route, $lang = [], $page = 0)
{
// 获取页面信息
$page_info = $this->getInfoByRoute($route);
// 根据项目和路由信息返回的结果确定当前页面使用5.0还是6.0的页面;
if ($project && $page_info) {
$html = $this->getHtmlV6($page_info['master_lang'], $lang = [], $page = 0);
} else {
$html = $this->getHtmlV5();
}
return $html;
}
/**
* 返回5.0页面最终HTML
* @return string
*/
public function getHtmlV5()
{
$html = '';
return $html;
}
/**
* 返回6.0页面最终HTML
* @return mixed
*/
public function getHtmlV6($master_lang, $lang = [], $page = 0)
{
// 初始化后续需要渲染页面需要的数据 路由、主语种、tdk、嵌入等信息
$origin_html = $this->originHtml();
$html = $this->renderData($origin_html, $page);
$html = $this->plugHead($html);
$html = $this->processFinal($html);
/** ... 调用其他方法, 直至返回完整的正确的HTML */
return $html;
}
/**
* 根据路由信息 返回 路由属性及详细信息
* @param string $route
* @return array
*/
public function getInfoByRoute($route)
{
// TODO 获取详情需要通过路由查下路由信息, 以及数据信息, 要处理特殊几个路由: top-search、products、news、blog, 这几个如果存在就用查下的信息, 如果不存在要初始化信息
return [];
}
/**
* 获取可视化HTML
* @return string
*/
public function originHtml()
{
$html = '根据路由查询数据库,并拼装HTML';
return $html;
}
/**
* 补充其他信息
* TDK mate信息等
* @param $html
* @return mixed
*/
public function plugHead($html)
{
/** 渲染tdk信息、 mate信息、 嵌入信息、 图标信息*/
return $html;
}
/**
* 处理最终信息
* 处理标签、最后代码标识、特殊规则或者字符等
* @param string $html
* @return string
*/
public function processFinal($html)
{
return $html;
}
/**
* 渲染页面数据
* @param string $html
* @return string
*/
public function renderData($html, $page)
{
/**
* 根据可视化HTML中关键词渲染数据
* 这个方法还需要进行拆分, 这个功能内容应该会比较多
* 并且还会根据路由信息和分页信息不同, 渲染不同数据, 只要针对列表页面
*/
return $html;
}
}
\ No newline at end of file
... ...
<?php
/**
* @remark :
* @name :GeneratePageService.php
* @author :lyh
* @method :post
* @time :2024/2/19 15:54
*/
namespace App\Services;
use App\Models\CustomModule\CustomModule;
use App\Models\CustomModule\CustomModuleCategory;
use App\Models\CustomModule\CustomModuleContent;
use App\Models\Project\Project;
use App\Models\RouteMap\RouteMap;
use App\Models\Template\BTemplate;
use App\Models\Template\BTemplateCommon;
use App\Models\Template\BTemplateMain;
use App\Models\Template\Setting;
use App\Models\Template\Template;
use App\Models\Template\TemplateTypeMain;
use Illuminate\Support\Facades\DB;
class GeneratePageService
{
protected $route;
protected $param;
protected $project_id = 0;
public function __construct(){
$this->param = request()->all();
$this->route = $this->param['route'];
$this->project_id = $this->param['project_id'];
}
/**
* @remark :生成单页数据
* @name :generateHtml
* @author :lyh
* @method :post
* @time :2024/2/19 16:57
*/
public function generateHtml(){
ProjectServer::useProject($this->project_id);
$routeMapModel = new RouteMap();
$routeInfo = $routeMapModel->read(['route'=>$this->param['route']]);
if($this->param['route'] != RouteMap::SOURCE_INDEX && $routeInfo['source'] == RouteMap::SOURCE_PAGE){
//页面管理单独处理
}else{
$this->handleParam($routeInfo);
$this->getTemplateHtml();
}
DB::disconnect('custom_mysql');
return true;
}
/**
* @remark :生成页面参数处理
* @name :generateHtml
* @author :lyh
* @method :post
* @time :2024/2/19 16:36
*/
public function handleParam($routeInfo){
switch ($routeInfo['source']){
case RouteMap::SOURCE_PRODUCT:
$this->param['source'] = BTemplate::SOURCE_PRODUCT;
$this->param['is_list'] = BTemplate::IS_DETAIL;
break;
case RouteMap::SOURCE_PRODUCT_CATE:
$this->param['source'] = BTemplate::SOURCE_PRODUCT;
$this->param['is_list'] = BTemplate::IS_LIST;
break;
case RouteMap::SOURCE_BLOG:
$this->param['source'] = BTemplate::SOURCE_BLOG;
$this->param['is_list'] = BTemplate::IS_DETAIL;
break;
case RouteMap::SOURCE_BLOG_CATE:
$this->param['source'] = BTemplate::SOURCE_BLOG;
$this->param['is_list'] = BTemplate::IS_LIST;
break;
case RouteMap::SOURCE_NEWS:
$this->param['source'] = BTemplate::SOURCE_NEWS;
$this->param['is_list'] = BTemplate::IS_DETAIL;
break;
case RouteMap::SOURCE_NEWS_CATE:
$this->param['source'] = BTemplate::SOURCE_NEWS;
$this->param['is_list'] = BTemplate::IS_LIST;
break;
case RouteMap::SOURCE_MODULE:
$this->param['is_custom'] = BTemplate::IS_CUSTOM;
//TODO::获取对应模块数据
$moduleModel = new CustomModuleContent();
$moduleInfo = $moduleModel->read(['id'=>$routeInfo['source_id']],['module_id']);
$this->param['source'] = $moduleInfo['id'] ?? 0;
$this->param['is_list'] = BTemplate::IS_DETAIL;
break;
case RouteMap::SOURCE_MODULE_CATE:
$this->param['is_custom'] = BTemplate::IS_CUSTOM;
//TODO::获取对应模块数据
$moduleModel = new CustomModuleCategory();
$moduleInfo = $moduleModel->read(['id'=>$routeInfo['source_id']],['module_id']);
$this->param['source'] = $moduleInfo['id'] ?? 0;
$this->param['is_list'] = BTemplate::IS_LIST;
break;
default:
$this->param['source'] = BTemplate::SOURCE_HOME;
$this->param['is_list'] = BTemplate::IS_DETAIL;
break;
return true;
}
}
/**
* @notes: 请简要描述方法功能
* @param array $data
* @return array
*/
public function success($data = [])
{
return $data;
}
/**
* @remark :获取html
* @name :getTemplateHtml
* @author :lyh
* @method :post
*/
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,$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->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代码
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'];
$html = $this->getHeadFooter($html);
$result = ['html'=>$html,'template_id'=>$template_id];
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]);
}
/**
* @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($is_list == BTemplate::IS_LIST && $info['list_customized'] == BTemplate::IS_VISUALIZATION){
$html = $this->customModuleCustomizeHtml($source,$is_list,$is_custom);
return $this->success(['html'=>$html,'template_id'=>$template_id]);
}
if($is_list == BTemplate::IS_DETAIL && $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
* @method :post
* @time :2023/12/27 15:00
*/
public function getMAinHtml($type,$is_custom,$is_list){
//获取设置的默认中间部分
$bTemplateMainModel = new BTemplateMain();
$mainInfo = $bTemplateMainModel->read(['type'=>$type,'is_list'=>$is_list,'is_custom'=>$is_custom]);
if($mainInfo === false){
$main_html = $this->getInitModule($type,$is_custom,$is_list);
$main_css = "<style id='globalsojs-styles'></style>";
}else{
$main_html = $mainInfo['main_html'];
$main_css = $mainInfo['main_css'];
}
return ['main_html'=>$main_html,'main_css'=>$main_css];
}
/**
* @remark :默认复合页数据
* @name :getProductModule
* @author :lyh
* @method :post
* @time :2023/7/27 15:08
*/
public function getInitModule($type,$is_custom,$is_list){
if($is_custom == BTemplate::IS_CUSTOM) {
$type = BTemplate::SOURCE_CUSTOM;
}
$mainModel = new TemplateTypeMain();
$info = $mainModel->read(['type'=>$type,'is_list'=>$is_list]);
return $info['main_html'];
}
/**
* @remark :返回整个html截取代码
* @name :handleAllHtml
* @author :lyh
* @method :post
* @time :2023/12/13 15:39
*/
public function handleAllHtml($commonInfo,$html){
if(!empty($commonInfo)){
$html = preg_replace('/<header\b[^>]*>(.*?)<\/header>/s', $commonInfo['head_html'], $html);
$html = preg_replace('/<footer\b[^>]*>(.*?)<\/footer>/s', $commonInfo['footer_html'], $html);
$html = preg_replace('/<style id="globalsojs-header">(.*?)<\/style>/s', $commonInfo['head_css'], $html);
$html = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', $commonInfo['footer_css'], $html);
}
return $html;
}
/**
* @remark :页面是否为定制页面获取初始代码
* @name :watchProjectIsCustomized
* @author :lyh
* @method :post
* @time :2023/12/13 10:55
*/
public function isCustomizedPage($source,$is_list,$is_custom)
{
$type = $this->getCustomizedType($source, $is_list);//获取定制界面类型
//查看当前页面是否定制,是否开启可视化
$page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面
if (in_array($type, $page_array)) {//是定制界面
//TODO::获取初始代码
$bTemplateMainModel = new BTemplateMain();
$customHtmlInfo = $bTemplateMainModel->read(['type'=>$source,'is_custom'=>$is_custom,'is_list'=>$is_list]);
if($customHtmlInfo === false){
$this->fail('定制页面,请先上传代码块');
}
$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 false;
}
/**
* @remark :定制项目获取头部底部
* @name :getCustomizedCommonHtml
* @author :lyh
* @method :post
* @time :2023/12/29 13:13
*/
public function getCustomizedCommonHtml($type,$is_custom = 0,$is_list = 0){
$data = [
'template_id' => 0,
'project_id' => $this->user['project_id'],
'type'=>$type,
'is_custom'=>$is_custom,
'is_list'=>$is_list
];
$commonTemplateModel = new BTemplateCommon();
return $commonTemplateModel->read($data);
}
/**
* @remark :定制页面头部类型---根据source获取type类型
* @name :getType
* @author :lyh
* @method :post
* @time :2023/11/16 11:20
*/
public function getCustomizedType($source,$is_list){
$type = BTemplate::TYPE_HOME;
if($source == BTemplate::SOURCE_PRODUCT){
if($is_list == BTemplate::IS_LIST){
$type = BTemplate::TYPE_PRODUCT_LIST;
}else{
$type = BTemplate::TYPE_PRODUCT_DETAIL;
}
}
if($source == BTemplate::SOURCE_BLOG){
if($is_list == BTemplate::IS_LIST){
$type = BTemplate::TYPE_BLOG_LIST;
}else{
$type = BTemplate::TYPE_BLOG_DETAIL;
}
}
if($source == BTemplate::SOURCE_NEWS){
if($is_list == BTemplate::IS_LIST){
$type = BTemplate::TYPE_NEWS_LIST;
}else{
$type = BTemplate::TYPE_NEWS_DETAIL;
}
}
return $type;
}
/**
* @remark :获取当前项目设置的模版
* @name :getSettingTemplate
* @author :lyh
* @method :post
* @time :2023/12/13 10:48
*/
public function getSettingTemplate($source,$is_list,$is_custom){
$template_id = 0;
if($this->user['is_customized'] == BTemplate::IS_VISUALIZATION) {//定制项目
if($is_custom == BTemplate::IS_CUSTOM){
$customModuleModel = new CustomModule();
$info = $customModuleModel->read(['id'=>$source]);
if($info === false){
return false;
}
if($info['list_customized'] == BTemplate::IS_VISUALIZATION && $is_list == BTemplate::IS_LIST){
return $this->success($template_id);
}
if($info['detail_customized'] == BTemplate::IS_VISUALIZATION && $is_list == BTemplate::IS_DETAIL){
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();
$info = $bSettingModel->read(['project_id'=>$this->user['project_id']]);
if($info === false){
$this->fail('请先选择模版');
}
$template_id = $info['template_id'];
return $this->success($template_id);
}
/**
* @remark :根据类型获取公共头和底
* @name :getCommonPage
* @author :lyh
* @method :post
* @time :2023/10/21 16:55
*/
public function getCommonHtml($source,$is_list,$template_id,$is_custom = 0){
$type = $this->getType($source,$is_list,$is_custom);
$data = [
'template_id' => $template_id,
'project_id' => $this->user['project_id'],
'type'=>$type,
'is_custom'=>0,
];
$commonTemplateModel = new BTemplateCommon();
$commonInfo = $commonTemplateModel->read($data);
if($commonInfo === false){
$data['type'] = BTemplate::SOURCE_HOME;
$commonInfo = $commonTemplateModel->read($data);
}
return $this->success($commonInfo);
}
}
... ...
... ... @@ -380,6 +380,7 @@ Route::group([], function () {
Route::any('/collect', [Aside\Collect\CollectController::class, 'index'])->name('admin.collect');
//同步询盘
Route::any('/sync_inquiry', [Aside\Com\IndexController::class, 'sync_inquiry'])->name('admin.sync_inquiry');
Route::any('/getKeywordImage', [Aside\Com\IndexController::class, 'getKeywordImage'])->name('admin.getKeywordImage');
});
... ...
... ... @@ -19,6 +19,7 @@ Route::middleware(['bloginauth'])->group(function () {
Route::any('/get_project', [\App\Http\Controllers\Bside\BCom\ComController::class, 'get_project'])->name('get_project');
Route::any('/generateToken', [\App\Http\Controllers\Bside\BCom\ComController::class, 'generateToken'])->name('generateToken');
Route::any('/getLink', [\App\Http\Controllers\Bside\BCom\ComController::class, 'getLink'])->name('getLink');
Route::any('/getMobileProject', [\App\Http\Controllers\Bside\BCom\ComController::class, 'getMobileProject'])->name('getMobileProject');
//用户相关路由
Route::prefix('user')->group(function () {
Route::any('/', [\App\Http\Controllers\Bside\User\UserController::class, 'lists'])->name('user_lists');
... ... @@ -495,6 +496,12 @@ Route::middleware(['bloginauth'])->group(function () {
Route::any('/save', [\App\Http\Controllers\Bside\Scoring\RatingController::class, 'save'])->name('rating_save');
Route::any('/code', [\App\Http\Controllers\Bside\Scoring\RatingController::class, 'verificationCode'])->name('rating_code');
});
//月报表
Route::prefix('month_report')->group(function () {
Route::any('/month', [\App\Http\Controllers\Bside\BCom\MonthReportController::class, 'getMonth'])->name('month_report_getMonth');
Route::any('/read', [\App\Http\Controllers\Bside\BCom\MonthReportController::class, 'monthReportInfo'])->name('month_report_read');
});
});
//无需登录验证的路由组
Route::group([], function () {
... ...