diff --git a/adm/shop_admin/couponformupdate.php b/adm/shop_admin/couponformupdate.php
index 0b7043f72..b9d993eb0 100644
--- a/adm/shop_admin/couponformupdate.php
+++ b/adm/shop_admin/couponformupdate.php
@@ -50,56 +50,38 @@ if($_POST['cp_method'] == 0) {
}
if($w == '') {
- $arr_mb_id = array();
-
if($_POST['chk_all_mb']) {
- $sql = " select mb_id from {$g4['member_table']} where mb_id <> '{$config['cf_admin']}' and mb_leave_date = '' and mb_intercept_date = '' ";
- $result = sql_query($sql);
- for($i=0; $row=sql_fetch_array($result); $i++) {
- $arr_mb_id[] = $row['mb_id'];
- }
-
- if($i == 0)
- alert('관리자를 제외한 쿠폰 발급 가능 회원이 없습니다.');
+ $mb_id = '전체회원';
} else {
- if($_POST['mb_id'] == $config['cf_admin'])
- alert('관리자를 제외한 회원의 아이디를 입력해 주십시오.');
-
- $sql2 = " select mb_id from {$g4['member_table']} where mb_id = '{$_POST['mb_id']}' and mb_leave_date = '' and mb_intercept_date = '' ";
- $row2 = sql_fetch($sql2);
- if(!$row2['mb_id'])
+ $sql = " select mb_id from {$g4['member_table']} where mb_id = '{$_POST['mb_id']}' and mb_leave_date = '' and mb_intercept_date = '' ";
+ $row = sql_fetch($sql);
+ if(!$row['mb_id'])
alert('입력하신 회원아이디는 존재하지 않거나 탈퇴 또는 차단된 회원아이디입니다.');
- $arr_mb_id[] = $_POST['mb_id'];
+ $mb_id = $_POST['mb_id'];
}
- $mb_id_count = count($arr_mb_id);
+ $j = 0;
+ do {
+ $cp_id = get_coupon_id();
- for($i=0; $i<$mb_id_count; $i++) {
- $mb_id = $arr_mb_id[$i];
+ $sql3 = " select count(*) as cnt from {$g4['shop_coupon_table']} where cp_id = '$cp_id' ";
+ $row3 = sql_fetch($sql3);
- $j = 0;
- do {
- $cp_id = get_coupon_id();
+ if(!$row3['cnt'])
+ break;
+ else {
+ if($j > 20)
+ die('Coupon ID Error');
+ }
+ } while(1);
- $sql3 = " select count(*) as cnt from {$g4['shop_coupon_table']} where cp_id = '$cp_id' ";
- $row3 = sql_fetch($sql3);
+ $sql = " INSERT INTO {$g4['shop_coupon_table']}
+ ( cp_id, cp_subject, cp_method, cp_target, mb_id, cp_start, cp_end, cp_type, cp_price, cp_trunc, cp_minimum, cp_maximum, cp_used, cp_datetime )
+ VALUES
+ ( '$cp_id', '$cp_subject', '$cp_method', '$cp_target', '$mb_id', '$cp_start', '$cp_end', '$cp_type', '$cp_price', '$cp_trunc', '$cp_minimum', '$cp_maximum', '$cp_used', '".G4_TIME_YMDHIS."' ) ";
- if(!$row3['cnt'])
- break;
- else {
- if($j > 20)
- die('Coupon ID Error');
- }
- } while(1);
-
- $sql = " INSERT INTO {$g4['shop_coupon_table']}
- ( cp_id, cp_subject, cp_method, cp_target, mb_id, cp_start, cp_end, cp_type, cp_price, cp_trunc, cp_minimum, cp_maximum, cp_used, cp_datetime )
- VALUES
- ( '$cp_id', '$cp_subject', '$cp_method', '$cp_target', '$mb_id', '$cp_start', '$cp_end', '$cp_type', '$cp_price', '$cp_trunc', '$cp_minimum', '$cp_maximum', '$cp_used', '".G4_TIME_YMDHIS."' ) ";
-
- sql_query($sql);
- }
+ sql_query($sql);
} else if($w == 'u') {
$sql = " select * from {$g4['shop_coupon_table']} where cp_id = '$cp_id' ";
$cp = sql_fetch($sql);
@@ -107,6 +89,10 @@ if($w == '') {
if(!$cp['cp_id'])
alert('쿠폰정보가 존해하지 않습니다.', './couponlist.php');
+ if($_POST['chk_all_mb']) {
+ $mb_id = '전체회원';
+ }
+
$sql = " update {$g4['shop_coupon_table']}
set cp_subject = '$cp_subject',
cp_method = '$cp_method',
diff --git a/adm/shop_admin/couponlist.php b/adm/shop_admin/couponlist.php
index c82f71a62..47e02b52a 100644
--- a/adm/shop_admin/couponlist.php
+++ b/adm/shop_admin/couponlist.php
@@ -6,11 +6,6 @@ auth_check($auth[$sub_menu], "r");
$token = get_token();
-// 사용하지 않고 사용종료일이 초과된 쿠폰삭제
-$end_date = date('Y-m-d', (G4_SERVER_TIME - (86400 * 7)));
-$sql = " delete from {$g4['shop_coupon_table']} where cp_used = '0' and cp_end < '$end_date' ";
-sql_query($sql);
-
$sql_common = " from {$g4['shop_coupon_table']} ";
$sql_search = " where (1) ";
@@ -109,20 +104,13 @@ $colspan = 8;
적용대상 |
회원아이디 |
사용기한 |
- 사용 |
+ 사용회수 |
관리 |
';
$link2 = '';
+
+ // 쿠폰사용회수
+ $sql = " select count(*) as cnt from {$g4['shop_coupon_log_table']} where cp_id = '{$row['cp_id']}' ";
+ $tmp = sql_fetch($sql);
+ $used_count = $tmp['cnt'];
?>
@@ -156,7 +149,7 @@ $colspan = 8;
|
|
~ |
- |
+ |
수정
|
diff --git a/extend/shop.extend2.php b/extend/shop.extend2.php
index c520c993c..a03f360f1 100644
--- a/extend/shop.extend2.php
+++ b/extend/shop.extend2.php
@@ -513,4 +513,25 @@ if(!sql_query(" select od_misu from {$g4['shop_order_table']} limit 1 ", false))
sql_query(" ALTER TABLE `{$g4['shop_order_table']}`
ADD `od_misu` int(11) NOT NULL DEFAULT '0' AFTER `od_coupon` ", true);
}
+
+// 쿠폰 history 테이블추가
+if(!isset($g4['shop_coupon_log_table']))
+ die_utf8('dbconfig.php 파일에 $g4[\'shop_coupon_log_table\'] = SHOP_TABLE_PREFIX.\'coupon_log\'; // 쿠폰정보 테이블 추가해주세요.');
+if(!sql_query(" DESCRIBE `{$g4['shop_coupon_log_table']}` ", false)) {
+ sql_query(" CREATE TABLE IF NOT EXISTS `{$g4['shop_coupon_log_table']}` (
+ `cl_id` int(11) NOT NULL AUTO_INCREMENT,
+ `cp_id` varchar(255) NOT NULL DEFAULT '',
+ `mb_id` varchar(255) NOT NULL DEFAULT '',
+ `od_id` bigint(20) NOT NULL,
+ `cp_price` int(11) NOT NULL DEFAULT '0',
+ `cl_datetime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
+ PRIMARY KEY (`cl_id`),
+ KEY `mb_id` (`mb_id`),
+ KEY `od_id` (`od_id`)
+ )", true);
+ sql_query(" ALTER TABLE `{$g4['shop_coupon_table']}`
+ DROP `od_id`,
+ DROP `cp_used_time`,
+ DROP `cp_used` ", true);
+}
?>
diff --git a/install/shop.sql b/install/shop.sql
index f514d2648..ca66ab144 100644
--- a/install/shop.sql
+++ b/install/shop.sql
@@ -128,8 +128,6 @@ CREATE TABLE IF NOT EXISTS `shop_coupon` (
`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`),
@@ -138,6 +136,24 @@ CREATE TABLE IF NOT EXISTS `shop_coupon` (
-- --------------------------------------------------------
+--
+-- Table structure for table `shop_coupon_log`
+--
+
+CREATE TABLE IF NOT EXISTS `shop_coupon_log` (
+ `cl_id` int(11) NOT NULL AUTO_INCREMENT,
+ `cp_id` varchar(255) NOT NULL DEFAULT '',
+ `mb_id` varchar(255) NOT NULL DEFAULT '',
+ `od_id` bigint(20) NOT NULL,
+ `cp_price` int(11) NOT NULL DEFAULT '0',
+ `cl_datetime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
+ PRIMARY KEY (`cl_id`),
+ KEY `mb_id` (`mb_id`),
+ KEY `od_id` (`od_id`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
+
+-- --------------------------------------------------------
+
--
-- Table structure for table `shop_default`
--
diff --git a/lib/shop.lib.php b/lib/shop.lib.php
index 241c4f47f..501bea297 100644
--- a/lib/shop.lib.php
+++ b/lib/shop.lib.php
@@ -1603,6 +1603,22 @@ function get_order_misu($od_id)
return $od['misu'];
}
+
+// 쿠폰 사용체크
+function is_used_coupon($mb_id, $cp_id)
+{
+ global $g4;
+
+ $used = false;
+
+ $sql = " select count(*) as cnt from {$g4['shop_coupon_log_table']} where mb_id = '$mb_id' and cp_id = '$cp_id' ";
+ $row = sql_fetch($sql);
+
+ if($row['cnt'])
+ $used = true;
+
+ return $used;
+}
//==============================================================================
// 쇼핑몰 라이브러리 모음 끝
//==============================================================================
diff --git a/mobile/shop/orderform.php b/mobile/shop/orderform.php
index c3c47883c..1667a7904 100644
--- a/mobile/shop/orderform.php
+++ b/mobile/shop/orderform.php
@@ -145,11 +145,11 @@ ob_start();
// 쿠폰
if($is_member) {
$cp_button = '';
+ $cp_count = 0;
- $sql = " select count(*) as cnt
+ $sql = " select cp_id
from {$g4['shop_coupon_table']}
- where mb_id = '{$member['mb_id']}'
- and cp_used = '0'
+ where mb_id IN ( '{$member['mb_id']}', '전체회원' )
and cp_start <= '".G4_TIME_YMD."'
and cp_end >= '".G4_TIME_YMD."'
and cp_minimum <= '$sell_price'
@@ -158,9 +158,16 @@ ob_start();
OR
( cp_method = '1' and ( cp_target IN ( '{$row['ca_id']}', '{$row['ca_id2']}', '{$row['ca_id3']}' ) ) )
) ";
- $cp = sql_fetch($sql);
+ $res = sql_query($sql);
- if($cp['cnt'])
+ for($k=0; $cp=sql_fetch_array($res); $k++) {
+ if(is_used_coupon($member['mb_id'], $cp['cp_id']))
+ continue;
+
+ $cp_count++;
+ }
+
+ if($cp_count)
$cp_button = '';
}
?>
@@ -514,29 +521,40 @@ ob_end_clean();
= '".G4_TIME_YMD."'
- and cp_used = '0' ";
- $row = sql_fetch($sql);
- $oc_cnt = $row['cnt'];
+ and cp_end >= '".G4_TIME_YMD."' ";
+ $res = sql_query($sql);
+
+ for($k=0; $cp=sql_fetch_array($res); $k++) {
+ if(is_used_coupon($member['mb_id'], $cp['cp_id']))
+ continue;
+
+ $oc_cnt++;
+ }
if($send_cost > 0) {
// 배송비쿠폰
- $sql = " select count(*) as cnt
+ $sql = " select cp_id
from {$g4['shop_coupon_table']}
- where mb_id = '{$member['mb_id']}'
+ where mb_id IN ( '{$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'];
+ and cp_end >= '".G4_TIME_YMD."' ";
+ $res = sql_query($sql);
+
+ for($k=0; $cp=sql_fetch_array($res); $k++) {
+ if(is_used_coupon($member['mb_id'], $cp['cp_id']))
+ continue;
+
+ $sc_cnt++;
+ }
}
}
?>
diff --git a/mobile/shop/orderformupdate.php b/mobile/shop/orderformupdate.php
index da7447502..3a388d1e6 100644
--- a/mobile/shop/orderformupdate.php
+++ b/mobile/shop/orderformupdate.php
@@ -86,15 +86,18 @@ if($is_member) {
$sql = " select cp_id, cp_method, cp_target, cp_type, cp_price, cp_trunc, cp_minimum, cp_maximum
from {$g4['shop_coupon_table']}
where cp_id = '$cid'
- and mb_id = '{$member['mb_id']}'
+ and mb_id IN ( '{$member['mb_id']}', '전체회원' )
and cp_start <= '".G4_TIME_YMD."'
and cp_end >= '".G4_TIME_YMD."'
- and cp_used = '0'
and cp_method IN ( 0, 1 ) ";
$cp = sql_fetch($sql);
if(!$cp['cp_id'])
continue;
+ // 사용한 쿠폰인지
+ if(is_used_coupon($member['mb_id'], $cp['cp_id']))
+ continue;
+
// 분류할인인지
if($cp['cp_method']) {
$sql2 = " select it_id, ca_id, ca_id2, ca_id3
@@ -155,8 +158,11 @@ if($is_member) {
and cp_method = '2' ";
$cp = sql_fetch($sql);
+ // 사용한 쿠폰인지
+ $cp_used = is_used_coupon($member['mb_id'], $cp['cp_id']);
+
$dc = 0;
- if($cp['cp_id'] && ($cp['cp_minimum'] <= $tot_od_price)) {
+ if(!$cp_used && $cp['cp_id'] && ($cp['cp_minimum'] <= $tot_od_price)) {
if($cp['cp_type']) {
$dc = floor(($tot_od_price * ($cp['cp_price'] / 100)) / $cp['cp_trunc']) * $cp['cp_trunc'];
} else {
@@ -198,8 +204,11 @@ if($is_member && $send_cost > 0) {
and cp_method = '3' ";
$cp = sql_fetch($sql);
+ // 사용한 쿠폰인지
+ $cp_used = is_used_coupon($member['mb_id'], $cp['cp_id']);
+
$dc = 0;
- if($cp['cp_id'] && ($cp['cp_minimum'] <= $tot_od_price)) {
+ if(!$cp_used && $cp['cp_id'] && ($cp['cp_minimum'] <= $tot_od_price)) {
if($cp['cp_type']) {
$dc = floor(($send_cost * ($cp['cp_price'] / 100)) / $cp['cp_trunc']) * $cp['cp_trunc'];
} else {
@@ -473,13 +482,14 @@ if($is_member) {
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 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 ) ";
+ $cp_prc = (int)$arr_it_cp_prc[$cp_it_id];
+
+ $sql = " insert into {$g4['shop_coupon_log_table']}
+ set cp_id = '$cid',
+ mb_id = '{$member['mb_id']}',
+ od_id = '$od_id',
+ cp_price = '$cp_prc',
+ cl_datetime = '".G4_TIME_YMDHIS."' ";
sql_query($sql);
// 쿠폰사용금액 cart에 기록
@@ -495,24 +505,22 @@ if($is_member) {
}
if($_POST['od_cp_id']) {
- $sql = " update {$g4['shop_coupon_table']}
- 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' ";
+ $sql = " insert into {$g4['shop_coupon_log_table']}
+ set cp_id = '{$_POST['od_cp_id']}',
+ mb_id = '{$member['mb_id']}',
+ od_id = '$od_id',
+ cp_price = '$tot_od_cp_price',
+ cl_datetime = '".G4_TIME_YMDHIS."' ";
sql_query($sql);
}
if($_POST['sc_cp_id']) {
- $sql = " update {$g4['shop_coupon_table']}
- 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' ";
+ $sql = " insert into {$g4['shop_coupon_log_table']}
+ set cp_id = '{$_POST['sc_cp_id']}',
+ mb_id = '{$member['mb_id']}',
+ od_id = '$od_id',
+ cp_price = '$tot_sc_cp_price',
+ cl_datetime = '".G4_TIME_YMDHIS."' ";
sql_query($sql);
}
}
diff --git a/shop/ordercoupon.php b/shop/ordercoupon.php
index 7661143ff..08dc412b0 100644
--- a/shop/ordercoupon.php
+++ b/shop/ordercoupon.php
@@ -9,11 +9,10 @@ $price = $_POST['price'];
// 쿠폰정보
$sql = " select *
from {$g4['shop_coupon_table']}
- where mb_id = '{$member['mb_id']}'
+ where mb_id IN ( '{$member['mb_id']}', '전체회원' )
and cp_method = '2'
and cp_start <= '".G4_TIME_YMD."'
and cp_end >= '".G4_TIME_YMD."'
- and cp_used = '0'
and cp_minimum <= '$price' ";
$result = sql_query($sql);
$count = mysql_num_rows($result);
@@ -34,6 +33,10 @@ $count = mysql_num_rows($result);
= '".G4_TIME_YMD."'
and cp_minimum <= '$sell_price'
@@ -246,9 +246,16 @@ function get_intall_file()
OR
( cp_method = '1' and ( cp_target IN ( '{$row['ca_id']}', '{$row['ca_id2']}', '{$row['ca_id3']}' ) ) )
) ";
- $cp = sql_fetch($sql);
+ $res = sql_query($sql);
- if($cp['cnt'])
+ for($k=0; $cp=sql_fetch_array($res); $k++) {
+ if(is_used_coupon($member['mb_id'], $cp['cp_id']))
+ continue;
+
+ $cp_count++;
+ }
+
+ if($cp_count)
$cp_button = '';
}
?>
@@ -752,29 +759,40 @@ function get_intall_file()
= '".G4_TIME_YMD."'
- and cp_used = '0' ";
- $row = sql_fetch($sql);
- $oc_cnt = $row['cnt'];
+ and cp_end >= '".G4_TIME_YMD."' ";
+ $res = sql_query($sql);
+
+ for($k=0; $cp=sql_fetch_array($res); $k++) {
+ if(is_used_coupon($member['mb_id'], $cp['cp_id']))
+ continue;
+
+ $oc_cnt++;
+ }
if($send_cost > 0) {
// 배송비쿠폰
- $sql = " select count(*) as cnt
+ $sql = " select cp_id
from {$g4['shop_coupon_table']}
- where mb_id = '{$member['mb_id']}'
+ where mb_id IN ( '{$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'];
+ and cp_end >= '".G4_TIME_YMD."' ";
+ $res = sql_query($sql);
+
+ for($k=0; $cp=sql_fetch_array($res); $k++) {
+ if(is_used_coupon($member['mb_id'], $cp['cp_id']))
+ continue;
+
+ $sc_cnt++;
+ }
}
}
?>
diff --git a/shop/orderformupdate.php b/shop/orderformupdate.php
index 9c06f01aa..9cdc9c9b5 100644
--- a/shop/orderformupdate.php
+++ b/shop/orderformupdate.php
@@ -81,15 +81,18 @@ if($is_member) {
$sql = " select cp_id, cp_method, cp_target, cp_type, cp_price, cp_trunc, cp_minimum, cp_maximum
from {$g4['shop_coupon_table']}
where cp_id = '$cid'
- and mb_id = '{$member['mb_id']}'
+ and mb_id IN ( '{$member['mb_id']}', '전체회원' )
and cp_start <= '".G4_TIME_YMD."'
and cp_end >= '".G4_TIME_YMD."'
- and cp_used = '0'
and cp_method IN ( 0, 1 ) ";
$cp = sql_fetch($sql);
if(!$cp['cp_id'])
continue;
+ // 사용한 쿠폰인지
+ if(is_used_coupon($member['mb_id'], $cp['cp_id']))
+ continue;
+
// 분류할인인지
if($cp['cp_method']) {
$sql2 = " select it_id, ca_id, ca_id2, ca_id3
@@ -143,15 +146,17 @@ if($is_member) {
$sql = " select cp_id, cp_type, cp_price, 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 mb_id IN ( '{$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);
+ // 사용한 쿠폰인지
+ $cp_used = is_used_coupon($member['mb_id'], $cp['cp_id']);
+
$dc = 0;
- if($cp['cp_id'] && ($cp['cp_minimum'] <= $tot_od_price)) {
+ if(!$cp_used && $cp['cp_id'] && ($cp['cp_minimum'] <= $tot_od_price)) {
if($cp['cp_type']) {
$dc = floor(($tot_od_price * ($cp['cp_price'] / 100)) / $cp['cp_trunc']) * $cp['cp_trunc'];
} else {
@@ -186,15 +191,17 @@ if($is_member && $send_cost > 0) {
$sql = " select cp_id, cp_type, cp_price, 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 mb_id IN ( '{$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);
+ // 사용한 쿠폰인지
+ $cp_used = is_used_coupon($member['mb_id'], $cp['cp_id']);
+
$dc = 0;
- if($cp['cp_id'] && ($cp['cp_minimum'] <= $tot_od_price)) {
+ if(!$cp_used && $cp['cp_id'] && ($cp['cp_minimum'] <= $tot_od_price)) {
if($cp['cp_type']) {
$dc = floor(($send_cost * ($cp['cp_price'] / 100)) / $cp['cp_trunc']) * $cp['cp_trunc'];
} else {
@@ -468,13 +475,14 @@ if($is_member) {
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 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 ) ";
+ $cp_prc = (int)$arr_it_cp_prc[$cp_it_id];
+
+ $sql = " insert into {$g4['shop_coupon_log_table']}
+ set cp_id = '$cid',
+ mb_id = '{$member['mb_id']}',
+ od_id = '$od_id',
+ cp_price = '$cp_prc',
+ cl_datetime = '".G4_TIME_YMDHIS."' ";
sql_query($sql);
// 쿠폰사용금액 cart에 기록
@@ -490,24 +498,22 @@ if($is_member) {
}
if($_POST['od_cp_id']) {
- $sql = " update {$g4['shop_coupon_table']}
- 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' ";
+ $sql = " insert into {$g4['shop_coupon_log_table']}
+ set cp_id = '{$_POST['od_cp_id']}',
+ mb_id = '{$member['mb_id']}',
+ od_id = '$od_id',
+ cp_price = '$tot_od_cp_price',
+ cl_datetime = '".G4_TIME_YMDHIS."' ";
sql_query($sql);
}
if($_POST['sc_cp_id']) {
- $sql = " update {$g4['shop_coupon_table']}
- 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' ";
+ $sql = " insert into {$g4['shop_coupon_log_table']}
+ set cp_id = '{$_POST['sc_cp_id']}',
+ mb_id = '{$member['mb_id']}',
+ od_id = '$od_id',
+ cp_price = '$tot_sc_cp_price',
+ cl_datetime = '".G4_TIME_YMDHIS."' ";
sql_query($sql);
}
}
diff --git a/shop/orderitemcoupon.php b/shop/orderitemcoupon.php
index ac02aebfb..612ea288f 100644
--- a/shop/orderitemcoupon.php
+++ b/shop/orderitemcoupon.php
@@ -26,8 +26,7 @@ $item_price = $ct['sum_price'];
// 쿠폰정보
$sql = " select *
from {$g4['shop_coupon_table']}
- where mb_id = '{$member['mb_id']}'
- and cp_used = '0'
+ where mb_id IN ( '{$member['mb_id']}', '전체회원' )
and cp_start <= '".G4_TIME_YMD."'
and cp_end >= '".G4_TIME_YMD."'
and cp_minimum <= '$item_price'
@@ -55,6 +54,10 @@ $count = mysql_num_rows($result);
= '".G4_TIME_YMD."'
- and cp_used = '0'
and cp_minimum <= '$price' ";
$result = sql_query($sql);
$count = mysql_num_rows($result);
@@ -35,6 +34,10 @@ $count = mysql_num_rows($result);