task-21: 拆分 withdraw / patrol-delete 模块 API 至 types/modules/withdraw.ts,java-modules.ts re-export

This commit is contained in:
2026-08-31 19:48:49 +08:00
parent 99998fba3e
commit 45815f5919
3 changed files with 765 additions and 433 deletions
+1 -433
View File
@@ -20,6 +20,7 @@ export * from "./types/modules/delete-brand.ts";
export * from "./types/modules/price-track.ts";
export * from "./types/modules/shop-match.ts";
export * from "./types/modules/query-asin.ts";
export * from "./types/modules/withdraw.ts";
import type {
ProductRiskCandidateVo,
ProductRiskDashboardVo,
@@ -164,439 +165,6 @@ export async function uploadTempFileToJava(
}
export type PatrolDeleteCandidateVo = ProductRiskCandidateVo;
export type PatrolDeleteDashboardVo = ProductRiskDashboardVo;
export type PatrolDeleteShopQueueItem = ProductRiskShopQueueItem;
export interface PatrolDeleteConditionVo {
id: number;
conditionText: string;
createdAt?: string;
}
export interface PatrolDeleteCountryMetricRow {
status: string;
quantity: string;
deleteQuantity: string;
processStatus: string;
}
export interface PatrolDeleteCountrySection {
country: string;
rows: PatrolDeleteCountryMetricRow[];
}
export interface PatrolDeleteCartRatio {
country: string;
ratio: string;
}
export interface PatrolDeleteTaskItem {
shopName?: string;
matched?: boolean;
shopId?: string;
platform?: string;
companyName?: string;
matchStatus?: string;
matchMessage?: string;
countrySections: PatrolDeleteCountrySection[];
cartRatios: PatrolDeleteCartRatio[];
}
export interface PatrolDeleteHistoryItem {
resultId?: number;
taskId?: number;
shopName?: string;
shopId?: string;
platform?: string;
companyName?: string;
matched?: boolean;
matchStatus?: string;
matchMessage?: string;
taskStatus?: string;
success?: boolean;
error?: string;
createdAt?: string;
finishedAt?: string;
outputFilename?: string;
downloadUrl?: string;
fileJobId?: number;
fileStatus?: string;
fileError?: string;
fileReady?: boolean;
countrySections: PatrolDeleteCountrySection[];
cartRatios: PatrolDeleteCartRatio[];
}
export interface PatrolDeleteHistoryVo {
items: PatrolDeleteHistoryItem[];
}
export interface PatrolDeleteTaskBatchVo {
items: PatrolDeleteHistoryItem[];
missingTaskIds: number[];
}
export interface PatrolDeleteCreateTaskVo {
taskId: number;
items: PatrolDeleteHistoryItem[];
}
export function listPatrolDeleteCandidates() {
return unwrapJavaResponse(
get<JavaApiResponse<PatrolDeleteCandidateVo[]>>(
`${JAVA_API_PREFIX}/patrol-delete/candidates`,
{
params: { user_id: getCurrentUserId() },
},
),
);
}
export function addPatrolDeleteCandidate(shopName: string) {
return unwrapJavaResponse(
post<
JavaApiResponse<PatrolDeleteCandidateVo>,
{ user_id: number; shop_name: string }
>(`${JAVA_API_PREFIX}/patrol-delete/candidates`, {
user_id: getCurrentUserId(),
shop_name: shopName,
}),
);
}
export function deletePatrolDeleteCandidate(id: number) {
return unwrapJavaResponse(
del<JavaApiResponse<null>>(
`${JAVA_API_PREFIX}/patrol-delete/candidates/${id}`,
{
params: { user_id: getCurrentUserId() },
},
),
);
}
export function listPatrolDeleteConditions() {
return unwrapJavaResponse(
get<JavaApiResponse<PatrolDeleteConditionVo[]>>(
`${JAVA_API_PREFIX}/patrol-delete/conditions`,
{
params: { user_id: getCurrentUserId() },
},
),
);
}
export function addPatrolDeleteCondition(conditionText: string) {
return unwrapJavaResponse(
post<
JavaApiResponse<PatrolDeleteConditionVo>,
{ user_id: number; condition_text: string }
>(`${JAVA_API_PREFIX}/patrol-delete/conditions`, {
user_id: getCurrentUserId(),
condition_text: conditionText,
}),
);
}
export function deletePatrolDeleteCondition(id: number) {
return unwrapJavaResponse(
del<JavaApiResponse<null>>(
`${JAVA_API_PREFIX}/patrol-delete/conditions/${id}`,
{
params: { user_id: getCurrentUserId() },
},
),
);
}
export function matchPatrolDeleteShops(shopNames: string[]) {
return unwrapJavaResponse(
post<
JavaApiResponse<ProductRiskMatchShopsVo>,
{ user_id: number; shop_names: string[] }
>(`${JAVA_API_PREFIX}/patrol-delete/match-shops`, {
user_id: getCurrentUserId(),
shop_names: shopNames,
}),
);
}
export function getPatrolDeleteDashboard() {
return unwrapJavaResponse(
get<JavaApiResponse<PatrolDeleteDashboardVo>>(
`${JAVA_API_PREFIX}/patrol-delete/dashboard`,
{
params: { user_id: getCurrentUserId() },
},
),
);
}
export function getPatrolDeleteHistory() {
return unwrapJavaResponse(
get<JavaApiResponse<PatrolDeleteHistoryVo>>(
`${JAVA_API_PREFIX}/patrol-delete/history`,
{
params: { user_id: getCurrentUserId() },
},
),
);
}
export function getPatrolDeleteTaskProgressBatch(taskIds: number[]) {
return postTaskProgressBatch<PatrolDeleteTaskBatchVo>(
`${JAVA_API_PREFIX}/patrol-delete/tasks/progress/batch`,
taskIds,
);
}
export function createPatrolDeleteTask(items: PatrolDeleteTaskItem[]) {
return unwrapJavaResponse(
post<
JavaApiResponse<PatrolDeleteCreateTaskVo>,
{ user_id: number; items: PatrolDeleteTaskItem[] }
>(`${JAVA_API_PREFIX}/patrol-delete/tasks`, {
user_id: getCurrentUserId(),
items,
}),
);
}
export function submitPatrolDeleteTaskResult(
taskId: number,
payload: {
shops: Array<{
shopName: string;
error?: string;
countrySections: PatrolDeleteCountrySection[];
cartRatios: PatrolDeleteCartRatio[];
shopDone?: boolean;
submissionId?: string;
chunkIndex?: number;
chunkTotal?: number;
}>;
},
) {
return unwrapJavaResponse(
post<
JavaApiResponse<null>,
{
shops: Array<{
shopName: string;
error?: string;
countrySections: PatrolDeleteCountrySection[];
cartRatios: PatrolDeleteCartRatio[];
shopDone?: boolean;
submissionId?: string;
chunkIndex?: number;
chunkTotal?: number;
}>;
}
>(`${JAVA_API_PREFIX}/patrol-delete/tasks/${taskId}/result`, payload),
);
}
export function getPatrolDeleteResultDownloadUrl(resultId: number) {
return getJavaDownloadUrl(`/patrol-delete/results/${resultId}/download`);
}
export function deletePatrolDeleteTask(taskId: number) {
return unwrapJavaResponse(
del<JavaApiResponse<null>>(
`${JAVA_API_PREFIX}/patrol-delete/tasks/${taskId}`,
{
params: { user_id: getCurrentUserId() },
},
),
);
}
export function deletePatrolDeleteHistory(resultId: number) {
return unwrapJavaResponse(
del<JavaApiResponse<null>>(
`${JAVA_API_PREFIX}/patrol-delete/history/${resultId}`,
{
params: { user_id: getCurrentUserId() },
},
),
);
}
// ========== 取款 ==========
export type WithdrawCandidateVo = QueryAsinCandidateVo;
export type WithdrawDashboardVo = QueryAsinDashboardVo;
export type WithdrawShopQueueItem = ProductRiskShopQueueItem;
export type WithdrawStatusCode =
| "ZERO_AVAILABLE"
| "SUCCESS"
| "BALANCE_FORBIDDEN"
| "NEGATIVE_WITHDRAW_BLANK";
export interface WithdrawRow {
country?: string;
shopAmount?: number | string | null;
withdrawAmount?: number | string | null;
status?: WithdrawStatusCode | string;
}
export interface WithdrawTaskItem {
shopName: string;
matched: boolean;
shopId?: string;
platform?: string;
companyName?: string;
matchStatus?: string;
matchMessage?: string;
}
export interface WithdrawHistoryItem extends WithdrawTaskItem {
resultId?: number;
taskId?: number;
taskStatus?: string;
reservedAmount?: number | string | null;
success?: boolean;
error?: string;
outputFilename?: string;
downloadUrl?: string;
fileJobId?: number;
fileStatus?: string;
fileError?: string;
fileReady?: boolean;
createdAt?: string;
finishedAt?: string;
rows?: WithdrawRow[];
shops?: WithdrawHistoryItem[];
}
export interface WithdrawHistoryVo {
items: WithdrawHistoryItem[];
}
export interface WithdrawTaskBatchVo {
items: WithdrawHistoryItem[];
missingTaskIds: number[];
}
export interface WithdrawCreateTaskVo {
taskId: number;
items: WithdrawHistoryItem[];
}
export function listWithdrawCandidates() {
return unwrapJavaResponse(
get<JavaApiResponse<WithdrawCandidateVo[]>>(`${JAVA_API_PREFIX}/withdraw/candidates`, {
params: { user_id: getCurrentUserId() },
}),
);
}
export function addWithdrawCandidate(shopName: string) {
return unwrapJavaResponse(
post<JavaApiResponse<WithdrawCandidateVo>, { user_id: number; shop_name: string }>(
`${JAVA_API_PREFIX}/withdraw/candidates`,
{ user_id: getCurrentUserId(), shop_name: shopName },
),
);
}
export function deleteWithdrawCandidate(id: number) {
return unwrapJavaResponse(
del<JavaApiResponse<null>>(`${JAVA_API_PREFIX}/withdraw/candidates/${id}`, {
params: { user_id: getCurrentUserId() },
}),
);
}
export function clearWithdrawCandidates(shopNames: string[]) {
return unwrapJavaResponse(
post<JavaApiResponse<null>, { user_id: number; shop_names: string[] }>(
`${JAVA_API_PREFIX}/withdraw/candidates/clear`,
{ user_id: getCurrentUserId(), shop_names: shopNames },
),
);
}
export function matchWithdrawShops(shopNames: string[]) {
return unwrapJavaResponse(
post<JavaApiResponse<ProductRiskMatchShopsVo>, { user_id: number; shop_names: string[] }>(
`${JAVA_API_PREFIX}/withdraw/match-shops`,
{ user_id: getCurrentUserId(), shop_names: shopNames },
),
);
}
export function getWithdrawDashboard() {
return unwrapJavaResponse(
get<JavaApiResponse<WithdrawDashboardVo>>(`${JAVA_API_PREFIX}/withdraw/dashboard`, {
params: { user_id: getCurrentUserId() },
}),
);
}
export function getWithdrawHistory() {
return unwrapJavaResponse(
get<JavaApiResponse<WithdrawHistoryVo>>(`${JAVA_API_PREFIX}/withdraw/history`, {
params: { user_id: getCurrentUserId() },
}),
);
}
export function getWithdrawTaskProgressBatch(taskIds: number[]) {
return postTaskProgressBatch<WithdrawTaskBatchVo>(
`${JAVA_API_PREFIX}/withdraw/tasks/progress/batch`,
taskIds,
);
}
export function createWithdrawTask(items: WithdrawTaskItem[], reservedAmount: number | string | null) {
return unwrapJavaResponse(
post<JavaApiResponse<WithdrawCreateTaskVo>, { user_id: number; reserved_amount: number | string | null; items: WithdrawTaskItem[] }>(
`${JAVA_API_PREFIX}/withdraw/tasks`,
{ user_id: getCurrentUserId(), reserved_amount: reservedAmount, items },
),
);
}
export function submitWithdrawTaskResult(
taskId: number,
payload: {
shops: Array<{
shopName: string;
error?: string;
rows?: WithdrawRow[];
shopDone?: boolean;
submissionId?: string;
}>;
},
) {
return unwrapJavaResponse(
post<JavaApiResponse<null>, typeof payload>(`${JAVA_API_PREFIX}/withdraw/tasks/${taskId}/result`, payload),
);
}
export function getWithdrawResultDownloadUrl(resultId: number) {
return getJavaDownloadUrl(`/withdraw/results/${resultId}/download`);
}
export function deleteWithdrawTask(taskId: number) {
return unwrapJavaResponse(
del<JavaApiResponse<null>>(`${JAVA_API_PREFIX}/withdraw/tasks/${taskId}`, {
params: { user_id: getCurrentUserId() },
}),
);
}
export function deleteWithdrawHistory(resultId: number) {
return unwrapJavaResponse(
del<JavaApiResponse<null>>(`${JAVA_API_PREFIX}/withdraw/history/${resultId}`, {
params: { user_id: getCurrentUserId() },
}),
);
}
// ========== 视频复刻 / 图生视频 ==========
export interface ImageVideoDouyinCopyVo {