diff --git a/exchange/temporal_client.py b/exchange/temporal_client.py index ea0c351..90b6f3c 100644 --- a/exchange/temporal_client.py +++ b/exchange/temporal_client.py @@ -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, diff --git a/offers/services.py b/offers/services.py index 3a74dec..4f186f2 100644 --- a/offers/services.py +++ b/offers/services.py @@ -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,