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.
 
 
 

47 lines
984 B

<?php
namespace api\controllers;
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';
/**
* @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->addGoods($goodsId, $count, $skuId);
}
/**
* 删除商品
*/
public function actionDelete()
{
Yii::$app->cartLogic->delete();
}
}