From 58ddee111a03beba6434ae18e20447c466658b59 Mon Sep 17 00:00:00 2001 From: chenbo <709206448@qq.com> Date: Thu, 7 Dec 2023 18:36:02 +0800 Subject: [PATCH] =?UTF-8?q?update=20=20=E6=95=B0=E6=8D=AE=E4=B9=8B?= =?UTF-8?q?=E7=9C=BC-=E9=A6=96=E9=A1=B5-=E7=94=A8=E6=88=B7=E6=80=BB?= =?UTF-8?q?=E9=87=8F=E7=BB=9F=E8=AE=A1=E5=85=BC=E5=AE=B9=E5=8C=BA=E5=8E=BF?= =?UTF-8?q?/=E9=95=87=E8=A1=97=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/api/dataview/User.php | 31 ++++++++++++++++------------ 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/app/controller/api/dataview/User.php b/app/controller/api/dataview/User.php index 145697d3..aef30ed0 100644 --- a/app/controller/api/dataview/User.php +++ b/app/controller/api/dataview/User.php @@ -67,21 +67,26 @@ class User extends BaseController $endCurrDay1 = $startCurrDay1+ 86399; $userCountlist[] = $this->getTimeRangeUserCount([$startCurrDay1, $endCurrDay1]); - // 地方店铺数量统计 - // 该地区下所有乡镇 - $geoStreetList = Db::name('geo_street')->where('area_code',$this->areaCode)->select()->toArray(); - // 遍历统计每个乡镇的店铺数 $merchantTotalCount = 0; - foreach ($geoStreetList as $street) { - $temp['street_name'] = $street['street_name']; - $temp['merchant_count'] = Db::name('merchant')->where('street_id', $street['street_code'])->count(); - $merchantTotalCount += $temp['merchant_count']; - $merchatCountList[] = $temp; - unset($temp); + + // 查镇的用户统计不需要查店铺数 + if ($this->streetCode != '') { + + // 该地区下所有乡镇 + $geoStreetList = Db::name('geo_street')->where('area_code',$this->areaCode)->select()->toArray(); + + foreach ($geoStreetList as $street) { + $temp['street_name'] = $street['street_name']; + $temp['merchant_count'] = Db::name('merchant')->where('street_id', $street['street_code'])->count(); + $merchantTotalCount += $temp['merchant_count']; + $merchatCountList[] = $temp; + unset($temp); + } } + return app('json')->success(compact('merchantTotalCount' ,'userCountlist', 'merchatCountList')); } public function getTimeRangeUserCount($timeRange=[]) @@ -96,7 +101,7 @@ class User extends BaseController $query->where('ua.district', $this->areaCode); } }) - ->whereTime('u.create_time', 'between', $timeRange)->fetchSql() + ->whereTime('u.create_time', 'between', $timeRange) ->count(); // 访问 @@ -109,7 +114,7 @@ class User extends BaseController $query->where('ua.district', $this->areaCode); } }) - ->whereTime('u.last_time', 'between', $timeRange)->fetchSql() + ->whereTime('u.last_time', 'between', $timeRange) ->count(); // 累计 @@ -122,7 +127,7 @@ class User extends BaseController $query->where('ua.district', $this->areaCode); } }) - ->whereTime('u.create_time', '<', $timeRange[1])->fetchSql() + ->whereTime('u.create_time', '<', $timeRange[1]) ->count(); return compact('newUserCount', 'viewUserCount', 'totalUserCount');