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.

36 lines
1.2 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. <?php
  2. namespace App\Controller\v3;
  3. use App\Controller\BaseController;
  4. use Hyperf\Di\Annotation\Inject;
  5. use App\Service\v3\Interfaces\ShopCartServiceInterface;
  6. class ShopCartController extends BaseController
  7. {
  8. /**
  9. * @Inject
  10. * @var ShopCartServiceInterface
  11. */
  12. protected $shopCartService;
  13. public function detail()
  14. {
  15. $userId = $this->request->input('user_id');
  16. $marketId = $this->request->input('market_id');
  17. //获取购物车商品信息
  18. $res['store_lists'] = $this->shopCartService->do($userId,$marketId);
  19. //获取购物车失效商品信息
  20. $res['store_lists_invalid'] = $this->shopCartService->undo();
  21. //计算购物车价格
  22. $res['total'] = $this->shopCartService->getTotal($userId,$marketId);
  23. return $this->success($res);
  24. }
  25. public function info()
  26. {
  27. $userId = $this->request->input('user_id');
  28. $marketId = $this->request->input('market_id');
  29. $res['shopcart']['count'] = $this->shopCartService->countGoods();
  30. $res['shopcart']['total'] = $this->shopCartService->getTotal($userId,$marketId);
  31. return $this->success($res);
  32. }
  33. }