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

  1. <?php
  2. namespace api\controllers;
  3. use yii\db\ActiveRecord;
  4. use yii\rest\ActiveController;
  5. use Yii;
  6. /**
  7. * @author iron
  8. * @email weiriron@gmail.com
  9. */
  10. class CartController extends CommonController
  11. {
  12. public $modelClass = 'common\models\ars\Cart';
  13. /**
  14. * @return bool
  15. * 更新购物车(增/删商品)
  16. */
  17. public function actionUpdate()
  18. {
  19. $type = Yii::$app->request->post('type');
  20. return Yii::$app->cartLogic->addOrSubGoods($type);
  21. }
  22. /**
  23. * @return ActiveRecord
  24. * 创建商品
  25. */
  26. public function actionCreate()
  27. {
  28. $goodsId = Yii::$app->request->getBodyParam('goodsId');
  29. $count = Yii::$app->request->getBodyParam('count');
  30. $skuId = Yii::$app->request->getBodyParam('skuId');
  31. return Yii::$app->cartLogic->addGoods($goodsId, $count, $skuId);
  32. }
  33. /**
  34. * 删除商品
  35. */
  36. public function actionDelete()
  37. {
  38. Yii::$app->cartLogic->delete();
  39. }
  40. }