diff --git a/src/Eccube/Controller/ShoppingController.php b/src/Eccube/Controller/ShoppingController.php index 1f8b7accd8d..bc398092319 100644 --- a/src/Eccube/Controller/ShoppingController.php +++ b/src/Eccube/Controller/ShoppingController.php @@ -29,6 +29,7 @@ use Eccube\Form\Type\Shopping\CustomerAddressType; use Eccube\Form\Type\Shopping\OrderType; use Eccube\Repository\CustomerAddressRepository; +use Eccube\Repository\OrderRepository; use Eccube\Service\CartService; use Eccube\Service\OrderHelper; use Eccube\Service\Payment\PaymentDispatcher; @@ -92,6 +93,7 @@ public function __construct( CartService $cartService, ShoppingService $shoppingService, CustomerAddressRepository $customerAddressRepository, + OrderRepository $orderRepository, ParameterBag $parameterBag ) { $this->BaseInfo = $BaseInfo; @@ -99,6 +101,7 @@ public function __construct( $this->cartService = $cartService; $this->shoppingService = $shoppingService; $this->customerAddressRepository = $customerAddressRepository; + $this->orderRepository = $orderRepository; $this->parameterBag = $parameterBag; } @@ -333,9 +336,15 @@ public function complete(Request $request) // 受注IDを取得 $orderId = $this->session->get($this->sessionOrderKey); + if (empty($orderId)) { + return $this->redirectToRoute('homepage'); + } + + $Order = $this->orderRepository->find($orderId); + $event = new EventArgs( [ - 'orderId' => $orderId, + 'Order' => $Order, ], $request ); @@ -350,12 +359,12 @@ public function complete(Request $request) $this->session->remove($this->sessionKey); $this->session->remove($this->sessionCustomerAddressKey); - log_info('購入処理完了', [$orderId]); + log_info('購入処理完了', [$Order->getId()]); $hasNextCart = !empty($this->cartService->getCarts()); return [ - 'orderId' => $orderId, + 'Order' => $Order, 'hasNextCart' => $hasNextCart, ]; } diff --git a/src/Eccube/Entity/Order.php b/src/Eccube/Entity/Order.php index 3343f1f0b69..be07a534ae5 100644 --- a/src/Eccube/Entity/Order.php +++ b/src/Eccube/Entity/Order.php @@ -304,6 +304,20 @@ public function getTotalPrice() */ private $currency_code; + /** + * @var string|null + * + * @ORM\Column(name="complete_message", type="text", nullable=true) + */ + private $complete_message; + + /** + * @var string|null + * + * @ORM\Column(name="complete_mail_message", type="text", nullable=true) + */ + private $complete_mail_message; + /** * @var \Doctrine\Common\Collections\Collection * @@ -1136,6 +1150,70 @@ public function setCurrencyCode($currencyCode = null) return $this; } + /** + * @return null|string + */ + public function getCompleteMessage() + { + return $this->complete_message; + } + + /** + * @param null|string $complete_message + * + * @return $this + */ + public function setCompleteMessage($complete_message = null) + { + $this->complete_message = $complete_message; + + return $this; + } + + /** + * @param null|string $complete_message + * + * @return $this + */ + public function appendCompleteMessage($complete_message = null) + { + $this->complete_message .= $complete_message; + + return $this; + } + + /** + * @return null|string + */ + public function getCompleteMailMessage() + { + return $this->complete_mail_message; + } + + /** + * @param null|string $complete_mail_message + * + * @return + */ + public function setCompleteMailMessage($complete_mail_message = null) + { + $this->complete_mail_message = $complete_mail_message; + + return $this; + } + + /** + * @param null|string $complete_mail_message + * + * @return + */ + public function appendCompleteMailMessage($complete_mail_message = null) + { + $this->complete_mail_message .= $complete_mail_message; + + return $this; + } + /** * 商品の受注明細を取得 * diff --git a/src/Eccube/Resource/template/admin/Mail/order.twig b/src/Eccube/Resource/template/admin/Mail/order.twig index b1a59952a61..f0de77a142c 100644 --- a/src/Eccube/Resource/template/admin/Mail/order.twig +++ b/src/Eccube/Resource/template/admin/Mail/order.twig @@ -89,4 +89,8 @@ file that was distributed with this source code. {% endfor %} {% endfor %} +{% if Order.complete_mail_message is not empty %} +{{ Order.complete_mail_message }} +{% endif %} + {{ footer }} diff --git a/src/Eccube/Resource/template/default/Mail/order.twig b/src/Eccube/Resource/template/default/Mail/order.twig index 6406f7ed68d..3a536b0d4d7 100644 --- a/src/Eccube/Resource/template/default/Mail/order.twig +++ b/src/Eccube/Resource/template/default/Mail/order.twig @@ -86,4 +86,8 @@ file that was distributed with this source code. {% endfor %} {% endfor %} +{% if Order.complete_mail_message is not empty %} +{{ Order.complete_mail_message }} +{% endif %} + {{ footer }} diff --git a/src/Eccube/Resource/template/default/Shopping/complete.twig b/src/Eccube/Resource/template/default/Shopping/complete.twig index acdfd619fa8..98d092caf9f 100644 --- a/src/Eccube/Resource/template/default/Shopping/complete.twig +++ b/src/Eccube/Resource/template/default/Shopping/complete.twig @@ -66,6 +66,9 @@ file that was distributed with this source code.

{{'shopping.text.message.thank_you_order'|trans}}

{{'shopping.text.message.sent_email'|trans}}
{{'shopping.text.message.in_case'|trans}}
{{'shopping.text.message.thank_you_with_us'|trans}}

+ {% if Order is not null and Order.complete_message is not empty %} + {{ Order.complete_message|raw }} + {% endif %}
{% if hasNextCart %}
購入を続ける
{# TODO 未翻訳 #} diff --git a/tests/Eccube/Tests/Web/ShoppingControllerTest.php b/tests/Eccube/Tests/Web/ShoppingControllerTest.php index 4f0238e200e..9281239e6e9 100644 --- a/tests/Eccube/Tests/Web/ShoppingControllerTest.php +++ b/tests/Eccube/Tests/Web/ShoppingControllerTest.php @@ -49,7 +49,9 @@ public function testRoutingShoppingLogin() public function testComplete() { - $this->container->get('session')->set('eccube.front.shopping.order.id', 111); + $Customer = $this->createCustomer(); + $Order = $this->createOrder($Customer); + $this->container->get('session')->set('eccube.front.shopping.order.id', $Order->getId()); $this->client->request('GET', $this->generateUrl('shopping_complete')); $this->assertTrue($this->client->getResponse()->isSuccessful());