Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

改正商取引法の施行に伴うECカート「最終確認画面」表示項目の変更[#5304]について #5399

Merged
merged 45 commits into from
Jun 29, 2022
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
e8ddcf5
dtb_tradelawテーブル定義の実装。
sai-gillingham Jun 15, 2022
6f4ff62
データベースのテーブル初期値処理の修正。
sai-gillingham Jun 16, 2022
9bad6bf
管理側の特定商取引法設定画面の追加。
sai-gillingham Jun 16, 2022
1638910
null|string ゲッターセッターハンドル。
sai-gillingham Jun 16, 2022
3e7a161
特定商取引法設定の件数は10件から15件に変更。
sai-gillingham Jun 16, 2022
d12377b
フロント側に特定商取引法設定表示の追加。
sai-gillingham Jun 16, 2022
c1e97cd
名称バリデーション修正。
sai-gillingham Jun 16, 2022
4bbd3f0
nullableチェック。
sai-gillingham Jun 16, 2022
d3733a3
タブ空間の削除。
sai-gillingham Jun 16, 2022
6019987
初期値のUT。
sai-gillingham Jun 16, 2022
8cc974c
バリデーションUT
sai-gillingham Jun 16, 2022
4b57333
UT修正。
sai-gillingham Jun 20, 2022
ca43aac
管理側の特定商取引法設定画面のUTテストの追加。
sai-gillingham Jun 20, 2022
043ab0b
コメント追加。
sai-gillingham Jun 20, 2022
15b43cf
todo を消す。
sai-gillingham Jun 20, 2022
ae33f21
ご注文手続きの特定商取引法設定表示のUTテスト。
sai-gillingham Jun 20, 2022
c4bbe1d
PHP UTDOC 更新
sai-gillingham Jun 20, 2022
5bc80f4
フロント側の注文確認画面の特定商取引法設定の表示UTの追加。
sai-gillingham Jun 20, 2022
fdbc8b3
表示順番テストの追加。
sai-gillingham Jun 20, 2022
97239a3
英語の翻訳ファイルの修正。
sai-gillingham Jun 20, 2022
67cf74d
HTML追加。
sai-gillingham Jun 20, 2022
5746cb6
バリデーション追加。
sai-gillingham Jun 20, 2022
af7cbae
バリデーションUTの追加。
sai-gillingham Jun 20, 2022
793b7ff
twigで改正商取引法の有効設定は正しいかどうかチェックする。
sai-gillingham Jun 20, 2022
e79a9ee
リポジトリUTの修正。
sai-gillingham Jun 20, 2022
f1e4ebd
Update src/Eccube/Controller/Admin/Setting/Shop/TradeLawController.php
nanasess Jun 28, 2022
9222fbd
TradeLawController.phpの修正。
sai-gillingham Jun 28, 2022
5d105d8
ShoppingControllerTest.php修正。
sai-gillingham Jun 28, 2022
ca10837
var_dump削除.
sai-gillingham Jun 28, 2022
097b51a
TradeLawリポジトリ変数をprivate -> protectedに更新。
sai-gillingham Jun 28, 2022
2964d53
display_order_screen は boolean なので 0 に変更
nanasess Jun 28, 2022
029c71e
フロント側の特定商取引法のページ追加
nanasess Jun 28, 2022
bcac815
Merge branch 'issue/5304' of github.com:sai-gillingham/ec-cube into i…
nanasess Jun 28, 2022
626ee6b
WebTest 追加
nanasess Jun 28, 2022
527ef0a
古いルーティングを削除
nanasess Jun 28, 2022
73b48dd
テンプレート追加
nanasess Jun 28, 2022
b612e95
古いE2Eテストを削除
nanasess Jun 28, 2022
abcbb0f
Merge remote-tracking branch 'upstream/4.2' into issue/5304
nanasess Jun 28, 2022
5b51141
E2Eテストのエンドポイント修正
nanasess Jun 28, 2022
eacdc5d
ルーティングをhelp_tradelawに
chihiro-adachi Jun 29, 2022
debe64a
コードの記載を統一
chihiro-adachi Jun 29, 2022
90d7844
不要なバリデーションを削除
chihiro-adachi Jun 29, 2022
3397ec6
不要な記述を削除
chihiro-adachi Jun 29, 2022
fd0a563
テストの修正
chihiro-adachi Jun 29, 2022
da9ff65
バリデーションの変更に伴いテストを削除
chihiro-adachi Jun 29, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions app/config/eccube/packages/eccube_nav.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@ parameters:
url: admin_setting_shop
shop_tradelaw:
name: admin.setting.shop.tradelaw_setting
url: admin_content_page_edit
param: { id: !php/const Eccube\Entity\Page::TRADELAW_PAGE_ID, return: tradelaw }
url: admin_setting_shop_tradelaw
shop_agreement:
name: admin.setting.shop.agreement_setting
url: admin_content_page_edit
Expand Down
86 changes: 86 additions & 0 deletions src/Eccube/Controller/Admin/Setting/Shop/TradeLawController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?php

namespace Eccube\Controller\Admin\Setting\Shop;

use Eccube\Controller\AbstractController;
use Eccube\Event\EccubeEvents;
use Eccube\Event\EventArgs;
use Eccube\Form\Type\Admin\OrderStatusSettingType;
use Eccube\Form\Type\Admin\TradeLawType;
use Eccube\Form\Type\Front\ForgotType;
use Eccube\Repository\TradeLawRepository;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\HttpFoundation\Request;

class TradeLawController extends AbstractController
{
private TradeLawRepository $tradeLawRepository;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

他の Controller に合わせて protected でお願いします

nanasess marked this conversation as resolved.
Show resolved Hide resolved

/**
* @param TradeLawRepository $tradeLawRepository
*/
public function __construct(
TradeLawRepository $tradeLawRepository
) {
$this->tradeLawRepository = $tradeLawRepository;
}

/**
* 税率設定の初期表示・登録
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* 税率設定の初期表示・登録
* 特定商取引法設定の初期表示・登録

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

コメントありがとうございます。こちらのコメントを更新しました。

*
* @Route("/%eccube_admin_route%/setting/shop/tradelaw", name="admin_setting_shop_tradelaw", methods={"GET", "POST"})
* @Template("@admin/Setting/Shop/tradelaw.twig")
* @param Request $request
*/
public function index(Request $request)
{
$tradeLawDetails = $this->tradeLawRepository->findBy([], ['sortNo' => 'ASC']);
$builder = $this->formFactory->createBuilder();
$builder
->add(
'TradeLaws',
CollectionType::class,
[
'entry_type' => TradeLawType::class,
'data' => $tradeLawDetails,
]
);
$form = $builder->getForm();
$form->handleRequest($request);

$event = new EventArgs(
[
'TradeLaw' => $tradeLawDetails,
],
$request
);



$form = $builder->getForm();
$form->handleRequest($request);

if ($form->isSubmitted() && $form->isValid()) {
foreach ($form['TradeLaws'] as $child) {
$OrderStatus = $child->getData();
$this->entityManager->persist($OrderStatus);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$OrderStatus = $child->getData();
$this->entityManager->persist($OrderStatus);
$TradeLaw = $child->getData();
$this->entityManager->persist($TradeLaw);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

コメントありがとうございます。変数名を更新しました。

}
$this->entityManager->flush();

$this->addSuccess('admin.common.save_complete', 'admin');

$this->eventDispatcher->dispatch($event, EccubeEvents::ADMIN_SETTING_SHOP_TRADE_LAW_POST_COMPLETE);

return $this->redirectToRoute('admin_setting_shop_tradelaw');
}

$this->eventDispatcher->dispatch($event, EccubeEvents::ADMIN_SETTING_SHOP_TRADE_LAW_INDEX_COMPLETE);

return [
'form' => $form->createView(),
'tradeLawDetails' => $tradeLawDetails
];
}
}
19 changes: 18 additions & 1 deletion src/Eccube/Controller/ShoppingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use Eccube\Form\Type\Shopping\CustomerAddressType;
use Eccube\Form\Type\Shopping\OrderType;
use Eccube\Repository\OrderRepository;
use Eccube\Repository\TradeLawRepository;
use Eccube\Service\CartService;
use Eccube\Service\MailService;
use Eccube\Service\OrderHelper;
Expand Down Expand Up @@ -67,18 +68,25 @@ class ShoppingController extends AbstractShoppingController
*/
protected $serviceContainer;

/**
* @var TradeLawRepository
*/
private TradeLawRepository $tradeLawRepository;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

他の Controller に合わせて protected でお願いします

Copy link
Contributor Author

@sai-gillingham sai-gillingham Jun 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

了解いたしました。ShoppingControllerクラスの変数と合わせて変数定義 [例 TradeLawRepository] を削除した方が良いでしょうか?

Copy link
Contributor Author

@sai-gillingham sai-gillingham Jun 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private TradeLawRepository $tradeLawRepository;
protected $tradeLawRepository;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private TradeLawRepository $tradeLawRepository;
protected TradeLawRepository $tradeLawRepository;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

コメントありがとうございます。protected に更新しました。


public function __construct(
CartService $cartService,
MailService $mailService,
OrderRepository $orderRepository,
OrderHelper $orderHelper,
ContainerInterface $serviceContainer
ContainerInterface $serviceContainer,
TradeLawRepository $tradeLawRepository
) {
$this->cartService = $cartService;
$this->mailService = $mailService;
$this->orderRepository = $orderRepository;
$this->orderHelper = $orderHelper;
$this->serviceContainer = $serviceContainer;
$this->tradeLawRepository = $tradeLawRepository;
}

/**
Expand Down Expand Up @@ -145,11 +153,14 @@ public function index(PurchaseFlow $cartPurchaseFlow)
$this->entityManager->flush();
}

$activeTradeLaws = $this->tradeLawRepository->findBy(['displayOrderScreen' => true], ['sortNo' => 'ASC']);

$form = $this->createForm(OrderType::class, $Order);

return [
'form' => $form->createView(),
'Order' => $Order,
'activeTradeLaws' => $activeTradeLaws
];
}

Expand Down Expand Up @@ -230,11 +241,14 @@ public function redirectTo(Request $request, RouterInterface $router)
}
}

$activeTradeLaws = $this->tradeLawRepository->findBy(['displayOrderScreen' => true], ['sortNo' => 'ASC']);

log_info('[リダイレクト] フォームエラーのため, 注文手続き画面を表示します.', [$Order->getId()]);

return [
'form' => $form->createView(),
'Order' => $Order,
'activeTradeLaws' => $activeTradeLaws
];
}

Expand Down Expand Up @@ -266,6 +280,7 @@ public function confirm(Request $request)
return $this->redirectToRoute('shopping_error');
}

$activeTradeLaws = $this->tradeLawRepository->findBy(['displayOrderScreen' => true], ['sortNo' => 'ASC']);
$form = $this->createForm(OrderType::class, $Order);
$form->handleRequest($request);

Expand Down Expand Up @@ -311,6 +326,7 @@ public function confirm(Request $request)
return [
'form' => $form->createView(),
'Order' => $Order,
'activeTradeLaws' => $activeTradeLaws
];
}

Expand All @@ -325,6 +341,7 @@ public function confirm(Request $request)
return [
'form' => $form->createView(),
'Order' => $Order,
'activeTradeLaws' => $activeTradeLaws
];
}

Expand Down
189 changes: 189 additions & 0 deletions src/Eccube/Entity/TradeLaw.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
<?php

/*
* This file is part of EC-CUBE
*
* Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
*
* http://www.ec-cube.co.jp/
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Eccube\Entity;

use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Translation\TranslatableMessage;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
use Symfony\Component\Validator\Mapping\ClassMetadata;
use Symfony\Component\Validator\Constraints as Assert;

if (!class_exists('\Eccube\Entity\TradeLaw')) {
/**
* TradeLaw
*
* @ORM\Table(name="dtb_tradelaw")
* @ORM\InheritanceType("SINGLE_TABLE")
* @ORM\DiscriminatorColumn(name="discriminator_type", type="string", length=255)
* @ORM\HasLifecycleCallbacks()
* @ORM\Entity(repositoryClass="Eccube\Repository\TradeLawRepository")
*/
class TradeLaw extends AbstractEntity
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer", options={"unsigned":true})
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private int $id;

/**
* @var ?string
*
* @ORM\Column(name="name", type="string", length=255, nullable=true)
*/
private ?string $name;

/**
* @var ?string
*
* @ORM\Column(name="description", type="string", length=4000, nullable=true)
*/
private ?string $description;

/**
* @var int
*
* @ORM\Column(name="sort_no", type="smallint", nullable=false)
*/
private int $sortNo;

/**
* @var boolean
*
* @ORM\Column(name="display_order_screen", type="boolean")
*/
private bool $displayOrderScreen = false;

public static function loadValidatorMetadata(ClassMetadata $metadata)
{
$metadata->addConstraint(new Assert\Callback('validateActivation'));
}


/**
* @return string
*/
public function __toString()
{
return $this->getName();
}

/**
* @param int $id
* @return TradeLaw
*/
public function setId(int $id): TradeLaw
{
$this->id = $id;
return $this;
}

/**
* @return int
*/
public function getId(): int
{
return $this->id;
}

/**
* @param string $name
* @return TradeLaw
*/
public function setName(?string $name): TradeLaw
{
$this->name = $name ?: "";
return $this;
}

/**
* @return string
*/
public function getName(): ?string
{
return $this->name;
}

/**
* @param string $description
* @return TradeLaw
*/
public function setDescription(?string $description): TradeLaw
{
$this->description = $description ?: "";
return $this;
}

/**
* @return string
*/
public function getDescription(): ?string
{
return $this->description;
}

/**
* @param int $sortNo
* @return TradeLaw
*/
public function setSortNo(int $sortNo): TradeLaw
{
$this->sortNo = $sortNo;
return $this;
}

/**
* @return int
*/
public function getSortNo(): int
{
return $this->sortNo;
}

/**
* @param bool $displayOrderScreen
* @return TradeLaw
*/
public function setDisplayOrderScreen(bool $displayOrderScreen): TradeLaw
{
$this->displayOrderScreen = $displayOrderScreen;
return $this;
}

/**
* @return bool
*/
public function isDisplayOrderScreen(): bool
{
return $this->displayOrderScreen;
}

public function validateActivation(ExecutionContextInterface $context, $payload)
{
// check if the name is actually a fake name
if (
$this->isDisplayOrderScreen() === true &&
(empty($this->getName()) ||
empty($this->getDescription()))
) {
$context->buildViolation(trans('admin.setting.shop.trade_law.error.activation_error'))
->atPath('displayOrderScreen')
->addViolation();
}
}
}
}
3 changes: 3 additions & 0 deletions src/Eccube/Event/EccubeEvents.php
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,9 @@ final class EccubeEvents
// delete
const ADMIN_SETTING_SHOP_PAYMENT_DELETE_COMPLETE = 'admin.setting.shop.payment.delete.complete';

const ADMIN_SETTING_SHOP_TRADE_LAW_INDEX_COMPLETE = 'admin.setting.shop.trade.law.index.complete';
const ADMIN_SETTING_SHOP_TRADE_LAW_POST_COMPLETE = 'admin.setting.shop.trade.law.post.complete';

/**
* Admin/Setting/Shop/ShopController
*/
Expand Down
Loading