123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172 |
- <?php
- /**
- * 客户标签管理模块
- * Created by PhpStorm.
- * User: kyl
- * Date: 2021/03/05
- */
-
- namespace JinDouYun\Controller\Customer;
- use JinDouYun\Controller\Market\VipCard;
- use JinDouYun\Model\Customer\MCustomer;
- use Mall\Framework\Core\ErrorCode;
- use Mall\Framework\Core\StatusCode;
- use JinDouYun\Controller\BaseController;
- use JinDouYun\Model\Customer\MCustomerTagLib;
- class CustomerTagLib extends BaseController
- {
- private $objMCustomerTagLib;
-
- public function __construct($isCheckAcl = true, $isMustLogin = true)
- {
- parent::__construct($isCheckAcl, $isMustLogin);
-
- $this->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());
- }
-
- }
- }
|