增加微信支付,商城逻辑,公告
This commit is contained in:
@@ -574,7 +574,48 @@ async function createTables() {
|
||||
FOREIGN KEY (order_id) REFERENCES matching_orders(id) ON DELETE SET NULL
|
||||
)
|
||||
`);
|
||||
}
|
||||
|
||||
// 通知公告表
|
||||
await getDB().execute(`
|
||||
CREATE TABLE IF NOT EXISTS announcements (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
title VARCHAR(255) NOT NULL COMMENT '公告标题',
|
||||
content TEXT NOT NULL COMMENT '公告内容',
|
||||
type ENUM('system', 'maintenance', 'promotion', 'warning') DEFAULT 'system' COMMENT '公告类型',
|
||||
priority ENUM('low', 'medium', 'high', 'urgent') DEFAULT 'medium' COMMENT '优先级',
|
||||
status ENUM('draft', 'published', 'archived') DEFAULT 'draft' COMMENT '状态',
|
||||
is_pinned BOOLEAN DEFAULT FALSE COMMENT '是否置顶',
|
||||
publish_time TIMESTAMP NULL COMMENT '发布时间',
|
||||
expire_time TIMESTAMP NULL COMMENT '过期时间',
|
||||
created_by INT NOT NULL COMMENT '创建者ID',
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
FOREIGN KEY (created_by) REFERENCES users(id) ON DELETE CASCADE,
|
||||
INDEX idx_status (status),
|
||||
INDEX idx_type (type),
|
||||
INDEX idx_publish_time (publish_time),
|
||||
INDEX idx_created_at (created_at)
|
||||
) COMMENT='通知公告表'
|
||||
`);
|
||||
|
||||
// 用户公告阅读状态表
|
||||
await getDB().execute(`
|
||||
CREATE TABLE IF NOT EXISTS user_announcement_reads (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
user_id INT NOT NULL COMMENT '用户ID',
|
||||
announcement_id INT NOT NULL COMMENT '公告ID',
|
||||
is_read BOOLEAN DEFAULT FALSE COMMENT '是否已读',
|
||||
read_at TIMESTAMP NULL COMMENT '阅读时间',
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
UNIQUE KEY unique_user_announcement (user_id, announcement_id),
|
||||
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (announcement_id) REFERENCES announcements(id) ON DELETE CASCADE,
|
||||
INDEX idx_user_id (user_id),
|
||||
INDEX idx_announcement_id (announcement_id),
|
||||
INDEX idx_is_read (is_read)
|
||||
) COMMENT='用户公告阅读状态表'
|
||||
`);}
|
||||
|
||||
/**
|
||||
* 添加缺失的字段(处理数据库升级)
|
||||
@@ -862,13 +903,13 @@ async function createDefaultData() {
|
||||
}
|
||||
|
||||
// 初始化浙江省区域数据
|
||||
await initializeZhejiangRegions();
|
||||
// await initializeZhejiangRegions();
|
||||
|
||||
// 初始化默认地址标签
|
||||
await initializeDefaultAddressLabels();
|
||||
// await initializeDefaultAddressLabels();
|
||||
|
||||
// 初始化全国省市区数据
|
||||
await initializeChinaRegions();
|
||||
// await initializeChinaRegions();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user