CommissionController.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace addons\BusinessActivity\api\modules\v1\controllers;
  3. use addons\BusinessActivity\common\service\CommissionService;
  4. use api\controllers\OnAuthController;
  5. use Yii;
  6. class CommissionController extends OnAuthController
  7. {
  8. public $modelClass = '';
  9. /**
  10. * 不用进行登录验证的方法
  11. *
  12. * 例如: ['index', 'update', 'create', 'view', 'delete']
  13. * 默认全部需要验证
  14. *
  15. * @var array
  16. */
  17. protected $authOptional = [
  18. 'index'
  19. ];
  20. /**
  21. * 用户佣金列表
  22. * @return mixed|null
  23. */
  24. public function actionIndex()
  25. {
  26. $data = Yii::$app->request->get();
  27. if (!Yii::$app->services->validate->validate($data, [
  28. [['activity_id', 'page', 'limit'], 'integer'],
  29. [['start_date', 'end_date'], 'string']
  30. ])) {
  31. return $this->error(Yii::$app->services->validate->getErrorMessage());
  32. }
  33. if (empty($this->user_id)) return $this->success('请登录');
  34. $ret = (new CommissionService())->frontPage($this->mall_id, $this->user_id, $data);
  35. return is_string($ret) ? $this->error($ret) : $this->success('获取成功', $ret);
  36. }
  37. }