数据库设计 ```sql -- 优惠券表 CREATE TABLE coupons ( id INT PRIMARY KEY AUTO_INCREMENT, coupon_code VARCHAR(32) UNIQUE NOT NULL, type ENUM(scratch, wheel, task, puzzle) NOT NULL, value DECIMAL(10,2) NOT NULL, min_order DECIMAL(10,2) DEFAULT 0, expiry_date DATETIME NOT NULL, is_active BOOLEAN DEFAULT TRUE, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP );
-- 用户优惠券表 CREATE TABLE user_coupons ( id INT PRIMARY KEY AUTO_INCREMENT, user_id INT NOT NULL, coupon_id INT NOT NULL, is_used BOOLEAN DEFAULT FALSE, used_at DATETIME NULL, FOREIGN KEY (coupon_id) REFERENCES coupons(id), UNIQUE KEY (user_id, coupon_id) );
-- 互动活动表 CREATE TABLE interactive_activities ( id INT PRIMARY KEY AUTO_INCREMENT, activity_name VARCHAR(100) NOT NULL, type ENUM(scratch, wheel, task, puzzle) NOT NULL, config JSON NOT NULL, -- 存储活动特定配置 start_time DATETIME NOT NULL, end_time DATETIME NOT NULL, is_active BOOLEAN DEFAULT TRUE );
-- 用户活动参与记录 CREATE TABLE user_activity_logs ( id INT PRIMARY KEY AUTO_INCREMENT, user_id INT NOT NULL, activity_id INT NOT NULL, result JSON NOT NULL, -- 存储互动结果和获得的优惠券 created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY (activity_id) REFERENCES interactive_activities(id) ); ```
API接口设计 ```javascript // 获取可用互动活动列表 GET /api/interactive-activities
// 参与互动活动 POST /api/interactive-activities/:id/participate { "userId": 123 }
// 获取用户优惠券列表 GET /api/user/coupons
// 使用优惠券 POST /api/coupons/:code/use { "orderId": 456 } ```
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 12288 bytes) in /www/wwwroot/www.sjwxsc.com/config/function.php on line 274