quanwei
2025-12-04 12913c1069347ea4b1f6ab87f480da0f8d8c646a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
 
namespace app\agent\model\user;
 
use app\common\model\user\Visit as VisitModel;
/**
 * 收藏模型
 */
class Visit extends VisitModel
{
    /**
     * 获取用户统计数量
     */
    public function getVisitData($startDate = null, $endDate = null, $type)
    {
        $model = $this;
        if(!is_null($startDate)){
            $model = $model->where('create_time', '>=', strtotime($startDate));
        }
        if(is_null($endDate)){
            $model = $model->where('create_time', '<', strtotime($startDate) + 86400);
        }else{
            $model = $model->where('create_time', '<', strtotime($endDate) + 86400);
        }
        if($type == 'visit_user'){
            $userIds = $model->distinct(true)->column('visitcode');
            return count($userIds);
        }else if($type == 'visit_count'){
            return $model->count();
        }
        return 0;
    }
}