作者 lyh

gx

@@ -4,10 +4,14 @@ namespace App\Http\Logic\Bside\HomeCount; @@ -4,10 +4,14 @@ namespace App\Http\Logic\Bside\HomeCount;
4 4
5 5
6 use App\Http\Logic\Bside\BaseLogic; 6 use App\Http\Logic\Bside\BaseLogic;
  7 +use App\Models\CustomerVisit\CustomerVisit;
7 use App\Models\HomeCount\Count; 8 use App\Models\HomeCount\Count;
  9 +use App\Models\News\News;
  10 +use App\Models\Product\Product;
8 use App\Models\Project\Project; 11 use App\Models\Project\Project;
9 use App\Models\RankData\RankData as RankDataModel; 12 use App\Models\RankData\RankData as RankDataModel;
10 use App\Models\Service\Service; 13 use App\Models\Service\Service;
  14 +use App\Models\Template\BTemplate;
11 use Carbon\Carbon; 15 use Carbon\Carbon;
12 use Illuminate\Support\Facades\DB; 16 use Illuminate\Support\Facades\DB;
13 17
@@ -97,9 +101,9 @@ class CountLogic extends BaseLogic @@ -97,9 +101,9 @@ class CountLogic extends BaseLogic
97 * @time :2023/5/24 14:12 101 * @time :2023/5/24 14:12
98 */ 102 */
99 public function with_data_count(){ 103 public function with_data_count(){
100 - $product_count = DB::table('gl_product')->where(['project_id' => $this->user['project_id']])->count();  
101 - $news_count = DB::table('gl_news')->where(['project_id' => $this->user['project_id']])->count();  
102 - $page_count = DB::table('gl_web_template')->where(['project_id' => $this->user['project_id']])->count(); 104 + $product_count = (new Product())->where(['project_id' => $this->user['project_id']])->count();
  105 + $news_count = (new News())->where(['project_id' => $this->user['project_id']])->count();
  106 + $page_count = (new BTemplate())->where(['project_id' => $this->user['project_id']])->count();
103 $data = [ 107 $data = [
104 'product_count' => $product_count, 108 'product_count' => $product_count,
105 'news_count' => $news_count, 109 'news_count' => $news_count,
@@ -130,8 +134,8 @@ class CountLogic extends BaseLogic @@ -130,8 +134,8 @@ class CountLogic extends BaseLogic
130 * @time :2023/5/24 15:32 134 * @time :2023/5/24 15:32
131 */ 135 */
132 public function referrer_count(){ 136 public function referrer_count(){
133 - $data = DB::table('gl_customer_visit')  
134 - ->select('referrer_url', DB::raw('COUNT(*) as count')) 137 + $customerVisitModel = new CustomerVisit();
  138 + $data = $customerVisitModel->select('referrer_url', DB::raw('COUNT(*) as count'))
135 ->groupBy('referrer_url')->where(['domain'=>$this->user['domain']]) 139 ->groupBy('referrer_url')->where(['domain'=>$this->user['domain']])
136 ->orderByDesc('count')->limit(8)->get()->toArray(); 140 ->orderByDesc('count')->limit(8)->get()->toArray();
137 $total = DB::table('gl_customer_visit')->count(); 141 $total = DB::table('gl_customer_visit')->count();
@@ -151,8 +155,8 @@ class CountLogic extends BaseLogic @@ -151,8 +155,8 @@ class CountLogic extends BaseLogic
151 * @time :2023/5/24 15:56 155 * @time :2023/5/24 15:56
152 */ 156 */
153 public function access_country_count(){ 157 public function access_country_count(){
154 - $data = DB::table('gl_customer_visit')  
155 - ->select('country',DB::raw('COUNT(*) as ip'),DB::raw('SUM(depth) as pv')) 158 + $customerVisitModel = new CustomerVisit();
  159 + $data = $customerVisitModel->select('country',DB::raw('COUNT(*) as ip'),DB::raw('SUM(depth) as pv'))
156 ->groupBy('country')->where(['domain'=>$this->user['domain']]) 160 ->groupBy('country')->where(['domain'=>$this->user['domain']])
157 ->orderBy('ip','desc')->limit(10)->get()->toArray(); 161 ->orderBy('ip','desc')->limit(10)->get()->toArray();
158 if(!empty($data)){ 162 if(!empty($data)){
@@ -13,4 +13,6 @@ use App\Models\Base; @@ -13,4 +13,6 @@ use App\Models\Base;
13 class BSetting extends Base 13 class BSetting extends Base
14 { 14 {
15 protected $table = 'gl_web_setting_template'; 15 protected $table = 'gl_web_setting_template';
  16 + //连接数据库
  17 + protected $connection = 'custom_mysql';
16 } 18 }