/**
  * Page のプロセス(モバイル).
  *
  * @return void
  */
 function mobileProcess()
 {
     $conn = new SC_DBConn();
     $objView = new SC_MobileView();
     $this->objSiteSess = new SC_SiteSession();
     $this->objCartSess = new SC_CartSession();
     $objSiteInfo = $objView->objSiteInfo;
     $this->arrInfo = $objSiteInfo->data;
     $this->objCustomer = new SC_Customer();
     $mailHelper = new SC_Helper_Mail_Ex();
     // 前のページで正しく登録手続きが行われたか判定
     SC_Utils_Ex::sfIsPrePage($this->objSiteSess, true);
     // ユーザユニークIDの取得と購入状態の正当性をチェック
     $uniqid = SC_Utils_Ex::sfCheckNormalAccess($this->objSiteSess, $this->objCartSess);
     if ($uniqid != "") {
         // 完了処理
         $objQuery = new SC_Query();
         $objQuery->begin();
         $order_id = $this->lfDoComplete($objQuery, $uniqid);
         $objQuery->commit();
         // セッションに保管されている情報を更新する
         $this->objCustomer->updateSession();
         // 完了メール送信
         if ($order_id != "") {
             $mailHelper->sfSendOrderMail($order_id, '2');
         }
         //その他情報の取得
         $other_data = $objQuery->get("dtb_order", "memo02", "order_id = ? ", array($order_id));
         if ($other_data != "") {
             $arrOther = unserialize($other_data);
             // データを編集
             foreach ($arrOther as $key => $val) {
                 // URLの場合にはリンクつきで表示させる
                 if (preg_match('/^(https?|ftp)(:\\/\\/[-_.!~*\'()a-zA-Z0-9;\\/?:\\@&=+\\$,%#]+)$/', $val["value"])) {
                     $arrOther[$key]["value"] = "<a href='" . $val["value"] . "'>" . $val["value"] . "</a>";
                 }
             }
             $this->arrOther = $arrOther;
         }
         // アフィリエイト用コンバージョンタグの設定
         $this->tpl_conv_page = AFF_SHOPPING_COMPLETE;
         $this->tpl_aff_option = "order_id={$order_id}";
         //合計価格の取得
         $total = $objQuery->get("dtb_order", "total", "order_id = ? ", array($order_id));
         if ($total != "") {
             $this->tpl_aff_option .= "|total={$total}";
         }
         // TS連携モジュールの実行
         if (function_exists('sfTSRequest')) {
             sfTSRequest($order_id);
         }
     }
     $objView->assignobj($this);
     $objView->display(SITE_FRAME);
 }
 /**
  * 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;
     }
 }
 /**
  * 注文受付メールを送信する.
  *
  * 端末種別IDにより, 携帯電話の場合は携帯用の文面,
  * それ以外の場合は PC 用の文面でメールを送信する.
  *
  * @param integer $order_id 受注ID
  * @param  object  $objPage LC_Page インスタンス
  * @return boolean 送信に成功したか。現状では、正確には取得できない。
  */
 public static function sendOrderMail($order_id, &$objPage = NULL)
 {
     $objMail = new SC_Helper_Mail_Ex();
     // setPageは、プラグインの処理に必要(see #1798)
     if (is_object($objPage)) {
         $objMail->setPage($objPage);
     }
     $arrOrder = SC_Helper_Purchase::getOrder($order_id);
     if (empty($arrOrder)) {
         return false;
         // 失敗
     }
     $template_id = $arrOrder['device_type_id'] == DEVICE_TYPE_MOBILE ? 2 : 1;
     $objMail->sfSendOrderMail($order_id, $template_id);
     return true;
     // 成功
 }
 /**
  * 確認画面を表示する為の準備
  * @param SC_FormParam $objFormParam
  */
 public function confirm(&$objFormParam)
 {
     $arrErr = $objFormParam->checkerror();
     // メールの送信
     if (count($arrErr) == 0) {
         // 注文受付メール(送信なし)
         $objMail = new SC_Helper_Mail_Ex();
         $objSendMail = $objMail->sfSendOrderMail($objFormParam->getValue('order_id'), $objFormParam->getValue('template_id'), $objFormParam->getValue('subject'), $objFormParam->getValue('header'), $objFormParam->getValue('footer'), false);
         $this->tpl_subject = $objFormParam->getValue('subject');
         $this->tpl_body = mb_convert_encoding($objSendMail->body, CHAR_CODE, 'auto');
         $this->tpl_to = $objSendMail->tpl_to;
         $this->tpl_mainpage = 'order/mail_confirm.tpl';
         return true;
     }
     return $arrErr;
 }
 /**
  * 受注完了メールを送信する.
  *
  * HTTP_USER_AGENT の種別により, 携帯電話の場合は携帯用の文面,
  * PC の場合は PC 用の文面でメールを送信する.
  *
  * @param integer $orderId 受注ID
  * @return void
  */
 function sendOrderMail($orderId)
 {
     $mailHelper = new SC_Helper_Mail_Ex();
     $template_id = SC_Display_Ex::detectDevice() == DEVICE_TYPE_MOBILE ? 2 : 1;
     $mailHelper->sfSendOrderMail($orderId, $template_id);
 }
 /**
  * Page のプロセス.
  *
  * @return void
  */
 function process()
 {
     $objView = new SC_AdminView();
     $objSess = new SC_Session();
     SC_Utils_Ex::sfIsSuccess($objSess);
     // 検索パラメータの引き継ぎ
     foreach ($_POST as $key => $val) {
         if (ereg("^search_", $key)) {
             $this->arrSearchHidden[$key] = $val;
         }
     }
     $this->tpl_order_id = $_POST['order_id'];
     // パラメータ管理クラス
     $objFormParam = new SC_FormParam();
     // パラメータ情報の初期化
     $this->lfInitParam($objFormParam);
     $objMail = new SC_Helper_Mail_Ex();
     switch ($_POST['mode']) {
         case 'pre_edit':
             break;
         case 'return':
             // POST値の取得
             $objFormParam->setParam($_POST);
             break;
         case 'send':
             // POST値の取得
             $objFormParam->setParam($_POST);
             // 入力値の変換
             $objFormParam->convParam();
             $this->arrErr = $objFormParam->checkerror();
             // メールの送信
             if (count($this->arrErr) == 0) {
                 // 注文受付メール
                 $objMail->sfSendOrderMail($_POST['order_id'], $_POST['template_id'], $_POST['subject'], $_POST['header'], $_POST['footer']);
             }
             $this->sendRedirect($this->getLocation(URL_SEARCH_ORDER));
             exit;
             break;
         case 'confirm':
             // POST値の取得
             $objFormParam->setParam($_POST);
             // 入力値の変換
             $objFormParam->convParam();
             // 入力値の引き継ぎ
             $this->arrHidden = $objFormParam->getHashArray();
             $this->arrErr = $objFormParam->checkerror();
             // メールの送信
             if (count($this->arrErr) == 0) {
                 // 注文受付メール(送信なし)
                 $objSendMail = $objMail->sfSendOrderMail($_POST['order_id'], $_POST['template_id'], $_POST['subject'], $_POST['header'], $_POST['footer'], false);
                 // 確認ページの表示
                 $this->tpl_subject = $_POST['subject'];
                 $this->tpl_body = mb_convert_encoding($objSendMail->body, CHAR_CODE, "auto");
                 $this->tpl_to = $objSendMail->tpl_to;
                 $this->tpl_mainpage = 'order/mail_confirm.tpl';
                 $objView->assignobj($this);
                 $objView->display(MAIN_FRAME);
                 exit;
             }
             break;
         case 'change':
             // POST値の取得
             $objFormParam->setValue('template_id', $_POST['template_id']);
             if (SC_Utils_Ex::sfIsInt($_POST['template_id'])) {
                 $objQuery = new SC_Query();
                 $where = "template_id = ?";
                 $arrRet = $objQuery->select("subject, header, footer", "dtb_mailtemplate", $where, array($_POST['template_id']));
                 $objFormParam->setParam($arrRet[0]);
             }
             break;
     }
     $objQuery = new SC_Query();
     $col = "send_date, subject, template_id, send_id";
     $where = "order_id = ?";
     $objQuery->setorder("send_date DESC");
     if (SC_Utils_Ex::sfIsInt($_POST['order_id'])) {
         $this->arrMailHistory = $objQuery->select($col, "dtb_mail_history", $where, array($_POST['order_id']));
     }
     $this->arrForm = $objFormParam->getFormParamList();
     $objView->assignobj($this);
     $objView->display(MAIN_FRAME);
 }
    $currency = $_POST["currency"];
    $objPurchase = new SC_Helper_Purchase();
    $orderInfo = $objPurchase->getOrder($out_trade_no);
    if (is_null($orderInfo)) {
        log_result("受注番号存在しない。アリペイパラメータ出力 out_trade_no:" . $out_trade_no . "status:" . $status . "trade_no:" . $trade_no . "total_fee:" . $total_fee . "currency" . $currency);
        exit;
    }
    $parameter = array("memo01" => "アリペイパラメータ出力 status:" . $status . "trade_no:" . $trade_no . "total_fee:" . $total_fee . "currency" . $currency);
    if ($status == "TRADE_FINISHED" && $orderInfo['status'] != ORDER_DELIV && $orderInfo['status'] != ORDER_PRE_END) {
        $objQuery =& SC_Query_Ex::getSingletonInstance();
        $objQuery->begin();
        $objPurchase->sfUpdateOrderStatus($out_trade_no, ORDER_PRE_END);
        $objQuery->commit();
        log_result("支払い完了。アリペイパラメータ出力 out_trade_no:" . $out_trade_no . "status:" . $status . "trade_no:" . $trade_no . "total_fee:" . $total_fee . "currency" . $currency);
        //支払い完了メール送信
        $objMail->sfSendOrderMail($out_trade_no, 7);
    } else {
        if ($status == "TRADE_CLOSED" && $orderInfo['status'] != ORDER_CANCEL) {
            $objQuery =& SC_Query_Ex::getSingletonInstance();
            $objQuery->begin();
            $objPurchase->sfUpdateOrderStatus($out_trade_no, ORDER_CANCEL);
            $objQuery->commit();
            log_result("支払期限過ぎです。受注キャンセルし、在庫を引き戻す!out_trade_no:" . $out_trade_no . "status:" . $status . "trade_no:" . $trade_no . "total_fee:" . $total_fee . "currency" . $currency);
        }
    }
} else {
    log_result("不正アクセス.");
}
function log_result($word)
{
    $fp = fopen("notify.log", "a");
 /**
  * 受注完了メールを送信する.
  *
  * HTTP_USER_AGENT の種別により, 携帯電話の場合は携帯用の文面,
  * PC の場合は PC 用の文面でメールを送信する.
  *
  * @param integer $orderId 受注ID
  * @return void
  */
 function sendOrderMail($orderId)
 {
     $mailHelper = new SC_Helper_Mail_Ex();
     $mailHelper->sfSendOrderMail($orderId, SC_MobileUserAgent_Ex::isMobile() ? 2 : 1);
 }