前面的ok了, 绑定与角色

This commit is contained in:
yml
2026-05-03 20:58:18 +08:00
parent dd2192b6ae
commit 0f0253bffe
30 changed files with 1900 additions and 409 deletions
@@ -23,6 +23,35 @@ export async function findOrderByPlatformOrderId({ provider = 'agiso', platform,
return /** @type {OrderRow | null} */ (result.rows[0] || null)
}
/** @returns {Promise<OrderRow | null>} */
export async function findOrderByPlatformOrderIdCandidates({
provider = 'agiso',
platform,
shopIds = [],
platformOrderId,
}) {
const normalizedShopIds = [...new Set((Array.isArray(shopIds) ? shopIds : [])
.map((item) => String(item || '').trim())
.filter(Boolean))]
if (!platform || !platformOrderId || normalizedShopIds.length === 0) {
return null
}
const result = await query(
`
SELECT *
FROM orders
WHERE provider = $1 AND platform = $2 AND shop_id = ANY($3::text[]) AND platform_order_id = $4
ORDER BY id DESC
LIMIT 1
`,
[provider, platform, normalizedShopIds, platformOrderId],
)
return /** @type {OrderRow | null} */ (result.rows[0] || null)
}
/** @returns {Promise<OrderRow | null>} */
/** @param {OrderUpsertInput} input */
export async function createOrder(input) {