feat(backend): implement pricing engine for loyalty points and 3-level promotions
This commit is contained in:
1 parent
36ea126993
commit
77c52e0534
4 files changed
+109
-7
No files matched your search
@@ -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' }
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user