| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | /* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  |  * This file is part of EC-CUBE | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * Copyright(c) 2000-2015 LOCKON CO.,LTD. All Rights Reserved. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * http://www.lockon.co.jp/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  * This program is free software; you can redistribute it and/or | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  * modify it under the terms of the GNU General Public License | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  * as published by the Free Software Foundation; either version 2 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  * of the License, or (at your option) any later version. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  * This program is distributed in the hope that it will be useful, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |  * GNU General Public License for more details. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |  * You should have received a copy of the GNU General Public License | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |  * along with this program; if not, write to the Free Software | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  | namespace Eccube\Controller; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  | use Eccube\Application; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  | use Eccube\Common\Constant; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  | use Eccube\Entity\Customer; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  | use Eccube\Entity\CustomerAddress; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  | use Eccube\Entity\MailHistory; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  | use Eccube\Entity\ShipmentItem; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  | use Eccube\Entity\Shipping; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  | use Eccube\Event\EccubeEvents; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  | use Eccube\Event\EventArgs; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  | use Eccube\Exception\CartException; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  | use Symfony\Component\HttpFoundation\Request; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  | use Symfony\Component\HttpFoundation\Response; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  | use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  | use Symfony\Component\Validator\Constraints as Assert; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  | class ShoppingController extends AbstractController | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |      * @var string 非会員用セッションキー | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |     private $sessionKey = 'eccube.front.shopping.nonmember'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |      * @var string 非会員用セッションキー | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |     private $sessionCustomerAddressKey = 'eccube.front.shopping.nonmember.customeraddress'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |      * @var string 複数配送警告メッセージ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |     private $sessionMultipleKey = 'eccube.front.shopping.multiple'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |      * @var string 受注IDキー | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |     private $sessionOrderKey = 'eccube.front.shopping.order.id'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |      * 購入画面表示 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |      * @param Application $app | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |      * @param Request $request | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 | 20 |  |      * @return \Symfony\Component\HttpFoundation\RedirectResponse|Response | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 71 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 72 |  |  |     public function index(Application $app, Request $request) | 
            
                                                                        
                            
            
                                    
            
            
                | 73 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 74 |  |  |         $cartService = $app['eccube.service.cart']; | 
            
                                                                        
                            
            
                                    
            
            
                | 75 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 76 |  |  |         // カートチェック | 
            
                                                                        
                            
            
                                    
            
            
                | 77 |  |  |         if (!$cartService->isLocked()) { | 
            
                                                                        
                            
            
                                    
            
            
                | 78 |  |  |             // カートが存在しない、カートがロックされていない時はエラー | 
            
                                                                        
                            
            
                                    
            
            
                | 79 |  |  |             return $app->redirect($app->url('cart')); | 
            
                                                                        
                            
            
                                    
            
            
                | 80 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 81 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 82 |  |  |         // カートチェック | 
            
                                                                        
                            
            
                                    
            
            
                | 83 |  |  |         if (count($cartService->getCart()->getCartItems()) <= 0) { | 
            
                                                                        
                            
            
                                    
            
            
                | 84 |  |  |             // カートが存在しない時はエラー | 
            
                                                                        
                            
            
                                    
            
            
                | 85 |  |  |             return $app->redirect($app->url('cart')); | 
            
                                                                        
                            
            
                                    
            
            
                | 86 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 87 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 88 |  |  |         // 登録済みの受注情報を取得 | 
            
                                                                        
                            
            
                                    
            
            
                | 89 |  |  |         $Order = $app['eccube.service.shopping']->getOrder($app['config']['order_processing']); | 
            
                                                                        
                            
            
                                    
            
            
                | 90 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 91 |  |  |         // 初回アクセス(受注情報がない)の場合は, 受注情報を作成 | 
            
                                                                        
                            
            
                                    
            
            
                | 92 |  |  |         if (is_null($Order)) { | 
            
                                                                        
                            
            
                                    
            
            
                | 93 |  |  |             // 未ログインの場合, ログイン画面へリダイレクト. | 
            
                                                                        
                            
            
                                    
            
            
                | 94 |  |  |             if (!$app->isGranted('IS_AUTHENTICATED_FULLY')) { | 
            
                                                                        
                            
            
                                    
            
            
                | 95 |  |  |                 // 非会員でも一度会員登録されていればショッピング画面へ遷移 | 
            
                                                                        
                            
            
                                    
            
            
                | 96 |  |  |                 $Customer = $app['eccube.service.shopping']->getNonMember($this->sessionKey); | 
            
                                                                        
                            
            
                                    
            
            
                | 97 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 98 |  |  |                 if (is_null($Customer)) { | 
            
                                                                        
                            
            
                                    
            
            
                | 99 |  |  |                     return $app->redirect($app->url('shopping_login')); | 
            
                                                                        
                            
            
                                    
            
            
                | 100 |  |  |                 } | 
            
                                                                        
                            
            
                                    
            
            
                | 101 | 8 |  |             } else { | 
            
                                                                        
                            
            
                                    
            
            
                | 102 |  |  |                 $Customer = $app->user(); | 
            
                                                                        
                            
            
                                    
            
            
                | 103 |  |  |             } | 
            
                                                                        
                            
            
                                    
            
            
                | 104 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 105 |  |  |             try { | 
            
                                                                        
                            
            
                                    
            
            
                | 106 |  |  |                 // 受注情報を作成 | 
            
                                                                        
                            
            
                                    
            
            
                | 107 |  |  |                 $Order = $app['eccube.service.shopping']->createOrder($Customer); | 
            
                                                                        
                            
            
                                    
            
            
                | 108 |  |  |             } catch (CartException $e) { | 
            
                                                                        
                            
            
                                    
            
            
                | 109 | 17 |  |                 $app->addRequestError($e->getMessage()); | 
            
                                                                        
                            
            
                                    
            
            
                | 110 |  |  |                 return $app->redirect($app->url('cart')); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 111 |  |  |             } | 
            
                                                                        
                            
            
                                    
            
            
                | 112 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 113 |  |  |             // セッション情報を削除 | 
            
                                                                        
                            
            
                                    
            
            
                | 114 |  |  |             $app['session']->remove($this->sessionOrderKey); | 
            
                                                                        
                            
            
                                    
            
            
                | 115 |  |  |             $app['session']->remove($this->sessionMultipleKey); | 
            
                                                                        
                            
            
                                    
            
            
                | 116 |  |  |         } else { | 
            
                                                                        
                            
            
                                    
            
            
                | 117 | 17 |  |             // 計算処理 | 
            
                                                                        
                            
            
                                    
            
            
                | 118 |  |  |             $Order = $app['eccube.service.shopping']->getAmount($Order); | 
            
                                                                        
                            
            
                                    
            
            
                | 119 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 120 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 121 |  |  |         // 受注関連情報を最新状態に更新 | 
            
                                                                        
                            
            
                                    
            
            
                | 122 |  |  |         $app['orm.em']->refresh($Order); | 
            
                                                                        
                            
            
                                    
            
            
                | 123 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 124 |  |  |         // form作成 | 
            
                                                                        
                            
            
                                    
            
            
                | 125 |  |  |         $builder = $app['eccube.service.shopping']->getShippingFormBuilder($Order); | 
            
                                                                        
                            
            
                                    
            
            
                | 126 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 127 |  |  |         $event = new EventArgs( | 
            
                                                                        
                            
            
                                    
            
            
                | 128 |  |  |             array( | 
            
                                                                        
                            
            
                                    
            
            
                | 129 |  |  |                 'builder' => $builder, | 
            
                                                                        
                            
            
                                    
            
            
                | 130 |  |  |                 'Order' => $Order, | 
            
                                                                        
                            
            
                                    
            
            
                | 131 |  |  |             ), | 
            
                                                                        
                            
            
                                    
            
            
                | 132 |  |  |             $request | 
            
                                                                        
                            
            
                                    
            
            
                | 133 | 17 |  |         ); | 
            
                                                                        
                            
            
                                    
            
            
                | 134 | 17 |  |         $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_SHOPPING_INDEX_INITIALIZE, $event); | 
            
                                                                        
                            
            
                                    
            
            
                | 135 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 136 |  |  |         $form = $builder->getForm(); | 
            
                                                                        
                            
            
                                    
            
            
                | 137 | 20 |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 138 |  |  |         // 複数配送の場合、エラーメッセージを一度だけ表示 | 
            
                                                                        
                            
            
                                    
            
            
                | 139 |  |  |         if (!$app['session']->has($this->sessionMultipleKey)) { | 
            
                                                                        
                            
            
                                    
            
            
                | 140 |  |  |             if (count($Order->getShippings()) > 1) { | 
            
                                                                        
                            
            
                                    
            
            
                | 141 |  |  |                 $app->addRequestError('shopping.multiple.delivery'); | 
            
                                                                        
                            
            
                                    
            
            
                | 142 | 4 |  |             } | 
            
                                                                        
                            
            
                                    
            
            
                | 143 |  |  |             $app['session']->set($this->sessionMultipleKey, 'multiple'); | 
            
                                                                        
                            
            
                                    
            
            
                | 144 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 145 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 146 |  |  |         return $app->render('Shopping/index.twig', array( | 
            
                                                                        
                            
            
                                    
            
            
                | 147 |  |  |             'form' => $form->createView(), | 
            
                                                                        
                            
            
                                    
            
            
                | 148 |  |  |             'Order' => $Order, | 
            
                                                                        
                            
            
                                    
            
            
                | 149 |  |  |         )); | 
            
                                                                        
                            
            
                                    
            
            
                | 150 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  |     /** | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 | 4 |  |      * 購入処理 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  |      */ | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  |     public function confirm(Application $app, Request $request) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  |         $cartService = $app['eccube.service.cart']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  |         // カートチェック | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  |         if (!$cartService->isLocked()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  |             // カートが存在しない、カートがロックされていない時はエラー | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  |             return $app->redirect($app->url('cart')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  |         $Order = $app['eccube.service.shopping']->getOrder($app['config']['order_processing']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  |         if (!$Order) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  |             $app->addError('front.shopping.order.error'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  |             return $app->redirect($app->url('shopping_error')); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  |         if ('POST' !== $request->getMethod()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  |             return $app->redirect($app->url('cart')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 | 4 |  |         // form作成 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  |         $builder = $app['eccube.service.shopping']->getShippingFormBuilder($Order); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  |         $event = new EventArgs( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  |             array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  |                 'builder' => $builder, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  |                 'Order' => $Order, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  |             ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  |             $request | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  |         $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_SHOPPING_CONFIRM_INITIALIZE, $event); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  |         $form = $builder->getForm(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  |         $form->handleRequest($request); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  |         if ($form->isSubmitted() && $form->isValid()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  |             $data = $form->getData(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 |  |  |             // トランザクション制御 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  |             $em = $app['orm.em']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 |  |  |             $em->getConnection()->beginTransaction(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  |             try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  |                 // 商品公開ステータスチェック、商品制限数チェック、在庫チェック | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 |  |  |                 $check = $app['eccube.service.shopping']->isOrderProduct($em, $Order); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  |                 if (!$check) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 |  |  |                     $em->getConnection()->rollback(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 | 4 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 |  |  |                     $app->addError('front.shopping.stock.error'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 |  |  |                     return $app->redirect($app->url('shopping_error')); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  |                 // 受注情報、配送情報を更新 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  |                 $app['eccube.service.shopping']->setOrderUpdate($Order, $data); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  |                 // 在庫情報を更新 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 |  |  |                 $app['eccube.service.shopping']->setStockUpdate($em, $Order); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  |                 if ($app->isGranted('ROLE_USER')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 |  |  |                     // 会員の場合、購入金額を更新 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 |  |  |                     $app['eccube.service.shopping']->setCustomerUpdate($Order, $app->user()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 | 4 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 | 4 |  |                 $em->flush(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 | 4 |  |                 $em->getConnection()->commit(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 |  |  |             } catch (\Exception $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 |  |  |                 $em->getConnection()->rollback(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 |  |  |                 $app->log($e); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 | 4 |  |                 $app->addError('front.shopping.system.error'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 226 | 4 |  |                 return $app->redirect($app->url('shopping_error')); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 |  |  |             // カート削除 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 230 |  |  |             $app['eccube.service.cart']->clear()->save(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 231 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 232 |  |  |             $event = new EventArgs( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 233 |  |  |                 array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 234 |  |  |                     'form' => $form, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 235 |  |  |                     'Order' => $Order, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 236 |  |  |                 ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 237 |  |  |                 $request | 
            
                                                                                                            
                            
            
                                    
            
            
                | 238 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 239 |  |  |             $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_SHOPPING_CONFIRM_PROCESSING, $event); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 240 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 241 | 4 |  |             if ($event->getResponse() !== null) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 242 |  |  |                 return $event->getResponse(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 243 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 244 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 245 |  |  |             // メール送信 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 246 |  |  |             $app['eccube.service.mail']->sendOrderMail($Order); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 247 | 1 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 248 |  |  |             // 受注IDをセッションにセット | 
            
                                                                                                            
                            
            
                                    
            
            
                | 249 |  |  |             $app['session']->set($this->sessionOrderKey, $Order->getId()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 250 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 251 |  |  |             // 送信履歴を保存. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 252 |  |  |             $MailTemplate = $app['eccube.repository.mail_template']->find(1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 253 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 254 |  |  |             $body = $app->renderView($MailTemplate->getFileName(), array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 255 | 1 |  |                 'header' => $MailTemplate->getHeader(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 256 |  |  |                 'footer' => $MailTemplate->getFooter(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 257 |  |  |                 'Order' => $Order, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 258 | 1 |  |             )); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 259 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 260 |  |  |             $MailHistory = new MailHistory(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 261 |  |  |             $MailHistory | 
            
                                                                                                            
                            
            
                                    
            
            
                | 262 |  |  |                 ->setSubject('[' . $app['eccube.repository.base_info']->get()->getShopName() . '] ' . $MailTemplate->getSubject()) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 263 |  |  |                 ->setMailBody($body) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 264 | 3 |  |                 ->setMailTemplate($MailTemplate) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 265 |  |  |                 ->setSendDate(new \DateTime()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 266 |  |  |                 ->setOrder($Order); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 267 |  |  |             $app['orm.em']->persist($MailHistory); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 268 |  |  |             $app['orm.em']->flush($MailHistory); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 269 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 270 |  |  |             $event = new EventArgs( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 271 |  |  |                 array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 272 |  |  |                     'form' => $form, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 273 | 3 |  |                     'Order' => $Order, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 274 |  |  |                     'MailHistory' => $MailHistory, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 275 |  |  |                 ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 276 |  |  |                 $request | 
            
                                                                                                            
                            
            
                                    
            
            
                | 277 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 278 |  |  |             $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_SHOPPING_CONFIRM_COMPLETE, $event); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 279 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 280 |  |  |             if ($event->getResponse() !== null) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 281 |  |  |                 return $event->getResponse(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 282 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 283 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 284 |  |  |             // 完了画面表示 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 285 |  |  |             return $app->redirect($app->url('shopping_complete')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 286 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 287 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 288 | 1 |  |         return $app->render('Shopping/index.twig', array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 289 |  |  |             'form' => $form->createView(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 290 | 1 |  |             'Order' => $Order, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 291 |  |  |         )); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 292 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 293 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 294 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 295 |  |  |     /** | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 296 | 1 |  |      * 購入完了画面表示 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 297 |  |  |      */ | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 298 |  |  |     public function complete(Application $app, Request $request) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 299 | 1 |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 300 |  |  |         // 受注IDを取得 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 301 |  |  |         $orderId = $app['session']->get($this->sessionOrderKey); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 302 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 303 |  |  |         $event = new EventArgs( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 304 |  |  |             array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 305 |  |  |                 'orderId' => $orderId, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 306 |  |  |             ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 307 |  |  |             $request | 
            
                                                                                                            
                            
            
                                    
            
            
                | 308 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 309 |  |  |         $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_SHOPPING_COMPLETE_INITIALIZE, $event); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 310 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 311 |  |  |         if ($event->getResponse() !== null) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 312 |  |  |             return $event->getResponse(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 313 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 314 | 1 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 315 | 1 |  |         // 受注IDセッションを削除 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 316 |  |  |         $app['session']->remove($this->sessionOrderKey); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 317 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 318 |  |  |         return $app->render('Shopping/complete.twig', array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 319 |  |  |             'orderId' => $orderId, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 320 |  |  |         )); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 321 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 322 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 323 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 324 |  |  |     /** | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 325 |  |  |      * 配送業者選択処理 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 326 |  |  |      */ | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 327 |  |  |     public function delivery(Application $app, Request $request) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 328 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 329 |  |  |         // カートチェック | 
            
                                                                                                            
                            
            
                                    
            
            
                | 330 |  |  |         if (!$app['eccube.service.cart']->isLocked()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 331 |  |  |             // カートが存在しない、カートがロックされていない時はエラー | 
            
                                                                                                            
                            
            
                                    
            
            
                | 332 |  |  |             return $app->redirect($app->url('cart')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 333 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 334 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 335 | 2 |  |         $Order = $app['eccube.service.shopping']->getOrder($app['config']['order_processing']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 336 | 2 |  |         if (!$Order) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 337 |  |  |             $app->addError('front.shopping.order.error'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 338 |  |  |             return $app->redirect($app->url('shopping_error')); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 339 | 3 |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 340 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 341 |  |  |         if ('POST' !== $request->getMethod()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 342 |  |  |             return $app->redirect($app->url('shopping')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 343 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 344 | 2 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 345 |  |  |         $builder = $app['eccube.service.shopping']->getShippingFormBuilder($Order); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 346 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 347 | 2 |  |         $event = new EventArgs( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 348 |  |  |             array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 349 |  |  |                 'builder' => $builder, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 350 |  |  |                 'Order' => $Order, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 351 |  |  |             ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 352 |  |  |             $request | 
            
                                                                                                            
                            
            
                                    
            
            
                | 353 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 354 |  |  |         $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_SHOPPING_DELIVERY_INITIALIZE, $event); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 355 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 356 |  |  |         $form = $builder->getForm(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 357 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 358 |  |  |         $form->handleRequest($request); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 359 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 360 |  |  |         if ($form->isSubmitted() && $form->isValid()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 361 | 1 |  |             $data = $form->getData(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 362 | 1 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 363 |  |  |             $shippings = $data['shippings']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 364 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 365 |  |  |             $productDeliveryFeeTotal = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 366 |  |  |             $BaseInfo = $app['eccube.repository.base_info']->get(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 367 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 368 |  |  |             foreach ($shippings as $Shipping) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 369 |  |  |                 $Delivery = $Shipping->getDelivery(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 370 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 371 |  |  |                 if ($Delivery) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 372 |  |  |                     $deliveryFee = $app['eccube.repository.delivery_fee']->findOneBy(array( | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 373 |  |  |                         'Delivery' => $Delivery, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 374 |  |  |                         'Pref' => $Shipping->getPref() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 375 |  |  |                     )); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 376 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 377 |  |  |                     // 商品ごとの配送料合計 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 378 |  |  |                     if (!is_null($BaseInfo->getOptionProductDeliveryFee())) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 379 |  |  |                         $productDeliveryFeeTotal += $app['eccube.service.shopping']->getProductDeliveryFee($Shipping); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 380 | 1 |  |                     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 381 | 1 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 382 |  |  |                     $Shipping->setDeliveryFee($deliveryFee); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 383 |  |  |                     $Shipping->setShippingDeliveryFee($deliveryFee->getFee() + $productDeliveryFeeTotal); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 384 | 2 |  |                     $Shipping->setShippingDeliveryName($Delivery->getName()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 385 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 386 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 387 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 388 |  |  |             // 支払い情報をセット | 
            
                                                                                                            
                            
            
                                    
            
            
                | 389 | 3 |  |             $payment = $data['payment']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 390 |  |  |             $message = $data['message']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 391 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 392 | 3 |  |             $Order->setPayment($payment); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 393 |  |  |             $Order->setPaymentMethod($payment->getMethod()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 394 |  |  |             $Order->setMessage($message); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 395 |  |  |             $Order->setCharge($payment->getCharge()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 396 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 397 |  |  |             $Order->setDeliveryFeeTotal($app['eccube.service.shopping']->getShippingDeliveryFeeTotal($shippings)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 398 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 399 |  |  |             $total = $Order->getSubTotal() + $Order->getCharge() + $Order->getDeliveryFeeTotal(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 400 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 401 |  |  |             $Order->setTotal($total); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 402 |  |  |             $Order->setPaymentTotal($total); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 403 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 404 |  |  |             // 受注関連情報を最新状態に更新 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 405 |  |  |             $app['orm.em']->flush(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 406 | 3 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 407 |  |  |             $event = new EventArgs( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 408 |  |  |                 array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 409 |  |  |                     'form' => $form, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 410 |  |  |                     'Order' => $Order, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 411 |  |  |                 ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 412 |  |  |                 $request | 
            
                                                                                                            
                            
            
                                    
            
            
                | 413 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 414 |  |  |             $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_SHOPPING_DELIVERY_COMPLETE, $event); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 415 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 416 |  |  |             return $app->redirect($app->url('shopping')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 417 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 418 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 419 | 3 |  |         return $app->render('Shopping/index.twig', array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 420 |  |  |             'form' => $form->createView(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 421 |  |  |             'Order' => $Order, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 422 |  |  |         )); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 423 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 424 | 2 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 425 |  |  |     /** | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 426 |  |  |      * 支払い方法選択処理 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 427 |  |  |      */ | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 428 |  |  |     public function payment(Application $app, Request $request) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 429 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 430 |  |  |         $Order = $app['eccube.service.shopping']->getOrder($app['config']['order_processing']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 431 |  |  |         if (!$Order) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 432 |  |  |             $app->addError('front.shopping.order.error'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 433 |  |  |             return $app->redirect($app->url('shopping_error')); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 434 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 435 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 436 |  |  |         if ('POST' !== $request->getMethod()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 437 |  |  |             return $app->redirect($app->url('shopping')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 438 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 439 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 440 |  |  |         $builder = $app['eccube.service.shopping']->getShippingFormBuilder($Order); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 441 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 442 |  |  |         $event = new EventArgs( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 443 |  |  |             array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 444 |  |  |                 'builder' => $builder, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 445 |  |  |                 'Order' => $Order, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 446 |  |  |             ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 447 |  |  |             $request | 
            
                                                                                                            
                            
            
                                    
            
            
                | 448 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 449 |  |  |         $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_SHOPPING_PAYMENT_INITIALIZE, $event); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 450 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 451 |  |  |         $form = $builder->getForm(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 452 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 453 |  |  |         $form->handleRequest($request); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 454 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 455 |  |  |         if ($form->isSubmitted() && $form->isValid()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 456 |  |  |             $data = $form->getData(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 457 |  |  |             $payment = $data['payment']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 458 |  |  |             $message = $data['message']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 459 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 460 |  |  |             $Order->setPayment($payment); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 461 |  |  |             $Order->setPaymentMethod($payment->getMethod()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 462 |  |  |             $Order->setMessage($message); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 463 |  |  |             $Order->setCharge($payment->getCharge()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 464 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 465 |  |  |             $total = $Order->getSubTotal() + $Order->getCharge() + $Order->getDeliveryFeeTotal(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 466 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 467 |  |  |             $Order->setTotal($total); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 468 |  |  |             $Order->setPaymentTotal($total); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 469 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 470 |  |  |             // 受注関連情報を最新状態に更新 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 471 |  |  |             $app['orm.em']->flush(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 472 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 473 |  |  |             $event = new EventArgs( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 474 |  |  |                 array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 475 |  |  |                     'form' => $form, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 476 |  |  |                     'Order' => $Order, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 477 |  |  |                 ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 478 |  |  |                 $request | 
            
                                                                                                            
                            
            
                                    
            
            
                | 479 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 480 |  |  |             $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_SHOPPING_PAYMENT_COMPLETE, $event); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 481 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 482 | 2 |  |             return $app->redirect($app->url('shopping')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 483 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 484 | 2 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 485 |  |  |         return $app->render('Shopping/index.twig', array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 486 | 2 |  |             'form' => $form->createView(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 487 |  |  |             'Order' => $Order, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 488 |  |  |         )); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 489 | 2 |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 490 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 491 |  |  |     /** | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 492 |  |  |      * お届け先変更がクリックされた場合の処理 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 493 |  |  |      */ | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 494 | 5 | View Code Duplication |     public function shippingChange(Application $app, Request $request, $id) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 495 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 496 |  |  |         $Order = $app['eccube.service.shopping']->getOrder($app['config']['order_processing']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 497 | 5 |  |         if (!$Order) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 498 |  |  |             $app->addError('front.shopping.order.error'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 499 |  |  |             return $app->redirect($app->url('shopping_error')); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 500 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 501 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 502 |  |  |         if ('POST' !== $request->getMethod()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 503 |  |  |             return $app->redirect($app->url('shopping')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 504 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 505 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 506 |  |  |         $builder = $app['eccube.service.shopping']->getShippingFormBuilder($Order); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 507 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 508 |  |  |         $event = new EventArgs( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 509 |  |  |             array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 510 |  |  |                 'builder' => $builder, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 511 | 3 |  |                 'Order' => $Order, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 512 |  |  |             ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 513 |  |  |             $request | 
            
                                                                                                            
                            
            
                                    
            
            
                | 514 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 515 |  |  |         $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_SHOPPING_INDEX_INITIALIZE, $event); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 516 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 517 |  |  |         $form = $builder->getForm(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 518 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 519 |  |  |         $form->handleRequest($request); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 520 | 1 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 521 | 1 |  |         if ($form->isSubmitted() && $form->isValid()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 522 |  |  |             $data = $form->getData(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 523 |  |  |             $message = $data['message']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 524 | 5 |  |             $Order->setMessage($message); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 525 |  |  |             // 受注情報を更新 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 526 |  |  |             $app['orm.em']->flush(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 527 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 528 |  |  |             // お届け先設定一覧へリダイレクト | 
            
                                                                                                            
                            
            
                                    
            
            
                | 529 | 2 |  |             return $app->redirect($app->url('shopping_shipping', array('id' => $id))); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 530 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 531 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 532 |  |  |         return $app->render('Shopping/index.twig', array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 533 |  |  |             'form' => $form->createView(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 534 |  |  |             'Order' => $Order, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 535 |  |  |         )); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 536 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 537 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 538 |  |  |     /** | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 539 |  |  |      * お届け先の設定一覧からの選択 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 540 |  |  |      */ | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 541 |  |  |     public function shipping(Application $app, Request $request, $id) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 542 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 543 |  |  |         // カートチェック | 
            
                                                                                                            
                            
            
                                    
            
            
                | 544 |  |  |         if (!$app['eccube.service.cart']->isLocked()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 545 |  |  |             // カートが存在しない、カートがロックされていない時はエラー | 
            
                                                                                                            
                            
            
                                    
            
            
                | 546 |  |  |             return $app->redirect($app->url('cart')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 547 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 548 | 2 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 549 |  |  |         if ('POST' === $request->getMethod()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 550 |  |  |             $address = $request->get('address'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 551 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 552 |  |  |             if (is_null($address)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 553 |  |  |                 // 選択されていなければエラー | 
            
                                                                                                            
                            
            
                                    
            
            
                | 554 | 2 |  |                 return $app->render( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 555 |  |  |                     'Shopping/shipping.twig', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 556 |  |  |                     array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 557 |  |  |                         'Customer' => $app->user(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 558 |  |  |                         'shippingId' => $id, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 559 |  |  |                         'error' => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 560 |  |  |                     ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 561 |  |  |                 ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 562 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 563 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 564 |  |  |             // 選択されたお届け先情報を取得 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 565 |  |  |             $CustomerAddress = $app['eccube.repository.customer_address']->findOneBy(array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 566 |  |  |                 'Customer' => $app->user(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 567 |  |  |                 'id' => $address, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 568 |  |  |             )); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 569 |  |  |             if (is_null($CustomerAddress)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 570 |  |  |                 throw new NotFoundHttpException(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 571 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 572 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 573 |  |  |             $Order = $app['eccube.service.shopping']->getOrder($app['config']['order_processing']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 574 |  |  |             if (!$Order) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 575 |  |  |                 $app->addError('front.shopping.order.error'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 576 | 2 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 577 |  |  |                 return $app->redirect($app->url('shopping_error')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 578 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 579 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 580 |  |  |             $Shipping = $Order->findShipping($id); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 581 |  |  |             if (!$Shipping) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 582 |  |  |                 throw new NotFoundHttpException(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 583 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 584 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 585 |  |  |             // お届け先情報を更新 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 586 |  |  |             $Shipping | 
            
                                                                                                            
                            
            
                                    
            
            
                | 587 |  |  |                 ->setFromCustomerAddress($CustomerAddress); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 588 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 589 | 2 |  |             // 配送料金の設定 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 590 | 2 |  |             $app['eccube.service.shopping']->setShippingDeliveryFee($Shipping); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 591 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 592 |  |  |             // 配送先を更新 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 593 | 2 |  |             $app['orm.em']->flush(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 594 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 595 |  |  |             $event = new EventArgs( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 596 |  |  |                 array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 597 |  |  |                     'Order' => $Order, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 598 |  |  |                     'shippingId' => $id, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 599 |  |  |                 ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 600 |  |  |                 $request | 
            
                                                                                                            
                            
            
                                    
            
            
                | 601 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 602 |  |  |             $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_SHOPPING_SHIPPING_COMPLETE, $event); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 603 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 604 |  |  |             return $app->redirect($app->url('shopping')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 605 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 606 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 607 |  |  |         return $app->render( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 608 |  |  |             'Shopping/shipping.twig', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 609 |  |  |             array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 610 |  |  |                 'Customer' => $app->user(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 611 |  |  |                 'shippingId' => $id, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 612 |  |  |                 'error' => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 613 |  |  |             ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 614 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 615 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 616 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 617 |  |  |     /** | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 618 |  |  |      * お届け先の設定(非会員)がクリックされた場合の処理 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 619 |  |  |      */ | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 620 |  | View Code Duplication |     public function shippingEditChange(Application $app, Request $request, $id) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 621 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 622 |  |  |         $Order = $app['eccube.service.shopping']->getOrder($app['config']['order_processing']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 623 |  |  |         if (!$Order) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 624 |  |  |             $app->addError('front.shopping.order.error'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 625 |  |  |             return $app->redirect($app->url('shopping_error')); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 626 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 627 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 628 |  |  |         if ('POST' !== $request->getMethod()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 629 |  |  |             return $app->redirect($app->url('shopping')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 630 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 631 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 632 |  |  |         $builder = $app['eccube.service.shopping']->getShippingFormBuilder($Order); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 633 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 634 |  |  |         $event = new EventArgs( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 635 |  |  |             array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 636 |  |  |                 'builder' => $builder, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 637 |  |  |                 'Order' => $Order, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 638 |  |  |             ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 639 |  |  |             $request | 
            
                                                                                                            
                            
            
                                    
            
            
                | 640 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 641 |  |  |         $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_SHOPPING_INDEX_INITIALIZE, $event); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 642 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 643 |  |  |         $form = $builder->getForm(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 644 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 645 |  |  |         $form->handleRequest($request); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 646 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 647 |  |  |         if ($form->isSubmitted() && $form->isValid()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 648 |  |  |             $data = $form->getData(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 649 |  |  |             $message = $data['message']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 650 |  |  |             $Order->setMessage($message); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 651 |  |  |             // 受注情報を更新 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 652 |  |  |             $app['orm.em']->flush(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 653 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 654 |  |  |             // お届け先設定一覧へリダイレクト | 
            
                                                                                                            
                            
            
                                    
            
            
                | 655 |  |  |             return $app->redirect($app->url('shopping_shipping_edit', array('id' => $id))); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 656 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 657 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 658 |  |  |         return $app->render('Shopping/index.twig', array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 659 |  |  |             'form' => $form->createView(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 660 |  |  |             'Order' => $Order, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 661 |  |  |         )); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 662 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 663 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 664 |  |  |     /** | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 665 | 2 |  |      * お届け先の設定(非会員でも使用する) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 666 |  |  |      */ | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 667 |  |  |     public function shippingEdit(Application $app, Request $request, $id) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 668 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 669 |  |  |         // 配送先住所最大値判定 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 670 |  |  |         $Customer = $app->user(); | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 671 |  | View Code Duplication |         if ($app->isGranted('IS_AUTHENTICATED_FULLY')) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 672 |  |  |             $addressCurrNum = count($app->user()->getCustomerAddresses()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 673 |  |  |             $addressMax = $app['config']['deliv_addr_max']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 674 |  |  |             if ($addressCurrNum >= $addressMax) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 675 |  |  |                 throw new NotFoundHttpException(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 676 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 677 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 678 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 679 |  |  |         // カートチェック | 
            
                                                                                                            
                            
            
                                    
            
            
                | 680 |  |  |         if (!$app['eccube.service.cart']->isLocked()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 681 |  |  |             // カートが存在しない、カートがロックされていない時はエラー | 
            
                                                                                                            
                            
            
                                    
            
            
                | 682 |  |  |             return $app->redirect($app->url('cart')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 683 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 684 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 685 |  |  |         $Order = $app['eccube.service.shopping']->getOrder($app['config']['order_processing']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 686 |  |  |         if (!$Order) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 687 |  |  |             $app->addError('front.shopping.order.error'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 688 |  |  |             return $app->redirect($app->url('shopping_error')); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 689 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 690 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 691 | 2 |  |         $Shipping = $Order->findShipping($id); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 692 |  |  |         if (!$Shipping) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 693 |  |  |             throw new NotFoundHttpException(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 694 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 695 |  |  |         if ($app->isGranted('IS_AUTHENTICATED_FULLY')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 696 | 12 |  |             $Shipping->clearCustomerAddress(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 697 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 698 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 699 |  |  |         $CustomerAddress = new CustomerAddress(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 700 |  |  |         if ($app->isGranted('IS_AUTHENTICATED_FULLY')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 701 |  |  |             $CustomerAddress->setCustomer($Customer); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 702 |  |  |         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 703 |  |  |             $CustomerAddress->setFromShipping($Shipping); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 704 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 705 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 706 |  |  |         $builder = $app['form.factory']->createBuilder('shopping_shipping', $CustomerAddress); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 707 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 708 |  |  |         $event = new EventArgs( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 709 |  |  |             array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 710 |  |  |                 'builder' => $builder, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 711 |  |  |                 'Order' => $Order, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 712 |  |  |                 'Shipping' => $Shipping, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 713 |  |  |                 'CustomerAddress' => $CustomerAddress, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 714 |  |  |             ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 715 |  |  |             $request | 
            
                                                                                                            
                            
            
                                    
            
            
                | 716 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 717 |  |  |         $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_SHOPPING_SHIPPING_EDIT_INITIALIZE, $event); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 718 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 719 |  |  |         $form = $builder->getForm(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 720 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 721 |  |  |         $form->handleRequest($request); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 722 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 723 |  | View Code Duplication |         if ($form->isSubmitted() && $form->isValid()) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 724 | 9 |  |             // 会員の場合、お届け先情報を新規登録 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 725 | 9 |  |             $Shipping->setFromCustomerAddress($CustomerAddress); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 726 | 9 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 727 | 9 |  |             if ($Customer instanceof Customer) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 728 | 9 |  |                 $app['orm.em']->persist($CustomerAddress); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 729 | 9 |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 730 | 9 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 731 | 9 |  |             // 配送料金の設定 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 732 | 9 |  |             $app['eccube.service.shopping']->setShippingDeliveryFee($Shipping); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 733 | 9 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 734 | 9 |  |             // 配送先を更新  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 735 | 9 |  |             $app['orm.em']->flush(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 736 | 9 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 737 | 9 |  |             $event = new EventArgs( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 738 |  |  |                 array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 739 |  |  |                     'form' => $form, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 740 |  |  |                     'Shipping' => $Shipping, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 741 |  |  |                     'CustomerAddress' => $CustomerAddress, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 742 |  |  |                 ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 743 | 9 |  |                 $request | 
            
                                                                                                            
                            
            
                                    
            
            
                | 744 | 9 |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 745 | 9 |  |             $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_SHOPPING_SHIPPING_EDIT_COMPLETE, $event); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 746 | 9 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 747 | 9 |  |             return $app->redirect($app->url('shopping')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 748 | 9 |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 749 | 9 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 750 | 9 |  |         return $app->render('Shopping/shipping_edit.twig', array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 751 | 9 |  |             'form' => $form->createView(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 752 | 9 |  |             'shippingId' => $id, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 753 | 9 |  |         )); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 754 | 9 |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 755 | 9 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 756 | 9 |  |     /** | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 757 | 9 |  |      * お客様情報の変更(非会員) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 758 |  |  |      */ | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 759 |  |  |     public function customer(Application $app, Request $request) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 760 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 761 |  |  |         if ($request->isXmlHttpRequest()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 762 |  |  |             try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 763 |  |  |                 $data = $request->request->all(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 764 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 765 |  |  |                 // 入力チェック | 
            
                                                                                                            
                            
            
                                    
            
            
                | 766 |  |  |                 $errors = $this->customerValidation($app, $data); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 767 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 768 |  |  |                 foreach ($errors as $error) { | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 769 |  | View Code Duplication |                     if ($error->count() != 0) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 770 |  |  |                         $response = new Response(json_encode('NG'), 400); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 771 |  |  |                         $response->headers->set('Content-Type', 'application/json'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 772 |  |  |                         return $response; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 773 | 9 |  |                     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 774 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 775 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 776 |  |  |                 $pref = $app['eccube.repository.master.pref']->findOneBy(array('name' => $data['customer_pref'])); | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 777 | 9 | View Code Duplication |                 if (!$pref) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 778 | 9 |  |                     $response = new Response(json_encode('NG'), 400); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 779 |  |  |                     $response->headers->set('Content-Type', 'application/json'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 780 |  |  |                     return $response; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 781 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 782 | 9 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 783 | 9 |  |                 $Order = $app['eccube.service.shopping']->getOrder($app['config']['order_processing']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 784 |  |  |                 if (!$Order) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 785 |  |  |                     $app->addError('front.shopping.order.error'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 786 |  |  |                     return $app->redirect($app->url('shopping_error')); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 787 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 788 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 789 | 1 |  |                 $Order | 
            
                                                                                                            
                            
            
                                    
            
            
                | 790 | 1 |  |                     ->setName01($data['customer_name01']) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 791 |  |  |                     ->setName02($data['customer_name02']) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 792 | 12 |  |                     ->setCompanyName($data['customer_company_name']) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 793 |  |  |                     ->setTel01($data['customer_tel01']) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 794 |  |  |                     ->setTel02($data['customer_tel02']) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 795 |  |  |                     ->setTel03($data['customer_tel03']) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 796 |  |  |                     ->setZip01($data['customer_zip01']) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 797 |  |  |                     ->setZip02($data['customer_zip02']) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 798 |  |  |                     ->setZipCode($data['customer_zip01'] . $data['customer_zip02']) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 799 |  |  |                     ->setPref($pref) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 800 |  |  |                     ->setAddr01($data['customer_addr01']) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 801 |  |  |                     ->setAddr02($data['customer_addr02']) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 802 |  |  |                     ->setEmail($data['customer_email']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 803 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 804 |  |  |                 // 配送先を更新 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 805 |  |  |                 $app['orm.em']->flush(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 806 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 807 |  |  |                 // 受注関連情報を最新状態に更新 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 808 |  |  |                 $app['orm.em']->refresh($Order); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 809 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 810 |  |  |                 $event = new EventArgs( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 811 |  |  |                     array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 812 |  |  |                         'Order' => $Order, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 813 |  |  |                         'data' => $data, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 814 |  |  |                     ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 815 |  |  |                     $request | 
            
                                                                                                            
                            
            
                                    
            
            
                | 816 |  |  |                 ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 817 |  |  |                 $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_SHOPPING_CUSTOMER_INITIALIZE, $event); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 818 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 819 |  |  |                 $response = new Response(json_encode('OK')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 820 |  |  |                 $response->headers->set('Content-Type', 'application/json'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 821 |  |  |             } catch (\Exception $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 822 |  |  |                 $app['monolog']->error($e); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 823 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 824 |  |  |                 $response = new Response(json_encode('NG'), 500); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 825 |  |  |                 $response->headers->set('Content-Type', 'application/json'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 826 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 827 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 828 |  |  |             return $response; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 829 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 830 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 831 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 832 |  |  |     /** | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 833 |  |  |      * ログイン | 
            
                                                                                                            
                            
            
                                    
            
            
                | 834 |  |  |      */ | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 835 |  |  |     public function login(Application $app, Request $request) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 836 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 837 |  |  |         if (!$app['eccube.service.cart']->isLocked()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 838 |  |  |             return $app->redirect($app->url('cart')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 839 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 840 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 841 |  |  |         if ($app->isGranted('IS_AUTHENTICATED_FULLY')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 842 |  |  |             return $app->redirect($app->url('shopping')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 843 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 844 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 845 |  |  |         /* @var $form \Symfony\Component\Form\FormInterface */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 846 |  |  |         $builder = $app['form.factory']->createNamedBuilder('', 'customer_login'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 847 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 848 |  | View Code Duplication |         if ($app->isGranted('IS_AUTHENTICATED_REMEMBERED')) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 849 |  |  |             $Customer = $app->user(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 850 |  |  |             if ($Customer) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 851 |  |  |                 $builder->get('login_email')->setData($Customer->getEmail()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 852 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 853 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 854 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 855 |  |  |         $event = new EventArgs( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 856 |  |  |             array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 857 |  |  |                 'builder' => $builder, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 858 |  |  |             ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 859 |  |  |             $request | 
            
                                                                                                            
                            
            
                                    
            
            
                | 860 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 861 |  |  |         $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_SHOPPING_LOGIN_INITIALIZE, $event); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 862 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 863 |  |  |         $form = $builder->getForm(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 864 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 865 |  |  |         return $app->render('Shopping/login.twig', array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 866 |  |  |             'error' => $app['security.last_error']($request), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 867 |  |  |             'form' => $form->createView(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 868 |  |  |         )); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 869 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 870 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 871 |  |  |     /** | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 872 |  |  |      * 非会員処理 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 873 |  |  |      */ | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 874 |  |  |     public function nonmember(Application $app, Request $request) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 875 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 876 |  |  |         $cartService = $app['eccube.service.cart']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 877 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 878 |  |  |         // カートチェック | 
            
                                                                                                            
                            
            
                                    
            
            
                | 879 |  |  |         if (!$cartService->isLocked()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 880 |  |  |             // カートが存在しない、カートがロックされていない時はエラー | 
            
                                                                                                            
                            
            
                                    
            
            
                | 881 |  |  |             return $app->redirect($app->url('cart')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 882 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 883 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 884 |  |  |         // ログイン済みの場合は, 購入画面へリダイレクト. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 885 |  |  |         if ($app->isGranted('ROLE_USER')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 886 |  |  |             return $app->redirect($app->url('shopping')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 887 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 888 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 889 |  |  |         // カートチェック | 
            
                                                                                                            
                            
            
                                    
            
            
                | 890 |  |  |         if (count($cartService->getCart()->getCartItems()) <= 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 891 |  |  |             // カートが存在しない時はエラー | 
            
                                                                                                            
                            
            
                                    
            
            
                | 892 |  |  |             return $app->redirect($app->url('cart')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 893 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 894 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 895 |  |  |         $builder = $app['form.factory']->createBuilder('nonmember'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 896 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 897 |  |  |         $event = new EventArgs( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 898 |  |  |             array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 899 |  |  |                 'builder' => $builder, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 900 |  |  |             ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 901 |  |  |             $request | 
            
                                                                                                            
                            
            
                                    
            
            
                | 902 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 903 |  |  |         $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_SHOPPING_NONMEMBER_INITIALIZE, $event); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 904 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 905 |  |  |         $form = $builder->getForm(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 906 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 907 |  |  |         $form->handleRequest($request); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 908 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 909 |  |  |         if ($form->isSubmitted() && $form->isValid()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 910 |  |  |             $data = $form->getData(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 911 |  |  |             $Customer = new Customer(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 912 |  |  |             $Customer | 
            
                                                                                                            
                            
            
                                    
            
            
                | 913 |  |  |                 ->setName01($data['name01']) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 914 |  |  |                 ->setName02($data['name02']) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 915 |  |  |                 ->setKana01($data['kana01']) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 916 |  |  |                 ->setKana02($data['kana02']) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 917 |  |  |                 ->setCompanyName($data['company_name']) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 918 |  |  |                 ->setEmail($data['email']) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 919 |  |  |                 ->setTel01($data['tel01']) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 920 |  |  |                 ->setTel02($data['tel02']) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 921 |  |  |                 ->setTel03($data['tel03']) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 922 |  |  |                 ->setZip01($data['zip01']) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 923 |  |  |                 ->setZip02($data['zip02']) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 924 |  |  |                 ->setZipCode($data['zip01'] . $data['zip02']) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 925 |  |  |                 ->setPref($data['pref']) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 926 |  |  |                 ->setAddr01($data['addr01']) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 927 |  |  |                 ->setAddr02($data['addr02']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 928 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 929 |  |  |             // 非会員複数配送用 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 930 |  |  |             $CustomerAddress = new CustomerAddress(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 931 |  |  |             $CustomerAddress | 
            
                                                                                                            
                            
            
                                    
            
            
                | 932 |  |  |                 ->setCustomer($Customer) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 933 |  |  |                 ->setName01($data['name01']) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 934 |  |  |                 ->setName02($data['name02']) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 935 |  |  |                 ->setKana01($data['kana01']) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 936 |  |  |                 ->setKana02($data['kana02']) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 937 |  |  |                 ->setCompanyName($data['company_name']) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 938 |  |  |                 ->setTel01($data['tel01']) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 939 |  |  |                 ->setTel02($data['tel02']) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 940 |  |  |                 ->setTel03($data['tel03']) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 941 |  |  |                 ->setZip01($data['zip01']) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 942 |  |  |                 ->setZip02($data['zip02']) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 943 |  |  |                 ->setZipCode($data['zip01'] . $data['zip02']) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 944 |  |  |                 ->setPref($data['pref']) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 945 |  |  |                 ->setAddr01($data['addr01']) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 946 |  |  |                 ->setAddr02($data['addr02']) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 947 |  |  |                 ->setDelFlg(Constant::DISABLED); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 948 |  |  |             $Customer->addCustomerAddress($CustomerAddress); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 949 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 950 |  |  |             // 受注情報を取得 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 951 |  |  |             $Order = $app['eccube.service.shopping']->getOrder($app['config']['order_processing']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 952 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 953 |  |  |             // 初回アクセス(受注データがない)の場合は, 受注情報を作成 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 954 |  |  |             if (is_null($Order)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 955 |  |  |                 // 受注情報を作成 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 956 |  |  |                 try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 957 |  |  |                     // 受注情報を作成 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 958 |  |  |                     $app['eccube.service.shopping']->createOrder($Customer); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 959 |  |  |                 } catch (CartException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 960 |  |  |                     $app->addRequestError($e->getMessage()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 961 |  |  |                     return $app->redirect($app->url('cart')); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 962 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 963 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 964 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 965 |  |  |             // 非会員用セッションを作成 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 966 |  |  |             $nonMember = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 967 |  |  |             $nonMember['customer'] = $Customer; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 968 |  |  |             $nonMember['pref'] = $Customer->getPref()->getId(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 969 |  |  |             $app['session']->set($this->sessionKey, $nonMember); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 970 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 971 |  |  |             $customerAddresses = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 972 |  |  |             $customerAddresses[] = $CustomerAddress; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 973 |  |  |             $app['session']->set($this->sessionCustomerAddressKey, serialize($customerAddresses)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 974 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 975 |  |  |             $event = new EventArgs( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 976 |  |  |                 array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 977 |  |  |                     'form' => $form, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 978 |  |  |                     'Order' => $Order, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 979 |  |  |                 ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 980 |  |  |                 $request | 
            
                                                                                                            
                            
            
                                    
            
            
                | 981 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 982 |  |  |             $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_SHOPPING_NONMEMBER_COMPLETE, $event); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 983 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 984 |  |  |             if ($event->getResponse() !== null) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 985 |  |  |                 return $event->getResponse(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 986 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 987 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 988 |  |  |             return $app->redirect($app->url('shopping')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 989 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 990 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 991 |  |  |         return $app->render('Shopping/nonmember.twig', array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 992 |  |  |             'form' => $form->createView(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 993 |  |  |         )); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 994 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 995 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 996 |  |  |     /** | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 997 |  |  |      * 複数配送処理がクリックされた場合の処理 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 998 |  |  |      */ | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 999 |  | View Code Duplication |     public function shippingMultipleChange(Application $app, Request $request) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1000 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1001 |  |  |         $Order = $app['eccube.service.shopping']->getOrder($app['config']['order_processing']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1002 |  |  |         if (!$Order) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1003 |  |  |             $app->addError('front.shopping.order.error'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1004 |  |  |             return $app->redirect($app->url('shopping_error')); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1005 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1006 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1007 |  |  |         if ('POST' !== $request->getMethod()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1008 |  |  |             return $app->redirect($app->url('shopping')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1009 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1010 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1011 |  |  |         $builder = $app['eccube.service.shopping']->getShippingFormBuilder($Order); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1012 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1013 |  |  |         $event = new EventArgs( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1014 |  |  |             array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1015 |  |  |                 'builder' => $builder, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1016 |  |  |                 'Order' => $Order, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1017 |  |  |             ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1018 |  |  |             $request | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1019 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1020 |  |  |         $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_SHOPPING_INDEX_INITIALIZE, $event); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1021 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1022 |  |  |         $form = $builder->getForm(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1023 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1024 |  |  |         $form->handleRequest($request); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1025 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1026 |  |  |         if ($form->isSubmitted() && $form->isValid()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1027 |  |  |             $data = $form->getData(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1028 |  |  |             $message = $data['message']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1029 |  |  |             $Order->setMessage($message); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1030 |  |  |             // 受注情報を更新 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1031 |  |  |             $app['orm.em']->flush(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1032 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1033 |  |  |             // 複数配送設定へリダイレクト | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1034 |  |  |             return $app->redirect($app->url('shopping_shipping_multiple')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1035 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1036 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1037 |  |  |         return $app->render('Shopping/index.twig', array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1038 |  |  |             'form' => $form->createView(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1039 |  |  |             'Order' => $Order, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1040 |  |  |         )); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1041 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1042 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1043 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1044 |  |  |     /** | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1045 |  |  |      * 複数配送処理 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1046 |  |  |      */ | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1047 |  |  |     public function shippingMultiple(Application $app, Request $request) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1048 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1049 |  |  |         $cartService = $app['eccube.service.cart']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1050 | 1 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1051 |  |  |         // カートチェック | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1052 |  |  |         if (!$cartService->isLocked()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1053 | 1 |  |             // カートが存在しない、カートがロックされていない時はエラー | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1054 |  |  |             return $app->redirect($app->url('cart')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1055 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1056 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1057 |  |  |         // カートチェック | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1058 |  |  |         if (count($cartService->getCart()->getCartItems()) <= 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1059 |  |  |             // カートが存在しない時はエラー | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1060 |  |  |             return $app->redirect($app->url('cart')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1061 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1062 |  |  |         $Order = $app['eccube.service.shopping']->getOrder($app['config']['order_processing']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1063 |  |  |         if (!$Order) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1064 |  |  |             $app->addError('front.shopping.order.error'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1065 |  |  |             return $app->redirect($app->url('shopping_error')); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1066 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1067 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1068 |  |  |         // 複数配送時は商品毎でお届け先を設定する為、商品をまとめた数量を設定 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1069 |  |  |         $compItemQuantities = array(); | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 1070 |  | View Code Duplication |         foreach ($Order->getShippings() as $Shipping) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1071 |  |  |             foreach ($Shipping->getShipmentItems() as $ShipmentItem) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1072 |  |  |                 $itemId = $ShipmentItem->getProductClass()->getId(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1073 |  |  |                 $quantity = $ShipmentItem->getQuantity(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1074 |  |  |                 if (array_key_exists($itemId, $compItemQuantities)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1075 |  |  |                     $compItemQuantities[$itemId] = $compItemQuantities[$itemId] + $quantity; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1076 |  |  |                 } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1077 |  |  |                     $compItemQuantities[$itemId] = $quantity; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1078 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1079 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1080 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1081 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1082 |  |  |         // 商品に紐づく商品情報を取得 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1083 |  |  |         $shipmentItems = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1084 |  |  |         $productClassIds = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1085 |  |  |         foreach ($Order->getShippings() as $Shipping) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1086 |  |  |             foreach ($Shipping->getShipmentItems() as $ShipmentItem) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1087 |  |  |                 if (!in_array($ShipmentItem->getProductClass()->getId(), $productClassIds)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1088 |  |  |                     $shipmentItems[] = $ShipmentItem; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1089 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1090 |  |  |                 $productClassIds[] = $ShipmentItem->getProductClass()->getId(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1091 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1092 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1093 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1094 |  |  |         $builder = $app->form(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1095 |  |  |         $builder | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1096 |  |  |             ->add('shipping_multiple', 'collection', array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1097 |  |  |                 'type' => 'shipping_multiple', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1098 |  |  |                 'data' => $shipmentItems, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1099 |  |  |                 'allow_add' => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1100 |  |  |                 'allow_delete' => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1101 |  |  |             )); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1102 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1103 |  |  |         $event = new EventArgs( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1104 |  |  |             array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1105 |  |  |                 'builder' => $builder, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1106 |  |  |                 'Order' => $Order, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1107 |  |  |             ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1108 |  |  |             $request | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1109 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1110 |  |  |         $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_SHOPPING_SHIPPING_MULTIPLE_INITIALIZE, $event); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1111 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1112 |  |  |         $form = $builder->getForm(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1113 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1114 |  |  |         $form->handleRequest($request); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1115 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1116 |  |  |         $errors = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1117 |  |  |         if ($form->isSubmitted() && $form->isValid()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1118 |  |  |             $data = $form['shipping_multiple']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1119 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1120 |  |  |             // 数量が超えていないか、同一でないとエラー | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1121 |  |  |             $itemQuantities = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1122 |  |  |             foreach ($data as $mulitples) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1123 |  |  |                 /** @var \Eccube\Entity\ShipmentItem $multipleItem */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1124 |  |  |                 $multipleItem = $mulitples->getData(); | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 1125 |  | View Code Duplication |                 foreach ($mulitples as $items) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1126 |  |  |                     foreach ($items as $item) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1127 |  |  |                         $quantity = $item['quantity']->getData(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1128 |  |  |                         $itemId = $multipleItem->getProductClass()->getId(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1129 |  |  |                         if (array_key_exists($itemId, $itemQuantities)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1130 |  |  |                             $itemQuantities[$itemId] = $itemQuantities[$itemId] + $quantity; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1131 |  |  |                         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1132 |  |  |                             $itemQuantities[$itemId] = $quantity; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1133 |  |  |                         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1134 |  |  |                     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1135 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1136 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1137 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1138 |  |  |             foreach ($compItemQuantities as $key => $value) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1139 |  |  |                 if (array_key_exists($key, $itemQuantities)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1140 |  |  |                     if ($itemQuantities[$key] != $value) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1141 |  |  |                         $errors[] = array('message' => '数量の数が異なっています。'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1142 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1143 |  |  |                         // 対象がなければエラー | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1144 |  |  |                         return $app->render('Shopping/shipping_multiple.twig', array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1145 |  |  |                             'form' => $form->createView(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1146 |  |  |                             'shipmentItems' => $shipmentItems, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1147 |  |  |                             'compItemQuantities' => $compItemQuantities, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1148 |  |  |                             'errors' => $errors, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1149 |  |  |                         )); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1150 |  |  |                     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1151 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1152 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1153 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1154 |  |  |             // お届け先情報をdelete/insert | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1155 |  |  |             $shippings = $Order->getShippings(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1156 |  |  |             foreach ($shippings as $Shipping) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1157 |  |  |                 $Order->removeShipping($Shipping); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1158 |  |  |                 $app['orm.em']->remove($Shipping); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1159 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1160 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1161 |  |  |             foreach ($data as $mulitples) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1162 |  |  |                 /** @var \Eccube\Entity\ShipmentItem $multipleItem */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1163 |  |  |                 $multipleItem = $mulitples->getData(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1164 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1165 |  |  |                 foreach ($mulitples as $items) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1166 |  |  |                     foreach ($items as $item) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1167 |  |  |                         // 追加された配送先情報を作成 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1168 |  |  |                         $Delivery = $multipleItem->getShipping()->getDelivery(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1169 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1170 |  |  |                         // 選択された情報を取得 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1171 |  |  |                         $data = $item['customer_address']->getData(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1172 |  |  |                         if ($data instanceof CustomerAddress) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1173 |  |  |                             // 会員の場合、CustomerAddressオブジェクトを取得 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1174 |  |  |                             $CustomerAddress = $data; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1175 |  |  |                         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1176 |  |  |                             // 非会員の場合、選択されたindexが取得される | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1177 |  |  |                             $customerAddresses = $app['session']->get($this->sessionCustomerAddressKey); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1178 |  |  |                             $customerAddresses = unserialize($customerAddresses); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1179 |  |  |                             $CustomerAddress = $customerAddresses[$data]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1180 |  |  |                             $pref = $app['eccube.repository.master.pref']->find($CustomerAddress->getPref()->getId()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1181 |  |  |                             $CustomerAddress->setPref($pref); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1182 |  |  |                         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1183 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1184 |  |  |                         $Shipping = new Shipping(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1185 |  |  |                         $Shipping | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1186 |  |  |                             ->setFromCustomerAddress($CustomerAddress) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1187 |  |  |                             ->setDelivery($Delivery) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1188 |  |  |                             ->setDelFlg(Constant::DISABLED) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1189 |  |  |                             ->setOrder($Order); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1190 |  |  |                         $app['orm.em']->persist($Shipping); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1191 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1192 |  |  |                         $ProductClass = $multipleItem->getProductClass(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1193 |  |  |                         $Product = $multipleItem->getProduct(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1194 |  |  |                         $quantity = $item['quantity']->getData(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1195 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1196 |  |  |                         $ShipmentItem = new ShipmentItem(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1197 |  |  |                         $ShipmentItem->setShipping($Shipping) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1198 |  |  |                             ->setOrder($Order) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1199 |  |  |                             ->setProductClass($ProductClass) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1200 |  |  |                             ->setProduct($Product) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1201 |  |  |                             ->setProductName($Product->getName()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1202 |  |  |                             ->setProductCode($ProductClass->getCode()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1203 |  |  |                             ->setPrice($ProductClass->getPrice02()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1204 |  |  |                             ->setQuantity($quantity); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1205 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1206 |  |  |                         $ClassCategory1 = $ProductClass->getClassCategory1(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1207 |  |  |                         if (!is_null($ClassCategory1)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1208 |  |  |                             $ShipmentItem->setClasscategoryName1($ClassCategory1->getName()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1209 |  |  |                             $ShipmentItem->setClassName1($ClassCategory1->getClassName()->getName()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1210 |  |  |                         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1211 |  |  |                         $ClassCategory2 = $ProductClass->getClassCategory2(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1212 |  |  |                         if (!is_null($ClassCategory2)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1213 |  |  |                             $ShipmentItem->setClasscategoryName2($ClassCategory2->getName()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1214 |  |  |                             $ShipmentItem->setClassName2($ClassCategory2->getClassName()->getName()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1215 |  |  |                         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1216 |  |  |                         $Shipping->addShipmentItem($ShipmentItem); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1217 |  |  |                         $app['orm.em']->persist($ShipmentItem); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1218 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1219 |  |  |                         // 配送料金の設定 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1220 |  |  |                         $app['eccube.service.shopping']->setShippingDeliveryFee($Shipping); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1221 |  |  |                     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1222 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1223 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1224 |  |  |             // 配送先を更新 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1225 |  |  |             $app['orm.em']->flush(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1226 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1227 |  |  |             $event = new EventArgs( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1228 |  |  |                 array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1229 |  |  |                     'form' => $form, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1230 |  |  |                     'Order' => $Order, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1231 |  |  |                 ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1232 |  |  |                 $request | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1233 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1234 |  |  |             $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_SHOPPING_SHIPPING_MULTIPLE_COMPLETE, $event); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1235 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1236 |  |  |             return $app->redirect($app->url('shopping')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1237 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1238 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1239 |  |  |         return $app->render('Shopping/shipping_multiple.twig', array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1240 |  |  |             'form' => $form->createView(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1241 |  |  |             'shipmentItems' => $shipmentItems, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1242 |  |  |             'compItemQuantities' => $compItemQuantities, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1243 |  |  |             'errors' => $errors, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1244 |  |  |         )); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1245 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1246 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1247 |  |  |     /** | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1248 |  |  |      * 非会員用複数配送設定時の新規お届け先の設定 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1249 |  |  |      */ | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1250 |  |  |     public function shippingMultipleEdit(Application $app, Request $request) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1251 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1252 |  |  |         // カートチェック | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1253 |  |  |         if (!$app['eccube.service.cart']->isLocked()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1254 |  |  |             // カートが存在しない、カートがロックされていない時はエラー | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1255 |  |  |             return $app->redirect($app->url('cart')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1256 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1257 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1258 |  |  |         // 非会員用Customerを取得 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1259 |  |  |         $Customer = $app['eccube.service.shopping']->getNonMember($this->sessionKey); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1260 |  |  |         $CustomerAddress = new CustomerAddress(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1261 |  |  |         $CustomerAddress->setCustomer($Customer); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1262 |  |  |         $Customer->addCustomerAddress($CustomerAddress); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1263 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1264 |  |  |         $builder = $app['form.factory']->createBuilder('shopping_shipping', $CustomerAddress); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1265 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1266 |  |  |         $event = new EventArgs( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1267 |  |  |             array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1268 |  |  |                 'builder' => $builder, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1269 |  |  |                 'Customer' => $Customer, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1270 |  |  |             ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1271 |  |  |             $request | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1272 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1273 |  |  |         $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_SHOPPING_SHIPPING_MULTIPLE_EDIT_INITIALIZE, $event); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1274 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1275 |  |  |         $form = $builder->getForm(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1276 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1277 |  |  |         $form->handleRequest($request); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1278 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1279 |  |  |         if ($form->isSubmitted() && $form->isValid()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1280 |  |  |             // 非会員用のセッションに追加 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1281 |  |  |             $customerAddresses = $app['session']->get($this->sessionCustomerAddressKey); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1282 |  |  |             $customerAddresses = unserialize($customerAddresses); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1283 |  |  |             $customerAddresses[] = $CustomerAddress; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1284 |  |  |             $app['session']->set($this->sessionCustomerAddressKey, serialize($customerAddresses)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1285 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1286 |  |  |             $event = new EventArgs( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1287 |  |  |                 array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1288 |  |  |                     'form' => $form, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1289 |  |  |                     'CustomerAddresses' => $customerAddresses, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1290 |  |  |                 ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1291 |  |  |                 $request | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1292 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1293 |  |  |             $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_SHOPPING_SHIPPING_MULTIPLE_EDIT_COMPLETE, $event); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1294 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1295 |  |  |             return $app->redirect($app->url('shopping_shipping_multiple')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1296 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1297 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1298 |  |  |         return $app->render('Shopping/shipping_multiple_edit.twig', array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1299 |  |  |             'form' => $form->createView(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1300 |  |  |         )); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1301 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1302 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1303 |  |  |     /** | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1304 |  |  |      * 購入エラー画面表示 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1305 |  |  |      */ | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1306 |  |  |     public function shoppingError(Application $app, Request $request) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1307 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1308 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1309 |  |  |         $event = new EventArgs( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1310 |  |  |             array(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1311 |  |  |             $request | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1312 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1313 |  |  |         $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_SHOPPING_SHIPPING_ERROR_COMPLETE, $event); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1314 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1315 |  |  |         if ($event->getResponse() !== null) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1316 |  |  |             return $event->getResponse(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1317 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1318 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1319 |  |  |         return $app->render('Shopping/shopping_error.twig'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1320 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1321 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1322 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1323 |  |  |      * 非会員でのお客様情報変更時の入力チェック | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1324 |  |  |      * @param $data リクエストパラメータ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1325 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1326 |  |  |     private function customerValidation($app, $data) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1327 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1328 |  |  |         // 入力チェック | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1329 |  |  |         $errors = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1330 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1331 |  |  |         $errors[] = $app['validator']->validateValue($data['customer_name01'], array( | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1332 |  |  |             new Assert\NotBlank(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1333 |  |  |             new Assert\Length(array('max' => $app['config']['name_len'],)), | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1334 |  |  |             new Assert\Regex(array('pattern' => '/^[^\s ]+$/u', 'message' => 'form.type.name.firstname.nothasspace')) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1335 |  |  |         )); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1336 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1337 |  |  |         $errors[] = $app['validator']->validateValue($data['customer_name02'], array( | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1338 |  |  |             new Assert\NotBlank(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1339 |  |  |             new Assert\Length(array('max' => $app['config']['name_len'], )), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1340 |  |  |             new Assert\Regex(array('pattern' => '/^[^\s ]+$/u', 'message' => 'form.type.name.firstname.nothasspace')) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1341 |  |  |         )); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1342 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1343 |  |  |         $errors[] = $app['validator']->validateValue($data['customer_company_name'], array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1344 |  |  |             new Assert\Length(array('max' => $app['config']['stext_len'])), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1345 |  |  |         )); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1346 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1347 |  |  |         $errors[] = $app['validator']->validateValue($data['customer_tel01'], array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1348 |  |  |             new Assert\NotBlank(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1349 |  |  |             new Assert\Type(array('type' => 'numeric', 'message' => 'form.type.numeric.invalid')), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1350 |  |  |             new Assert\Length(array('max' => $app['config']['tel_len'], 'min' => $app['config']['tel_len_min'])), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1351 |  |  |         )); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1352 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1353 |  |  |         $errors[] = $app['validator']->validateValue($data['customer_tel02'], array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1354 |  |  |             new Assert\NotBlank(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1355 |  |  |             new Assert\Type(array('type' => 'numeric', 'message' => 'form.type.numeric.invalid')), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1356 |  |  |             new Assert\Length(array('max' => $app['config']['tel_len'], 'min' => $app['config']['tel_len_min'])), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1357 |  |  |         )); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1358 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1359 |  |  |         $errors[] = $app['validator']->validateValue($data['customer_tel03'], array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1360 |  |  |             new Assert\NotBlank(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1361 |  |  |             new Assert\Type(array('type' => 'numeric', 'message' => 'form.type.numeric.invalid')), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1362 |  |  |             new Assert\Length(array('max' => $app['config']['tel_len'], 'min' => $app['config']['tel_len_min'])), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1363 |  |  |         )); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1364 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1365 |  |  |         $errors[] = $app['validator']->validateValue($data['customer_zip01'], array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1366 |  |  |             new Assert\NotBlank(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1367 |  |  |             new Assert\Type(array('type' => 'numeric', 'message' => 'form.type.numeric.invalid')), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1368 |  |  |             new Assert\Length(array('min' => $app['config']['zip01_len'], 'max' => $app['config']['zip01_len'])), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1369 |  |  |         )); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1370 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1371 |  |  |         $errors[] = $app['validator']->validateValue($data['customer_zip02'], array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1372 |  |  |             new Assert\NotBlank(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1373 |  |  |             new Assert\Type(array('type' => 'numeric', 'message' => 'form.type.numeric.invalid')), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1374 |  |  |             new Assert\Length(array('min' => $app['config']['zip02_len'], 'max' => $app['config']['zip02_len'])), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1375 |  |  |         )); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1376 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1377 |  |  |         $errors[] = $app['validator']->validateValue($data['customer_addr01'], array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1378 |  |  |             new Assert\NotBlank(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1379 |  |  |             new Assert\Length(array('max' => $app['config']['address1_len'])), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1380 |  |  |         )); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1381 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1382 |  |  |         $errors[] = $app['validator']->validateValue($data['customer_addr02'], array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1383 |  |  |             new Assert\NotBlank(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1384 |  |  |             new Assert\Length(array('max' => $app['config']['address2_len'])), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1385 |  |  |         )); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1386 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1387 |  |  |         $errors[] = $app['validator']->validateValue($data['customer_email'], array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1388 |  |  |             new Assert\NotBlank(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1389 |  |  |             new Assert\Email(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1390 |  |  |         )); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1391 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1392 |  |  |         return $errors; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1393 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 1394 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 1395 |  |  |  |