objMCustomerContact = new MCustomerContact($this->onlineEnterpriseId, $this->onlineUserId); } /** * 添加和编辑客户联系人管理公共字段处理方法 * * @return array */ public function commonFieldFilter(){ $params = $this->request->getRawJson(); if( empty($params) ){ $this->sendOutput('参数为空', ErrorCode::$paramError ); } $customerContactData = [ 'customerId' => isset($params['customerId']) ? $params['customerId'] : '', 'name' => isset($params['name']) ? $params['name'] : '', 'mobile' => isset($params['mobile']) ? $params['mobile'] : '', ]; foreach($customerContactData as $key => $value){ if(empty($value) && $value !== 0){ $this->sendOutput($key.'参数错误', ErrorCode::$paramError ); } } $customerContactData['provinceCode'] = isset($params['provinceCode']) ? $params['provinceCode'] : ''; $customerContactData['cityCode'] = isset($params['cityCode']) ? $params['cityCode'] : ''; $customerContactData['districtCode'] = isset($params['districtCode']) ? $params['districtCode'] : ''; $customerContactData['address'] = isset($params['address']) ? $params['address'] : ''; $customerContactData['deleteStatus']= StatusCode::$standard; $customerContactData['createTime'] = time(); $customerContactData['updateTime'] = time(); return $customerContactData; } /** * 添加客户联系人 */ public function addCustomerContact() { $customerContactData = $this->commonFieldFilter(); $result = $this->objMCustomerContact->addCustomerContact($customerContactData); if($result->isSuccess()){ parent::sendOutput($result->getData()); }else{ parent::sendOutput($result->getData(), $result->getErrorCode()); } } /** * 获取指定客户联系人信息 */ public function getCustomerContactInfo() { $customerContactId = $this->request->param('request_id'); if ( !$customerContactId ) { $this->sendOutput('参数错误', ErrorCode::$paramError ); } $result = $this->objMCustomerContact->getCustomerContactInfo($customerContactId); if($result->isSuccess()){ $this->sendOutput($result->getData()); }else{ $this->sendOutput($result->getData(), $result->getErrorCode()); } } /** * 编辑客户联系人 */ public function editCustomerContact() { $customerContactId = $this->request->param('request_id'); if(empty($customerContactId)){ $this->sendOutput('参数错误', ErrorCode::$paramError); } $customerContactData = $this->commonFieldFilter(); $customerContactData['id'] = $customerContactId; unset($customerContactData['createTime']); $result = $this->objMCustomerContact->editCustomerContact($customerContactData); if($result->isSuccess()){ parent::sendOutput($result->getData()); }else{ parent::sendOutput($result->getData(), $result->getErrorCode()); } } /** * 删除客户联系人 */ public function delCustomerContact() { $customerContactId = $this->request->param('request_id'); if(!$customerContactId){ $this->sendOutput('参数错误', ErrorCode::$paramError); } $result = $this->objMCustomerContact->delCustomerContact($customerContactId); if($result->isSuccess()){ parent::sendOutput($result->getData()); }else{ parent::sendOutput($result->getData(), $result->getErrorCode()); } } /** * 客户联系人启用和禁用 */ public function updateCustomerContactStatus() { $params['id'] = $this->request->param('request_id'); $params['type'] = $this->request->param('type'); if($params['type'] == 1){ //启用 $params['enableStatus'] = StatusCode::$standard; }else if($params['type'] == 2){ //停用 $params['enableStatus'] = StatusCode::$offline; } foreach($params as $key => $value){ if(empty($value)){ $this->sendOutput($key.'参数错误', ErrorCode::$paramError ); } } unset($params['type']); $result = $this->objMCustomerContact->updateCustomerContactStatus($params); if($result->isSuccess()){ parent::sendOutput($result->getData()); }else{ parent::sendOutput($result->getData(), $result->getErrorCode()); } } /** * 后台所有客户联系人列表 */ public function getAllCustomerContact() { $result = $this->objMCustomerContact->getAllCustomerContact([],'*',true); if($result->isSuccess()){ parent::sendOutput($result->getData(), 0); }else{ parent::sendOutput($result->getData(), $result->getErrorCode()); } } }