OMSFlash Sale

Lấy Flash Sale theo sản phẩm

Tìm các chương trình Flash Sale đang active có chứa một sản phẩm cụ thể.

Endpoint

GET /site/flashsales/by-product/{productId}

Headers

KeyValueBắt buộcMô tả
SiteTenantId{tenant_id}CóID của công ty/tenant.

Path Parameters

TênKiểuBắt buộcMô tả
productIdintegerCóID sản phẩm cần tra cứu.

Workflow & Logic

API này tìm tất cả chương trình Flash Sale đang active mà có chứa sản phẩm được chỉ định. Phù hợp để hiển thị badge/thông tin Flash Sale trên trang chi tiết sản phẩm hoặc listing.

Quy trình xử lý

  1. Tìm Flash Sale Detail theo product_id

    • Lấy Flash Sale Detail (tối đa 100) của shop hiện tại có product_id khớp và status = 1 (ENABLE).
  2. Nhóm theo flash_sale_id

    • Gom danh sách detail theo từng flash sale cha.
  3. Lọc Flash Sale đang active

    • Chỉ trả về các Flash Sale có:

      • status = 3 (ENABLE).
      • date_started <= now (đã bắt đầu).
      • date_ended >= now (chưa kết thúc).
  4. Trả kết quả

    • Mỗi Flash Sale kèm theo details[] chỉ chứa các item matching product đó (không phải toàn bộ details).

Response Schema

HTTP 200 - Thành công

FieldKiểuMô tả
totalintegerTổng số Flash Sale matching.
itemsarrayDanh sách Flash Sale (kèm details[] đã lọc theo product). Xem thêm Flash Sale Object.

Ví dụ Response

{
  "total": 1,
  "items": [
    {
      "id": 5,
      "company_id": 1,
      "creator_id": 10,
      "type": 1,
      "name": "Flash Sale T3/2026",
      "title": "Siêu Sale Tháng 3",
      "status": 3,
      "date_started": 1741564800,
      "date_ended": 1741651200,
      "date_created": 1741500000,
      "date_modified": 1741500000,
      "details": [
        {
          "id": 20,
          "flash_sale_id": 5,
          "company_id": 1,
          "creator_id": 10,
          "product_id": 150,
          "product_variant_id": 301,
          "pricing_mode": 3,
          "uom_unit_price": 99000,
          "min_uom_quantity": 1,
          "max_uom_quantity": 5,
          "max_per_customer": 2,
          "quota_total_quantity": 100,
          "description": "",
          "display_order": 1,
          "status": 1,
          "date_created": 1741500000,
          "date_modified": 1741500000
        }
      ]
    }
  ]
}

Khi không tìm thấy

Nếu productId <= 0 hoặc không có Flash Sale nào matching:

{
  "total": 0,
  "items": []
}

On this page