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

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