/** * 設定情報IDに基づいて税金の金額を返す * (受注データのようにルールが決まっている場合用) * * @param int $price 計算対象の金額 * @param int $tax_rule_id 税規約ID * @return double 税金付与した金額 */ public static function calcTaxFromRuleId($price, $tax_rule_id = 0) { $arrTaxRule = SC_Helper_TaxRule_Ex::getTaxRuleData($tax_rule_id); return SC_Helper_TaxRule_Ex::calcTax($price, $arrTaxRule['tax_rate'], $arrTaxRule['tax_rule'], $arrTaxRule['tax_adjust']); }
/** * 商品種別ごとにカート内商品の一覧を取得する. * * @param integer $productTypeId 商品種別ID * @param integer $pref_id 税金計算用注文者都道府県ID * @param integer $country_id 税金計算用注文者国ID * @return array カート内商品一覧の配列 */ public function getCartList($productTypeId, $pref_id = 0, $country_id = 0) { $objProduct = new SC_Product_Ex(); $max = $this->getMax($productTypeId); $arrRet = array(); /* $const_name = '_CALLED_SC_CARTSESSION_GETCARTLIST_' . $productTypeId; if (defined($const_name)) { $is_first = true; } else { define($const_name, true); $is_first = false; } */ for ($i = 0; $i <= $max; $i++) { if (isset($this->cartSession[$productTypeId][$i]['cart_no']) && $this->cartSession[$productTypeId][$i]['cart_no'] != '') { // 商品情報は常に取得 // TODO: 同一インスタンス内では1回のみ呼ぶようにしたい // TODO: ここの商品の合計処理は getAllProductsTotalや getAllProductsTaxとで類似重複なので統一出来そう /* // 同一セッション内では初回のみDB参照するようにしている if (!$is_first) { $this->setCartSession4getCartList($productTypeId, $i); } */ $this->cartSession[$productTypeId][$i]['productsClass'] =& $objProduct->getDetailAndProductsClass($this->cartSession[$productTypeId][$i]['id']); $price = $this->cartSession[$productTypeId][$i]['productsClass']['price02']; $this->cartSession[$productTypeId][$i]['price'] = $price; $this->cartSession[$productTypeId][$i]['point_rate'] = $this->cartSession[$productTypeId][$i]['productsClass']['point_rate']; $quantity = $this->cartSession[$productTypeId][$i]['quantity']; $arrTaxRule = SC_Helper_TaxRule_Ex::getTaxRule($this->cartSession[$productTypeId][$i]['productsClass']['product_id'], $this->cartSession[$productTypeId][$i]['productsClass']['product_class_id'], $pref_id, $country_id); $incTax = $price + SC_Helper_TaxRule_Ex::calcTax($price, $arrTaxRule['tax_rate'], $arrTaxRule['tax_rule'], $arrTaxRule['tax_adjust']); $total = $incTax * $quantity; $this->cartSession[$productTypeId][$i]['price_inctax'] = $incTax; $this->cartSession[$productTypeId][$i]['total_inctax'] = $total; $this->cartSession[$productTypeId][$i]['tax_rate'] = $arrTaxRule['tax_rate']; $this->cartSession[$productTypeId][$i]['tax_rule'] = $arrTaxRule['tax_rule']; $this->cartSession[$productTypeId][$i]['tax_adjust'] = $arrTaxRule['tax_adjust']; $arrRet[] = $this->cartSession[$productTypeId][$i]; // セッション変数のデータ量を抑制するため、一部の商品情報を切り捨てる // XXX 上で「常に取得」するのだから、丸ごと切り捨てて良さそうにも感じる。 $this->adjustSessionProductsClass($this->cartSession[$productTypeId][$i]['productsClass']); } } return $arrRet; }
/** * Page のAction. * * @return void */ public function action() { //決済処理中ステータスのロールバック $objPurchase = new SC_Helper_Purchase_Ex(); $objPurchase->cancelPendingOrder(PENDING_ORDER_CANCEL_FLAG); $objCustomer = new SC_Customer_Ex(); $objProduct = new SC_Product(); if (!SC_Utils_Ex::sfIsInt($_GET['order_id'])) { SC_Utils_Ex::sfDispSiteError(CUSTOMER_ERROR); } $order_id = $_GET['order_id']; $this->is_price_change = false; //受注データの取得 $this->tpl_arrOrderData = $objPurchase->getOrder($order_id, $objCustomer->getValue('customer_id')); if (empty($this->tpl_arrOrderData)) { SC_Utils_Ex::sfDispSiteError(CUSTOMER_ERROR); } $this->arrShipping = $this->lfGetShippingDate($objPurchase, $order_id, $this->arrWDAY); $this->isMultiple = count($this->arrShipping) > 1; // 支払い方法の取得 $this->arrPayment = SC_Helper_Payment_Ex::getIDValueList(); // 受注商品明細の取得 $this->tpl_arrOrderDetail = $objPurchase->getOrderDetail($order_id); foreach ($this->tpl_arrOrderDetail as $product_index => $arrOrderProductDetail) { //必要なのは商品の販売金額のみなので、遅い場合は、別途SQL作成した方が良い $arrTempProductDetail = $objProduct->getProductsClass($arrOrderProductDetail['product_class_id']); // 税計算 $this->tpl_arrOrderDetail[$product_index]['price_inctax'] = $this->tpl_arrOrderDetail[$product_index]['price'] + SC_Helper_TaxRule_Ex::calcTax($this->tpl_arrOrderDetail[$product_index]['price'], $this->tpl_arrOrderDetail[$product_index]['tax_rate'], $this->tpl_arrOrderDetail[$product_index]['tax_rule']); $arrTempProductDetail['price02_inctax'] = SC_Helper_TaxRule_Ex::sfCalcIncTax($arrTempProductDetail['price02'], $arrTempProductDetail['product_id'], $arrTempProductDetail['product_class_id']); if ($this->tpl_arrOrderDetail[$product_index]['price_inctax'] != $arrTempProductDetail['price02_inctax']) { $this->is_price_change = true; } $this->tpl_arrOrderDetail[$product_index]['product_price_inctax'] = $arrTempProductDetail['price02_inctax'] ? $arrTempProductDetail['price02_inctax'] : 0; } $this->tpl_arrOrderDetail = $this->setMainListImage($this->tpl_arrOrderDetail); $objPurchase->setDownloadableFlgTo($this->tpl_arrOrderDetail); // モバイルダウンロード対応処理 $this->lfSetAU($this->tpl_arrOrderDetail); // 受注メール送信履歴の取得 $this->tpl_arrMailHistory = $this->lfGetMailHistory($order_id); }