-- ******************************************************************
-- 表 kku_mex_admin_operations 的创建SQL
-- 对应的Model: App\Module\Mex\Models\MexAdminOperation
-- 警告: 此文件由系统自动生成，禁止修改！
-- ******************************************************************

CREATE TABLE `kku_mex_admin_operations` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '操作记录ID，主键',
  `admin_user_id` bigint NOT NULL COMMENT '管理员用户ID',
  `operation_type` enum('INJECT','RECYCLE') COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '操作类型：INJECT注入，RECYCLE回收',
  `item_id` int NOT NULL COMMENT '商品ID，关联物品表',
  `quantity` int NOT NULL COMMENT '操作数量',
  `price` decimal(15,5) NOT NULL COMMENT '操作价格',
  `total_amount` decimal(20,5) NOT NULL COMMENT '操作总金额',
  `before_warehouse_quantity` int NOT NULL COMMENT '操作前仓库数量',
  `after_warehouse_quantity` int NOT NULL COMMENT '操作后仓库数量',
  `transaction_id` bigint DEFAULT NULL COMMENT '关联的成交记录ID',
  `remark` varchar(500) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '操作备注',
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '操作时间',
  PRIMARY KEY (`id`) USING BTREE,
  KEY `idx_admin_user_id` (`admin_user_id`) USING BTREE,
  KEY `idx_operation_type` (`operation_type`) USING BTREE,
  KEY `idx_item_id` (`item_id`) USING BTREE,
  KEY `idx_transaction_id` (`transaction_id`) USING BTREE,
  KEY `idx_created_at` (`created_at`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='农贸市场管理员调控记录表';
