Changeset 20093


Ignore:
Timestamp:
2011/02/04 18:22:47 (13 years ago)
Author:
nanasess
bzr:base-revision:
svn-v4:1e3b908f-19a9-db11-a64c-001125224ba8:branches/version-2_5-dev:20092
bzr:committer:
Kentaro Ohkouchi <ohkouchi@loop-az.jp>
bzr:file-ids:

data/class/pages/shopping/LC_Page_Shopping.php 15223@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2Fclass%2Fpages%2Fshopping%2FLC_Page_Shopping.php
data/class/pages/shopping/LC_Page_Shopping_Deliv.php 15223@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2Fclass%2Fpages%2Fshopping%2FLC_Page_Shopping_Deliv.php
bzr:mapping-version:
v4
bzr:merge:

ohkouchi@loop-az.jp-20110204090833-fc76wcbblb76h52s
bzr:repository-uuid:
1e3b908f-19a9-db11-a64c-001125224ba8
bzr:revision-id:
ohkouchi@loop-az.jp-20110204092244-y0hrkdubtevkymuq
bzr:revno:
2821
bzr:revprop:branch-nick:
branches/version-2_5-dev
bzr:root:
branches/version-2_5-dev
bzr:text-revisions:

data/class/pages/shopping/LC_Page_Shopping_Deliv.php ohkouchi@loop-az.jp-20110204090833-fc76wcbblb76h52s
bzr:timestamp:
2011-02-04 18:22:44.084000111 +0900
bzr:user-agent:
bzr2.2.1+bzr-svn1.0.4
svn:original-date:
2011-02-04T09:22:44.084000Z
Message:

#984([フロント]商品購入 リファクタリング)

  • /shopping/deliv.php
Location:
branches/version-2_5-dev/data/class/pages/shopping
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/version-2_5-dev/data/class/pages/shopping/LC_Page_Shopping.php

    r20091 r20093  
    8282        $objPurchase = new SC_Helper_Purchase_Ex(); 
    8383        $objFormParam = new SC_FormParam(); 
    84  
    8584 
    8685        $this->tpl_uniqid = $objSiteSess->getUniqId(); 
  • branches/version-2_5-dev/data/class/pages/shopping/LC_Page_Shopping_Deliv.php

    r20091 r20093  
    7070        $objCustomer = new SC_Customer(); 
    7171        $objPurchase = new SC_Helper_Purchase_Ex(); 
    72         $objQuery = SC_Query::getSingletonInstance();; 
     72        $objFormParam = new SC_FormParam(); 
    7373        $objCookie = new SC_Cookie(COOKIE_EXPIRE); 
     74 
    7475        $this->tpl_uniqid = $objSiteSess->getUniqId(); 
    7576        $objPurchase->verifyChangeCart($this->tpl_uniqid, $objCartSess); 
     
    7879 
    7980        // ログインチェック 
    80         if(!$objCustomer->isLoginSuccess(true)) { 
     81        if (!$objCustomer->isLoginSuccess(true)) { 
    8182            SC_Utils_Ex::sfDispSiteError(CUSTOMER_ERROR); 
    8283        } 
    8384 
    84         if($this->cartKey == PRODUCT_TYPE_DOWNLOAD){ 
    85             // 会員情報の住所を受注一時テーブルに書き込む 
     85        // ダウンロード商品の場合は、支払方法画面に転送 
     86        if ($this->cartKey == PRODUCT_TYPE_DOWNLOAD) { 
    8687            $objPurchase->copyFromCustomer($sqlval, $objCustomer, 'shipping'); 
    8788            $objPurchase->saveShippingTemp($sqlval); 
    8889            $objPurchase->saveOrderTemp($this->tpl_uniqid, $sqlval, $objCustomer); 
    89             // 正常に登録されたことを記録しておく 
    9090            $objSiteSess->setRegistFlag(); 
    91             // ダウンロード商品有りの場合は、支払方法画面に転送 
    9291            SC_Response_Ex::sendRedirect('payment.php'); 
    9392            exit; 
    9493        } 
     94 
     95        $this->lfInitParam($objFormParam); 
     96        $objFormParam->setParam($_POST); 
     97        $objFormParam->convParam(); 
     98        $arrErr = $objFormParam->checkError(); 
     99        if (!SC_Utils_Ex::isBlank($arrErr)) { 
     100            SC_Utils_Ex::sfDispSiteError(PAGE_ERROR, "", true); 
     101            exit; 
     102        } 
     103 
     104        $arrForm = $objFormParam->getHashArray(); 
    95105 
    96106        switch($this->getMode()) { 
    97107        // 削除 
    98108        case 'delete': 
    99             if (SC_Utils_Ex::sfIsInt($_POST['other_deliv_id'])) { 
    100                 $where = "other_deliv_id = ?"; 
    101                 $arrRet = $objQuery->delete("dtb_other_deliv", $where, array($_POST['other_deliv_id'])); 
    102             } 
    103             break; 
     109            $this->doDelete($arrForm['other_deliv_id']); 
     110            break; 
     111 
    104112        // 会員登録住所に送る 
    105113        case 'customer_addr': 
    106             $sqlval = array(); 
    107             $arrDeliv = $objPurchase->getDeliv($this->cartKey); 
    108             $sqlval['deliv_id'] = $arrDeliv[0]['deliv_id']; 
    109             // 会員登録住所がチェックされている場合 
    110             if ($_POST['deliv_check'] == '-1') { 
    111                 // 会員情報の住所を受注一時テーブルに書き込む 
    112                 $objPurchase->copyFromCustomer($sqlval, $objCustomer, 'shipping'); 
    113                 $objPurchase->saveShippingTemp($sqlval); 
    114                 $objPurchase->saveOrderTemp($this->tpl_uniqid, $sqlval, $objCustomer); 
    115  
    116                 // 正常に登録されたことを記録しておく 
     114            if ($this->registerDeliv($arrForm['deliv_check'], $this->tpl_uniqid, 
     115                                     $objPurchase, $objCustomer)) { 
    117116                $objSiteSess->setRegistFlag(); 
    118                 // お支払い方法選択ページへ移動 
    119117                SC_Response_Ex::sendRedirect(SHOPPING_PAYMENT_URLPATH); 
    120118                exit; 
    121             // 別のお届け先がチェックされている場合 
    122             } elseif($_POST['deliv_check'] >= 1) { 
    123                 if (SC_Utils_Ex::sfIsInt($_POST['deliv_check'])) { 
    124                     $otherDeliv = $objQuery->getRow("*", "dtb_other_deliv","customer_id = ? AND other_deliv_id = ?" 
    125                                                     ,array($objCustomer->getValue('customer_id'), $_POST['deliv_check'])); 
    126                     if (SC_Utils_Ex::isBlank($otherDeliv)) { 
    127                         SC_Utils_Ex::sfDispSiteError(CUSTOMER_ERROR); 
    128                     } 
    129  
    130                     $objPurchase->copyFromOrder($sqlval, $otherDeliv, 'shipping', '');; 
    131                     $objPurchase->saveShippingTemp($sqlval); 
    132                     $objPurchase->saveOrderTemp($this->tpl_uniqid, $sqlval, $objCustomer); 
    133  
    134                     // 正常に登録されたことを記録しておく 
    135                     $objSiteSess->setRegistFlag(); 
    136                     // お支払い方法選択ページへ移動 
    137                     SC_Response_Ex::sendRedirect(SHOPPING_PAYMENT_URLPATH); 
    138                     exit; 
    139                 } 
    140             }else{ 
    141                 // エラーを返す 
    142                 $arrErr['deli'] = '※ お届け先を選択してください。'; 
     119 
     120            } else { 
     121                SC_Utils_Ex::sfDispSiteError(PAGE_ERROR, "", true); 
    143122            } 
    144123            break; 
     124 
    145125        // 前のページに戻る 
    146126        case 'return': 
     
    149129            exit; 
    150130            break; 
     131 
    151132        // お届け先複数指定 
    152133        case 'multiple': 
     
    157138        default: 
    158139            $objPurchase->unsetShippingTemp(); 
    159  
    160140            break; 
    161141        } 
    162142 
    163143        // 登録済み住所を取得 
    164         $this->arrAddr = $objCustomer->getCustomerAddress($_SESSION['customer']['customer_id']); 
    165         // 入力値の取得 
    166         if (!isset($arrErr)) $arrErr = array(); 
    167         $this->arrErr = $arrErr; 
     144        $this->arrAddr = $objCustomer->getCustomerAddress($objCustomer->getValue('customer_id')); 
    168145    } 
    169146 
     
    176153        parent::destroy(); 
    177154    } 
     155 
     156    /** 
     157     * パラメータ情報の初期化を行う. 
     158     * 
     159     * @param SC_FormParam $objFormParam SC_FormParam インスタンス 
     160     * @return void 
     161     */ 
     162    function lfInitParam(&$objFormParam) { 
     163        $objFormParam->addParam("その他のお届け先ID", "other_deliv_id", INT_LEN, "n", array("NUM_CHECK", "MAX_LENGTH_CHECK")); 
     164        $objFormParam->addParam("お届け先チェック", "deliv_check", INT_LEN, "n", array("MAX_LENGTH_CHECK")); 
     165    } 
     166 
     167    /** 
     168     * その他のお届け先情報を削除する. 
     169     * 
     170     * @param integer $other_deliv_id その他のお届け先ID 
     171     * @return void 
     172     */ 
     173    function doDelete($other_deliv_id) { 
     174        $objQuery =& SC_Query::getSingletonInstance(); 
     175        $where = "other_deliv_id = ?"; 
     176        $objQuery->delete("dtb_other_deliv", $where, array($other_deliv_id)); 
     177    } 
     178 
     179    /** 
     180     * お届け先チェックの値に応じて, お届け先情報を保存する. 
     181     * 
     182     * 会員住所がチェックされている場合は, 会員情報からお届け先を取得する. 
     183     * その他のお届け先がチェックされている場合は, その他のお届け先からお届け先を取得する. 
     184     * お届け先チェックの値が不正な場合は false を返す. 
     185     * 
     186     * @param integer $deliv_check お届け先チェック 
     187     * @param string $uniqid 受注一時テーブルのユニークID 
     188     * @param SC_Helper_Purchase $objPurchase SC_Helper_Purchase インスタンス 
     189     * @param SC_Customer $objCustomer SC_Customer インスタンス 
     190     * @return boolean お届け先チェックの値が妥当な場合 true 
     191     */ 
     192    function registerDeliv($deliv_check, $uniqid, &$objPurchase, &$objCustomer) { 
     193        $arrValues = array(); 
     194        // 会員登録住所がチェックされている場合 
     195        if ($deliv_check == '-1') { 
     196            $objPurchase->copyFromCustomer($arrValues, $objCustomer, 'shipping'); 
     197            $objPurchase->saveShippingTemp($arrValues); 
     198            $objPurchase->saveOrderTemp($uniqid, $arrValues, $objCustomer); 
     199            return true; 
     200        } 
     201        // 別のお届け先がチェックされている場合 
     202        elseif ($deliv_check >= 1) { 
     203            $objQuery =& SC_Query::getSingletonInstance(); 
     204            $arrOtherDeliv = $objQuery->getRow("*", "dtb_other_deliv", 
     205                                               "customer_id = ? AND other_deliv_id = ?", 
     206                                               array($objCustomer->getValue('customer_id'), $deliv_check)); 
     207            if (SC_Utils_Ex::isBlank($arrOtherDeliv)) { 
     208                return false; 
     209            } 
     210 
     211            $objPurchase->copyFromOrder($arrValues, $arrOtherDeliv, 'shipping', '');; 
     212            $objPurchase->saveShippingTemp($arrValues); 
     213            $objPurchase->saveOrderTemp($uniqid, $arrValues, $objCustomer); 
     214            return true; 
     215        } 
     216        // お届け先チェックが不正な場合 
     217        else { 
     218            return false; 
     219        } 
     220    } 
    178221} 
    179222?> 
Note: See TracChangeset for help on using the changeset viewer.