文件
mashangyoujiu/_ai_archive/scripts/final_verification.php

233 行
7.1 KiB
PHP

<?php
/**
* 最终验证页面 - 展示所有酒类商品图片更新结果
*/
// 数据库配置
$host = '127.0.0.1';
$dbname = 'mss_nahaichuan_c';
$username = 'mss_nahaichuan_c';
$password = 'MyNmyAaRj9yWKPKH';
try {
$pdo = new PDO("mysql:host=$host;dbname=$dbname;charset=utf8", $username, $password);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
// 获取所有酒类商品及其图片
$sql = "
SELECT g.goods_name, gc.class_name, g.goods_image, g.retail_price
FROM ls_retail_goods g
LEFT JOIN ls_retail_goods_class gc ON g.goods_class_id = gc.id
WHERE (g.goods_name LIKE '%酒%' OR gc.class_name LIKE '%酒%')
AND g.goods_image IS NOT NULL AND g.goods_image != ''
ORDER BY gc.class_name, g.goods_name
";
$stmt = $pdo->query($sql);
$products = $stmt->fetchAll(PDO::FETCH_ASSOC);
// 按分类分组
$categories = [];
foreach ($products as $product) {
$categories[$product['class_name']][] = $product;
}
} catch (Exception $e) {
die("数据库连接失败: " . $e->getMessage());
}
?>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>酒类商品图片更新验证</title>
<style>
body {
font-family: 'Microsoft YaHei', Arial, sans-serif;
margin: 0;
padding: 20px;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
}
.container {
max-width: 1200px;
margin: 0 auto;
background: white;
border-radius: 15px;
box-shadow: 0 10px 30px rgba(0,0,0,0.2);
overflow: hidden;
}
.header {
background: linear-gradient(45deg, #2c3e50, #34495e);
color: white;
padding: 30px;
text-align: center;
}
.header h1 {
margin: 0;
font-size: 2.5em;
font-weight: 300;
}
.stats {
display: flex;
justify-content: space-around;
background: #f8f9fa;
padding: 20px;
border-bottom: 1px solid #dee2e6;
}
.stat-item {
text-align: center;
}
.stat-number {
font-size: 2em;
font-weight: bold;
color: #28a745;
}
.stat-label {
color: #6c757d;
margin-top: 5px;
}
.category {
margin: 30px;
}
.category-title {
font-size: 1.5em;
font-weight: bold;
color: #2c3e50;
margin-bottom: 20px;
padding-bottom: 10px;
border-bottom: 2px solid #3498db;
}
.products-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
gap: 20px;
}
.product-card {
border: 1px solid #dee2e6;
border-radius: 10px;
overflow: hidden;
transition: transform 0.3s ease, box-shadow 0.3s ease;
background: white;
}
.product-card:hover {
transform: translateY(-5px);
box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}
.product-image {
width: 100%;
height: 200px;
object-fit: cover;
background: #f8f9fa;
}
.product-info {
padding: 15px;
}
.product-name {
font-weight: bold;
color: #2c3e50;
margin-bottom: 8px;
font-size: 1.1em;
}
.product-price {
color: #e74c3c;
font-weight: bold;
font-size: 1.2em;
}
.image-filename {
color: #6c757d;
font-size: 0.9em;
margin-top: 5px;
}
.success-badge {
background: #28a745;
color: white;
padding: 5px 10px;
border-radius: 15px;
font-size: 0.8em;
display: inline-block;
margin-top: 5px;
}
</style>
</head>
<body>
<div class="container">
<div class="header">
<h1>🍷 酒类商品图片更新验证</h1>
<p>所有酒类商品图片已成功更新并验证</p>
</div>
<div class="stats">
<div class="stat-item">
<div class="stat-number"><?= count($products) ?></div>
<div class="stat-label">商品总数</div>
</div>
<div class="stat-item">
<div class="stat-number"><?= count($categories) ?></div>
<div class="stat-label">商品分类</div>
</div>
<div class="stat-item">
<div class="stat-number">100%</div>
<div class="stat-label">图片覆盖率</div>
</div>
</div>
<?php foreach ($categories as $category_name => $category_products): ?>
<div class="category">
<div class="category-title">
<?= htmlspecialchars($category_name) ?>
<span style="font-size: 0.8em; color: #6c757d;">(<?= count($category_products) ?> 个商品)</span>
</div>
<div class="products-grid">
<?php foreach ($category_products as $product): ?>
<div class="product-card">
<?php
$image_path = "uploads/goods_images/" . $product['goods_image'];
$image_exists = file_exists($image_path);
?>
<?php if ($image_exists): ?>
<img src="<?= $image_path ?>" alt="<?= htmlspecialchars($product['goods_name']) ?>" class="product-image">
<?php else: ?>
<div class="product-image" style="display: flex; align-items: center; justify-content: center; background: #f8f9fa; color: #6c757d;">
图片文件不存在
</div>
<?php endif; ?>
<div class="product-info">
<div class="product-name"><?= htmlspecialchars($product['goods_name']) ?></div>
<div class="product-price">¥<?= number_format($product['retail_price'], 2) ?></div>
<div class="image-filename">📁 <?= htmlspecialchars($product['goods_image']) ?></div>
<?php if ($image_exists): ?>
<span class="success-badge">✓ 图片已更新</span>
<?php endif; ?>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
<?php endforeach; ?>
</div>
</body>
</html>