import logging
from django.apps import AppConfig

logger = logging.getLogger(__name__)


class BusinessConfig(AppConfig):
    default_auto_field = 'django.db.models.BigAutoField'
    name = 'business'
    verbose_name = '业务模块'

    def ready(self):
        from .models import PreSalesOrder
        from . import handlers
        from .signals import pre_sales_order_created

        pre_sales_order_created.connect(
            handlers.on_pre_sales_order_created,
            sender=PreSalesOrder,
            dispatch_uid='business.on_pre_sales_order_created',
        )

        logger.info(
            f'[business.apps] 已注册 pre_sales_order_created 信号处理器, '
            f'sender={PreSalesOrder}, handler={handlers.on_pre_sales_order_created}'
        )
