From 6b58878cbf0740bf28932964d8be35dbd5d22bb7 Mon Sep 17 00:00:00 2001 From: yaooo <272523191@qq.com> Date: Wed, 23 Aug 2023 14:33:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=A0=B9=E6=8D=AE=E5=9C=B0?= =?UTF-8?q?=E5=8C=BA=E6=9F=A5=E8=AF=A2=E5=95=86=E6=88=B7=E6=80=BB=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/api/Auth.php | 46 ++++++++++++++++++++++++++++++++----- route/api.php | 2 ++ 2 files changed, 42 insertions(+), 6 deletions(-) diff --git a/app/controller/api/Auth.php b/app/controller/api/Auth.php index 12990812..9204e9df 100644 --- a/app/controller/api/Auth.php +++ b/app/controller/api/Auth.php @@ -891,11 +891,11 @@ class Auth extends BaseController { $cityCode = $this->request->param('city_code', ''); $districtCode = $this->request->param('district_code', ''); - $streetCode = $this->request->param('street_code'); + $streetCode = $this->request->param('street_code', ''); $villageCode = $this->request->param('village_code', ''); $brigadeId = $this->request->param('brigade_id', 0); - $startDate = $this->request->param('start_date', date('Y-m-d')); - $endDate = $this->request->param('end_date', date('Y-m-d')); + $startDate = $this->request->param('start_date', ''); + $endDate = $this->request->param('end_date', ''); $queryBuilder = Db::name('ProductOrderLog')->where('status', 1); if ($cityCode) { $queryBuilder = $queryBuilder->where('city_code', $cityCode); @@ -936,11 +936,11 @@ class Auth extends BaseController [$page, $limit] = $this->getPage(); $cityCode = $this->request->param('city_code', ''); $districtCode = $this->request->param('district_code', ''); - $streetCode = $this->request->param('street_code'); + $streetCode = $this->request->param('street_code', ''); $villageCode = $this->request->param('village_code', ''); $brigadeId = $this->request->param('brigade_id', 0); - $startDate = $this->request->param('start_date', date('Y-m-d')); - $endDate = $this->request->param('end_date', date('Y-m-d')); + $startDate = $this->request->param('start_date', ''); + $endDate = $this->request->param('end_date', ''); $queryBuilder = Db::name('ProductOrderLog')->where('status', 1); if ($cityCode) { $queryBuilder = $queryBuilder->where('city_code', $cityCode); @@ -979,4 +979,38 @@ class Auth extends BaseController return app('json')->success(compact('count', 'list')); } + //根据地址信息查询商家数 + public function merStatistics() + { + $districtCode = $this->request->param('district_code', ''); + $streetCode = $this->request->param('street_code', ''); + $villageCode = $this->request->param('village_code', ''); + $startDate = $this->request->param('start_date', ''); + $endDate = $this->request->param('end_date', ''); + $villageId = Db::name('GeoVillage')->where('village_code', $villageCode)->fetchSql(false)->value('village_id', 0); + $queryBuilder = Db::name('Merchant')->where('status', 1); + + if ($districtCode) { + $queryBuilder = $queryBuilder->where('area_id', $districtCode); + } + if ($streetCode) { + $queryBuilder = $queryBuilder->where('street_id', $streetCode); + } + if ($villageId) { + $queryBuilder = $queryBuilder->where('village_id', $villageId); + } + if ($startDate) { + $queryBuilder = $queryBuilder->whereTime('create_time', '>=', trim($startDate)); + } + if ($endDate) { + $queryBuilder = $queryBuilder->whereTime('create_time', '<=', trim($endDate) . ' 23:59:59'); + } + $merNum = $queryBuilder->fetchSql(false)->count(); + $data = [ + 'where' => $this->request->param(), + 'mer_num' => $merNum + ]; + return app('json')->success($data); + } + } diff --git a/route/api.php b/route/api.php index 17fe0b26..1ca179d9 100644 --- a/route/api.php +++ b/route/api.php @@ -25,6 +25,8 @@ Route::group('api/', function () { Route::post('goods/take/:id', 'api.Auth/deliveryGoods'); Route::get('order/statistics', 'api.Auth/orderStatistics'); Route::get('region/order', 'api.Auth/orderList'); + Route::get('region/merchant', 'api.Auth/merStatistics'); + Route::get('region/goods', 'api.Auth/goodsStatistics'); Route::resource('upload', 'api.Upload'); Route::post('articleCatch', 'api.Upload/article'); //强制登录