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.

59 lines
1.9 KiB

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\ShopCartServiceInterface;
  5. use App\Service\v3\Implementations\GoodsActivityService;
  6. use App\Service\v3\Interfaces\CollectStoreServiceInterface;
  7. use Hyperf\Di\Annotation\Inject;
  8. use App\Service\v3\Interfaces\GoodsServiceInterface;
  9. use App\Service\v3\Interfaces\GoodsActivityServiceInterface;
  10. use App\Constants\v3\Goods;
  11. class GoodsController extends BaseController
  12. {
  13. /**
  14. * @Inject
  15. * @var GoodsServiceInterface
  16. */
  17. protected $goodsService;
  18. /**
  19. * @Inject
  20. * @var GoodsActivityServiceInterface
  21. */
  22. protected $goodsActivityService;
  23. /**
  24. * @Inject
  25. * @var CollectStoreServiceInterface
  26. */
  27. protected $collectService;
  28. /**
  29. * @Inject
  30. * @var ShopCartServiceInterface
  31. */
  32. protected $shopCartService;
  33. public function detail()
  34. {
  35. $params = $this->request->all();
  36. //判断是普通商品还是特价商品
  37. if(isset($params['activity']) && $params['activity'] == Goods::IS_ACTIVITY){
  38. $res['detail'] = $this->goodsActivityService->detail($params['goods_id']);
  39. $res['banner'] = $this->goodsActivityService->getBanner(1572);
  40. }else{
  41. $res['detail'] = $this->goodsService->detail($params['goods_id']);
  42. $res['banner'] = $this->goodsService->getBanner(1572);
  43. }
  44. if(isset($params['user_id'])) {
  45. $res['shopcart']['count'] = $this->shopCartService->check(111);
  46. $res['shopcart']['total'] = $this->shopCartService->getTotal();
  47. $res['detail']->store->is_collected = (bool)$this->collectService->check($params['user_id'], $params['store_id']);
  48. }else{
  49. $res['shopcart'] = '';
  50. $res['detail']->store->is_collected = '';
  51. }
  52. return $this->success($res);
  53. }
  54. }