From 5940e5c6b6e87e41c1db005bd861bf02bf38da2a Mon Sep 17 00:00:00 2001 From: chenbo <709206448@qq.com> Date: Tue, 19 Dec 2023 17:51:10 +0800 Subject: [PATCH] =?UTF-8?q?=E5=95=86=E6=88=B7=20=E5=90=84=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/api/dataview/Merchant.php | 29 +++++++++++++----------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/app/controller/api/dataview/Merchant.php b/app/controller/api/dataview/Merchant.php index 3052667f..5ea2088c 100644 --- a/app/controller/api/dataview/Merchant.php +++ b/app/controller/api/dataview/Merchant.php @@ -122,6 +122,7 @@ class Merchant extends BaseController $startDate = $this->request->param('start_date'); $endDate = $this->request->param('end_date'); $merId = $this->request->param('mer_id'); + $endDate = date("$endDate H:i:s", time()); // $res = Cache::store('file')->remember(self::class . '@merchantProductRanking' . $merId. $startDate. $endDate, function () use ($repository, $startDate, $endDate, $merId) { // $list = StoreOrderProduct::getDB()->alias('A')->leftJoin('StoreOrder B', 'A.order_id = B.order_id') // ->field(\think\facade\Db::raw('sum(A.product_num) as total,A.product_id,cart_info')) @@ -136,13 +137,13 @@ class Merchant extends BaseController // }, 2000 + random_int(600, 1200)); $list = StoreOrderProduct::getDB()->alias('A')->leftJoin('StoreOrder B', 'A.order_id = B.order_id') ->field(\think\facade\Db::raw('sum(A.product_num) as total,A.product_id,cart_info')) - ->whereBetweenTime('B.pay_time', $startDate, date("Y-m-d H:i:s", $endDate)) + ->whereBetweenTime('B.pay_time', $startDate, $endDate) ->where('B.mer_id', $merId) - ->where('B.paid', 1)->group('A.product_id')->limit(30)->order('total DESC')->fetchSql()->select(); + ->where('B.paid', 1)->group('A.product_id')->limit(30)->order('total DESC')->select(); $totalCount = 0; -// foreach ($list as $item) { -// $totalCount += $item['total']; -// } + foreach ($list as $item) { + $totalCount += $item['total']; + } return app('json')->success(compact('list', 'totalCount')); } @@ -151,6 +152,7 @@ class Merchant extends BaseController $startDate = $this->request->param('start_date'); $endDate = $this->request->param('end_date'); $merId = $this->request->param('mer_id'); + $endDate = date("$endDate H:i:s", time()); // $res = Cache::store('file')->remember(self::class . '@merchantProductVisit' . $merId . $startDate. $endDate, function () use ($repository, $startDate, $endDate, $merId) { // $list = UserVisit::getDB()->alias('A')->join('StoreProduct B', 'A.type_id = B.product_id') // ->join('Merchant C', 'C.mer_id = B.mer_id') @@ -168,12 +170,12 @@ class Merchant extends BaseController ->join('Merchant C', 'C.mer_id = B.mer_id') ->field(\think\facade\Db::raw('count(A.type_id) as total,B.image,B.store_name')) ->whereBetweenTime('A.create_time', $startDate, $endDate) - ->where('A.type', 'product')->where('B.mer_id', $merId)->group('A.type_id')->order('total DESC')->fetchSql() + ->where('A.type', 'product')->where('B.mer_id', $merId)->group('A.type_id')->order('total DESC') ->limit(30)->select(); $totalCount = 0; -// foreach ($list as $item) { -// $totalCount += $item['total']; -// } + foreach ($list as $item) { + $totalCount += $item['total']; + } return app('json')->success(compact('list', 'totalCount')); } @@ -182,6 +184,7 @@ class Merchant extends BaseController $startDate = $this->request->param('start_date'); $endDate = $this->request->param('end_date'); $merId = $this->request->param('mer_id'); + $endDate = date("$endDate H:i:s", time()); // $res = Cache::store('file')->remember(self::class . '@merchantProductCart' . $merId . $startDate. $endDate, function () use ($repository, $startDate, $endDate, $merId) { // $list = \app\common\model\store\product\Product::getDB()->alias('A')->leftJoin('StoreCart B', 'A.product_id = B.product_id') // ->field(\think\facade\Db::raw('sum(B.cart_num) as total,A.product_id,A.store_name,A.image')) @@ -200,11 +203,11 @@ class Merchant extends BaseController ->whereBetweenTime('B.create_time', $startDate, $endDate) ->where('A.mer_id', $merId) ->where('B.product_type', 0)->where('B.is_pay', 0)->where('B.is_del', 0) - ->where('B.is_new', 0)->where('B.is_fail', 0)->group('A.product_id')->limit(30)->order('total DESC')->fetchSql()->select(); + ->where('B.is_new', 0)->where('B.is_fail', 0)->group('A.product_id')->limit(30)->order('total DESC')->select(); $totalCount = 0; -// foreach ($list as $item) { -// $totalCount += $item['total']; -// } + foreach ($list as $item) { + $totalCount += $item['total']; + } return app('json')->success(compact('list', 'totalCount')); }