OperationController.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. namespace addons\OperationCenter\api\modules\v1\controllers;
  3. use addons\OperationCenter\api\services\CenterService;
  4. use api\controllers\OnAuthController;
  5. /**
  6. * 运营中心控制器
  7. *
  8. * OperationController class
  9. * @package addons\OperationCenter\api\modules\v1\controllers
  10. */
  11. class OperationController extends OnAuthController
  12. {
  13. /**
  14. * @var string
  15. */
  16. public $modelClass = '';
  17. /**
  18. * @var boolean
  19. */
  20. public $enableCsrfValidation = false;
  21. /**
  22. * 微店(运营中心)列表
  23. *
  24. * @return string
  25. */
  26. public function actionList()
  27. {
  28. $params = $this->request->get();
  29. $service = new CenterService(['mall_id' => $this->mall_id]);
  30. return $this->success('ok', $service->getPageListOrderByDistance($this->user_id, $params));
  31. }
  32. /**
  33. * 选择运营中心
  34. *
  35. * @return string
  36. */
  37. public function actionSelectOperation()
  38. {
  39. $id = $this->request->get('id', 0);
  40. if (empty($id)) return $this->error('ID不能为空');
  41. $service = new CenterService(['mall_id' => $this->mall_id]);
  42. return $service->selectOperation($this->user_id, $id)
  43. ? $this->success('ok')
  44. : $this->error($service->getError());
  45. }
  46. /**
  47. * 当前运营中心
  48. *
  49. * @return string
  50. */
  51. public function actionCurrent()
  52. {
  53. $service = new CenterService(['mall_id' => $this->mall_id]);
  54. return $this->success(
  55. 'ok',
  56. $service->currentOperation($this->user_id)
  57. );
  58. }
  59. }