Files
spacestation/admin/controllers/sys/Vlog.php
T
2025-11-08 23:07:53 +08:00

101 lines
2.9 KiB
PHP

<?php
defined('BASEPATH') or exit('No direct script access allowed');
class Vlog extends HD_Controller
{
public function __construct()
{
parent::__construct();
$this->load->model('biz/biz_visit_log_model');
$this->load->model('biz/biz_model');
$this->load->model("sys/sys_admin_model");
}
public function index()
{
return $this->lists();
}
public function lists()
{
$params = $this->input->get();
$page = $this->input->get('page');
!$page && $page = 1;
$pageSize = 20;
$where = [];
if ($params['user_name']) {
$uids = 0;
$userList = $this->sys_admin_model->select(["username like '%{$params['user_name']}%'" => null], '', '', '', 'id,username');
if ($userList) {
$uids = implode(',', array_column($userList, 'id'));
}
$where["uid in ($uids)"] = null;
}
if ($params['biz_name']) {
$bizs = 0;
$bizList = $this->biz_model->select(["biz_name like '%{$params['biz_name']}%'" => null], '', '', '', 'id,biz_name');
if ($bizList) {
$bizs = implode(',', array_column($bizList, 'id'));
}
$where["biz_id in ($bizs)"] = null;
}
if ($params['c_time']) {
$c_time = explode(' ~ ', $params['c_time']);
$c_time[0] && $where["createTime >="] = $c_time[0] . ' 00:00:00';
$c_time[1] && $where["createTime <="] = $c_time[1] . ' 23:59:59';
}
$rows = $this->biz_visit_log_model->select($where, 'id desc', $page, $pageSize);
$count = $this->biz_visit_log_model->count($where);
$list = [];
if ($rows) {
$bizIds = implode(',', array_unique(array_column($rows, 'biz_id')));
!$bizIds && $bizIds = 0;
$bizs = $this->biz_model->map('id', 'biz_name', ["id in ({$bizIds})" => null]);
$userIds = implode(',', array_unique(array_column($rows, 'uid')));
!$userIds && $userIds = 0;
$users = $this->sys_admin_model->map('id', 'username', ["id in ({$userIds})" => null]);
foreach ($rows as $v) {
$v['url'] = explode('?', $v['url'])[0];
$v['biz_name'] = $bizs[$v['biz_id']] ?: '';
$v['username'] = $users[$v['uid']] ?: '';
$list[] = $v;
}
}
$this->data['params'] = $params;
$this->data['lists'] = $list;
$this->data['_title'] = '小程序访问日志';
$this->data['pager'] = array('count' => ceil($count / $pageSize), 'curr' => $page, 'totle' => $count);
$this->show_view('sys/vlog/lists', true);
}
public function add()
{
}
public function get()
{
}
public function edit()
{
}
public function batch()
{
}
public function export()
{
}
public function del()
{
}
}