Add supplier_uuid to offer workflow for graph sync
All checks were successful
Build Docker Image / build (push) Successful in 1m27s
All checks were successful
Build Docker Image / build (push) Successful in 1m27s
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user