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.

46 lines
1.6 KiB

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