feat: 增强注单处理逻辑并优化用户反馈体验
新增注单错误处理逻辑,支持已退款及待确认状态的异常场景处理。 更新 HallBetResultDialog:针对部分失败与已退款订单显示对应提示信息。 优化注单分组逻辑,新增订单状态处理,提升整体订单管理能力。 新增订单状态与用户通知相关多语言翻译,进一步提升用户体验。
This commit is contained in:
@@ -36,6 +36,13 @@ export function mapTicketBetError(
|
||||
"hall.ticketError.2008",
|
||||
"赔率或玩法配置已更新,请关闭预览后重新操作。",
|
||||
);
|
||||
case 2009:
|
||||
return msg(
|
||||
"hall.ticketError.2009",
|
||||
"该订单已退款或不可重复提交,请关闭预览后重新下注。",
|
||||
);
|
||||
case 1007:
|
||||
return msg("hall.ticketError.1007", "彩票钱包已冻结,暂无法下注。");
|
||||
case 1003:
|
||||
return msg("hall.ticketError.1003", "下注金额超出该玩法允许范围。");
|
||||
default:
|
||||
|
||||
@@ -25,6 +25,9 @@ type HallBetResultDialogProps = {
|
||||
jackpotEnabled?: boolean;
|
||||
};
|
||||
|
||||
const SUCCESS_ITEM_STATUSES = new Set(["pending_draw", "placed"]);
|
||||
const FAILURE_ITEM_STATUSES = new Set(["failed", "refunded"]);
|
||||
|
||||
export function HallBetResultDialog({
|
||||
open,
|
||||
onOpenChange,
|
||||
@@ -34,18 +37,41 @@ export function HallBetResultDialog({
|
||||
}: HallBetResultDialogProps) {
|
||||
const { t } = useTranslation("player");
|
||||
|
||||
// 成功注项状态为 pending_draw(待开奖),不是 success
|
||||
const successItems = data?.items.filter((item) => item.status !== "failed") ?? [];
|
||||
const failedItems = data?.items.filter((item) => item.status === "failed") ?? [];
|
||||
const successItems =
|
||||
data?.items.filter((item) => SUCCESS_ITEM_STATUSES.has(item.status)) ?? [];
|
||||
const failedItems =
|
||||
data?.items.filter((item) => FAILURE_ITEM_STATUSES.has(item.status)) ?? [];
|
||||
const pendingItems =
|
||||
data?.items.filter((item) => item.status === "pending_confirm") ?? [];
|
||||
|
||||
const orderStatus = data?.summary.order_status;
|
||||
const isRefundedOrder = orderStatus === "refunded";
|
||||
const totalSuccess = data?.summary.success_count ?? successItems.length;
|
||||
const totalFailure = data?.summary.failure_count ?? failedItems.length;
|
||||
const isPartial = totalSuccess > 0 && totalFailure > 0;
|
||||
const isAllFailed = totalFailure > 0 && totalSuccess === 0;
|
||||
const pendingConfirmCount =
|
||||
data?.summary.pending_confirm_count ?? pendingItems.length;
|
||||
|
||||
const ResultIcon = isAllFailed ? XCircle : isPartial ? AlertTriangle : CheckCircle2;
|
||||
const isAllFailed =
|
||||
isRefundedOrder ||
|
||||
(totalFailure > 0 && totalSuccess === 0 && pendingConfirmCount === 0);
|
||||
const isPartial =
|
||||
!isRefundedOrder &&
|
||||
totalSuccess > 0 &&
|
||||
(totalFailure > 0 || pendingConfirmCount > 0);
|
||||
const isPendingOnly =
|
||||
!isRefundedOrder &&
|
||||
pendingConfirmCount > 0 &&
|
||||
totalSuccess === 0 &&
|
||||
totalFailure === 0;
|
||||
|
||||
const ResultIcon = isAllFailed
|
||||
? XCircle
|
||||
: isPartial || isPendingOnly
|
||||
? AlertTriangle
|
||||
: CheckCircle2;
|
||||
const iconWrapClass = isAllFailed
|
||||
? "border-rose-100 text-rose-600 shadow-[0_10px_24px_rgba(225,29,72,0.12)]"
|
||||
: isPartial
|
||||
: isPartial || isPendingOnly
|
||||
? "border-amber-100 text-amber-600 shadow-[0_10px_24px_rgba(217,119,6,0.12)]"
|
||||
: "border-emerald-100 text-emerald-600 shadow-[0_10px_24px_rgba(22,163,74,0.12)]";
|
||||
|
||||
@@ -74,11 +100,15 @@ export function HallBetResultDialog({
|
||||
</div>
|
||||
<DialogHeader className="mt-3 items-center gap-2">
|
||||
<DialogTitle className="text-2xl font-black text-slate-950">
|
||||
{isAllFailed
|
||||
? t("hall.result.titleAllFailed")
|
||||
: isPartial
|
||||
? t("hall.result.titlePartial")
|
||||
: t("hall.result.title")}
|
||||
{isRefundedOrder
|
||||
? t("hall.result.titleRefunded")
|
||||
: isAllFailed
|
||||
? t("hall.result.titleAllFailed")
|
||||
: isPartial
|
||||
? t("hall.result.titlePartial")
|
||||
: isPendingOnly
|
||||
? t("hall.result.titlePendingConfirm")
|
||||
: t("hall.result.title")}
|
||||
</DialogTitle>
|
||||
{data ? (
|
||||
<DialogDescription className="text-sm leading-relaxed text-slate-500">
|
||||
@@ -99,6 +129,16 @@ export function HallBetResultDialog({
|
||||
</p>
|
||||
) : (
|
||||
<>
|
||||
{isRefundedOrder ? (
|
||||
<p className="rounded-lg border border-rose-200 bg-rose-50 px-3 py-2 text-xs text-rose-800">
|
||||
{t("hall.result.refundedHint")}
|
||||
</p>
|
||||
) : null}
|
||||
{isPendingOnly ? (
|
||||
<p className="rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-900">
|
||||
{t("hall.result.pendingConfirmHint")}
|
||||
</p>
|
||||
) : null}
|
||||
<div className="grid grid-cols-2 gap-3">
|
||||
<div className="rounded-lg border border-emerald-100 bg-emerald-50 px-3 py-4 text-center">
|
||||
<p className="text-sm font-bold text-emerald-700">
|
||||
@@ -196,29 +236,38 @@ export function HallBetResultDialog({
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{totalFailure === 0 ? (
|
||||
{failedItems.length === 0 && pendingItems.length === 0 ? (
|
||||
<div className="rounded-lg border border-emerald-100 bg-emerald-50 px-3 py-3 text-sm font-semibold text-emerald-700">
|
||||
{t("hall.result.noFailures")}
|
||||
</div>
|
||||
) : (
|
||||
<div className="space-y-2 rounded-lg border border-rose-100 bg-rose-50 px-3 py-3">
|
||||
<p className="text-sm font-black text-[#e5002c]">
|
||||
{t("hall.result.failedItems")}
|
||||
</p>
|
||||
{failedItems.map((item, index) => (
|
||||
<div
|
||||
key={`${item.ticket_no}-${index}`}
|
||||
className="flex items-center justify-between gap-3 rounded-md bg-white px-3 py-2 text-xs"
|
||||
>
|
||||
<span className="min-w-0 truncate font-semibold text-slate-700">
|
||||
<span className="font-mono font-black text-slate-950">{item.number}</span>{" "}
|
||||
{playLabel(item.play_code, t)}
|
||||
</span>
|
||||
<span className="shrink-0 font-bold text-[#e5002c]">
|
||||
{item.fail_reason_text ?? item.fail_reason_code ?? t("hall.result.failed")}
|
||||
</span>
|
||||
</div>
|
||||
))}
|
||||
{failedItems.length > 0 ? (
|
||||
<>
|
||||
<p className="text-sm font-black text-[#e5002c]">
|
||||
{t("hall.result.failedItems")}
|
||||
</p>
|
||||
{failedItems.map((item, index) => (
|
||||
<div
|
||||
key={`${item.ticket_no}-${index}`}
|
||||
className="flex items-center justify-between gap-3 rounded-md bg-white px-3 py-2 text-xs"
|
||||
>
|
||||
<span className="min-w-0 truncate font-semibold text-slate-700">
|
||||
<span className="font-mono font-black text-slate-950">{item.number}</span>{" "}
|
||||
{playLabel(item.play_code, t)}
|
||||
</span>
|
||||
<span className="shrink-0 font-bold text-[#e5002c]">
|
||||
{item.fail_reason_text ?? item.fail_reason_code ?? t("hall.result.failed")}
|
||||
</span>
|
||||
</div>
|
||||
))}
|
||||
</>
|
||||
) : null}
|
||||
{pendingItems.length > 0 ? (
|
||||
<p className="text-xs text-amber-800">
|
||||
{t("hall.result.pendingConfirmLines", { count: pendingItems.length })}
|
||||
</p>
|
||||
) : null}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -721,6 +721,7 @@ export function HallBettingGrid({ drawLive }: { drawLive: HallDrawLiveSnapshot }
|
||||
const removed = clearAmountsForPlay(evt.play_code);
|
||||
setPreviewOpen(false);
|
||||
setPreviewData(null);
|
||||
clearPlaceTraceId();
|
||||
toast.warning(
|
||||
removed
|
||||
? t("hall.playConfig.playClosedDraftCleared", {
|
||||
@@ -739,6 +740,7 @@ export function HallBettingGrid({ drawLive }: { drawLive: HallDrawLiveSnapshot }
|
||||
void loadCatalog();
|
||||
setPreviewOpen(false);
|
||||
setPreviewData(null);
|
||||
clearPlaceTraceId();
|
||||
toast.message(evt.message ?? t("hall.playConfig.oddsUpdated"));
|
||||
};
|
||||
|
||||
@@ -855,7 +857,7 @@ export function HallBettingGrid({ drawLive }: { drawLive: HallDrawLiveSnapshot }
|
||||
const playCode = String(item?.play_code ?? "");
|
||||
if (!Number.isInteger(clientLineNo) || clientLineNo <= 0 || playCode.trim() === "") return;
|
||||
const entry = entries[clientLineNo - 1];
|
||||
if (!entry) return;
|
||||
if (!entry || entry.play.play_code !== playCode) return;
|
||||
cleanupPairs.add(`${entry.rowId}::${entry.amountKey}`);
|
||||
});
|
||||
|
||||
@@ -929,6 +931,11 @@ export function HallBettingGrid({ drawLive }: { drawLive: HallDrawLiveSnapshot }
|
||||
toast.error(payload.cleanup_hint ?? t("hall.ticketError.2002"));
|
||||
return;
|
||||
}
|
||||
if (e instanceof LotteryApiBizError && code === 2008) {
|
||||
setPreviewOpen(false);
|
||||
setPreviewData(null);
|
||||
clearPlaceTraceId();
|
||||
}
|
||||
toast.error(mapTicketBetError(code, msg, t));
|
||||
} finally {
|
||||
setPreviewLoading(false);
|
||||
@@ -1010,8 +1017,14 @@ export function HallBettingGrid({ drawLive }: { drawLive: HallDrawLiveSnapshot }
|
||||
toast.error(payload.cleanup_hint ?? t("hall.ticketError.2002"));
|
||||
setPreviewOpen(false);
|
||||
setPreviewData(null);
|
||||
clearPlaceTraceId();
|
||||
return;
|
||||
}
|
||||
if (e instanceof LotteryApiBizError && (code === 2008 || code === 2009)) {
|
||||
setPreviewOpen(false);
|
||||
setPreviewData(null);
|
||||
clearPlaceTraceId();
|
||||
}
|
||||
toast.error(mapTicketBetError(code, msg, t));
|
||||
} finally {
|
||||
setPlaceLoading(false);
|
||||
@@ -1051,7 +1064,10 @@ export function HallBettingGrid({ drawLive }: { drawLive: HallDrawLiveSnapshot }
|
||||
);
|
||||
}
|
||||
|
||||
const canSubmit = !tableDisabled && draftEntries.length > 0 && availableMinor >= debouncedSummary.actual;
|
||||
const submitActualMinor =
|
||||
previewData?.summary.total_actual_deduct ?? debouncedSummary.actual;
|
||||
const canSubmit =
|
||||
!tableDisabled && draftEntries.length > 0 && availableMinor >= submitActualMinor;
|
||||
const favoriteChips = favorites.slice(0, 10);
|
||||
const historyChips = historyNumbers.slice(0, 20);
|
||||
|
||||
@@ -1471,7 +1487,7 @@ export function HallBettingGrid({ drawLive }: { drawLive: HallDrawLiveSnapshot }
|
||||
? t("hall.table.previewing")
|
||||
: !isBettable
|
||||
? t("hall.closed.title")
|
||||
: availableMinor < debouncedSummary.actual
|
||||
: availableMinor < submitActualMinor
|
||||
? t("hall.table.insufficientBalance")
|
||||
: t("hall.table.submitBet")}
|
||||
</Button>
|
||||
@@ -1492,7 +1508,7 @@ export function HallBettingGrid({ drawLive }: { drawLive: HallDrawLiveSnapshot }
|
||||
data={previewData}
|
||||
placing={placeLoading}
|
||||
jackpotEnabled={Boolean(jackpot?.enabled)}
|
||||
allowSubmit={isBettable && availableMinor >= debouncedSummary.actual}
|
||||
allowSubmit={isBettable && availableMinor >= submitActualMinor}
|
||||
onConfirmPlace={() => void handlePlace()}
|
||||
/>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user