mex_orders.sql 2.2 KB

1234567891011121314151617181920212223242526272829303132
  1. -- ******************************************************************
  2. -- 表 kku_mex_orders 的创建SQL
  3. -- 对应的Model: App\Module\Mex\Models\MexOrder
  4. -- 警告: 此文件由系统自动生成,禁止修改!
  5. -- ******************************************************************
  6. CREATE TABLE `kku_mex_orders` (
  7. `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '订单ID,主键',
  8. `user_id` bigint NOT NULL COMMENT '用户ID',
  9. `item_id` int NOT NULL COMMENT '商品ID,关联物品表',
  10. `currency_type` int NOT NULL DEFAULT '2' COMMENT '币种类型,关联FUND_CURRENCY_TYPE枚举,默认2为钻石',
  11. `order_type` enum('BUY','SELL') COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '订单类型:BUY买入,SELL卖出',
  12. `quantity` int NOT NULL COMMENT '订单数量',
  13. `price` decimal(15,5) NOT NULL COMMENT '订单价格,支持5位小数',
  14. `total_amount` decimal(20,5) NOT NULL COMMENT '订单总金额',
  15. `status` enum('PENDING','COMPLETED','CANCELLED','FAILED') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'PENDING' COMMENT '订单状态:PENDING等待,COMPLETED完成,CANCELLED取消,FAILED失败',
  16. `frozen_amount` decimal(20,5) DEFAULT '0.00000' COMMENT '冻结金额(买单使用)',
  17. `completed_quantity` int DEFAULT '0' COMMENT '已成交数量',
  18. `completed_amount` decimal(20,5) DEFAULT '0.00000' COMMENT '已成交金额',
  19. `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  20. `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  21. `completed_at` timestamp NULL DEFAULT NULL COMMENT '完成时间',
  22. `failed_reason` text COLLATE utf8mb4_unicode_ci COMMENT '失败原因',
  23. PRIMARY KEY (`id`) USING BTREE,
  24. KEY `idx_user_id` (`user_id`) USING BTREE,
  25. KEY `idx_item_id` (`item_id`) USING BTREE,
  26. KEY `idx_order_type` (`order_type`) USING BTREE,
  27. KEY `idx_status` (`status`) USING BTREE,
  28. KEY `idx_created_at` (`created_at`) USING BTREE,
  29. KEY `idx_status_price_created` (`status`,`price`,`created_at`) USING BTREE COMMENT '撮合排序复合索引',
  30. KEY `idx_currency_type` (`currency_type`) USING BTREE COMMENT '币种类型索引'
  31. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='农贸市场订单表';