作者 lyh

gx

... ... @@ -7,6 +7,7 @@ use App\Helper\FormGlobalsoApi;
use App\Models\Project\DeployBuild;
use App\Models\Project\DeployOptimize;
use App\Models\Project\Project;
use App\Services\ProjectServer;
use Carbon\Carbon;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
... ... @@ -54,12 +55,14 @@ class Count extends Command
$arr = [];
//统计时间
$arr['date'] = $yesterday;
ProjectServer::useProject($v['id']);
//pv统计
$arr['pv_num'] = $this->pv_num($yesterday,$v['test_domain']);
//ip统计
$arr['ip_num'] = $this->ip_num($yesterday,$v['test_domain']);
DB::disconnect('custom_mysql');
//服务达标天数
$arr['compliance_day'] = $this->compliance_day($v['test_domain']);
$arr['compliance_day'] = $this->compliance_day($v['id']);
//剩余服务时常
$arr['service_day'] = ((int)$v['service_duration'] - (int)$arr['compliance_day']) > 0 ? ((int)$v['service_duration'] - (int)$arr['compliance_day']) : 0;
//项目id
... ... @@ -86,7 +89,7 @@ class Count extends Command
* @time :2023/6/14 15:40
*/
public function pv_num($yesterday,$domain){
$pv = DB::table('gl_customer_visit_item')->whereDate('updated_date', $yesterday)->where('domain',$domain)->count();
$pv = DB::connection('custom_mysql')->table('gl_customer_visit_item')->whereDate('updated_date', $yesterday)->where('domain',$domain)->count();
return $pv;
}
... ... @@ -97,7 +100,7 @@ class Count extends Command
* @time :2023/6/14 15:40
*/
public function ip_num($yesterday,$domain){
$ip = DB::table('gl_customer_visit')->whereDate('updated_date', $yesterday)->where('domain',$domain)->count();
$ip = DB::connection('custom_mysql')->table('gl_customer_visit')->whereDate('updated_date', $yesterday)->where('domain',$domain)->count();
return $ip;
}
... ... @@ -158,7 +161,7 @@ class Count extends Command
*/
public function selectParam(){
$select = [
'gl_project.id AS user_id',
'gl_project.id AS id',
'gl_project.extend_type AS extend_type',
'gl_project_deploy_build.test_domain AS test_domain',
'gl_project_deploy_optimize.domain AS domain',
... ...
... ... @@ -3,6 +3,7 @@
namespace App\Console\Commands\MonthlyCount;
use App\Helper\FormGlobalsoApi;
use App\Services\ProjectServer;
use Carbon\Carbon;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
... ... @@ -50,7 +51,9 @@ class InquiryMonthlyCount extends Command
//按月统计询盘记录
$arr = $this->inquiryCount($arr,$startTime,$endTime,$value['test_domain']);
$arr = $this->flowCount($arr,$startTime,$endTime,$value['project_id']);
ProjectServer::useProject($value['project_id']);
$arr = $this->sourceCount($arr,$value['test_domain'],$startTime,$endTime);
DB::disconnect('custom_mysql');
$arr['created_at'] = date('Y-m-d H:i:s');
$arr['updated_at'] = date('Y-m-d H:i:s');
$arr['project_id'] = $value['project_id'];
... ... @@ -128,21 +131,21 @@ class InquiryMonthlyCount extends Command
*/
public function sourceCount(&$arr,$domain,$startTime,$endTime){
//访问来源前10
$source = DB::table('gl_customer_visit')
$source = DB::connection('custom_mysql')->table('gl_customer_visit')
->select('referrer_url', DB::raw('COUNT(*) as count'))
->groupBy('referrer_url')->where(['domain'=>$domain])
->whereBetween('updated_date', [$startTime,$endTime])
->orderByDesc('count')->limit(10)->get()->toArray();
$arr['source'] = json_encode($source);
//访问国家前15
$source_country = DB::table('gl_customer_visit')
$source_country = DB::connection('custom_mysql')->table('gl_customer_visit')
->select('country',DB::raw('COUNT(*) as ip'),DB::raw('SUM(depth) as pv'))
->groupBy('country')->where(['domain'=>$domain])
->whereBetween('updated_date', [$startTime,$endTime])
->orderBy('ip','desc')->limit(15)->get()->toArray();
$arr['source_country'] = json_encode($source_country);
//受访界面前15
$referrer_url = DB::table('gl_customer_visit')
$referrer_url = DB::connection('custom_mysql')->table('gl_customer_visit')
->select('url',DB::raw('COUNT(*) as num'))
->orderBy('num','desc')->where(['domain'=>$domain])
->whereBetween('updated_date', [$startTime,$endTime])
... ... @@ -150,7 +153,7 @@ class InquiryMonthlyCount extends Command
->limit(15)->get()->toArray();
$arr['referrer_url'] = json_encode($referrer_url);
//访问端口
$referrer_port = DB::table('gl_customer_visit')
$referrer_port = DB::connection('custom_mysql')->table('gl_customer_visit')
->select('device_port',DB::raw('COUNT(*) as num'))
->orderBy('num','desc')->where(['domain'=>$domain])
->whereBetween('updated_date', [$startTime,$endTime])
... ... @@ -168,7 +171,7 @@ class InquiryMonthlyCount extends Command
*/
public function selectParam(){
$select = [
'gl_project.id AS user_id',
'gl_project.id AS id',
'gl_project.extend_type AS extend_type',
'gl_project_deploy_build.test_domain AS test_domain',
'gl_project_deploy_optimize.domain AS domain',
... ...
... ... @@ -16,7 +16,8 @@ class Visit extends Base
//设置关联表名
protected $table = 'gl_customer_visit';
//连接数据库
protected $connection = 'custom_mysql';
protected $appends = ['device_text'];
public static function deviceMap(){
... ...
... ... @@ -14,4 +14,6 @@ class VisitItem extends Base
{
//设置关联表名
protected $table = 'gl_customer_visit_item';
//连接数据库
protected $connection = 'custom_mysql';
}
... ...