CREATE TABLE `customer_order` (
    `id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `order_no` VARCHAR(64) NOT NULL UNIQUE COMMENT '订单号（全局唯一）',
    `product_id` BIGINT NOT NULL COMMENT '商品ID',
    `product_name` VARCHAR(500) NOT NULL COMMENT '商品名称',
    `sku_id` BIGINT NOT NULL COMMENT 'SKU ID',
    `sku_name` VARCHAR(500) NOT NULL COMMENT 'SKU名称/描述',
    `quantity` INT NOT NULL COMMENT '购买数量',
    `unit_price` DECIMAL(10, 2) NOT NULL COMMENT '单价',
    `total_amount` DECIMAL(10, 2) NOT NULL COMMENT '订单总金额',
    `currency` VARCHAR(3) NOT NULL COMMENT '货币代码',
    `status` VARCHAR(20) NOT NULL DEFAULT 'PENDING' COMMENT '订单状态：PENDING-待支付，PAID-已支付，SHIPPED-已发货，COMPLETED-已完成，CANCELLED-已取消',
    
    -- 客户信息
    `customer_name` VARCHAR(100) NOT NULL COMMENT '客户姓名',
    `customer_phone` VARCHAR(20) NOT NULL COMMENT '客户电话',
    `customer_email` VARCHAR(100) COMMENT '客户邮箱',
    
    -- 收货地址
    `shipping_name` VARCHAR(100) NOT NULL COMMENT '收货人姓名',
    `shipping_phone` VARCHAR(20) NOT NULL COMMENT '收货人电话',
    `shipping_country` VARCHAR(50) NOT NULL COMMENT '收货国家',
    `shipping_state` VARCHAR(50) COMMENT '收货州/省',
    `shipping_city` VARCHAR(50) NOT NULL COMMENT '收货城市',
    `shipping_street` VARCHAR(200) NOT NULL COMMENT '收货街道地址',
    `shipping_postcode` VARCHAR(20) COMMENT '收货邮编',
    
    -- 支付信息
    `payment_order_id` BIGINT COMMENT '关联的支付订单ID',
    `payment_status` VARCHAR(20) DEFAULT 'UNPAID' COMMENT '支付状态：UNPAID-未支付，PAID-已支付，FAILED-支付失败',
    
    -- 备注
    `remark` VARCHAR(500) COMMENT '订单备注',
    
    `create_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `update_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    PRIMARY KEY (`id`),
    KEY `idx_order_no` (`order_no`),
    KEY `idx_product_id` (`product_id`),
    KEY `idx_status` (`status`),
    KEY `idx_create_time` (`create_time`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='客户订单表';

