前面的ok了, 绑定与角色
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user