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.

39 lines
1.3 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. return $this->success($this->shopCartService->allForUser($userId, $marketId));
  18. // //获取购物车商品信息
  19. // $res['store_lists'] = $this->shopCartService->do($userId,$marketId);
  20. // //获取购物车失效商品信息
  21. // $res['store_lists_invalid'] = $this->shopCartService->undo($userId,$marketId);
  22. // //计算购物车价格
  23. // $res['total'] = $this->shopCartService->getTotal($userId,$marketId);
  24. // return $this->success($res);
  25. }
  26. public function info()
  27. {
  28. $userId = $this->request->input('user_id');
  29. $marketId = $this->request->input('market_id');
  30. $res['shopcart']['count'] = $this->shopCartService->countGoods($userId,$marketId);
  31. $res['shopcart']['total'] = $this->shopCartService->getTotal($userId,$marketId);
  32. return $this->success($res);
  33. }
  34. }