|
@@ -35,6 +35,7 @@ class CustomerService extends Service
|
|
|
$model->company = $data['company'] ?? '';
|
|
|
$model->company_short_name = $data['company_short_name'] ?? '';
|
|
|
$model->depart_id = $data['depart_id'] ?? 0;
|
|
|
+ $model->top_depart_id = $data['top_depart_id'] ?? 0;
|
|
|
$model->state_type = $data['state_type'] ?? 0;
|
|
|
$model->customer_state = $data['customer_state'] ?? 0;
|
|
|
$model->customer_grade = $data['customer_grade'] ?? 0;
|
|
@@ -160,6 +161,7 @@ class CustomerService extends Service
|
|
|
$model->company = $data['company'] ?? '';
|
|
|
$model->company_short_name = $data['company_short_name'] ?? '';
|
|
|
$model->depart_id = $data['depart_id'] ?? 0;
|
|
|
+ $model->top_depart_id = $data['top_depart_id'] ?? 0;
|
|
|
$model->state_type = $data['state_type'] ?? 0;
|
|
|
$model->customer_state = $data['customer_state'] ?? 0;
|
|
|
$model->customer_grade = $data['customer_grade'] ?? 0;
|
|
@@ -384,9 +386,19 @@ class CustomerService extends Service
|
|
|
|
|
|
public function customerList($data,$user){
|
|
|
$model = Customer::where('del_time',0)
|
|
|
- ->select('title','id','model_type','customer_intention','customer_from','customer_type','car_type','consulting_product','intention_product','progress_stage','address1','address2','crt_id','crt_time','mark','importance','company','company_short_name','depart_id','state_type','customer_state','customer_grade')
|
|
|
+ ->select('title','id','model_type','customer_intention','customer_from','customer_type','car_type','consulting_product','intention_product','progress_stage','address1','address2','crt_id','crt_time','mark','importance','company','company_short_name','depart_id','state_type','customer_state','customer_grade','pond_state')
|
|
|
->orderby('id', 'desc');
|
|
|
|
|
|
+ //getALL传入后无视设置范围
|
|
|
+ if(empty($data['getAll']) && $user['id'] != Employee::SPECIAL_ADMIN) {
|
|
|
+ $user_id = $user['id'];
|
|
|
+ $customer_id = CustomerInfo::where('del_time',0)
|
|
|
+ ->where(function ($query) use($user_id) {
|
|
|
+ $query->where('employee_id',$user_id);
|
|
|
+ })->select('customer_id')->get()
|
|
|
+ ->toArray();
|
|
|
+ $model->whereIn('id',array_unique(array_column($customer_id,'customer_id')));
|
|
|
+ }
|
|
|
if(! empty($data['title'])) $model->where('title', 'LIKE', '%'.$data['title'].'%');
|
|
|
if(! empty($data['time_type'])) {
|
|
|
if($data['time_type'] == 1) {
|
|
@@ -409,10 +421,11 @@ class CustomerService extends Service
|
|
|
return [true, $list];
|
|
|
}
|
|
|
|
|
|
- public function customerRule($data, $is_add = true){
|
|
|
+ public function customerRule(&$data, $is_add = true){
|
|
|
if(empty($data['model_type'])) return [false,'客户模板类型不能为空'];
|
|
|
if(! in_array($data['model_type'],Customer::$model_type)) return [false,'客户模板类型错误'];
|
|
|
if(empty($data['title'])) return [false,'客户名称不能为空'];
|
|
|
+ if(! empty($data['depart_id'])) $data['top_depart_id'] = $user['depart_map'][$data['depart_id']] ?? 0;
|
|
|
if($data['model_type'] == Customer::Model_type_one){
|
|
|
if(empty($data['customer_from'])) return [false,'客户来源不能为空'];
|
|
|
if(empty($data['customer_type'])) return [false,'客户类别不能为空'];
|