chenhao 4 years ago
parent
commit
394a17d2fa

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

@@ -159,7 +159,18 @@ class Crontab extends Controller
                     $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) {
+                                $query->whereOr('website','like','%'.$v.'%');
+                            }
+                        })
+                        ->where('status',0)
+                        ->where('email','')
+                        ->find();
                     if ($ckeckWebsiteCompany) {
                         Db::name('customer')->where('id',$ckeckWebsiteCompany['id'])->update(['spread_id'=>$uid,'emial' => $v[2]]);
                         Db::name('customer')->where('emial',$v[2])->setInc('people',1);

+ 19 - 12
application/admin/controller/Customer.php

@@ -341,20 +341,27 @@ class Customer extends Base
             $param = input('post.');
 //            var_dump($param);die;
             // 主客户信息
-            $info = CustomerModel::where('id', $param['cid'])->find()->toArray();
-            if ($info['spread_id'] != $param['aid']) {
-                CustomerModel::where('id', $param['cid'])->update(['spread_id' => $param['aid']]);
-                Db::name('rangk')->where('c_id', 'in', $param['ids'])->update(['admin_id' => $param['aid']]);
-            }
-            if (isset($param['check'])) {
-                $cids = explode(',', $param['ids']);
-                foreach ($cids as $k => $v) {
-                    if ($cids[$k] != $param['cid']) {
-                        Db::name('customer')->where('id', $cids[$k])->delete();
-                        Db::name('ranking')->where('c_id', $cids[$k])->delete();
-                    }
+            $info = CustomerModel::where('id', $param['cid'])
+                ->find()
+                ->toArray();
+
+            $customerAll  = CustomerModel::where('id','in',$param['ids'])
+                ->where('id','neq',$param['cid'])
+                ->select();
+            foreach ($customerAll as &$v) {
+                $count = Db::name('customer')
+                    ->where('spread_id',$v['spread_id'])
+                    ->where('email',$customerAll['email'])
+                    ->count();
+                if ($count > 1) {
+                    return json(['msg'=>'邮箱重复','code' => 100]);
                 }
             }
+//            if ($info['spread_id'] != $param['aid']) {
+                CustomerModel::where('id','in' ,$param['ids'])
+                    ->update(['email' => $info['email'],'company' =>$info['company']]);
+//                Db::name('rangk')->where('c_id', 'in', $param['ids'])->update(['admin_id' => $param['aid']]);
+//            }
             return json(['code' => 200, 'msg' => '合并成功']);
         }
         $customerModel = new CustomerModel();

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

@@ -484,7 +484,7 @@ class Upload extends Base
                         ->where('website','like','%'.$v[3].'%')
                         ->where(function ($query) use ($websiteArr) {
                             foreach ($websiteArr as $v) {
-
+                                 $query->whereOr('website','like','%'.$v.'%');
                             }
                         })
                         ->where('status',0)

+ 16 - 10
application/admin/model/CustomerModel.php

@@ -207,11 +207,16 @@ class CustomerModel extends Model
             }
         }
         if (isset($param['email'])){
-            $upd_email = $this->where('id',$param['id'])->update(['email' => $param['email']]);
-            if ($upd_email) {
-                writelog('操作员'.session('nickname').'修改客户'.$customer['name'].'的邮箱为'.$param['email'],200);
-                $status = 200;
-                $msg = '修改成功!';
+            $customerIsset = $this->where('spread_id',$customer['spread_id'])->where('email',$param['email'])->find()->toArray();
+            if ($customerIsset) {
+                return json(['code' => 100,'msg'=>'邮箱重复,修改失败']);
+            } else{
+                $upd_email = $this->where('id',$param['id'])->update(['email' => $param['email']]);
+                if ($upd_email) {
+                    writelog('操作员'.session('nickname').'修改客户'.$customer['name'].'的邮箱为'.$param['email'],200);
+                    $status = 200;
+                    $msg = '修改成功!';
+                }
             }
         }
         if (isset($param['company'])){
@@ -248,13 +253,14 @@ class CustomerModel extends Model
             $check = $this->where('type',$info['type'])->where('product',$info['product'])->find();
             if ($check) {
                 $msg = '行业与产品与原先一致,无需修改';
+            } else {
+                $res = $this->where('id',$param['id'])->update($info);
+                if ($res) {
+                    $status = 200;
+                    $msg = '修改成功!';
+                }
             }
         }
-        $res = $this->where('id',$param['id'])->update($info);
-        if ($res) {
-            $status = 200;
-            $msg = '修改成功!';
-        }
         return json(['code' => $status,'msg'=>$msg]);
     }
     /**

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

@@ -133,9 +133,9 @@
 					<button class="layui-btn layui-btn-normal layuiBtn" data-type="guanLian">
                     标记为关联
                 </button>
-					<!--                <button class="layui-btn layui-btn-normal layuiBtn"  data-type="huiFu">-->
-					<!--                    标记为已回复-->
-					<!--                </button>-->
+<!--				<button class="layui-btn layui-btn-normal layuiBtn"  data-type="huiFu">-->
+<!--					标记为已回复-->
+<!--				</button>-->
 					<!--                <button class="layui-btn layui-btn-normal layuiBtn"  data-type="hebing">-->
 					<!--                    合并-->
 					<!--                </button>-->

+ 19 - 19
application/admin/view/customer/admin/hebing.html

@@ -5,33 +5,33 @@
         <div class="layui-card-body layui-form">
             <div class="layui-row layui-col-space10 layui-form-item ">
                 <input type="hidden" name = 'ids' value="{$ids}">
-                <div style="margin-left: 30%;font-size: 15px"><strong>被合并客户的所有资料(包括子资料全部转移到主客户)</strong></div>
+                <div style="margin-left: 30%;font-size: 15px"><strong>标记选择邮箱为同一家客户所有</strong></div>
                 <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
-                    <label class="layui-form-label" style="height: 20px;background-color:#C2C5D3;text-align: center " >合并的主客户</label>
+                    <label class="layui-form-label" style="height: 20px;background-color:#C2C5D3;text-align: center " >按此条数据内容</label>
                     <div class="layui-input-block">
                         <select name="cid" lay-verify="required" lay-search="">
                             {foreach name="customer" item="vo"}
-                            <option value="{$vo.id}">{$vo.name}</option>
+                            <option value="{$vo.id}">{$vo.email}</option>
                             {/foreach}
                         </select>
                     </div>
                 </div>
-                <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
-                    <label class="layui-form-label" style="height: 20px;background-color:#C2C5D3;text-align: center ">合并的主业务员</label>
-                    <div class="layui-input-block">
-                        <select name="aid" lay-verify="required" lay-search="">
-                            {foreach name="admin_user" item="vo"}
-                            <option value="{$vo.aid}">{$vo.username}</option>
-                            {/foreach}
-                        </select>
-                    </div>
-                </div>
-                <div class="layui-form-item layui-col-md-offset1 layui-col-md8" >
-                    <label class="layui-form-label" style="margin-top: 3px;height: 18px;background-color:#C2C5D3;text-align: center ">合并后操作</label>
-                    <div class="layui-input-block" >
-                        <input  type="checkbox" name="check" lay-filter="like" title="合并后删除客户" value="1" checked>
-                    </div>
-                </div>
+<!--                <div class="layui-form-item layui-col-md-offset1 layui-col-md8">-->
+<!--                    <label class="layui-form-label" style="height: 20px;background-color:#C2C5D3;text-align: center ">合并的主业务员</label>-->
+<!--                    <div class="layui-input-block">-->
+<!--                        <select name="aid" lay-verify="required" lay-search="">-->
+<!--                            {foreach name="admin_user" item="vo"}-->
+<!--                            <option value="{$vo.aid}">{$vo.username}</option>-->
+<!--                            {/foreach}-->
+<!--                        </select>-->
+<!--                    </div>-->
+<!--                </div>-->
+<!--                <div class="layui-form-item layui-col-md-offset1 layui-col-md8" >-->
+<!--                    <label class="layui-form-label" style="margin-top: 3px;height: 18px;background-color:#C2C5D3;text-align: center ">合并后操作</label>-->
+<!--                    <div class="layui-input-block" >-->
+<!--                        <input  type="checkbox" name="check" lay-filter="like" title="合并后删除客户" value="1" checked>-->
+<!--                    </div>-->
+<!--                </div>-->
                 <div class="layui-form-item layui-col-md-offset1 layui-col-md8" style="text-align: center">
                     <div class="layui-input-block">
                         <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="component-form-element">保存

+ 4 - 4
application/admin/view/customer/admin/see.html

@@ -8,7 +8,7 @@
                 <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                     <label class="layui-form-label"><strong>用户名:</strong></label>
                     <div class="layui-input-block">
-                        <input type="text" name="name" lay-verify="required|username" placeholder="请输入用户名" class="layui-input " value="{$see.name}">
+                        <input type="text" name="name"  placeholder="请输入用户名" class="layui-input " value="{$see.name}">
                     </div>
                 </div>
                 {else}
@@ -59,7 +59,7 @@
                 <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                     <label class="layui-form-label"><strong>公司:</strong></label>
                     <div class="layui-input-block">
-                        <input type="text" name="company" lay-verify="required" placeholder="" class="layui-input " value="{$see.company}">
+                        <input type="text" name="company"  placeholder="" class="layui-input " value="{$see.company}">
 
                     </div>
                 </div>
@@ -73,7 +73,7 @@
                 <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                     <label class="layui-form-label"><strong>电话:</strong></label>
                     <div class="layui-input-block">
-                        <input type="text" name="phone" lay-verify="required|phone" placeholder="" class="layui-input " value="{$see.phone}">
+                        <input type="text" name="phone"  placeholder="" class="layui-input " value="{$see.phone}">
 
                     </div>
                 </div>
@@ -159,7 +159,7 @@
                 success:function(res){
                     if (res.code == 200) {
                         if(res.data == 100){
-                            wk.success(res.msg,'',"{:url('admin/Login/loginOut')}");
+                            // wk.success(res.msg,'',"{:url('admin/Login/loginOut')}");
                         }else{
                             if (res.type == "have") {
                                 // wk.success(res.msg,'top.location.reload()');