app/Customize/Controller/ProductController.php line 45

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of EC-CUBE
  4.  *
  5.  * Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
  6.  *
  7.  * http://www.ec-cube.co.jp/
  8.  *
  9.  * For the full copyright and license information, please view the LICENSE
  10.  * file that was distributed with this source code.
  11.  */
  12. namespace Customize\Controller;
  13. use Customize\Event\EccubeEvents;
  14. use Customize\Repository\BitHistoryRepository;
  15. use Customize\Repository\PreviewTenderRepository;
  16. use Customize\Repository\ProductRepository;
  17. use Customize\Repository\ProductAccessRepository;
  18. use Customize\Repository\ProductMemoRepository;
  19. use Customize\Repository\OrderRepository;
  20. use Eccube\Controller\AbstractController;
  21. //use Eccube\Entity\BaseInfo;
  22. use Eccube\Entity\Master\ProductStatus;
  23. use Eccube\Entity\Product;
  24. use Eccube\Event\EventArgs;
  25. //use Eccube\Form\Type\AddCartType;
  26. //use Eccube\Form\Type\SearchProductType;
  27. //use Eccube\Repository\BaseInfoRepository;
  28. use Eccube\Repository\CustomerFavoriteProductRepository;
  29. use Eccube\Repository\Master\ProductListMaxRepository;
  30. //use Eccube\Service\CartService;
  31. //use Eccube\Service\PurchaseFlow\PurchaseContext;
  32. //use Eccube\Service\PurchaseFlow\PurchaseFlow;
  33. //use Knp\Bundle\PaginatorBundle\Pagination\SlidingPagination;
  34. //use Knp\Component\Pager\PaginatorInterface;
  35. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
  36. use Symfony\Component\HttpFoundation\Request;
  37. use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
  38. use Symfony\Component\Routing\Annotation\Route;
  39. use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
  40. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  41. class ProductController extends AbstractController
  42. {
  43.     /**
  44.      * @var BitHistoryRepository
  45.      */
  46.     protected $bitHistoryRepository;
  47.     /**
  48.      * @var CustomerFavoriteProductRepository
  49.      */
  50.     protected $customerFavoriteProductRepository;
  51.     /**
  52.      * @var PreviewTenderRepository
  53.      */
  54.     protected $previewTenderRepository;
  55.     /**
  56.      * @var ProductRepository
  57.      */
  58.     protected $productRepository;
  59.     /**
  60.      * @var ProductAccessRepository
  61.      */
  62.     protected $productAccessRepository;
  63.     /**
  64.      * @var ProductMemoRepository
  65.      */
  66.     protected $productMemoRepository;
  67.     /**
  68.      * @var AuthenticationUtils
  69.      */
  70.     protected $helper;
  71.     /**
  72.      * @var ProductListMaxRepository
  73.      */
  74.     protected $productListMaxRepository;
  75.     /**
  76.      * @var OrderRepository
  77.      */
  78.     protected $orderRepository;
  79.     private $title '';
  80.     /**
  81.      * ProductController constructor.
  82.      *
  83.      * @param  ProductAccessRepository  $ProductAccessRepository
  84.      */
  85.     public function __construct(
  86.         CustomerFavoriteProductRepository $customerFavoriteProductRepository,
  87.         PreviewTenderRepository $previewTenderRepository,
  88.         ProductRepository $productRepository,
  89.         ProductAccessRepository $productAccessRepository,
  90.         ProductMemoRepository $productMemoRepository,
  91.         AuthenticationUtils $helper,
  92.         ProductListMaxRepository $productListMaxRepository,
  93.         BitHistoryRepository $bitHistoryRepository,
  94.         OrderRepository $orderRepository,
  95.     ) {
  96.         $this->customerFavoriteProductRepository $customerFavoriteProductRepository;
  97.         $this->previewTenderRepository $previewTenderRepository;
  98.         $this->productRepository $productRepository;
  99.         $this->productAccessRepository $productAccessRepository;
  100.         $this->productMemoRepository $productMemoRepository;
  101.         $this->helper $helper;
  102.         $this->productListMaxRepository $productListMaxRepository;
  103.         $this->bitHistoryRepository $bitHistoryRepository;
  104.         $this->orderRepository $orderRepository;
  105.     }
  106.     /**
  107.      * 商品一覧画面.
  108.      *
  109.      * @Route("/products/list", name="product_list", methods={"GET"})
  110.      *
  111.      * @Template("Product/list.twig")
  112.      */
  113.     /* public function index(Request $request, PaginatorInterface $paginator)
  114.     {
  115.         if ($this->BaseInfo->isOptionNostockHidden()) {
  116.             $this->entityManager->getFilters()->enable('option_nostock_hidden');
  117.         }
  118.         if ($request->getMethod() === 'GET') {
  119.             $request->query->set('pageno', $request->query->get('pageno', ''));
  120.         }
  121.         $builder = $this->formFactory->createNamedBuilder('', SearchProductType::class);
  122.         if ($request->getMethod() === 'GET') {
  123.             $builder->setMethod('GET');
  124.         }
  125.         $event = new EventArgs(
  126.             [
  127.                 'builder' => $builder,
  128.             ],
  129.             $request
  130.         );
  131.         $this->eventDispatcher->dispatch($event, EccubeEvents::FRONT_PRODUCT_INDEX_INITIALIZE);
  132.         $searchForm = $builder->getForm();
  133.         $searchForm->handleRequest($request);
  134.         $searchData = $searchForm->getData();
  135.         $qb = $this->productRepository->getQueryBuilderBySearchData($searchData);
  136.         $event = new EventArgs(
  137.             [
  138.                 'searchData' => $searchData,
  139.                 'qb' => $qb,
  140.             ],
  141.             $request
  142.         );
  143.         $this->eventDispatcher->dispatch($event, EccubeEvents::FRONT_PRODUCT_INDEX_SEARCH);
  144.         $searchData = $event->getArgument('searchData');
  145.         $query = $qb->getQuery()
  146.             ->useResultCache(true, $this->eccubeConfig['eccube_result_cache_lifetime_short']);
  147.         $pagination = $paginator->paginate(
  148.             $query,
  149.             !empty($searchData['pageno']) ? $searchData['pageno'] : 1,
  150.             !empty($searchData['disp_number']) ? $searchData['disp_number']->getId() : $this->productListMaxRepository->findOneBy([], ['sort_no' => 'ASC'])->getId()
  151.         );
  152.         $ids = [];
  153.         foreach ($pagination as $Product) {
  154.             $ids[] = $Product->getId();
  155.         }
  156.         $ProductsAndClassCategories = $this->productRepository->findProductsWithSortedClassCategories($ids, 'p.id');
  157.         $forms = [];
  158.         foreach ($pagination as $Product) {
  159.             $builder = $this->formFactory->createNamedBuilder(
  160.                 '',
  161.                 AddCartType::class,
  162.                 null,
  163.                 [
  164.                     'product' => $ProductsAndClassCategories[$Product->getId()],
  165.                     'allow_extra_fields' => true,
  166.                 ]
  167.             );
  168.             $addCartForm = $builder->getForm();
  169.             $forms[$Product->getId()] = $addCartForm->createView();
  170.         }
  171.         $Category = $searchForm->get('category_id')->getData();
  172.         return [
  173.             'subtitle' => $this->getPageTitle($searchData),
  174.             'pagination' => $pagination,
  175.             'search_form' => $searchForm->createView(),
  176.             'forms' => $forms,
  177.             'Category' => $Category,
  178.         ];
  179.     } */
  180.     /**
  181.      * 商品詳細画面.
  182.      *
  183.      * @Route("/products/detail/{id}", name="product_detail", methods={"GET"}, requirements={"id" = "\d+"})
  184.      *
  185.      * @Template("Product/detail.twig")
  186.      *
  187.      * @return array
  188.      */
  189.     public function detail(Request $requestProduct $Product)
  190.     {
  191.         if ($this->isGranted('ROLE_USER')) {
  192.             if (!$this->checkVisibility($Product)) {
  193.                 throw new NotFoundHttpException();
  194.             }
  195.             /* $builder = $this->formFactory->createNamedBuilder(
  196.                 '',
  197.                 AddCartType::class,
  198.                 null,
  199.                 [
  200.                     'product' => $Product,
  201.                     'id_add_product_id' => false,
  202.                 ]
  203.             ); */
  204.             $event = new EventArgs(
  205.                 [
  206.                     //'builder' => $builder,
  207.                     'Product' => $Product,
  208.                 ],
  209.                 $request
  210.             );
  211.             $this->eventDispatcher->dispatch($eventEccubeEvents::FRONT_PRODUCT_DETAIL_INITIALIZE);
  212.             $Auction $Product->getAuction();
  213.             $Customer $this->getUser();
  214.             if ($Auction->isBefore() && !$Customer->getIsAdmin()) {
  215.                 throw new NotFoundHttpException();
  216.             }
  217.             
  218.             // 下見期間かどうか
  219.             $is_preview $Auction->isPreview();
  220.             
  221.             // 競り後かどうか
  222.             $is_closed $Auction->isClosed();
  223.             // 入札社数
  224.             if ($is_closed) {
  225.                 $biddingCompaniesCount $this->bitHistoryRepository->countBiddingCompanies($Product->getId());
  226.             } else {
  227.                 $biddingCompaniesCount $this->productRepository->countBiddingCompanies($Product->getId());
  228.             }
  229.             $is_favorite $this->customerFavoriteProductRepository->isFavorite($Customer$Product);
  230.             $this->productAccessRepository->addAccess($Product$Customer);
  231.             $prevProduct $this->productRepository->findPrevProduct($Auction->getId(), $Product->getAuctionNo());
  232.             $nextProduct $this->productRepository->findNextProduct($Auction->getId(), $Product->getAuctionNo());
  233.             $isUnpaid = !empty($this->orderRepository->getNotPaidOrder($Customer)) ? true false;
  234.             $randomBytes random_bytes(32);
  235.             $token hash('sha256'$randomBytes);
  236.             $hashedToken hash('sha256'$token);
  237.             $Customer->setToken($hashedToken);
  238.             $this->entityManager->persist($Customer);
  239.             $this->entityManager->flush();
  240.             return [
  241.                 'title' => $this->title,
  242.                 'subtitle' => $Product->getName(),
  243.                 //'form' => $builder->getForm()->createView(),
  244.                 'Product' => $Product,
  245.                 'Customer' => $Customer,
  246.                 'biddingCompaniesCount' => $biddingCompaniesCount,
  247.                 'is_preview' => $is_preview,
  248.                 'is_closed' => $is_closed,
  249.                 'is_favorite' => $is_favorite,
  250.                 'prevProduct' => $prevProduct,
  251.                 'nextProduct' => $nextProduct,
  252.                 'auctionId' => $Auction->getId(),
  253.                 'isUnpaid' => $isUnpaid,
  254.                 'token' => $token,
  255.                 'maxAutoBidLimit' => $this->previewTenderRepository->findMaxAutoBidLimitByProductId($Product->getId(), $Customer->getId()) ?? 0,
  256.             ];
  257.         } else {
  258.             // 非会員の場合、ログイン画面を表示
  259.             //  ログイン後の画面遷移先を設定
  260.             $this->setLoginTargetPath($this->generateUrl('product_detail', ['id' => $Product->getId()], UrlGeneratorInterface::ABSOLUTE_URL));
  261.             return $this->redirectToRoute('mypage_login');
  262.         }
  263.     }
  264.     /**
  265.      * 商品詳細(共有)画面.
  266.      *
  267.      * @Route("/products/sharing_detail/{id}", name="sharing_product_detail", methods={"GET"}, requirements={"id" = "\d+"})
  268.      *
  269.      * @Template("Product/sharing_detail.twig")
  270.      *
  271.      * @return array
  272.      */
  273.     public function sharingDetail(Request $requestProduct $Product)
  274.     {
  275.         if ($this->isGranted('ROLE_USER')) {
  276.             if (!$this->checkVisibility($Product)) {
  277.                 throw new NotFoundHttpException();
  278.             }
  279.             $event = new EventArgs(
  280.                 [
  281.                     'Product' => $Product,
  282.                 ],
  283.                 $request
  284.             );
  285.             $this->eventDispatcher->dispatch($eventEccubeEvents::FRONT_PRODUCT_DETAIL_INITIALIZE);
  286.             $Auction $Product->getAuction();
  287.             $Customer $this->getUser();
  288.             if ($Auction->isBefore() && !$Customer->getIsAdmin()) {
  289.                 throw new NotFoundHttpException();
  290.             }
  291.             
  292.             // 下見期間かどうか
  293.             $is_preview $Auction->isPreview();
  294.             
  295.             // 競り後かどうか
  296.             $is_closed $Auction->isClosed();
  297.             // 入札社数
  298.             if ($is_closed) {
  299.                 $biddingCompaniesCount $this->bitHistoryRepository->countBiddingCompanies($Product->getId());
  300.             } else {
  301.                 $biddingCompaniesCount $this->productRepository->countBiddingCompanies($Product->getId());
  302.             }
  303.             $is_favorite $this->customerFavoriteProductRepository->isFavorite($Customer$Product);
  304.             $this->productAccessRepository->addAccess($Product$Customer);
  305.             $prevProduct $this->productRepository->findPrevProduct($Auction->getId(), $Product->getAuctionNo());
  306.             $nextProduct $this->productRepository->findNextProduct($Auction->getId(), $Product->getAuctionNo());
  307.             $isUnpaid = !empty($this->orderRepository->getNotPaidOrder($Customer)) ? true false;
  308.             $randomBytes random_bytes(32);
  309.             $token hash('sha256'$randomBytes);
  310.             $hashedToken hash('sha256'$token);
  311.             $Customer->setToken($hashedToken);
  312.             $this->entityManager->persist($Customer);
  313.             $this->entityManager->flush();
  314.             return [
  315.                 'title' => $this->title,
  316.                 'subtitle' => $Product->getName(),
  317.                 'Product' => $Product,
  318.                 'Customer' => $Customer,
  319.                 'biddingCompaniesCount' => $biddingCompaniesCount,
  320.                 'is_preview' => $is_preview,
  321.                 'is_closed' => $is_closed,
  322.                 'is_favorite' => $is_favorite,
  323.                 'prevProduct' => $prevProduct,
  324.                 'nextProduct' => $nextProduct,
  325.                 'auctionId' => $Auction->getId(),
  326.                 'isUnpaid' => $isUnpaid,
  327.                 'token' => $token,
  328.             ];
  329.         } else {
  330.             // 非会員の場合、ログイン画面を表示
  331.             return $this->redirectToRoute('mypage_login');
  332.         }
  333.     }
  334.     /**
  335.      * お気に入り追加.
  336.      *
  337.      * @Route("/products/add_favorite/{id}", name="product_add_favorite", requirements={"id" = "\d+"}, methods={"GET", "POST"})
  338.      */
  339.     public function addFavorite(Request $requestProduct $Product)
  340.     {
  341.         $this->checkVisibility($Product);
  342.         $event = new EventArgs(
  343.             [
  344.                 'Product' => $Product,
  345.             ],
  346.             $request
  347.         );
  348.         $this->eventDispatcher->dispatch($eventEccubeEvents::FRONT_PRODUCT_FAVORITE_ADD_INITIALIZE);
  349.         if ($this->isGranted('ROLE_USER')) {
  350.             $Customer $this->getUser();
  351.             $this->customerFavoriteProductRepository->addFavorite($Customer$Product);
  352.             $this->session->getFlashBag()->set('product_detail.just_added_favorite'$Product->getId());
  353.             $event = new EventArgs(
  354.                 [
  355.                     'Product' => $Product,
  356.                 ],
  357.                 $request
  358.             );
  359.             $this->eventDispatcher->dispatch($eventEccubeEvents::FRONT_PRODUCT_FAVORITE_ADD_COMPLETE);
  360.             return $this->redirect($_SERVER['HTTP_REFERER']);
  361.         } else {
  362.             // 非会員の場合、ログイン画面を表示
  363.             //  ログイン後の画面遷移先を設定
  364.             $this->setLoginTargetPath($this->generateUrl('product_add_favorite', ['id' => $Product->getId()], UrlGeneratorInterface::ABSOLUTE_URL));
  365.             $this->session->getFlashBag()->set('eccube.add.favorite'true);
  366.             $event = new EventArgs(
  367.                 [
  368.                     'Product' => $Product,
  369.                 ],
  370.                 $request
  371.             );
  372.             $this->eventDispatcher->dispatch($eventEccubeEvents::FRONT_PRODUCT_FAVORITE_ADD_COMPLETE);
  373.             return $this->redirectToRoute('mypage_login');
  374.         }
  375.     }
  376.     /**
  377.      * お気に入り削除.
  378.      *
  379.      * @Route("/products/remove_favorite/{id}", name="product_remove_favorite", requirements={"id" = "\d+"}, methods={"GET", "POST"})
  380.      */
  381.     public function removeFavorite(Request $requestProduct $Product)
  382.     {
  383.         if ($this->isGranted('ROLE_USER')) {
  384.             $Customer $this->getUser();
  385.             $CustomerFavoriteProduct $this->customerFavoriteProductRepository->findOneBy(['Customer' => $Customer'Product' => $Product]);
  386.             if ($CustomerFavoriteProduct) {
  387.                 $this->customerFavoriteProductRepository->delete($CustomerFavoriteProduct);
  388.             } else {
  389.                 throw new BadRequestHttpException();
  390.             }
  391.             $event = new EventArgs(
  392.                 [
  393.                     'Customer' => $Customer,
  394.                     'CustomerFavoriteProduct' => $CustomerFavoriteProduct,
  395.                 ],
  396.                 $request
  397.             );
  398.             $this->eventDispatcher->dispatch($eventEccubeEvents::FRONT_PRODUCT_FAVORITE_REMOVE_COMPLETE);
  399.             return $this->redirect($_SERVER['HTTP_REFERER']);
  400.         } else {
  401.             // 非会員の場合、ログイン画面を表示
  402.             return $this->redirectToRoute('mypage_login');
  403.         }
  404.     }
  405.     /**
  406.      * 商品一覧からのお気に入り操作.
  407.      *
  408.      * @Route("/products/favorite_from_list/{id}", name="product_favorite_from_list", requirements={"id" = "\d+"}, methods={"GET", "POST"})
  409.      */
  410.     public function favoriteFromList(Request $requestProduct $Product)
  411.     {
  412.         $this->checkVisibility($Product);
  413.         $event = new EventArgs(
  414.             [
  415.                 'Product' => $Product,
  416.             ],
  417.             $request
  418.         );
  419.         $this->eventDispatcher->dispatch($eventEccubeEvents::FRONT_PRODUCT_FAVORITE_ADD_INITIALIZE);
  420.         if ($this->isGranted('ROLE_USER')) {
  421.             $Customer $this->getUser();
  422.             $CustomerFavoriteProduct $this->customerFavoriteProductRepository->findOneBy(['Customer' => $Customer'Product' => $Product]);
  423.             if ($CustomerFavoriteProduct) {
  424.                 $this->customerFavoriteProductRepository->delete($CustomerFavoriteProduct);
  425.                 $status 'not-favorite';
  426.             } else {
  427.                 $this->customerFavoriteProductRepository->addFavorite($Customer$Product);
  428.                 $status 'favorite';
  429.             }
  430.             $event = new EventArgs(
  431.                 [
  432.                     'Product' => $Product,
  433.                 ],
  434.                 $request
  435.             );
  436.             $this->eventDispatcher->dispatch($eventEccubeEvents::FRONT_PRODUCT_FAVORITE_ADD_COMPLETE);
  437.             return $this->json([
  438.                 'done' => true,
  439.                 'product_id' => $Product->getId(),
  440.                 'status' => $status
  441.             ]);
  442.         } else {
  443.             // 非会員の場合、ログイン画面を表示
  444.             return $this->redirectToRoute('mypage_login');
  445.         }
  446.     }
  447.     /**
  448.      * 商品一覧からのメモ登録.
  449.      *
  450.      * @Route("/products/register_memo_from_list/", name="product_memo_from_list", methods={"POST"})
  451.      */
  452.     public function registerMemoFromList(Request $request)
  453.     {
  454.         if ($this->isGranted('ROLE_USER')) {
  455.             $product_id intval($request->request->get('product_id'));
  456.             $customer_id intval($request->request->get('customer_id'));
  457.             $memo $request->request->get('memo');
  458.             $params = [
  459.                 'Product' => $product_id,
  460.                 'Customer' => $customer_id,
  461.             ];
  462.             $this->productMemoRepository->register($params$memo);
  463.             return $this->json([
  464.                 'done' => true,
  465.                 'product_id' => $product_id,
  466.                 'memo' => $memo
  467.             ]);
  468.         } else {
  469.             // 非会員の場合、ログイン画面を表示
  470.             return $this->redirectToRoute('mypage_login');
  471.         }
  472.     }
  473.     /**
  474.      * 事前入札画面からのメモ登録.
  475.      *
  476.      * @Route("/products/register_memo/{id}", name="product_memo", requirements={"id" = "\d+"}, methods={"POST"})
  477.      */
  478.     public function registerMemo(Request $requestProduct $Product)
  479.     {
  480.         if ($this->isGranted('ROLE_USER')) {
  481.             $product_id $Product->getId();
  482.             $customer_id $this->getUser()->getId();
  483.             $memo $request->request->get('memo');
  484.             $params = [
  485.                 'Product' => $product_id,
  486.                 'Customer' => $customer_id,
  487.             ];
  488.             $this->productMemoRepository->register($params$memo);
  489.             return $this->redirect($_SERVER['HTTP_REFERER']);
  490.         } else {
  491.             // 非会員の場合、ログイン画面を表示
  492.             return $this->redirectToRoute('mypage_login');
  493.         }
  494.     }
  495.     /**
  496.      * 商品一覧からの事前入札.
  497.      *
  498.      * @Route("/products/preview_tender_from_list/", name="preview_tender_from_list", methods={"POST"})
  499.      */
  500.     public function previewTenderFromList(Request $request)
  501.     {
  502.         if ($this->isGranted('ROLE_USER')) {
  503.             $product_id intval($request->request->get('preview_tender_product_id'));
  504.             $tender_price intval($request->request->get('tender_price'));
  505.             $auto_bid_limit $request->request->get('auto_bid_limit');
  506.             $autoBidLimit $auto_bid_limit === null || $auto_bid_limit === '' null intval($auto_bid_limit);
  507.             $Customer $this->getUser();
  508.             $Product $this->productRepository->find($product_id);
  509.             $Auction $Product->getAuction();
  510.             // 下見期間かどうか
  511.             $is_preview $Auction->isPreview();
  512.             if (!$is_preview) {
  513.                 return $this->json(['done' => false]);
  514.             }
  515.             $result $this->previewTenderRepository->registerWithAutoBid($Product$Customer$tender_price$autoBidLimit);
  516.             if (!$result['success']) {
  517.                 return $this->json([
  518.                     'done' => false,
  519.                     'message' => $result['message'] ?? null,
  520.                     'current_price' => $result['current_price'] ?? null,
  521.                 ]);
  522.             }
  523.             return $this->json([
  524.                 'done' => true,
  525.                 'product_id' => $product_id,
  526.                 'tender_price' => number_format($result['winning_price']),
  527.                 'winning_price' => $result['winning_price'],
  528.                 'winner_customer_id' => $result['winner_customer_id'],
  529.             ]);
  530.         } else {
  531.             // 非会員の場合、ログイン画面を表示
  532.             return $this->redirectToRoute('mypage_login');
  533.         }
  534.     }
  535.     /**
  536.      * 事前入札画面からの事前入札.
  537.      *
  538.      * @Route("/products/preview_tender/{id}", name="preview_tender", requirements={"id" = "\d+"}, methods={"POST"})
  539.      */
  540.     public function previewTender(Request $requestProduct $Product)
  541.     {
  542.         if ($this->isGranted('ROLE_USER')) {
  543.             $product_id $Product->getId();
  544.             $tender_price intval($request->request->get('tender_price'));
  545.             $auto_bid_limit $request->request->get('auto_bid_limit');
  546.             $autoBidLimit $auto_bid_limit === null || $auto_bid_limit === '' null intval($auto_bid_limit);
  547.             $Customer $this->getUser();
  548.             $Product $this->productRepository->find($product_id);
  549.             $Auction $Product->getAuction();
  550.             // 下見期間かどうか
  551.             $is_preview $Auction->isPreview();
  552.             if (!$is_preview) {
  553.                 return $this->json(['done' => false]);
  554.             }
  555.             $result $this->previewTenderRepository->registerWithAutoBid($Product$Customer$tender_price$autoBidLimit);
  556.             if (!$result['success']) {
  557.                 return $this->json(['done' => false'message' => $result['message'] ?? null]);
  558.             }
  559.             return $this->json(['done' => true]);
  560.         } else {
  561.             // 非会員の場合、ログイン画面を表示
  562.             return $this->redirectToRoute('mypage_login');
  563.         }
  564.     }
  565.     /**
  566.      * ページタイトルの設定
  567.      *
  568.      * @param  array|null  $searchData
  569.      * @return string
  570.      */
  571.     protected function getPageTitle($searchData)
  572.     {
  573.         if (isset($searchData['name']) && !empty($searchData['name'])) {
  574.             return trans('front.product.search_result');
  575.         } elseif (isset($searchData['category_id']) && $searchData['category_id']) {
  576.             return $searchData['category_id']->getName();
  577.         } else {
  578.             return trans('front.product.all_products');
  579.         }
  580.     }
  581.     /**
  582.      * 閲覧可能な商品かどうかを判定
  583.      *
  584.      * @return bool 閲覧可能な場合はtrue
  585.      */
  586.     protected function checkVisibility(Product $Product)
  587.     {
  588.         $is_admin $this->session->has('_security_admin');
  589.         // 管理ユーザの場合はステータスやオプションにかかわらず閲覧可能.
  590.         if (!$is_admin) {
  591.             // 在庫なし商品の非表示オプションが有効な場合.
  592.             // if ($this->BaseInfo->isOptionNostockHidden()) {
  593.             //     if (!$Product->getStockFind()) {
  594.             //         return false;
  595.             //     }
  596.             // }
  597.             // 公開ステータスでない商品は表示しない.
  598.             if ($Product->getStatus()->getId() !== ProductStatus::DISPLAY_SHOW) {
  599.                 return false;
  600.             }
  601.         }
  602.         return true;
  603.     }
  604.     /**
  605.      * オークション再開時の商品番号を取得
  606.      *
  607.      * @Route("/auctions/get_restart_product", name="get_restart_product", methods={"GET", "POST"})
  608.      */
  609.     public function getRestartProduct(Request $request) {
  610.         $productId $request->request->get('product_id');
  611.         $productNumber $this->productRepository->find($productId)->formatProductNumber();
  612.         return $this->json([
  613.             'product_number' => $productNumber,
  614.         ]);
  615.     }
  616. }