source: branches/version-2_12-dev/data/class/helper/SC_Helper_Payment.php @ 22796

Revision 22796, 4.1 KB checked in by h_yoshimoto, 11 years ago (diff)

#2236 2.12.3リリース以降の2.12-devへのコミット差し戻し

Line 
1<?php
2/*
3 * This file is part of EC-CUBE
4 *
5 * Copyright(c) 2000-2013 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 * @package Helper
28 * @author pineray
29 * @version $Id:$
30 */
31class SC_Helper_Payment
32{
33    /**
34     * 支払方法の情報を取得.
35     *
36     * @param integer $payment_id 支払方法ID
37     * @return array
38     */
39    public function get($payment_id) {
40        $objQuery =& SC_Query_Ex::getSingletonInstance();
41        $where = 'payment_id = ?';
42        $arrRet = $objQuery->select('*', 'dtb_payment', $where, array($payment_id));
43        return $arrRet[0];
44    }
45
46    /**
47     * 支払方法一覧の取得.
48     *
49     * @return array
50     */
51    public function getList() {
52        $objQuery =& SC_Query_Ex::getSingletonInstance();
53        $col = 'payment_id, payment_method, charge, rule_max, upper_rule, note, fix, charge_flg';
54        $where = 'del_flg = 0';
55        $table = 'dtb_payment';
56        $objQuery->setOrder('rank DESC');
57        $arrRet = $objQuery->select($col, $table, $where);
58        return $arrRet;
59    }
60
61    /**
62     * 支払方法の登録.
63     *
64     * @param array $sqlval
65     * @return void
66     */
67    public function save($sqlval) {
68        $payment_id = $sqlval['payment_id'];
69
70        $objQuery =& SC_Query_Ex::getSingletonInstance();
71        // 新規登録
72        if ($payment_id == '') {
73            // INSERTの実行
74            $sqlval['rank'] = $objQuery->max('rank', 'dtb_payment') + 1;
75            $sqlval['create_date'] = 'CURRENT_TIMESTAMP';
76            $sqlval['payment_id'] = $objQuery->nextVal('dtb_payment_payment_id');
77            $objQuery->insert('dtb_payment', $sqlval);
78        // 既存編集
79        } else {
80            unset($sqlval['creator_id']);
81            $where = 'payment_id = ?';
82            $objQuery->update('dtb_payment', $sqlval, $where, array($payment_id));
83        }
84    }
85
86    /**
87     * 支払方法の削除.
88     *
89     * @param integer $payment_id 支払方法ID
90     * @return void
91     */
92    public function delete($payment_id) {
93        $objDb = new SC_Helper_DB_Ex();
94        // ランク付きレコードの削除
95        $objDb->sfDeleteRankRecord('dtb_payment', 'payment_id', $payment_id);
96    }
97
98    /**
99     * 支払方法の表示順をひとつ上げる.
100     *
101     * @param integer $payment_id 支払方法ID
102     * @return void
103     */
104    public function rankUp($payment_id) {
105        $objDb = new SC_Helper_DB_Ex();
106        $objDb->sfRankUp('dtb_payment', 'payment_id', $payment_id);
107    }
108
109    /**
110     * 支払方法の表示順をひとつ下げる.
111     *
112     * @param integer $payment_id 支払方法ID
113     * @return void
114     */
115    public function rankDown($payment_id) {
116        $objDb = new SC_Helper_DB_Ex();
117        $objDb->sfRankDown('dtb_payment', 'payment_id', $payment_id);
118    }
119
120    /**
121     * 決済モジュールを使用するかどうか.
122     *
123     * dtb_payment.memo03 に値が入っている場合は決済モジュールと見なす.
124     *
125     * @param integer $payment_id 支払い方法ID
126     * @return boolean 決済モジュールを使用する支払い方法の場合 true
127     */
128    public static function useModule($payment_id) {
129        $objQuery =& SC_Query_Ex::getSingletonInstance();
130        $memo03 = $objQuery->get('memo03', 'dtb_payment', 'payment_id = ?', array($payment_id));
131        return !SC_Utils_Ex::isBlank($memo03);
132    }
133}
Note: See TracBrowser for help on using the repository browser.