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

Revision 22552, 4.7 KB checked in by pineray, 11 years ago (diff)

#2134 where句の誤りを訂正.

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     * @param boolean $has_deleted 削除された支払方法も含む場合 true; 初期値 false
38     * @return array
39     */
40    public function get($payment_id, $has_deleted = false) {
41        $objQuery =& SC_Query_Ex::getSingletonInstance();
42        $where = 'payment_id = ?';
43        if (!$has_deleted) {
44            $where .= ' AND del_flg = 0';
45        }
46        $arrRet = $objQuery->select('*', 'dtb_payment', $where, array($payment_id));
47        return $arrRet[0];
48    }
49
50    /**
51     * 支払方法一覧の取得.
52     *
53     * @param boolean $has_deleted 削除された支払方法も含む場合 true; 初期値 false
54     * @return array
55     */
56    public function getList($has_deleted = false) {
57        $objQuery =& SC_Query_Ex::getSingletonInstance();
58        $col = 'payment_id, payment_method, charge, rule_max, upper_rule, note, fix, charge_flg';
59        $where = '';
60        if (!$has_deleted) {
61            $where .= 'del_flg = 0';
62        }
63        $table = 'dtb_payment';
64        $objQuery->setOrder('rank DESC');
65        $arrRet = $objQuery->select($col, $table, $where);
66        return $arrRet;
67    }
68
69    /**
70     * 支払方法の登録.
71     *
72     * @param array $sqlval
73     * @return void
74     */
75    public function save($sqlval) {
76        $payment_id = $sqlval['payment_id'];
77
78        $objQuery =& SC_Query_Ex::getSingletonInstance();
79        // 新規登録
80        if ($payment_id == '') {
81            // INSERTの実行
82            $sqlval['rank'] = $objQuery->max('rank', 'dtb_payment') + 1;
83            $sqlval['create_date'] = 'CURRENT_TIMESTAMP';
84            $sqlval['payment_id'] = $objQuery->nextVal('dtb_payment_payment_id');
85            $objQuery->insert('dtb_payment', $sqlval);
86        // 既存編集
87        } else {
88            unset($sqlval['creator_id']);
89            $where = 'payment_id = ?';
90            $objQuery->update('dtb_payment', $sqlval, $where, array($payment_id));
91        }
92    }
93
94    /**
95     * 支払方法の削除.
96     *
97     * @param integer $payment_id 支払方法ID
98     * @return void
99     */
100    public function delete($payment_id) {
101        $objDb = new SC_Helper_DB_Ex();
102        // ランク付きレコードの削除
103        $objDb->sfDeleteRankRecord('dtb_payment', 'payment_id', $payment_id);
104    }
105
106    /**
107     * 支払方法の表示順をひとつ上げる.
108     *
109     * @param integer $payment_id 支払方法ID
110     * @return void
111     */
112    public function rankUp($payment_id) {
113        $objDb = new SC_Helper_DB_Ex();
114        $objDb->sfRankUp('dtb_payment', 'payment_id', $payment_id);
115    }
116
117    /**
118     * 支払方法の表示順をひとつ下げる.
119     *
120     * @param integer $payment_id 支払方法ID
121     * @return void
122     */
123    public function rankDown($payment_id) {
124        $objDb = new SC_Helper_DB_Ex();
125        $objDb->sfRankDown('dtb_payment', 'payment_id', $payment_id);
126    }
127
128    /**
129     * 決済モジュールを使用するかどうか.
130     *
131     * dtb_payment.memo03 に値が入っている場合は決済モジュールと見なす.
132     *
133     * @param integer $payment_id 支払い方法ID
134     * @return boolean 決済モジュールを使用する支払い方法の場合 true
135     */
136    public static function useModule($payment_id) {
137        $objQuery =& SC_Query_Ex::getSingletonInstance();
138        $memo03 = $objQuery->get('memo03', 'dtb_payment', 'payment_id = ?', array($payment_id));
139        return !SC_Utils_Ex::isBlank($memo03);
140    }
141
142    /**
143     * 支払方法IDをキー, 名前を値とする配列を取得.
144     *
145     * @return array
146     */
147    public static function getIDValueList() {
148        return SC_Helper_DB_Ex::sfGetIDValueList('dtb_payment', 'payment_id', 'payment_method');
149    }
150}
Note: See TracBrowser for help on using the repository browser.