From 04bf89e780c69fb678fdc4838c2f7411d17ba13e Mon Sep 17 00:00:00 2001 From: morry48 Date: Sun, 8 Nov 2020 01:10:33 +0900 Subject: [PATCH 1/5] =?UTF-8?q?=E5=8F=97=E6=B3=A8=E7=AE=A1=E7=90=86?= =?UTF-8?q?=EF=BC=9E=E5=8F=97=E6=B3=A8=E6=A4=9C=E7=B4=A2=E3=81=AE=E3=81=8A?= =?UTF-8?q?=E5=90=8D=E5=89=8D=E3=80=81=E6=B3=A8=E6=96=87=E8=80=85=E5=90=8D?= =?UTF-8?q?=E6=A4=9C=E7=B4=A2=E3=81=AE=E3=83=AD=E3=82=B8=E3=83=83=E3=82=AF?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3=20=E3=81=8A=E5=90=8D=E5=89=8D=E3=83=BB?= =?UTF-8?q?=E6=B3=A8=E6=96=87=E8=80=85=E5=90=8D=E3=83=BB=E3=82=AB=E3=83=8A?= =?UTF-8?q?=E3=81=AB=E3=81=8A=E3=81=84=E3=81=A6=E3=83=95=E3=83=AB=E3=83=8D?= =?UTF-8?q?=E3=83=BC=E3=83=A0=E6=A4=9C=E7=B4=A2=E3=81=AB=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Eccube/Repository/OrderRepository.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/Eccube/Repository/OrderRepository.php b/src/Eccube/Repository/OrderRepository.php index f80ee50e8d8..e1984e7e63f 100644 --- a/src/Eccube/Repository/OrderRepository.php +++ b/src/Eccube/Repository/OrderRepository.php @@ -106,16 +106,18 @@ public function getQueryBuilderBySearchDataForAdmin($searchData) } // multi if (isset($searchData['multi']) && StringUtil::isNotBlank($searchData['multi'])) { - $multi = preg_match('/^\d{0,10}$/', $searchData['multi']) ? $searchData['multi'] : null; - if ($multi && $multi > '2147483647' && $this->isPostgreSQL()) { - $multi = null; + //スペース除去 + $clean_key_multi = preg_replace('/\s+|[ ]+/u', '', $searchData['multi']); + $id = preg_match('/^\d{0,10}$/', $clean_key_multi) ? $clean_key_multi : null; + if ($id && $id > '2147483647' && $this->isPostgreSQL()) { + $id = null; } $qb - ->andWhere('o.id = :multi OR o.name01 LIKE :likemulti OR o.name02 LIKE :likemulti OR '. - 'o.kana01 LIKE :likemulti OR o.kana02 LIKE :likemulti OR o.company_name LIKE :likemulti OR '. + ->andWhere('o.id = :order_id OR CONCAT(o.name01, o.name02) LIKE :likemulti OR '. + 'CONCAT(o.kana01, o.kana02) LIKE :likemulti OR o.company_name LIKE :likemulti OR '. 'o.order_no LIKE :likemulti OR o.email LIKE :likemulti OR o.phone_number LIKE :likemulti') - ->setParameter('multi', $multi) - ->setParameter('likemulti', '%'.$searchData['multi'].'%'); + ->setParameter('order_id', $id) + ->setParameter('likemulti', '%'.$clean_key_multi.'%'); } // order_id_end From 57a22bcc23fc05a1e9affdb94b5d00b714e899b4 Mon Sep 17 00:00:00 2001 From: morry48 Date: Sun, 8 Nov 2020 01:29:23 +0900 Subject: [PATCH 2/5] =?UTF-8?q?=E5=8F=97=E6=B3=A8=E7=AE=A1=E7=90=86?= =?UTF-8?q?=EF=BC=9E=E5=8F=97=E6=B3=A8=E6=A4=9C=E7=B4=A2=E3=81=AE=E3=81=8A?= =?UTF-8?q?=E5=90=8D=E5=89=8D=E3=80=81=E6=B3=A8=E6=96=87=E8=80=85=E5=90=8D?= =?UTF-8?q?=E6=A4=9C=E7=B4=A2=E3=81=AE=E3=83=AD=E3=82=B8=E3=83=83=E3=82=AF?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3=20=E8=A9=B3=E7=B4=B0=E6=A4=9C=E7=B4=A2?= =?UTF-8?q?=EF=BC=88=E6=B3=A8=E6=96=87=E8=80=85=E5=90=8D=E3=83=BB=E6=B3=A8?= =?UTF-8?q?=E6=96=87=E8=80=85=E5=90=8D-=E3=82=AB=E3=83=8A=EF=BC=89?= =?UTF-8?q?=E3=81=AB=E3=81=8A=E3=81=84=E3=81=A6=E3=83=95=E3=83=AB=E3=83=8D?= =?UTF-8?q?=E3=83=BC=E3=83=A0=E6=A4=9C=E7=B4=A2=E3=82=92=E5=8F=AF=E8=83=BD?= =?UTF-8?q?=E3=81=AB=E3=81=99=E3=82=8B=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Eccube/Repository/OrderRepository.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Eccube/Repository/OrderRepository.php b/src/Eccube/Repository/OrderRepository.php index e1984e7e63f..c6fbcc94ec0 100644 --- a/src/Eccube/Repository/OrderRepository.php +++ b/src/Eccube/Repository/OrderRepository.php @@ -151,16 +151,18 @@ public function getQueryBuilderBySearchDataForAdmin($searchData) // name if (isset($searchData['name']) && StringUtil::isNotBlank($searchData['name'])) { + $clean_name = preg_replace('/\s+|[ ]+/u', '', $searchData['name']); $qb ->andWhere('CONCAT(o.name01, o.name02) LIKE :name') - ->setParameter('name', '%'.$searchData['name'].'%'); + ->setParameter('name', '%'.$clean_name.'%'); } // kana if (isset($searchData['kana']) && StringUtil::isNotBlank($searchData['kana'])) { + $clean_kana = preg_replace('/\s+|[ ]+/u', '', $searchData['kana']); $qb ->andWhere('CONCAT(o.kana01, o.kana02) LIKE :kana') - ->setParameter('kana', '%'.$searchData['kana'].'%'); + ->setParameter('kana', '%'.$clean_kana.'%'); } // email From 42609b52eca225faa8ae8d9bcad398f6983ba315 Mon Sep 17 00:00:00 2001 From: morry48 Date: Thu, 12 Nov 2020 00:23:01 +0900 Subject: [PATCH 3/5] =?UTF-8?q?issues=20#4716=20getQueryBuilderBySearchDat?= =?UTF-8?q?aForAdmin()=E3=81=AE$order=5Fid=E3=82=92$id=E3=81=AB=E6=88=BB?= =?UTF-8?q?=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Eccube/Repository/OrderRepository.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Eccube/Repository/OrderRepository.php b/src/Eccube/Repository/OrderRepository.php index c6fbcc94ec0..9ebd838d93d 100644 --- a/src/Eccube/Repository/OrderRepository.php +++ b/src/Eccube/Repository/OrderRepository.php @@ -108,15 +108,15 @@ public function getQueryBuilderBySearchDataForAdmin($searchData) if (isset($searchData['multi']) && StringUtil::isNotBlank($searchData['multi'])) { //スペース除去 $clean_key_multi = preg_replace('/\s+|[ ]+/u', '', $searchData['multi']); - $id = preg_match('/^\d{0,10}$/', $clean_key_multi) ? $clean_key_multi : null; - if ($id && $id > '2147483647' && $this->isPostgreSQL()) { - $id = null; + $multi = preg_match('/^\d{0,10}$/', $clean_key_multi) ? $clean_key_multi : null; + if ($multi && $multi > '2147483647' && $this->isPostgreSQL()) { + $multi = null; } $qb - ->andWhere('o.id = :order_id OR CONCAT(o.name01, o.name02) LIKE :likemulti OR '. + ->andWhere('o.id = :multi OR CONCAT(o.name01, o.name02) LIKE :likemulti OR '. 'CONCAT(o.kana01, o.kana02) LIKE :likemulti OR o.company_name LIKE :likemulti OR '. 'o.order_no LIKE :likemulti OR o.email LIKE :likemulti OR o.phone_number LIKE :likemulti') - ->setParameter('order_id', $id) + ->setParameter('multi', $multi) ->setParameter('likemulti', '%'.$clean_key_multi.'%'); } From a8592c45987afdb1192009c54292b1da16aa4966 Mon Sep 17 00:00:00 2001 From: hideki_okajima Date: Thu, 12 Nov 2020 16:45:57 +0900 Subject: [PATCH 4/5] =?UTF-8?q?=E5=8F=97=E6=B3=A8=E3=81=AE=E3=83=9E?= =?UTF-8?q?=E3=83=AB=E3=83=81=E6=A4=9C=E7=B4=A2=E3=81=A7=E3=80=81=E4=BC=9A?= =?UTF-8?q?=E7=A4=BE=E5=90=8D=E3=81=AF=E3=82=B9=E3=83=9A=E3=83=BC=E3=82=B9?= =?UTF-8?q?=E3=82=92=E9=99=A4=E5=8E=BB=E3=81=9B=E3=81=9A=E6=A4=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Eccube/Repository/OrderRepository.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Eccube/Repository/OrderRepository.php b/src/Eccube/Repository/OrderRepository.php index 9ebd838d93d..3105015e9de 100644 --- a/src/Eccube/Repository/OrderRepository.php +++ b/src/Eccube/Repository/OrderRepository.php @@ -114,10 +114,11 @@ public function getQueryBuilderBySearchDataForAdmin($searchData) } $qb ->andWhere('o.id = :multi OR CONCAT(o.name01, o.name02) LIKE :likemulti OR '. - 'CONCAT(o.kana01, o.kana02) LIKE :likemulti OR o.company_name LIKE :likemulti OR '. + 'CONCAT(o.kana01, o.kana02) LIKE :likemulti OR o.company_name LIKE :company_name OR '. 'o.order_no LIKE :likemulti OR o.email LIKE :likemulti OR o.phone_number LIKE :likemulti') ->setParameter('multi', $multi) - ->setParameter('likemulti', '%'.$clean_key_multi.'%'); + ->setParameter('likemulti', '%'.$clean_key_multi.'%') + ->setParameter('company_name', '%'.$searchData['multi'].'%'); // 会社名はスペースを除去せず検索 } // order_id_end From 328bacddb9f7854be2652e41422864718dc639fd Mon Sep 17 00:00:00 2001 From: hideki_okajima Date: Thu, 12 Nov 2020 17:46:02 +0900 Subject: [PATCH 5/5] =?UTF-8?q?OrderRepository=20=E3=81=AE=E5=90=8D?= =?UTF-8?q?=E5=89=8D=E3=81=AE=E6=A4=9C=E7=B4=A2=E3=81=AB=E9=96=A2=E3=81=99?= =?UTF-8?q?=E3=82=8B=E3=83=86=E3=82=B9=E3=83=88=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Tests/Repository/OrderRepositoryTest.php | 73 ++++++++++++++++++- 1 file changed, 71 insertions(+), 2 deletions(-) diff --git a/tests/Eccube/Tests/Repository/OrderRepositoryTest.php b/tests/Eccube/Tests/Repository/OrderRepositoryTest.php index c13a5eac521..1537878094d 100644 --- a/tests/Eccube/Tests/Repository/OrderRepositoryTest.php +++ b/tests/Eccube/Tests/Repository/OrderRepositoryTest.php @@ -14,8 +14,8 @@ namespace Eccube\Tests\Repository; use Eccube\Entity\Customer; -use Eccube\Entity\Order; use Eccube\Entity\Master\OrderStatus; +use Eccube\Entity\Order; use Eccube\Repository\OrderRepository; use Eccube\Tests\EccubeTestCase; @@ -125,7 +125,7 @@ public function testGetQueryBuilderBySearchDataForAdmin_multi_2147483648() $Order = $this->createOrder($this->createCustomer('2147483648@example.com')); $Order->setOrderStatus($this->entityManager->find(OrderStatus::class, OrderStatus::NEW)); $this->orderRepository->save($Order); - $this->entityManager->flush();; + $this->entityManager->flush(); $actual = $this->orderRepository->getQueryBuilderBySearchDataForAdmin(['multi' => '2147483648']) ->getQuery() @@ -133,4 +133,73 @@ public function testGetQueryBuilderBySearchDataForAdmin_multi_2147483648() self::assertEquals($Order, $actual[0]); } + + /** + * @dataProvider dataGetQueryBuilderBySearchDataForAdmin_nameProvider + */ + public function testGetQueryBuilderBySearchDataForAdmin_name(string $formName, string $searchWord, int $expected) + { + $this->Order + ->setOrderStatus($this->entityManager->find(OrderStatus::class, OrderStatus::NEW)) + ->setName01('姓') + ->setName02('名') + ->setKana01('セイ') + ->setKana02('メイ') + ->setCompanyName('株式会社 会社名'); // 全角スペース + $this->orderRepository->save($this->Order); + $this->entityManager->flush(); + + $actual = $this->orderRepository->getQueryBuilderBySearchDataForAdmin([$formName => $searchWord]) + ->getQuery() + ->getResult(); + + self::assertCount($expected, $actual); + } + + public function dataGetQueryBuilderBySearchDataForAdmin_nameProvider() + { + return [ + ['multi', '姓', 1], + ['multi', '名', 1], + ['multi', '姓名', 1], + ['multi', '姓 名', 1], + ['multi', '姓 名', 1], + ['multi', 'セイ', 1], + ['multi', 'メイ', 1], + ['multi', 'セイメイ', 1], + ['multi', 'セイ メイ', 1], + ['multi', 'セイ メイ', 1], + ['multi', '株式会社', 1], + ['multi', '会社名', 1], + ['multi', '株式会社会社名', 0], + ['multi', '株式会社 会社名', 0], // 半角スペース + ['multi', '株式会社 会社名', 1], // 全角スペース + ['multi', '石', 0], + ['multi', 'キューブ', 0], + ['multi', '姓 球部', 0], + ['multi', 'セイ 名', 0], + ['multi', '姓 メイ', 0], + ['name', '姓', 1], + ['name', '名', 1], + ['name', '姓名', 1], + ['name', '姓 名', 1], + ['name', '姓 名', 1], + ['name', 'セイ', 0], + ['name', '株式会社 会社名', 0], + ['kana', 'セイ', 1], + ['kana', 'メイ', 1], + ['kana', 'セイメイ', 1], + ['kana', 'セイ メイ', 1], + ['kana', 'セイ メイ', 1], + ['kana', '姓', 0], + ['kana', '株式会社 会社名', 0], + ['company_name', '株式会社', 1], + ['company_name', '会社名', 1], + ['company_name', '株式会社会社名', 0], + ['company_name', '株式会社 会社名', 0], // 半角スペース + ['company_name', '株式会社 会社名', 1], // 全角スペース + ['company_name', '姓', 0], + ['company_name', 'セイ', 0], + ]; + } }