update 数据之眼-首页-用户总量统计兼容区县/镇街查询
This commit is contained in:
parent
b3f263c57a
commit
58ddee111a
@ -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');
|
||||
|
Loading…
x
Reference in New Issue
Block a user