Guide.Class.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <?php
  2. namespace JInDouYun\Controller\Cashier;
  3. use JinDouYun\Controller\BaseController;
  4. use JinDouYun\Model\Cashier\MCashierGuide;
  5. use Mall\Framework\Core\ErrorCode;
  6. use Mall\Framework\Core\StatusCode;
  7. /**
  8. * Description: 导购员 废弃
  9. * Class Guide
  10. * @package JInDouYun\Controller\Cashier
  11. */
  12. class Guide extends BaseController
  13. {
  14. /**
  15. * @var MCashierGuide
  16. */
  17. private $objMCashierGuide;
  18. /**
  19. * Guide constructor.
  20. * @param bool $isCheckAcl
  21. * @param bool $isMustLogin
  22. * @param bool $checkToken
  23. * @param bool $getAreaCode
  24. * @throws \Exception
  25. */
  26. public function __construct($isCheckAcl = true, $isMustLogin = true, $checkToken = true, $getAreaCode = false)
  27. {
  28. parent::__construct($isCheckAcl, $isMustLogin, $checkToken, $getAreaCode);
  29. $this->objMCashierGuide = new MCashierGuide($this->onlineUserId, $this->onlineEnterpriseId);
  30. }
  31. /**
  32. * Doc: (des="导购员列表")
  33. * User: XMing
  34. * Date: 2020/8/31
  35. * Time: 3:46 下午
  36. */
  37. public function getAll()
  38. {
  39. $params = $this->request->getRawJson();
  40. if (empty($params)) {
  41. parent::sendOutput('参数为空', ErrorCode::$paramError);
  42. }
  43. $pageParams = pageToOffset($params['page'] ?: 1, $params['pageSize'] ?: 10);
  44. $params['limit'] = $pageParams['limit'];
  45. $params['offset'] = $pageParams['offset'];
  46. $result = $this->objMCashierGuide->getAll($params);
  47. if (!$result->isSuccess()) {
  48. parent::sendOutput($result->getData(), $result->getErrorCode());
  49. }
  50. $returnData = $result->getData();
  51. $pageData = [
  52. 'pageIndex' => $params['page'],
  53. 'pageSize' => $params['pageSize'],
  54. 'pageTotal' => $returnData['total'],
  55. ];
  56. parent::sendOutput($returnData['data'], 0, $pageData);
  57. }
  58. /**
  59. * Doc: (des="导购员添加")
  60. * User: XMing
  61. * Date: 2020/8/31
  62. * Time: 4:23 下午
  63. */
  64. public function add()
  65. {
  66. $params = $this->request->getRawJson();
  67. if (empty($params)){
  68. parent::sendOutput('参数为空',ErrorCode::$paramError);
  69. }
  70. $data = [
  71. 'name' => isset($params['name']) ? $params['name'] : null,
  72. 'mobile' => isset($params['mobile']) ? $params['mobile'] : null,
  73. 'isSetRule' => isset($params['isSetRule']) ? $params['isSetRule'] : null,
  74. 'enableStatus' => isset($params['enableStatus']) ? $params['enableStatus'] : null,
  75. ];
  76. foreach ($data as $key => $value){
  77. if(empty($value)){
  78. parent::sendOutput($key.'参数错误', ErrorCode::$paramError);
  79. }
  80. }
  81. if($data['isSetRule'] == StatusCode::$standard){
  82. if (!isset($params['rule']) || empty($params['rule'])){
  83. parent::sendOutput('rule参数错误',ErrorCode::$paramError);
  84. }
  85. $data['rule'] = json_encode($params['rule']);
  86. }
  87. $result = $this->objMCashierGuide->add($data);
  88. if (!$result->isSuccess()){
  89. parent::sendOutput($result->getData(),$result->getErrorCode());
  90. }
  91. parent::sendOutput($result->getData());
  92. }
  93. /**
  94. * Doc: (des="")
  95. * User: XMing
  96. * Date: 2020/9/1
  97. * Time: 9:30 上午
  98. */
  99. public function getInfo()
  100. {
  101. $id = $this->request->param('request_id');
  102. if (empty($id)){
  103. parent::sendOutput('id参数错误',ErrorCode::$paramError);
  104. }
  105. $result = $this->objMCashierGuide->getInfo($id);
  106. if (!$result->isSuccess()){
  107. parent::sendOutput($result->getData(),$result->getErrorCode());
  108. }
  109. parent::sendOutput($result->getData());
  110. }
  111. }