영카트 회원별 등급 가격 및 적립금적용.zip
0.04MB
/*
CREATE TABLE `g5_shop_membership` (
`sm_id` int(11) NOT NULL auto_increment,
`sm_subject` varchar(255) NOT NULL default '',
`sm_level` varchar(255) NOT NULL default '',
`sm_limit_price` varchar(255) NOT NULL default '',
`sm_dc` varchar(10) NOT NULL default '',
`sm_insert_point` varchar(255) NOT NULL default '',
PRIMARY KEY (`sm_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 "
//테이블구조
*/
관리자페이지->커스텀관리->회원등급관리->누적금액 입력
/adm/shop_adm/membership.php 파일 추가
/adm/shop_adm/membershipupdate.php 파일 추가
/adm/shop_adm/orderform.php 30번째줄 밑에 추가
//회원등급조정
save_membership_rating($od['mb_id']);
/skin/shop/basic/item.form.php 출력부분추가
<tr>
<th scope="row"><b>DC</b></th>
<td>
<?php echo number_format(get_dcPirce($it))." 원".get_dc(); ?>
</td>
</tr>
<tr>
<th scope="row"><b>판매가격</b></th>
<td>
<?php echo display_price(get_price($it)); ?>
<input type="hidden" id="it_price" value="<?php echo get_price($it); ?>">
</td>
</tr>
<tr>
<th scope="row"><b>적립포인트</b></th>
<td>
<?php echo number_format(get_ratingPointRes($it))." P".get_ratingPoint(); ?>
</td>
</tr>
/common.php
//글로벌멤버쉽변수 추가
$sql = " SELECT * FROM g5_shop_membership ORDER BY sm_id ASC ";
$res = sql_query($sql);
$memberShip = array();
while($row = sql_fetch_array($res))
{
$memberShip[$row["sm_level"]] = $row;
}
/lib/shop.lib.php 함수 수정 및 추가
function get_price($it)
{
global $member, $memberShip;
if ($it['it_tel_inq']) return '전화문의';
$price = $it['it_price'];
$tmpLevel = $member["mb_level"];
while($tmpLevel > 0)
{
if($memberShip[$tmpLevel]["sm_dc"])
{
break;
}
$tmpLevel--;
}
$dcPirce = $it['it_price'] * $memberShip[$tmpLevel]["sm_dc"] / 100;
$price = $price - $dcPirce;
return (int)$price;
}
//할일적용 금액
function get_dcPirce($it)
{
global $member, $memberShip;
$tmpLevel = $member["mb_level"];
while($tmpLevel > 0)
{
if($memberShip[$tmpLevel]["sm_dc"])
{
break;
}
$tmpLevel--;
}
$dcPirce = $it['it_price'] * $memberShip[$tmpLevel]["sm_dc"] / 100;
return $dcPirce;
}
//할인금액
function get_dc()
{
global $member, $memberShip;
$tmpLevel = $member["mb_level"];
while($tmpLevel > 0)
{
if($memberShip[$tmpLevel]["sm_dc"])
{
break;
}
$tmpLevel--;
}
return "(".$memberShip[$tmpLevel]["sm_dc"]." %▼)";
}
//할인 퍼센트
function get_ratingPoint()
{
global $member, $memberShip;
$tmpLevel = $member["mb_level"];
while($tmpLevel > 0)
{
if($memberShip[$tmpLevel]["sm_insert_point"])
{
break;
}
$tmpLevel--;
}
return "( ".$memberShip[$tmpLevel]["sm_insert_point"]." %)";
}
//적립포인트율
function get_ratingPointRes($it)
{
global $member, $memberShip;
$tmpLevel = $member["mb_level"];
while($tmpLevel > 0)
{
if($memberShip[$tmpLevel]["sm_insert_point"])
{
break;
}
$tmpLevel--;
}
$inPoint = $it['it_price'] * $memberShip[$tmpLevel]["sm_insert_point"] / 100;
return $inPoint;
}
//적립 포인트
function save_membership_rating($mb_id)
{
global $g5, $memberShip;
if($mb_id == "비회원")
{
return false;
}
$sql = " select sum(a.od_receipt_price) od_receipt_price
from {$g5['g5_shop_order_table']} a
inner join {$g5['member_table']} b
on a.mb_id = b.mb_id
where a.od_status = '완료'
and a.mb_id = '{$mb_id}' ";
$totPrice = sql_fetch($sql);
$mbLevel = 2;
foreach($memberShip as $key => $val)
{
if(!$val["sm_limit_price"]) continue;
if($totPrice["od_receipt_price"] > $val["sm_limit_price"])
{
$mbLevel = $val["sm_level"];
}
}
//현재등급보다 낮은경우 레벨이 변경되지 않는다
$mb = get_member($mb_id);
if($mb["mb_level"] < $mbLevel)
{
//등급 업데이트
sql_query(" UPDATE {$g5["member_table"]} SET mb_level = '{$mbLevel}' WHERE mb_id = '{$mb_id}' ");
}
}
//회원등급변경
/shop/cartupdate.php insert Value 부분에 추가
//회원DC,적립금 적용
$dcPrice = get_dcPirce($it);
//기존 적립포인트 사용안함 초기화
$point = 0;
$point = get_ratingPointRes($it);
$it_price = $it['it_price'] - $dcPrice;
$sql .= $comma."( '$tmp_cart_id', '{$member['mb_id']}', '{$it['it_id']}', '".addslashes($it['it_name'])."', '{$it['it_sc_type']}', '{$it['it_sc_method']}', '{$it['it_sc_price']}', '{$it['it_sc_minimum']}', '{$it['it_sc_qty']}', '쇼핑', '{$it_price}', '$point', '0', '0', '$io_value', '$ct_qty', '{$it['it_notax']}', '$io_id', '$io_type', '$io_price', '".G5_TIME_YMDHIS."', '$remote_addr', '$ct_send_cost', '$sw_direct', '$ct_select', '$ct_select_time' )";