作者 lyh

gx数据

... ... @@ -63,7 +63,6 @@ class TemplateLog extends Command
* @time :2024/7/10 14:48
*/
public function deleteTemplate(){
$date = date('Y-m-d H:i:s', strtotime('-30 days'));
$templateLogModel = new BTemplateLog();
$templateLogModel->del(['created_at'=>['<=',$date],'source'=>['!=',1]]);
... ...
... ... @@ -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,60 +110,27 @@ class OptimizationReportController extends BaseController
* @method :post
* @time :2023/7/3 9:55
*/
public function currentMonthCount($domain,$project_id){
public function currentMonthCount($project_id){
// 获取当前月的开始时间
$startTime = date('Y-m-01', strtotime($this->param['date']));
// 获取当前月的结束时间
$endTime = date('Y-m-t', strtotime($this->param['date']));
$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));
$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'=>$this->param['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 = $this->sourceCount($arr,$startTime,$endTime);
$arr['month'] = date('Y-m',time());
return $arr;
}
... ... @@ -174,7 +141,7 @@ class OptimizationReportController extends BaseController
* @method :post
* @time :2023/6/30 16:14
*/
public function sourceCount(&$arr,$startTime,$endTime,$domain){
public function sourceCount(&$arr,$startTime,$endTime){
//访问来源前10
$source = DB::connection('custom_mysql')->table('gl_customer_visit')
->select('referrer_url', DB::raw('COUNT(*) as count'))
... ...
... ... @@ -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'];
... ...