Chuyển tới nội dung chính

productSyncImportWorkflow

Luồng nghiệp vụ xử lý đồng bộ và import sản phẩm từ các nền tảng thương mại điện tử tích hợp (Pancake, KiotViet, Sapo) vào hệ thống OMS.


Steps

acquireLockStep
verifyBusinessTokenStep
⚡ validateCatalogRules
fetchPlatformProductsStep
normalizeProductPayloadStep
resolveCategoriesStep
createLineItemsStep
updateLineItemsStep
ℹ️ confirmWarehouseStock
executeOmsImportStep
emitEventStep
releaseLockStep
⚡ Workflow hook
ℹ️ Step conditioned by when

Example

import { productSyncImportWorkflow } from "@merchant/oms/core-flows"

// Hook mở rộng kiểm tra quy tắc danh mục custom cho Merchant
productSyncImportWorkflow.hooks.validateCatalogRules(
async ({ products, business_id }, { container }) => {
// TODO: Bổ sung logic kiểm tra mã danh mục tùy biến
}
)

Input

Dưới đây là schema dữ liệu đầu vào chi tiết cho productSyncImportWorkflow:

Thuộc tínhKiểu dữ liệuBắt buộcMô tả
commerce_platformstringBắt buộcNền tảng tích hợp nguồn: PANCAKE, KIOTVIET, SAPO.
business_idstringBắt buộcĐịnh danh duy nhất của doanh nghiệp Merchant trong hệ thống.
overwritebooleanTùy chọnCó ghi đè sản phẩm nếu trùng khớp integration_id hay không. Mặc định true.
is_activebooleanTùy chọnTrạng thái kích hoạt sản phẩm sau khi đồng bộ thành công. Mặc định true.
additional_dataRecord<string, unknown>Tùy chọnDữ liệu mở rộng truyền qua HTTP request cho các workflow hooks.

Emitted Events

Danh sách sự kiện hệ thống được phát ra (emit) sau khi quy trình đồng bộ hoàn tất:

EventMô tảPayload Structure
product.syncedPhát ra khi một batch sản phẩm được đồng bộ thành công vào cơ sở dữ liệu OMS.
{
"business_id": "biz_891241",
"platform": "PANCAKE",
"synced_count": 45,
"timestamp": 1785862800
}
inventory.updatedPhát ra khi số lượng tồn kho biến thể sản phẩm được cập nhật theo số liệu sàn.
{
"product_id": "prod_99182",
"variant_sku": "SKU-XL-RED",
"new_stock": 150
}
[ON THIS PAGE]
[SHORTCUTS]