주문내역 상태 처리시 문자 메일 에스크로 배송 처리 코드 추가

This commit is contained in:
chicpro
2013-11-06 17:06:35 +09:00
parent 310a1d285f
commit 18b7ae8d02
8 changed files with 143 additions and 167 deletions

View File

@ -1,9 +1,28 @@
<?php
$sub_menu = '400400';
include_once('./_common.php');
include_once(G5_LIB_PATH.'/mailer.lib.php');
include_once(G5_LIB_PATH.'/icode.sms.lib.php');
define("_ORDERMAIL_", true);
//print_r2($_POST); exit;
$sms_count = 0;
if($config['cf_sms_use'] == 'icode' && $_POST['send_sms'])
{
$SMS = new SMS;
$SMS->SMS_con($config['cf_icode_server_ip'], $config['cf_icode_id'], $config['cf_icode_pw'], $config['cf_icode_server_port']);
}
$escrow_count = 0;
if($_POST['send_escrow']) {
$escrow_tno = array();
$escrow_corp = array();
$escrow_numb = array();
$escrow_idx = 0;
}
// 상품옵션별재고 또는 상품재고에 더하기
function add_io_stock($it_id, $ct_qty, $io_id="", $io_type=0)
{
@ -72,7 +91,10 @@ function order_update_delivery($od_id, $mb_id, $change_status, $delivery)
{
global $g5;
$sql = " update {$g5['g5_shop_order_table']} set od_delivery_company = '{$delivery['delivery_company']}', od_invoice = '{$delivery['invoice']}', od_invoice_time = '{$delivery['invoice_time']}' where od_id = '$od_id' and od_status = '배송' ";
if($change_status != '배송')
return;
$sql = " update {$g5['g5_shop_order_table']} set od_delivery_company = '{$delivery['delivery_company']}', od_invoice = '{$delivery['invoice']}', od_invoice_time = '{$delivery['invoice_time']}' where od_id = '$od_id' and od_status = '준비' ";
sql_query($sql);
$sql = " select * from {$g5['g5_shop_cart_table']} where od_id = '$od_id' ";
@ -80,54 +102,46 @@ function order_update_delivery($od_id, $mb_id, $change_status, $delivery)
for ($i=0; $row=sql_fetch_array($result); $i++)
{
// 재고를 이미 사용했거나 재고에서 이미 뺐다면
// 재고를 사용하지 않았다면
$stock_use = $row['ct_stock_use'];
if ($row['ct_stock_use'])
if(!$row['ct_stock_use'])
{
if ($change_status == '주문' ||
$change_status == '취소' ||
$change_status == '반품' ||
$change_status == '품절')
{
// 재고에 다시 더한다.
add_io_stock($row['it_id'], $row['ct_qty'], $row['io_id'], $row['io_type']);
$stock_use = 0;
}
}
else
{
// 재고 오류로 인한 수정
if ($change_status == '배송' ||
$change_status == '완료')
{
// 재고에서 뺀다.
subtract_io_stock($row['it_id'], $row['ct_qty'], $row['io_id'], $row['io_type']);
$stock_use = 1;
}
}
// 재고에서 뺀다.
subtract_io_stock($row['it_id'], $row['ct_qty'], $row['io_id'], $row['io_type']);
$stock_use = 1;
$point_use = $row['ct_point_use'];
// 회원이면서 포인트가 0보다 크거나 이미 포인트를 부여했다면 뺀다.
if ($mb_id && $row['ct_point'] && $row['ct_point_use'])
{
delete_point($mb_id, "@delivery", $mb_id, "$od_id,{$row['ct_id']}");
$point_use = 0;
$sql = " update {$g5['g5_shop_cart_table']} set ct_stock_use = '$stock_use' where od_id = '{$row['ct_id']}' ";
sql_query($sql);
}
/*
$sql = " update {$g5['g5_shop_cart_table']}
set ct_point_use = '$point_use',
ct_stock_use = '$stock_use',
ct_history = CONCAT(ct_history,'$ct_history')
where od_id = '$od_id' ";
*/
$sql = " update {$g5['g5_shop_cart_table']} set ct_point_use = '$point_use', ct_stock_use = '$stock_use' where od_id = '$od_id' ";
sql_query($sql);
}
}
// 처리내용 SMS
function conv_sms_contents($od_id, $contents)
{
global $g5, $config, $default;
$sms_contents = '';
if ($od_id && $config['cf_sms_use'] == 'icode')
{
$sql = " select od_id, od_name, od_invoice, od_receipt_price, od_delivery_company
from {$g5['g5_shop_order_table']} where od_id = '$od_id' ";
$od = sql_fetch($sql);
$sms_contents = $contents;
$sms_contents = preg_replace("/{이름}/", $od['od_name'], $sms_contents);
$sms_contents = preg_replace("/{입금액}/", number_format($od['od_receipt_price']), $sms_contents);
$sms_contents = preg_replace("/{택배회사}/", $od['od_delivery_company'], $sms_contents);
$sms_contents = preg_replace("/{운송장번호}/", $od['od_invoice'], $sms_contents);
$sms_contents = preg_replace("/{주문번호}/", $od['od_id'], $sms_contents);
$sms_contents = preg_replace("/{회사명}/", $default['de_admin_company_name'], $sms_contents);
}
return iconv("utf-8", "euc-kr", stripslashes($sms_contents));
}
for ($i=0; $i<count($_POST['chk']); $i++)
{
@ -155,6 +169,25 @@ for ($i=0; $i<count($_POST['chk']); $i++)
if ($od['od_settle_case'] != '무통장') continue;
change_status($od_id, '주문', '입금');
order_update_receipt($od_id);
// SMS
if($config['cf_sms_use'] == 'icode' && $_POST['send_sms'] && $default['de_sms_use4']) {
$sms_contents = conv_sms_contents($od_id, $default['de_sms_cont4']);
if($sms_contents) {
$receive_number = preg_replace("/[^0-9]/", "", $od['od_hp']); // 수신자번호
$send_number = preg_replace("/[^0-9]/", "", $default['de_admin_company_tel']); // 발신자번호
if($receive_number && $send_number) {
$SMS->Add($receive_number, $send_number, $config['cf_icode_id'], $sms_contents, "");
$sms_count++;
}
}
}
// 메일
if($config['cf_email_use'] && $_POST['od_send_mail'])
include './ordermail.inc.php';
break;
case '입금' :
@ -164,67 +197,42 @@ for ($i=0; $i<count($_POST['chk']); $i++)
case '준비' :
if ($change_status != '배송') continue;
change_status($od_id, '준비', '배송');
$delivery['invoice'] = $invoice;
$delivery['invoice_time'] = $invoice_time;
$delivery['delivery_company'] = $delivery_company;
order_update_delivery($od_id, $od['mb_id'], $change_status, $delivery);
change_status($od_id, '준비', '배송');
/*
$sql = " update {$g5['g5_shop_order_table']}
set od_delivery_company = '$delivery_company',
od_invoice = '$invoice',
od_invoice_time = '$invoice_time'
where od_id = '$od_id' and od_status = '배송' ";
sql_query($sql, true);
// SMS
if($config['cf_sms_use'] == 'icode' && $_POST['send_sms'] && $default['de_sms_use5']) {
$sms_contents = conv_sms_contents($od_id, $default['de_sms_cont5']);
if($sms_contents) {
$receive_number = preg_replace("/[^0-9]/", "", $od['od_hp']); // 수신자번호
$send_number = preg_replace("/[^0-9]/", "", $default['de_admin_company_tel']); // 발신자번호
$sql = " select * from {$g5['g5_shop_cart_table']} where od_id = '$od_id' ";
$result = sql_query($sql);
for ($i=0; $row=sql_fetch_array($result); $i++)
{
// 재고를 이미 사용했거나 재고에서 이미 뺐다면
$stock_use = $row['ct_stock_use'];
if ($row['ct_stock_use'])
{
if ($ct_status == '주문' || $ct_status == '취소' || $ct_status == '반품' || $ct_status == '품절')
{
$stock_use = 0;
// 재고에 다시 더한다.
add_io_stock($row['it_id'], $row['ct_qty'], $row['io_id'], $row['io_type']);
if($receive_number && $send_number) {
$SMS->Add($receive_number, $send_number, $config['cf_icode_id'], $sms_contents, "");
$sms_count++;
}
}
else
{
// 재고 오류로 인한 수정
if ($ct_status == '배송' || $ct_status == '완료')
{
$stock_use = 1;
// 재고에서 뺀다.
subtract_io_stock($row['it_id'], $row['ct_qty'], $row['io_id'], $row['io_type']);
}
}
$point_use = $row['ct_point_use'];
// 회원이면서 포인트가 0보다 크거나 이미 포인트를 부여했다면 뺀다.
if ($od['mb_id'] && $row['ct_point'] && $row['ct_point_use'])
{
$point_use = 0;
delete_point($od['mb_id'], "@delivery", $od['mb_id'], "$od_id,{$row['ct_id']}");
}
$sql = " update {$g5['g5_shop_cart_table']}
set ct_point_use = '$point_use',
ct_stock_use = '$stock_use',
ct_history = CONCAT(ct_history,'$ct_history')
where od_id = '{$row['od_id']}' ";
sql_query($sql);
}
*/
// 메일
if($config['cf_email_use'] && $_POST['od_send_mail'])
include './ordermail.inc.php';
// 에스크로 배송
if($_POST['send_escrow'] && $od['od_tno'] && $od['od_escrow']) {
$od = sql_fetch(" select * from {$g5['g5_shop_order_table']} where od_id = '$od_id' ");
$escrow_tno[$escrow_idx] = $od['od_tno'];
$escrow_numb[$escrow_idx] = $od['od_invoice'];
$escrow_corp[$escrow_idx] = $od['od_delivery_company'];
$escrow_idx++;
$escrow_count++;
}
break;
@ -251,6 +259,18 @@ for ($i=0; $i<count($_POST['chk']); $i++)
}
// SMS
if($config['cf_sms_use'] == 'icode' && $_POST['send_sms'] && $sms_count)
{
$SMS->Send();
}
// 에스크로 배송
if($_POST['send_escrow'] && $escrow_count)
{
include_once('./orderescrow.inc.php');
}
$qstr = "sort1=$sort1&amp;sort2=$sort2&amp;sel_field=$sel_field&amp;search=$search";
$qstr .= "&amp;od_status=$od_status";
$qstr .= "&amp;od_settle_case=$od_settle_case";