EC-CUBE /
ec-cube
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | /* |
||
| 4 | * This file is part of EC-CUBE |
||
| 5 | * |
||
| 6 | * Copyright(c) 2000-2015 LOCKON CO.,LTD. All Rights Reserved. |
||
| 7 | * |
||
| 8 | * http://www.lockon.co.jp/ |
||
| 9 | * |
||
| 10 | * This program is free software; you can redistribute it and/or |
||
| 11 | * modify it under the terms of the GNU General Public License |
||
| 12 | * as published by the Free Software Foundation; either version 2 |
||
| 13 | * of the License, or (at your option) any later version. |
||
| 14 | * |
||
| 15 | * This program is distributed in the hope that it will be useful, |
||
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
| 18 | * GNU General Public License for more details. |
||
| 19 | * |
||
| 20 | * You should have received a copy of the GNU General Public License |
||
| 21 | * along with this program; if not, write to the Free Software |
||
| 22 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||
| 23 | */ |
||
| 24 | |||
| 25 | namespace Eccube\Repository; |
||
| 26 | |||
| 27 | use Eccube\Annotation\Repository; |
||
| 28 | use Eccube\Entity\Delivery; |
||
| 29 | use Eccube\Entity\Master\SaleType; |
||
| 30 | use Eccube\Entity\Payment; |
||
| 31 | |||
| 32 | /** |
||
| 33 | * DelivRepository |
||
| 34 | * |
||
| 35 | * This class was generated by the Doctrine ORM. Add your own custom |
||
| 36 | * repository methods below. |
||
| 37 | * |
||
| 38 | * @Repository |
||
| 39 | */ |
||
| 40 | class DeliveryRepository extends AbstractRepository |
||
| 41 | { |
||
| 42 | |||
| 43 | /** |
||
| 44 | * @deprecated 呼び出し元で制御する |
||
| 45 | * @param $id |
||
| 46 | * @return Delivery|null|object |
||
| 47 | 8 | */ |
|
| 48 | public function findOrCreate($id) |
||
| 49 | 8 | { |
|
| 50 | 8 | if ($id == 0) { |
|
| 51 | $em = $this->getEntityManager(); |
||
| 52 | |||
| 53 | 8 | $SaleType = $em |
|
| 54 | 8 | ->getRepository(SaleType::class) |
|
| 55 | ->findOneBy(array(), array('rank' => 'DESC')); |
||
| 56 | 8 | ||
| 57 | $Delivery = $this->findOneBy(array(), array('rank' => 'DESC')); |
||
| 58 | 8 | ||
| 59 | 8 | $rank = 1; |
|
| 60 | 8 | if ($Delivery) { |
|
| 61 | $rank = $Delivery->getRank() + 1; |
||
| 62 | } |
||
| 63 | 8 | ||
| 64 | $Delivery = new Delivery(); |
||
| 65 | 8 | $Delivery |
|
| 66 | 8 | ->setRank($rank) |
|
| 67 | 8 | ->setVisible(true) |
|
| 68 | ->setSaleType($SaleType); |
||
| 69 | } else { |
||
| 70 | $Delivery = $this->find($id); |
||
| 71 | } |
||
| 72 | 8 | ||
| 73 | return $Delivery; |
||
| 74 | } |
||
| 75 | |||
| 76 | /** |
||
|
0 ignored issues
–
show
introduced
by
Loading history...
|
|||
| 77 | * 複数の販売種別から配送業者を取得 |
||
| 78 | * |
||
| 79 | * @param $saleTypes |
||
|
0 ignored issues
–
show
|
|||
| 80 | * @return array |
||
| 81 | 20 | */ |
|
| 82 | public function getDeliveries($saleTypes) |
||
| 83 | 20 | { |
|
| 84 | 20 | $deliveries = $this->createQueryBuilder('d') |
|
| 85 | 20 | ->where('d.SaleType in (:saleTypes)') |
|
| 86 | 20 | ->andWhere('d.visible = :visible') |
|
| 87 | 20 | ->setParameter('saleTypes', $saleTypes) |
|
| 88 | 20 | ->setParameter('visible', true) |
|
| 89 | 20 | ->getQuery() |
|
| 90 | ->getResult(); |
||
| 91 | 20 | ||
| 92 | return $deliveries; |
||
| 93 | } |
||
| 94 | |||
| 95 | /** |
||
|
0 ignored issues
–
show
|
|||
| 96 | * 選択可能な配送業者を取得 |
||
| 97 | * |
||
| 98 | * @param $saleTypes |
||
|
0 ignored issues
–
show
|
|||
| 99 | * @param $payments |
||
|
0 ignored issues
–
show
|
|||
| 100 | 2 | * @return array |
|
| 101 | */ |
||
| 102 | public function findAllowedDeliveries($saleTypes, $payments) |
||
| 103 | 2 | { |
|
| 104 | 2 | ||
| 105 | $d = $this->getDeliveries($saleTypes); |
||
| 106 | 2 | $arr = array(); |
|
| 107 | 1 | ||
| 108 | foreach ($d as $Delivery) { |
||
| 109 | 1 | $paymentOptions = $Delivery->getPaymentOptions(); |
|
| 110 | 1 | ||
| 111 | foreach ($paymentOptions as $PaymentOption) { |
||
| 112 | foreach ($payments as $Payment) { |
||
| 113 | if ($PaymentOption->getPayment() instanceof Payment) { |
||
| 114 | 1 | if ($PaymentOption->getPayment()->getId() == $Payment['id']) { |
|
| 115 | $arr[$Delivery->getId()] = $Delivery; |
||
| 116 | break; |
||
| 117 | } |
||
| 118 | } |
||
| 119 | } |
||
| 120 | } |
||
| 121 | 2 | } |
|
| 122 | |||
| 123 | return array_values($arr); |
||
| 124 | } |
||
| 125 | } |
||
| 126 |