Changeset 20138


Ignore:
Timestamp:
2011/02/11 18:56:57 (13 years ago)
Author:
kimoto
Message:

リファクタリング #981

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/version-2_5-dev/data/class/pages/mypage/LC_Page_Mypage_Order.php

    r20116 r20138  
    6464    function action() { 
    6565        $objCustomer = new SC_Customer(); 
    66         $objCartSess = new SC_CartSession(); 
    6766 
    6867        //受注詳細データの取得 
    69         $arrDisp = $this->lfGetOrderDetail($_POST['order_id']); 
     68        $arrOrderDetail = $this->lfGetOrderDetail($_POST['order_id']); 
    7069 
    7170        //ログインしていない、またはDBに情報が無い場合 
    72         if (!$objCustomer->isLoginSuccess(true) or count($arrDisp) == 0){ 
     71        if (!$objCustomer->isLoginSuccess(true) || empty($arrOrderDetail)){ 
    7372            SC_Utils_Ex::sfDispSiteError(CUSTOMER_ERROR); 
    7473        } 
    7574 
    76         for($num = 0; $num < count($arrDisp); $num++) { 
    77             $product_class_id = $arrDisp[$num]['product_class_id']; 
    78             $quantity = $arrDisp[$num]['quantity']; 
    79             $product_type_id = $arrDisp[$num]['product_type_id']; 
    80  
    81             $objCartSess->addProduct($product_class_id, $quantity, $product_type_id); 
    82         } 
     75        $this->lfAddCartProducts($arrOrderDetail); 
    8376        SC_Response_Ex::sendRedirect(CART_URLPATH); 
    8477    } 
     
    9588    // 受注詳細データの取得 
    9689    function lfGetOrderDetail($order_id) { 
    97         $objQuery = new SC_Query(); 
    98         $objCustomer = new SC_Customer(); 
     90        $objQuery       = SC_Query::getSingletonInstance(); 
     91 
     92        $objCustomer    = new SC_Customer(); 
    9993        //customer_idを検証 
    100         $customer_id = $objCustomer->getValue("customer_id"); 
    101         $order_count = $objQuery->count("dtb_order", "order_id = ? and customer_id = ?", array($order_id, $customer_id)); 
     94        $customer_id    = $objCustomer->getValue("customer_id"); 
     95        $order_count    = $objQuery->count("dtb_order", "order_id = ? and customer_id = ?", array($order_id, $customer_id)); 
    10296        if ($order_count != 1) return array(); 
    103         $col = "product_class_id, quantity, product_type_id"; 
    104         $table = "dtb_order_detail LEFT JOIN dtb_products_class USING(product_class_id)"; 
    105         $where = "order_id = ?"; 
     97 
     98        $col    = "product_class_id, quantity, product_type_id"; 
     99        $table  = "dtb_order_detail LEFT JOIN dtb_products_class USING(product_class_id)"; 
     100        $where  = "order_id = ?"; 
    106101        $objQuery->setOrder("product_class_id"); 
    107         $arrRet = $objQuery->select($col, $table, $where, array($order_id)); 
    108         return $arrRet; 
     102        $arrOrderDetail = $objQuery->select($col, $table, $where, array($order_id)); 
     103        return $arrOrderDetail; 
    109104    } 
     105 
     106    // 商品をカートに追加 
     107    function lfAddCartProducts($arrOrderDetail) { 
     108 
     109        $objCartSess = new SC_CartSession(); 
     110        foreach($arrOrderDetail as $order_row) { 
     111 
     112            $objCartSess->addProduct($order_row['product_class_id'], 
     113                                     $order_row['quantity'], 
     114                                     $order_row['product_type_id']); 
     115        } 
     116    } 
     117 
    110118 
    111119} 
Note: See TracChangeset for help on using the changeset viewer.