130 lines
3.6 KiB
PHP
130 lines
3.6 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Notes:AppBase
|
|
* Created on: 2020/3/16 17:03
|
|
* Created by: dengbw
|
|
*/
|
|
abstract class AppBase extends HD_Controller
|
|
{
|
|
protected $app_id;
|
|
public $appUserAry = array();
|
|
private $map_app;
|
|
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->load->model('app/App_model', 'mdApp');
|
|
|
|
if(!$this->app_id){
|
|
$app_id = intval($this->input->get_post('app_id'));
|
|
$app_id && $this->app_id = $app_id;
|
|
} else {
|
|
$app_id = $this->app_id;
|
|
}
|
|
|
|
$this->data['app_id'] = $this->app_id = $app_id;
|
|
}
|
|
|
|
/**
|
|
* Notes:所属小程序
|
|
* Created on: 2020/3/16 12:00
|
|
* Created by: dengbw
|
|
* @return array
|
|
*/
|
|
public function app_list()
|
|
{
|
|
if ($this->app_id) {
|
|
$appList[] = $this->mdApp->get(array("id" => $this->app_id), 'id,name');
|
|
} else {
|
|
$appList[] = array("id" => "0", "name" => "选择小程序");
|
|
$resApp = $this->mdApp->select('', 'id DESC', 0, 0, 'id,name');
|
|
if ($resApp) {
|
|
foreach ($resApp as $key => $value) {
|
|
$setValue = array();
|
|
$setValue['id'] = $value['id'];
|
|
$setValue['name'] = $value['name'];
|
|
$appList[$value['id']] = $setValue;
|
|
}
|
|
}
|
|
}
|
|
return $appList;
|
|
}
|
|
|
|
/**
|
|
* 获取管理员可操作的app列表
|
|
* @return mixed
|
|
*/
|
|
function admin_apps(){
|
|
if(SUPER_ADMIN == $this->role){
|
|
$where = array();
|
|
} else {
|
|
$app_ids = $_SESSION['admin_info']['app_id'];
|
|
if($app_ids){
|
|
$str_ids = implode(',', $app_ids);
|
|
$where = array("id in({$str_ids})" => null);
|
|
} else {
|
|
$where = array('id' => -1);
|
|
}
|
|
}
|
|
|
|
$rows = $this->mdApp->select($where, 'id asc', 0, 0, 'id,name');
|
|
|
|
return $rows;
|
|
}
|
|
|
|
/**
|
|
* Notes:获取小程序详情
|
|
* Created on: 2020/3/16 14:57
|
|
* Created by: dengbw
|
|
* @return array
|
|
*/
|
|
public function app_info()
|
|
{
|
|
$info = array();
|
|
if ($this->app_id) {
|
|
$info = $this->mdApp->get(array("id" => $this->app_id), 'id,name,logo,jsondata');
|
|
$info['jsondata'] = $info['jsondata'] ? json_decode($info['jsondata'], true) : '';
|
|
}
|
|
return $info;
|
|
}
|
|
|
|
|
|
/**
|
|
* Notes:获取用户
|
|
* Created on: 2020/4/17 10:18
|
|
* Created by: dengbw
|
|
* @param int $app_id
|
|
* @param int $app_uid
|
|
* @return array
|
|
*/
|
|
public function app_user($app_id = 0, $app_uid = 0)
|
|
{
|
|
$app_id = $app_id ? $app_id : $this->app_id;
|
|
if (!$this->appUserAry[$app_id]) {
|
|
if ($this->mdApp->appConfig()[$app_id]['model']) {
|
|
$this->load->model($this->mdApp->appConfig()[$app_id]['model'], 'mdAppUser');
|
|
$this->appUserAry[$app_id] = $this->mdAppUser;
|
|
}
|
|
}
|
|
$res = array();
|
|
if ($app_uid && $this->appUserAry[$app_id]) {
|
|
$res = $this->appUserAry[$app_id]->get(array('id' => $app_uid), 'nickname,mobile');
|
|
}
|
|
return $res;
|
|
}
|
|
|
|
public function get_app($app_id = 0){
|
|
$map_app = $this->map_app;
|
|
if(!$map_app){
|
|
$map_app = $this->mdApp->map('id','*', '', 'id DESC', 0, 0, 'id,name');
|
|
$this->map_app = $map_app;
|
|
}
|
|
if($app_id){
|
|
return $map_app[$app_id];
|
|
}
|
|
|
|
return $map_app ? $map_app : array();
|
|
}
|
|
}
|