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.
|
|
<?php
namespace api\controllers;
use backend\models\ars\Cart; use yii\db\ActiveRecord; use yii\rest\ActiveController; use Yii;
/** * @author iron * @email weiriron@gmail.com */ class CartController extends CommonController { public $modelClass = 'common\models\ars\Cart';
public function actions() { $action = parent::actions(); unset($action['index']); return $action; }
public function actionIndex() { return Cart::find() ->where(['user_id' => Yii::$app->user->getId()]) ->all(); }
/** * @return bool * 更新购物车(增/删商品) */ public function actionUpdate() { $type = Yii::$app->request->post('type'); return Yii::$app->cartLogic->addOrSubGoods($type); }
/** * @return ActiveRecord * 创建商品 */ public function actionCreate() { $goodsId = Yii::$app->request->getBodyParam('goodsId'); $count = Yii::$app->request->getBodyParam('count'); $skuId = Yii::$app->request->getBodyParam('skuId'); return Yii::$app->cartLogic->create($goodsId, $count, $skuId); }
}
|