作者 刘锟

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

... ... @@ -63,13 +63,18 @@ class TemplateLog extends Command
* @time :2024/7/10 14:48
*/
public function deleteTemplate(){
$date = date('Y-m-d H:i:s', strtotime('-60 days'));
$date = date('Y-m-d H:i:s', strtotime('-30 days'));
$templateLogModel = new BTemplateLog();
$templateLogModel->del(['created_at'=>['<=',$date],'source'=>['!=',1]]);
//首页保存最新的20条记录
$latestIds = $templateLogModel->where(['source'=>1,'is_custom'=>0])->orderBy('created_at', 'desc')->take(20)->pluck('id'); // 仅提取ID字段
return $templateLogModel->del(['id'=>['not in',$latestIds],'source'=>1,'is_custom'=>0,'is_list'=>0]);
//查询最近20天是否有装修记录,首页保存最新的20条记录
$counts = $templateLogModel->counts(['source'=>1,'source_id'=>0,'is_custom'=>0,'created_at'=>['>=',$date]]);
if($counts == 0){
$latestIds = $templateLogModel->where(['source'=>1,'is_custom'=>0])->orderBy('created_at', 'desc')->take(20)->pluck('id'); // 仅提取ID字段
$templateLogModel->del(['id'=>['not in',$latestIds],'source'=>1,'is_custom'=>0,'is_list'=>0]);
}else{
$templateLogModel->del(['created_at'=>['<=',$date],'source'=>1]);
}
return true;
}
/**
... ...
... ... @@ -93,7 +93,7 @@ class OptimizationReportController extends BaseController
'data' => array_values($indexed_pages['data'] ?? []),
];
//月统计报告
$data['month_count'] = $this->currentMonthCount($domain_info['domain'],$this->param['project_id']);
$data['month_count'] = $this->currentMonthCount($this->param['project_id']);
//测速
$speed = Speed::where('project_id', $this->param['project_id'])->first();
$data['speed'] = $speed['data'] ?? [];
... ... @@ -110,107 +110,30 @@ class OptimizationReportController extends BaseController
* @method :post
* @time :2023/7/3 9:55
*/
public function currentMonthCount($domain,$project_id){
// 获取当前月的开始时间
$startTime = date('Y-m-01', strtotime($this->param['date']));
// 获取当前月的结束时间
$endTime = date('Y-m-t', strtotime($this->param['date']));
public function currentMonthCount($project_id){
$arr = [];
$arr = $this->inquiryCount($arr,$startTime,$endTime,$domain,$project_id);
$arr = $this->flowCount($arr,$startTime,$endTime,$project_id);
$arr = $this->sourceCount($arr,$startTime,$endTime,$domain);
$arr['month'] = date('Y-m',time());
return $arr;
}
/**
* @param $domain
* @param $project_id
* @remark :询盘按月统计
* @name :inquiryCount
* @author :lyh
* @method :post
* @time :2023/6/30 14:29
*/
public function inquiryCount(&$arr, &$startTime, $project_id){
$month = date('Y-m',strtotime($startTime));
$date = date('Y-m', strtotime($this->param['date']));
$monthCountModel = new MonthCount();
$info = $monthCountModel->read(['project_id'=>$project_id,'month'=>$month]);
if($info !== false){
$arr['country'] = $info['country'];
$arr['total'] = $info['total'];
$arr['month_total'] = $info['month_total'];
}
return $arr;
}
/**
* @remark :流量统计
* @name :flowCount
* @author :lyh
* @method :post
* @time :2023/6/30 14:31
*/
public function flowCount(&$arr,&$startTime,&$endTime,$project_id){
$pv_ip = DB::table('gl_count')
->where(['project_id'=>$project_id])
->whereBetween('date', [$startTime,$endTime])
->select(DB::raw('SUM(pv_num) as pv_num'), DB::raw('SUM(ip_num) as ip_num'))
->orderBy('id','desc')
->first();
$arr['pv'] = $pv_ip->pv_num;
$arr['ip'] = $pv_ip->ip_num;
$arr['rate'] = 0;
if($arr['ip'] != 0){
$arr['rate'] = round(($arr['month_total'] / $arr['ip']) * 100,2);
$month_info = $monthCountModel->read(['project_id'=>$project_id,'month'=>$date]);
if($month_info !== false){
$arr['country'] = $month_info['country'];
$arr['total'] = $month_info['total'];
$arr['month_total'] = $month_info['month_total'];
$arr['pv'] = $month_info['pv'];
$arr['ip'] = $month_info['ip'];
$arr['rate'] = 0;
if($arr['ip'] != 0){
$arr['rate'] = round(($arr['month_total'] / $arr['ip']) * 100,2);
}
$arr['source'] = json_decode($month_info['source'],true);
$arr['source_country'] = json_decode($month_info['source_country'],true);
$arr['referrer_url'] = json_decode($month_info['referrer_url'],true);
$arr['referrer_port'] = json_decode($month_info['referrer_port'],true);
}
$arr['month'] = date('Y-m',time());
return $arr;
}
/**
* @remark :来源访问前8
* @name :sourceCount
* @author :lyh
* @method :post
* @time :2023/6/30 16:14
*/
public function sourceCount(&$arr,$startTime,$endTime,$domain){
//访问来源前10
$source = DB::connection('custom_mysql')->table('gl_customer_visit')
->select('referrer_url', DB::raw('COUNT(*) as count'))
->groupBy('referrer_url')
->where('referrer_url','!=','')
->whereBetween('updated_date', [$startTime,$endTime])
->orderByDesc('count')->limit(10)->get()->toArray();
$arr['source'] = $source;
//访问国家前15
$query = DB::connection('custom_mysql')->table('gl_customer_visit')
->select('country',DB::raw('COUNT(*) as ip'),DB::raw('SUM(depth) as pv'))
->groupBy('country');
$query->where('country','<>','中国');
$source_country = $query->whereBetween('updated_date', [$startTime,$endTime])
->orderBy('ip','desc')->limit(15)->get()->toArray();
$arr['source_country'] = $source_country;
//受访界面前15
$referrer_url = DB::connection('custom_mysql')->table('gl_customer_visit')
->select('url',DB::raw('COUNT(*) as num'))
->orderBy('num','desc')
->whereBetween('updated_date', [$startTime,$endTime])
->groupBy('url')
->limit(15)->get()->toArray();
$arr['referrer_url'] = $referrer_url;
//访问断后
$referrer_port = DB::connection('custom_mysql')->table('gl_customer_visit')
->select('device_port',DB::raw('COUNT(*) as num'))
->orderBy('num','desc')
->whereBetween('updated_date', [$startTime,$endTime])
->groupBy('device_port')
->limit(15)->get()->toArray();
$arr['referrer_port'] = $referrer_port;
return $arr;
}
public function getApiList($projectInfo,$export = false)
{
... ...
... ... @@ -72,6 +72,7 @@ class CNoticeController extends BaseController
if($number >= 450000){
$this->response('success',Code::SUCCESS,['msg'=>'翻译数量过多, 大概页面数量:'.$number.', 磁盘空间占用可能会超过40G,请联系管理员操作!']);
}
//? Copyright - 2010-2024 : All Rights Reserved.© Copyright - 2010-2024 : All Rights Reserved.
$this->response('success');
}
... ...
... ... @@ -88,7 +88,6 @@ class MonthReportController extends BaseController
])->count();
$info['service_duration'] = $this->user['service_duration'];//服务天数
$info['ip_total'] = (new Visit())->count();//ip总数
$info['remain_day'] = $this->user['remain_day'];//剩余服务天数
$info['speed'] = round((0.3 + mt_rand()/mt_getrandmax() * (1-0.3)),2);
$info['month_total'] = (int)$info['month_total'];
... ...