declare namespace Api {
  /** 门店管理类型 */
  namespace Store {
    /** 门店状态枚举 */
    enum StoreStatus {
      Closed = 0,
      Preparing = 1,
      Operating = 2,
      Suspended = 3
    }

    /** 门店审核状态枚举 */
    enum StoreAuditStatus {
      Draft = 0,
      Pending = 1,
      Activated = 2,
      Rejected = 3
    }

    /** 门店经营状态枚举 */
    enum StoreBusinessStatus {
      Open = 0,
      Resting = 1,
      ForceClosed = 2
    }

    /** 门店主体类型枚举 */
    enum StoreOwnershipType {
      SameEntity = 0,
      DifferentEntity = 1
    }

    /** 门店歇业原因枚举 */
    enum StoreClosureReason {
      OutOfBusinessHours = 0,
      EquipmentMaintenance = 1,
      OwnerVacation = 2,
      OutOfStock = 3,
      TemporarilyClosed = 4,
      LicenseExpired = 5,
      Other = 99
    }

    /** 打包费模式枚举 */
    enum PackagingFeeMode {
      Fixed = 0,
      PerItem = 1
    }

    /** 门店资质类型枚举 */
    enum StoreQualificationType {
      BusinessLicense = 0,
      FoodServiceLicense = 1,
      StorefrontPhoto = 2,
      InteriorPhoto = 3
    }

    /** 门店审核动作枚举 */
    enum StoreAuditAction {
      Submit = 0,
      Resubmit = 1,
      Approve = 2,
      Reject = 3,
      ForceClose = 4,
      Reopen = 5,
      AutoActivate = 6
    }

    /** 营业时段类型枚举 */
    enum BusinessHourType {
      Normal = 0,
      ReservationOnly = 1,
      PickupOrDelivery = 2,
      Closed = 3
    }

    /** 临时时段覆盖类型枚举 */
    enum OverrideType {
      Closed = 0,
      TemporaryOpen = 1,
      ModifiedHours = 2
    }

    /** 门店信息 */
    interface StoreDto {
      id: string
      tenantId: string
      merchantId: string
      code: string
      name: string
      phone?: string | null
      managerName?: string | null
      status: StoreStatus
      signboardImageUrl?: string | null
      ownershipType: StoreOwnershipType
      auditStatus: StoreAuditStatus
      businessStatus: StoreBusinessStatus
      closureReason?: StoreClosureReason | null
      closureReasonText?: string | null
      categoryId?: string | null
      rejectionReason?: string | null
      submittedAt?: string | null
      activatedAt?: string | null
      forceClosedAt?: string | null
      forceCloseReason?: string | null
      province?: string | null
      city?: string | null
      district?: string | null
      address?: string | null
      longitude?: number | null
      latitude?: number | null
      announcement?: string | null
      tags?: string | null
      deliveryRadiusKm: number
      supportsDineIn: boolean
      supportsPickup: boolean
      supportsDelivery: boolean
      supportsReservation: boolean
      supportsQueueing: boolean
      createdAt: string
    }

    /** 门店列表查询参数 */
    interface StoreListParams extends Api.Common.PageParams {
      merchantId?: string
      status?: StoreStatus
      auditStatus?: StoreAuditStatus
      businessStatus?: StoreBusinessStatus
      ownershipType?: StoreOwnershipType
      keyword?: string
      sortBy?: string
      sortDesc?: boolean
    }

    /** 门店列表响应 */
    type StoreListResponse = Api.Common.PageResult<StoreDto>

    /** 创建门店请求 */
    interface CreateStoreRequest {
      merchantId: string
      code: string
      name: string
      phone?: string | null
      managerName?: string | null
      status?: StoreStatus
      signboardImageUrl?: string | null
      ownershipType: StoreOwnershipType
      categoryId?: string | null
      province?: string | null
      city?: string | null
      district?: string | null
      address?: string | null
      longitude?: number | null
      latitude?: number | null
      announcement?: string | null
      tags?: string | null
      deliveryRadiusKm: number
      supportsDineIn?: boolean
      supportsPickup?: boolean
      supportsDelivery?: boolean
      supportsReservation?: boolean
      supportsQueueing?: boolean
    }

    /** 更新门店请求 */
    interface UpdateStoreRequest {
      merchantId: string
      code: string
      name: string
      phone?: string | null
      managerName?: string | null
      status?: StoreStatus
      signboardImageUrl?: string | null
      categoryId?: string | null
      province?: string | null
      city?: string | null
      district?: string | null
      address?: string | null
      longitude?: number | null
      latitude?: number | null
      announcement?: string | null
      tags?: string | null
      deliveryRadiusKm: number
      supportsDineIn?: boolean
      supportsPickup?: boolean
      supportsDelivery?: boolean
      supportsReservation?: boolean
      supportsQueueing?: boolean
    }

    /** 切换经营状态请求 */
    interface ToggleBusinessStatusRequest {
      businessStatus: StoreBusinessStatus
      closureReason?: StoreClosureReason | null
      closureReasonText?: string | null
    }

    /** 门店资质 */
    interface StoreQualificationDto {
      id: string
      storeId: string
      qualificationType: StoreQualificationType
      fileUrl: string
      documentNumber?: string | null
      issuedAt?: string | null
      expiresAt?: string | null
      isExpired: boolean
      isExpiringSoon: boolean
      daysUntilExpiry?: number | null
      sortOrder: number
      createdAt: string
      updatedAt?: string | null
    }

    /** 资质完整性项 */
    interface StoreQualificationRequirementDto {
      qualificationType: StoreQualificationType
      isRequired: boolean
      isUploaded: boolean
      isValid: boolean
      uploadedCount: number
    }

    /** 资质完整性检查结果 */
    interface StoreQualificationCheckResultDto {
      isComplete: boolean
      canSubmitAudit: boolean
      requiredTypes: StoreQualificationRequirementDto[]
      expiringSoonCount: number
      expiredCount: number
      missingTypes: string[]
      warnings: string[]
    }

    /** 创建资质请求 */
    interface CreateStoreQualificationRequest {
      qualificationType: StoreQualificationType
      fileUrl: string
      documentNumber?: string | null
      issuedAt?: string | null
      expiresAt?: string | null
      sortOrder?: number
    }

    /** 更新资质请求 */
    interface UpdateStoreQualificationRequest {
      fileUrl?: string | null
      documentNumber?: string | null
      issuedAt?: string | null
      expiresAt?: string | null
      sortOrder?: number | null
    }

    /** 营业时段 */
    interface StoreBusinessHourDto {
      id: string
      tenantId: string
      storeId: string
      dayOfWeek: number
      hourType: BusinessHourType
      startTime: string
      endTime: string
      capacityLimit?: number | null
      notes?: string | null
      createdAt: string
    }

    /** 批量更新营业时段输入项 */
    interface StoreBusinessHourInputDto {
      dayOfWeek: number
      hourType: BusinessHourType
      startTime: string
      endTime: string
      capacityLimit?: number | null
      notes?: string | null
    }

    /** 批量更新营业时段请求 */
    interface BatchUpdateBusinessHoursRequest {
      items: StoreBusinessHourInputDto[]
    }

    /** 门店临时时段 */
    interface StoreHolidayDto {
      id: string
      tenantId: string
      storeId: string
      date: string
      endDate?: string
      isAllDay: boolean
      startTime?: string
      endTime?: string
      overrideType: OverrideType
      isClosed: boolean
      reason?: string
      createdAt: string
    }

    /** 创建临时时段请求 */
    interface CreateStoreHolidayRequest {
      date: string
      endDate?: string
      isAllDay: boolean
      startTime?: string
      endTime?: string
      overrideType: OverrideType
      reason?: string
    }

    /** 更新临时时段请求 */
    type UpdateStoreHolidayRequest = CreateStoreHolidayRequest

    /** 配送区域 */
    interface StoreDeliveryZoneDto {
      id: string
      tenantId: string
      storeId: string
      zoneName: string
      polygonGeoJson: string
      minimumOrderAmount?: number | null
      deliveryFee?: number | null
      estimatedMinutes?: number | null
      sortOrder: number
      createdAt: string
    }

    /** 创建配送区域请求 */
    interface CreateStoreDeliveryZoneRequest {
      zoneName: string
      polygonGeoJson: string
      minimumOrderAmount?: number | null
      deliveryFee?: number | null
      estimatedMinutes?: number | null
      sortOrder?: number
    }

    /** 更新配送区域请求 */
    interface UpdateStoreDeliveryZoneRequest {
      zoneName: string
      polygonGeoJson: string
      minimumOrderAmount?: number | null
      deliveryFee?: number | null
      estimatedMinutes?: number | null
      sortOrder?: number
    }

    /** 配送范围检测请求 */
    interface StoreDeliveryCheckRequest {
      longitude: number
      latitude: number
    }

    /** 配送范围检测结果 */
    interface StoreDeliveryCheckResultDto {
      inRange: boolean
      distance?: number | null
      deliveryZoneId?: string | null
      deliveryZoneName?: string | null
    }

    /** 门店费用配置 */
    interface StoreFeeDto {
      id: string
      storeId: string
      minimumOrderAmount: number
      deliveryFee: number
      packagingFeeMode: PackagingFeeMode
      fixedPackagingFee: number
      freeDeliveryThreshold?: number | null
      createdAt: string
      updatedAt?: string | null
    }

    /** 更新费用请求 */
    interface UpdateStoreFeeRequest {
      minimumOrderAmount: number
      deliveryFee: number
      packagingFeeMode: PackagingFeeMode
      fixedPackagingFee?: number | null
      freeDeliveryThreshold?: number | null
    }

    /** 费用计算请求 */
    interface CalculateStoreFeeRequest {
      orderAmount: number
      itemCount?: number | null
      items?: StoreFeeCalculationItemDto[]
    }

    /** 费用计算商品项 */
    interface StoreFeeCalculationItemDto {
      skuId: string
      quantity: number
      packagingFee: number
    }

    /** 打包费拆分明细 */
    interface StoreFeeCalculationBreakdownDto {
      skuId: string
      quantity: number
      unitFee: number
      subtotal: number
    }

    /** 费用计算结果 */
    interface StoreFeeCalculationResultDto {
      orderAmount: number
      minimumOrderAmount: number
      meetsMinimum: boolean
      shortfall?: number | null
      deliveryFee: number
      packagingFee: number
      packagingFeeMode: PackagingFeeMode
      packagingFeeBreakdown?: StoreFeeCalculationBreakdownDto[] | null
      totalFee: number
      totalAmount: number
      message?: string | null
    }

    /** 资质预警查询参数 */
    interface StoreQualificationAlertQueryParams extends Api.Common.PageParams {
      daysThreshold?: number
      tenantId?: string
      expired?: boolean
    }

    /** 资质预警项 */
    interface StoreQualificationAlertDto {
      qualificationId: string
      storeId: string
      storeName: string
      storeCode: string
      tenantId: string
      tenantName: string
      qualificationType: StoreQualificationType
      expiresAt?: string | null
      daysUntilExpiry?: number | null
      isExpired: boolean
      storeBusinessStatus: StoreBusinessStatus
    }

    /** 资质预警汇总 */
    interface StoreQualificationAlertSummaryDto {
      expiringSoonCount: number
      expiredCount: number
    }

    /** 资质预警分页结果 */
    interface StoreQualificationAlertResultDto
      extends Api.Common.PageResult<StoreQualificationAlertDto> {
      summary: StoreQualificationAlertSummaryDto
    }
  }

  /** 门店审核管理类型 */
  namespace StoreAudit {
    /** 待审核门店 */
    interface PendingStoreAuditDto {
      storeId: string
      storeName: string
      storeCode: string
      tenantId: string
      tenantName: string
      merchantId: string
      merchantName: string
      signboardImageUrl?: string | null
      fullAddress: string
      ownershipType: Api.Store.StoreOwnershipType
      submittedAt?: string | null
      waitingDays: number
      isOverdue: boolean
      qualificationCount: number
    }

    /** 门店审核详情 - 门店信息 */
    interface StoreAuditStoreDto {
      id: string
      name: string
      code: string
      phone?: string | null
      signboardImageUrl?: string | null
      province?: string | null
      city?: string | null
      district?: string | null
      address?: string | null
      longitude?: number | null
      latitude?: number | null
      ownershipType: Api.Store.StoreOwnershipType
      auditStatus: Api.Store.StoreAuditStatus
      submittedAt?: string | null
    }

    /** 门店审核详情 - 租户信息 */
    interface StoreAuditTenantDto {
      id: string
      name: string
      contactName?: string | null
      contactPhone?: string | null
    }

    /** 门店审核详情 - 商户信息 */
    interface StoreAuditMerchantDto {
      id: string
      name: string
      legalName?: string | null
      creditCode?: string | null
    }

    /** 审核记录 */
    interface StoreAuditRecordDto {
      id: string
      action: Api.Store.StoreAuditAction
      actionName: string
      operatorId?: string | null
      operatorName: string
      previousStatus?: Api.Store.StoreAuditStatus | null
      newStatus: Api.Store.StoreAuditStatus
      rejectionReasonId?: string | null
      rejectionReasonText?: string | null
      remark?: string | null
      createdAt: string
    }

    /** 门店审核详情 */
    interface StoreAuditDetailDto {
      store: StoreAuditStoreDto
      tenant: StoreAuditTenantDto
      merchant: StoreAuditMerchantDto
      qualifications: Api.Store.StoreQualificationDto[]
      auditHistory: StoreAuditRecordDto[]
    }

    /** 审核统计趋势项 */
    interface StoreAuditDailyTrendDto {
      date: string
      submitted: number
      approved: number
      rejected: number
    }

    /** 审核统计 */
    interface StoreAuditStatisticsDto {
      pendingCount: number
      overdueCount: number
      approvedCount: number
      rejectedCount: number
      avgProcessingHours: number
      dailyTrend: StoreAuditDailyTrendDto[]
    }

    /** 审核/风控操作结果 */
    interface StoreAuditActionResultDto {
      storeId: string
      auditStatus: Api.Store.StoreAuditStatus
      businessStatus: Api.Store.StoreBusinessStatus
      rejectionReason?: string | null
      message?: string | null
    }

    /** 待审核列表查询参数 */
    interface ListPendingStoreAuditsParams extends Api.Common.PageParams {
      tenantId?: string
      keyword?: string
      submittedFrom?: string
      submittedTo?: string
      overdueOnly?: boolean
      sortBy?: string
      sortDesc?: boolean
    }

    /** 待审核门店分页响应 */
    type PendingStoreAuditResponse = Api.Common.PageResult<PendingStoreAuditDto>

    /** 审核记录查询参数 */
    interface ListStoreAuditRecordsParams {
      page?: number
      pageSize?: number
    }

    /** 审核统计查询参数 */
    interface StoreAuditStatisticsParams {
      dateFrom?: string
      dateTo?: string
    }

    /** 审核通过请求 */
    interface ApproveStoreAuditRequest {
      remark?: string | null
    }

    /** 审核驳回请求 */
    interface RejectStoreAuditRequest {
      rejectionReasonId: number
      rejectionReasonText?: string | null
      remark?: string | null
    }

    /** 强制关闭请求 */
    interface ForceCloseStoreRequest {
      reason: string
      remark?: string | null
    }

    /** 解除关闭请求 */
    interface ReopenStoreRequest {
      remark?: string | null
    }
  }
}
