/**
  * 配送業者IDから, 支払い方法, お届け時間の配列を取得する.
  *
  * 結果の連想配列の添字の値は以下の通り
  * - 'arrDelivTime' - お届け時間の配列
  * - 'arrPayment' - 支払い方法の配列
  * - 'img_show' - 支払い方法の画像の有無
  *
  * @param  SC_CartSession $objCartSess SC_CartSession インスタンス
  * @param  integer        $deliv_id    配送業者ID
  * @return array          支払い方法, お届け時間を格納した配列
  */
 public function getSelectablePayment(&$objCartSess, $deliv_id, $is_list = false)
 {
     $arrPayment = array();
     if (strval($deliv_id) === strval(intval($deliv_id))) {
         $total = $objCartSess->getAllProductsTotal($objCartSess->getKey());
         $payments_deliv = DeliveryHelper::getPayments($deliv_id);
         $objPayment = new PaymentHelper();
         $payments_total = $objPayment->getByPrice($total);
         foreach ($payments_total as $payment) {
             if (in_array($payment['payment_id'], $payments_deliv)) {
                 if ($is_list) {
                     $arrPayment[$payment['payment_id']] = $payment['payment_method'];
                 } else {
                     $arrPayment[] = $payment;
                 }
             }
         }
     }
     return $arrPayment;
 }
Exemple #2
0
 /**
  * Page のアクション.
  *
  * @return void
  */
 public function action()
 {
     //決済処理中ステータスのロールバック
     /* @var $objPurchase PurchaseHelper */
     $objPurchase = Application::alias('eccube.helper.purchase');
     $objPurchase->cancelPendingOrder(PENDING_ORDER_CANCEL_FLAG);
     /* @var $objCartSess CartSession */
     $objCartSess = Application::alias('eccube.cart_session');
     /* @var $objSiteSess SiteSession */
     $objSiteSess = Application::alias('eccube.site_session');
     /* @var $objCustomer Customer */
     $objCustomer = Application::alias('eccube.customer');
     $this->is_multiple = $objPurchase->isMultiple();
     // 前のページで正しく登録手続きが行われた記録があるか判定
     if (!$objSiteSess->isPrePage()) {
         Utils::sfDispSiteError(PAGE_ERROR, $objSiteSess);
     }
     // ユーザユニークIDの取得と購入状態の正当性をチェック
     $this->tpl_uniqid = $objSiteSess->getUniqId();
     $objPurchase->verifyChangeCart($this->tpl_uniqid, $objCartSess);
     $this->cartKey = $objCartSess->getKey();
     // カート内商品のチェック
     $this->tpl_message = $objCartSess->checkProducts($this->cartKey);
     if (!Utils::isBlank($this->tpl_message)) {
         Application::alias('eccube.response')->sendRedirect(CART_URL);
         Application::alias('eccube.response')->actionExit();
     }
     $this->is_download = $this->cartKey == PRODUCT_TYPE_DOWNLOAD;
     // カートの商品を取得
     $this->arrShipping = $objPurchase->getShippingTemp($this->is_multiple);
     $this->arrCartItems = $objCartSess->getCartList($this->cartKey);
     // 合計金額
     $this->tpl_total_inctax = $objCartSess->getAllProductsTotal($this->cartKey);
     // 税額
     $this->tpl_total_tax = $objCartSess->getAllProductsTax($this->cartKey);
     $this->tpl_total_tax = $objCartSess->getAllProductsTax($this->cartKey);
     $objFormParam = new FormParam();
     $this->lfInitParam($objFormParam, $this->arrShipping);
     $objFormParam->setParam($_POST);
     $objFormParam->convParam();
     $objFormParam->trimParam();
     // 一時受注テーブルの読込
     $arrOrderTemp = $objPurchase->getOrderTemp($this->tpl_uniqid);
     // 配送業者を取得
     $objDelivery = new DeliveryHelper();
     $this->arrDeliv = $objDelivery->getList($this->cartKey, false, true);
     $this->tpl_is_single_deliv = $objDelivery->isSingleDeliv($this->cartKey);
     // お届け日一覧の取得
     $this->arrDelivDate = $objPurchase->getDelivDate($objCartSess, $this->cartKey);
     if (Utils::sfIsInt($arrOrderTemp['deliv_id'])) {
         $this->arrPayment = $objPurchase->getSelectablePayment($objCartSess, $arrOrderTemp['deliv_id'], true);
         $this->arrDelivTime = DeliveryHelper::getDelivTime($arrOrderTemp['deliv_id']);
     }
     // カート集計を元に最終計算
     $arrCalcResults = $objCartSess->calculate($this->cartKey, $objCustomer, $arrOrderTemp['use_point'], $objPurchase->getShippingPref($this->is_multiple), $arrOrderTemp['charge'], $arrOrderTemp['discount'], $arrOrderTemp['deliv_id'], $arrOrderTemp['order_pref'], $arrOrderTemp['order_country_id']);
     $this->arrForm = array_merge($arrOrderTemp, $arrCalcResults);
     foreach ($objFormParam->getHashArray() as $key => $param) {
         if (!Utils::isBlank($param) && Utils::isBlank($this->arrForm[$key])) {
             $this->arrForm[$key] = $param;
         }
     }
     // 会員ログインチェック
     if ($objCustomer->isLoginSuccess(true)) {
         $this->tpl_login = '******';
         $this->tpl_user_point = $objCustomer->getValue('point');
     }
     // 決済モジュールを使用するかどうか
     $this->use_module = Application::alias('eccube.helper.payment')->useModule($this->arrForm['payment_id']);
     switch ($this->getMode()) {
         case 'select_deliv':
             $sqlval = $objFormParam->getHashArray();
             if (Utils::isBlank($sqlval['use_point'])) {
                 $sqlval['use_point'] = '0';
             }
             $deliv_id = $objFormParam->getValue('deliv_id');
             $arrPayment = $objPurchase->getSelectablePayment($objCartSess, $deliv_id);
             $sqlval['payment_id'] = $arrPayment[0]['payment_id'];
             $sqlval['payment_method'] = $arrPayment[0]['payment_method'];
             $objPurchase->saveOrderTemp($this->tpl_uniqid, $sqlval);
             Response::reload();
             break;
             // 前のページに戻る
         // 前のページに戻る
         case 'return':
             // 正常な推移であることを記録しておく
             $objSiteSess->setRegistFlag();
             Application::alias('eccube.response')->sendRedirect(SHOPPING_PAYMENT_URLPATH);
             Application::alias('eccube.response')->actionExit();
             break;
         case 'confirm':
             $this->saveShippings($objFormParam, $this->arrDelivTime);
             $deliv_id = $objFormParam->getValue('deliv_id');
             $arrPayment = $objPurchase->getSelectablePayment($objCartSess, $deliv_id);
             $this->lfRegistPayment($this->tpl_uniqid, $objFormParam->getHashArray(), $objPurchase, $arrPayment);
             /*
              * 決済モジュールで必要なため, 受注番号を取得
              */
             $this->arrForm['order_id'] = $objPurchase->getNextOrderID();
             $_SESSION['order_id'] = $this->arrForm['order_id'];
             // 集計結果を受注一時テーブルに反映
             $objPurchase->saveOrderTemp($this->tpl_uniqid, $this->arrForm, $objCustomer);
             // 正常に登録されたことを記録しておく
             $objSiteSess->setRegistFlag();
             // 決済モジュールを使用する場合
             if ($this->use_module) {
                 $objPurchase->completeOrder(ORDER_PENDING);
                 Application::alias('eccube.response')->sendRedirect(SHOPPING_MODULE_URLPATH);
                 // 購入完了ページ
             } else {
                 $objPurchase->completeOrder(ORDER_NEW);
                 PurchaseHelper::sendOrderMail($this->arrForm['order_id'], $this);
                 Application::alias('eccube.response')->sendRedirect(SHOPPING_COMPLETE_URLPATH);
             }
             Application::alias('eccube.response')->actionExit();
             break;
         default:
             break;
     }
 }