From 4fde559f4d3fc48f30350e4d3f1ea7615af9a081 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Fri, 19 Jul 2024 11:24:53 +0800 Subject: [PATCH] =?UTF-8?q?feat(DemoController):=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E4=BA=A7=E5=93=81=E7=BB=9F=E8=AE=A1=E9=80=BB=E8=BE=91=EF=BC=8C?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=9F=A5=E8=AF=A2=E6=80=A7=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/statistics/controller/DemoController.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/statistics/controller/DemoController.php b/app/statistics/controller/DemoController.php index 94b6374c..a58c179e 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) {