|
@@ -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']);
|