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

Revision 22566, 4.8 KB checked in by pineray, 11 years ago (diff)

#2136 #2134 get した値をそのまま save できるように調整.

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        $objQuery =& SC_Query_Ex::getSingletonInstance();
77
78        $payment_id = $sqlval['payment_id'];
79        $sqlval['update_date'] = 'CURRENT_TIMESTAMP';
80        // 新規登録
81        if ($payment_id == '') {
82            // INSERTの実行
83            $sqlval['rank'] = $objQuery->max('rank', 'dtb_payment') + 1;
84            $sqlval['create_date'] = 'CURRENT_TIMESTAMP';
85            $sqlval['payment_id'] = $objQuery->nextVal('dtb_payment_payment_id');
86            $objQuery->insert('dtb_payment', $sqlval);
87        // 既存編集
88        } else {
89            unset($sqlval['creator_id']);
90            unset($sqlval['create_date']);
91            $where = 'payment_id = ?';
92            $objQuery->update('dtb_payment', $sqlval, $where, array($payment_id));
93        }
94    }
95
96    /**
97     * 支払方法の削除.
98     *
99     * @param integer $payment_id 支払方法ID
100     * @return void
101     */
102    public function delete($payment_id) {
103        $objDb = new SC_Helper_DB_Ex();
104        // ランク付きレコードの削除
105        $objDb->sfDeleteRankRecord('dtb_payment', 'payment_id', $payment_id);
106    }
107
108    /**
109     * 支払方法の表示順をひとつ上げる.
110     *
111     * @param integer $payment_id 支払方法ID
112     * @return void
113     */
114    public function rankUp($payment_id) {
115        $objDb = new SC_Helper_DB_Ex();
116        $objDb->sfRankUp('dtb_payment', 'payment_id', $payment_id);
117    }
118
119    /**
120     * 支払方法の表示順をひとつ下げる.
121     *
122     * @param integer $payment_id 支払方法ID
123     * @return void
124     */
125    public function rankDown($payment_id) {
126        $objDb = new SC_Helper_DB_Ex();
127        $objDb->sfRankDown('dtb_payment', 'payment_id', $payment_id);
128    }
129
130    /**
131     * 決済モジュールを使用するかどうか.
132     *
133     * dtb_payment.memo03 に値が入っている場合は決済モジュールと見なす.
134     *
135     * @param integer $payment_id 支払い方法ID
136     * @return boolean 決済モジュールを使用する支払い方法の場合 true
137     */
138    public static function useModule($payment_id) {
139        $objQuery =& SC_Query_Ex::getSingletonInstance();
140        $memo03 = $objQuery->get('memo03', 'dtb_payment', 'payment_id = ?', array($payment_id));
141        return !SC_Utils_Ex::isBlank($memo03);
142    }
143
144    /**
145     * 支払方法IDをキー, 名前を値とする配列を取得.
146     *
147     * @return array
148     */
149    public static function getIDValueList() {
150        return SC_Helper_DB_Ex::sfGetIDValueList('dtb_payment', 'payment_id', 'payment_method');
151    }
152}
Note: See TracBrowser for help on using the repository browser.