作者 刘锟

Merge remote-tracking branch 'origin/master' into akun

... ... @@ -55,7 +55,7 @@ class UpdateRoute extends Command
*/
public function handle(){
$projectModel = new Project();
$list = $projectModel->list(['id'=>358]);
$list = $projectModel->list(['id'=>687]);
$data = [];
foreach ($list as $v){
echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
... ...
... ... @@ -7,6 +7,7 @@ use App\Models\Product\Category;
use App\Models\Product\Product;
use App\Models\Project\OnlineCheck;
use App\Models\Project\Project;
use App\Models\Project\WebTrafficConfig;
use App\Models\Template\BCustomTemplate;
use App\Models\WebSetting\WebLanguage;
use App\Services\ProjectServer;
... ... @@ -193,35 +194,35 @@ class WebTraffic extends Command
$need_project[] = $project;
}
//随机访问ip
$ips = $this->getIpAreas(count($need_project));
$ips = $this->getIpAreas(array_column($need_project, 'project_id'));
//特殊日期 降访问率
foreach ($need_project as $project_key => $project){
if(empty($ips[$project_key]['ip'])){
Log::channel('traffic')->info('未获取到ip project_id:' . $project['project_id']);
unset($need_project[$project_key]);
continue;
}
$diff = $ips[$project_key]['diff'];
//当地时间
$w = date('w', strtotime($diff . 'hour'));
$date = date('m-d', strtotime($diff . 'hour'));
//元旦节和圣诞节按照周六的比例处理
if(in_array($date, ['01-01', '12-25'])){
$w = 6;
}
//周五流量不变 周六周日下降20-30% 元旦圣诞下降30-50%
switch ($w){
case 0:
//周日降70-80%
$rate = rand(70, 80) * 10;
$res = $this->get_rand([1000-$rate, $rate]);
break;
case 5:
//周5降30-40%
$rate = rand(30, 40) * 10;
$res = $this->get_rand([1000-$rate, $rate]);
break;
case 6:
//周6降60-70%
$rate = rand(60, 70) * 10;
//周日降20-30%
$rate = rand(20, 30) * 10;
$res = $this->get_rand([1000-$rate, $rate]);
break;
default:
//元旦圣诞下降30-50%
if(in_array($date, ['01-01', '12-25'])){
$rate = rand(30, 50) * 10;
$res = $this->get_rand([1000-$rate, $rate]);
break;
}
$res = 0;
}
//不访问
... ... @@ -265,7 +266,7 @@ class WebTraffic extends Command
$page++;
}
}catch (\Exception $e){
Log::channel('traffic')->error($e->getMessage());
Log::channel('traffic')->error("line" . $e->getLine() . ',error:' . $e->getMessage(), $e->getTrace());
}
}
... ... @@ -298,22 +299,22 @@ class WebTraffic extends Command
->where('gl_project.is_upgrade', 0) //非升级项目
->where('gl_project.main_lang_id', '<>', $ru_lang_id) //非俄语站
->where(function ($query) use ($type) {
if($type == 1){
//1-3个月项目
$startTime = Carbon::now()->addMonths(-4)->toDateString();
$endTime = Carbon::now()->addMonths(-1)->toDateString();
$query->whereBetween('pdo.start_date', [$startTime,$endTime]);
}elseif($type == 2){
//4-8个月项目
$startTime = Carbon::now()->addMonths(-9)->startOfDay()->toDateTimeString();
$endTime = Carbon::now()->addMonths(-4)->endOfDay()->toDateTimeString();
$query->whereBetween('pdo.start_date', [$startTime,$endTime]);
}else{
//大于9个月项目
$startTime = Carbon::now()->addMonths(-9)->startOfDay()->toDateTimeString();
$query->where('pdo.start_date', '<', $startTime);
}
})->select(['pdo.project_id','gl_project.main_lang_id','gl_project.id'])->forPage($page, 500)->get();
if($type == 1){
//1-3个月项目
$startTime = Carbon::now()->addMonths(-4)->toDateString();
$endTime = Carbon::now()->addMonths(-1)->toDateString();
$query->whereBetween('pdo.start_date', [$startTime,$endTime]);
}elseif($type == 2){
//4-8个月项目
$startTime = Carbon::now()->addMonths(-9)->startOfDay()->toDateTimeString();
$endTime = Carbon::now()->addMonths(-4)->endOfDay()->toDateTimeString();
$query->whereBetween('pdo.start_date', [$startTime,$endTime]);
}else{
//大于9个月项目
$startTime = Carbon::now()->addMonths(-9)->startOfDay()->toDateTimeString();
$query->where('pdo.start_date', '<', $startTime);
}
})->select(['pdo.project_id','gl_project.main_lang_id','gl_project.id'])->forPage($page, 500)->get();
//其他地方在引流的域名
$other = DB::connection('projects_mysql')->table('projects')->where('switch', 1)->pluck('domain')->toArray();
$data = [];
... ... @@ -368,7 +369,7 @@ class WebTraffic extends Command
/**
* 获取地区IP
*/
protected function getIpAreas($num)
protected function getIpAreas($project_ids)
{
//本地时间为7-23点的地区
$h = date('H');
... ... @@ -386,11 +387,26 @@ class WebTraffic extends Command
$time_zones[$v['name']] = $v['diff'];
}
}
//根据地区随机取该地区的IP
$data = DB::table('gl_xunpan_ipdata')->whereIn('ip_area', $areas)->inRandomOrder()->limit($num)->get();
$data = Arr::s2a(Arr::a2s($data));
foreach ($data as &$item){
$item['diff'] = $time_zones[$item['ip_area']];
$data = [];
foreach ($project_ids as $project_id){
//引流配置
$config = WebTrafficConfig::getCacheInfoByProjectId($project_id);
$main_countries = !empty($config->main_countries) ? explode(',',$config->main_countries) : [];
$filter_countries = !empty($config->filter_countries) ? explode(',',$config->filter_countries) : [];
//根据地区随机取该地区的IP
$ipdata = DB::table('gl_xunpan_ipdata')->whereIn('ip_area', $areas)
->where(function ($query) use ($main_countries, $filter_countries){
if($main_countries){
$query->whereIn('ip_area', $main_countries);
}
if($filter_countries){
$query->whereNotIn('ip_area', $main_countries);
}
})->inRandomOrder()->first();
$ipdata = (array)$ipdata ?: [];
$ipdata['diff'] = $time_zones[$ipdata['ip_area']];
$data[] = $ipdata;
}
return $data;
}
... ... @@ -457,6 +473,9 @@ class WebTraffic extends Command
$v = $project_urls['home'] . $v;
}
}
Log::channel('traffic')->info('project_id:访问深度' . $res_sdzb, $url);
return array_unique(array_filter($url));
}
... ...
... ... @@ -7,6 +7,7 @@ use App\Models\Product\Category;
use App\Models\Product\Product;
use App\Models\Project\OnlineCheck;
use App\Models\Project\Project;
use App\Models\Project\WebTrafficConfig;
use App\Models\Template\BCustomTemplate;
use App\Models\WebSetting\WebLanguage;
use App\Services\ProjectServer;
... ... @@ -229,35 +230,34 @@ class WebTrafficRussia extends Command
$need_project[] = $project;
}
//随机访问ip
$ips = $this->getIpAreas(count($need_project));
$ips = $this->getIpAreas(array_column($need_project, 'project_id'));
//特殊日期 降访问率
foreach ($need_project as $project_key => $project){
if(empty($ips[$project_key]['ip'])){
Log::channel('traffic')->info('未获取到ip project_id:' . $project['project_id']);
unset($need_project[$project_key]);
continue;
}
$diff = $ips[$project_key]['diff'];
//当地时间
$w = date('w', strtotime($diff . 'hour'));
$date = date('m-d', strtotime($diff . 'hour'));
//元旦节和圣诞节按照周六的比例处理
if(in_array($date, ['01-01', '12-25'])){
$w = 6;
}
//周五流量不变 周六周日下降20-30% 元旦圣诞下降30-50%
switch ($w){
case 0:
//周日降70-80%
$rate = rand(70, 80) * 10;
$res = $this->get_rand([1000-$rate, $rate]);
break;
case 5:
//周5降30-40%
$rate = rand(30, 40) * 10;
$res = $this->get_rand([1000-$rate, $rate]);
break;
case 6:
//周6降60-70%
$rate = rand(60, 70) * 10;
//周日降20-30%
$rate = rand(20, 30) * 10;
$res = $this->get_rand([1000-$rate, $rate]);
break;
default:
//元旦圣诞下降30-50%
if(in_array($date, ['01-01', '12-25'])){
$rate = rand(30, 50) * 10;
$res = $this->get_rand([1000-$rate, $rate]);
break;
}
$res = 0;
}
//不访问
... ... @@ -301,7 +301,7 @@ class WebTrafficRussia extends Command
$page++;
}
}catch (\Exception $e){
Log::channel('traffic')->error("ru:line" . $e->getLine() . ',error:' . $e->getMessage());
Log::channel('traffic')->error("ru:line" . $e->getLine() . ',error:' . $e->getMessage(), $e->getTrace());
}
}
... ... @@ -404,7 +404,7 @@ class WebTrafficRussia extends Command
/**
* 获取地区IP
*/
protected function getIpAreas($num)
protected function getIpAreas($project_ids)
{
//本地时间为7-23点的地区
$h = date('H');
... ... @@ -431,11 +431,31 @@ class WebTrafficRussia extends Command
}
$data = [];
for ($i=0;$i<$num;$i++){
//ip国家占比
$ip_area = $this->get_rand($country_ratio);
foreach ($project_ids as $project_id) {
$project_country = $country_ratio;
//引流配置
$config = WebTrafficConfig::getCacheInfoByProjectId($project_id);
$main_countries = !empty($config->main_countries) ? explode(',',$config->main_countries) : [];
$filter_countries = !empty($config->filter_countries) ? explode(',',$config->filter_countries) : [];
//设置了主推的
if($main_countries){
foreach ($project_country as $k => $v){
if(!in_array($k, $main_countries)){
unset($project_country[$k]);
}
}
}
//设置了不推广
if($filter_countries){
foreach ($project_country as $k => $v){
if(in_array($k, $filter_countries)){
unset($project_country[$k]);
}
}
}
$ip_area = $this->get_rand($project_country);
$res = DB::table('gl_xunpan_ipdata')->where('ip_area', $ip_area)->inRandomOrder()->first();
$res = (array)$res;
$res = (array)$res ?: [];
$res['diff'] = $time_zones[$res['ip_area']];
$data[] = $res;
}
... ... @@ -504,6 +524,9 @@ class WebTrafficRussia extends Command
$v = $project_urls['home'] . $v;
}
}
Log::channel('traffic')->info('project_id:访问深度' . $res_sdzb, $url);
return array_unique(array_filter($url));
}
... ...
... ... @@ -7,6 +7,7 @@ use App\Models\Product\Category;
use App\Models\Product\Product;
use App\Models\Project\OnlineCheck;
use App\Models\Project\Project;
use App\Models\Project\WebTrafficConfig;
use App\Models\Template\BCustomTemplate;
use App\Models\WebSetting\WebLanguage;
use App\Services\ProjectServer;
... ... @@ -52,9 +53,6 @@ class WebTrafficRussiaSpecial extends Command
parent::__construct();
}
protected $projects = [
969 => 60,
];
/**
* 国家概率
... ... @@ -232,35 +230,34 @@ class WebTrafficRussiaSpecial extends Command
$need_project[] = $project;
}
//随机访问ip
$ips = $this->getIpAreas(count($need_project));
$ips = $this->getIpAreas(array_column($need_project, 'project_id'));
//特殊日期 降访问率
foreach ($need_project as $project_key => $project){
if(empty($ips[$project_key]['ip'])){
Log::channel('traffic')->info('未获取到ip project_id:' . $project['project_id']);
unset($need_project[$project_key]);
continue;
}
$diff = $ips[$project_key]['diff'];
//当地时间
$w = date('w', strtotime($diff . 'hour'));
$date = date('m-d', strtotime($diff . 'hour'));
//元旦节和圣诞节按照周六的比例处理
if(in_array($date, ['01-01', '12-25'])){
$w = 6;
}
//周五流量不变 周六周日下降20-30% 元旦圣诞下降30-50%
switch ($w){
case 0:
//周日降70-80%
$rate = rand(70, 80) * 10;
$res = $this->get_rand([1000-$rate, $rate]);
break;
case 5:
//周5降30-40%
$rate = rand(30, 40) * 10;
$res = $this->get_rand([1000-$rate, $rate]);
break;
case 6:
//周6降60-70%
$rate = rand(60, 70) * 10;
//周日降20-30%
$rate = rand(20, 30) * 10;
$res = $this->get_rand([1000-$rate, $rate]);
break;
default:
//元旦圣诞下降30-50%
if(in_array($date, ['01-01', '12-25'])){
$rate = rand(30, 50) * 10;
$res = $this->get_rand([1000-$rate, $rate]);
break;
}
$res = 0;
}
//不访问
... ... @@ -304,7 +301,7 @@ class WebTrafficRussiaSpecial extends Command
$page++;
}
}catch (\Exception $e){
Log::channel('traffic')->error("ru:line" . $e->getLine() . ',error:' . $e->getMessage());
Log::channel('traffic')->error("ru special:line" . $e->getLine() . ',error:' . $e->getMessage(), $e->getTrace());
}
}
... ... @@ -319,6 +316,9 @@ class WebTrafficRussiaSpecial extends Command
* 俄语站引流的项目
*/
protected function getProjectList($page){
//设置了特殊引流的项目
$projects = WebTrafficConfig::where('add_num', '>', 0)->pluck('add_num', 'project_id')->toArray();
$ru_lang_id = WebLanguage::getIdByLang('ru');
//推广项目
... ... @@ -330,7 +330,7 @@ class WebTrafficRussiaSpecial extends Command
->whereIn('gl_project.type', [Project::TYPE_TWO, Project::TYPE_FOUR])
->where('gl_project.is_upgrade', 0) //非升级项目
->where('gl_project.main_lang_id', $ru_lang_id)// 俄语站
->whereIn('gl_project.id', array_keys($this->projects))
->whereIn('gl_project.id', array_keys($projects))
->select(['pdo.project_id','gl_project.main_lang_id','gl_project.id'])->forPage($page, 500)->get();
//其他地方在引流的域名
// $other = DB::connection('projects_mysql')->table('projects')->where('switch', 1)->pluck('domain')->toArray();
... ... @@ -342,7 +342,7 @@ class WebTrafficRussiaSpecial extends Command
if(Cache::get('web_traffic_russia_special_' . $project['project_id'])){
continue;
}else{
$ttl = 24 * 60 * 60 / $this->projects[$project['project_id']];
$ttl = 24 * 60 * 60 / ($projects[$project['project_id']] / ($this->sjjg[0] / ($this->sjjg[0] + $this->sjjg[1])));
Cache::put('web_traffic_russia_special_' . $project['project_id'], 1, $ttl);
}
... ... @@ -396,7 +396,7 @@ class WebTrafficRussiaSpecial extends Command
/**
* 获取地区IP
*/
protected function getIpAreas($num)
protected function getIpAreas($project_ids)
{
//本地时间为7-23点的地区
$h = date('H');
... ... @@ -423,11 +423,31 @@ class WebTrafficRussiaSpecial extends Command
}
$data = [];
for ($i=0;$i<$num;$i++){
//ip国家占比
$ip_area = $this->get_rand($country_ratio);
foreach ($project_ids as $project_id) {
$project_country = $country_ratio;
//引流配置
$config = WebTrafficConfig::getCacheInfoByProjectId($project_id);
$main_countries = !empty($config->main_countries) ? explode(',',$config->main_countries) : [];
$filter_countries = !empty($config->filter_countries) ? explode(',',$config->filter_countries) : [];
//设置了主推的
if($main_countries){
foreach ($project_country as $k => $v){
if(!in_array($k, $main_countries)){
unset($project_country[$k]);
}
}
}
//设置了不推广
if($filter_countries){
foreach ($project_country as $k => $v){
if(in_array($k, $filter_countries)){
unset($project_country[$k]);
}
}
}
$ip_area = $this->get_rand($project_country);
$res = DB::table('gl_xunpan_ipdata')->where('ip_area', $ip_area)->inRandomOrder()->first();
$res = (array)$res;
$res = (array)$res ?: [];
$res['diff'] = $time_zones[$res['ip_area']];
$data[] = $res;
}
... ... @@ -496,6 +516,9 @@ class WebTrafficRussiaSpecial extends Command
$v = $project_urls['home'] . $v;
}
}
Log::channel('traffic')->info('project_id:访问深度' . $res_sdzb, $url);
return array_unique(array_filter($url));
}
... ...
... ... @@ -7,6 +7,7 @@ use App\Models\Product\Category;
use App\Models\Product\Product;
use App\Models\Project\OnlineCheck;
use App\Models\Project\Project;
use App\Models\Project\WebTrafficConfig;
use App\Models\Template\BCustomTemplate;
use App\Models\WebSetting\WebLanguage;
use App\Services\ProjectServer;
... ... @@ -53,20 +54,6 @@ class WebTrafficSpecial extends Command
parent::__construct();
}
/**
* 要增加引流的项目及腰增加的数量
* key 要引流的ID
* value 每天要增加的流量
* @var array
*/
protected $projects = [
509 => 30,
79 => 20,
];
/**
* google域名后缀
* @var string[]
... ... @@ -207,35 +194,34 @@ class WebTrafficSpecial extends Command
$need_project[] = $project;
}
//随机访问ip
$ips = $this->getIpAreas(count($need_project));
$ips = $this->getIpAreas(array_column($need_project, 'project_id'));
//特殊日期 降访问率
foreach ($need_project as $project_key => $project){
if(empty($ips[$project_key]['ip'])){
Log::channel('traffic')->info('未获取到ip project_id:' . $project['project_id']);
unset($need_project[$project_key]);
continue;
}
$diff = $ips[$project_key]['diff'];
//当地时间
$w = date('w', strtotime($diff . 'hour'));
$date = date('m-d', strtotime($diff . 'hour'));
//元旦节和圣诞节按照周六的比例处理
if(in_array($date, ['01-01', '12-25'])){
$w = 6;
}
//周五流量不变 周六周日下降20-30% 元旦圣诞下降30-50%
switch ($w){
case 0:
//周日降70-80%
$rate = rand(70, 80) * 10;
$res = $this->get_rand([1000-$rate, $rate]);
break;
case 5:
//周5降30-40%
$rate = rand(30, 40) * 10;
$res = $this->get_rand([1000-$rate, $rate]);
break;
case 6:
//周6降60-70%
$rate = rand(60, 70) * 10;
//周日降20-30%
$rate = rand(20, 30) * 10;
$res = $this->get_rand([1000-$rate, $rate]);
break;
default:
//元旦圣诞下降30-50%
if(in_array($date, ['01-01', '12-25'])){
$rate = rand(30, 50) * 10;
$res = $this->get_rand([1000-$rate, $rate]);
break;
}
$res = 0;
}
//不访问
... ... @@ -279,7 +265,7 @@ class WebTrafficSpecial extends Command
$page++;
}
}catch (\Exception $e){
Log::channel('traffic')->error($e->getMessage());
Log::channel('traffic')->error("special line" . $e->getLine() . ',error:' . $e->getMessage(), $e->getTrace());
}
}
... ... @@ -294,6 +280,9 @@ class WebTrafficSpecial extends Command
* 非俄语站的引流的项目
*/
protected function getProjectList($page){
//设置了特殊引流的项目
$projects = WebTrafficConfig::where('add_num', '>', 0)->pluck('add_num', 'project_id')->toArray();
$ru_lang_id = WebLanguage::getIdByLang('ru');
//推广项目
... ... @@ -305,7 +294,7 @@ class WebTrafficSpecial extends Command
->whereIn('gl_project.type', [Project::TYPE_TWO, Project::TYPE_FOUR])
->where('gl_project.is_upgrade', 0) //非升级项目
->where('gl_project.main_lang_id', '<>', $ru_lang_id) //非俄语站
->whereIn('gl_project.id', array_keys($this->projects))
->whereIn('gl_project.id', array_keys($projects))
->select(['pdo.project_id','gl_project.main_lang_id','gl_project.id'])->forPage($page, 500)->get();
//其他地方在引流的域名
// $other = DB::connection('projects_mysql')->table('projects')->where('switch', 1)->pluck('domain')->toArray();
... ... @@ -317,7 +306,7 @@ class WebTrafficSpecial extends Command
if(Cache::get('traffic_special_' . $project['project_id'])){
continue;
}else{
$ttl = 24 * 60 * 60 / $this->projects[$project['project_id']];
$ttl = 24 * 60 * 60 / ($projects[$project['project_id']] / ($this->sjjg[0] / ($this->sjjg[0] + $this->sjjg[1])));
Cache::put('traffic_special_' . $project['project_id'], 1, $ttl);
}
... ... @@ -371,7 +360,7 @@ class WebTrafficSpecial extends Command
/**
* 获取地区IP
*/
protected function getIpAreas($num)
protected function getIpAreas($project_ids)
{
//本地时间为7-23点的地区
$h = date('H');
... ... @@ -389,11 +378,26 @@ class WebTrafficSpecial extends Command
$time_zones[$v['name']] = $v['diff'];
}
}
//根据地区随机取该地区的IP
$data = DB::table('gl_xunpan_ipdata')->whereIn('ip_area', $areas)->inRandomOrder()->limit($num)->get();
$data = Arr::s2a(Arr::a2s($data));
foreach ($data as &$item){
$item['diff'] = $time_zones[$item['ip_area']];
$data = [];
foreach ($project_ids as $project_id){
//引流配置
$config = WebTrafficConfig::getCacheInfoByProjectId($project_id);
$main_countries = !empty($config->main_countries) ? explode(',',$config->main_countries) : [];
$filter_countries = !empty($config->filter_countries) ? explode(',',$config->filter_countries) : [];
//根据地区随机取该地区的IP
$ipdata = DB::table('gl_xunpan_ipdata')->whereIn('ip_area', $areas)
->where(function ($query) use ($main_countries, $filter_countries){
if($main_countries){
$query->whereIn('ip_area', $main_countries);
}
if($filter_countries){
$query->whereNotIn('ip_area', $main_countries);
}
})->inRandomOrder()->first();
$ipdata = (array)$ipdata ?: [];
$ipdata['diff'] = $time_zones[$ipdata['ip_area']];
$data[] = $ipdata;
}
return $data;
}
... ... @@ -460,6 +464,9 @@ class WebTrafficSpecial extends Command
$v = $project_urls['home'] . $v;
}
}
Log::channel('traffic')->info('project_id:访问深度' . $res_sdzb, $url);
return array_unique(array_filter($url));
}
... ...
... ... @@ -28,7 +28,7 @@ class DomainInfoController extends BaseController
{
$domainModel = new DomainInfo();
if(isset($this->map['domain']) && !empty($this->map['domain'])){
$this->map['domain'] = ['like','%'.$this->map['domain'],'%'];
$this->map['domain'] = ['like','%'.$this->map['domain'].'%'];
}
$lists = $domainModel->lists($this->map,$this->page,$this->row,$this->order);
if(!empty($lists)){
... ...
... ... @@ -34,7 +34,7 @@ class NewsController extends BaseController
$lists = $query->select($filed)->paginate($this->row, ['*'], 'page', $this->page);
if(!empty($lists)){
$lists = $lists->toArray();
// //获取当前项目的所有分类
//获取当前项目的所有分类
$data = $this->getCategoryList();
//获取当前用户选择的模版
$template_id = $this->getTemplateId(BTemplate::SOURCE_NEWS,BTemplate::IS_DETAIL);//获取模版id
... ...
... ... @@ -433,8 +433,8 @@ class ProductController extends BaseController
* @time :2023/7/29 14:59
*/
public function copyProduct(ProductLogic $logic){
$rs = $logic->setCopyProduct();
$this->response('success',Code::SUCCESS,$rs);
$data = $logic->setCopyProduct();
$this->response('success',Code::SUCCESS,$data);
}
/**
... ...
... ... @@ -227,7 +227,8 @@ class ProjectLogic extends BaseLogic
$param['is_visualization'] = json_encode($param['is_visualization']);
}
}
$param['upload_config'] = json_encode($param['upload_config'] ?? []);
$param['web_traffic_config'] = json_encode($param['web_traffic_config'] ?? []);
$this->model->edit($param,['id'=>$param['id']]);
Common::del_user_cache($this->model->getTable(),$param['id']);
return $this->success();
... ...
... ... @@ -123,30 +123,43 @@ class BTemplateLogLogic extends BaseLogic
$this->fail('当前数据不存在,或已被删除');
}
if($this->user['is_customized'] != BTemplate::IS_VISUALIZATION){
if(empty($info['other'])){
$footer_other = str_replace('<header','',characterTruncation($info['text'],'/<style id="globalsojs-footer">(.*?)<header/s'));
$info['other'] = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', '', $footer_other);
}
$html = $info['head_css'].$info['main_css'].$info['footer_css'].$info['other'].
$info['head_html'].$info['main_html'].$info['footer_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'];
}
}
$html = $this->getTemplateHtml($info);
}else{
$page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面
if (in_array(1, $page_array)) {//首页是定制界面
$html = $info['text'];
}else{
$html = $this->getTemplateHtml($info);
}
}
return $this->success(['html'=>$html]);
}
/**
* @remark :生成界面
* @name :getTemplateHtml
* @author :lyh
* @method :post
* @time :2024/4/3 17:11
*/
public function getTemplateHtml($info){
if(empty($info['other'])){
$footer_other = str_replace('<header','',characterTruncation($info['text'],'/<style id="globalsojs-footer">(.*?)<header/s'));
$info['other'] = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', '', $footer_other);
}
$html = $info['head_css'].$info['main_css'].$info['footer_css'].$info['other'].
$info['head_html'].$info['main_html'].$info['footer_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 $this->success($html);
}
}
... ...
... ... @@ -50,7 +50,7 @@ class BlogLogic extends BaseLogic
DB::commit();
}catch (\Exception $e){
DB::rollBack();
$this->fail('error');
$this->fail('系统错误,请联系管理员');
}
$this->addUpdateNotify(RouteMap::SOURCE_BLOG,$route);
$this->curlDelRoute(['new_route'=>$route]);
... ... @@ -137,8 +137,13 @@ class BlogLogic extends BaseLogic
DB::beginTransaction();
try {
foreach ($this->param['id'] as $id){
$this->delRoute($id);
$this->model->del(['id'=>$id]);
$info = $this->model->read(['id'=>$id],['id','status']);
if($info['status'] != 2){
$this->model->edit(['status'=>2],['id'=>$id]);
}else{
$this->delRoute($id);
$this->model->del(['id' => $id]);
}
}
DB::commit();
}catch (Exception $e){
... ...
... ... @@ -5,6 +5,7 @@ namespace App\Http\Logic\Bside\HomeCount;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\RouteMap\RouteMap;
use App\Models\Template\BCustomTemplate;
use App\Models\Visit\Visit;
use App\Models\Visit\VisitItem;
use App\Models\HomeCount\Count;
... ... @@ -117,7 +118,7 @@ class CountLogic extends BaseLogic
public function with_data_count(){
$product_count = (new Product())->where(['project_id' => $this->user['project_id']])->count();
$news_count = (new News())->where(['project_id' => $this->user['project_id']])->count();
$page_count = (new RouteMap())->where(['project_id' => $this->user['project_id']])->count();
$page_count = (new BCustomTemplate())->where(['project_id' => $this->user['project_id'],'status'=>1])->count();
$data = [
'product_count' => $product_count,
'news_count' => $news_count,
... ...
... ... @@ -167,8 +167,13 @@ class NewsLogic extends BaseLogic
DB::beginTransaction();
try {
foreach ($this->param['id'] as $id) {
$this->delRoute($id);
$this->model->del(['id' => $id]);
$info = $this->model->read(['id'=>$id],['id','status']);
if($info['status'] != 2){
$this->model->edit(['status'=>2],['id'=>$id]);
}else{
$this->delRoute($id);
$this->model->del(['id' => $id]);
}
}
DB::commit();
} catch (Exception $e) {
... ...
... ... @@ -47,7 +47,6 @@ class ProductLogic extends BaseLogic
$this->param = $this->handleSaveParam($this->param);
try {
if(isset($this->param['id']) && !empty($this->param['id'])){
$is_upgrade = $this->param['is_upgrade'] ?? 0;//1:5.0数据 0:6.0
$six_read = $this->param['six_read'] ?? 0;//是否按6.0显示
if($is_upgrade == 0 || $six_read == 1){
... ... @@ -442,7 +441,7 @@ class ProductLogic extends BaseLogic
$this->model->edit(['route'=>$route],['id'=>$save_id]);
//同步可视化装修数据
$this->copyTemplate($this->param['id'],$info['project_id'],$save_id);
return $this->success();
return $this->success(['id'=>$save_id]);
}
/**
... ...
... ... @@ -81,8 +81,6 @@ class RatingLogic extends BaseLogic
$str = trim($str,'&');
$url = "http://www.quanqiusou.cn/extend_api/api/service_score.php?postid=$postId&token=$token&ftype=$fType&$str";
$rs = http_get($url,['charset=utf-8']);
@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);
return $rs;
}
}
... ...
... ... @@ -4,6 +4,7 @@ namespace App\Models\Inquiry;
use App\Helper\FormGlobalsoApi;
use App\Models\Base;
use App\Utils\LogUtils;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Facades\DB;
... ... @@ -83,7 +84,10 @@ class InquiryFormData extends Base
$data['message'].= "<br/>" . $k .': ' . $v;
}
}
!$has_file && (new FormGlobalsoApi())->submitInquiry($ip, $referer, $submit_at, $data);
if(!$has_file) {
$res = (new FormGlobalsoApi())->submitInquiry($ip, $referer, $submit_at, $data);
LogUtils::info('询盘提交', $data, $res?: []);
}
}
return true;
}
... ...
... ... @@ -19,11 +19,6 @@ class Project extends Base
public static $projectLocationDangerous = 1; //危险项目
public static $storageTypeZero = 0; //默认腾讯压缩存储桶
public static $storageTypeOne = 1; //非压缩存储桶
public static $storageTypeZeroFileFix = "ecdn6.globalso.com"; //非压缩存储桶
public static $storageTypeOneFileFix = "ecdn6-nc.globalso.com"; //压缩存储桶
public static $projectLocationDangerousFileFix = "globalso-v6.s3.us-west-2.amazonaws.com"; //危险项目存储桶
//项目标识集合
public static $blockItems = "blockitems"; //html循环项父级标识
public static $blockAttrItems = "[blockitems]"; //html循环项父级属性标识
... ... @@ -335,6 +330,14 @@ class Project extends Base
return $value;
}
public function getWebTrafficConfigAttribute($value)
{
if($value){
$value = Arr::s2a($value);
}
return $value;
}
/**
* 根据域名获取项目信息
* @author zbj
... ...
... ... @@ -56,7 +56,7 @@ class RouteMap extends Base
if(preg_match('/[\x{4e00}-\x{9fa5}]/u', $title)){
$title = Translate::tran($title, 'en');
}else{
if(!preg_match('/^[a-zA-Z\s]+$/', $title)){
if(!preg_match('/[a-zA-Z]/', $title)){
$title = Translate::tran($title, 'en');
}
}
... ...
... ... @@ -872,19 +872,21 @@ class CreatePageService{
{
$projectLocation = $project->project_location;
$storageType = $project->storage_type;
$cos = config('filesystems.disks.cos');
if ($projectLocation == Project::$projectLocationZero){
//普通项目
if ($storageType == Project::$storageTypeZero){
//压缩项目
$html = str_replace(Project::$storageTypeOneFileFix,Project::$storageTypeZeroFileFix,$html);
$html = str_replace($cos['cdn1'],$cos['cdn'],$html);
}else{
//非压缩项目
$html = str_replace(Project::$storageTypeZeroFileFix,Project::$storageTypeOneFileFix,$html);
$html = str_replace($cos['cdn'],$cos['cdn1'],$html);
}
}else{
$s3 = config('filesystems.disks.s3');
//危险项目
$html = str_replace(Project::$storageTypeOneFileFix,Project::$projectLocationDangerousFileFix,$html);
$html = str_replace(Project::$storageTypeZeroFileFix,Project::$projectLocationDangerousFileFix,$html);
$html = str_replace($cos['cdn1'],$s3['cdn'],$html);
$html = str_replace($cos['cdn'],$s3['cdn'],$html);
}
return $html;
}
... ...
... ... @@ -69,7 +69,8 @@ class SyncSubmitTaskService
];
if(Str::contains($referer, $url)){
$referer = pathinfo($referer,PATHINFO_DIRNAME);
$referer = parse_url($referer);
$referer = !empty($referer['host']) ? $referer['scheme'] . '://' . $referer['host'] . '/' : $referer['path'];
}
return $referer;
}
... ...