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
|
|
|
} |
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
|
|
|
} |
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
|
|
|
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
|
|
|
} |
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
|
|
|
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
|
2 |
|
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
|
2 |
|
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
|
4 |
|
$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
|
4 |
|
return $app->render('Order/edit.twig', array( |
221
|
4 |
|
'form' => $form->createView(), |
222
|
4 |
|
'searchCustomerModalForm' => $searchCustomerModalForm->createView(), |
223
|
4 |
|
'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
|
|
|
public function searchCustomer(Application $app, Request $request) |
238
|
|
|
{ |
239
|
|
|
if ($request->isXmlHttpRequest()) { |
240
|
|
|
$app['monolog']->addDebug('search customer start.'); |
241
|
|
|
|
242
|
|
|
$searchData = array( |
243
|
|
|
'multi' => $request->get('search_word'), |
244
|
|
|
); |
245
|
|
|
|
246
|
|
|
$Customers = $app['eccube.repository.customer'] |
247
|
|
|
->getQueryBuilderBySearchData($searchData) |
248
|
|
|
->getQuery() |
249
|
|
|
->getResult(); |
250
|
|
|
|
251
|
|
|
if (empty($Customers)) { |
252
|
|
|
$app['monolog']->addDebug('search customer not found.'); |
253
|
|
|
} |
254
|
|
|
|
255
|
|
|
$data = array(); |
256
|
|
|
|
257
|
|
|
$formatTel = '%s-%s-%s'; |
258
|
|
|
$formatName = '%s%s(%s%s)'; |
259
|
|
|
foreach ($Customers as $Customer) { |
260
|
|
|
$data[] = array( |
261
|
|
|
'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
|
|
|
} |
271
|
|
|
|
272
|
|
|
/** |
273
|
|
|
* 顧客情報を検索する. |
274
|
|
|
* |
275
|
|
|
* @param Application $app |
276
|
|
|
* @param Request $request |
|
|
|
|
277
|
|
|
* @return \Symfony\Component\HttpFoundation\JsonResponse |
278
|
|
|
*/ |
279
|
|
|
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
|
|
|
'id' => $Customer->getId(), |
298
|
|
|
'name01' => $Customer->getName01(), |
299
|
|
|
'name02' => $Customer->getName02(), |
300
|
|
|
'kana01' => $Customer->getKana01(), |
301
|
|
|
'kana02' => $Customer->getKana02(), |
302
|
|
|
'zip01' => $Customer->getZip01(), |
303
|
|
|
'zip02' => $Customer->getZip02(), |
304
|
|
|
'pref' => is_null($Customer->getPref()) ? null : $Customer->getPref()->getId(), |
305
|
|
|
'addr01' => $Customer->getAddr01(), |
306
|
|
|
'addr02' => $Customer->getAddr02(), |
307
|
|
|
'email' => $Customer->getEmail(), |
308
|
|
|
'tel01' => $Customer->getTel01(), |
309
|
|
|
'tel02' => $Customer->getTel02(), |
310
|
|
|
'tel03' => $Customer->getTel03(), |
311
|
|
|
'fax01' => $Customer->getFax01(), |
312
|
|
|
'fax02' => $Customer->getFax02(), |
313
|
|
|
'fax03' => $Customer->getFax03(), |
314
|
|
|
'company_name' => $Customer->getCompanyName(), |
315
|
|
|
); |
316
|
|
|
|
317
|
|
|
return $app->json($data); |
318
|
|
|
} |
319
|
|
|
} |
320
|
|
|
|
321
|
|
|
public function searchProduct(Application $app, Request $request) |
|
|
|
|
322
|
|
|
{ |
323
|
|
|
if ($request->isXmlHttpRequest()) { |
324
|
|
|
$app['monolog']->addDebug('search product start.'); |
325
|
|
|
|
326
|
|
|
$searchData = array( |
327
|
|
|
'name' => $request->get('id'), |
328
|
|
|
); |
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
|
|
|
->getQuery() |
339
|
|
|
->getResult(); |
340
|
|
|
|
341
|
|
|
if (empty($Products)) { |
342
|
|
|
$app['monolog']->addDebug('search product not found.'); |
343
|
|
|
} |
344
|
|
|
|
345
|
|
|
$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
|
|
|
} |
354
|
|
|
|
355
|
|
|
return $app->render('Order/search_product.twig', array( |
356
|
|
|
'forms' => $forms, |
357
|
|
|
'Products' => $Products, |
358
|
|
|
)); |
359
|
|
|
} |
360
|
|
|
} |
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
|
|
|
$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); |
|
|
|
|
398
|
|
|
$OrderDetail->setClassName2($OrderDetail->getProductClass()->hasClassCategory2() |
399
|
|
|
? $OrderDetail->getProductClass()->getClassCategory2()->getClassName()->getName() |
400
|
|
|
: null); |
|
|
|
|
401
|
|
|
$OrderDetail->setClassCategoryName1($OrderDetail->getProductClass()->hasClassCategory1() |
402
|
|
|
? $OrderDetail->getProductClass()->getClassCategory1()->getName() |
403
|
|
|
: null); |
|
|
|
|
404
|
|
|
$OrderDetail->setClassCategoryName2($OrderDetail->getProductClass()->hasClassCategory2() |
405
|
|
|
? $OrderDetail->getProductClass()->getClassCategory2()->getName() |
406
|
|
|
: null); |
|
|
|
|
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
|
1 |
|
$taxtotal += $tax; |
415
|
|
|
|
416
|
|
|
// 小計 |
417
|
|
|
$subtotal += $OrderDetail->getTotalPrice(); |
418
|
1 |
|
} |
419
|
|
|
|
420
|
|
|
|
421
|
|
|
$shippings = $Order->getShippings(); |
422
|
|
|
/** @var \Eccube\Entity\Shipping $Shipping */ |
423
|
|
|
foreach ($shippings as $Shipping) { |
424
|
|
|
$shipmentItems = $Shipping->getShipmentItems(); |
425
|
|
|
$Shipping->setDelFlg(Constant::DISABLED); |
426
|
|
|
/** @var \Eccube\Entity\ShipmentItem $ShipmentItem */ |
427
|
|
|
if (!$Shipping->getId()) { |
428
|
|
|
foreach ($shipmentItems as $ShipmentItem) { |
429
|
|
|
$ShipmentItem->setProductName($ShipmentItem->getProduct()->getName()); |
430
|
|
|
$ShipmentItem->setProductCode($ShipmentItem->getProductClass()->getCode()); |
431
|
|
|
$ShipmentItem->setClassName1($ShipmentItem->getProductClass()->hasClassCategory1() |
432
|
|
|
? $ShipmentItem->getProductClass()->getClassCategory1()->getClassName()->getName() |
433
|
|
|
: null); |
|
|
|
|
434
|
|
|
$ShipmentItem->setClassName2($ShipmentItem->getProductClass()->hasClassCategory2() |
435
|
|
|
? $ShipmentItem->getProductClass()->getClassCategory2()->getClassName()->getName() |
436
|
|
|
: null); |
|
|
|
|
437
|
|
|
$ShipmentItem->setClassCategoryName1($ShipmentItem->getProductClass()->hasClassCategory1() |
438
|
|
|
? $ShipmentItem->getProductClass()->getClassCategory1()->getName() |
439
|
|
|
: null); |
|
|
|
|
440
|
|
|
$ShipmentItem->setClassCategoryName2($ShipmentItem->getProductClass()->hasClassCategory2() |
441
|
|
|
? $ShipmentItem->getProductClass()->getClassCategory2()->getName() |
442
|
|
|
: null); |
|
|
|
|
443
|
1 |
|
} |
444
|
|
|
} |
445
|
|
|
|
446
|
|
|
} |
447
|
|
|
|
448
|
|
|
// 受注データの税・小計・合計を再計算 |
449
|
|
|
$Order->setTax($taxtotal); |
450
|
|
|
$Order->setSubtotal($subtotal); |
451
|
|
|
$Order->setTotal($subtotal + $Order->getCharge() + $Order->getDeliveryFeeTotal() - $Order->getDiscount()); |
452
|
|
|
// お支払い合計は、totalと同一金額(2系ではtotal - point) |
453
|
|
|
$Order->setPaymentTotal($Order->getTotal()); |
454
|
|
|
} |
455
|
|
|
|
456
|
|
|
/** |
457
|
|
|
* 受注ステータスに応じて, 受注日/入金日/発送日を更新する, |
458
|
|
|
* 発送済ステータスが設定された場合は, お届け先情報の発送日も更新を行う. |
459
|
|
|
* |
460
|
|
|
* 編集の場合 |
461
|
|
|
* - 受注ステータスが他のステータスから発送済へ変更された場合に発送日を更新 |
462
|
|
|
* - 受注ステータスが他のステータスから入金済へ変更された場合に入金日を更新 |
463
|
|
|
* |
464
|
|
|
* 新規登録の場合 |
465
|
|
|
* - 受注日を更新 |
466
|
|
|
* - 受注ステータスが発送済に設定された場合に発送日を更新 |
467
|
|
|
* - 受注ステータスが入金済に設定された場合に入金日を更新 |
468
|
|
|
* |
469
|
|
|
* |
470
|
|
|
* @param $app |
471
|
|
|
* @param $TargetOrder |
472
|
|
|
* @param $OriginOrder |
473
|
|
|
*/ |
474
|
|
|
protected function updateDate($app, $TargetOrder, $OriginOrder) |
475
|
|
|
{ |
476
|
|
|
$dateTime = new \DateTime(); |
477
|
|
|
|
478
|
|
|
// 編集 |
479
|
|
|
if ($TargetOrder->getId()) { |
480
|
|
|
// 発送済 |
481
|
|
|
if ($TargetOrder->getOrderStatus()->getId() == $app['config']['order_deliv']) { |
482
|
|
|
// 編集前と異なる場合のみ更新 |
483
|
|
|
if ($TargetOrder->getOrderStatus()->getId() != $OriginOrder->getOrderStatus()->getId()) { |
484
|
|
|
$TargetOrder->setCommitDate($dateTime); |
485
|
|
|
// お届け先情報の発送日も更新する. |
486
|
|
|
$Shippings = $TargetOrder->getShippings(); |
487
|
|
|
foreach ($Shippings as $Shipping) { |
488
|
|
|
$Shipping->setShippingCommitDate($dateTime); |
489
|
|
|
} |
490
|
|
|
} |
491
|
|
|
// 入金済 |
492
|
|
|
} elseif ($TargetOrder->getOrderStatus()->getId() == $app['config']['order_pre_end']) { |
493
|
|
|
// 編集前と異なる場合のみ更新 |
494
|
|
|
if ($TargetOrder->getOrderStatus()->getId() != $OriginOrder->getOrderStatus()->getId()) { |
495
|
|
|
$TargetOrder->setPaymentDate($dateTime); |
496
|
|
|
} |
497
|
|
|
} |
498
|
|
|
// 新規 |
499
|
|
|
} else { |
500
|
|
|
// 発送済 |
501
|
|
|
if ($TargetOrder->getOrderStatus()->getId() == $app['config']['order_deliv']) { |
502
|
|
|
$TargetOrder->setCommitDate($dateTime); |
503
|
|
|
// お届け先情報の発送日も更新する. |
504
|
|
|
$Shippings = $TargetOrder->getShippings(); |
505
|
|
|
foreach ($Shippings as $Shipping) { |
506
|
|
|
$Shipping->setShippingCommitDate($dateTime); |
507
|
|
|
} |
508
|
|
|
// 入金済 |
509
|
|
|
} elseif ($TargetOrder->getOrderStatus()->getId() == $app['config']['order_pre_end']) { |
510
|
|
|
$TargetOrder->setPaymentDate($dateTime); |
511
|
|
|
} |
512
|
|
|
// 受注日時 |
513
|
|
|
$TargetOrder->setOrderDate($dateTime); |
514
|
|
|
} |
515
|
|
|
} |
516
|
|
|
} |
517
|
|
|
|