diff --git a/adm/shop_admin/orderform.php b/adm/shop_admin/orderform.php
index 34b085a3a..9f977048e 100644
--- a/adm/shop_admin/orderform.php
+++ b/adm/shop_admin/orderform.php
@@ -100,7 +100,8 @@ $total_order = $row['sum_order'];
// 상품목록
$sql = " select it_id,
- it_name
+ it_name,
+ cp_amount
from {$g4['shop_cart_table']}
where uq_id = '{$od['uq_id']}'
and ct_num = '0'
@@ -215,6 +216,7 @@ $pg_anchor = '
+ $t_cp_amount += $row['cp_amount']; // 쿠폰사용금액
$t_ct_amount['합계'] += $ct_amount['소계'];
$t_ct_point['합계'] += $ct_point['소계'];
}
@@ -247,8 +249,11 @@ $pg_anchor = '
// 입금액 = 무통장(가상계좌, 계좌이체 포함) + 신용카드 + 휴대폰 + 포인트
$amount['입금'] = $od['od_receipt_bank'] + $od['od_receipt_card'] + $od['od_receipt_hp'] + $od['od_receipt_point'];
- // 미수금 = (주문금액 - DC + 환불액) - (입금액 - 신용카드승인취소)
- $amount['미수'] = ($amount['정상'] - $od['od_dc_amount'] + $od['od_refund_amount']) - ($amount['입금'] - $od['od_cancel_card']);
+ // 쿠폰금액
+ $amount['쿠폰'] = $t_cp_amount + $od['od_coupon'];
+
+ // 미수금 = (주문금액 - DC + 환불액) - (입금액 - 신용카드승인취소) - 쿠폰금액
+ $amount['미수'] = ($amount['정상'] - $od['od_dc_amount'] + $od['od_refund_amount']) - ($amount['입금'] - $od['od_cancel_card']) - $amount['쿠폰'];
// 결제방법
$s_receipt_way = $od['od_settle_case'];
@@ -267,6 +272,7 @@ $pg_anchor = '
| 주문총액 |
포인트결제 |
총결제액 |
+ 쿠폰 |
DC |
환불액 |
주문취소 |
@@ -279,6 +285,7 @@ $pg_anchor = '
|
|
원 |
+ |
|
|
원 |
diff --git a/adm/shop_admin/orderlist2.php b/adm/shop_admin/orderlist2.php
index d7c10df8c..f67627e23 100644
--- a/adm/shop_admin/orderlist2.php
+++ b/adm/shop_admin/orderlist2.php
@@ -161,6 +161,7 @@ if ($search) // 검색렬일 때만 처음 버튼을 보여줌
$tot_dc_amount += $row['od_dc_amount'];
$tot_receiptamount += $row['receiptamount'];
$tot_receiptcancel += $row['receiptcancel'];
+ $tot_couponamount += $row['couponamount'];
$tot_misu += $row['misu'];
?>
-
@@ -200,6 +201,8 @@ if ($search) // 검색렬일 때만 처음 버튼을 보여줌
- 입금합계
+ - 쿠폰사용
+
- 주문취소
- 입금취소
@@ -300,6 +303,7 @@ if ($search) // 검색렬일 때만 처음 버튼을 보여줌
| 주문건수 |
주문액 |
+ 쿠폰 |
취소 |
DC |
입금완료 |
@@ -311,6 +315,7 @@ if ($search) // 검색렬일 때만 처음 버튼을 보여줌
| 건 |
|
+ |
|
|
|
diff --git a/extend/shop.extend.php b/extend/shop.extend.php
index a0db96aff..39ce974ac 100644
--- a/extend/shop.extend.php
+++ b/extend/shop.extend.php
@@ -33,6 +33,7 @@ define(_MISU_QUERY_, "
count(distinct a.od_id) as ordercount, /* 주문서건수 */
count(b.ct_id) as itemcount, /* 상품건수 */
(SUM(IF(b.io_type = 1, b.io_price * b.ct_qty, (b.ct_price + b.io_price) * b.ct_qty)) + a.od_send_cost) as orderamount, /* 주문합계 */
+ (SUM(b.cp_amount) + a.od_coupon) as couponamount, /* 쿠폰합계*/
(SUM(IF(b.ct_status = '취소' OR b.ct_status = '반품' OR b.ct_status = '품절', (IF(b.io_type = 1, b.io_price * b.ct_qty, (b.ct_price + b.io_price) * b.ct_qty)), 0))) as ordercancel, /* 주문취소 */
(a.od_receipt_bank + a.od_receipt_card + a.od_receipt_hp + a.od_receipt_point) as receiptamount, /* 입금합계 */
(a.od_refund_amount + a.od_cancel_card) as receiptcancel, /* 입금취소 */
@@ -41,8 +42,9 @@ define(_MISU_QUERY_, "
(SUM(IF(b.ct_status = '취소' OR b.ct_status = '반품' OR b.ct_status = '품절', (IF(b.io_type = 1, b.io_price * b.ct_qty, (b.ct_price + b.io_price) * b.ct_qty)), 0))) -
a.od_dc_amount -
(a.od_receipt_bank + a.od_receipt_card + a.od_receipt_hp + a.od_receipt_point) +
- (a.od_refund_amount + a.od_cancel_card)
- ) as misu /* 미수금 = 주문합계 - 주문취소 - DC - 입금합계 + 입금취소 */");
+ (a.od_refund_amount + a.od_cancel_card) -
+ (SUM(b.cp_amount) + a.od_coupon)
+ ) as misu /* 미수금 = 주문합계 - 주문취소 - DC - 입금합계 + 입금취소 - 쿠폰합계 */");
//------------------------------------------------------------------------------
// 쇼핑몰 상수 모음 끝
//------------------------------------------------------------------------------
diff --git a/extend/shop.extend2.php b/extend/shop.extend2.php
index 30770d30e..ed86afbb7 100644
--- a/extend/shop.extend2.php
+++ b/extend/shop.extend2.php
@@ -265,4 +265,13 @@ if(!$result) {
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);
}
+
+// 쿠폰사용정보필드추가
+$sql = " select od_id from {$g4['shop_coupon_table']} limit 1 ";
+$result = sql_query($sql, false);
+if(!$result) {
+ sql_query(" ALTER TABLE `{$g4['shop_coupon_table']}`
+ ADD `od_id` BIGINT(20) UNSIGNED NOT NULL AFTER `cp_maximum`,
+ ADD `cp_used_time` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `cp_used` ", false);
+}
?>
\ No newline at end of file
diff --git a/install/shop.sql b/install/shop.sql
index 5f27ffc1a..5da38de42 100644
--- a/install/shop.sql
+++ b/install/shop.sql
@@ -153,7 +153,9 @@ CREATE TABLE IF NOT EXISTS `shop_coupon` (
`cp_trunc` INT(11) NOT NULL DEFAULT '0',
`cp_minimum` INT(11) NOT NULL DEFAULT '0',
`cp_maximum` INT(11) NOT NULL DEFAULT '0',
+ `od_id` bigint(20) unsigned NOT NULL,
`cp_used` TINYINT(4) NOT NULL DEFAULT '0',
+ `cp_used_time` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
`cp_datetime` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
PRIMARY KEY (`cp_no`),
UNIQUE KEY `cp_id` (`cp_id`),
diff --git a/shop/orderform.php b/shop/orderform.php
index 923d5b3e5..ae96bde5d 100644
--- a/shop/orderform.php
+++ b/shop/orderform.php
@@ -929,6 +929,12 @@ $(function() {
var subj = $el.find("input[name='f_cp_subj[]']").val();
var sell_amount;
+ if(parseInt(amount) == 0) {
+ if(!confirm(subj+"쿠폰의 할인 금액은 "+amount+"원입니다.\n쿠폰을 적용하시겠습니까?")) {
+ return false;
+ }
+ }
+
// 이미 사용한 쿠폰이 있는지
var cp_dup = false;
var cp_dup_idx;
@@ -1224,7 +1230,8 @@ function forderform_check(f)
}
var tot_amount = ;
- var max_point = parseInt(f.max_temp_point.value);
+ if (typeof(f.max_temp_point) != "undefined")
+ var max_point = parseInt(f.max_temp_point.value);
var temp_point = 0;
if (typeof(f.od_temp_point) != "undefined") {
diff --git a/shop/orderformupdate.php b/shop/orderformupdate.php
index 0627f2c33..ab900a55f 100644
--- a/shop/orderformupdate.php
+++ b/shop/orderformupdate.php
@@ -69,14 +69,14 @@ if($is_member) {
// 상품쿠폰
$tot_it_cp_amount = $tot_od_cp_amount = 0;
$it_cp_cnt = count($_POST['cp_id']);
+ $arr_it_cp_amt = array();
for($i=0; $i<$it_cp_cnt; $i++) {
$cid = $_POST['cp_id'][$i];
$it_id = $_POST['it_id'][$i];
- $sql = " select cp_id, cp_type, cp_amount, cp_trunc, cp_minimum, cp_maximum
+ $sql = " select cp_id, cp_method, cp_target, cp_type, cp_amount, cp_trunc, cp_minimum, cp_maximum
from {$g4['shop_coupon_table']}
where cp_id = '$cid'
and mb_id = '{$member['mb_id']}'
- and cp_target = '$it_id'
and cp_start <= '".G4_TIME_YMD."'
and cp_end >= '".G4_TIME_YMD."'
and cp_used = '0'
@@ -85,6 +85,23 @@ if($is_member) {
if(!$cp['cp_id'])
continue;
+ // 분류할인인지
+ if($cp['cp_method']) {
+ $sql2 = " select it_id, ca_id, ca_id2, ca_id3
+ from {$g4['shop_item_table']}
+ where it_id = '$it_id' ";
+ $row2 = sql_fetch($sql2);
+
+ if(!$row2['it_id'])
+ continue;
+
+ if($row2['ca_id'] != $cp['cp_target'] && $row2['ca_id2'] != $cp['cp_target'] && $row2['ca_id3'] != $cp['cp_target'])
+ continue;
+ } else {
+ if($cp['cp_target'] != $it_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']}
@@ -107,6 +124,7 @@ if($is_member) {
$dc = $cp['cp_maximum'];
$tot_it_cp_amount += $dc;
+ $arr_it_cp_amt[$it_id] = $dc;
}
$tot_od_amount = $tot_ct_amount - $tot_it_cp_amount;
@@ -166,7 +184,7 @@ if ($default['de_send_cost_case'] == "없음") {
}
$tot_sc_cp_amount = 0;
-if($is_member) {
+if($is_member && $send_cost > 0) {
// 배송쿠폰
if($_POST['sc_cp_id']) {
$sql = " select cp_id, cp_type, cp_amount, cp_trunc, cp_minimum, cp_maximum
@@ -372,6 +390,8 @@ $sql = " insert {$g4['shop_order_table']}
od_deposit_name = '$od_deposit_name',
od_memo = '$od_memo',
od_send_cost = '$od_send_cost',
+ od_send_coupon = '$tot_sc_cp_amount',
+ od_coupon = '$tot_od_cp_amount',
od_temp_bank = '$od_temp_bank',
od_temp_card = '$od_receipt_card',
od_temp_hp = '$od_receipt_hp',
@@ -448,17 +468,31 @@ if($is_member) {
$it_cp_cnt = count($_POST['cp_id']);
for($i=0; $i<$it_cp_cnt; $i++) {
$cid = $_POST['cp_id'][$i];
+ $cp_it_id = $_POST['it_id'][$i];
$sql = " update {$g4['shop_coupon_table']}
- set cp_used = '1'
+ set od_id = '$od_id',
+ cp_used = '1',
+ cp_used_time = '".G4_TIME_YMDHIS."'
where cp_id = '$cid'
and mb_id = '{$member['mb_id']}'
and cp_method IN ( 0, 1 ) ";
sql_query($sql);
+
+ // 쿠폰사용금액 cart에 기록
+ $cp_amt = (int)$arr_it_cp_amt[$cp_it_id];
+ $sql = " update {$g4['shop_cart_table']}
+ set cp_amount = '$cp_amt'
+ where uq_id = '$tmp_uq_id'
+ and it_id = '$cp_it_id'
+ and ct_num = '0' ";
+ sql_query($sql);
}
if($_POST['od_cp_id']) {
$sql = " update {$g4['shop_coupon_table']}
- set cp_used = '1'
+ set od_id = '$od_id',
+ cp_used = '1',
+ cp_used_time = '".G4_TIME_YMDHIS."'
where cp_id = '{$_POST['od_cp_id']}'
and mb_id = '{$member['mb_id']}'
and cp_method = '2' ";
@@ -467,7 +501,9 @@ if($is_member) {
if($_POST['sc_cp_id']) {
$sql = " update {$g4['shop_coupon_table']}
- set cp_used = '1'
+ set od_id = '$od_id',
+ cp_used = '1',
+ cp_used_time = '".G4_TIME_YMDHIS."'
where cp_id = '{$_POST['sc_cp_id']}'
and mb_id = '{$member['mb_id']}'
and cp_method = '3' ";
diff --git a/shop/orderinquiry.sub.php b/shop/orderinquiry.sub.php
index bc8fec84d..46d242668 100644
--- a/shop/orderinquiry.sub.php
+++ b/shop/orderinquiry.sub.php
@@ -13,6 +13,7 @@ if (!defined("_ORDERINQUIRY_")) exit; // 개별 페이지 접근 불가
주문일시 |
상품수 |
주문금액 |
+ 쿠폰 |
입금액 |
미입금액 |
@@ -40,6 +41,7 @@ for ($i=0; $row=sql_fetch_array($result); $i++)
() |
|
|
+ |
|
|
diff --git a/shop/orderinquiryview.php b/shop/orderinquiryview.php
index 922b80fa4..349ec07a1 100644
--- a/shop/orderinquiryview.php
+++ b/shop/orderinquiryview.php
@@ -56,7 +56,7 @@ if(openwin != null) {
- 상품 배송이 완료되었습니다.
+
0)
- {
+ // 총계 = 주문상품금액합계 + 배송비 - 상품할인 - 결제할인
+ $od_coupon = $od['od_coupon'];
+ $tot_amount = $tot_sell_amount + $send_cost - $tot_cp_amount - $od_coupon;
?>
- 배송비
- 원
+ 주문총액
+ 원
+ 0) { ?>
+
+ 상품할인
+ 원
+
- 0) {
- ?>
+ 0) { ?>
+
+ 결제할인
+ 원
+
+
+
+ 0) { ?>
+
+ 배송비
+ 원
+
+
+
+ 0) { ?>
+
+ 배송비할인
+ 원
+
+
총계
- 원 점
+ 원
-
+
+ 포인트
+ 점
+