fix: 全面修复项目问题

后端修复:
- 验证码存储与校验机制
- 订单创建事务+库存扣减
- GetStats字段名错误
- VerifyEmail改为POST
- 供应商更新字段白名单
- 文件删除安全检查
- 抽奖安全随机数
- 用户管理CRUD
- 订单取消/确认收货
- 工单回复
- Toggle返回新数据
- 移除死代码

前端修复:
- 404兜底路由
- 401软跳转
- API层统一
- 面包屑补充banners
- 国际化完善
- 购物车并行删除
- 退出清理购物车
- 供应商Dashboard数据
- 工单详情页
- 订单取消/确认收货
This commit is contained in:
2026-05-06 09:16:34 +08:00
parent 739481b59f
commit 3a898e8aa0
52 changed files with 2807 additions and 920 deletions
+1 -1
View File
@@ -108,7 +108,7 @@ def main():
print("请先创建管理员账户")
return
with open('ribenyan_products.json', 'r', encoding='utf-8') as f:
with open('../ribenyan_products.json', 'r', encoding='utf-8') as f:
products = json.load(f)
print(f"读取到 {len(products)} 个商品")
+81
View File
@@ -0,0 +1,81 @@
import sqlite3
from datetime import datetime
# 连接数据库
conn = sqlite3.connect('../backend/cmd/server/sale.db')
cursor = conn.cursor()
# 轮播图测试数据
banners = [
{
'title': '新品上市',
'desc': '精选优质商品,限时特惠',
'image': 'https://images.unsplash.com/photo-1441986300917-64674bd600d8?w=1920&h=400&fit=crop',
'link': '/products',
'button': '立即选购',
'bg_color': 'linear-gradient(135deg, #4e6ef2 0%, #7c5cfc 100%)',
'sort_order': 1,
'is_active': 1
},
{
'title': '幸运抽奖',
'desc': '参与抽奖赢取好礼',
'image': 'https://images.unsplash.com/photo-1511895426328-dc8714191300?w=1920&h=400&fit=crop',
'link': '/lotteries',
'button': '参与活动',
'bg_color': 'linear-gradient(135deg, #f59e0b 0%, #f97316 100%)',
'sort_order': 2,
'is_active': 1
},
{
'title': '限时秒杀',
'desc': '每日精选,超值优惠',
'image': 'https://images.unsplash.com/photo-1607082348824-0a96f2a4b9da?w=1920&h=400&fit=crop',
'link': '/products',
'button': '查看详情',
'bg_color': 'linear-gradient(135deg, #10b981 0%, #059669 100%)',
'sort_order': 3,
'is_active': 1
},
{
'title': '会员专享',
'desc': '注册即送积分,享受更多优惠',
'image': 'https://images.unsplash.com/photo-1556742049-0cfed4f6a45d?w=1920&h=400&fit=crop',
'link': '/register',
'button': '立即注册',
'bg_color': 'linear-gradient(135deg, #8b5cf6 0%, #a78bfa 100%)',
'sort_order': 4,
'is_active': 1
}
]
# 插入数据
for banner in banners:
cursor.execute('''
INSERT INTO banners (title, desc, image, link, button, bg_color, sort_order, is_active, created_at, updated_at)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
''', (
banner['title'],
banner['desc'],
banner['image'],
banner['link'],
banner['button'],
banner['bg_color'],
banner['sort_order'],
banner['is_active'],
datetime.now().isoformat(),
datetime.now().isoformat()
))
conn.commit()
# 查询验证
cursor.execute('SELECT id, title, link, is_active FROM banners ORDER BY sort_order')
results = cursor.fetchall()
print(f"✅ 成功插入 {len(banners)} 条轮播图数据:\n")
for row in results:
status = "启用" if row[3] else "禁用"
print(f"ID: {row[0]}, 标题: {row[1]}, 链接: {row[2]}, 状态: {status}")
conn.close()
+207
View File
@@ -0,0 +1,207 @@
import sqlite3
import random
from datetime import datetime, timedelta
# 连接数据库
conn = sqlite3.connect('e:/Code/sale/backend/cmd/server/sale.db')
cursor = conn.cursor()
# 抽奖活动数据
lotteries = [
{
'name': '新年大抽奖',
'description': '参与新年抽奖,赢取丰厚奖品!iPhone、iPad、AirPods等你来拿!',
'image': 'https://images.unsplash.com/photo-1513151233558-d860c5398176?w=400&h=300&fit=crop',
'start_time': datetime.now().isoformat(),
'end_time': (datetime.now() + timedelta(days=30)).isoformat(),
'cycle': 'daily',
'daily_quota': 100,
'total_quota': 3000,
'registration_validity': 7,
'is_active': 1
},
{
'name': '会员专属抽奖',
'description': '会员专属福利,积分抽奖赢好礼!',
'image': 'https://images.unsplash.com/photo-1511895426328-dc8714191300?w=400&h=300&fit=crop',
'start_time': datetime.now().isoformat(),
'end_time': (datetime.now() + timedelta(days=60)).isoformat(),
'cycle': 'weekly',
'daily_quota': 50,
'total_quota': 1000,
'registration_validity': 14,
'is_active': 1
},
{
'name': '春季特惠抽奖',
'description': '春季特惠活动,购物即可参与抽奖!',
'image': 'https://images.unsplash.com/photo-1492684223066-81342ee5ff30?w=400&h=300&fit=crop',
'start_time': datetime.now().isoformat(),
'end_time': (datetime.now() + timedelta(days=45)).isoformat(),
'cycle': 'monthly',
'daily_quota': 200,
'total_quota': 5000,
'registration_validity': 30,
'is_active': 1
},
{
'name': '限时秒杀抽奖',
'description': '限时秒杀活动,参与抽奖享更多优惠!',
'image': 'https://images.unsplash.com/photo-1607082348824-0a96f2a4b9da?w=400&h=300&fit=crop',
'start_time': datetime.now().isoformat(),
'end_time': (datetime.now() + timedelta(days=15)).isoformat(),
'cycle': 'daily',
'daily_quota': 150,
'total_quota': 2000,
'registration_validity': 5,
'is_active': 1
},
{
'name': '品牌联合抽奖',
'description': '多个品牌联合抽奖,奖品更丰厚!',
'image': 'https://images.unsplash.com/photo-1556742049-0cfed4f6a45d?w=400&h=300&fit=crop',
'start_time': datetime.now().isoformat(),
'end_time': (datetime.now() + timedelta(days=90)).isoformat(),
'cycle': 'weekly',
'daily_quota': 80,
'total_quota': 1500,
'registration_validity': 10,
'is_active': 1
}
]
# 插入抽奖活动
for lottery in lotteries:
cursor.execute('''
INSERT INTO lotteries (name, description, image, start_time, end_time, cycle, daily_quota, total_quota, registration_validity, is_active, created_at, updated_at)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
''', (
lottery['name'],
lottery['description'],
lottery['image'],
lottery['start_time'],
lottery['end_time'],
lottery['cycle'],
lottery['daily_quota'],
lottery['total_quota'],
lottery['registration_validity'],
lottery['is_active'],
datetime.now().isoformat(),
datetime.now().isoformat()
))
print(f"✅ 成功插入 {len(lotteries)} 个抽奖活动")
# 资讯数据
articles = [
{
'title': '2024年电商行业发展趋势分析',
'content': '随着技术的不断发展,电商行业正在经历前所未有的变革。本文将深入分析2024年电商行业的发展趋势,包括人工智能、社交电商、直播带货等多个方面。人工智能技术的应用让个性化推荐更加精准,社交电商正在改变传统的购物方式,直播带货已经成为品牌营销的重要渠道。',
'summary': '深入分析2024年电商行业发展趋势,涵盖AI、社交电商、直播带货等热门话题',
'cover_image': 'https://images.unsplash.com/photo-1556742049-0cfed4f6a45d?w=800&h=400&fit=crop',
'is_published': 1,
'is_pinned': 1,
'sort_order': 1
},
{
'title': '如何选择适合自己的商品',
'content': '在众多商品中选择适合自己的产品并不容易。本文将从价格、质量、品牌、用户评价等多个维度,为您提供详细的选购指南。首先,要明确自己的需求和预算;其次,要关注商品的质量和售后服务;最后,要参考其他用户的评价和建议。',
'summary': '从价格、质量、品牌等多维度提供商品选购指南',
'cover_image': 'https://images.unsplash.com/photo-1441986300917-64674bd600d8?w=800&h=400&fit=crop',
'is_published': 1,
'is_pinned': 0,
'sort_order': 2
},
{
'title': '平台优惠活动全攻略',
'content': '想要在购物时获得更多优惠?本文为您详细介绍平台的各种优惠活动,包括满减、折扣、优惠券、积分兑换等多种方式。了解这些优惠规则,让您在购物时省更多钱。满减活动通常在特定节日举行,折扣商品需要及时关注,优惠券可以通过多种渠道获取。',
'summary': '详细介绍平台满减、折扣、优惠券等各种优惠活动',
'cover_image': 'https://images.unsplash.com/photo-1607082348824-0a96f2a4b9da?w=800&h=400&fit=crop',
'is_published': 1,
'is_pinned': 0,
'sort_order': 3
},
{
'title': '新品上市:春季系列商品推荐',
'content': '春季新品已经上市!本文为您推荐本季最热门的商品系列,包括服装、配饰、家居用品等多个品类。春季系列以清新、活力为主题,采用最新的设计理念和优质材料,为您带来全新的使用体验。',
'summary': '推荐春季最热门的新品系列,涵盖多个品类',
'cover_image': 'https://images.unsplash.com/photo-1492684223066-81342ee5ff30?w=800&h=400&fit=crop',
'is_published': 1,
'is_pinned': 1,
'sort_order': 4
},
{
'title': '用户购物安全指南',
'content': '在网上购物时,安全是最重要的。本文为您提供全面的购物安全指南,包括如何识别假冒商品、保护个人信息、安全支付等多个方面。建议您选择官方渠道购买商品,注意查看商品评价和卖家信誉,使用安全的支付方式。',
'summary': '提供全面的网购安全指南,保护您的购物安全',
'cover_image': 'https://images.unsplash.com/photo-1563013544-824ae1b704d3?w=800&h=400&fit=crop',
'is_published': 1,
'is_pinned': 0,
'sort_order': 5
},
{
'title': '积分使用技巧大公开',
'content': '积分是平台会员的重要福利,但很多人不知道如何高效使用积分。本文将为您详细介绍积分的获取方式和使用技巧,让您在购物时获得更多实惠。积分可以通过购物、签到、参与活动等多种方式获取,可以用来兑换商品、抵扣现金等。',
'summary': '详细介绍积分获取方式和使用技巧',
'cover_image': 'https://images.unsplash.com/photo-1556742111-a301076d9c18?w=800&h=400&fit=crop',
'is_published': 1,
'is_pinned': 0,
'sort_order': 6
},
{
'title': '售后服务政策详解',
'content': '了解平台的售后服务政策,让您购物更放心。本文详细介绍了退换货政策、质量保证、维修服务等多个方面。我们承诺7天无理由退换货,30天质量问题包退,1年质量问题保修。让您购物无忧。',
'summary': '详细介绍平台退换货、质量保证等售后服务政策',
'cover_image': 'https://images.unsplash.com/photo-1553877522-43269d4ea984?w=800&h=400&fit=crop',
'is_published': 1,
'is_pinned': 0,
'sort_order': 7
},
{
'title': '会员等级权益全解析',
'content': '平台会员分为多个等级,不同等级享受不同的权益。本文为您详细解析各个等级的权益,包括折扣力度、积分倍率、专属客服等。等级越高,享受的权益越多。升级方式包括购物金额、积分数量、活跃度等多个维度。',
'summary': '详细解析各等级会员权益和升级方式',
'cover_image': 'https://images.unsplash.com/photo-1511895426328-dc8714191300?w=800&h=400&fit=crop',
'is_published': 1,
'is_pinned': 0,
'sort_order': 8
}
]
# 插入资讯
for article in articles:
cursor.execute('''
INSERT INTO articles (title, content, summary, cover_image, is_published, is_pinned, sort_order, created_at, updated_at)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
''', (
article['title'],
article['content'],
article['summary'],
article['cover_image'],
article['is_published'],
article['is_pinned'],
article['sort_order'],
datetime.now().isoformat(),
datetime.now().isoformat()
))
print(f"✅ 成功插入 {len(articles)} 篇资讯")
# 查询验证
cursor.execute('SELECT id, name, is_active FROM lotteries ORDER BY created_at DESC LIMIT 5')
lottery_results = cursor.fetchall()
cursor.execute('SELECT id, title, is_pinned FROM articles ORDER BY sort_order ASC LIMIT 5')
article_results = cursor.fetchall()
print("\n抽奖活动:")
for row in lottery_results:
status = "启用" if row[2] else "禁用"
print(f"ID: {row[0]}, 名称: {row[1]}, 状态: {status}")
print("\n资讯文章:")
for row in article_results:
pinned = "置顶" if row[2] else "普通"
print(f"ID: {row[0]}, 标题: {row[1]}, 状态: {pinned}")
conn.close()
+53
View File
@@ -0,0 +1,53 @@
import sqlite3
from datetime import datetime, timedelta
# 连接数据库
conn = sqlite3.connect('e:/Code/sale/backend/cmd/server/sale.db')
cursor = conn.cursor()
# 插入抽奖活动
lotteries_data = [
('新年大抽奖', '参与新年抽奖,赢取丰厚奖品!iPhone、iPad、AirPods等你来拿!', 'https://images.unsplash.com/photo-1513151233558-d860c5398176?w=400&h=300&fit=crop', 'daily', 100, 3000, 7),
('会员专属抽奖', '会员专属福利,积分抽奖赢好礼!', 'https://images.unsplash.com/photo-1511895426328-dc8714191300?w=400&h=300&fit=crop', 'weekly', 50, 1000, 14),
('春季特惠抽奖', '春季特惠活动,购物即可参与抽奖!', 'https://images.unsplash.com/photo-1492684223066-81342ee5ff30?w=400&h=300&fit=crop', 'monthly', 200, 5000, 30),
('限时秒杀抽奖', '限时秒杀活动,参与抽奖享更多优惠!', 'https://images.unsplash.com/photo-1607082348824-0a96f2a4b9da?w=400&h=300&fit=crop', 'daily', 150, 2000, 5),
('品牌联合抽奖', '多个品牌联合抽奖,奖品更丰厚!', 'https://images.unsplash.com/photo-1556742049-0cfed4f6a45d?w=400&h=300&fit=crop', 'weekly', 80, 1500, 10)
]
for name, desc, image, cycle, daily_q, total_q, validity in lotteries_data:
cursor.execute('''
INSERT INTO lotteries (name, description, image, start_time, end_time, cycle, daily_quota, total_quota, registration_validity, is_active, created_at, updated_at)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, 1, ?, ?)
''', (name, desc, image, datetime.now().isoformat(), (datetime.now() + timedelta(days=30)).isoformat(), cycle, daily_q, total_q, validity, datetime.now().isoformat(), datetime.now().isoformat()))
# 插入资讯
articles_data = [
('2024年电商行业发展趋势分析', '随着技术的不断发展,电商行业正在经历前所未有的变革。本文将深入分析2024年电商行业的发展趋势,包括人工智能、社交电商、直播带货等多个方面。', '深入分析2024年电商行业发展趋势', 'https://images.unsplash.com/photo-1556742049-0cfed4f6a45d?w=800&h=400&fit=crop', 1, 1),
('如何选择适合自己的商品', '在众多商品中选择适合自己的产品并不容易。本文将从价格、质量、品牌、用户评价等多个维度,为您提供详细的选购指南。', '从价格、质量、品牌等多维度提供商品选购指南', 'https://images.unsplash.com/photo-1441986300917-64674bd600d8?w=800&h=400&fit=crop', 1, 0),
('平台优惠活动全攻略', '想要在购物时获得更多优惠?本文为您详细介绍平台的各种优惠活动,包括满减、折扣、优惠券、积分兑换等多种方式。', '详细介绍平台满减、折扣、优惠券等各种优惠活动', 'https://images.unsplash.com/photo-1607082348824-0a96f2a4b9da?w=800&h=400&fit=crop', 1, 0),
('新品上市:春季系列商品推荐', '春季新品已经上市!本文为您推荐本季最热门的商品系列,包括服装、配饰、家居用品等多个品类。', '推荐春季最热门的新品系列', 'https://images.unsplash.com/photo-1492684223066-81342ee5ff30?w=800&h=400&fit=crop', 1, 1),
('用户购物安全指南', '在网上购物时,安全是最重要的。本文为您提供全面的购物安全指南,包括如何识别假冒商品、保护个人信息、安全支付等多个方面。', '提供全面的网购安全指南', 'https://images.unsplash.com/photo-1563013544-824ae1b704d3?w=800&h=400&fit=crop', 1, 0),
('积分使用技巧大公开', '积分是平台会员的重要福利,但很多人不知道如何高效使用积分。本文将为您详细介绍积分的获取方式和使用技巧。', '详细介绍积分获取方式和使用技巧', 'https://images.unsplash.com/photo-1556742111-a301076d9c18?w=800&h=400&fit=crop', 1, 0),
('售后服务政策详解', '了解平台的售后服务政策,让您购物更放心。本文详细介绍了退换货政策、质量保证、维修服务等多个方面。', '详细介绍平台退换货、质量保证等售后服务政策', 'https://images.unsplash.com/photo-1553877522-43269d4ea984?w=800&h=400&fit=crop', 1, 0),
('会员等级权益全解析', '平台会员分为多个等级,不同等级享受不同的权益。本文为您详细解析各个等级的权益,包括折扣力度、积分倍率、专属客服等。', '详细解析各等级会员权益和升级方式', 'https://images.unsplash.com/photo-1511895426328-dc8714191300?w=800&h=400&fit=crop', 1, 0)
]
for i, (title, content, summary, cover, published, pinned) in enumerate(articles_data, 1):
cursor.execute('''
INSERT INTO articles (title, content, summary, cover_image, is_published, is_pinned, sort_order, created_at, updated_at)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
''', (title, content, summary, cover, published, pinned, i, datetime.now().isoformat(), datetime.now().isoformat()))
conn.commit()
# 验证
cursor.execute('SELECT COUNT(*) FROM lotteries')
lottery_count = cursor.fetchone()[0]
cursor.execute('SELECT COUNT(*) FROM articles')
article_count = cursor.fetchone()[0]
print(f"✅ 成功插入 {lottery_count} 个抽奖活动")
print(f"✅ 成功插入 {article_count} 篇资讯")
conn.close()
+30
View File
@@ -0,0 +1,30 @@
import sqlite3
import bcrypt
# 连接数据库
conn = sqlite3.connect('../backend/cmd/server/sale.db')
cursor = conn.cursor()
# 生成密码哈希
password = 'admin123'
hashed = bcrypt.hashpw(password.encode('utf-8'), bcrypt.gensalt()).decode('utf-8')
# 更新管理员密码
cursor.execute('UPDATE users SET password_hash = ? WHERE email = ?', (hashed, 'admin@viaeon.com'))
conn.commit()
# 验证更新
cursor.execute('SELECT email, password_hash FROM users WHERE email = ?', ('admin@viaeon.com',))
result = cursor.fetchone()
print(f"邮箱: {result[0]}")
print(f"密码哈希: {result[1]}")
print(f"密码已更新为: {password}")
# 测试密码验证
if bcrypt.checkpw(password.encode('utf-8'), result[1].encode('utf-8')):
print("✅ 密码验证成功!")
else:
print("❌ 密码验证失败!")
conn.close()