| 1 | <?php |
|---|
| 2 | /* |
|---|
| 3 | * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved. |
|---|
| 4 | * |
|---|
| 5 | * http://www.lockon.co.jp/ |
|---|
| 6 | */ |
|---|
| 7 | |
|---|
| 8 | require_once("../require.php"); |
|---|
| 9 | |
|---|
| 10 | class LC_Page { |
|---|
| 11 | function LC_Page() { |
|---|
| 12 | $this->tpl_mainpage = 'shopping/complete.tpl'; |
|---|
| 13 | $this->tpl_css = URL_DIR.'css/layout/shopping/complete.css'; |
|---|
| 14 | $this->tpl_title = "¤´Ãíʸ´°Î»"; |
|---|
| 15 | global $arrCONVENIENCE; |
|---|
| 16 | $this->arrCONVENIENCE = $arrCONVENIENCE; |
|---|
| 17 | global $arrCONVENIMESSAGE; |
|---|
| 18 | $this->arrCONVENIMESSAGE = $arrCONVENIMESSAGE; |
|---|
| 19 | global $arrCONVENIENCE; |
|---|
| 20 | global $arrCONVENIMESSAGE; |
|---|
| 21 | $objPage->arrCONVENIENCE = $arrCONVENIENCE; |
|---|
| 22 | $objPage->arrCONVENIMESSAGE = $arrCONVENIMESSAGE; |
|---|
| 23 | /* |
|---|
| 24 | session_start»þ¤Îno-cache¥Ø¥Ã¥À¡¼¤òÍÞÀ©¤¹¤ë¤³¤È¤Ç |
|---|
| 25 | ¡ÖÌá¤ë¡×¥Ü¥¿¥ó»ÈÍÑ»þ¤Î͸ú´ü¸ÂÀÚ¤ìɽ¼¨¤òÍÞÀ©¤¹¤ë¡£ |
|---|
| 26 | private-no-expire:¥¯¥é¥¤¥¢¥ó¥È¤Î¥¥ã¥Ã¥·¥å¤òµö²Ä¤¹¤ë¡£ |
|---|
| 27 | */ |
|---|
| 28 | session_cache_limiter('private-no-expire'); |
|---|
| 29 | |
|---|
| 30 | } |
|---|
| 31 | } |
|---|
| 32 | |
|---|
| 33 | $conn = new SC_DBConn(); |
|---|
| 34 | $objPage = new LC_Page(); |
|---|
| 35 | $objView = new SC_SiteView(); |
|---|
| 36 | $objSiteSess = new SC_SiteSession(); |
|---|
| 37 | $objCartSess = new SC_CartSession(); |
|---|
| 38 | $objCampaignSess = new SC_CampaignSession(); |
|---|
| 39 | $objSiteInfo = $objView->objSiteInfo; |
|---|
| 40 | $arrInfo = $objSiteInfo->data; |
|---|
| 41 | $objCustomer = new SC_Customer(); |
|---|
| 42 | |
|---|
| 43 | // Á°¤Î¥Ú¡¼¥¸¤ÇÀµ¤·¤¯ÅÐÏ¿¼ê³¤¤¬¹Ô¤ï¤ì¤¿¤«È½Äê |
|---|
| 44 | sfIsPrePage($objSiteSess); |
|---|
| 45 | // ¥æ¡¼¥¶¥æ¥Ë¡¼¥¯ID¤Î¼èÆÀ¤È¹ØÆþ¾õÂÖ¤ÎÀµÅöÀ¤ò¥Á¥§¥Ã¥¯ |
|---|
| 46 | $uniqid = sfCheckNormalAccess($objSiteSess, $objCartSess); |
|---|
| 47 | if ($uniqid != "") { |
|---|
| 48 | |
|---|
| 49 | // ´°Î»½èÍý |
|---|
| 50 | $objQuery = new SC_Query(); |
|---|
| 51 | $objQuery->begin(); |
|---|
| 52 | $order_id = lfDoComplete($objQuery, $uniqid); |
|---|
| 53 | $objQuery->commit(); |
|---|
| 54 | |
|---|
| 55 | // ¥»¥Ã¥·¥ç¥ó¤ËÊݴɤµ¤ì¤Æ¤¤¤ë¾ðÊó¤ò¹¹¿·¤¹¤ë |
|---|
| 56 | $objCustomer->updateSession(); |
|---|
| 57 | |
|---|
| 58 | // ´°Î»¥á¡¼¥ëÁ÷¿® |
|---|
| 59 | if($order_id != "") { |
|---|
| 60 | $order_email = $objQuery->select("order_email", "dtb_order", "order_id = ?", array($order_id)); |
|---|
| 61 | |
|---|
| 62 | //ÅÐÏ¿¤µ¤ì¤Æ¤¤¤ë¥á¡¼¥ë¥¢¥É¥ì¥¹¤¬·ÈÂÓ¤«PC¤«¤Ë±þ¤¸¤ÆÃíʸ´°Î»¥á¡¼¥ë¤Î¥Æ¥ó¥×¥ì¡¼¥È¤òÊѤ¨¤ë |
|---|
| 63 | if(ereg("(ezweb.ne.jp$|docomo.ne.jp$|softbank.ne.jp$|vodafone.ne.jp$)",$order_email[0]['order_email'])){ |
|---|
| 64 | sfSendOrderMail($order_id, '1'); |
|---|
| 65 | }else{ |
|---|
| 66 | sfSendOrderMail($order_id, '0'); |
|---|
| 67 | } |
|---|
| 68 | } |
|---|
| 69 | |
|---|
| 70 | // ¤½¤Î¾¾ðÊó¤Î¼èÆÀ |
|---|
| 71 | $arrResults = $objQuery->getall("SELECT memo02, memo05 FROM dtb_order WHERE order_id = ? ", array($order_id)); |
|---|
| 72 | |
|---|
| 73 | if (count($arrResults) > 0) { |
|---|
| 74 | if (isset($arrResults[0]["memo02"]) || isset($arrResults[0]["memo05"])) { |
|---|
| 75 | // ´°Î»²èÌ̤Çɽ¼¨¤¹¤ë·èºÑÆâÍÆ |
|---|
| 76 | $arrOther = unserialize($arrResults[0]["memo02"]); |
|---|
| 77 | // ´°Î»²èÌ̤«¤éÁ÷¿®¤¹¤ë·èºÑÆâÍÆ |
|---|
| 78 | $arrModuleParam = unserialize($arrResults[0]["memo05"]); |
|---|
| 79 | |
|---|
| 80 | // ¥Ç¡¼¥¿¤òÊÔ½¸ |
|---|
| 81 | foreach($arrOther as $key => $val){ |
|---|
| 82 | // URL¤Î¾ì¹ç¤Ë¤Ï¥ê¥ó¥¯¤Ä¤¤Çɽ¼¨¤µ¤»¤ë |
|---|
| 83 | if (preg_match('/^(https?|ftp)(:\/\/[-_.!~*\'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)$/', $val["value"])) { |
|---|
| 84 | $arrOther[$key]["value"] = "<a href='#' onClick=\"window.open('". $val["value"] . "'); \" >" . $val["value"] ."</a>"; |
|---|
| 85 | } |
|---|
| 86 | } |
|---|
| 87 | |
|---|
| 88 | $objPage->arrOther = $arrOther; |
|---|
| 89 | $objPage->arrModuleParam = $arrModuleParam; |
|---|
| 90 | } |
|---|
| 91 | } |
|---|
| 92 | |
|---|
| 93 | // ¥¢¥Õ¥£¥ê¥¨¥¤¥ÈÍÑ¥³¥ó¥Ð¡¼¥¸¥ç¥ó¥¿¥°¤ÎÀßÄê |
|---|
| 94 | $objPage->tpl_conv_page = AFF_SHOPPING_COMPLETE; |
|---|
| 95 | $objPage->tpl_aff_option = "order_id=$order_id"; |
|---|
| 96 | //¹ç·×²Á³Ê¤Î¼èÆÀ |
|---|
| 97 | $total = $objQuery->get("dtb_order", "total", "order_id = ? ", array($order_id)); |
|---|
| 98 | if($total != "") { |
|---|
| 99 | $objPage->tpl_aff_option.= "|total=$total"; |
|---|
| 100 | } |
|---|
| 101 | } |
|---|
| 102 | |
|---|
| 103 | $objPage->arrInfo = $arrInfo; |
|---|
| 104 | // ¥¥ã¥ó¥Ú¡¼¥ó¤«¤é¤ÎÁ«°Ü¤«¥Á¥§¥Ã¥¯ |
|---|
| 105 | $objPage->is_campaign = $objCampaignSess->getIsCampaign(); |
|---|
| 106 | $objPage->campaign_dir = $objCampaignSess->getCampaignDir(); |
|---|
| 107 | |
|---|
| 108 | $objView->assignobj($objPage); |
|---|
| 109 | // ¥Õ¥ì¡¼¥à¤òÁªÂò(¥¥ã¥ó¥Ú¡¼¥ó¥Ú¡¼¥¸¤«¤éÁ«°Ü¤Ê¤éÊѹ¹) |
|---|
| 110 | $objCampaignSess->pageView($objView); |
|---|
| 111 | |
|---|
| 112 | // ¥»¥Ã¥·¥ç¥ó³«Êü |
|---|
| 113 | $objCampaignSess->delCampaign(); |
|---|
| 114 | //-------------------------------------------------------------------------------------------------------------------------- |
|---|
| 115 | // ¥¨¥Ó¥¹¥¿¥°°úÅϤ·Íѥǡ¼¥¿¤òÀ¸À®¤¹¤ë |
|---|
| 116 | function lfGetEbisData($order_id) { |
|---|
| 117 | $objQuery = new SC_Query(); |
|---|
| 118 | $col = "customer_id, total, order_sex, order_job, to_number(to_char(age(current_timestamp, order_birth), 'YYY'), 999) AS order_age"; |
|---|
| 119 | $arrRet = $objQuery->select($col, "dtb_order", "order_id = ?", array($order_id)); |
|---|
| 120 | |
|---|
| 121 | if($arrRet[0]['customer_id'] > 0) { |
|---|
| 122 | // ²ñ°÷ÈÖ¹æ |
|---|
| 123 | $arrEbis['m1id'] = $arrRet[0]['customer_id']; |
|---|
| 124 | // Èó²ñ°÷or²ñ°÷ |
|---|
| 125 | $arrEbis['o5id'] = '1'; |
|---|
| 126 | } else { |
|---|
| 127 | // ²ñ°÷ÈÖ¹æ |
|---|
| 128 | $arrEbis['m1id'] = ''; |
|---|
| 129 | // Èó²ñ°÷or²ñ°÷ |
|---|
| 130 | $arrEbis['o5id'] = '2'; |
|---|
| 131 | } |
|---|
| 132 | |
|---|
| 133 | // ¹ØÆþ¶â³Û |
|---|
| 134 | $arrEbis['a1id'] = $arrRet[0]['total']; |
|---|
| 135 | // ÀÊÌ |
|---|
| 136 | $arrEbis['o2id'] = $arrRet[0]['order_sex']; |
|---|
| 137 | // ǯÎð |
|---|
| 138 | $arrEbis['o3id'] = $arrRet[0]['order_age']; |
|---|
| 139 | // ¿¦¶È |
|---|
| 140 | $arrEbis['o4id'] = $arrRet[0]['order_job']; |
|---|
| 141 | |
|---|
| 142 | $objQuery->setgroupby("product_id"); |
|---|
| 143 | $arrRet = $objQuery->select("product_id", "dtb_order_detail", "order_id = ?", array($order_id)); |
|---|
| 144 | $arrProducts = sfSwapArray($arrRet); |
|---|
| 145 | |
|---|
| 146 | $line = ""; |
|---|
| 147 | // ¾¦ÉÊID¤ò¥¢¥ó¥À¡¼¥Ð¡¼¤ÇÀܳ¤¹¤ë¡£ |
|---|
| 148 | foreach($arrProducts['product_id'] as $val) { |
|---|
| 149 | if($line != "") { |
|---|
| 150 | $line .= "_$val"; |
|---|
| 151 | } else { |
|---|
| 152 | $line .= "$val"; |
|---|
| 153 | } |
|---|
| 154 | } |
|---|
| 155 | |
|---|
| 156 | // ¾¦ÉÊID |
|---|
| 157 | $arrEbis['o1id'] = $line; |
|---|
| 158 | |
|---|
| 159 | return $arrEbis; |
|---|
| 160 | } |
|---|
| 161 | |
|---|
| 162 | // ´°Î»½èÍý |
|---|
| 163 | function lfDoComplete($objQuery, $uniqid) { |
|---|
| 164 | global $objCartSess; |
|---|
| 165 | global $objSiteSess; |
|---|
| 166 | global $objCampaignSess; |
|---|
| 167 | global $objCustomer; |
|---|
| 168 | global $arrInfo; |
|---|
| 169 | |
|---|
| 170 | // °ì»þ¼õÃí¥Æ¡¼¥Ö¥ë¤ÎÆÉ¹þ |
|---|
| 171 | $arrData = sfGetOrderTemp($uniqid); |
|---|
| 172 | |
|---|
| 173 | // ²ñ°÷¾ðÊóÅÐÏ¿½èÍý |
|---|
| 174 | if ($objCustomer->isLoginSuccess()) { |
|---|
| 175 | // ¿·¤ªÆÏ¤±Àè¤ÎÅÐÏ¿ |
|---|
| 176 | lfSetNewAddr($uniqid, $objCustomer->getValue('customer_id')); |
|---|
| 177 | // ¹ØÆþ½¸·×¤ò¸ÜµÒ¥Æ¡¼¥Ö¥ë¤ËÈ¿±Ç |
|---|
| 178 | lfSetCustomerPurchase($objCustomer->getValue('customer_id'), $arrData, $objQuery); |
|---|
| 179 | } else { |
|---|
| 180 | //¹ØÆþ»þ¶¯À©²ñ°÷ÅÐÏ¿ |
|---|
| 181 | switch(PURCHASE_CUSTOMER_REGIST) { |
|---|
| 182 | //̵¸ú |
|---|
| 183 | case '0': |
|---|
| 184 | // ¹ØÆþ»þ²ñ°÷ÅÐÏ¿ |
|---|
| 185 | if($arrData['member_check'] == '1') { |
|---|
| 186 | // ²¾²ñ°÷ÅÐÏ¿ |
|---|
| 187 | $customer_id = lfRegistPreCustomer($arrData, $arrInfo); |
|---|
| 188 | // ¹ØÆþ½¸·×¤ò¸ÜµÒ¥Æ¡¼¥Ö¥ë¤ËÈ¿±Ç |
|---|
| 189 | lfSetCustomerPurchase($customer_id, $arrData, $objQuery); |
|---|
| 190 | } |
|---|
| 191 | break; |
|---|
| 192 | //͸ú |
|---|
| 193 | case '1': |
|---|
| 194 | // ²¾²ñ°÷ÅÐÏ¿ |
|---|
| 195 | $customer_id = lfRegistPreCustomer($arrData, $arrInfo); |
|---|
| 196 | // ¹ØÆþ½¸·×¤ò¸ÜµÒ¥Æ¡¼¥Ö¥ë¤ËÈ¿±Ç |
|---|
| 197 | lfSetCustomerPurchase($customer_id, $arrData, $objQuery); |
|---|
| 198 | break; |
|---|
| 199 | } |
|---|
| 200 | |
|---|
| 201 | } |
|---|
| 202 | // °ì»þ¥Æ¡¼¥Ö¥ë¤ò¼õÃí¥Æ¡¼¥Ö¥ë¤Ë³ÊǼ¤¹¤ë |
|---|
| 203 | $order_id = lfRegistOrder($objQuery, $arrData, $objCampaignSess); |
|---|
| 204 | // ¥«¡¼¥È¾¦Éʤò¼õÃí¾ÜºÙ¥Æ¡¼¥Ö¥ë¤Ë³ÊǼ¤¹¤ë |
|---|
| 205 | lfRegistOrderDetail($objQuery, $order_id, $objCartSess); |
|---|
| 206 | // ¼õÃí°ì»þ¥Æ¡¼¥Ö¥ë¤Î¾ðÊó¤òºï½ü¤¹¤ë¡£ |
|---|
| 207 | lfDeleteTempOrder($objQuery, $uniqid); |
|---|
| 208 | // ¥¥ã¥ó¥Ú¡¼¥ó¤«¤é¤ÎÁ«°Ü¤Î¾ì¹çÅÐÏ¿¤¹¤ë¡£ |
|---|
| 209 | if($objCampaignSess->getIsCampaign() and $objCartSess->chkCampaign($objCampaignSess->getCampaignId())) { |
|---|
| 210 | lfRegistCampaignOrder($objQuery, $objCampaignSess, $order_id); |
|---|
| 211 | } |
|---|
| 212 | |
|---|
| 213 | // ¥»¥Ã¥·¥ç¥ó¥«¡¼¥ÈÆâ¤Î¾¦Éʤòºï½ü¤¹¤ë¡£ |
|---|
| 214 | $objCartSess->delAllProducts(); |
|---|
| 215 | // Ãíʸ°ì»þID¤ò²ò½ü¤¹¤ë¡£ |
|---|
| 216 | $objSiteSess->unsetUniqId(); |
|---|
| 217 | |
|---|
| 218 | return $order_id; |
|---|
| 219 | } |
|---|
| 220 | |
|---|
| 221 | // ²ñ°÷ÅÐÏ¿¡Ê²¾ÅÐÏ¿¡Ë |
|---|
| 222 | function lfRegistPreCustomer($arrData, $arrInfo) { |
|---|
| 223 | // ¹ØÆþ»þ¤Î²ñ°÷ÅÐÏ¿ |
|---|
| 224 | $sqlval['name01'] = $arrData['order_name01']; |
|---|
| 225 | $sqlval['name02'] = $arrData['order_name02']; |
|---|
| 226 | $sqlval['kana01'] = $arrData['order_kana01']; |
|---|
| 227 | $sqlval['kana02'] = $arrData['order_kana02']; |
|---|
| 228 | $sqlval['zip01'] = $arrData['order_zip01']; |
|---|
| 229 | $sqlval['zip02'] = $arrData['order_zip02']; |
|---|
| 230 | $sqlval['pref'] = $arrData['order_pref']; |
|---|
| 231 | $sqlval['addr01'] = $arrData['order_addr01']; |
|---|
| 232 | $sqlval['addr02'] = $arrData['order_addr02']; |
|---|
| 233 | $sqlval['email'] = $arrData['order_email']; |
|---|
| 234 | $sqlval['tel01'] = $arrData['order_tel01']; |
|---|
| 235 | $sqlval['tel02'] = $arrData['order_tel02']; |
|---|
| 236 | $sqlval['tel03'] = $arrData['order_tel03']; |
|---|
| 237 | $sqlval['fax01'] = $arrData['order_fax01']; |
|---|
| 238 | $sqlval['fax02'] = $arrData['order_fax02']; |
|---|
| 239 | $sqlval['fax03'] = $arrData['order_fax03']; |
|---|
| 240 | $sqlval['sex'] = $arrData['order_sex']; |
|---|
| 241 | $sqlval['password'] = $arrData['password']; |
|---|
| 242 | $sqlval['reminder'] = $arrData['reminder']; |
|---|
| 243 | $sqlval['reminder_answer'] = $arrData['reminder_answer']; |
|---|
| 244 | |
|---|
| 245 | // ¥á¥ë¥Þ¥¬ÇÛ¿®Íѥե饰¤ÎȽÄê |
|---|
| 246 | switch($arrData['mail_flag']) { |
|---|
| 247 | case '1': // HTML¥á¡¼¥ë |
|---|
| 248 | $mail_flag = 4; |
|---|
| 249 | break; |
|---|
| 250 | case '2': // TEXT¥á¡¼¥ë |
|---|
| 251 | $mail_flag = 5; |
|---|
| 252 | break; |
|---|
| 253 | case '3': // ´õ˾¤Ê¤· |
|---|
| 254 | $mail_flag = 6; |
|---|
| 255 | break; |
|---|
| 256 | default: |
|---|
| 257 | $mail_flag = 6; |
|---|
| 258 | break; |
|---|
| 259 | } |
|---|
| 260 | // ¥á¥ë¥Þ¥¬¥Õ¥é¥° |
|---|
| 261 | $sqlval['mailmaga_flg'] = $mail_flag; |
|---|
| 262 | |
|---|
| 263 | // ²ñ°÷²¾ÅÐÏ¿ |
|---|
| 264 | $sqlval['status'] = 1; |
|---|
| 265 | // URLȽÄêÍÑ¥¡¼ |
|---|
| 266 | $sqlval['secret_key'] = sfGetUniqRandomId("t"); |
|---|
| 267 | |
|---|
| 268 | $objQuery = new SC_Query(); |
|---|
| 269 | $sqlval['create_date'] = "now()"; |
|---|
| 270 | $sqlval['update_date'] = "now()"; |
|---|
| 271 | $objQuery->insert("dtb_customer", $sqlval); |
|---|
| 272 | |
|---|
| 273 | // ¸ÜµÒID¤Î¼èÆÀ |
|---|
| 274 | $arrRet = $objQuery->select("customer_id", "dtb_customer", "secret_key = ?", array($sqlval['secret_key'])); |
|---|
| 275 | $customer_id = $arrRet[0]['customer_id']; |
|---|
| 276 | |
|---|
| 277 | //¡¡²¾ÅÐÏ¿´°Î»¥á¡¼¥ëÁ÷¿® |
|---|
| 278 | $objMailPage = new LC_Page(); |
|---|
| 279 | $objMailPage->to_name01 = $arrData['order_name01']; |
|---|
| 280 | $objMailPage->to_name02 = $arrData['order_name02']; |
|---|
| 281 | $objMailPage->CONF = $arrInfo; |
|---|
| 282 | $objMailPage->uniqid = $sqlval['secret_key']; |
|---|
| 283 | $objMailView = new SC_SiteView(); |
|---|
| 284 | $objMailView->assignobj($objMailPage); |
|---|
| 285 | $body = $objMailView->fetch("mail_templates/customer_mail.tpl"); |
|---|
| 286 | |
|---|
| 287 | $objMail = new GC_SendMail(); |
|---|
| 288 | $objMail->setItem( |
|---|
| 289 | '' //¡¡°¸Àè |
|---|
| 290 | , sfMakeSubject("²ñ°÷ÅÐÏ¿¤Î¤´³Îǧ") //¡¡¥µ¥Ö¥¸¥§¥¯¥È |
|---|
| 291 | , $body //¡¡ËÜʸ |
|---|
| 292 | , $arrInfo['email03'] //¡¡ÇÛÁ÷¸µ¥¢¥É¥ì¥¹ |
|---|
| 293 | , $arrInfo['shop_name'] //¡¡ÇÛÁ÷¸µ¡¡Ì¾Á° |
|---|
| 294 | , $arrInfo["email03"] //¡¡reply_to |
|---|
| 295 | , $arrInfo["email04"] //¡¡return_path |
|---|
| 296 | , $arrInfo["email04"] // Errors_to |
|---|
| 297 | , $arrInfo["email01"] // Bcc |
|---|
| 298 | ); |
|---|
| 299 | // °¸Àè¤ÎÀßÄê |
|---|
| 300 | $name = $arrData['order_name01'] . $arrData['order_name02'] ." ÍÍ"; |
|---|
| 301 | $objMail->setTo($arrData['order_email'], $name); |
|---|
| 302 | $objMail->sendMail(); |
|---|
| 303 | |
|---|
| 304 | return $customer_id; |
|---|
| 305 | } |
|---|
| 306 | |
|---|
| 307 | // ¼õÃí¥Æ¡¼¥Ö¥ë¤ØÅÐÏ¿ |
|---|
| 308 | function lfRegistOrder($objQuery, $arrData, $objCampaignSess) { |
|---|
| 309 | $sqlval = $arrData; |
|---|
| 310 | |
|---|
| 311 | // ¼õÃí¥Æ¡¼¥Ö¥ë¤Ë½ñ¤¹þ¤Þ¤Ê¤¤Îó¤ò½üµî |
|---|
| 312 | unset($sqlval['mailmaga_flg']); // ¥á¥ë¥Þ¥¬¥Á¥§¥Ã¥¯ |
|---|
| 313 | unset($sqlval['deliv_check']); // Ê̤ΤªÆÏ¤±Àè¥Á¥§¥Ã¥¯ |
|---|
| 314 | unset($sqlval['point_check']); // ¥Ý¥¤¥ó¥ÈÍøÍÑ¥Á¥§¥Ã¥¯ |
|---|
| 315 | unset($sqlval['member_check']); // ¹ØÆþ»þ²ñ°÷¥Á¥§¥Ã¥¯ |
|---|
| 316 | unset($sqlval['password']); // ¥í¥°¥¤¥ó¥Ñ¥¹¥ï¡¼¥É |
|---|
| 317 | unset($sqlval['reminder']); // ¥ê¥Þ¥¤¥ó¥À¡¼¼ÁÌä |
|---|
| 318 | unset($sqlval['reminder_answer']); // ¥ê¥Þ¥¤¥ó¥À¡¼Åú¤¨ |
|---|
| 319 | unset($sqlval['mail_flag']); // ¥á¡¼¥ë¥Õ¥é¥° |
|---|
| 320 | |
|---|
| 321 | // Ãíʸ¥¹¥Æ¡¼¥¿¥¹:»ØÄ̵꤬¤±¤ì¤Ð¿·µ¬¼õÉÕ¤ËÀßÄê |
|---|
| 322 | if($sqlval["status"] == ""){ |
|---|
| 323 | $sqlval['status'] = '1'; |
|---|
| 324 | } |
|---|
| 325 | |
|---|
| 326 | // Ê̤ΤªÆÏ¤±Àè¤ò»ØÄꤷ¤Æ¤¤¤Ê¤¤¾ì¹ç¡¢ÇÛÁ÷Àè¤ËÅÐÏ¿½»½ê¤ò¥³¥Ô¡¼¤¹¤ë¡£ |
|---|
| 327 | if($arrData["deliv_check"] == "-1") { |
|---|
| 328 | $sqlval['deliv_name01'] = $arrData['order_name01']; |
|---|
| 329 | $sqlval['deliv_name02'] = $arrData['order_name02']; |
|---|
| 330 | $sqlval['deliv_kana01'] = $arrData['order_kana01']; |
|---|
| 331 | $sqlval['deliv_kana02'] = $arrData['order_kana02']; |
|---|
| 332 | $sqlval['deliv_pref'] = $arrData['order_pref']; |
|---|
| 333 | $sqlval['deliv_zip01'] = $arrData['order_zip01']; |
|---|
| 334 | $sqlval['deliv_zip02'] = $arrData['order_zip02']; |
|---|
| 335 | $sqlval['deliv_addr01'] = $arrData['order_addr01']; |
|---|
| 336 | $sqlval['deliv_addr02'] = $arrData['order_addr02']; |
|---|
| 337 | $sqlval['deliv_tel01'] = $arrData['order_tel01']; |
|---|
| 338 | $sqlval['deliv_tel02'] = $arrData['order_tel02']; |
|---|
| 339 | $sqlval['deliv_tel03'] = $arrData['order_tel03']; |
|---|
| 340 | } |
|---|
| 341 | |
|---|
| 342 | $order_id = $arrData['order_id']; // ¥ª¡¼¥À¡¼ID |
|---|
| 343 | $sqlval['create_date'] = 'now()'; // ¼õÃíÆü |
|---|
| 344 | |
|---|
| 345 | // ¥¥ã¥ó¥Ú¡¼¥óID |
|---|
| 346 | if($objCampaignSess->getIsCampaign()) $sqlval['campaign_id'] = $objCampaignSess->getCampaignId(); |
|---|
| 347 | |
|---|
| 348 | // ¥²¥Ã¥È¤ÎÃͤò¥¤¥ó¥µ¡¼¥È |
|---|
| 349 | //$sqlval = lfGetInsParam($sqlval); |
|---|
| 350 | |
|---|
| 351 | // INSERT¤Î¼Â¹Ô |
|---|
| 352 | $objQuery->insert("dtb_order", $sqlval); |
|---|
| 353 | |
|---|
| 354 | return $order_id; |
|---|
| 355 | } |
|---|
| 356 | |
|---|
| 357 | // ¼õÃí¾ÜºÙ¥Æ¡¼¥Ö¥ë¤ØÅÐÏ¿ |
|---|
| 358 | function lfRegistOrderDetail($objQuery, $order_id, $objCartSess) { |
|---|
| 359 | // ¥«¡¼¥ÈÆâ¾ðÊó¤Î¼èÆÀ |
|---|
| 360 | $arrCart = $objCartSess->getCartList(); |
|---|
| 361 | $max = count($arrCart); |
|---|
| 362 | |
|---|
| 363 | // ´û¤Ë¸ºß¤¹¤ë¾ÜºÙ¥ì¥³¡¼¥É¤ò¾Ã¤·¤Æ¤ª¤¯¡£ |
|---|
| 364 | $objQuery->delete("dtb_order_detail", "order_id = $order_id"); |
|---|
| 365 | |
|---|
| 366 | // µ¬³Ê̾°ìÍ÷ |
|---|
| 367 | $arrClassName = sfGetIDValueList("dtb_class", "class_id", "name"); |
|---|
| 368 | // µ¬³ÊʬÎà̾°ìÍ÷ |
|---|
| 369 | $arrClassCatName = sfGetIDValueList("dtb_classcategory", "classcategory_id", "name"); |
|---|
| 370 | |
|---|
| 371 | for ($i = 0; $i < $max; $i++) { |
|---|
| 372 | // ¾¦Éʵ¬³Ê¾ðÊó¤Î¼èÆÀ |
|---|
| 373 | $arrData = sfGetProductsClass($arrCart[$i]['id']); |
|---|
| 374 | |
|---|
| 375 | // ¸ºß¤¹¤ë¾¦ÉʤΤßɽ¼¨¤¹¤ë¡£ |
|---|
| 376 | if($arrData != "") { |
|---|
| 377 | $sqlval['order_id'] = $order_id; |
|---|
| 378 | $sqlval['product_id'] = $arrCart[$i]['id'][0]; |
|---|
| 379 | $sqlval['classcategory_id1'] = $arrCart[$i]['id'][1]; |
|---|
| 380 | $sqlval['classcategory_id2'] = $arrCart[$i]['id'][2]; |
|---|
| 381 | $sqlval['product_name'] = $arrData['name']; |
|---|
| 382 | $sqlval['product_code'] = $arrData['product_code']; |
|---|
| 383 | $sqlval['classcategory_name1'] = $arrClassCatName[$arrData['classcategory_id1']]; |
|---|
| 384 | $sqlval['classcategory_name2'] = $arrClassCatName[$arrData['classcategory_id2']]; |
|---|
| 385 | $sqlval['point_rate'] = $arrCart[$i]['point_rate']; |
|---|
| 386 | $sqlval['price'] = $arrCart[$i]['price']; |
|---|
| 387 | $sqlval['quantity'] = $arrCart[$i]['quantity']; |
|---|
| 388 | lfReduceStock($objQuery, $arrCart[$i]['id'], $arrCart[$i]['quantity']); |
|---|
| 389 | // INSERT¤Î¼Â¹Ô |
|---|
| 390 | $objQuery->insert("dtb_order_detail", $sqlval); |
|---|
| 391 | } else { |
|---|
| 392 | sfDispSiteError(CART_NOT_FOUND); |
|---|
| 393 | } |
|---|
| 394 | } |
|---|
| 395 | } |
|---|
| 396 | |
|---|
| 397 | // ¥¥ã¥ó¥Ú¡¼¥ó¼õÃí¥Æ¡¼¥Ö¥ë¤ØÅÐÏ¿ |
|---|
| 398 | function lfRegistCampaignOrder($objQuery, $objCampaignSess, $order_id) { |
|---|
| 399 | |
|---|
| 400 | // ¼õÃí¥Ç¡¼¥¿¤ò¼èÆÀ |
|---|
| 401 | $cols = "order_id, campaign_id, customer_id, message, order_name01, order_name02,". |
|---|
| 402 | "order_kana01, order_kana02, order_email, order_tel01, order_tel02, order_tel03,". |
|---|
| 403 | "order_fax01, order_fax02, order_fax03, order_zip01, order_zip02, order_pref, order_addr01,". |
|---|
| 404 | "order_addr02, order_sex, order_birth, order_job, deliv_name01, deliv_name02, deliv_kana01,". |
|---|
| 405 | "deliv_kana02, deliv_tel01, deliv_tel02, deliv_tel03, deliv_fax01, deliv_fax02, deliv_fax03,". |
|---|
| 406 | "deliv_zip01, deliv_zip02, deliv_pref, deliv_addr01, deliv_addr02, payment_total"; |
|---|
| 407 | |
|---|
| 408 | $arrOrder = $objQuery->select($cols, "dtb_order", "order_id = ?", array($order_id)); |
|---|
| 409 | |
|---|
| 410 | $sqlval = $arrOrder[0]; |
|---|
| 411 | $sqlval['create_date'] = 'now()'; |
|---|
| 412 | |
|---|
| 413 | // INSERT¤Î¼Â¹Ô |
|---|
| 414 | $objQuery->insert("dtb_campaign_order", $sqlval); |
|---|
| 415 | |
|---|
| 416 | // ¿½¤·¹þ¤ß¿ô¤Î¹¹¿· |
|---|
| 417 | $total_count = $objQuery->get("dtb_campaign", "total_count", "campaign_id = ?", array($sqlval['campaign_id'])); |
|---|
| 418 | $arrCampaign['total_count'] = $total_count += 1; |
|---|
| 419 | $objQuery->update("dtb_campaign", $arrCampaign, "campaign_id = ?", array($sqlval['campaign_id'])); |
|---|
| 420 | |
|---|
| 421 | } |
|---|
| 422 | |
|---|
| 423 | |
|---|
| 424 | |
|---|
| 425 | /* ¼õÃí°ì»þ¥Æ¡¼¥Ö¥ë¤Îºï½ü */ |
|---|
| 426 | function lfDeleteTempOrder($objQuery, $uniqid) { |
|---|
| 427 | $where = "order_temp_id = ?"; |
|---|
| 428 | $sqlval['del_flg'] = 1; |
|---|
| 429 | $objQuery->update("dtb_order_temp", $sqlval, $where, array($uniqid)); |
|---|
| 430 | // $objQuery->delete("dtb_order_temp", $where, array($uniqid)); |
|---|
| 431 | } |
|---|
| 432 | |
|---|
| 433 | // ¼õÃí°ì»þ¥Æ¡¼¥Ö¥ë¤Î½»½ê¤¬ÅÐÏ¿ºÑ¤ß¥Æ¡¼¥Ö¥ë¤È°Û¤Ê¤ë¾ì¹ç¤Ï¡¢Ê̤ΤªÆÏ¤±Àè¤ËÄɲ乤ë |
|---|
| 434 | function lfSetNewAddr($uniqid, $customer_id) { |
|---|
| 435 | $objQuery = new SC_Query(); |
|---|
| 436 | $diff = false; |
|---|
| 437 | $find_same = false; |
|---|
| 438 | |
|---|
| 439 | $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"; |
|---|
| 440 | $where = "order_temp_id = ?"; |
|---|
| 441 | $arrRet = $objQuery->select($col, "dtb_order_temp", $where, array($uniqid)); |
|---|
| 442 | |
|---|
| 443 | // Í×ÁÇ̾¤Îdeliv_¤òºï½ü¤¹¤ë¡£ |
|---|
| 444 | foreach($arrRet[0] as $key => $val) { |
|---|
| 445 | $keyname = ereg_replace("^deliv_", "", $key); |
|---|
| 446 | $arrNew[$keyname] = $val; |
|---|
| 447 | } |
|---|
| 448 | |
|---|
| 449 | // ²ñ°÷¾ðÊ󥯡¼¥Ö¥ë¤È¤ÎÈæ³Ó |
|---|
| 450 | $col = "name01,name02,kana01,kana02,tel01,tel02,tel03,zip01,zip02,pref,addr01,addr02"; |
|---|
| 451 | $where = "customer_id = ?"; |
|---|
| 452 | $arrCustomerAddr = $objQuery->select($col, "dtb_customer", $where, array($customer_id)); |
|---|
| 453 | |
|---|
| 454 | // ²ñ°÷¾ðÊó¤Î½»½ê¤È°Û¤Ê¤ë¾ì¹ç |
|---|
| 455 | if($arrNew != $arrCustomerAddr[0]) { |
|---|
| 456 | // Ê̤ΤªÆÏ¤±Àè¥Æ¡¼¥Ö¥ë¤Î½»½ê¤ÈÈæ³Ó¤¹¤ë |
|---|
| 457 | $col = "name01,name02,kana01,kana02,tel01,tel02,tel03,zip01,zip02,pref,addr01,addr02"; |
|---|
| 458 | $where = "customer_id = ?"; |
|---|
| 459 | $arrOtherAddr = $objQuery->select($col, "dtb_other_deliv", $where, array($customer_id)); |
|---|
| 460 | |
|---|
| 461 | foreach($arrOtherAddr as $arrval) { |
|---|
| 462 | if($arrNew == $arrval) { |
|---|
| 463 | // ¤¹¤Ç¤ËƱ¤¸½»½ê¤¬ÅÐÏ¿¤µ¤ì¤Æ¤¤¤ë |
|---|
| 464 | $find_same = true; |
|---|
| 465 | } |
|---|
| 466 | } |
|---|
| 467 | |
|---|
| 468 | if(!$find_same) { |
|---|
| 469 | $diff = true; |
|---|
| 470 | } |
|---|
| 471 | } |
|---|
| 472 | |
|---|
| 473 | // ¿·¤·¤¤¤ªÆÏ¤±À褬ÅÐÏ¿ºÑ¤ß¤Î¤â¤Î¤È°Û¤Ê¤ë¾ì¹ç¤ÏÊ̤ΤªÆÏ¤±Àè¥Æ¡¼¥Ö¥ë¤ËÅÐÏ¿¤¹¤ë |
|---|
| 474 | if($diff) { |
|---|
| 475 | $sqlval = $arrNew; |
|---|
| 476 | $sqlval['customer_id'] = $customer_id; |
|---|
| 477 | $objQuery->insert("dtb_other_deliv", $sqlval); |
|---|
| 478 | } |
|---|
| 479 | } |
|---|
| 480 | |
|---|
| 481 | /* ¹ØÆþ¾ðÊó¤ò²ñ°÷¥Æ¡¼¥Ö¥ë¤ËÅÐÏ¿¤¹¤ë */ |
|---|
| 482 | function lfSetCustomerPurchase($customer_id, $arrData, $objQuery) { |
|---|
| 483 | $col = "first_buy_date, last_buy_date, buy_times, buy_total, point"; |
|---|
| 484 | $where = "customer_id = ?"; |
|---|
| 485 | $arrRet = $objQuery->select($col, "dtb_customer", $where, array($customer_id)); |
|---|
| 486 | $sqlval = $arrRet[0]; |
|---|
| 487 | |
|---|
| 488 | if($sqlval['first_buy_date'] == "") { |
|---|
| 489 | $sqlval['first_buy_date'] = "Now()"; |
|---|
| 490 | } |
|---|
| 491 | $sqlval['last_buy_date'] = "Now()"; |
|---|
| 492 | $sqlval['buy_times']++; |
|---|
| 493 | $sqlval['buy_total']+= $arrData['total']; |
|---|
| 494 | $sqlval['point'] = ($sqlval['point'] + $arrData['add_point'] - $arrData['use_point']); |
|---|
| 495 | |
|---|
| 496 | // ¥Ý¥¤¥ó¥È¤¬ÉÔ¤·¤Æ¤¤¤ë¾ì¹ç |
|---|
| 497 | if($sqlval['point'] < 0) { |
|---|
| 498 | $objQuery->rollback(); |
|---|
| 499 | sfDispSiteError(LACK_POINT); |
|---|
| 500 | } |
|---|
| 501 | |
|---|
| 502 | $objQuery->update("dtb_customer", $sqlval, $where, array($customer_id)); |
|---|
| 503 | } |
|---|
| 504 | |
|---|
| 505 | // ºß¸Ë¤ò¸º¤é¤¹½èÍý |
|---|
| 506 | function lfReduceStock($objQuery, $arrID, $quantity) { |
|---|
| 507 | $where = "product_id = ? AND classcategory_id1 = ? AND classcategory_id2 = ?"; |
|---|
| 508 | $arrRet = $objQuery->select("stock, stock_unlimited", "dtb_products_class", $where, $arrID); |
|---|
| 509 | |
|---|
| 510 | // Çä¤êÀڤ쥨¥é¡¼ |
|---|
| 511 | if(($arrRet[0]['stock_unlimited'] != '1' && $arrRet[0]['stock'] < $quantity) || $quantity == 0) { |
|---|
| 512 | $objQuery->rollback(); |
|---|
| 513 | sfDispSiteError(SOLD_OUT, "", true); |
|---|
| 514 | // ̵À©¸Â¤Î¾ì¹ç¡¢ºß¸Ë¤ÏNULL |
|---|
| 515 | } elseif($arrRet[0]['stock_unlimited'] == '1') { |
|---|
| 516 | $sqlval['stock'] = null; |
|---|
| 517 | $objQuery->update("dtb_products_class", $sqlval, $where, $arrID); |
|---|
| 518 | // ºß¸Ë¤ò¸º¤é¤¹ |
|---|
| 519 | } else { |
|---|
| 520 | $sqlval['stock'] = ($arrRet[0]['stock'] - $quantity); |
|---|
| 521 | if($sqlval['stock'] == "") { |
|---|
| 522 | $sqlval['stock'] = '0'; |
|---|
| 523 | } |
|---|
| 524 | $objQuery->update("dtb_products_class", $sqlval, $where, $arrID); |
|---|
| 525 | } |
|---|
| 526 | } |
|---|
| 527 | |
|---|
| 528 | // GET¤ÎÃͤò¥¤¥ó¥µ¡¼¥ÈÍѤËÀ°¤¨¤ë |
|---|
| 529 | function lfGetInsParam($sqlVal){ |
|---|
| 530 | |
|---|
| 531 | foreach($_GET as $key => $val){ |
|---|
| 532 | // ¥«¥é¥à¤Î¸ºß¥Á¥§¥Ã¥¯ |
|---|
| 533 | if(sfColumnExists("dtb_order", $key)) $sqlVal[$key] = $val; |
|---|
| 534 | } |
|---|
| 535 | |
|---|
| 536 | return $sqlVal; |
|---|
| 537 | } |
|---|
| 538 | |
|---|
| 539 | ?> |
|---|