diff --git a/app/statistics/controller/DemoController.php b/app/statistics/controller/DemoController.php index 94b6374c2..a58c179e6 100644 --- a/app/statistics/controller/DemoController.php +++ b/app/statistics/controller/DemoController.php @@ -48,14 +48,15 @@ class DemoController extends BaseLikeController public function product_count_sotre_count() { $time = $this->request->get('date', date('Y-m-d')); - $data=SystemStore::where('is_show', 1)->field('id,introduction street_name')->select()->each(function ($item) { - $item['product_count'] = StoreBranchProduct::where('store_id', $item['id'])->count(); - return $item; + $data=SystemStore::where('is_show', 1)->field('id,introduction street_name')->select() + ->each(function (&$item) { + $item['product_count'] = Db::connect('demo')->name('store_branch_product')->where('store_id', $item['id'])->count(); }); //总商品 - $townProductCount = StoreProduct::where('create_time','<=',strtotime($time))->count(); + // $townProductCount = StoreProduct::where('create_time','<=',strtotime($time))->count(); + $townProductCount = Db::connect('demo')->name('store_product')->where('create_time','<=',strtotime($time))->count(); //商品销量 - $product_count = StoreBranchProduct::where('create_time','<=',strtotime($time))->group('product_id')->order('total_sales desc')->limit(20)->field('image,product_id,store_name,sum(sales) as total_sales')->select(); + $product_count = Db::connect('demo')->name('store_branch_product')->where('create_time','<=',strtotime($time))->group('product_id')->order('total_sales desc')->limit(20)->field('image,product_id,store_name,sum(sales) as total_sales')->select(); //总销量 $productRankingTotal = 0; foreach ($product_count as $item) {