作者 lyh
@@ -159,21 +159,21 @@ class InquiryMonthlyCount extends Command @@ -159,21 +159,21 @@ class InquiryMonthlyCount extends Command
159 //访问来源前10 159 //访问来源前10
160 $source = DB::connection('custom_mysql')->table('gl_customer_visit') 160 $source = DB::connection('custom_mysql')->table('gl_customer_visit')
161 ->select('referrer_url', DB::raw('COUNT(*) as count')) 161 ->select('referrer_url', DB::raw('COUNT(*) as count'))
162 - ->groupBy('referrer_url')->where(['domain'=>$domain]) 162 + ->groupBy('referrer_url')
163 ->whereBetween('updated_date', [$startTime,$endTime]) 163 ->whereBetween('updated_date', [$startTime,$endTime])
164 ->orderByDesc('count')->limit(10)->get()->toArray(); 164 ->orderByDesc('count')->limit(10)->get()->toArray();
165 $arr['source'] = json_encode($source); 165 $arr['source'] = json_encode($source);
166 //访问国家前15 166 //访问国家前15
167 $source_country = DB::connection('custom_mysql')->table('gl_customer_visit') 167 $source_country = DB::connection('custom_mysql')->table('gl_customer_visit')
168 ->select('country',DB::raw('COUNT(*) as ip'),DB::raw('SUM(depth) as pv')) 168 ->select('country',DB::raw('COUNT(*) as ip'),DB::raw('SUM(depth) as pv'))
169 - ->groupBy('country')->where(['domain'=>$domain]) 169 + ->groupBy('country')
170 ->whereBetween('updated_date', [$startTime,$endTime]) 170 ->whereBetween('updated_date', [$startTime,$endTime])
171 ->orderBy('ip','desc')->limit(15)->get()->toArray(); 171 ->orderBy('ip','desc')->limit(15)->get()->toArray();
172 $arr['source_country'] = json_encode($source_country); 172 $arr['source_country'] = json_encode($source_country);
173 //受访界面前15 173 //受访界面前15
174 $referrer_url = DB::connection('custom_mysql')->table('gl_customer_visit') 174 $referrer_url = DB::connection('custom_mysql')->table('gl_customer_visit')
175 ->select('url',DB::raw('COUNT(*) as num')) 175 ->select('url',DB::raw('COUNT(*) as num'))
176 - ->orderBy('num','desc')->where(['domain'=>$domain]) 176 + ->orderBy('num','desc')
177 ->whereBetween('updated_date', [$startTime,$endTime]) 177 ->whereBetween('updated_date', [$startTime,$endTime])
178 ->groupBy('url') 178 ->groupBy('url')
179 ->limit(15)->get()->toArray(); 179 ->limit(15)->get()->toArray();
@@ -181,7 +181,7 @@ class InquiryMonthlyCount extends Command @@ -181,7 +181,7 @@ class InquiryMonthlyCount extends Command
181 //访问端口 181 //访问端口
182 $referrer_port = DB::connection('custom_mysql')->table('gl_customer_visit') 182 $referrer_port = DB::connection('custom_mysql')->table('gl_customer_visit')
183 ->select('device_port',DB::raw('COUNT(*) as num')) 183 ->select('device_port',DB::raw('COUNT(*) as num'))
184 - ->orderBy('num','desc')->where(['domain'=>$domain]) 184 + ->orderBy('num','desc')
185 ->whereBetween('updated_date', [$startTime,$endTime]) 185 ->whereBetween('updated_date', [$startTime,$endTime])
186 ->groupBy('device_port') 186 ->groupBy('device_port')
187 ->limit(15)->get()->toArray(); 187 ->limit(15)->get()->toArray();
@@ -46,6 +46,8 @@ class MonthCountLogic extends BaseLogic @@ -46,6 +46,8 @@ class MonthCountLogic extends BaseLogic
46 $startTime = Carbon::now()->startOfMonth()->toDateString(); 46 $startTime = Carbon::now()->startOfMonth()->toDateString();
47 $endTime = date('Y-m-d',time()); 47 $endTime = date('Y-m-d',time());
48 $arr = []; 48 $arr = [];
  49 +
  50 + ProjectServer::useProject($this->user['project_id']);
49 $arr = $this->inquiryCount($arr,$startTime,$endTime,$this->user['domain']); 51 $arr = $this->inquiryCount($arr,$startTime,$endTime,$this->user['domain']);
50 $arr = $this->flowCount($arr,$startTime,$endTime,$this->user['project_id']); 52 $arr = $this->flowCount($arr,$startTime,$endTime,$this->user['project_id']);
51 $arr = $this->sourceCount($arr,$startTime,$endTime,$this->user['domain']); 53 $arr = $this->sourceCount($arr,$startTime,$endTime,$this->user['domain']);
@@ -84,7 +86,6 @@ class MonthCountLogic extends BaseLogic @@ -84,7 +86,6 @@ class MonthCountLogic extends BaseLogic
84 } 86 }
85 } 87 }
86 //加上其他询盘 88 //加上其他询盘
87 - ProjectServer::useProject($this->user['project_id']);  
88 $arr['total'] += InquiryOther::count(); 89 $arr['total'] += InquiryOther::count();
89 $arr['month_total'] += InquiryOther::whereBetween('submit_time',[$startTime, $endTime])->count(); 90 $arr['month_total'] += InquiryOther::whereBetween('submit_time',[$startTime, $endTime])->count();
90 $countryData = InquiryOther::whereBetween('submit_time',[$startTime, $endTime]) 91 $countryData = InquiryOther::whereBetween('submit_time',[$startTime, $endTime])
@@ -134,31 +135,31 @@ class MonthCountLogic extends BaseLogic @@ -134,31 +135,31 @@ class MonthCountLogic extends BaseLogic
134 */ 135 */
135 public function sourceCount(&$arr,$startTime,$endTime,$domain){ 136 public function sourceCount(&$arr,$startTime,$endTime,$domain){
136 //访问来源前10 137 //访问来源前10
137 - $source = DB::table('gl_customer_visit') 138 + $source = DB::connection('custom_mysql')->table('gl_customer_visit')
138 ->select('referrer_url', DB::raw('COUNT(*) as count')) 139 ->select('referrer_url', DB::raw('COUNT(*) as count'))
139 - ->groupBy('referrer_url')->where(['domain'=>$domain]) 140 + ->groupBy('referrer_url')
140 ->whereBetween('updated_date', [$startTime,$endTime]) 141 ->whereBetween('updated_date', [$startTime,$endTime])
141 ->orderByDesc('count')->limit(10)->get()->toArray(); 142 ->orderByDesc('count')->limit(10)->get()->toArray();
142 $arr['source'] = $source; 143 $arr['source'] = $source;
143 //访问国家前15 144 //访问国家前15
144 - $source_country = DB::table('gl_customer_visit') 145 + $source_country = DB::connection('custom_mysql')->table('gl_customer_visit')
145 ->select('country',DB::raw('COUNT(*) as ip'),DB::raw('SUM(depth) as pv')) 146 ->select('country',DB::raw('COUNT(*) as ip'),DB::raw('SUM(depth) as pv'))
146 - ->groupBy('country')->where(['domain'=>$domain]) 147 + ->groupBy('country')
147 ->whereBetween('updated_date', [$startTime,$endTime]) 148 ->whereBetween('updated_date', [$startTime,$endTime])
148 ->orderBy('ip','desc')->limit(15)->get()->toArray(); 149 ->orderBy('ip','desc')->limit(15)->get()->toArray();
149 $arr['source_country'] = $source_country; 150 $arr['source_country'] = $source_country;
150 //受访界面前15 151 //受访界面前15
151 - $referrer_url = DB::table('gl_customer_visit') 152 + $referrer_url = DB::connection('custom_mysql')->table('gl_customer_visit')
152 ->select('url',DB::raw('COUNT(*) as num')) 153 ->select('url',DB::raw('COUNT(*) as num'))
153 - ->orderBy('num','desc')->where(['domain'=>$domain]) 154 + ->orderBy('num','desc')
154 ->whereBetween('updated_date', [$startTime,$endTime]) 155 ->whereBetween('updated_date', [$startTime,$endTime])
155 ->groupBy('url') 156 ->groupBy('url')
156 ->limit(15)->get()->toArray(); 157 ->limit(15)->get()->toArray();
157 $arr['referrer_url'] = $referrer_url; 158 $arr['referrer_url'] = $referrer_url;
158 //访问断后 159 //访问断后
159 - $referrer_port = DB::table('gl_customer_visit') 160 + $referrer_port = DB::connection('custom_mysql')->table('gl_customer_visit')
160 ->select('device_port',DB::raw('COUNT(*) as num')) 161 ->select('device_port',DB::raw('COUNT(*) as num'))
161 - ->orderBy('num','desc')->where(['domain'=>$domain]) 162 + ->orderBy('num','desc')
162 ->whereBetween('updated_date', [$startTime,$endTime]) 163 ->whereBetween('updated_date', [$startTime,$endTime])
163 ->groupBy('device_port') 164 ->groupBy('device_port')
164 ->limit(15)->get()->toArray(); 165 ->limit(15)->get()->toArray();