From cbb278bef62f97082eff3e43470e2f95648deac3 Mon Sep 17 00:00:00 2001 From: chicpro Date: Tue, 4 Jun 2013 14:13:49 +0900 Subject: [PATCH] =?UTF-8?q?#209=20=EC=BF=A0=ED=8F=B0=EA=B4=80=EB=A6=AC=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- adm/admin.menu400.shop_1of2.php | 1 + adm/shop_admin/couponform.php | 240 +++++++++++++++++++++++++++ adm/shop_admin/couponformupdate.php | 123 ++++++++++++++ adm/shop_admin/couponlist.php | 194 ++++++++++++++++++++++ adm/shop_admin/couponlist_delete.php | 25 +++ adm/shop_admin/couponmember.php | 66 ++++++++ adm/shop_admin/coupontarget.php | 80 +++++++++ extend/shop.extend2.php | 26 +++ install/install_db.php | 1 + install/shop.sql | 28 ++++ lib/shop.lib.php | 23 +++ 11 files changed, 807 insertions(+) create mode 100644 adm/shop_admin/couponform.php create mode 100644 adm/shop_admin/couponformupdate.php create mode 100644 adm/shop_admin/couponlist.php create mode 100644 adm/shop_admin/couponlist_delete.php create mode 100644 adm/shop_admin/couponmember.php create mode 100644 adm/shop_admin/coupontarget.php diff --git a/adm/admin.menu400.shop_1of2.php b/adm/admin.menu400.shop_1of2.php index 418cd4ec2..f7f51a296 100644 --- a/adm/admin.menu400.shop_1of2.php +++ b/adm/admin.menu400.shop_1of2.php @@ -19,6 +19,7 @@ $menu['menu400'] = array ( array('400740', '배송업체관리', G4_ADMIN_URL.'/shop_admin/deliverycodelist.php', 'scf_deli_co', 1), array('400630', '이벤트관리', G4_ADMIN_URL.'/shop_admin/itemevent.php', 'scf_event'), array('400640', '이벤트일괄처리', G4_ADMIN_URL.'/shop_admin/itemeventlist.php', 'scf_event_mng'), + array('400650', '쿠폰관리', G4_ADMIN_URL.'/shop_admin/couponlist.php', 'scf_coupon'), array('400700', '내용관리', G4_ADMIN_URL.'/shop_admin/contentlist.php', 'scf_contents', 1), array('400710', 'FAQ관리', G4_ADMIN_URL.'/shop_admin/faqmasterlist.php', 'scf_faq', 1), array('400730', '배너관리', G4_ADMIN_URL.'/shop_admin/bannerlist.php', 'scf_banner', 1), diff --git a/adm/shop_admin/couponform.php b/adm/shop_admin/couponform.php new file mode 100644 index 000000000..2a27d808b --- /dev/null +++ b/adm/shop_admin/couponform.php @@ -0,0 +1,240 @@ + + +
+ + + +
+

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+ + +
+ + + + +
+ 입력예: +
+ 입력예: +
+ +
+ +
+ +
+ 원 +
+ 원 +
+ +
+ + 목록 +
+
+
+ + + + \ No newline at end of file diff --git a/adm/shop_admin/couponformupdate.php b/adm/shop_admin/couponformupdate.php new file mode 100644 index 000000000..97690b60a --- /dev/null +++ b/adm/shop_admin/couponformupdate.php @@ -0,0 +1,123 @@ + $_POST['cp_end']) + alert('사용 시작일은 종료일 이전으로 입력해 주십시오.'); + +if($_POST['cp_end'] < G4_TIME_YMD) + alert('종료일은 오늘('.G4_TIME_YMD.')이후로 입력해 주십시오.'); + +if(!$_POST['cp_amount']) { + if($_POST['cp_type']) + alert('할인비율을 입력해 주십시오.'); + else + alert('할인금액을 입력해 주십시오.'); +} + +if($_POST['cp_type'] && ($_POST['cp_amount'] < 1 || $_POST['cp_amount'] > 99)) + alert('할인비율을은 1과 99사이 값으로 입력해 주십시오.'); + +if($_POST['cp_method'] == 0) { + $sql = " select count(*) as cnt from {$g4['shop_item_table']} where it_id = '$cp_target' "; + $row = sql_fetch($sql); + if(!$row['cnt']) + alert('입력하신 상품코드는 존재하지 않는 상품코드입니다.'); +} else if($_POST['cp_method'] == 1) { + $sql = " select count(*) as cnt from {$g4['shop_category_table']} where ca_id = '$cp_target' "; + $row = sql_fetch($sql); + if(!$row['cnt']) + alert('입력하신 분류코드는 존재하지 않는 분류코드입니다.'); +} + +if($w == '') { + $arr_mb_id = array(); + + if($_POST['chk_all_mb']) { + $sql = " select mb_id from {$g4['member_table']} where mb_id <> '{$config['cf_admin']}' and mb_leave_date = '' and mb_intercept_date = '' "; + $result = sql_query($sql); + for($i=0; $row=sql_fetch_array($result); $i++) { + $arr_mb_id[] = $row['mb_id']; + } + } else { + $arr_mb_id[] = $_POST['mb_id']; + } + + $mb_id_count = count($arr_mb_id); + + for($i=0; $i<$mb_id_count; $i++) { + $mb_id = $arr_mb_id[$i]; + + if(!$_POST['chk_all_mb']) { + $sql2 = " select mb_id from {$g4['member_table']} where mb_id = '$mb_id' and mb_leave_date = '' and mb_intercept_date = '' "; + $row2 = sql_fetch($sql2); + if(!$row2['mb_id']) + alert('입력하신 회원아이디는 존재하지 않거나 탈퇴 또는 차단된 회원아이디입니다.'); + } + + $j = 0; + do { + $cp_id = get_coupon_id(); + + $sql3 = " select count(*) as cnt from {$g4['shop_coupon_table']} where cp_id = '$cp_id' "; + $row3 = sql_fetch($sql3); + + if(!$row3['cnt']) + break; + else { + if($j > 20) + die('Coupon ID Error'); + } + } while(1); + + $sql = " INSERT INTO {$g4['shop_coupon_table']} + ( cp_id, cp_subject, cp_method, cp_target, mb_id, cp_start, cp_end, cp_type, cp_amount, cp_trunc, cp_minimum, cp_maximum, cp_used, cp_datetime ) + VALUES + ( '$cp_id', '$cp_subject', '$cp_method', '$cp_target', '$mb_id', '$cp_start', '$cp_end', '$cp_type', '$cp_amount', '$cp_trunc', '$cp_minimum', '$cp_maximum', '$cp_used', '".G4_TIME_YMDHIS."' ) "; + + sql_query($sql); + } +} else if($w == 'u') { + $sql = " select * from {$g4['shop_coupon_table']} where cp_id = '$cp_id' "; + $cp = sql_fetch($sql); + + if(!$cp['cp_id']) + alert('쿠폰정보가 존해하지 않습니다.', './couponlist.php'); + + $sql = " update {$g4['shop_coupon_table']} + set cp_subject = '$cp_subject', + cp_method = '$cp_method', + cp_target = '$cp_target', + mb_id = '$cp_mb_id', + cp_start = '$cp_start', + cp_end = '$cp_end', + cp_type = '$cp_type', + cp_amount = '$cp_amount', + cp_trunc = '$cp_trunc', + cp_maximum = '$cp_maximum', + cp_minimum = '$cp_minimum' + where cp_id = '$cp_id' "; + sql_query($sql); +} + +goto_url('./couponlist.php'); +?> \ No newline at end of file diff --git a/adm/shop_admin/couponlist.php b/adm/shop_admin/couponlist.php new file mode 100644 index 000000000..a6ebd8689 --- /dev/null +++ b/adm/shop_admin/couponlist.php @@ -0,0 +1,194 @@ + + + + +
+
+ 쿠폰 검색 + + + 전체 건 + + + + +
+
+ +
+

쿠폰 내역

+ + + +
+ + + + + + + + + + + + + + + + + + + + + + '; + $link2 = ''; + ?> + + + + + + + + + + + + + '; + ?> + +
쿠폰코드쿠폰이름적용대상회원아이디사용기한사용관리
+ + +
~ <?php echo $row['cp_id']; ?> 수정
자료가 없습니다.
+ +
+ +
+ +
+
+ + + + \ No newline at end of file diff --git a/adm/shop_admin/couponlist_delete.php b/adm/shop_admin/couponlist_delete.php new file mode 100644 index 000000000..d73645d77 --- /dev/null +++ b/adm/shop_admin/couponlist_delete.php @@ -0,0 +1,25 @@ + diff --git a/adm/shop_admin/couponmember.php b/adm/shop_admin/couponmember.php new file mode 100644 index 000000000..eefab2e06 --- /dev/null +++ b/adm/shop_admin/couponmember.php @@ -0,0 +1,66 @@ + + +
+
+
+ + +
+ + + + + + + + + + + + +'; +?> +
회원이름회원아이디선택
+
검색된 자료가 없습니다.
+ +
+ + +
+
+
+ + + + \ No newline at end of file diff --git a/adm/shop_admin/coupontarget.php b/adm/shop_admin/coupontarget.php new file mode 100644 index 000000000..746c533ef --- /dev/null +++ b/adm/shop_admin/coupontarget.php @@ -0,0 +1,80 @@ + + +
+
+ +
+ + +
+ + + + + + + + + + + + +'; +?> +
선택
+
검색된 자료가 없습니다.
+ +
+ + +
+
+
+ + + + \ No newline at end of file diff --git a/extend/shop.extend2.php b/extend/shop.extend2.php index f461ceeca..4b3ff5664 100644 --- a/extend/shop.extend2.php +++ b/extend/shop.extend2.php @@ -228,4 +228,30 @@ if(!$result) { sql_query(" ALTER TABLE `{$g4['shop_default_table']}` ADD `de_mileage_use` TINYINT(4) NOT NULL DEFAULT '0' AFTER `de_point_settle` ", false); } + +// 쿠폰테이블 +$sql = " DESCRIBE `{$g4['shop_coupon_table']}` "; +$result = sql_query($sql, false); +if(!$result) { + sql_query(" CREATE TABLE IF NOT EXISTS `{$g4['shop_coupon_table']}` ( + `cp_no` INT(11) NOT NULL AUTO_INCREMENT, + `cp_id` VARCHAR(255) NOT NULL DEFAULT '', + `cp_subject` VARCHAR(255) NOT NULL DEFAULT '', + `cp_method` TINYINT(4) NOT NULL DEFAULT '0', + `cp_target` VARCHAR(255) NOT NULL DEFAULT '', + `mb_id` VARCHAR(255) NOT NULL DEFAULT '', + `cp_start` DATE NOT NULL DEFAULT '0000-00-00', + `cp_end` DATE NOT NULL DEFAULT '0000-00-00', + `cp_type` TINYINT(4) NOT NULL DEFAULT '0', + `cp_amount` INT(11) NOT NULL DEFAULT '0', + `cp_trunc` INT(11) NOT NULL DEFAULT '0', + `cp_minimum` INT(11) NOT NULL DEFAULT '0', + `cp_maximum` INT(11) NOT NULL DEFAULT '0', + `cp_used` TINYINT(4) NOT NULL DEFAULT '0', + `cp_datetime` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', + PRIMARY KEY (`cp_no`), + UNIQUE KEY `cp_id` (`cp_id`), + KEY `mb_id` (`mb_id`) + )", false); +} ?> \ No newline at end of file diff --git a/install/install_db.php b/install/install_db.php index 1559af4c1..3e05de7b8 100644 --- a/install/install_db.php +++ b/install/install_db.php @@ -493,6 +493,7 @@ if($shop_install) { 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, "\$g4['shop_coupon_table'] = SHOP_TABLE_PREFIX.'coupon'; // 쿠폰정보 테이블\n"); fwrite($f, "?>"); } diff --git a/install/shop.sql b/install/shop.sql index 17224fbb2..99dca6aa8 100644 --- a/install/shop.sql +++ b/install/shop.sql @@ -133,6 +133,34 @@ CREATE TABLE IF NOT EXISTS `shop_content` ( -- -------------------------------------------------------- +-- +-- Table structure for table `shop_coupon` +-- + +DROP TABLE IF EXISTS `shop_coupon`; +CREATE TABLE IF NOT EXISTS `shop_coupon` ( + `cp_no` INT(11) NOT NULL AUTO_INCREMENT, + `cp_id` VARCHAR(255) NOT NULL DEFAULT '', + `cp_subject` VARCHAR(255) NOT NULL DEFAULT '', + `cp_method` TINYINT(4) NOT NULL DEFAULT '0', + `cp_target` VARCHAR(255) NOT NULL DEFAULT '', + `mb_id` VARCHAR(255) NOT NULL DEFAULT '', + `cp_start` DATE NOT NULL DEFAULT '0000-00-00', + `cp_end` DATE NOT NULL DEFAULT '0000-00-00', + `cp_amount` INT(11) NOT NULL DEFAULT '0', + `cp_type` TINYINT(4) NOT NULL DEFAULT '0', + `cp_trunc` INT(11) NOT NULL DEFAULT '0', + `cp_minimum` INT(11) NOT NULL DEFAULT '0', + `cp_maximum` INT(11) NOT NULL DEFAULT '0', + `cp_used` TINYINT(4) NOT NULL DEFAULT '0', + `cp_datetime` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', + PRIMARY KEY (`cp_no`), + UNIQUE KEY `cp_id` (`cp_id`), + KEY `mb_id` (`mb_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +-- -------------------------------------------------------- + -- -- Table structure for table `shop_default` -- diff --git a/lib/shop.lib.php b/lib/shop.lib.php index 6c5f58779..fc343fa27 100644 --- a/lib/shop.lib.php +++ b/lib/shop.lib.php @@ -1116,6 +1116,29 @@ function insert_mileage($mb_id, $point, $content='', $od_id, $ct_id) return 1; } + +// 쿠폰번호 생성함수 +function get_coupon_id() +{ + $len = 16; + $chars = "ABCDEFGHJKLMNPQRSTUVWXYZ123456789"; + + srand((double)microtime()*1000000); + + $i = 0; + $str = ''; + + while ($i < $len) { + $num = rand() % strlen($chars); + $tmp = substr($chars, $num, 1); + $str .= $tmp; + $i++; + } + + $str = preg_replace("/([0-9A-Z]{4})([0-9A-Z]{4})([0-9A-Z]{4})([0-9A-Z]{4})/", "\\1-\\2-\\3-\\4", $str); + + return $str; +} //============================================================================== // 쇼핑몰 함수 모음 끝 //==============================================================================