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