fix : update shop
This commit is contained in:
@@ -424,7 +424,7 @@ export const enum AdminMessage {
|
|||||||
ADMIN_ROLE_NOT_FOUND = 'نقش ادمین یافت نشد',
|
ADMIN_ROLE_NOT_FOUND = 'نقش ادمین یافت نشد',
|
||||||
}
|
}
|
||||||
|
|
||||||
export const enum RestMessage {
|
export const enum ShopMessage {
|
||||||
NOT_FOUND = 'کسب و کار یافت نشد',
|
NOT_FOUND = 'کسب و کار یافت نشد',
|
||||||
DUPLICATE_SUBSCRIPTION_ID = 'شناسه اشتراک تکراری است',
|
DUPLICATE_SUBSCRIPTION_ID = 'شناسه اشتراک تکراری است',
|
||||||
SYSTEM_ROLE_NOT_FOUND = 'نقش سیستمی یافت نشد',
|
SYSTEM_ROLE_NOT_FOUND = 'نقش سیستمی یافت نشد',
|
||||||
@@ -466,6 +466,7 @@ export const enum RestMessage {
|
|||||||
PAYMENT_GATEWAY_ERROR = 'خطا در اتصال به درگاه پرداخت',
|
PAYMENT_GATEWAY_ERROR = 'خطا در اتصال به درگاه پرداخت',
|
||||||
QUOTA_UPDATED = 'حجم ایمیل با موفقیت به روز شد',
|
QUOTA_UPDATED = 'حجم ایمیل با موفقیت به روز شد',
|
||||||
USER_DOES_NOT_HAVE_ACCESS_TO_SERVICE = 'کاربر دسترسی به این سرویس را ندارد',
|
USER_DOES_NOT_HAVE_ACCESS_TO_SERVICE = 'کاربر دسترسی به این سرویس را ندارد',
|
||||||
|
SHOP_EXIST_WITH_THIS_SLUG='فروشگاه با این اسلاگ وجود دارد'
|
||||||
}
|
}
|
||||||
|
|
||||||
export const enum DomainMessage {
|
export const enum DomainMessage {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { UserService } from 'src/modules/users/providers/user.service';
|
|||||||
import { randomInt } from 'crypto';
|
import { randomInt } from 'crypto';
|
||||||
import { TokensService } from './tokens.service';
|
import { TokensService } from './tokens.service';
|
||||||
import { ShopRepository } from 'src/modules/shops/repositories/rest.repository';
|
import { ShopRepository } from 'src/modules/shops/repositories/rest.repository';
|
||||||
import { AuthMessage, RestMessage } from 'src/common/enums/message.enum';
|
import { AuthMessage, ShopMessage } from 'src/common/enums/message.enum';
|
||||||
import { AdminRepository } from 'src/modules/admin/repositories/admin.repository';
|
import { AdminRepository } from 'src/modules/admin/repositories/admin.repository';
|
||||||
import { AdminLoginTransformer } from '../transformers/admin-login.transformer';
|
import { AdminLoginTransformer } from '../transformers/admin-login.transformer';
|
||||||
import { UserLoginTransformer } from '../transformers/user-login.transformer';
|
import { UserLoginTransformer } from '../transformers/user-login.transformer';
|
||||||
@@ -71,7 +71,7 @@ export class AuthService {
|
|||||||
const shop = await this.shopRepository.findOne({ slug });
|
const shop = await this.shopRepository.findOne({ slug });
|
||||||
|
|
||||||
if (!shop) {
|
if (!shop) {
|
||||||
throw new BadRequestException(RestMessage.NOT_FOUND);
|
throw new BadRequestException(ShopMessage.NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
const tokens = await this.tokensService.generateTokens(user.id, shop.id, false, slug);
|
const tokens = await this.tokensService.generateTokens(user.id, shop.id, false, slug);
|
||||||
@@ -96,7 +96,7 @@ export class AuthService {
|
|||||||
const shop = await this.shopRepository.findOne({ slug });
|
const shop = await this.shopRepository.findOne({ slug });
|
||||||
|
|
||||||
if (!shop) {
|
if (!shop) {
|
||||||
throw new BadRequestException(RestMessage.NOT_FOUND);
|
throw new BadRequestException(ShopMessage.NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
const tokens = await this.tokensService.generateTokens(admin.id, shop.id, true, slug);
|
const tokens = await this.tokensService.generateTokens(admin.id, shop.id, true, slug);
|
||||||
@@ -120,7 +120,7 @@ export class AuthService {
|
|||||||
const shop = await this.shopRepository.findOne({ slug });
|
const shop = await this.shopRepository.findOne({ slug });
|
||||||
|
|
||||||
if (!shop) {
|
if (!shop) {
|
||||||
throw new BadRequestException(RestMessage.NOT_FOUND);
|
throw new BadRequestException(ShopMessage.NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
const tokens = await this.tokensService.generateTokens(admin.id, shop.id, true, slug);
|
const tokens = await this.tokensService.generateTokens(admin.id, shop.id, true, slug);
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import { EntityManager } from '@mikro-orm/postgresql';
|
|||||||
import { RequiredEntityData } from '@mikro-orm/core';
|
import { RequiredEntityData } from '@mikro-orm/core';
|
||||||
import { Coupon } from '../entities/coupon.entity';
|
import { Coupon } from '../entities/coupon.entity';
|
||||||
import { CouponType } from '../interface/coupon';
|
import { CouponType } from '../interface/coupon';
|
||||||
import { CouponMessage, RestMessage } from 'src/common/enums/message.enum';
|
import { CouponMessage, ShopMessage } from 'src/common/enums/message.enum';
|
||||||
import { randomBytes } from 'node:crypto';
|
import { randomBytes } from 'node:crypto';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@@ -22,7 +22,7 @@ export class CouponService {
|
|||||||
async create(shopId: string, createCouponDto: CreateCouponDto): Promise<Coupon> {
|
async create(shopId: string, createCouponDto: CreateCouponDto): Promise<Coupon> {
|
||||||
const shop = await this.shopRepository.findOne({ id: shopId });
|
const shop = await this.shopRepository.findOne({ id: shopId });
|
||||||
if (!shop) {
|
if (!shop) {
|
||||||
throw new NotFoundException(RestMessage.NOT_FOUND);
|
throw new NotFoundException(ShopMessage.NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if code already exists
|
// Check if code already exists
|
||||||
@@ -260,7 +260,7 @@ export class CouponService {
|
|||||||
async generateCouponCode(shopId: string): Promise<{ code: string }> {
|
async generateCouponCode(shopId: string): Promise<{ code: string }> {
|
||||||
const shop = await this.shopRepository.findOne({ id: shopId });
|
const shop = await this.shopRepository.findOne({ id: shopId });
|
||||||
if (!shop) {
|
if (!shop) {
|
||||||
throw new NotFoundException(RestMessage.NOT_FOUND);
|
throw new NotFoundException(ShopMessage.NOT_FOUND);
|
||||||
}
|
}
|
||||||
const code = this.generateShortCode(shop.slug);
|
const code = this.generateShortCode(shop.slug);
|
||||||
const existing = await this.couponRepository.findOne({ code, shop: { id: shopId } });
|
const existing = await this.couponRepository.findOne({ code, shop: { id: shopId } });
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { Shop } from '../../shops/entities/shop.entity';
|
|||||||
import { CreatePreferenceDto } from '../dto/create-preference.dto';
|
import { CreatePreferenceDto } from '../dto/create-preference.dto';
|
||||||
import { UpdatePreferenceDto } from '../dto/update-preference.dto';
|
import { UpdatePreferenceDto } from '../dto/update-preference.dto';
|
||||||
import { NotifTitleEnum } from '../interfaces/notification.interface';
|
import { NotifTitleEnum } from '../interfaces/notification.interface';
|
||||||
import { NotificationMessage, RestMessage } from 'src/common/enums/message.enum';
|
import { NotificationMessage, ShopMessage } from 'src/common/enums/message.enum';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class NotificationPreferenceService {
|
export class NotificationPreferenceService {
|
||||||
@@ -14,7 +14,7 @@ export class NotificationPreferenceService {
|
|||||||
async create(shopId: string, dto: CreatePreferenceDto): Promise<NotificationPreference> {
|
async create(shopId: string, dto: CreatePreferenceDto): Promise<NotificationPreference> {
|
||||||
const shop = await this.em.findOne(Shop, { id: shopId });
|
const shop = await this.em.findOne(Shop, { id: shopId });
|
||||||
if (!shop) {
|
if (!shop) {
|
||||||
throw new NotFoundException(RestMessage.NOT_FOUND);
|
throw new NotFoundException(ShopMessage.NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
const preference = this.em.create(NotificationPreference, {
|
const preference = this.em.create(NotificationPreference, {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { CreatePaymentMethodDto } from '../dto/create-payment-method.dto';
|
|||||||
import { UpdatePaymentMethodDto } from '../dto/update-payment-method.dto';
|
import { UpdatePaymentMethodDto } from '../dto/update-payment-method.dto';
|
||||||
import { RequiredEntityData } from '@mikro-orm/core';
|
import { RequiredEntityData } from '@mikro-orm/core';
|
||||||
import { Shop } from '../../shops/entities/shop.entity';
|
import { Shop } from '../../shops/entities/shop.entity';
|
||||||
import { RestMessage, PaymentMessage } from 'src/common/enums/message.enum';
|
import { ShopMessage, PaymentMessage } from 'src/common/enums/message.enum';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class PaymentMethodService {
|
export class PaymentMethodService {
|
||||||
@@ -19,7 +19,7 @@ export class PaymentMethodService {
|
|||||||
// Check if shop exists
|
// Check if shop exists
|
||||||
const shop = await this.em.findOne(Shop, { id: shopId });
|
const shop = await this.em.findOne(Shop, { id: shopId });
|
||||||
if (!shop) {
|
if (!shop) {
|
||||||
throw new NotFoundException(RestMessage.NOT_FOUND);
|
throw new NotFoundException(ShopMessage.NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
const paymentMethod = this.paymentMethodRepository.create({
|
const paymentMethod = this.paymentMethodRepository.create({
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { CategoryRepository } from '../repositories/category.repository';
|
|||||||
import { EntityManager } from '@mikro-orm/postgresql';
|
import { EntityManager } from '@mikro-orm/postgresql';
|
||||||
import { RequiredEntityData } from '@mikro-orm/core';
|
import { RequiredEntityData } from '@mikro-orm/core';
|
||||||
import { Category } from '../entities/category.entity';
|
import { Category } from '../entities/category.entity';
|
||||||
import { CategoryMessage, RestMessage } from 'src/common/enums/message.enum';
|
import { CategoryMessage, ShopMessage } from 'src/common/enums/message.enum';
|
||||||
import { Shop } from '../../shops/entities/shop.entity';
|
import { Shop } from '../../shops/entities/shop.entity';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@@ -18,7 +18,7 @@ export class CategoryService {
|
|||||||
async create(shopId: string, dto: CreateCategoryDto): Promise<Category> {
|
async create(shopId: string, dto: CreateCategoryDto): Promise<Category> {
|
||||||
const shop = await this.em.findOne(Shop, { id: shopId });
|
const shop = await this.em.findOne(Shop, { id: shopId });
|
||||||
if (!shop) {
|
if (!shop) {
|
||||||
throw new NotFoundException(RestMessage.NOT_FOUND);
|
throw new NotFoundException(ShopMessage.NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
let parent: Category | undefined;
|
let parent: Category | undefined;
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import { UserRepository } from '../../users/repositories/user.repository';
|
|||||||
import { EntityManager } from '@mikro-orm/postgresql';
|
import { EntityManager } from '@mikro-orm/postgresql';
|
||||||
import { RequiredEntityData } from '@mikro-orm/core';
|
import { RequiredEntityData } from '@mikro-orm/core';
|
||||||
import { Review } from '../entities/review.entity';
|
import { Review } from '../entities/review.entity';
|
||||||
import { OrderMessage, ProductMessage, RestMessage, UserMessage, ReviewMessage } from 'src/common/enums/message.enum';
|
import { OrderMessage, ProductMessage, ShopMessage, UserMessage, ReviewMessage } from 'src/common/enums/message.enum';
|
||||||
import { Order } from '../../orders/entities/order.entity';
|
import { Order } from '../../orders/entities/order.entity';
|
||||||
import { OrderItem } from '../../orders/entities/order-item.entity';
|
import { OrderItem } from '../../orders/entities/order-item.entity';
|
||||||
import { Shop } from '../../shops/entities/shop.entity';
|
import { Shop } from '../../shops/entities/shop.entity';
|
||||||
@@ -115,7 +115,7 @@ export class ReviewService {
|
|||||||
const { shopSlug: restuarantSlug, ...restDto } = dto;
|
const { shopSlug: restuarantSlug, ...restDto } = dto;
|
||||||
const shop = await this.em.findOne(Shop, { slug: restuarantSlug });
|
const shop = await this.em.findOne(Shop, { slug: restuarantSlug });
|
||||||
if (!shop) {
|
if (!shop) {
|
||||||
throw new NotFoundException(RestMessage.NOT_FOUND);
|
throw new NotFoundException(ShopMessage.NOT_FOUND);
|
||||||
}
|
}
|
||||||
return this.reviewRepository.findAllPaginated({ ...restDto, shopId: shop.id });
|
return this.reviewRepository.findAllPaginated({ ...restDto, shopId: shop.id });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import { EntityManager } from '@mikro-orm/postgresql';
|
|||||||
import { CreateRoleDto } from '../dto/create-role.dto';
|
import { CreateRoleDto } from '../dto/create-role.dto';
|
||||||
import { UpdateRoleDto } from '../dto/update-role.dto';
|
import { UpdateRoleDto } from '../dto/update-role.dto';
|
||||||
import { RolePermission } from '../entities/rolePermission.entity';
|
import { RolePermission } from '../entities/rolePermission.entity';
|
||||||
import { RestMessage, RoleMessage } from 'src/common/enums/message.enum';
|
import { ShopMessage, RoleMessage } from 'src/common/enums/message.enum';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class RolesService {
|
export class RolesService {
|
||||||
@@ -33,7 +33,7 @@ export class RolesService {
|
|||||||
if (shopId) {
|
if (shopId) {
|
||||||
shop = await this.em.findOne(Shop, { id: shopId });
|
shop = await this.em.findOne(Shop, { id: shopId });
|
||||||
if (!shop) {
|
if (!shop) {
|
||||||
throw new NotFoundException(RestMessage.NOT_FOUND);
|
throw new NotFoundException(ShopMessage.NOT_FOUND);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import { UpdateScheduleDto } from '../dto/update-schedule.dto';
|
|||||||
import { FindSchedulesDto } from '../dto/find-schedules.dto';
|
import { FindSchedulesDto } from '../dto/find-schedules.dto';
|
||||||
import { ShopRepository } from '../repositories/rest.repository';
|
import { ShopRepository } from '../repositories/rest.repository';
|
||||||
import { Shop } from '../entities/shop.entity';
|
import { Shop } from '../entities/shop.entity';
|
||||||
import { RestMessage } from 'src/common/enums/message.enum';
|
import { ShopMessage } from 'src/common/enums/message.enum';
|
||||||
// import { RestMessage } from 'src/common/enums/message.enum';
|
// import { RestMessage } from 'src/common/enums/message.enum';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@@ -51,7 +51,7 @@ export class ScheduleService {
|
|||||||
async findTodaySchedules(slug: string): Promise<Schedule | null> {
|
async findTodaySchedules(slug: string): Promise<Schedule | null> {
|
||||||
const shop = await this.em.findOne(Shop, { slug });
|
const shop = await this.em.findOne(Shop, { slug });
|
||||||
if (!shop) {
|
if (!shop) {
|
||||||
throw new NotFoundException(RestMessage.NOT_FOUND);
|
throw new NotFoundException(ShopMessage.NOT_FOUND);
|
||||||
}
|
}
|
||||||
const today = new Date();
|
const today = new Date();
|
||||||
const weekDay = today.getDay(); // 0 = Sunday, 6 = Saturday
|
const weekDay = today.getDay(); // 0 = Sunday, 6 = Saturday
|
||||||
@@ -68,7 +68,7 @@ export class ScheduleService {
|
|||||||
async findScheduleBySlug(slug: string): Promise<Schedule[]> {
|
async findScheduleBySlug(slug: string): Promise<Schedule[]> {
|
||||||
const shop = await this.em.findOne(Shop, { slug });
|
const shop = await this.em.findOne(Shop, { slug });
|
||||||
if (!shop) {
|
if (!shop) {
|
||||||
throw new NotFoundException(RestMessage.NOT_FOUND);
|
throw new NotFoundException(ShopMessage.NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
const where: FilterQuery<Schedule> = {
|
const where: FilterQuery<Schedule> = {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { UpdateSubscriptionDto } from '../dto/update-subscription.dto';
|
|||||||
import { Shop } from '../entities/shop.entity';
|
import { Shop } from '../entities/shop.entity';
|
||||||
import { EntityManager } from '@mikro-orm/postgresql';
|
import { EntityManager } from '@mikro-orm/postgresql';
|
||||||
import { ShopRepository } from '../repositories/rest.repository';
|
import { ShopRepository } from '../repositories/rest.repository';
|
||||||
import { RestMessage } from 'src/common/enums/message.enum';
|
import { ShopMessage } from 'src/common/enums/message.enum';
|
||||||
import { FindRestaurantsDto } from '../dto/find-shops.dto';
|
import { FindRestaurantsDto } from '../dto/find-shops.dto';
|
||||||
import { PaginatedResult } from 'src/common/interfaces/pagination.interface';
|
import { PaginatedResult } from 'src/common/interfaces/pagination.interface';
|
||||||
import { Admin } from '../../admin/entities/admin.entity';
|
import { Admin } from '../../admin/entities/admin.entity';
|
||||||
@@ -46,7 +46,7 @@ export class ShopService {
|
|||||||
|
|
||||||
const validateSubscriptionId = await em.findOne(Shop, { subscriptionId: dto.subscriptionId })
|
const validateSubscriptionId = await em.findOne(Shop, { subscriptionId: dto.subscriptionId })
|
||||||
if (validateSubscriptionId) {
|
if (validateSubscriptionId) {
|
||||||
throw new BadRequestException(RestMessage.DUPLICATE_SUBSCRIPTION_ID);
|
throw new BadRequestException(ShopMessage.DUPLICATE_SUBSCRIPTION_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create shop
|
// Create shop
|
||||||
@@ -64,7 +64,7 @@ export class ShopService {
|
|||||||
|
|
||||||
const role = await em.findOne(Role, { isSystem: true });
|
const role = await em.findOne(Role, { isSystem: true });
|
||||||
if (!role) {
|
if (!role) {
|
||||||
throw new BadRequestException(RestMessage.SYSTEM_ROLE_NOT_FOUND);
|
throw new BadRequestException(ShopMessage.SYSTEM_ROLE_NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
const normalizedPhone = normalizePhone(dto.phone);
|
const normalizedPhone = normalizePhone(dto.phone);
|
||||||
@@ -116,7 +116,7 @@ export class ShopService {
|
|||||||
const shop = await this.em.findOne(Shop, { slug });
|
const shop = await this.em.findOne(Shop, { slug });
|
||||||
|
|
||||||
if (!shop) {
|
if (!shop) {
|
||||||
throw new NotFoundException(RestMessage.NOT_FOUND);
|
throw new NotFoundException(ShopMessage.NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
return shop;
|
return shop;
|
||||||
@@ -126,7 +126,7 @@ export class ShopService {
|
|||||||
const shop = await this.shopRepository.findOne({ id });
|
const shop = await this.shopRepository.findOne({ id });
|
||||||
|
|
||||||
if (!shop) {
|
if (!shop) {
|
||||||
throw new NotFoundException(RestMessage.NOT_FOUND);
|
throw new NotFoundException(ShopMessage.NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
return shop;
|
return shop;
|
||||||
@@ -137,7 +137,7 @@ export class ShopService {
|
|||||||
const shop = await this.shopRepository.findOne({ subscriptionId });
|
const shop = await this.shopRepository.findOne({ subscriptionId });
|
||||||
console.log('shop', shop)
|
console.log('shop', shop)
|
||||||
if (!shop) {
|
if (!shop) {
|
||||||
throw new NotFoundException(RestMessage.NOT_FOUND);
|
throw new NotFoundException(ShopMessage.NOT_FOUND);
|
||||||
}
|
}
|
||||||
return shop;
|
return shop;
|
||||||
}
|
}
|
||||||
@@ -146,19 +146,25 @@ export class ShopService {
|
|||||||
const shop = await this.findBySlug(slug);
|
const shop = await this.findBySlug(slug);
|
||||||
return shop;
|
return shop;
|
||||||
}
|
}
|
||||||
// TODO : it must be done inside transaction
|
|
||||||
async update(id: string, dto: UpdateRestaurantDto): Promise<Shop> {
|
|
||||||
|
|
||||||
|
async update(id: string, dto: UpdateRestaurantDto): Promise<Shop> {
|
||||||
const shop = await this.shopRepository.findOne({ id: id });
|
const shop = await this.shopRepository.findOne({ id: id });
|
||||||
|
|
||||||
if (!shop) {
|
if (!shop) {
|
||||||
throw new NotFoundException(RestMessage.NOT_FOUND);
|
throw new NotFoundException(ShopMessage.NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (dto.slug) {
|
||||||
|
const shopWithThisSlug = await this.shopRepository.findOne({ slug: dto.slug, $not: { id } });
|
||||||
|
|
||||||
|
if (shopWithThisSlug) {
|
||||||
|
throw new NotFoundException(ShopMessage.SHOP_EXIST_WITH_THIS_SLUG);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.shopRepository.assign(shop, dto);
|
this.shopRepository.assign(shop, dto);
|
||||||
|
|
||||||
await this.em.persistAndFlush(shop);
|
await this.em.flush();
|
||||||
|
|
||||||
return shop;
|
return shop;
|
||||||
}
|
}
|
||||||
@@ -168,7 +174,7 @@ export class ShopService {
|
|||||||
const shop = await this.shopRepository.findOne({ subscriptionId });
|
const shop = await this.shopRepository.findOne({ subscriptionId });
|
||||||
|
|
||||||
if (!shop) {
|
if (!shop) {
|
||||||
throw new NotFoundException(RestMessage.NOT_FOUND);
|
throw new NotFoundException(ShopMessage.NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
const isActive = new Date(dto.subscriptionEndDate) > new Date()
|
const isActive = new Date(dto.subscriptionEndDate) > new Date()
|
||||||
@@ -187,7 +193,7 @@ export class ShopService {
|
|||||||
const shop = await em.findOne(Shop, { id });
|
const shop = await em.findOne(Shop, { id });
|
||||||
|
|
||||||
if (!shop) {
|
if (!shop) {
|
||||||
throw new NotFoundException(RestMessage.NOT_FOUND);
|
throw new NotFoundException(ShopMessage.NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete orders first (will cascade to order items and payments due to cascade settings)
|
// Delete orders first (will cascade to order items and payments due to cascade settings)
|
||||||
@@ -235,7 +241,7 @@ export class ShopService {
|
|||||||
async findOrFail(shopId: string) {
|
async findOrFail(shopId: string) {
|
||||||
const shop = await this.shopRepository.findOne({ id: shopId }, { populate: ['deliveries'] })
|
const shop = await this.shopRepository.findOne({ id: shopId }, { populate: ['deliveries'] })
|
||||||
if (!shop) {
|
if (!shop) {
|
||||||
throw new BadRequestException(RestMessage.NOT_FOUND);
|
throw new BadRequestException(ShopMessage.NOT_FOUND);
|
||||||
}
|
}
|
||||||
return shop
|
return shop
|
||||||
}
|
}
|
||||||
@@ -243,7 +249,7 @@ export class ShopService {
|
|||||||
async findOrFailBySlug(shopSlug: string) {
|
async findOrFailBySlug(shopSlug: string) {
|
||||||
const shop = await this.shopRepository.findOne({ slug: shopSlug }, { populate: ['deliveries'] })
|
const shop = await this.shopRepository.findOne({ slug: shopSlug }, { populate: ['deliveries'] })
|
||||||
if (!shop) {
|
if (!shop) {
|
||||||
throw new BadRequestException(RestMessage.NOT_FOUND);
|
throw new BadRequestException(ShopMessage.NOT_FOUND);
|
||||||
}
|
}
|
||||||
return shop
|
return shop
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import { WalletTransactionRepository } from '../repositories/wallet-transaction.
|
|||||||
import { WalletService } from './wallet.service';
|
import { WalletService } from './wallet.service';
|
||||||
import { WalletTransactionReason, WalletTransactionType } from '../interface/wallet';
|
import { WalletTransactionReason, WalletTransactionType } from '../interface/wallet';
|
||||||
import { WalletTransaction } from '../entities/wallet-transaction.entity';
|
import { WalletTransaction } from '../entities/wallet-transaction.entity';
|
||||||
import { RestMessage, UserMessage } from 'src/common/enums/message.enum';
|
import { ShopMessage, UserMessage } from 'src/common/enums/message.enum';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class UserService {
|
export class UserService {
|
||||||
@@ -87,7 +87,7 @@ export class UserService {
|
|||||||
// get registerscore from shop
|
// get registerscore from shop
|
||||||
const shop = await this.restaurantRepository.findOne({ id: shopId });
|
const shop = await this.restaurantRepository.findOne({ id: shopId });
|
||||||
if (!shop) {
|
if (!shop) {
|
||||||
throw new NotFoundException(RestMessage.NOT_FOUND);
|
throw new NotFoundException(ShopMessage.NOT_FOUND);
|
||||||
}
|
}
|
||||||
const points = Number(shop.score?.registerScore || 0);
|
const points = Number(shop.score?.registerScore || 0);
|
||||||
const createData = _raw as unknown as RequiredEntityData<User>;
|
const createData = _raw as unknown as RequiredEntityData<User>;
|
||||||
@@ -315,7 +315,7 @@ export class UserService {
|
|||||||
}
|
}
|
||||||
const shop = await em.findOne(Shop, { id: shopId });
|
const shop = await em.findOne(Shop, { id: shopId });
|
||||||
if (!shop) {
|
if (!shop) {
|
||||||
throw new NotFoundException(RestMessage.NOT_FOUND);
|
throw new NotFoundException(ShopMessage.NOT_FOUND);
|
||||||
}
|
}
|
||||||
let walletTransaction = await em.findOne(WalletTransaction, { user: { id: userId }, shop: { id: shopId } },
|
let walletTransaction = await em.findOne(WalletTransaction, { user: { id: userId }, shop: { id: shopId } },
|
||||||
{ orderBy: { createdAt: 'DESC' } });
|
{ orderBy: { createdAt: 'DESC' } });
|
||||||
|
|||||||
Reference in New Issue
Block a user