diff --git a/adm/shop_admin/itemdelete.inc.php b/adm/shop_admin/itemdelete.inc.php index c06101225..04072564e 100644 --- a/adm/shop_admin/itemdelete.inc.php +++ b/adm/shop_admin/itemdelete.inc.php @@ -41,7 +41,7 @@ if (!function_exists("itemdelete")) { @unlink(G5_DATA_PATH."/item/$it_id"."_t"); // 장바구니 삭제 - $sql = " delete from {$g5['g5_shop_cart_table']} where it_id = '$it_id' "; + $sql = " delete from {$g5['g5_shop_cart_table']} where it_id = '$it_id' and ct_status = '쇼핑' "; sql_query($sql); // 이벤트삭제 diff --git a/adm/shop_admin/orderform.php b/adm/shop_admin/orderform.php index a17b63b2b..57be8d64a 100644 --- a/adm/shop_admin/orderform.php +++ b/adm/shop_admin/orderform.php @@ -77,6 +77,16 @@ if(!sql_query(" select ad_addr3 from {$g5['g5_shop_order_address_table']} limit sql_query(" ALTER TABLE `{$g5['g5_shop_order_address_table']}` ADD `ad_addr3` varchar(255) NOT NULL DEFAULT '' AFTER `ad_addr2` ", true); } + +// 배송비정보 필드 cart 테이블에 추가 +if(!sql_query(" select it_sc_type from {$g5['g5_shop_cart_table']} limit 1 ", false)) { + sql_query(" ALTER TABLE `{$g5['g5_shop_cart_table']}` + ADD `it_sc_type` tinyint(4) NOT NULL DEFAULT '0' AFTER `it_name`, + ADD `it_sc_method` tinyint(4) NOT NULL DEFAULT '0' AFTER `it_sc_type`, + ADD `it_sc_price` int(11) NOT NULL DEFAULT '0' AFTER `it_sc_method`, + ADD `it_sc_minimum` int(11) NOT NULL DEFAULT '0' AFTER `it_sc_price`, + ADD `it_sc_qty` int(11) NOT NULL DEFAULT '0' AFTER `it_sc_minimum` ", true); +} ?>
diff --git a/adm/shop_admin/orderformreceiptupdate.php b/adm/shop_admin/orderformreceiptupdate.php index be16ac70d..d7af08281 100644 --- a/adm/shop_admin/orderformreceiptupdate.php +++ b/adm/shop_admin/orderformreceiptupdate.php @@ -56,13 +56,17 @@ if($_POST['od_delivery_company'] && $_POST['od_invoice'] && in_array($od['od_sta $cart_status = true; } +// 미수금액 +$od_misu = ( $od['od_cart_price'] - $od['od_cancel_price'] + $od_send_cost + $od_send_cost2 ) + - ( $od['od_cart_coupon'] + $od['od_coupon'] + $od['od_send_coupon'] ) + - ( $od['od_receipt_price'] + $od['od_receipt_point'] - $od['od_refund_price'] ); + // 미수금 정보 등 반영 $sql = " update {$g5['g5_shop_order_table']} - set od_misu = '{$info['od_misu']}', + set od_misu = '$od_misu', od_tax_mny = '{$info['od_tax_mny']}', od_vat_mny = '{$info['od_vat_mny']}', od_free_mny = '{$info['od_free_mny']}', - od_send_cost = '{$info['od_send_cost']}', od_status = '$od_status' where od_id = '$od_id' "; sql_query($sql); diff --git a/install/gnuboard5shop.sql b/install/gnuboard5shop.sql index 4b51620ca..aea52a3e7 100644 --- a/install/gnuboard5shop.sql +++ b/install/gnuboard5shop.sql @@ -33,6 +33,11 @@ CREATE TABLE IF NOT EXISTS `g5_shop_cart` ( `mb_id` varchar(255) NOT NULL DEFAULT '', `it_id` varchar(20) NOT NULL DEFAULT '', `it_name` varchar(255) NOT NULL DEFAULT '', + `it_sc_type` tinyint(4) NOT NULL DEFAULT '0', + `it_sc_method` tinyint(4) NOT NULL DEFAULT '0', + `it_sc_price` int(11) NOT NULL DEFAULT '0', + `it_sc_minimum` int(11) NOT NULL DEFAULT '0', + `it_sc_qty` int(11) NOT NULL DEFAULT '0', `ct_status` varchar(255) NOT NULL DEFAULT '', `ct_history` text NOT NULL, `ct_price` int(11) NOT NULL DEFAULT '0', diff --git a/lib/shop.lib.php b/lib/shop.lib.php index 714e0ca80..dc5c300f7 100644 --- a/lib/shop.lib.php +++ b/lib/shop.lib.php @@ -1695,10 +1695,12 @@ function get_sendcost($cart_id, $selected=1) SUM(ct_qty) as qty from {$g5['g5_shop_cart_table']} where it_id = '{$sc['it_id']}' - and od_id = '$cart_id' "; + and od_id = '$cart_id' + and ct_status IN ( '쇼핑', '주문', '입금', '준비', '배송', '완료' ) + and ct_select = '$selected'"; $sum = sql_fetch($sql); - $send_cost = get_item_sendcost($sc['it_id'], $sum['price'], $sum['qty']); + $send_cost = get_item_sendcost($sc['it_id'], $sum['price'], $sum['qty'], $cart_id); if($send_cost > 0) $total_send_cost += $send_cost; @@ -1727,33 +1729,36 @@ function get_sendcost($cart_id, $selected=1) // 상품별 배송비 -function get_item_sendcost($it_id, $price, $qty) +function get_item_sendcost($it_id, $price, $qty, $cart_id) { global $g5, $default; $sql = " select it_id, it_sc_type, it_sc_method, it_sc_price, it_sc_minimum, it_sc_qty - from {$g5['g5_shop_item_table']} - where it_id = '$it_id' "; - $it = sql_fetch($sql); - if(!$it['it_id']) + from {$g5['g5_shop_cart_table']} + where it_id = '$it_id' + and od_id = '$cart_id' + order by ct_id + limit 1 "; + $ct = sql_fetch($sql); + if(!$ct['it_id']) return 0; - if($it['it_sc_type'] > 1) { - if($it['it_sc_type'] == 2) { // 조건부무료 - if($price >= $it['it_sc_minimum']) + if($ct['it_sc_type'] > 1) { + if($ct['it_sc_type'] == 2) { // 조건부무료 + if($price >= $ct['it_sc_minimum']) $sendcost = 0; else - $sendcost = $it['it_sc_price']; - } else if($it['it_sc_type'] == 3) { // 유료배송 - $sendcost = $it['it_sc_price']; + $sendcost = $ct['it_sc_price']; + } else if($ct['it_sc_type'] == 3) { // 유료배송 + $sendcost = $ct['it_sc_price']; } else { // 수량별 부과 - if(!$it['it_sc_qty']) - $it['it_sc_qty'] = 1; + if(!$ct['it_sc_qty']) + $ct['it_sc_qty'] = 1; - $q = ceil((int)$qty / (int)$it['it_sc_qty']); - $sendcost = (int)$it['it_sc_price'] * $q; + $q = ceil((int)$qty / (int)$ct['it_sc_qty']); + $sendcost = (int)$ct['it_sc_price'] * $q; } - } else if($it['it_sc_type'] == 1) { // 무료배송 + } else if($ct['it_sc_type'] == 1) { // 무료배송 $sendcost = 0; } else { $sendcost = -1; diff --git a/shop/cartupdate.php b/shop/cartupdate.php index dccf51b8d..a923b0bec 100644 --- a/shop/cartupdate.php +++ b/shop/cartupdate.php @@ -191,7 +191,7 @@ else // 장바구니에 담기 // 장바구니에 Insert $comma = ''; $sql = " INSERT INTO {$g5['g5_shop_cart_table']} - ( od_id, mb_id, it_id, it_name, ct_status, ct_price, ct_point, ct_point_use, ct_stock_use, ct_option, ct_qty, ct_notax, io_id, io_type, io_price, ct_time, ct_ip, ct_send_cost, ct_direct, ct_select ) + ( od_id, mb_id, it_id, it_name, it_sc_type, it_sc_method, it_sc_price, it_sc_minimum, it_sc_qty, ct_status, ct_price, ct_point, ct_point_use, ct_stock_use, ct_option, ct_qty, ct_notax, io_id, io_type, io_price, ct_time, ct_ip, ct_send_cost, ct_direct, ct_select ) VALUES "; for($k=0; $k<$opt_count; $k++) { @@ -254,7 +254,7 @@ else // 장바구니에 담기 else if($it['it_sc_type'] > 1 && $it['it_sc_method'] == 1) $ct_send_cost = 1; // 착불 - $sql .= $comma."( '$tmp_cart_id', '{$member['mb_id']}', '{$it['it_id']}', '".addslashes($it['it_name'])."', '쇼핑', '{$it['it_price']}', '$point', '0', '0', '$io_value', '$ct_qty', '{$it['it_notax']}', '$io_id', '$io_type', '$io_price', '".G5_TIME_YMDHIS."', '$REMOTE_ADDR', '$ct_send_cost', '$sw_direct', '$ct_select' )"; + $sql .= $comma."( '$tmp_cart_id', '{$member['mb_id']}', '{$it['it_id']}', '".addslashes($it['it_name'])."', '{$it['it_sc_type']}', '{$it['it_sc_method']}', '{$it['it_sc_price']}', '{$it['it_sc_minimum']}', '{$it['it_sc_qty']}', '쇼핑', '{$it['it_price']}', '$point', '0', '0', '$io_value', '$ct_qty', '{$it['it_notax']}', '$io_id', '$io_type', '$io_price', '".G5_TIME_YMDHIS."', '$REMOTE_ADDR', '$ct_send_cost', '$sw_direct', '$ct_select' )"; $comma = ' , '; $ct_count++; }