"""金额罚单 fadan 状态常量（与 orders.models.Penalty.Status 一致）"""

PENALTY_PENDING_PAY = 1       # 待缴纳（平台审核通过后）
PENALTY_PAID = 2              # 已缴纳
PENALTY_APPEALING = 3         # 申诉中
PENALTY_REJECTED = 4          # 已驳回 / 打手申诉成功
PENALTY_PLATFORM_AUDIT = 5  # 平台审核中（商家提交后，审核通过前）

# 影响抢单：仅平台审核通过后的未结案罚单
PENALTY_GRAB_BLOCK_STATUSES = (PENALTY_PENDING_PAY, PENALTY_APPEALING)

# 影响提现：含平台审核中
PENALTY_WITHDRAW_BLOCK_STATUSES = (PENALTY_PENDING_PAY, PENALTY_APPEALING, PENALTY_PLATFORM_AUDIT)

PENALTY_STATUS_LABELS = {
    1: '待缴纳',
    2: '已缴纳',
    3: '申诉中',
    4: '已驳回',
    5: '平台审核中',
}

# 商家身份（ApplicantIdentity）
APPLICANT_MERCHANT = 5


def penalty_platform_audit_pending_q():
    """待平台审核：仅 zhuangtai=5（商家新流程提交）。"""
    from django.db.models import Q
    return Q(Status=PENALTY_PLATFORM_AUDIT)


def is_penalty_platform_audit_pending(penalty):
    return getattr(penalty, 'Status', None) == PENALTY_PLATFORM_AUDIT


def penalty_display_status(penalty):
    status = getattr(penalty, 'Status', None)
    return PENALTY_STATUS_LABELS.get(status, '未知')
