import { Descriptions } from 'antd'; import { REDEEM_CHANNEL_LABELS, type RedeemChannel } from '@dukang/shared-types'; import { fmtTime } from '../lib/constants'; function maskPhone(phone: string | null | undefined) { if (!phone || phone.length < 7) return phone ?? '—'; return `${phone.slice(0, 3)}****${phone.slice(-4)}`; } type Props = { detail: Record; /** 列表页已脱敏展示时可设为 false,详情抽屉展示完整手机号 */ maskUserPhone?: boolean; }; export default function RedeemRecordDetailDescriptions({ detail, maskUserPhone = false }: Props) { const user = detail.user as | { userNo?: string; nickname?: string | null; phone?: string | null } | undefined; const store = detail.store as | { name?: string; cityName?: string; address?: string; partnerAccount?: { companyName?: string }; } | undefined; const coupon = detail.coupon as { couponNo?: string; order?: { orderNo?: string } } | undefined; const channel = detail.channel === 'PHONE' ? 'PHONE' : 'SCAN'; return ( {String(detail.redeemNo ?? '—')} {REDEEM_CHANNEL_LABELS[channel as RedeemChannel]} ¥{Number(detail.amount ?? 0).toFixed(2)} ¥{Number(detail.settleAmount ?? 0).toFixed(2)} {fmtTime(String(detail.createdAt ?? ''))} {user?.userNo ?? '—'} {user?.nickname?.trim() || '—'} {maskUserPhone ? maskPhone(user?.phone) : user?.phone || '—'} {store?.name ?? '—'} {store?.cityName ? `(${store.cityName})` : ''} {store?.address ?? '—'} {store?.partnerAccount?.companyName ?? '—'} {coupon?.couponNo ?? '—'} {coupon?.order?.orderNo ?? '—'} {Array.isArray(detail.allocations) && (detail.allocations as unknown[]).length > 0 ? ( {( detail.allocations as Array<{ couponNo?: string; orderNo?: string | null; amount?: number; }> ) .map((a, idx) => { const role = idx === 0 ? '主' : '次'; return `${role} ${a.couponNo ?? '—'}¥${Number(a.amount ?? 0).toFixed(2)}${ a.orderNo ? `(订单 ${a.orderNo})` : '' }`; }) .join(';')} ) : null} {detail.payout ? ( ¥{Number((detail.payout as { settleAmount?: number }).settleAmount ?? 0).toFixed(2)} {' / '} {String((detail.payout as { status?: string }).status ?? '—')} ) : null} {detail.rating ? ( 服务 {(detail.rating as { serviceScore?: number }).serviceScore ?? '—'} 分 / 环境{' '} {(detail.rating as { envScore?: number }).envScore ?? '—'} 分 ) : null} ); }