app/Plugin/RemisePayment42/RemiseEvent.php line 172

Open in your IDE?
  1. <?php
  2. namespace Plugin\RemisePayment42;
  3. use Eccube\EntityPayment;
  4. use Eccube\Entity\Master\OrderStatus;
  5. use Eccube\Entity\Order;
  6. use Eccube\Entity\Payment;
  7. use Eccube\Event\EccubeEvents;
  8. use Eccube\Event\TemplateEvent;
  9. use Eccube\Event\EventArgs;
  10. use Eccube\Repository\CustomerRepository;
  11. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  12. use Symfony\Component\HttpFoundation\Session\SessionInterface;
  13. use Plugin\RemisePayment42\Entity\Config;
  14. use Plugin\RemisePayment42\Entity\ConfigInfo;
  15. use Plugin\RemisePayment42\Entity\OrderResult;
  16. use Plugin\RemisePayment42\Entity\OrderResultCard;
  17. use Plugin\RemisePayment42\Entity\OrderResultCvs;
  18. use Plugin\RemisePayment42\Entity\Payquick;
  19. use Plugin\RemisePayment42\Entity\RemisePayment;
  20. use Plugin\RemisePayment42\Service\UtilService;
  21. use Plugin\RemisePayment42\Service\AcService;
  22. use Plugin\RemisePayment42\Service\AcApiService;
  23. use Plugin\RemisePayment42\Repository\RemisePaymentRepository;
  24. use Plugin\RemisePayment42\Repository\RemiseSaleTypeRepository;
  25. use Plugin\RemisePayment42\Repository\RemiseACTypeRepository;
  26. use Plugin\RemisePayment42\Repository\RemiseACMemberRepository;
  27. /**
  28.  * イベント処理用
  29.  */
  30. class RemiseEvent implements EventSubscriberInterface
  31. {
  32.     /**
  33.      * @var SessionInterface
  34.      */
  35.     protected $session;
  36.     /**
  37.      * @var CustomerRepository
  38.      */
  39.     protected $customerRepository;
  40.     /**
  41.      * @var UtilService
  42.      */
  43.     protected $utilService;
  44.     /**
  45.      * @var AcService
  46.      */
  47.     protected $acService;
  48.     /**
  49.      * @var AcApiService
  50.      */
  51.     protected $acApiService;
  52.     /**
  53.      * @var RemisePaymentRepository
  54.      */
  55.     protected $remisePaymentRepository;
  56.     /**
  57.      *
  58.      * @var RemiseSaleTypeRepository
  59.      */
  60.     protected $remiseSaleTypeRepository;
  61.     /**
  62.      *
  63.      * @var RemiseACTypeRepository
  64.      */
  65.     protected $remiseACTypeRepository;
  66.     /**
  67.      *
  68.      * @var RemiseACMemberRepository
  69.      */
  70.     protected $remiseACMemberRepository;
  71.     /**
  72.      * コンストラクタ
  73.      *
  74.      * @param SessionInterface $session
  75.      * @param CustomerRepository $customerRepository
  76.      * @param UtilService $utilService
  77.      * @param AcService $acService
  78.      * @param AcApiService $acApiService
  79.      * @param RemisePaymentRepository $remisePaymentRepository
  80.      * @param RemiseSaleTypeRepository $remiseSaleTypeRepository
  81.      * @param RemiseACTypeRepository $remiseACTypeRepository
  82.      * @param RemiseACMemberRepository $remiseACMemberRepository
  83.      */
  84.     public function __construct(
  85.         SessionInterface $session,
  86.         CustomerRepository $customerRepository,
  87.         UtilService $utilService,
  88.         AcService $acService,
  89.         AcApiService $acApiService,
  90.         RemisePaymentRepository $remisePaymentRepository,
  91.         RemiseSaleTypeRepository $remiseSaleTypeRepository,
  92.         RemiseACTypeRepository $remiseACTypeRepository,
  93.         RemiseACMemberRepository $remiseACMemberRepository
  94.     ) {
  95.         $this->session $session;
  96.         $this->customerRepository $customerRepository;
  97.         $this->utilService $utilService;
  98.         $this->acService $acService;
  99.         $this->acApiService $acApiService;
  100.         $this->remisePaymentRepository $remisePaymentRepository;
  101.         $this->remiseSaleTypeRepository $remiseSaleTypeRepository;
  102.         $this->remiseACTypeRepository $remiseACTypeRepository;
  103.         $this->remiseACMemberRepository $remiseACMemberRepository;
  104.     }
  105.     /**
  106.      * @return array
  107.      */
  108.     public static function getSubscribedEvents()
  109.     {
  110.         return [
  111.             // 管理画面 支払方法登録・編集画面
  112.             '@admin/Setting/Shop/payment_edit.twig' => 'onAdminPaymentEditTwig',
  113.             // 管理画面 受注一覧
  114.             '@admin/Order/index.twig' => 'onAdminOrderIndexTwig',
  115.             // 管理画面 受注一覧(検索実行)
  116.             EccubeEvents::ADMIN_ORDER_INDEX_SEARCH => 'onAdminOrderIndexSearch',
  117.             // 管理画面 受注登録
  118.             '@admin/Order/edit.twig' => 'onAdminOrderEditTwig',
  119.             // 管理画面 会員一覧
  120.             '@admin/Customer/index.twig' => 'onAdminCustomerIndexTwig',
  121.             // 管理画面 会員登録・編集
  122.             '@admin/Customer/edit.twig' => 'onAdminCustomerEditTwig',
  123.             // 管理画面 商品登録
  124.             '@admin/Product/product.twig' => 'onAdminProductProductTwig',
  125.             // 管理画面 商品登録完了イベント
  126.             EccubeEvents::ADMIN_PRODUCT_EDIT_COMPLETE => 'onAdminProductEditComplete',
  127.             // 管理画面 商品規格
  128.             '@admin/Product/product_class.twig' => 'onAdminProductProductClassTwig',
  129.             // 管理画面 配送方法設定
  130.             '@admin/Setting/Shop/delivery_edit.twig' => 'onAdminSettingSystemDeliveryEditTwig',
  131.             // 管理画面 マスターデータ管理
  132.             '@admin/Setting/System/masterdata.twig' => 'onAdminSettingSystemMasterdataTwig',
  133.             // ショッピングカート
  134.             'Cart/index.twig' => 'onCartIndexTwig',
  135.             // ご注文手続き
  136.             'Shopping/index.twig' => 'onShoppingIndexTwig',
  137.             // ご注文内容のご確認
  138.             'Shopping/confirm.twig' => 'onShoppingConfirmTwig',
  139.             // ご注文完了
  140.             'Shopping/complete.twig' => 'onShoppingCompleteTwig',
  141.             // マイページ/ご注文履歴一覧
  142.             'Mypage/index.twig' => 'onMypageIndexTwig',
  143.             // マイページ/ご注文履歴詳細
  144.             'Mypage/history.twig' => 'onMypageHistoryTwig',
  145.             // マイページ/会員情報編集
  146.             'Mypage/change.twig' => 'onMypageChangeTwig',
  147.             // マイページ/退会
  148.             'Mypage/withdraw.twig' => 'onMypageWithdrawTwig',
  149.         ];
  150.     }
  151.     /**
  152.      * 管理画面 商品登録画面
  153.      *
  154.      * @param $event
  155.      */
  156.     public function onAdminProductProductTwig(TemplateEvent $event)
  157.     {
  158.         // プラグイン設定情報の取得
  159.         $Config $this->utilService->getConfig();
  160.         if (!$Config) {
  161.             return;
  162.         }
  163.         // 設定情報の取得
  164.         $ConfigInfo $Config->getUnserializeInfo();
  165.         if (!$ConfigInfo) {
  166.             return;
  167.         }
  168.         // 定期購買が無効の場合
  169.         if(!$ConfigInfo->useOptionAC())
  170.         {
  171.             return;
  172.         }
  173.         // ルミーズ販売種別(定期購買)既存レコード確認
  174.         $RemiseSaleTypes $this->remiseSaleTypeRepository->findBy([
  175.             'sale_type' => trans('remise_payment4.ac.sale_type')
  176.         ], [
  177.             'id' => 'DESC'
  178.         ]);
  179.         if (! $RemiseSaleTypes) {
  180.             return;
  181.         }
  182.         // ルミーズ定期購買種別
  183.         $remiseACTypes $this->remiseACTypeRepository->findBy([
  184.             'visible' => '1'
  185.         ], [
  186.             'sort_no' => 'DESC'
  187.         ]);
  188.         if (! $remiseACTypes) {
  189.             return;
  190.         }
  191.         // 商品情報を取得
  192.         $Product $event->getParameter('Product');
  193.         if ($Product && $Product->getId() != null && $Product->getId() != "") {
  194.             // 規格有りの場合、出力しない
  195.             $has_class $Product->hasProductClass();
  196.             if ($has_class) {
  197.                 return;
  198.             }
  199.         }
  200.         $event->setParameter('RemiseSaleTypes'$RemiseSaleTypes);
  201.         $asset 'RemisePayment42/Resource/template/admin/sub_product_edit.twig';
  202.         $event->addAsset($asset);
  203.         return;
  204.     }
  205.     /**
  206.      *  管理画面 商品登録完了イベント
  207.      *
  208.      * @param $event
  209.      */
  210.     public function onAdminProductEditComplete(EventArgs $eventArgs)
  211.     {
  212.         // プラグイン設定情報の取得
  213.         $Config $this->utilService->getConfig();
  214.         if (!$Config) {
  215.             return;
  216.         }
  217.         // 設定情報の取得
  218.         $ConfigInfo $Config->getUnserializeInfo();
  219.         if (!$ConfigInfo) {
  220.             return;
  221.         }
  222.         // 定期購買が無効の場合
  223.         if(!$ConfigInfo->useOptionAC())
  224.         {
  225.             return;
  226.         }
  227.         // form情報取得
  228.         $form $eventArgs->getArgument('form');
  229.         // 商品情報取得
  230.         $Product $eventArgs->getArgument('Product');
  231.         // 規格有りの商品の場合、処理を抜ける
  232.         $has_class $Product->hasProductClass();
  233.         if ($has_class) {
  234.             return;
  235.         }
  236.         // ルミーズ定期購買金額取得
  237.         $acAmount $form->get('remise_payment4_ac_amount')->getViewData();
  238.         $acAmount str_replace(',','',$acAmount);
  239.         // ルミーズ定期購買種別取得
  240.         $acAcType $form->get('remise_payment4_ac_actype_id')->getViewData();
  241.         // ルミーズ定期購買ポイント付与
  242.         $acPointFlg $form->get('remise_payment4_ac_point_flg')->getViewData();
  243.         // 商品規格情報を取得(規格無し商品でも、デフォルトで1件必ず存在する)
  244.         $ProductClasses $Product->getProductClasses();
  245.         // ルミーズ定期購買商品登録
  246.         $this->acService->saveACProduct($ProductClasses[0], $acAmount$acAcType$acPointFlg);
  247.     }
  248.     /**
  249.      * 管理画面 商品規格画面
  250.      *
  251.      * @param $event
  252.      */
  253.     public function onAdminProductProductClassTwig(TemplateEvent $event)
  254.     {
  255.         // プラグイン設定情報の取得
  256.         $Config $this->utilService->getConfig();
  257.         if (!$Config) {
  258.             return;
  259.         }
  260.         // 設定情報の取得
  261.         $ConfigInfo $Config->getUnserializeInfo();
  262.         if (!$ConfigInfo) {
  263.             return;
  264.         }
  265.         // 定期購買が無効の場合
  266.         if(!$ConfigInfo->useOptionAC())
  267.         {
  268.             return;
  269.         }
  270.         $asset 'RemisePayment42/Resource/assets/js/admin/sub_product_class_index.js';
  271.         $event->addAsset($asset);
  272.     }
  273.     /**
  274.      * 管理画面 支払方法登録・編集画面
  275.      *
  276.      * @param $event
  277.      */
  278.     public function onAdminPaymentEditTwig(TemplateEvent $event)
  279.     {
  280.         // 表示対象のEC-CUBE支払方法を取得
  281.         $Payment $event->getParameter('Payment');
  282.         if (!$Payment)
  283.         {
  284.             return;
  285.         }
  286.         // ルミーズ支払方法取得の取得
  287.         $RemisePayment $this->utilService->getRemisePayment($Payment->getId());
  288.         if (!$RemisePayment)
  289.         {
  290.             return;
  291.         }
  292.         // カード決済の場合
  293.         if ($RemisePayment->getKind() == trans('remise_payment4.common.label.payment.kind.card'))
  294.         {
  295.             // 手数料の項目を消す
  296.             $asset 'RemisePayment42/Resource/assets/js/admin/sub_payment_edit_card.js';
  297.             $event->addAsset($asset);
  298.         }
  299.         // マルチ決済の場合
  300.         else if ($RemisePayment->getKind() == trans('remise_payment4.common.label.payment.kind.cvs'))
  301.         {
  302.             // 支払方法の複製ボタンを追加
  303.             $asset 'RemisePayment42/Resource/assets/js/admin/sub_payment_edit_cvs.js';
  304.             $event->addAsset($asset);
  305.         }
  306.     }
  307.     /**
  308.      * 管理画面 受注一覧
  309.      *
  310.      * @param $event
  311.      */
  312.     public function onAdminOrderIndexTwig(TemplateEvent $event)
  313.     {
  314.         // プラグイン設定情報の取得
  315.         $Config $this->utilService->getConfig();
  316.         if (!$Config)
  317.         {
  318.             return;
  319.         }
  320.         // 設定情報の取得
  321.         $ConfigInfo $Config->getUnserializeInfo();
  322.         if (!$ConfigInfo)
  323.         {
  324.             return;
  325.         }
  326.         // 定期購買検索用の検索フォームを設定
  327.         if($ConfigInfo->useOptionAC())
  328.         {
  329.             $snippet 'RemisePayment42/Resource/template/admin/sub_order_index_ac.twig';
  330.             $event->addSnippet($snippet);
  331.         }
  332.         // 表示対象の受注一覧を取得
  333.         $pagination $event->getParameter('pagination');
  334.         if (empty($pagination) || count($pagination) == 0)
  335.         {
  336.             return;
  337.         }
  338.         // 受注一覧から受注番号を取得
  339.         $orderIds = array();
  340.         foreach ($pagination as $Order)
  341.         {
  342.             $orderIds[] = $Order->getId();
  343.             $orderNos[$Order->getId()] = $Order->getOrderNo();
  344.         }
  345.         if (empty($orderIds))
  346.         {
  347.             return;
  348.         }
  349.         $event->setParameter('orderNos'$orderNos);
  350.         // 受注未確定の決済履歴詳細を取得
  351.         $OrderResultCardsNotCompleted $this->utilService->getOrderResultCardForNotCompleted($orderIds);
  352.         // 課金失敗の決済履歴詳細を取得
  353.         $OrderResultCardsAcFailed $this->utilService->getOrderResultCardForAcFailed($orderIds);
  354.         if($OrderResultCardsNotCompleted || $OrderResultCardsAcFailed)
  355.         {
  356.             if($OrderResultCardsNotCompleted)
  357.             {
  358.                 // 受注未確定の決済履歴詳細
  359.                 $event->setParameter('NotCompletedOrderResultCards'$OrderResultCardsNotCompleted);
  360.             }else{
  361.                 $event->setParameter('NotCompletedOrderResultCards', Array());
  362.             }
  363.             if($OrderResultCardsAcFailed)
  364.             {
  365.                 // 課金失敗の決済履歴詳細
  366.                 $event->setParameter('AcFailedOrderResultCards'$OrderResultCardsAcFailed);
  367.             }else{
  368.                 $event->setParameter('AcFailedOrderResultCards', Array());
  369.             }
  370.             // 注文状況へ課金失敗の表記追加
  371.             $asset 'RemisePayment42/Resource/assets/js/admin/sub_order_index.js';
  372.             $event->addAsset($asset);
  373.         }
  374.         if (!$ConfigInfo->useOptionExtset())
  375.         {
  376.             return;
  377.         }
  378.         if($ConfigInfo->useOptionExtset())
  379.         {
  380.             // 決済履歴詳細を取得
  381.             $states = Array(
  382.                 trans('remise_payment4.common.label.card.state.result'),
  383.                 trans('remise_payment4.common.label.card.state.complete'),
  384.                 trans('remise_payment4.common.label.card.state.result.deleted'),
  385.                 trans('remise_payment4.common.label.card.state.result.ac.failed'),
  386.                 trans('remise_payment4.common.label.card.state.result.ac.success'));
  387.             $ExtsetOrderResultCards $this->utilService->getOrderResultCardsOrderIdsStates($orderIds,$states);
  388.             $event->setParameter('ExtsetOrderResultCards'$ExtsetOrderResultCards);
  389.             // 本体側のステータス、受注番号を取得
  390.             $ExtsetOrderResultCardsOrderState = array();
  391.             foreach ($ExtsetOrderResultCards as $ExtsetOrderResultCard)
  392.             {
  393.                 $Order $this->utilService->getOrder($ExtsetOrderResultCard->getId());
  394.                 $ExtsetOrderResultCardsOrderState[$ExtsetOrderResultCard->getId()] = $Order->getOrderStatus()['id'];
  395.             }
  396.             $event->setParameter('ExtsetOrderResultCardsOrderState'$ExtsetOrderResultCardsOrderState);
  397.             $snippet 'RemisePayment42/Resource/template/admin/sub_order_index.twig';
  398.             $event->addSnippet($snippet);
  399.             $asset 'RemisePayment42/Resource/assets/js/admin/sub_order_index_extset.js';
  400.             $event->addAsset($asset);
  401.         }
  402.     }
  403.     /**
  404.      * 管理画面 受注一覧(検索実行)
  405.      *
  406.      * @param $event
  407.      */
  408.     public function onAdminOrderIndexSearch(EventArgs $event)
  409.     {
  410.         // SQLを取得
  411.         $qb $event->getArgument('qb');
  412.         // リクエスト情報を取得
  413.         $request $event->getRequest();
  414.         if ('POST' === $request->getMethod()) {
  415.             // 検索実行時の検索条件を取得
  416.             $requestData $request->request->all();
  417.             $admin_search_order $this->utilService->getValue($requestData'admin_search_order');
  418.             $result_status_array $this->utilService->getValue($admin_search_order'remise_payment4_ac_result_status');
  419.             $member_id $this->utilService->getValue($admin_search_order'remise_payment4_ac_member_id');
  420.         }else{
  421.             // 検索実行時以外(他画面からの遷移など)の検索条件を取得
  422.             $viewData $this->session->get('eccube.admin.order.search', []);
  423.             $result_status_array $this->utilService->getValue($viewData'remise_payment4_ac_result_status');
  424.             $member_id $this->utilService->getValue($viewData'remise_payment4_ac_member_id');
  425.         }
  426.         // テーブル結合
  427.         if($result_status_array || $member_id){
  428.             $qb
  429.             ->innerJoin('\Plugin\RemisePayment42\Entity\OrderResultCard''rms_orc''WITH''rms_orc.id = o.id')
  430.             ->innerJoin('\Plugin\RemisePayment42\Entity\RemiseACMember''rms_acm''WITH''rms_acm.id = rms_orc.member_id')
  431.             ->innerJoin('\Plugin\RemisePayment42\Entity\RemiseACResult''rms_acr''WITH''rms_acr.id = o.id');
  432.         }
  433.         // 自動継続課金結果の検索条件追加
  434.         if($result_status_array){
  435.             $qb
  436.             ->andWhere('rms_acr.result IN (:result_status)')
  437.             ->setParameter('result_status'$result_status_array);
  438.         }
  439.         // メンバーIDの検索条件追加
  440.         if($member_id){
  441.             $qb
  442.             ->andWhere('rms_orc.member_id = :member_id')
  443.             ->setParameter('member_id'$member_id);
  444.         }
  445.     }
  446.     /**
  447.      * 管理画面 受注登録
  448.      *
  449.      * @param $event
  450.      */
  451.     public function onAdminOrderEditTwig(TemplateEvent $event)
  452.     {
  453.         // 表示対象の受注情報を取得
  454.         $Order $event->getParameter('Order');
  455.         if (!$Order)
  456.         {
  457.             return;
  458.         }
  459.         if (!$Order->getOrderStatus())
  460.         {
  461.             return;
  462.         }
  463.         // ステータス 決済処理中、購入処理中 は対象外
  464.         if ($Order->getOrderStatus()->getId() == OrderStatus::PENDING
  465.          || $Order->getOrderStatus()->getId() == OrderStatus::PROCESSING)
  466.         {
  467.             return;
  468.         }
  469.         // EC-CUBE支払方法の取得
  470.         $Payment $Order->getPayment();
  471.         if (!$Payment)
  472.         {
  473.             return;
  474.         }
  475.         $paymentId $Payment->getId();
  476.         // ルミーズ支払方法の取得
  477.         $RemisePayment $this->utilService->getRemisePayment($paymentId);
  478.         if (!$RemisePayment)
  479.         {
  480.             return;
  481.         }
  482.         // 決済履歴の取得
  483.         $OrderResult $this->utilService->getOrderResult($Order->getId());
  484.         if (!$OrderResult)
  485.         {
  486.             return;
  487.         }
  488.         $OrderResultCard null;
  489.         $OrderResultCvs null;
  490.         $cvsInfo null;
  491.         // カード決済
  492.         if ($RemisePayment->getKind() == trans('remise_payment4.common.label.payment.kind.card'))
  493.         {
  494.             // 決済履歴詳細の取得
  495.             $OrderResultCard $this->utilService->getOrderResultCard($Order->getId());
  496.             if (!$OrderResultCard)
  497.             {
  498.                 return;
  499.             }
  500.             // 受注未確定のwarningメッセージ
  501.             if ($OrderResultCard->getState() == trans('remise_payment4.common.label.card.state.result'))
  502.             {
  503.                 $this->session->getFlashBag()->add('eccube.'."admin".'.warning'trans('remise_payment4.admin_order_edit.text.card.state.result.warning'));
  504.             }
  505.             // 課金失敗のwarningメッセージ
  506.             if ($OrderResultCard->getState() == trans('remise_payment4.common.label.card.state.result.ac.failed'))
  507.             {
  508.                 $this->session->getFlashBag()->add('eccube.'."admin".'.warning'trans('remise_payment4.admin_order_edit.text.card.state.result.ac.failed.warning'));
  509.             }
  510.         }
  511.         // マルチ決済
  512.         if ($RemisePayment->getKind() == trans('remise_payment4.common.label.payment.kind.cvs'))
  513.         {
  514.             // 決済履歴詳細の取得
  515.             $OrderResultCvs $this->utilService->getOrderResultCvs($Order->getId());
  516.             if (!$OrderResultCvs)
  517.             {
  518.                 return;
  519.             }
  520.             // 追加情報
  521.             $cvsInfo $this->utilService->getCvsInfo($Order$OrderResultCvs);
  522.         }
  523.         // プラグイン設定情報の取得
  524.         $Config $this->utilService->getConfig();
  525.         // 設定情報の取得
  526.         if ($Config) {
  527.             $ConfigInfo $Config->getUnserializeInfo();
  528.             // 拡張セットが有効の場合
  529.             if($ConfigInfo->useOptionExtset() && $RemisePayment->getKind() == trans('remise_payment4.common.label.payment.kind.card'))
  530.             {
  531.                 if(($OrderResultCard->getState() == trans('remise_payment4.common.label.card.state.complete')
  532.                     || $OrderResultCard->getState() == trans('remise_payment4.common.label.card.state.result.deleted')
  533.                     || $OrderResultCard->getState() == trans('remise_payment4.common.label.card.state.result.ac.success'))
  534.                     && $Order->getOrderStatus()['id'] != OrderStatus::CANCEL
  535.                     && $Order->getOrderStatus()['id'] != OrderStatus::RETURNED
  536.                     && $Order->getOrderStatus()['id'] != OrderStatus::PENDING
  537.                     && $Order->getOrderStatus()['id'] != OrderStatus::PROCESSING
  538.                 )
  539.                 {
  540.                     $event->setParameter('OptionExtset'true);
  541.                     $remisePaymentCard $this->remisePaymentRepository->findByKind(trans('remise_payment4.common.label.payment.kind.card'));
  542.                     $event->setParameter('RemisePaymentCard'$remisePaymentCard[0]);
  543.                 }
  544.             }
  545.         }
  546.         // 決済履歴
  547.         $event->setParameter('OrderResult'$OrderResult);
  548.         // 決済履歴詳細
  549.         $event->setParameter('OrderResultCard'$OrderResultCard);
  550.         $event->setParameter('OrderResultCvs'$OrderResultCvs);
  551.         // 追加情報
  552.         $event->setParameter('CvsInfo'$cvsInfo);
  553.         // ルミーズ決済情報の表示欄追加
  554.         $snippet 'RemisePayment42/Resource/template/admin/sub_order_edit.twig';
  555.         $event->addSnippet($snippet);
  556.         // 定期購買が有効な場合
  557.         if($ConfigInfo->useOptionAC()){
  558.             $total $Order->getTotal();
  559.             $paymentTotal $Order->getPaymentTotal();
  560.             // 定期購買情報取得
  561.             $RemiseACMember $this->acService->getRemiseACMemberByOrderId($Order->getId());
  562.             // 定期購買商品、かつ、合計とお支払い合計に差分がある場合
  563.             if($RemiseACMember && $total != $paymentTotal){
  564.                 $difference = ($total $paymentTotal) * -1;
  565.                 $event->setParameter('difference'$difference);
  566.                 $snippet 'RemisePayment42/Resource/template/admin/sub_order_edit_ac.twig';
  567.                 $event->addSnippet($snippet);
  568.             }
  569.         }
  570.     }
  571.     /**
  572.      * 管理画面 会員一覧
  573.      *
  574.      * @param $event
  575.      */
  576.     public function onAdminCustomerIndexTwig(TemplateEvent $event)
  577.     {
  578.         $customers $this->customerRepository->findAll();
  579.         $customerIds = array();
  580.         foreach($customers as $customer){
  581.             $customerIds[] = $customer->getId();
  582.         }
  583.         $Customers $this->remiseACMemberRepository->getCustomersByCustomerIds($customerIds);
  584.         $event->setParameter('Customers'$Customers);
  585.         $asset 'RemisePayment42/Resource/assets/js/admin/sub_customer_index.js';
  586.         $event->addAsset($asset);
  587.     }
  588.     /**
  589.      * 管理画面 会員登録・編集
  590.      *
  591.      * @param $event
  592.      */
  593.     public function onAdminCustomerEditTwig(TemplateEvent $event)
  594.     {
  595.         // 表示対象の会員情報を取得
  596.         $Customer $event->getParameter('Customer');
  597.         if (!$Customer || $Customer->getId() == null)
  598.         {
  599.             return;
  600.         }
  601.         // ペイクイック情報の取得
  602.         $Payquick $this->utilService->getPayquickByCustomer($Customer);
  603.         if (!$Payquick)
  604.         {
  605.             return;
  606.         }
  607.         // ペイクイック情報
  608.         $event->setParameter('Payquick'$Payquick);
  609.         // カードご利用情報の表示欄追加
  610.         $snippet 'RemisePayment42/Resource/template/admin/sub_customer_edit.twig';
  611.         $event->addSnippet($snippet);
  612.         $asset 'RemisePayment42/Resource/assets/css/payquick.css';
  613.         $event->addAsset($asset);
  614.         // 会員に紐づく継続中の定期購買情報を検索
  615.         $remiseACMembers $this->remiseACMemberRepository->getRemiseACMembersByCustomerId($Customer->getId());
  616.         if($remiseACMembers){
  617.             // 継続中の定期購買がある場合、退会をさせない
  618.             $asset 'RemisePayment42/Resource/assets/js/admin/sub_customer_edit.js';
  619.             $event->addAsset($asset);
  620.         }
  621.     }
  622.     /**
  623.      * 配送先設定
  624.      *
  625.      * @param $event
  626.      */
  627.     public function onAdminSettingSystemDeliveryEditTwig(TemplateEvent $event)
  628.     {
  629.         // ルミーズ販売種別(定期購買)既存レコード確認
  630.         $RemiseSaleTypes $this->remiseSaleTypeRepository->findBy([
  631.             'sale_type' => trans('remise_payment4.ac.sale_type')
  632.         ], [
  633.             'id' => 'DESC'
  634.         ]);
  635.         if (! $RemiseSaleTypes) {
  636.             return;
  637.         }
  638.         $event->setParameter('RemiseSaleTypes'$RemiseSaleTypes);
  639.         $asset 'RemisePayment42/Resource/assets/js/admin/sub_delivery_edit.js';
  640.         $event->addAsset($asset);
  641.     }
  642.     /**
  643.      * マスターデータ管理
  644.      *
  645.      * @param $event
  646.      */
  647.     public function onAdminSettingSystemMasterdataTwig(TemplateEvent $event)
  648.     {
  649.         // リクエスト情報を取得
  650.         $form $event->getParameter('form');
  651.         $masterdata $form->offsetGet('masterdata');
  652.         if(strcmp($masterdata->vars['value'],'Eccube-Entity-Master-SaleType') != 0) {
  653.             return;
  654.         }
  655.         // プラグイン設定情報の取得
  656.         $Config $this->utilService->getConfig();
  657.         if (!$Config) {
  658.             return;
  659.         }
  660.         // 設定情報の取得
  661.         $ConfigInfo $Config->getUnserializeInfo();
  662.         if (!$ConfigInfo) {
  663.             return;
  664.         }
  665.         // 定期購買が無効の場合
  666.         if(!$ConfigInfo->useOptionAC())
  667.         {
  668.             return;
  669.         }
  670.         $snippet 'RemisePayment42/Resource/template/admin/sub_masterdata_edit.twig';
  671.         $event->addSnippet($snippet);
  672.     }
  673.     /**
  674.      * ショッピングカート
  675.      *
  676.      * @param $event
  677.      */
  678.     public function onCartIndexTwig(TemplateEvent $event)
  679.     {
  680.         // プラグイン設定情報の取得
  681.         $Config $this->utilService->getConfig();
  682.         if (!$Config) {
  683.             return;
  684.         }
  685.         // 設定情報の取得
  686.         $ConfigInfo $Config->getUnserializeInfo();
  687.         if (!$ConfigInfo) {
  688.             return;
  689.         }
  690.         // 定期購買が無効の場合
  691.         if(!$ConfigInfo->useOptionAC())
  692.         {
  693.             return;
  694.         }
  695.         // カートの商品情報を取得
  696.         $Carts $event->getParameter('Carts');
  697.         if(!$Carts){
  698.             return;
  699.         }
  700.         $cartKeys $this->acService->checkACCartDuplicate($Carts);
  701.         if($cartKeys != null)
  702.         {
  703.             // 購入手続きボタン無効化JavaScriptを差し込む
  704.             $event->setParameter('remiseAcCartKeys'$cartKeys);
  705.             $asset 'RemisePayment42/Resource/assets/js/sub_cart_index.js';
  706.             $event->addAsset($asset);
  707.             $this->session->getFlashBag()->add('eccube.'.'front.cart'.'.error'trans('remise_payment4.ac.front.cart.duplicate.text'));
  708.         }else{
  709.             return;
  710.         }
  711.     }
  712.     /**
  713.      * ご注文手続き
  714.      *
  715.      * @param $event
  716.      */
  717.     public function onShoppingIndexTwig(TemplateEvent $event)
  718.     {
  719.         // 表示対象の受注情報を取得
  720.         $Order $event->getParameter('Order');
  721.         if (!$Order)
  722.         {
  723.             return;
  724.         }
  725.         // セッションから処理中の受注番号を取得
  726.         $orderId $this->session->get('remise_payment4.order_id');
  727.         if (is_null($orderId))
  728.         {
  729.             $orderId '';
  730.         }
  731.         // セッションに保持している受注番号と表示対象の注文番号が不一致の場合
  732.         if ($orderId != "" && $orderId != $Order->getId())
  733.         {
  734.             // セッションクリア
  735.             $this->session->remove('remise_payment4.payquick_state.' $orderId);
  736.             $this->session->remove('remise_payment4.use_payquick.' $orderId);
  737.             $this->session->remove('remise_payment4.method.' $orderId);
  738.             $this->session->remove('remise_payment4.ptimes.' $orderId);
  739.             $this->session->remove('remise_payment4.regist_payquick.' $orderId);
  740.             $this->session->remove('remise_payment4.order_no');
  741.         }
  742.         // セッション設定
  743.         $orderId $Order->getId();
  744.         $this->session->set('remise_payment4.order_id'$orderId);
  745.         // EC-CUBE支払方法の取得
  746.         $Payment $Order->getPayment();
  747.         if (!$Payment)
  748.         {
  749.             return;
  750.         }
  751.         $paymentId $Payment->getId();
  752.         // ルミーズ支払方法の取得
  753.         $RemisePayment $this->utilService->getRemisePayment($paymentId);
  754.         if (!$RemisePayment)
  755.         {
  756.             return;
  757.         }
  758.         // カード決済の場合
  759.         if ($RemisePayment->getKind() == trans('remise_payment4.common.label.payment.kind.card'))
  760.         {
  761.             // 行程の追加
  762.             $asset 'RemisePayment42/Resource/assets/js/sub_shopping_flow.js';
  763.             $event->addAsset($asset);
  764.             // プラグイン設定情報の取得
  765.             $ConfigInfo $this->utilService->getConfigInfo();
  766.             if (!$ConfigInfo)
  767.             {
  768.                 return;
  769.             }
  770.             // 定期購買が有効の場合
  771.             if($ConfigInfo->useOptionAC())
  772.             {
  773.                 if(!$this->acService->checkACOrderDuplicate($Order))
  774.                 {
  775.                     $asset 'RemisePayment42/Resource/assets/js/sub_shopping_index_redirect_to_cart.js';
  776.                     $event->addAsset($asset);
  777.                     return;
  778.                 }
  779.                 // 商品規格情報取得
  780.                 $ProductClass $this->acService->getProductClassByOrder($Order);
  781.                 // ルミーズ定期購買種別マスタ取得
  782.                 $RemiseAcType $this->acService->getRemiseAcTypeByProductClass($ProductClass);
  783.                 if($RemiseAcType){
  784.                     // 課金間隔取得
  785.                     $interval "";
  786.                     if (strcmp($RemiseAcType->getIntervalMark(), trans('remise_payment4.ac.plg_remise_payment4_remise_ac_type.interval_marks.m.key')) == 0)
  787.                     {
  788.                         $interval $RemiseAcType->getIntervalValue().trans('remise_payment4.ac.plg_remise_payment4_remise_ac_type.interval_marks.m.value');
  789.                     }
  790.                     else if(strcmp($RemiseAcType->getIntervalMark(), trans('remise_payment4.ac.plg_remise_payment4_remise_ac_type.interval_marks.d.key')) == 0)
  791.                     {
  792.                         $interval $RemiseAcType->getIntervalValue().trans('remise_payment4.ac.plg_remise_payment4_remise_ac_type.interval_marks.d.value');
  793.                     }
  794.                     // 初回課金日取得
  795.                     $firstDate $this->acService->getFirstDate($RemiseAcType, new \DateTime());
  796.                     // 次回課金額
  797.                     $RemiseACMember $this->acService->createRemiseACMember($Order);
  798.                     $remiseAcAmount $RemiseACMember->getTotal();
  799.                     // 課金回数
  800.                     if($RemiseAcType->getCount() && $RemiseAcType->getCount() > 0){
  801.                         $countText $RemiseAcType->getCount().trans('remise_payment4.ac.plg_remise_payment4_remise_ac_type.count.value');
  802.                     }else{
  803.                         $countText "";
  804.                     }
  805.                     $event->setParameter('RemiseProductClass'$ProductClass);
  806.                     $event->setParameter('RemiseAcType'$RemiseAcType);
  807.                     $event->setParameter('remiseAcAmount'$remiseAcAmount);
  808.                     $event->setParameter('remiseAcFirstDate',$firstDate);
  809.                     $event->setParameter('remiseAcInterval'$interval);
  810.                     $event->setParameter('remiseAcCount'$countText);
  811.                     $snippet 'RemisePayment42/Resource/template/sub_shopping_index_autocharge.twig';
  812.                     $event->addSnippet($snippet);
  813.                 }
  814.             }
  815.             // 会員の注文処理でペイクイックを「利用する」の場合
  816.             if ($Order->getCustomer() && $ConfigInfo->getPayquickFlag() === '1')
  817.             {
  818.                 // ペイクイック情報の取得
  819.                 $Payquick $this->utilService->getPayquickByCustomer($Order->getCustomer());
  820.                 // ペイクイック情報
  821.                 $event->setParameter('Payquick'$Payquick);
  822.                 // セッションから情報の取得
  823.                 $regist_payquick '0';
  824.                 $use_payquick '0';
  825.                 $method '';
  826.                 $ptimes '';
  827.                 if ($Payquick)
  828.                 {
  829.                     // 支払方法の取得
  830.                     $configUseMethod $ConfigInfo->getUseMethod();
  831.                     if (empty($configUseMethod)) $configUseMethod = array();
  832.                     sort($configUseMethod);
  833.                     $useMethod = [];
  834.                     foreach ($configUseMethod as $key => $value)
  835.                     {
  836.                         $useMethod[trans('remise_payment4.common.label.card_method.' $value)] = $value;
  837.                     }
  838.                     // 分割回数の取得
  839.                     $configPtimes $ConfigInfo->getPtimes();
  840.                     if (empty($configPtimes)) $configPtimes = array();
  841.                     sort($configPtimes);
  842.                     $usePtimes = [];
  843.                     foreach ($configPtimes as $key => $value)
  844.                     {
  845.                         $usePtimes[$value trans('remise_payment4.common.label.card_ptimes_count')] = $value;
  846.                     }
  847.                     $event->setParameter('useMethod'$useMethod);
  848.                     $event->setParameter('usePtimes'$usePtimes);
  849.                     // ペイクイック利用
  850.                     $work $this->session->get('remise_payment4.use_payquick.' $orderId);
  851.                     if (isset($work))
  852.                     {
  853.                         $use_payquick $work;
  854.                     }
  855.                     else {
  856.                         $use_payquick '1';
  857.                     }
  858.                     // 支払方法
  859.                     $work $this->session->get('remise_payment4.method.' $orderId);
  860.                     if (isset($work))
  861.                     {
  862.                         $method $work;
  863.                     }
  864.                     else {
  865.                         foreach ($configUseMethod as $key => $value)
  866.                         {
  867.                             $method $value;
  868.                             break;
  869.                         }
  870.                     }
  871.                     // 分割回数
  872.                     $work $this->session->get('remise_payment4.ptimes.' $orderId);
  873.                     if (isset($work))
  874.                     {
  875.                         $ptimes $work;
  876.                     }
  877.                     else {
  878.                         foreach ($configPtimes as $key => $value)
  879.                         {
  880.                             $ptimes $value;
  881.                             break;
  882.                         }
  883.                     }
  884.                     // クレジットカード登録
  885.                     if ($use_payquick == '1') {
  886.                         $regist_payquick '1';
  887.                     }
  888.                     else {
  889.                         $work $this->session->get('remise_payment4.regist_payquick.' $orderId);
  890.                         if (isset($work))
  891.                         {
  892.                             $regist_payquick $work;
  893.                         }
  894.                     }
  895.                 }
  896.                 else {
  897.                     // クレジットカード登録
  898.                     $work $this->session->get('remise_payment4.regist_payquick.' $orderId);
  899.                     if (isset($work))
  900.                     {
  901.                         $regist_payquick $work;
  902.                     }
  903.                 }
  904.                 // カードご利用情報
  905.                 $PayquickInfo = array();
  906.                 $PayquickInfo['regist_payquick'] = $regist_payquick;
  907.                 $PayquickInfo['use_payquick'] = $use_payquick;
  908.                 $PayquickInfo['method'] = $method;
  909.                 $PayquickInfo['ptimes'] = $ptimes;
  910.                 $event->setParameter('PayquickInfo'$PayquickInfo);
  911.                 // カードご利用情報の表示欄追加
  912.                 $snippet 'RemisePayment42/Resource/template/sub_shopping_index_payquick.twig';
  913.                 $event->addSnippet($snippet);
  914.                 $asset 'RemisePayment42/Resource/assets/css/payquick.css';
  915.                 $event->addAsset($asset);
  916.             }
  917.         }
  918.         // マルチ決済の場合
  919.         else if ($RemisePayment->getKind() == trans('remise_payment4.common.label.payment.kind.cvs'))
  920.         {
  921.             // 行程の追加
  922.             $asset 'RemisePayment42/Resource/assets/js/sub_shopping_flow.js';
  923.             $event->addAsset($asset);
  924.         }
  925.     }
  926.     /**
  927.      * ご注文内容のご確認
  928.      *
  929.      * @param $event
  930.      */
  931.     public function onShoppingConfirmTwig(TemplateEvent $event)
  932.     {
  933.         // 表示対象の受注情報の取得
  934.         $Order $event->getParameter('Order');
  935.         if (!$Order)
  936.         {
  937.             return;
  938.         }
  939.         // セッションから処理中の受注番号を取得
  940.         $orderId $this->session->get('remise_payment4.order_id');
  941.         if (is_null($orderId))
  942.         {
  943.             $orderId '';
  944.         }
  945.         // EC-CUBE支払方法の取得
  946.         $Payment $Order->getPayment();
  947.         if (!$Payment)
  948.         {
  949.             return;
  950.         }
  951.         $paymentId $Payment->getId();
  952.         // ルミーズ支払方法の取得
  953.         $RemisePayment $this->utilService->getRemisePayment($paymentId);
  954.         if (!$RemisePayment)
  955.         {
  956.             return;
  957.         }
  958.         // カード決済の場合
  959.         if ($RemisePayment->getKind() == trans('remise_payment4.common.label.payment.kind.card'))
  960.         {
  961.             // 行程の追加
  962.             $asset 'RemisePayment42/Resource/assets/js/sub_shopping_flow.js';
  963.             $event->addAsset($asset);
  964.             // ボタン名の変更
  965.             $asset 'RemisePayment42/Resource/assets/js/sub_shopping_confirm.twig';
  966.             $event->addAsset($asset);
  967.             // プラグイン設定情報の取得
  968.             $ConfigInfo $this->utilService->getConfigInfo();
  969.             if (!$ConfigInfo)
  970.             {
  971.                 return;
  972.             }
  973.             // 定期購買が有効の場合
  974.             if($ConfigInfo->useOptionAC())
  975.             {
  976.                 // 商品規格情報取得
  977.                 $ProductClass $this->acService->getProductClassByOrder($Order);
  978.                 // ルミーズ定期購買種別マスタ取得
  979.                 $RemiseAcType $this->acService->getRemiseAcTypeByProductClass($ProductClass);
  980.                 if($RemiseAcType){
  981.                     // 課金間隔取得
  982.                     $interval "";
  983.                     if (strcmp($RemiseAcType->getIntervalMark(), trans('remise_payment4.ac.plg_remise_payment4_remise_ac_type.interval_marks.m.key')) == 0)
  984.                     {
  985.                         $interval $RemiseAcType->getIntervalValue().trans('remise_payment4.ac.plg_remise_payment4_remise_ac_type.interval_marks.m.value');
  986.                     }
  987.                     else if(strcmp($RemiseAcType->getIntervalMark(), trans('remise_payment4.ac.plg_remise_payment4_remise_ac_type.interval_marks.d.key')) == 0)
  988.                     {
  989.                         $interval $RemiseAcType->getIntervalValue().trans('remise_payment4.ac.plg_remise_payment4_remise_ac_type.interval_marks.d.value');
  990.                     }
  991.                     // 初回課金日取得
  992.                     $firstDate $this->acService->getFirstDate($RemiseAcType, new \DateTime());
  993.                     // 次回課金額
  994.                     $RemiseACMember $this->acService->createRemiseACMember($Order);
  995.                     $remiseAcAmount $RemiseACMember->getTotal();
  996.                     // 課金回数
  997.                     if($RemiseAcType->getCount() && $RemiseAcType->getCount() > 0){
  998.                         $countText $RemiseAcType->getCount().trans('remise_payment4.ac.plg_remise_payment4_remise_ac_type.count.value');
  999.                     }else{
  1000.                         $countText "";
  1001.                     }
  1002.                     $event->setParameter('RemiseProductClass'$ProductClass);
  1003.                     $event->setParameter('RemiseAcType'$RemiseAcType);
  1004.                     $event->setParameter('remiseAcAmount'$remiseAcAmount);
  1005.                     $event->setParameter('remiseAcFirstDate',$firstDate);
  1006.                     $event->setParameter('remiseAcInterval'$interval);
  1007.                     $event->setParameter('remiseAcCount'$countText);
  1008.                     $snippet 'RemisePayment42/Resource/template/sub_shopping_index_autocharge.twig';
  1009.                     $event->addSnippet($snippet);
  1010.                 }
  1011.             }
  1012.             // 会員の注文処理でペイクイックを「利用する」の場合
  1013.             if ($Order->getCustomer() && $ConfigInfo->getPayquickFlag() === '1')
  1014.             {
  1015.                 // ペイクイック情報の取得
  1016.                 $Payquick $this->utilService->getPayquickByCustomer($Order->getCustomer());
  1017.                 // ペイクイック情報
  1018.                 $event->setParameter('Payquick'$Payquick);
  1019.                 // フォーム情報
  1020.                 $form $event->getParameter('form');
  1021.                 $payquick_state '0';
  1022.                 $regist_payquick '0';
  1023.                 $use_payquick '0';
  1024.                 $method '';
  1025.                 $method_name '';
  1026.                 $ptimes '';
  1027.                 $ptimes_name '';
  1028.                 // 新規時
  1029.                 if (!$Payquick)
  1030.                 {
  1031.                     $payquick_state '1';
  1032.                     // クレジットカード登録
  1033.                     $work $form->offsetGet('remise_payment4_regist_payquick')->vars['data'];
  1034.                     if (isset($work))
  1035.                     {
  1036.                         foreach ($work as $value)
  1037.                         {
  1038.                             if ($value == '1')
  1039.                             {
  1040.                                 $regist_payquick '1';
  1041.                             }
  1042.                         }
  1043.                     }
  1044.                 }
  1045.                 // 既存時
  1046.                 else
  1047.                 {
  1048.                     $payquick_state '2';
  1049.                     // ペイクイック利用
  1050.                     $work $form->offsetGet('remise_payment4_use_payquick')->vars['data'];
  1051.                     if (isset($work))
  1052.                     {
  1053.                         $use_payquick $work;
  1054.                     }
  1055.                     // 支払方法
  1056.                     $work $form->offsetGet('remise_payment4_method')->vars['data'];
  1057.                     if (isset($work))
  1058.                     {
  1059.                         $method $work;
  1060.                     }
  1061.                     $method_name trans('remise_payment4.common.label.card_method.' $method);
  1062.                     // 分割回数
  1063.                     $work $form->offsetGet('remise_payment4_ptimes')->vars['data'];
  1064.                     if (isset($work))
  1065.                     {
  1066.                         $ptimes $work;
  1067.                     }
  1068.                     $ptimes_name $ptimes trans('remise_payment4.common.label.card_ptimes_count');
  1069.                     // クレジットカード登録
  1070.                     if ($use_payquick == '1') {
  1071.                         $regist_payquick '1';
  1072.                     }
  1073.                     else {
  1074.                         $work $form->offsetGet('remise_payment4_regist_payquick')->vars['data'];
  1075.                         if (isset($work))
  1076.                         {
  1077.                             foreach ($work as $value)
  1078.                             {
  1079.                                 if ($value == '1')
  1080.                                 {
  1081.                                     $regist_payquick '1';
  1082.                                 }
  1083.                             }
  1084.                         }
  1085.                     }
  1086.                 }
  1087.                 // セッション設定
  1088.                 $this->session->set('remise_payment4.regist_payquick.' $orderId$regist_payquick);
  1089.                 $this->session->set('remise_payment4.use_payquick.' $orderId$use_payquick);
  1090.                 $this->session->set('remise_payment4.method.' $orderId$method);
  1091.                 $this->session->set('remise_payment4.ptimes.' $orderId$ptimes);
  1092.                 // カードご利用情報
  1093.                 $PayquickInfo = array();
  1094.                 $PayquickInfo['payquick_state'] = $payquick_state;
  1095.                 $PayquickInfo['regist_payquick'] = $regist_payquick;
  1096.                 $PayquickInfo['use_payquick'] = $use_payquick;
  1097.                 $PayquickInfo['method'] = $method;
  1098.                 $PayquickInfo['method_name'] = $method_name;
  1099.                 $PayquickInfo['ptimes'] = $ptimes;
  1100.                 $PayquickInfo['ptimes_name'] = $ptimes_name;
  1101.                 $event->setParameter('PayquickInfo'$PayquickInfo);
  1102.                 // カードご利用情報の表示欄追加
  1103.                 $snippet 'RemisePayment42/Resource/template/sub_shopping_confirm_payquick.twig';
  1104.                 $event->addSnippet($snippet);
  1105.                 $asset 'RemisePayment42/Resource/assets/css/payquick.css';
  1106.                 $event->addAsset($asset);
  1107.             }
  1108.         }
  1109.         // マルチ決済の場合
  1110.         else if ($RemisePayment->getKind() == trans('remise_payment4.common.label.payment.kind.cvs'))
  1111.         {
  1112.             // 行程の追加
  1113.             $asset 'RemisePayment42/Resource/assets/js/sub_shopping_flow.js';
  1114.             $event->addAsset($asset);
  1115.             // ボタン名の変更
  1116.             $asset 'RemisePayment42/Resource/assets/js/sub_shopping_confirm.twig';
  1117.             $event->addAsset($asset);
  1118.         }
  1119.     }
  1120.     /**
  1121.      * ご注文完了
  1122.      *
  1123.      * @param $event
  1124.      */
  1125.     public function onShoppingCompleteTwig(TemplateEvent $event)
  1126.     {
  1127.         // 表示対象の受注情報を取得
  1128.         $Order $event->getParameter('Order');
  1129.         if (!$Order)
  1130.         {
  1131.             return;
  1132.         }
  1133.         // EC-CUBE支払方法の取得
  1134.         $Payment $Order->getPayment();
  1135.         if (!$Payment)
  1136.         {
  1137.             return;
  1138.         }
  1139.         $paymentId $Payment->getId();
  1140.         // ルミーズ支払方法の取得
  1141.         $RemisePayment $this->utilService->getRemisePayment($paymentId);
  1142.         if (!$RemisePayment)
  1143.         {
  1144.             return;
  1145.         }
  1146.         // カード決済の場合
  1147.         if ($RemisePayment->getKind() == trans('remise_payment4.common.label.payment.kind.card'))
  1148.         {
  1149.             // 行程の追加
  1150.             $asset 'RemisePayment42/Resource/assets/js/sub_shopping_flow.js';
  1151.             $event->addAsset($asset);
  1152.         }
  1153.         // マルチ決済の場合
  1154.         else if ($RemisePayment->getKind() == trans('remise_payment4.common.label.payment.kind.cvs'))
  1155.         {
  1156.             // 行程の追加
  1157.             $asset 'RemisePayment42/Resource/assets/js/sub_shopping_flow.js';
  1158.             $event->addAsset($asset);
  1159.         }
  1160.     }
  1161.     /**
  1162.      * マイページ/ご注文履歴一覧
  1163.      *
  1164.      * @param $event
  1165.      */
  1166.     public function onMypageIndexTwig(TemplateEvent $event)
  1167.     {
  1168.         // 表示対象の注文履歴一覧を取得
  1169.         $pagination $event->getParameter('pagination');
  1170.         if (empty($pagination) || count($pagination) == 0)
  1171.         {
  1172.             return;
  1173.         }
  1174.         // 注文履歴一覧から受注番号を取得
  1175.         $orderIds = array();
  1176.         foreach ($pagination as $Order)
  1177.         {
  1178.             $orderIds[] = $Order->getId();
  1179.         }
  1180.         if (empty($orderIds))
  1181.         {
  1182.             return;
  1183.         }
  1184.         // 受注未確定の決済履歴詳細を取得
  1185.         $OrderResultCards $this->utilService->getOrderResultCardForNotCompleted($orderIds);
  1186.         if (!$OrderResultCards)
  1187.         {
  1188.             return;
  1189.         }
  1190.         // 受注未確定の決済履歴詳細
  1191.         $event->setParameter('NotCompletedOrderResultCards'$OrderResultCards);
  1192.         // ご注文状況を入金確認中(受注未確定)へ表記変更
  1193.         $asset 'RemisePayment42/Resource/assets/js/sub_mypage_index.js';
  1194.         $event->addAsset($asset);
  1195.     }
  1196.     /**
  1197.      * マイページ/ご注文履歴詳細
  1198.      *
  1199.      * @param $event
  1200.      */
  1201.     public function onMypageHistoryTwig(TemplateEvent $event)
  1202.     {
  1203.         // プラグイン設定情報の取得
  1204.         $Config $this->utilService->getConfig();
  1205.         if (!$Config) {
  1206.             return;
  1207.         }
  1208.         // 設定情報の取得
  1209.         $ConfigInfo $Config->getUnserializeInfo();
  1210.         if (!$ConfigInfo) {
  1211.             return;
  1212.         }
  1213.         // 表示対象の受注情報を取得
  1214.         $Order $event->getParameter('Order');
  1215.         if (!$Order)
  1216.         {
  1217.             return;
  1218.         }
  1219.         // 定期購買が有効の場合
  1220.         if($ConfigInfo->useOptionAC())
  1221.         {
  1222.             // 定期購買メンバー情報取得
  1223.             $RemiseACMember $this->acService->getRemiseACMemberByOrderId($Order->getId());
  1224.             if($RemiseACMember){
  1225.                 $event->setParameter('RemiseACMember'$RemiseACMember);
  1226.                 $event->setParameter('skippingFlg'$this->acService->getSkippingFlg($RemiseACMember));
  1227.                 $event->setParameter('refusalFlg'$this->acService->getRefusalFlg($RemiseACMember));
  1228.                 $event->setParameter('dispAcStopFlg'$this->acService->getDispAcStopFlg($RemiseACMember));
  1229.                 $event->setParameter('useKeizokuEditExtend'$this->acApiService->useKeizokuEditExtend());
  1230.                 $event->setParameter('useKeizokuResultExtend'$this->acApiService->useKeizokuResultExtend());
  1231.                 $snippet 'RemisePayment42/Resource/template/sub_mypage_history_autocharge.twig';
  1232.                 $event->addSnippet($snippet);
  1233.             }
  1234.         }
  1235.         $orderIds = array($Order->getId());
  1236.         // ご注文状況へ入金確認中(受注未確定)の表記追加
  1237.         $OrderResultCards $this->utilService->getOrderResultCardForNotCompleted($orderIds);
  1238.         if (!$OrderResultCards || count($OrderResultCards) == 0)
  1239.         {
  1240.             return;
  1241.         }
  1242.         // ご注文状況を入金確認中(受注未確定)へ表記変更
  1243.         $asset 'RemisePayment42/Resource/assets/js/sub_mypage_history.js';
  1244.         $event->addAsset($asset);
  1245.     }
  1246.     /**
  1247.      * マイページ/会員情報編集
  1248.      *
  1249.      * @param $event
  1250.      */
  1251.     public function onMypageChangeTwig(TemplateEvent $event)
  1252.     {
  1253.         // ペイクイック削除後の状況をセッションから取得
  1254.         $delete_payquick $this->session->get('remise_payment4.delete_payquick');
  1255.         if (is_null($delete_payquick)) $delete_payquick '';
  1256.         // ペイクイック削除を実施した場合
  1257.         if ($delete_payquick == '1')
  1258.         {
  1259.             // ペイクイック削除完了メッセージの表示
  1260.             $snippet 'RemisePayment42/Resource/template/sub_mypage_change_payquick_deleted.twig';
  1261.             $event->addSnippet($snippet);
  1262.             $asset 'RemisePayment42/Resource/assets/css/payquick.css';
  1263.             $event->addAsset($asset);
  1264.         }
  1265.         // ペイクイック削除情報のクリア
  1266.         $this->session->remove('remise_payment4.delete_payquick');
  1267.         // 表示対象のフォームを取得
  1268.         $form $event->getParameter('form');
  1269.         if (empty($form) || !isset($form->vars['value']))
  1270.         {
  1271.             return;
  1272.         }
  1273.         // 会員情報の取得
  1274.         $Customer $form->vars['value'];
  1275.         if (!$Customer)
  1276.         {
  1277.             return;
  1278.         }
  1279.         // ペイクイック情報の取得
  1280.         $Payquick $this->utilService->getPayquickByCustomer($Customer);
  1281.         if (!$Payquick)
  1282.         {
  1283.             return;
  1284.         }
  1285.         // ペイクイック情報
  1286.         $event->setParameter('Payquick'$Payquick);
  1287.         // カードご利用情報の表示欄追加
  1288.         $snippet 'RemisePayment42/Resource/template/sub_mypage_change_payquick.twig';
  1289.         $event->addSnippet($snippet);
  1290.         $asset 'RemisePayment42/Resource/assets/css/payquick.css';
  1291.         $event->addAsset($asset);
  1292.     }
  1293.     /**
  1294.      * マイページ/退会
  1295.      *
  1296.      * @param $event
  1297.      */
  1298.     public function onMypageWithdrawTwig(TemplateEvent $event)
  1299.     {
  1300.         // 表示対象の会員情報を取得
  1301.         $Customer $this->utilService->getLoginCustomer();
  1302.         // 会員に紐づく継続中の定期購買情報を検索
  1303.         $remiseACMembers $this->remiseACMemberRepository->getRemiseACMembersByCustomerId($Customer->getId());
  1304.         if(!$remiseACMembers){
  1305.             return;
  1306.         }
  1307.         foreach($remiseACMembers as $remiseACMember){
  1308.             $this->acService->setRemiseAcMemberRelatedOrder($remiseACMember);
  1309.         }
  1310.         $event->setParameter('RemiseACMembers'$remiseACMembers);
  1311.         $snippet 'RemisePayment42/Resource/template/sub_mypage_withdraw.twig';
  1312.         $event->addSnippet($snippet);
  1313.     }
  1314. }