-- 确保 douyin_orders 表包含所需字段(解决产品ID窜台问题) -- 1. 添加产品ID字段(如果不存在) ALTER TABLE douyin_orders ADD COLUMN IF NOT EXISTS douyin_product_id VARCHAR(64) DEFAULT '' COMMENT '关联商品ID' AFTER shop_order_id; -- 2. 添加商品数量字段(如果不存在) ALTER TABLE douyin_orders ADD COLUMN IF NOT EXISTS product_count INT NOT NULL DEFAULT 1 COMMENT '商品数量' AFTER order_status; -- 3. 添加已发放次数字段(如果不存在) ALTER TABLE douyin_orders ADD COLUMN IF NOT EXISTS reward_granted INT NOT NULL DEFAULT 0 COMMENT '已发放次数' AFTER product_count; -- 4. 添加索引(提升查询性能) CREATE INDEX IF NOT EXISTS idx_douyin_product_id ON douyin_orders(douyin_product_id);