-- 农贸市场撮合日志表
CREATE TABLE `kku_mex_match_logs` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '撮合日志ID，主键',
  `match_type` enum('USER_BUY','USER_SELL') NOT NULL COMMENT '撮合类型：USER_BUY用户买入撮合，USER_SELL用户卖出撮合',
  `item_id` int(11) NOT NULL COMMENT '商品ID，关联物品表',
  `batch_size` int(11) NOT NULL DEFAULT 100 COMMENT '批处理大小',
  `matched_orders` int(11) NOT NULL DEFAULT 0 COMMENT '成功撮合的订单数',
  `total_amount` decimal(20,5) NOT NULL DEFAULT 0.00000 COMMENT '撮合总金额',
  `success` tinyint(1) NOT NULL DEFAULT 0 COMMENT '撮合是否成功：0失败，1成功',
  `message` text COMMENT '撮合结果消息',
  `execution_time_ms` int(11) DEFAULT NULL COMMENT '执行时间（毫秒）',
  `error_message` text COMMENT '错误消息（失败时记录）',
  `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '撮合时间',
  PRIMARY KEY (`id`),
  KEY `idx_match_type` (`match_type`),
  KEY `idx_item_id` (`item_id`),
  KEY `idx_created_at` (`created_at`),
  KEY `idx_success` (`success`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='农贸市场撮合日志表';
