|
@@ -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']); // 修改记录表
|