1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
<?php include_once("./_common.php");
if($mode=='cp_reg'){
$coupon_reg_no = trim($coupon_reg_no); $sql = "select count(*) as cnt from shop_coupon_list where cp_id = '{$coupon_reg_no}' and upper(login_id) = '".strtoupper($id_cust)."' "; $info = sql_fetch($sql,$connect_j3); if($info['cnt']>0){ echo "이미등록하거나 사용하신 쿠폰번호 입니다."; exit; }
$sql = "select * from shop_coupon where cp_id = '{$coupon_reg_no}'"; $cp_info = sql_fetch($sql,$connect_j3);
if($cp_info['cp_id']==''){ echo "해당되는 쿠폰번호가 없습니다. 쿠폰번호를 다시 확인하시기 바랍니다."; exit; }
$cur_date = date("Y-m-d"); if($cp_info['cp_sdate']=='0000-00-00' || $cp_info['cp_edate']=='0000-00-00'){
} else if(!($cp_info['cp_sdate']<=$cur_date && $cp_info['cp_edate']>=$cur_date)){ echo "해당되는 쿠폰의 유효기간이 아닙니다."; exit; }
if($cp_info['cp_cnt']>0){ $sql = "select count(*) as cnt from shop_coupon_list where cp_id = '{$coupon_reg_no}'"; $info = sql_fetch($sql,$connect_j3); if($info['cnt']>=$cp_info['cp_cnt']){ echo "해당되는 쿠폰의 발행갯수가 마감되었습니다."; exit; } }
$sql = "insert into shop_coupon_list set cp_id = '{$cp_info['cp_id']}', login_id = '{$id_cust}', od_id = '', cp_price = '{$cp_info['cp_price']}', reg_date = now() "; mysql_query($sql,$connect_j3); echo "OK"; }
?>
|