quanwei
2025-12-05 feda780069d64479c0c20493603717e100655da9
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
 
namespace app\supplier\model\user;
 
use app\common\model\user\Visit as VisitModel;
/**
 * 收藏模型
 */
class Visit extends VisitModel
{
    /**
     * 获取某天的访问数
     * $endDate不传则默认当天
     */
    public function getVisitData($startDate, $endDate, $shop_supplier_id){
        $model = $this;
        !is_null($startDate) && $model = $model->where('create_time', '>=', strtotime($startDate));
 
        if(is_null($endDate)){
            !is_null($startDate) && $model = $model->where('create_time', '<', strtotime($startDate) + 86400);
        }else{
            $model = $model->where('create_time', '<', strtotime($endDate) + 86400);
        }
 
        return $model->where('shop_supplier_id', '=', $shop_supplier_id)
            ->count();
    }
 
    /**
     * 获取某天的访客数
     * $endDate不传则默认当天
     */
    public function getVisitUserData($startDate, $endDate, $shop_supplier_id){
        $model = $this;
        !is_null($startDate) && $model = $model->where('create_time', '>=', strtotime($startDate));
 
        if(is_null($endDate)){
            !is_null($startDate) && $model = $model->where('create_time', '<', strtotime($startDate) + 86400);
        }else{
            $model = $model->where('create_time', '<', strtotime($endDate) + 86400);
        }
 
        $userIds = $model->distinct(true)
            ->where('shop_supplier_id', '=', $shop_supplier_id)
            ->column('visitcode');
        return count($userIds);
    }
}