コード例 #1
0
 /**
  * 受注を完了する.
  *
  * 下記のフローで受注を完了する.
  *
  * 1. トランザクションを開始する
  * 2. カートの内容を検証する.
  * 3. 受注一時テーブルから受注データを読み込む
  * 4. ユーザーがログインしている場合はその他の発送先へ登録する
  * 5. 受注データを受注テーブルへ登録する
  * 6. トランザクションをコミットする
  *
  * 実行中に, 何らかのエラーが発生した場合, 処理を中止しエラーページへ遷移する
  *
  * 決済モジュールを使用する場合は対応状況を「決済処理中」に設定し,
  * 決済完了後「新規受付」に変更すること
  *
  * @param  integer $orderStatus 受注処理を完了する際に設定する対応状況
  * @return void
  */
 public function completeOrder($orderStatus = ORDER_NEW)
 {
     $objQuery =& SC_Query_Ex::getSingletonInstance();
     $objSiteSession = new SC_SiteSession_Ex();
     $objCartSession = new SC_CartSession_Ex();
     $objCustomer = new SC_Customer_Ex();
     $customerId = $objCustomer->getValue('customer_id');
     $objQuery->begin();
     if (!$objSiteSession->isPrePage()) {
         SC_Utils_Ex::sfDispSiteError(PAGE_ERROR, $objSiteSession);
     }
     $uniqId = $objSiteSession->getUniqId();
     $this->verifyChangeCart($uniqId, $objCartSession);
     $orderTemp = $this->getOrderTemp($uniqId);
     $orderTemp['status'] = $orderStatus;
     $cartkey = $objCartSession->getKey();
     $order_id = $this->registerOrderComplete($orderTemp, $objCartSession, $cartkey);
     $isMultiple = SC_Helper_Purchase::isMultiple();
     $shippingTemp =& $this->getShippingTemp($isMultiple);
     foreach ($shippingTemp as $shippingId => $val) {
         $this->registerShipmentItem($order_id, $shippingId, $val['shipment_item']);
     }
     $this->registerShipping($order_id, $shippingTemp);
     $objQuery->commit();
     //会員情報の最終購入日、購入合計を更新
     if ($customerId > 0) {
         SC_Customer_Ex::updateOrderSummary($customerId);
     }
     $this->cleanupSession($order_id, $objCartSession, $objCustomer, $cartkey);
     GC_Utils_Ex::gfPrintLog('order complete. order_id=' . $order_id);
 }