|
@@ -16,8 +16,8 @@ class FollowUpRecordService extends Service
|
|
|
|
|
|
$model = new FollowUpRecord();
|
|
$model = new FollowUpRecord();
|
|
$model = $model->where('id',$data['id'])->first();
|
|
$model = $model->where('id',$data['id'])->first();
|
|
- $model->sales_order_id = $data['sales_order_id'] ?? 0;
|
|
|
|
- $model->customer_id = $data['customer_id'];
|
|
|
|
|
|
+ $model->data_id = $data['data_id'] ?? 0;
|
|
|
|
+ $model->type = $data['type'] ?? '';
|
|
$model->basic_type_id = $data['basic_type_id'] ;
|
|
$model->basic_type_id = $data['basic_type_id'] ;
|
|
$model->visit_time = $data['visit_time'];
|
|
$model->visit_time = $data['visit_time'];
|
|
$model->content = $data['content'];
|
|
$model->content = $data['content'];
|
|
@@ -33,8 +33,8 @@ class FollowUpRecordService extends Service
|
|
if(!$status) return [$status,$msg];
|
|
if(!$status) return [$status,$msg];
|
|
|
|
|
|
$model = new FollowUpRecord();
|
|
$model = new FollowUpRecord();
|
|
- $model->sales_order_id = $data['sales_order_id'] ?? 0;
|
|
|
|
- $model->customer_id = $data['customer_id'];
|
|
|
|
|
|
+ $model->data_id = $data['data_id'] ?? 0;
|
|
|
|
+ $model->type = $data['type'] ?? '';
|
|
$model->basic_type_id = $data['basic_type_id'] ;
|
|
$model->basic_type_id = $data['basic_type_id'] ;
|
|
$model->visit_time = $data['visit_time'];
|
|
$model->visit_time = $data['visit_time'];
|
|
$model->content = $data['content'];
|
|
$model->content = $data['content'];
|
|
@@ -58,13 +58,13 @@ class FollowUpRecordService extends Service
|
|
|
|
|
|
public function followUpRecordList($data,$user){
|
|
public function followUpRecordList($data,$user){
|
|
$model = FollowUpRecord::where('del_time',0)
|
|
$model = FollowUpRecord::where('del_time',0)
|
|
- ->select('customer_id','basic_type_id','visit_time','id','content','is_remind','crt_time','crt_id','sales_order_id','result')
|
|
|
|
|
|
+ ->select('data_id','basic_type_id','visit_time','id','content','is_remind','crt_time','crt_id','type','result')
|
|
->orderBy('id','desc');
|
|
->orderBy('id','desc');
|
|
|
|
|
|
- if(! empty($data['customer_id'])) $model->where('customer_id',$data['customer_id']);
|
|
|
|
|
|
+ if(! empty($data['data_id'])) $model->where('data_id',$data['data_id']);
|
|
if(! empty($data['basic_type_id'])) $model->where('basic_type_id', $data['basic_type_id']);
|
|
if(! empty($data['basic_type_id'])) $model->where('basic_type_id', $data['basic_type_id']);
|
|
if(! empty($data['crt_id'])) $model->where('crt_id',$data['crt_id']);
|
|
if(! empty($data['crt_id'])) $model->where('crt_id',$data['crt_id']);
|
|
- if(! empty($data['sales_order_id'])) $model->where('sales_order_id',$data['sales_order_id']);
|
|
|
|
|
|
+ if(! empty($data['type'])) $model->where('type',$data['type']);
|
|
|
|
|
|
$list = $this->limit($model,'',$data);
|
|
$list = $this->limit($model,'',$data);
|
|
$list = $this->organizationData($list);
|
|
$list = $this->organizationData($list);
|
|
@@ -75,25 +75,18 @@ class FollowUpRecordService extends Service
|
|
public function organizationData($data) {
|
|
public function organizationData($data) {
|
|
if (empty($data['data'])) return $data;
|
|
if (empty($data['data'])) return $data;
|
|
|
|
|
|
- $customer = Customer::whereIn('id',array_unique(array_column($data['data'],'customer_id')))
|
|
|
|
- ->pluck('title','id')
|
|
|
|
- ->toArray();
|
|
|
|
-
|
|
|
|
$basic_type = BasicType::whereIn('id',array_unique(array_column($data['data'],'basic_type_id')))
|
|
$basic_type = BasicType::whereIn('id',array_unique(array_column($data['data'],'basic_type_id')))
|
|
->pluck('title','id')
|
|
->pluck('title','id')
|
|
->toArray();
|
|
->toArray();
|
|
- $sales = SalesOrder::whereIn('id',array_unique(array_column($data['data'],'sales_order_id')))->pluck('order_number','id')->toArray();
|
|
|
|
-
|
|
|
|
foreach ($data['data'] as $key => $value){
|
|
foreach ($data['data'] as $key => $value){
|
|
- $data['data'][$key]['customer_name'] = $customer[$value['customer_id']] ?? '';
|
|
|
|
$data['data'][$key]['basic_type_name'] = $basic_type[$value['basic_type_id']] ?? '';
|
|
$data['data'][$key]['basic_type_name'] = $basic_type[$value['basic_type_id']] ?? '';
|
|
- $data['data'][$key]['sales_order_number'] = $sales[$value['sales_order_id']] ?? '';
|
|
|
|
}
|
|
}
|
|
return $data;
|
|
return $data;
|
|
}
|
|
}
|
|
|
|
|
|
public function followUpRecordRule(&$data,$is_add = true){
|
|
public function followUpRecordRule(&$data,$is_add = true){
|
|
- if($this->isEmpty($data,'customer_id')) return [false,'客户不能为空'];
|
|
|
|
|
|
+ if($this->isEmpty($data,'data_id')) return [false,'数据id不能为空'];
|
|
|
|
+ if(empty($data['type']) || ! isset(FollowUpRecord::$type[$data['type']])) return [false,'跟进类型不能为空'];
|
|
if($this->isEmpty($data,'basic_type_id')) return [false,'跟进方式不能为空'];
|
|
if($this->isEmpty($data,'basic_type_id')) return [false,'跟进方式不能为空'];
|
|
if($this->isEmpty($data,'visit_time')) return [false,'拜访时间不能为空'];
|
|
if($this->isEmpty($data,'visit_time')) return [false,'拜访时间不能为空'];
|
|
if($this->isEmpty($data,'content')) return [false,'跟进内容不能为空'];
|
|
if($this->isEmpty($data,'content')) return [false,'跟进内容不能为空'];
|
|
@@ -114,8 +107,6 @@ class FollowUpRecordService extends Service
|
|
->first();
|
|
->first();
|
|
if(empty($record)) return [false,'跟进记录不存在或已被删除'];
|
|
if(empty($record)) return [false,'跟进记录不存在或已被删除'];
|
|
$record = $record->toArray();
|
|
$record = $record->toArray();
|
|
- $sales = SalesOrder::where('id',$record['sales_order_id'])->value('order_number');
|
|
|
|
- $record['sales_order_number'] = $sales;
|
|
|
|
$emp_map = Employee::where('id',$record['crt_id'])->value('emp_name');
|
|
$emp_map = Employee::where('id',$record['crt_id'])->value('emp_name');
|
|
$record['crt_name'] = $emp_map;
|
|
$record['crt_name'] = $emp_map;
|
|
$record['crt_time'] = $record['crt_time'] ? date("Y-m-d H:i:s",$record['crt_time']): '';
|
|
$record['crt_time'] = $record['crt_time'] ? date("Y-m-d H:i:s",$record['crt_time']): '';
|