-- ============================================
-- 快速更新：2026-01-16补录数据的领取时间为2025-11-16
-- 执行前请先确认数据范围
-- ============================================

-- 1. 先查询确认要更新的数据
SELECT 
    F_Id,
    F_UsageBatchId,
    F_ApplicationStoreId,
    F_ApplicationTime,
    F_ReceiveTime as CurrentReceiveTime,
    '2025-11-16 00:00:00' as NewReceiveTime,
    F_IsReceived,
    F_ApprovalStatus
FROM lq_inventory_usage_application
WHERE (
    DATE(F_ApplicationTime) = '2026-01-16'  -- 今天创建的申请
    OR DATE(F_ReceiveTime) = '2026-01-16'   -- 今天标记为已领取
    OR DATE(F_UpdateTime) = '2026-01-16'    -- 今天更新的记录
)
AND F_IsEffective = 1
AND F_IsReceived = 1
AND F_ReceiveTime IS NOT NULL
ORDER BY F_UpdateTime DESC;

-- 2. 确认数据后，执行更新（取消下面的注释）
-- UPDATE lq_inventory_usage_application
-- SET F_ReceiveTime = '2025-11-16 00:00:00',
--     F_UpdateTime = NOW(),
--     F_UpdateUser = 'admin'
-- WHERE (
--     DATE(F_ApplicationTime) = '2026-01-16'
--     OR DATE(F_ReceiveTime) = '2026-01-16'
--     OR DATE(F_UpdateTime) = '2026-01-16'
-- )
-- AND F_IsEffective = 1
-- AND F_IsReceived = 1
-- AND F_ReceiveTime IS NOT NULL;

-- 3. 验证更新结果
-- SELECT 
--     F_Id,
--     F_UsageBatchId,
--     F_ApplicationStoreId,
--     F_ApplicationTime,
--     F_ReceiveTime,
--     F_IsReceived,
--     F_ApprovalStatus,
--     F_UpdateTime
-- FROM lq_inventory_usage_application
-- WHERE (
--     DATE(F_ApplicationTime) = '2026-01-16'
--     OR DATE(F_UpdateTime) = '2026-01-16'
-- )
-- AND F_IsEffective = 1
-- AND F_IsReceived = 1
-- AND DATE(F_ReceiveTime) = '2025-11-16'
-- ORDER BY F_UpdateTime DESC;
