From c9007b47490d3880d1063e2141ae70169d51f9ba Mon Sep 17 00:00:00 2001 From: chicpro Date: Fri, 24 May 2013 18:16:45 +0900 Subject: [PATCH] =?UTF-8?q?=EC=98=B5=EC=85=98=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=EC=97=90=20=EB=94=B0=EB=A5=B8=20=EC=9E=A5?= =?UTF-8?q?=EB=B0=94=EA=B5=AC=EB=8B=88=20=EC=9E=AC=EA=B3=A0=20=EC=B2=B4?= =?UTF-8?q?=ED=81=AC=20=EC=BD=94=EB=93=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/shop.lib.php | 23 +++++++++++++++++++++++ shop/cartupdate.php | 31 +++++++++++-------------------- 2 files changed, 34 insertions(+), 20 deletions(-) diff --git a/lib/shop.lib.php b/lib/shop.lib.php index 738ead5e4..cfadc8562 100644 --- a/lib/shop.lib.php +++ b/lib/shop.lib.php @@ -157,6 +157,29 @@ function get_it_stock_qty($it_id) $sql = " select SUM(ct_qty) as sum_qty from {$g4['shop_cart_table']} where it_id = '$it_id' + and io_id = '' + and ct_stock_use = 0 + and ct_status in ('주문', '준비') "; + $row = sql_fetch($sql); + $daegi = (int)$row['sum_qty']; + + return $jaego - $daegi; +} + +// 옵션의 재고 (창고재고수량 - 주문대기수량) +function get_option_stock_qty($it_id, $io_id) +{ + global $g4; + + $sql = " select io_stock_qty from {$g4['shop_item_option_table']} where it_id = '$it_id' and io_id = '$io_id' and io_use = '1' "; + $row = sql_fetch($sql); + $jaego = (int)$row['it_stock_qty']; + + // 재고에서 빼지 않았고 주문인것만 + $sql = " select SUM(ct_qty) as sum_qty + from {$g4['shop_cart_table']} + where it_id = '$it_id' + and io_id = '$io_id' and ct_stock_use = 0 and ct_status in ('주문', '준비') "; $row = sql_fetch($sql); diff --git a/shop/cartupdate.php b/shop/cartupdate.php index d1ac9cdc6..64918ec15 100644 --- a/shop/cartupdate.php +++ b/shop/cartupdate.php @@ -207,7 +207,7 @@ else // 장바구니에 담기 if(!$_POST['io_id'][$i]) $it_stock_qty = get_it_stock_qty($_POST['it_id']); else - $it_stock_qty = get_option_stock_qty($_POST['io_id'][$i]); + $it_stock_qty = get_option_stock_qty($_POST['it_id'], $_POST['io_id'][$i]); if ($ct_qty + $sum_qty > $it_stock_qty) { @@ -227,25 +227,16 @@ else // 장바구니에 담기 if (!$config['cf_use_point']) { $_POST['it_point'] = 0; } // 장바구니에 Insert - $sql = " insert {$g4['shop_cart_table']} - set uq_id = '$tmp_uq_id', - it_id = '{$_POST['it_id']}', - it_name = '{$_POST['it_name']}', - it_opt1 = '{$_POST['it_opt1']}', - it_opt2 = '{$_POST['it_opt2']}', - it_opt3 = '{$_POST['it_opt3']}', - it_opt4 = '{$_POST['it_opt4']}', - it_opt5 = '{$_POST['it_opt5']}', - it_opt6 = '{$_POST['it_opt6']}', - ct_status = '쇼핑', - ct_price = '{$_POST['it_price']}', - ct_point = '{$_POST['it_point']}', - ct_point_use = '0', - ct_stock_use = '0', - ct_qty = '{$_POST['ct_qty']}', - ct_time = '".G4_TIME_YMDHIS."', - ct_ip = '$REMOTE_ADDR', - ct_direct = '$sw_direct' "; + $comma = ''; + $sql = " INSERT INTO {$g4['shop_cart_table']} + ( uq_id, it_id, it_name, ct_status, ct_price, ct_point, ct_point_use, ct_stock_use, ct_option, ct_qty, io_id, io_type, io_price, ct_time, ct_ip, ct_direct ) + VALUES "; + + for($i=0; $i<$option_count; $i++) { + $sql .= $comma."( '$tmp_uq_id', '{$_POST['it_id']}', '{$_POST['it_name']}', '쇼핑', '{$_POST['it_price']}', '{$_POST['it_point']}', '0', '0', '{$_POST[['io_value'][$i]}', '{$_POST['ct_qty'][$i]}', '{$_POST['io_id'][$i]}', '{$_POST['io_type'][$i]}', '{$_POST['io_price']}', '".G4_TIME_YMDHIS."', '$REMOTE_ADDR', '$sw_direct' )"; + $comma = ' , '; + } + sql_query($sql); }