chenhao 4 years ago
parent
commit
b54f87a554

+ 57 - 11
application/admin/controller/Customer.php

@@ -203,11 +203,27 @@ class Customer extends Base
             $data = CustomerModel::where('id', 'in', $param['ids'])->select()->toArray();
             foreach ($data as &$v) {
                 // 找到这个用户相同公司的人员,然后把这个公司的所有客户都放到此业务员下
+                $websiteArr = explode('##',$v['website']);
+                $company = $v['company'];
                 if (!empty($v['company'])) {
-                    CustomerModel::where('company', $v['company'])->update(['spread_id' => $param['id'], 'status' => 2, 'follow_time' => time()]);
+                    $res = CustomerModel::where(function ($query) use ($websiteArr,$company){
+                            foreach ($websiteArr as $v) {
+                                $query->whereOr('website','like','%'.$v.'%');
+                            }
+                            $query->whereOr('company',$company);
+                        })
+                        ->column('id');
+                    Db::name('customer')->where('id','in',implode(',',$res))->update(['spread_id' => $param['id'], 'status' => 2, 'follow_time' => time()]);
                 } else {
-                    CustomerModel::where('id',$v['id'])->update(['spread_id' => $param['id'], 'status' => 2, 'follow_time' => time()]);
+                    $res = CustomerModel::where(function ($query) use ($websiteArr) {
+                        foreach ($websiteArr as $v) {
+                            $query->whereOr('website', 'like', '%' . $v . '%');
+                        }
+                    })
+                    ->column('id');
+                    Db::name('customer')->where('id', 'in', implode(',', $res))->update(['spread_id' => $param['id'], 'status' => 2, 'follow_time' => time()]);
                 }
+                unset($websiteArr);
                 $ranking = new RankingModel();
                 $ranking->set_chengjiao($v['id']); // 修改记录表
             }
@@ -230,12 +246,28 @@ class Customer extends Base
             $data = CustomerModel::where('id', 'in', $param['ids'])->select()->toArray();
             foreach ($data as &$v) {
                 // 找到这个用户相同公司的人员,然后把这个公司的所有客户都放到此业务员下
+                $websiteArr = explode('##',$v['website']);
+                $company = $v['company'];
                 if (!empty($v['company'])) {
-                    CustomerModel::where('company', $v['company'])->update(['spread_id' => $param['id'], 'status' => 1, 'follow_time' => time()]);
+                    $res = CustomerModel::where(function ($query) use ($websiteArr,$company){
+                        foreach ($websiteArr as $v) {
+                            $query->whereOr('website','like','%'.$v.'%');
+                        }
+                        $query->whereOr('company',$company);
+                    })
+                        ->column('id');
+                    Db::name('customer')->where('id','in',implode(',',$res))->update(['spread_id' => $param['id'], 'status' => 1, 'follow_time' => time()]);
+
                 } else {
-                    CustomerModel::where('id',$v['id'])->update(['spread_id' => $param['id'], 'status' => 1, 'follow_time' => time()]);
+                    $res = CustomerModel::where(function ($query) use ($websiteArr,$company){
+                        foreach ($websiteArr as $v) {
+                            $query->whereOr('website','like','%'.$v.'%');
+                        }
+                    })
+                    ->column('id');
+                    Db::name('customer')->where('id','in',implode(',',$res))->update(['spread_id' => $param['id'], 'status' => 1, 'follow_time' => time()]);
                 }
-
+                unset($websiteArr);
                 $ranking = new RankingModel();
                 $ranking->set_huifu($v['id']); // 修改记录表
             }
@@ -259,15 +291,29 @@ class Customer extends Base
             $customer = CustomerModel::where('id', $param['id'])->find();
 //            Db::name('rangk')->where('c_id','in',$param['ids'])->update(['admin_id' => $customer['spread_id']]);
             foreach ($data as &$v) {
-//                if ($v['status'] == '已关联' ) {
-//                    return json(['code' => 100,'msg' => $v['name'].'——已经有关联上级了']);
-//                }
+                $websiteArr = explode('##',$v['website']);
+                $company = $v['company'];
                 // 找到这个用户相同公司的人员,然后把这个公司的所有客户都放到此业务员下
-                CustomerModel::where('id', $v['id'])->update(['spread_id' => $customer['spread_id'], 'follow_time' => time(), 'status' => 3, 'guanlianid' => $param['id']]);
+//                CustomerModel::where('id', $v['id'])->update(['spread_id' => $customer['spread_id'], 'follow_time' => time(), 'status' => 3, 'guanlianid' => $param['id']]);
                 if(!empty($v['company'])) {
-                    CustomerModel::where('company',$v['company'])->update(['spread_id' => $customer['spread_id']]);
+                    $res = CustomerModel::where(function ($query) use ($websiteArr,$company){
+                        foreach ($websiteArr as $v) {
+                            $query->whereOr('website','like','%'.$v.'%');
+                        }
+                        $query->whereOr('company',$company);
+                    })
+                        ->column('id');
+                    Db::name('customer')->where('id','in',implode(',',$res))->update(['spread_id' => $customer['spread_id'], 'follow_time' => time(), 'status' => 3, 'guanlianid' => $param['id']]);
+//                    CustomerModel::where('company',$v['company'])->update(['spread_id' => $customer['spread_id']]);
                 } else {
-                    CustomerModel::where('id',$v['id'])->update(['spread_id' => $customer['id']]);
+                    $res = CustomerModel::where(function ($query) use ($websiteArr,$company){
+                        foreach ($websiteArr as $v) {
+                            $query->whereOr('website','like','%'.$v.'%');
+                        }
+                    })
+                    ->column('id');
+                    Db::name('customer')->where('id','in',implode(',',$res))->update(['spread_id' => $customer['spread_id'], 'follow_time' => time(), 'status' => 3, 'guanlianid' => $param['id']]);
+//                    CustomerModel::where('id',$v['id'])->update(['spread_id' => $customer['id']]);
                 }
                 $ranking = new RankingModel();
                 $ranking->setGuanlian($v['id']); // 修改记录表

+ 12 - 1
application/admin/controller/Upload.php

@@ -478,7 +478,18 @@ class Upload extends Base
                     $status = 0; // 设置为0标识此行有错误
                 }
                 if (!empty($v[2])) {
-                    $ckeckWebsiteCompany = Db::name('customer')->where('website','like','%'.$v[3].'%')->where('status',0)->where('email','')->find();
+                    $websiteArr =explode(chr(10), $v[3]);
+//                    $ckeckWebsiteCompany = Db::name('customer')->where('website','like','%'.$v[3].'%')->where('status',0)->where('email','')->find();
+                    $ckeckWebsiteCompany = Db::name('customer')
+                        ->where('website','like','%'.$v[3].'%')
+                        ->where(function ($query) use ($websiteArr) {
+                            foreach ($websiteArr as $v) {
+
+                            }
+                        })
+                        ->where('status',0)
+                        ->where('email','')
+                        ->find();
                     if ($ckeckWebsiteCompany) {
                         Db::name('customer')->where('id',$ckeckWebsiteCompany['id'])->update(['spread_id'=>session('uid'),'emial' => $v[2]]);
                         Db::name('customer')->where('emial',$v[2])->setInc('people',1);

+ 63 - 12
application/admin/model/RankingModel.php

@@ -15,12 +15,27 @@ class RankingModel extends Model
     {
 
         $customer = CustomerModel::where('id',$id)->find(); // 查出用户信息
-        $all_company = CustomerModel::where('company',$customer['company'])
-            ->where('company','neq','')
-            ->select()
-            ->toArray();
-        $num = count($all_company);
-        $all_company[$num] = $customer;
+        $websiteArr = explode('##',$customer['website']);
+        if (!empty($customer['company'])) {
+            $company = $customer['company'];
+            $res = CustomerModel::where(function ($query) use ($websiteArr,$company){
+                foreach ($websiteArr as $v) {
+                    $query->whereOr('website','like','%'.$v.'%');
+                }
+                $query->whereOr('company',$company);
+            })
+                ->select()
+                ->toArray();
+        } else {
+            $res = CustomerModel::where(function ($query) use ($websiteArr) {
+                foreach ($websiteArr as $v) {
+                    $query->whereOr('website', 'like', '%' . $v . '%');
+                }
+            })
+                ->select()
+                ->toArray();
+        }
+        $all_company = $res;
         if (count($all_company) > 0) {
             foreach ($all_company  as $k=>$v) {
 //            $rank = $this->where('c_id',$all_company[$k]['id'])->where('admin_id',$all_company[$k]['spread_id'])->find();
@@ -53,9 +68,27 @@ class RankingModel extends Model
     public function set_chengjiao($id)
     {
         $customer = CustomerModel::where('id',$id)->find(); // 查出用户信息
-        $all_company = CustomerModel::where('company',$customer['company'])->where('company','neq','')->select()->toArray();
-        $num = count($all_company);
-        $all_company[$num] = $customer;
+        $websiteArr = explode('##',$customer['website']);
+        if (!empty($customer['company'])) {
+            $company = $customer['company'];
+            $res = CustomerModel::where(function ($query) use ($websiteArr,$company){
+                foreach ($websiteArr as $v) {
+                    $query->whereOr('website','like','%'.$v.'%');
+                }
+                $query->whereOr('company',$company);
+                 })
+            ->select()
+            ->toArray();
+        } else {
+            $res = CustomerModel::where(function ($query) use ($websiteArr) {
+                foreach ($websiteArr as $v) {
+                    $query->whereOr('website', 'like', '%' . $v . '%');
+                   }
+                })
+                ->select()
+                ->toArray();
+        }
+        $all_company = $res;
         foreach ($all_company  as $k=>$v) {
             $rank = $this->where('c_id',$all_company[$k]['id'])->find();
             if ($rank) {
@@ -86,9 +119,27 @@ class RankingModel extends Model
     public function setGuanlian($id)
     {
         $customer = CustomerModel::where('id',$id)->find(); // 查出用户信息
-        $all_company = CustomerModel::where('company',$customer['company'])->where('company','neq','')->select()->toArray();
-        $num = count($all_company);
-        $all_company[$num] = $customer;
+        $websiteArr = explode('##',$customer['website']);
+        if (!empty($customer['company'])) {
+            $company = $customer['company'];
+            $res = CustomerModel::where(function ($query) use ($websiteArr,$company){
+                foreach ($websiteArr as $v) {
+                    $query->whereOr('website','like','%'.$v.'%');
+                }
+                $query->whereOr('company',$company);
+            })
+                ->select()
+                ->toArray();
+        } else {
+            $res = CustomerModel::where(function ($query) use ($websiteArr) {
+                foreach ($websiteArr as $v) {
+                    $query->whereOr('website', 'like', '%' . $v . '%');
+                }
+            })
+                ->select()
+                ->toArray();
+        }
+        $all_company = $res;
         foreach ($all_company  as $k=>$v) {
             $rank = $this->where('c_id',$all_company[$k]['id'])->find();
             if ($rank) {

+ 1 - 1
application/admin/view/customer/add_customer.html

@@ -37,7 +37,7 @@
                 <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                     <label class="layui-form-label">公司</label>
                     <div class="layui-input-block">
-                        <input type="text" name="company" lay-verify="required" placeholder="请输入公司" class="layui-input ">
+                        <input type="text" name="company"  placeholder="请输入公司" class="layui-input ">
                     </div>
                 </div>
 <!--                <div class="layui-form-item layui-col-md-offset1 layui-col-md8">-->

+ 3 - 3
application/admin/view/customer/admin/admin_user_index_3.html

@@ -207,9 +207,9 @@
                 , {field: 'name', width: '', title: '联系人',sort:true, align: 'center'}
                 , {field: 'company', width: '', title: '公司名', align: 'center'}
                 , {field: 'admin_name', width: '', title: '业务员', align: 'center'}
-                , {field: 'type_name', width: '', title: '行业分类', align: 'center'}
-                , {field: 'product_name', width: '', title: '主营产品分类', align: 'center'}
-                , {field: 'guanlian_company', width: '', title: '关联客户邮箱名称', align: 'center'}
+                // , {field: 'type_name', width: '', title: '行业分类', align: 'center'}
+                // , {field: 'product_name', width: '', title: '主营产品分类', align: 'center'}
+                , {field: 'guanlian_company', width: '', title: '关联的成交客户', align: 'center'}
                 // , {field: 'grade', width: '', title: '等级评分', sort:true,align: 'center'}
                 // , {field: 'people', width: '', title: '建档人数', align: 'center'}
                 // , {field: 'follow_time', width: '', title: '跟进记录', align: 'center'}

+ 1 - 1
application/admin/view/ranking/new_customer.html

@@ -51,7 +51,7 @@
             ,response: {
                 statusCode: 220 //成功的状态码,默认:0
             }
-            , page: true
+            , page: false
             , even: false //开启隔行背景
             , size: 'lg' //sm小尺寸的表格 lg大尺寸
             // ,width:100

+ 1 - 1
application/admin/view/ranking/reply_customer.html

@@ -51,7 +51,7 @@
             ,response: {
                 statusCode: 220 //成功的状态码,默认:0
             }
-            , page: true
+            , page: false
             , even: false //开启隔行背景
             , size: 'lg' //sm小尺寸的表格 lg大尺寸
             // ,width:100

+ 1 - 1
application/admin/view/ranking/yes_customer.html

@@ -51,7 +51,7 @@
             ,response: {
                 statusCode: 220 //成功的状态码,默认:0
             }
-            , page: true
+            , page: false
             , even: false //开启隔行背景
             , size: 'lg' //sm小尺寸的表格 lg大尺寸
             // ,width:100