作者 赵彬吉

update

... ... @@ -46,6 +46,8 @@ class MonthCountLogic extends BaseLogic
$startTime = Carbon::now()->startOfMonth()->toDateString();
$endTime = date('Y-m-d',time());
$arr = [];
ProjectServer::useProject($this->user['project_id']);
$arr = $this->inquiryCount($arr,$startTime,$endTime,$this->user['domain']);
$arr = $this->flowCount($arr,$startTime,$endTime,$this->user['project_id']);
$arr = $this->sourceCount($arr,$startTime,$endTime,$this->user['domain']);
... ... @@ -84,7 +86,6 @@ class MonthCountLogic extends BaseLogic
}
}
//加上其他询盘
ProjectServer::useProject($this->user['project_id']);
$arr['total'] += InquiryOther::count();
$arr['month_total'] += InquiryOther::whereBetween('submit_time',[$startTime, $endTime])->count();
$countryData = InquiryOther::whereBetween('submit_time',[$startTime, $endTime])
... ... @@ -134,21 +135,21 @@ class MonthCountLogic extends BaseLogic
*/
public function sourceCount(&$arr,$startTime,$endTime,$domain){
//访问来源前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'] = $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'] = $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])
... ... @@ -156,7 +157,7 @@ class MonthCountLogic extends BaseLogic
->limit(15)->get()->toArray();
$arr['referrer_url'] = $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])
... ...