refactor cart service and DTOs to improve item handling and delivery method compatibility

This commit is contained in:
2025-12-17 09:21:46 +03:30
parent 87534e8c6f
commit 25a8391ced
4 changed files with 186 additions and 69 deletions
@@ -31,7 +31,7 @@ export class OrdersService {
private readonly orderRepository: OrderRepository,
private readonly eventEmitter2: EventEmitter2,
// private readonly paymentGatewayService: PaymentGatewayService,
) {}
) { }
async checkout(userId: string, restaurantId: string) {
const cart = await this.cartService.findOneOrFail(userId, restaurantId);
@@ -251,8 +251,8 @@ export class OrdersService {
restaurant,
delivery,
paymentMethod,
userAddress: cart?.userAddress ?? null,
carAddress: cart?.carAddress ?? null,
userAddress: delivery.method === DeliveryMethodEnum.DeliveryCourier ? (cart?.userAddress ?? null) : null,
carAddress: delivery.method === DeliveryMethodEnum.DeliveryCar ? (cart?.carAddress ?? null) : null,
orderItemsData,
};
}