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.

49 lines
1.5 KiB

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