Browse Source

Merge branch 'liuxiangxin' into jun

jun 4 months ago
parent
commit
51c8befb76

+ 1 - 0
app/Facades/Servers/WeiBan/OpenApi.php

@@ -11,6 +11,7 @@ use Illuminate\Support\Facades\Facade;
  * @method static array  getUserListByPhone($phone)                                                         通过手机获取用户列表
  * @method static array  getTagList(int $limit=100,int $offset=0)                                           获取标签列表
  * @method static array  markTags($extUserid,$addTags,$rmTags,$staffId)                                     给客户打标签
+ * @method static array  addTag($staffId,$extUserid,$tagGroup,$tagName)                                     给客户添加企业标签
  * 
  * @see \App\Servers\WeiBan\OpenApi
  * 

+ 55 - 107
app/Http/Controllers/Admin/AdminUser.php

@@ -24,74 +24,53 @@ class AdminUser extends Auth{
 	 * 列表页
 	 * 
 	 * */
-    public function index(Model $Model){
-        $mp                     =   [];
-        $session                = session('userRule');
-        if ($session){
-            $mp[]               =   ['admin_rule.company_id','=',$session['company_id']];
-            if ($session['business_id']){
-                $mp[]               =   ['admin_rule.business_id','=',$session['business_id']];
-            }
-        }
-        if(!in_array(admin('uid'), explode(',', config('administrator')))){
-            $mp['admin_rule.type']       = 1;
+    public function index(Model $Model,Business $Business,Company $Company){
+		// 查询数据
+        $map                     	= [];
+		// 当前登录用户角色数据
+        $session				 	= session('userRule') ? session('userRule') : ['menu_type'=>0,'company_id'=>1,'business_id'=>0];
+		// 非超管
+		if( !in_array(admin('uid'), explode(',', config('administrator'))) ){
+			// 规格条件
+            $map[]					= ['admin_rule.type','=',1];
+			$map[]                	= ['admin_rule.company_id','=',$session['company_id']];
+            if ($session['business_id']) $map[] = ['admin_rule.business_id','=',$session['business_id']];
         }
  		// 查询系统用户
-		$list					= $Model::query();
-		if($mp) 				$list->join('admin_rule','admin_rule.admin_uid','=','admin.uid');
-        $list					= $list->where($mp)
-                                ->orderByDesc('admin.uid')
-                                ->paginate(config('page_num',10));
+		$list						= $Model->query()->join('admin_rule','admin_rule.admin_uid','=','admin.uid','LEFT')->where($map)->orderByDesc('admin.uid')->paginate(config('page_num',10));
 		// 循环处理
 		foreach ($list as $key => $value) {
 			// 获取分组名
-			$group				= DB::table('auth_group')
+			$group					= DB::table('auth_group')
 									->join('auth_group_access','auth_group_access.group_id','=','auth_group.id')
 									->where([['auth_group_access.user_uid','=',$value['uid']]])
 									->pluck('auth_group.title')->toArray();
-			if (in_array($value['uid'],explode(',',config('administrator')))) $group[] = '超管';
+			// 返回结果
+			if ( in_array($value['uid'],explode(',',config('administrator'))) ) $group[] = '超管';
 			// 切成字符串
-			$value['title']		= implode('、', $group);
+			$value['title']			= implode('、', $group);
             //获取用户角色
-            $rule               = DB::table('admin_rule')->where('admin_uid',$value['uid'])->first();
-            $rule_title         =   '';
-            if ($rule){
-                switch ($rule['menu_type']){
-                    case 1:
-                        $rule_title         =  '商户';
-                        break;
-                    case 2:
-                        $rule_title         =  '店铺';
-                        break;
-                }
-                if ($rule['menu_type'] == 1){
-                    if ($rule['data_type'] == 1){
-                        $rule_title     =   '商户普通员工';
-                    }elseif ($rule['data_type'] == 2){
-                        $rule_title     =   '商户代表';
-                    }
-                }elseif ($rule['menu_type'] == 2){
-                    if ($rule['data_type'] == 1){
-                        $rule_title     =   '店铺普通员工';
-                    }elseif ($rule['data_type'] == 2){
-                        $rule_title     =   '店铺推广员';
-                    }
-                }
+            $rule               	= DB::table('admin_rule')->where('admin_uid',$value['uid'])->first();
+			// 角色标题
+            $rule_title         	= '';
+			// 角色标题
+            if ( $rule )			{
+				if( $rule['menu_type'] == 1 && $rule['data_type'] == 1 )  $rule_title     =   '商户普通员工';
+				if( $rule['menu_type'] == 1 && $rule['data_type'] == 2 )  $rule_title     =   '商户代表';
+				if( $rule['menu_type'] == 2 && $rule['data_type'] == 1 )  $rule_title     =   '店铺普通员工';
+				if( $rule['menu_type'] == 2 && $rule['data_type'] == 2 )  $rule_title     =   '店铺推广员';
             }
-            $value['rule_title']    =   $rule_title;
-            $value['business_name']         =   '';
-            if ($value['business_id']){
-                $value['business_name']      =  Business::query()->where('id', $value['business_id'])->value('name');
-            }
-            $value['company_name']      =   Company::query()->where('id', $value['company_id'])->value('name');
+            $value['rule_title']    = $rule_title;
+            $value['business_name'] = $value['business_id'] ? (string)$Business->getOne($value['business_id'] ,'name') : '';
+            $value['company_name']  = $value['company_id'] ? $Company->getOne($value['company_id'],'name') : '';
 			// 重组
-			$list[$key]			= $value;
+			$list[$key]				= $value;
 		}
 		// 分配数据
 		$this->assign('empty', '<tr><td colspan="20">~~暂无数据</td></tr>');
 		$this->assign('list',$list);
 		// 加载模板
-		return $this->fetch();   
+		return						$this->fetch();   
     }
 
 	/**
@@ -110,14 +89,13 @@ class AdminUser extends Auth{
 			$data['password']					= request('password','');
 			$data['password']					= md5($data['password']);
             $dataType		        			= request('data_type',1);
+			$groups								= (array) request('groups',[]);
 			// 角色数据
             $ruleData               			= ['menu_type'=>1,'data_type'=>$dataType,'type'=>1,'company_id'=>1,'business_id'=>0];
 			// 修改数据
 			if( $session['menu_type'] ) 		$ruleData['menu_type'] = $session['menu_type'];
 			if( $session['company_id'] ) 		$ruleData['company_id'] = $session['company_id'];
 			if( $session['business_id'] ) 		$ruleData['business_id'] = $session['business_id'];
-			// 所属权限组
-			$groups								= (array) request('groups',[]);
 			// 开启事务
 			DB::beginTransaction();
 			// 写入数据表
@@ -161,37 +139,24 @@ class AdminUser extends Auth{
 			// 告知结果
 			return								json_send(['code'=>'success','msg'=>'新增成功','action'=>'add']);
 		}
-		$whereGroup = [];
+		// 查询条件
+        $map  									= [];
 		// 如果不是超管 查询当前用户所属组
-		$administrator = explode(',', config('administrator'));
-		/*if(!in_array(admin('uid'),$administrator)){
-		    //用户所属组
-			$gsGroup = DB::table('auth_group_access')->where(['user_uid'=>admin('uid')])->pluck('group_id')->toArray();
-			//用户所属组 上级
-			$upGroup = DB::table('auth_group')->whereIn('id',$gsGroup)->pluck('group_pid')->toArray();
-			//用户所属组的下级
-			$groupLower = DB::table('auth_group')->whereIn('group_pid',$gsGroup)->pluck('id')->toArray();
-			//var_dump($groupLower);
-		    $whereGroup = array_merge($upGroup,$gsGroup,$groupLower);
-		}*/
-        $where  =   [];
-        if(!in_array(admin('uid'),$administrator)){
-            if($session && $session['menu_type'] ) 		    $where['menu_type'] = $session['menu_type'];
-            if($session && $session['company_id'] ) 		$where['company_id'] = $session['company_id'];
-            if($session && $session['business_id'] ) 		$where['business_id'] = $session['business_id'];
-            $where['type']       = 1;
+        if(!in_array(admin('uid'),explode(',', config('administrator')))){
+			$map[]       									= ['type','=',1];
+            if($session && $session['menu_type'] ) 		    $map[] = [['menu_type'],'=',$session['menu_type']];
+            if($session && $session['company_id'] ) 		$map[] = [$map['company_id'],'=',$session['company_id']];
+            if($session && $session['business_id'] ) 		$map[] = [$map['business_id'],'=',$session['business_id']];
         }
 		// 查询用户组
-	    $query 						= DB::table('auth_group');
-	    if($where) 			        $query->where($where);
-		$group						= $query->whereNotIn('id',explode(',',config('CUSTOM_GROUP')))->select(['id','title'])->get()->toArray();
+	    $group 									= DB::table('auth_group')->where($map)->select(['id','title'])->get()->toArray();
 		// 错误告知
-		if( !$group )				$this->error('请先添加用户组');
+		if( !$group )							$this->error('请先添加用户组');
 		// 分配数据
 		$this->assign('group',$group);
 		$this->assign('crumbs','新增');
 		// 加载模板
-		return						$this->fetch(); 
+		return									$this->fetch(); 
 	}
 
 	/**
@@ -202,13 +167,10 @@ class AdminUser extends Auth{
 		// 接收参数
 		$uid									= request('uid',0);
 		// 查询用户
-		$oldData								= $Model
-                    ->join('admin_rule','admin_rule.admin_uid','=','admin.uid')
-                    ->where(['uid'=>$uid])
-                    ->select('admin.*','admin_rule.data_type','admin_rule.menu_type')
-                    ->first();
+		$oldData								= $Model->query()->join('admin_rule','admin_rule.admin_uid','=','admin.uid','LEFT')->where(['uid'=>$uid])->first();
         // 当前登录用户角色数据
         $session							    = session('userRule') ? session('userRule') : ['menu_type'=>0,'company_id'=>0,'business_id'=>0];
+		// 修改提交
 		if(request()->isMethod('post')){
 			// 验证参数
 			$request->scene('edit')->validate();
@@ -216,18 +178,18 @@ class AdminUser extends Auth{
 			$data['username']					= request('username','');
 			$data['phone']						= request('phone','');
 			$dataType			    			= request('data_type',1);
+			$groups								= (array) request('groups',[]);
 			// 角色数据
             $ruleData               			= $AdminRule::query()->where([['admin_uid','=',$uid]])->first(['id','admin_uid','menu_type','data_type','type','company_id','business_id']);
 			// 如果不存在的话
-			$ruleData							= $ruleData ? $ruleData->toArray() : ['admin_uid'=>$uid,'menu_type'=>1,'data_type'=>$dataType,'type'=>1,'company_id'=>1,'business_id'=>0];
+			$ruleData							= $ruleData ? $ruleData->toArray() : ['admin_uid'=>$uid,'menu_type'=>0,'data_type'=>$dataType,'type'=>1,'company_id'=>1,'business_id'=>0];
 			// 修改数据
+			if( $dataType ) 					$ruleData['data_type'] = $dataType;
 			if( $session['menu_type'] ) 		$ruleData['menu_type'] = $session['menu_type'];
 			if( $session['company_id'] ) 		$ruleData['company_id'] = $session['company_id'];
 			if( $session['business_id'] ) 		$ruleData['business_id'] = $session['business_id'];
 			// 密码
 			$password							= request('password','');
-			// 所属权限组
-			$groups								= (array) request('groups',[]);
 			// 如果用户不存在
 			if( !$oldData )						return json_send(['code'=>'error','msg'=>'用户不存在']);
 			// 不能修改超管的账号
@@ -279,31 +241,17 @@ class AdminUser extends Auth{
 			// 告知结果
 			return					json_send(['code'=>'success','msg'=>'修改成功','action'=>'edit']);
 		}
-		//$whereGroup = [];
+		// 查询条件
+        $map  						= [];
 		// 如果不是超管 查询当前用户所属组
-		$administrator = explode(',', config('administrator'));
-		/*if(!in_array(admin('uid'),$administrator)){
-		    // 用户所属组
-			$gsGroup				= DB::table('auth_group_access')->where(['user_uid'=>admin('uid')])->pluck('group_id')->toArray();
-			// 用户所属组 上级
-			$upGroup				= DB::table('auth_group')->whereIn('id',$gsGroup)->pluck('group_pid')->toArray();
-			// 用户所属组的下级
-			$groupLower				= DB::table('auth_group')->whereIn('group_pid',$gsGroup)->pluck('id')->toArray();
-			// 下属组
-		    $whereGroup				= array_merge($upGroup,$gsGroup,$groupLower);
-		}*/
-        $where  =   [];
-        if(!in_array(admin('uid'),$administrator)){
-            if($session && $session['menu_type'] ) 		    $where['menu_type'] = $session['menu_type'];
-            if($session && $session['company_id'] ) 		$where['company_id'] = $session['company_id'];
-            if($session && $session['business_id'] ) 		$where['business_id'] = $session['business_id'];
-            $where['type']       = 1;
+        if(!in_array(admin('uid'),explode(',', config('administrator')))){
+			$map[]       									= ['type','=',1];
+            if($session && $session['menu_type'] ) 		    $map[] = [['menu_type'],'=',$session['menu_type']];
+            if($session && $session['company_id'] ) 		$map[] = [$map['company_id'],'=',$session['company_id']];
+            if($session && $session['business_id'] ) 		$map[] = [$map['business_id'],'=',$session['business_id']];
         }
         // 查询用户组
-        $query 						= DB::table('auth_group');
-        if($where) 			        $query->where($where);
-		// 获取
-		$group						= $query->whereNotIn('id',explode(',',config('CUSTOM_GROUP')))->select(['id','title'])->get()->toArray();
+		$group						= DB::table('auth_group')->where($map)->select(['id','title'])->get()->toArray();
 		// 错误告知
 		if( !$group )				return $this->error('请先添加用户组');
 		// 错误告知
@@ -330,7 +278,7 @@ class AdminUser extends Auth{
     	$this->assign('breadcrumb2','操作记录');
 		$this->assign('list',$list);
 		// 加载模板
-		return $this->fetch();   
+		return						$this->fetch();   
     }
 
 	/**

+ 121 - 99
app/Http/Controllers/Admin/Business.php

@@ -66,21 +66,21 @@ class Business extends Auth{
                                 ->paginate(config('page_num',10));
 		// 循环处理数据
 		foreach ($list as $key => $value) {
-            $value['username']      = $value['admin_uid'] ? (string) $AdminUser->getOne($value['admin_uid'],'username') : '';
-            $value['phone']         = $value['admin_uid'] ? (string) $AdminUser->getOne($value['admin_uid'],'phone') : '';
-			// id转编号
+            // id转编号
 			$value['business_code'] = $Model->idToCode($value['id']);
+            $value['username']      = $value['admin_uid'] ? (string) $AdminUser->getOne($value['admin_uid'],'username') : '';
+            $value['admin_phone']   = $value['admin_uid'] ? (string) $AdminUser->getOne($value['admin_uid'],'phone') : '';
             $value['logopic']		= $value['logopic'] ? path_compat($value['logopic']) : '';
             $addHistory             = AdminHistory::query()
-                ->join('admin','admin.uid','=','admin_history.admin_uid')
-                ->where(['admin_history.primary_id'=>$value['id'],'admin_history.notes_type'=>1,'admin_history.table_name'=>$Model->getTable()])
-                ->select('admin_history.insert_time','admin.username as username')
-                ->first();
+                                    ->join('admin','admin.uid','=','admin_history.admin_uid')
+                                    ->where(['admin_history.primary_id'=>$value['id'],'admin_history.notes_type'=>1,'admin_history.table_name'=>$Model->getTable()])
+                                    ->select('admin_history.insert_time','admin.username as username')
+                                    ->first();
             $editHistory            = AdminHistory::query()
-                ->join('admin','admin.uid','=','admin_history.admin_uid')
-                ->where(['admin_history.primary_id'=>$value['id'],'admin_history.notes_type'=>2,'admin_history.table_name'=>$Model->getTable()])
-                ->select('admin_history.update_time','admin.username as username')
-                ->orderByDesc('id')->first();
+                                        ->join('admin','admin.uid','=','admin_history.admin_uid')
+                                        ->where(['admin_history.primary_id'=>$value['id'],'admin_history.notes_type'=>2,'admin_history.table_name'=>$Model->getTable()])
+                                        ->select('admin_history.update_time','admin.username as username')
+                                        ->orderByDesc('id')->first();
             $value['add_history_username']  = $addHistory   ? $addHistory->username : '';
             $value['add_history_time']      = $addHistory   ? $addHistory->insert_time : 0;
             $value['edit_history_username'] = $editHistory  ? $editHistory->username : '';
@@ -115,87 +115,96 @@ class Business extends Auth{
 	 * 
 	 * */
 	public function add(Request $request,Model $Model,City $City,AdminUser $AdminUser,AdminRule $AdminRule){
-        $session				= session('userRule') ? session('userRule') : ['menu_type'=>0,'company_id'=>0,'business_id'=>0];
+        // 当前用户角色
+        $session				= session('userRule') ? session('userRule') : ['menu_type'=>0,'company_id'=>1,'business_id'=>0];
+        // 添加
 		if( request()->isMethod('post') ){
 			// 验证参数
 			$request->scene('add')->validate();
 			// 接收数据
-			$data['name']			= request('name','');
-			$data['phone']			= request('phone','');
-			$data['logopic']		= request('logopic','');
-			$data['desc']			= request('desc','');
-			$data['leader_uid']		= request('leader_uid','');
-            $data['address']		= request('address','');
-            $data['city_ids']		= request('city_ids','');
-            if ($data['city_ids']){
-                $data['city_ids']		= implode(',',$data['city_ids']);
-            }
-			$custom_name		    = request('custom_name','');
-			$phone		            = request('phone','');
-			$custom_password		= request('custom_password','');
-            if ($session['company_id']){
-                $data['company_id']	        = $session['company_id'];
-                $ruleData['company_id']     = $session['company_id'];
-            }
-            $userData['username']		= $custom_name;
-            $userData['phone']			= $phone;
-            $userData['password']		= md5($custom_password);
+			$data['name']			    = request('name','');
+			$data['phone']			    = request('phone','');
+			$data['logopic']		    = request('logopic','');
+			$data['desc']			    = request('desc','');
+			$data['leader_uid']		    = request('leader_uid','');
+            $data['address']		    = request('address','');
+            $data['city_ids']		    = request('city_ids',[]);
+            $data['city_ids']		    = implode(',',$data['city_ids']);
+            // 店铺管理员
+			$userData['username']		= request('custom_name','');
+			$userData['phone']		    = request('phone','');
+			$userData['password']		= request('custom_password','');
+            $userData['password']		= md5($userData['password']);
+            // 如果有公司ID
+            $data['company_id']	        = empty($session['company_id'])? 1 : $session['company_id'];
+            // 查询店铺管理员
+            $oldAdmin                   = $AdminUser->query()->where([['username','=',$userData['username']]])->first();
+            // 如果存在的话
+            if( $oldAdmin )             return json_send(['code'=>'error','msg'=>'管理员账号不可重复']);
             // 开启事务
             DB::beginTransaction();
             try {
                 // 写入数据表
                 $id						= $Model->add($data);
                 // 如果操作失败
-                if( !$id ){
-                    return json_send(['code'=>'error','msg'=>'新增店铺失败']);
+                if( !$id )              {
+                    // 回滚事务
+                    DB::rollBack();
+                    // 失败提示
+                    return json_send(['code'=>'error','msg'=>'新增商业公司失败']);
                 }
                 // 写入数据表
-                $uid					= $AdminUser->add($userData);
+                $uid					 = $AdminUser->add($userData);
                 // 如果操作失败
                 if( !$uid ){
                     // 回滚事务
                     DB::rollBack();
-                    return json_send(['code'=>'error','msg'=>'新增管理员失败']);
+                    // 提示
+                    return              json_send(['code'=>'error','msg'=>'新增管理员失败']);
                 }
-                $ruleData['admin_uid']      =   $uid;
-                $ruleData['business_id']        =   $id;
-                $ruleData['menu_type']      =   2;
+                // 角色数据
+                $ruleData['admin_uid']  = $uid;
+                $ruleData['business_id']= $id;
+                $ruleData['menu_type']  = 2;
                 // 写入数据表
-                $ruleUid					=   $AdminRule->add($ruleData);
+                $ruleUid				= $AdminRule->add($ruleData);
                 // 如果操作失败
                 if( !$ruleUid ){
                     // 回滚事务
                     DB::rollBack();
-                    return json_send(['code'=>'error','msg'=>'新增管理员角色失败']);
+                    // 提示
+                    return              json_send(['code'=>'error','msg'=>'新增管理员角色失败']);
                 }
                 // 写入数据表
-                $re					= $Model->edit($id,['admin_uid'=>$uid]);
+                $re					    = $Model->edit($id,['admin_uid'=>$uid]);
                 // 如果操作失败
                 if( !$re ){
                     // 回滚事务
                     DB::rollBack();
-                    return json_send(['code'=>'error','msg'=>'新增失败','data'=>'新增店铺管理员']);
+                    // 提示
+                    return              json_send(['code'=>'error','msg'=>'新增失败','data'=>'新增店铺管理员']);
                 }
                 // 写入数据表
-                $re					= DB::table('auth_group_access')->insert(['group_id'=>5,'user_uid'=>$uid]);
+                $re					    = DB::table('auth_group_access')->insert(['group_id'=>5,'user_uid'=>$uid]);
                 // 如果操作失败
                 if( !$re ){
                     // 回滚事务
                     DB::rollBack();
-                    return json_send(['code'=>'error','msg'=>'新增失败','data'=>'新增店铺管理员']);
+                    // 提示
+                    return              json_send(['code'=>'error','msg'=>'新增失败','data'=>'新增店铺管理员']);
                 }
+                // 提交事务
+                DB::commit();
+                // 记录行为
+                $this->addAdminHistory(admin('uid'),$Model->getTable(),$id,1,[],$data);
+                // 告知结果
+                return					json_send(['code'=>'success','msg'=>'新增成功','action'=>'add']);
             }catch (\Exception $e){
                 // 回滚事务
                 DB::rollBack();
                 // 告知错误
                 return				json_send(['code'=>'error','msg'=>'新增失败','data'=>json_encode($e->getMessage())]);
             }
-            // 提交事务
-            DB::commit();
-			// 记录行为
-			$this->addAdminHistory(admin('uid'),$Model->getTable(),$id,1,[],$data);
-			// 告知结果
-			return					json_send(['code'=>'success','msg'=>'新增成功','action'=>'add']);
 		}
         // 获取列表
         $cityList					= $City->getCityList();
@@ -230,76 +239,89 @@ class Business extends Auth{
 		$id							= request('id',0);
 		// 查询用户
 		$oldData					= $Model->where(['id'=>$id])->first();
+        // 当前用户角色
+        $session				    = session('userRule') ? session('userRule') : ['menu_type'=>0,'company_id'=>0,'business_id'=>0];
 		// 修改
 		if(request()->isMethod('post')){
 			// 验证参数
 			$request->scene('edit')->validate();
 			// 接收数据
-			$data['name']			= request('name','');
-			$data['phone']			= request('phone','');
-			$data['logopic']		= request('logopic','');
-			$data['desc']			= request('desc','');
-            $data['leader_uid']		= request('leader_uid','');
-            $data['address']		= request('address','');
-            $data['city_ids']		= request('city_ids','');
-            $custom_name		    = request('custom_name','');
-            $phone		            = request('phone','');
-            $custom_password		= request('custom_password','');
-            if ($data['city_ids']){
-                $data['city_ids']		= implode(',',$data['city_ids']);
-            }
-            //事务
+			$data['name']			    = request('name','');
+			$data['phone']			    = request('phone','');
+			$data['logopic']		    = request('logopic','');
+			$data['desc']			    = request('desc','');
+            $data['leader_uid']		    = request('leader_uid','');
+            $data['address']		    = request('address','');
+            $data['city_ids']		    = request('city_ids',[]);
+            $data['city_ids']		    = implode(',',$data['city_ids']);
+            // 店铺管理员
+			$userData['username']		= request('custom_name','');
+			$userData['phone']		    = request('phone','');
+            // 是否修改密码
+            if( request('custom_password','') ) $userData['password'] = md5(request('custom_password',''));
+            // 如果有公司ID
+            $data['company_id']	        = empty($session['company_id'])? 1 : $session['company_id'];
+            // 查询店铺管理员
+            $oldAdmin                   = $AdminUser->query()->where([['username','=',$userData['username']]])->value('uid');
+            // 如果存在的话,而且不是当前的管理员
+            if( $oldAdmin && $oldAdmin != $oldData['admin_uid'] ) return json_send(['code'=>'error','msg'=>'管理员账号不可重复']);
+            // 事务
             DB::beginTransaction();
+            // 尝试执行
             try {
-                // 写入数据表
-                $result					= $Model->edit($id,$data);
+                // 修改或者新增
+                $data['admin_uid']          = $oldData['admin_uid'] ? $AdminUser->edit($oldData['admin_uid'],$userData) : $AdminUser->add($userData);
                 // 如果操作失败
-                if( !$result ) 			return json_send(['code'=>'error','msg'=>'新增失败']);
-                $userData['username']	= $custom_name;
-                $userData['phone']		= $phone;
-                if ($custom_password){
-                    $userData['password']	= md5($custom_password);
+                if( !$data['admin_uid'] )   {
+                    // 回滚事务
+                    DB::rollBack();
+                    // 提示
+                    return                  json_send(['code'=>'error','msg'=>'编辑失败']);
                 }
-                //获取用户信息
-                $userInfo               = $AdminUser->getOne($oldData['admin_uid']);
                 // 写入数据表
-                if (!$userInfo){
-                    $result					= $AdminUser->add($userData);
-                    if( !$result ){
-                        DB::rollBack();
-                        return json_send(['code'=>'error','msg'=>'编辑失败']);
-                    }
-                    $result					= $Model->edit($id,['admin_uid'=>$result['admin_uid']]);
-                    if( !$result ){
-                        DB::rollBack();
-                        return json_send(['code'=>'error','msg'=>'编辑失败']);
-                    }
-                }else{
-                    $result					= $AdminUser->edit($oldData['admin_uid'],$userData);
-                    if( !$result ){
+                $result					    = $Model->edit($id,$data);
+                // 如果操作失败
+                if( !$result )              {
+                    // 回滚事务
+                    DB::rollBack();
+                    // 提示
+                    return                  json_send(['code'=>'error','msg'=>'编辑失败']);
+                }
+                // 如果新增的话,绑定角色关系
+                if( !$oldData['admin_uid'] ){
+                    // 角色数据
+                    $ruleData['admin_uid']  = $data['admin_uid'];
+                    $ruleData['business_id']= $id;
+                    $ruleData['menu_type']  = 2;
+                    // 写入数据表
+                    $ruleUid				= $AdminRule->add($ruleData);
+                    // 如果操作失败
+                    if( !$ruleUid )         {
+                        // 回滚事务
                         DB::rollBack();
-                        return json_send(['code'=>'error','msg'=>'编辑失败']);
+                        // 提示
+                        return              json_send(['code'=>'error','msg'=>'新增管理员角色失败']);
                     }
                 }
-            }catch (\Exception $e){
+                // 提交事务
+                DB::commit();
+                // 记录行为
+                $this->addAdminHistory(admin('uid'),$Model->getTable(),$id,2,$oldData,$data);
+                // 告知结果
+                return					    json_send(['code'=>'success','msg'=>'修改成功','action'=>'edit']);
+            }catch (\Exception $e)  {
                 DB::rollBack();
-                return				json_send(['code'=>'error','msg'=>'编辑失败','data'=>json_encode($e->getMessage())]);
+                return				    json_send(['code'=>'error','msg'=>'编辑失败','data'=>json_encode($e->getMessage())]);
             }
-			// 记录行为
-			$this->addAdminHistory(admin('uid'),$Model->getTable(),$id,2,$oldData,$data);
-			// 告知结果
-			return					json_send(['code'=>'success','msg'=>'修改成功','action'=>'edit']);
 		}
 		// 错误告知
 		if( !$oldData )				return $this->error('查无数据');
         //查询管理账户信息
         $adminInfo                  = $AdminUser->getOne($oldData['admin_uid']);
-        // 错误告知
-        if( !$adminInfo )			return $this->error('查无管理员账户数据');
-        $oldData['city_ids']			= explode(',',$oldData['city_ids']);
+        $adminInfo                  = $adminInfo ? $adminInfo : ['username'=>'','phone'=>''];
+        $oldData['city_ids']		= explode(',',$oldData['city_ids']);
         // 获取列表
         $cityList					= $City->getCityList();
-        $session				    = session('userRule') ? session('userRule') : ['menu_type'=>0,'company_id'=>0,'business_id'=>0];
         $mp                         =   [];
         if ($session){
             $mp[]                   =   ['admin_rule.company_id','=',$session['company_id']];

+ 2 - 1
app/Http/Controllers/Admin/Orders.php

@@ -112,7 +112,8 @@ class Orders extends Auth{
 			// 重组
 			$list[$key]				= $value;
 		}
-        $businessList 			    = $Business->getList();
+		// 查询商业公司数据
+        $businessList 			    = $Business->getListByAdmin();
 		// 分配数据
 		$this->assign('empty', '<tr><td colspan="20">~~暂无数据</td></tr>');
 		$this->assign('list', $list);

+ 4 - 4
app/Http/Controllers/Admin/Product.php

@@ -110,7 +110,7 @@ class Product extends Auth{
 		}
 		// 获取列表
 		$cityList					= $City->getCityList();
-        $businessList 			    = $Business->getList();
+        $businessList 			    = $Business->getListByAdmin();
 		// 分配数据
 		$this->assign('empty', '<tr><td colspan="20">~~暂无数据</td></tr>');
 		$this->assign('cityList',$cityList);
@@ -416,7 +416,7 @@ class Product extends Auth{
 		// 获取类型数据
 		$typeList				= $ProductType->getList();
 		$cityList				= $City->getCityList();
-		$businessList 			= $Business->getList();
+		$businessList 			= $Business->getListByAdmin();
 		$producerList			= $Producer->getList();
 		// 标签列表
 		$tagData				= $WeiBanTags->query()->groupBy('group')->groupBy('name')->get(['group','name'])->toArray();
@@ -668,7 +668,7 @@ class Product extends Auth{
 		// 获取类型数据
 		$typeList				= $ProductType->getList();
 		$cityList				= $City->getCityList();
-		$businessList 			= $Business->getList();
+		$businessList 			= $Business->getListByAdmin();
 		$producerList			= $Producer->getList();
 		// 标签列表
 		$tagData					= $WeiBanTags->query()->groupBy('group')->groupBy('name')->get(['group','name'])->toArray();
@@ -934,7 +934,7 @@ class Product extends Auth{
 		// 获取类型数据
 		$typeList				= $ProductType->getList();
 		$cityList				= $City->getCityList();
-		$businessList 			= $Business->getList();
+		$businessList 			= $Business->getListByAdmin();
 		$producerList			= $Producer->getList();
 		// 分配数据
 		$this->assign('tagList',$tagList);

+ 2 - 2
app/Http/Controllers/Admin/RegimentActive.php

@@ -151,7 +151,7 @@ class RegimentActive extends Auth{
         // 标签列表
         $tagList					        = [];
         $cityList					        = [];
-        $businessList 			    = $Business->getList();
+        $businessList 			            = $Business->getListByAdmin();
         // 分配数据
         $this->assign('cityList',$cityList);
         $this->assign('tagList',$tagList);
@@ -237,7 +237,7 @@ class RegimentActive extends Auth{
         }
         // 错误告知
         if( !$oldData )				        return $this->error('查无数据');
-        $businessList 			    = $Business->getList();
+        $businessList 			            = $Business->getListByAdmin();
         // 返回结果
         $oldData['product_code']	        = $Product->idToCode($oldData['product_id']);
         $this->assign('oldData',$oldData);

+ 0 - 7
app/Http/Controllers/Api/Custom.php

@@ -62,8 +62,6 @@ class Custom extends Api{
 		$followQrcode					= $custom['weiban_extid'] ?  ['thumb'=>'','link_url'=>''] : $WeiBanQrcode->getFollowQrcode($custom['city_id']);
 		// 城市ID换城市名
 		$cityName						= (string) $City->getOne($custom['city_id'],'name');
-		$pid 							= (int) $City->getOne($custom['city_id'],'pid');
-		$province						= (string)($pid ? $City->getOne($pid,'name') : '');
 		// 所需数组组合
 		$custom							= [
 											'uid'=>$custom['uid'],
@@ -74,11 +72,6 @@ class Custom extends Api{
 											'company_id'=>1, // 无需验证资质
 											'show_price'=>$cityName?1:0, // 是否选择了城市处理
 											'city_id'=>$cityName,
-											'city_info'=>[
-												'city_id'=>$custom['city_id'],
-												'city_name'=>$cityName,
-												'province_name'=>$province,
-											],
 											'follow_qrcode'=>$followQrcode['thumb'],
 											'follow_linkurl'=>$followQrcode['link_url'],
 										];

+ 68 - 0
app/Http/Controllers/Api/CustomAddr.php

@@ -5,6 +5,7 @@ use App\Models\CustomAddr as Model;
 use App\Http\Requests\Api\CustomAddr as Request;
 use App\Models\City;
 use App\Models\Custom;
+use App\Models\WeiBan\Follow as WeiBanFollow;
 
 /**
  * 客户地址
@@ -173,5 +174,72 @@ class CustomAddr extends Api{
 		return							json_send(['code'=>'success','msg'=>'保存成功','data'=>['id'=>$id]]);
 	}
 	
+	/**
+	 * 获取用户地址信息	/api/custom_addr/get_remark_addr
+	 * 
+	 */
+	public function get_remark_addr(Custom $Custom,City $City,WeiBanFollow $WeiBanFollow){
+		// 接口验签
+		// $this->verify_sign();
+		// 检查登录
+		$uid							= $this->checkLogin();
+		// 获取客户城市ID
+		$custom							= $Custom->getOne($uid);
+		// 数据组合
+		$data							= ['contact_province'=>'','contact_city'=>'','contact_area'=>'','contact_addr'=>'','contact_name'=>'','contact_shop'=>'','contact_phone'=>'','shop_type'=>1];
+		// 如果不存在用户信息
+		if( !$custom )					return json_send(['code'=>'success','msg'=>'获取成功','data'=>$data]);
+		// 省份
+        $data['contact_phone']       	= $custom['phone'];
+        // 获取用户城市信息
+        $city                       	= $City->getOne($custom['city_id']);
+        // 如果有城市信息
+        if( !$city )                	return json_send(['code'=>'success','msg'=>'获取成功','data'=>$data]);
+        // 获取上级城市/省份
+        $parentCity 		            = $City->getOne($city['pid']);
+        // 如果上级是省辖,获取省份
+        if( isset($parentCity['name']) && $parentCity['name'] == '直辖县级' )  $parentCity = $City->getOne($parentCity['pid']);
+        // 如果有获取到省份信息
+        if( !$parentCity )          	return json_send(['code'=>'success','msg'=>'获取成功','data'=>$data]);
+        // 省份
+        $data['contact_province']       = $parentCity['name'];
+        // 省份
+        $data['contact_city']           = $city['name'];
+        // 如果用户没有绑定对应的微伴账号
+		if( !$custom['weiban_extid'] )	return json_send(['code'=>'success','msg'=>'获取成功','data'=>$data]);
+		// 获取客服对应的备注等信息
+		$follow							= $WeiBanFollow->getListByWeibanExtid($custom['weiban_extid']);
+		// 获取备注列表
+		$remark							= array_filter(array_column($follow,'remark'),function($value) {return !empty($value);});
+		// 获取备注列表
+		$contactShop					= array_filter(array_column($follow,'remark_corp_name'),function($value) {return !empty($value);});
+		// 如果有备注信息
+		if( isset($remark[0]) )			$data['contact_name']	= $remark[0];
+		// 如果有备注信息
+		if( isset($contactShop[0]) )	$data['contact_shop']	= $contactShop[0];
+		// 返回结果
+		return							json_send(['code'=>'success','msg'=>'获取成功','data'=>$data]);
+	}
+
+	/**
+	 * 获取可能性地址	/api/custom_addr/get_guess_addr
+	 * 
+	 */
+	public function get_guess_addr(Request $request,Model $Model){
+		// 接口验签
+		// $this->verify_sign();
+		// 检查登录
+		$uid							= $this->checkLogin();
+		// 接收参数
+		$request->scene('get_guess_addr')->validate();
+		// 接收参数
+		$contactShop					= request('contact_shop','');
+		// 获取参数
+		$map							= [['contact_shop','LIKE','%'.$contactShop.'%']];
+		// 查询
+		$list							= $Model->query()->where($map)->limit('20')->get(['contact_province','contact_city','contact_area','contact_addr','contact_shop','shop_type'])->toArray();
+		// 返回结果
+		return							json_send(['code'=>'success','msg'=>'获取成功','data'=>$list]);
+	}
 
 }

+ 2 - 2
app/Http/Controllers/Api/ShopCart.php

@@ -133,7 +133,7 @@ class ShopCart extends Api{
 		// 循环处理数据
 		foreach ($list as $key => $value) {
 			// 获取商业公司名称
-			$value['business_name'] = $value['business_id'] ? $Business->getOne($value['business_id'])['name'] : 0;
+			$value['business_name'] = $value['business_id'] ? (string) $Business->getOne($value['business_id'],'name') : '';
 			// 如果有sku
 			if( $value['skuid'] )	{
 				// 是否存在
@@ -256,7 +256,7 @@ class ShopCart extends Api{
 		// 循环处理数据
 		foreach ($list as $key => $value) {
 			// 获取商业公司名称
-			$value['business_name'] = $value['business_id'] ? $Business->getOne($value['business_id'])['name'] : 0;
+			$value['business_name'] = $value['business_id'] ? (string)$Business->getOne($value['business_id'],'name') : '';
 			// 如果有sku
 			if( $value['skuid'] )	{
 				// 是否存在

+ 3 - 0
app/Http/Requests/Api/CustomAddr.php

@@ -27,6 +27,7 @@ class CustomAddr extends BaseRequest
             'contact_addr'          => 'required|max:64',
             // 备注
             'contact_name'          => 'required|max:20',
+            'contact_shop'          => 'required|max:20',
             'contact_phone'         => 'required|phone',
         ];
     }
@@ -37,6 +38,7 @@ class CustomAddr extends BaseRequest
         'edit'                  => ['id','contact_province','contact_city','contact_area','contact_name','contact_phone'],
         'del'                   => ['id'],
         'set_default'           => ['id'],
+        'get_guess_addr'        => ['contact_shop'],
 	];
 
     /**
@@ -56,6 +58,7 @@ class CustomAddr extends BaseRequest
             'contact_area.max'   	    => '区县超长啦',
             'contact_addr.max'   	    => '地址超长啦',
             'contact_name.required'   	=> '请填写收件人',
+            'contact_shop.required'   	=> '请填写终端名称',
             'contact_phone.required'    => '请填写收件人手机号',
             'contact_phone.phone'       => '请填写正确的手机号',
             'id.required'               => '请选择地址',

+ 79 - 2
app/Jobs/WeiBanSync.php

@@ -4,7 +4,6 @@ namespace App\Jobs;
 
 use App\Facades\Servers\Logs\Log;
 use Illuminate\Bus\Queueable;
-use Illuminate\Contracts\Queue\ShouldBeUnique;
 use Illuminate\Contracts\Queue\ShouldQueue;
 use Illuminate\Foundation\Bus\Dispatchable;
 use Illuminate\Queue\InteractsWithQueue;
@@ -15,6 +14,8 @@ use App\Models\Custom;
 use App\Models\WeiBan\External as WeiBanExternal;
 use App\Models\WeiBan\Follow as WeiBanFollow;
 use App\Models\WeiBan\Tags as WeiBanTags;
+use App\Models\City;
+use App\Models\CustomAddr;
 
 class WeiBanSync implements ShouldQueue
 {
@@ -98,6 +99,8 @@ class WeiBanSync implements ShouldQueue
         $extUser                        = ['id'=>$extUser['id'],'name'=>$extUser['name'],'avatar'=>str_ireplace('http://','https://',(string)$extUser['avatar']),'gender'=>$extUser['gender'],'type'=>$extUser['type'],'corp_name'=>(string)$extUser['corp_name'],'corp_full_name'=>(string)$extUser['corp_full_name'],'insert_time'=>$extUser['created_at'],'update_time'=>time(),'custom_uid'=>0];
         // 手机号
         $phone                          = '';
+        // 标签处理
+        $staffId                        = '';
         // 循环跟进客服
         foreach ( $followList as $follow ) {
             // 标签处理
@@ -115,6 +118,13 @@ class WeiBanSync implements ShouldQueue
         if( $oldExtUser )               $extUser['custom_uid'] = ($oldExtUser->custom_uid);
         // 存在手机号,才创建账号
         if( $phone )                    $extUser['custom_uid'] = $this->customHandle($phone,$extUser,$Custom);
+        // 需要有客服,如果存在的旧账号但是 没有关联客户UID 还存在系统客户UID可关联
+        if( $staffId && isset($oldExtUser['custom_uid']) && empty($oldExtUser['custom_uid']) && $extUser['custom_uid'] ){
+            // 城市标签
+            $this->cityTags($extUser,$staffId,$Custom);
+            // 终端标签
+            $this->shopTypeTag($staffId,$extUser);
+        }
         // 新增或者修改
         $External->query()->upsert($extUser,'id',['name','avatar','gender','type','corp_name','corp_full_name','status','custom_uid','update_time']);
     }
@@ -162,7 +172,6 @@ class WeiBanSync implements ShouldQueue
         return                      $uid;
     }
 
-
     /**
      * 客服处理
      */
@@ -195,5 +204,73 @@ class WeiBanSync implements ShouldQueue
         $followId ? $Follow->edit($followId,$follow) : $Follow->add($follow);
     }
 
+    /**
+     * 城市标签
+     */
+    private function cityTags($extUser,$staffId,Custom $Custom){
+        // 实例化
+        $City                       = New City();
+        // 获取城市ID
+        $cityId                     = $Custom->getValue($extUser['custom_uid'],'city_id');
+        // 如果有城市
+        if( !$cityId )              return ['info'=>'请先设置城市'];
+        // 获取用户城市信息
+        $city                       = $City->getOne($cityId);
+        // 如果有城市信息
+        if( !$city )                return ['info'=>'未查询到城市'];
+        // 获取上级城市/省份
+        $parentCity 		            = $City->getOne($city['pid']);
+        // 如果上级是省辖,获取省份
+        if( isset($parentCity['name']) && $parentCity['name'] == '直辖县级' )  $parentCity = $City->getOne($parentCity['pid']);
+        // 如果有获取到省份信息
+        if( !$parentCity )          return ['info'=>'未查询到省份'];
+        // 省份
+        $province                   = str_ireplace(['自治区','壮族','回族','维吾尔','特别行政区','省'],'',$parentCity['name']);
+        // 省份
+        $cityName                   = str_ireplace(['自治州','自治县','蒙古','蒙古族','回族','藏族','维吾尔','苗族','彝族','壮族','布依族','朝鲜族','满族','侗族','瑶族','白族','土家族','哈尼族','哈萨克','傣族','黎族','傈僳族','佤族','畲族','拉祜族','水族','东乡族','纳西族','景颇族','柯尔克孜','土族','达斡尔族','仫佬族','羌族','布朗族','撒拉族','毛南族','仡佬族','锡伯','阿昌族','普米族','塔吉克','怒族','鄂温克族','德昂族','保安族','裕固族','塔塔尔','独龙族'],'',$city['name']);
+        // 打省份标签
+        if( !$province )             return ['info'=>'暂无省份数据'];
+        // 打省份标签
+        if( !$cityName )             return ['info'=>'暂无城市数据'];
+        // 打省份标签
+        $result['province']         = OpenApi::addTag($staffId,$extUser['id'],'省份',$province);
+        // 打城市标签
+        $result['cityNname']        = OpenApi::addTag($staffId,$extUser['id'],$province,$cityName);
+        // 返回结果
+        return                      ['success'=>'返回结果','result'=>$result];
+    }
+
+    /**
+     * 终端类型标签
+     * 
+     */
+    public function shopTypeTag($staffId,$extUser){
+        // 地址模型
+        $Addr                       = New CustomAddr();
+        // 打终端类型标签
+        $shopType                   = (int) $Addr->query()->where([['custom_uid','=',$extUser['custom_uid']],['shop_type','>',0]])->value('shop_type');
+        // 如果有地址信息
+        switch ($shopType)          {
+            case '1':
+            $shopType               = '单店';
+            break;
+            case '3':
+            $shopType               = '连锁';
+            break;
+            case '4':
+            $shopType               = '第三终端';
+            break;
+            default:
+            $shopType               = '';
+            break;
+        }
+        // 没有数据,直接结束
+        if( !$shopType )            return ['info'=>'没有终端类型标签']; 
+        // 如果有终端类型
+        $result                     = OpenApi::addTag($staffId,$extUser['id'],'企业类型',$shopType);
+        // 数据返回
+        return                      ['success'=>'返回结果','result'=>$result];
+    }
+
 
 }

+ 3 - 3
app/Models/AdminUser.php

@@ -32,7 +32,7 @@ class AdminUser extends Model
         // 写入数据表
         $id						            = $this->query()->insertGetId($data);
         // 如果操作失败
-        if( !$id )                          return $id;
+        if( !$id )                          return 0;
         // 更新缓存
         $this->getList(true);
         // 返回结果
@@ -50,11 +50,11 @@ class AdminUser extends Model
         // 写入数据表
         $result						        = $this->query()->where(['uid'=>$id])->update($data);
         // 如果操作失败
-        if( !$result )                      return $result;
+        if( !$result )                      return 0;
         // 更新缓存
         $this->getList(true);
         // 返回结果
-        return                              $result;
+        return                              $id;
     }
 
     /**

+ 37 - 19
app/Models/Business.php

@@ -64,26 +64,11 @@ class Business extends Model
     public function getList($force = false)
     {
         // 结果数据
-        //$list                  = $force ? [] : cache('admin:business:list');
-        $list                   =   [];
+        $list                  = $force ? [] : cache('admin:business:list');
         // 不存在数据
-        if ( !$list ) {
-            $session           = session('userRule');
-            $map                =   [];
-            $map[] = ['status','=',0];
-            if ($session){
-                $map[] = ['company_id','=',$session['company_id']];
-                if ($session['business_id']){
-                    $map[] = ['id','=',$session['business_id']];
-                }
-                if ($session['menu_type'] == 1 && $session['data_type'] == 2){
-                    $map[] = ['leader_uid','=',$session['admin_uid']];
-                }
-            }
+        if ( !$list )          {
             // 从数据库获取数据
-            $data              = $this->query()->where($map)->get();
-            // 是否有数据
-            $data              = $data ? $data->toArray() : [];
+            $data              = $this->query()->where([['status','=',0]])->get()->toArray();
             // 循环处理数据
             $list              = [];
             // 进行更新
@@ -98,6 +83,39 @@ class Business extends Model
         return                  $list;
     }
 
+
+    /**
+     * 获取列表
+     * @param   Bool    $force  是否强制更新
+     * 
+     */
+    public function getListByAdmin()
+    {
+        // 结果数据
+        $list                               = [];
+        // 不存在数据
+        if ( !$list )                       {
+            $session                        = session('userRule') ? session('userRule') : ['company_id'=>1,'business_id'=>0,'menu_type'=>0,'data_type'=>0];
+            $map                            = [['status','=',0]];
+            if( $session['company_id'] )    $map[] = ['company_id','=',$session['company_id']];
+            if( $session['business_id'] )   $map[] = ['id','=',$session['business_id']];
+            if ($session['menu_type'] == 1  && $session['data_type'] == 2) $map[] = ['leader_uid','=',$session['admin_uid']];
+            // 从数据库获取数据
+            $data                           = $this->query()->where($map)->get();
+            // 是否有数据
+            $data                           = $data ? $data->toArray() : [];
+            // 循环处理数据
+            $list                           = [];
+            // 进行更新
+            foreach ($data as $value)       {
+                // 重组数据
+                $list[$value['id']] = $value;
+            }
+        }
+        // 返回结果
+        return                              $list;
+    }
+
     /**
      * 获取配置平台对应的应用数据
      * 
@@ -108,7 +126,7 @@ class Business extends Model
     public function getOne($id,$field='')
     {
         // 获取列表数据
-        $list                   = $this->getList();
+        $list                   = $this->getList(true);
         // 获取数据
         $one                    = isset($list[$id]) ? $list[$id] : [];
         // 返回值

+ 8 - 42
app/Models/Company.php

@@ -31,7 +31,7 @@ class Company extends Model
         // 写入数据表
         $id						            = $this->query()->insertGetId($data);
         // 如果操作失败
-        if( !$id )                          return $id;
+        if( !$id )                          return 0;
         // 更新缓存
         $this->getList(true);
         // 返回结果
@@ -49,11 +49,11 @@ class Company extends Model
         // 写入数据表
         $result						        = $this->query()->where(['id'=>$id])->update($data);
         // 如果操作失败
-        if( !$result )                      return $result;
+        if( !$result )                      return 0;
         // 更新缓存
         $this->getList(true);
         // 返回结果
-        return                              $result;
+        return                              $id;
     }
 
     /**
@@ -64,35 +64,22 @@ class Company extends Model
     public function getList($force = false)
     {
         // 结果数据
-        //$list                  = $force ? [] : cache('admin:business:list');
-        $list                   =   [];
+        $list                  = $force ? [] : cache('admin:company:list');
         // 不存在数据
-        if ( !$list ) {
-            $session           = session('userRule');
-            $map                =   [];
-            $map[] = ['status','=',0];
-            if ($session){
-                $map[] = ['company_id','=',$session['company_id']];
-                if ($session['business_id']){
-                    $map[] = ['id','=',$session['business_id']];
-                }
-                if ($session['menu_type'] == 1 && $session['data_type'] == 2){
-                    $map[] = ['leader_uid','=',$session['admin_uid']];
-                }
-            }
+        if ( !$list )           {
             // 从数据库获取数据
-            $data              = $this->query()->where($map)->get();
+            $data              = $this->query()->where([['status','=',0]])->get();
             // 是否有数据
             $data              = $data ? $data->toArray() : [];
             // 循环处理数据
             $list              = [];
             // 进行更新
-            foreach ($data as $value) {
+            foreach ( $data as $value ) {
                 // 重组数据
                 $list[$value['id']] = $value;
             }
             // 存起来
-            cache(['admin:business:list'=>$list]);
+            cache(['admin:company:list'=>$list]);
         }
         // 返回结果
         return                  $list;
@@ -138,25 +125,4 @@ class Company extends Model
         return                              $id;
     }
 
-
-    /**
-     * 编码转id
-     * 
-     * @param  string $code 编码
-     * 
-     */
-    public function codeToId($code){
-        return intval(str_ireplace('klsj','',$code));
-    }
- 
-    /**
-     * id转编码
-     * 
-     * @param  int  $id 编码
-     * 
-     */
-    public function idToCode($id){
-         return 'klsj'. str_pad($id, 9, '0', STR_PAD_LEFT);
-    }
-
 }

+ 2 - 2
resources/views/admin/admin_user/edit.blade.php

@@ -20,7 +20,7 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
 		<label class="control-label">账户角色</label>
 		<div class="clearfix">
 			<label class="checkbox-inline">
-				<input type="checkbox" value="1" name="data_type" @if($oldData['data_type'] == 1) checked @endif>
+				<input type="radio" value="1" name="data_type" @if($oldData['data_type'] == 1) checked @endif>
 				@if(session('userRule.business_id'))
 					店铺普通员工
 				@else
@@ -28,7 +28,7 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
 				@endif
 			</label>
 			<label class="checkbox-inline">
-				<input type="checkbox" value="2" name="data_type" @if($oldData['data_type'] == 2) checked @endif>
+				<input type="radio" value="2" name="data_type" @if($oldData['data_type'] == 2) checked @endif>
 				@if(session('userRule.business_id'))
 					推广员
 				@else

+ 2 - 0
resources/views/admin/admin_user/index.blade.php

@@ -22,6 +22,7 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
 					<tr>
 						<th>序号</th>
 						<th>用户账号</th>
+						<th>用户手机</th>
 						<th>商户名称</th>
 						<th>商业公司名称</th>
 						<th>用户角色</th>
@@ -36,6 +37,7 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
 						<tr>
 							<th>{{$a['uid']}}</th>
 							<td>{{$a['username']}}</td>
+							<td>{{$a['phone']}}</td>
 							<td>{{$a['company_name']}}</td>
 							<td>{{$a['business_name']}}</td>
 							<td>{{$a['rule_title']}}</td>

+ 1 - 1
resources/views/admin/weiban_external/index.blade.php

@@ -56,7 +56,7 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
 									<span class="btn btn-xs btn-default">{{$v['name']}}</span>
 								@endforeach
 							</td>
-							<td> <a href="{{url('admin/custom/index?'.http_build_query(['custom_code'=>$a['custom_code']]))}}">{{$a['custom_name']}}</a></td>
+							<td> <a href="{{url('admin/custom/index?'.http_build_query(['custom_code'=>$a['custom_code']]))}}">{{$a['custom_code']}}</a></td>
 							<td> {{date('Y/m/d H:i:s',$a['insert_time'])}}</td>
 							<td> {{date('Y/m/d H:i:s',$a['update_time'])}}</td>
 							<td>

+ 4 - 1
routes/api.php

@@ -86,7 +86,10 @@ Route::any('custom_addr/del',[\App\Http\Controllers\Api\CustomAddr::class,'del']
 Route::any('custom_addr/get_list',[\App\Http\Controllers\Api\CustomAddr::class,'get_list']);
 // 列表
 Route::any('custom_addr/set_default',[\App\Http\Controllers\Api\CustomAddr::class,'set_default']);
-
+// 列表
+Route::any('custom_addr/get_remark_addr',[\App\Http\Controllers\Api\CustomAddr::class,'get_remark_addr']);
+// 列表
+Route::any('custom_addr/get_guess_addr',[\App\Http\Controllers\Api\CustomAddr::class,'get_guess_addr']);
 
 // 积分信息
 Route::any('custom_score/get_info',[\App\Http\Controllers\Api\CustomScore::class,'get_info']);