-- 抖店订单表
CREATE TABLE IF NOT EXISTS douyin_orders (
  id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  shop_order_id VARCHAR(64) NOT NULL COMMENT '抖店订单号',
  order_status INT NOT NULL DEFAULT 0 COMMENT '订单状态: 5=已完成',
  douyin_user_id VARCHAR(64) NOT NULL COMMENT '抖店用户ID',
  local_user_id BIGINT DEFAULT 0 COMMENT '匹配到的本地用户ID',
  actual_receive_amount BIGINT DEFAULT 0 COMMENT '实收金额(分)',
  pay_type_desc VARCHAR(64) DEFAULT '' COMMENT '支付方式描述',
  remark VARCHAR(512) DEFAULT '' COMMENT '备注',
  user_nickname VARCHAR(128) DEFAULT '' COMMENT '抖音昵称',
  raw_data JSON COMMENT '原始响应数据',
  created_at DATETIME(3) DEFAULT CURRENT_TIMESTAMP(3),
  updated_at DATETIME(3) DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3),
  UNIQUE KEY uk_shop_order_id (shop_order_id),
  INDEX idx_local_user_id (local_user_id),
  INDEX idx_douyin_user_id (douyin_user_id),
  INDEX idx_order_status (order_status)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='抖店订单表';
