|
...
|
...
|
@@ -6,7 +6,9 @@ use App\Helper\FormGlobalsoApi; |
|
|
|
use App\Http\Logic\Bside\BaseLogic;
|
|
|
|
use App\Models\HomeCount\Count;
|
|
|
|
use App\Models\HomeCount\MonthCount;
|
|
|
|
use App\Models\Inquiry\InquiryOther;
|
|
|
|
use App\Models\Project\DeployOptimize;
|
|
|
|
use App\Services\ProjectServer;
|
|
|
|
use Carbon\Carbon;
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
|
|
...
|
...
|
@@ -44,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']);
|
|
...
|
...
|
@@ -67,8 +71,8 @@ class MonthCountLogic extends BaseLogic |
|
|
|
//数据详情
|
|
|
|
$data = $inquiry_list['data']['data'] ?? '';
|
|
|
|
$arr['month_total'] = 0;
|
|
|
|
$countryArr = [];
|
|
|
|
if(isset($data) && !empty($data)){
|
|
|
|
$countryArr = [];
|
|
|
|
foreach ($data as $v){
|
|
|
|
if(($startTime.' 00:00:00' <= $v['submit_time']) && $v['submit_time'] <= $endTime.' 23:59:59'){
|
|
|
|
$arr['month_total']++;
|
|
...
|
...
|
@@ -76,14 +80,27 @@ class MonthCountLogic extends BaseLogic |
|
|
|
if(isset($countryArr[$v['country']])){
|
|
|
|
$countryArr[$v['country']]++;
|
|
|
|
}else{
|
|
|
|
$countryArr[$v['country']] = 0;
|
|
|
|
$countryArr[$v['country']] = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
arsort($countryArr);
|
|
|
|
$top20 = array_slice($countryArr, 0, 15, true);
|
|
|
|
$arr['country'] = $top20;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//加上其他询盘
|
|
|
|
$arr['total'] += InquiryOther::count();
|
|
|
|
$arr['month_total'] += InquiryOther::whereBetween('submit_time',[$startTime, $endTime])->count();
|
|
|
|
$countryData = InquiryOther::whereBetween('submit_time',[$startTime, $endTime])
|
|
|
|
->select("country",DB::raw('COUNT(*) as count'))
|
|
|
|
->groupBy('country')->get()->toArray();
|
|
|
|
foreach ($countryData as $v1){
|
|
|
|
if(isset($countryArr[$v1['country']])){
|
|
|
|
$countryArr[$v1['country']] += $v1['count'];
|
|
|
|
}else{
|
|
|
|
$countryArr[$v1['country']] = $v1['count'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
arsort($countryArr);
|
|
|
|
$top20 = array_slice($countryArr, 0, 15, true);
|
|
|
|
$arr['country'] = $top20;
|
|
|
|
return $arr;
|
|
|
|
}
|
|
|
|
|
|
...
|
...
|
@@ -118,31 +135,31 @@ 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])
|
|
|
|
->groupBy('referrer_url')
|
|
|
|
->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])
|
|
|
|
->groupBy('country')
|
|
|
|
->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])
|
|
|
|
->orderBy('num','desc')
|
|
|
|
->whereBetween('updated_date', [$startTime,$endTime])
|
|
|
|
->groupBy('url')
|
|
|
|
->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])
|
|
|
|
->orderBy('num','desc')
|
|
|
|
->whereBetween('updated_date', [$startTime,$endTime])
|
|
|
|
->groupBy('device_port')
|
|
|
|
->limit(15)->get()->toArray();
|
...
|
...
|
|