Commit 655657b8 authored by hujun's avatar hujun

代码修改

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