Ignore:
Timestamp:
2010/01/10 19:53:26 (14 years ago)
Author:
Seasoft
Message:
  • 使用ポイントも対応状況を考慮して算出 (r18100の拡張)
  • コメント・ドキュメントの改善 (主にr18100関連)
  • 表示位置が不自然なものを移動
  • 変数名変更 (顧客.ポイントの加減値: $addPoint → $addCustomerPoint)
  • ソース整形
File:
1 edited

Legend:

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

    r18436 r18489  
    206206    function sf_getBasisData($force = false) { 
    207207        static $data; 
    208          
     208 
    209209        if ($force || !isset($data)) { 
    210210            $objQuery = new SC_Query(); 
    211211            $arrRet = $objQuery->select('*', 'dtb_baseinfo'); 
    212              
     212 
    213213            if (isset($arrRet[0])) { 
    214214                $data = $arrRet[0]; 
     
    217217            } 
    218218        } 
    219          
     219 
    220220        return $data; 
    221221    } 
     
    344344                    $quantity = $arrCart['quantity']; 
    345345                } 
    346                  
     346 
    347347                // (商品規格単位でなく)商品単位での評価のための準備 
    348348                $product_id = $arrCart['id'][0]; 
     
    350350                $arrQuantityInfo_by_product[$product_id]['sale_limit'] = $arrData['sale_limit']; 
    351351                $arrQuantityInfo_by_product[$product_id]['name'] = $arrData['name']; 
    352                  
     352 
    353353                $objPage->arrProductsClass[$cnt] = $arrData; 
    354354                $objPage->arrProductsClass[$cnt]['quantity'] = $quantity; 
     
    391391            } 
    392392        } 
    393          
     393 
    394394        foreach ($arrQuantityInfo_by_product as $product_id => $quantityInfo) { 
    395395            if (SC_Utils_Ex::sfIsInt($quantityInfo['sale_limit']) && $quantityInfo['quantity'] > $quantityInfo['sale_limit']) { 
     
    404404            } 
    405405        } 
    406          
     406 
    407407        // 全商品合計金額(税込み) 
    408408        $objPage->tpl_total_pretax = $objCartSess->getAllProductsTotal(); 
     
    439439                $objQuery->update("dtb_order_temp", $sqlval, $where, array($uniqid)); 
    440440            } 
    441              
     441 
    442442            // 受注_Tempテーブルの名称列を更新 
    443443            $this->sfUpdateOrderNameCol($uniqid, true); 
     
    987987            GROUP BY T1.category_id, T2.category_id 
    988988__EOS__; 
    989          
     989 
    990990        $objQuery->query($sql); 
    991991 
    992992        //子カテゴリ内の商品数を集計する 
    993          
     993 
    994994        // カテゴリ情報を取得 
    995995        $arrCat = $objQuery->select('category_id', 'dtb_category'); 
    996          
     996 
    997997        foreach ($arrCat as $row) { 
    998998            $category_id = $row['category_id']; 
    999999            $arrval = array(); 
    1000              
     1000 
    10011001            $arrval[] = $category_id; 
    1002              
     1002 
    10031003            list($tmp_where, $tmp_arrval) = $this->sfGetCatWhere($category_id); 
    10041004            if ($tmp_where != "") { 
     
    10081008                $sql_where_product_ids = '0<>0'; // 一致させない 
    10091009            } 
    1010              
     1010 
    10111011            $sql = <<< __EOS__ 
    10121012                INSERT INTO dtb_category_total_count (category_id, product_count, create_date) 
     
    10181018                WHERE ($sql_where) AND ($sql_where_product_ids) 
    10191019__EOS__; 
    1020              
     1020 
    10211021            $objQuery->query($sql, $arrval); 
    10221022        } 
     
    15211521        // 店舗基本情報を取得する 
    15221522        $arrInfo = SC_Helper_DB_Ex::sf_getBasisData(); 
    1523          
     1523 
    15241524        // 未定義変数を定義 
    15251525        if (!isset($arrData['deliv_pref'])) $arrData['deliv_pref'] = ""; 
     
    15531553            // 商品の合計数量 
    15541554            $total_quantity = $objCartSess->getTotalQuantity(true); 
    1555              
     1555 
    15561556            if($total_quantity >= DELIV_FREE_AMOUNT) { 
    15571557                $arrData['deliv_fee'] = 0; 
     
    15761576        if (USE_POINT !== false) { 
    15771577            $arrData['add_point'] = SC_Helper_DB_Ex::sfGetAddPoint($objPage->tpl_total_point, $arrData['use_point']); 
    1578                  
     1578 
    15791579            if($objCustomer != "") { 
    15801580                // 誕生日月であった場合 
     
    17651765    function sfUpdateOrderNameCol($order_id, $temp_table = false) { 
    17661766        $objQuery = new SC_Query(); 
    1767          
     1767 
    17681768        if ($temp_table) { 
    17691769            $tgt_table = 'dtb_order_temp'; 
     
    17731773            $sql_where = 'WHERE order_id = ?'; 
    17741774        } 
    1775          
     1775 
    17761776        $sql = <<< __EOS__ 
    17771777            UPDATE 
     
    17821782            $sql_where 
    17831783__EOS__; 
    1784          
     1784 
    17851785        $objQuery->query($sql, array($order_id)); 
    17861786    } 
     
    17951795        // 店舗基本情報を取得 
    17961796        $CONF = SC_Helper_DB_Ex::sf_getBasisData(); 
    1797          
     1797 
    17981798        return SC_Utils_Ex::sfTax($price, $CONF['tax'], $CONF['tax_rule']); 
    17991799    } 
     
    18081808        // 店舗基本情報を取得 
    18091809        $CONF = SC_Helper_DB_Ex::sf_getBasisData(); 
    1810          
     1810 
    18111811        return SC_Utils_Ex::sfPreTax($price, $CONF['tax'], $CONF['tax_rule']); 
    18121812    } 
     
    18221822        // 店舗基本情報を取得 
    18231823        $CONF = SC_Helper_DB_Ex::sf_getBasisData(); 
    1824          
     1824 
    18251825        return SC_Utils_Ex::sfGetAddPoint($totalpoint, $use_point, $CONF['point_rate']); 
    18261826    } 
     
    18341834     * @param integer|null $newStatus 対応状況 (null=変更無し) 
    18351835     * @param integer|null $newAddPoint 加算ポイント (null=変更無し) 
    1836      * @param integer|null $newUsePoint ポイント (null=変更無し) 
     1836     * @param integer|null $newUsePoint 使用ポイント (null=変更無し) 
    18371837     * @return void 
    18381838     */ 
    18391839    function sfUpdateOrderStatus($orderId, $newStatus = null, $newAddPoint = null, $newUsePoint = null) { 
    18401840        $objQuery = new SC_Query(); 
    1841          
     1841 
    18421842        $arrOrderOld = $objQuery->getRow('dtb_order', 'status, add_point, use_point, customer_id', 'order_id = ?', array($orderId)); 
    1843          
    1844         // 対応状況 
     1843 
     1844        // 対応状況が変更無しの場合、DB値を引き継ぐ 
    18451845        if (is_null($newStatus)) { 
    18461846            $newStatus = $arrOrderOld['status']; 
    18471847        } 
    1848          
     1848 
     1849        // 使用ポイント、DB値を引き継ぐ 
     1850        if (is_null($newUsePoint)) { 
     1851            $newUsePoint = $arrOrderOld['use_point']; 
     1852        } 
     1853 
     1854        // 加算ポイント、DB値を引き継ぐ 
     1855        if (is_null($newAddPoint)) { 
     1856            $newAddPoint = $arrOrderOld['add_point']; 
     1857        } 
     1858 
    18491859        if (USE_POINT !== false) { 
    1850             $addPoint = 0; 
    1851              
    1852             // 使用ポイント 
    1853             if (!is_null($newUsePoint)) { 
    1854                 $addPoint += $arrOrderOld['use_point']; // 変更前のポイントを戻す 
    1855                 $addPoint -= $newUsePoint;              // 変更後のポイントを引く 
    1856             } 
    1857              
     1860            // 顧客.ポイントの加減値 
     1861            $addCustomerPoint = 0; 
     1862 
     1863            // ▼使用ポイント 
     1864            // 変更前の対応状況が利用対象の場合、変更前の使用ポイント分を戻す 
     1865            if (SC_Utils_Ex::sfIsUsePoint($arrOrderOld['status'])) { 
     1866                $addCustomerPoint += $arrOrderOld['use_point']; 
     1867            } 
     1868 
     1869            // 変更後の対応状況が利用対象の場合、変更後の使用ポイント分を引く 
     1870            if (SC_Utils_Ex::sfIsUsePoint($newStatus)) { 
     1871                $addCustomerPoint -= $newUsePoint; 
     1872            } 
     1873            // ▲使用ポイント 
     1874 
    18581875            // ▼加算ポイント 
    1859             // 変更前の状態が加算対象の場合、 
     1876            // 変更前の対応状況が加算対象の場合、変更前の加算ポイント分を戻す 
    18601877            if (SC_Utils_Ex::sfIsAddPoint($arrOrderOld['status'])) { 
    1861                 $addPoint -= $arrOrderOld['add_point']; 
    1862             } 
    1863              
    1864             // 変更後の状態が加算対象の場合、 
     1878                $addCustomerPoint -= $arrOrderOld['add_point']; 
     1879            } 
     1880 
     1881            // 変更後の対応状況が加算対象の場合、変更後の加算ポイント分を足す 
    18651882            if (SC_Utils_Ex::sfIsAddPoint($newStatus)) { 
    1866                 $addPoint += is_null($newAddPoint) ? $arrOrderOld['add_point'] : $newAddPoint; 
     1883                $addCustomerPoint += $newAddPoint; 
    18671884            } 
    18681885            // ▲加算ポイント 
    1869              
    1870             if ($addPoint != 0) { 
     1886 
     1887            if ($addCustomerPoint != 0) { 
    18711888                // ▼顧客テーブルの更新 
    18721889                $sqlval = array(); 
     
    18751892                $arrRawSql = array(); 
    18761893                $arrRawSqlVal = array(); 
    1877                  
     1894 
    18781895                $sqlval['update_date'] = 'Now()'; 
    18791896                $arrRawSql['point'] = 'point + ?'; 
    1880                 $arrRawSqlVal[] = $addPoint; 
     1897                $arrRawSqlVal[] = $addCustomerPoint; 
    18811898                $where .= 'customer_id = ?'; 
    18821899                $arrVal[] = $arrOrderOld['customer_id']; 
    1883                  
     1900 
    18841901                $objQuery->update('dtb_customer', $sqlval, $where, $arrVal, $arrRawSql, $arrRawSqlVal); 
    18851902                // ▲顧客テーブルの更新 
    1886                  
    1887                 // ポイントをマイナスした場合、 
    1888                 if ($addPoint < 0) { 
     1903 
     1904                // 顧客.ポイントをマイナスした場合、 
     1905                if ($addCustomerPoint < 0) { 
    18891906                    $sql = 'SELECT point FROM dtb_customer WHERE customer_id = ?'; 
    18901907                    $point = $objQuery->getone($sql, array($arrOrderOld['customer_id'])); 
    1891                     // 変更後のポイントがマイナスの場合、 
     1908                    // 変更後の顧客.ポイントがマイナスの場合、 
    18921909                    if ($point < 0) { 
    18931910                        // ロールバック 
     
    18991916            } 
    19001917        } 
    1901          
     1918 
    19021919        // ▼受注テーブルの更新 
    19031920        $sqlval = array(); 
    19041921        if (USE_POINT !== false) { 
    1905             if (!is_null($newAddPoint)) { 
    1906                 $sqlval['add_point'] = $newAddPoint; 
    1907             } 
    1908             if (!is_null($newUsePoint)) { 
    1909                 $sqlval['use_point'] = $newUsePoint; 
    1910             } 
     1922            $sqlval['add_point'] = $newAddPoint; 
     1923            $sqlval['use_point'] = $newUsePoint; 
    19111924        } 
    19121925        // ステータスが発送済みに変更の場合、発送日を更新 
     
    19161929        $sqlval['status'] = $newStatus; 
    19171930        $sqlval['update_date'] = 'Now()'; 
    1918          
     1931 
    19191932        $objQuery->update('dtb_order', $sqlval, 'order_id = ?', array($orderId)); 
    19201933        // ▲受注テーブルの更新 
Note: See TracChangeset for help on using the changeset viewer.