prepare('SELECT COUNT(*) FROM redemption_codes WHERE product_id = ? AND (code = ? OR batch_no = ?)'); $stmt->execute([$pid, $q, $q]); $total = (int)$stmt->fetchColumn(); $totalPages = max(1, ceil($total / $perPage)); // 分页查询 $stmt = $pdo->prepare("SELECT r.*, u.username FROM redemption_codes r LEFT JOIN users u ON r.claim_user_id = u.id WHERE r.product_id = ? AND (r.code = ? OR r.batch_no = ?) ORDER BY r.id DESC LIMIT ? OFFSET ?"); $stmt->execute([$pid, $q, $q, $perPage, $offset]); $results = $stmt->fetchAll(); } ?>
| 序号 | 兑换码名称 | 批次号 | 类型 | 兑换码 | 面值 | 状态 | 过期时间 | 创建时间 | 用户 | 领取时间 |
|---|---|---|---|---|---|---|---|---|---|---|
| = $idx ?> | = h($r['name']) ?> | = h($r['batch_no']) ?> | = h($r['type']) ?> | = h(maskCode($r['code'])) ?> |
= h($r['value']) ?> | = claimStatusBadge((int)$r['status']) ?> | = formatDateTime($r['expired_at']) ?> | = formatDateTime($r['created_at']) ?> | = h($r['username'] ?? '-') ?> | = formatDateTime($r['claimed_at']) ?> |