[19661] | 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 | // {{{ requires |
---|
[19805] | 25 | require_once(CLASS_EX_REALDIR . "SC_Plugin_Ex.php"); |
---|
[19661] | 26 | // }}} |
---|
| 27 | |
---|
| 28 | class SC_Plugin_bingo extends SC_Plugin_Ex { |
---|
| 29 | var $plugin_name = null; |
---|
| 30 | |
---|
| 31 | // $X回に1回が当たり |
---|
| 32 | var $X = 1; |
---|
| 33 | |
---|
| 34 | function SC_Plugin_bingo() { |
---|
| 35 | $this->plugin_name = 'bingo'; |
---|
| 36 | |
---|
| 37 | // $X回に1回が当たり |
---|
| 38 | // ここの値を変更して下さい。 |
---|
| 39 | $this->X = 1; |
---|
| 40 | } |
---|
| 41 | |
---|
[20032] | 42 | function isEnable($class_name) { |
---|
| 43 | // parent::isEnable($class_name); |
---|
[19661] | 44 | |
---|
| 45 | $arrEnableClass = array( |
---|
| 46 | 'LC_Page_Shopping_Confirm_Ex', |
---|
| 47 | 'LC_Page_Shopping_Complete_Ex', |
---|
| 48 | ); |
---|
| 49 | |
---|
| 50 | return in_array($class_name, $arrEnableClass); |
---|
| 51 | } |
---|
| 52 | |
---|
| 53 | function preProcess(&$objPage) { |
---|
| 54 | // parent::preProcess($objPage); |
---|
| 55 | |
---|
| 56 | $class_name = get_class($objPage); |
---|
| 57 | switch ($class_name) { |
---|
| 58 | case 'LC_Page_Shopping_Confirm_Ex': |
---|
| 59 | if ($_POST['mode'] == 'confirm') { |
---|
| 60 | $this->lfDrawing(); |
---|
| 61 | } |
---|
| 62 | break; |
---|
| 63 | } |
---|
| 64 | } |
---|
| 65 | |
---|
| 66 | function process(&$objPage) { |
---|
| 67 | // parent::process($objPage); |
---|
| 68 | |
---|
| 69 | $class_name = get_class($objPage); |
---|
| 70 | switch ($class_name) { |
---|
| 71 | case 'LC_Page_Shopping_Confirm_Ex': |
---|
| 72 | break; |
---|
| 73 | case 'LC_Page_Shopping_Complete_Ex': |
---|
| 74 | $is_bingo = $_SESSION['plugin_bingo']['is_bingo']; |
---|
| 75 | if ($is_bingo) { |
---|
| 76 | if (SC_Utils_Ex::sfIsMobileSite()) { |
---|
[19805] | 77 | $objPage->tpl_mainpage = DATA_REALDIR . 'plugin/' . $this->plugin_name . '/templates/mobile/shopping/complete.tpl'; |
---|
[19661] | 78 | } else { |
---|
[19805] | 79 | $objPage->tpl_mainpage = DATA_REALDIR . 'plugin/' . $this->plugin_name . '/templates/shopping/complete.tpl'; |
---|
[19661] | 80 | } |
---|
| 81 | } |
---|
| 82 | break; |
---|
| 83 | } |
---|
| 84 | } |
---|
| 85 | |
---|
| 86 | function lfDrawing() { |
---|
| 87 | // is_bingoを初期化 |
---|
| 88 | $_SESSION['plugin_bingo'] = array('is_bingo'=>false); |
---|
| 89 | |
---|
| 90 | $rand = mt_rand(1, $this->X); |
---|
| 91 | |
---|
| 92 | // 当たり! |
---|
| 93 | if ($rand === 1) { |
---|
| 94 | $objDb = new SC_Helper_DB_Ex(); |
---|
| 95 | $objCartSess = new SC_CartSession(); |
---|
| 96 | $objCustomer = new SC_Customer(); |
---|
| 97 | $objSiteSess = new SC_SiteSession(); |
---|
| 98 | |
---|
| 99 | $tmpData = $objDb->sfGetOrderTemp($uniqid); |
---|
| 100 | |
---|
| 101 | // 当たりなので、使用ポイントを未使用にする。 |
---|
| 102 | $tmpData['use_point'] = 0; |
---|
| 103 | |
---|
| 104 | $cartKey = $_SESSION['cartKey']; |
---|
| 105 | $results = $objCartSess->calculate($cartKey, $objCustomer, $tmpData['use_point'], $tmpData['deliv_pref'], $tmpData['payment_id'], $tmpData['charge']); |
---|
| 106 | |
---|
| 107 | // 合計を0にするために合計額を値引にセット |
---|
| 108 | $tmpData['discount'] = $results['total']; |
---|
| 109 | |
---|
| 110 | // メモに「当たり」と記載する |
---|
| 111 | $tmpData['note'] = '当たり'; |
---|
| 112 | |
---|
| 113 | $uniqid = $objSiteSess->getUniqId(); |
---|
| 114 | $objDb->sfRegistTempOrder($uniqid, $tmpData); |
---|
| 115 | |
---|
| 116 | // is_bingoセット |
---|
| 117 | $_SESSION['plugin_bingo'] = array('is_bingo'=>true); |
---|
| 118 | } |
---|
| 119 | } |
---|
| 120 | } |
---|
| 121 | |
---|
| 122 | ?> |
---|