Add supplier_uuid to offer workflow for graph sync
All checks were successful
Build Docker Image / build (push) Successful in 1m27s

This commit is contained in:
Ruslan Bakiev
2026-01-16 10:50:16 +07:00
parent 3626a6dc42
commit ff752a4d37
2 changed files with 18 additions and 0 deletions

View File

@@ -32,6 +32,7 @@ def start_offer_workflow(
*,
offer_uuid: str,
team_uuid: str,
supplier_uuid: str | None = None,
product_uuid: str,
product_name: str,
category_name: str | None = None,
@@ -53,6 +54,7 @@ def start_offer_workflow(
payload = {
"offer_uuid": offer_uuid,
"team_uuid": team_uuid,
"supplier_uuid": supplier_uuid,
"product_uuid": product_uuid,
"product_name": product_name,
"category_name": category_name,

View File

@@ -9,10 +9,21 @@ from decimal import Decimal
from typing import Optional, Tuple
from exchange.temporal_client import start_offer_workflow
from suppliers.models import SupplierProfile
logger = logging.getLogger(__name__)
def get_supplier_uuid(team_uuid: str) -> Optional[str]:
"""Get supplier public UUID from team_uuid."""
try:
supplier = SupplierProfile.objects.get(team_uuid=team_uuid)
return supplier.uuid
except SupplierProfile.DoesNotExist:
logger.warning(f"SupplierProfile not found for team_uuid: {team_uuid}")
return None
@dataclass
class OfferData:
"""Данные для создания оффера"""
@@ -45,10 +56,12 @@ class OfferService:
Tuple[offer_uuid, workflow_id, run_id]
"""
offer_uuid = str(uuid.uuid4())
supplier_uuid = get_supplier_uuid(data.team_uuid)
workflow_id, run_id = start_offer_workflow(
offer_uuid=offer_uuid,
team_uuid=data.team_uuid,
supplier_uuid=supplier_uuid,
product_uuid=data.product_uuid,
product_name=data.product_name,
category_name=data.category_name,
@@ -80,9 +93,12 @@ class OfferService:
Returns:
Tuple[workflow_id, run_id]
"""
supplier_uuid = get_supplier_uuid(offer.team_uuid)
workflow_id, run_id = start_offer_workflow(
offer_uuid=offer.uuid,
team_uuid=offer.team_uuid,
supplier_uuid=supplier_uuid,
product_uuid=offer.product_uuid,
product_name=offer.product_name,
category_name=offer.category_name,