增加微信支付,商城逻辑,公告
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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
24
config/wechatPay.js
Normal file
24
config/wechatPay.js
Normal file
@@ -0,0 +1,24 @@
|
||||
// 微信支付配置
|
||||
module.exports = {
|
||||
// 微信支付配置
|
||||
wechatPay: {
|
||||
appId: process.env.WECHAT_APP_ID || '', // 微信公众号AppID
|
||||
mchId: process.env.WECHAT_MCH_ID || '', // 商户号
|
||||
apiKey: process.env.WECHAT_API_KEY || '', // API密钥
|
||||
apiV3Key: process.env.WECHAT_API_V3_KEY || '', // APIv3密钥
|
||||
notifyUrl: process.env.WECHAT_NOTIFY_URL || 'https://your-domain.com/api/wechat/notify', // 支付回调地址
|
||||
|
||||
// 证书路径(生产环境需要配置)
|
||||
certPath: process.env.WECHAT_CERT_PATH || '',
|
||||
keyPath: process.env.WECHAT_KEY_PATH || '',
|
||||
|
||||
// 支付相关配置
|
||||
tradeType: {
|
||||
h5: 'MWEB', // H5支付
|
||||
jsapi: 'JSAPI' // 公众号支付
|
||||
},
|
||||
|
||||
// 注册费用配置(单位:分)
|
||||
registrationFee: 100 // 1元注册费
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user