[19864] | 1 | <?php |
---|
| 2 | /* |
---|
| 3 | * This file is part of EC-CUBE |
---|
| 4 | * |
---|
| 5 | * Copyright(c) 2000-2010 LOCKON CO.,LTD. All Rights Reserved. |
---|
| 6 | * |
---|
| 7 | * http://www.lockon.co.jp/ |
---|
| 8 | * |
---|
| 9 | * This program is free software; you can redistribute it and/or |
---|
| 10 | * modify it under the terms of the GNU General Public License |
---|
| 11 | * as published by the Free Software Foundation; either version 2 |
---|
| 12 | * of the License, or (at your option) any later version. |
---|
| 13 | * |
---|
| 14 | * This program is distributed in the hope that it will be useful, |
---|
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 17 | * GNU General Public License for more details. |
---|
| 18 | * |
---|
| 19 | * You should have received a copy of the GNU General Public License |
---|
| 20 | * along with this program; if not, write to the Free Software |
---|
| 21 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
---|
| 22 | */ |
---|
| 23 | |
---|
| 24 | /** |
---|
| 25 | * 会員情報の登録・編集・検索ヘルパークラス. |
---|
| 26 | * |
---|
| 27 | * |
---|
| 28 | * @package Helper |
---|
| 29 | * @author Hirokazu Fukuda |
---|
| 30 | * @version $Id$ |
---|
| 31 | */ |
---|
| 32 | class SC_Helper_Customer { |
---|
| 33 | |
---|
| 34 | |
---|
| 35 | /** |
---|
| 36 | * 会員編集登録処理を行う. |
---|
| 37 | * |
---|
| 38 | * @param array $array パラメータの配列 |
---|
| 39 | * @param array $arrRegistColumn 登録するカラムの配列 |
---|
| 40 | * @return void |
---|
| 41 | */ |
---|
| 42 | function sfEditCustomerData($array, $arrRegistColumn) { |
---|
| 43 | $objQuery =& SC_Query::getSingletonInstance(); |
---|
| 44 | |
---|
| 45 | foreach ($arrRegistColumn as $data) { |
---|
| 46 | if ($data["column"] != "password") { |
---|
| 47 | if($array[ $data['column'] ] != "") { |
---|
| 48 | $arrRegist[ $data["column"] ] = $array[ $data["column"] ]; |
---|
| 49 | } else { |
---|
| 50 | $arrRegist[ $data['column'] ] = NULL; |
---|
| 51 | } |
---|
| 52 | } |
---|
| 53 | } |
---|
| 54 | if (strlen($array["year"]) > 0 && strlen($array["month"]) > 0 && strlen($array["day"]) > 0) { |
---|
| 55 | $arrRegist["birth"] = $array["year"] ."/". $array["month"] ."/". $array["day"] ." 00:00:00"; |
---|
| 56 | } else { |
---|
| 57 | $arrRegist["birth"] = NULL; |
---|
| 58 | } |
---|
| 59 | |
---|
| 60 | //-- パスワードの更新がある場合は暗号化。(更新がない場合はUPDATE文を構成しない) |
---|
| 61 | if ($array["password"] != DEFAULT_PASSWORD) $arrRegist["password"] = sha1($array["password"] . ":" . AUTH_MAGIC); |
---|
| 62 | $arrRegist["update_date"] = "NOW()"; |
---|
| 63 | |
---|
| 64 | //-- 編集登録実行 |
---|
| 65 | $objQuery->update("dtb_customer", $arrRegist, "customer_id = ? ", array($array['customer_id'])); |
---|
| 66 | } |
---|
| 67 | |
---|
| 68 | /** |
---|
| 69 | * 注文番号、利用ポイント、加算ポイントから最終ポイントを取得する. |
---|
| 70 | * |
---|
| 71 | * @param integer $order_id 注文番号 |
---|
| 72 | * @param integer $use_point 利用ポイント |
---|
| 73 | * @param integer $add_point 加算ポイント |
---|
| 74 | * @return array 最終ポイントの配列 |
---|
| 75 | */ |
---|
| 76 | function sfGetCustomerPoint($order_id, $use_point, $add_point) { |
---|
| 77 | $objQuery =& SC_Query::getSingletonInstance(); |
---|
| 78 | $arrRet = $objQuery->select("customer_id", "dtb_order", "order_id = ?", array($order_id)); |
---|
| 79 | $customer_id = $arrRet[0]['customer_id']; |
---|
| 80 | if ($customer_id != "" && $customer_id >= 1) { |
---|
| 81 | if (USE_POINT !== false) { |
---|
| 82 | $arrRet = $objQuery->select("point", "dtb_customer", "customer_id = ?", array($customer_id)); |
---|
| 83 | $point = $arrRet[0]['point']; |
---|
| 84 | $total_point = $arrRet[0]['point'] - $use_point + $add_point; |
---|
| 85 | } else { |
---|
| 86 | $total_point = 0; |
---|
| 87 | $point = 0; |
---|
| 88 | } |
---|
| 89 | } else { |
---|
| 90 | $total_point = ""; |
---|
| 91 | $point = ""; |
---|
| 92 | } |
---|
| 93 | return array($point, $total_point); |
---|
| 94 | } |
---|
| 95 | |
---|
[19881] | 96 | /** |
---|
| 97 | * emailアドレスから、登録済み会員や退会済み会員をチェックする |
---|
| 98 | * |
---|
| 99 | * @param string $email メールアドレス |
---|
| 100 | * @return integer 0:登録可能 1:登録済み 2:再登録制限期間内削除ユーザー |
---|
| 101 | */ |
---|
| 102 | function lfCheckRegisterUserFromEmail($email){ |
---|
| 103 | $return = 0; |
---|
| 104 | |
---|
| 105 | $objQuery =& SC_Query::getSingletonInstance(); |
---|
| 106 | $arrRet = $objQuery->select("email, update_date, del_flg" |
---|
| 107 | ,"dtb_customer" |
---|
| 108 | ,"email = ? OR email_mobile = ? ORDER BY del_flg" |
---|
| 109 | ,array($email, $email) |
---|
| 110 | ); |
---|
| 111 | |
---|
| 112 | if(count($arrRet) > 0) { |
---|
| 113 | if($arrRet[0]['del_flg'] != '1') { |
---|
| 114 | // 会員である場合 |
---|
| 115 | if (!isset($objErr->arrErr['email'])) $objErr->arrErr['email'] = ""; |
---|
| 116 | $return = 1; |
---|
| 117 | } else { |
---|
| 118 | // 退会した会員である場合 |
---|
| 119 | $leave_time = SC_Utils_Ex::sfDBDatetoTime($arrRet[0]['update_date']); |
---|
| 120 | $now_time = time(); |
---|
| 121 | $pass_time = $now_time - $leave_time; |
---|
| 122 | // 退会から何時間-経過しているか判定する。 |
---|
| 123 | $limit_time = ENTRY_LIMIT_HOUR * 3600; |
---|
| 124 | if($pass_time < $limit_time) { |
---|
| 125 | if (!isset($objErr->arrErr['email'])) $objErr->arrErr['email'] = ""; |
---|
| 126 | $return = 2; |
---|
| 127 | } |
---|
| 128 | } |
---|
| 129 | } |
---|
| 130 | return $return; |
---|
| 131 | } |
---|
| 132 | |
---|
| 133 | |
---|
| 134 | |
---|
| 135 | |
---|
[19864] | 136 | } |
---|