-- +goose Up

CREATE TABLE admin_pickup_financial_adjustments (
  id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
  pickup_id BIGINT UNSIGNED NOT NULL COMMENT '关联提号ID',
  profit_delta_cent BIGINT NOT NULL DEFAULT 0 COMMENT '利润调整差额(分，可正负)',
  settle_delta_cent BIGINT NOT NULL DEFAULT 0 COMMENT '打款调整差额(分，可正负)',
  settlement_mode VARCHAR(32) NOT NULL COMMENT '调整时结算模式快照',
  status VARCHAR(24) NOT NULL COMMENT '打款调整状态: settled已处理/pending待付款/recovery_pending待追回',
  reason VARCHAR(255) NOT NULL COMMENT '调整原因',
  created_by BIGINT UNSIGNED NOT NULL COMMENT '创建管理员ID',
  settled_by BIGINT UNSIGNED NULL COMMENT '确认付款或追回的管理员ID',
  settled_at DATETIME NULL COMMENT '确认付款或追回时间',
  settlement_remark VARCHAR(255) NOT NULL DEFAULT '' COMMENT '确认备注',
  created_at DATETIME NOT NULL,
  PRIMARY KEY (id),
  KEY idx_pickup_financial_adjustment_pickup (pickup_id, created_at),
  KEY idx_pickup_financial_adjustment_status (status, created_at)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='管理员提号完成后的财务调整流水';

-- +goose Down

DROP TABLE IF EXISTS admin_pickup_financial_adjustments;
