| 1 | <?php
|
|---|
| 2 |
|
|---|
| 3 | $objSiteSess = new SC_SiteSession();
|
|---|
| 4 | $objCartSess = new SC_CartSession();
|
|---|
| 5 | $objCampaignSess = new SC_CampaignSession();
|
|---|
| 6 | $objCustomer = new SC_Customer();
|
|---|
| 7 |
|
|---|
| 8 | $objSiteInfo = $objView->objSiteInfo;
|
|---|
| 9 | $arrInfo = $objSiteInfo->data;
|
|---|
| 10 |
|
|---|
| 11 | define("ZERO_RECV_APPROVE_MAIL", $arrInfo["email03"]); // ¾µÇ§¾ðÊó¤ò¼õ¿®¤¹¤ë¥á¡¼¥ë¥¢¥É¥ì¥¹
|
|---|
| 12 | define("ZERO_SEND_MAIL", true); // ¾µÇ§¾ðÊó¤ò¼õ¿®¤¹¤ë¥á¡¼¥ë¥¢¥É¥ì¥¹
|
|---|
| 13 |
|
|---|
| 14 | $log_path = DATA_PATH . "logs/zero.log";
|
|---|
| 15 | gfPrintLog("** zero start **", $log_path);
|
|---|
| 16 |
|
|---|
| 17 | $arrResult = $_GET;
|
|---|
| 18 | // GET¤ÎÆâÍÆ¤òÁ´¤Æ¥í¥°Êݸ
|
|---|
| 19 | foreach($arrResult as $key => $val){
|
|---|
| 20 | gfPrintLog( "\t" . $key . " => " . $val, $log_path);
|
|---|
| 21 | }
|
|---|
| 22 |
|
|---|
| 23 | $objQuery->begin();
|
|---|
| 24 | $order_id = lfDoComplete($objQuery, $arrResult);
|
|---|
| 25 | $objQuery->commit();
|
|---|
| 26 |
|
|---|
| 27 | // ´°Î»¥á¡¼¥ëÁ÷¿®
|
|---|
| 28 | if(sfIsInt($order_id)) {
|
|---|
| 29 | sfSendOrderMail($order_id, '1');
|
|---|
| 30 | print("OK");
|
|---|
| 31 | }else{
|
|---|
| 32 | // ¥¨¥é¡¼¤Î¾ì¹ç¼õ¿®¥Ç¡¼¥¿¤òÁ÷¿®
|
|---|
| 33 | gfPrintLog(" zero error ", $log_path);;
|
|---|
| 34 | if(ZERO_SEND_MAIL){
|
|---|
| 35 | ob_start();
|
|---|
| 36 | print($order_id . "\n");
|
|---|
| 37 | print_r($arrResult);
|
|---|
| 38 | $msg = ob_get_contents();
|
|---|
| 39 | ob_end_clean();
|
|---|
| 40 | mb_send_mail(ZERO_RECV_APPROVE_MAIL, "¥¼¥í¥¯¥ì¥¸¥Ã¥È¥¨¥é¡¼:" . $arrResult['sendid'], $msg . "\n");
|
|---|
| 41 | gfPrintLog(" send error mail ", $log_path);;
|
|---|
| 42 | }
|
|---|
| 43 | print("NG");
|
|---|
| 44 | }
|
|---|
| 45 | gfPrintLog("** zero end **", $log_path);
|
|---|
| 46 | //---------------------------------------------------------------------------------------------------------------------------------
|
|---|
| 47 | // ´°Î»½èÍý
|
|---|
| 48 | function lfDoComplete($objQuery, $arrResult) {
|
|---|
| 49 | global $objCartSess;
|
|---|
| 50 | global $objSiteSess;
|
|---|
| 51 | $objCampaignSess = new SC_CampaignSession();
|
|---|
| 52 | $objCustomer = new SC_Customer();
|
|---|
| 53 | global $arrInfo;
|
|---|
| 54 |
|
|---|
| 55 | gfprintlog($objCustomer->isLoginSuccess(),DATA_PATH . "logs/zero.log");
|
|---|
| 56 |
|
|---|
| 57 | // sendid ¤ÎÃͤò¶èÀÚ¤ë
|
|---|
| 58 | $arrSendid = preg_split("/\\".SEND_PARAM_DELIMITER."/", $arrResult["sendid"]);
|
|---|
| 59 |
|
|---|
| 60 | $uniqid = $arrSendid[0]; // order_temp_id
|
|---|
| 61 | $money = $arrResult["money"]; // payment_total
|
|---|
| 62 |
|
|---|
| 63 | $arrCrilentIP = $objQuery->select("memo02, memo04", "dtb_payment", "payment_id = ? and del_flg = 0", array($arrSendid[1]));
|
|---|
| 64 | //$client_id = $objQuery->getAll("SELECT memo04 FROM dtb_payment WHERE payment_id = ? and del_flg = 0", array($arrSendid[1]));
|
|---|
| 65 |
|
|---|
| 66 | // ²ÃÌÁŹ¥³¡¼¥É¤¬°ã¤¦¾ì¹ç¤Ë¤Ï¥¨¥é¡¼
|
|---|
| 67 | if(count($arrResult)){
|
|---|
| 68 | if(in_array($arrResult["clientip"], $arrCrilentIP)) return "²ÃÌÁŹ¥³¡¼¥É¤¬°ã¤¤¤Þ¤¹¡£";
|
|---|
| 69 | }else{
|
|---|
| 70 | return "²ÃÌÁŹ¥³¡¼¥É¤¬°ã¤¤¤Þ¤¹¡£";
|
|---|
| 71 | }
|
|---|
| 72 |
|
|---|
| 73 | // °ì»þ¼õÃí¥Æ¡¼¥Ö¥ë¤ÎÆÉ¹þ
|
|---|
| 74 | $arrData = sfGetOrderTemp($uniqid);
|
|---|
| 75 |
|
|---|
| 76 | // °ì»þ¼õÃí¥Æ¡¼¥Ö¥ë¤«¤é¥Ç¡¼¥¿¤¬¼èÆÀ¤Ç¤¤Ê¤±¤ì¤Ð¡¢¥¨¥é¡¼
|
|---|
| 77 | if(count($arrData) <= 0) return "¼õÃí°ì»þ¥Æ¡¼¥Ö¥ë¤Ë»ØÄꤷ¤¿ID¤Î¥Ç¡¼¥¿¤¬¤¢¤ê¤Þ¤»¤ó¡£";
|
|---|
| 78 |
|
|---|
| 79 | // ·èºÑ´°Î»ºÑ¤ß¤Ç¤¢¤ì¤Ð¥¨¥é¡¼
|
|---|
| 80 | if($arrData["del_flg"] == 1) return "»ØÄꤷ¤¿ID¤Î¥Ç¡¼¥¿¤Ï·èºÑ´°Î»ºÑ¤ß¤Ç¤¹¡£";
|
|---|
| 81 |
|
|---|
| 82 | // °ì»þ¼õÃí¥Æ¡¼¥Ö¥ë¤Î¤ª»Ùʧ¤¤¹ç·×¤È¡¢¥¼¥í¤«¤éÊ֤äƤ¤¿¶â³Û¤È¤¬°ã¤¦¾ì¹ç¤Ï¥¨¥é¡¼
|
|---|
| 83 | if($arrData["payment_total"] != $money) return "¤ª»Ùʧ¤¤¶â³Û¤¬°ã¤¤¤Þ¤¹¡£";
|
|---|
| 84 |
|
|---|
| 85 | // ¥»¥Ã¥·¥ç¥ó¾ðÊó¤ÎÉüµ¢
|
|---|
| 86 | $_SESSION = unserialize($arrData["session"]);
|
|---|
| 87 |
|
|---|
| 88 | // ²ñ°÷¾ðÊóÅÐÏ¿½èÍý
|
|---|
| 89 | if ($objCustomer->isLoginSuccess()) {
|
|---|
| 90 | // ¿·¤ªÆÏ¤±Àè¤ÎÅÐÏ¿
|
|---|
| 91 | lfSetNewAddr($uniqid, $objCustomer->getValue('customer_id'));
|
|---|
| 92 | // ¹ØÆþ½¸·×¤ò¸ÜµÒ¥Æ¡¼¥Ö¥ë¤ËÈ¿±Ç
|
|---|
| 93 | lfSetCustomerPurchase($objCustomer->getValue('customer_id'), $arrData, $objQuery);
|
|---|
| 94 | } else {
|
|---|
| 95 | //¹ØÆþ»þ¶¯À©²ñ°÷ÅÐÏ¿
|
|---|
| 96 | switch(PURCHASE_CUSTOMER_REGIST) {
|
|---|
| 97 | //̵¸ú
|
|---|
| 98 | case '0':
|
|---|
| 99 | // ¹ØÆþ»þ²ñ°÷ÅÐÏ¿
|
|---|
| 100 | if($arrData['member_check'] == '1') {
|
|---|
| 101 | // ²¾²ñ°÷ÅÐÏ¿
|
|---|
| 102 | $customer_id = lfRegistPreCustomer($arrData, $arrInfo);
|
|---|
| 103 | // ¹ØÆþ½¸·×¤ò¸ÜµÒ¥Æ¡¼¥Ö¥ë¤ËÈ¿±Ç
|
|---|
| 104 | lfSetCustomerPurchase($customer_id, $arrData, $objQuery);
|
|---|
| 105 | }
|
|---|
| 106 | break;
|
|---|
| 107 | //͸ú
|
|---|
| 108 | case '1':
|
|---|
| 109 | // ²¾²ñ°÷ÅÐÏ¿
|
|---|
| 110 | $customer_id = lfRegistPreCustomer($arrData, $arrInfo);
|
|---|
| 111 | // ¹ØÆþ½¸·×¤ò¸ÜµÒ¥Æ¡¼¥Ö¥ë¤ËÈ¿±Ç
|
|---|
| 112 | lfSetCustomerPurchase($customer_id, $arrData, $objQuery);
|
|---|
| 113 | break;
|
|---|
| 114 | }
|
|---|
| 115 | }
|
|---|
| 116 |
|
|---|
| 117 | // °ì»þ¥Æ¡¼¥Ö¥ë¤ò¼õÃí¥Æ¡¼¥Ö¥ë¤Ë³ÊǼ¤¹¤ë
|
|---|
| 118 | $order_id = lfRegistOrder($objQuery, $arrData);
|
|---|
| 119 | // ¥«¡¼¥È¾¦Éʤò¼õÃí¾ÜºÙ¥Æ¡¼¥Ö¥ë¤Ë³ÊǼ¤¹¤ë
|
|---|
| 120 | lfRegistOrderDetail($objQuery, $order_id, $objCartSess);
|
|---|
| 121 | // ¼õÃí°ì»þ¥Æ¡¼¥Ö¥ë¤Î¾ðÊó¤òºï½ü¤¹¤ë¡£
|
|---|
| 122 | lfDeleteTempOrder($objQuery, $uniqid);
|
|---|
| 123 | // ¥¥ã¥ó¥Ú¡¼¥ó¤«¤é¤ÎÁ«°Ü¤Î¾ì¹çÅÐÏ¿¤¹¤ë¡£
|
|---|
| 124 | if($objCampaignSess->getIsCampaign()) {
|
|---|
| 125 | lfRegistCampaignOrder($objQuery, $objCampaignSess, $order_id);
|
|---|
| 126 | }
|
|---|
| 127 |
|
|---|
| 128 | return $order_id;
|
|---|
| 129 | }
|
|---|
| 130 |
|
|---|
| 131 | // ²ñ°÷ÅÐÏ¿¡Ê²¾ÅÐÏ¿¡Ë
|
|---|
| 132 | function lfRegistPreCustomer($arrData, $arrInfo) {
|
|---|
| 133 | // ¹ØÆþ»þ¤Î²ñ°÷ÅÐÏ¿
|
|---|
| 134 | $sqlval['name01'] = $arrData['order_name01'];
|
|---|
| 135 | $sqlval['name02'] = $arrData['order_name02'];
|
|---|
| 136 | $sqlval['kana01'] = $arrData['order_kana01'];
|
|---|
| 137 | $sqlval['kana02'] = $arrData['order_kana02'];
|
|---|
| 138 | $sqlval['zip01'] = $arrData['order_zip01'];
|
|---|
| 139 | $sqlval['zip02'] = $arrData['order_zip02'];
|
|---|
| 140 | $sqlval['pref'] = $arrData['order_pref'];
|
|---|
| 141 | $sqlval['addr01'] = $arrData['order_addr01'];
|
|---|
| 142 | $sqlval['addr02'] = $arrData['order_addr02'];
|
|---|
| 143 | $sqlval['email'] = $arrData['order_email'];
|
|---|
| 144 | $sqlval['tel01'] = $arrData['order_tel01'];
|
|---|
| 145 | $sqlval['tel02'] = $arrData['order_tel02'];
|
|---|
| 146 | $sqlval['tel03'] = $arrData['order_tel03'];
|
|---|
| 147 | $sqlval['fax01'] = $arrData['order_fax01'];
|
|---|
| 148 | $sqlval['fax02'] = $arrData['order_fax02'];
|
|---|
| 149 | $sqlval['fax03'] = $arrData['order_fax03'];
|
|---|
| 150 | $sqlval['sex'] = $arrData['order_sex'];
|
|---|
| 151 | $sqlval['password'] = $arrData['password'];
|
|---|
| 152 | $sqlval['reminder'] = $arrData['reminder'];
|
|---|
| 153 | $sqlval['reminder_answer'] = $arrData['reminder_answer'];
|
|---|
| 154 |
|
|---|
| 155 | // ¥á¥ë¥Þ¥¬ÇÛ¿®Íѥե饰¤ÎȽÄê
|
|---|
| 156 | switch($arrData['mail_flag']) {
|
|---|
| 157 | case '1': // HTML¥á¡¼¥ë
|
|---|
| 158 | $mail_flag = 4;
|
|---|
| 159 | break;
|
|---|
| 160 | case '2': // TEXT¥á¡¼¥ë
|
|---|
| 161 | $mail_flag = 5;
|
|---|
| 162 | break;
|
|---|
| 163 | case '3': // ´õ˾¤Ê¤·
|
|---|
| 164 | $mail_flag = 6;
|
|---|
| 165 | break;
|
|---|
| 166 | default:
|
|---|
| 167 | $mail_flag = 6;
|
|---|
| 168 | break;
|
|---|
| 169 | }
|
|---|
| 170 | // ¥á¥ë¥Þ¥¬¥Õ¥é¥°
|
|---|
| 171 | $sqlval['mailmaga_flg'] = $mail_flag;
|
|---|
| 172 |
|
|---|
| 173 | // ²ñ°÷²¾ÅÐÏ¿
|
|---|
| 174 | $sqlval['status'] = 1;
|
|---|
| 175 | // URLȽÄêÍÑ¥¡¼
|
|---|
| 176 | $sqlval['secret_key'] = sfGetUniqRandomId("t");
|
|---|
| 177 |
|
|---|
| 178 | $objQuery = new SC_Query();
|
|---|
| 179 | $sqlval['create_date'] = "now()";
|
|---|
| 180 | $sqlval['update_date'] = "now()";
|
|---|
| 181 | $objQuery->insert("dtb_customer", $sqlval);
|
|---|
| 182 |
|
|---|
| 183 | // ¸ÜµÒID¤Î¼èÆÀ
|
|---|
| 184 | $arrRet = $objQuery->select("customer_id", "dtb_customer", "secret_key = ?", array($sqlval['secret_key']));
|
|---|
| 185 | $customer_id = $arrRet[0]['customer_id'];
|
|---|
| 186 |
|
|---|
| 187 | //¡¡²¾ÅÐÏ¿´°Î»¥á¡¼¥ëÁ÷¿®
|
|---|
| 188 | $objMailPage = new LC_Page();
|
|---|
| 189 | $objMailPage->to_name01 = $arrData['order_name01'];
|
|---|
| 190 | $objMailPage->to_name02 = $arrData['order_name02'];
|
|---|
| 191 | $objMailPage->CONF = $arrInfo;
|
|---|
| 192 | $objMailPage->uniqid = $sqlval['secret_key'];
|
|---|
| 193 | $objMailView = new SC_SiteView();
|
|---|
| 194 | $objMailView->assignobj($objMailPage);
|
|---|
| 195 | $body = $objMailView->fetch("mail_templates/customer_mail.tpl");
|
|---|
| 196 |
|
|---|
| 197 | $objMail = new GC_SendMail();
|
|---|
| 198 | $objMail->setItem(
|
|---|
| 199 | '' //¡¡°¸Àè
|
|---|
| 200 | , sfMakeSubject("²ñ°÷ÅÐÏ¿¤Î¤´³Îǧ") //¡¡¥µ¥Ö¥¸¥§¥¯¥È
|
|---|
| 201 | , $body //¡¡ËÜʸ
|
|---|
| 202 | , $arrInfo['email03'] //¡¡ÇÛÁ÷¸µ¥¢¥É¥ì¥¹
|
|---|
| 203 | , $arrInfo['shop_name'] //¡¡ÇÛÁ÷¸µ¡¡Ì¾Á°
|
|---|
| 204 | , $arrInfo["email03"] //¡¡reply_to
|
|---|
| 205 | , $arrInfo["email04"] //¡¡return_path
|
|---|
| 206 | , $arrInfo["email04"] // Errors_to
|
|---|
| 207 | , $arrInfo["email01"] // Bcc
|
|---|
| 208 | );
|
|---|
| 209 | // °¸Àè¤ÎÀßÄê
|
|---|
| 210 | $name = $arrData['order_name01'] . $arrData['order_name02'] ." ÍÍ";
|
|---|
| 211 | $objMail->setTo($arrData['order_email'], $name);
|
|---|
| 212 | $objMail->sendMail();
|
|---|
| 213 |
|
|---|
| 214 | return $customer_id;
|
|---|
| 215 | }
|
|---|
| 216 |
|
|---|
| 217 | // ¼õÃí¥Æ¡¼¥Ö¥ë¤ØÅÐÏ¿
|
|---|
| 218 | function lfRegistOrder($objQuery, $arrData) {
|
|---|
| 219 | $objCampaignSess = new SC_CampaignSession();
|
|---|
| 220 | $sqlval = $arrData;
|
|---|
| 221 |
|
|---|
| 222 | // ¼õÃí¥Æ¡¼¥Ö¥ë¤Ë½ñ¤¹þ¤Þ¤Ê¤¤Îó¤ò½üµî
|
|---|
| 223 | unset($sqlval['mailmaga_flg']); // ¥á¥ë¥Þ¥¬¥Á¥§¥Ã¥¯
|
|---|
| 224 | unset($sqlval['deliv_check']); // Ê̤ΤªÆÏ¤±Àè¥Á¥§¥Ã¥¯
|
|---|
| 225 | unset($sqlval['point_check']); // ¥Ý¥¤¥ó¥ÈÍøÍÑ¥Á¥§¥Ã¥¯
|
|---|
| 226 | unset($sqlval['member_check']); // ¹ØÆþ»þ²ñ°÷¥Á¥§¥Ã¥¯
|
|---|
| 227 | unset($sqlval['password']); // ¥í¥°¥¤¥ó¥Ñ¥¹¥ï¡¼¥É
|
|---|
| 228 | unset($sqlval['reminder']); // ¥ê¥Þ¥¤¥ó¥À¡¼¼ÁÌä
|
|---|
| 229 | unset($sqlval['reminder_answer']); // ¥ê¥Þ¥¤¥ó¥À¡¼Åú¤¨
|
|---|
| 230 | unset($sqlval['mail_flag']); // ¥á¡¼¥ë¥Õ¥é¥°
|
|---|
| 231 | unset($sqlval['session']); // ¥»¥Ã¥·¥ç¥ó¾ðÊó
|
|---|
| 232 |
|
|---|
| 233 | // Ãíʸ¥¹¥Æ¡¼¥¿¥¹:»ØÄ̵꤬¤±¤ì¤Ð¿·µ¬¼õÉÕ¤ËÀßÄê
|
|---|
| 234 | if($sqlval["status"] == ""){
|
|---|
| 235 | $sqlval['status'] = '1';
|
|---|
| 236 | }
|
|---|
| 237 |
|
|---|
| 238 | // Ê̤ΤªÆÏ¤±Àè¤ò»ØÄꤷ¤Æ¤¤¤Ê¤¤¾ì¹ç¡¢ÇÛÁ÷Àè¤ËÅÐÏ¿½»½ê¤ò¥³¥Ô¡¼¤¹¤ë¡£
|
|---|
| 239 | if($arrData["deliv_check"] == "-1") {
|
|---|
| 240 | $sqlval['deliv_name01'] = $arrData['order_name01'];
|
|---|
| 241 | $sqlval['deliv_name02'] = $arrData['order_name02'];
|
|---|
| 242 | $sqlval['deliv_kana01'] = $arrData['order_kana01'];
|
|---|
| 243 | $sqlval['deliv_kana02'] = $arrData['order_kana02'];
|
|---|
| 244 | $sqlval['deliv_pref'] = $arrData['order_pref'];
|
|---|
| 245 | $sqlval['deliv_zip01'] = $arrData['order_zip01'];
|
|---|
| 246 | $sqlval['deliv_zip02'] = $arrData['order_zip02'];
|
|---|
| 247 | $sqlval['deliv_addr01'] = $arrData['order_addr01'];
|
|---|
| 248 | $sqlval['deliv_addr02'] = $arrData['order_addr02'];
|
|---|
| 249 | $sqlval['deliv_tel01'] = $arrData['order_tel01'];
|
|---|
| 250 | $sqlval['deliv_tel02'] = $arrData['order_tel02'];
|
|---|
| 251 | $sqlval['deliv_tel03'] = $arrData['order_tel03'];
|
|---|
| 252 | }
|
|---|
| 253 |
|
|---|
| 254 | $order_id = $arrData['order_id']; // ¥ª¡¼¥À¡¼ID
|
|---|
| 255 | $sqlval['create_date'] = 'now()'; // ¼õÃíÆü
|
|---|
| 256 |
|
|---|
| 257 | // ¥¥ã¥ó¥Ú¡¼¥óID
|
|---|
| 258 | if($objCampaignSess->getIsCampaign()) $sqlval['campaign_id'] = $objCampaignSess->getCampaignId();
|
|---|
| 259 |
|
|---|
| 260 | // ¥²¥Ã¥È¤ÎÃͤò¥¤¥ó¥µ¡¼¥È
|
|---|
| 261 | //$sqlval = lfGetInsParam($sqlval);
|
|---|
| 262 |
|
|---|
| 263 | // INSERT¤Î¼Â¹Ô
|
|---|
| 264 | $objQuery->insert("dtb_order", $sqlval);
|
|---|
| 265 |
|
|---|
| 266 | return $order_id;
|
|---|
| 267 | }
|
|---|
| 268 |
|
|---|
| 269 | // ¼õÃí¾ÜºÙ¥Æ¡¼¥Ö¥ë¤ØÅÐÏ¿
|
|---|
| 270 | function lfRegistOrderDetail($objQuery, $order_id) {
|
|---|
| 271 | $objCartSess = new SC_CartSession();
|
|---|
| 272 |
|
|---|
| 273 | // ¥«¡¼¥ÈÆâ¾ðÊó¤Î¼èÆÀ
|
|---|
| 274 | $arrCart = $objCartSess->getCartList();
|
|---|
| 275 | $max = count($arrCart);
|
|---|
| 276 |
|
|---|
| 277 | // ´û¤Ë¸ºß¤¹¤ë¾ÜºÙ¥ì¥³¡¼¥É¤ò¾Ã¤·¤Æ¤ª¤¯¡£
|
|---|
| 278 | $objQuery->delete("dtb_order_detail", "order_id = $order_id");
|
|---|
| 279 |
|
|---|
| 280 | // µ¬³Ê̾°ìÍ÷
|
|---|
| 281 | $arrClassName = sfGetIDValueList("dtb_class", "class_id", "name");
|
|---|
| 282 | // µ¬³ÊʬÎà̾°ìÍ÷
|
|---|
| 283 | $arrClassCatName = sfGetIDValueList("dtb_classcategory", "classcategory_id", "name");
|
|---|
| 284 |
|
|---|
| 285 | for ($i = 0; $i < $max; $i++) {
|
|---|
| 286 | // ¾¦Éʵ¬³Ê¾ðÊó¤Î¼èÆÀ
|
|---|
| 287 | $arrData = sfGetProductsClass($arrCart[$i]['id']);
|
|---|
| 288 |
|
|---|
| 289 | // ¸ºß¤¹¤ë¾¦ÉʤΤßɽ¼¨¤¹¤ë¡£
|
|---|
| 290 | if($arrData != "") {
|
|---|
| 291 | $sqlval['order_id'] = $order_id;
|
|---|
| 292 | $sqlval['product_id'] = $arrCart[$i]['id'][0];
|
|---|
| 293 | $sqlval['classcategory_id1'] = $arrCart[$i]['id'][1];
|
|---|
| 294 | $sqlval['classcategory_id2'] = $arrCart[$i]['id'][2];
|
|---|
| 295 | $sqlval['product_name'] = $arrData['name'];
|
|---|
| 296 | $sqlval['product_code'] = $arrData['product_code'];
|
|---|
| 297 | $sqlval['classcategory_name1'] = $arrClassCatName[$arrData['classcategory_id1']];
|
|---|
| 298 | $sqlval['classcategory_name2'] = $arrClassCatName[$arrData['classcategory_id2']];
|
|---|
| 299 | $sqlval['point_rate'] = $arrCart[$i]['point_rate'];
|
|---|
| 300 | $sqlval['price'] = $arrCart[$i]['price'];
|
|---|
| 301 | $sqlval['quantity'] = $arrCart[$i]['quantity'];
|
|---|
| 302 | lfReduceStock($objQuery, $arrCart[$i]['id'], $arrCart[$i]['quantity']);
|
|---|
| 303 | // INSERT¤Î¼Â¹Ô
|
|---|
| 304 | $objQuery->insert("dtb_order_detail", $sqlval);
|
|---|
| 305 | } else {
|
|---|
| 306 | sfDispSiteError(CART_NOT_FOUND);
|
|---|
| 307 | }
|
|---|
| 308 | }
|
|---|
| 309 | }
|
|---|
| 310 |
|
|---|
| 311 | // ¥¥ã¥ó¥Ú¡¼¥ó¼õÃí¥Æ¡¼¥Ö¥ë¤ØÅÐÏ¿
|
|---|
| 312 | function lfRegistCampaignOrder($objQuery, $objCampaignSess, $order_id) {
|
|---|
| 313 |
|
|---|
| 314 | // ¼õÃí¥Ç¡¼¥¿¤ò¼èÆÀ
|
|---|
| 315 | $cols = "order_id, campaign_id, customer_id, message, order_name01, order_name02,".
|
|---|
| 316 | "order_kana01, order_kana02, order_email, order_tel01, order_tel02, order_tel03,".
|
|---|
| 317 | "order_fax01, order_fax02, order_fax03, order_zip01, order_zip02, order_pref, order_addr01,".
|
|---|
| 318 | "order_addr02, order_sex, order_birth, order_job, deliv_name01, deliv_name02, deliv_kana01,".
|
|---|
| 319 | "deliv_kana02, deliv_tel01, deliv_tel02, deliv_tel03, deliv_fax01, deliv_fax02, deliv_fax03,".
|
|---|
| 320 | "deliv_zip01, deliv_zip02, deliv_pref, deliv_addr01, deliv_addr02, payment_total";
|
|---|
| 321 |
|
|---|
| 322 | $arrOrder = $objQuery->select($cols, "dtb_order", "order_id = ?", array($order_id));
|
|---|
| 323 |
|
|---|
| 324 | $sqlval = $arrOrder[0];
|
|---|
| 325 | $sqlval['create_date'] = 'now()';
|
|---|
| 326 |
|
|---|
| 327 | // INSERT¤Î¼Â¹Ô
|
|---|
| 328 | $objQuery->insert("dtb_campaign_order", $sqlval);
|
|---|
| 329 |
|
|---|
| 330 | // ¿½¤·¹þ¤ß¿ô¤Î¹¹¿·
|
|---|
| 331 | $total_count = $objQuery->get("dtb_campaign", "total_count", "campaign_id = ?", array($sqlval['campaign_id']));
|
|---|
| 332 | $arrCampaign['total_count'] = $total_count += 1;
|
|---|
| 333 | $objQuery->update("dtb_campaign", $arrCampaign, "campaign_id = ?", array($sqlval['campaign_id']));
|
|---|
| 334 |
|
|---|
| 335 | }
|
|---|
| 336 |
|
|---|
| 337 | /* ¼õÃí°ì»þ¥Æ¡¼¥Ö¥ë¤Îºï½ü */
|
|---|
| 338 | function lfDeleteTempOrder($objQuery, $uniqid) {
|
|---|
| 339 | $where = "order_temp_id = ?";
|
|---|
| 340 | $sqlval['del_flg'] = 1;
|
|---|
| 341 | $objQuery->update("dtb_order_temp", $sqlval, $where, array($uniqid));
|
|---|
| 342 | // $objQuery->delete("dtb_order_temp", $where, array($uniqid));
|
|---|
| 343 | }
|
|---|
| 344 |
|
|---|
| 345 | // ¼õÃí°ì»þ¥Æ¡¼¥Ö¥ë¤Î½»½ê¤¬ÅÐÏ¿ºÑ¤ß¥Æ¡¼¥Ö¥ë¤È°Û¤Ê¤ë¾ì¹ç¤Ï¡¢Ê̤ΤªÆÏ¤±Àè¤ËÄɲ乤ë
|
|---|
| 346 | function lfSetNewAddr($uniqid, $customer_id) {
|
|---|
| 347 | $objQuery = new SC_Query();
|
|---|
| 348 | $diff = false;
|
|---|
| 349 | $find_same = false;
|
|---|
| 350 |
|
|---|
| 351 | $col = "deliv_name01,deliv_name02,deliv_kana01,deliv_kana02,deliv_tel01,deliv_tel02,deliv_tel03,deliv_zip01,deliv_zip02,deliv_pref,deliv_addr01,deliv_addr02";
|
|---|
| 352 | $where = "order_temp_id = ?";
|
|---|
| 353 | $arrRet = $objQuery->select($col, "dtb_order_temp", $where, array($uniqid));
|
|---|
| 354 |
|
|---|
| 355 | // Í×ÁÇ̾¤Îdeliv_¤òºï½ü¤¹¤ë¡£
|
|---|
| 356 | foreach($arrRet[0] as $key => $val) {
|
|---|
| 357 | $keyname = ereg_replace("^deliv_", "", $key);
|
|---|
| 358 | $arrNew[$keyname] = $val;
|
|---|
| 359 | }
|
|---|
| 360 |
|
|---|
| 361 | // ²ñ°÷¾ðÊ󥯡¼¥Ö¥ë¤È¤ÎÈæ³Ó
|
|---|
| 362 | $col = "name01,name02,kana01,kana02,tel01,tel02,tel03,zip01,zip02,pref,addr01,addr02";
|
|---|
| 363 | $where = "customer_id = ?";
|
|---|
| 364 | $arrCustomerAddr = $objQuery->select($col, "dtb_customer", $where, array($customer_id));
|
|---|
| 365 |
|
|---|
| 366 | // ²ñ°÷¾ðÊó¤Î½»½ê¤È°Û¤Ê¤ë¾ì¹ç
|
|---|
| 367 | if($arrNew != $arrCustomerAddr[0]) {
|
|---|
| 368 | // Ê̤ΤªÆÏ¤±Àè¥Æ¡¼¥Ö¥ë¤Î½»½ê¤ÈÈæ³Ó¤¹¤ë
|
|---|
| 369 | $col = "name01,name02,kana01,kana02,tel01,tel02,tel03,zip01,zip02,pref,addr01,addr02";
|
|---|
| 370 | $where = "customer_id = ?";
|
|---|
| 371 | $arrOtherAddr = $objQuery->select($col, "dtb_other_deliv", $where, array($customer_id));
|
|---|
| 372 |
|
|---|
| 373 | foreach($arrOtherAddr as $arrval) {
|
|---|
| 374 | if($arrNew == $arrval) {
|
|---|
| 375 | // ¤¹¤Ç¤ËƱ¤¸½»½ê¤¬ÅÐÏ¿¤µ¤ì¤Æ¤¤¤ë
|
|---|
| 376 | $find_same = true;
|
|---|
| 377 | }
|
|---|
| 378 | }
|
|---|
| 379 |
|
|---|
| 380 | if(!$find_same) {
|
|---|
| 381 | $diff = true;
|
|---|
| 382 | }
|
|---|
| 383 | }
|
|---|
| 384 |
|
|---|
| 385 | // ¿·¤·¤¤¤ªÆÏ¤±À褬ÅÐÏ¿ºÑ¤ß¤Î¤â¤Î¤È°Û¤Ê¤ë¾ì¹ç¤ÏÊ̤ΤªÆÏ¤±Àè¥Æ¡¼¥Ö¥ë¤ËÅÐÏ¿¤¹¤ë
|
|---|
| 386 | if($diff) {
|
|---|
| 387 | $sqlval = $arrNew;
|
|---|
| 388 | $sqlval['customer_id'] = $customer_id;
|
|---|
| 389 | $objQuery->insert("dtb_other_deliv", $sqlval);
|
|---|
| 390 | }
|
|---|
| 391 | }
|
|---|
| 392 |
|
|---|
| 393 | /* ¹ØÆþ¾ðÊó¤ò²ñ°÷¥Æ¡¼¥Ö¥ë¤ËÅÐÏ¿¤¹¤ë */
|
|---|
| 394 | function lfSetCustomerPurchase($customer_id, $arrData, $objQuery) {
|
|---|
| 395 | $col = "first_buy_date, last_buy_date, buy_times, buy_total, point";
|
|---|
| 396 | $where = "customer_id = ?";
|
|---|
| 397 | $arrRet = $objQuery->select($col, "dtb_customer", $where, array($customer_id));
|
|---|
| 398 | $sqlval = $arrRet[0];
|
|---|
| 399 |
|
|---|
| 400 | if($sqlval['first_buy_date'] == "") {
|
|---|
| 401 | $sqlval['first_buy_date'] = "Now()";
|
|---|
| 402 | }
|
|---|
| 403 | $sqlval['last_buy_date'] = "Now()";
|
|---|
| 404 | $sqlval['buy_times']++;
|
|---|
| 405 | $sqlval['buy_total']+= $arrData['total'];
|
|---|
| 406 | $sqlval['point'] = ($sqlval['point'] + $arrData['add_point'] - $arrData['use_point']);
|
|---|
| 407 |
|
|---|
| 408 | // ¥Ý¥¤¥ó¥È¤¬ÉÔ¤·¤Æ¤¤¤ë¾ì¹ç
|
|---|
| 409 | if($sqlval['point'] < 0) {
|
|---|
| 410 | $objQuery->rollback();
|
|---|
| 411 | sfDispSiteError(LACK_POINT);
|
|---|
| 412 | }
|
|---|
| 413 |
|
|---|
| 414 | $objQuery->update("dtb_customer", $sqlval, $where, array($customer_id));
|
|---|
| 415 | }
|
|---|
| 416 |
|
|---|
| 417 | // ºß¸Ë¤ò¸º¤é¤¹½èÍý
|
|---|
| 418 | function lfReduceStock($objQuery, $arrID, $quantity) {
|
|---|
| 419 | $where = "product_id = ? AND classcategory_id1 = ? AND classcategory_id2 = ?";
|
|---|
| 420 | $arrRet = $objQuery->select("stock, stock_unlimited", "dtb_products_class", $where, $arrID);
|
|---|
| 421 |
|
|---|
| 422 | // Çä¤êÀڤ쥨¥é¡¼
|
|---|
| 423 | if(($arrRet[0]['stock_unlimited'] != '1' && $arrRet[0]['stock'] < $quantity) || $quantity == 0) {
|
|---|
| 424 | $objQuery->rollback();
|
|---|
| 425 | sfDispSiteError(SOLD_OUT, "", true);
|
|---|
| 426 | // ̵À©¸Â¤Î¾ì¹ç¡¢ºß¸Ë¤ÏNULL
|
|---|
| 427 | } elseif($arrRet[0]['stock_unlimited'] == '1') {
|
|---|
| 428 | $sqlval['stock'] = null;
|
|---|
| 429 | $objQuery->update("dtb_products_class", $sqlval, $where, $arrID);
|
|---|
| 430 | // ºß¸Ë¤ò¸º¤é¤¹
|
|---|
| 431 | } else {
|
|---|
| 432 | $sqlval['stock'] = ($arrRet[0]['stock'] - $quantity);
|
|---|
| 433 | if($sqlval['stock'] == "") {
|
|---|
| 434 | $sqlval['stock'] = '0';
|
|---|
| 435 | }
|
|---|
| 436 | $objQuery->update("dtb_products_class", $sqlval, $where, $arrID);
|
|---|
| 437 | }
|
|---|
| 438 | }
|
|---|
| 439 |
|
|---|
| 440 | // GET¤ÎÃͤò¥¤¥ó¥µ¡¼¥ÈÍѤËÀ°¤¨¤ë
|
|---|
| 441 | function lfGetInsParam($sqlVal){
|
|---|
| 442 |
|
|---|
| 443 | foreach($_GET as $key => $val){
|
|---|
| 444 | // ¥«¥é¥à¤Î¸ºß¥Á¥§¥Ã¥¯
|
|---|
| 445 | if(sfColumnExists("dtb_order", $key)) $sqlVal[$key] = $val;
|
|---|
| 446 | }
|
|---|
| 447 |
|
|---|
| 448 | return $sqlVal;
|
|---|
| 449 | }
|
|---|
| 450 | ?>
|
|---|