{
  "schema_version": 2,
  "diagram_type": "workflow",
  "meta": {
    "title": "Hủy đơn và hoàn tiền — thiết kế đề xuất",
    "locale": "vi",
    "translations": {
      "page.title": "Sơ đồ {title}",
      "legend.title": "Chú giải",
      "viewer.theme.dark": "Tối",
      "viewer.theme.light": "Sáng",
      "viewer.motion.live": "Chuyển động",
      "viewer.motion.still": "Tĩnh",
      "viewer.present.present": "Trình chiếu",
      "viewer.present.exit.label": "Thoát",
      "legend.sequence.emphasis": "Luồng chính",
      "legend.sequence.return": "Phản hồi",
      "legend.sequence.security": "Kiểm soát",
      "legend.sequence.dashed": "Bất đồng bộ",
      "legend.sequence.default": "Thông điệp",
      "legend.workflow.frontend": "Giao diện",
      "legend.workflow.backend": "Xử lý nghiệp vụ",
      "legend.workflow.security": "Kiểm soát",
      "legend.workflow.messagebus": "Tác vụ",
      "legend.workflow.database": "Dữ liệu",
      "legend.workflow.cloud": "Dịch vụ",
      "legend.workflow.external": "Bên ngoài",
      "legend.dataflow.emphasis": "Dữ liệu chính",
      "legend.dataflow.security": "Quyền / dữ liệu nhạy cảm",
      "legend.dataflow.dashed": "Nhập theo đợt",
      "legend.dataflow.database": "Lưu trữ",
      "legend.dataflow.default": "Luồng dữ liệu"
    },
    "output": "docs/ssa-miniapp/archify/refund.html",
    "quality_profile": "showcase"
  },
  "lanes": [
    {
      "id": "cancel",
      "label": "Xác minh khoản thu và hủy chưa thu"
    },
    {
      "id": "request",
      "label": "Yêu cầu và quyết định"
    },
    {
      "id": "payment",
      "label": "Thực hiện hoàn tiền"
    },
    {
      "id": "exception",
      "label": "Ngoại lệ và xác minh",
      "variant": "exception"
    }
  ],
  "mainPath": [
    "request",
    "check",
    "approve",
    "send",
    "verify",
    "record"
  ],
  "nodes": [
    {
      "id": "request",
      "lane": "request",
      "col": 0,
      "type": "frontend",
      "label": "Yêu cầu hủy/hoàn",
      "sublabel": "Phụ huynh hoặc tài chính"
    },
    {
      "id": "check",
      "lane": "request",
      "col": 1,
      "type": "backend",
      "label": "Kiểm quyền + tiền",
      "sublabel": "Điều kiện hủy / số còn hoàn"
    },
    {
      "id": "approve",
      "lane": "request",
      "col": 2,
      "type": "security",
      "label": "Người khác duyệt",
      "sublabel": "Maker khác checker"
    },
    {
      "id": "send",
      "lane": "payment",
      "col": 2,
      "type": "backend",
      "label": "Gửi yêu cầu hoàn",
      "sublabel": "Cùng idempotency key"
    },
    {
      "id": "verify",
      "lane": "payment",
      "col": 3,
      "type": "security",
      "label": "Xác minh kết quả",
      "sublabel": "Provider + số tiền"
    },
    {
      "id": "record",
      "lane": "payment",
      "col": 4,
      "type": "database",
      "label": "Ghi hoàn + outbox",
      "sublabel": "Atomic + audit"
    },
    {
      "id": "notify",
      "lane": "payment",
      "col": 5,
      "type": "frontend",
      "label": "Cập nhật phụ huynh",
      "sublabel": "Trạng thái hoàn thực tế"
    },
    {
      "id": "deny",
      "lane": "exception",
      "col": 1,
      "type": "external",
      "label": "Từ chối / bổ sung",
      "sublabel": "Có lý do và lịch sử"
    },
    {
      "id": "unknown",
      "lane": "exception",
      "col": 3,
      "type": "backend",
      "label": "Tra kết quả hoàn",
      "sublabel": "Refund pending / unknown"
    },
    {
      "id": "failed",
      "lane": "exception",
      "col": 4,
      "type": "external",
      "label": "Xử lý lỗi đã rõ",
      "sublabel": "Owner và evidence"
    },
    {
      "id": "resolve-payment",
      "lane": "cancel",
      "col": 0,
      "type": "backend",
      "label": "Tra khoản thu",
      "sublabel": "Chưa rõ: chưa hủy/hoàn"
    },
    {
      "id": "cancel-unpaid",
      "lane": "cancel",
      "col": 2,
      "type": "database",
      "label": "Hủy đơn chưa thu",
      "sublabel": "Nhả giữ hàng; audit/outbox"
    },
    {
      "id": "cancel-notify",
      "lane": "cancel",
      "col": 3,
      "type": "frontend",
      "label": "Thông báo đã hủy",
      "sublabel": "Không gọi refund provider"
    }
  ],
  "edges": [
    {
      "id": "e1",
      "from": "request",
      "to": "check",
      "variant": "emphasis"
    },
    {
      "id": "e2",
      "from": "check",
      "to": "approve",
      "variant": "emphasis",
      "label": "Đã thu; hợp lệ"
    },
    {
      "id": "e3",
      "from": "check",
      "to": "deny",
      "variant": "security",
      "label": "Không đạt"
    },
    {
      "id": "e4",
      "from": "approve",
      "to": "send",
      "variant": "security",
      "label": "Đã duyệt"
    },
    {
      "id": "e5",
      "from": "approve",
      "to": "deny",
      "variant": "security",
      "label": "Từ chối"
    },
    {
      "id": "e6",
      "from": "send",
      "to": "verify",
      "variant": "emphasis"
    },
    {
      "id": "e7",
      "from": "verify",
      "to": "record",
      "variant": "emphasis",
      "label": "Thành công"
    },
    {
      "id": "e8",
      "from": "record",
      "to": "notify",
      "variant": "emphasis"
    },
    {
      "id": "e9",
      "from": "verify",
      "to": "unknown",
      "variant": "default",
      "label": "Chưa rõ"
    },
    {
      "id": "e10",
      "from": "verify",
      "to": "failed",
      "variant": "default",
      "label": "Thất bại"
    },
    {
      "id": "e11",
      "from": "unknown",
      "to": "verify",
      "variant": "default",
      "label": "Đã tra",
      "role": "return"
    },
    {
      "id": "e12",
      "from": "failed",
      "to": "send",
      "variant": "default",
      "label": "Được phép retry",
      "role": "return",
      "route": "bottom-channel",
      "fromSide": "bottom",
      "toSide": "bottom"
    },
    {
      "id": "payment-unknown",
      "from": "check",
      "to": "resolve-payment",
      "label": "Pending / unknown",
      "variant": "default",
      "role": "branch"
    },
    {
      "id": "payment-resolved",
      "from": "resolve-payment",
      "to": "check",
      "label": "Đã xác minh",
      "variant": "default",
      "role": "return"
    },
    {
      "id": "cancel-confirmed-unpaid",
      "from": "check",
      "to": "cancel-unpaid",
      "label": "Chưa thu; hết pending",
      "variant": "security",
      "role": "branch"
    },
    {
      "id": "cancel-inbox",
      "from": "cancel-unpaid",
      "to": "cancel-notify",
      "label": "Sau commit",
      "variant": "emphasis"
    }
  ],
  "cards": [
    {
      "dot": "slate",
      "title": "Nguồn và phạm vi",
      "items": [
        "FEATURES.md §7.3–7.6; PLAN FR-17/T20. Quy trình đề xuất, chưa có tích hợp hoàn tiền.",
        "Hủy đơn, kết quả hoàn và tồn kho là các trạng thái riêng. Chưa thu: nhả giữ hàng; hàng đã giao chỉ nhập lại tồn sau kiểm tra thực tế."
      ]
    },
    {
      "dot": "rose",
      "title": "Kiểm soát tài chính",
      "items": [
        "Người lập khác người duyệt; Sale không tự đánh dấu đã trả tiền hoặc đã hoàn.",
        "Hoàn một phần/tổng không vượt số thu còn hoàn được; audit actor, reason, evidence, before/after.",
        "Nhánh chưa thu chỉ chạy sau xác minh không còn attempt pending/unknown và điều kiện hủy hợp lệ. Chưa rõ kết quả thu phải tra provider rồi quyết định lại."
      ]
    },
    {
      "dot": "amber",
      "title": "Không hoàn lặp",
      "items": [
        "Một yêu cầu hoàn dùng một idempotency key xuyên suốt.",
        "Timeout/unknown phải tra provider trước retry; không tạo yêu cầu hoàn mới để né lỗi."
      ]
    }
  ]
}
