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.
79 lines
1.9 KiB
79 lines
1.9 KiB
<?php
|
|
|
|
namespace api\controllers;
|
|
|
|
use Yii;
|
|
use yii\base\InvalidConfigException;
|
|
use Throwable;
|
|
use backend\modules\shop\models\ars\Order;
|
|
/**
|
|
* @author iron
|
|
* @email weiriron@gmail.com
|
|
*/
|
|
class OrderController extends CommonController
|
|
{
|
|
public $modelClass = 'backend\modules\shop\models\ars\Order';
|
|
public $className = 'api\logic\OrderLogic';
|
|
|
|
/**
|
|
* @return array
|
|
* @throws InvalidConfigException
|
|
*/
|
|
public function actions()
|
|
{
|
|
$action = parent::actions();
|
|
unset($action['delete']);
|
|
$action['index'] = [
|
|
'class' => 'yii\rest\IndexAction',
|
|
'modelClass' => $this->modelClass,
|
|
'dataFilter' => $this->getFilter()
|
|
];
|
|
return $action;
|
|
}
|
|
|
|
/**
|
|
* @return array
|
|
* @throws InvalidConfigException
|
|
*/
|
|
protected function getFilter()
|
|
{
|
|
if (empty(Yii::$app->request->getBodyParams())) {
|
|
Yii::$app->request->setBodyParams(['user' => true]);
|
|
}
|
|
$array = ['user_id' => Yii::$app->user->getId()];
|
|
$status = Yii::$app->request->getBodyParam('status');
|
|
if ($status) {
|
|
$array['status'] = $status;
|
|
}
|
|
return ['class' => 'yii\data\ActiveDataFilter',
|
|
'filter' => $array,
|
|
'searchModel' => ['class' => 'backend\modules\shop\models\searchs\OrderSearch']
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @return Order
|
|
* @throws yii\base\Exception
|
|
* @throws yii\web\BadRequestHttpException
|
|
*/
|
|
public function actionCreate()
|
|
{
|
|
return $this->object->create();
|
|
}
|
|
|
|
/**
|
|
* @return bool
|
|
* @throws InvalidConfigException
|
|
* @throws Throwable
|
|
* @throws yii\base\Exception
|
|
* @throws yii\web\BadRequestHttpException
|
|
* @throws yii\web\NotFoundHttpException
|
|
* @throws yii\web\ServerErrorHttpException
|
|
*/
|
|
public function actionUpdate()
|
|
{
|
|
return $this->object->update();
|
|
}
|
|
|
|
|
|
}
|