source: branches/feature-module-paygent/data/downloads/module/mdl_paygent/mdl_paygent.php @ 15180

Revision 15180, 9.0 KB checked in by naka, 14 years ago (diff)
Line 
1<?php
2/**
3 *
4 * @copyright   2000-2007 LOCKON CO.,LTD. All Rights Reserved.
5 * @version CVS: $Id: mdl_epsilon.php 1.2 2006-12-04 06:08:28Z kakinaka $
6 * @link        http://www.lockon.co.jp/
7 *
8 */
9require_once(MODULE_PATH . "mdl_paygent/mdl_paygent.inc");
10
11$arrPayment = array(
12    1 => '¥¯¥ì¥¸¥Ã¥È',
13    2 => '¥³¥ó¥Ó¥Ë',
14    3 => 'ATM·èºÑ',
15    4 => '¶ä¹Ô¥Í¥Ã¥È'
16);
17
18$arrCredit = array(
19    1 => 'VISA, MASTER, Diners',
20    2 => 'JCB, AMEX'
21);
22
23//¥Ú¡¼¥¸´ÉÍý¥¯¥é¥¹
24class LC_Page {
25    //¥³¥ó¥¹¥È¥é¥¯¥¿
26    function LC_Page() {
27        //¥á¥¤¥ó¥Æ¥ó¥×¥ì¡¼¥È¤Î»ØÄê
28        $this->tpl_mainpage = MODULE_PATH . 'mdl_paygent/mdl_paygent.tpl';
29        $this->tpl_subtitle = '¥Ú¥¤¥¸¥§¥ó¥È·èºÑ¥â¥¸¥å¡¼¥ë';
30        global $arrPayment;
31        $this->arrPayment = $arrPayment;
32        global $arrCredit;
33        $this->arrCredit = $arrCredit;
34        global $arrConvenience;
35        $this->arrConvenience = $arrConvenience;
36    }
37}
38$objPage = new LC_Page();
39$objView = new SC_AdminView();
40$objQuery = new SC_Query();
41
42// ¥³¥ó¥Ó¥ËÆþ¶â¥Á¥§¥Ã¥¯
43lfEpsilonCheck();
44
45// ǧ¾Ú³Îǧ
46$objSess = new SC_Session();
47sfIsSuccess($objSess);
48
49// ¥Ñ¥é¥á¡¼¥¿´ÉÍý¥¯¥é¥¹
50$objFormParam = new SC_FormParam();
51$objFormParam = lfInitParam($objFormParam);
52// POSTÃͤμèÆÀ
53$objFormParam->setParam($_POST);
54
55// ÈÆÍѹàÌܤòÄɲÃ(ɬ¿Ü¡ª¡ª)
56sfAlterMemo();
57
58switch($_POST['mode']) {
59case 'edit':
60    // ÆþÎÏ¥¨¥é¡¼È½Äê
61    $objPage->arrErr = lfCheckError();
62
63    // ¥¨¥é¡¼¤Ê¤·¤Î¾ì¹ç¤Ë¤Ï¥Ç¡¼¥¿¤ò¹¹¿·
64    if(count($objPage->arrErr) == 0) {
65        // ¥Ç¡¼¥¿¹¹¿·
66        lfUpdPaymentDB(MDL_PAYGENT_ID);
67       
68        // javascript¼Â¹Ô
69        $objPage->tpl_onload = 'alert("ÅÐÏ¿´°Î»¤·¤Þ¤·¤¿¡£\n´ðËܾðÊó¡ä»ÙʧÊýË¡ÀßÄê¤è¤ê¾ÜºÙÀßÄê¤ò¤·¤Æ¤¯¤À¤µ¤¤¡£"); window.close();';
70    }
71    break;
72case 'module_del':
73    // ÈÆÍѹàÌܤθºß¥Á¥§¥Ã¥¯
74    if(sfColumnExists("dtb_payment", "memo01")){
75        // ¥Ç¡¼¥¿¤Îºï½ü¥Õ¥é¥°¤ò¤¿¤Æ¤ë
76        $objQuery->query("UPDATE dtb_payment SET del_flg = 1 WHERE module_id = ?", array(MDL_EPSILON_ID));
77    }
78    break;
79default:
80    // ¥Ç¡¼¥¿¤Î¥í¡¼¥É
81    lfLoadData();   
82    break;
83}
84
85$objPage->arrForm = $objFormParam->getFormParamList();
86
87$objView->assignobj($objPage);                  //ÊÑ¿ô¤ò¥Æ¥ó¥×¥ì¡¼¥È¤Ë¥¢¥µ¥¤¥ó¤¹¤ë
88$objView->display($objPage->tpl_mainpage);      //¥Æ¥ó¥×¥ì¡¼¥È¤Î½ÐÎÏ
89//-------------------------------------------------------------------------------------------------------
90/* ¥Ñ¥é¥á¡¼¥¿¾ðÊó¤Î½é´ü²½ */
91function lfInitParam($objFormParam) {
92    $objFormParam->addParam("¥Þ¡¼¥Á¥ã¥ó¥ÈID", "merchant_id", STEXT_LEN, "KVa", array("EXIST_CHECK", "MAX_LENGTH_CHECK"));
93    $objFormParam->addParam("ÀܳID", "connect_id", STEXT_LEN, "KVa", array("EXIST_CHECK", "MAX_LENGTH_CHECK"));
94    $objFormParam->addParam("Àܳ¥Ñ¥¹¥ï¡¼¥É", "connect_password", STEXT_LEN, "KVa", array("EXIST_CHECK", "MAX_LENGTH_CHECK")); 
95    $objFormParam->addParam("»Ùʧ´ü¸ÂÆü", "conveni_limit_date", 2, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
96    $objFormParam->addParam("»Ùʧ´ü¸ÂÆü", "atm_limit_date", 2, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
97    $objFormParam->addParam("»ÙʧÀâÌÀʸ", "payment_detail", STEXT_LEN, "KVa", array("MAX_LENGTH_CHECK", "KANA_CHECK"), "¥ª¥ó¥é¥¤¥ó¥·¥ç¥Ã¥Ô¥ó¥°");   
98    $objFormParam->addParam("ÍøÍÑ·èºÑ", "payment", "", "", array("EXIST_CHECK"));
99    return $objFormParam;
100}
101   
102// ¥¨¥é¡¼¥Á¥§¥Ã¥¯¤ò¹Ô¤¦
103function lfCheckError(){
104    global $objFormParam;
105    $arrErr = $objFormParam->checkError();
106    if($_POST['conveni_limit_date'] != "" && !($_POST['conveni_limit_date'] >= 1 &&  $_POST['conveni_limit_date'] <= 60)) {
107            $arrErr['conveni_limit_date'] = "¢¨ »Ùʧ´ü¸ÂÆü¤Ï¡¢1¡Á60Æü¤Þ¤Ç¤Î´Ö¤ÇÀßÄꤷ¤Æ¤¯¤À¤µ¤¤¡£<br>";
108    }
109    if($_POST['atm_limit_date'] != "" && !($_POST['atm_limit_date'] >= 0 &&  $_POST['atm_limit_date'] <= 60)) {
110            $arrErr['atm_limit_date'] = "¢¨ »Ùʧ´ü¸ÂÆü¤Ï¡¢0¡Á60Æü¤Þ¤Ç¤Î´Ö¤ÇÀßÄꤷ¤Æ¤¯¤À¤µ¤¤¡£<br>";
111    }
112    return $arrErr;
113}
114
115// ÅÐÏ¿¥Ç¡¼¥¿¤òÆɤ߹þ¤à
116function lfLoadData(){
117    global $objFormParam;
118   
119    //¥Ç¡¼¥¿¤ò¼èÆÀ
120    $arrRet = sfGetPaymentDB(MDL_PAYGENT_ID, "AND del_flg = '0'");
121    $objFormParam->setParam($arrRet[0]);
122   
123   
124    // ²èÌÌɽ¼¨ÍѤ˥ǡ¼¥¿¤òÊÑ´¹
125    $arrDisp = array();
126   
127    foreach($arrRet as $key => $val){
128        // ÍøÍÑ·èºÑ¤òɽ¼¨ÍѤËÊÑ´¹
129        $arrDisp["payment"][$key] = $val["payment"];
130       
131        switch($val['payment']) {
132        // ¥¯¥ì¥¸¥Ã¥È
133        case '1':
134            break;
135        // ¥³¥ó¥Ó¥Ë
136        case '2':
137            $arrParam = unserialize($val['other_param']);
138            $arrDisp['conveni_limit_date'] = $arrParam['payment_limit_date'];
139            break;
140        // ATM·èºÑ
141        case '3':
142            $arrParam = unserialize($val['other_param']);
143            $arrDisp['payment_detail'] = $arrParam['payment_detail'];
144            $arrDisp['atm_limit_date'] = $arrParam['payment_limit_date'];
145            break;
146        // ¥Í¥Ã¥È¥Ð¥ó¥¯
147        case '4':
148            break;                 
149        }
150    }   
151   
152    $objFormParam->setParam($arrDisp);
153}
154
155// ¥Ç¡¼¥¿¤Î¹¹¿·½èÍý
156function lfUpdPaymentDB($module_id){
157    global $objQuery;
158    global $objSess;
159       
160    // ´ØÏ¢¤¹¤ë»Ùʧ¤¤ÊýË¡¤Îdel_flg¤òºï½ü¤Ë¤·¤Æ¤ª¤¯
161    $del_sql = "UPDATE dtb_payment SET del_flg = 1 WHERE module_id = ? ";
162    $arrDel = array($module_id);
163    $objQuery->query($del_sql, $arrDel);
164   
165    // ¥Ç¡¼¥¿ÅÐÏ¿
166    foreach($_POST["payment"] as $key => $val){
167        // ¥é¥ó¥¯¤ÎºÇÂçÃͤò¼èÆÀ¤¹¤ë
168        $max_rank = $objQuery->getone("SELECT max(rank) FROM dtb_payment");
169
170        // »ÙʧÊýË¡¥Ç¡¼¥¿¤ò¼èÆÀ         
171        $arrPaymentData = sfGetPaymentDB(MDL_PAYGENT_ID, "AND memo03 = ?", array($val));
172       
173        // ¥¯¥ì¥¸¥Ã¥È¤Ë¥Á¥§¥Ã¥¯¤¬Æþ¤Ã¤Æ¤¤¤ì¤Ð¥¯¥ì¥¸¥Ã¥È¤òÅÐÏ¿¤¹¤ë
174        if($val == 1){
175            $arrData = array(           
176                "payment_method" => "PAYGENT¥¯¥ì¥¸¥Ã¥È"
177                ,"fix" => 3
178                ,"creator_id" => $objSess->member_id
179                ,"create_date" => "now()"
180                ,"update_date" => "now()"
181                ,"upper_rule" => 500000
182                ,"module_id" => $module_id
183                ,"module_path" => MODULE_PATH . "mdl_paygent/paygent_credit.php"
184                ,"memo01" => $_POST["merchant_id"]
185                ,"memo02" => $_POST["connect_id"]
186                ,"memo03" => $val
187                ,"memo04" => $_POST["connect_password"]
188                ,"memo05" => ""
189                ,"del_flg" => "0"
190                ,"charge_flg" => "2"
191                ,"upper_rule_max" => CHARGE_MAX
192               
193            );
194        }
195       
196        // ¥³¥ó¥Ó¥Ë¤Ë¥Á¥§¥Ã¥¯¤¬Æþ¤Ã¤Æ¤¤¤ì¤Ð¥³¥ó¥Ó¥Ë¤òÅÐÏ¿¤¹¤ë
197        if($val == 2){
198            $arrParam = array();
199            $arrParam['payment_limit_date'] = $_POST['conveni_limit_date'];
200           
201            $arrData = array(
202                "payment_method" => "PAYGENT¥³¥ó¥Ó¥Ë"
203                ,"fix" => 3
204                ,"creator_id" => $objSess->member_id
205                ,"create_date" => "now()"
206                ,"update_date" => "now()"
207                ,"upper_rule" => $upper_rule
208                ,"module_id" => $module_id
209                ,"module_path" => MODULE_PATH . "mdl_paygent/paygent_conveni.php"
210                ,"memo01" => $_POST["merchant_id"]
211                ,"memo02" => $_POST["connect_id"]
212                ,"memo03" => $val
213                ,"memo04" => $_POST["connect_password"]
214                ,"memo05" => serialize($arrParam)
215                ,"del_flg" => "0"
216                ,"charge_flg" => "1"
217                ,"upper_rule_max" => $upper_rule_max
218            );
219        }
220       
221        // ATM·èºÑ¤Ë¥Á¥§¥Ã¥¯¤¬Æþ¤Ã¤Æ¤¤¤ì¤ÐATM·èºÑ¤òÅÐÏ¿¤¹¤ë
222        if($val == 3){
223            $arrParam = array();
224            $arrParam['payment_detail'] = $_POST['payment_detail'];
225            $arrParam['payment_limit_date'] = $_POST['atm_limit_date'];
226           
227            $arrData = array(
228                "payment_method" => "PAYGENTATM·èºÑ"
229                ,"fix" => 3
230                ,"creator_id" => $objSess->member_id
231                ,"create_date" => "now()"
232                ,"update_date" => "now()"
233                ,"upper_rule" => $upper_rule
234                ,"module_id" => $module_id
235                ,"module_path" => MODULE_PATH . "mdl_paygent/paygent_atm.php"
236                ,"memo01" => $_POST["merchant_id"]
237                ,"memo02" => $_POST["connect_id"]
238                ,"memo03" => $val
239                ,"memo04" => $_POST["connect_password"]
240                ,"memo05" => serialize($arrParam)
241                ,"del_flg" => "0"
242                ,"charge_flg" => "1"
243                ,"upper_rule_max" => $upper_rule_max
244            );
245        }
246       
247        // ¶ä¹ÔNET¤Ë¥Á¥§¥Ã¥¯¤¬Æþ¤Ã¤Æ¤¤¤ì¤ÐATM·èºÑ¤òÅÐÏ¿¤¹¤ë
248        if($val == 4){
249            $arrData = array(
250                "payment_method" => "PAYGENT¶ä¹Ô¥Í¥Ã¥È"
251                ,"fix" => 3
252                ,"creator_id" => $objSess->member_id
253                ,"create_date" => "now()"
254                ,"update_date" => "now()"
255                ,"upper_rule" => $upper_rule
256                ,"module_id" => $module_id
257                ,"module_path" => MODULE_PATH . "mdl_paygent/paygent_bank.php"
258                ,"memo01" => $_POST["merchant_id"]
259                ,"memo02" => $_POST["connect_id"]
260                ,"memo03" => $val
261                ,"memo04" => $_POST["connect_password"]
262                ,"memo05" => ""
263                ,"del_flg" => "0"
264                ,"charge_flg" => "1"
265                ,"upper_rule_max" => $upper_rule_max
266            );
267        }
268       
269       
270        // ¥Ç¡¼¥¿¤¬Â¸ºß¤·¤Æ¤¤¤ì¤ÐUPDATE¡¢Ìµ¤±¤ì¤ÐINSERT
271        if(count($arrPaymentData) > 0){
272            $objQuery->update("dtb_payment", $arrData, " module_id = '" . $module_id . "' AND memo03 = '" . $val ."'");
273        }else{
274            $arrData["rank"] = $max_rank + 1;
275            $objQuery->insert("dtb_payment", $arrData);
276        }
277    }
278}
279
280// ¥³¥ó¥Ó¥ËÆþ¶â³Îǧ½èÍý
281function lfEpsilonCheck(){
282    global $objQuery;
283   
284    // trans_code ¤ò»ØÄꤵ¤ì¤Æ¤¤¤Æ³î¤Ä¡¢Æþ¶âºÑ¤ß¤Î¾ì¹ç
285    if($_POST["trans_code"] != "" and $_POST["paid"] == 1 and $_POST["order_number"] != ""){
286        // ¥¹¥Æ¡¼¥¿¥¹¤òÆþ¶âºÑ¤ß¤ËÊѹ¹¤¹¤ë
287        $sql = "UPDATE dtb_order SET status = 6, update_date = now() WHERE order_id = ? AND memo04 = ? ";
288        $objQuery->query($sql, array($_POST["order_number"], $_POST["trans_code"]));
289       
290        // POST¤ÎÆâÍƤòÁ´¤Æ¥í¥°Êݸ
291        $log_path = DATA_PATH . "logs/epsilon.log";
292        gfPrintLog("epsilon conveni start---------------------------------------------------------", $log_path);
293        foreach($_POST as $key => $val){
294            gfPrintLog( "\t" . $key . " => " . $val, $log_path);
295        }
296        gfPrintLog("epsilon conveni end-----------------------------------------------------------", $log_path);
297       
298        //±þÅú·ë²Ì¤òɽ¼¨
299        echo "1";
300    }
301}
302
303?>
Note: See TracBrowser for help on using the repository browser.