chenhao 4 年之前
父節點
當前提交
132e0898f1
共有 2 個文件被更改,包括 12 次插入2 次删除
  1. 1 0
      application/admin/controller/Customer.php
  2. 11 2
      application/admin/model/CustomerModel.php

+ 1 - 0
application/admin/controller/Customer.php

@@ -1612,6 +1612,7 @@ class Customer extends Base
                         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);
+                            Db::name('ranking')->where('c_id',$ckeckWebsiteCompany['id'])->update([['admin_id' => session('uid')]]);
                             $error[] = [
                                 'rows'    => $k,
                                 'msg'     => '已存在此公司,网站客户,直接更新,不计入添加次数',

+ 11 - 2
application/admin/model/CustomerModel.php

@@ -91,12 +91,21 @@ class CustomerModel extends Model
              'company' => $data['company'],
 //             'country' => $data['country'],
              'website' => $data['website'],
-             'phone' => $data['phone'],
+//             'phone' => $data['phone'],
          ];
          $checkEmail = $this->where('email',$data['email'])->where('spread_id',session('uid'))->find();
          if ($checkEmail) return json(['cdoe' => 100, 'msg' => '你已创建过此邮箱的客户了']);
-         $isset = $this->where($where)->find();
+         $isset = $this->where($where)->where('spread_id',session('uid'))->find();
          if ($isset) return json(['cdoe' => 100, 'msg' => '此客户已存在']);
+         $issets = $this->where($where)->where('status','in','1,2,3')->find();
+         if ($issets) return json(['cdoe' => 100, 'msg' => '此客户状态已经发生改变,无法添加']);
+         $issetss = $this->where('email','')->where('company' , $data['company'])->where('website' , $data['website'])->where('status',0)->find();
+         if ($issetss) {
+             Db::name('customer')->where('id'.$issetss['id'])->update(['spread_id' => session('uid')]);
+             Db::name('customer')->where('id'.$issetss['id'])->setInc('people',1);
+             Db::name('ranking')->where('c_id',$issetss['id'])->update(['admin_id' => session('uid')]);
+             return json(['code' => 200,'msg' => '添加成功']);
+         }
          $data['type'] = ','.$data['type'].',';
          $data['product'] = ','.$data['product'].',';
          self::people_set($data['name'],$data['email']);