From b304aa143bdfddb848112f7e5b8d89049d3f3fda Mon Sep 17 00:00:00 2001 From: chicpro Date: Fri, 7 Jun 2013 18:04:35 +0900 Subject: [PATCH] =?UTF-8?q?#209=20=EC=A3=BC=EB=AC=B8=ED=8F=BC=EC=97=90=20?= =?UTF-8?q?=EC=BF=A0=ED=8F=B0=20=EC=84=A0=ED=83=9D=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20=EC=9E=91=EC=97=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extend/shop.extend2.php | 11 + install/shop.sql | 3 + lib/shop.lib.php | 22 ++ shop/cart.php | 257 +++++++++++++- shop/cartsub.inc.php | 85 ++++- shop/ordercoupon.php | 64 ++++ shop/orderform.php | 667 +++++++++++++++++++++++++++++------ shop/orderformupdate.php | 166 ++++++++- shop/orderitemcoupon.php | 81 +++++ shop/ordersendcostcoupon.php | 68 ++++ 10 files changed, 1310 insertions(+), 114 deletions(-) create mode 100644 shop/ordercoupon.php create mode 100644 shop/orderitemcoupon.php create mode 100644 shop/ordersendcostcoupon.php diff --git a/extend/shop.extend2.php b/extend/shop.extend2.php index 4b3ff5664..30770d30e 100644 --- a/extend/shop.extend2.php +++ b/extend/shop.extend2.php @@ -254,4 +254,15 @@ if(!$result) { KEY `mb_id` (`mb_id`) )", false); } + +// 쿠폰관련필드 추가 +$sql = " select cp_amount from {$g4['shop_cart_table']} limit 1 "; +$result = sql_query($sql, false); +if(!$result) { + sql_query(" ALTER TABLE `{$g4['shop_cart_table']}` + ADD `cp_amount` INT(11) NOT NULL DEFAULT '0' AFTER `ct_point` ", false); + sql_query(" ALTER TABLE `{$g4['shop_order_table']}` + ADD `od_coupon` INT(11) NOT NULL DEFAULT '0' AFTER `od_dc_amount`, + ADD `od_send_coupon` INT(11) NOT NULL DEFAULT '0' AFTER `od_send_cost` ", false); +} ?> \ No newline at end of file diff --git a/install/shop.sql b/install/shop.sql index 99dca6aa8..5f27ffc1a 100644 --- a/install/shop.sql +++ b/install/shop.sql @@ -63,6 +63,7 @@ CREATE TABLE IF NOT EXISTS `shop_cart` ( `ct_history` text NOT NULL, `ct_price` int(11) NOT NULL DEFAULT '0', `ct_point` int(11) NOT NULL DEFAULT '0', + `cp_amount` int(11) NOT NULL DEFAULT '0', `ct_point_use` tinyint(4) NOT NULL DEFAULT '0', `ct_stock_use` tinyint(4) NOT NULL DEFAULT '0', `ct_option` varchar(255) NOT NULL DEFAULT '', @@ -588,6 +589,7 @@ CREATE TABLE IF NOT EXISTS `shop_order` ( `od_b_addr2` varchar(100) NOT NULL DEFAULT '', `od_memo` text NOT NULL, `od_send_cost` int(11) NOT NULL DEFAULT '0', + `od_send_coupon` int(11) NOT NULL DEFAULT '0', `od_temp_bank` int(11) NOT NULL DEFAULT '0', `od_temp_card` int(11) NOT NULL DEFAULT '0', `od_temp_hp` int(11) NOT NULL, @@ -602,6 +604,7 @@ CREATE TABLE IF NOT EXISTS `shop_order` ( `od_hp_time` datetime NOT NULL, `od_cancel_card` int(11) NOT NULL DEFAULT '0', `od_dc_amount` int(11) NOT NULL DEFAULT '0', + `od_coupon` int(11) NOT NULL DEFAULT '0', `od_refund_amount` int(11) NOT NULL DEFAULT '0', `od_shop_memo` text NOT NULL, `dl_id` int(11) NOT NULL DEFAULT '0', diff --git a/lib/shop.lib.php b/lib/shop.lib.php index fc343fa27..366f6e97e 100644 --- a/lib/shop.lib.php +++ b/lib/shop.lib.php @@ -1139,6 +1139,28 @@ function get_coupon_id() return $str; } + +// array_map() 대체 +function array_add_callback($func, $array) +{ + if(!$func) { + return; + } + + if(is_array($array)) { + foreach($array as $key => $value) { + if(is_array($value)) { + $array[$key] = array_add_callback($func, $value); + } else { + $array[$key] = call_user_func($func, $value); + } + } + } else { + $array = call_user_func($func, $array); + } + + return $array; +} //============================================================================== // 쇼핑몰 함수 모음 끝 //============================================================================== diff --git a/shop/cart.php b/shop/cart.php index 5f5408684..0308070d5 100644 --- a/shop/cart.php +++ b/shop/cart.php @@ -29,18 +29,269 @@ if (G4_IS_MOBILE) { $g4['title'] = '장바구니'; include_once('./_head.php'); +$s_uq_id = get_session('ss_uq_id'); ?> + +
+
+ + + + + + + + + + + + + '$ctime' "; + } + $sql .= " order by a.ct_id "; + $result = sql_query($sql); + + $good_info = ''; + + for ($i=0; $row=mysql_fetch_array($result); $i++) + { + // 합계금액 계산 + $sql = " select SUM(IF(io_type = 1, (io_price * ct_qty), ((ct_price + io_price) * ct_qty))) as price, + SUM(ct_point * ct_qty) as point, + SUM(ct_qty) as qty + from {$g4['shop_cart_table']} + where it_id = '{$row['it_id']}' + and uq_id = '$s_uq_id' "; + $sum = sql_fetch($sql); + + if ($i==0) { // 계속쇼핑 + $continue_ca_id = $row['ca_id']; + } + + $a1 = ''; + $a2 = ''; + $image = get_it_image($row['it_id'], 70, 70); + + $it_name = $a1 . stripslashes($row['it_name']) . $a2; + $it_options = print_item_options($row['it_id'], $s_uq_id); + if($it_options) { + $mod_options = '
'; + $it_name .= '
'.$it_options.'
'; + } + + $point = $sum['point']; + $sell_amount = $sum['price']; ?> + + + + + + + + + + + '; + } else { + // 배송비 계산 + if ($default['de_send_cost_case'] == '없음') + $send_cost = 0; + else { + // 배송비 상한 : 여러단계의 배송비 적용 가능 + $send_cost_limit = explode(";", $default['de_send_cost_limit']); + $send_cost_list = explode(";", $default['de_send_cost_list']); + $send_cost = 0; + for ($k=0; $k + +
상품이미지상품명총수량판매가소계포인트
+ + + +
장바구니에 담긴 상품이 없습니다.
+ + + + 0) + { + ?> + +
+ 배송비 + +
+ + + + 0) { + ?> + +
+ 총계 + +
+ + + +
+ + 쇼핑 계속하기 + + + + +

장바구니의 상품을 주문하시려면 주문하기를 클릭하세요. 비우기는 장바구니의 상품을 모두 비웁니다.

+ 쇼핑 계속하기 + 주문하기 + 선택삭제 + 비우기 + +
+ +
+
+ + \ No newline at end of file diff --git a/shop/cartsub.inc.php b/shop/cartsub.inc.php index 3e92b9361..a66784fd6 100644 --- a/shop/cartsub.inc.php +++ b/shop/cartsub.inc.php @@ -153,6 +153,8 @@ for ($i=0; $row=mysql_fetch_array($result); $i++) + + @@ -160,7 +162,7 @@ for ($i=0; $row=mysql_fetch_array($result); $i++) - + 0) { + + = '".G4_TIME_YMD."' + and cp_used = '0' + and cp_minimum <= '$amount' "; +$result = sql_query($sql); +$count = mysql_num_rows($result); +?> + +
+ 0) { ?> + + +
+ + 0) { ?> + + +
+
\ No newline at end of file diff --git a/shop/orderform.php b/shop/orderform.php index e7f8bf5b4..923d5b3e5 100644 --- a/shop/orderform.php +++ b/shop/orderform.php @@ -28,106 +28,279 @@ include_once('./_head.php'); // 새로운 주문번호 생성 $od_id = get_uniqid(); set_session('ss_order_uniqid', $od_id); +$s_uq_id = $tmp_uq_id; +$order_action_url = G4_HTTPS_SHOP_URL.'/orderformupdate.php'; +if (file_exists('./settle_'.$default['de_card_pg'].'.inc.php')) { + include './settle_'.$default['de_card_pg'].'.inc.php'; +} ?> -
+ + + + - - + return RetVal ; +} + +// Payplus Plug-in 설치 안내 +function init_pay_button() +{ + /* + if( document.Payplus.object == null ) + document.getElementById("display_setup_message").style.display = "block" ; + else + document.getElementById("display_pay_button").style.display = "block" ; + */ + // 체크 방법이 변경 + if( GetPluginObject() == null ){ + document.getElementById("display_setup_message").style.display = "block" ; + } + else{ + document.getElementById("display_pay_button").style.display = "block" ; + } +} + +/* +* 인터넷 익스플로러와 파이어폭스(사파리, 크롬.. 등등)는 javascript 파싱법이 틀리기 때문에 object 가 인식 전에 실행 되는 문제 +* 기존에는 onload 부분에 추가를 했지만 setTimeout 부분에 추가 +* setTimeout 에 2번째 변수 0은 딜레이 시간 0은 딜래이 없음을 의미 +* - 김민수 - 20101018 - +*/ +setTimeout("init_pay_button();",300); + + +
+
+

주문하실 상품을 확인하세요.

+ + + + + + + + + + + + + + '$ctime' "; + } + $sql .= " order by a.ct_id "; + $result = sql_query($sql); + + $good_info = ''; + + for ($i=0; $row=mysql_fetch_array($result); $i++) + { + // 합계금액 계산 + $sql = " select SUM(IF(io_type = 1, (io_price * ct_qty), ((ct_price + io_price) * ct_qty))) as price, + SUM(ct_point * ct_qty) as point, + SUM(ct_qty) as qty + from {$g4['shop_cart_table']} + where it_id = '{$row['it_id']}' + and uq_id = '$s_uq_id' "; + $sum = sql_fetch($sql); + + if (!$goods) + { + //$goods = addslashes($row[it_name]); + //$goods = get_text($row[it_name]); + $goods = preg_replace("/\'|\"|\||\,|\&|\;/", "", $row['it_name']); + $goods_it_id = $row['it_id']; + } + $goods_count++; + + // 에스크로 상품정보 + if($s_page == 'orderform.php' && $default['de_escrow_use']) { + if ($i>0) + $good_info .= chr(30); + $good_info .= "seq=".($i+1).chr(31); + $good_info .= "ordr_numb={$od_id}_".sprintf("%04d", $i).chr(31); + $good_info .= "good_name=".addslashes($row['it_name']).chr(31); + $good_info .= "good_cntx=".$row['ct_qty'].chr(31); + $good_info .= "good_amtx=".$row['ct_price'].chr(31); + } + + $image = get_it_image($row['it_id'], 50, 50); + + $it_name = '' . stripslashes($row['it_name']) . ''; + $it_options = print_item_options($row['it_id'], $s_uq_id); + if($it_options) { + $it_name .= '
'.$it_options.'
'; + } + + $point = $sum['point']; + $sell_amount = $sum['price']; + + // 쿠폰 + if($is_member) { + $cp_button = ''; + + $sql = " select count(*) as cnt + from {$g4['shop_coupon_table']} + where mb_id = '{$member['mb_id']}' + and cp_used = '0' + and cp_start <= '".G4_TIME_YMD."' + and cp_end >= '".G4_TIME_YMD."' + and ( + ( cp_method = '0' and cp_target = '{$row['it_id']}' ) + OR + ( cp_method = '1' and ( cp_target IN ( '{$row['ca_id']}', '{$row['ca_id2']}', '{$row['ca_id3']}' ) ) ) + ) "; + $cp = sql_fetch($sql); + + if($cp['cnt']) + $cp_button = ''; + } + ?> + + + + + + + + + + + + '; + } else { + // 배송비 계산 + if ($default['de_send_cost_case'] == '없음') + $send_cost = 0; + else { + // 배송비 상한 : 여러단계의 배송비 적용 가능 + $send_cost_limit = explode(";", $default['de_send_cost_limit']); + $send_cost_list = explode(";", $default['de_send_cost_list']); + $send_cost = 0; + for ($k=0; $k + +
상품이미지상품명총수량판매가쿠폰소계포인트
+ + + + + + +
장바구니에 담긴 상품이 없습니다.
+ + + + 0) + { + ?> + +
+ 배송비 + +
+ + + + 0) { + ?> + +
+ 총계 + +
+ + - + + - + @@ -473,9 +646,64 @@ set_session('ss_order_uniqid', $od_id); + = '".G4_TIME_YMD."' + and cp_used = '0' "; + $row = sql_fetch($sql); + $oc_cnt = $row['cnt']; + + if($send_cost > 0) { + // 배송비쿠폰 + $sql = " select count(*) as cnt + from {$g4['shop_coupon_table']} + where mb_id = '{$member['mb_id']}' + and cp_method = '3' + and cp_start <= '".G4_TIM_YMD."' + and cp_end >= '".G4_TIME_YMD."' + and cp_used = '0' "; + $row = sql_fetch($sql); + $sc_cnt = $row['cnt']; + } + } + ?> +

결제정보

+ + + 0) { ?> + + + + + + 0) { ?> + + + + + + + + + + +
결제할인쿠폰 + + +
배송비할인쿠폰 + + +
총 주문금액
+ 무통장입금 이외의 결제 수단으로 결제하시는 경우 포인트를 적립해드리지 않습니다.

'; @@ -543,7 +771,8 @@ set_session('ss_order_uniqid', $od_id); if ($temp_point > $member_mileage) $temp_point = $member_mileage; ?> -

보유마일리지()중 최대 까지 사용 가능 (주문금액 %)

+

보유마일리지()중 최대 까지 사용 가능 (주문금액 %)

+ 점 (100점 단위로 입력하세요.) $member_point) $temp_point = $member_point; ?> -

보유포인트()중 최대 까지 사용 가능 (주문금액 %)

+

보유포인트()중 최대 까지 사용 가능 (주문금액 %)

+ 점 (100점 단위로 입력하세요.) = '".G4_TIME_YMD."' + and cp_used = '0' + and cp_method IN ( 0, 1 ) "; + $cp = sql_fetch($sql); + if(!$cp['cp_id']) + continue; + + // 상품금액 + $sql = " select SUM( IF(io_type = '1', io_price * ct_qty, (ct_price + io_price) * ct_qty)) as sum_price + from {$g4['shop_cart_table']} + where uq_id = '$tmp_uq_id' + and it_id = '$it_id' "; + $ct = sql_fetch($sql); + $item_price = $ct['sum_price']; + + if($cp['cp_minimum'] > $item_price) + continue; + + $dc = 0; + if($cp['cp_type']) { + $dc = floor(($item_price * ($cp['cp_amount'] / 100)) / $cp['cp_trunc']) * $cp['cp_trunc']; + } else { + $dc = $cp['cp_amount']; + } + + if($cp['cp_maximum'] && $dc > $cp['cp_maximum']) + $dc = $cp['cp_maximum']; + + $tot_it_cp_amount += $dc; + } + + $tot_od_amount = $tot_ct_amount - $tot_it_cp_amount; + + // 주문쿠폰 + if($_POST['od_cp_id']) { + $sql = " select cp_id, cp_type, cp_amount, cp_trunc, cp_minimum, cp_maximum + from {$g4['shop_coupon_table']} + where cp_id = '{$_POST['od_cp_id']}' + and mb_id = '{$member['mb_id']}' + and cp_start <= '".G4_TIME_YMD."' + and cp_end >= '".G4_TIME_YMD."' + and cp_used = '0' + and cp_method = '2' "; + $cp = sql_fetch($sql); + + $dc = 0; + if($cp['cp_id'] && ($cp['cp_minimum'] <= $tot_od_amount)) { + if($cp['cp_type']) { + $dc = floor(($tot_od_amount * ($cp['cp_amount'] / 100)) / $cp['cp_trunc']) * $cp['cp_trunc']; + } else { + $dc = $cp['cp_amount']; + } + + if($cp['cp_maximum'] && $dc > $cp['cp_maximum']) + $dc = $cp['cp_maximum']; + + $tot_od_cp_amount = $dc; + $tot_od_amount -= $tot_od_cp_amount; + } + } + + $tot_cp_amount = $tot_it_cp_amount + $tot_od_cp_amount; +} + +if ((int)($row['od_amount'] - $tot_cp_amount) !== $i_amount) { die("Error."); } @@ -79,12 +164,46 @@ if ($default['de_send_cost_case'] == "없음") { } } } -if ((int)$send_cost !== $i_send_cost) { + +$tot_sc_cp_amount = 0; +if($is_member) { + // 배송쿠폰 + if($_POST['sc_cp_id']) { + $sql = " select cp_id, cp_type, cp_amount, cp_trunc, cp_minimum, cp_maximum + from {$g4['shop_coupon_table']} + where cp_id = '{$_POST['sc_cp_id']}' + and mb_id = '{$member['mb_id']}' + and cp_start <= '".G4_TIME_YMD."' + and cp_end >= '".G4_TIME_YMD."' + and cp_used = '0' + and cp_method = '3' "; + $cp = sql_fetch($sql); + + $dc = 0; + if($cp['cp_id'] && ($cp['cp_minimum'] <= $tot_od_amount)) { + if($cp['cp_type']) { + $dc = floor(($tot_od_amount * ($cp['cp_amount'] / 100)) / $cp['cp_trunc']) * $cp['cp_trunc']; + } else { + $dc = $cp['cp_amount']; + } + + if($cp['cp_maximum'] && $dc > $cp['cp_maximum']) + $dc = $cp['cp_maximum']; + + if($dc > $send_cost) + $dc = $send_cost; + + $tot_sc_cp_amount = $dc; + } + } +} + +if ((int)($send_cost - $tot_sc_cp_amount) !== $i_send_cost) { die("Error.."); } // 결제포인트가 상이함 -$tot_amount = $tot_sell_amount + $send_cost; +$tot_amount = $tot_od_amount + ($send_cost - $tot_sc_cp_amount); // 회원이면서 포인트사용이면 $temp_point = 0; if($default['de_mileage_use']) { @@ -324,6 +443,39 @@ include_once(G4_SHOP_PATH.'/kcp/pp_ax_hub_result.php'); $od_memo = nl2br(htmlspecialchars2(stripslashes($od_memo))) . " "; +// 쿠폰사용내역기록 +if($is_member) { + $it_cp_cnt = count($_POST['cp_id']); + for($i=0; $i<$it_cp_cnt; $i++) { + $cid = $_POST['cp_id'][$i]; + $sql = " update {$g4['shop_coupon_table']} + set cp_used = '1' + where cp_id = '$cid' + and mb_id = '{$member['mb_id']}' + and cp_method IN ( 0, 1 ) "; + sql_query($sql); + } + + if($_POST['od_cp_id']) { + $sql = " update {$g4['shop_coupon_table']} + set cp_used = '1' + where cp_id = '{$_POST['od_cp_id']}' + and mb_id = '{$member['mb_id']}' + and cp_method = '2' "; + sql_query($sql); + } + + if($_POST['sc_cp_id']) { + $sql = " update {$g4['shop_coupon_table']} + set cp_used = '1' + where cp_id = '{$_POST['sc_cp_id']}' + and mb_id = '{$member['mb_id']}' + and cp_method = '3' "; + sql_query($sql); + } +} + + include_once(G4_SHOP_PATH.'/ordermail1.inc.php'); include_once(G4_SHOP_PATH.'/ordermail2.inc.php'); diff --git a/shop/orderitemcoupon.php b/shop/orderitemcoupon.php new file mode 100644 index 000000000..19795d7e0 --- /dev/null +++ b/shop/orderitemcoupon.php @@ -0,0 +1,81 @@ += '".G4_TIME_YMD."' + and cp_minimum <= '$item_price' + and ( + ( cp_method = '0' and cp_target = '{$it['it_id']}' ) + OR + ( cp_method = '1' and ( cp_target IN ( '{$it['ca_id']}', '{$it['ca_id2']}', '{$it['ca_id3']}' ) ) ) + ) "; +$result = sql_query($sql); +$count = mysql_num_rows($result); +?> + +
+ 0) { ?> +
    +
  • + 쿠폰명 + 할인금액 + 적용 +
  • + $row['cp_maximum']) + $dc = $row['cp_maximum']; + ?> +
  • + + + + + + +
  • + +
+ +
+ + 0) { ?> + + +
+
\ No newline at end of file diff --git a/shop/ordersendcostcoupon.php b/shop/ordersendcostcoupon.php new file mode 100644 index 000000000..f6d4b546f --- /dev/null +++ b/shop/ordersendcostcoupon.php @@ -0,0 +1,68 @@ += '".G4_TIME_YMD."' + and cp_used = '0' + and cp_minimum <= '$amount' "; +$result = sql_query($sql); +$count = mysql_num_rows($result); +?> + +
+ 0) { ?> +
    +
  • + 쿠폰명 + 할인금액 + 적용 +
  • + $row['cp_maximum']) + $dc = $row['cp_maximum']; + + if($dc > $send_cost) + $dc = $send_cost; + ?> +
  • + + + + + +
  • + +
+ +
+ + 0) { ?> + + +
+
\ No newline at end of file