diff --git a/data/Smarty/templates/admin/order/edit.tpl b/data/Smarty/templates/admin/order/edit.tpl index b1581c624e..4d3d47b2b4 100644 --- a/data/Smarty/templates/admin/order/edit.tpl +++ b/data/Smarty/templates/admin/order/edit.tpl @@ -424,17 +424,15 @@ - - -
+
税率% - 円 + diff --git a/data/class/SC_FormParam.php b/data/class/SC_FormParam.php index aa3556f7f2..57461d1a57 100644 --- a/data/class/SC_FormParam.php +++ b/data/class/SC_FormParam.php @@ -426,19 +426,27 @@ public function getKeyList() // キー名と一致した値を返す public function getValue($keyname, $default = '') { - $ret = null; - if (in_array($keyname, $this->keyname)) { - $ret = isset($this->arrValue[$keyname]) ? $this->arrValue[$keyname] : $this->arrDefault[$keyname]; + if (!in_array($keyname, $this->keyname)) { + throw new Exception('定義されていない $keyname: ' . var_export($keyname, true)); } + // 意図的に NULL をセットしているケースを考慮し、isset() を使わない。 + $ret = array_key_exists($keyname, $this->arrValue) ? $this->arrValue[$keyname] : $this->arrDefault[$keyname]; + if (is_array($ret)) { foreach ($ret as &$value) { - if (SC_Utils_Ex::isBlank($value)) { + // 多次元配列の場合、手出ししない。(PHP8 不具合の応急対応。) + if (is_array($value)) { + // nop + } + elseif (SC_Utils_Ex::isBlank($value)) { + // FIXME: 上で取得している $this->arrDefault を上書きしている。不適切だと思うが影響が大きそうなので対応保留した。 $value = $default; } } } else { if (SC_Utils_Ex::isBlank($ret)) { + // FIXME: 上で取得している $this->arrDefault を上書きしている。不適切だと思うが影響が大きそうなので対応保留した。 $ret = $default; } } diff --git a/data/class/helper/SC_Helper_DB.php b/data/class/helper/SC_Helper_DB.php index 3c7f97bcb6..cf1648ea18 100644 --- a/data/class/helper/SC_Helper_DB.php +++ b/data/class/helper/SC_Helper_DB.php @@ -320,12 +320,13 @@ public function sfGetRootId() public static function sfGetRollbackPoint($order_id, $use_point, $add_point, $order_status) { $objQuery = SC_Query_Ex::getSingletonInstance(); - $arrRet = $objQuery->select('customer_id', 'dtb_order', 'order_id = ?', array($order_id)); - $customer_id = $arrRet[0]['customer_id']; - if ($customer_id != '' && $customer_id >= 1) { - $arrRet = $objQuery->select('point', 'dtb_customer', 'customer_id = ?', array($customer_id)); - $point = $arrRet[0]['point']; - $rollback_point = $arrRet[0]['point']; + + $customer_id = (int) $objQuery->get('customer_id', 'dtb_order', 'order_id = ?', array($order_id)); + $rollback_point = 0; + $point = 0; + if ($customer_id >= 1) { + $point = (int) $objQuery->get('point', 'dtb_customer', 'customer_id = ?', array($customer_id)); + $rollback_point = $point; // 対応状況がポイント利用対象の場合、使用ポイント分を戻す if (SC_Helper_Purchase_Ex::isUsePoint($order_status)) { @@ -336,9 +337,6 @@ public static function sfGetRollbackPoint($order_id, $use_point, $add_point, $or if (SC_Helper_Purchase_Ex::isAddPoint($order_status)) { $rollback_point -= $add_point; } - } else { - $rollback_point = ''; - $point = ''; } return array($point, $rollback_point); diff --git a/data/class/pages/admin/order/LC_Page_Admin_Order_Edit.php b/data/class/pages/admin/order/LC_Page_Admin_Order_Edit.php index b7c80c3314..f964a6a204 100644 --- a/data/class/pages/admin/order/LC_Page_Admin_Order_Edit.php +++ b/data/class/pages/admin/order/LC_Page_Admin_Order_Edit.php @@ -202,36 +202,40 @@ public function action() case 'edit': $objFormParam->setParam($_POST); $objFormParam->convParam(); + $this->arrErr = $this->lfCheckError($objFormParam); + if (!SC_Utils_Ex::isBlank($this->arrErr)) { + break; + } //複数配送時に各商品の総量を設定 $this->setProductsQuantity($objFormParam); - $this->arrErr = $this->lfCheckError($objFormParam); - if (SC_Utils_Ex::isBlank($this->arrErr)) { - $message = '受注を編集しました。'; - $order_id = $this->doRegister($order_id, $objPurchase, $objFormParam, $message, $arrValuesBefore); - if ($order_id >= 0) { - $this->setOrderToFormParam($objFormParam, $order_id); - } - $this->tpl_onload = "window.alert('" . $message . "');"; + + $message = '受注を編集しました。'; + $order_id = $this->doRegister($order_id, $objPurchase, $objFormParam, $message, $arrValuesBefore); + if ($order_id >= 0) { + $this->setOrderToFormParam($objFormParam, $order_id); } + $this->tpl_onload = "window.alert('" . $message . "');"; break; case 'add': if ($_SERVER['REQUEST_METHOD'] == 'POST') { $objFormParam->setParam($_POST); $objFormParam->convParam(); + $this->arrErr = $this->lfCheckError($objFormParam); + if (!SC_Utils_Ex::isBlank($this->arrErr)) { + break; + } //複数配送時に各商品の総量を設定 $this->setProductsQuantity($objFormParam); - $this->arrErr = $this->lfCheckError($objFormParam); - if (SC_Utils_Ex::isBlank($this->arrErr)) { - $message = '受注を登録しました。'; - $order_id = $this->doRegister(null, $objPurchase, $objFormParam, $message, $arrValuesBefore); - if ($order_id >= 0) { - $this->tpl_mode = 'edit'; - $objFormParam->setValue('order_id', $order_id); - $this->setOrderToFormParam($objFormParam, $order_id); - } - $this->tpl_onload = "window.alert('" . $message . "');"; + + $message = '受注を登録しました。'; + $order_id = $this->doRegister(null, $objPurchase, $objFormParam, $message, $arrValuesBefore); + if ($order_id >= 0) { + $this->tpl_mode = 'edit'; + $objFormParam->setValue('order_id', $order_id); + $this->setOrderToFormParam($objFormParam, $order_id); } + $this->tpl_onload = "window.alert('" . $message . "');"; } break; @@ -244,9 +248,12 @@ public function action() case 'deliv': $objFormParam->setParam($_POST); $objFormParam->convParam(); + $this->arrErr = $this->lfCheckError($objFormParam); + if (!SC_Utils_Ex::isBlank($this->arrErr)) { + break; + } //複数配送時に各商品の総量を設定 $this->setProductsQuantity($objFormParam); - $this->arrErr = $this->lfCheckError($objFormParam); break; // 商品削除 @@ -255,9 +262,12 @@ public function action() $objFormParam->convParam(); $delete_no = $objFormParam->getValue('delete_no'); $this->doDeleteProduct($delete_no, $objFormParam); + $this->arrErr = $this->lfCheckError($objFormParam); + if (!SC_Utils_Ex::isBlank($this->arrErr)) { + break; + } //複数配送時に各商品の総量を設定 $this->setProductsQuantity($objFormParam); - $this->arrErr = $this->lfCheckError($objFormParam); break; // 商品追加ポップアップより商品選択 @@ -265,16 +275,18 @@ public function action() $objFormParam->setParam($_POST); $objFormParam->convParam(); $this->doRegisterProduct($objFormParam); + $this->arrErr = $this->lfCheckError($objFormParam); + if (!SC_Utils_Ex::isBlank($this->arrErr)) { + break; + } //複数配送時に各商品の総量を設定 $this->setProductsQuantity($objFormParam); - $this->arrErr = $this->lfCheckError($objFormParam); break; // 会員検索ポップアップより会員指定 case 'search_customer': $objFormParam->setParam($_POST); $objFormParam->convParam(); - $this->setProductsQuantity($objFormParam); $this->setCustomerTo($objFormParam->getValue('edit_customer_id'), $objFormParam); $customer_birth = $objFormParam->getValue('order_birth'); @@ -291,16 +303,23 @@ public function action() } } $objFormParam->setValue("birth_point", $birth_point); + $this->arrErr = $this->lfCheckError($objFormParam); + if (!SC_Utils_Ex::isBlank($this->arrErr)) { + break; + } + $this->setProductsQuantity($objFormParam); } - $this->arrErr = $this->lfCheckError($objFormParam); break; // 複数配送設定表示 case 'multiple': $objFormParam->setParam($_POST); $objFormParam->convParam(); - $this->setProductsQuantity($objFormParam); $this->arrErr = $this->lfCheckError($objFormParam); + if (!SC_Utils_Ex::isBlank($this->arrErr)) { + break; + } + $this->setProductsQuantity($objFormParam); break; // 複数配送設定を反映 @@ -308,16 +327,24 @@ public function action() $this->lfInitMultipleParam($objFormParam); $objFormParam->setParam($_POST); $objFormParam->convParam(); - $this->setProductsQuantity($objFormParam); $this->setMultipleItemTo($objFormParam); + $this->arrErr = $this->lfCheckError($objFormParam); + if (!SC_Utils_Ex::isBlank($this->arrErr)) { + break; + } + $this->setProductsQuantity($objFormParam); break; // お届け先の追加 case 'append_shipping': $objFormParam->setParam($_POST); $objFormParam->convParam(); - $this->setProductsQuantity($objFormParam); $this->addShipping($objFormParam); + $this->arrErr = $this->lfCheckError($objFormParam); + if (!SC_Utils_Ex::isBlank($this->arrErr)) { + break; + } + $this->setProductsQuantity($objFormParam); break; default: @@ -393,23 +420,25 @@ public function lfInitParam(&$objFormParam) $objFormParam->addParam('お支払い方法', 'payment_id', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK')); $objFormParam->addParam('対応状況', 'status', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK')); $objFormParam->addParam('お支払方法名称', 'payment_method'); - - // 受注詳細情報 - $objFormParam->addParam('商品種別ID', 'product_type_id', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK'), '0'); - $objFormParam->addParam('単価', 'price', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK'), '0'); - $objFormParam->addParam('数量', 'quantity', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK'), '0'); - $objFormParam->addParam('商品ID', 'product_id', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK'), '0'); - $objFormParam->addParam('商品規格ID', 'product_class_id', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK'), '0'); - $objFormParam->addParam('ポイント付与率', 'point_rate'); - $objFormParam->addParam('商品コード', 'product_code'); - $objFormParam->addParam('商品名', 'product_name'); - $objFormParam->addParam('規格名1', 'classcategory_name1'); - $objFormParam->addParam('規格名2', 'classcategory_name2'); - $objFormParam->addParam('税率', 'tax_rate', INT_LEN, 'n', array('NUM_CHECK')); - $objFormParam->addParam('課税規則', 'tax_rule', INT_LEN, 'n', array('NUM_CHECK')); $objFormParam->addParam('メモ', 'note', MTEXT_LEN, 'KVa', array('MAX_LENGTH_CHECK')); $objFormParam->addParam('削除用項番', 'delete_no', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK')); + // 受注詳細情報 + $objFormParam->addParam('商品種別ID', 'product_type_id', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK'), []); + $objFormParam->addParam('単価', 'price', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK'), []); + $objFormParam->addParam('数量', 'quantity', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK'), []); + $objFormParam->addParam('税額', 'price_tax', '', '', [], [], false); + $objFormParam->addParam('税込単価', 'price_inctax', '', '', [], [], false); + $objFormParam->addParam('商品ID', 'product_id', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK'), []); + $objFormParam->addParam('商品規格ID', 'product_class_id', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK'), []); + $objFormParam->addParam('ポイント付与率', 'point_rate', []); + $objFormParam->addParam('商品コード', 'product_code', []); + $objFormParam->addParam('商品名', 'product_name', []); + $objFormParam->addParam('規格名1', 'classcategory_name1', []); + $objFormParam->addParam('規格名2', 'classcategory_name2', []); + $objFormParam->addParam('税率', 'tax_rate', INT_LEN, 'n', array('NUM_CHECK'), []); + $objFormParam->addParam('課税規則', 'tax_rule', INT_LEN, 'n', array('NUM_CHECK'), []); + // DB読込用 $objFormParam->addParam('小計', 'subtotal'); $objFormParam->addParam('合計', 'total'); @@ -421,7 +450,7 @@ public function lfInitParam(&$objFormParam) $objFormParam->addParam('会員ID', 'customer_id', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK'), '0'); $objFormParam->addParam('会員ID', 'edit_customer_id', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK'), '0'); $objFormParam->addParam('現在のポイント', 'customer_point'); - $objFormParam->addParam('受注前ポイント', 'point'); + $objFormParam->addParam('受注前ポイント', 'point', '', '', [], 0); $objFormParam->addParam('注文番号', 'order_id'); $objFormParam->addParam('受注日', 'create_date'); $objFormParam->addParam('発送日', 'commit_date'); @@ -457,13 +486,13 @@ public function lfInitParam(&$objFormParam) $objFormParam->addParam('お届け日(日)', 'shipping_date_day', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK')); $objFormParam->addParam('お届け日', 'shipping_date', STEXT_LEN, 'KVa', array('SPTAB_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('商品規格ID', 'shipment_product_class_id', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK')); - $objFormParam->addParam('商品コード', 'shipment_product_code'); - $objFormParam->addParam('商品名', 'shipment_product_name'); - $objFormParam->addParam('規格名1', 'shipment_classcategory_name1'); - $objFormParam->addParam('規格名2', 'shipment_classcategory_name2'); - $objFormParam->addParam('単価', 'shipment_price', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK'), '0'); - $objFormParam->addParam('数量', 'shipment_quantity', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK'), '0'); + $objFormParam->addParam('商品規格ID', 'shipment_product_class_id', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK'), []); + $objFormParam->addParam('商品コード', 'shipment_product_code', '', '', [], []); + $objFormParam->addParam('商品名', 'shipment_product_name', '', '', [], []); + $objFormParam->addParam('規格名1', 'shipment_classcategory_name1', '', '', [], []); + $objFormParam->addParam('規格名2', 'shipment_classcategory_name2', '', '', [], []); + $objFormParam->addParam('単価', 'shipment_price', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK'), []); + $objFormParam->addParam('数量', 'shipment_quantity', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK'), []); $objFormParam->addParam('商品項番', 'no', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK')); $objFormParam->addParam('追加商品規格ID', 'add_product_class_id', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK')); @@ -579,6 +608,7 @@ public function setOrderToFormParam(&$objFormParam, $order_id) // 受注詳細を設定 $arrOrderDetail = $objPurchase->getOrderDetail($order_id, false); $objFormParam->setParam(SC_Utils_Ex::sfSwapArray($arrOrderDetail)); + $this->calcPriceInctax($objFormParam); $arrShippingsTmp = $objPurchase->getShippings($order_id); $arrShippings = array(); @@ -592,12 +622,12 @@ public function setOrderToFormParam(&$objFormParam, $order_id) $row['shipping_date_month'] = date('n', $ts); $row['shipping_date_day'] = date('j', $ts); } - $arrShippings[$row['shipping_id']] = $row; + $arrShippings[$row['shipping_id']] = array_intersect_key($row, array_flip($this->arrShippingKeys)); } } else { // ダウンロード商品の場合はお届け先情報がないので受注詳細から必要なデータを挿入する foreach ($this->arrShippingKeys as $keys) { - $arrShippings[0][$keys] = ''; + $arrShippings[0][$keys] = null; } foreach ($arrOrderDetail as $key => $value) { $arrShippings[0]['shipment_item'][$key]['shipping_id'] = $key; @@ -650,9 +680,6 @@ public function setOrderToFormParam(&$objFormParam, $order_id) ); $objFormParam->setValue('total_point', $db_point); $objFormParam->setValue('point', $rollback_point); - } else { - $objFormParam->setValue('total_point', 0); - $objFormParam->setValue('point', 0); } if (!SC_Utils_Ex::isBlank($objFormParam->getValue('customer_id'))) { @@ -670,10 +697,16 @@ public function setOrderToFormParam(&$objFormParam, $order_id) public function lfCheckError(&$objFormParam) { $objProduct = new SC_Product_Ex(); + $arrErrTemp = $objFormParam->checkError(); + + if (!SC_Utils_Ex::isBlank($arrErrTemp)) { + return $arrErrTemp; + } + + $this->calcPriceInctax($objFormParam); + $arrValues = $objFormParam->getHashArray(); $arrErr = array(); - $arrErrTemp = $objFormParam->checkError(); - $arrErrDate = array(); foreach ($arrValues['shipping_date_year'] as $key_index => $year) { $month = $arrValues['shipping_date_month'][$key_index]; $day = $arrValues['shipping_date_day'][$key_index]; @@ -681,9 +714,10 @@ public function lfCheckError(&$objFormParam) 'shipping_date_month' => $month, 'shipping_date_day' => $day)); $objError->doFunc(array('お届け日', 'shipping_date_year', 'shipping_date_month', 'shipping_date_day'), array('CHECK_DATE')); - $arrErrDate['shipping_date_year'][$key_index] = $objError->arrErr['shipping_date_year']; + foreach ($objError->arrErr as $key => $error) { + $arrErrTemp[$key][$key_index] = $error; + } } - $arrErrTemp = array_merge($arrErrTemp, $arrErrDate); // 複数項目チェック $year = $arrValues['order_birth_year']; @@ -694,7 +728,9 @@ public function lfCheckError(&$objFormParam) 'order_birth_day' => $day)); $objError->doFunc(array('生年月日', 'order_birth_year', 'order_birth_month', 'order_birth_day'), array('CHECK_BIRTHDAY')); - $arrErrTemp['order_birth_year'] = $objError->arrErr['order_birth_year']; + foreach ($objError->arrErr as $key => $error) { + $arrErrTemp[$key] = $error; + } // 商品の種類数 $max = count($arrValues['quantity']); @@ -703,10 +739,9 @@ public function lfCheckError(&$objFormParam) $totaltax = 0; for ($i = 0; $i < $max; $i++) { // 小計の計算 - $tax = SC_Helper_TaxRule_Ex::calcTax($arrValues['price'][$i], $arrValues['tax_rate'][$i], $arrValues['tax_rule'][$i]); - $subtotal += ($tax + $arrValues['price'][$i]) * $arrValues['quantity'][$i]; + $subtotal += $arrValues['price_inctax'][$i] * $arrValues['quantity'][$i]; // 税額の計算 - $totaltax += $tax * $arrValues['quantity'][$i]; + $totaltax += $arrValues['price_tax'][$i] * $arrValues['quantity'][$i]; // 加算ポイントの計算 $totalpoint += SC_Utils_Ex::sfPrePoint($arrValues['price'][$i], $arrValues['point_rate'][$i]) * $arrValues['quantity'][$i]; @@ -1024,7 +1059,7 @@ public function getAnchorKey(&$objFormParam) } /** - * 商品を追加 + * 配送先に商品を追加 * * @param SC_FormParam $objFormParam SC_FormParam インスタンス * @param integer $add_product_class_id 追加商品規格ID @@ -1032,27 +1067,34 @@ public function getAnchorKey(&$objFormParam) */ public function shipmentAddProduct(&$objFormParam, $add_product_class_id) { - //複数配送に商品情報追加 $select_shipping_id = $objFormParam->getValue('select_shipping_id'); - //届け先に選択済みの商品がある場合 $arrShipmentProducts = $this->getShipmentProducts($objFormParam); - if ($arrShipmentProducts['shipment_product_class_id'] && in_array($add_product_class_id, $arrShipmentProducts['shipment_product_class_id'][$select_shipping_id])) { - foreach ($arrShipmentProducts['shipment_product_class_id'][$select_shipping_id] as $relation_index => $shipment_product_class_id) { - if ($shipment_product_class_id == $add_product_class_id) { - $arrShipmentProducts['shipment_quantity'][$select_shipping_id][$relation_index]++; - break; - } + // PHP8 で初期化されていない配列によるエラーを回避する目的のワンライナー + // XXX 今後同様の処理を量産するかもしれないが、多分、もっと美しい処理がある。正規表現「([^ ]+)\s*=\s*\(array\)\s*\1」で同様の処理を抽出できる。 + // $arrShipmentProducts['shipment_product_class_id'][$select_shipping_id] = (array) $arrShipmentProducts['shipment_product_class_id'][$select_shipping_id]; + + $found = false; + foreach ($arrShipmentProducts['shipment_product_class_id'][$select_shipping_id] as $relation_index => $shipment_product_class_id) { + // 届け先に選択済みの商品がある場合 + if ($shipment_product_class_id == $add_product_class_id) { + $arrShipmentProducts['shipment_quantity'][$select_shipping_id][$relation_index]++; + $found = true; + break; } - } else { - //届け先に選択商品がない場合 + } + + // 届け先に選択商品がない場合 + if (!$found) { $objProduct = new SC_Product_Ex(); $arrAddProductInfo = $objProduct->getDetailAndProductsClass($add_product_class_id); $arrShipmentProducts['shipment_product_class_id'][$select_shipping_id][] = $add_product_class_id; $arrShipmentProducts['shipment_product_code'][$select_shipping_id][] = $arrAddProductInfo['product_code']; $arrShipmentProducts['shipment_product_name'][$select_shipping_id][] = $arrAddProductInfo['name']; + $arrShipmentProducts['shipment_classcategory_name1'][$select_shipping_id][] = $arrAddProductInfo['classcategory_name1']; + $arrShipmentProducts['shipment_classcategory_name2'][$select_shipping_id][] = $arrAddProductInfo['classcategory_name2']; $arrShipmentProducts['shipment_price'][$select_shipping_id][] = $arrAddProductInfo['price02']; $arrShipmentProducts['shipment_quantity'][$select_shipping_id][] = 1; @@ -1061,6 +1103,7 @@ public function shipmentAddProduct(&$objFormParam, $add_product_class_id) $arrProducts = $this->checkInsertOrderProducts($objFormParam, $arrPreProductClassIds, $add_product_class_id, $arrAddProductInfo); $objFormParam->setParam($arrProducts); } + $objFormParam->setParam($arrShipmentProducts); } @@ -1195,6 +1238,9 @@ public function setProductsQuantity(&$objFormParam) $arrUpdateQuantity = array(); foreach ($arrShipmentsItems as $arritems) { foreach ($arritems['shipment_product_class_id'] as $relation_index => $shipment_product_class_id) { + if (!isset($arrUpdateQuantity[$shipment_product_class_id])) { + $arrUpdateQuantity[$shipment_product_class_id] = 0; + } $arrUpdateQuantity[$shipment_product_class_id] += $arritems['shipment_quantity'][$relation_index]; } } @@ -1308,4 +1354,24 @@ public function checkInsertOrderProducts(&$objFormParam, $arrProductClassIds, $i return null; } } + + /** + * 税込単価を計算する。 + * + * @param SC_FormParam $objFormParam + * @return void + */ + public function calcPriceInctax(&$objFormParam) + { + $arrValues = $objFormParam->getHashArray(); + foreach ($arrValues['price'] as $index => $dummy) { + // 税額 + $arrValues['price_tax'][$index] = + $tax = SC_Helper_TaxRule_Ex::calcTax($arrValues['price'][$index], $arrValues['tax_rate'][$index], $arrValues['tax_rule'][$index]); + + // 税込単価 + $arrValues['price_inctax'][$index] = $tax + $arrValues['price'][$index]; + } + $objFormParam->setParam($arrValues); + } } diff --git a/data/class/util/SC_Utils.php b/data/class/util/SC_Utils.php index 70e4f18ddc..55b0feeb9e 100755 --- a/data/class/util/SC_Utils.php +++ b/data/class/util/SC_Utils.php @@ -885,6 +885,13 @@ public static function getHash2Array($hash, $requires = array()) /* かけ算をする(Smarty用) */ public static function sfMultiply($num1, $num2) { + if (strlen($num1) == 0) { + return ''; + } + if (strlen($num2) == 0) { + return ''; + } + return $num1 * $num2; } diff --git a/tests/class/helper/SC_Helper_DB/SC_Helper_DB_sfGetRollbackPointTest.php b/tests/class/helper/SC_Helper_DB/SC_Helper_DB_sfGetRollbackPointTest.php index 66f8890b16..e13eae8d55 100644 --- a/tests/class/helper/SC_Helper_DB/SC_Helper_DB_sfGetRollbackPointTest.php +++ b/tests/class/helper/SC_Helper_DB/SC_Helper_DB_sfGetRollbackPointTest.php @@ -63,8 +63,8 @@ public function testSfGetRollbackPointNonCustomer() $this->order_id = $this->objGenerator->createOrder(); $this->secenario(100, 100, ORDER_CANCEL); - $this->assertSame('', $this->order_point, '非会員の場合は空'); - $this->assertSame('', $this->rollback_point, '非会員の場合は空'); + $this->assertSame(0, $this->order_point, '非会員の場合は0'); + $this->assertSame(0, $this->rollback_point, '非会員の場合は0'); } protected function secenario($use_point, $add_point, $order_status)