From 8191a4b8d555c50c382a1b87839ed1d68a9c42fb Mon Sep 17 00:00:00 2001 From: chicpro Date: Tue, 16 Jul 2013 16:25:36 +0900 Subject: [PATCH] =?UTF-8?q?=EC=A3=BC=EB=AC=B8=EC=83=81=ED=92=88=20?= =?UTF-8?q?=EA=B0=9C=EC=88=98=20=EC=88=98=EC=A0=95=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- adm/shop_admin/ordercartupdate.php | 196 ++++++++++++++++++----------- adm/shop_admin/orderform.php | 16 ++- extend/shop.extend2.php | 6 + install/shop.sql | 1 + lib/shop.lib.php | 27 +++- 5 files changed, 162 insertions(+), 84 deletions(-) diff --git a/adm/shop_admin/ordercartupdate.php b/adm/shop_admin/ordercartupdate.php index a5245e5e6..601ca7331 100644 --- a/adm/shop_admin/ordercartupdate.php +++ b/adm/shop_admin/ordercartupdate.php @@ -36,100 +36,144 @@ switch($_POST['act_button']) break; } -$cnt = count($_POST['ct_chk']); +$mod_history = ''; +$cnt = count($_POST['ct_id']); for ($i=0; $i<$cnt; $i++) { - if ($_POST['ct_chk'][$i]) - { - $ct_id = $_POST['ct_chk'][$i]; + $k = $_POST['ct_chk'][$i]; + $ct_id = $_POST['ct_id'][$k]; - $sql = " select * from {$g4['shop_cart_table']} - where uq_id = '$uq_id' - and ct_id = '$ct_id' "; - $ct = sql_fetch($sql); + $sql = " select * from {$g4['shop_cart_table']} + where uq_id = '$uq_id' + and ct_id = '$ct_id' "; + $ct = sql_fetch($sql); + if(!$ct['ct_id']) + continue; - // 재고를 이미 사용했다면 (재고에서 이미 뺐다면) - $stock_use = $ct['ct_stock_use']; - if ($ct['ct_stock_use']) - { - if ($ct_status == '주문' || $ct_status == '취소' || $ct_status == '반품' || $ct_status == '품절') - { - $stock_use = 0; - // 재고에 다시 더한다. - if($ct['io_id']) { - $sql = " update {$g4['shop_item_option_table']} - set io_stock_qty = io_stock_qty + '{$ct['ct_qty']}' - where it_id = '{$ct['it_id']}' - and io_id = '{$ct['io_id']}' - and io_type = '{$ct['io_type']}' "; - } else { - $sql = " update {$g4['shop_item_table']} - set it_stock_qty = it_stock_qty + '{$ct['ct_qty']}' - where it_id = '{$ct['it_id']}' "; - } + // 수량이 변경됐다면 + $ct_qty = $_POST['ct_qty'][$k]; + if($ct['ct_qty'] != $ct_qty) { + $diff_qty = $ct['ct_qty'] - $ct_qty; - sql_query($sql); + // 재고에 차이 반영. + if($ct['ct_stock_use']) { + if($ct['io_id']) { + $sql = " update {$g4['shop_item_option_table']} + set io_stock_qty = io_stock_qty + '$diff_qty' + where it_id = '{$ct['it_id']}' + and io_id = '{$ct['io_id']}' + and io_type = '{$ct['io_type']}' "; + } else { + $sql = " update {$g4['shop_item_table']} + set it_stock_qty = it_stock_qty + '$diff_qty' + where it_id = '{$ct['it_id']}' "; } - } - else - { - // 재고 오류로 인한 수정 - if ($ct_status == '배송' || $ct_status == '완료') - { - $stock_use = 1; - // 재고에서 뺀다. - if($ct['io_id']) { - $sql = " update {$g4['shop_item_option_table']} - set io_stock_qty = io_stock_qty - '{$ct['ct_qty']}' - where it_id = '{$ct['it_id']}' - and io_id = '{$ct['io_id']}' - and io_type = '{$ct['io_type']}' "; - } else { - $sql = " update {$g4['shop_item_table']} - set it_stock_qty = it_stock_qty - '{$ct['ct_qty']}' - where it_id = '{$ct['it_id']}' "; - } - sql_query($sql); - } - /* 주문 수정에서 "품절" 선택시 해당 상품 자동 품절 처리하기 - else if ($ct_status == '품절') { - $stock_use = 1; - // 재고에서 뺀다. - $sql =" update {$g4['shop_item_table']} set it_stock_qty = 0 where it_id = '{$ct['it_id']}' "; - sql_query($sql); - } */ + sql_query($sql); } - $point_use = $ct['ct_point_use']; - // 회원이면서 포인트가 0보다 크면 - // 이미 포인트를 부여했다면 뺀다. - if ($mb_id && $ct['ct_point'] && $ct['ct_point_use']) - { - $point_use = 0; - //insert_point($mb_id, (-1) * ($ct[ct_point] * $ct[ct_qty]), "주문번호 $od_id ($ct_id) 취소"); - delete_point($mb_id, "@delivery", $mb_id, "$od_id,$uq_id,$ct_id"); - } - - // 히스토리에 남김 - // 히스토리에 남길때는 작업|시간|IP|그리고 나머지 자료 - $ct_history="\n$ct_status|$now|$REMOTE_ADDR"; - + // 수량변경 $sql = " update {$g4['shop_cart_table']} - set ct_point_use = '$point_use', - ct_stock_use = '$stock_use', - ct_status = '$ct_status', - ct_history = CONCAT(ct_history,'$ct_history') - where uq_id = '$uq_id' - and ct_id = '$ct_id' "; + set ct_qty = '$ct_qty' + where ct_id = '$ct_id' + and uq_id = '$uq_id' "; sql_query($sql); + $mod_history .= $ct['ct_option'].' 수량변경 '.$ct['ct_qty'].' -> '.$ct_qty."\n"; } + + // 재고를 이미 사용했다면 (재고에서 이미 뺐다면) + $stock_use = $ct['ct_stock_use']; + if ($ct['ct_stock_use']) + { + if ($ct_status == '주문' || $ct_status == '취소' || $ct_status == '반품' || $ct_status == '품절') + { + $stock_use = 0; + // 재고에 다시 더한다. + if($ct['io_id']) { + $sql = " update {$g4['shop_item_option_table']} + set io_stock_qty = io_stock_qty + '{$ct['ct_qty']}' + where it_id = '{$ct['it_id']}' + and io_id = '{$ct['io_id']}' + and io_type = '{$ct['io_type']}' "; + } else { + $sql = " update {$g4['shop_item_table']} + set it_stock_qty = it_stock_qty + '{$ct['ct_qty']}' + where it_id = '{$ct['it_id']}' "; + } + + sql_query($sql); + } + } + else + { + // 재고 오류로 인한 수정 + if ($ct_status == '배송' || $ct_status == '완료') + { + $stock_use = 1; + // 재고에서 뺀다. + if($ct['io_id']) { + $sql = " update {$g4['shop_item_option_table']} + set io_stock_qty = io_stock_qty - '{$ct['ct_qty']}' + where it_id = '{$ct['it_id']}' + and io_id = '{$ct['io_id']}' + and io_type = '{$ct['io_type']}' "; + } else { + $sql = " update {$g4['shop_item_table']} + set it_stock_qty = it_stock_qty - '{$ct['ct_qty']}' + where it_id = '{$ct['it_id']}' "; + } + + sql_query($sql); + } + /* 주문 수정에서 "품절" 선택시 해당 상품 자동 품절 처리하기 + else if ($ct_status == '품절') { + $stock_use = 1; + // 재고에서 뺀다. + $sql =" update {$g4['shop_item_table']} set it_stock_qty = 0 where it_id = '{$ct['it_id']}' "; + sql_query($sql); + } */ + } + + $point_use = $ct['ct_point_use']; + // 회원이면서 포인트가 0보다 크면 + // 이미 포인트를 부여했다면 뺀다. + if ($mb_id && $ct['ct_point'] && $ct['ct_point_use']) + { + $point_use = 0; + //insert_point($mb_id, (-1) * ($ct[ct_point] * $ct[ct_qty]), "주문번호 $od_id ($ct_id) 취소"); + if(!$default['de_mileage_use']) + delete_point($mb_id, "@delivery", $mb_id, "$od_id,$uq_id,$ct_id"); + + // 마일리지 삭제 + delete_mileage($mb_id, $od_id, $ct_id); + } + + // 히스토리에 남김 + // 히스토리에 남길때는 작업|시간|IP|그리고 나머지 자료 + $ct_history="\n$ct_status|$now|$REMOTE_ADDR"; + + $sql = " update {$g4['shop_cart_table']} + set ct_point_use = '$point_use', + ct_stock_use = '$stock_use', + ct_status = '$ct_status', + ct_history = CONCAT(ct_history,'$ct_history') + where uq_id = '$uq_id' + and ct_id = '$ct_id' "; + sql_query($sql); } $qstr = "sort1=$sort1&sort2=$sort2&sel_field=$sel_field&search=$search&page=$page"; $url = "./orderform.php?od_id=$od_id&$qstr"; +// 수량변경 히스토리 기록 +if($mod_history) { + $sql = " update {$g4['shop_order_table']} + set od_mod_history = CONCAT(od_mod_history,'$mod_history') + where od_id = '$od_id' "; + sql_query($sql); +} + // 1.06.06 $od = sql_fetch(" select od_receipt_point from {$g4['shop_order_table']} where od_id = '$od_id' "); if ($od['od_receipt_point']) diff --git a/adm/shop_admin/orderform.php b/adm/shop_admin/orderform.php index 6936f65d0..543509709 100644 --- a/adm/shop_admin/orderform.php +++ b/adm/shop_admin/orderform.php @@ -213,12 +213,16 @@ $pg_anchor .='
  • 결제상세정보 확인
  • ?> - - + + + - + + + + @@ -882,16 +886,16 @@ $(function() { $("#sit_select_all").click(function() { if($(this).is(":checked")) { $("input[name='it_sel[]']").attr("checked", true); - $("input[name='ct_chk[]']").attr("checked", true); + $("input[name^=ct_chk]").attr("checked", true); } else { $("input[name='it_sel[]']").attr("checked", false); - $("input[name='ct_chk[]']").attr("checked", false); + $("input[name^=ct_chk]").attr("checked", false); } }); // 상품의 옵션선택 $("input[name='it_sel[]']").click(function() { - var $chk = $(this).closest("li").find("input[name='ct_chk[]']"); + var $chk = $(this).closest("li").find("input[name^=ct_chk]"); if($(this).is(":checked")) $chk.attr("checked", true); else diff --git a/extend/shop.extend2.php b/extend/shop.extend2.php index f3879de0e..10cb083a1 100644 --- a/extend/shop.extend2.php +++ b/extend/shop.extend2.php @@ -382,4 +382,10 @@ if(!sql_query(" select rq_id from {$g4['shop_request_table']} limit 1 ", false)) PRIMARY KEY (`rq_id`) ) ", false); } + +// 수량변경 history 기록 +if(!sql_query(" select od_mod_history from {$g4['shop_order_table']} limit 1 ", false)) { + sql_query(" ALTER TABLE `{$g4['shop_order_table']}` + ADD `od_mod_history` TEXT NOT NULL AFTER `od_shop_memo` ", true); +} ?> \ No newline at end of file diff --git a/install/shop.sql b/install/shop.sql index 8b19a8307..9f6f68560 100644 --- a/install/shop.sql +++ b/install/shop.sql @@ -613,6 +613,7 @@ CREATE TABLE IF NOT EXISTS `shop_order` ( `od_coupon` int(11) NOT NULL DEFAULT '0', `od_refund_amount` int(11) NOT NULL DEFAULT '0', `od_shop_memo` text NOT NULL, + `od_mod_history` text NOT NULL, `dl_id` int(11) NOT NULL DEFAULT '0', `od_invoice` varchar(255) NOT NULL DEFAULT '', `od_invoice_time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', diff --git a/lib/shop.lib.php b/lib/shop.lib.php index ae771cc96..6faf84c2c 100644 --- a/lib/shop.lib.php +++ b/lib/shop.lib.php @@ -1135,12 +1135,35 @@ function insert_mileage($mb_id, $point, $content='', $od_id, $ct_id) ml_datetime = '".G4_TIME_YMDHIS."' "; sql_query($sql); - // 포인트 내역의 합을 구하고 + // 마일리지 내역의 합을 구하고 $sql = " select sum(ml_point) as sum_mileage from {$g4['shop_mileage_table']} where mb_id = '$mb_id' "; $row = sql_fetch($sql); $sum_mileage = $row['sum_mileage']; - // 포인트 UPDATE + // 마일리지 UPDATE + $sql = " update {$g4['member_table']} set mb_mileage = '$sum_mileage' where mb_id = '$mb_id' "; + sql_query($sql); + + return 1; +} + +// 마일리지 삭제 +function delete_mileage($mb_id, $od_id, $ct_id) +{ + global $g4; + + $sql = " delete from {$g4['shop_mileage_table']} + where mb_id = '$mb_id' + and od_id = '$od_id' + and ct_id = '$ct_id' "; + sql_query($sql); + + // 마일리지 내역의 합을 구하고 + $sql = " select sum(ml_point) as sum_mileage from {$g4['shop_mileage_table']} where mb_id = '$mb_id' "; + $row = sql_fetch($sql); + $sum_mileage = $row['sum_mileage']; + + // 마일리지 UPDATE $sql = " update {$g4['member_table']} set mb_mileage = '$sum_mileage' where mb_id = '$mb_id' "; sql_query($sql);