Browse Source

添加和编辑客户修改

lizhen_gitee 8 months ago
parent
commit
7cc05e1531
1 changed files with 25 additions and 78 deletions
  1. 25 78
      application/company/controller/Usercompany.php

+ 25 - 78
application/company/controller/Usercompany.php

@@ -53,79 +53,6 @@ class Usercompany extends Apic
         $this->success(1,$rs);
     }
 
-    //检索未绑定过的正常用户
-    public function find_user(){
-        $mobile = input('mobile','');
-
-        //检查用户
-        $find = Db::name('user')->field('id as user_id,nickname')->where('mobile',$mobile)->where('status',1)->where('company_id',0)->find();
-
-        //检查客户表
-        if($find){
-            $check = Db::name($this->table)->where('user_id',$find['user_id'])->where('deletetime',NULL)->find();
-            if($check){
-                $find = null;
-            }
-        }
-
-        $this->success(1,$find);
-    }
-
-    public function add_old(){
-        $user_id = input('user_id',0);
-
-        Db::startTrans();
-        $user_info = Db::name('user')->where('id',$user_id)->lock(true)->find();
-        if(empty($user_info) || $user_info['status'] != 1){
-            Db::rollback();
-            $this->error('不存在的客户');
-        }
-        if($user_info['company_id'] != 0){
-            Db::rollback();
-            $this->error('客户已经被他人绑定');
-        }
-
-        //添加客户
-        $data = [
-            'user_id'    => $user_id,
-            'header'     => input('header',''),
-            'starttime'  => input('starttime','','strtotime'),
-            'endtime'    => input('endtime','','strtotime'),
-            'company_id' => $this->auth->company_id,
-        ];
-        $uc_id = Db::name($this->table)->insertGetId($data);
-        if(!$uc_id){
-            Db::rollback();
-            $this->error('添加客户失败,请重新再试');
-        }
-
-        //修改用户
-        $rs_user = Db::name('user')->where('id',$user_id)->update(['company_id'=>$this->auth->company_id]);
-        if($rs_user === false){
-            Db::rollback();
-            $this->error('添加客户失败,请重新再试');
-        }
-
-        Db::commit();
-        $this->success();
-    }
-
-    //检查手机号
-    public function check_mobile(){
-        $mobile = input('mobile','');
-        if(empty($mobile)){
-            $this->error();
-        }
-
-        //检查用户
-        $find = Db::name('user')->where('mobile',$mobile)->find();
-        if($find){
-            $this->error('该手机号已被注册客户');
-        }
-
-        $this->success(1);
-    }
-
     //添加客户
     public function add(){
         $mobile = input('mobile','');
@@ -136,13 +63,13 @@ class Usercompany extends Apic
         //检查用户
         $find = Db::name('user')->where('mobile',$mobile)->find();
         if($find){
-            $this->error('该手机号已被注册客户');
+            $this->error('该手机号已被注册客户');
         }
 
         //注册到用户表
         $nickname = input('nickname','');
         if(empty($nickname)){
-            $this->error('客户名必填');
+            $this->error('客户名必填');
         }
         $extend = [
             'nickname' => $nickname,
@@ -155,14 +82,29 @@ class Usercompany extends Apic
 
         $user_id = $register_rs;
 
+        $zuobiao = input('zuobiao','','trim');
+        $zuobiao = explode(',',$zuobiao);
+
         Db::startTrans();
         //添加客户
         $data = [
             'user_id'    => $user_id,
-            'header'     => input('header',''),
-            'starttime'  => input('starttime','','strtotime'),
-            'endtime'    => input('endtime','','strtotime'),
             'company_id' => $this->auth->company_id,
+            'projectname'      => input('projectname',''),
+            'projectaddress'   => input('projectaddress',''),
+            'image'            => input('image',''),
+            'starttime'        => input('starttime','','strtotime'),
+            'endtime'          => input('endtime','','strtotime'),
+            'header'           => input('header',''),
+            'header_avatar'    => input('header_avatar',''),
+            'header_mobile'    => input('header_mobile',''),
+            'xiaofang'         => input('xiaofang',''),
+            'xiaofang_mobile'  => input('xiaofang_mobile',''),
+            'weituo'           => input('weituo',''),
+            'fuwujigou'        => input('fuwujigou',''),
+            'weibaofanwei'     => input('weibaofanwei',''),
+            'longitude'        => isset($zuobiao[0]) ? $zuobiao[0] : '',
+            'latitude'         => isset($zuobiao[1]) ? $zuobiao[1] : '',
         ];
         $uc_id = Db::name($this->table)->insertGetId($data);
         if(!$uc_id){
@@ -194,6 +136,9 @@ class Usercompany extends Apic
             $this->error('没找到该信息,请刷新重试');
         }
 
+        $zuobiao = input('zuobiao','','trim');
+        $zuobiao = explode(',',$zuobiao);
+
         $data = [
             'projectname'      => input('projectname',''),
             'projectaddress'   => input('projectaddress',''),
@@ -208,6 +153,8 @@ class Usercompany extends Apic
             'weituo'           => input('weituo',''),
             'fuwujigou'        => input('fuwujigou',''),
             'weibaofanwei'     => input('weibaofanwei',''),
+            'longitude'        => isset($zuobiao[0]) ? $zuobiao[0] : '',
+            'latitude'         => isset($zuobiao[1]) ? $zuobiao[1] : '',
         ];
 
         Db::name($this->table)->where('id',$id)->update($data);