fix(edit): 类目问题修改
This commit is contained in:
+8
-34
@@ -18,6 +18,7 @@ import {
|
||||
syncOzonCatalog,
|
||||
type CatalogSyncScope,
|
||||
} from './ozon-catalog-sync.js';
|
||||
import { scheduleStoreCategoryTreeSync } from './store-category-tree-scheduler.js';
|
||||
|
||||
const connection = new Redis(workerConfig.redisUrl, {
|
||||
maxRetriesPerRequest: null,
|
||||
@@ -161,8 +162,8 @@ async function completeVerification(
|
||||
rejectedStatus?: 401 | 403,
|
||||
) {
|
||||
await database.workspaceTransaction(job.workspaceId, async (tx) => {
|
||||
const current = await tx.query<{ id: string }>(
|
||||
`SELECT s.id FROM atlas.stores s JOIN atlas.store_secrets secret ON secret.id = $2
|
||||
const current = await tx.query<{ id: string; platform_id: string }>(
|
||||
`SELECT s.id, s.platform_id FROM atlas.stores s JOIN atlas.store_secrets secret ON secret.id = $2
|
||||
WHERE s.id = $1 AND s.deleted_at IS NULL AND secret.store_id = s.id
|
||||
AND secret.revoked_at IS NULL FOR UPDATE`,
|
||||
[job.payload.store_id, job.payload.secret_id ?? ''],
|
||||
@@ -216,38 +217,11 @@ async function completeVerification(
|
||||
],
|
||||
);
|
||||
if (!valid) return;
|
||||
const catalogOperation = await tx.query<{
|
||||
id: string;
|
||||
}>(
|
||||
`INSERT INTO atlas.operations
|
||||
(workspace_id, kind, resource_type, resource_id)
|
||||
VALUES (current_setting('app.workspace_id')::uuid,
|
||||
'store_category_tree_sync', 'store', $1)
|
||||
RETURNING id`,
|
||||
[job.payload.store_id],
|
||||
);
|
||||
const operationId = catalogOperation.rows[0]?.id;
|
||||
if (!operationId) throw new Error('Unable to create store catalog sync operation');
|
||||
await tx.query(
|
||||
`INSERT INTO atlas.outbox_events
|
||||
(workspace_id, aggregate_type, aggregate_id, event_type, event_payload, deduplication_key)
|
||||
VALUES (current_setting('app.workspace_id')::uuid, 'store', $1,
|
||||
'store_category_tree_sync.requested', $2::jsonb, $3)`,
|
||||
[
|
||||
job.payload.store_id,
|
||||
JSON.stringify({
|
||||
store_id: job.payload.store_id,
|
||||
secret_id: job.payload.secret_id,
|
||||
operation_id: operationId,
|
||||
platform_id: (await tx.query<{ platform_id: string }>(
|
||||
`SELECT platform_id FROM atlas.stores WHERE id = $1`,
|
||||
[job.payload.store_id],
|
||||
)).rows[0]?.platform_id,
|
||||
scope: 'tree',
|
||||
}),
|
||||
operationId,
|
||||
],
|
||||
);
|
||||
await scheduleStoreCategoryTreeSync(tx, {
|
||||
storeId: job.payload.store_id,
|
||||
platformId: current.rows[0].platform_id,
|
||||
secretId: job.payload.secret_id ?? '',
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user