#292 쿠폰 로그 테이블 추가하여 내역을 기록함

This commit is contained in:
chicpro
2013-09-12 11:39:43 +09:00
parent 5b622a1e32
commit e5758b4466
12 changed files with 241 additions and 150 deletions

View File

@ -50,56 +50,38 @@ if($_POST['cp_method'] == 0) {
} }
if($w == '') { if($w == '') {
$arr_mb_id = array();
if($_POST['chk_all_mb']) { 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 = '' "; $mb_id = '전체회원';
$result = sql_query($sql);
for($i=0; $row=sql_fetch_array($result); $i++) {
$arr_mb_id[] = $row['mb_id'];
}
if($i == 0)
alert('관리자를 제외한 쿠폰 발급 가능 회원이 없습니다.');
} else { } else {
if($_POST['mb_id'] == $config['cf_admin']) $sql = " select mb_id from {$g4['member_table']} where mb_id = '{$_POST['mb_id']}' and mb_leave_date = '' and mb_intercept_date = '' ";
alert('관리자를 제외한 회원의 아이디를 입력해 주십시오.'); $row = sql_fetch($sql);
if(!$row['mb_id'])
$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'])
alert('입력하신 회원아이디는 존재하지 않거나 탈퇴 또는 차단된 회원아이디입니다.'); 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++) { $sql3 = " select count(*) as cnt from {$g4['shop_coupon_table']} where cp_id = '$cp_id' ";
$mb_id = $arr_mb_id[$i]; $row3 = sql_fetch($sql3);
$j = 0; if(!$row3['cnt'])
do { break;
$cp_id = get_coupon_id(); 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' "; $sql = " INSERT INTO {$g4['shop_coupon_table']}
$row3 = sql_fetch($sql3); ( 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']) sql_query($sql);
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);
}
} else if($w == 'u') { } else if($w == 'u') {
$sql = " select * from {$g4['shop_coupon_table']} where cp_id = '$cp_id' "; $sql = " select * from {$g4['shop_coupon_table']} where cp_id = '$cp_id' ";
$cp = sql_fetch($sql); $cp = sql_fetch($sql);
@ -107,6 +89,10 @@ if($w == '') {
if(!$cp['cp_id']) if(!$cp['cp_id'])
alert('쿠폰정보가 존해하지 않습니다.', './couponlist.php'); alert('쿠폰정보가 존해하지 않습니다.', './couponlist.php');
if($_POST['chk_all_mb']) {
$mb_id = '전체회원';
}
$sql = " update {$g4['shop_coupon_table']} $sql = " update {$g4['shop_coupon_table']}
set cp_subject = '$cp_subject', set cp_subject = '$cp_subject',
cp_method = '$cp_method', cp_method = '$cp_method',

View File

@ -6,11 +6,6 @@ auth_check($auth[$sub_menu], "r");
$token = get_token(); $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_common = " from {$g4['shop_coupon_table']} ";
$sql_search = " where (1) "; $sql_search = " where (1) ";
@ -109,20 +104,13 @@ $colspan = 8;
<th scope="col">적용대상</th> <th scope="col">적용대상</th>
<th scope="col">회원아이디</a></th> <th scope="col">회원아이디</a></th>
<th scope="col">사용기한</a></th> <th scope="col">사용기한</a></th>
<th scope="col">사용</th> <th scope="col">사용회수</th>
<th scope="col">관리</th> <th scope="col">관리</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php <?php
for ($i=0; $row=sql_fetch_array($result); $i++) { for ($i=0; $row=sql_fetch_array($result); $i++) {
if ($i==0 || ($row2['mb_id'] != $row['mb_id'])) {
$sql2 = " select mb_id, mb_name, mb_nick, mb_email, mb_homepage from {$g4['member_table']} where mb_id = '{$row['mb_id']}' ";
$row2 = sql_fetch($sql2);
}
$mb_nick = get_sideview($row['mb_id'], $row2['mb_nick'], $row2['mb_email'], $row2['mb_homepage']);
switch($row['cp_method']) { switch($row['cp_method']) {
case '0': case '0':
$sql3 = " select it_name from {$g4['shop_item_table']} where it_id = '{$row['cp_target']}' "; $sql3 = " select it_name from {$g4['shop_item_table']} where it_id = '{$row['cp_target']}' ";
@ -144,6 +132,11 @@ $colspan = 8;
$link1 = '<a href="./orderform.php?od_id='.$row['od_id'].'">'; $link1 = '<a href="./orderform.php?od_id='.$row['od_id'].'">';
$link2 = '</a>'; $link2 = '</a>';
// 쿠폰사용회수
$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'];
?> ?>
<tr> <tr>
@ -156,7 +149,7 @@ $colspan = 8;
<td><?php echo $cp_target; ?></td> <td><?php echo $cp_target; ?></td>
<td class="td_name sv_use"><div><?php echo $row['mb_id']; ?></div></td> <td class="td_name sv_use"><div><?php echo $row['mb_id']; ?></div></td>
<td class="td_time"><?php echo substr($row['cp_start'], 2, 8); ?> ~ <?php echo substr($row['cp_end'], 2, 8); ?></td> <td class="td_time"><?php echo substr($row['cp_start'], 2, 8); ?> ~ <?php echo substr($row['cp_end'], 2, 8); ?></td>
<td class="td_boolean"><?php echo $row['cp_used'] ? '예' : '아니오'; ?></td> <td class="td_boolean"><?php echo number_format($used_count); ?></td>
<td class="td_smallmng"> <td class="td_smallmng">
<a href="./couponform.php?w=u&amp;cp_id=<?php echo $row['cp_id']; ?>&amp;<?php echo $qstr; ?>"><span class="sound_only"><?php echo $row['cp_id']; ?> </span>수정</a> <a href="./couponform.php?w=u&amp;cp_id=<?php echo $row['cp_id']; ?>&amp;<?php echo $qstr; ?>"><span class="sound_only"><?php echo $row['cp_id']; ?> </span>수정</a>
</td> </td>

View File

@ -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']}` sql_query(" ALTER TABLE `{$g4['shop_order_table']}`
ADD `od_misu` int(11) NOT NULL DEFAULT '0' AFTER `od_coupon` ", true); 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);
}
?> ?>

View File

@ -128,8 +128,6 @@ CREATE TABLE IF NOT EXISTS `shop_coupon` (
`cp_minimum` INT(11) NOT NULL DEFAULT '0', `cp_minimum` INT(11) NOT NULL DEFAULT '0',
`cp_maximum` INT(11) NOT NULL DEFAULT '0', `cp_maximum` INT(11) NOT NULL DEFAULT '0',
`od_id` bigint(20) unsigned NOT NULL, `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', `cp_datetime` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
PRIMARY KEY (`cp_no`), PRIMARY KEY (`cp_no`),
UNIQUE KEY `cp_id` (`cp_id`), 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` -- Table structure for table `shop_default`
-- --

View File

@ -1603,6 +1603,22 @@ function get_order_misu($od_id)
return $od['misu']; 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;
}
//============================================================================== //==============================================================================
// 쇼핑몰 라이브러리 모음 끝 // 쇼핑몰 라이브러리 모음 끝
//============================================================================== //==============================================================================

View File

@ -145,11 +145,11 @@ ob_start();
// 쿠폰 // 쿠폰
if($is_member) { if($is_member) {
$cp_button = ''; $cp_button = '';
$cp_count = 0;
$sql = " select count(*) as cnt $sql = " select cp_id
from {$g4['shop_coupon_table']} from {$g4['shop_coupon_table']}
where mb_id = '{$member['mb_id']}' where mb_id IN ( '{$member['mb_id']}', '전체회원' )
and cp_used = '0'
and cp_start <= '".G4_TIME_YMD."' and cp_start <= '".G4_TIME_YMD."'
and cp_end >= '".G4_TIME_YMD."' and cp_end >= '".G4_TIME_YMD."'
and cp_minimum <= '$sell_price' and cp_minimum <= '$sell_price'
@ -158,9 +158,16 @@ ob_start();
OR OR
( cp_method = '1' and ( cp_target IN ( '{$row['ca_id']}', '{$row['ca_id2']}', '{$row['ca_id3']}' ) ) ) ( 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 = '<button type="button" class="it_coupon_btn btn_frmline">적용</button>'; $cp_button = '<button type="button" class="it_coupon_btn btn_frmline">적용</button>';
} }
?> ?>
@ -514,29 +521,40 @@ ob_end_clean();
</section> </section>
<?php <?php
$oc_cnt = $sc_cnt = 0;
if($is_member) { if($is_member) {
// 주문쿠폰 // 주문쿠폰
$sql = " select count(*) as cnt $sql = " select cp_id
from {$g4['shop_coupon_table']} from {$g4['shop_coupon_table']}
where mb_id = '{$member['mb_id']}' where mb_id IN ( '{$member['mb_id']}', '전체회원' )
and cp_method = '2' and cp_method = '2'
and cp_start <= '".G4_TIM_YMD."' and cp_start <= '".G4_TIM_YMD."'
and cp_end >= '".G4_TIME_YMD."' and cp_end >= '".G4_TIME_YMD."' ";
and cp_used = '0' "; $res = sql_query($sql);
$row = sql_fetch($sql);
$oc_cnt = $row['cnt']; 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) { if($send_cost > 0) {
// 배송비쿠폰 // 배송비쿠폰
$sql = " select count(*) as cnt $sql = " select cp_id
from {$g4['shop_coupon_table']} from {$g4['shop_coupon_table']}
where mb_id = '{$member['mb_id']}' where mb_id IN ( '{$member['mb_id']}', '전체회원' )
and cp_method = '3' and cp_method = '3'
and cp_start <= '".G4_TIM_YMD."' and cp_start <= '".G4_TIM_YMD."'
and cp_end >= '".G4_TIME_YMD."' and cp_end >= '".G4_TIME_YMD."' ";
and cp_used = '0' "; $res = sql_query($sql);
$row = sql_fetch($sql);
$sc_cnt = $row['cnt']; for($k=0; $cp=sql_fetch_array($res); $k++) {
if(is_used_coupon($member['mb_id'], $cp['cp_id']))
continue;
$sc_cnt++;
}
} }
} }
?> ?>

View File

@ -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 $sql = " select cp_id, cp_method, cp_target, cp_type, cp_price, cp_trunc, cp_minimum, cp_maximum
from {$g4['shop_coupon_table']} from {$g4['shop_coupon_table']}
where cp_id = '$cid' 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_start <= '".G4_TIME_YMD."'
and cp_end >= '".G4_TIME_YMD."' and cp_end >= '".G4_TIME_YMD."'
and cp_used = '0'
and cp_method IN ( 0, 1 ) "; and cp_method IN ( 0, 1 ) ";
$cp = sql_fetch($sql); $cp = sql_fetch($sql);
if(!$cp['cp_id']) if(!$cp['cp_id'])
continue; continue;
// 사용한 쿠폰인지
if(is_used_coupon($member['mb_id'], $cp['cp_id']))
continue;
// 분류할인인지 // 분류할인인지
if($cp['cp_method']) { if($cp['cp_method']) {
$sql2 = " select it_id, ca_id, ca_id2, ca_id3 $sql2 = " select it_id, ca_id, ca_id2, ca_id3
@ -155,8 +158,11 @@ if($is_member) {
and cp_method = '2' "; and cp_method = '2' ";
$cp = sql_fetch($sql); $cp = sql_fetch($sql);
// 사용한 쿠폰인지
$cp_used = is_used_coupon($member['mb_id'], $cp['cp_id']);
$dc = 0; $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']) { if($cp['cp_type']) {
$dc = floor(($tot_od_price * ($cp['cp_price'] / 100)) / $cp['cp_trunc']) * $cp['cp_trunc']; $dc = floor(($tot_od_price * ($cp['cp_price'] / 100)) / $cp['cp_trunc']) * $cp['cp_trunc'];
} else { } else {
@ -198,8 +204,11 @@ if($is_member && $send_cost > 0) {
and cp_method = '3' "; and cp_method = '3' ";
$cp = sql_fetch($sql); $cp = sql_fetch($sql);
// 사용한 쿠폰인지
$cp_used = is_used_coupon($member['mb_id'], $cp['cp_id']);
$dc = 0; $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']) { if($cp['cp_type']) {
$dc = floor(($send_cost * ($cp['cp_price'] / 100)) / $cp['cp_trunc']) * $cp['cp_trunc']; $dc = floor(($send_cost * ($cp['cp_price'] / 100)) / $cp['cp_trunc']) * $cp['cp_trunc'];
} else { } else {
@ -473,13 +482,14 @@ if($is_member) {
for($i=0; $i<$it_cp_cnt; $i++) { for($i=0; $i<$it_cp_cnt; $i++) {
$cid = $_POST['cp_id'][$i]; $cid = $_POST['cp_id'][$i];
$cp_it_id = $_POST['it_id'][$i]; $cp_it_id = $_POST['it_id'][$i];
$sql = " update {$g4['shop_coupon_table']} $cp_prc = (int)$arr_it_cp_prc[$cp_it_id];
set od_id = '$od_id',
cp_used = '1', $sql = " insert into {$g4['shop_coupon_log_table']}
cp_used_time = '".G4_TIME_YMDHIS."' set cp_id = '$cid',
where cp_id = '$cid' mb_id = '{$member['mb_id']}',
and mb_id = '{$member['mb_id']}' od_id = '$od_id',
and cp_method IN ( 0, 1 ) "; cp_price = '$cp_prc',
cl_datetime = '".G4_TIME_YMDHIS."' ";
sql_query($sql); sql_query($sql);
// 쿠폰사용금액 cart에 기록 // 쿠폰사용금액 cart에 기록
@ -495,24 +505,22 @@ if($is_member) {
} }
if($_POST['od_cp_id']) { if($_POST['od_cp_id']) {
$sql = " update {$g4['shop_coupon_table']} $sql = " insert into {$g4['shop_coupon_log_table']}
set od_id = '$od_id', set cp_id = '{$_POST['od_cp_id']}',
cp_used = '1', mb_id = '{$member['mb_id']}',
cp_used_time = '".G4_TIME_YMDHIS."' od_id = '$od_id',
where cp_id = '{$_POST['od_cp_id']}' cp_price = '$tot_od_cp_price',
and mb_id = '{$member['mb_id']}' cl_datetime = '".G4_TIME_YMDHIS."' ";
and cp_method = '2' ";
sql_query($sql); sql_query($sql);
} }
if($_POST['sc_cp_id']) { if($_POST['sc_cp_id']) {
$sql = " update {$g4['shop_coupon_table']} $sql = " insert into {$g4['shop_coupon_log_table']}
set od_id = '$od_id', set cp_id = '{$_POST['sc_cp_id']}',
cp_used = '1', mb_id = '{$member['mb_id']}',
cp_used_time = '".G4_TIME_YMDHIS."' od_id = '$od_id',
where cp_id = '{$_POST['sc_cp_id']}' cp_price = '$tot_sc_cp_price',
and mb_id = '{$member['mb_id']}' cl_datetime = '".G4_TIME_YMDHIS."' ";
and cp_method = '3' ";
sql_query($sql); sql_query($sql);
} }
} }

View File

@ -9,11 +9,10 @@ $price = $_POST['price'];
// 쿠폰정보 // 쿠폰정보
$sql = " select * $sql = " select *
from {$g4['shop_coupon_table']} from {$g4['shop_coupon_table']}
where mb_id = '{$member['mb_id']}' where mb_id IN ( '{$member['mb_id']}', '전체회원' )
and cp_method = '2' and cp_method = '2'
and cp_start <= '".G4_TIME_YMD."' and cp_start <= '".G4_TIME_YMD."'
and cp_end >= '".G4_TIME_YMD."' and cp_end >= '".G4_TIME_YMD."'
and cp_used = '0'
and cp_minimum <= '$price' "; and cp_minimum <= '$price' ";
$result = sql_query($sql); $result = sql_query($sql);
$count = mysql_num_rows($result); $count = mysql_num_rows($result);
@ -34,6 +33,10 @@ $count = mysql_num_rows($result);
<tbody> <tbody>
<?php <?php
for($i=0; $row=sql_fetch_array($result); $i++) { for($i=0; $row=sql_fetch_array($result); $i++) {
// 사용한 쿠폰인지 체크
if(is_used_coupon($member['mb_id'], $row['cp_id']))
continue;
$dc = 0; $dc = 0;
if($row['cp_type']) { if($row['cp_type']) {
$dc = floor(($price * ($row['cp_price'] / 100)) / $row['cp_trunc']) * $row['cp_trunc']; $dc = floor(($price * ($row['cp_price'] / 100)) / $row['cp_trunc']) * $row['cp_trunc'];

View File

@ -233,11 +233,11 @@ function get_intall_file()
// 쿠폰 // 쿠폰
if($is_member) { if($is_member) {
$cp_button = ''; $cp_button = '';
$cp_count = 0;
$sql = " select count(*) as cnt $sql = " select cp_id
from {$g4['shop_coupon_table']} from {$g4['shop_coupon_table']}
where mb_id = '{$member['mb_id']}' where mb_id IN ( '{$member['mb_id']}', '전체회원' )
and cp_used = '0'
and cp_start <= '".G4_TIME_YMD."' and cp_start <= '".G4_TIME_YMD."'
and cp_end >= '".G4_TIME_YMD."' and cp_end >= '".G4_TIME_YMD."'
and cp_minimum <= '$sell_price' and cp_minimum <= '$sell_price'
@ -246,9 +246,16 @@ function get_intall_file()
OR OR
( cp_method = '1' and ( cp_target IN ( '{$row['ca_id']}', '{$row['ca_id2']}', '{$row['ca_id3']}' ) ) ) ( 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 = '<button type="button" class="it_coupon_btn btn_frmline">적용</button>'; $cp_button = '<button type="button" class="it_coupon_btn btn_frmline">적용</button>';
} }
?> ?>
@ -752,29 +759,40 @@ function get_intall_file()
<!-- 결제정보 입력 시작 { --> <!-- 결제정보 입력 시작 { -->
<?php <?php
$oc_cnt = $sc_cnt = 0;
if($is_member) { if($is_member) {
// 주문쿠폰 // 주문쿠폰
$sql = " select count(*) as cnt $sql = " select cp_id
from {$g4['shop_coupon_table']} from {$g4['shop_coupon_table']}
where mb_id = '{$member['mb_id']}' where mb_id IN ( '{$member['mb_id']}', '전체회원' )
and cp_method = '2' and cp_method = '2'
and cp_start <= '".G4_TIM_YMD."' and cp_start <= '".G4_TIM_YMD."'
and cp_end >= '".G4_TIME_YMD."' and cp_end >= '".G4_TIME_YMD."' ";
and cp_used = '0' "; $res = sql_query($sql);
$row = sql_fetch($sql);
$oc_cnt = $row['cnt']; 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) { if($send_cost > 0) {
// 배송비쿠폰 // 배송비쿠폰
$sql = " select count(*) as cnt $sql = " select cp_id
from {$g4['shop_coupon_table']} from {$g4['shop_coupon_table']}
where mb_id = '{$member['mb_id']}' where mb_id IN ( '{$member['mb_id']}', '전체회원' )
and cp_method = '3' and cp_method = '3'
and cp_start <= '".G4_TIM_YMD."' and cp_start <= '".G4_TIM_YMD."'
and cp_end >= '".G4_TIME_YMD."' and cp_end >= '".G4_TIME_YMD."' ";
and cp_used = '0' "; $res = sql_query($sql);
$row = sql_fetch($sql);
$sc_cnt = $row['cnt']; for($k=0; $cp=sql_fetch_array($res); $k++) {
if(is_used_coupon($member['mb_id'], $cp['cp_id']))
continue;
$sc_cnt++;
}
} }
} }
?> ?>

View File

@ -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 $sql = " select cp_id, cp_method, cp_target, cp_type, cp_price, cp_trunc, cp_minimum, cp_maximum
from {$g4['shop_coupon_table']} from {$g4['shop_coupon_table']}
where cp_id = '$cid' 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_start <= '".G4_TIME_YMD."'
and cp_end >= '".G4_TIME_YMD."' and cp_end >= '".G4_TIME_YMD."'
and cp_used = '0'
and cp_method IN ( 0, 1 ) "; and cp_method IN ( 0, 1 ) ";
$cp = sql_fetch($sql); $cp = sql_fetch($sql);
if(!$cp['cp_id']) if(!$cp['cp_id'])
continue; continue;
// 사용한 쿠폰인지
if(is_used_coupon($member['mb_id'], $cp['cp_id']))
continue;
// 분류할인인지 // 분류할인인지
if($cp['cp_method']) { if($cp['cp_method']) {
$sql2 = " select it_id, ca_id, ca_id2, ca_id3 $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 $sql = " select cp_id, cp_type, cp_price, cp_trunc, cp_minimum, cp_maximum
from {$g4['shop_coupon_table']} from {$g4['shop_coupon_table']}
where cp_id = '{$_POST['od_cp_id']}' 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_start <= '".G4_TIME_YMD."'
and cp_end >= '".G4_TIME_YMD."' and cp_end >= '".G4_TIME_YMD."'
and cp_used = '0'
and cp_method = '2' "; and cp_method = '2' ";
$cp = sql_fetch($sql); $cp = sql_fetch($sql);
// 사용한 쿠폰인지
$cp_used = is_used_coupon($member['mb_id'], $cp['cp_id']);
$dc = 0; $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']) { if($cp['cp_type']) {
$dc = floor(($tot_od_price * ($cp['cp_price'] / 100)) / $cp['cp_trunc']) * $cp['cp_trunc']; $dc = floor(($tot_od_price * ($cp['cp_price'] / 100)) / $cp['cp_trunc']) * $cp['cp_trunc'];
} else { } 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 $sql = " select cp_id, cp_type, cp_price, cp_trunc, cp_minimum, cp_maximum
from {$g4['shop_coupon_table']} from {$g4['shop_coupon_table']}
where cp_id = '{$_POST['sc_cp_id']}' 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_start <= '".G4_TIME_YMD."'
and cp_end >= '".G4_TIME_YMD."' and cp_end >= '".G4_TIME_YMD."'
and cp_used = '0'
and cp_method = '3' "; and cp_method = '3' ";
$cp = sql_fetch($sql); $cp = sql_fetch($sql);
// 사용한 쿠폰인지
$cp_used = is_used_coupon($member['mb_id'], $cp['cp_id']);
$dc = 0; $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']) { if($cp['cp_type']) {
$dc = floor(($send_cost * ($cp['cp_price'] / 100)) / $cp['cp_trunc']) * $cp['cp_trunc']; $dc = floor(($send_cost * ($cp['cp_price'] / 100)) / $cp['cp_trunc']) * $cp['cp_trunc'];
} else { } else {
@ -468,13 +475,14 @@ if($is_member) {
for($i=0; $i<$it_cp_cnt; $i++) { for($i=0; $i<$it_cp_cnt; $i++) {
$cid = $_POST['cp_id'][$i]; $cid = $_POST['cp_id'][$i];
$cp_it_id = $_POST['it_id'][$i]; $cp_it_id = $_POST['it_id'][$i];
$sql = " update {$g4['shop_coupon_table']} $cp_prc = (int)$arr_it_cp_prc[$cp_it_id];
set od_id = '$od_id',
cp_used = '1', $sql = " insert into {$g4['shop_coupon_log_table']}
cp_used_time = '".G4_TIME_YMDHIS."' set cp_id = '$cid',
where cp_id = '$cid' mb_id = '{$member['mb_id']}',
and mb_id = '{$member['mb_id']}' od_id = '$od_id',
and cp_method IN ( 0, 1 ) "; cp_price = '$cp_prc',
cl_datetime = '".G4_TIME_YMDHIS."' ";
sql_query($sql); sql_query($sql);
// 쿠폰사용금액 cart에 기록 // 쿠폰사용금액 cart에 기록
@ -490,24 +498,22 @@ if($is_member) {
} }
if($_POST['od_cp_id']) { if($_POST['od_cp_id']) {
$sql = " update {$g4['shop_coupon_table']} $sql = " insert into {$g4['shop_coupon_log_table']}
set od_id = '$od_id', set cp_id = '{$_POST['od_cp_id']}',
cp_used = '1', mb_id = '{$member['mb_id']}',
cp_used_time = '".G4_TIME_YMDHIS."' od_id = '$od_id',
where cp_id = '{$_POST['od_cp_id']}' cp_price = '$tot_od_cp_price',
and mb_id = '{$member['mb_id']}' cl_datetime = '".G4_TIME_YMDHIS."' ";
and cp_method = '2' ";
sql_query($sql); sql_query($sql);
} }
if($_POST['sc_cp_id']) { if($_POST['sc_cp_id']) {
$sql = " update {$g4['shop_coupon_table']} $sql = " insert into {$g4['shop_coupon_log_table']}
set od_id = '$od_id', set cp_id = '{$_POST['sc_cp_id']}',
cp_used = '1', mb_id = '{$member['mb_id']}',
cp_used_time = '".G4_TIME_YMDHIS."' od_id = '$od_id',
where cp_id = '{$_POST['sc_cp_id']}' cp_price = '$tot_sc_cp_price',
and mb_id = '{$member['mb_id']}' cl_datetime = '".G4_TIME_YMDHIS."' ";
and cp_method = '3' ";
sql_query($sql); sql_query($sql);
} }
} }

View File

@ -26,8 +26,7 @@ $item_price = $ct['sum_price'];
// 쿠폰정보 // 쿠폰정보
$sql = " select * $sql = " select *
from {$g4['shop_coupon_table']} from {$g4['shop_coupon_table']}
where mb_id = '{$member['mb_id']}' where mb_id IN ( '{$member['mb_id']}', '전체회원' )
and cp_used = '0'
and cp_start <= '".G4_TIME_YMD."' and cp_start <= '".G4_TIME_YMD."'
and cp_end >= '".G4_TIME_YMD."' and cp_end >= '".G4_TIME_YMD."'
and cp_minimum <= '$item_price' and cp_minimum <= '$item_price'
@ -55,6 +54,10 @@ $count = mysql_num_rows($result);
<tbody> <tbody>
<?php <?php
for($i=0; $row=sql_fetch_array($result); $i++) { for($i=0; $row=sql_fetch_array($result); $i++) {
// 사용한 쿠폰인지 체크
if(is_used_coupon($member['mb_id'], $row['cp_id']))
continue;
$dc = 0; $dc = 0;
if($row['cp_type']) { if($row['cp_type']) {
$dc = floor(($item_price * ($row['cp_price'] / 100)) / $row['cp_trunc']) * $row['cp_trunc']; $dc = floor(($item_price * ($row['cp_price'] / 100)) / $row['cp_trunc']) * $row['cp_trunc'];

View File

@ -10,11 +10,10 @@ $send_cost = $_POST['send_cost'];
// 쿠폰정보 // 쿠폰정보
$sql = " select * $sql = " select *
from {$g4['shop_coupon_table']} from {$g4['shop_coupon_table']}
where mb_id = '{$member['mb_id']}' where mb_id IN ( '{$member['mb_id']}', '전체회원' )
and cp_method = '3' and cp_method = '3'
and cp_start <= '".G4_TIME_YMD."' and cp_start <= '".G4_TIME_YMD."'
and cp_end >= '".G4_TIME_YMD."' and cp_end >= '".G4_TIME_YMD."'
and cp_used = '0'
and cp_minimum <= '$price' "; and cp_minimum <= '$price' ";
$result = sql_query($sql); $result = sql_query($sql);
$count = mysql_num_rows($result); $count = mysql_num_rows($result);
@ -35,6 +34,10 @@ $count = mysql_num_rows($result);
<tbody> <tbody>
<?php <?php
for($i=0; $row=sql_fetch_array($result); $i++) { for($i=0; $row=sql_fetch_array($result); $i++) {
// 사용한 쿠폰인지 체크
if(is_used_coupon($member['mb_id'], $row['cp_id']))
continue;
$dc = 0; $dc = 0;
if($row['cp_type']) { if($row['cp_type']) {
$dc = floor(($send_cost * ($row['cp_price'] / 100)) / $row['cp_trunc']) * $row['cp_trunc']; $dc = floor(($send_cost * ($row['cp_price'] / 100)) / $row['cp_trunc']) * $row['cp_trunc'];