938 lines
22 KiB
TypeScript
938 lines
22 KiB
TypeScript
import {
|
|
del,
|
|
get,
|
|
http,
|
|
post,
|
|
put,
|
|
type JavaApiResponse,
|
|
unwrapJavaResponse,
|
|
} from "@/shared/api/http";
|
|
|
|
const JAVA_API_PREFIX = "/newApi/api";
|
|
|
|
function getCurrentUserId() {
|
|
const raw =
|
|
typeof window === "undefined"
|
|
? ""
|
|
: window.localStorage.getItem("uid") || "";
|
|
const value = Number(raw);
|
|
if (!Number.isFinite(value) || value <= 0) {
|
|
throw new Error("未获取到用户ID");
|
|
}
|
|
return value;
|
|
}
|
|
|
|
export interface UploadedFileRef {
|
|
fileKey: string;
|
|
originalFilename?: string;
|
|
relativePath?: string;
|
|
}
|
|
|
|
export interface UploadFileVo {
|
|
fileKey: string;
|
|
originalFilename: string;
|
|
localPath: string;
|
|
size: number;
|
|
relativePath?: string;
|
|
}
|
|
|
|
export interface DedupeResultItem {
|
|
resultId?: number;
|
|
sourceFilename: string;
|
|
outputFilename?: string;
|
|
success: boolean;
|
|
error?: string;
|
|
downloadUrl?: string;
|
|
}
|
|
|
|
export interface DedupeRunVo {
|
|
total: number;
|
|
successCount: number;
|
|
failedCount: number;
|
|
items: DedupeResultItem[];
|
|
}
|
|
|
|
export interface DedupeHistoryVo {
|
|
items: DedupeResultItem[];
|
|
}
|
|
|
|
export interface DedupeRunRequest {
|
|
files: UploadedFileRef[];
|
|
selectedColumns: string[];
|
|
keepIntegerIds: boolean;
|
|
keepUnderscoreIds: boolean;
|
|
keepIntegerMainIdsWhenNoSubIds: boolean;
|
|
archiveName?: string;
|
|
user_id: number;
|
|
}
|
|
|
|
export interface SplitArchiveEntry {
|
|
filename: string;
|
|
rowCount?: number;
|
|
}
|
|
|
|
export interface SplitResultItem {
|
|
resultId?: number;
|
|
sourceFilename: string;
|
|
outputFilename?: string;
|
|
success: boolean;
|
|
error?: string;
|
|
rowCount?: number;
|
|
downloadUrl?: string;
|
|
entryCount?: number;
|
|
entries?: SplitArchiveEntry[];
|
|
}
|
|
|
|
export interface SplitRunVo {
|
|
total: number;
|
|
successCount: number;
|
|
failedCount: number;
|
|
items: SplitResultItem[];
|
|
}
|
|
|
|
export interface SplitHistoryVo {
|
|
items: SplitResultItem[];
|
|
}
|
|
|
|
export interface SplitRunRequest {
|
|
files: UploadedFileRef[];
|
|
selectedColumns: string[];
|
|
splitMode: "rows_per_file" | "parts";
|
|
rowsPerFile?: number;
|
|
parts?: number;
|
|
archiveName?: string;
|
|
user_id: number;
|
|
}
|
|
|
|
export interface ConvertResultItem {
|
|
resultId?: number;
|
|
sourceFilename: string;
|
|
outputFilename?: string;
|
|
success: boolean;
|
|
error?: string;
|
|
downloadUrl?: string;
|
|
}
|
|
|
|
export interface ConvertRunVo {
|
|
total: number;
|
|
successCount: number;
|
|
failedCount: number;
|
|
items: ConvertResultItem[];
|
|
}
|
|
|
|
export interface ConvertHistoryVo {
|
|
items: ConvertResultItem[];
|
|
}
|
|
|
|
export interface ConvertRunRequest {
|
|
files: UploadedFileRef[];
|
|
templateId: string;
|
|
archiveName?: string;
|
|
user_id: number;
|
|
}
|
|
|
|
export interface DeleteBrandPreviewRow {
|
|
rowIndex: number;
|
|
country: string;
|
|
asin: string;
|
|
status: string;
|
|
}
|
|
|
|
export interface DeleteBrandCountryAsinItem {
|
|
rowIndex: number;
|
|
asin: string;
|
|
status: string;
|
|
}
|
|
|
|
export interface DeleteBrandCountryGroup {
|
|
country: string;
|
|
asinCount: number;
|
|
items: DeleteBrandCountryAsinItem[];
|
|
}
|
|
|
|
export interface DeleteBrandCountryResultItem {
|
|
asin: string;
|
|
status?: string;
|
|
}
|
|
|
|
export interface DeleteBrandProcessedCountry {
|
|
country: string;
|
|
items: DeleteBrandCountryResultItem[];
|
|
}
|
|
|
|
export interface DeleteBrandResultFile {
|
|
fileKey?: string;
|
|
sourceFilename: string;
|
|
fileIndex?: number;
|
|
fileTotal?: number;
|
|
chunkIndex?: number;
|
|
chunkTotal?: number;
|
|
processedRows?: number;
|
|
totalRows?: number;
|
|
currentCountry?: string;
|
|
currentAsin?: string;
|
|
countries: DeleteBrandProcessedCountry[];
|
|
}
|
|
|
|
export interface DeleteBrandSubmitResultRequest {
|
|
submissionId?: string;
|
|
files: DeleteBrandResultFile[];
|
|
}
|
|
|
|
export interface DeleteBrandLineProgressInfo {
|
|
file_index?: number;
|
|
file_total?: number;
|
|
file_name?: string;
|
|
current_line?: number;
|
|
total_lines?: number;
|
|
current_country?: string;
|
|
current_asin?: string;
|
|
finished_files?: number;
|
|
phase?: string;
|
|
}
|
|
|
|
export interface DeleteBrandLineProgress {
|
|
has_progress: boolean;
|
|
info?: DeleteBrandLineProgressInfo;
|
|
}
|
|
|
|
export interface DeleteBrandTaskItem {
|
|
id: number;
|
|
taskNo?: string;
|
|
status?: string;
|
|
sourceFileCount?: number;
|
|
successFileCount?: number;
|
|
failedFileCount?: number;
|
|
errorMessage?: string;
|
|
createdAt?: string;
|
|
updatedAt?: string;
|
|
finishedAt?: string;
|
|
downloadUrl?: string;
|
|
downloadFilename?: string;
|
|
}
|
|
|
|
export interface DeleteBrandTaskFileProgress {
|
|
fileKey?: string;
|
|
sourceFilename?: string;
|
|
processedRows?: number;
|
|
totalRows?: number;
|
|
percent?: number;
|
|
status?: "PENDING" | "RUNNING" | "COMPLETED" | "FAILED";
|
|
}
|
|
|
|
export interface DeleteBrandTaskDetailVo {
|
|
task: DeleteBrandTaskItem;
|
|
line_progress: DeleteBrandLineProgress;
|
|
items?: DeleteBrandResultItem[];
|
|
fileProgress?: DeleteBrandTaskFileProgress[];
|
|
}
|
|
|
|
export interface DeleteBrandTaskBatchVo {
|
|
items: DeleteBrandTaskDetailVo[];
|
|
missingTaskIds: number[];
|
|
}
|
|
|
|
export type DeleteBrandMatchStatus =
|
|
| "MATCHED"
|
|
| "PENDING"
|
|
| "CONFLICT"
|
|
| "INDEX_STALE";
|
|
|
|
export interface DeleteBrandResultItem {
|
|
resultId?: number;
|
|
fileKey?: string;
|
|
sourceFilename: string;
|
|
shopName?: string;
|
|
matched?: boolean;
|
|
matchStatus?: DeleteBrandMatchStatus;
|
|
matchMessage?: string;
|
|
shopId?: string;
|
|
platform?: string;
|
|
openStoreUrl?: string;
|
|
outputFilename?: string;
|
|
downloadUrl?: string;
|
|
taskId?: number;
|
|
countryCount?: number;
|
|
countries?: DeleteBrandCountryGroup[];
|
|
totalRows?: number;
|
|
truncated?: boolean;
|
|
previewRows?: DeleteBrandPreviewRow[];
|
|
success: boolean;
|
|
error?: string;
|
|
taskStatus?: string;
|
|
}
|
|
|
|
export interface DeleteBrandRunVo {
|
|
total: number;
|
|
successCount: number;
|
|
failedCount: number;
|
|
items: DeleteBrandResultItem[];
|
|
}
|
|
|
|
export interface DeleteBrandHistoryVo {
|
|
items: DeleteBrandResultItem[];
|
|
}
|
|
|
|
export interface DeleteBrandRunRequest {
|
|
files: UploadedFileRef[];
|
|
user_id: number;
|
|
}
|
|
|
|
export interface ConvertTemplateVo {
|
|
id: string;
|
|
templateCode: string;
|
|
templateName: string;
|
|
outputFilename: string;
|
|
isDefault?: boolean;
|
|
builtIn?: boolean;
|
|
}
|
|
|
|
export interface ConvertTemplateImportRequest {
|
|
templateName: string;
|
|
templateContent: string;
|
|
}
|
|
|
|
export interface ExcelInfoVo {
|
|
headers: string[];
|
|
totalRows: number;
|
|
}
|
|
|
|
export function getExcelInfo(fileKey: string) {
|
|
return unwrapJavaResponse(
|
|
get<JavaApiResponse<ExcelInfoVo>>(`${JAVA_API_PREFIX}/files/excel-info`, {
|
|
params: { fileKey },
|
|
}),
|
|
);
|
|
}
|
|
|
|
export function runDedupe(
|
|
request: Omit<DedupeRunRequest, "user_id"> | DedupeRunRequest,
|
|
) {
|
|
return unwrapJavaResponse(
|
|
post<JavaApiResponse<DedupeRunVo>, DedupeRunRequest>(
|
|
`${JAVA_API_PREFIX}/dedupe/run`,
|
|
{
|
|
...request,
|
|
user_id: getCurrentUserId(),
|
|
},
|
|
),
|
|
);
|
|
}
|
|
|
|
export function getDedupeHistory() {
|
|
return unwrapJavaResponse(
|
|
get<JavaApiResponse<DedupeHistoryVo>>(`${JAVA_API_PREFIX}/dedupe/history`, {
|
|
params: { user_id: getCurrentUserId() },
|
|
}),
|
|
);
|
|
}
|
|
|
|
export function deleteDedupeHistory(resultId: number) {
|
|
return unwrapJavaResponse(
|
|
del<JavaApiResponse<null>>(
|
|
`${JAVA_API_PREFIX}/dedupe/history/${resultId}`,
|
|
{
|
|
params: { user_id: getCurrentUserId() },
|
|
},
|
|
),
|
|
);
|
|
}
|
|
|
|
export function runSplit(
|
|
request: Omit<SplitRunRequest, "user_id"> | SplitRunRequest,
|
|
) {
|
|
return unwrapJavaResponse(
|
|
post<JavaApiResponse<SplitRunVo>, SplitRunRequest>(
|
|
`${JAVA_API_PREFIX}/split/run`,
|
|
{
|
|
...request,
|
|
user_id: getCurrentUserId(),
|
|
},
|
|
),
|
|
);
|
|
}
|
|
|
|
export function getSplitHistory() {
|
|
return unwrapJavaResponse(
|
|
get<JavaApiResponse<SplitHistoryVo>>(`${JAVA_API_PREFIX}/split/history`, {
|
|
params: { user_id: getCurrentUserId() },
|
|
}),
|
|
);
|
|
}
|
|
|
|
export function deleteSplitHistory(resultId: number) {
|
|
return unwrapJavaResponse(
|
|
del<JavaApiResponse<null>>(`${JAVA_API_PREFIX}/split/history/${resultId}`, {
|
|
params: { user_id: getCurrentUserId() },
|
|
}),
|
|
);
|
|
}
|
|
|
|
export function getConvertTemplates() {
|
|
return unwrapJavaResponse(
|
|
get<JavaApiResponse<ConvertTemplateVo[]>>(
|
|
`${JAVA_API_PREFIX}/convert/templates`,
|
|
),
|
|
);
|
|
}
|
|
|
|
export function importConvertTemplate(request: ConvertTemplateImportRequest) {
|
|
return unwrapJavaResponse(
|
|
post<JavaApiResponse<ConvertTemplateVo>, ConvertTemplateImportRequest>(
|
|
`${JAVA_API_PREFIX}/convert/templates/import`,
|
|
request,
|
|
),
|
|
);
|
|
}
|
|
|
|
export function setDefaultConvertTemplate(templateCode: string) {
|
|
return unwrapJavaResponse(
|
|
post<JavaApiResponse<null>>(
|
|
`${JAVA_API_PREFIX}/convert/templates/${templateCode}/default`,
|
|
),
|
|
);
|
|
}
|
|
|
|
export function deleteConvertTemplate(templateCode: string) {
|
|
return unwrapJavaResponse(
|
|
del<JavaApiResponse<null>>(
|
|
`${JAVA_API_PREFIX}/convert/templates/${templateCode}`,
|
|
),
|
|
);
|
|
}
|
|
|
|
export function runConvert(
|
|
request: Omit<ConvertRunRequest, "user_id"> | ConvertRunRequest,
|
|
) {
|
|
return unwrapJavaResponse(
|
|
post<JavaApiResponse<ConvertRunVo>, ConvertRunRequest>(
|
|
`${JAVA_API_PREFIX}/convert/run`,
|
|
{
|
|
...request,
|
|
user_id: getCurrentUserId(),
|
|
},
|
|
),
|
|
);
|
|
}
|
|
|
|
export function getConvertHistory() {
|
|
return unwrapJavaResponse(
|
|
get<JavaApiResponse<ConvertHistoryVo>>(
|
|
`${JAVA_API_PREFIX}/convert/history`,
|
|
{
|
|
params: { user_id: getCurrentUserId() },
|
|
},
|
|
),
|
|
);
|
|
}
|
|
|
|
export function deleteConvertHistory(resultId: number) {
|
|
return unwrapJavaResponse(
|
|
del<JavaApiResponse<null>>(
|
|
`${JAVA_API_PREFIX}/convert/history/${resultId}`,
|
|
{
|
|
params: { user_id: getCurrentUserId() },
|
|
},
|
|
),
|
|
);
|
|
}
|
|
|
|
export function runDeleteBrand(
|
|
request: Omit<DeleteBrandRunRequest, "user_id"> | DeleteBrandRunRequest,
|
|
) {
|
|
return unwrapJavaResponse(
|
|
post<JavaApiResponse<DeleteBrandRunVo>, DeleteBrandRunRequest>(
|
|
`${JAVA_API_PREFIX}/delete-brand/run`,
|
|
{
|
|
...request,
|
|
user_id: getCurrentUserId(),
|
|
},
|
|
),
|
|
);
|
|
}
|
|
|
|
export function getDeleteBrandHistory() {
|
|
return unwrapJavaResponse(
|
|
get<JavaApiResponse<DeleteBrandHistoryVo>>(
|
|
`${JAVA_API_PREFIX}/delete-brand/history`,
|
|
{
|
|
params: { user_id: getCurrentUserId() },
|
|
},
|
|
),
|
|
);
|
|
}
|
|
|
|
export function deleteDeleteBrandHistory(resultId: number) {
|
|
return unwrapJavaResponse(
|
|
del<JavaApiResponse<null>>(
|
|
`${JAVA_API_PREFIX}/delete-brand/history/${resultId}`,
|
|
{
|
|
params: { user_id: getCurrentUserId() },
|
|
},
|
|
),
|
|
);
|
|
}
|
|
|
|
export function getDeleteBrandTaskDetail(taskId: number) {
|
|
return unwrapJavaResponse(
|
|
get<JavaApiResponse<DeleteBrandTaskDetailVo>>(
|
|
`${JAVA_API_PREFIX}/delete-brand/tasks/${taskId}`,
|
|
),
|
|
);
|
|
}
|
|
|
|
export function getDeleteBrandTaskDetails(taskIds: number[]) {
|
|
return unwrapJavaResponse(
|
|
post<JavaApiResponse<DeleteBrandTaskBatchVo>, { taskIds: number[] }>(
|
|
`${JAVA_API_PREFIX}/delete-brand/tasks/batch`,
|
|
{ taskIds },
|
|
),
|
|
);
|
|
}
|
|
|
|
export function getDeleteBrandTaskDownloadUrl(taskId: number) {
|
|
return getJavaDownloadUrl(`/delete-brand/tasks/${taskId}/download`);
|
|
}
|
|
|
|
export function submitDeleteBrandResult(
|
|
taskId: number,
|
|
request: DeleteBrandSubmitResultRequest,
|
|
) {
|
|
return unwrapJavaResponse(
|
|
post<JavaApiResponse<null>, DeleteBrandSubmitResultRequest>(
|
|
`${JAVA_API_PREFIX}/delete-brand/tasks/${taskId}/result`,
|
|
request,
|
|
),
|
|
);
|
|
}
|
|
|
|
/** 商品风险处理:备选店铺与匹配相关数据结构。 */
|
|
export interface ProductRiskCandidateVo {
|
|
id: number;
|
|
shop_name: string;
|
|
created_at?: string;
|
|
}
|
|
|
|
export interface ProductRiskShopQueueItem {
|
|
shopName: string;
|
|
matched: boolean;
|
|
shopId?: string;
|
|
platform?: string;
|
|
companyName?: string;
|
|
openStoreUrl?: string;
|
|
matchedUserId?: number;
|
|
matchStatus?: string;
|
|
matchMessage?: string;
|
|
}
|
|
|
|
export interface ProductRiskMatchShopsVo {
|
|
items: ProductRiskShopQueueItem[];
|
|
}
|
|
|
|
export function listProductRiskCandidates() {
|
|
return unwrapJavaResponse(
|
|
get<JavaApiResponse<ProductRiskCandidateVo[]>>(
|
|
`${JAVA_API_PREFIX}/product-risk-resolve/candidates`,
|
|
{
|
|
params: { user_id: getCurrentUserId() },
|
|
},
|
|
),
|
|
);
|
|
}
|
|
|
|
export function addProductRiskCandidate(shopName: string) {
|
|
return unwrapJavaResponse(
|
|
post<
|
|
JavaApiResponse<ProductRiskCandidateVo>,
|
|
{ user_id: number; shop_name: string }
|
|
>(`${JAVA_API_PREFIX}/product-risk-resolve/candidates`, {
|
|
user_id: getCurrentUserId(),
|
|
shop_name: shopName,
|
|
}),
|
|
);
|
|
}
|
|
|
|
export function deleteProductRiskCandidate(id: number) {
|
|
return unwrapJavaResponse(
|
|
del<JavaApiResponse<null>>(
|
|
`${JAVA_API_PREFIX}/product-risk-resolve/candidates/${id}`,
|
|
{
|
|
params: { user_id: getCurrentUserId() },
|
|
},
|
|
),
|
|
);
|
|
}
|
|
|
|
export interface ProductRiskCountryPreferenceVo {
|
|
country_codes: string[];
|
|
}
|
|
|
|
export function getProductRiskCountryPreference() {
|
|
return unwrapJavaResponse(
|
|
get<JavaApiResponse<ProductRiskCountryPreferenceVo>>(
|
|
`${JAVA_API_PREFIX}/product-risk-resolve/country-preference`,
|
|
{
|
|
params: { user_id: getCurrentUserId() },
|
|
},
|
|
),
|
|
);
|
|
}
|
|
|
|
export function putProductRiskCountryPreference(countryCodes: string[]) {
|
|
return unwrapJavaResponse(
|
|
put<
|
|
JavaApiResponse<ProductRiskCountryPreferenceVo>,
|
|
{ user_id: number; country_codes: string[] }
|
|
>(`${JAVA_API_PREFIX}/product-risk-resolve/country-preference`, {
|
|
user_id: getCurrentUserId(),
|
|
country_codes: countryCodes,
|
|
}),
|
|
);
|
|
}
|
|
|
|
export function matchProductRiskShops(shopNames: string[]) {
|
|
return unwrapJavaResponse(
|
|
post<
|
|
JavaApiResponse<ProductRiskMatchShopsVo>,
|
|
{ user_id: number; shop_names: string[] }
|
|
>(`${JAVA_API_PREFIX}/product-risk-resolve/match-shops`, {
|
|
user_id: getCurrentUserId(),
|
|
shop_names: shopNames,
|
|
}),
|
|
);
|
|
}
|
|
|
|
export interface ProductRiskDashboardVo {
|
|
candidateCount: number;
|
|
processedTaskCount: number;
|
|
successTaskCount: number;
|
|
failedTaskCount: number;
|
|
}
|
|
|
|
export interface ProductRiskHistoryItem {
|
|
resultId?: number;
|
|
taskId?: number;
|
|
shopName?: string;
|
|
shopId?: string;
|
|
platform?: string;
|
|
companyName?: string;
|
|
matched?: boolean;
|
|
matchStatus?: string;
|
|
matchMessage?: string;
|
|
taskStatus?: string;
|
|
success?: boolean;
|
|
error?: string;
|
|
outputFilename?: string;
|
|
downloadUrl?: string;
|
|
scheduledAt?: string;
|
|
}
|
|
|
|
export interface ProductRiskHistoryVo {
|
|
items: ProductRiskHistoryItem[];
|
|
}
|
|
|
|
export interface ProductRiskTaskSummary {
|
|
id?: number;
|
|
taskNo?: string;
|
|
status?: string;
|
|
errorMessage?: string;
|
|
createdAt?: string;
|
|
updatedAt?: string;
|
|
finishedAt?: string;
|
|
scheduledAt?: string;
|
|
countryCodes?: string[];
|
|
currentStageIndex?: number;
|
|
activeStageIndex?: number;
|
|
scheduleStages?: ShopMatchTaskStage[];
|
|
}
|
|
|
|
export interface ProductRiskTaskDetailVo {
|
|
task?: ProductRiskTaskSummary;
|
|
items?: ProductRiskHistoryItem[];
|
|
}
|
|
|
|
export interface ProductRiskTaskBatchVo {
|
|
items: ProductRiskTaskDetailVo[];
|
|
missingTaskIds?: number[];
|
|
}
|
|
|
|
export interface ProductRiskPendingDeleteVo {
|
|
removed: boolean;
|
|
}
|
|
|
|
export interface ProductRiskCreateTaskVo {
|
|
taskId: number;
|
|
items: ProductRiskHistoryItem[];
|
|
}
|
|
|
|
export type ShopMatchCandidateVo = ProductRiskCandidateVo;
|
|
export type ShopMatchCountryPreferenceVo = ProductRiskCountryPreferenceVo;
|
|
export type ShopMatchShopQueueItem = ProductRiskShopQueueItem;
|
|
export type ShopMatchDashboardVo = ProductRiskDashboardVo;
|
|
export type ShopMatchHistoryItem = ProductRiskHistoryItem;
|
|
export type ShopMatchHistoryVo = ProductRiskHistoryVo;
|
|
export type ShopMatchTaskDetailVo = ProductRiskTaskDetailVo;
|
|
export type ShopMatchTaskBatchVo = ProductRiskTaskBatchVo;
|
|
export type ShopMatchCreateTaskVo = ProductRiskCreateTaskVo;
|
|
|
|
export interface ShopMatchTaskStage {
|
|
stageIndex?: number;
|
|
scheduledAt?: string;
|
|
status?: string;
|
|
}
|
|
|
|
export function getProductRiskDashboard() {
|
|
return unwrapJavaResponse(
|
|
get<JavaApiResponse<ProductRiskDashboardVo>>(
|
|
`${JAVA_API_PREFIX}/product-risk-resolve/dashboard`,
|
|
{
|
|
params: { user_id: getCurrentUserId() },
|
|
},
|
|
),
|
|
);
|
|
}
|
|
|
|
export function getProductRiskHistory() {
|
|
return unwrapJavaResponse(
|
|
get<JavaApiResponse<ProductRiskHistoryVo>>(
|
|
`${JAVA_API_PREFIX}/product-risk-resolve/history`,
|
|
{
|
|
params: { user_id: getCurrentUserId() },
|
|
},
|
|
),
|
|
);
|
|
}
|
|
|
|
export function deleteProductRiskHistory(resultId: number) {
|
|
return unwrapJavaResponse(
|
|
del<JavaApiResponse<null>>(
|
|
`${JAVA_API_PREFIX}/product-risk-resolve/history/${resultId}`,
|
|
{
|
|
params: { user_id: getCurrentUserId() },
|
|
},
|
|
),
|
|
);
|
|
}
|
|
|
|
export function createProductRiskTask(items: ProductRiskShopQueueItem[]) {
|
|
return unwrapJavaResponse(
|
|
post<
|
|
JavaApiResponse<ProductRiskCreateTaskVo>,
|
|
{ user_id: number; items: ProductRiskShopQueueItem[] }
|
|
>(`${JAVA_API_PREFIX}/product-risk-resolve/tasks`, {
|
|
user_id: getCurrentUserId(),
|
|
items,
|
|
}),
|
|
);
|
|
}
|
|
|
|
export function deleteProductRiskTask(taskId: number) {
|
|
return unwrapJavaResponse(
|
|
del<JavaApiResponse<null>>(
|
|
`${JAVA_API_PREFIX}/product-risk-resolve/tasks/${taskId}`,
|
|
{
|
|
params: { user_id: getCurrentUserId() },
|
|
},
|
|
),
|
|
);
|
|
}
|
|
|
|
export function deletePendingProductRiskShopResult(shopName: string) {
|
|
return unwrapJavaResponse(
|
|
del<JavaApiResponse<ProductRiskPendingDeleteVo>>(
|
|
`${JAVA_API_PREFIX}/product-risk-resolve/pending-shop-result`,
|
|
{
|
|
params: { user_id: getCurrentUserId(), shop_name: shopName },
|
|
},
|
|
),
|
|
);
|
|
}
|
|
|
|
export function getProductRiskTasksBatch(taskIds: number[]) {
|
|
return unwrapJavaResponse(
|
|
post<JavaApiResponse<ProductRiskTaskBatchVo>, { taskIds: number[] }>(
|
|
`${JAVA_API_PREFIX}/product-risk-resolve/tasks/batch`,
|
|
{ taskIds },
|
|
),
|
|
);
|
|
}
|
|
|
|
export function getProductRiskResultDownloadUrl(resultId: number) {
|
|
return getJavaDownloadUrl(
|
|
`/product-risk-resolve/results/${resultId}/download`,
|
|
);
|
|
}
|
|
|
|
export function listShopMatchCandidates() {
|
|
return unwrapJavaResponse(
|
|
get<JavaApiResponse<ShopMatchCandidateVo[]>>(
|
|
`${JAVA_API_PREFIX}/shop-match/candidates`,
|
|
{
|
|
params: { user_id: getCurrentUserId() },
|
|
},
|
|
),
|
|
);
|
|
}
|
|
|
|
export function addShopMatchCandidate(shopName: string) {
|
|
return unwrapJavaResponse(
|
|
post<
|
|
JavaApiResponse<ShopMatchCandidateVo>,
|
|
{ user_id: number; shop_name: string }
|
|
>(`${JAVA_API_PREFIX}/shop-match/candidates`, {
|
|
user_id: getCurrentUserId(),
|
|
shop_name: shopName,
|
|
}),
|
|
);
|
|
}
|
|
|
|
export function deleteShopMatchCandidate(id: number) {
|
|
return unwrapJavaResponse(
|
|
del<JavaApiResponse<null>>(`${JAVA_API_PREFIX}/shop-match/candidates/${id}`, {
|
|
params: { user_id: getCurrentUserId() },
|
|
}),
|
|
);
|
|
}
|
|
|
|
export function getShopMatchCountryPreference() {
|
|
return unwrapJavaResponse(
|
|
get<JavaApiResponse<ShopMatchCountryPreferenceVo>>(
|
|
`${JAVA_API_PREFIX}/shop-match/country-preference`,
|
|
{
|
|
params: { user_id: getCurrentUserId() },
|
|
},
|
|
),
|
|
);
|
|
}
|
|
|
|
export function putShopMatchCountryPreference(countryCodes: string[]) {
|
|
return unwrapJavaResponse(
|
|
put<
|
|
JavaApiResponse<ShopMatchCountryPreferenceVo>,
|
|
{ user_id: number; country_codes: string[] }
|
|
>(`${JAVA_API_PREFIX}/shop-match/country-preference`, {
|
|
user_id: getCurrentUserId(),
|
|
country_codes: countryCodes,
|
|
}),
|
|
);
|
|
}
|
|
|
|
export function matchShopMatchShops(shopNames: string[]) {
|
|
return unwrapJavaResponse(
|
|
post<
|
|
JavaApiResponse<ProductRiskMatchShopsVo>,
|
|
{ user_id: number; shop_names: string[] }
|
|
>(`${JAVA_API_PREFIX}/shop-match/match-shops`, {
|
|
user_id: getCurrentUserId(),
|
|
shop_names: shopNames,
|
|
}),
|
|
);
|
|
}
|
|
|
|
export function getShopMatchDashboard() {
|
|
return unwrapJavaResponse(
|
|
get<JavaApiResponse<ShopMatchDashboardVo>>(
|
|
`${JAVA_API_PREFIX}/shop-match/dashboard`,
|
|
{
|
|
params: { user_id: getCurrentUserId() },
|
|
},
|
|
),
|
|
);
|
|
}
|
|
|
|
export function getShopMatchHistory() {
|
|
return unwrapJavaResponse(
|
|
get<JavaApiResponse<ShopMatchHistoryVo>>(
|
|
`${JAVA_API_PREFIX}/shop-match/history`,
|
|
{
|
|
params: { user_id: getCurrentUserId() },
|
|
},
|
|
),
|
|
);
|
|
}
|
|
|
|
export function deleteShopMatchHistory(resultId: number) {
|
|
return unwrapJavaResponse(
|
|
del<JavaApiResponse<null>>(`${JAVA_API_PREFIX}/shop-match/history/${resultId}`, {
|
|
params: { user_id: getCurrentUserId() },
|
|
}),
|
|
);
|
|
}
|
|
|
|
export function createShopMatchTask(
|
|
items: ShopMatchShopQueueItem[],
|
|
countryCodes: string[],
|
|
scheduleTimes?: string[],
|
|
) {
|
|
return unwrapJavaResponse(
|
|
post<
|
|
JavaApiResponse<ShopMatchCreateTaskVo>,
|
|
{ user_id: number; items: ShopMatchShopQueueItem[]; country_codes: string[]; schedule_times?: string[] }
|
|
>(`${JAVA_API_PREFIX}/shop-match/tasks`, {
|
|
user_id: getCurrentUserId(),
|
|
items,
|
|
country_codes: countryCodes,
|
|
schedule_times: scheduleTimes,
|
|
}),
|
|
);
|
|
}
|
|
|
|
export function deleteShopMatchTask(taskId: number) {
|
|
return unwrapJavaResponse(
|
|
del<JavaApiResponse<null>>(`${JAVA_API_PREFIX}/shop-match/tasks/${taskId}`, {
|
|
params: { user_id: getCurrentUserId() },
|
|
}),
|
|
);
|
|
}
|
|
|
|
export function activateShopMatchTask(taskId: number, stageIndex: number) {
|
|
return unwrapJavaResponse(
|
|
post<JavaApiResponse<null>, undefined>(
|
|
`${JAVA_API_PREFIX}/shop-match/tasks/${taskId}/activate?user_id=${encodeURIComponent(String(getCurrentUserId()))}&stage_index=${encodeURIComponent(String(stageIndex))}`,
|
|
undefined,
|
|
),
|
|
);
|
|
}
|
|
|
|
export function completeShopMatchTaskStage(taskId: number, stageIndex: number) {
|
|
return unwrapJavaResponse(
|
|
post<JavaApiResponse<null>, { stage_index: number }>(
|
|
`${JAVA_API_PREFIX}/shop-match/tasks/${taskId}/stage-finished?user_id=${encodeURIComponent(String(getCurrentUserId()))}`,
|
|
{ stage_index: stageIndex },
|
|
),
|
|
);
|
|
}
|
|
|
|
export function getShopMatchTasksBatch(taskIds: number[]) {
|
|
return unwrapJavaResponse(
|
|
post<JavaApiResponse<ShopMatchTaskBatchVo>, { taskIds: number[] }>(
|
|
`${JAVA_API_PREFIX}/shop-match/tasks/batch`,
|
|
{ taskIds },
|
|
),
|
|
);
|
|
}
|
|
|
|
export function getShopMatchResultDownloadUrl(resultId: number) {
|
|
return getJavaDownloadUrl(`/shop-match/results/${resultId}/download`);
|
|
}
|
|
|
|
export function getJavaDownloadUrl(path: string) {
|
|
let raw =
|
|
path.startsWith("http://") || path.startsWith("https://")
|
|
? path
|
|
: `${JAVA_API_PREFIX}${path}`;
|
|
// pywebview 的 save_file_from_url_new 需要完整且带 schema 的 URL
|
|
if (
|
|
!raw.startsWith("http://") &&
|
|
!raw.startsWith("https://") &&
|
|
typeof window !== "undefined"
|
|
) {
|
|
raw = `${window.location.origin}${raw}`;
|
|
}
|
|
const separator = raw.includes("?") ? "&" : "?";
|
|
return `${raw}${separator}user_id=${encodeURIComponent(String(getCurrentUserId()))}`;
|
|
}
|
|
|
|
export { JAVA_API_PREFIX, http };
|
|
|