作者 刘锟

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

正在显示 44 个修改的文件 包含 493 行增加82 行删除
... ... @@ -42,7 +42,7 @@ class Count extends Command
public function handle()
{
$list = DB::table('gl_project')->where('gl_project.extend_type','=',0)
->where('gl_project.type','!=',0)->where('gl_project.delete_status',0)
->where('gl_project.type','!=',0)
->leftJoin('gl_project_deploy_build', 'gl_project.id', '=', 'gl_project_deploy_build.project_id')
->leftJoin('gl_project_deploy_optimize', 'gl_project.id', '=', 'gl_project_deploy_optimize.project_id')
->select($this->selectParam())->get();
... ...
... ... @@ -33,7 +33,7 @@ class UpgradeProjectCount extends Command
protected $description = '升级项目统计';
public function handle(){
$project_id = 769;
$project_id = 528;
ProjectServer::useProject($project_id);
$this->count($project_id);
DB::disconnect('custom_mysql');
... ...
... ... @@ -38,7 +38,7 @@ class InquiryMonthlyCount extends Command
*/
public function handle(){
$list = DB::table('gl_project')->where('gl_project.extend_type','=',0)
->where('gl_project.type','!=',0)->where('gl_project.delete_status',0)
->where('gl_project.type','!=',0)
->leftJoin('gl_project_deploy_build', 'gl_project.id', '=', 'gl_project_deploy_build.project_id')
->leftJoin('gl_project_deploy_optimize', 'gl_project.id', '=', 'gl_project_deploy_optimize.project_id')
->select($this->selectParam())->get()->toArray();
... ...
... ... @@ -36,7 +36,7 @@ class UpgradeProjectCount extends Command
protected $description = '升级项目统计';
public function handle(){
$project_id = 769;
$project_id = 528;
$oldModel = new UpdateOldInfo();
$info = $oldModel->read(['project_id'=>$project_id]);
$url = $info['old_domain_online'];
... ...
... ... @@ -40,7 +40,7 @@ class RecommDomain extends BaseCommands
foreach ($list as $item) {
$rankDataLogic = new RankDataLogic();
$rankDataLogic->syncExternalLinks($item['api_no']);
$rankDataLogic->syncRecommDomain($item['api_no']);
}
return true;
}
... ...
<?php
/**
* @remark :
* @name :ServiceCount.php
* @author :lyh
* @method :post
* @time :2024/1/29 15:29
*/
namespace App\Console\Commands;
use App\Models\Devops\ServerConfig;
use App\Models\Project\Project;
use Illuminate\Console\Command;
class ServiceCount extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'service_count';
/**
* The console command description.
*
* @var string
*/
protected $description = '服务器数据库使用统计';
/**
* @remark :执行脚本
* @name :handle
* @author :lyh
* @method :post
* @time :2024/1/29 15:31
*/
public function handle(){
return $this->serverConfigCount();
}
/**
* @remark :域名统计统计
* @name :domainCount
* @author :lyh
* @method :post
* @time :2024/1/29 15:33
*/
public function serverConfigCount(){
$model = new ServerConfig();
$list = $model->list();
$projectModel = new Project();
foreach ($list as $v){
if($v['type'] == 1){
$count = $projectModel->formatQuery(['serve_id'=>$v['id']])->count();
//服务器
}else{
$count = $projectModel->formatQuery(['mysql_id'=>$v['id']])->count();
//数据库
}
$model->edit(['count'=>$count],['id'=>$v['id']]);
}
}
}
... ...
... ... @@ -50,7 +50,7 @@ class UpdateProductCategory extends Command
public function handle(){
//获取所有项目
$projectModel = new Project();
$list = $projectModel->list(['id'=>['in',[218]]],'id',['id']);
$list = $projectModel->list(['id'=>['in',[302]]],'id',['id']);
echo date('Y-m-d H:i:s') . ' start: ' . json_encode($list) . PHP_EOL;
try {
foreach ($list as $v) {
... ...
... ... @@ -55,19 +55,12 @@ class UpdateRoute extends Command
*/
public function handle(){
$projectModel = new Project();
$list = $projectModel->list(['id'=>206]);
$list = $projectModel->list(['is_upgrade'=>0,'delete_status'=>0,'id'=>['<',500]]);
$data = [];
foreach ($list as $v){
echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
ProjectServer::useProject($v['id']);
// $this->delProductKeyword();
// $this->checkProduct($data,$v['id']);
// $this->getProduct();
$this->setProductKeyword();
// $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;
... ... @@ -128,13 +121,12 @@ class UpdateRoute extends Command
// $keywordModel->edit(['route'=>$route],['id'=>$v['id']]);
// }
}else{
echo date('Y-m-d H:i:s') . 'id :'.$v['id'] . PHP_EOL;
$route = Translate::tran($v['title'], 'en');
echo date('Y-m-d H:i:s') . 'route :'.$route . PHP_EOL;
$route = RouteMap::setRoute($route, RouteMap::SOURCE_PRODUCT_KEYWORD, $v['id'], $v['project_id']);
$keywordModel->edit(['route'=>$route],['id'=>$v['id']]);
}
echo date('Y-m-d H:i:s') . 'end :' . PHP_EOL;
// echo date('Y-m-d H:i:s') . 'end :' . PHP_EOL;
}
}
}
... ...
... ... @@ -178,6 +178,43 @@ class WebTraffic extends Command
}
//随机访问ip
$ips = $this->getIpAreas(count($need_project));
//特殊日期 降访问率
foreach ($need_project as $project_key => $project){
$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;
}
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;
$res = $this->get_rand([1000-$rate, $rate]);
break;
default:
$res = 0;
}
//不访问
if($res == 1){
unset($need_project[$project_key]);
unset($ips[$project_key]);
}
}
//最多10层深度
$client = new Client(['verify' => false]);
for ($j = 0; $j < 10; $j++) {
... ... @@ -314,6 +351,7 @@ class WebTraffic extends Command
$h = date('H');
$areas = [];
$list = DB::table('gl_area_timezone')->get();
$time_zones = [];
foreach ($list as $v) {
$v = (array)$v;
$country_hour = $h + $v['diff'];
... ... @@ -322,11 +360,16 @@ class WebTraffic extends Command
}
if ($country_hour >= 7 && $country_hour < 23) {
$areas[] = $v['name'];
$time_zones[$v['name']] = $v['diff'];
}
}
//根据地区随机取该地区的IP
$data = DB::table('gl_xunpan_ipdata')->whereIn('ip_area', $areas)->inRandomOrder()->limit($num)->get();
return Arr::s2a(Arr::a2s($data));
$data = Arr::s2a(Arr::a2s($data));
foreach ($data as &$item){
$item['diff'] = $time_zones[$item['ip_area']];
}
return $data;
}
/**
... ...
... ... @@ -26,6 +26,7 @@ class Kernel extends ConsoleKernel
$schedule->command('rank_data_week')->dailyAt('01:00')->withoutOverlapping(1); // 排名数据,每周一凌晨执行一次
// $schedule->command('share_user')->dailyAt('01:00')->withoutOverlapping(1); // 清除用户ayr_share数据,每天凌晨1点执行一次
$schedule->command('count')->dailyAt('01:00')->withoutOverlapping(1); //每天凌晨1点执行一次
$schedule->command('service_count')->dailyAt('01:00')->withoutOverlapping(1); //服务器使用情况,每天凌晨1点执行一次
$schedule->command('web_traffic 1')->everyThirtyMinutes(); // 引流 1-3个月的项目,半小时一次
$schedule->command('web_traffic 2')->cron('*/18 * * * *'); // 引流 4-8个月的项目,18分钟一次
$schedule->command('web_traffic 3')->cron('*/12 * * * *'); // 引流 大于9个月的项目,12分钟一次
... ...
... ... @@ -100,12 +100,17 @@ if (!function_exists('http_get')) {
curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch1, CURLOPT_ENCODING, '');
curl_setopt($ch1, CURLOPT_MAXREDIRS, 10);
curl_setopt($ch1, CURLOPT_TIMEOUT, 120);
curl_setopt($ch1, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch1, CURLOPT_CONNECTTIMEOUT, $timeout);
curl_setopt($ch1, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch1, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($ch1, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
$access_txt = curl_exec($ch1);
if (curl_errno($ch1)) {
$error_message = curl_error($ch1);
@file_put_contents(storage_path('logs/lyh_error.log'), var_export($error_message, true) . PHP_EOL, FILE_APPEND);
}
curl_close($ch1);
return json_decode($access_txt, true);
}
... ...
... ... @@ -7,7 +7,10 @@
*/
namespace App\Http\Controllers\Api;
use App\Enums\Common\Code;
use App\Http\Controllers\Controller;
use Illuminate\Http\Exceptions\HttpResponseException;
use Illuminate\Http\JsonResponse;
/**
* Class BaseController
... ... @@ -38,4 +41,23 @@ class BaseController extends Controller
$array = compact('status', 'message', 'data');
return json_encode($array, JSON_UNESCAPED_UNICODE);
}
}
\ No newline at end of file
/**
* @name :统一返回参数
* @return JsonResponse
* @author :liyuhang
* @method
*/
public function response($msg = null,string $code = Code::SUCCESS,$data = [],$result_code = 200,$type = 'application/json'): JsonResponse
{
$code = Code::fromValue($code);
$result = [
'code' => $code->value,
'data' => $data,
'message' => $msg == ' ' ? $code->description : $msg,
];
$header['Content-Type'] = $type;
$response = response($result,$result_code,$header);
throw new HttpResponseException($response);
}
}
... ...
<?php
namespace App\Http\Controllers\Api;
use App\Enums\Common\Code;
use App\Models\Product\Product;
use App\Services\ProjectServer;
use App\Utils\LogUtils;
use Illuminate\Http\Request;
use Illuminate\Support\Arr;
/**
* Class ProductController
* @package App\Http\Controllers\Api
* @author zbj
* @date 2024/2/1
*/
class ProductController extends BaseController
{
/**
* 获取项目随机产品的图片
* @param Request $request
* @return void
*/
public function getImages(Request $request)
{
$project_id = $request->input('project_id');
$project = ProjectServer::useProject($project_id);
if (!$project) {
$this->response('项目不存在', Code::SYSTEM_ERROR);
}
try {
$gallery = Product::where('status', Product::STATUS_ON)->whereNotNull('gallery')->inRandomOrder()->value('gallery');
$gallery = array_map(function ($item) use ($project) {
return getImageUrl($item, $project['storage_type'], $project['project_location']);
}, Arr::pluck($gallery, 'url'));
} catch (\Exception $e) {
LogUtils::error('Project Id: ' . $project_id . ' getProductImages error:' . $e->getMessage());
$gallery = [];
}
$this->response('success', Code::SUCCESS, $gallery);
}
}
... ...
... ... @@ -125,6 +125,9 @@ class ProjectController extends BaseController
$query->whereIn('gl_project.type', [Project::TYPE_FOUR,Project::TYPE_SIX]);
}
}
if(isset($this->map['uptime']) && is_array($this->map['uptime'])){
$query->whereBetween('gl_project.uptime', $this->map['uptime']);
}
return $query;
}
... ... @@ -153,6 +156,7 @@ class ProjectController extends BaseController
'gl_project.channel AS channel',
'gl_project.company AS company',
'gl_project.type AS type',
'gl_project.is_upgrade AS is_upgrade',
'gl_project.created_at AS created_at',
'gl_project.cooperate_date AS cooperate_date',
'gl_project_online_check.id AS online_check_id',
... ...
... ... @@ -27,8 +27,6 @@ class ATemplateModuleController extends BaseController
public function lists(ATemplateModuleLogic $ATemplateModuleLogic){
if(isset($this->map['type']) && ($this->map['type'] == 99)){
$this->map['type'] = 99;
}else{
$this->map['project_id'] = 0;
}
$lists = $ATemplateModuleLogic->aTemplateModuleLists($this->map,$this->page,$this->row,$this->order);
$this->response('success',Code::SUCCESS,$lists);
... ...
... ... @@ -69,20 +69,28 @@ class AyrReleaseController extends BaseController
}
//参数处理
$this->param['mediaUrls'] = $ayrReleaseLogic->image_file_param($data);
//时间处理
$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 = [
'post'=>$this->param['content'],
'platforms'=>$this->param['platforms'],
'mediaUrls'=>$this->param['mediaUrls'],//参数处理
'scheduleDate'=>$formattedTime,//时间(如是过去时间,立即发布)
];
//统一生成发布
foreach ($this->param['platforms'] as $value){
if($value == 'youtube'){
$param['youTubeOptions'] = ['title'=>$this->param['title']];
}
}
if(isset($this->param['schedule_date']) && !empty($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['scheduleDate'] = $formattedTime;//时间(如是过去时间,立即发布)
}
//发送请求发布社交文章
$res = $ayrShare->post_send_msg($param,$share_info['profile_key']);
//保存数据库
$ayrReleaseLogic->release_add();
$ayrReleaseLogic->release_add($res);
//保存返回的内容
$this->response('success',Code::SUCCESS,json_decode($res));
}
... ...
... ... @@ -12,7 +12,10 @@ namespace App\Http\Controllers\Bside\CustomModule;
use App\Enums\Common\Code;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Bside\CustomModule\CustomModuleCategoryLogic;
use App\Models\CustomModule\CustomModule;
use App\Models\CustomModule\CustomModuleCategory;
use App\Models\Template\BTemplate;
use App\Models\Template\Setting;
use App\Models\User\User;
class CustomModuleCategoryController extends BaseController
... ... @@ -34,7 +37,9 @@ class CustomModuleCategoryController extends BaseController
$this->map['status'] = 0;
$list = $customModuleCategory->list($this->map,'sort');
if(!empty($list)){
$template_id = $this->getModuleTemplateId($this->param['module_id']);
foreach ($list as $k => $v){
$v['is_renovation'] = $this->getIsRenovation($v['module_id'],BTemplate::IS_LIST,$template_id,$v['id'],BTemplate::IS_CUSTOM);
$v['url'] = $this->user['domain'].$v['route'];
$list[$k] = $v;
}
... ... @@ -44,6 +49,25 @@ class CustomModuleCategoryController extends BaseController
}
/**
* @remark :扩展模块获取模版id
* @name :getTemplateId
* @author :lyh
* @method :post
* @time :2024/1/31 16:47
*/
public function getModuleTemplateId($module_id){
$template_id = 0;
$moduleModel = new CustomModule();
$info = $moduleModel->read(['id'=>$module_id]);
if($info['list_customized'] != 1){
$bSettingModel = new Setting();
$info = $bSettingModel->read(['project_id'=>$this->user['project_id']]);
$template_id = $info['template_id'];
}
return $this->success($template_id);
}
/**
* @remark :无分页子集处理
* @name :getListSon
* @author :lyh
... ...
... ... @@ -12,9 +12,12 @@ namespace App\Http\Controllers\Bside\CustomModule;
use App\Enums\Common\Code;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Bside\CustomModule\CustomModuleContentLogic;
use App\Models\CustomModule\CustomModule;
use App\Models\CustomModule\CustomModuleCategory;
use App\Models\CustomModule\CustomModuleContent;
use App\Models\RouteMap\RouteMap;
use App\Models\Template\BTemplate;
use App\Models\Template\Setting;
use App\Models\User\User;
class CustomModuleContentController extends BaseController
... ... @@ -35,12 +38,14 @@ class CustomModuleContentController extends BaseController
$this->map['project_id'] = $this->user['project_id'];
$lists = $customModuleContent->lists($this->map,$this->page,$this->row,$this->order = ['sort','id']);
if(!empty($lists)){
$template_id = $this->getModuleTemplateId($this->param['module_id']);
$data = $this->getAllCategoryName();
foreach ($lists['list'] as $k=>$v){
$v['url'] = $this->getUrl($v);
$v = $this->getHandleImageFile($v);
$v['category_name'] = $this->categoryName($v['category_id'],$data);
$v['image_link'] = getImageUrl($v['image'],$this->user['storage_type'],$this->user['project_location']);
$v['operator_name'] = (new User())->getName($v['operator_id']);
$v['is_renovation'] = $this->getIsRenovation($v['module_id'],BTemplate::IS_DETAIL,$template_id,$v['id'],BTemplate::IS_CUSTOM);
$lists['list'][$k] = $v;
}
}
... ... @@ -48,6 +53,43 @@ class CustomModuleContentController extends BaseController
}
/**
* @remark :扩展模块获取模版id
* @name :getTemplateId
* @author :lyh
* @method :post
* @time :2024/1/31 16:47
*/
public function getModuleTemplateId($module_id){
$template_id = 0;
$moduleModel = new CustomModule();
$info = $moduleModel->read(['id'=>$module_id]);
if($info['detail_customized'] != 1){
$bSettingModel = new Setting();
$info = $bSettingModel->read(['project_id'=>$this->user['project_id']]);
$template_id = $info['template_id'];
}
return $this->success($template_id);
}
/**
* @remark :获取时处理视频,图片,文件
* @name :getHandleImageFile
* @author :lyh
* @method :post
* @time :2024/1/31 15:48
*/
public function getHandleImageFile($v){
if(!empty($v['image'])){
$v['image_link'] = getImageUrl($v['image'],$this->user['storage_type'] ?? 0,$this->user['project_location']);
}
if(!empty($v['video'])){
$v['video']['url'] = getFileUrl($v['video']['url'],$this->user['storage_type'] ?? 0,$this->user['project_location']);
$v['video']['video_image'] = getImageUrl($v['video']['video_image'],$this->user['storage_type'] ?? 0,$this->user['project_location']);
}
return $this->success($v);
}
/**
* @remark :获取连接
* @name :getUrl
* @author :lyh
... ... @@ -141,6 +183,7 @@ class CustomModuleContentController extends BaseController
'id.required' => 'ID不能为空',
]);
$info = $logic->getContentInfo();
$info = $this->getHandleImageFile($info);
$this->response('success',Code::SUCCESS,$info);
}
... ...
... ... @@ -313,7 +313,7 @@ class NewsController extends BaseController
],[
'keyword.required' => 'keyword不能为空',
]);
$data = http_get('http://gnews.globalso.com/gnews_news.php?keyword='.$this->param['keyword']);
$data = http_get('http://gnews.globalso.com/gnews_news.php?keyword='.$this->param['keyword'],['charset=utf-8']);
$this->response('success',Code::SUCCESS,$data);
}
}
... ...
... ... @@ -40,7 +40,7 @@ class CategoryController extends BaseController
$template_id = $this->getTemplateId(BTemplate::SOURCE_PRODUCT,BTemplate::IS_LIST);//获取模版id
foreach ($list as $k =>$v){
$v['url'] = $this->user['domain'] . $v['route'].'/';
$v['product_num'] = Category::getProductNum($v['id']);
$v['product_num'] = $category->getProductNum($list,$v['id']);
$v['image_link'] = getImageUrl($v['image'],$this->user['storage_type'],$this->user['project_location']);
$v['is_renovation'] = $this->getIsRenovation(BTemplate::SOURCE_PRODUCT,BTemplate::IS_LIST,$template_id,$v['id']);
$list[$k] = $v;
... ...
... ... @@ -135,7 +135,10 @@ class KeywordController extends BaseController
'title.array' => 'title为数组',
'title.max' => '批量操作不能超过1000条数据'
]);
$logic->batchAdd();
$rs = $logic->batchAdd();
if($rs === false){
$this->response('创建任务添加关键词任务失败,请稍后重试!',Code::SYSTEM_ERROR);
}
$this->response('关键词后台异步添加中,请稍后刷新查看!');
}
... ...
... ... @@ -20,10 +20,12 @@ use App\Models\Product\Product;
use App\Models\Template\Setting;
use App\Models\Template\BTemplate;
use App\Models\User\User;
use App\Models\WebSetting\SettingNum;
use App\Rules\Ids;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
/**
* Class ProductController
... ... @@ -92,11 +94,12 @@ class ProductController extends BaseController
$v['icon'][$icon_k] = $icon_v;
}
}
if(!empty($v['video']) && !empty($v['video']['url'])){
$v['video']['url'] = getImageUrl($v['video']['url'],$this->user['storage_type'] ?? 0,$this->user['project_location']);
if(!empty($v['video'])){
$v['video']['url'] = getFileUrl($v['video']['url'],$this->user['storage_type'] ?? 0,$this->user['project_location']);
$v['video']['video_image'] = getImageUrl($v['video']['video_image'] ?? '',$this->user['storage_type'] ?? 0,$this->user['project_location']);
}
if(!empty($v['files']) && !empty($v['files']['url'])){
$v['files']['url'] = getImageUrl($v['files']['url'],$this->user['storage_type'] ?? 0,$this->user['project_location']);
$v['files']['url'] = getFileUrl($v['files']['url'],$this->user['storage_type'] ?? 0,$this->user['project_location']);
}
return $this->success($v);
}
... ... @@ -111,7 +114,6 @@ class ProductController extends BaseController
public function searchParam(&$query){
$query = $query->where('project_id',$this->user['project_id']);
if (isset($this->map['category_id']) && !empty($this->map['category_id'])) {
$str = [];
$str[] = $this->map['category_id'];
$this->getAllSub($this->map['category_id'],$str);
$query->where(function ($subQuery) use ($str) {
... ... @@ -472,4 +474,54 @@ class ProductController extends BaseController
$logic->setAllSort();
$this->response('success');
}
/**
* @remark :设置产品排序
* @name :setProductSort
* @author :lyh
* @method :post
* @time :2024/1/31 10:14
*/
public function setProductSort(){
$setNumModel = new SettingNum();
try {
if(isset($this->param['id']) && !empty($this->param['id'])){
//执行编辑
$param = [
'data'=>json_encode($this->param['data']),
];
$setNumModel->edit($param,['id'=>$this->param['id']]);
}else{
//执行新增
$param = [
'type'=>$setNumModel::TYPE_PRODUCT_SORT,
'project_id'=>$this->user['project_id'],
'data'=>json_encode($this->param['data']),
];
$setNumModel->add($param);
}
}catch (\Exception $e){
Log::info('error file: ' . __CLASS__ . __FUNCTION__ . $e->getMessage());
$this->response('设置排序失败,请稍后重试',Code::SYSTEM_ERROR);
}
$this->response('success');
}
/**
* @remark :获取产品排序
* @name :getProductSort
* @author :lyh
* @method :post
* @time :2024/1/31 10:24
*/
public function getProductSort(){
$setNumModel = new SettingNum();
$info = $setNumModel->read(['type'=>$setNumModel::TYPE_PRODUCT_SORT]);
if($info === false){
$info = [];
}else{
$info['data'] = json_decode($info['data']);
}
$this->response('success',Code::SUCCESS,$info);
}
}
... ...
... ... @@ -251,11 +251,11 @@ class DomainInfoLogic extends BaseLogic
foreach ($output as $line){
if($line){
$checkA = strpos($line, $server_info['host']) !== false;
if($checkA){
return $domain;
}
}
}
if($checkA){
return $domain;
}
//是否cname
$process = new Process(['nslookup', '-qt=cname', $domain]);
... ... @@ -264,12 +264,11 @@ class DomainInfoLogic extends BaseLogic
foreach ($output as $line){
if($line){
$checkCname = (strpos($line, $server_info['init_domain']) !== false);
if($checkCname){
return $domain;
}
}
}
if($checkCname){
return $domain;
}
return false;
}
}
... ...
... ... @@ -46,9 +46,16 @@ class OnlineCheckLogic extends BaseLogic
if(($info['qa_mid'] != 0) && ($info['qa_mid'] != $this->manager['id'])){
$this->fail('你无权限提交审核');
}
$projectModel = new Project();
$projectInfo = $projectModel->read(['id'=>$this->param['id']]);
if(!empty($projectInfo['uptime'])){
$param['uptime'] = date('Y-m-d H:i:s');
}
if(isset($this->param['project_type']) && !empty($this->param['project_type'])){
$projectModel = new Project();
$projectModel->edit(['type'=>$this->param['project_type']],['id'=>$this->param['id']]);
$param['type'] = $this->param['project_type'];
}
if(isset($param)){
$projectModel->edit($param,['id'=>$this->param['id']]);
}
}
$data = [
... ...
... ... @@ -133,6 +133,7 @@ class ProjectLogic extends BaseLogic
public function projectSave(){
DB::beginTransaction();
try {
$this->param['project_location'] = 0;//TODO::图片文件存储不同地方,上线后删除
if($this->param['type'] == Project::TYPE_SEVEN){
//错误单直接返回,单独处理
$this->setTypeSevenEdit($this->param);
... ...
... ... @@ -55,9 +55,9 @@ class UserLogic extends BaseLogic
$this->param = $this->editPassword($this->param);
$rs = $this->model->edit($this->param, ['id' => $this->param['id']]);
} else {
$mobileModel = new Mobile();
//查看当前手机号码是否存在于手机号码库
$mobileInfo = $mobileModel->read(['mobile'=>$this->param['mobile']]);
// $mobileModel = new Mobile();
// //查看当前手机号码是否存在于手机号码库
// $mobileInfo = $mobileModel->read(['mobile'=>$this->param['mobile']]);
$this->param['password'] = base64_encode(md5($this->param['password']));
$rs = $this->model->add($this->param);
}
... ...
... ... @@ -37,12 +37,13 @@ class AyrReleaseLogic extends BaseLogic
* @method :post
* @time :2023/5/9 9:38
*/
public function release_add(){
public function release_add($res){
$this->param['project_id'] = $this->user['project_id'];
$this->param['operator_id'] = $this->user['id'];
if(isset($this->param['images']) && !empty($this->param['images'])){
$this->param['images'] = implode(',',$this->param['images']);
}
$this->param['result_data'] = $res;
$this->param['platforms'] = json_encode($this->param['platforms']);
$rs = $this->model->add($this->param);
if($rs === false){
... ... @@ -60,18 +61,16 @@ class AyrReleaseLogic extends BaseLogic
$arr = [];
foreach ($data as $k => $v){
if($k == 'images'){
$images = $v;
$imageModel = new Image();
$list = $imageModel->list(['path'=>['in',$images]],'id');
foreach ($list as $v1){
$arr[] = getImageUrl($v1['path'],$this->user['storage_type'],$this->user['project_location']);
foreach ($v as $v1){
$v1 = 'https://file.globalso.com'.str_replace_url($v1);
$arr[] = $v1;
}
}else{
$fileModel = new File();
$info = $fileModel->read(['path'=>$v]);
$arr[] = getFileUrl($info['path'],$this->user['storage_type'],$this->user['project_location']);
$v = 'https://file.globalso.com'.str_replace_url($v);
$arr[] = $v;
}
}
@file_put_contents(storage_path('logs/lyh_error.log'), var_export($arr, true) . PHP_EOL, FILE_APPEND);
return $this->success($arr);
}
... ...
... ... @@ -65,7 +65,11 @@ class CustomTemplateLogic extends BaseLogic
public function customTemplateSave(){
$this->param['url'] = str_replace_url($this->param['url']);
if(isset($this->param['id']) && !empty($this->param['id'])){
$this->param['url'] = RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_PAGE, $this->param['id'], $this->user['project_id']);
$is_upgrade = $this->param['is_upgrade'] ?? 0;//1:5.0数据 0:6.0
$six_read = $this->param['six_read'] ?? 0;//5.0数据时,是否按6.0显示
if($is_upgrade == 0 || $six_read == 1) {
$this->param['url'] = RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_PAGE, $this->param['id'], $this->user['project_id']);
}
$this->editCustomRoute($this->param['url']);
$rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
}else{
... ...
... ... @@ -34,7 +34,11 @@ class BlogLogic extends BaseLogic
try {
$this->param = $this->paramProcessing($this->param);
if(isset($this->param['id']) && !empty($this->param['id'])){
$this->param['url'] = RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_BLOG, $this->param['id'], $this->user['project_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){
$this->param['url'] = RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_BLOG, $this->param['id'], $this->user['project_id']);
}
$route = $this->param['url'];
$this->edit($this->param,['id'=>$this->param['id']]);
}else{
... ... @@ -195,7 +199,7 @@ class BlogLogic extends BaseLogic
foreach ($category as $v){
$str .= $v.',';
}
return !empty($str) ? ','.$str : '';
return !empty(trim($str,',')) ? ','.$str.',' : '';
}
/**
... ...
... ... @@ -150,6 +150,7 @@ class CustomModuleCategoryLogic extends BaseLogic
* @time :2023/12/5 10:55
*/
public function categoryEdit(){
$route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_MODULE_CATE,
$this->param['id'], $this->user['project_id']);
$this->editRoute($this->param['id'],$route);
... ...
... ... @@ -9,6 +9,7 @@
namespace App\Http\Logic\Bside\CustomModule;
use App\Helper\Arr;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\CustomModule\CustomModuleCategory;
use App\Models\CustomModule\CustomModuleContent;
... ... @@ -39,7 +40,6 @@ class CustomModuleContentLogic extends BaseLogic
if($info === false){
$this->fail('当前数据不存在或已被删除');
}
$info['image'] = getImageUrl($info['image'],$this->user['storage_type'],$this->user['project_location']);
$info['extend'] = $this->getExtendInfo($info['module_id'],$info['id']);
return $this->success($info);
}
... ... @@ -186,9 +186,12 @@ class CustomModuleContentLogic extends BaseLogic
* @time :2023/12/7 15:04
*/
public function contentEdit(){
$route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_MODULE,
$this->param['id'], $this->user['project_id']);
$this->editRoute($this->param['id'],$route);
$is_upgrade = $this->param['is_upgrade'] ?? 0;//5.0数据 1:6.0
$six_read = $this->param['six_read'] ?? 0;//是否按6.0显示
if($is_upgrade == 0 || $six_read == 1) {
$this->param['route'] = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_MODULE, $this->param['id'], $this->user['project_id']);
}
$this->editRoute($this->param['id'],$this->param['route']);
$rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
if($rs === false){
$this->fail('系统错误,请连续管理员');
... ... @@ -214,6 +217,11 @@ class CustomModuleContentLogic extends BaseLogic
if(isset($param['image']) && !empty($param['image'])){
$param['image'] = str_replace_url($param['image']);
}
if(isset($param['video'])){
$param['video']['url'] = str_replace_url($param['video']['url']);
$param['video']['video_image'] = str_replace_url($param['video']['video_image']);
$param['video'] = Arr::a2s($param['video'] ?? []);
}
return $this->success($param);
}
... ...
... ... @@ -64,7 +64,11 @@ class NewsLogic extends BaseLogic
try {
$this->param = $this->paramProcessing($this->param);
if (isset($this->param['id']) && !empty($this->param['id'])) {
$this->param['url'] = RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_NEWS, $this->param['id'], $this->user['project_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) {
$this->param['url'] = RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_NEWS, $this->param['id'], $this->user['project_id']);
}
//是否更新路由
$route = $this->param['url'];
$this->edit($this->param, ['id' => $this->param['id']]);
... ... @@ -213,7 +217,7 @@ class NewsLogic extends BaseLogic
foreach ($category as $v){
$str .= $v.',';
}
return !empty($str) ? ','.$str : '';
return !empty(trim($str,',')) ? ','.$str.',' : '';
}
/**
... ...
... ... @@ -196,7 +196,9 @@ class CategoryLogic extends BaseLogic
RouteMap::delRoute(RouteMap::SOURCE_PRODUCT_CATE, $id, $this->user['project_id']);
//生成一条删除路由记录
$info = $this->model->read(['id'=>$id],['id','route']);
$this->curlDelRoute(['route'=>$info['route']]);
if($info !== false){
$this->curlDelRoute(['route'=>$info['route']]);
}
return $this->success();
}
... ... @@ -248,7 +250,7 @@ class CategoryLogic extends BaseLogic
$str .= $v.',';
}
}
return !empty($str) ? ','.$str : '';
return !empty(trim($str,',')) ? ','.$str.',' : '';
}
/**
... ...
... ... @@ -145,10 +145,10 @@ class KeywordLogic extends BaseLogic
$this->model->insertGetId($param);
}
}
NoticeLog::createLog(NoticeLog::TYPE_INIT_KEYWORD, ['project_id' => $this->user['project_id']]);
}catch (\Exception $e){
$this->fail('创建任务添加关键词任务失败,请稍后重试!');
return false;
}
NoticeLog::createLog(NoticeLog::TYPE_INIT_KEYWORD, ['project_id' => $this->user['project_id']]);
return $this->success();
}
... ...
... ... @@ -14,6 +14,7 @@ use App\Models\RouteMap\RouteMap;
use App\Models\Template\BTemplate;
use App\Services\CosService;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
/**
* Class ProductLogic
... ... @@ -46,7 +47,11 @@ class ProductLogic extends BaseLogic
$this->param = $this->handleSaveParam($this->param);
try {
if(isset($this->param['id']) && !empty($this->param['id'])){
$this->param['route'] = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_PRODUCT, $this->param['id'], $this->user['project_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){
$this->param['route'] = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_PRODUCT, $this->param['id'], $this->user['project_id']);
}
$route = $this->param['route'];
$this->model->edit($this->param,['id'=>$this->param['id']]);
$id = $this->param['id'];
... ... @@ -62,6 +67,7 @@ class ProductLogic extends BaseLogic
//保存扩展字段
$this->saveExtendInfo($id,$extend);
}catch (\Exception $e){
Log::info('错误信息---'.$e->getMessage());
$this->fail('系统错误请联系管理员');
}
$this->addUpdateNotify(RouteMap::SOURCE_PRODUCT,$route);
... ... @@ -193,6 +199,7 @@ class ProductLogic extends BaseLogic
* @time :2023/10/26 9:49
*/
public function editList(){
$category_ids = $this->param['category_id'];
$this->param['category_id'] = $this->handleListCategory($this->param['category_id']);
$this->param['keyword_id'] = $this->saveKeyword($this->param['keyword_id']);
if(isset($this->param['gallery']) && !empty($this->param['gallery'])){
... ... @@ -208,9 +215,11 @@ class ProductLogic extends BaseLogic
try {
if(isset($this->param['route']) && !empty($this->param['route'])){
$this->param['route'] = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_PRODUCT, $this->param['id'], $this->user['project_id']);
$this->editProductRoute($this->param['id'],$this->param['route']);
// $this->editProductRoute($this->param['id'],$this->param['route']);
}
$this->model->edit($this->param,['id'=>$this->param['id']]);
//产品分类关联
CategoryRelated::saveRelated($this->param['id'], $category_ids);
}catch (\Exception $e){
$this->fail('系统错误,请连续管理员');
}
... ... @@ -278,6 +287,7 @@ class ProductLogic extends BaseLogic
}
if(isset($param['video'])){
$param['video']['url'] = str_replace_url($param['video']['url']);
$param['video']['video_image'] = str_replace_url($param['video']['video_image']);
$param['video'] = Arr::a2s($param['video'] ?? []);
}
if(isset($param['keyword_id']) && !empty($param['keyword_id'])){
... ... @@ -313,7 +323,7 @@ class ProductLogic extends BaseLogic
$str .= $v.',';
}
}
return !empty($str) ? ','.$str : '';
return !empty(trim($str,',')) ? ','.$str.',' : '';
}
/**
... ...
... ... @@ -28,6 +28,7 @@ use App\Models\RankData\Speed;
use App\Models\RankData\Speed as GoogleSpeedModel;
use App\Utils\HttpUtils;
use GuzzleHttp\Exception\GuzzleException;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Str;
... ... @@ -110,9 +111,10 @@ class RankDataLogic extends BaseLogic
//外链引荐域名
$recomm_domain = $recomm_domain ? $recomm_domain->toArray() : [];
$recomm_domain['data'] = Collection::make($recomm_domain['data'] ?? [])->sortBy('backlinks_num')->all();
$data['external_links_domain_chat'] = [
'labels' => array_map(function ($item) {
return Str::substrReplace($item, '***', 2, 3);
return mb_substr($item, 0, 2) . '***' . mb_substr($item, 5);
}, Arr::pluck($recomm_domain['data'] ?? [], 'domain')),
'data' => Arr::pluck($recomm_domain['data'] ?? [], 'backlinks_num'),
'list_date' => $recomm_domain['updated_at'] ?? '',
... ... @@ -611,7 +613,6 @@ class RankDataLogic extends BaseLogic
//外链引荐域名
$domain = (new DomainInfo())->getDomain($domain);
$semrushApi = new SemrushApi();
$domain = (new DomainInfo())->getDomain($domain);
$data = $semrushApi->backlinks_refdomains($domain);
}
... ...
... ... @@ -21,4 +21,18 @@ class CustomModuleContent extends Base
public function getCategoryIdAttribute($value){
return explode(',',trim($value,','));
}
/**
* @remark :视频
* @name :getVideoAttribute
* @author :lyh
* @method :post
* @time :2024/1/23 14:31
*/
public function getVideoAttribute($value){
if(!empty($value)){
$value = Arr::s2a($value);
}
return $value;
}
}
... ...
... ... @@ -5,6 +5,7 @@ namespace App\Models\Inquiry;
use App\Models\Base;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Str;
/**
* Class InquiryForm
... ... @@ -36,10 +37,11 @@ class InquiryForm extends Base
'phone' => '电话',
'mobile' => '电话',
'message' => '询盘内容',
'company' => '公司名称'
'company' => '公司名称',
'file' => '文件'
];
if($field){
return $map[$field] ?? $field;
return $map[Str::lower($field)] ?? Str::studly($field);
}
return $map;
}
... ... @@ -70,6 +72,13 @@ class InquiryForm extends Base
unset($data['globalso-domain']);
unset($data['globalso-edition']);
unset($data['globalso-date']);
foreach ($data as $k => $v){
if(in_array($k, ['name', 'email', 'message']) && empty($v)){
unset($data[$k]);
}
}
ksort($data);
$field = array_keys($data);
$sign = md5(json_encode($field));
... ...
... ... @@ -41,7 +41,22 @@ class Category extends Base
return $ids;
}
/**
* @remark :获取当前id下所有子集
* @name :getAllSub
* @author :lyh
* @method :post
* @time :2023/10/18 15:10
*/
public function getAllSub($list,$id,&$str = []){
foreach ($list as $k =>$v){
if($v['pid'] == $id){
$str[] = $v['id'];
$this->getAllSub($list,$v['id'],$str);
}
}
return $str;
}
/**
* 关联产品数量
... ... @@ -50,10 +65,11 @@ class Category extends Base
* @author zbj
* @date 2023/4/28
*/
public static function getProductNum($cate_id){
$cate_ids = self::getChildIdsArr($cate_id);
$count = CategoryRelated::whereIn('cate_id',$cate_ids)->count();
// $str = 0;
public function getProductNum($list,$cate_id){
$str[] = $cate_id;
$cate_ids = $this->getAllSub($list,$cate_id,$str);
$productArr = CategoryRelated::whereIn('cate_id',$cate_ids)->pluck('product_id')->unique()->toArray();
$count = count($productArr);
return $count;
}
}
... ...
... ... @@ -3,6 +3,7 @@
namespace App\Models\Project;
use App\Helper\Arr;
use App\Helper\Translate;
use App\Models\Base;
use App\Models\Devops\ServerConfig;
use App\Models\Optimize\Process;
... ... @@ -320,6 +321,14 @@ class Project extends Base
$project_id = DeployBuild::where('test_domain', 'https://' . $domain . '/')->value('project_id');
//是否正式域名
if (!$project_id) {
//是否小语种域名
$domainPrefix = explode(".",$domain);
if (!empty($domainPrefix)){
$isLang = Translate::getTls($domainPrefix[0]);
if ($isLang) {
$domain = "www.".$domainPrefix[1].".".$domainPrefix[2];
}
}
$project_id = \App\Models\Domain\DomainInfo::where('domain', $domain)->value('project_id');
}
$project = self::find($project_id ?: 0);
... ...
... ... @@ -20,6 +20,8 @@ use App\Models\Base;
*/
class SettingNum extends Base
{
const TYPE_PRODUCT_SORT = 10;//c端显示排序
protected $table = 'gl_setting_num';
//连接数据库
protected $connection = 'custom_mysql';
... ...
... ... @@ -70,6 +70,9 @@ class SyncSubmitTaskService
$this->inquiryFilter($data['project_id'], $data);
//数组key转为小写
$data['data'] = array_change_key_case($data['data'], CASE_LOWER);
$form_id = InquiryForm::getFromId($data['data']);
InquiryFormData::saveData($form_id, $data['domain'], $data['ip'], $data['country'], $data['referer'], $data['user_agent'], $data['submit_at'], $data['data']);
... ... @@ -92,7 +95,14 @@ class SyncSubmitTaskService
{
$visit_data = $data['data'];
$visit_data['referrer_url'] = $data['data']['referrer_url']??'';
$referrer_url = '';
if($data['data']['referrer_url']){
$url_arr = parse_url($data['data']['referrer_url']);
if(!empty($url_arr['scheme']) && !empty($url_arr['host'])){
$referrer_url = $url_arr['scheme'] . '://' . $url_arr['host'] . '/';
}
}
$visit_data['referrer_url'] = $referrer_url;
$visit_data['device_port'] = $data['data']['device_port']??'';
$visit_data['url'] = $data['data']['url']??'';
$visit_data['domain'] = $data['domain']??'';
... ...
... ... @@ -20,4 +20,6 @@ Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
Route::any('traffic_visit', [\App\Http\Controllers\Api\NoticeController::class, 'trafficVisit'])->name('api.traffic_visit');
Route::get('optimize_project_list', [\App\Http\Controllers\Api\PrivateController::class, 'optimizeProjectList'])->name('api.optimize_project_list');
Route::get('get_project_route', [\App\Http\Controllers\Api\PrivateController::class, 'getProjectRoute'])->name('api.get_project_route');
\ No newline at end of file
Route::get('get_project_route', [\App\Http\Controllers\Api\PrivateController::class, 'getProjectRoute'])->name('api.get_project_route');
Route::any('get_product_images', [\App\Http\Controllers\Api\ProductController::class, 'getImages'])->name('api.get_product_images');
... ...
... ... @@ -223,6 +223,8 @@ Route::middleware(['bloginauth'])->group(function () {
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::post('/setProductSort', [\App\Http\Controllers\Bside\Product\ProductController::class, 'setProductSort'])->name('product_setProductSort');
Route::post('/getProductSort', [\App\Http\Controllers\Bside\Product\ProductController::class, 'getProductSort'])->name('product_getProductSort');
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');
... ...