190 lines
4.7 KiB
PHP
190 lines
4.7 KiB
PHP
<?php
|
|
|
|
require_once 'Entity.php';
|
|
/**
|
|
* Created by PhpStorm.
|
|
* User: xuxb
|
|
* Date: 2020/3/6
|
|
* Time: 20:40
|
|
*/
|
|
class User_entity extends Entity{
|
|
public $app_user_model;
|
|
|
|
public function __construct($param = 0){
|
|
if(is_numeric($param)){
|
|
$app_id = $param;
|
|
} elseif(is_array($param)) {
|
|
$app_id = $param['app_id'];
|
|
} else {
|
|
$app_id = 0;
|
|
}
|
|
parent::__construct($app_id);
|
|
|
|
$app_id && $this->init($app_id);
|
|
}
|
|
|
|
function init($app_id){
|
|
$this->app_id = $app_id;
|
|
switch($app_id){
|
|
case 1://狸车
|
|
$this->load->model('app/liche/app_liche_users_model', 'app_user_model');
|
|
$this->app_user_model = $this->ci->app_user_model;
|
|
break;
|
|
case 2://狸车宝
|
|
$this->load->model('app/licheb/app_licheb_users_model', 'app_user_model');
|
|
$this->app_user_model = $this->ci->app_user_model;
|
|
break;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 获取马甲列表
|
|
* @param int $page
|
|
* @param int $size
|
|
* @return array {"total":1, "list":[{"id":1, "title":"明"}]}
|
|
*/
|
|
public function majia($page = 0, $size = 0){
|
|
$total = 0;
|
|
$list = array();
|
|
|
|
switch($this->app_id){
|
|
case 1://尚柏卡
|
|
case 3://飞鱼
|
|
$where = array(
|
|
'group_id' => 4,
|
|
'status >=' => 0,
|
|
);
|
|
$total = $this->app_user_model->count($where);
|
|
if($total){
|
|
$select = 'id, nickname as title';
|
|
$list = $this->app_user_model->select($where, 'id DESC', $page, $size, $select);
|
|
}
|
|
break;
|
|
}
|
|
|
|
return array('total' => $total, 'list' => $list);
|
|
}
|
|
|
|
/**
|
|
* 获取用户信息
|
|
* @param $uid
|
|
* @return mixed
|
|
*/
|
|
public function info($uid){
|
|
return $this->app_user_model->get(array('id' => $uid));
|
|
}
|
|
|
|
/**
|
|
* 数量
|
|
* @param array $where
|
|
* @param string $distinct
|
|
* @return mixed
|
|
*/
|
|
public function count($where = array(), $distinct = ''){
|
|
return $this->app_user_model->count($where, $distinct);
|
|
}
|
|
|
|
/*
|
|
* 列表
|
|
* @param array $where
|
|
* @param string $order
|
|
* @param int $page
|
|
* @param int $size
|
|
* @param string $select
|
|
* @return mixed
|
|
*/
|
|
public function select($where = array(), $order = '', $page = 0, $size = 20, $select = ''){
|
|
return $this->app_user_model->select($where, $order, $page, $size, $select);
|
|
}
|
|
|
|
/**
|
|
* @param string $map_key
|
|
* @param string $map_value
|
|
* @param array $where
|
|
* @param string $order
|
|
* @param int $page
|
|
* @param int $size
|
|
* @param string $select
|
|
* @return mixed
|
|
*/
|
|
public function map($map_key = 'id', $map_value = '', $where = array(), $order = '', $page = 0, $size = 20, $select = ''){
|
|
return $this->app_user_model->map($map_key, $map_value, $where, $order, $page, $size, $select);
|
|
}
|
|
|
|
/**
|
|
* 获取用户信息
|
|
* @param $where
|
|
* @param string $select
|
|
* @return mixed
|
|
*/
|
|
public function get($where, $select = ''){
|
|
return $this->app_user_model->get($where, $select);
|
|
}
|
|
|
|
/**
|
|
* 更新用户信息
|
|
* @param $data
|
|
* @param $where
|
|
* @return mixed
|
|
*/
|
|
function update($data, $where){
|
|
return $this->app_user_model->update($data, $where);
|
|
}
|
|
|
|
/**
|
|
* 新增
|
|
* @param $data
|
|
* @return mixed
|
|
*/
|
|
function add($data){
|
|
return $this->app_user_model->add($data);
|
|
}
|
|
|
|
/**
|
|
* 手机号是否在黑名单内
|
|
* @param $mobile
|
|
* @return bool
|
|
*/
|
|
function is_black($mobile){
|
|
$cache_dir = APPPATH. '../admin/cache';
|
|
|
|
if (!file_exists($cache_dir)) {
|
|
debug_log("[error] ". __FUNCTION__ . "# {$cache_dir} not exist", $this->log_file);
|
|
return false;
|
|
}
|
|
|
|
$filename = "moblack_{$this->app_id}.txt";
|
|
$cache_dir = $cache_dir . '/';
|
|
if (!$filename) {
|
|
$filename = $cache_dir;
|
|
} else {
|
|
$filename = $cache_dir . $filename;
|
|
}
|
|
|
|
if (!file_exists($filename)) {
|
|
$oldumask = umask(0);
|
|
touch($filename);
|
|
chmod($filename, 0666);
|
|
umask($oldumask);
|
|
}
|
|
|
|
$res = file_get_contents($filename);
|
|
|
|
$blacks = $res ? json_decode($res, true) : array();
|
|
|
|
if(in_array($mobile, $blacks)){
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
/**
|
|
* 返回最后的sql
|
|
* @return mixed
|
|
*/
|
|
function last_query(){
|
|
return $this->app_user_model->db->last_query();
|
|
}
|
|
}
|