From 893aecff5f81ea2e0bac39812aa52f4f587991e3 Mon Sep 17 00:00:00 2001 From: ryo-endo Date: Fri, 6 May 2016 11:12:36 +0900 Subject: [PATCH] =?UTF-8?q?=E5=89=8A=E9=99=A4=E3=81=97=E3=81=9F=E5=8F=97?= =?UTF-8?q?=E6=B3=A8=E3=81=AE=E3=83=9D=E3=82=A4=E3=83=B3=E3=83=88=E3=82=92?= =?UTF-8?q?=E9=9B=86=E8=A8=88=E3=81=97=E3=81=AA=E3=81=84=E5=AF=BE=E5=BF=9C?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Event/WorkPlace/AdminOrder.php | 37 +++++++++++++++++++ .../EventRoutineWorksHelper.php | 9 +++++ .../PointHistoryHelper/PointHistoryHelper.php | 19 ++++++++++ PointEvent.php | 10 +++++ Repository/PointStatusRepository.php | 9 ++++- event.yml | 4 ++ 6 files changed, 86 insertions(+), 2 deletions(-) diff --git a/Event/WorkPlace/AdminOrder.php b/Event/WorkPlace/AdminOrder.php index 6b82c9200d4..9b11a6cd544 100644 --- a/Event/WorkPlace/AdminOrder.php +++ b/Event/WorkPlace/AdminOrder.php @@ -314,6 +314,43 @@ public function save(EventArgs $event) $this->pointUseEvent($event); } + /** + * 受注削除 + * @param EventArgs $event + */ + public function delete(EventArgs $event) + { + // 必要情報をセット + $this->targetOrder = $event->getArgument('Order'); + if (empty($this->targetOrder)) { + return; + } + $this->customer = $event->getArgument('Customer'); + if (empty($this->customer)) { + return; + } + + // ポイントステータスを削除にする + $this->history->deletePointStatus($this->targetOrder); + + // 会員ポイントの再計算 + $this->history->refreshEntity(); + $this->history->addEntity($this->targetOrder); + $this->history->addEntity($this->customer); + $currentPoint = $this->calculateCurrentPoint(); + $this->app['eccube.plugin.point.repository.pointcustomer']->savePoint( + $currentPoint, + $this->customer + ); + + // SnapShot保存 + $point = array(); + $point['current'] = $currentPoint; + $point['use'] = 0; + $point['add'] = 0; + $this->saveAdjustUseOrderSnapShot($point); + } + /** * 受注編集で購入商品の構成が変更した際に以下処理を行う * - 前回付与ポイントの打ち消し diff --git a/Helper/EventRoutineWorksHelper/EventRoutineWorksHelper.php b/Helper/EventRoutineWorksHelper/EventRoutineWorksHelper.php index ce1fe84ae24..f0ff068fbe1 100644 --- a/Helper/EventRoutineWorksHelper/EventRoutineWorksHelper.php +++ b/Helper/EventRoutineWorksHelper/EventRoutineWorksHelper.php @@ -70,4 +70,13 @@ public function save(EventArgs $event) { $this->place->save($event); } + + /** + * 受注削除拡張 + * @param EventArgs $event + */ + public function delete(EventArgs $event) + { + $this->place->delete($event); + } } diff --git a/Helper/PointHistoryHelper/PointHistoryHelper.php b/Helper/PointHistoryHelper/PointHistoryHelper.php index f3184135d37..9f6b782d3d2 100644 --- a/Helper/PointHistoryHelper/PointHistoryHelper.php +++ b/Helper/PointHistoryHelper/PointHistoryHelper.php @@ -4,6 +4,7 @@ namespace Plugin\Point\Helper\PointHistoryHelper; use Doctrine\DBAL\Exception\DatabaseObjectNotFoundException; +use Eccube\Entity\Order; use Plugin\Point\Entity\PointSnapshot; use Plugin\Point\Entity\Point; use Plugin\Point\Entity\PointStatus; @@ -290,4 +291,22 @@ public function fixPointStatus() $pointStatus->setPointFixDate(new \DateTime()); $this->app['orm.em']->flush(); } + + /** + * ポイントステータスを削除状態にする + * @param Order $order 対象オーダー + */ + public function deletePointStatus(Order $order) + { + $orderId = $order->getId(); + $pointStatus = $this->app['eccube.plugin.point.repository.pointstatus']->findOneBy( + array('order_id' => $orderId) + ); + if (!$pointStatus) { + return; + } + /** @var PointStatus $pointStatus */ + $pointStatus->setDelFlg(1); + $this->app['orm.em']->flush(); + } } diff --git a/PointEvent.php b/PointEvent.php index 6f26c779f5c..167b715fab2 100644 --- a/PointEvent.php +++ b/PointEvent.php @@ -200,6 +200,16 @@ public function onAdminOrderEditIndexComplete(EventArgs $event) //$this->save($event); } + /** + * 受注削除 + * @param EventArgs $event + */ + public function onAdminOrderDeleteComplete(EventArgs $event) + { + $helper = $this->app['eccube.plugin.point.hookpoint.routinework'](new AdminOrder()); + $helper->delete($event); + } + /** * 商品購入確認完了 * - 利用ポイント・保有ポイント・仮付与ポイント保存 diff --git a/Repository/PointStatusRepository.php b/Repository/PointStatusRepository.php index d0e69310845..9d5111faa09 100644 --- a/Repository/PointStatusRepository.php +++ b/Repository/PointStatusRepository.php @@ -5,6 +5,7 @@ use Doctrine\ORM\EntityRepository; use Doctrine\ORM\NoResultException; +use Eccube\Common\Constant; use Plugin\Point\Entity\PointStatus; /** @@ -29,8 +30,10 @@ public function selectOrderIdsWithUnfixedByCustomer($customer_id) ->select('p.order_id') ->andWhere('p.customer_id = :customer_id') ->andWhere('p.status = :status') + ->andWhere('p.del_flg = :del_flg') ->setParameter('customer_id', $customer_id) - ->setParameter('status', PointStatusRepository::POINT_STATUS_UNFIX); + ->setParameter('status', PointStatusRepository::POINT_STATUS_UNFIX) + ->setParameter('del_flg', 0); $result = $qb->getQuery()->getScalarResult(); @@ -54,8 +57,10 @@ public function selectOrderIdsWithFixedByCustomer($customer_id) ->select('p.order_id') ->andWhere('p.customer_id = :customer_id') ->andWhere('p.status = :status') + ->andWhere('p.del_flg = :del_flg') ->setParameter('customer_id', $customer_id) - ->setParameter('status', PointStatusRepository::POINT_STATUS_FIX); + ->setParameter('status', PointStatusRepository::POINT_STATUS_FIX) + ->setParameter('del_flg', 0); $result = $qb->getQuery()->getScalarResult(); diff --git a/event.yml b/event.yml index 3323d800995..9d9b463e6c4 100644 --- a/event.yml +++ b/event.yml @@ -19,6 +19,10 @@ admin.order.edit.index.progress: admin.order.edit.index.complete: - [onAdminOrderEditIndexComplete, NORMAL] +## 管理画面 > 受注一覧 +admin.order.delete.complete: + - [onAdminOrderDeleteComplete, NORMAL] + # フロント画面 ## フロント画面 > 商品購入確認完了(ポイント利用処理) front.shopping.confirm.processing: