Ignore:
Timestamp:
2009/06/06 03:19:45 (14 years ago)
Author:
Seasoft
Message:

・店舗基本情報の取得処理にランタイムのキャッシュ機構を設け、店舗基本情報を深く渡し回す実装を改めた。
・SC_Utils 冒頭のコメントに従い、インスタンスを生成していた処理を、Helper クラスへ移す。計算処理のみ SC_Utils に残す。

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/comu-ver2/data/class/helper/SC_Helper_DB.php

    r18044 r18052  
    201201     * 店舗基本情報を取得する. 
    202202     * 
     203     * @param boolean $force 強制的にDB取得するか 
    203204     * @return array 店舗基本情報の配列 
    204205     */ 
    205     function sf_getBasisData() { 
    206         $objQuery = new SC_Query(); 
    207         $arrRet = $objQuery->select('*', 'dtb_baseinfo'); 
    208  
    209         if (isset($arrRet[0])) return $arrRet[0]; 
    210  
    211         return array(); 
     206    function sf_getBasisData($force = false) { 
     207        static $data; 
     208         
     209        if ($force || !isset($data)) { 
     210            $objQuery = new SC_Query(); 
     211            $arrRet = $objQuery->select('*', 'dtb_baseinfo'); 
     212             
     213            if (isset($arrRet[0])) { 
     214                $data = $arrRet[0]; 
     215            } else { 
     216                $data = array(); 
     217            } 
     218        } 
     219         
     220        return $data; 
    212221    } 
    213222 
     
    282291     * @param LC_Page $objPage ページクラスのインスタンス 
    283292     * @param SC_CartSession $objCartSess カートセッションのインスタンス 
    284      * @param array $arrInfo 商品情報の配列 
    285293     * @return LC_Page 集計処理後のページクラスインスタンス 
    286294     */ 
    287     function sfTotalCart(&$objPage, $objCartSess, $arrInfo) { 
     295    function sfTotalCart(&$objPage, $objCartSess) { 
    288296 
    289297        // 規格名一覧 
     
    372380                } 
    373381                // 商品ごとの合計金額 
    374                 $objPage->arrProductsClass[$cnt]['total_pretax'] = $objCartSess->getProductTotal($arrInfo, $arrCart['id']); 
     382                $objPage->arrProductsClass[$cnt]['total_pretax'] = $objCartSess->getProductTotal($arrCart['id']); 
    375383                // 送料の合計を計算する 
    376384                $objPage->tpl_total_deliv_fee+= ($arrData['deliv_fee'] * $arrCart['quantity']); 
     
    394402         
    395403        // 全商品合計金額(税込み) 
    396         $objPage->tpl_total_pretax = $objCartSess->getAllProductsTotal($arrInfo); 
     404        $objPage->tpl_total_pretax = $objCartSess->getAllProductsTotal(); 
    397405        // 全商品合計消費税 
    398         $objPage->tpl_total_tax = $objCartSess->getAllProductsTax($arrInfo); 
     406        $objPage->tpl_total_tax = $objCartSess->getAllProductsTax(); 
    399407        // 全商品合計ポイント 
    400408        if (USE_POINT !== false) { 
     
    14801488     * @param LC_Page $objPage LC_Page インスタンス 
    14811489     * @param SC_CartSession $objCartSess SC_CartSession インスタンス 
    1482      * @param array $arrInfo 店舗情報の配列 
    14831490     * @param SC_Customer $objCustomer SC_Customer インスタンス 
    14841491     * @return array 最終計算後の配列 
    14851492     */ 
    1486     function sfTotalConfirm($arrData, &$objPage, &$objCartSess, $arrInfo, $objCustomer = "") { 
     1493    function sfTotalConfirm($arrData, &$objPage, &$objCartSess, $objCustomer = "") { 
     1494        // 店舗基本情報を取得する 
     1495        $arrInfo = SC_Helper_DB_Ex::sf_getBasisData(); 
     1496         
    14871497        // 未定義変数を定義 
    14881498        if (!isset($arrData['deliv_pref'])) $arrData['deliv_pref'] = ""; 
     
    15381548        // 加算ポイントの計算 
    15391549        if (USE_POINT !== false) { 
    1540             $arrData['add_point'] = SC_Utils::sfGetAddPoint($objPage->tpl_total_point, $arrData['use_point'], $arrInfo); 
     1550            $arrData['add_point'] = SC_Helper_DB_Ex::sfGetAddPoint($objPage->tpl_total_point, $arrData['use_point']); 
    15411551                 
    15421552            if($objCustomer != "") { 
     
    17481758        $objQuery->query($sql, array($order_id)); 
    17491759    } 
     1760 
     1761    /** 
     1762     * 店舗基本情報に基づいて税金額を返す 
     1763     * 
     1764     * @param integer $price 計算対象の金額 
     1765     * @return integer 税金額 
     1766     */ 
     1767    function sfTax($price) { 
     1768        // 店舗基本情報を取得 
     1769        $CONF = SC_Helper_DB_Ex::sf_getBasisData(); 
     1770         
     1771        return SC_Utils_Ex::sfTax($price, $CONF['tax'], $CONF['tax_rule']); 
     1772    } 
     1773 
     1774    /** 
     1775     * 店舗基本情報に基づいて税金付与した金額を返す 
     1776     *  
     1777     * @param integer $price 計算対象の金額 
     1778     * @return integer 税金付与した金額 
     1779     */ 
     1780    function sfPreTax($price, $tax = null, $tax_rule = null) { 
     1781        // 店舗基本情報を取得 
     1782        $CONF = SC_Helper_DB_Ex::sf_getBasisData(); 
     1783         
     1784        return SC_Utils_Ex::sfPreTax($price, $CONF['tax'], $CONF['tax_rule']); 
     1785    } 
     1786 
     1787    /** 
     1788     * 店舗基本情報に基づいて加算ポイントを返す 
     1789     * 
     1790     * @param integer $totalpoint 
     1791     * @param integer $use_point 
     1792     * @return integer 加算ポイント 
     1793     */ 
     1794    function sfGetAddPoint($totalpoint, $use_point) { 
     1795        // 店舗基本情報を取得 
     1796        $CONF = SC_Helper_DB_Ex::sf_getBasisData(); 
     1797         
     1798        return SC_Utils_Ex::sfGetAddPoint($totalpoint, $use_point, $CONF['point_rate']); 
     1799    } 
    17501800} 
    17511801?> 
Note: See TracChangeset for help on using the changeset viewer.