function action() { parent::action(); if (is_array($this->arrResults) && count($this->arrResults) > 0) { $objPurchase = new SC_Helper_Purchase_Ex(); $detect = new Mobile_Detect(); foreach ($this->arrResults as &$order) { $order["detail"] = $objPurchase->getOrderDetail($order["order_id"]); if (isset($order["useragent"])) { $detect->setUserAgent($order["useragent"]); $useragent = array(); if ($detect->is("AndroidOS")) { preg_match("{.*;([^;]+) Build}", $order["useragent"], $useragent); $order["device"] = $useragent[1]; } } } } }
/** * 受注データを取得して, SC_FormParam へ設定する. * * @param SC_FormParam $objFormParam SC_FormParam インスタンス * @param integer $order_id 取得元の受注ID * @return void */ function setOrderToFormParam(&$objFormParam, $order_id) { $objPurchase = new SC_Helper_Purchase_Ex(); // 受注詳細を設定 $arrOrderDetail = $objPurchase->getOrderDetail($order_id, false); $objFormParam->setParam(SC_Utils_Ex::sfSwapArray($arrOrderDetail)); $arrShippingsTmp = $objPurchase->getShippings($order_id); $arrShippings = array(); foreach ($arrShippingsTmp as $row) { // お届け日の処理 if (!SC_Utils_Ex::isBlank($row['shipping_date'])) { $ts = strtotime($row['shipping_date']); $row['shipping_date_year'] = date('Y', $ts); $row['shipping_date_month'] = date('n', $ts); $row['shipping_date_day'] = date('j', $ts); } $arrShippings[$row['shipping_id']] = $row; } $objFormParam->setValue('shipping_quantity', count($arrShippings)); $objFormParam->setParam(SC_Utils_Ex::sfSwapArray($arrShippings)); /* * 配送商品を設定 * * $arrShipmentItem['shipment_(key)'][$shipping_id][$item_index] = 値 * $arrProductQuantity[$shipping_id] = 配送先ごとの配送商品数量 */ $arrProductQuantity = array(); $arrShipmentItem = array(); foreach ($arrShippings as $shipping_id => $arrShipping) { $arrProductQuantity[$shipping_id] = count($arrShipping['shipment_item']); foreach ($arrShipping['shipment_item'] as $item_index => $arrItem) { foreach ($arrItem as $item_key => $item_val) { $arrShipmentItem['shipment_' . $item_key][$shipping_id][$item_index] = $item_val; } } } $objFormParam->setValue('shipping_product_quantity', $arrProductQuantity); $objFormParam->setParam($arrShipmentItem); /* * 受注情報を設定 * $arrOrderDetail と項目が重複しており, $arrOrderDetail は連想配列の値 * が渡ってくるため, $arrOrder で上書きする. */ $arrOrder = $objPurchase->getOrder($order_id); $objFormParam->setParam($arrOrder); // ポイントを設定 list($db_point, $rollback_point) = SC_Helper_DB_Ex::sfGetRollbackPoint($order_id, $arrOrder['use_point'], $arrOrder['add_point'], $arrOrder['status']); $objFormParam->setValue('total_point', $db_point); $objFormParam->setValue('point', $rollback_point); if (!SC_Utils_Ex::isBlank($objFormParam->getValue('customer_id'))) { $arrCustomer = SC_Helper_Customer_Ex::sfGetCustomerDataFromId($objFormParam->getValue('customer_id')); $objFormParam->setValue('customer_point', $arrCustomer['point']); } }
/** * 入力内容のチェックを行う. * * @param SC_FormParam $objFormParam SC_FormParam インスタンス * @return array エラーメッセージの配列 */ function lfCheckError(&$objFormParam) { $objProduct = new SC_Product_Ex(); $arrErr = $objFormParam->checkError(); if (!SC_Utils_Ex::isBlank($objErr->arrErr)) { return $arrErr; } $arrValues = $objFormParam->getHashArray(); // 商品の種類数 $max = count($arrValues['quantity']); $subtotal = 0; $totalpoint = 0; $totaltax = 0; for ($i = 0; $i < $max; $i++) { // 小計の計算 $subtotal += SC_Helper_DB_Ex::sfCalcIncTax($arrValues['price'][$i]) * $arrValues['quantity'][$i]; // 小計の計算 $totaltax += SC_Helper_DB_Ex::sfTax($arrValues['price'][$i]) * $arrValues['quantity'][$i]; // 加算ポイントの計算 $totalpoint += SC_Utils_Ex::sfPrePoint($arrValues['price'][$i], $arrValues['point_rate'][$i]) * $arrValues['quantity'][$i]; // 在庫数のチェック $arrProduct = $objProduct->getDetailAndProductsClass($arrValues['product_class_id'][$i]); // 編集前の値と比較するため受注詳細を取得 $objPurchase = new SC_Helper_Purchase_Ex(); $arrOrderDetail = SC_Utils_Ex::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 = SC_Utils_Ex::isBlank($class_name1) ? 'なし' : $class_name1; $class_name2 = $arrValues['classcategory_name2'][$i]; $class_name2 = SC_Utils_Ex::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'] = SC_Helper_DB_Ex::sfGetAddPoint($totalpoint, $arrValues['use_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); return $arrErr; }
/** * 入力内容のチェックを行う. * * @param SC_FormParam $objFormParam SC_FormParam インスタンス * @return array エラーメッセージの配列 */ public function lfCheckError(&$objFormParam) { $objProduct = new SC_Product_Ex(); $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]; $objError = new SC_CheckError_Ex(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']; $objError = new SC_CheckError_Ex(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 += SC_Helper_DB_Ex::sfCalcIncTax($arrValues['price'][$i], $arrValues['tax_rate'][$i], $arrValues['tax_rule'][$i]) * $arrValues['quantity'][$i]; // 小計の計算 $totaltax += SC_Utils_Ex::sfTax($arrValues['price'][$i], $arrValues['tax_rate'][$i], $arrValues['tax_rule'][$i]) * $arrValues['quantity'][$i]; // 加算ポイントの計算 $totalpoint += SC_Utils_Ex::sfPrePoint($arrValues['price'][$i], $arrValues['point_rate'][$i]) * $arrValues['quantity'][$i]; // 在庫数のチェック $arrProduct = $objProduct->getDetailAndProductsClass($arrValues['product_class_id'][$i]); // 編集前の値と比較するため受注詳細を取得 $objPurchase = new SC_Helper_Purchase_Ex(); $arrOrderDetail = SC_Utils_Ex::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 = SC_Utils_Ex::isBlank($class_name1) ? 'なし' : $class_name1; $class_name2 = $arrValues['classcategory_name2'][$i]; $class_name2 = SC_Utils_Ex::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'] = SC_Helper_DB_Ex::sfGetAddPoint($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; }
private function lfGetOrderData($order_id) { if (SC_Utils_Ex::sfIsInt($order_id)) { // DBから受注情報を読み込む $objPurchase = new SC_Helper_Purchase_Ex(); $this->arrDisp = $objPurchase->getOrder($order_id); list($point) = SC_Helper_Customer_Ex::sfGetCustomerPoint($order_id, $this->arrDisp['use_point'], $this->arrDisp['add_point']); $this->arrDisp['point'] = $point; // 受注詳細データの取得 $arrRet = $objPurchase->getOrderDetail($order_id); $arrRet = SC_Utils_Ex::sfSwapArray($arrRet); $this->arrDisp = array_merge($this->arrDisp, $arrRet); // その他支払い情報を表示 if ($this->arrDisp['memo02'] != '') { $this->arrDisp['payment_info'] = unserialize($this->arrDisp['memo02']); } $this->arrDisp['payment_type'] = 'お支払い'; } }
/** * 購入履歴情報の取得 * * @return array( integer 全体件数, mixed 会員データ一覧配列, mixed SC_PageNaviオブジェクト) */ public function lfPurchaseHistory($customer_id, $pageno = 0) { if (SC_Utils_Ex::isBlank($customer_id)) { return array('0', array(), NULL); } $objQuery =& SC_Query_Ex::getSingletonInstance(); $page_max = ADMIN_SEARCH_DEFAULT_NUM; $table = 'dtb_order'; /* * キャンセル、決済処理中を除く */ $where = 'customer_id = ? AND del_flg <> 1 AND status <> ? AND status <> ? '; $arrVal = array($customer_id, ORDER_CANCEL, ORDER_PENDING); // 購入履歴の件数取得 $linemax = $objQuery->count($table, $where, $arrVal); // ページ送りの取得 $objNavi = new SC_PageNavi_Ex($pageno, $linemax, $page_max, 'eccube.moveSecondSearchPage', NAVI_PMAX); // 取得範囲の指定(開始行番号、行数のセット) $objQuery->setLimitOffset($page_max, $objNavi->start_row); // 表示順序 $order = 'order_id DESC'; $objQuery->setOrder($order); // 購入履歴情報の取得 $col = "*"; $objDb = new SC_Helper_DB_Ex(); if ($objDb->sfColumnExists("cp_dtb_point_history", "order_id")) { $col .= ",(SELECT count(*) FROM cp_dtb_point_history WHERE order_id = dtb_order.order_id AND customer_id = dtb_order.customer_id ) AS download_count"; $col .= ",(SELECT min(create_date) FROM cp_dtb_point_history WHERE order_id = dtb_order.order_id AND customer_id = dtb_order.customer_id ) AS min_download_date"; $col .= ",(SELECT max(create_date) FROM cp_dtb_point_history WHERE order_id = dtb_order.order_id AND customer_id = dtb_order.customer_id ) AS max_download_date"; } $arrPurchaseHistory = $objQuery->select($col, $table, $where, $arrVal); $objPurchase = new SC_Helper_Purchase_Ex(); foreach ($arrPurchaseHistory as &$row) { $row["detail"] = $objPurchase->getOrderDetail($row["order_id"]); } return array($linemax, $arrPurchaseHistory, $objNavi); }
function init() { parent::init(); $objCustomer = new SC_Customer_Ex(); if (isset($_GET["sid"]) && isset($_GET["admin"])) { $sid = $_REQUEST["sid"]; $email = $objCustomer->getValue("email"); $osid = session_id(); if ($osid != $sid) { session_destroy(); session_id($sid); session_start(); } $objCustomer->setLogin($email); $get = $_GET; unset($get["sid"]); SC_Response_Ex::reload($get, true); } $objQuery = SC_Query_Ex::getSingletonInstance(); $objProduct = new SC_Product_Ex(); if (GC_Utils_Ex::isFrontFunction() && $this->skip_load_page_layout == false) { $objCustomer = new SC_Customer_Ex(); // 画面更新毎に情報を更新する if ($objCustomer->isLoginSuccess()) { // 初回アクセス時に更新 $objCustomer->updateSession(); $this->tpl_login = true; $this->tpl_point = $objCustomer->getValue("point"); $this->tpl_customer_id = $objCustomer->getValue("customer_id"); $this->tpl_first_buy_date = $objCustomer->getValue("first_buy_date"); $this->tpl_carrier = $objCustomer->getValue("carrier"); $downloadable_days = $this->arrSiteInfo["downloadable_days"]; $downloadable_days_unlimited = $this->arrSiteInfo["downloadable_days_unlimited"]; $date = null; if ($downloadable_days_unlimited) { $date = SC_Utils_Ex::sfGetTimestamp(RELEASE_YEAR, 1, 1, false); $date2 = SC_Utils_Ex::sfGetTimestamp(9999, 12, 31, false); } else { $xdate = strtotime("-{$downloadable_days} day"); $date = SC_Utils_Ex::sfGetTimestamp(date("Y", $xdate), date("m", $xdate), date("d", $xdate), false); $xdate = strtotime("+{$downloadable_days} day"); $date2 = SC_Utils_Ex::sfGetTimestamp(date("Y", $xdate), date("m", $xdate), date("d", $xdate), false); } $this->downloadable_days = $date; $this->downloadable_days2 = $date2; $objPurchase = new SC_Helper_Purchase_Ex(); $arrOrderId = $objQuery->getCol("order_id", "dtb_order", "payment_date > ? AND customer_id = ?", array($date, $this->tpl_customer_id)); $this->arrRedownloadProduct = array(); foreach ($arrOrderId as $order_id) { $arrOrderDetail = $objPurchase->getOrderDetail($order_id, true); $this->arrRedownloadProduct = array_merge($this->arrRedownloadProduct, $arrOrderDetail); } // 再ダウンロード可能な商品一覧 $this->arrRedownloadProduct = SC_Utils_Ex::makeArrayIDToKey("product_id", $this->arrRedownloadProduct); foreach ($this->arrRedownloadProduct as $product_id => $row) { $row["product"] = $objProduct->getDetail($product_id); $this->arrRedownloadProduct[$product_id] = $row; } } else { $this->tpl_login = false; $this->tpl_point = 0; $this->tpl_customer_id = 0; $this->tpl_first_buy_date = null; $this->tpl_carrier = 9; $this->arrRedownloadProduct = array(); } $objDb = new SC_Helper_DB_Ex(); if ($objDb->sfColumnExists("cp_dtb_customer_transaction", "id")) { $where = " customer_id = ? AND transaction_status = ? AND continue_account_id IS NOT NULL AND del_flg = 0"; $arrWhereVal = array($this->tpl_customer_id, 40); if ($objQuery->exists("cp_dtb_customer_transaction", $where, $arrWhereVal)) { // OK } else { switch (basename(dirname($_SERVER["SCRIPT_NAME"]))) { case "au": break; default: if ($objCustomer->isLoginSuccess()) { $objCustomer->EndSession(); SC_Response_Ex::reload(); } break; } } } $objCategory = new SC_Helper_Category_Ex(); $this->arrCommonCategory = $objCategory->getList(true); $this->arrCommonCategoryTree = $objCategory->getTree(); $detect = new Mobile_Detect(); $script_file = $_SERVER["SCRIPT_NAME"]; $script_file = ltrim($script_file, "/"); $script_file2 = str_replace("ios/", "", $script_file); if ($detect->is("iOS")) { if (file_exists(HTML_REALDIR . "ios/{$script_file}")) { SC_Response_Ex::sendRedirect(HTTP_URL . "ios/{$script_file}", $_GET); } } elseif (strcmp($script_file, $script_file2) !== 0) { SC_Response_Ex::sendRedirect(HTTP_URL . "{$script_file2}", $_GET); } $_SESSION["is_android"] = $detect->is("AndroidOS"); if ($detect->isMobile() == false) { // NG $this->device_support = false; } elseif ($detect->is("iOS")) { if ($detect->match("iPhone")) { // OK $this->device_support = true; } elseif ($detect->match("iPod")) { // NG $this->device_support = false; } elseif ($detect->match("iPad")) { // NG $this->device_support = false; } else { // NG $this->device_support = false; } $version = $detect->version("iOS", $detect::VERSION_TYPE_FLOAT); if ($version < 6) { // NG $this->device_support = false; } } elseif ($detect->match("Android") == false) { // NG $this->device_support = false; } elseif (class_exists("SC_DeviceAndroidSelect_Ex", true)) { $useragent = array(); if (preg_match("|.*; ([^;]+) Build/.*|", $_SERVER["HTTP_USER_AGENT"], $useragent)) { $device = new SC_DeviceAndroidSelect_Ex(array("search_device_user_agent_word" => $useragent[1], "search_status" => 1)); $this->device_support = $device->exists(); $this->tpl_device = $device->getOne(); } } elseif ($detect->match("Android")) { // OK $this->device_support = true; } else { // NG $this->device_support = false; } } if ($this->device_support) { GC_Utils_Ex::gfPrintLog("対応端末:" . $_SERVER['HTTP_USER_AGENT']); return; } else { GC_Utils_Ex::gfPrintLog("非対応端末:" . $_SERVER['HTTP_USER_AGENT']); if (is_a($this, "LC_Page_Index")) { SC_Response_Ex::sendRedirect(HTTP_URL . "unsupported/index.php"); } elseif (is_a($this, "LC_Page_Unsupported")) { // 非対応端末表示を行わない return; } elseif (is_a($this, "LC_Page_Entry_Kiyaku")) { // 非対応端末表示を行わない return; } elseif ($this->not_unsupported) { // 非対応端末表示を行わない return; } else { SC_Response_Ex::sendRedirect(HTTP_URL . "unsupported/index.php"); } } }
/** * 入力内容のチェックを行う. * * @param SC_FormParam $objFormParam SC_FormParam インスタンス * @return array エラーメッセージの配列 */ function lfCheckError(&$objFormParam) { $objProduct = new SC_Product_Ex(); $arrErr = $objFormParam->checkError(); if (!SC_Utils_Ex::isBlank($objErr->arrErr)) { return $arrErr; } $arrValues = $objFormParam->getHashArray(); // 商品の種類数 $max = count($arrValues['quantity']); $subtotal = 0; $totalpoint = 0; $totaltax = 0; for ($i = 0; $i < $max; $i++) { // 小計の計算 $subtotal += SC_Helper_DB_Ex::sfCalcIncTax($arrValues['price'][$i]) * $arrValues['quantity'][$i]; // 小計の計算 $totaltax += SC_Helper_DB_Ex::sfTax($arrValues['price'][$i]) * $arrValues['quantity'][$i]; // 加算ポイントの計算 $totalpoint += SC_Utils_Ex::sfPrePoint($arrValues['price'][$i], $arrValues['point_rate'][$i]) * $arrValues['quantity'][$i]; // 在庫数のチェック $arrProduct = $objProduct->getDetailAndProductsClass($arrValues['product_class_id'][$i]); // 編集前の値と比較するため受注詳細を取得 $objPurchase = new SC_Helper_Purchase_Ex(); $arrOrderDetail = SC_Utils_Ex::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 = SC_Utils_Ex::isBlank($class_name1) ? t('c_None_01') : $class_name1; $class_name2 = $arrValues['classcategory_name2'][$i]; $class_name2 = SC_Utils_Ex::isBlank($class_name2) ? t('c_None_01') : $class_name2; $arrErr['quantity'][$i] .= t('c_There is an inventory shortage for T_ARG1/(T_ARG2)/(T_ARG3). Up to T_ARG4 can be set for the quantity.<br />_1', array('T_ARG1' => $arrValues['product_name'][$i], 'T_ARG2' => $class_name1, 'T_ARG3' => $class_name2, 'T_ARG4' => $arrOrderDetail['quantity'][$i] + $arrProduct['stock'])); } } // 消費税 $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'] = SC_Helper_DB_Ex::sfGetAddPoint($totalpoint, $arrValues['use_point']); // 最終保持ポイント $arrValues['total_point'] = $objFormParam->getValue('point') - $arrValues['use_point']; if ($arrValues['total'] < 0) { $arrErr['total'] = t('c_Adjust so that the total amount is not a negative number.<br />_01'); } if ($arrValues['payment_total'] < 0) { $arrErr['payment_total'] = t('c_Adjust so that a negative number is not displayed for the payment total.<br />_01'); } if ($arrValues['total_point'] < 0) { $arrErr['use_point'] = t('c_Adjust the final number of points registered so that it does not become a negative number.<br />_01'); } $objFormParam->setParam($arrValues); return $arrErr; }