쿠폰존 추가
This commit is contained in:
69
shop/ajax.coupondownload.php
Normal file
69
shop/ajax.coupondownload.php
Normal file
@ -0,0 +1,69 @@
|
||||
<?php
|
||||
include_once('./_common.php');
|
||||
include_once(G5_LIB_PATH.'/json.lib.php');
|
||||
|
||||
if(!$member['mb_id'])
|
||||
die(json_encode(array('error' => '회원 로그인 후 이용해 주십시오.')));
|
||||
|
||||
$cz_id = preg_replace('#[^0-9]#', '', $_GET['cz_id']);
|
||||
|
||||
if(!$cz_id)
|
||||
die(json_encode(array('error' => '올바른 방법으로 이용해 주십시오.')));
|
||||
|
||||
$sql = " select * from {$g5['g5_shop_coupon_zone_table']} where cz_id = '$cz_id' ";
|
||||
$cp = sql_fetch($sql);
|
||||
|
||||
if(!$cp['cz_id'])
|
||||
die(json_encode(array('error' => '쿠폰정보가 존재하지 않습니다.')));
|
||||
|
||||
if(!($cp['cz_start'] <= G5_TIME_YMD && $cp['cz_end'] >= G5_TIME_YMD))
|
||||
die(json_encode(array('error' => '다운로드할 수 없는 쿠폰입니다.')));
|
||||
|
||||
// 발급여부
|
||||
if(is_coupon_downloaded($member['mb_id'], $cp['cz_id']))
|
||||
die(json_encode(array('error' => '이미 다운로드하신 쿠폰입니다.')));
|
||||
|
||||
// 포인트 쿠폰은 회원포인트 체크
|
||||
if($cp['cz_type'] && ($member['mb_point'] - $cp['cz_point']) < 0)
|
||||
die(json_encode(array('error' => '보유하신 포인트가 부족하여 쿠폰을 다운로드할 수 없습니다.')));
|
||||
|
||||
// 쿠폰발급
|
||||
$j = 0;
|
||||
do {
|
||||
$cp_id = get_coupon_id();
|
||||
|
||||
$sql3 = " select count(*) as cnt from {$g5['g5_shop_coupon_table']} where cp_id = '$cp_id' ";
|
||||
$row3 = sql_fetch($sql3);
|
||||
|
||||
if(!$row3['cnt'])
|
||||
break;
|
||||
else {
|
||||
if($j > 20)
|
||||
die(json_encode(array('error' => 'Coupon ID Error')));
|
||||
}
|
||||
} while(1);
|
||||
|
||||
$cp = array_map('addslashes', $cp);
|
||||
$cp_start = G5_TIME_YMD;
|
||||
$period = $cp['cz_period'] - 1;
|
||||
if($period < 0)
|
||||
$period = 0;
|
||||
$cp_end = date('Y-m-d', strtotime("+{$period} days", G5_SERVER_TIME));
|
||||
$result = false;
|
||||
|
||||
$sql = " INSERT INTO {$g5['g5_shop_coupon_table']}
|
||||
( cp_id, cp_subject, cp_method, cp_target, mb_id, cz_id, cp_start, cp_end, cp_type, cp_price, cp_trunc, cp_minimum, cp_maximum, cp_datetime )
|
||||
VALUES
|
||||
( '$cp_id', '{$cp['cz_subject']}', '{$cp['cp_method']}', '{$cp['cp_target']}', '{$member['mb_id']}', '$cz_id', '$cp_start', '$cp_end', '{$cp['cp_type']}', '{$cp['cp_price']}', '{$cp['cp_trunc']}', '{$cp['cp_minimum']}', '{$cp['cp_maximum']}', '".G5_TIME_YMDHIS."' ) ";
|
||||
|
||||
$result = sql_query($sql);
|
||||
|
||||
// 포인트 쿠폰이면 포인트 차감
|
||||
if($result && $cp['cz_type'])
|
||||
insert_point($member['mb_id'], (-1) * $cp['cz_point'], "쿠폰 $cp_id 발급");
|
||||
|
||||
// 다운로드 증가
|
||||
sql_query(" update {$g5['g5_shop_coupon_zone_table']} set cz_download = cz_download + 1 where cz_id = '$cz_id' ");
|
||||
|
||||
die(json_encode(array('error' => '')));
|
||||
?>
|
||||
34
shop/couponzone.php
Normal file
34
shop/couponzone.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
include_once('./_common.php');
|
||||
|
||||
$sql_common = " from {$g5['g5_shop_coupon_zone_table']}
|
||||
where cz_start <= '".G5_TIME_YMD."'
|
||||
and cz_end >= '".G5_TIME_YMD."' ";
|
||||
|
||||
$sql_order = " order by cz_id desc ";
|
||||
|
||||
add_javascript('<script src="'.G5_JS_URL.'/shop.couponzone.js"></script>', 100);
|
||||
|
||||
$g5['title'] = '쿠폰존';
|
||||
include_once(G5_SHOP_PATH.'/_head.php');
|
||||
|
||||
if (!G5_IS_MOBILE && $is_admin)
|
||||
echo '<div class="sct_admin"><a href="'.G5_ADMIN_URL.'/shop_admin/couponzonelist.php" class="btn_admin">쿠폰존 관리</a></div>';
|
||||
|
||||
if(G5_IS_MOBILE) {
|
||||
define('G5_SHOP_CSS_URL', G5_MSHOP_SKIN_URL);
|
||||
$skin_file = G5_MSHOP_SKIN_PATH.'/couponzone.10.skin.php';
|
||||
} else {
|
||||
define('G5_SHOP_CSS_URL', G5_SHOP_SKIN_URL);
|
||||
$skin_file = G5_SHOP_SKIN_PATH.'/couponzone.10.skin.php';
|
||||
}
|
||||
|
||||
if (is_file($skin_file)) {
|
||||
include_once($skin_file);
|
||||
|
||||
} else {
|
||||
echo '<div class="sct_nofile">'.str_replace(G5_PATH.'/', '', $skin_file).' 파일을 찾을 수 없습니다.<br>관리자에게 알려주시면 감사하겠습니다.</div>';
|
||||
}
|
||||
|
||||
include_once(G5_SHOP_PATH.'/_tail.php');
|
||||
?>
|
||||
@ -74,6 +74,7 @@ include_once(G5_LIB_PATH.'/latest.lib.php');
|
||||
<li><a href="<?php echo G5_BBS_URL; ?>/login.php?url=<?php echo $urlencode; ?>"><b>로그인</b></a></li>
|
||||
<?php } ?>
|
||||
<li><a href="<?php echo G5_SHOP_URL; ?>/mypage.php">마이페이지</a></li>
|
||||
<li><a href="<?php echo G5_SHOP_URL; ?>/couponzone.php">쿠폰존</a></li>
|
||||
<li><a href="<?php echo G5_BBS_URL; ?>/faq.php">FAQ</a></li>
|
||||
<li><a href="<?php echo G5_BBS_URL; ?>/qalist.php">1:1문의</a></li>
|
||||
<li><a href="<?php echo G5_SHOP_URL; ?>/personalpay.php">개인결제</a></li>
|
||||
|
||||
Reference in New Issue
Block a user