This commit is contained in:
2025-12-17 11:59:10 +03:30
parent 28011286f9
commit 26220dbb8b
2 changed files with 12 additions and 8 deletions
+5 -2
View File
@@ -21,6 +21,7 @@ import { CouponService } from 'src/modules/coupons/providers/coupon.service';
import { OrderCouponDetail } from 'src/modules/orders/interface/order-status'; import { OrderCouponDetail } from 'src/modules/orders/interface/order-status';
import { CouponType } from 'src/modules/coupons/interface/coupon'; import { CouponType } from 'src/modules/coupons/interface/coupon';
import { UserWallet } from 'src/modules/users/entities/user-wallet.entity'; import { UserWallet } from 'src/modules/users/entities/user-wallet.entity';
import { PaymentMethodEnum } from 'src/modules/payments/interface/payment';
@Injectable() @Injectable()
export class CartService { export class CartService {
@@ -221,8 +222,10 @@ export class CartService {
): Promise<Cart> { ): Promise<Cart> {
const cart = await this.findOneOrFail(userId, restaurantId); const cart = await this.findOneOrFail(userId, restaurantId);
await this.getEnabledPaymentMethodOrFail(restaurantId, setPaymentMethodDto.paymentMethodId); const paymentMethod = await this.getEnabledPaymentMethodOrFail(restaurantId, setPaymentMethodDto.paymentMethodId);
if (paymentMethod.method === PaymentMethodEnum.Wallet) {
await this.assertWalletHasEnoughBalance(userId, restaurantId, cart.total); await this.assertWalletHasEnoughBalance(userId, restaurantId, cart.total);
}
cart.paymentMethodId = setPaymentMethodDto.paymentMethodId; cart.paymentMethodId = setPaymentMethodDto.paymentMethodId;
return this.recalculateAndSaveCart(cart); return this.recalculateAndSaveCart(cart);
} }
@@ -236,7 +239,7 @@ export class CartService {
user: { id: userId }, user: { id: userId },
restaurant: { id: restaurantId }, restaurant: { id: restaurantId },
}); });
console.log('wallet', wallet);
if (!wallet) { if (!wallet) {
throw new BadRequestException('User wallet not found'); throw new BadRequestException('User wallet not found');
} }
+3 -2
View File
@@ -8,8 +8,9 @@ export class CacheService implements OnModuleInit {
this.logger.log('Pinging Redis to check connection...'); this.logger.log('Pinging Redis to check connection...');
try { try {
// 3. Try to set and get a test key // 3. Try to set and get a test key
await this.cacheManager.set('ping', 'pong', 10); // 10-second TTL // Use the wrapper to keep TTL units consistent (seconds -> ms)
const result = await this.cacheManager.get('ping'); await this.set('ping', 'pong', 10); // 10-second TTL
const result = await this.get('ping');
if (result === 'pong') { if (result === 'pong') {
this.logger.log('✅ Redis connection successful (set/get test passed).'); this.logger.log('✅ Redis connection successful (set/get test passed).');