-- =============================================================================
-- 定时任务：已发货超时自动确认收货
-- 调用：orderAutoConfirmReceiveJob.autoConfirmReceive
-- 天数：每次执行读取 biz_mall_config.auto_confirm_days（默认 7 自然日）
-- 前置：已执行 sql/biz_mall_config.sql；应用已部署 OrderAutoConfirmReceiveJob
-- 说明：幂等插入；status=0 启用；部署后重启应用或于「定时任务」点执行一次生效
-- =============================================================================

INSERT INTO sys_job (
    job_name,
    job_group,
    invoke_target,
    cron_expression,
    misfire_policy,
    concurrent,
    status,
    create_by,
    create_time,
    remark
)
SELECT
    '订单自动确认收货',
    'DEFAULT',
    'orderAutoConfirmReceiveJob.autoConfirmReceive',
    '0 0 1 * * ?',
    '3',
    '1',
    '0',
    'admin',
    sysdate(),
    '已发货订单按商城设置 auto_confirm_days 自然日自动确认收货；与买家手动确认等价'
WHERE NOT EXISTS (
    SELECT 1 FROM sys_job WHERE invoke_target = 'orderAutoConfirmReceiveJob.autoConfirmReceive'
);
