feat(M10-A): 完成统一通知中心与投递闭环
This commit is contained in:
@@ -126,6 +126,18 @@ export class OrderStateRepository {
|
||||
actor.actorType, actor.userId, actor.source, reason.slice(0, 512),
|
||||
actor.traceId, nextVersion]
|
||||
);
|
||||
await connection.execute(
|
||||
`INSERT IGNORE INTO qipai_outbox_events
|
||||
(tenant_id, aggregate_type, aggregate_id, event_type, idempotency_key, payload)
|
||||
VALUES (?, 'ORDER', ?, ?, ?, JSON_OBJECT(
|
||||
'storeId', ?, 'orderId', ?, 'customerId', (
|
||||
SELECT user_id FROM qipai_order_user_access
|
||||
WHERE tenant_id = ? AND order_id = ? ORDER BY user_id LIMIT 1
|
||||
), 'fromStatus', ?, 'status', ?, 'action', ?))`,
|
||||
[actor.tenantId, orderId, `ORDER_${action}`,
|
||||
`order:${orderId}:history:${result.insertId}:notification`, order.storeId,
|
||||
orderId, actor.tenantId, orderId, order.status, targetStatus, action]
|
||||
);
|
||||
await connection.execute(
|
||||
`INSERT INTO qipai_audit_logs
|
||||
(tenant_id, actor_type, actor_id, action, resource_type, resource_id,
|
||||
@@ -244,7 +256,7 @@ export class OrderStateRepository {
|
||||
if (this.benefits) {
|
||||
const [users] = await connection.execute<RowDataPacket[]>(
|
||||
`SELECT user_id AS userId FROM qipai_order_user_access
|
||||
WHERE tenant_id = ? AND order_id = ? ORDER BY id LIMIT 1`,
|
||||
WHERE tenant_id = ? AND order_id = ? ORDER BY user_id LIMIT 1`,
|
||||
[tenantId, orderId]
|
||||
);
|
||||
if (users[0]?.userId) {
|
||||
|
||||
Reference in New Issue
Block a user