#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

@ -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);
<tbody>
<?php
for($i=0; $row=sql_fetch_array($result); $i++) {
// 사용한 쿠폰인지 체크
if(is_used_coupon($member['mb_id'], $row['cp_id']))
continue;
$dc = 0;
if($row['cp_type']) {
$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) {
$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'
@ -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 = '<button type="button" class="it_coupon_btn btn_frmline">적용</button>';
}
?>
@ -752,29 +759,40 @@ function get_intall_file()
<!-- 결제정보 입력 시작 { -->
<?php
$oc_cnt = $sc_cnt = 0;
if($is_member) {
// 주문쿠폰
$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 = '2'
and cp_start <= '".G4_TIM_YMD."'
and cp_end >= '".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++;
}
}
}
?>

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
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);
}
}

View File

@ -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);
<tbody>
<?php
for($i=0; $row=sql_fetch_array($result); $i++) {
// 사용한 쿠폰인지 체크
if(is_used_coupon($member['mb_id'], $row['cp_id']))
continue;
$dc = 0;
if($row['cp_type']) {
$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 *
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_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);
@ -35,6 +34,10 @@ $count = mysql_num_rows($result);
<tbody>
<?php
for($i=0; $row=sql_fetch_array($result); $i++) {
// 사용한 쿠폰인지 체크
if(is_used_coupon($member['mb_id'], $row['cp_id']))
continue;
$dc = 0;
if($row['cp_type']) {
$dc = floor(($send_cost * ($row['cp_price'] / 100)) / $row['cp_trunc']) * $row['cp_trunc'];