You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
179 lines
6.4 KiB
179 lines
6.4 KiB
<?php
|
|
/**
|
|
* Created by ETEDU.
|
|
* User: Leo Chu
|
|
* Date: 2017/3/28 0028
|
|
* Time: 15:45
|
|
*/
|
|
|
|
namespace app\capital\model;
|
|
|
|
use think\Model;
|
|
use think\Db;
|
|
|
|
/**
|
|
* 文化四板申请流程
|
|
* @package app\admin\model
|
|
*/
|
|
class Capitalapply extends Model
|
|
{
|
|
|
|
/**
|
|
* 根据用户id获取用户信息,返回值为数组
|
|
* @param int $uid 用户id
|
|
* @return array 用户所属的用户组 array(根据前后台不同,对应不同用户组)
|
|
*/
|
|
public static function getUserInfos($uid,$utype)
|
|
{
|
|
if($utype==1)//前台用户
|
|
{
|
|
$db=db()->name('member_list');
|
|
$uids=[];
|
|
if(strpos($uid,',')===false){
|
|
$db->where("member_list_id='$uid'");
|
|
}else{
|
|
$db->where('member_list_id','in',$uid);
|
|
}
|
|
$frontUserInfos =$db->field('member_list_id,member_list_nickname,member_list_username,member_list_open')->select();
|
|
|
|
if(count($uids)){
|
|
$data=[];
|
|
foreach ($frontUserInfos as $row){
|
|
$mid=$row['member_list_id'];
|
|
$data[$mid]=$row;
|
|
}
|
|
foreach ($uids as $row){
|
|
if(!isset($data[$row]))$data[$row]=array();
|
|
}
|
|
return $data;
|
|
}else{
|
|
$frontUserInfos[$uid]=$frontUserInfos?:array();
|
|
return $frontUserInfos[$uid];
|
|
}
|
|
}elseif ($utype==2)//后台用户
|
|
{
|
|
$db=db()->name('admin');
|
|
$uids=[];
|
|
if(strpos($uid,',')===false){
|
|
$db->where("admin_id='$uid'");
|
|
}else{
|
|
$uids=explode(',', $uid);
|
|
$db->where('admin_id','in',$uids);
|
|
}
|
|
$backUserInfos = $db
|
|
->field('admin_id,admin_realname,admin_username,admin_open')->select();
|
|
|
|
if(count($uids)){
|
|
$data=[];
|
|
foreach ($backUserInfos as $row){
|
|
$mid=$row['admin_id'];
|
|
$data[$mid]=$row;
|
|
}
|
|
foreach ($uids as $row){
|
|
if(!isset($data[$row]))$data[$row]=array();
|
|
}
|
|
return $data;
|
|
}else{
|
|
$backUserInfos[$uid]=$backUserInfos?:array();
|
|
return $backUserInfos[$uid];
|
|
}
|
|
}
|
|
return array();
|
|
}
|
|
|
|
/**
|
|
* 根据角色id获取角色信息,返回值为数组
|
|
* @param int $rid 角色id
|
|
* @return array 角色所属的用户组 array(根据前后台不同,对应不同角色组)
|
|
*/
|
|
public static function getRoleInfos($rid,$utype)
|
|
{
|
|
if($utype==1)//前台角色
|
|
{
|
|
$frontRoleInfos = db()->name('member_group')
|
|
->where("member_group_id='$rid'")
|
|
->field('member_group_id,member_group_name,member_group_open')->select();
|
|
$frontRoleInfos[$rid]=$frontRoleInfos?:array();
|
|
return $frontRoleInfos[$rid];
|
|
}
|
|
elseif ($utype==2)//后台角色
|
|
{
|
|
$backRoleInfos = db()->name('auth_group')
|
|
->where("id='$rid'")
|
|
->field('id,title,status')->select();
|
|
$backRoleInfos[$rid]=$backRoleInfos?:array();
|
|
return $backRoleInfos[$rid];
|
|
}
|
|
return array();
|
|
}
|
|
/**
|
|
* 申请列表
|
|
* @param array
|
|
* @param string $search_name 查询条件(公司名称)
|
|
* @param int $status 后台查询的操作用户状态
|
|
* @param int $admin_id 后台查询的操作用户ID
|
|
* @param string $order 结果排序
|
|
* @return mixed
|
|
*/
|
|
public static function getListAll($search_name=null,$admin_id,$order='apply_id')
|
|
{
|
|
$map=array();
|
|
if($search_name){
|
|
//(b.c_name or b.p_name or b.t_apply_username) and b.new_flag
|
|
$data=array();
|
|
$data=Db::name('capitalapply')->alias("a")->join(config('database.prefix').'capitalbaseinfo b','a.apply_id =b.apply_id')
|
|
->where(['b.c_name|b.p_name|b.t_apply_username'=>array('like','%'.$search_name.'%') ,'b.new_flag'=>1])->order('a.apply_id')->paginate(config('paginate.list_rows'),false,['query'=>get_query()]);
|
|
return $data;
|
|
}
|
|
$where=array();
|
|
$where['status'] = array('egt',0);
|
|
|
|
//取得apply_admin_id为0或者当前用户的数据
|
|
//$where['apply_admin_id']=array(array('eq',0),array('eq',$admin_id),'or');
|
|
return self::where($where)->order($order)->paginate(config('paginate.list_rows'),false,['query'=>get_query()]);
|
|
}
|
|
/**
|
|
* 申请列表
|
|
* @param array
|
|
* @param string $search_name 查询条件(公司名称)
|
|
* @param int $status 后台查询的操作用户状态
|
|
* @param int $admin_id 后台查询的操作用户ID
|
|
* @param string $order 结果排序
|
|
* @return mixed
|
|
*/
|
|
public static function getList($search_name=null,$status=-1,$order='apply_id',$status2=-1,$apply_type=''){
|
|
if($order){
|
|
$orders=explode(",",$order);
|
|
foreach ($orders as &$item){
|
|
$item="a.".$item;
|
|
}
|
|
$order=implode(",",$orders);
|
|
}
|
|
if($search_name){
|
|
$where=['b.hoster_name|b.legal_person|b.natural_name'=>array('like','%'.$search_name.'%')];
|
|
$data=array();
|
|
$data=Db::name('capitalapply')->alias("a")->join(config('database.prefix').'capitalbaseinfo b','a.apply_id =b.apply_id')
|
|
->where($where)->order($order)->paginate(config('paginate.list_rows'),false,['query'=>get_query()]);
|
|
|
|
return $data;
|
|
}
|
|
$where=array();
|
|
//根据状态值取出对应状态的数据
|
|
if($status != -1){
|
|
$where['status'] = array('eq',$status);
|
|
}
|
|
if($status2 != -1){
|
|
$where['apply_status'] = 0;
|
|
}else{
|
|
$where['apply_status'] = array('neq',$status2);
|
|
}
|
|
if($apply_type){
|
|
$where['apply_type'] =$apply_type;
|
|
}
|
|
|
|
$list=Db::name('capitalapply')->alias("a")->join(config('database.prefix').'capitalbaseinfo b','a.apply_id =b.apply_id')
|
|
->where($where)->order($order)->paginate(config('paginate.list_rows'),false,['query'=>get_query()]);
|
|
// echo Db::name('capitalapply')->getLastSql();exit;
|
|
return $list;
|
|
}
|
|
}
|