You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
cf-sdk/Application/Admin/Model/UserLoginRecordModel.class.php

93 lines
2.4 KiB
PHP

<?php
// +----------------------------------------------------------------------
// | OneThink [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: 麦当苗儿 <zuojiazi@vip.qq.com> <http://www.zjzit.cn>
// +----------------------------------------------------------------------
namespace Admin\Model;
use Think\Model;
/**
* 用户模型
* @author 麦当苗儿 <zuojiazi@vip.qq.com>
*/
class UserLoginRecordModel extends Model {
protected $_validate = array(
);
/* 自动完成规则 */
protected $_auto = array(
);
/**
* 构造函数
* @param string $name 模型名称
* @param string $tablePrefix 表前缀
* @param mixed $connection 数据库连接信息
*/
public function __construct($name = '', $tablePrefix = '', $connection = '') {
/* 设置默认的表前缀 */
$this->tablePrefix ='tab_';
/* 执行构造方法 */
parent::__construct($name, $tablePrefix, $connection);
}
/*
* 活跃用户
* @param array $map 条件数组
* @author 鹿文学
*/
public function active($map=array()) {
$data = $this->field(' DISTINCT user_id as user_id')
->where($map)->select();
return $data;
}
/*
* 投放平台-活跃用户
* @param integer $start 开始时间(时间戳)
* @param integer $end 结束时间(时间戳)
* @author 鹿文学
*/
public function active_by_launch_record($start,$end) {
$map['login_time'] = array('between',[$start,$end]);
$data = $this->alias('ul')->field('lr.platform_id,lr.platform_name,lr.promote_id,lr.promote_account,lr.game_id,lr.game_name,group_concat(DISTINCT ul.user_id) as activeids,count(DISTINCT ul.user_id) as active')
->join('right join tab_launch_record as lr on(ul.user_id=lr.user_id)')
->where($map)->group('lr.platform_id,lr.promote_id,lr.game_id')->select();
return $data;
}
/*
* 活跃用户总数
* @param array $map 条件数组
* @author 鹿文学
*/
public function active_count($map=array()) {
$data = $this->field('count( DISTINCT user_id) as count')
->where($map)->select();
return $data[0]?$data[0]['count']:0;
}
}