EC-CUBE /
ec-cube
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | /* |
||
| 3 | * 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 | namespace Eccube\Service; |
||
| 25 | |||
| 26 | use Doctrine\ORM\EntityManager; |
||
| 27 | use Eccube\Annotation\Inject; |
||
| 28 | use Eccube\Annotation\Service; |
||
| 29 | use Eccube\Application; |
||
| 30 | use Eccube\Entity\BaseInfo; |
||
| 31 | use Eccube\Entity\Customer; |
||
| 32 | use Eccube\Entity\Delivery; |
||
| 33 | use Eccube\Entity\MailHistory; |
||
| 34 | use Eccube\Entity\Order; |
||
| 35 | use Eccube\Entity\OrderItem; |
||
| 36 | use Eccube\Entity\Product; |
||
| 37 | use Eccube\Entity\ProductClass; |
||
| 38 | use Eccube\Entity\Shipping; |
||
| 39 | use Eccube\Event\EccubeEvents; |
||
| 40 | use Eccube\Event\EventArgs; |
||
| 41 | use Eccube\Exception\CartException; |
||
| 42 | use Eccube\Exception\ShoppingException; |
||
| 43 | use Eccube\Form\Type\ShippingItemType; |
||
| 44 | use Eccube\Repository\CustomerAddressRepository; |
||
| 45 | use Eccube\Repository\DeliveryFeeRepository; |
||
| 46 | use Eccube\Repository\DeliveryRepository; |
||
| 47 | use Eccube\Repository\DeliveryTimeRepository; |
||
| 48 | use Eccube\Repository\MailTemplateRepository; |
||
| 49 | use Eccube\Repository\Master\DeviceTypeRepository; |
||
| 50 | use Eccube\Repository\Master\OrderStatusRepository; |
||
| 51 | use Eccube\Repository\Master\PrefRepository; |
||
| 52 | use Eccube\Repository\OrderRepository; |
||
| 53 | use Eccube\Repository\PaymentRepository; |
||
| 54 | use Eccube\Repository\TaxRuleRepository; |
||
| 55 | use Eccube\Util\Str; |
||
| 56 | use Symfony\Component\EventDispatcher\EventDispatcher; |
||
| 57 | use Symfony\Component\Form\Extension\Core\Type\CollectionType; |
||
| 58 | use Symfony\Component\Form\FormFactory; |
||
| 59 | use Symfony\Component\HttpFoundation\Session\Session; |
||
| 60 | |||
| 61 | /** |
||
| 62 | * @Service |
||
| 63 | */ |
||
| 64 | class ShoppingService |
||
| 65 | { |
||
| 66 | /** |
||
| 67 | * @Inject(MailTemplateRepository::class) |
||
| 68 | * @var MailTemplateRepository |
||
| 69 | */ |
||
| 70 | protected $mailTemplateRepository; |
||
| 71 | |||
| 72 | /** |
||
| 73 | * @Inject(MailService::class) |
||
| 74 | * @var MailService |
||
| 75 | */ |
||
| 76 | protected $mailService; |
||
| 77 | |||
| 78 | /** |
||
| 79 | * @Inject("eccube.event.dispatcher") |
||
| 80 | * @var EventDispatcher |
||
| 81 | */ |
||
| 82 | protected $eventDispatcher; |
||
| 83 | |||
| 84 | /** |
||
| 85 | * @Inject("form.factory") |
||
| 86 | * @var FormFactory |
||
| 87 | */ |
||
| 88 | protected $formFactory; |
||
| 89 | |||
| 90 | /** |
||
| 91 | * @Inject(DeliveryFeeRepository::class) |
||
| 92 | * @var DeliveryFeeRepository |
||
| 93 | */ |
||
| 94 | protected $deliveryFeeRepository; |
||
| 95 | |||
| 96 | /** |
||
| 97 | * @Inject(TaxRuleRepository::class) |
||
| 98 | * @var TaxRuleRepository |
||
| 99 | */ |
||
| 100 | protected $taxRuleRepository; |
||
| 101 | |||
| 102 | /** |
||
| 103 | * @Inject(CustomerAddressRepository::class) |
||
| 104 | * @var CustomerAddressRepository |
||
| 105 | */ |
||
| 106 | protected $customerAddressRepository; |
||
| 107 | |||
| 108 | /** |
||
| 109 | * @Inject(DeliveryRepository::class) |
||
| 110 | * @var DeliveryRepository |
||
| 111 | */ |
||
| 112 | protected $deliveryRepository; |
||
| 113 | |||
| 114 | /** |
||
| 115 | * @Inject(DeliveryTimeRepository::class) |
||
| 116 | * @var DeliveryTimeRepository |
||
| 117 | */ |
||
| 118 | protected $deliveryTimeRepository; |
||
| 119 | |||
| 120 | /** |
||
| 121 | * @Inject(OrderStatusRepository::class) |
||
| 122 | * @var OrderStatusRepository |
||
| 123 | */ |
||
| 124 | protected $orderStatusRepository; |
||
| 125 | |||
| 126 | /** |
||
| 127 | * @Inject(PaymentRepository::class) |
||
| 128 | * @var PaymentRepository |
||
| 129 | */ |
||
| 130 | protected $paymentRepository; |
||
| 131 | |||
| 132 | /** |
||
| 133 | * @Inject(DeviceTypeRepository::class) |
||
| 134 | * @var DeviceTypeRepository |
||
| 135 | */ |
||
| 136 | protected $deviceTypeRepository; |
||
| 137 | |||
| 138 | /** |
||
| 139 | * @Inject("orm.em") |
||
| 140 | * @var EntityManager |
||
| 141 | */ |
||
| 142 | protected $entityManager; |
||
| 143 | |||
| 144 | /** |
||
| 145 | * @Inject("config") |
||
| 146 | * @var array |
||
| 147 | */ |
||
| 148 | protected $appConfig; |
||
| 149 | |||
| 150 | /** |
||
| 151 | * @Inject(PrefRepository::class) |
||
| 152 | * @var PrefRepository |
||
| 153 | */ |
||
| 154 | protected $prefRepository; |
||
| 155 | |||
| 156 | /** |
||
| 157 | * @Inject("session") |
||
| 158 | * @var Session |
||
| 159 | */ |
||
| 160 | protected $session; |
||
| 161 | |||
| 162 | /** |
||
| 163 | * @Inject(OrderRepository::class) |
||
| 164 | * @var OrderRepository |
||
| 165 | */ |
||
| 166 | protected $orderRepository; |
||
| 167 | |||
| 168 | /** |
||
| 169 | * @Inject(BaseInfo::class) |
||
| 170 | * @var BaseInfo |
||
| 171 | */ |
||
| 172 | protected $BaseInfo; |
||
| 173 | |||
| 174 | /** |
||
| 175 | * @Inject(Application::class) |
||
| 176 | * @var \Eccube\Application |
||
| 177 | */ |
||
| 178 | public $app; |
||
| 179 | |||
| 180 | /** |
||
| 181 | * @Inject(CartService::class) |
||
| 182 | * @var \Eccube\Service\CartService |
||
| 183 | */ |
||
| 184 | protected $cartService; |
||
| 185 | |||
| 186 | /** |
||
| 187 | * @var \Eccube\Service\OrderService |
||
| 188 | * |
||
| 189 | * @deprecated |
||
| 190 | */ |
||
| 191 | protected $orderService; |
||
| 192 | |||
| 193 | /** |
||
| 194 | * セッションにセットされた受注情報を取得 |
||
| 195 | * |
||
| 196 | * @param null $status |
||
| 197 | * @return null|object |
||
| 198 | */ |
||
| 199 | public function getOrder($status = null) |
||
| 200 | { |
||
| 201 | 11 | ||
| 202 | // 受注データを取得 |
||
| 203 | $preOrderId = $this->cartService->getPreOrderId(); |
||
| 204 | if (!$preOrderId) { |
||
| 205 | 11 | return null; |
|
| 206 | 11 | } |
|
| 207 | 11 | ||
| 208 | $condition = array( |
||
| 209 | 'pre_order_id' => $preOrderId, |
||
| 210 | ); |
||
| 211 | 7 | ||
| 212 | if (!is_null($status)) { |
||
| 213 | $condition += array( |
||
| 214 | 7 | 'OrderStatus' => $status, |
|
| 215 | ); |
||
| 216 | 7 | } |
|
| 217 | |||
| 218 | $Order = $this->orderRepository->findOneBy($condition); |
||
| 219 | |||
| 220 | 7 | return $Order; |
|
| 221 | |||
| 222 | 7 | } |
|
| 223 | |||
| 224 | /** |
||
| 225 | * 非会員情報を取得 |
||
| 226 | * |
||
| 227 | * @param $sesisonKey |
||
| 228 | * @return $Customer|null |
||
| 229 | */ |
||
| 230 | public function getNonMember($sesisonKey) |
||
| 231 | { |
||
| 232 | 4 | ||
| 233 | // 非会員でも一度会員登録されていればショッピング画面へ遷移 |
||
| 234 | $nonMember = $this->session->get($sesisonKey); |
||
| 235 | if (is_null($nonMember)) { |
||
| 236 | 4 | return null; |
|
| 237 | 4 | } |
|
| 238 | 1 | if (!array_key_exists('customer', $nonMember) || !array_key_exists('pref', $nonMember)) { |
|
| 239 | return null; |
||
| 240 | 3 | } |
|
| 241 | |||
| 242 | $Customer = $nonMember['customer']; |
||
| 243 | $Customer->setPref($this->prefRepository->find($nonMember['pref'])); |
||
| 244 | 3 | ||
| 245 | 3 | foreach ($Customer->getCustomerAddresses() as $CustomerAddress) { |
|
| 246 | $Pref = $CustomerAddress->getPref(); |
||
| 247 | 3 | if ($Pref) { |
|
| 248 | 3 | $CustomerAddress->setPref($this->prefRepository->find($Pref->getId())); |
|
| 249 | 3 | } |
|
| 250 | 3 | } |
|
| 251 | |||
| 252 | return $Customer; |
||
| 253 | |||
| 254 | 3 | } |
|
| 255 | |||
| 256 | /** |
||
| 257 | * 受注情報を作成 |
||
| 258 | * |
||
| 259 | * @param $Customer |
||
| 260 | * @return \Eccube\Entity\Order |
||
| 261 | */ |
||
| 262 | public function createOrder($Customer) |
||
| 263 | { |
||
| 264 | // ランダムなpre_order_idを作成 |
||
| 265 | View Code Duplication | do { |
|
| 266 | $preOrderId = sha1(Str::random(32)); |
||
| 267 | $Order = $this->orderRepository->findOneBy(array( |
||
| 268 | 'pre_order_id' => $preOrderId, |
||
| 269 | 'OrderStatus' => $this->appConfig['order_processing'], |
||
| 270 | )); |
||
| 271 | } while ($Order); |
||
| 272 | |||
| 273 | // 受注情報、受注明細情報、お届け先情報、配送商品情報を作成 |
||
| 274 | $Order = $this->registerPreOrder( |
||
| 275 | $Customer, |
||
| 276 | $preOrderId); |
||
| 277 | |||
| 278 | $this->cartService->setPreOrderId($preOrderId); |
||
| 279 | $this->cartService->save(); |
||
| 280 | |||
| 281 | return $Order; |
||
| 282 | } |
||
| 283 | |||
| 284 | /** |
||
| 285 | * 仮受注情報作成 |
||
| 286 | * |
||
| 287 | * @param $Customer |
||
| 288 | * @param $preOrderId |
||
| 289 | * @return mixed |
||
| 290 | * @throws \Doctrine\ORM\NoResultException |
||
| 291 | * @throws \Doctrine\ORM\NonUniqueResultException |
||
| 292 | */ |
||
| 293 | public function registerPreOrder(Customer $Customer, $preOrderId) |
||
| 294 | { |
||
| 295 | |||
| 296 | $this->em = $this->entityManager; |
||
| 297 | |||
| 298 | // 受注情報を作成 |
||
| 299 | $Order = $this->getNewOrder($Customer); |
||
| 300 | $Order->setPreOrderId($preOrderId); |
||
| 301 | |||
| 302 | $DeviceType = $this->deviceTypeRepository->find($this->app['mobile_detect.device_type']); |
||
| 303 | $Order->setDeviceType($DeviceType); |
||
| 304 | |||
| 305 | $this->entityManager->persist($Order); |
||
| 306 | |||
| 307 | // 配送業者情報を取得 |
||
| 308 | $deliveries = $this->getDeliveriesCart(); |
||
| 309 | |||
| 310 | // お届け先情報を作成 |
||
| 311 | $Order = $this->getNewShipping($Order, $Customer, $deliveries); |
||
| 312 | |||
| 313 | // 受注明細情報、配送商品情報を作成 |
||
| 314 | $Order = $this->getNewDetails($Order); |
||
| 315 | |||
| 316 | // 小計 |
||
| 317 | $subTotal = $this->orderService->getSubTotal($Order); |
||
| 318 | |||
| 319 | // 消費税のみの小計 |
||
| 320 | $tax = $this->orderService->getTotalTax($Order); |
||
| 321 | |||
| 322 | // 配送料合計金額 |
||
| 323 | // TODO CalculateDeliveryFeeStrategy でセットする |
||
| 324 | // $Order->setDeliveryFeeTotal($this->getShippingDeliveryFeeTotal($Order->getShippings())); |
||
| 325 | |||
| 326 | // 小計 |
||
| 327 | $Order->setSubTotal($subTotal); |
||
| 328 | |||
| 329 | // 配送料無料条件(合計金額) |
||
| 330 | $this->setDeliveryFreeAmount($Order); |
||
| 331 | |||
| 332 | // 配送料無料条件(合計数量) |
||
| 333 | $this->setDeliveryFreeQuantity($Order); |
||
| 334 | |||
| 335 | // 初期選択の支払い方法をセット |
||
| 336 | $payments = $this->paymentRepository->findAllowedPayments($deliveries); |
||
| 337 | $payments = $this->getPayments($payments, $subTotal); |
||
| 338 | |||
| 339 | if (count($payments) > 0) { |
||
| 340 | $payment = $payments[0]; |
||
| 341 | $Order->setPayment($payment); |
||
| 342 | $Order->setPaymentMethod($payment->getMethod()); |
||
| 343 | $Order->setCharge($payment->getCharge()); |
||
| 344 | } else { |
||
| 345 | $Order->setCharge(0); |
||
| 346 | } |
||
| 347 | |||
| 348 | $Order->setTax($tax); |
||
| 349 | |||
| 350 | // 合計金額の計算 |
||
| 351 | $this->calculatePrice($Order); |
||
| 352 | |||
| 353 | $this->entityManager->flush(); |
||
| 354 | |||
| 355 | return $Order; |
||
| 356 | |||
| 357 | } |
||
| 358 | |||
| 359 | /** |
||
| 360 | * 受注情報を作成 |
||
| 361 | * |
||
| 362 | * @param $Customer |
||
| 363 | * @return \Eccube\Entity\Order |
||
| 364 | */ |
||
| 365 | public function getNewOrder(Customer $Customer) |
||
| 366 | { |
||
| 367 | $Order = $this->newOrder(); |
||
| 368 | $this->copyToOrderFromCustomer($Order, $Customer); |
||
| 369 | |||
| 370 | return $Order; |
||
| 371 | } |
||
| 372 | |||
| 373 | |||
| 374 | /** |
||
| 375 | * 受注情報を作成 |
||
| 376 | * |
||
| 377 | * @return \Eccube\Entity\Order |
||
| 378 | */ |
||
| 379 | public function newOrder() |
||
| 380 | { |
||
| 381 | $OrderStatus = $this->orderStatusRepository->find($this->appConfig['order_processing']); |
||
| 382 | $Order = new \Eccube\Entity\Order($OrderStatus); |
||
| 383 | |||
| 384 | return $Order; |
||
| 385 | } |
||
| 386 | |||
| 387 | /** |
||
| 388 | * 受注情報を作成 |
||
| 389 | * |
||
| 390 | * @param \Eccube\Entity\Order $Order |
||
| 391 | * @param \Eccube\Entity\Customer|null $Customer |
||
| 392 | * @return \Eccube\Entity\Order |
||
| 393 | */ |
||
| 394 | public function copyToOrderFromCustomer(Order $Order, Customer $Customer = null) |
||
| 395 | { |
||
| 396 | if (is_null($Customer)) { |
||
| 397 | return $Order; |
||
| 398 | } |
||
| 399 | |||
| 400 | if ($Customer->getId()) { |
||
| 401 | $Order->setCustomer($Customer); |
||
| 402 | } |
||
| 403 | $Order |
||
| 404 | ->setName01($Customer->getName01()) |
||
| 405 | ->setName02($Customer->getName02()) |
||
| 406 | ->setKana01($Customer->getKana01()) |
||
| 407 | ->setKana02($Customer->getKana02()) |
||
| 408 | ->setCompanyName($Customer->getCompanyName()) |
||
| 409 | ->setEmail($Customer->getEmail()) |
||
| 410 | ->setTel01($Customer->getTel01()) |
||
| 411 | ->setTel02($Customer->getTel02()) |
||
| 412 | ->setTel03($Customer->getTel03()) |
||
| 413 | ->setFax01($Customer->getFax01()) |
||
| 414 | ->setFax02($Customer->getFax02()) |
||
| 415 | ->setFax03($Customer->getFax03()) |
||
| 416 | ->setZip01($Customer->getZip01()) |
||
| 417 | ->setZip02($Customer->getZip02()) |
||
| 418 | ->setZipCode($Customer->getZip01().$Customer->getZip02()) |
||
| 419 | ->setPref($Customer->getPref()) |
||
| 420 | ->setAddr01($Customer->getAddr01()) |
||
| 421 | ->setAddr02($Customer->getAddr02()) |
||
| 422 | ->setSex($Customer->getSex()) |
||
| 423 | ->setBirth($Customer->getBirth()) |
||
| 424 | ->setJob($Customer->getJob()); |
||
| 425 | |||
| 426 | return $Order; |
||
| 427 | } |
||
| 428 | |||
| 429 | |||
| 430 | /** |
||
| 431 | * 配送業者情報を取得 |
||
| 432 | * |
||
| 433 | * @return array |
||
| 434 | */ |
||
| 435 | public function getDeliveriesCart() |
||
| 436 | { |
||
| 437 | |||
| 438 | // カートに保持されている販売種別を取得 |
||
| 439 | $saleTypes = $this->cartService->getSaleTypes(); |
||
|
0 ignored issues
–
show
|
|||
| 440 | |||
| 441 | return $this->getDeliveries($saleTypes); |
||
| 442 | |||
| 443 | } |
||
| 444 | |||
| 445 | /** |
||
| 446 | * 配送業者情報を取得 |
||
| 447 | * |
||
| 448 | * @param Order $Order |
||
| 449 | * @return array |
||
| 450 | */ |
||
| 451 | public function getDeliveriesOrder(Order $Order) |
||
| 452 | { |
||
| 453 | |||
| 454 | // 受注情報から販売種別を取得 |
||
| 455 | $saleTypes = $this->orderService->getSaleTypes($Order); |
||
|
0 ignored issues
–
show
The property
Eccube\Service\ShoppingService::$orderService has been deprecated.
This property has been deprecated. The supplier of the class has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead. Loading history...
The method
Eccube\Service\OrderService::getSaleTypes() has been deprecated with message: since 3.0.0, to be removed in 3.1
This method has been deprecated. The supplier of the class has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead. Loading history...
|
|||
| 456 | |||
| 457 | return $this->getDeliveries($saleTypes); |
||
| 458 | |||
| 459 | } |
||
| 460 | |||
| 461 | /** |
||
|
0 ignored issues
–
show
|
|||
| 462 | * 配送業者情報を取得 |
||
| 463 | * |
||
| 464 | * @param $saleTypes |
||
|
0 ignored issues
–
show
|
|||
| 465 | * @return array |
||
| 466 | */ |
||
| 467 | public function getDeliveries($saleTypes) |
||
| 468 | { |
||
| 469 | 3 | ||
| 470 | // 販売種別に紐づく配送業者を取得 |
||
| 471 | $deliveries = $this->deliveryRepository->getDeliveries($saleTypes); |
||
| 472 | |||
| 473 | 3 | if ($this->BaseInfo->isOptionMultipleShipping()) { |
|
| 474 | // 複数配送対応 |
||
| 475 | 3 | ||
| 476 | // 支払方法を取得 |
||
| 477 | $payments = $this->paymentRepository->findAllowedPayments($deliveries); |
||
| 478 | |||
| 479 | 1 | if (count($saleTypes) > 1) { |
|
| 480 | // 販売種別が複数ある場合、配送対象となる配送業者を取得 |
||
| 481 | 1 | $deliveries = $this->deliveryRepository->findAllowedDeliveries($saleTypes, $payments); |
|
| 482 | } |
||
| 483 | 1 | ||
| 484 | } |
||
| 485 | |||
| 486 | return $deliveries; |
||
| 487 | |||
| 488 | 3 | } |
|
| 489 | |||
| 490 | |||
| 491 | /** |
||
| 492 | * お届け先情報を作成 |
||
| 493 | * |
||
| 494 | * @param Order $Order |
||
| 495 | * @param Customer $Customer |
||
| 496 | * @param $deliveries |
||
| 497 | * @return Order |
||
| 498 | */ |
||
| 499 | public function getNewShipping(Order $Order, Customer $Customer, $deliveries) |
||
| 500 | { |
||
| 501 | $saleTypes = array(); |
||
| 502 | foreach ($deliveries as $Delivery) { |
||
| 503 | if (!in_array($Delivery->getSaleType()->getId(), $saleTypes)) { |
||
| 504 | $Shipping = new Shipping(); |
||
| 505 | |||
| 506 | $this->copyToShippingFromCustomer($Shipping, $Customer) |
||
| 507 | ->setOrder($Order); |
||
| 508 | |||
| 509 | // 配送料金の設定 |
||
| 510 | $this->setShippingDeliveryFee($Shipping, $Delivery); |
||
| 511 | |||
| 512 | $this->entityManager->persist($Shipping); |
||
| 513 | |||
| 514 | $Order->addShipping($Shipping); |
||
| 515 | |||
| 516 | $saleTypes[] = $Delivery->getProductType()->getId(); |
||
| 517 | } |
||
| 518 | } |
||
| 519 | |||
| 520 | return $Order; |
||
| 521 | } |
||
| 522 | |||
| 523 | /** |
||
| 524 | * お届け先情報を作成 |
||
| 525 | * |
||
| 526 | * @param \Eccube\Entity\Shipping $Shipping |
||
| 527 | * @param \Eccube\Entity\Customer|null $Customer |
||
| 528 | * @return \Eccube\Entity\Shipping |
||
| 529 | */ |
||
| 530 | public function copyToShippingFromCustomer(Shipping $Shipping, Customer $Customer = null) |
||
| 531 | { |
||
| 532 | if (is_null($Customer)) { |
||
| 533 | 1 | return $Shipping; |
|
| 534 | } |
||
| 535 | 1 | ||
| 536 | 1 | $CustomerAddress = $this->customerAddressRepository->findOneBy( |
|
| 537 | array('Customer' => $Customer), |
||
| 538 | array('id' => 'ASC') |
||
| 539 | ); |
||
| 540 | |||
| 541 | if (!is_null($CustomerAddress)) { |
||
| 542 | $Shipping |
||
| 543 | ->setName01($CustomerAddress->getName01()) |
||
| 544 | ->setName02($CustomerAddress->getName02()) |
||
| 545 | ->setKana01($CustomerAddress->getKana01()) |
||
| 546 | ->setKana02($CustomerAddress->getKana02()) |
||
| 547 | ->setCompanyName($CustomerAddress->getCompanyName()) |
||
| 548 | ->setTel01($CustomerAddress->getTel01()) |
||
| 549 | ->setTel02($CustomerAddress->getTel02()) |
||
| 550 | ->setTel03($CustomerAddress->getTel03()) |
||
| 551 | ->setFax01($CustomerAddress->getFax01()) |
||
| 552 | ->setFax02($CustomerAddress->getFax02()) |
||
| 553 | ->setFax03($CustomerAddress->getFax03()) |
||
| 554 | ->setZip01($CustomerAddress->getZip01()) |
||
| 555 | ->setZip02($CustomerAddress->getZip02()) |
||
| 556 | ->setZipCode($CustomerAddress->getZip01().$CustomerAddress->getZip02()) |
||
| 557 | ->setPref($CustomerAddress->getPref()) |
||
| 558 | ->setAddr01($CustomerAddress->getAddr01()) |
||
| 559 | ->setAddr02($CustomerAddress->getAddr02()); |
||
| 560 | } else { |
||
| 561 | $Shipping |
||
| 562 | ->setName01($Customer->getName01()) |
||
| 563 | ->setName02($Customer->getName02()) |
||
| 564 | ->setKana01($Customer->getKana01()) |
||
| 565 | ->setKana02($Customer->getKana02()) |
||
| 566 | ->setCompanyName($Customer->getCompanyName()) |
||
| 567 | ->setTel01($Customer->getTel01()) |
||
| 568 | ->setTel02($Customer->getTel02()) |
||
| 569 | ->setTel03($Customer->getTel03()) |
||
| 570 | ->setFax01($Customer->getFax01()) |
||
| 571 | ->setFax02($Customer->getFax02()) |
||
| 572 | ->setFax03($Customer->getFax03()) |
||
| 573 | ->setZip01($Customer->getZip01()) |
||
| 574 | ->setZip02($Customer->getZip02()) |
||
| 575 | ->setZipCode($Customer->getZip01().$Customer->getZip02()) |
||
| 576 | ->setPref($Customer->getPref()) |
||
| 577 | ->setAddr01($Customer->getAddr01()) |
||
| 578 | ->setAddr02($Customer->getAddr02()); |
||
| 579 | } |
||
| 580 | |||
| 581 | return $Shipping; |
||
| 582 | } |
||
| 583 | |||
| 584 | |||
| 585 | /** |
||
| 586 | * 受注明細情報、配送商品情報を作成 |
||
| 587 | * |
||
| 588 | * @param Order $Order |
||
| 589 | * @return Order |
||
| 590 | */ |
||
| 591 | public function getNewDetails(Order $Order) |
||
| 592 | { |
||
| 593 | |||
| 594 | // 受注詳細, 配送商品 |
||
| 595 | foreach ($this->cartService->getCart()->getCartItems() as $item) { |
||
| 596 | /* @var $ProductClass \Eccube\Entity\ProductClass */ |
||
| 597 | $ProductClass = $item->getProductClass(); |
||
| 598 | /* @var $Product \Eccube\Entity\Product */ |
||
| 599 | $Product = $ProductClass->getProduct(); |
||
| 600 | |||
| 601 | $quantity = $item->getQuantity(); |
||
| 602 | |||
| 603 | // 配送商品情報を作成 |
||
| 604 | $this->getNewOrderItem($Order, $Product, $ProductClass, $quantity); |
||
| 605 | } |
||
| 606 | |||
| 607 | return $Order; |
||
| 608 | |||
| 609 | } |
||
| 610 | |||
| 611 | /** |
||
| 612 | * 配送商品情報を作成 |
||
| 613 | * |
||
| 614 | * @param Order $Order |
||
| 615 | * @param Product $Product |
||
| 616 | * @param ProductClass $ProductClass |
||
| 617 | * @param $quantity |
||
| 618 | * @return \Eccube\Entity\OrderItem |
||
| 619 | */ |
||
| 620 | public function getNewOrderItem(Order $Order, Product $Product, ProductClass $ProductClass, $quantity) |
||
| 621 | { |
||
| 622 | |||
| 623 | $OrderItem = new OrderItem(); |
||
| 624 | $shippings = $Order->getShippings(); |
||
| 625 | |||
| 626 | // 選択された商品がどのお届け先情報と関連するかチェック |
||
| 627 | $Shipping = null; |
||
| 628 | foreach ($shippings as $s) { |
||
| 629 | if ($s->getDelivery()->getSaleType()->getId() == $ProductClass->getSaleType()->getId()) { |
||
| 630 | // 販売種別が同一のお届け先情報と関連させる |
||
| 631 | $Shipping = $s; |
||
| 632 | break; |
||
| 633 | } |
||
| 634 | } |
||
| 635 | |||
| 636 | if (is_null($Shipping)) { |
||
| 637 | // お届け先情報と関連していない場合、エラー |
||
| 638 | throw new CartException('shopping.delivery.not.saletype'); |
||
| 639 | } |
||
| 640 | |||
| 641 | // 商品ごとの配送料合計 |
||
| 642 | $productDeliveryFeeTotal = 0; |
||
| 643 | if ($this->BaseInfo->isOptionProductDeliveryFee()) { |
||
| 644 | $productDeliveryFeeTotal = $ProductClass->getDeliveryFee() * $quantity; |
||
| 645 | } |
||
| 646 | |||
| 647 | $Shipping->setShippingDeliveryFee($Shipping->getShippingDeliveryFee() + $productDeliveryFeeTotal); |
||
| 648 | |||
| 649 | $OrderItem->setShipping($Shipping) |
||
| 650 | ->setOrder($Order) |
||
| 651 | ->setProductClass($ProductClass) |
||
| 652 | ->setProduct($Product) |
||
| 653 | ->setProductName($Product->getName()) |
||
| 654 | ->setProductCode($ProductClass->getCode()) |
||
| 655 | ->setPrice($ProductClass->getPrice02()) |
||
| 656 | ->setQuantity($quantity); |
||
| 657 | |||
| 658 | $ClassCategory1 = $ProductClass->getClassCategory1(); |
||
| 659 | if (!is_null($ClassCategory1)) { |
||
| 660 | $OrderItem->setClasscategoryName1($ClassCategory1->getName()); |
||
| 661 | $OrderItem->setClassName1($ClassCategory1->getClassName()->getName()); |
||
| 662 | } |
||
| 663 | $ClassCategory2 = $ProductClass->getClassCategory2(); |
||
| 664 | if (!is_null($ClassCategory2)) { |
||
| 665 | $OrderItem->setClasscategoryName2($ClassCategory2->getName()); |
||
| 666 | $OrderItem->setClassName2($ClassCategory2->getClassName()->getName()); |
||
| 667 | } |
||
| 668 | $Shipping->addOrderItem($OrderItem); |
||
| 669 | $this->entityManager->persist($OrderItem); |
||
| 670 | |||
| 671 | return $OrderItem; |
||
| 672 | |||
| 673 | } |
||
| 674 | |||
| 675 | /** |
||
| 676 | * お届け先ごとの送料合計を取得 |
||
| 677 | * |
||
| 678 | * @param $shippings |
||
| 679 | * @return int |
||
| 680 | */ |
||
| 681 | public function getShippingDeliveryFeeTotal($shippings) |
||
| 682 | { |
||
| 683 | $deliveryFeeTotal = 0; |
||
| 684 | foreach ($shippings as $Shipping) { |
||
| 685 | $deliveryFeeTotal += $Shipping->getShippingDeliveryFee(); |
||
| 686 | } |
||
| 687 | |||
| 688 | return $deliveryFeeTotal; |
||
| 689 | |||
| 690 | } |
||
| 691 | |||
| 692 | /** |
||
| 693 | * 商品ごとの配送料を取得 |
||
| 694 | * |
||
| 695 | * @param Shipping $Shipping |
||
| 696 | * @return int |
||
| 697 | */ |
||
| 698 | public function getProductDeliveryFee(Shipping $Shipping) |
||
| 699 | { |
||
| 700 | $productDeliveryFeeTotal = 0; |
||
| 701 | $OrderItems = $Shipping->getOrderItems(); |
||
| 702 | foreach ($OrderItems as $OrderItem) { |
||
| 703 | $productDeliveryFeeTotal += $OrderItem->getProductClass()->getDeliveryFee() * $OrderItem->getQuantity(); |
||
| 704 | } |
||
| 705 | |||
| 706 | return $productDeliveryFeeTotal; |
||
| 707 | } |
||
| 708 | |||
| 709 | /** |
||
| 710 | * 住所などの情報が変更された時に金額の再計算を行う |
||
| 711 | * @deprecated PurchaseFlowで行う |
||
| 712 | * @param Order $Order |
||
| 713 | * @return Order |
||
| 714 | */ |
||
| 715 | public function getAmount(Order $Order) |
||
| 716 | { |
||
| 717 | |||
| 718 | 1 | // 初期選択の配送業者をセット |
|
| 719 | $shippings = $Order->getShippings(); |
||
| 720 | |||
| 721 | // 配送料合計金額 |
||
| 722 | 1 | // TODO CalculateDeliveryFeeStrategy でセットする |
|
| 723 | // $Order->setDeliveryFeeTotal($this->getShippingDeliveryFeeTotal($shippings)); |
||
| 724 | |||
| 725 | // 配送料無料条件(合計金額) |
||
| 726 | $this->setDeliveryFreeAmount($Order); |
||
| 727 | |||
| 728 | // 配送料無料条件(合計数量) |
||
| 729 | 1 | $this->setDeliveryFreeQuantity($Order); |
|
| 730 | |||
| 731 | // 合計金額の計算 |
||
| 732 | 1 | $this->calculatePrice($Order); |
|
| 733 | |||
| 734 | return $Order; |
||
| 735 | 1 | ||
| 736 | } |
||
| 737 | 1 | ||
| 738 | /** |
||
| 739 | * 配送料金の設定 |
||
| 740 | * |
||
| 741 | * @param Shipping $Shipping |
||
| 742 | * @param Delivery|null $Delivery |
||
| 743 | */ |
||
| 744 | public function setShippingDeliveryFee(Shipping $Shipping, Delivery $Delivery = null) |
||
| 745 | { |
||
| 746 | // 配送料金の設定 |
||
| 747 | if (is_null($Delivery)) { |
||
| 748 | $Delivery = $Shipping->getDelivery(); |
||
| 749 | } |
||
| 750 | $deliveryFee = $this->deliveryFeeRepository->findOneBy(array('Delivery' => $Delivery, 'Pref' => $Shipping->getPref())); |
||
| 751 | if ($deliveryFee) { |
||
| 752 | $Shipping->setFeeId($deliveryFee->getId()); |
||
| 753 | } |
||
| 754 | $Shipping->setDelivery($Delivery); |
||
| 755 | |||
| 756 | // 商品ごとの配送料合計 |
||
| 757 | $productDeliveryFeeTotal = 0; |
||
| 758 | if ($this->BaseInfo->isOptionProductDeliveryFee()) { |
||
| 759 | $productDeliveryFeeTotal += $this->getProductDeliveryFee($Shipping); |
||
| 760 | } |
||
| 761 | |||
| 762 | $Shipping->setShippingDeliveryFee($deliveryFee->getFee() + $productDeliveryFeeTotal); |
||
| 763 | $Shipping->setShippingDeliveryName($Delivery->getName()); |
||
| 764 | } |
||
| 765 | |||
| 766 | /** |
||
| 767 | * 配送料無料条件(合計金額)の条件を満たしていれば配送料金を0に設定 |
||
| 768 | * |
||
| 769 | * @param Order $Order |
||
| 770 | */ |
||
| 771 | View Code Duplication | public function setDeliveryFreeAmount(Order $Order) |
|
| 772 | { |
||
| 773 | // 配送料無料条件(合計金額) |
||
| 774 | 4 | $deliveryFreeAmount = $this->BaseInfo->getDeliveryFreeAmount(); |
|
| 775 | if (!is_null($deliveryFreeAmount)) { |
||
| 776 | // 合計金額が設定金額以上であれば送料無料 |
||
| 777 | 4 | if ($Order->getSubTotal() >= $deliveryFreeAmount) { |
|
| 778 | 4 | $Order->setDeliveryFeeTotal(0); |
|
| 779 | // お届け先情報の配送料も0にセット |
||
| 780 | 1 | $shippings = $Order->getShippings(); |
|
| 781 | 1 | foreach ($shippings as $Shipping) { |
|
| 782 | $Shipping->setShippingDeliveryFee(0); |
||
| 783 | 1 | } |
|
| 784 | 1 | } |
|
| 785 | 1 | } |
|
| 786 | } |
||
| 787 | |||
| 788 | /** |
||
| 789 | * 配送料無料条件(合計数量)の条件を満たしていれば配送料金を0に設定 |
||
| 790 | * |
||
| 791 | * @param Order $Order |
||
| 792 | */ |
||
| 793 | View Code Duplication | public function setDeliveryFreeQuantity(Order $Order) |
|
| 794 | { |
||
| 795 | // 配送料無料条件(合計数量) |
||
| 796 | 3 | $deliveryFreeQuantity = $this->BaseInfo->getDeliveryFreeQuantity(); |
|
| 797 | if (!is_null($deliveryFreeQuantity)) { |
||
| 798 | // 合計数量が設定数量以上であれば送料無料 |
||
| 799 | 3 | if ($this->orderService->getTotalQuantity($Order) >= $deliveryFreeQuantity) { |
|
| 800 | 3 | $Order->setDeliveryFeeTotal(0); |
|
| 801 | // お届け先情報の配送料も0にセット |
||
| 802 | $shippings = $Order->getShippings(); |
||
| 803 | foreach ($shippings as $Shipping) { |
||
| 804 | $Shipping->setShippingDeliveryFee(0); |
||
| 805 | } |
||
| 806 | } |
||
| 807 | } |
||
| 808 | } |
||
| 809 | |||
| 810 | /** |
||
| 811 | * 受注情報、お届け先情報の更新 |
||
| 812 | * |
||
| 813 | * @param Order $Order 受注情報 |
||
| 814 | * @param $data フォームデータ |
||
| 815 | * |
||
| 816 | * @deprecated since 3.0.5, to be removed in 3.1 |
||
| 817 | */ |
||
| 818 | public function setOrderUpdate(Order $Order, $data) |
||
| 819 | { |
||
| 820 | // 受注情報を更新 |
||
| 821 | $Order->setOrderDate(new \DateTime()); |
||
| 822 | $Order->setOrderStatus($this->orderStatusRepository->find($this->appConfig['order_new'])); |
||
| 823 | $Order->setMessage($data['message']); |
||
| 824 | // お届け先情報を更新 |
||
| 825 | $shippings = $data['shippings']; |
||
| 826 | foreach ($shippings as $Shipping) { |
||
| 827 | $Delivery = $Shipping->getDelivery(); |
||
| 828 | $deliveryFee = $this->deliveryFeeRepository->findOneBy(array( |
||
| 829 | 'Delivery' => $Delivery, |
||
| 830 | 'Pref' => $Shipping->getPref() |
||
| 831 | )); |
||
| 832 | $deliveryTime = $Shipping->getDeliveryTime(); |
||
| 833 | if (!empty($deliveryTime)) { |
||
| 834 | $Shipping->setShippingDeliveryTime($deliveryTime->getDeliveryTime()); |
||
| 835 | $Shipping->setTimeId($deliveryTime->getId()); |
||
| 836 | } |
||
| 837 | $Shipping->setDeliveryFee($deliveryFee); |
||
| 838 | // 商品ごとの配送料合計 |
||
| 839 | $productDeliveryFeeTotal = 0; |
||
| 840 | if ($this->BaseInfo->isOptionProductDeliveryFee()) { |
||
| 841 | $productDeliveryFeeTotal += $this->getProductDeliveryFee($Shipping); |
||
| 842 | } |
||
| 843 | $Shipping->setShippingDeliveryFee($deliveryFee->getFee() + $productDeliveryFeeTotal); |
||
| 844 | $Shipping->setShippingDeliveryName($Delivery->getName()); |
||
| 845 | } |
||
| 846 | // 配送料無料条件(合計金額) |
||
| 847 | $this->setDeliveryFreeAmount($Order); |
||
| 848 | // 配送料無料条件(合計数量) |
||
| 849 | $this->setDeliveryFreeQuantity($Order); |
||
| 850 | } |
||
| 851 | |||
| 852 | |||
| 853 | /** |
||
| 854 | * 受注情報の更新 |
||
| 855 | * |
||
| 856 | * @param Order $Order 受注情報 |
||
| 857 | */ |
||
| 858 | public function setOrderUpdateData(Order $Order) |
||
| 859 | { |
||
| 860 | // 受注情報を更新 |
||
| 861 | 3 | $Order->setOrderDate(new \DateTime()); // XXX 後続の setOrderStatus でも時刻を更新している |
|
| 862 | $OrderStatus = $this->orderStatusRepository->find($this->appConfig['order_new']); |
||
| 863 | $this->setOrderStatus($Order, $OrderStatus); |
||
| 864 | 3 | ||
| 865 | 3 | } |
|
| 866 | 3 | ||
| 867 | |||
| 868 | /** |
||
| 869 | * 会員情報の更新 |
||
| 870 | * |
||
| 871 | * @param Order $Order 受注情報 |
||
| 872 | * @param Customer $user ログインユーザ |
||
| 873 | */ |
||
| 874 | public function setCustomerUpdate(Order $Order, Customer $user) |
||
| 875 | { |
||
| 876 | // 顧客情報を更新 |
||
| 877 | 2 | $now = new \DateTime(); |
|
| 878 | $firstBuyDate = $user->getFirstBuyDate(); |
||
| 879 | if (empty($firstBuyDate)) { |
||
| 880 | 2 | $user->setFirstBuyDate($now); |
|
| 881 | 2 | } |
|
| 882 | 2 | $user->setLastBuyDate($now); |
|
| 883 | 2 | ||
| 884 | $user->setBuyTimes($user->getBuyTimes() + 1); |
||
| 885 | 2 | $user->setBuyTotal($user->getBuyTotal() + $Order->getTotal()); |
|
| 886 | } |
||
| 887 | 2 | ||
| 888 | 2 | ||
| 889 | /** |
||
| 890 | * 支払方法選択の表示設定 |
||
| 891 | * |
||
| 892 | * @param $payments 支払選択肢情報 |
||
| 893 | * @param $subTotal 小計 |
||
| 894 | * @return array |
||
| 895 | */ |
||
| 896 | public function getPayments($payments, $subTotal) |
||
| 897 | { |
||
| 898 | $pays = array(); |
||
| 899 | 1 | foreach ($payments as $payment) { |
|
| 900 | // 支払方法の制限値内であれば表示 |
||
| 901 | 1 | if (!is_null($payment)) { |
|
| 902 | 1 | $pay = $this->paymentRepository->find($payment['id']); |
|
| 903 | if (intval($pay->getRuleMin()) <= $subTotal) { |
||
| 904 | 1 | if (is_null($pay->getRuleMax()) || $pay->getRuleMax() >= $subTotal) { |
|
| 905 | 1 | $pays[] = $pay; |
|
| 906 | 1 | } |
|
| 907 | 1 | } |
|
| 908 | 1 | } |
|
| 909 | } |
||
| 910 | |||
| 911 | return $pays; |
||
| 912 | |||
| 913 | } |
||
| 914 | 1 | ||
| 915 | /** |
||
| 916 | * お届け日を取得 |
||
| 917 | * |
||
| 918 | * @param Order $Order |
||
| 919 | * @return array |
||
| 920 | */ |
||
| 921 | public function getFormDeliveryDates(Order $Order) |
||
| 922 | { |
||
| 923 | |||
| 924 | 2 | // お届け日の設定 |
|
| 925 | $minDate = 0; |
||
| 926 | $deliveryDateFlag = false; |
||
| 927 | |||
| 928 | 2 | // 配送時に最大となる商品日数を取得 |
|
| 929 | 2 | View Code Duplication | foreach ($Order->getOrderItems() as $item) { |
| 930 | if (!$item->isProduct()) { |
||
| 931 | continue; |
||
| 932 | 2 | } |
|
| 933 | 2 | $ProductClass = $item->getProductClass(); |
|
| 934 | 1 | $deliveryDate = $ProductClass->getDeliveryDate(); |
|
| 935 | if (!is_null($deliveryDate)) { |
||
| 936 | 2 | if ($deliveryDate->getValue() < 0) { |
|
| 937 | 2 | // 配送日数がマイナスの場合はお取り寄せなのでスキップする |
|
| 938 | 2 | $deliveryDateFlag = false; |
|
| 939 | 2 | break; |
|
| 940 | } |
||
| 941 | 1 | ||
| 942 | 1 | if ($minDate < $deliveryDate->getValue()) { |
|
| 943 | $minDate = $deliveryDate->getValue(); |
||
| 944 | } |
||
| 945 | 1 | // 配送日数が設定されている |
|
| 946 | $deliveryDateFlag = true; |
||
| 947 | } |
||
| 948 | } |
||
| 949 | 1 | ||
| 950 | // 配達最大日数期間を設定 |
||
| 951 | $deliveryDates = array(); |
||
| 952 | |||
| 953 | // 配送日数が設定されている |
||
| 954 | 2 | View Code Duplication | if ($deliveryDateFlag) { |
| 955 | $period = new \DatePeriod ( |
||
| 956 | new \DateTime($minDate.' day'), |
||
| 957 | 2 | new \DateInterval('P1D'), |
|
| 958 | 1 | new \DateTime($minDate + $this->appConfig['deliv_date_end_max'].' day') |
|
| 959 | 1 | ); |
|
| 960 | 1 | ||
| 961 | 1 | foreach ($period as $day) { |
|
| 962 | $deliveryDates[$day->format('Y/m/d')] = $day->format('Y/m/d'); |
||
| 963 | } |
||
| 964 | 1 | } |
|
| 965 | 1 | ||
| 966 | return $deliveryDates; |
||
| 967 | } |
||
| 968 | |||
| 969 | 2 | /** |
|
| 970 | * 支払方法を取得 |
||
| 971 | * |
||
| 972 | * @param $deliveries |
||
| 973 | * @param Order $Order |
||
| 974 | * @return array |
||
| 975 | */ |
||
| 976 | public function getFormPayments($deliveries, Order $Order) |
||
| 977 | { |
||
| 978 | |||
| 979 | $saleTypes = $this->orderService->getSaleTypes($Order); |
||
|
0 ignored issues
–
show
The property
Eccube\Service\ShoppingService::$orderService has been deprecated.
This property has been deprecated. The supplier of the class has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead. Loading history...
The method
Eccube\Service\OrderService::getSaleTypes() has been deprecated with message: since 3.0.0, to be removed in 3.1
This method has been deprecated. The supplier of the class has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead. Loading history...
|
|||
| 980 | if ($this->BaseInfo->isOptionMultipleShipping() && count($saleTypes) > 1) { |
||
| 981 | // 複数配送時の支払方法 |
||
| 982 | |||
| 983 | $payments = $this->paymentRepository->findAllowedPayments($deliveries); |
||
| 984 | } else { |
||
| 985 | |||
| 986 | // 配送業者をセット |
||
| 987 | $shippings = $Order->getShippings(); |
||
| 988 | $Shipping = $shippings[0]; |
||
| 989 | $payments = $this->paymentRepository->findPayments($Shipping->getDelivery(), true); |
||
| 990 | |||
| 991 | } |
||
| 992 | $payments = $this->getPayments($payments, $Order->getSubTotal()); |
||
| 993 | |||
| 994 | return $payments; |
||
| 995 | |||
| 996 | } |
||
| 997 | |||
| 998 | /** |
||
| 999 | * お届け先ごとにFormを作成 |
||
| 1000 | * |
||
| 1001 | * @param Order $Order |
||
| 1002 | * @return \Symfony\Component\Form\Form |
||
| 1003 | * @deprecated since 3.0, to be removed in 3.1 |
||
| 1004 | */ |
||
| 1005 | View Code Duplication | public function getShippingForm(Order $Order) |
|
| 1006 | { |
||
| 1007 | $message = $Order->getMessage(); |
||
| 1008 | |||
| 1009 | $deliveries = $this->getDeliveriesOrder($Order); |
||
| 1010 | |||
| 1011 | // 配送業者の支払方法を取得 |
||
| 1012 | $payments = $this->getFormPayments($deliveries, $Order); |
||
| 1013 | |||
| 1014 | $builder = $this->formFactory->createBuilder('shopping', null, array( |
||
| 1015 | 'payments' => $payments, |
||
| 1016 | 'payment' => $Order->getPayment(), |
||
| 1017 | 'message' => $message, |
||
| 1018 | )); |
||
| 1019 | |||
| 1020 | $builder |
||
| 1021 | ->add('shippings', CollectionType::class, array( |
||
| 1022 | 'entry_type' => ShippingItemType::class, |
||
| 1023 | 'data' => $Order->getShippings(), |
||
| 1024 | )); |
||
| 1025 | |||
| 1026 | $form = $builder->getForm(); |
||
| 1027 | |||
| 1028 | return $form; |
||
| 1029 | |||
| 1030 | } |
||
| 1031 | |||
| 1032 | /** |
||
| 1033 | * お届け先ごとにFormBuilderを作成 |
||
| 1034 | * |
||
| 1035 | * @param Order $Order |
||
| 1036 | * @return \Symfony\Component\Form\FormBuilderInterface |
||
| 1037 | * |
||
| 1038 | * @deprecated 利用している箇所なし |
||
| 1039 | */ |
||
| 1040 | View Code Duplication | public function getShippingFormBuilder(Order $Order) |
|
| 1041 | { |
||
| 1042 | $message = $Order->getMessage(); |
||
| 1043 | |||
| 1044 | $deliveries = $this->getDeliveriesOrder($Order); |
||
| 1045 | |||
| 1046 | // 配送業者の支払方法を取得 |
||
| 1047 | $payments = $this->getFormPayments($deliveries, $Order); |
||
| 1048 | |||
| 1049 | $builder = $this->formFactory->createBuilder('shopping', null, array( |
||
| 1050 | 'payments' => $payments, |
||
| 1051 | 'payment' => $Order->getPayment(), |
||
| 1052 | 'message' => $message, |
||
| 1053 | )); |
||
| 1054 | |||
| 1055 | $builder |
||
| 1056 | ->add('shippings', CollectionType::class, array( |
||
| 1057 | 'entry_type' => ShippingItemType::class, |
||
| 1058 | 'data' => $Order->getShippings(), |
||
| 1059 | )); |
||
| 1060 | |||
| 1061 | return $builder; |
||
| 1062 | |||
| 1063 | } |
||
| 1064 | |||
| 1065 | |||
| 1066 | /** |
||
| 1067 | * フォームデータを更新 |
||
| 1068 | * |
||
| 1069 | * @param Order $Order |
||
| 1070 | * @param array $data |
||
| 1071 | * |
||
| 1072 | * @deprecated |
||
| 1073 | */ |
||
| 1074 | public function setFormData(Order $Order, array $data) |
||
| 1075 | { |
||
| 1076 | |||
| 1077 | 1 | // お問い合わせ |
|
| 1078 | $Order->setMessage($data['message']); |
||
| 1079 | |||
| 1080 | // お届け先情報を更新 |
||
| 1081 | 1 | $shippings = $data['shippings']; |
|
| 1082 | foreach ($shippings as $Shipping) { |
||
| 1083 | |||
| 1084 | 1 | $timeId = $Shipping->getTimeId(); |
|
| 1085 | 1 | $deliveryTime = null; |
|
| 1086 | if ($timeId) { |
||
| 1087 | 1 | $deliveryTime = $this->deliveryTimeRepository->find($timeId); |
|
| 1088 | 1 | } |
|
| 1089 | 1 | if ($deliveryTime) { |
|
| 1090 | $Shipping->setShippingDeliveryTime($deliveryTime->getDeliveryTime()); |
||
| 1091 | $Shipping->setTimeId($timeId); |
||
| 1092 | 1 | } |
|
| 1093 | |||
| 1094 | 1 | } |
|
| 1095 | |||
| 1096 | } |
||
| 1097 | |||
| 1098 | /** |
||
| 1099 | * 配送料の合計金額を計算 |
||
| 1100 | * |
||
| 1101 | * @param Order $Order |
||
| 1102 | * @return Order |
||
| 1103 | */ |
||
| 1104 | public function calculateDeliveryFee(Order $Order) |
||
| 1105 | { |
||
| 1106 | |||
| 1107 | 2 | // 配送業者を取得 |
|
| 1108 | $shippings = $Order->getShippings(); |
||
| 1109 | |||
| 1110 | // 配送料合計金額 |
||
| 1111 | 2 | // TODO CalculateDeliveryFeeStrategy でセットする |
|
| 1112 | // $Order->setDeliveryFeeTotal($this->getShippingDeliveryFeeTotal($shippings)); |
||
| 1113 | |||
| 1114 | // 配送料無料条件(合計金額) |
||
| 1115 | $this->setDeliveryFreeAmount($Order); |
||
| 1116 | |||
| 1117 | // 配送料無料条件(合計数量) |
||
| 1118 | 2 | $this->setDeliveryFreeQuantity($Order); |
|
| 1119 | |||
| 1120 | return $Order; |
||
| 1121 | 2 | ||
| 1122 | } |
||
| 1123 | 2 | ||
| 1124 | |||
| 1125 | /** |
||
| 1126 | * 購入処理を行う |
||
| 1127 | * |
||
| 1128 | * @param Order $Order |
||
| 1129 | * @throws ShoppingException |
||
| 1130 | */ |
||
| 1131 | public function processPurchase(Order $Order) |
||
| 1132 | { |
||
| 1133 | |||
| 1134 | 2 | $em = $this->entityManager; |
|
| 1135 | |||
| 1136 | // 受注情報、配送情報を更新 |
||
| 1137 | 2 | $Order = $this->calculateDeliveryFee($Order); |
|
| 1138 | $this->setOrderUpdateData($Order); |
||
| 1139 | |||
| 1140 | 2 | if ($this->app->isGranted('ROLE_USER')) { |
|
| 1141 | 2 | // 会員の場合、購入金額を更新 |
|
| 1142 | $this->setCustomerUpdate($Order, $this->app->user()); |
||
| 1143 | 2 | } |
|
| 1144 | } |
||
| 1145 | 1 | ||
| 1146 | |||
| 1147 | /** |
||
| 1148 | * 値引き可能かチェック |
||
| 1149 | * |
||
| 1150 | * @param Order $Order |
||
| 1151 | * @param $discount |
||
| 1152 | * @return bool |
||
| 1153 | */ |
||
| 1154 | public function isDiscount(Order $Order, $discount) |
||
| 1155 | { |
||
| 1156 | |||
| 1157 | if ($Order->getTotal() < $discount) { |
||
| 1158 | return false; |
||
| 1159 | } |
||
| 1160 | |||
| 1161 | return true; |
||
| 1162 | } |
||
| 1163 | |||
| 1164 | |||
| 1165 | /** |
||
| 1166 | * 値引き金額をセット |
||
| 1167 | * |
||
| 1168 | * @param Order $Order |
||
| 1169 | * @param $discount |
||
| 1170 | */ |
||
| 1171 | public function setDiscount(Order $Order, $discount) |
||
| 1172 | { |
||
| 1173 | |||
| 1174 | $Order->setDiscount($Order->getDiscount() + $discount); |
||
| 1175 | |||
| 1176 | } |
||
| 1177 | |||
| 1178 | |||
| 1179 | /** |
||
| 1180 | * 合計金額を計算 |
||
| 1181 | * |
||
| 1182 | * @param Order $Order |
||
| 1183 | * @return Order |
||
| 1184 | */ |
||
| 1185 | public function calculatePrice(Order $Order) |
||
| 1186 | { |
||
| 1187 | |||
| 1188 | 1 | $total = $Order->getTotalPrice(); |
|
| 1189 | |||
| 1190 | if ($total < 0) { |
||
| 1191 | 1 | // 合計金額がマイナスの場合、0を設定し、discountは値引きされた額のみセット |
|
| 1192 | $total = 0; |
||
| 1193 | 1 | } |
|
| 1194 | |||
| 1195 | $Order->setTotal($total); |
||
| 1196 | $Order->setPaymentTotal($total); |
||
| 1197 | |||
| 1198 | 1 | return $Order; |
|
| 1199 | 1 | ||
| 1200 | } |
||
| 1201 | 1 | ||
| 1202 | /** |
||
| 1203 | * 受注ステータスをセット |
||
| 1204 | * |
||
| 1205 | * @param Order $Order |
||
| 1206 | * @param $status |
||
| 1207 | * @return Order |
||
| 1208 | */ |
||
| 1209 | public function setOrderStatus(Order $Order, $status) |
||
| 1210 | { |
||
| 1211 | |||
| 1212 | 3 | $Order->setOrderDate(new \DateTime()); |
|
| 1213 | $Order->setOrderStatus($this->orderStatusRepository->find($status)); |
||
| 1214 | |||
| 1215 | 3 | $event = new EventArgs( |
|
| 1216 | 3 | array( |
|
| 1217 | 'Order' => $Order, |
||
| 1218 | 3 | ), |
|
| 1219 | null |
||
| 1220 | 3 | ); |
|
| 1221 | $this->eventDispatcher->dispatch(EccubeEvents::SERVICE_SHOPPING_ORDER_STATUS, $event); |
||
| 1222 | 3 | ||
| 1223 | return $Order; |
||
| 1224 | 3 | ||
| 1225 | } |
||
| 1226 | 3 | ||
| 1227 | /** |
||
| 1228 | * 受注メール送信を行う |
||
| 1229 | * |
||
| 1230 | * @param Order $Order |
||
| 1231 | * @return MailHistory |
||
| 1232 | */ |
||
| 1233 | public function sendOrderMail(Order $Order) |
||
| 1234 | { |
||
| 1235 | |||
| 1236 | 2 | // メール送信 |
|
| 1237 | $message = $this->mailService->sendOrderMail($Order); |
||
| 1238 | |||
| 1239 | // 送信履歴を保存. |
||
| 1240 | 2 | $MailHistory = new MailHistory(); |
|
| 1241 | $MailHistory |
||
| 1242 | ->setSubject($message->getSubject()) |
||
| 1243 | 2 | ->setMailBody($message->getBody()) |
|
| 1244 | ->setSendDate(new \DateTime()) |
||
| 1245 | 2 | ->setOrder($Order); |
|
| 1246 | 2 | ||
| 1247 | 2 | $this->entityManager->persist($MailHistory); |
|
| 1248 | 2 | $this->entityManager->flush($MailHistory); |
|
| 1249 | |||
| 1250 | 2 | return $MailHistory; |
|
| 1251 | 2 | ||
| 1252 | } |
||
| 1253 | 2 | ||
| 1254 | |||
| 1255 | /** |
||
| 1256 | * 受注処理完了通知 |
||
| 1257 | * |
||
| 1258 | * @param Order $Order |
||
| 1259 | */ |
||
| 1260 | public function notifyComplete(Order $Order) |
||
| 1261 | { |
||
| 1262 | |||
| 1263 | $event = new EventArgs( |
||
| 1264 | array( |
||
| 1265 | 'Order' => $Order, |
||
| 1266 | ), |
||
| 1267 | null |
||
| 1268 | ); |
||
| 1269 | $this->eventDispatcher->dispatch(EccubeEvents::SERVICE_SHOPPING_NOTIFY_COMPLETE, $event); |
||
| 1270 | |||
| 1271 | } |
||
| 1272 | |||
| 1273 | |||
| 1274 | } |
||
| 1275 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.