마일리지 기능 추가 및 상품 포인트 유형 추가

This commit is contained in:
chicpro
2013-05-31 16:15:28 +09:00
parent f21987e30c
commit 087c610751
13 changed files with 410 additions and 30 deletions

View File

@ -14,6 +14,7 @@ $menu['menu400'] = array (
array('400620', '상품재고관리', G4_ADMIN_URL.'/shop_admin/itemstocklist.php', 'scf_item_stock'),
array('400610', '상품유형관리', G4_ADMIN_URL.'/shop_admin/itemtypelist.php', 'scf_item_type'),
array('400500', '상품옵션재고관리', G4_ADMIN_URL.'/shop_admin/optionstocklist.php', 'scf_item_option'),
array('400490', '마일리지관리', G4_ADMIN_URL.'/shop_admin/mileagelist.php', 'scf_mileage'),
array('400500', '배송일괄처리', G4_ADMIN_URL.'/shop_admin/deliverylist.php', 'scf_deli', 1),
array('400740', '배송업체관리', G4_ADMIN_URL.'/shop_admin/deliverycodelist.php', 'scf_deli_co', 1),
array('400630', '이벤트관리', G4_ADMIN_URL.'/shop_admin/itemevent.php', 'scf_event'),

View File

@ -775,11 +775,37 @@ $(function(){
<label for="chk_all_it_cust_price">전체적용</label>
</td>
</tr>
<tr>
<th scope="row"><label for="it_point_type">포인트 유형</label></th>
<td>
<?php echo help("포인트 유형을 설정할 수 있습니다. 비율로 설정했을 경우 판매가격의 %비율로 포인트가 지급됩니다."); ?>
<select name="it_point_type" id="it_point_type">
<option value="0"<?php echo get_selected('0', $it['it_point_type']); ?>>금액</option>
<option value="1"<?php echo get_selected('1', $it['it_point_type']); ?>>비율</option>
</select>
<script>
$(function() {
$("#it_point_type").change(function() {
if($(this).val() == "1")
$("#it_point_unit").text("%");
else
$("#it_point_unit").text("점");
});
});
</script>
</td>
<td class="group_setting">
<input type="checkbox" name="chk_ca_it_point_type" value="1" id="chk_ca_it_point_type">
<label for="chk_ca_it_point_type">분류적용</label>
<input type="checkbox" name="chk_all_it_point_type" value="1" id="chk_all_it_point_type">
<label for="chk_all_it_point_type">전체적용</label>
</td>
</tr>
<tr>
<th scope="row"><label for="it_point">포인트</label></th>
<td>
<?php echo help("주문완료후 환경설정에서 설정한 주문완료 설정일 후 회원에게 부여하는 포인트입니다.\n또, 포인트부여를 '아니오'로 설정한 경우 신용카드, 계좌이체로 주문하는 회원께는 부여하지 않습니다.\n포인트 기능을 사용해야 동작합니다."); ?>
<input type="text" name="it_point" value="<?php echo $it['it_point']; ?>" id="it_point" class="frm_input" size="8">
<?php echo help("주문완료후 환경설정에서 설정한 주문완료 설정일 후 회원에게 부여하는 포인트입니다.\n또, 포인트부여를 '아니오'로 설정한 경우 신용카드, 계좌이체로 주문하는 회원께는 부여하지 않습니다.\n게시판의 포인트 기능과는 별개로 동작합니다."); ?>
<input type="text" name="it_point" value="<?php echo $it['it_point']; ?>" id="it_point" class="frm_input" size="8"> <span id="it_point_unit"><?php if($it['it_point_type']) echo '%'; else echo '점'; ?></span>
</td>
<td class="group_setting">
<input type="checkbox" name="chk_ca_it_point" value="1" id="chk_ca_it_point">
@ -1314,30 +1340,11 @@ function fitemformcheck(f)
}
}
// 옵션값 검사
for (var i=1; i<=6; i++) {
var opt = document.getElementsByName("it_opt"+i)[0];
var arr = opt.value.split("\n");
for (var k=0; k<arr.length; k++) {
var str = arr[k];
if (k==0) {
if (str.indexOf("&") == -1 && str.indexOf(";") != -1) {
alert("옵션의 첫 번째 라인에는 금액을 입력할 수 없습니다.\n\n또는 ; 를 입력할 수 없습니다.");
opt.focus();
return false;
}
}
else {
var exp = str.split(";");
if (typeof exp[1] != "undefined") {
var c = exp[1].substr(0,1);
if (!(c == "+" || c == "-")) {
alert("옵션의 금액 입력 오류입니다.\n\n추가되는 금액은 + 부호를\n\n할인되는 금액은 - 부호를 붙여 주십시오.");
opt.focus();
return false;
}
}
}
if(f.it_point_type.value == "1") {
var point = parseInt(f.it_point.value);
if(point > 99) {
alert("포인트 비율을 0과 99 사이의 값으로 입력해 주십시오.");
return false;
}
}

View File

@ -351,6 +351,10 @@ for($i=0; $i<count($_POST['ii_article']); $i++) {
}
$it_info_value = serialize($value_array);
// 포인트 비율 값 체크
if($it_point_type == 1 && $it_point > 99)
alert("포인트 비율을 0과 99 사이의 값으로 입력해 주십시오.");
$sql_common = " ca_id = '$ca_id',
ca_id2 = '$ca_id2',
ca_id3 = '$ca_id3',
@ -374,6 +378,7 @@ $sql_common = " ca_id = '$ca_id',
it_cust_price = '$it_cust_price',
it_price = '$it_price',
it_point = '$it_point',
it_point_type = '$it_point_type',
it_sell_email = '$it_sell_email',
it_use = '$it_use',
it_stock_qty = '$it_stock_qty',

View File

@ -0,0 +1,206 @@
<?php
$sub_menu = "400490";
include_once('./_common.php');
auth_check($auth[$sub_menu], 'r');
$token = get_token();
$sql_common = " from {$g4['shop_mileage_table']} ";
$sql_search = " where (1) ";
if ($stx) {
$sql_search .= " and ( ";
switch ($sfl) {
case 'mb_id' :
$sql_search .= " ({$sfl} = '{$stx}') ";
break;
default :
$sql_search .= " ({$sfl} like '%{$stx}%') ";
break;
}
$sql_search .= " ) ";
}
if (!$sst) {
$sst = "ml_id";
$sod = "desc";
}
$sql_order = " order by {$sst} {$sod} ";
$sql = " select count(*) as cnt
{$sql_common}
{$sql_search}
{$sql_order} ";
$row = sql_fetch($sql);
$total_count = $row['cnt'];
$rows = $config['cf_page_rows'];
$total_page = ceil($total_count / $rows); // 전체 페이지 계산
if ($page == '') $page = 1; // 페이지가 없으면 첫 페이지 (1 페이지)
$from_record = ($page - 1) * $rows; // 시작 열을 구함
$sql = " select *
{$sql_common}
{$sql_search}
{$sql_order}
limit {$from_record}, {$rows} ";
$result = sql_query($sql);
$listall = '';
if ($sfl || $stx) // 검색렬일 때만 처음 버튼을 보여줌
$listall = '<a href="'.$_SERVER['PHP_SELF'].'">전체목록</a>';
$mb = array();
if ($sfl == 'mb_id' && $stx)
$mb = get_member(isset($stx));
$g4['title'] = '마일리지관리';
include_once (G4_ADMIN_PATH.'/admin.head.php');
$colspan = 8;
?>
<script>
var list_update_php = '';
var list_delete_php = 'mileagelist_delete.php';
</script>
<form name="fsearch" id="fsearch" method="get">
<fieldset>
<legend>마일리지 내역 검색</legend>
<span>
<?php echo $listall ?>
전체 <?php echo number_format($total_count) ?> 건
<?php
if (isset($mb['mb_id']) && $mb['mb_id']) {
echo '&nbsp;(' . $mb['mb_id'] .' 님 마일리지 합계 : ' . number_format($mb['mb_mileage']) . '점)';
} else {
$row2 = sql_fetch(" select sum(ml_point) as sum_mileage from {$g4['shop_mileage_table']} ");
echo '&nbsp;(전체 합계 '.number_format($row2['sum_mileage']).'점)';
}
?>
</span>
<select name="sfl" title="검색대상">
<option value="mb_id"<?php echo get_selected($_GET['sfl'], "mb_id"); ?>>회원아이디</option>
<option value="sp_content"<?php echo get_selected($_GET['sfl'], "ml_content"); ?>>내용</option>
</select>
<input type="text" name="stx" value="<?php echo $stx ?>" title="검색어(필수)" required class="required frm_input">
<input type="submit" class="btn_submit" value="검색">
</fieldset>
</form>
<section class="cbox">
<h2>마일리지 내역</h2>
<form name="fpointlist" id="fpointlist" method="post">
<input type="hidden" name="sst" value="<?php echo $sst; ?>">
<input type="hidden" name="sod" value="<?php echo $sod; ?>">
<input type="hidden" name="sfl" value="<?php echo $sfl; ?>">
<input type="hidden" name="stx" value="<?php echo $stx; ?>">
<input type="hidden" name="page" value="<?php echo $page; ?>">
<input type="hidden" name="token" value="<?php echo $token; ?>">
<table class="tbl_pt_list">
<thead>
<tr>
<th scope="col"><input type="checkbox" name="chkall" value="1" id="chkall" title="현재 페이지 마일리지 내역 전체선택" onclick="check_all(this.form)"></th>
<th scope="col"><?php echo subject_sort_link('mb_id') ?>회원아이디</a></th>
<th scope="col">이름</th>
<th scope="col">별명</th>
<th scope="col"><?php echo subject_sort_link('ml_datetime') ?>일시</a></th>
<th scope="col"><?php echo subject_sort_link('ml_content') ?>마일리지 내용</a></th>
<th scope="col"><?php echo subject_sort_link('ml_point') ?>마일리지</a></th>
<th scope="col">마일리지합</th>
</tr>
</thead>
<tbody>
<?php
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, mb_mileage 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']);
$link1 = '<a href="./orderform.php?od_id='.$row['od_id'].'">';
$link2 = '</a>';
?>
<tr>
<td class="td_chk">
<input type="hidden" id="mb_id_<?php echo $i ?>" name="mb_id[<?php echo $i ?>]" value="<?php echo $row['mb_id'] ?>">
<input type="hidden" id="ml_id_<?php echo $i ?>" name="ml_id[<?php echo $i ?>]" value="<?php echo $row['ml_id'] ?>">
<input type="checkbox" id="chk_<?php echo $i ?>" name="chk[]" value="<?php echo $i ?>" title="내역선택">
</td>
<td class="td_mbid"><a href="?sfl=mb_id&amp;stx=<?php echo $row['mb_id'] ?>"><?php echo $row['mb_id'] ?></a></td>
<td class="td_mbname"><?php echo $row2['mb_name'] ?></td>
<td class="td_name sv_use"><div><?php echo $mb_nick ?></div></td>
<td class="td_time"><?php echo $row['ml_datetime'] ?></td>
<td class="td_pt_log"><?php echo $link1 ?><?php echo $row['ml_content'] ?><?php echo $link2 ?></td>
<td class="td_num td_pt"><?php echo number_format($row['ml_point']) ?></td>
<td class="td_bignum td_pt"><?php echo number_format($row2['mb_mileage']) ?></td>
</tr>
<?php
}
if ($i == 0)
echo '<tr><td colspan="'.$colspan.'" class="empty_table">자료가 없습니다.</td></tr>';
?>
</tbody>
</table>
<div class="btn_list">
<button onclick="btn_check(this.form, 'delete')">선택삭제</button>
</div>
</form>
</section>
<?php echo get_paging(G4_IS_MOBILE ? $config['cf_mobile_pages'] : $config['cf_write_pages'], $page, $total_page, "{$_SERVER['PHP_SELF']}?$qstr&amp;page="); ?>
<section id="point_mng" class="cbox">
<h2>개별회원 마일리지 증감 설정</h2>
<form name="fmileagelist2" method="post" id="fmileagelist2" action="./mileageupdate.php" autocomplete="off">
<input type="hidden" name="sfl" value="<?php echo $sfl; ?>">
<input type="hidden" name="stx" value="<?php echo $stx; ?>">
<input type="hidden" name="sst" value="<?php echo $sst; ?>">
<input type="hidden" name="sod" value="<?php echo $sod; ?>">
<input type="hidden" name="page" value="<?php echo $page; ?>">
<input type="hidden" name="token" value="<?php echo $token; ?>">
<table class="frm_tbl">
<colgroup>
<col class="grid_3">
<col>
</colgroup>
<tbody>
<tr>
<th scope="row"><label for="mb_id">회원아이디<strong class="sound_only">필수</strong></label></th>
<td><input type="text" name="mb_id" value="<?php echo $mb_id ?>" id="mb_id" class="required frm_input" required></td>
</tr>
<tr>
<th scope="row"><label for="ml_content">마일리지 내용<strong class="sound_only">필수</strong></label></th>
<td><input type="text" name="ml_content" id="ml_content" required class="required frm_input" size="80"></td>
</tr>
<tr>
<th scope="row"><label for="ml_point">마일리지<strong class="sound_only">필수</strong></label></th>
<td><input type="text" name="ml_point" id="ml_point" required class="required frm_input"></td>
</tr>
</tbody>
</table>
<div class="btn_confirm">
<input type="submit" value="확인" class="btn_submit">
</div>
</form>
</section>
<?php
include_once (G4_ADMIN_PATH.'/admin.tail.php');
?>

View File

@ -0,0 +1,32 @@
<?php
$sub_menu = "400490";
include_once('./_common.php');
check_demo();
auth_check($auth[$sub_menu], 'd');
check_token();
$count = count($_POST['chk']);
if(!$count)
alert("선택삭제 하실 항목을 하나이상 선택해 주세요.");
for ($i=0; $i<$count; $i++)
{
// 실제 번호를 넘김
$k = $_POST['chk'][$i];
$sql = " delete from {$g4['shop_mileage_table']} where ml_id = '{$_POST['ml_id'][$k]}' ";
sql_query($sql);
$sql = " select sum(ml_point) as sum_ml_point from {$g4['shop_mileage_table']} where mb_id = '{$_POST['mb_id'][$k]}' ";
$row = sql_fetch($sql);
$sum_mileage = $row['sum_ml_point'];
$sql= " update {$g4['member_table']} set mb_mileage = '{$sum_mileage}' where mb_id = '{$_POST['mb_id'][$k]}' ";
sql_query($sql);
}
goto_url('./mileagelist.php?'.$qstr);
?>

View File

@ -0,0 +1,24 @@
<?php
$sub_menu = "400490";
include_once('./_common.php');
auth_check($auth[$sub_menu], 'w');
check_token();
$mb_id = $_POST['mb_id'];
$ml_point = $_POST['ml_point'];
$ml_content = $_POST['ml_content'];
$mb = get_member($mb_id);
if (!$mb['mb_id'])
alert('존재하는 회원아이디가 아닙니다.', './mileagelist.php?'.$qstr);
if (($ml_point < 0) && ($ml_point * (-1) > $mb['mb_mileage']))
alert('포인트를 깎는 경우 현재 마일리지보다 작으면 안됩니다.', './mileagelist.php?'.$qstr);
insert_mileage($mb_id, $ml_point, $ml_content, '', '');
goto_url('./mileagelist.php?'.$qstr);
?>

View File

@ -48,9 +48,16 @@ if (!isset($order_not_point)) {
// 회원이면서 포인트가 0보다 크다면
if ($tmp_row['mb_id'] && $row['ct_point'] > 0)
{
/** 주문완료 포인트를 게시판 포인트와 연동하려면 주석제거
$po_point = $row['ct_point'] * $row['ct_qty'];
$po_content = "$cart_title3 {$tmp_row['od_id']} ({$row['ct_id']}) $cart_title4";
insert_point($tmp_row['mb_id'], $po_point, $po_content, "@delivery", $tmp_row['mb_id'], "{$tmp_row['od_id']},{$row['uq_id']},{$row['ct_id']}");
*/
// 주문완료 쇼핑몰 포인트로 적립
$ml_point = $row['ct_point'] * $row['ct_qty'];
$ml_content = "$cart_title3 {$tmp_row['od_id']} ({$row['ct_id']}) $cart_title4";
insert_mileage($tmp_row['mb_id'], $ml_point, $ml_content, $tmp_row['od_id'], $row['ct_id']);
}
sql_query("update {$g4['shop_cart_table']} set ct_point_use = '1' where ct_id = '{$row['ct_id']}' ");

View File

@ -199,4 +199,25 @@ if(!$result) {
ADD `de_cart_keep_term` INT(11) NOT NULL DEFAULT '0' AFTER `de_code_dup_use`,
ADD `de_guest_cart_use` TINYINT(4) NOT NULL DEFAULT '0' AFTER `de_cart_keep_term` ", false);
}
// 마일리지관련 필드 추가
$sql = " select it_point_type from {$g4['shop_item_table']} limit 1 ";
$result = sql_query($sql, false);
if(!$result) {
sql_query(" CREATE TABLE IF NOT EXISTS `{$g4['shop_mileage_table']}` (
`ml_id` INT(11) NOT NULL AUTO_INCREMENT,
`mb_id` VARCHAR(255) NOT NULL DEFAULT '',
`od_id` BIGINT(20) unsigned NOT NULL,
`ct_id` INT(11) NOT NULL DEFAULT '0',
`ml_content` VARCHAR(255) NOT NULL DEFAULT '',
`ml_point` INT(11) NOT NULL DEFAULT '0',
`ml_datetime` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
PRIMARY KEY (`ml_id`),
KEY `mb_id` (`mb_id`)
) ", false);
sql_query(" ALTER TABLE `{$g4['member_table']}`
ADD `mb_mileage` INT(11) NOT NULL DEFAULT '0' AFTER `mb_point` ", false);
sql_query(" ALTER TABLE `{$g4['shop_item_table']}`
ADD `it_point_type` TINYINT(4) NOT NULL DEFAULT '0' AFTER `it_point` ", false);
}
?>

View File

@ -487,6 +487,7 @@ if($shop_install) {
fwrite($f, "\$g4['shop_onlinecalc_table'] = SHOP_TABLE_PREFIX.'onlinecalc'; // 온라인견적 테이블\n");
fwrite($f, "\$g4['shop_order_table'] = SHOP_TABLE_PREFIX.'order'; // 주문서 테이블\n");
fwrite($f, "\$g4['shop_wish_table'] = SHOP_TABLE_PREFIX.'wish'; // 보관함(위시리스트) 테이블\n");
fwrite($f, "\$g4['shop_mileage_table'] = SHOP_TABLE_PREFIX.'mileage'; // 마일리지 테이블\n");
fwrite($f, "?>");
}

View File

@ -384,6 +384,7 @@ CREATE TABLE IF NOT EXISTS `shop_item` (
`it_cust_price` int(11) NOT NULL DEFAULT '0',
`it_price` int(11) NOT NULL DEFAULT '0',
`it_point` int(11) NOT NULL DEFAULT '0',
`it_point_type` tinyint(4) NOT NULL DEFAULT '0',
`it_sell_email` varchar(255) NOT NULL DEFAULT '',
`it_use` tinyint(4) NOT NULL DEFAULT '0',
`it_stock_qty` int(11) NOT NULL DEFAULT '0',
@ -600,6 +601,23 @@ CREATE TABLE IF NOT EXISTS `shop_order` (
-- --------------------------------------------------------
--
-- Table structure for table `shop_mileage`
--
DROP TABLE IF EXISTS `shop_mileage`;
CREATE TABLE IF NOT EXISTS `shop_mileage` (
`ml_id` INT(11) NOT NULL AUTO_INCREMENT,
`mb_id` VARCHAR(255) NOT NULL DEFAULT '',
`od_id` BIGINT(20) unsigned NOT NULL,
`ct_id` INT(11) NOT NULL DEFAULT '0',
`ml_content` VARCHAR(255) NOT NULL DEFAULT '',
`ml_point` INT(11) NOT NULL DEFAULT '0',
`ml_datetime` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
PRIMARY KEY (`ml_id`),
KEY `mb_id` (`mb_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
--
-- Table structure for table `shop_wish`
--

View File

@ -1070,6 +1070,52 @@ function delete_item_thumbnail($dir, $file)
}
}
}
// 마일리지 부여
function insert_mileage($mb_id, $point, $content='', $od_id, $ct_id)
{
global $g4;
// 포인트가 없다면 업데이트 할 필요 없음
if ($point == 0) { return 0; }
// 회원아이디가 없다면 업데이트 할 필요 없음
if ($mb_id == '') { return 0; }
$mb = sql_fetch(" select mb_id from {$g4['member_table']} where mb_id = '$mb_id' ");
if (!$mb['mb_id']) { return 0; }
// 이미 등록된 내역이라면 건너뜀
if($od_id && $ct_id) {
$sql = " select count(*) as cnt from {$g4['shop_mileage_table']}
where mb_id = '$mb_id'
and od_id = '$od_id'
and ct_id = '$ct_id' ";
$row = sql_fetch($sql);
if ($row['cnt'])
return -1;
}
// 마일리지 건별 생성
$sql = " insert into {$g4['shop_mileage_table']}
set mb_id = '$mb_id',
od_id = '$od_id',
ct_id = '$ct_id',
ml_content = '".addslashes($content)."',
ml_point = '$point',
ml_datetime = '".G4_TIME_YMDHIS."' ";
sql_query($sql);
// 포인트 내역의 합을 구하고
$sql = " select sum(ml_point) as sum_mileage from {$g4['shop_mileage_table']} where mb_id = '$mb_id' ";
$row = sql_fetch($sql);
$sum_mileage = $row['sum_mileage'];
// 포인트 UPDATE
$sql = " update {$g4['member_table']} set mb_mileage = '$sum_mileage' where mb_id = '$mb_id' ";
sql_query($sql);
return 1;
}
//==============================================================================
// 쇼핑몰 함수 모음 끝
//==============================================================================

View File

@ -267,7 +267,11 @@ else // 장바구니에 담기
if ((int)$_POST['total_price'] !== (int)$total_price)
die("Error..");
$point = $it['it_point'];
if($it['it_point_type']) {
$point = floor(($it['it_price'] * ($it['it_point'] / 100) / 10)) * 10;
} else {
$point = $it['it_point'];
}
// 포인트가 다름
if ((int)$point !== (int)$_POST['it_point'] && $config['cf_use_point'])
die("Error...");

View File

@ -319,7 +319,7 @@ else
<tr>
<th scope="row">판매가격</th>
<td>
<?php echo number_format($it['it_price']); ?> 원
<?php echo number_format(get_price($it)); ?> 원
<input type="hidden" name="it_price" value="<?php echo get_price($it); ?>">
</td>
</tr>
@ -337,8 +337,16 @@ else
<tr>
<th scope="row">포인트</th>
<td>
<?php echo number_format($it['it_point']); ?> 점
<input type="hidden" name="it_point" value="<?php echo $it['it_point']; ?>">
<?php
if($it['it_point_type']) {
$it_point = floor(($it['it_price'] * ($it['it_point'] / 100) / 10)) * 10;
} else {
$it_point = $it['it_point'];
}
echo number_format($it_point);
?> 점
<input type="hidden" name="it_point" value="<?php echo $it_point; ?>">
</td>
</tr>
<?php } ?>