You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace app\api\service\statistics;
|
|
|
|
|
|
|
|
use app\api\model\GoodsBrowseLog;
|
|
|
|
use app\api\model\User;
|
|
|
|
use app\common\service\BaseService;
|
|
|
|
|
|
|
|
class UserData extends BaseService
|
|
|
|
{
|
|
|
|
protected User $userModel;
|
|
|
|
|
|
|
|
public function initialize()
|
|
|
|
{
|
|
|
|
parent::initialize(); // TODO: Change the autogenerated stub
|
|
|
|
$this->userModel = new User();
|
|
|
|
}
|
|
|
|
public function getUserData($startDate = null, $endDate = null): array
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'visitorCount' => 0,
|
|
|
|
'viewCount' => $this->getViewCount($startDate, $endDate),
|
|
|
|
'newUserCount' => 0,
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 用户访问总数
|
|
|
|
*/
|
|
|
|
public function getVisitorCount() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 用户浏览总数
|
|
|
|
*/
|
|
|
|
public function getViewCount($startDate = null, $endDate = null): string
|
|
|
|
{
|
|
|
|
$query = new GoodsBrowseLog();
|
|
|
|
if(!empty($startDate) && !empty($endDate)) {
|
|
|
|
$query->where('create_time', '>=', strtotime($startDate))
|
|
|
|
->where('create_time', '<', strtotime($endDate) + 86400);
|
|
|
|
}
|
|
|
|
$value = $query->group('user_id')->count();
|
|
|
|
return number_format($value);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 新用户数量
|
|
|
|
*/
|
|
|
|
public function getNewUserCount() {
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|