objMCustomerTagLib = new MCustomerTagLib($this->onlineEnterpriseId, $this->onlineUserId); } /** * 添加和编辑客户标签管理公共字段处理方法 * * @return array */ public function commonFieldFilter() { $params = $this->request->getRawJson(); if( empty($params) ){ $this->sendOutput('参数为空', ErrorCode::$paramError ); } $customerLibData = [ 'enterpriseId' => $this->onlineEnterpriseId, 'name' => getArrayItem($params,'name'), 'pid' => getArrayItem($params,'pid',0), 'colour' => getArrayItem($params,'colour', StatusCode::$delete), 'mustValue' => getArrayItem($params,'mustValue',0), 'tags' => getArrayItem($params,'tags',[]), ]; foreach($customerLibData as $key => $value){ if(empty($value) && $value !== 0){ $this->sendOutput($key.'参数错误', ErrorCode::$paramError ); } } return $customerLibData; } /** * 添加客户标签 */ public function addCustomerTagLib() { $customerTagLibData = $this->commonFieldFilter(); $result = $this->objMCustomerTagLib ->addCustomerTagLib($customerTagLibData); if($result->isSuccess()){ parent::sendOutput($result->getData()); }else{ parent::sendOutput($result->getData(), $result->getErrorCode()); } } /** * 获取指定客户标签 */ public function getCustomerTagLibInfo() { $customerTagLibId = $this->request->param('request_id'); if ( !$customerTagLibId ) { $this->sendOutput('参数错误', ErrorCode::$paramError ); } $result = $this->objMCustomerTagLib->getCustomerTagLibInfo($customerTagLibId); if($result->isSuccess()){ $this->sendOutput($result->getData()); }else{ $this->sendOutput($result->getData(), $result->getErrorCode()); } } /** * 编辑客户标签 */ public function editCustomerTagLib() { $params = $this->request->getRawJson(); if(empty($params)){ $this->sendOutput('参数错误', ErrorCode::$paramError); } $result = $this->objMCustomerTagLib->editCustomerTagLib($params); if($result->isSuccess()){ parent::sendOutput($result->getData()); }else{ parent::sendOutput($result->getData(), $result->getErrorCode()); } } /** * 删除客户标签 */ public function delCustomerTagLib() { $params = $this->request->getRawJson(); if( empty($params) ){ $this->sendOutput('参数为空', ErrorCode::$paramError ); } $result = $this->objMCustomerTagLib->delCustomerTagLib($params); if($result->isSuccess()){ parent::sendOutput($result->getData()); }else{ parent::sendOutput($result->getData(), $result->getErrorCode()); } } /** * 后台所有客户标签列表 */ public function getAllCustomerTagLib() { $result = $this->objMCustomerTagLib->getAllCustomerTagLib(); if($result->isSuccess()){ parent::sendOutput($result->getData(), 0); }else{ parent::sendOutput($result->getData(), $result->getErrorCode()); } } /** * 编辑客户指定标签 */ public function updateCustomerTagLibById() { $params = $this->request->getRawJson(); if ( !$params ) { $this->sendOutput('参数错误', ErrorCode::$paramError ); } $updateCustomerLibData = [ 'id' => getArrayItem($params,'id'), 'taglib' => getArrayItem($params,'taglib',[]), ]; foreach($updateCustomerLibData as $key => $value){ if(empty($value) && $value !== 0){ $this->sendOutput($key.'参数错误', ErrorCode::$paramError ); } } $result = $this->objMCustomerTagLib->updateCustomerTagLibById($updateCustomerLibData); if($result->isSuccess()){ parent::sendOutput($result->getData()); }else{ parent::sendOutput($result->getData(), $result->getErrorCode()); } } }