feat: 重做协作台账状态机并支持充值核账

This commit is contained in:
yml2213
2026-10-19 16:06:02 +08:00
parent 781b27e63a
commit 3a6649a054
15 changed files with 2330 additions and 363 deletions
+8
View File
@@ -52,6 +52,8 @@ import type {
HuyaCollabOrderQuery,
HuyaCollabOrderUpdate,
HuyaCollabOwner,
HuyaCollabRechargeRequest,
HuyaCollabRechargeResult,
HuyaCollabShop,
HuyaCollabShopCreate,
HuyaCollabShopUpdate,
@@ -284,6 +286,12 @@ export const huyaApi = {
'/huya/external-orders/status/batch',
data,
),
/** 充值核账:按绑定账号整组校验 CK + 积分,整组落「已充值 / 积分异常」 */
rechargeCollabOrders: (data: HuyaCollabRechargeRequest) =>
api.post<HuyaCollabRechargeResult, HuyaCollabRechargeResult>(
'/huya/external-orders/recharge',
data,
),
/** 归档抢购成功的订单(可带备注;archive_filtered 时按当前筛选批量归档) */
archiveCollabOrders: (data: HuyaCollabArchiveRequest) =>
api.post<HuyaCollabArchiveResult, HuyaCollabArchiveResult>(
+60 -3
View File
@@ -1202,11 +1202,13 @@ export interface AccountExchangeRecords {
export type HuyaCollabStatus =
/** 只登记了订单号 + 店铺,CK / 礼包 / 主页截图等客户资料还没到 */
| 'incomplete'
| 'pending'
| 'bound'
/** 资料齐全且 CK 有效;等充值 */
| 'to_recharge'
| 'recharged'
| 'scripted'
| 'done'
/** 充值完成但积分不足或超出阈值(可重新核账恢复) */
| 'points_error'
/** 旁路终态:抢购后查兑换记录没查到这一单的礼包(人工确认后可作废或回退重试) */
| 'failed'
| 'void';
@@ -1252,6 +1254,8 @@ export interface HuyaCollabOrder {
bind_image_thumb_urls: string[];
home_image_thumb_urls: string[];
gift_name: string;
/** 购买该礼包所需积分快照(来自积分中心 queryAllocation) */
required_points: number | null;
remark: string;
status: HuyaCollabStatus;
status_label: string;
@@ -1260,6 +1264,14 @@ export interface HuyaCollabOrder {
recharged_at: string | null;
scripted_at: string | null;
done_at: string | null;
points_checked_at: string | null;
points_balance: number | null;
points_required_total: number | null;
points_surplus: number | null;
points_threshold: number | null;
points_check_reason: string;
points_check_message: string;
points_check_detail: Record<string, unknown> | null;
void_reason: string;
/** 归档是可见性状态,不改业务状态;归档行只读 */
is_archived: boolean;
@@ -1430,6 +1442,49 @@ export interface HuyaCollabStatusBatchResult {
results: HuyaCollabStatusBatchItem[];
}
/** 充值核账:按绑定账号整组核账 */
export interface HuyaCollabRechargeRequest {
ids: number[];
/** 允许结余上限,默认 100 */
threshold: number;
}
export interface HuyaCollabRechargeOrder {
id: number;
order_no: string;
status: HuyaCollabStatus;
status_label: string;
}
export interface HuyaCollabRechargeGroup {
group_key: string;
status: HuyaCollabStatus | '';
status_label: string;
balance: number | null;
required_total: number | null;
surplus: number | null;
threshold: number;
reason: string;
message: string;
order_ids: number[];
orders: HuyaCollabRechargeOrder[];
}
export interface HuyaCollabRechargeFailure {
id: number;
order_no: string;
message: string;
}
export interface HuyaCollabRechargeResult {
total: number;
updated: number;
failed: number;
threshold: number;
groups: HuyaCollabRechargeGroup[];
failures: HuyaCollabRechargeFailure[];
}
/** 归档请求:ids 为空且 archive_filtered=true 时按筛选范围归档 */
export interface HuyaCollabArchiveRequest {
ids?: number[];
@@ -1540,6 +1595,7 @@ export interface HuyaCollabOrderCreate {
ck_text?: string;
bind_douyu_account?: string;
gift_name?: string;
required_points?: number | null;
/** 主页截图(object_key 数组,第一张作封面);严格模式下必填至少 1 张 */
home_images?: string[];
remark?: string;
@@ -1556,6 +1612,7 @@ export interface HuyaCollabOrderUpdate {
bind_douyu_account?: string;
bind_douyu_uid?: string;
gift_name?: string;
required_points?: number | null;
remark?: string;
expected_version?: number;
}
@@ -1627,7 +1684,7 @@ export interface FileUploadResult {
size: number;
}
/** 活动礼包(用一份有效 CK 现拉) */
/** 积分中心商品(用一份有效 CK 现拉;PlayMallUI.queryAllocation) */
export interface HuyaCollabGift {
product_id: string;
name: string;