diff --git a/niucloud/app/api/controller/apiController/CustomerResources.php b/niucloud/app/api/controller/apiController/CustomerResources.php index f58175ec..4f8afca8 100644 --- a/niucloud/app/api/controller/apiController/CustomerResources.php +++ b/niucloud/app/api/controller/apiController/CustomerResources.php @@ -28,12 +28,14 @@ class CustomerResources extends BaseApiService public function getAll(Request $request){ $name = $request->param('name', '');//客户姓名 - if(empty($name)){ - return fail("缺少客户姓名"); + $phone_number = $request->param('phone_number', '');//客户手机号 + if(empty($name) && empty($phone_number)){ + return fail("缺少查询参数"); } $where = [ - 'name'=>$name + 'name'=>$name, + 'phone_number'=>$phone_number ]; $res = (new CustomerResourcesService())->getAll($where); if(!$res['code']){ @@ -93,6 +95,11 @@ class CustomerResources extends BaseApiService return fail("缺少必填项{$k}"); } } + + if (strlen($customer_resources_data['phone_number']) > 12) { + return fail("联系电话不能超过12位"); + } + foreach($six_speed_data as $k=>$v){ if(!isset($v) || $v === ''){ return fail("缺少必填项{$k}"); @@ -177,6 +184,16 @@ class CustomerResources extends BaseApiService return fail("缺少必填项{$k}"); } } + + if (strlen($customer_resources_data['phone_number']) > 12) { + return fail("联系电话不能超过12位"); + } + + //如果六要素人员id没有就是当前登录人的员工id + if(empty($six_speed_data['staff_id'])){ + $six_speed_data['staff_id'] = $this->member_id; + } + foreach($six_speed_data as $k=>$v){ // 排除 first_visit_status 和 second_visit_status 的必填校验 if (in_array($k, ['first_visit_status', 'second_visit_status'])) { diff --git a/niucloud/app/model/customer_resources/CustomerResources.php b/niucloud/app/model/customer_resources/CustomerResources.php index ae42a928..30a93c58 100644 --- a/niucloud/app/model/customer_resources/CustomerResources.php +++ b/niucloud/app/model/customer_resources/CustomerResources.php @@ -341,6 +341,33 @@ class CustomerResources extends BaseModel } } + /** + * 获取决策人类型名称 + * @param $value + * @param $data + * @return array|mixed|string + */ + public function getDecisionMakerNameAttr($value, $data) + { + $key = 'decision_maker'; + $val = (String)$data['decision_maker'] ?? ''; + if ((!empty($val) || isset($val)) && $val !== '') { + $dict = Dict::where('key',$key)->find(); + $dictionary = $dict['dictionary'] ?? []; + // 查找匹配的 name + $res = $val; + foreach ($dictionary as $item) { + if ($item['value'] == $val) { + $res = $item['name']; + break; + } + } + return $res; + } else { + return $val; + } + } + } diff --git a/niucloud/app/service/api/apiService/CustomerResourcesService.php b/niucloud/app/service/api/apiService/CustomerResourcesService.php index 838d087b..6483fe29 100644 --- a/niucloud/app/service/api/apiService/CustomerResourcesService.php +++ b/niucloud/app/service/api/apiService/CustomerResourcesService.php @@ -86,12 +86,15 @@ class CustomerResourcesService extends BaseApiService if(!empty($where['name'])){ $model = $model->where('name', 'like', "%{$where['name']}%"); } + if(!empty($where['phone_number'])){ + $model = $model->where('phone_number', $where['phone_number']); + } $data = $model->field($field) ->with([ 'resourceSharingHasMany' ]) ->append([ - 'initial_intent_name' + 'initial_intent_name', ]) ->select()->toArray(); if (!$data) {