mex_orders.sql 2.5 KB

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