|
@@ -5,6 +5,7 @@ namespace App\Service;
|
|
|
use App\Model\BasicType;
|
|
|
use App\Model\Depart;
|
|
|
use App\Model\DepartIndex;
|
|
|
+use App\Model\DepartWithDHF;
|
|
|
use App\Model\Employee;
|
|
|
use App\Model\EmployeeDepartPermission;
|
|
|
use App\Model\EmployeeFile;
|
|
@@ -1021,7 +1022,7 @@ class EmployeeService extends Service
|
|
|
->exists();
|
|
|
}else{
|
|
|
if($this->isEmpty($data,'id')) return [false,'id不能为空!'];
|
|
|
- if($data['id'] == $user['head']['id'] && empty($data['is_main'])) return [false,'总社不支持变更!'];
|
|
|
+ if($data['id'] == $user['head']['id'] && empty($value['is_main'])) return [false,'总社不支持变更!'];
|
|
|
$bool = Depart::whereRaw("binary code = '{$value['code']}'")
|
|
|
->where('id','<>',$data['id'])
|
|
|
->where('del_time',0)
|
|
@@ -1767,4 +1768,56 @@ class EmployeeService extends Service
|
|
|
->get()->toArray();
|
|
|
return array_column($emp,'id');
|
|
|
}
|
|
|
+
|
|
|
+ public function departSetDaHuangFengID($data,$user){
|
|
|
+ if(empty($data['top_depart_id'])) return [false, '请选择门店'];
|
|
|
+ if(empty($data['clueSourceId'])) return [false, '请填写大黄蜂clueSourceId'];
|
|
|
+
|
|
|
+ $dhf_map = DepartWithDHF::where('del_time',0)
|
|
|
+ ->whereIn('clueSourceId',$data['clueSourceId'])
|
|
|
+ ->pluck('top_depart_id','clueSourceId')->toArray();
|
|
|
+
|
|
|
+ $depart_map = Depart::where('del_time',0)
|
|
|
+ ->whereIn('id',array_values($dhf_map))
|
|
|
+ ->pluck('title','id')->toArray();
|
|
|
+
|
|
|
+ $time = time();
|
|
|
+ $insert = [];
|
|
|
+ $msg = "";
|
|
|
+ foreach ($data['clueSourceId'] as $value){
|
|
|
+ $top_depart_id_tmp = $dhf_map[$value] ?? 0;
|
|
|
+ if(! empty($top_depart_id_tmp) && $top_depart_id_tmp != $data['top_depart_id']){
|
|
|
+ $title = $depart_map[$top_depart_id_tmp] ?? "";
|
|
|
+ $msg .= "大黄蜂clueSourceId($value)已绑定门店($title),";
|
|
|
+ }else{
|
|
|
+ $insert[] = [
|
|
|
+ 'top_depart_id' => $data['top_depart_id'],
|
|
|
+ 'clueSourceId' => $value,
|
|
|
+ 'crt_time' => $time
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(! empty($msg)) return [false, rtrim($msg,',')];
|
|
|
+ if(empty($insert)) return [false, '暂无需要写入的数据'];
|
|
|
+
|
|
|
+ //删除
|
|
|
+ DepartWithDHF::where('del_time',0)
|
|
|
+ ->where('top_depart_id',$data['top_depart_id'])
|
|
|
+ ->update(['del_time' => $time]);
|
|
|
+
|
|
|
+ //写入
|
|
|
+ DepartWithDHF::insert($insert);
|
|
|
+
|
|
|
+ return [true, ''];
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getDepartDaHuangFengID($data,$user){
|
|
|
+ if(empty($data['top_depart_id'])) return [false, '门店ID不能为空'];
|
|
|
+
|
|
|
+ $clueSourceId = DepartWithDHF::where('del_time',0)
|
|
|
+ ->where('top_depart_id',$data['top_depart_id'])
|
|
|
+ ->pluck('clueSourceId')->toArray();
|
|
|
+
|
|
|
+ return [true, $clueSourceId];
|
|
|
+ }
|
|
|
}
|