You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.3 KiB

  1. <?php
  2. namespace api\controllers;
  3. use yii\web\ForbiddenHttpException;
  4. use Yii;
  5. /**
  6. * @author iron
  7. * @email weiriron@gmail.com
  8. */
  9. class OrderController extends CommonController
  10. {
  11. public $modelClass = 'common\models\ars\Order';
  12. protected function getFilter()
  13. {
  14. $status = Yii::$app->request->getBodyParam('status');
  15. $data = \Yii::$app->request->getBodyParams();
  16. $data['user'] = true;
  17. \Yii::$app->request->setBodyParams($data);
  18. $array = ['user_id' => Yii::$app->user->getId()];
  19. if ($status) {
  20. $array['status'] = $status;
  21. }
  22. $filter = ['class' => 'yii\data\ActiveDataFilter',
  23. 'filter' => $array,
  24. 'searchModel' => ['class' => 'common\models\searchs\OrderSearch']];
  25. return $filter;
  26. }
  27. public function actionCreate()
  28. {
  29. $originId = Yii::$app->request->getBodyParam('originId');
  30. $count = Yii::$app->request->getBodyParam('count');
  31. $skuId = Yii::$app->request->getBodyParam('skuId');
  32. return Yii::$app->orderLogic->addGoods($originId, $count, $skuId);
  33. }
  34. /**
  35. * @return mixed
  36. * @throws \yii\base\InvalidConfigException
  37. */
  38. public function actionUpdate()
  39. {
  40. $data = Yii::$app->request->getBodyParams();
  41. return Yii::$app->orderLogic->update($data);
  42. }
  43. }