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

Revision 15283, 11.5 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        'asp_payment_term' => 7,
102    );
103    $objFormParam->addParam("¥Þ¡¼¥Á¥ã¥ó¥ÈID", "merchant_id", STEXT_LEN, "KVa", array("EXIST_CHECK", "MAX_LENGTH_CHECK"));
104    $objFormParam->addParam("ÀܳID", "connect_id", STEXT_LEN, "KVa", array("EXIST_CHECK", "MAX_LENGTH_CHECK"));
105    $objFormParam->addParam("Àܳ¥Ñ¥¹¥ï¡¼¥É", "connect_password", STEXT_LEN, "KVa", array("EXIST_CHECK", "MAX_LENGTH_CHECK"));
106    $objFormParam->addParam("»Ùʧ´ü¸ÂÆü", "conveni_limit_date", 2, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"), $arrDefault['conveni_limit_date']);
107    $objFormParam->addParam("»Ùʧ´ü¸ÂÆü", "atm_limit_date", 2, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"), $arrDefault['atm_limit_date']);
108    $objFormParam->addParam("ɽ¼¨Å¹ÊÞ̾(¥«¥Ê)", "payment_detail", 12, "KVa", array("MAX_LENGTH_CHECK", "KANA_CHECK"), $arrDefault['payment_detail']);
109    $objFormParam->addParam("»Ùʧ´ü¸ÂÆü", "asp_payment_term", 2, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"), $arrDefault['asp_payment_term']);
110    $objFormParam->addParam("ɽ¼¨Å¹ÊÞ̾(Á´³Ñ)", "claim_kanji", 12, "KVa", array("MAX_LENGTH_CHECK"), $arrDefault['claim_kanji']);
111    $objFormParam->addParam("ɽ¼¨Å¹ÊÞ̾(¥«¥Ê)", "claim_kana", 12, "KVa", array("MAX_LENGTH_CHECK", "KANA_CHECK"), $arrDefault['claim_kana']);
112    $objFormParam->addParam("ÍøÍÑ·èºÑ", "payment", "", "", array("EXIST_CHECK"));
113    $objFormParam->addParam("·èºÑ¥Ú¡¼¥¸ÍÑ¥³¥Ô¡¼¥é¥¤¥È(Ⱦ³Ñ±Ñ¿ô)", "copy_right", 64, "KVa", array("MAX_LENGTH_CHECK"));
114    $objFormParam->addParam("·èºÑ¥Ú¡¼¥¸ÍÑÀâÌÀʸ(Á´³Ñ)", "free_memo", 128, "KVa", array("MAX_LENGTH_CHECK"));   
115    return $objFormParam;
116}
117   
118// ¥¨¥é¡¼¥Á¥§¥Ã¥¯¤ò¹Ô¤¦
119function lfCheckError(){
120    global $objFormParam;
121    $arrErr = $objFormParam->checkError();
122       
123    if($_POST['conveni_limit_date'] != "" && !($_POST['conveni_limit_date'] >= 1 &&  $_POST['conveni_limit_date'] <= 60)) {
124            $arrErr['conveni_limit_date'] = "¢¨ »Ùʧ´ü¸ÂÆü¤Ï¡¢1¡Á60Æü¤Þ¤Ç¤Î´Ö¤ÇÀßÄꤷ¤Æ¤¯¤À¤µ¤¤¡£<br>";
125    }
126    if($_POST['atm_limit_date'] != "" && !($_POST['atm_limit_date'] >= 0 &&  $_POST['atm_limit_date'] <= 60)) {
127            $arrErr['atm_limit_date'] = "¢¨ »Ùʧ´ü¸ÂÆü¤Ï¡¢0¡Á60Æü¤Þ¤Ç¤Î´Ö¤ÇÀßÄꤷ¤Æ¤¯¤À¤µ¤¤¡£<br>";
128    }
129    if(isset($_POST['payment_detail']) && $_POST['payment_detail'] == '') {
130            $arrErr['payment_detail'] = "¢¨ »ÙʧÀâÌÀʸ¡Ê¥«¥Ê¡Ë¤òÆþÎϤ·¤Æ¤¯¤À¤µ¤¤¡£<br>";
131    }
132    if(isset($_POST['claim_kanji']) && $_POST['claim_kanji'] == '') {
133            $arrErr['claim_kanji'] = "¢¨ »ÙʧÀâÌÀʸ¡Ê´Á»ú¡Ë¤òÆþÎϤ·¤Æ¤¯¤À¤µ¤¤¡£<br>";
134    }
135    if(isset($_POST['claim_kana']) && $_POST['claim_kana'] == '') {
136            $arrErr['claim_kana'] = "¢¨ »ÙʧÀâÌÀʸ¡Ê¥«¥Ê¡Ë¤òÆþÎϤ·¤Æ¤¯¤À¤µ¤¤¡£<br>";
137    }
138   
139   
140   
141    /** ¶¦ÄÌÅÅʸ **/   
142    // ¥Þ¡¼¥Á¥ã¥ó¥ÈID
143    $arrParam['merchant_id'] = $objFormParam->getValue('merchant_id');
144    // ÀܳID
145    $arrParam['connect_id'] = $objFormParam->getValue('connect_id');
146    // Àܳ¥Ñ¥¹¥ï¡¼¥É
147    $arrParam['connect_password'] = $objFormParam->getValue('connect_password');
148
149    // Àܳ¥Æ¥¹¥È¤ò¼Â¹Ô¤¹¤ë¡£
150    if(!sfPaygentTest($arrParam)) {
151        $arrErr['err'] = "¢¨ Àܳ»î¸³¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£";
152    }   
153   
154    return $arrErr;
155}
156
157// ÅÐÏ¿¥Ç¡¼¥¿¤òÆɤ߹þ¤à
158function lfLoadData(){
159    global $objFormParam;
160   
161    //¥Ç¡¼¥¿¤ò¼èÆÀ
162    $arrRet = sfGetPaymentDB(MDL_PAYGENT_ID, "AND del_flg = '0'");
163    $objFormParam->setParam($arrRet[0]);
164   
165   
166    // ²èÌÌɽ¼¨ÍѤ˥ǡ¼¥¿¤òÊÑ´¹
167    $arrDisp = array();
168   
169    foreach($arrRet as $key => $val){
170        // ÍøÍÑ·èºÑ¤òɽ¼¨ÍѤËÊÑ´¹
171        $arrDisp["payment"][$key] = $val["payment"];
172       
173        switch($val['payment']) {
174        // ¥¯¥ì¥¸¥Ã¥È
175        case '1':
176            break;
177        // ¥³¥ó¥Ó¥Ë
178        case '2':
179            $arrParam = unserialize($val['other_param']);
180            $arrDisp['conveni_limit_date'] = $arrParam['payment_limit_date'];
181            break;
182        // ATM·èºÑ
183        case '3':
184            $arrParam = unserialize($val['other_param']);
185            $arrDisp['payment_detail'] = $arrParam['payment_detail'];
186            $arrDisp['atm_limit_date'] = $arrParam['payment_limit_date'];
187            break;
188        // ¥Í¥Ã¥È¥Ð¥ó¥¯
189        case '4':
190            $arrParam = unserialize($val['other_param']);
191            $arrDisp['claim_kana'] = $arrParam['claim_kana'];
192            $arrDisp['claim_kanji'] = $arrParam['claim_kanji'];
193            $arrDisp['asp_payment_term'] = $arrParam['asp_payment_term'];
194            $arrDisp['copy_right'] = $arrParam['copy_right'];
195            $arrDisp['free_memo'] = $arrParam['free_memo'];
196            break;                 
197        }
198    }   
199   
200    $objFormParam->setParam($arrDisp);
201}
202
203// ¥Ç¡¼¥¿¤Î¹¹¿·½èÍý
204function lfUpdPaymentDB($module_id){
205    global $objQuery;
206    global $objSess;
207       
208    // ´ØÏ¢¤¹¤ë»Ùʧ¤¤ÊýË¡¤Îdel_flg¤òºï½ü¤Ë¤·¤Æ¤ª¤¯
209    $del_sql = "UPDATE dtb_payment SET del_flg = 1 WHERE module_id = ? ";
210    $arrDel = array($module_id);
211    $objQuery->query($del_sql, $arrDel);
212   
213    // ¥Ç¡¼¥¿ÅÐÏ¿
214    foreach($_POST["payment"] as $key => $val){
215        // ¥é¥ó¥¯¤ÎºÇÂçÃͤò¼èÆÀ¤¹¤ë
216        $max_rank = $objQuery->getone("SELECT max(rank) FROM dtb_payment");
217
218        // »ÙʧÊýË¡¥Ç¡¼¥¿¤ò¼èÆÀ         
219        $arrPaymentData = sfGetPaymentDB(MDL_PAYGENT_ID, "AND memo03 = ?", array($val));
220       
221        // ¥¯¥ì¥¸¥Ã¥È¤Ë¥Á¥§¥Ã¥¯¤¬Æþ¤Ã¤Æ¤¤¤ì¤Ð¥¯¥ì¥¸¥Ã¥È¤òÅÐÏ¿¤¹¤ë
222        if($val == 1){
223            $arrData = array(           
224                "payment_method" => "PAYGENT¥¯¥ì¥¸¥Ã¥È"
225                ,"fix" => 3
226                ,"creator_id" => $objSess->member_id
227                ,"create_date" => "now()"
228                ,"update_date" => "now()"
229                ,"upper_rule" => 500000
230                ,"module_id" => $module_id
231                ,"module_path" => MODULE_PATH . "mdl_paygent/paygent_credit.php"
232                ,"memo01" => $_POST["merchant_id"]
233                ,"memo02" => $_POST["connect_id"]
234                ,"memo03" => $val
235                ,"memo04" => $_POST["connect_password"]
236                ,"memo05" => ""
237                ,"del_flg" => "0"
238                ,"charge_flg" => "2"
239                ,"upper_rule_max" => CHARGE_MAX
240               
241            );
242        }
243       
244        // ¥³¥ó¥Ó¥Ë¤Ë¥Á¥§¥Ã¥¯¤¬Æþ¤Ã¤Æ¤¤¤ì¤Ð¥³¥ó¥Ó¥Ë¤òÅÐÏ¿¤¹¤ë
245        if($val == 2){
246            $arrParam = array();
247            $arrParam['payment_limit_date'] = $_POST['conveni_limit_date'];
248           
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_conveni.php"
258                ,"memo01" => $_POST["merchant_id"]
259                ,"memo02" => $_POST["connect_id"]
260                ,"memo03" => $val
261                ,"memo04" => $_POST["connect_password"]
262                ,"memo05" => serialize($arrParam)
263                ,"del_flg" => "0"
264                ,"charge_flg" => "1"
265                ,"upper_rule_max" => $upper_rule_max
266            );
267        }
268       
269        // ATM·èºÑ¤Ë¥Á¥§¥Ã¥¯¤¬Æþ¤Ã¤Æ¤¤¤ì¤ÐATM·èºÑ¤òÅÐÏ¿¤¹¤ë
270        if($val == 3){
271            $arrParam = array();
272            $arrParam['payment_detail'] = $_POST['payment_detail'];
273            $arrParam['payment_limit_date'] = $_POST['atm_limit_date'];
274           
275            $arrData = array(
276                "payment_method" => "PAYGENTATM·èºÑ"
277                ,"fix" => 3
278                ,"creator_id" => $objSess->member_id
279                ,"create_date" => "now()"
280                ,"update_date" => "now()"
281                ,"upper_rule" => $upper_rule
282                ,"module_id" => $module_id
283                ,"module_path" => MODULE_PATH . "mdl_paygent/paygent_atm.php"
284                ,"memo01" => $_POST["merchant_id"]
285                ,"memo02" => $_POST["connect_id"]
286                ,"memo03" => $val
287                ,"memo04" => $_POST["connect_password"]
288                ,"memo05" => serialize($arrParam)
289                ,"del_flg" => "0"
290                ,"charge_flg" => "1"
291                ,"upper_rule_max" => $upper_rule_max
292            );
293        }
294       
295        // ¶ä¹ÔNET¤Ë¥Á¥§¥Ã¥¯¤¬Æþ¤Ã¤Æ¤¤¤ì¤ÐATM·èºÑ¤òÅÐÏ¿¤¹¤ë
296        if($val == 4){
297            $arrParam = array();
298            $arrParam['claim_kana'] = $_POST['claim_kana'];
299            $arrParam['claim_kanji'] = $_POST['claim_kanji'];
300            $arrParam['asp_payment_term'] = $_POST['asp_payment_term'];
301            $arrParam['copy_right'] = $_POST['copy_right'];
302            $arrParam['free_memo'] = $_POST['free_memo'];
303            $arrData = array(
304                "payment_method" => "PAYGENT¶ä¹Ô¥Í¥Ã¥È"
305                ,"fix" => 3
306                ,"creator_id" => $objSess->member_id
307                ,"create_date" => "now()"
308                ,"update_date" => "now()"
309                ,"upper_rule" => $upper_rule
310                ,"module_id" => $module_id
311                ,"module_path" => MODULE_PATH . "mdl_paygent/paygent_bank.php"
312                ,"memo01" => $_POST["merchant_id"]
313                ,"memo02" => $_POST["connect_id"]
314                ,"memo03" => $val
315                ,"memo04" => $_POST["connect_password"]
316                ,"memo05" => serialize($arrParam)
317                ,"del_flg" => "0"
318                ,"charge_flg" => "1"
319                ,"upper_rule_max" => $upper_rule_max
320            );
321        }
322       
323       
324        // ¥Ç¡¼¥¿¤¬Â¸ºß¤·¤Æ¤¤¤ì¤ÐUPDATE¡¢Ìµ¤±¤ì¤ÐINSERT
325        if(count($arrPaymentData) > 0){
326            $objQuery->update("dtb_payment", $arrData, " module_id = '" . $module_id . "' AND memo03 = '" . $val ."'");
327        }else{
328            $arrData["rank"] = $max_rank + 1;
329            $objQuery->insert("dtb_payment", $arrData);
330        }
331    }
332}
333
334// ¥³¥ó¥Ó¥ËÆþ¶â³Îǧ½èÍý
335function lfEpsilonCheck(){
336    global $objQuery;
337   
338    // trans_code ¤ò»ØÄꤵ¤ì¤Æ¤¤¤Æ³î¤Ä¡¢Æþ¶âºÑ¤ß¤Î¾ì¹ç
339    if($_POST["trans_code"] != "" and $_POST["paid"] == 1 and $_POST["order_number"] != ""){
340        // ¥¹¥Æ¡¼¥¿¥¹¤òÆþ¶âºÑ¤ß¤ËÊѹ¹¤¹¤ë
341        $sql = "UPDATE dtb_order SET status = 6, update_date = now() WHERE order_id = ? AND memo04 = ? ";
342        $objQuery->query($sql, array($_POST["order_number"], $_POST["trans_code"]));
343       
344        // POST¤ÎÆâÍƤòÁ´¤Æ¥í¥°Êݸ
345        $log_path = DATA_PATH . "logs/epsilon.log";
346        gfPrintLog("epsilon conveni start---------------------------------------------------------", $log_path);
347        foreach($_POST as $key => $val){
348            gfPrintLog( "\t" . $key . " => " . $val, $log_path);
349        }
350        gfPrintLog("epsilon conveni end-----------------------------------------------------------", $log_path);
351       
352        //±þÅú·ë²Ì¤òɽ¼¨
353        echo "1";
354    }
355}
356
357?>
Note: See TracBrowser for help on using the repository browser.