- Timestamp:
- 2007/08/06 22:04:26 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/feature-module-update/html/shopping/payment.php
r15080 r15223 6 6 */ 7 7 8 // {{{ requires 8 9 require_once("../require.php"); 10 require_once(CLASS_PATH . "page_extends/shopping/LC_Page_Shopping_Payment_Ex.php"); 9 11 10 class LC_Page { 11 var $arrSession; 12 var $tpl_mode; 13 function LC_Page() { 14 $this->tpl_css = URL_DIR.'css/layout/shopping/pay.css'; 15 $this->tpl_mainpage = 'shopping/payment.tpl'; 16 $this->tpl_onload = 'fnCheckInputPoint();'; 17 $this->tpl_title = "お支払方法・お届け時間等の指定"; 18 /* 19 session_start時のno-cacheヘッダーを抑制することで 20 「戻る」ボタン使用時の有効期限切れ表示を抑制する。 21 private-no-expire:クライアントのキャッシュを許可する。 22 */ 23 session_cache_limiter('private-no-expire'); 24 } 25 } 12 // }}} 13 // {{{ generate page 26 14 27 $objPage = new LC_Page(); 28 $objView = new SC_SiteView(); 29 $objSiteSess = new SC_SiteSession(); 30 $objCartSess = new SC_CartSession(); 31 $objCampaignSess = new SC_CampaignSession(); 32 $objCustomer = new SC_Customer(); 33 $objSiteInfo = $objView->objSiteInfo; 34 $arrInfo = $objSiteInfo->data; 35 36 // パラメータ管理クラス 37 $objFormParam = new SC_FormParam(); 38 // パラメータ情報の初期化 39 lfInitParam(); 40 // POST値の取得 41 $objFormParam->setParam($_POST); 42 43 // ユーザユニークIDの取得と購入状態の正当性をチェック 44 $uniqid = sfCheckNormalAccess($objSiteSess, $objCartSess); 45 // ユニークIDを引き継ぐ 46 $objPage->tpl_uniqid = $uniqid; 47 48 // 会員ログインチェック 49 if($objCustomer->isLoginSuccess()) { 50 $objPage->tpl_login = '1'; 51 $objPage->tpl_user_point = $objCustomer->getValue('point'); 52 //戻り先URL 53 $objPage->tpl_back_url = URL_DELIV_TOP; 54 } else { 55 $objPage->tpl_back_url = URL_SHOP_TOP . "?from=nonmember"; 56 } 57 58 // 金額の取得 (購入途中で売り切れた場合にはこの関数内にてその商品の個数が0になる) 59 $objPage = sfTotalCart($objPage, $objCartSess, $arrInfo); 60 $objPage->arrData = sfTotalConfirm($arrData, $objPage, $objCartSess, $arrInfo); 61 62 // カー都内の商品の売り切れチェック 63 $objCartSess->chkSoldOut($objCartSess->getCartList()); 64 65 switch($_POST['mode']) { 66 case 'confirm': 67 // 入力値の変換 68 $objFormParam->convParam(); 69 $objPage->arrErr = lfCheckError($objPage->arrData ); 70 // 入力エラーなし 71 if(count($objPage->arrErr) == 0) { 72 // DBへのデータ登録 73 lfRegistData($uniqid); 74 // 正常に登録されたことを記録しておく 75 $objSiteSess->setRegistFlag(); 76 // 確認ページへ移動 77 header("Location: " . URL_SHOP_CONFIRM); 78 exit; 79 }else{ 80 // ユーザユニークIDの取得 81 $uniqid = $objSiteSess->getUniqId(); 82 // 受注一時テーブルからの情報を格納 83 lfSetOrderTempData($uniqid); 84 } 85 break; 86 // 前のページに戻る 87 case 'return': 88 // 非会員の場合 89 // 正常な推移であることを記録しておく 90 $objSiteSess->setRegistFlag(); 91 header("Location: " . URL_SHOP_TOP); 92 exit; 93 break; 94 // 支払い方法が変更された場合 95 case 'payment': 96 // ここのbreakは、意味があるので外さないで下さい。 97 break; 98 default: 99 // 受注一時テーブルからの情報を格納 100 lfSetOrderTempData($uniqid); 101 break; 102 } 103 104 // 店舗情報の取得 105 $arrInfo = $objSiteInfo->data; 106 // 購入金額の取得得 107 $total_pretax = $objCartSess->getAllProductsTotal($arrInfo); 108 // 支払い方法の取得 109 $objPage->arrPayment = lfGetPayment($total_pretax); 110 // 配送時間の取得 111 $arrRet = sfGetDelivTime($objFormParam->getValue('payment_id')); 112 $objPage->arrDelivTime = sfArrKeyValue($arrRet, 'time_id', 'deliv_time'); 113 $objPage->objCustomer = $objCustomer; 114 // 配送日一覧の取得 115 $objPage->arrDelivDate = lfGetDelivDate(); 116 117 $objPage->arrForm = $objFormParam->getFormParamList(); 118 119 $objView->assignobj($objPage); 120 // フレームを選択(キャンペーンページから遷移なら変更) 121 $objCampaignSess->pageView($objView); 122 //-------------------------------------------------------------------------------------------------------------------------- 123 /* パラメータ情報の初期化 */ 124 function lfInitParam() { 125 global $objFormParam; 126 $objFormParam->addParam("お支払い方法", "payment_id", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK")); 127 $objFormParam->addParam("ポイント", "use_point", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK", "ZERO_START")); 128 $objFormParam->addParam("配達時間", "deliv_time_id", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK")); 129 $objFormParam->addParam("ご質問", "message", LTEXT_LEN, "KVa", array("SPTAB_CHECK", "MAX_LENGTH_CHECK")); 130 $objFormParam->addParam("ポイントを使用する", "point_check", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"), '2'); 131 $objFormParam->addParam("配達日", "deliv_date", STEXT_LEN, "KVa", array("MAX_LENGTH_CHECK")); 132 } 133 134 function lfGetPayment($total_pretax) { 135 $objQuery = new SC_Query(); 136 $objQuery->setorder("rank DESC"); 137 //削除されていない支払方法を取得 138 $arrRet = $objQuery->select("payment_id, payment_method, rule, upper_rule, note, payment_image", "dtb_payment", "del_flg = 0 AND deliv_id IN (SELECT deliv_id FROM dtb_deliv WHERE del_flg = 0) "); 139 //利用条件から支払可能方法を判定 140 foreach($arrRet as $data) { 141 //下限と上限が設定されている 142 if($data['rule'] > 0 && $data['upper_rule'] > 0) { 143 if($data['rule'] <= $total_pretax && $data['upper_rule'] >= $total_pretax) { 144 $arrPayment[] = $data; 145 } 146 //下限のみ設定されている 147 } elseif($data['rule'] > 0) { 148 if($data['rule'] <= $total_pretax) { 149 $arrPayment[] = $data; 150 } 151 //上限のみ設定されている 152 } elseif($data['upper_rule'] > 0) { 153 if($data['upper_rule'] >= $total_pretax) { 154 $arrPayment[] = $data; 155 } 156 //設定なし 157 } else { 158 $arrPayment[] = $data; 159 } 160 } 161 return $arrPayment; 162 } 163 164 /* 入力内容のチェック */ 165 function lfCheckError($arrData) { 166 global $objFormParam; 167 global $objCustomer; 168 // 入力データを渡す。 169 $arrRet = $objFormParam->getHashArray(); 170 $objErr = new SC_CheckError($arrRet); 171 $objErr->arrErr = $objFormParam->checkError(); 172 173 if($_POST['point_check'] == '1') { 174 $objErr->doFunc(array("ポイントを使用する", "point_check"), array("EXIST_CHECK")); 175 $objErr->doFunc(array("ポイント", "use_point"), array("EXIST_CHECK")); 176 $max_point = $objCustomer->getValue('point'); 177 if($max_point == "") { 178 $max_point = 0; 179 } 180 if($arrRet['use_point'] > $max_point) { 181 $objErr->arrErr['use_point'] = "※ ご利用ポイントが所持ポイントを超えています。<br />"; 182 } 183 if(($arrRet['use_point'] * POINT_VALUE) > $arrData['subtotal']) { 184 $objErr->arrErr['use_point'] = "※ ご利用ポイントがご購入金額を超えています。<br />"; 185 } 186 } 187 return $objErr->arrErr; 188 } 189 190 /* 支払い方法文字列の取得 */ 191 function lfGetPaymentInfo($payment_id) { 192 $objQuery = new SC_Query(); 193 $where = "payment_id = ?"; 194 $arrRet = $objQuery->select("payment_method, charge", "dtb_payment", $where, array($payment_id)); 195 return (array($arrRet[0]['payment_method'], $arrRet[0]['charge'])); 196 } 197 198 /* 配送時間文字列の取得 */ 199 function lfGetDelivTimeInfo($time_id) { 200 $objQuery = new SC_Query(); 201 $where = "time_id = ?"; 202 $arrRet = $objQuery->select("deliv_id, deliv_time", "dtb_delivtime", $where, array($time_id)); 203 return (array($arrRet[0]['deliv_id'], $arrRet[0]['deliv_time'])); 204 } 205 206 /* DBへデータの登録 */ 207 function lfRegistData($uniqid) { 208 global $objFormParam; 209 $arrRet = $objFormParam->getHashArray(); 210 $sqlval = $objFormParam->getDbArray(); 211 // 登録データの作成 212 $sqlval['order_temp_id'] = $uniqid; 213 $sqlval['update_date'] = 'Now()'; 214 215 if($sqlval['payment_id'] != "") { 216 list($sqlval['payment_method'], $sqlval['charge']) = lfGetPaymentInfo($sqlval['payment_id']); 217 } else { 218 $sqlval['payment_id'] = '0'; 219 $sqlval['payment_method'] = ""; 220 } 221 222 if($sqlval['deliv_time_id'] != "") { 223 list($sqlval['deliv_id'], $sqlval['deliv_time']) = lfGetDelivTimeInfo($sqlval['deliv_time_id']); 224 } else { 225 $sqlval['deliv_time_id'] = '0'; 226 $sqlval['deliv_id'] = '0'; 227 $sqlval['deliv_time'] = ""; 228 } 229 230 // 使用ポイントの設定 231 if($sqlval['point_check'] != '1') { 232 $sqlval['use_point'] = 0; 233 } 234 235 sfRegistTempOrder($uniqid, $sqlval); 236 } 237 238 /* 配達日一覧を取得する */ 239 function lfGetDelivDate() { 240 $objCartSess = new SC_CartSession(); 241 $objQuery = new SC_Query(); 242 // 商品IDの取得 243 $max = $objCartSess->getMax(); 244 for($i = 1; $i <= $max; $i++) { 245 if($_SESSION[$objCartSess->key][$i]['id'][0] != "") { 246 $arrID['product_id'][$i] = $_SESSION[$objCartSess->key][$i]['id'][0]; 247 } 248 } 249 if(count($arrID['product_id']) > 0) { 250 $id = implode(",", $arrID['product_id']); 251 //商品から発送目安の取得 252 $deliv_date = $objQuery->get("dtb_products", "MAX(deliv_date_id)", "product_id IN (".$id.")"); 253 //発送目安 254 switch($deliv_date) { 255 //即日発送 256 case '1': 257 $start_day = 1; 258 break; 259 //1-2日後 260 case '2': 261 $start_day = 3; 262 break; 263 //3-4日後 264 case '3': 265 $start_day = 5; 266 break; 267 //1週間以内 268 case '4': 269 $start_day = 8; 270 break; 271 //2週間以内 272 case '5': 273 $start_day = 15; 274 break; 275 //3週間以内 276 case '6': 277 $start_day = 22; 278 break; 279 //1ヶ月以内 280 case '7': 281 $start_day = 32; 282 break; 283 //2ヶ月以降 284 case '8': 285 $start_day = 62; 286 break; 287 //お取り寄せ(商品入荷後) 288 case '9': 289 $start_day = ""; 290 break; 291 default: 292 //お届け日が設定されていない場合 293 $start_day = ""; 294 break; 295 } 296 //配達可能日のスタート値から、配達日の配列を取得する 297 $arrDelivDate = lfGetDateArray($start_day, DELIV_DATE_END_MAX); 298 } 299 return $arrDelivDate; 300 } 301 302 //配達可能日のスタート値から、配達日の配列を取得する 303 function lfGetDateArray($start_day, $end_day) { 304 global $arrWDAY; 305 //配達可能日のスタート値がセットされていれば 306 if($start_day >= 1) { 307 $now_time = time(); 308 $max_day = $start_day + $end_day; 309 // 集計 310 for ($i = $start_day; $i < $max_day; $i++) { 311 // 基本時間から日数を追加していく 312 $tmp_time = $now_time + ($i * 24 * 3600); 313 list($y, $m, $d, $w) = split(" ", date("y m d w", $tmp_time)); 314 $val = sprintf("%02d/%02d/%02d(%s)", $y, $m, $d, $arrWDAY[$w]); 315 $arrDate[$val] = $val; 316 } 317 } else { 318 $arrDate = false; 319 } 320 return $arrDate; 321 } 322 323 //一時受注テーブルからの情報を格納する 324 function lfSetOrderTempData($uniqid) { 325 global $objQuery; 326 global $objFormParam; 327 328 $objQuery = new SC_Query(); 329 $col = "payment_id, use_point, deliv_time_id, message, point_check, deliv_date"; 330 $from = "dtb_order_temp"; 331 $where = "order_temp_id = ?"; 332 $arrRet = $objQuery->select($col, $from, $where, array($uniqid)); 333 // DB値の取得 334 $objFormParam->setParam($arrRet[0]); 335 return $objFormParam; 336 } 337 338 15 $objPage = new LC_Page_Shopping_Payment_Ex(); 16 $objPage->init(); 17 $objPage->process(); 18 register_shutdown_function(array($objPage, "destroy")); 339 19 ?>
Note: See TracChangeset
for help on using the changeset viewer.