/** * Page のAction. * * @return void */ function action() { $objCustomer = new SC_Customer_Ex(); $objDb = new SC_Helper_DB_Ex(); $objPurchase = new SC_Helper_Purchase_Ex(); if (!SC_Utils_Ex::sfIsInt($_GET['order_id'])) { SC_Utils_Ex::sfDispSiteError(CUSTOMER_ERROR); } $order_id = $_GET['order_id']; //受注データの取得 $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 = $objDb->sfGetIDValueList('dtb_payment', 'payment_id', 'payment_method'); // 受注商品明細の取得 $this->tpl_arrOrderDetail = $objPurchase->getOrderDetail($order_id); $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); }
/** * Page のAction. * * @return void */ public function action() { //決済処理中ステータスのロールバック $objPurchase = new SC_Helper_Purchase_Ex(); $objPurchase->cancelPendingOrder(PENDING_ORDER_CANCEL_FLAG); SC_Response_Ex::sendRedirect(DIR_INDEX_PATH); }
/** * 受注IDをキーにして, 決済モジュールのパスを取得する. * * 決済モジュールが取得できた場合は, require 可能な決済モジュールのパスを返す. * 受注IDが無効な場合, 取得したパスにファイルが存在しない場合は false * * @param integer $order_id 受注ID * @return string|boolean 成功した場合は決済モジュールのパス; * 失敗した場合 false */ public function getModulePath($order_id) { $objPurchase = new SC_Helper_Purchase_Ex(); $objPayment = new SC_Helper_Payment_Ex(); $order = $objPurchase->getOrder($order_id); $payment = $objPayment->get($order['payment_id']); $module_path = $payment['module_path']; /* * 2.12.x までは dtb_payment.module_path がフルパスとなっていた. * 2.13.x より, MODULE_REALDIR からのパスでも対応できるよう修正 * http://svn.ec-cube.net/open_trac/ticket/2292 */ if (realpath($module_path) !== false) { $module_path = str_replace('\\', '/', realpath($module_path)); } else { $module_path = str_replace('\\', '/', $module_path); } $module_realdir = str_replace('\\', '/', realpath(MODULE_REALDIR) . '/'); if (strpos($module_path, $module_realdir) !== false) { $module_path = str_replace($module_realdir, '', $module_path); } $module_path = $module_realdir . $module_path; if (file_exists($module_path)) { return $module_path; } return false; }
/** * Page のAction. * * @return void */ public function action() { //決済処理中ステータスのロールバック $objPurchase = new SC_Helper_Purchase_Ex(); $objPurchase->cancelPendingOrder(PENDING_ORDER_CANCEL_FLAG); $objCustomer = new SC_Customer_Ex(); $customer_id = $objCustomer->getValue('customer_id'); //ページ送り用 $this->objNavi = new SC_PageNavi_Ex($_REQUEST['pageno'], $this->lfGetOrderHistory($customer_id), SEARCH_PMAX, 'eccube.movePage', NAVI_PMAX, 'pageno=#page#', SC_Display_Ex::detectDevice() !== DEVICE_TYPE_MOBILE); $this->arrOrder = $this->lfGetOrderHistory($customer_id, $this->objNavi->start_row); switch ($this->getMode()) { case 'getList': echo SC_Utils_Ex::jsonEncode($this->arrOrder); SC_Response_Ex::actionExit(); break; default: break; } // 支払い方法の取得 $this->arrPayment = SC_Helper_Payment_Ex::getIDValueList(); // 1ページあたりの件数 $this->dispNumber = SEARCH_PMAX; $this->json_payment = SC_Utils::jsonEncode($this->arrPayment); $this->json_customer_order_status = SC_Utils::jsonEncode($this->arrCustomerOrderStatus); }
/** * Page のアクション. * * @return void */ public function action() { //決済処理中ステータスのロールバック $objPurchase = new SC_Helper_Purchase_Ex(); $objPurchase->cancelPendingOrder(PENDING_ORDER_CANCEL_FLAG); $this->tpl_title = ''; $objCustomer = new SC_Customer_Ex(); $this->isLogin = $objCustomer->isLoginSuccess(true); }
/** * Page のアクション. * * @return void */ public function action() { //決済処理中ステータスのロールバック $objPurchase = new SC_Helper_Purchase_Ex(); $objPurchase->cancelPendingOrder(PENDING_ORDER_CANCEL_FLAG); $arrKiyaku = $this->lfGetKiyakuData(); $this->max = count($arrKiyaku); // mobile時はGETでページ指定 if (SC_Display_Ex::detectDevice() == DEVICE_TYPE_MOBILE) { $this->offset = $this->lfSetOffset($_GET['offset']); } $this->tpl_kiyaku_text = $this->lfMakeKiyakuText($arrKiyaku, $this->max, $this->offset); }
/** * Page のAction. * * @return void */ public function action() { //決済処理中ステータスのロールバック $objPurchase = new SC_Helper_Purchase_Ex(); $objPurchase->cancelPendingOrder(PENDING_ORDER_CANCEL_FLAG); //受注詳細データの取得 $arrOrderDetail = $this->lfGetOrderDetail($_POST['order_id']); //ログインしていない、またはDBに情報が無い場合 if (empty($arrOrderDetail)) { SC_Utils_Ex::sfDispSiteError(CUSTOMER_ERROR); } $this->lfAddCartProducts($arrOrderDetail); SC_Response_Ex::sendRedirect(CART_URL); }
/** * Page のAction. * * @return void */ public function action() { //決済処理中ステータスのロールバック $objPurchase = new SC_Helper_Purchase_Ex(); $objPurchase->cancelPendingOrder(PENDING_ORDER_CANCEL_FLAG); $objProduct = new SC_Product_Ex(); // パラメーター管理クラス $objFormParam = new SC_FormParam_Ex(); // パラメーター情報の初期化 $this->lfInitParam($objFormParam); // 値の設定 $objFormParam->setParam($_REQUEST); // 入力値の変換 $objFormParam->convParam(); // 値の取得 $this->arrForm = $objFormParam->getHashArray(); //modeの取得 $this->mode = $this->getMode(); //表示条件の取得 $this->arrSearchData = array('category_id' => $this->lfGetCategoryId(intval($this->arrForm['category_id'])), 'maker_id' => intval($this->arrForm['maker_id']), 'name' => $this->arrForm['name']); $this->orderby = $this->arrForm['orderby']; //ページング設定 $this->tpl_pageno = $this->arrForm['pageno']; $this->disp_number = $this->lfGetDisplayNum($this->arrForm['disp_number']); // 画面に表示するサブタイトルの設定 $this->tpl_subtitle = $this->lfGetPageTitle($this->mode, $this->arrSearchData['category_id']); // 画面に表示する検索条件を設定 $this->arrSearch = $this->lfGetSearchConditionDisp($this->arrSearchData); // 商品一覧データの取得 $arrSearchCondition = $this->lfGetSearchCondition($this->arrSearchData); $this->tpl_linemax = $this->lfGetProductAllNum($arrSearchCondition); $urlParam = "category_id={$this->arrSearchData['category_id']}&pageno=#page#"; // モバイルの場合に検索条件をURLの引数に追加 if (SC_Display_Ex::detectDevice() === DEVICE_TYPE_MOBILE) { $searchNameUrl = urlencode(mb_convert_encoding($this->arrSearchData['name'], 'SJIS-win', 'UTF-8')); $urlParam .= "&mode={$this->mode}&name={$searchNameUrl}&orderby={$this->orderby}"; } $this->objNavi = new SC_PageNavi_Ex($this->tpl_pageno, $this->tpl_linemax, $this->disp_number, 'eccube.movePage', NAVI_PMAX, $urlParam, SC_Display_Ex::detectDevice() !== DEVICE_TYPE_MOBILE); $this->arrProducts = $this->lfGetProductsList($arrSearchCondition, $this->disp_number, $this->objNavi->start_row, $objProduct); switch ($this->getMode()) { case 'json': $this->doJson($objProduct); break; default: $this->doDefault($objProduct, $objFormParam); break; } $this->tpl_rnd = SC_Utils_Ex::sfGetRandomString(3); }
/** * Page のプロセス. * * @return void */ public function action() { //決済処理中ステータスのロールバック $objPurchase = new SC_Helper_Purchase_Ex(); $objPurchase->cancelPendingOrder(PENDING_ORDER_CANCEL_FLAG); $objSiteSess = new SC_SiteSession_Ex(); $objCartSess = new SC_CartSession_Ex(); $objCustomer = new SC_Customer_Ex(); $objFormParam = new SC_FormParam_Ex(); $objAddress = new SC_Helper_Address_Ex(); // 複数配送先指定が無効な場合はエラー if (USE_MULTIPLE_SHIPPING === false) { SC_Utils_Ex::sfDispSiteError(PAGE_ERROR, '', true); SC_Response_Ex::actionExit(); } $this->tpl_uniqid = $objSiteSess->getUniqId(); $this->addrs = $this->getDelivAddrs($objCustomer, $objPurchase, $objAddress); $this->tpl_addrmax = count($this->addrs) - 2; // 「選択してください」と会員の住所をカウントしない $this->lfInitParam($objFormParam); $objPurchase->verifyChangeCart($this->tpl_uniqid, $objCartSess); switch ($this->getMode()) { case 'confirm': $objFormParam->setParam($_POST); $this->arrErr = $this->lfCheckError($objFormParam); if (SC_Utils_Ex::isBlank($this->arrErr)) { // フォームの情報を一時保存しておく $_SESSION['multiple_temp'] = $objFormParam->getHashArray(); $this->saveMultipleShippings($this->tpl_uniqid, $objFormParam, $objCustomer, $objPurchase, $objAddress); $objSiteSess->setRegistFlag(); SC_Response_Ex::sendRedirect('payment.php'); SC_Response_Ex::actionExit(); } break; default: $this->setParamToSplitItems($objFormParam, $objCartSess); } // 前のページから戻ってきた場合 if ($_GET['from'] == 'multiple') { $objFormParam->setParam($_SESSION['multiple_temp']); } $this->arrForm = $objFormParam->getFormParamList(); }
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]; } } } } }
/** * 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); }
/** * Page のアクション. * * @return void */ function action() { $objCartSess = new SC_CartSession_Ex(); $objSiteSess = new SC_SiteSession_Ex(); $objCustomer = new SC_Customer_Ex(); $objPurchase = new SC_Helper_Purchase_Ex(); $objHelperMail = new SC_Helper_Mail_Ex(); $this->is_multiple = $objPurchase->isMultiple(); // 前のページで正しく登録手続きが行われた記録があるか判定 if (!$objSiteSess->isPrePage()) { SC_Utils_Ex::sfDispSiteError(PAGE_ERROR, $objSiteSess); } // ユーザユニークIDの取得と購入状態の正当性をチェック $this->tpl_uniqid = $objSiteSess->getUniqId(); $objPurchase->verifyChangeCart($this->tpl_uniqid, $objCartSess); $this->cartKey = $objCartSess->getKey(); // カート内商品のチェック $this->tpl_message = $objCartSess->checkProducts($this->cartKey); if (!SC_Utils_Ex::isBlank($this->tpl_message)) { SC_Response_Ex::sendRedirect(CART_URLPATH); SC_Response_Ex::actionExit(); } // カートの商品を取得 $this->arrShipping = $objPurchase->getShippingTemp($this->is_multiple); $this->arrCartItems = $objCartSess->getCartList($this->cartKey); // 合計金額 $this->tpl_total_inctax[$this->cartKey] = $objCartSess->getAllProductsTotal($this->cartKey); // 税額 $this->tpl_total_tax[$this->cartKey] = $objCartSess->getAllProductsTax($this->cartKey); // ポイント合計 $this->tpl_total_point[$this->cartKey] = $objCartSess->getAllProductsPoint($this->cartKey); // 一時受注テーブルの読込 $arrOrderTemp = $objPurchase->getOrderTemp($this->tpl_uniqid); // カート集計を元に最終計算 $arrCalcResults = $objCartSess->calculate($this->cartKey, $objCustomer, $arrOrderTemp['use_point'], $objPurchase->getShippingPref($this->is_multiple), $arrOrderTemp['charge'], $arrOrderTemp['discount'], $arrOrderTemp['deliv_id']); $this->arrForm = array_merge($arrOrderTemp, $arrCalcResults); // 会員ログインチェック if ($objCustomer->isLoginSuccess(true)) { $this->tpl_login = '******'; $this->tpl_user_point = $objCustomer->getValue('point'); } // 決済モジュールを使用するかどうか $this->use_module = SC_Helper_Payment_Ex::useModule($this->arrForm['payment_id']); switch ($this->getMode()) { // 前のページに戻る case 'return': // 正常な推移であることを記録しておく $objSiteSess->setRegistFlag(); SC_Response_Ex::sendRedirect(SHOPPING_PAYMENT_URLPATH); SC_Response_Ex::actionExit(); break; case 'confirm': /* * 決済モジュールで必要なため, 受注番号を取得 */ $this->arrForm['order_id'] = $objPurchase->getNextOrderID(); $_SESSION['order_id'] = $this->arrForm['order_id']; // 集計結果を受注一時テーブルに反映 $objPurchase->saveOrderTemp($this->tpl_uniqid, $this->arrForm, $objCustomer); // 正常に登録されたことを記録しておく $objSiteSess->setRegistFlag(); // 決済モジュールを使用する場合 if ($this->use_module) { $objPurchase->completeOrder(ORDER_PENDING); SC_Response_Ex::sendRedirect(SHOPPING_MODULE_URLPATH); } else { $objPurchase->completeOrder(ORDER_NEW); $template_id = SC_Display_Ex::detectDevice() == DEVICE_TYPE_MOBILE ? 2 : 1; $objHelperMail->sfSendOrderMail($this->arrForm['order_id'], $template_id); SC_Response_Ex::sendRedirect(SHOPPING_COMPLETE_URLPATH); } SC_Response_Ex::actionExit(); break; default: break; } }
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'] = 'お支払い'; } }
/** * 対応状況の更新 */ function lfStatusMove($statusId, $arrOrderId) { $objPurchase = new SC_Helper_Purchase_Ex(); $objQuery =& SC_Query_Ex::getSingletonInstance(); if (!isset($arrOrderId) || !is_array($arrOrderId)) { return false; } $masterData = new SC_DB_MasterData_Ex(); $arrORDERSTATUS = $masterData->getMasterData('mtb_order_status'); $objQuery->begin(); foreach ($arrOrderId as $orderId) { $objPurchase->sfUpdateOrderStatus($orderId, $statusId); } $objQuery->commit(); $this->tpl_onload = "window.alert('" . t('c_The selected item was moved to T_ARG1._01', array('T_ARG1' => $arrORDERSTATUS[$statusId])) . "');"; return true; }
/** * 対応状況の更新 */ function lfStatusMove($statusId, $arrOrderId) { $objPurchase = new SC_Helper_Purchase_Ex(); $objQuery =& SC_Query_Ex::getSingletonInstance(); if (!isset($arrOrderId) || !is_array($arrOrderId)) { return false; } $masterData = new SC_DB_MasterData_Ex(); $arrORDERSTATUS = $masterData->getMasterData('mtb_order_status'); $objQuery->begin(); foreach ($arrOrderId as $orderId) { $objPurchase->sfUpdateOrderStatus($orderId, $statusId); } $objQuery->commit(); $this->tpl_onload = "window.alert('選択項目を" . $arrORDERSTATUS[$statusId] . "へ移動しました。');"; return true; }
/** * Page のAction. * * @return void */ public function action() { //決済処理中ステータスのロールバック $objPurchase = new SC_Helper_Purchase_Ex(); $objPurchase->cancelPendingOrder(PENDING_ORDER_CANCEL_FLAG); // 会員クラス $objCustomer = new SC_Customer_Ex(); // パラメーター管理クラス $this->objFormParam = new SC_FormParam_Ex(); // パラメーター情報の初期化 $this->arrForm = $this->lfInitParam($this->objFormParam); // ファイル管理クラス $this->objUpFile = new SC_UploadFile_Ex(IMAGE_TEMP_REALDIR, IMAGE_SAVE_REALDIR); // ファイル情報の初期化 $this->objUpFile = $this->lfInitFile($this->objUpFile); // プロダクトIDの正当性チェック $product_id = $this->lfCheckProductId($this->objFormParam->getValue('admin'), $this->objFormParam->getValue('product_id')); $this->mode = $this->getMode(); $objProduct = new SC_Product_Ex(); $objProduct->setProductsClassByProductIds(array($product_id)); // 規格1クラス名 $this->tpl_class_name1 = $objProduct->className1[$product_id]; // 規格2クラス名 $this->tpl_class_name2 = $objProduct->className2[$product_id]; // 規格1 $this->arrClassCat1 = $objProduct->classCats1[$product_id]; // 規格1が設定されている $this->tpl_classcat_find1 = $objProduct->classCat1_find[$product_id]; // 規格2が設定されている $this->tpl_classcat_find2 = $objProduct->classCat2_find[$product_id]; $this->tpl_stock_find = $objProduct->stock_find[$product_id]; $this->tpl_product_class_id = $objProduct->classCategories[$product_id]['__unselected']['__unselected']['product_class_id']; $this->tpl_product_type = $objProduct->classCategories[$product_id]['__unselected']['__unselected']['product_type']; // 在庫が無い場合は、OnLoadしない。(javascriptエラー防止) if ($this->tpl_stock_find) { // 規格選択セレクトボックスの作成 $this->js_lnOnload .= $this->lfMakeSelect(); } $this->tpl_javascript .= 'eccube.classCategories = ' . SC_Utils_Ex::jsonEncode($objProduct->classCategories[$product_id]) . ';'; $this->tpl_javascript .= 'function lnOnLoad() {' . $this->js_lnOnload . '}'; $this->tpl_onload .= 'lnOnLoad();'; // モバイル用 規格選択セレクトボックスの作成 if (SC_Display_Ex::detectDevice() == DEVICE_TYPE_MOBILE) { $this->lfMakeSelectMobile($this, $product_id, $this->objFormParam->getValue('classcategory_id1')); } // 商品IDをFORM内に保持する $this->tpl_product_id = $product_id; switch ($this->mode) { case 'cart': $this->doCart(); break; case 'add_favorite': $this->doAddFavorite($objCustomer); break; case 'add_favorite_sphone': $this->doAddFavoriteSphone($objCustomer); break; case 'select': case 'select2': case 'selectItem': /** * モバイルの数量指定・規格選択の際に、 * $_SESSION['cart_referer_url'] を上書きさせないために、 * 何もせずbreakする。 */ break; default: $this->doDefault(); break; } // モバイル用 ポストバック処理 if (SC_Display_Ex::detectDevice() == DEVICE_TYPE_MOBILE) { switch ($this->mode) { case 'select': $this->doMobileSelect(); break; case 'select2': $this->doMobileSelect2(); break; case 'selectItem': $this->doMobileSelectItem(); break; case 'cart': $this->doMobileCart(); break; default: $this->doMobileDefault(); break; } } // 商品詳細を取得 $this->arrProduct = $objProduct->getDetail($product_id); // サブタイトルを取得 $this->tpl_subtitle = $this->arrProduct['name']; // 関連カテゴリを取得 $this->arrRelativeCat = SC_Helper_DB_Ex::sfGetMultiCatTree($product_id); // 商品ステータスを取得 $this->productStatus = $objProduct->getProductStatus($product_id); // 画像ファイル指定がない場合の置換処理 $this->arrProduct['main_image'] = SC_Utils_Ex::sfNoImageMain($this->arrProduct['main_image']); $this->subImageFlag = $this->lfSetFile($this->objUpFile, $this->arrProduct, $this->arrFile); //レビュー情報の取得 $this->arrReview = $this->lfGetReviewData($product_id); //関連商品情報表示 $this->arrRecommend = $this->lfPreGetRecommendProducts($product_id); // ログイン判定 if ($objCustomer->isLoginSuccess() === true) { //お気に入りボタン表示 $this->tpl_login = true; $this->is_favorite = SC_Helper_DB_Ex::sfDataExists('dtb_customer_favorite_products', 'customer_id = ? AND product_id = ?', array($objCustomer->getValue('customer_id'), $product_id)); } }
/** * 購入履歴情報の取得 * * @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); }
/** * 指定の注文について WebPay API で実売上化する * エラーメッセージを返す。 * * @param \WebPay\WebPay $objWebPay WebPay client * @return string|null 決済時に発生したエラーを管理者に説明するメッセージ * @throws \WebPay\ApiException 管理者に原因がないエラー(設定ミスによるもの、通信障害によるもの) */ public function capture($objWebPay) { $current_total = intval($this->arrOrder['payment_total'], 10); if ($this->getAmount() < $current_total) { return sprintf('仮売上金額(%s円)以上で実売上化することはできません。合計金額を仮売上金額以下にするか、金額を増額する場合は購入者に連絡し、再度購入処理を行ってください。', number_format($this->getAmount())); } try { $objCharge = $objWebPay->chargeCapture(array('id' => $this->getChargeId(), 'amount' => $current_total)); } catch (\WebPay\ApiException $e) { $objData = $e->getData(); if ($objData && $objData->error) { $message = $objData->error->message; switch ($objData->error->causedBy) { case 'buyer': return '購入者に起因する問題で決済できませんでした。購入者に連絡して状況をお訪ねください。' . $message; case 'insufficient': return '不正なリクエストがおこなわれました。WebPayのダッシュボードを確認してください。' . $message; case 'missing': return '操作対象の課金が見つかりませんでした。WebPayのダッシュボードを確認してください。'; case 'service': default: return '未知のエラーが発生しました。時間をおいてやりなおしてください。' . $message; } } throw $e; } $objPurchase = new SC_Helper_Purchase_Ex(); $updateData = array(MDL_WEBPAY_CHARGE_DATA_COL => $this->lfConvertToDbChargeData($objCharge)); $objQuery = SC_Query_Ex::getSingletonInstance(); $objQuery->begin(); $objPurchase->sfUpdateOrderStatus($this->arrOrder['order_id'], ORDER_PRE_END, null, null, $updateData); $objQuery->commit(); $objPurchase->sendOrderMail($this->arrOrder['order_id']); return null; }
function doCheckBuyAndDownload($config) { $objFormParam = new SC_FormParam(); $this->lfInitParam($objFormParam); $objFormParam->setParam($_REQUEST); $objCustomer = new SC_Customer_Ex(); $objQuery = SC_Query::getSingletonInstance(); $detect = new Mobile_Detect(); $version = $detect->version("iOS", Mobile_Detect::VERSION_TYPE_FLOAT); $contentid = $this->arrProduct["product_code_min"]; $curl = $this->curl_init(KISEKAE_TOUCH_IPHONE_API01); $post = $this->getPost($config, array("contentid" => $contentid, "device" => $objFormParam->getValue("device_name", "iPhone6"), "version" => floor($version), "apiversion" => null, "operator" => "au", "lang" => "ja")); $this->getDs($post, $config); curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($post)); GC_Utils_Ex::gfPrintLog(print_r($post, TRUE), DEBUG_LOG_REALFILE); $result = curl_exec($curl); $status = SC_XML::xpath($result, "//status/@value"); $vid = SC_XML::xpath($result, "//validation/@id"); switch ($status) { default: SC_Utils_Ex::sfDispSiteError(PAGE_ERROR); case "000": GC_Utils_Ex::gfDebugLog($result); $_COOKIE["product_ktc_vid"] = $vid; break; } // API2 $openid = $objCustomer->getValue("au_open_id"); $curl = $this->curl_init(KISEKAE_TOUCH_IPHONE_API02); $post = $this->getPost($config, array("contentid" => $contentid, "userid" => $openid, "vid" => $vid)); $this->getDs($post, $config); curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($post)); GC_Utils_Ex::gfPrintLog(print_r($post, TRUE), DEBUG_LOG_REALFILE); $result = curl_exec($curl); $status = SC_XML::xpath($result, "//status/@value"); switch ($status) { default: SC_Utils_Ex::sfDispSiteError(PAGE_ERROR); break; case "000": case "010": // TEST // /ios/products/detail.php?mode=check_buy_and_download&product_id=13&classcategory_id1=0&classcategory_id2=0&quantity=1&admin=&favorite_product_id=&product_class_id=&device_name=iPhone6Plus&device_height=736&device_width=414&device_rate=3&device_lang=ja&ignore_redownload=1 if ($_GET["ignore_redownload"] == "1") { $status = "000"; } break; } if ($status == "000") { // FIXME 課金処理 // API03 $curl = $this->curl_init(KISEKAE_TOUCH_IPHONE_API03); if ($objCustomer->getValue("buy_to_nopoint") == "1") { $price = $this->arrProduct["price02_min"]; $settlementtype = "998"; $redownloaddate = date("Ymd"); } else { $price = $this->arrProduct["price02_min"]; $settlementtype = "001"; $redownloaddate = date("Ymd", strtotime($this->downloadable_days2)); } $post = $this->getPost($config, array("contentid" => $contentid, "price" => $price, "redownloaddate" => $redownloaddate, "userid" => $openid, "vid" => $vid, "settlementtype" => $settlementtype)); $this->getDs($post, $config); curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($post)); GC_Utils_Ex::gfPrintLog(print_r($post, TRUE), DEBUG_LOG_REALFILE); $result = curl_exec($curl); $authentication_id = SC_XML::xpath($result, "//authentication/@id"); $objFormParam = new SC_FormParam(); $this->setOrderParam($objFormParam, $vid, $authentication_id); $objFormParam->convParam(); $message = ''; $arrValBef = array(); $objPurchase = new SC_Helper_Purchase_Ex(); $objPurchase->saveShippingTemp(array()); $order_id = $this->doRegister("", $objPurchase, $objFormParam, $message, $arrValBef); $customer_id = $objCustomer->getValue("customer_id"); $this->addPointHistory($order_id, $customer_id, $objFormParam, $objQuery); } else { $authentication_id = SC_XML::xpath($result, "//authentication/@id"); } $netUrl = new Net_URL(KISEKAE_TOUCH_IPHONE_CST02); $netUrl->addQueryString("aid", $authentication_id); $netUrl->addQueryString("cpid", $config["cpid"]); $netUrl->addQueryString("siteid", $config["siteid"]); $netUrl->addQueryString("contentid", $contentid); $netUrl->addQueryString("ts", date("YmdHis")); $post2 = $netUrl->querystring; $this->getDs($post2, $config); $netUrl->addRawQueryString(http_build_query($post2)); GC_Utils_Ex::gfPrintLog(print_r($post2, TRUE), DEBUG_LOG_REALFILE); header("Location: " . $netUrl->getURL()); }
/** * 受注番号、最終ポイント、加算ポイント、利用ポイントから「オーダー前ポイント」を取得する * * @param integer $order_id 受注番号 * @param integer $use_point 利用ポイント * @param integer $add_point 加算ポイント * @param integer $order_status 対応状況 * @return array オーダー前ポイントの配列 */ function sfGetRollbackPoint($order_id, $use_point, $add_point, $order_status) { $objQuery = new SC_Query_Ex(); $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']; // 対応状況がポイント利用対象の場合、使用ポイント分を戻す if (SC_Helper_Purchase_Ex::isUsePoint($order_status)) { $rollback_point += $use_point; } // 対応状況がポイント加算対象の場合、加算ポイント分を戻す if (SC_Helper_Purchase_Ex::isAddPoint($order_status)) { $rollback_point -= $add_point; } } else { $rollback_point = ""; $point = ""; } return array($point, $rollback_point); }
/** * Page のアクション. * * @return void */ public function action() { //決済処理中ステータスのロールバック $objPurchase = new SC_Helper_Purchase_Ex(); $objPurchase->cancelPendingOrder(PENDING_ORDER_CANCEL_FLAG); $objCartSess = new SC_CartSession_Ex(); $objSiteSess = new SC_SiteSession_Ex(); $objCustomer = new SC_Customer_Ex(); $objFormParam = $this->lfInitParam($_POST); $this->mode = $this->getMode(); // モバイル対応 if (SC_Display_Ex::detectDevice() == DEVICE_TYPE_MOBILE) { if (isset($_GET['cart_no'])) { $objFormParam->setValue('cart_no', $_GET['cart_no']); } if (isset($_GET['cartKey'])) { $objFormParam->setValue('cartKey', $_GET['cartKey']); } } $this->cartKeys = $objCartSess->getKeys(); foreach ($this->cartKeys as $key) { // 商品購入中にカート内容が変更された。 if ($objCartSess->getCancelPurchase($key)) { $this->tpl_message .= "商品購入中にカート内容が変更されましたので、お手数ですが購入手続きをやり直して下さい。\n"; } } $cart_no = $objFormParam->getValue('cart_no'); $cartKey = $objFormParam->getValue('cartKey'); // エラーチェック $arrError = $objFormParam->checkError(); if (isset($arrError) && !empty($arrError)) { SC_Utils_Ex::sfDispSiteError(CART_NOT_FOUND); SC_Response_Ex::actionExit(); } $objFormParam4OpenCategoryTree = $this->lfInitParam4OpenCategoryTree($_REQUEST); if ($objFormParam4OpenCategoryTree->getValue('product_id')) { $arrQueryString = array('product_id' => $objFormParam4OpenCategoryTree->getValue('product_id')); } else { $arrQueryString = array('category_id' => $objFormParam4OpenCategoryTree->getValue('category_id')); } switch ($this->mode) { case 'confirm': // カート内情報の取得 $cartList = $objCartSess->getCartList($cartKey); // カート商品が1件以上存在する場合 if (count($cartList) > 0) { // カートを購入モードに設定 $this->lfSetCurrentCart($objSiteSess, $objCartSess, $cartKey); // 購入ページへ SC_Response_Ex::sendRedirect(SHOPPING_URL); SC_Response_Ex::actionExit(); } break; case 'up': //1個追加 $objCartSess->upQuantity($cart_no, $cartKey); SC_Response_Ex::reload($arrQueryString, true); SC_Response_Ex::actionExit(); break; case 'down': //1個減らす $objCartSess->downQuantity($cart_no, $cartKey); SC_Response_Ex::reload($arrQueryString, true); SC_Response_Ex::actionExit(); break; case 'setQuantity': //数量変更 $objCartSess->setQuantity($objFormParam->getValue('quantity'), $cart_no, $cartKey); SC_Response_Ex::reload($arrQueryString, true); SC_Response_Ex::actionExit(); break; case 'delete': //カートから削除 $objCartSess->delProduct($cart_no, $cartKey); SC_Response_Ex::reload($arrQueryString, true); SC_Response_Ex::actionExit(); break; default: break; } $this->arrInfo = SC_Helper_DB_Ex::sfGetBasisData(); $totalIncTax = 0; foreach ($this->cartKeys as $key) { // カート集計処理 $this->tpl_message .= $objCartSess->checkProducts($key); $this->tpl_total_inctax[$key] = $objCartSess->getAllProductsTotal($key); $totalIncTax += $this->tpl_total_inctax[$key]; $this->tpl_total_tax[$key] = $objCartSess->getAllProductsTax($key); // ポイント合計 $this->tpl_total_point[$key] = $objCartSess->getAllProductsPoint($key); $this->arrData[$key] = $objCartSess->calculate($key, $objCustomer); // 送料無料チェック $this->arrData[$key]['is_deliv_free'] = $objCartSess->isDelivFree($key); // 送料無料までの金額を計算 $this->tpl_deliv_free[$key] = $this->arrInfo['free_rule'] - $this->tpl_total_inctax[$key]; } //商品の合計金額をセット $this->tpl_all_total_inctax = $totalIncTax; $this->tpl_category_id = $objFormParam4OpenCategoryTree->getValue('category_id'); $this->tpl_product_id = $objFormParam4OpenCategoryTree->getValue('product_id'); // ログイン判定 if ($objCustomer->isLoginSuccess(true)) { $this->tpl_login = true; $this->tpl_user_point = $objCustomer->getValue('point'); $this->tpl_name = $objCustomer->getValue('name01'); } // 前頁のURLを取得 // TODO: SC_CartSession::setPrevURL()利用不可。 $this->lfGetCartPrevUrl($_SESSION, $_SERVER['HTTP_REFERER']); $this->tpl_prev_url = isset($_SESSION['cart_prev_url']) ? $_SESSION['cart_prev_url'] : ''; // 全てのカートの内容を取得する $this->cartItems = $objCartSess->getAllCartList(); }
/** * getShippingTemp() のテストケース. */ public function testGetShippingTemp() { $_SESSION['shipping'] = array('0' => array('shipping_name01' => 'test01', 'shipment_item' => array('10' => array('shipment_item' => 0))), '1' => array('shipping_name01' => 'test02'), '2' => array('shipping_name01' => 'test03', 'shipment_item' => array('11' => array('shipment_item' => 1))), '3' => array('shipping_name01' => 'test04', 'shipment_item' => array('12' => array('shipment_item' => 2)))); // 第一引数(複数お届け先フラグ)がfalseの場合、$_SESSION['shipping']をそのまま返す $result = SC_Helper_Purchase_Ex::getShippingTemp(false); $this->assertEquals($result, $_SESSION['shipping']); // 第一引数(複数お届け先フラグ)がtrueの場合、実際に配送で利用されるお届け先の情報のみを入れたデータを返す $result = SC_Helper_Purchase_Ex::getShippingTemp(true); $this->assertEquals(false, $result === $_SESSION['shipping']); $this->assertEquals(false, $result == $_SESSION['shipping']); $this->assertEquals(3, count($result)); unset($_SESSION['shipping']); }
public function checkSessionPendingOrder() { if (!SC_Utils_Ex::isBlank($_SESSION['order_id'])) { $order_id = $_SESSION['order_id']; unset($_SESSION['order_id']); $objQuery =& SC_Query_Ex::getSingletonInstance(); $objQuery->begin(); $arrOrder = SC_Helper_Purchase_Ex::getOrder($order_id); if ($arrOrder['status'] == ORDER_PENDING) { $objCartSess = new SC_CartSession_Ex(); $cartKeys = $objCartSess->getKeys(); if (SC_Utils_Ex::isBlank($cartKeys)) { SC_Helper_Purchase_Ex::rollbackOrder($order_id, ORDER_CANCEL, true); GC_Utils_Ex::gfPrintLog('order rollback.(session pending) order_id=' . $order_id); } else { SC_Helper_Purchase_Ex::cancelOrder($order_id, ORDER_CANCEL, true); GC_Utils_Ex::gfPrintLog('order rollback.(session pending and set card) order_id=' . $order_id); } } $objQuery->commit(); } }
/** * 受注番号、最終ポイント、加算ポイント、利用ポイントから「オーダー前ポイント」を取得する * * @param integer $order_id 受注番号 * @param integer $use_point 利用ポイント * @param integer $add_point 加算ポイント * @param integer $order_status 対応状況 * @return array オーダー前ポイントの配列 */ public 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']; // 対応状況がポイント利用対象の場合、使用ポイント分を戻す if (SC_Helper_Purchase_Ex::isUsePoint($order_status)) { $rollback_point += $use_point; } // 対応状況がポイント加算対象の場合、加算ポイント分を戻す if (SC_Helper_Purchase_Ex::isAddPoint($order_status)) { $rollback_point -= $add_point; } } else { $rollback_point = ''; $point = ''; } return array($point, $rollback_point); }
/** * 入力内容のチェックを行なう. * * @param SC_FormParam $objFormParam SC_FormParam インスタンス * @param integer $subtotal 購入金額の小計 * @param integer $max_point 会員の保持ポイント * @return array 入力チェック結果の配列 */ function lfCheckError(&$objFormParam, $subtotal, $max_point) { $objPurchase = new SC_Helper_Purchase_Ex(); // 入力データを渡す。 $arrForm = $objFormParam->getHashArray(); $objErr = new SC_CheckError_Ex($arrForm); $objErr->arrErr = $objFormParam->checkError(); if (USE_POINT === false) { return $objErr->arrErr; } if ($arrForm['point_check'] == '1') { $objErr->doFunc(array('ポイントを使用する', 'point_check'), array('EXIST_CHECK')); $objErr->doFunc(array('ポイント', 'use_point'), array('EXIST_CHECK')); if ($max_point == '') { $max_point = 0; } // FIXME mobile 互換のため br は閉じない... if ($arrForm['use_point'] > $max_point) { $objErr->arrErr['use_point'] = '※ ご利用ポイントが所持ポイントを超えています。<br>'; } if ($arrForm['use_point'] * POINT_VALUE > $subtotal) { $objErr->arrErr['use_point'] = '※ ご利用ポイントがご購入金額を超えています。<br>'; } // ポイント差し引き後の決済方法チェック $arrPayments = $objPurchase->getPaymentsByPaymentsId($arrForm['payment_id']); if ($arrPayments['rule_max'] > $subtotal - $arrForm['use_point'] * POINT_VALUE) { $objErr->arrErr['use_point'] = '※ 選択した支払方法では、ポイントは' . ($subtotal - $arrPayments['rule_max']) . 'ポイントまでご利用いただけます。<br>'; } } return $objErr->arrErr; }
/** * 受注テーブルの論理削除 */ public function lfDelete($arrOrderId) { $objQuery =& SC_Query_Ex::getSingletonInstance(); if (!isset($arrOrderId) || !is_array($arrOrderId)) { return false; } $objPurchase = new SC_Helper_Purchase_Ex(); foreach ($arrOrderId as $orderId) { $objPurchase->cancelOrder($orderId, ORDER_CANCEL, true); } $this->tpl_onload = "window.alert('選択項目を削除しました。');"; return true; }
function EndSession() { // セッション情報破棄の前にcustomer_idを保存 $customer_id = $_SESSION['customer']['customer_id']; // $_SESSION['customer']の解放 unset($_SESSION['customer']); // セッションの配送情報を全て破棄する SC_Helper_Purchase_Ex::unsetAllShippingTemp(true); // トランザクショントークンの破棄 SC_Helper_Session_Ex::destroyToken(); $objSiteSess = new SC_SiteSession_Ex(); $objSiteSess->unsetUniqId(); // ログに記録する $log = sprintf("logout : user=%d\tip=%s", $customer_id, $this->getRemoteHost()); GC_Utils_Ex::gfPrintLog($log, CUSTOMER_LOG_REALFILE, false); }
/** * 入力内容のチェックを行う. * * @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; }
/** * 受注データを取得して, 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 エラーメッセージの配列 */ 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; }