<?php
define('IN_PHPQUAN', true);
require dirname(__FILE__) . '/include/common.php';
$durl = 'list';
$id = $_REQUEST['id'] ? intval($_REQUEST['id']) : '';
if(empty($id)) showmsg('缺少参数！');
$sql = "SELECT a.*,m.comid,m.comname,count(c.juanid) as ujid,MAX(c.id) as cid FROM {$table}juan AS a LEFT JOIN {$table}com AS m ON m.userid=a.userid left join {$table}juan_user as c on a.id=c.juanid WHERE a.id='$id' and a.enddate>=".time()." and a.is_check=1";
$juan = $db->getRow($sql);
if(empty($juan)) showmsg('券不存在','list.php');
extract($juan);
$username = $db->getOne("select c.username from {$table}juan_user as a left join {$table}member as c on a.userid=c.userid where id='$cid' and juanid='$id'");
$username = !empty($username) ? $username.' 最近领取' : '还没有人领取~~';
$cat_array = get_cat_array();
$catname = $cat_array[$catid][0];
$yunum = round($nums-$ujid);
$forusers = $foruser==1 ? '仅在本店核销过会员可领' : '';
$jinfo = nl2br($jinfo);
if($enddate<time())showmsg('优惠券已经过期了！','list.php');
$enddates = date('Y/m/d', $enddate);
$lastdate = enddate($enddate);
$db->query("UPDATE LOW_PRIORITY {$table}juan SET click=click+1 WHERE id='$id'");/*更新点击量*/
$seo['title']   = $comname.$catname.'_'.$title . '_' .$CFG['webname'];
$seo['keywords']  = $comname.','.$catname.','.$CFG['webname'];
$seo['description'] = $comname.'发布的'.$catname.'_'.$CFG['webname'];
$cat_info = get_cat_info($catid);
$template = $cat_info['viewtplname'] ? $cat_info['viewtplname'] : 'view';
include template($template);
?>