gettotal("select count(*) as total from {$dbtbpre}enewsshop_precode where precode='$add[precode]' limit 1"); if($num) { printerror("RePrecode","history.go(-1)"); } $addtime=time(); $add['prename']=eaddslashes(ehtmlspecialchars($add['prename'])); $add['premoney']=(int)$add['premoney']; $add['pretype']=(int)$add['pretype']; $add['reuse']=(int)$add['reuse']; $add['endtime']=$add['endtime']?to_time($add['endtime']):0; $add['musttotal']=(int)$add['musttotal']; $add['usenum']=(int)$add['usenum']; $groupids=ReturnPreGroupids($add['groupid']); $add['classid']=trim($add['classid']); $classids=$add['classid']?','.$add['classid'].',':''; $sql=$empire->query("insert into {$dbtbpre}enewsshop_precode(prename,precode,premoney,pretype,reuse,addtime,endtime,groupid,classid,musttotal,usenum) values('$add[prename]','$add[precode]','$add[premoney]','$add[pretype]','$add[reuse]','$addtime','$add[endtime]','$groupids','".eaddslashes($classids)."','$add[musttotal]','$add[usenum]');"); $id=$empire->lastid(); if($sql) { //操作日志 insert_dolog("id=$id&precode=$add[precode]
premoney=$add[premoney]&pretype=$add[pretype]"); printerror("AddPrecodeSuccess","AddPrecode.php?enews=AddPrecode".hReturnEcmsHashStrHref2(0)); } else {printerror("DbError","history.go(-1)");} } //批量增加优惠码 function AddMorePrecode($add,$userid,$username){ global $empire,$dbtbpre; $donum=(int)$add['donum']; $precodenum=(int)$add['precodenum']; $add['prename']=eaddslashes(ehtmlspecialchars($add['prename'])); $add['premoney']=(int)$add['premoney']; $add['pretype']=(int)$add['pretype']; $add['reuse']=(int)$add['reuse']; $add['endtime']=$add['endtime']?to_time($add['endtime']):0; $add['musttotal']=(int)$add['musttotal']; $add['usenum']=(int)$add['usenum']; $groupids=ReturnPreGroupids($add['groupid']); $add['classid']=trim($add['classid']); $classids=$add['classid']?','.$add['classid'].',':''; if(!$donum||!$precodenum||!$add['prename']||!$add['premoney']) { printerror("EmptyMorePrecode","history.go(-1)"); } //验证权限 CheckLevel($userid,$username,$classid,"precode"); $addtime=time(); //写入优惠码 $no=1; while($no<=$donum) { $precode=strtoupper(make_password($precodenum)); $num=$empire->gettotal("select count(*) as total from {$dbtbpre}enewsshop_precode where precode='$precode' limit 1"); if(!$num) { $sql=$empire->query("insert into {$dbtbpre}enewsshop_precode(prename,precode,premoney,pretype,reuse,addtime,endtime,groupid,classid,musttotal,usenum) values('$add[prename]','$precode','$add[premoney]','$add[pretype]','$add[reuse]','$addtime','$add[endtime]','$groupids','".eaddslashes($classids)."','$add[musttotal]','$add[usenum]');"); $no+=1; } } if($sql) { //操作日志 insert_dolog("prenum=$donum&premoney=$add[premoney]&pretype=$add[pretype]"); printerror("AddMorePrecodeSuccess","AddMorePrecode.php".hReturnEcmsHashStrHref2(1)); } else {printerror("DbError","history.go(-1)");} } //修改优惠码 function EditPrecode($add,$userid,$username){ global $empire,$dbtbpre; $add['id']=(int)$add['id']; if(!$add['prename']||!$add['precode']||!$add['premoney']||!$add['id']) { printerror("EmptyPrecode","history.go(-1)"); } //验证权限 CheckLevel($userid,$username,$classid,"precode"); $add['precode']=RepPostVar($add['precode']); $num=$empire->gettotal("select count(*) as total from {$dbtbpre}enewsshop_precode where precode='$add[precode]' and id<>".$add[id]." limit 1"); if($num) { printerror("RePrecode","history.go(-1)"); } $time=(int)$add['time']; $add['prename']=eaddslashes(ehtmlspecialchars($add['prename'])); $add['premoney']=(int)$add['premoney']; $add['pretype']=(int)$add['pretype']; $add['reuse']=(int)$add['reuse']; $add['endtime']=$add['endtime']?to_time($add['endtime']):0; $add['musttotal']=(int)$add['musttotal']; $add['usenum']=(int)$add['usenum']; $groupids=ReturnPreGroupids($add['groupid']); $add['classid']=trim($add['classid']); $classids=$add['classid']?','.$add['classid'].',':''; $classids=eaddslashes($classids); $sql=$empire->query("update {$dbtbpre}enewsshop_precode set prename='$add[prename]',precode='$add[precode]',premoney='$add[premoney]',pretype='$add[pretype]',reuse='$add[reuse]',endtime='$add[endtime]',groupid='$groupids',classid='$classids',musttotal='$add[musttotal]',usenum='$add[usenum]' where id='$add[id]'"); if($sql) { //操作日志 insert_dolog("id=$add[id]&precode=$add[precode]
premoney=$add[premoney]&pretype=$add[pretype]"); printerror("EditPrecodeSuccess","ListPrecode.php?time=$time".hReturnEcmsHashStrHref2(0)); } else {printerror("DbError","history.go(-1)");} } //删除优惠码 function DelPrecode($add,$userid,$username){ global $empire,$dbtbpre; $id=(int)$add['id']; if(!$id) { printerror("NotChangePrecodeid","history.go(-1)"); } //验证权限 CheckLevel($userid,$username,$classid,"precode"); $time=(int)$add['time']; $r=$empire->fetch1("select precode,premoney,pretype from {$dbtbpre}enewsshop_precode where id='$id'"); $sql=$empire->query("delete from {$dbtbpre}enewsshop_precode where id='$id'"); if($sql) { //操作日志 insert_dolog("id=$id&precode=$r[precode]
premoney=$r[premoney]&pretype=$r[pretype]"); printerror("DelPrecodeSuccess","ListPrecode.php?time=$time".hReturnEcmsHashStrHref2(0)); } else {printerror("DbError","history.go(-1)");} } //批量删除优惠码 function DelPrecode_all($add,$userid,$username){ global $empire,$dbtbpre; $id=$add['id']; $count=count($id); if(!$count) { printerror("NotChangePrecodeid","history.go(-1)"); } //验证权限 CheckLevel($userid,$username,$classid,"precode"); $ids=''; $dh=''; for($i=0;$i<$count;$i++) { $ids.=$dh.intval($id[$i]); $dh=','; } $time=(int)$add['time']; $sql=$empire->query("delete from {$dbtbpre}enewsshop_precode where id in (".$ids.")"); if($sql) { //操作日志 insert_dolog(""); printerror("DelPrecodeSuccess","ListPrecode.php?time=$add[time]".hReturnEcmsHashStrHref2(0)); } else {printerror("DbError","history.go(-1)");} } $enews=$_POST['enews']; if(empty($enews)) {$enews=$_GET['enews'];} if($enews) { hCheckEcmsRHash(); } if($enews=="AddPrecode")//增加优惠码 { AddPrecode($_POST,$logininid,$loginin); } elseif($enews=="EditPrecode")//修改优惠码 { EditPrecode($_POST,$logininid,$loginin); } elseif($enews=="DelPrecode")//删除优惠码 { DelPrecode($_GET,$logininid,$loginin); } elseif($enews=="AddMorePrecode")//批量增加优惠码 { AddMorePrecode($_POST,$logininid,$loginin); } elseif($enews=="DelPrecode_all")//批量删除优惠码 { DelPrecode_all($_POST,$logininid,$loginin); } $page=(int)$_GET['page']; $page=RepPIntvar($page); $start=0; $line=25; $page_line=25; $add=""; $and=' where '; $search=""; $search.=$ecms_hashur['ehref']; $time=(int)$_GET['time']; //搜索 $sear=(int)$_GET['sear']; if($sear) { $show=(int)$_GET['show']; $keyboard=$_GET['keyboard']; $keyboard=RepPostVar2($keyboard); if($keyboard) { if($show==1)//优惠码名称 { $add.=$and."prename like '%$keyboard%'"; } elseif($show==2)//优惠码 { $add.=$and."precode='$keyboard'"; } else//金额 { $add.=$and."premoney='$keyboard'"; } $and=' and '; } //类型 $pretype=(int)$_GET['pretype']; if($pretype) { if($pretype==1)//金额 { $add.=$and."pretype=0"; } else//百分比 { $add.=$and."pretype=1"; } $and=' and '; } //重复使用 $reuse=(int)$_GET['reuse']; if($reuse) { if($reuse==1)//一次性使用 { $add.=$and."reuse=0"; } else//可重复使用 { $add.=$and."reuse=1"; } $and=' and '; } $search.="&sear=1&pretype=$pretype&reuse=$reuse&show=$show&keyboard=$keyboard"; } //过期 if($time) { $todaytime=time(); $search.="&time=$time"; $add.=$and."endtime>0 and endtime<".$todaytime; } $offset=$line*$page; $totalquery="select count(*) as total from {$dbtbpre}enewsshop_precode".$add; $num=$empire->gettotal($totalquery); $query="select id,prename,precode,pretype,premoney,reuse,addtime,endtime from {$dbtbpre}enewsshop_precode".$add; $query.=" order by id desc limit $offset,$line"; $sql=$empire->query($query); $returnpage=page2($num,$line,$page_line,$start,$page,$search); ?> 管理优惠码
位置:管理优惠码
     

搜索:
fetch($sql)) { if($r['pretype']==1) { $premoney=$r['premoney'].'%'; } else { $premoney=$r['premoney'].'元'; } ?>
ID
优惠码名称
优惠码
金额(元)
重复使用
操作
">
[修改] [删除]