포인트 소멸내역 삭제 처리 코드 추가

This commit is contained in:
chicpro
2013-07-30 14:38:42 +09:00
parent 697bb550f4
commit 470698c149
2 changed files with 56 additions and 13 deletions

View File

@ -25,14 +25,15 @@ for ($i=0; $i<$count; $i++)
continue;
if($row['po_point'] < 0) {
if($row['po_rel_table'] != '@expire') {
$mb_id = $row['mb_id'];
$po_point = abs($row['po_point']);
$mb_id = $row['mb_id'];
$po_point = abs($row['po_point']);
if($row['po_rel_table'] == '@expire')
delete_expire_point($mb_id, $po_point);
else
delete_use_point($mb_id, $po_point);
}
} else {
if($row['po_expired'] != 1 && $row['po_use_point'] > 0) {
if($row['po_use_point'] > 0) {
insert_use_point($row['mb_id'], $row['po_use_point'], $row['po_id']);
}
}
@ -44,10 +45,11 @@ for ($i=0; $i<$count; $i++)
// po_mb_point에 반영
$sql = " update {$g4['point_table']}
set po_mb_point = po_mb_point - '{$row['po_point']}'
where mb_id = '$mb_id'
and po_id > '{$row['po_id']}' ";
where mb_id = '{$_POST['mb_id'][$k]}'
and po_id > '{$_POST['po_id'][$k]}' ";
sql_query($sql);
// 포인트 UPDATE
$sum_point = get_point_sum($_POST['mb_id'][$k]);
$sql= " update {$g4['member_table']} set mb_point = '$sum_point' where mb_id = '{$_POST['mb_id'][$k]}' ";
sql_query($sql);

View File

@ -981,6 +981,7 @@ function delete_use_point($mb_id, $point)
$sql = " select po_id, po_use_point, po_expired, po_expire_date
from {$g4['point_table']}
where mb_id = '$mb_id'
and po_expired <> '1'
and po_use_point > 0
$sql_order ";
$result = sql_query($sql);
@ -1010,6 +1011,48 @@ function delete_use_point($mb_id, $point)
}
}
// 소멸포인트 삭제
function delete_expire_point($mb_id, $point)
{
global $g4, $config;
$point1 = abs($point);
$sql = " select po_id, po_use_point, po_expired, po_expire_date
from {$g4['point_table']}
where mb_id = '$mb_id'
and po_expired = '1'
and po_point >= 0
and po_use_point > 0
order by po_expire_date desc, po_id desc ";
$result = sql_query($sql);
for($i=0; $row=sql_fetch_array($result); $i++) {
$point2 = $row['po_use_point'];
$po_expired = '0';
$po_expire_date = '9999-12-31';
if($config['cf_point_term'] > 0)
$po_expire_date = date('Y-m-d', strtotime('+'.($config['cf_point_term'] - 1).' days', G4_SERVER_TIME));
if($point2 > $point1) {
$sql = " update {$g4['point_table']}
set po_use_point = po_use_point - '$point1',
po_expired = '$po_expired',
po_expire_date = '$po_expire_date'
where po_id = '{$row['po_id']}' ";
sql_query($sql);
break;
} else {
$sql = " update {$g4['point_table']}
set po_use_point = '0',
po_expired = '$po_expired',
po_expire_date = '$po_expire_date'
where po_id = '{$row['po_id']}' ";
sql_query($sql);
$point1 -= $point2;
}
}
}
// 포인트 내역 합계
function get_point_sum($mb_id)
{
@ -1104,14 +1147,12 @@ function delete_point($mb_id, $rel_table, $rel_id, $rel_action)
$row = sql_fetch($sql);
if($row['po_point'] < 0) {
if($row['po_rel_table'] != '@expire') {
$mb_id = $row['mb_id'];
$po_point = abs($row['po_point']);
$mb_id = $row['mb_id'];
$po_point = abs($row['po_point']);
delete_use_point($mb_id, $po_point);
}
delete_use_point($mb_id, $po_point);
} else {
if($row['po_expired'] != 1 && $row['po_use_point'] > 0) {
if($row['po_use_point'] > 0) {
insert_use_point($row['mb_id'], $row['po_use_point'], $row['po_id']);
}
}