Exemplo n.º 1
0
 /**
  * 入力内容のチェックを行う.
  *
  * @param  FormParam $objFormParam FormParam インスタンス
  * @return array        エラーメッセージの配列
  */
 public function lfCheckError(&$objFormParam)
 {
     /* @var $objProduct Product */
     $objProduct = Application::alias('eccube.product');
     $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];
         /* @var $objError CheckError */
         $objError = Application::alias('eccube.check_error', array('shipping_date_year' => $year, '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'];
     }
     $arrErrTemp = array_merge($arrErrTemp, $arrErrDate);
     // 複数項目チェック
     $year = $arrValues['order_birth_year'];
     $month = $arrValues['order_birth_month'];
     $day = $arrValues['order_birth_day'];
     /* @var $objError CheckError */
     $objError = Application::alias('eccube.check_error', array('order_birth_year' => $year, 'order_birth_month' => $month, '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'];
     // 商品の種類数
     $max = count($arrValues['quantity']);
     $subtotal = 0;
     $totalpoint = 0;
     $totaltax = 0;
     for ($i = 0; $i < $max; $i++) {
         // 小計の計算
         $subtotal += Application::alias('eccube.helper.db')->calcIncTax($arrValues['price'][$i], $arrValues['tax_rate'][$i], $arrValues['tax_rule'][$i]) * $arrValues['quantity'][$i];
         // 小計の計算
         $totaltax += Utils::sfTax($arrValues['price'][$i], $arrValues['tax_rate'][$i], $arrValues['tax_rule'][$i]) * $arrValues['quantity'][$i];
         // 加算ポイントの計算
         $totalpoint += Utils::sfPrePoint($arrValues['price'][$i], $arrValues['point_rate'][$i]) * $arrValues['quantity'][$i];
         // 在庫数のチェック
         $arrProduct = $objProduct->getDetailAndProductsClass($arrValues['product_class_id'][$i]);
         // 編集前の値と比較するため受注詳細を取得
         /* @var $objPurchase PurchaseHelper */
         $objPurchase = Application::alias('eccube.helper.purchase');
         $arrOrderDetail = Utils::sfSwapArray($objPurchase->getOrderDetail($objFormParam->getValue('order_id'), false));
         if ($arrProduct['stock_unlimited'] != '1' && $arrProduct['stock'] < $arrValues['quantity'][$i] - $arrOrderDetail['quantity'][$i]) {
             $class_name1 = $arrValues['classcategory_name1'][$i];
             $class_name1 = Utils::isBlank($class_name1) ? 'なし' : $class_name1;
             $class_name2 = $arrValues['classcategory_name2'][$i];
             $class_name2 = Utils::isBlank($class_name2) ? 'なし' : $class_name2;
             $arrErr['quantity'][$i] .= $arrValues['product_name'][$i] . '/(' . $class_name1 . ')/(' . $class_name2 . ') の在庫が不足しています。 設定できる数量は「' . ($arrOrderDetail['quantity'][$i] + $arrProduct['stock']) . '」までです。<br />';
         }
     }
     // 消費税
     $arrValues['tax'] = $totaltax;
     // 小計
     $arrValues['subtotal'] = $subtotal;
     // 合計
     $arrValues['total'] = $subtotal - $arrValues['discount'] + $arrValues['deliv_fee'] + $arrValues['charge'];
     // お支払い合計
     $arrValues['payment_total'] = $arrValues['total'] - $arrValues['use_point'] * POINT_VALUE;
     // 加算ポイント
     $arrValues['add_point'] = Application::alias('eccube.helper.db')->getAddPoint($totalpoint, $arrValues['use_point']) + $arrValues['birth_point'];
     // 最終保持ポイント
     $arrValues['total_point'] = $objFormParam->getValue('point') - $arrValues['use_point'];
     if ($arrValues['total'] < 0) {
         $arrErr['total'] = '合計額がマイナス表示にならないように調整して下さい。<br />';
     }
     if ($arrValues['payment_total'] < 0) {
         $arrErr['payment_total'] = 'お支払い合計額がマイナス表示にならないように調整して下さい。<br />';
     }
     if ($arrValues['total_point'] < 0) {
         $arrErr['use_point'] = '最終保持ポイントがマイナス表示にならないように調整して下さい。<br />';
     }
     $objFormParam->setParam($arrValues);
     $arrErr = array_merge($arrErr, $arrErrTemp);
     return $arrErr;
 }
Exemplo n.º 2
0
 /**
  * 店舗基本情報に基づいて税金額を返す
  *
  * @param  integer $price 計算対象の金額
  * @return double 税金額
  */
 public function tax($price)
 {
     // 店舗基本情報を取得
     $CONF = $this->getBasisData();
     return Utils::sfTax($price, $CONF['tax'], $CONF['tax_rule']);
 }