MatchMaster/server/laf-cloud/functions/passCheckTime.ts

15 lines
616 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import cloud from '@lafjs/cloud'
const db = cloud.database();
import Utils from "@/Utils";
export default async function (ctx: FunctionContext) {
let time =await db.collection("idcount").where({ _id:"690c786db30b6944c56be7aa"}).getOne();
let t=time.data.passcheckTime;
if(Date.now()>t+60*24*3600000){
const endOfDay: any = new Date();
endOfDay.setHours(0, 0, 0, 0); // 设置为明天的0点等同于今天的24点
t = endOfDay.getTime();
await db.collection("idcount").where({ _id: "690c786db30b6944c56be7aa" }).update({ passcheckTime:t});
}
return{code:1,data:{time:t},msg:"成功"}
}