43 lines
1.1 KiB
PHP
43 lines
1.1 KiB
PHP
<?php
|
|
|
|
|
|
namespace app\common\model\user;
|
|
|
|
|
|
use app\common\model\BaseModel;
|
|
use think\model\concern\SoftDelete;
|
|
|
|
/**
|
|
* 用户访问表
|
|
* Class UserVisit
|
|
* @package app\common\model
|
|
*/
|
|
class UserVisit extends BaseModel
|
|
{
|
|
use SoftDelete;
|
|
protected $pk = 'id';
|
|
|
|
protected $deleteTime = 'delete_time';
|
|
|
|
/**
|
|
* 用户趋势数据
|
|
* @param $time
|
|
* @param $type
|
|
* @param $timeType
|
|
* @param $str
|
|
* @return mixed
|
|
*/
|
|
public function getTrendData($time, $type, $timeType, $str)
|
|
{
|
|
return $this->when($type != '', function ($query) use ($type) {
|
|
$query->where('channel_type', $type);
|
|
})->where(function ($query) use ($time) {
|
|
if ($time[0] == $time[1]) {
|
|
$query->whereDay('create_time', $time[0]);
|
|
} else {
|
|
$time[1] = $time[1] + 86400;
|
|
$query->whereTime('create_time', 'between', $time);
|
|
}
|
|
})->field("FROM_UNIXTIME(create_time,'$timeType') as days,$str as num")->group('days')->select()->toArray();
|
|
}
|
|
} |