Skip to content

Commit

Permalink
削除した受注のポイントを集計しない対応。
Browse files Browse the repository at this point in the history
  • Loading branch information
ryo-endo committed May 6, 2016
1 parent 3f88bec commit 893aecf
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 2 deletions.
37 changes: 37 additions & 0 deletions Event/WorkPlace/AdminOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
* 受注編集で購入商品の構成が変更した際に以下処理を行う
* - 前回付与ポイントの打ち消し
Expand Down
9 changes: 9 additions & 0 deletions Helper/EventRoutineWorksHelper/EventRoutineWorksHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
19 changes: 19 additions & 0 deletions Helper/PointHistoryHelper/PointHistoryHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}
}
10 changes: 10 additions & 0 deletions PointEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
* 商品購入確認完了
* - 利用ポイント・保有ポイント・仮付与ポイント保存
Expand Down
9 changes: 7 additions & 2 deletions Repository/PointStatusRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\NoResultException;
use Eccube\Common\Constant;
use Plugin\Point\Entity\PointStatus;

/**
Expand All @@ -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();

Expand All @@ -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();

Expand Down
4 changes: 4 additions & 0 deletions event.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 893aecf

Please sign in to comment.