-- ============================================================
-- 订单数据迁移脚本 - orders 表
-- Feature: database-migration, Property 2: 数据记录数一致性
-- Feature: database-migration, Property 4: 财务数据一致性
-- Validates: Requirements 3.5, 11.1, 11.3
-- ============================================================
-- 源表: MySQL order (15 条记录)
-- 目标表: SQL Server orders
-- ============================================================

USE honey_box;
GO

-- 清空目标表（如果需要重新迁移）
-- TRUNCATE TABLE orders;
-- GO

SET IDENTITY_INSERT orders ON;
GO

-- 迁移订单数据
-- 字段映射: 直接映射，时间戳字段保留原值
-- 支付方式组合字段: use_money, use_integral, use_score, use_coupon, use_money2, use_draw, use_item_card

INSERT INTO orders (
    id, user_id, order_num, order_total, order_zhe_total, price,
    use_money, use_integral, use_score, use_draw, use_item_card, zhe,
    goods_id, num, goods_price, goods_title, goods_imgurl,
    prize_num, prize_card_set, status, addtime, pay_time, pay_type,
    order_type, kd_is, coupon_id, use_coupon, is_mibao, is_shou_zhe,
    zdfh_is, ad_id, click_id, is_flw, zdfh_time, use_money2,
    created_at, updated_at
)
VALUES
(51884, 25488, N'MH_MONH5MP02025121148535510561', 13.80, 13.80, 0.00, 13.80, 0.00, 0.00, 0, 0, 0.00, 1227, 0, 13.80, N'明星阵营翻滚吧', N'https://youdas-1308826010.cos.ap-shanghai.myqcloud.com/topic/20250515/f6f6de16ae10cda7f634d5e7eb65e758.png', 1, NULL, 1, 1765463152, 1765463152, 1, 16, 0, 0, 0.00, 0, 0, 0, 0, 0, 0, 0, 0.00, DATEADD(SECOND, 1765463152, '1970-01-01'), GETDATE()),
(51885, 25488, N'MH_MONH5MP02025121151991025353', 13.80, 13.80, 0.00, 13.80, 0.00, 0.00, 0, 0, 0.00, 1227, 0, 13.80, N'明星阵营翻滚吧', N'https://youdas-1308826010.cos.ap-shanghai.myqcloud.com/topic/20250515/f6f6de16ae10cda7f634d5e7eb65e758.png', 1, NULL, 1, 1765463907, 1765463907, 1, 16, 0, 0, 0.00, 0, 0, 0, 0, 0, 0, 0, 0.00, DATEADD(SECOND, 1765463907, '1970-01-01'), GETDATE()),
(51886, 24904, N'MH_MONYDMP02025122899975610230', 31.50, 31.50, 0.00, 31.50, 0.00, 0.00, 0, 0, 0.00, 1214, 0, 10.50, N'迪士尼520礼物', N'https://youdas-1308826010.cos.ap-shanghai.myqcloud.com/topic/20250507/11c7304bc3da740be443c1316de58900.png', 3, NULL, 1, 1766911628, 1766911628, 1, 2, 0, 0, 0.00, 0, 0, 0, 0, 0, 0, 0, 0.00, DATEADD(SECOND, 1766911628, '1970-01-01'), GETDATE()),
(51887, 24904, N'MH_MONYDMP02025122810098539820', 52.50, 52.50, 0.00, 52.50, 0.00, 0.00, 0, 0, 0.00, 1214, 0, 10.50, N'迪士尼520礼物', N'https://youdas-1308826010.cos.ap-shanghai.myqcloud.com/topic/20250507/11c7304bc3da740be443c1316de58900.png', 5, NULL, 1, 1766911645, 1766911645, 1, 2, 0, 0, 0.00, 0, 0, 0, 0, 0, 0, 0, 0.00, DATEADD(SECOND, 1766911645, '1970-01-01'), GETDATE()),
(51888, 24904, N'MH_MONYDMP02025122853491019423', 31.50, 31.50, 0.00, 31.50, 0.00, 0.00, 0, 0, 0.00, 1214, 0, 10.50, N'迪士尼520礼物', N'https://youdas-1308826010.cos.ap-shanghai.myqcloud.com/topic/20250507/11c7304bc3da740be443c1316de58900.png', 3, NULL, 1, 1766911829, 1766911829, 1, 2, 0, 0, 0.00, 0, 0, 0, 0, 0, 0, 0, 0.00, DATEADD(SECOND, 1766911829, '1970-01-01'), GETDATE()),
(51889, 24904, N'MH_MONYDMP02025122810148495529', 10.50, 10.50, 0.00, 10.50, 0.00, 0.00, 0, 0, 0.00, 1214, 0, 10.50, N'迪士尼520礼物', N'https://youdas-1308826010.cos.ap-shanghai.myqcloud.com/topic/20250507/11c7304bc3da740be443c1316de58900.png', 1, NULL, 1, 1766911870, 1766911870, 1, 2, 0, 0, 0.00, 0, 0, 0, 0, 0, 0, 0, 0.00, DATEADD(SECOND, 1766911870, '1970-01-01'), GETDATE()),
(51890, 24904, N'MH_MONYDMP02025122854535653379', 10.50, 10.50, 0.00, 10.50, 0.00, 0.00, 0, 0, 0.00, 1214, 0, 10.50, N'迪士尼520礼物', N'https://youdas-1308826010.cos.ap-shanghai.myqcloud.com/topic/20250507/11c7304bc3da740be443c1316de58900.png', 1, NULL, 1, 1766911926, 1766911926, 1, 2, 0, 0, 0.00, 0, 0, 0, 0, 0, 0, 0, 0.00, DATEADD(SECOND, 1766911926, '1970-01-01'), GETDATE()),
(51891, 24904, N'MH_MONYDMP02025122810153564833', 10.50, 10.50, 0.00, 10.50, 0.00, 0.00, 0, 0, 0.00, 1214, 0, 10.50, N'迪士尼520礼物', N'https://youdas-1308826010.cos.ap-shanghai.myqcloud.com/topic/20250507/11c7304bc3da740be443c1316de58900.png', 1, NULL, 1, 1766912014, 1766912014, 1, 2, 0, 0, 0.00, 0, 0, 0, 0, 0, 0, 0, 0.00, DATEADD(SECOND, 1766912014, '1970-01-01'), GETDATE()),
(51892, 24904, N'MH_MONYDMP02025122851100569668', 10.50, 10.50, 0.00, 10.50, 0.00, 0.00, 0, 0, 0.00, 1214, 0, 10.50, N'迪士尼520礼物', N'https://youdas-1308826010.cos.ap-shanghai.myqcloud.com/topic/20250507/11c7304bc3da740be443c1316de58900.png', 1, NULL, 1, 1766912035, 1766912035, 1, 2, 0, 0, 0.00, 0, 0, 0, 0, 0, 0, 0, 0.00, DATEADD(SECOND, 1766912035, '1970-01-01'), GETDATE()),
(51893, 24904, N'MH_MONYDMP02025122810049579596', 60.00, 60.00, 0.00, 60.00, 0.00, 0.00, 0, 0, 0.00, 1357, 0, 12.00, N'【宝箱】铜制生肖第一波', N'https://youdas-1308826010.cos.ap-shanghai.myqcloud.com/topic/20250614/b0a4a0e8315341201b8492f24fc157a5.jpg', 5, NULL, 1, 1766916029, 1766916029, 1, 2, 0, 0, 0.00, 0, 0, 0, 0, 0, 0, 0, 0.00, DATEADD(SECOND, 1766916029, '1970-01-01'), GETDATE()),
(51894, 24904, N'MH_MONYDMP02025122850545557591', 60.00, 60.00, 0.00, 60.00, 0.00, 0.00, 0, 0, 0.00, 1357, 0, 12.00, N'【宝箱】铜制生肖第一波', N'https://youdas-1308826010.cos.ap-shanghai.myqcloud.com/topic/20250614/b0a4a0e8315341201b8492f24fc157a5.jpg', 5, NULL, 1, 1766916034, 1766916034, 1, 2, 0, 0, 0.00, 0, 0, 0, 0, 0, 0, 0, 0.00, DATEADD(SECOND, 1766916034, '1970-01-01'), GETDATE()),
(51895, 24904, N'MH_MONYDMP02025122848509954709', 120.00, 120.00, 0.00, 120.00, 0.00, 0.00, 0, 0, 0.00, 1357, 0, 12.00, N'【宝箱】铜制生肖第一波', N'https://youdas-1308826010.cos.ap-shanghai.myqcloud.com/topic/20250614/b0a4a0e8315341201b8492f24fc157a5.jpg', 10, NULL, 1, 1766917936, 1766917936, 1, 2, 0, 0, 0.00, 0, 0, 0, 0, 0, 0, 0, 0.00, DATEADD(SECOND, 1766917936, '1970-01-01'), GETDATE()),
(51896, 24904, N'MH_MONYDMP02025122851499754455', 99.00, 99.00, 0.00, 99.00, 0.00, 0.00, 0, 0, 0.00, 1225, 0, 9.90, N'抓精灵大赛', N'https://youdas-1308826010.cos.ap-shanghai.myqcloud.com/topic/20250515/9487d51e9aebacab0fd5c867c5c7b7b1.jpg', 10, NULL, 1, 1766917955, 1766917955, 1, 16, 0, 0, 0.00, 0, 0, 0, 0, 0, 0, 0, 0.00, DATEADD(SECOND, 1766917955, '1970-01-01'), GETDATE()),
(51897, 24904, N'MH_MONYDMP02025122854575497526', 99.00, 99.00, 0.00, 99.00, 0.00, 0.00, 0, 0, 0.00, 1225, 0, 9.90, N'抓精灵大赛', N'https://youdas-1308826010.cos.ap-shanghai.myqcloud.com/topic/20250515/9487d51e9aebacab0fd5c867c5c7b7b1.jpg', 10, NULL, 1, 1766917958, 1766917958, 1, 16, 0, 0, 0.00, 0, 0, 0, 0, 0, 0, 0, 0.00, DATEADD(SECOND, 1766917958, '1970-01-01'), GETDATE()),
(51898, 24904, N'MH_MONYDMP02025122897515551953', 99.00, 99.00, 0.00, 99.00, 0.00, 0.00, 0, 0, 0.00, 1225, 0, 9.90, N'抓精灵大赛', N'https://youdas-1308826010.cos.ap-shanghai.myqcloud.com/topic/20250515/9487d51e9aebacab0fd5c867c5c7b7b1.jpg', 10, NULL, 1, 1766917962, 1766917962, 1, 16, 0, 0, 0.00, 0, 0, 0, 0, 0, 0, 0, 0.00, DATEADD(SECOND, 1766917962, '1970-01-01'), GETDATE());
GO

SET IDENTITY_INSERT orders OFF;
GO

-- 验证迁移后的记录数
SELECT COUNT(*) AS migrated_count FROM orders;
GO

-- 验证订单金额总和
SELECT SUM(order_total) AS total_order_amount FROM orders;
GO
