import logging

from celery import shared_task

from shipment.services import send_shipment_created_wecom


logger = logging.getLogger(__name__)


@shared_task(bind=True)
def notify_shipment_created_wecom(
    self,
    *,
    shipment_id: int,
    created_by_id: int | None = None,
) -> dict:
    payload = send_shipment_created_wecom(
        shipment_id=shipment_id,
        created_by_id=created_by_id,
    )
    payload["task_id"] = self.request.id
    logger.info("[shipment.tasks] 出货单创建企业微信通知发送完成: %s", payload)
    return payload
