CommissionGrade.Class.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <?php
  2. /**
  3. * 分销商等级Controller
  4. * Created by PhpStorm.
  5. * User: haoren
  6. * Date: 2020/07/22
  7. * Time: 15:00
  8. */
  9. namespace JinDouYun\Controller\Commission;
  10. use Exception;
  11. use Mall\Framework\Core\ErrorCode;
  12. use Mall\Framework\Core\ResultWrapper;
  13. use Mall\Framework\Core\StatusCode;
  14. use JinDouYun\Controller\BaseController;
  15. use JinDouYun\Model\Commission\MCommissionGrade;
  16. class CommissionGrade extends BaseController
  17. {
  18. private $objMCommissionGrade;
  19. public function __construct($isCheckAcl = true, $isMustLogin = true)
  20. {
  21. parent::__construct($isCheckAcl, $isMustLogin);
  22. $this->objMCommissionGrade = new MCommissionGrade($this->onlineEnterpriseId, $this->onlineUserId);
  23. }
  24. /**
  25. * 获取参数
  26. */
  27. public function commonFieldFilter()
  28. {
  29. $params = $this->request->getRawJson();
  30. if (empty($params)) {
  31. parent::sendOutput('参数为空', ErrorCode::$paramError);
  32. }
  33. $data = [
  34. 'name' => isset($params['name']) ? $params['name'] : '',
  35. 'grade' => isset($params['grade']) ? $params['grade'] : '',
  36. 'oneRate' => isset($params['oneRate']) ? $params['oneRate'] : '',
  37. 'twoRate' => isset($params['twoRate']) ? $params['twoRate'] : '',
  38. 'threeRate' => isset($params['threeRate']) ? $params['threeRate'] : '',
  39. 'upgradeMode' => isset($params['upgradeMode']) ? $params['upgradeMode'] : '',
  40. 'upgradeCondition' => isset($params['upgradeCondition']) ? $params['upgradeCondition'] : '',
  41. ];
  42. foreach($data as $key => $value){
  43. if(empty($value) && $value != 0){
  44. parent::sendOutput($key.'参数错误', ErrorCode::$paramError);
  45. }
  46. }
  47. return $data;
  48. }
  49. /**
  50. * 新增等级
  51. */
  52. public function addGrade()
  53. {
  54. $data = self::commonFieldFilter();
  55. $modelResult = $this->objMCommissionGrade->addGrade($data);
  56. if(!$modelResult->isSuccess()){
  57. parent::sendOutput($modelResult->getData(), $modelResult->getErrorCode());
  58. }
  59. parent::sendOutput($modelResult->getData());
  60. }
  61. /**
  62. * 删除等级
  63. */
  64. public function delGrade()
  65. {
  66. $id = $this->request->param('request_id');
  67. if(empty($id)){
  68. parent::sendOutput('参数为空', ErrorCode::$paramError);
  69. }
  70. $update = [
  71. 'deleteStatus' => StatusCode::$delete
  72. ];
  73. $where = [
  74. 'id' => $id
  75. ];
  76. $modelResult = $this->objMCommissionGrade->updateGrade($update, $where);
  77. if(!$modelResult->isSuccess()){
  78. parent::sendOutput($modelResult->getData(), $modelResult->getErrorCode());
  79. }
  80. parent::sendOutput($modelResult->getData());
  81. }
  82. /**
  83. * 修改等级
  84. */
  85. public function updateGrade()
  86. {
  87. $id = $this->request->param('request_id');
  88. if(empty($id)){
  89. parent::sendOutput('参数为空', ErrorCode::$paramError);
  90. }
  91. $data = self::commonFieldFilter();
  92. $modelResult = $this->objMCommissionGrade->updateGrade($data, ['id' => $id]);
  93. if(!$modelResult->isSuccess()){
  94. parent::sendOutput($modelResult->getData(), $modelResult->getErrorCode());
  95. }
  96. parent::sendOutput($modelResult->getData());
  97. }
  98. /**
  99. * 等级列表
  100. */
  101. public function getAllGrade()
  102. {
  103. $modelResult = $this->objMCommissionGrade->getAllGrade();
  104. if(!$modelResult->isSuccess()){
  105. parent::sendOutput($modelResult->getData(), $modelResult->getErrorCode());
  106. }
  107. parent::sendOutput($modelResult->getData());
  108. }
  109. /**
  110. * 等级详情
  111. */
  112. public function getInfoGrade()
  113. {
  114. $id = $this->request->param('request_id');
  115. if(empty($id)){
  116. parent::sendOutput('参数为空', ErrorCode::$paramError);
  117. }
  118. $where = [
  119. 'id' => $id
  120. ];
  121. $modelResult = $this->objMCommissionGrade->getInfoGrade($where);
  122. if(!$modelResult->isSuccess()){
  123. parent::sendOutput($modelResult->getData(), $modelResult->getErrorCode());
  124. }
  125. parent::sendOutput($modelResult->getData());
  126. }
  127. /**
  128. * 升级条件
  129. */
  130. public function getAllGradeCondition()
  131. {
  132. $modelResult = $this->objMCommissionGrade->getAllGradeCondition(['type' => StatusCode::$delete]);
  133. if(!$modelResult->isSuccess()){
  134. parent::sendOutput($modelResult->getData(), $modelResult->getErrorCode());
  135. }
  136. parent::sendOutput($modelResult->getData());
  137. }
  138. }