nanasess /
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\Controller\Admin\Order; |
||
| 25 | |||
| 26 | use Doctrine\Common\Collections\ArrayCollection; |
||
| 27 | use Eccube\Application; |
||
| 28 | use Eccube\Common\Constant; |
||
| 29 | use Eccube\Controller\AbstractController; |
||
| 30 | use Eccube\Entity\ShipmentItem; |
||
| 31 | use Symfony\Component\Form\FormError; |
||
| 32 | use Symfony\Component\HttpFoundation\Request; |
||
| 33 | use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; |
||
| 34 | |||
| 35 | class EditController extends AbstractController |
||
| 36 | { |
||
| 37 | 4 | public function index(Application $app, Request $request, $id = null) |
|
| 38 | { |
||
| 39 | 4 | $TargetOrder = null; |
|
| 40 | 4 | $OriginOrder = null; |
|
| 41 | |||
| 42 | if (is_null($id)) { |
||
| 43 | // 空のエンティティを作成. |
||
| 44 | $TargetOrder = $this->newOrder(); |
||
| 45 | } else { |
||
| 46 | $TargetOrder = $app['eccube.repository.order']->find($id); |
||
| 47 | if (is_null($TargetOrder)) { |
||
| 48 | throw new NotFoundHttpException(); |
||
| 49 | } |
||
| 50 | 2 | } |
|
| 51 | |||
| 52 | // 編集前の受注情報を保持 |
||
| 53 | 4 | $OriginOrder = clone $TargetOrder; |
|
| 54 | $OriginalOrderDetails = new ArrayCollection(); |
||
| 55 | |||
| 56 | 4 | foreach ($TargetOrder->getOrderDetails() as $OrderDetail) { |
|
| 57 | $OriginalOrderDetails->add($OrderDetail); |
||
| 58 | 2 | } |
|
| 59 | |||
| 60 | $builder = $app['form.factory'] |
||
| 61 | ->createBuilder('order', $TargetOrder); |
||
| 62 | |||
| 63 | $form = $builder->getForm(); |
||
| 64 | |||
| 65 | if ('POST' === $request->getMethod()) { |
||
| 66 | $form->handleRequest($request); |
||
| 67 | |||
| 68 | // 入力情報にもとづいて再計算. |
||
| 69 | $this->calculate($app, $TargetOrder); |
||
| 70 | |||
| 71 | // 登録ボタン押下 |
||
| 72 | 2 | switch ($request->get('mode')) { |
|
| 73 | 2 | case 'register': |
|
| 74 | if ($TargetOrder->getTotal() > $app['config']['max_total_fee']) { |
||
| 75 | $form['charge']->addError(new FormError('合計金額の上限を超えております。')); |
||
| 76 | } elseif ($form->isValid()) { |
||
| 77 | |||
| 78 | $BaseInfo = $app['eccube.repository.base_info']->get(); |
||
| 79 | |||
| 80 | // お支払い方法の更新 |
||
| 81 | $TargetOrder->setPaymentMethod($TargetOrder->getPayment()->getMethod()); |
||
| 82 | |||
| 83 | // 配送業者・お届け時間の更新 |
||
| 84 | $Shippings = $TargetOrder->getShippings(); |
||
| 85 | foreach ($Shippings as $Shipping) { |
||
| 86 | $Shipping->setShippingDeliveryName($Shipping->getDelivery()->getName()); |
||
| 87 | if (!is_null($Shipping->getDeliveryTime())) { |
||
| 88 | $Shipping->setShippingDeliveryTime($Shipping->getDeliveryTime()->getDeliveryTime()); |
||
| 89 | } else { |
||
| 90 | $Shipping->setShippingDeliveryTime(null); |
||
| 91 | 2 | } |
|
| 92 | } |
||
| 93 | |||
| 94 | |||
| 95 | // 受注日/発送日/入金日の更新. |
||
| 96 | $this->updateDate($app, $TargetOrder, $OriginOrder); |
||
| 97 | |||
| 98 | // 受注明細で削除されているものをremove |
||
| 99 | foreach ($OriginalOrderDetails as $OrderDetail) { |
||
| 100 | if (false === $TargetOrder->getOrderDetails()->contains($OrderDetail)) { |
||
| 101 | $app['orm.em']->remove($OrderDetail); |
||
| 102 | } |
||
| 103 | 1 | } |
|
| 104 | |||
| 105 | |||
| 106 | if ($BaseInfo->getOptionMultipleShipping() == Constant::ENABLED) { |
||
| 107 | foreach ($TargetOrder->getOrderDetails() as $OrderDetail) { |
||
| 108 | /** @var $OrderDetail \Eccube\Entity\OrderDetail */ |
||
| 109 | $OrderDetail->setOrder($TargetOrder); |
||
| 110 | } |
||
| 111 | |||
| 112 | /** @var \Eccube\Entity\Shipping $Shipping */ |
||
| 113 | View Code Duplication | foreach ($Shippings as $Shipping) { |
|
| 114 | $shipmentItems = $Shipping->getShipmentItems(); |
||
| 115 | /** @var \Eccube\Entity\ShipmentItem $ShipmentItem */ |
||
| 116 | foreach ($shipmentItems as $ShipmentItem) { |
||
| 117 | $ShipmentItem->setOrder($TargetOrder); |
||
| 118 | $ShipmentItem->setShipping($Shipping); |
||
| 119 | $app['orm.em']->persist($ShipmentItem); |
||
| 120 | } |
||
| 121 | $Shipping->setOrder($TargetOrder); |
||
| 122 | $app['orm.em']->persist($Shipping); |
||
| 123 | } |
||
| 124 | } else { |
||
| 125 | |||
| 126 | $NewShipmentItems = new ArrayCollection(); |
||
| 127 | |||
| 128 | 2 | foreach ($TargetOrder->getOrderDetails() as $OrderDetail) { |
|
| 129 | /** @var $OrderDetail \Eccube\Entity\OrderDetail */ |
||
| 130 | $OrderDetail->setOrder($TargetOrder); |
||
| 131 | |||
| 132 | $NewShipmentItem = new ShipmentItem(); |
||
| 133 | $NewShipmentItem |
||
| 134 | ->setProduct($OrderDetail->getProduct()) |
||
| 135 | ->setProductClass($OrderDetail->getProductClass()) |
||
| 136 | ->setProductName($OrderDetail->getProduct()->getName()) |
||
| 137 | ->setProductCode($OrderDetail->getProductClass()->getCode()) |
||
| 138 | ->setClassCategoryName1($OrderDetail->getClassCategoryName1()) |
||
| 139 | ->setClassCategoryName2($OrderDetail->getClassCategoryName2()) |
||
| 140 | ->setClassName1($OrderDetail->getClassName1()) |
||
| 141 | ->setClassName2($OrderDetail->getClassName2()) |
||
| 142 | ->setPrice($OrderDetail->getPrice()) |
||
| 143 | ->setQuantity($OrderDetail->getQuantity()) |
||
| 144 | ->setOrder($TargetOrder); |
||
| 145 | $NewShipmentItems[] = $NewShipmentItem; |
||
| 146 | |||
| 147 | } |
||
| 148 | // 配送商品の更新. delete/insert. |
||
| 149 | $Shippings = $TargetOrder->getShippings(); |
||
| 150 | View Code Duplication | foreach ($Shippings as $Shipping) { |
|
| 151 | $ShipmentItems = $Shipping->getShipmentItems(); |
||
| 152 | foreach ($ShipmentItems as $ShipmentItem) { |
||
| 153 | $app['orm.em']->remove($ShipmentItem); |
||
| 154 | 1 | } |
|
| 155 | $ShipmentItems->clear(); |
||
| 156 | foreach ($NewShipmentItems as $NewShipmentItem) { |
||
| 157 | $NewShipmentItem->setShipping($Shipping); |
||
| 158 | $ShipmentItems->add($NewShipmentItem); |
||
| 159 | } |
||
| 160 | } |
||
| 161 | } |
||
| 162 | |||
| 163 | $app['orm.em']->persist($TargetOrder); |
||
| 164 | $app['orm.em']->flush(); |
||
| 165 | |||
| 166 | $Customer = $TargetOrder->getCustomer(); |
||
| 167 | 2 | if ($Customer) { |
|
| 168 | // 会員の場合、購入回数、購入金額などを更新 |
||
| 169 | $app['eccube.repository.customer']->updateBuyData($app, $Customer, $TargetOrder->getOrderStatus()->getId()); |
||
| 170 | } |
||
| 171 | |||
| 172 | $app->addSuccess('admin.order.save.complete', 'admin'); |
||
| 173 | |||
| 174 | return $app->redirect($app->url('admin_order_edit', array('id' => $TargetOrder->getId()))); |
||
| 175 | } |
||
| 176 | |||
| 177 | break; |
||
| 178 | |||
| 179 | case 'add_delivery': |
||
| 180 | // お届け先情報の新規追加 |
||
| 181 | |||
| 182 | $form = $builder->getForm(); |
||
| 183 | |||
| 184 | $Shipping = new \Eccube\Entity\Shipping(); |
||
| 185 | $Shipping->setDelFlg(Constant::DISABLED); |
||
| 186 | |||
| 187 | $TargetOrder->addShipping($Shipping); |
||
| 188 | |||
| 189 | $Shipping->setOrder($TargetOrder); |
||
| 190 | |||
| 191 | $form->setData($TargetOrder); |
||
| 192 | |||
| 193 | break; |
||
| 194 | |||
| 195 | default: |
||
| 196 | break; |
||
| 197 | } |
||
| 198 | } |
||
| 199 | |||
| 200 | // 会員検索フォーム |
||
| 201 | $searchCustomerModalForm = $app['form.factory'] |
||
| 202 | ->createBuilder('admin_search_customer') |
||
| 203 | ->getForm(); |
||
| 204 | |||
| 205 | // 商品検索フォーム |
||
| 206 | $searchProductModalForm = $app['form.factory'] |
||
| 207 | ->createBuilder('admin_search_product') |
||
| 208 | ->getForm(); |
||
| 209 | |||
| 210 | // 配送業者のお届け時間 |
||
| 211 | 2 | $times = array(); |
|
| 212 | $deliveries = $app['eccube.repository.delivery']->findAll(); |
||
| 213 | foreach ($deliveries as $Delivery) { |
||
| 214 | $deliveryTiems = $Delivery->getDeliveryTimes(); |
||
| 215 | foreach ($deliveryTiems as $DeliveryTime) { |
||
| 216 | $times[$Delivery->getId()][$DeliveryTime->getId()] = $DeliveryTime->getDeliveryTime(); |
||
| 217 | } |
||
| 218 | } |
||
| 219 | |||
| 220 | 2 | return $app->render('Order/edit.twig', array( |
|
| 221 | 2 | 'form' => $form->createView(), |
|
| 222 | 2 | 'searchCustomerModalForm' => $searchCustomerModalForm->createView(), |
|
| 223 | 2 | 'searchProductModalForm' => $searchProductModalForm->createView(), |
|
| 224 | 'Order' => $TargetOrder, |
||
| 225 | 'id' => $id, |
||
| 226 | 'shippingDeliveryTimes' => $app['serializer']->serialize($times, 'json'), |
||
| 227 | )); |
||
| 228 | 4 | } |
|
| 229 | |||
| 230 | /** |
||
| 231 | * 顧客情報を検索する. |
||
| 232 | * |
||
| 233 | * @param Application $app |
||
| 234 | * @param Request $request |
||
| 235 | * @return \Symfony\Component\HttpFoundation\JsonResponse |
||
| 236 | */ |
||
| 237 | 1 | public function searchCustomer(Application $app, Request $request) |
|
| 238 | { |
||
| 239 | if ($request->isXmlHttpRequest()) { |
||
| 240 | $app['monolog']->addDebug('search customer start.'); |
||
| 241 | |||
| 242 | $searchData = array( |
||
| 243 | 1 | 'multi' => $request->get('search_word'), |
|
| 244 | 1 | ); |
|
| 245 | |||
| 246 | $Customers = $app['eccube.repository.customer'] |
||
| 247 | ->getQueryBuilderBySearchData($searchData) |
||
| 248 | 1 | ->getQuery() |
|
| 249 | ->getResult(); |
||
| 250 | |||
| 251 | 1 | if (empty($Customers)) { |
|
| 252 | $app['monolog']->addDebug('search customer not found.'); |
||
| 253 | } |
||
| 254 | |||
| 255 | 1 | $data = array(); |
|
| 256 | |||
| 257 | 1 | $formatTel = '%s-%s-%s'; |
|
| 258 | 1 | $formatName = '%s%s(%s%s)'; |
|
| 259 | foreach ($Customers as $Customer) { |
||
| 260 | $data[] = array( |
||
| 261 | 1 | 'id' => $Customer->getId(), |
|
| 262 | 'name' => sprintf($formatName, $Customer->getName01(), $Customer->getName02(), $Customer->getKana01(), |
||
| 263 | $Customer->getKana02()), |
||
| 264 | 'tel' => sprintf($formatTel, $Customer->getTel01(), $Customer->getTel02(), $Customer->getTel03()), |
||
| 265 | ); |
||
| 266 | } |
||
| 267 | |||
| 268 | return $app->json($data); |
||
| 269 | } |
||
| 270 | 1 | } |
|
| 271 | |||
| 272 | /** |
||
| 273 | * 顧客情報を検索する. |
||
| 274 | * |
||
| 275 | * @param Application $app |
||
| 276 | * @param Request $request |
||
| 277 | * @return \Symfony\Component\HttpFoundation\JsonResponse |
||
| 278 | */ |
||
| 279 | 1 | public function searchCustomerById(Application $app, Request $request) |
|
| 280 | { |
||
| 281 | if ($request->isXmlHttpRequest()) { |
||
| 282 | $app['monolog']->addDebug('search customer by id start.'); |
||
| 283 | |||
| 284 | /** @var $Customer \Eccube\Entity\Customer */ |
||
| 285 | $Customer = $app['eccube.repository.customer'] |
||
| 286 | ->find($request->get('id')); |
||
| 287 | |||
| 288 | if (is_null($Customer)) { |
||
| 289 | $app['monolog']->addDebug('search customer by id not found.'); |
||
| 290 | |||
| 291 | return $app->json(array(), 404); |
||
| 292 | } |
||
| 293 | |||
| 294 | $app['monolog']->addDebug('search customer by id found.'); |
||
| 295 | |||
| 296 | $data = array( |
||
| 297 | 1 | 'id' => $Customer->getId(), |
|
| 298 | 1 | 'name01' => $Customer->getName01(), |
|
| 299 | 1 | 'name02' => $Customer->getName02(), |
|
| 300 | 1 | 'kana01' => $Customer->getKana01(), |
|
| 301 | 1 | 'kana02' => $Customer->getKana02(), |
|
| 302 | 1 | 'zip01' => $Customer->getZip01(), |
|
| 303 | 1 | 'zip02' => $Customer->getZip02(), |
|
| 304 | 'pref' => is_null($Customer->getPref()) ? null : $Customer->getPref()->getId(), |
||
| 305 | 1 | 'addr01' => $Customer->getAddr01(), |
|
| 306 | 1 | 'addr02' => $Customer->getAddr02(), |
|
| 307 | 1 | 'email' => $Customer->getEmail(), |
|
| 308 | 1 | 'tel01' => $Customer->getTel01(), |
|
| 309 | 1 | 'tel02' => $Customer->getTel02(), |
|
| 310 | 1 | 'tel03' => $Customer->getTel03(), |
|
| 311 | 1 | 'fax01' => $Customer->getFax01(), |
|
| 312 | 1 | 'fax02' => $Customer->getFax02(), |
|
| 313 | 1 | 'fax03' => $Customer->getFax03(), |
|
| 314 | 1 | 'company_name' => $Customer->getCompanyName(), |
|
| 315 | ); |
||
| 316 | |||
| 317 | return $app->json($data); |
||
| 318 | } |
||
| 319 | 1 | } |
|
| 320 | |||
| 321 | 1 | public function searchProduct(Application $app, Request $request) |
|
| 322 | { |
||
| 323 | if ($request->isXmlHttpRequest()) { |
||
| 324 | $app['monolog']->addDebug('search product start.'); |
||
| 325 | |||
| 326 | $searchData = array( |
||
| 327 | 1 | 'name' => $request->get('id'), |
|
| 328 | 1 | ); |
|
| 329 | |||
| 330 | if ($categoryId = $request->get('category_id')) { |
||
| 331 | $Category = $app['eccube.repository.category']->find($categoryId); |
||
| 332 | $searchData['category_id'] = $Category; |
||
| 333 | } |
||
| 334 | |||
| 335 | /** @var $Products \Eccube\Entity\Product[] */ |
||
| 336 | $Products = $app['eccube.repository.product'] |
||
| 337 | ->getQueryBuilderBySearchData($searchData) |
||
| 338 | 1 | ->getQuery() |
|
| 339 | ->getResult(); |
||
| 340 | |||
| 341 | 1 | if (empty($Products)) { |
|
| 342 | $app['monolog']->addDebug('search product not found.'); |
||
| 343 | } |
||
| 344 | |||
| 345 | 1 | $forms = array(); |
|
| 346 | foreach ($Products as $Product) { |
||
| 347 | /* @var $builder \Symfony\Component\Form\FormBuilderInterface */ |
||
| 348 | $builder = $app['form.factory']->createNamedBuilder('', 'add_cart', null, array( |
||
| 349 | 'product' => $Product, |
||
| 350 | )); |
||
| 351 | $addCartForm = $builder->getForm(); |
||
| 352 | $forms[$Product->getId()] = $addCartForm->createView(); |
||
| 353 | 1 | } |
|
| 354 | |||
| 355 | 1 | return $app->render('Order/search_product.twig', array( |
|
| 356 | 'forms' => $forms, |
||
| 357 | 'Products' => $Products, |
||
| 358 | )); |
||
| 359 | } |
||
| 360 | 1 | } |
|
| 361 | |||
| 362 | 2 | protected function newOrder() |
|
| 363 | { |
||
| 364 | $Order = new \Eccube\Entity\Order(); |
||
| 365 | $Shipping = new \Eccube\Entity\Shipping(); |
||
| 366 | $Shipping->setDelFlg(0); |
||
| 367 | $Order->addShipping($Shipping); |
||
| 368 | $Shipping->setOrder($Order); |
||
| 369 | |||
| 370 | 2 | return $Order; |
|
| 371 | } |
||
| 372 | |||
| 373 | /** |
||
| 374 | * フォームからの入直内容に基づいて、受注情報の再計算を行う |
||
| 375 | * |
||
| 376 | * @param $app |
||
| 377 | * @param $Order |
||
| 378 | */ |
||
| 379 | 2 | protected function calculate($app, \Eccube\Entity\Order $Order) |
|
| 380 | { |
||
| 381 | 2 | $taxtotal = 0; |
|
| 382 | 2 | $subtotal = 0; |
|
| 383 | |||
| 384 | // 受注明細データの税・小計を再計算 |
||
| 385 | /** @var $OrderDetails \Eccube\Entity\OrderDetail[] */ |
||
| 386 | $OrderDetails = $Order->getOrderDetails(); |
||
| 387 | foreach ($OrderDetails as $OrderDetail) { |
||
| 388 | // 新規登録の場合は, 入力されたproduct_id/produc_class_idから明細にセットする. |
||
| 389 | if (!$OrderDetail->getId()) { |
||
| 390 | 1 | $TaxRule = $app['eccube.repository.tax_rule']->getByRule($OrderDetail->getProduct(), |
|
| 391 | $OrderDetail->getProductClass()); |
||
| 392 | $OrderDetail->setTaxRule($TaxRule->getCalcRule()->getId()); |
||
| 393 | $OrderDetail->setProductName($OrderDetail->getProduct()->getName()); |
||
| 394 | $OrderDetail->setProductCode($OrderDetail->getProductClass()->getCode()); |
||
| 395 | $OrderDetail->setClassName1($OrderDetail->getProductClass()->hasClassCategory1() |
||
| 396 | ? $OrderDetail->getProductClass()->getClassCategory1()->getClassName()->getName() |
||
| 397 | : null); |
||
|
0 ignored issues
–
show
Coding Style
introduced
by
Loading history...
|
|||
| 398 | $OrderDetail->setClassName2($OrderDetail->getProductClass()->hasClassCategory2() |
||
| 399 | ? $OrderDetail->getProductClass()->getClassCategory2()->getClassName()->getName() |
||
| 400 | : null); |
||
|
0 ignored issues
–
show
|
|||
| 401 | $OrderDetail->setClassCategoryName1($OrderDetail->getProductClass()->hasClassCategory1() |
||
| 402 | ? $OrderDetail->getProductClass()->getClassCategory1()->getName() |
||
| 403 | : null); |
||
|
0 ignored issues
–
show
|
|||
| 404 | $OrderDetail->setClassCategoryName2($OrderDetail->getProductClass()->hasClassCategory2() |
||
| 405 | ? $OrderDetail->getProductClass()->getClassCategory2()->getName() |
||
| 406 | : null); |
||
|
0 ignored issues
–
show
|
|||
| 407 | } |
||
| 408 | |||
| 409 | // 税 |
||
| 410 | $tax = $app['eccube.service.tax_rule'] |
||
| 411 | ->calcTax($OrderDetail->getPrice(), $OrderDetail->getTaxRate(), $OrderDetail->getTaxRule()); |
||
| 412 | $OrderDetail->setPriceIncTax($OrderDetail->getPrice() + $tax); |
||
| 413 | |||
| 414 | 2 | $taxtotal += $tax; |
|
| 415 | |||
| 416 | // 小計 |
||
| 417 | $subtotal += $OrderDetail->getTotalPrice(); |
||
| 418 | } |
||
| 419 | |||
| 420 | $shippings = $Order->getShippings(); |
||
| 421 | /** @var \Eccube\Entity\Shipping $Shipping */ |
||
| 422 | foreach ($shippings as $Shipping) { |
||
| 423 | $shipmentItems = $Shipping->getShipmentItems(); |
||
| 424 | $Shipping->setDelFlg(Constant::DISABLED); |
||
| 425 | /** @var \Eccube\Entity\ShipmentItem $ShipmentItem */ |
||
| 426 | foreach ($shipmentItems as $ShipmentItem) { |
||
| 427 | $ShipmentItem->setProductName($ShipmentItem->getProduct()->getName()); |
||
| 428 | $ShipmentItem->setProductCode($ShipmentItem->getProductClass()->getCode()); |
||
| 429 | $ShipmentItem->setClassName1($ShipmentItem->getProductClass()->hasClassCategory1() |
||
| 430 | ? $ShipmentItem->getProductClass()->getClassCategory1()->getClassName()->getName() |
||
| 431 | : null); |
||
|
0 ignored issues
–
show
|
|||
| 432 | $ShipmentItem->setClassName2($ShipmentItem->getProductClass()->hasClassCategory2() |
||
| 433 | ? $ShipmentItem->getProductClass()->getClassCategory2()->getClassName()->getName() |
||
| 434 | : null); |
||
|
0 ignored issues
–
show
|
|||
| 435 | $ShipmentItem->setClassCategoryName1($ShipmentItem->getProductClass()->hasClassCategory1() |
||
| 436 | ? $ShipmentItem->getProductClass()->getClassCategory1()->getName() |
||
| 437 | : null); |
||
|
0 ignored issues
–
show
|
|||
| 438 | $ShipmentItem->setClassCategoryName2($ShipmentItem->getProductClass()->hasClassCategory2() |
||
| 439 | ? $ShipmentItem->getProductClass()->getClassCategory2()->getName() |
||
| 440 | : null); |
||
|
0 ignored issues
–
show
|
|||
| 441 | 1 | } |
|
| 442 | } |
||
| 443 | |||
| 444 | // 受注データの税・小計・合計を再計算 |
||
| 445 | $Order->setTax($taxtotal); |
||
| 446 | $Order->setSubtotal($subtotal); |
||
| 447 | $Order->setTotal($subtotal + $Order->getCharge() + $Order->getDeliveryFeeTotal() - $Order->getDiscount()); |
||
| 448 | // お支払い合計は、totalと同一金額(2系ではtotal - point) |
||
| 449 | $Order->setPaymentTotal($Order->getTotal()); |
||
| 450 | } |
||
| 451 | |||
| 452 | /** |
||
| 453 | * 受注ステータスに応じて, 受注日/入金日/発送日を更新する, |
||
| 454 | * 発送済ステータスが設定された場合は, お届け先情報の発送日も更新を行う. |
||
| 455 | * |
||
| 456 | * 編集の場合 |
||
| 457 | * - 受注ステータスが他のステータスから発送済へ変更された場合に発送日を更新 |
||
| 458 | * - 受注ステータスが他のステータスから入金済へ変更された場合に入金日を更新 |
||
| 459 | * |
||
| 460 | * 新規登録の場合 |
||
| 461 | * - 受注日を更新 |
||
| 462 | * - 受注ステータスが発送済に設定された場合に発送日を更新 |
||
| 463 | * - 受注ステータスが入金済に設定された場合に入金日を更新 |
||
| 464 | * |
||
| 465 | * |
||
| 466 | * @param $app |
||
| 467 | * @param $TargetOrder |
||
| 468 | * @param $OriginOrder |
||
| 469 | */ |
||
| 470 | 2 | protected function updateDate($app, $TargetOrder, $OriginOrder) |
|
| 471 | { |
||
| 472 | $dateTime = new \DateTime(); |
||
| 473 | |||
| 474 | // 編集 |
||
| 475 | if ($TargetOrder->getId()) { |
||
| 476 | // 発送済 |
||
| 477 | if ($TargetOrder->getOrderStatus()->getId() == $app['config']['order_deliv']) { |
||
| 478 | // 編集前と異なる場合のみ更新 |
||
| 479 | if ($TargetOrder->getOrderStatus()->getId() != $OriginOrder->getOrderStatus()->getId()) { |
||
| 480 | $TargetOrder->setCommitDate($dateTime); |
||
| 481 | // お届け先情報の発送日も更新する. |
||
| 482 | $Shippings = $TargetOrder->getShippings(); |
||
| 483 | foreach ($Shippings as $Shipping) { |
||
| 484 | $Shipping->setShippingCommitDate($dateTime); |
||
| 485 | } |
||
| 486 | } |
||
| 487 | // 入金済 |
||
| 488 | } elseif ($TargetOrder->getOrderStatus()->getId() == $app['config']['order_pre_end']) { |
||
| 489 | // 編集前と異なる場合のみ更新 |
||
| 490 | if ($TargetOrder->getOrderStatus()->getId() != $OriginOrder->getOrderStatus()->getId()) { |
||
| 491 | $TargetOrder->setPaymentDate($dateTime); |
||
| 492 | } |
||
| 493 | } |
||
| 494 | // 新規 |
||
| 495 | } else { |
||
| 496 | // 発送済 |
||
| 497 | if ($TargetOrder->getOrderStatus()->getId() == $app['config']['order_deliv']) { |
||
| 498 | $TargetOrder->setCommitDate($dateTime); |
||
| 499 | // お届け先情報の発送日も更新する. |
||
| 500 | $Shippings = $TargetOrder->getShippings(); |
||
| 501 | foreach ($Shippings as $Shipping) { |
||
| 502 | $Shipping->setShippingCommitDate($dateTime); |
||
| 503 | } |
||
| 504 | // 入金済 |
||
| 505 | } elseif ($TargetOrder->getOrderStatus()->getId() == $app['config']['order_pre_end']) { |
||
| 506 | $TargetOrder->setPaymentDate($dateTime); |
||
| 507 | } |
||
| 508 | // 受注日時 |
||
| 509 | $TargetOrder->setOrderDate($dateTime); |
||
| 510 | 1 | } |
|
| 511 | 2 | } |
|
| 512 | } |
||
| 513 |