test commit
This commit is contained in:
@@ -65,7 +65,7 @@ export async function registerUserOrderRoutes(fastify) {
|
||||
if (cartItems.length === 0) return reply.code(400).send({ error: 'Корзина пуста' })
|
||||
|
||||
for (const ci of cartItems) {
|
||||
const available = ci.product.inStock ? ci.product.quantity : 1
|
||||
const available = ci.product.quantity
|
||||
if (ci.qty > available) {
|
||||
return reply.code(409).send({
|
||||
error: `Недостаточно товара: "${ci.product.title}". Доступно: ${available} шт.`,
|
||||
@@ -112,8 +112,6 @@ export async function registerUserOrderRoutes(fastify) {
|
||||
try {
|
||||
created = await prisma.$transaction(async (tx) => {
|
||||
for (const ci of cartItems) {
|
||||
if (!ci.product.inStock) continue
|
||||
|
||||
const res = await tx.product.updateMany({
|
||||
where: { id: ci.productId, quantity: { gte: ci.qty } },
|
||||
data: { quantity: { decrement: ci.qty } },
|
||||
|
||||
Reference in New Issue
Block a user