feat(backend): implement pricing engine for loyalty points and 3-level promotions

This commit is contained in:
Your Name committed 2026-06-06 20:00:18 +07:00
1 parent 36ea126993
commit 77c52e0534
4 files changed
+109 -7

No files matched your search

+20
View File
@@ -0,0 +1,20 @@
import { Elysia, t } from "elysia";
import prisma from "../lib/prisma";
export const promotionsRoute = new Elysia({ prefix: "/promotions" })
.get("/active", async () => {
const now = new Date()
return await prisma.promotion.findMany({
where: {
isActive: true,
OR: [
{ startDate: null },
{ startDate: { lte: now } }
],
AND: [
{ OR: [{ endDate: null }, { endDate: { gte: now } }] }
]
},
orderBy: { level: 'asc' }
});
});