Ignore:
Timestamp:
2012/11/02 19:27:41 (11 years ago)
Author:
pineray
Message:

#1958 別お届け先関連の処理をページクラスから分離

Location:
branches/version-2_12-dev/data/class/pages
Files:
4 edited

Legend:

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

    r21867 r22065  
    6969        $objCustomer    = new SC_Customer_Ex(); 
    7070        $customer_id    = $objCustomer->getValue('customer_id'); 
     71        $objAddress     = new SC_Helper_Address_Ex(); 
    7172        $objFormParam   = new SC_FormParam_Ex(); 
    7273 
     
    8485                } 
    8586 
    86                 $this->deleteOtherDeliv($customer_id, $objFormParam->getValue('other_deliv_id')); 
     87                $objAddress->deleteAddress($customer_id, $objFormParam->getValue('other_deliv_id')); 
    8788                break; 
    8889 
     
    9192                    $arrData = $objFormParam->getHashArray(); 
    9293                    //別のお届け先情報 
    93                     $arrOtherDeliv = $this->getOtherDeliv($customer_id, (($arrData['pageno'] - 1) * SEARCH_PMAX)); 
     94                    $arrOtherDeliv = $objAddress->getList($customer_id, (($arrData['pageno'] - 1) * SEARCH_PMAX)); 
    9495                    //県名をセット 
    9596                    $arrOtherDeliv = $this->setPref($arrOtherDeliv, $this->arrPref); 
     
    108109 
    109110        //別のお届け先情報 
    110         $this->arrOtherDeliv = $this->getOtherDeliv($customer_id); 
     111        $this->arrOtherDeliv = $objAddress->getList($customer_id); 
    111112 
    112113        //お届け先登録数 
     
    139140 
    140141    /** 
    141      * お届け先の取得 
    142      * 
    143      * @param integer $customerId 
    144      * @param integer $startno 
    145      * @return array 
    146      */ 
    147     function getOtherDeliv($customer_id, $startno = '') { 
    148         $objQuery   =& SC_Query_Ex::getSingletonInstance(); 
    149         $objQuery->setOrder('other_deliv_id DESC'); 
    150         //スマートフォン用の処理 
    151         if ($startno != '') { 
    152             $objQuery->setLimitOffset(SEARCH_PMAX, $startno); 
    153         } 
    154         return $objQuery->select('*', 'dtb_other_deliv', 'customer_id = ?', array($customer_id)); 
    155     } 
    156  
    157     /** 
    158      * お届け先の削除 
    159      * 
    160      * @param integer $customerId 
    161      * @param integer $delivId 
    162      */ 
    163     function deleteOtherDeliv($customer_id, $deliv_id) { 
    164         $where      = 'customer_id = ? AND other_deliv_id = ?'; 
    165         $objQuery   =& SC_Query_Ex::getSingletonInstance(); 
    166         $objQuery->delete('dtb_other_deliv', $where, array($customer_id, $deliv_id)); 
    167     } 
    168  
    169     /** 
    170142     * 県名をセット 
    171143     * 
  • branches/version-2_12-dev/data/class/pages/mypage/LC_Page_Mypage_DeliveryAddr.php

    r21867 r22065  
    7272 
    7373        $objCustomer = new SC_Customer_Ex(); 
     74        $objAddress  = new SC_Helper_Address_Ex(); 
    7475        $ParentPage  = MYPAGE_DELIVADDR_URLPATH; 
    7576 
     
    9798        // パラメーター管理クラス,パラメーター情報の初期化 
    9899        $objFormParam   = new SC_FormParam_Ex(); 
    99         SC_Helper_Customer_Ex::sfCustomerOtherDelivParam($objFormParam); 
     100        $objAddress->setFormParam($objFormParam); 
    100101        $objFormParam->setParam($_POST); 
    101102        $this->arrForm  = $objFormParam->getHashArray(); 
     
    104105            // 入力は必ずedit 
    105106            case 'edit': 
    106                 $this->arrErr = SC_Helper_Customer_Ex::sfCustomerOtherDelivErrorCheck($objFormParam); 
     107                $this->arrErr = $objAddress->errorCheck($objFormParam); 
    107108                // 入力エラーなし 
    108109                if (empty($this->arrErr)) { 
     
    116117 
    117118                    if ($objCustomer->isLoginSuccess(true)) { 
    118                         $this->lfRegistData($objFormParam, $objCustomer->getValue('customer_id')); 
     119                        $this->lfRegistData($objAddress, $objFormParam, $objCustomer->getValue('customer_id')); 
    119120                    } else { 
    120121                        $this->lfRegistDataNonMember($objFormParam); 
     
    135136 
    136137                if ($_GET['other_deliv_id'] != '') { 
    137                     $arrOtherDeliv = $this->lfGetOtherDeliv($objCustomer->getValue('customer_id'), $_SESSION['other_deliv_id']); 
     138                    $arrOtherDeliv = $objAddress->getAddress($objCustomer->getValue('customer_id'), $_SESSION['other_deliv_id']); 
    138139 
    139140                    //不正アクセス判定 
    140                     if (!$objCustomer->isLoginSuccess(true) || count($arrOtherDeliv) == 0) { 
     141                    if (!$objCustomer->isLoginSuccess(true) || !$arrOtherDeliv) { 
    141142                        SC_Utils_Ex::sfDispSiteError(CUSTOMER_ERROR); 
    142143                    } 
    143144 
    144145                    //別のお届け先情報取得 
    145                     $this->arrForm = $arrOtherDeliv[0]; 
     146                    $this->arrForm = $arrOtherDeliv; 
    146147                } 
    147148                break; 
     
    165166    } 
    166167 
    167     /** 
    168      * ほかのお届け先を取得する 
    169      * 
    170      * @param mixed $customer_id 
    171      * @param mixed $other_deliv_id 
    172      * @access private 
    173      * @return array() 
    174      */ 
    175     function lfGetOtherDeliv($customer_id, $other_deliv_id) { 
    176         $objQuery =& SC_Query_Ex::getSingletonInstance(); 
    177         return $objQuery->select('*', 'dtb_other_deliv', 'customer_id = ? AND other_deliv_id = ?', array($customer_id, $other_deliv_id)); 
    178     } 
    179  
    180168    /* 登録実行 */ 
    181     function lfRegistData($objFormParam, $customer_id) { 
    182         $objQuery   =& SC_Query_Ex::getSingletonInstance(); 
    183  
     169    function lfRegistData($objAddress, $objFormParam, $customer_id) { 
    184170        $arrRet     = $objFormParam->getHashArray(); 
    185171        $sqlval     = $objFormParam->getDbArray(); 
     
    187173        $sqlval['customer_id'] = $customer_id; 
    188174 
    189         // 追加 
    190         if (strlen($arrRet['other_deliv_id'] == 0)) { 
    191             // 別のお届け先登録数の取得 
    192             $deliv_count = $objQuery->count('dtb_other_deliv', 'customer_id = ?', array($customer_id)); 
    193             // 別のお届け先最大登録数に達している場合、エラー 
    194             if ($deliv_count >= DELIV_ADDR_MAX) { 
    195                 SC_Utils_Ex::sfDispSiteError(FREE_ERROR_MSG, '', false, '別のお届け先最大登録数に達しています。'); 
    196             } 
    197  
    198             // 実行 
    199             $sqlval['other_deliv_id'] = $objQuery->nextVal('dtb_other_deliv_other_deliv_id'); 
    200             $objQuery->insert('dtb_other_deliv', $sqlval); 
    201  
    202         // 変更 
    203         } else { 
    204             $deliv_count = $objQuery->count('dtb_other_deliv','customer_id = ? AND other_deliv_id = ?' ,array($customer_id, $arrRet['other_deliv_id'])); 
    205             if ($deliv_count != 1) { 
    206                 SC_Utils_Ex::sfDispSiteError(FREE_ERROR_MSG, '', false, '一致する別のお届け先がありません。'); 
    207             } 
    208  
    209             // 実行 
    210             $objQuery->update('dtb_other_deliv', $sqlval, 'other_deliv_id = ?', array($arrRet['other_deliv_id'])); 
    211         } 
     175        $objAddress->registAddress($customer_id, $sqlval, $arrRet['other_deliv_id']); 
    212176    } 
    213177 
  • branches/version-2_12-dev/data/class/pages/shopping/LC_Page_Shopping_Deliv.php

    r21951 r22065  
    7373        $objPurchase = new SC_Helper_Purchase_Ex(); 
    7474        $objFormParam = new SC_FormParam_Ex(); 
     75        $objAddress = new SC_Helper_Address_Ex(); 
    7576 
    7677        $this->tpl_uniqid = $objSiteSess->getUniqId(); 
     
    109110            // 削除 
    110111            case 'delete': 
    111                 $this->doDelete($arrForm['other_deliv_id']); 
     112                $objAddress->deleteAddress($objCustomer->getValue('customer_id'), $arrForm['other_deliv_id']); 
    112113                break; 
    113114 
     
    117118 
    118119                $shipping_id = $arrForm['deliv_check'] == -1 ? 0 : $arrForm['deliv_check']; 
    119                 $success = $this->registerDeliv($shipping_id, $this->tpl_uniqid, $objPurchase, $objCustomer); 
     120                $success = $this->registerDeliv($shipping_id, $this->tpl_uniqid, $objPurchase, $objCustomer, $objAddress); 
    120121                if (!$success) { 
    121122                    SC_Utils_Ex::sfDispSiteError(PAGE_ERROR, '', true); 
     
    161162 
    162163        // 登録済み住所を取得 
    163         $this->arrAddr = $objCustomer->getCustomerAddress($objCustomer->getValue('customer_id')); 
     164        $addr = array( 
     165            array( 
     166                'other_deliv_id'    => NULL, 
     167                'customer_id'       => $objCustomer->getValue('customer_id'), 
     168                'name01'            => $objCustomer->getValue('name01'), 
     169                'name02'            => $objCustomer->getValue('name02'), 
     170                'kana01'            => $objCustomer->getValue('kana01'), 
     171                'kana02'            => $objCustomer->getValue('kana02'), 
     172                'zip01'             => $objCustomer->getValue('zip01'), 
     173                'zip02'             => $objCustomer->getValue('zip02'), 
     174                'pref'              => $objCustomer->getValue('pref'), 
     175                'addr01'            => $objCustomer->getValue('addr01'), 
     176                'addr02'            => $objCustomer->getValue('addr02'), 
     177                'tel01'             => $objCustomer->getValue('tel01'), 
     178                'tel02'             => $objCustomer->getValue('tel02'), 
     179                'tel03'             => $objCustomer->getValue('tel03'), 
     180            ) 
     181        ); 
     182        $this->arrAddr = array_merge($addr, $objAddress->getList($objCustomer->getValue('customer_id'))); 
    164183        $this->tpl_addrmax = count($this->arrAddr); 
    165184 
     
    185204        $objFormParam->addParam('その他のお届け先ID', 'other_deliv_id', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); 
    186205        $objFormParam->addParam('お届け先チェック', 'deliv_check', INT_LEN, 'n', array('MAX_LENGTH_CHECK')); 
    187     } 
    188  
    189     /** 
    190      * その他のお届け先情報を削除する. 
    191      * 
    192      * @param integer $other_deliv_id その他のお届け先ID 
    193      * @return void 
    194      */ 
    195     function doDelete($other_deliv_id) { 
    196         $objQuery =& SC_Query_Ex::getSingletonInstance(); 
    197         $where = 'other_deliv_id = ?'; 
    198         $objQuery->delete('dtb_other_deliv', $where, array($other_deliv_id)); 
    199206    } 
    200207 
     
    212219     * @return boolean お届け先チェックの値が妥当な場合 true 
    213220     */ 
    214     function registerDeliv($other_deliv_id, $uniqid, &$objPurchase, &$objCustomer) { 
     221    function registerDeliv($other_deliv_id, $uniqid, &$objPurchase, &$objCustomer, $objAddress) { 
    215222        GC_Utils_Ex::gfDebugLog('register deliv. deliv_check=' . $deliv_check); 
    216223        $arrValues = array(); 
     
    221228        // 別のお届け先がチェックされている場合 
    222229        else { 
    223             $objQuery =& SC_Query_Ex::getSingletonInstance(); 
    224             $arrOtherDeliv = $objQuery->getRow('*', 'dtb_other_deliv', 
    225                                                'customer_id = ? AND other_deliv_id = ?', 
    226                                                array($objCustomer->getValue('customer_id'), $other_deliv_id)); 
    227             if (empty($arrOtherDeliv)) { 
     230            $arrOtherDeliv = $objAddress->getAddress($objCustomer->getValue('customer_id'), $other_deliv_id); 
     231            if (!$arrOtherDeliv) { 
    228232                return false; 
    229233            } 
  • branches/version-2_12-dev/data/class/pages/shopping/LC_Page_Shopping_Multiple.php

    r21951 r22065  
    7171        $objCustomer = new SC_Customer_Ex(); 
    7272        $objFormParam = new SC_FormParam_Ex(); 
     73        $objAddress = new SC_Helper_Address_Ex(); 
    7374 
    7475        // 複数配送先指定が無効な場合はエラー 
     
    8182 
    8283        $this->addrs = $this->getDelivAddrs($objCustomer, $objPurchase, 
    83                                             $this->tpl_uniqid); 
     84                                            $objAddress, $this->tpl_uniqid); 
    8485        $this->tpl_addrmax = count($this->addrs); 
    8586        $this->lfInitParam($objFormParam); 
     
    9697                    $this->saveMultipleShippings($this->tpl_uniqid, $objFormParam, 
    9798                                                 $objCustomer, $objPurchase, 
    98                                                  $objCartSess); 
     99                                                 $objCartSess, $objAddress); 
    99100                    $objSiteSess->setRegistFlag(); 
    100101 
     
    187188     * @return array 配送住所のプルダウン用連想配列 
    188189     */ 
    189     function getDelivAddrs(&$objCustomer, &$objPurchase, $uniqid) { 
     190    function getDelivAddrs(&$objCustomer, &$objPurchase, &$objAddress, $uniqid) { 
    190191        $masterData = new SC_DB_MasterData_Ex(); 
    191192        $arrPref = $masterData->getMasterData('mtb_pref'); 
     
    194195        // 会員ログイン時 
    195196        if ($objCustomer->isLoginSuccess(true)) { 
    196             $arrAddrs = $objCustomer->getCustomerAddress($objCustomer->getValue('customer_id')); 
     197            $addr = array( 
     198                array( 
     199                    'other_deliv_id'    => NULL, 
     200                    'customer_id'       => $objCustomer->getValue('customer_id'), 
     201                    'name01'            => $objCustomer->getValue('name01'), 
     202                    'name02'            => $objCustomer->getValue('name02'), 
     203                    'kana01'            => $objCustomer->getValue('kana01'), 
     204                    'kana02'            => $objCustomer->getValue('kana02'), 
     205                    'zip01'             => $objCustomer->getValue('zip01'), 
     206                    'zip02'             => $objCustomer->getValue('zip02'), 
     207                    'pref'              => $objCustomer->getValue('pref'), 
     208                    'addr01'            => $objCustomer->getValue('addr01'), 
     209                    'addr02'            => $objCustomer->getValue('addr02'), 
     210                    'tel01'             => $objCustomer->getValue('tel01'), 
     211                    'tel02'             => $objCustomer->getValue('tel02'), 
     212                    'tel03'             => $objCustomer->getValue('tel03'), 
     213                ) 
     214            ); 
     215            $arrAddrs = array_merge($addr, $objAddress->getList($objCustomer->getValue('customer_id'))); 
    197216            foreach ($arrAddrs as $val) { 
    198217                $other_deliv_id = SC_Utils_Ex::isBlank($val['other_deliv_id']) ? 0 : $val['other_deliv_id']; 
     
    280299     * @return void 
    281300     */ 
    282     function saveMultipleShippings($uniqid, &$objFormParam, &$objCustomer, &$objPurchase, &$objCartSess) { 
     301    function saveMultipleShippings($uniqid, &$objFormParam, &$objCustomer, &$objPurchase, &$objCartSess, &$objAddress) { 
    283302        $objQuery =& SC_Query_Ex::getSingletonInstance(); 
    284303 
     
    290309            if ($objCustomer->isLoginSuccess(true)) { 
    291310                if ($other_deliv_id != 0) { 
    292                     $otherDeliv = $objQuery->select('*', 'dtb_other_deliv', 
    293                                                     'other_deliv_id = ?', 
    294                                                     array($other_deliv_id)); 
    295                     foreach ($otherDeliv[0] as $key => $val) { 
     311                    $otherDeliv = $objAddress->getAddress($objCustomer->getValue('customer_id'), $other_deliv_id); 
     312                    foreach ($otherDeliv as $key => $val) { 
    296313                        $arrValues[$other_deliv_id]['shipping_' . $key] = $val; 
    297314                    } 
Note: See TracChangeset for help on using the changeset viewer.