This commit is contained in:
728
2023-05-31 09:41:51 +08:00
parent d4fa769d7a
commit cbb8f39b3f
3 changed files with 10 additions and 2 deletions

View File

@ -63,6 +63,8 @@ export type Work = Rec & Re & ({
export type Fund = Rec & {
fund: number,
msg: string,
rd?: Dst["_id"]["rd"],
unit?: number,
}
export type Dst = {
@ -81,6 +83,8 @@ export type Act = {
act: "fund",
aid: Agd["_id"],
msg: string,
rd?: Dst["_id"]["rd"],
unit?: number,
} | {
act: "nbr",
uid: number,

View File

@ -123,7 +123,11 @@ export async function pre_fund(
if (!a || a.act !== "fund") return null
const utc = Date.now()
await act_u(actid, { $set: { exp: utc } })
return rec_c(coll.fund, { _id: { uid: pas.uid, aid: a.aid, utc }, fund: 0, msg: a.msg })
return rec_c(coll.fund, {
_id: { uid: pas.uid, aid: a.aid, utc }, fund: 0, msg: a.msg,
...a.rd ? { rd: a.rd } : {},
...a.unit ? { unit: a.unit } : {},
})
}
export async function pre_dst(

View File

@ -133,7 +133,7 @@ Deno.test("rec", async () => {
utce: utc + 2 * utc_h,
})
assertEquals(id, await Promise.all(id.map(_id => rec_c(coll.fund, {
_id, fund: 32, msg: "msg"
_id, fund: 32, msg: "msg", rd: 1, unit: 3,
}))))
assertEquals(await nrec(), { work: 5, fund: 3 })
assertEquals(await nrec({ uid: [2] }), { work: 2, fund: 2 })