16 lines
572 B
TypeScript
16 lines
572 B
TypeScript
import cloud from '@lafjs/cloud'
|
|
const db = cloud.database();
|
|
import Utils from "@/Utils";
|
|
export default async function (ctx: FunctionContext) {
|
|
let cdk= ctx.body.cdk;
|
|
cdk = cdk.toLowerCase();
|
|
let info = await db.collection("idcount").where({ _id: "694e064b35004ffb5aba0dc6" }).getOne();
|
|
let count = info.data.count;
|
|
if(count.includes(cdk)){
|
|
return {code:0,data:"兑换码已存在"};
|
|
}
|
|
count.push(cdk);
|
|
await db.collection("idcount").where({ _id: "694e064b35004ffb5aba0dc6" }).update({count:count});
|
|
return {code:1,data:"兑换码保存成功"};
|
|
}
|