| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- <?php
- namespace backend\controllers;
- use common\services\xhGoodsService;
- use common\services\xhCartService;
- use common\services\xhUserService;
- use common\components\util;
- use Yii;
- use yii\web\Controller;
- class CartController extends BackendController
- {
- /**
- * 查看用户的购物车
- */
- public function actionUser()
- {
- $get = Yii::$app->request->get();
- $userId = isset($get['userId']) ? $get['userId'] : 0;
- $user = xhUserService::getById($userId);
- if($user['merchantId'] != $this->merchantId){
- util::stop('非法访问');
- }
- $cart = xhCartService::getUserCartList($userId);
- return $this->render('user', ['cart' => $cart,'user' => $user]);
- }
- /**
- * 购物车的里每个商品明细
- */
- public function actionDetail()
- {
- $get = Yii::$app->request->get();
- $userId = isset($get['userId']) ? $get['userId'] : 0;
- $goodsId = isset($get['goodsId']) ? $get['goodsId'] : 0;
- $user = xhUserService::getById($userId);
- if($user['merchantId'] != $this->merchantId){
- util::stop('非法访问');
- }
- $cart = xhCartService::getByIds($goodsId, $userId);
- $goods = xhGoodsService::getById($goodsId);
- return $this->render('detail',['cart' => $cart,'goods' => $goods]);
- }
- }
|