Changeset 22975


Ignore:
Timestamp:
2013/07/20 16:18:26 (11 years ago)
Author:
AMUAMU
Message:

#1730 (税率変更に対応できない)
#2191 (税率対応に向けて、税率管理画面を作成する)
関係の修正一部

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/version-2_13-dev/data/class/SC_CartSession.php

    r22960 r22975  
    110110    } 
    111111 
    112     /** 
    113      * 商品ごとの合計価格 
    114      * XXX 実際には、「商品」ではなく、「カートの明細行(≒商品規格)」のような気がします。 
    115      * 
    116      * @param integer $id 
    117      * @return string 商品ごとの合計価格(税込み) 
    118      * @deprecated SC_CartSession::getCartList() を使用してください 
    119      */ 
    120     function getProductTotal($id, $productTypeId) 
    121     { 
    122         $max = $this->getMax($productTypeId); 
    123         for ($i = 0; $i <= $max; $i++) { 
    124             if (isset($this->cartSession[$productTypeId][$i]['id']) 
    125                 && $this->cartSession[$productTypeId][$i]['id'] == $id 
    126             ) { 
    127                 // 税込み合計 
    128                 $price = $this->cartSession[$productTypeId][$i]['price']; 
    129                 $quantity = $this->cartSession[$productTypeId][$i]['quantity']; 
    130                 $incTax = SC_Helper_TaxRule_Ex::sfCalcIncTax($price, 0, $id[0]); 
    131                 $total = $incTax * $quantity; 
    132                 return $total; 
    133             } 
    134         } 
    135  
    136         return 0; 
    137     } 
    138  
    139112    // 値のセット 
    140113    function setProductValue($id, $key, $val, $productTypeId) 
     
    180153 
    181154    // 全商品の合計価格 
    182     function getAllProductsTotal($productTypeId) 
     155    function getAllProductsTotal($productTypeId, $pref_id = 0, $country_id = 0) 
    183156    { 
    184157        // 税込み合計 
     
    196169            } 
    197170            $quantity = $this->cartSession[$productTypeId][$i]['quantity']; 
    198  
    199171            $incTax = SC_Helper_TaxRule_Ex::sfCalcIncTax($price, 
    200172                $this->cartSession[$productTypeId][$i]['productsClass']['product_id'], 
    201                 $this->cartSession[$productTypeId][$i]['id'][0]); 
     173                $this->cartSession[$productTypeId][$i]['id'][0], 
     174                $pref_id, $country_id); 
     175 
    202176            $total+= ($incTax * $quantity); 
    203177        } 
    204  
    205178        return $total; 
    206179    } 
    207180 
    208181    // 全商品の合計税金 
    209     function getAllProductsTax($productTypeId) 
     182    function getAllProductsTax($productTypeId, $pref_id = 0, $country_id = 0) 
    210183    { 
    211184        // 税合計 
     
    217190            $tax = SC_Helper_TaxRule_Ex::sfTax($price, 
    218191                $this->cartSession[$productTypeId][$i]['productsClass']['product_id'], 
    219                 $this->cartSession[$productTypeId][$i]['id'][0]); 
     192                $this->cartSession[$productTypeId][$i]['id'][0], 
     193                $pref_id, $country_id); 
     194 
    220195            $total+= ($tax * $quantity); 
    221196        } 
     
    362337     * @param integer $key  
    363338     * @return void 
     339     * 
     340     * MEMO: せっかく一回だけ読み込みにされてますが、税率対応の関係でちょっと保留 
    364341     */ 
    365342    function setCartSession4getCartList($productTypeId, $key) 
     
    391368     * 
    392369     * @param integer $productTypeId 商品種別ID 
     370     * @param integer $pref_id 税金計算用注文者都道府県ID 
     371     * @param integer $country_id 税金計算用注文者国ID 
    393372     * @return array カート内商品一覧の配列 
    394373     */ 
    395     function getCartList($productTypeId) 
    396     { 
     374    function getCartList($productTypeId, $pref_id = 0, $country_id = 0) 
     375    { 
     376        $objProduct = new SC_Product_Ex(); 
    397377        $max = $this->getMax($productTypeId); 
    398378        $arrRet = array(); 
     379/* 
    399380 
    400381        $const_name = '_CALLED_SC_CARTSESSION_GETCARTLIST_' . $productTypeId; 
     
    406387        } 
    407388 
     389*/ 
    408390        for ($i = 0; $i <= $max; $i++) { 
    409391            if (isset($this->cartSession[$productTypeId][$i]['cart_no']) 
    410392                && $this->cartSession[$productTypeId][$i]['cart_no'] != '') { 
     393 
    411394                // 商品情報は常に取得 
    412  
     395                // TODO: 同一インスタンス内では1回のみ呼ぶようにしたい 
     396                // TODO: ここの商品の合計処理は getAllProductsTotalや getAllProductsTaxとで類似重複なので統一出来そう 
     397/* 
    413398                // 同一セッション内では初回のみDB参照するようにしている 
    414399                if (!$is_first) { 
    415400                    $this->setCartSession4getCartList($productTypeId, $i); 
    416401                } 
     402*/ 
     403 
     404                $this->cartSession[$productTypeId][$i]['productsClass'] 
     405                    =& $objProduct->getDetailAndProductsClass($this->cartSession[$productTypeId][$i]['id']); 
     406 
     407                $price = $this->cartSession[$productTypeId][$i]['productsClass']['price02']; 
     408                $this->cartSession[$productTypeId][$i]['price'] = $price; 
     409 
     410                $this->cartSession[$productTypeId][$i]['point_rate'] 
     411                    = $this->cartSession[$productTypeId][$i]['productsClass']['point_rate']; 
     412 
     413                $quantity = $this->cartSession[$productTypeId][$i]['quantity']; 
     414 
     415                $arrTaxRule = SC_Helper_TaxRule_Ex::getTaxRule( 
     416                                    $this->cartSession[$productTypeId][$i]['productsClass']['product_id'], 
     417                                    $this->cartSession[$productTypeId][$i]['id'][0], 
     418                                    $pref_id, 
     419                                    $country_id); 
     420                $incTax = $price + SC_Helper_TaxRule_Ex::calcTax($price, $arrTaxRule['tax_rate'], $arrTaxRule['tax_rule'], $arrTaxRule['tax_adjust']); 
     421 
     422                $total = $incTax * $quantity; 
     423                $this->cartSession[$productTypeId][$i]['price_inctax'] = $incTax; 
     424                $this->cartSession[$productTypeId][$i]['total_inctax'] = $total; 
     425                $this->cartSession[$productTypeId][$i]['tax_rate'] = $arrTaxRule['tax_rate']; 
     426                $this->cartSession[$productTypeId][$i]['tax_rule'] = $arrTaxRule['tax_rule']; 
     427                $this->cartSession[$productTypeId][$i]['tax_adjust'] = $arrTaxRule['tax_adjust']; 
    417428 
    418429                $arrRet[] = $this->cartSession[$productTypeId][$i]; 
     
    682693     * @param integer $discount 値引き 
    683694     * @param integer $deliv_id 配送業者ID 
     695     * @param integer $order_pref 注文者の都道府県ID 
     696     * @param integer $order_country_id 注文者の国 
    684697     * @return array カートの計算結果の配列 
    685698     */ 
    686699    function calculate($productTypeId, &$objCustomer, $use_point = 0, 
    687         $deliv_pref = '', $charge = 0, $discount = 0, $deliv_id = 0 
     700        $deliv_pref = '', $charge = 0, $discount = 0, $deliv_id = 0, 
     701        $order_pref = 0, $order_country_id = 0 
    688702    ) { 
     703 
    689704        $results = array(); 
    690705        $total_point = $this->getAllProductsPoint($productTypeId); 
    691         $results['tax'] = $this->getAllProductsTax($productTypeId); 
    692         $results['subtotal'] = $this->getAllProductsTotal($productTypeId); 
     706        // MEMO: 税金計算は注文者の住所基準 
     707        $results['tax'] = $this->getAllProductsTax($productTypeId, $order_pref, $order_country_id); 
     708        $results['subtotal'] = $this->getAllProductsTotal($productTypeId, $oder_pref, $order_country_id); 
    693709        $results['deliv_fee'] = 0; 
    694  
    695         $arrTaxInfo = SC_Helper_TaxRule_Ex::getTaxRule(); 
    696         $results['order_tax_rate'] = $arrTaxInfo['tax_rate']; 
    697         $results['order_tax_rule'] = $arrTaxInfo['calc_rule']; 
    698710 
    699711        // 商品ごとの送料を加算 
Note: See TracChangeset for help on using the changeset viewer.