cb/server/laf-cloud/functions/searchOrder.ts
2026-07-02 11:22:24 +08:00

24 lines
908 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 outTradeNo=ctx.body.outTradeNo;
const res = await db.collection("order").where({ outTradeNo:outTradeNo}).getOne();
console.log(res)
return { data:res}
}
function formatMilliseconds(ms) {
// 创建一个新的Date对象
const date = new Date(ms);
// 获取各个时间部分
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0'); // 月份从0开始所以要加1
const day = String(date.getDate()).padStart(2, '0');
const hours = String(date.getHours()).padStart(2, '0');
const minutes = String(date.getMinutes()).padStart(2, '0');
const seconds = String(date.getSeconds()).padStart(2, '0');
// 组合成想要的格式
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
}