Commit 655657b8 authored by hujun's avatar hujun

代码修改

parent 098362ce
......@@ -23,88 +23,81 @@ namespace app\index\controller;
use app\index\extend\Basic;
use app\model\AAgents;
use app\model\Agents;
use think\Session;
class Agent extends Basic
{
protected $authGroupModel;
protected $authRuleModel;
function _initialize()
{
}
//经纪人显示页面
/**
* 经纪人显示页面
*
* @return \think\response\View3
*/
public function agent(){
return view('agent');
}
//编辑页面
/**
* 编辑页面
*
* @return \think\response\View
*/
public function saveAgentIndex(){
return view('save_agent');
}
/*********************接口******************************/
/**首页显示列表【接口】
/**
* 首页显示列表
*
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function AgentList(){
$table= new Agents();
$table= new AAgents();
$data['status'] = 200;
$data['msg'] = '';
//获取当前模块可操作按钮start********************************
$userRule = Session::get('userRule');
$data['cz']=$userRule['cz'];
//获取当前模块可操作按钮end**********************************
$params = $this->request->param();
//获取操作权限
$userRule=Session::get('userRule');
$data['userRule']=$userRule;
$pageNo = empty($params['pageNo']) ? 1 : $params['pageNo'];
$userRule = Session::get('userRule');
$data['userRule'] = $userRule;
$pageNo = empty($params['pageNo']) ? 1 : $params['pageNo'];
$pageSize = empty($params['pageSize']) ? 15 : $params['pageSize'];
//条件
$where='a.status in(0,1)';
$search=$params['search'];
// prt($data);
if(!empty($search)){
$where.=" and a.id='$search' or a.name like '%$search%' or a.phone like '%$search%' ";
$where = 'a.status in(0,1)';
$search = $params['search'];
$data['search']=$search;
if(!empty($search)){
$where .= " and a.id='$search' or a.name like '%$search%' or a.phone like '%$search%' ";
$data['search'] = $search;
}
if(!empty($params['groupname'])){
$where.=" and g.title like '%{$params['groupname']}%' ";
$data['groupname']=$params['groupname'];
$where .= " and g.title like '%{$params['groupname']}%' ";
$data['groupname'] = $params['groupname'];
}
if(!empty($params['store_name'])){
$where.=" and s.store_name like '%{$params['store_name']}%' ";
$data['store_name']=$params['store_name'];
$where .=" and s.store_name like '%{$params['store_name']}%' ";
$data['store_name'] = $params['store_name'];
}
$field="a.id,a.store_id,a.district_id,a.`level`,a.`name`,a.phone,a.`status`,a.inviter_id,a.create_time,
ifnull(s.store_name,'')store_name,ifnull(d.district_name,'')district_name,ifnull(g.title,'无')groupname";
$order='a.id asc';
$join=[
$field = "a.id,a.store_id,a.district_id,a.`level`,a.`name`,a.phone,a.`status`,a.inviter_id,a.create_time,
ifnull(s.store_name,'')store_name,ifnull(d.district_name,'')district_name,ifnull(g.title,'无')groupname";
$order = 'a.id asc';
$join = [
['a_store s', ' a.store_id=s.id','left'],
['a_district d','a.district_id=d.id','left'],
['auth_group g','a.auth_group_id=g.id','left']
];
$data['list'] = $table->getListJoin($pageNo, $pageSize,$order,$field,$join, $where);
$data['total'] = $table->getTotal2($join,$where);
// prt($list);//转化arr
//prt(collection($list)->toArray());//转化arr
return $this->response(200,'成功',$data);
}
/*
* 新增or修改or查看
* $group_id !=0为查看
......@@ -118,101 +111,89 @@ class Agent extends Basic
* @throws \think\exception\DbException
*/
public function saveAgent(){
$group_id=$this->request->param('id');
$table= New AAgents;
$group_id = $this->request->param('id');
$table = new AAgents();
if ($this->request->isPost()) {
$data = input('post.');
//新增或者编辑数据
if(empty($data['id'])){
$data['create_time']= date( 'Y-m-d H:i:s',time());
$data['update_time']= date( 'Y-m-d H:i:s',time());
$id='';
}else{
$data['update_time']= date( 'Y-m-d H:i:s',time());
$id=$data['id'];
if(empty($data['id'])) {
$data['create_time'] = date( 'Y-m-d H:i:s',time());
$data['update_time'] = date( 'Y-m-d H:i:s',time());
$id = '';
} else {
$data['update_time'] = date( 'Y-m-d H:i:s',time());
$id = $data['id'];
}
//判断name是否重复
if($table->repetition('phone',$data['phone'])&& empty($id)){
//判断name是否重复
if($table->repetition('phone',$data['phone']) && empty($id)) {
return $this->response(100, '存在重复值');
}
if ($table->editData($data,$id)) {
return $this->response(200, '成功');
} else {
return $this->response(100, '无修改');
}
} else {
//查看
$info= $table->where('id',$group_id)->find();
//echo $table->getLastSql();
$info = $table->where('id',$group_id)->find();
return $this->response(200, '查看', $info);
}
}
//删除(冻结)
public function updateStatus(){
$data=$this->request->param();
$ids=$data['ids'];
/**
* 删除(冻结)
*
* @return \think\Response
*/
public function updateStatus(){
$data = $this->request->param();
$ids = $data['ids'];
//排除超级管理员
if (is_array($ids)) {
if (in_array(1, $ids)) {
return $this->response(100,'超级管理员不允许操作',$data);
}
} else {
if ($ids === 1) {
return $this->response(100,'超级管理员不允许操作',$data);
}
if (is_array($ids)) {
if (in_array(1, $ids)) {
return $this->response(100,'超级管理员不允许操作',$data);
}
} else {
if ($ids === 1) {
return $this->response(100,'超级管理员不允许操作',$data);
}
$table= New AAgents;
}
if($table->saveStatus('status',$data['status'],$ids)){
$table = new AAgents();
if($table->saveStatus('status', $data['status'], $ids)){
return $this->response(200,'成功',$data);
}else{
return $this->response(100,'失败',$data);
}
}
/**
* 批量变更角色
*
* @post ids 用户组id
* @post group_id 变更的角色组id
*/
public function updateRole(){
$table=New AAgents;
$data=$this->request->param();
$ids=trim($data['ids'],',');
if(!empty($ids)&&!empty($data['group_id'])){
if($table->saveStatus('auth_group_id',$data['group_id'],$ids)){
return $this->response(200,'成功',$data);
}
return $this->response(100,'失败',$data);
}else{
return $this->response(100,'数据为空',$data);
}
$table = New AAgents;
$data = $this->request->param();
$ids = trim($data['ids'],',');
$code = 200;
if(!empty($ids) && !empty($data['group_id'])) {
if($table->saveStatus('auth_group_id', $data['group_id'], $ids)){
$msg = '成功';
} else {
$code = '100';
$msg = '失败';
}
} else {
$msg = '数据为空';
$code = 100;
}
return $this->response($code,$msg, $data);
}
}
\ No newline at end of file
......@@ -32,6 +32,8 @@ class Login extends Basic
}
/**
* 登录接口
*
* @return \think\Response
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment