|
@@ -6,6 +6,7 @@ use App\Exports\TableHeadExport;
|
|
|
use App\Import\Import;
|
|
|
use App\Import\ImportAll;
|
|
|
use App\Model\BasicType;
|
|
|
+use App\Model\BasicTypeAllUse;
|
|
|
use App\Model\Customer;
|
|
|
use App\Model\CustomerInfo;
|
|
|
use App\Model\CustomerRepeat;
|
|
@@ -345,14 +346,20 @@ class ImportService extends Service
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- $model = Product::ProductClear($user,[]);
|
|
|
- $product = $model->where('del_time',0)
|
|
|
- ->whereIn('title',array_unique(array_column($array,'6')))
|
|
|
+// $model = Product::ProductClear($user,[]);
|
|
|
+// $product = $model->where('del_time',0)
|
|
|
+// ->whereIn('title',array_unique(array_column($array,'6')))
|
|
|
+// ->pluck('id','title')
|
|
|
+// ->toArray();
|
|
|
+
|
|
|
+ $basic_use = BasicTypeAllUse::where('del_time',0)
|
|
|
+ ->where('type', BasicTypeAllUse::type_one)
|
|
|
+ ->whereIn('title',array_unique(array_column($array,'5')))
|
|
|
->pluck('id','title')
|
|
|
->toArray();
|
|
|
|
|
|
$emp = Employee::where('del_time',0)
|
|
|
- ->whereIn('number',array_unique(array_column($array,'14')))
|
|
|
+ ->whereIn('number',array_unique(array_column($array,'13')))
|
|
|
->pluck('id','number')
|
|
|
->toArray();
|
|
|
|
|
@@ -367,7 +374,7 @@ class ImportService extends Service
|
|
|
->select('a.contact_info')->get()->toArray();
|
|
|
$contact_info_array = array_column($contact_info_array,'contact_info');
|
|
|
|
|
|
- list($status, $msg) = $this->customerFilterSecond($array,$time,$head,$user,$contact_info_array,$customer,$basic_list,$product,$emp);
|
|
|
+ list($status, $msg) = $this->customerFilterSecond($array,$time,$head,$user,$contact_info_array,$customer,$basic_list,$emp,$basic_use);
|
|
|
if(! $status) return [0, $msg];
|
|
|
list($insert, $insert_detail, $insert_detail2) = $msg;
|
|
|
|
|
@@ -443,23 +450,23 @@ class ImportService extends Service
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if(! empty($value[13])){
|
|
|
- if(in_array($value[13],$contact_info)) {
|
|
|
- $error[] = $line . '联系方式内容'. $value[13] .'在导入文件内重复出现';
|
|
|
+ if(! empty($value[12])){
|
|
|
+ if(in_array($value[12],$contact_info)) {
|
|
|
+ $error[] = $line . '联系方式内容'. $value[12] .'在导入文件内重复出现';
|
|
|
}else{
|
|
|
- $contact_info[] = $value[13];
|
|
|
+ $contact_info[] = $value[12];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if(! empty($value[15])){
|
|
|
- list($status, $msg) = $this->convertExcelCellToDate($value[15]);
|
|
|
+ if(! empty($value[14])){
|
|
|
+ list($status, $msg) = $this->convertExcelCellToDate($value[14]);
|
|
|
if(! $status) {
|
|
|
$error[] = $line . $msg;
|
|
|
}else{
|
|
|
- $value[15] = $msg;
|
|
|
+ $value[14] = $msg;
|
|
|
}
|
|
|
} else{
|
|
|
- $value[15] = $time;
|
|
|
+ $value[14] = $time;
|
|
|
}
|
|
|
|
|
|
$array[$key] = $value;
|
|
@@ -474,7 +481,7 @@ class ImportService extends Service
|
|
|
return [true, $contact_info];
|
|
|
}
|
|
|
|
|
|
- function customerFilterSecond($array, $time, $head, $user, $contact_info_array,$customer,$basic_list,$product,$emp){
|
|
|
+ function customerFilterSecond($array, $time, $head, $user, $contact_info_array,$customer,$basic_list,$emp,$basic_use){
|
|
|
$error = $insert = $insert_detail = $insert_detail2 = $repeat_array = [];
|
|
|
foreach ($array as $key => $value){
|
|
|
$line = '第' . $key . '行';
|
|
@@ -485,8 +492,8 @@ class ImportService extends Service
|
|
|
'customer_from' => '',
|
|
|
'customer_type' => '',
|
|
|
'car_type' => '',
|
|
|
- 'consulting_product' => '',
|
|
|
- 'intention_product' => '',
|
|
|
+ 'consulting_product_new' => '',
|
|
|
+// 'intention_product' => '',
|
|
|
'progress_stage' => '',
|
|
|
'state_type' => '',
|
|
|
'address2' => '',
|
|
@@ -496,12 +503,11 @@ class ImportService extends Service
|
|
|
'crt_id' => $user['id'],
|
|
|
'crt_time' => $time,
|
|
|
'upd_time' => $time,
|
|
|
- 'enter_time' => $value['15'],
|
|
|
+ 'enter_time' => $value['14'],
|
|
|
];
|
|
|
$tmp['model_type'] = $value['0'];
|
|
|
- $tmp['consulting_product'] = $value['5'];
|
|
|
- $tmp['mark'] = $value['10'];
|
|
|
- $tmp['address2'] = $value['11'];
|
|
|
+ $tmp['mark'] = $value['9'];
|
|
|
+ $tmp['address2'] = $value['10'];
|
|
|
$repeat = 0;//是否重复
|
|
|
|
|
|
if(! empty($customer[$value['1']])) {
|
|
@@ -533,64 +539,67 @@ class ImportService extends Service
|
|
|
$tmp['customer_type'] = $basic_list[$keys][$value['4']];
|
|
|
}
|
|
|
}
|
|
|
- if($value['6']){
|
|
|
- if(empty($product[$value['6']])) {
|
|
|
- $error[] = $line . '意向产品:' . $value['6'] . '不存在';
|
|
|
+ if($value['5']){
|
|
|
+ if(empty($basic_use[$value['5']])) {
|
|
|
+ $error[] = $line . '咨询产品:' . $value['5'] . '不存在';
|
|
|
}else{
|
|
|
- $tmp['intention_product'] = $product[$value['6']];
|
|
|
+ $tmp['consulting_product_new'] = $basic_use[$value['5']];
|
|
|
}
|
|
|
}
|
|
|
- if($value['7']){
|
|
|
- if(empty($basic_list[7][$value['7']])) {
|
|
|
- $error[] = $line . '进展阶段:' . $value['7'] . '不存在';
|
|
|
+// if($value['6']){
|
|
|
+// if(empty($product[$value['6']])) {
|
|
|
+// $error[] = $line . '意向产品:' . $value['6'] . '不存在';
|
|
|
+// }else{
|
|
|
+// $tmp['intention_product'] = $product[$value['6']];
|
|
|
+// }
|
|
|
+// }
|
|
|
+ if($value['6']){
|
|
|
+ if(empty($basic_list[7][$value['6']])) {
|
|
|
+ $error[] = $line . '进展阶段:' . $value['6'] . '不存在';
|
|
|
}else{
|
|
|
- $tmp['progress_stage'] = $basic_list[7][$value['7']];
|
|
|
+ $tmp['progress_stage'] = $basic_list[7][$value['6']];
|
|
|
}
|
|
|
}
|
|
|
- if($value['8']){
|
|
|
- if(empty($basic_list[8][$value['8']])) {
|
|
|
- $error[] = $line . '状态:' . $value['8'] . '不存在';
|
|
|
+ if($value['7']){
|
|
|
+ if(empty($basic_list[8][$value['7']])) {
|
|
|
+ $error[] = $line . '状态:' . $value['7'] . '不存在';
|
|
|
}else{
|
|
|
- $tmp['state_type'] = $basic_list[8][$value['8']];
|
|
|
+ $tmp['state_type'] = $basic_list[8][$value['7']];
|
|
|
}
|
|
|
}
|
|
|
- if($value['9']){
|
|
|
- if(empty($basic_list[9][$value['9']])) {
|
|
|
- $error[] = $line . '车型:' . $value['9'] . '不存在';
|
|
|
+ if($value['8']){
|
|
|
+ if(empty($basic_list[9][$value['8']])) {
|
|
|
+ $error[] = $line . '车型:' . $value['8'] . '不存在';
|
|
|
}else{
|
|
|
- $tmp['car_type'] = $basic_list[9][$value['9']];
|
|
|
+ $tmp['car_type'] = $basic_list[9][$value['8']];
|
|
|
}
|
|
|
}
|
|
|
$contact_id = 0;
|
|
|
- if($value['12']){
|
|
|
- if(empty($basic_list[12][$value['12']])) {
|
|
|
- $error[] = $line . '联系方式类型:' . $value['12'] . '不存在';
|
|
|
+ if($value['11']){
|
|
|
+ if(empty($basic_list[12][$value['11']])) {
|
|
|
+ $error[] = $line . '联系方式类型:' . $value['11'] . '不存在';
|
|
|
}else{
|
|
|
- $contact_id = $basic_list[12][$value['12']];
|
|
|
+ $contact_id = $basic_list[12][$value['11']];
|
|
|
}
|
|
|
}
|
|
|
- if($value['13'] && in_array($value['13'],$contact_info_array)){
|
|
|
+ if($value['12'] && in_array($value['12'],$contact_info_array)){
|
|
|
$repeat = 1;
|
|
|
- $error[] = $line . '联系方式内容:' . $value['13'] . '已存在';
|
|
|
+ $error[] = $line . '联系方式内容:' . $value['12'] . '已存在';
|
|
|
}
|
|
|
$man = 0;
|
|
|
- if($value['14']){
|
|
|
- if(empty($emp[$value['14']])) {
|
|
|
- $error[] = $line . '负责人:' . $value['14'] . '不存在';
|
|
|
+ if($value['13']){
|
|
|
+ if(empty($emp[$value['13']])) {
|
|
|
+ $error[] = $line . '负责人:' . $value['13'] . '不存在';
|
|
|
}else{
|
|
|
- $man = $emp[$value['14']];
|
|
|
+ $man = $emp[$value['13']];
|
|
|
}
|
|
|
}
|
|
|
-// if($value['12']){
|
|
|
-// if(empty($emp[$value['12']])) return [false, '协同人:' . $value['12'] . '不存在'];
|
|
|
-// $tmp['emp_two'] = $emp[$value['12']];
|
|
|
-// }
|
|
|
|
|
|
$insert[] = $tmp;
|
|
|
$insert_detail[] = [
|
|
|
'customer_id' => 0,
|
|
|
'contact_type' => $contact_id,
|
|
|
- 'contact_info' => $value['13'],
|
|
|
+ 'contact_info' => $value['12'],
|
|
|
'crt_time' => $time,
|
|
|
'type' => CustomerInfo::type_one
|
|
|
];
|
|
@@ -602,7 +611,7 @@ class ImportService extends Service
|
|
|
];
|
|
|
if($repeat){
|
|
|
$tmp['contact_type'] = $contact_id;
|
|
|
- $tmp['contact'] = $value['13'];
|
|
|
+ $tmp['contact'] = $value['12'];
|
|
|
$tmp['fz_man'] = $man;
|
|
|
$repeat_array[] = $tmp;
|
|
|
}
|