CustomerTagLib.Class.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <?php
  2. /**
  3. * 客户标签管理模块
  4. * Created by PhpStorm.
  5. * User: kyl
  6. * Date: 2021/03/05
  7. */
  8. namespace JinDouYun\Controller\Customer;
  9. use JinDouYun\Controller\Market\VipCard;
  10. use JinDouYun\Model\Customer\MCustomer;
  11. use Mall\Framework\Core\ErrorCode;
  12. use Mall\Framework\Core\StatusCode;
  13. use JinDouYun\Controller\BaseController;
  14. use JinDouYun\Model\Customer\MCustomerTagLib;
  15. class CustomerTagLib extends BaseController
  16. {
  17. private $objMCustomerTagLib;
  18. public function __construct($isCheckAcl = true, $isMustLogin = true)
  19. {
  20. parent::__construct($isCheckAcl, $isMustLogin);
  21. $this->objMCustomerTagLib = new MCustomerTagLib($this->onlineEnterpriseId, $this->onlineUserId);
  22. }
  23. /**
  24. * 添加和编辑客户标签管理公共字段处理方法
  25. *
  26. * @return array
  27. */
  28. public function commonFieldFilter()
  29. {
  30. $params = $this->request->getRawJson();
  31. if( empty($params) ){
  32. $this->sendOutput('参数为空', ErrorCode::$paramError );
  33. }
  34. $customerLibData = [
  35. 'enterpriseId' => $this->onlineEnterpriseId,
  36. 'name' => getArrayItem($params,'name'),
  37. 'pid' => getArrayItem($params,'pid',0),
  38. 'colour' => getArrayItem($params,'colour', StatusCode::$delete),
  39. 'mustValue' => getArrayItem($params,'mustValue',0),
  40. 'tags' => getArrayItem($params,'tags',[]),
  41. ];
  42. foreach($customerLibData as $key => $value){
  43. if(empty($value) && $value !== 0){
  44. $this->sendOutput($key.'参数错误', ErrorCode::$paramError );
  45. }
  46. }
  47. return $customerLibData;
  48. }
  49. /**
  50. * 添加客户标签
  51. */
  52. public function addCustomerTagLib()
  53. {
  54. $customerTagLibData = $this->commonFieldFilter();
  55. $result = $this->objMCustomerTagLib ->addCustomerTagLib($customerTagLibData);
  56. if($result->isSuccess()){
  57. parent::sendOutput($result->getData());
  58. }else{
  59. parent::sendOutput($result->getData(), $result->getErrorCode());
  60. }
  61. }
  62. /**
  63. * 获取指定客户标签
  64. */
  65. public function getCustomerTagLibInfo()
  66. {
  67. $customerTagLibId = $this->request->param('request_id');
  68. if ( !$customerTagLibId ) {
  69. $this->sendOutput('参数错误', ErrorCode::$paramError );
  70. }
  71. $result = $this->objMCustomerTagLib->getCustomerTagLibInfo($customerTagLibId);
  72. if($result->isSuccess()){
  73. $this->sendOutput($result->getData());
  74. }else{
  75. $this->sendOutput($result->getData(), $result->getErrorCode());
  76. }
  77. }
  78. /**
  79. * 编辑客户标签
  80. */
  81. public function editCustomerTagLib()
  82. {
  83. $params = $this->request->getRawJson();
  84. if(empty($params)){
  85. $this->sendOutput('参数错误', ErrorCode::$paramError);
  86. }
  87. $result = $this->objMCustomerTagLib->editCustomerTagLib($params);
  88. if($result->isSuccess()){
  89. parent::sendOutput($result->getData());
  90. }else{
  91. parent::sendOutput($result->getData(), $result->getErrorCode());
  92. }
  93. }
  94. /**
  95. * 删除客户标签
  96. */
  97. public function delCustomerTagLib()
  98. {
  99. $params = $this->request->getRawJson();
  100. if( empty($params) ){
  101. $this->sendOutput('参数为空', ErrorCode::$paramError );
  102. }
  103. $result = $this->objMCustomerTagLib->delCustomerTagLib($params);
  104. if($result->isSuccess()){
  105. parent::sendOutput($result->getData());
  106. }else{
  107. parent::sendOutput($result->getData(), $result->getErrorCode());
  108. }
  109. }
  110. /**
  111. * 后台所有客户标签列表
  112. */
  113. public function getAllCustomerTagLib()
  114. {
  115. $result = $this->objMCustomerTagLib->getAllCustomerTagLib();
  116. if($result->isSuccess()){
  117. parent::sendOutput($result->getData(), 0);
  118. }else{
  119. parent::sendOutput($result->getData(), $result->getErrorCode());
  120. }
  121. }
  122. /**
  123. * 编辑客户指定标签
  124. */
  125. public function updateCustomerTagLibById()
  126. {
  127. $params = $this->request->getRawJson();
  128. if ( !$params ) {
  129. $this->sendOutput('参数错误', ErrorCode::$paramError );
  130. }
  131. $updateCustomerLibData = [
  132. 'id' => getArrayItem($params,'id'),
  133. 'taglib' => getArrayItem($params,'taglib',[]),
  134. ];
  135. foreach($updateCustomerLibData as $key => $value){
  136. if(empty($value) && $value !== 0){
  137. $this->sendOutput($key.'参数错误', ErrorCode::$paramError );
  138. }
  139. }
  140. $result = $this->objMCustomerTagLib->updateCustomerTagLibById($updateCustomerLibData);
  141. if($result->isSuccess()){
  142. parent::sendOutput($result->getData());
  143. }else{
  144. parent::sendOutput($result->getData(), $result->getErrorCode());
  145. }
  146. }
  147. }