separated clients handlers, cart->checkout ppline

This commit is contained in:
2026-02-11 20:53:47 +07:00
parent 6409d66dfd
commit a3aaafd7ac
20 changed files with 658 additions and 369 deletions

View File

@@ -156,7 +156,7 @@ class OrderService:
return await self.order_items_repo.get_items_count(session, order_id=order.id)
async def build_cart_dto(
async def build_pagination_cart_dto(
self,
session: AsyncSession,
*,
@@ -190,4 +190,30 @@ class OrderService:
cart_items.append(cart_item)
total += cart_item.total
return CartDTO(items=cart_items, total=total)
return CartDTO(items=cart_items, total=total, order_id=order.id)
async def build_full_cart_dto(self, session: AsyncSession, customer: int):
order = await self.order_repo.get_draft_order_by_user(session, customer)
cart_items = []
total = 0
if not order:
return CartDTO(items=cart_items, total=total)
for cart_item in order.items:
if cart_item.quantity <= 0:
await self.order_items_repo.delete_item(session, item_id=cart_item.id)
continue
dto = CartItemDTO(
product_id=cart_item.product.id,
name=cart_item.product.name,
quantity=cart_item.quantity,
price=cart_item.product.price,
)
cart_items.append(dto)
total += dto.total
return CartDTO(cart_items, total=total, order_id=order.id)