优化了一些文件 增加多店铺
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import { runtimeConfig } from '../../config/runtime.js'
|
||||
import { createClaimToken } from '../../repositories/claim-token-repo.js'
|
||||
import { addHours, nowIso } from '../../utils/time.js'
|
||||
import { randomToken } from '../../utils/random.js'
|
||||
|
||||
export function createTaskClaimToken(taskId) {
|
||||
const createdAt = nowIso()
|
||||
const expiredAt = addHours(createdAt, Number(runtimeConfig.orders.tokenTtlHours || 24))
|
||||
const token = createClaimToken({
|
||||
taskId,
|
||||
token: randomToken(24),
|
||||
status: 'active',
|
||||
expiredAt,
|
||||
usedAt: null,
|
||||
maxUseCount: 1,
|
||||
usedCount: 0,
|
||||
createdAt,
|
||||
updatedAt: createdAt,
|
||||
})
|
||||
|
||||
return {
|
||||
...token,
|
||||
claimUrl: buildClaimUrl(token.token),
|
||||
}
|
||||
}
|
||||
|
||||
export function buildClaimUrl(token) {
|
||||
const baseUrl = String(runtimeConfig.orders.claimBaseUrl || '').trim()
|
||||
return baseUrl ? `${baseUrl.replace(/\/+$/, '')}/${token}` : token
|
||||
}
|
||||
Reference in New Issue
Block a user