feat(edit): 商品编辑页开发

This commit is contained in:
R524809
2026-09-10 17:45:46 +08:00
parent 130a005231
commit 946af649dd
22 changed files with 7034 additions and 518 deletions
+33 -2
View File
@@ -13,6 +13,11 @@ import {
import { decryptStoreSecret } from './store-secret.crypto.js';
import { MediaUploadCleanup } from './media-upload-cleanup.js';
import { materializeCollectionAssets } from './collection-assets.js';
import {
markCatalogSyncUnavailable,
syncOzonCatalog,
type CatalogSyncScope,
} from './ozon-catalog-sync.js';
const connection = new Redis(workerConfig.redisUrl, {
maxRetriesPerRequest: null,
@@ -35,6 +40,18 @@ const objectStorage = new S3Client({
});
const mediaUploadCleanup = new MediaUploadCleanup(database, objectStorage);
type StoreVerificationJob = OutboxJob & { payload: { store_id: string; operation_id: string; secret_id?: string } };
type CatalogSyncJob = OutboxJob & {
payload: {
store_id: string;
secret_id: string;
operation_id: string;
platform_id: string;
scope: CatalogSyncScope;
category_id?: string;
dictionary_id?: string;
query?: string;
};
};
const worker = new Worker<OutboxJob>(
'atlas-dispatch',
@@ -45,6 +62,12 @@ const worker = new Worker<OutboxJob>(
await cleanupCollection(database, job.data as OutboxJob & { payload: { operation_id: string; collection_item_ids: string[] } });
} else if (job.name === 'collection.assets.materialize.requested' || job.name === 'collection.assets.retry.requested') {
await materializeCollectionAssets(database, objectStorage, workerConfig.objectStorageBucket, job.data);
} else if (
job.name === 'platform_category_tree_sync.requested' ||
job.name === 'platform_category_attribute_sync.requested' ||
job.name === 'platform_attribute_dictionary_sync.requested'
) {
await syncOzonCatalog(database, job.data as CatalogSyncJob);
}
},
{ connection, concurrency: 5 },
@@ -59,8 +82,16 @@ async function cleanupCollection(database: Database, job: OutboxJob & { payload:
}
worker.on('failed', (job, error) => {
if (!job || job.attemptsMade < (job.opts.attempts ?? 1) || job.name !== 'store_credential_verification.requested') return;
void markUnavailable(database, job.data as StoreVerificationJob, error);
if (!job || job.attemptsMade < (job.opts.attempts ?? 1)) return;
if (job.name === 'store_credential_verification.requested') {
void markUnavailable(database, job.data as StoreVerificationJob, error);
} else if (
job.name === 'platform_category_tree_sync.requested' ||
job.name === 'platform_category_attribute_sync.requested' ||
job.name === 'platform_attribute_dictionary_sync.requested'
) {
void markCatalogSyncUnavailable(database, job.data as CatalogSyncJob, error);
}
});
async function verifyStoreCredentials(database: Database, job: StoreVerificationJob) {