From 65294eb9444850ed9602823bfdd9ddbc11180ca8 Mon Sep 17 00:00:00 2001 From: yaooo <272523191@qq.com> Date: Wed, 23 Aug 2023 14:47:33 +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=E5=93=81=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 | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/app/controller/api/Auth.php b/app/controller/api/Auth.php index 9204e9df..e635a266 100644 --- a/app/controller/api/Auth.php +++ b/app/controller/api/Auth.php @@ -1013,4 +1013,39 @@ class Auth extends BaseController return app('json')->success($data); } + //根据地址信息查询商品数 + public function goodsStatistics() + { + $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); + } + $merIdArray = $queryBuilder->fetchSql(false)->column('mer_id'); + $prodQueryBuilder = Db::name('StoreProduct')->where('is_show', 1)->where('status', 1)->whereIn('mer_id', $merIdArray); + if ($startDate) { + $prodQueryBuilder = $prodQueryBuilder->whereTime('create_time', '>=', trim($startDate)); + } + if ($endDate) { + $prodQueryBuilder = $prodQueryBuilder->whereTime('create_time', '<=', trim($endDate) . ' 23:59:59'); + } + $prodNum = $prodQueryBuilder->fetchSql(false)->count(); + $data = [ + 'where' => $this->request->param(), + 'goods_num' => $prodNum + ]; + return app('json')->success($data); + } + }