102 lines
2.4 KiB
TypeScript
102 lines
2.4 KiB
TypeScript
import { Collection, Entity, Index, OneToMany, Property } from '@mikro-orm/core';
|
|
import { BaseEntity } from '../../../common/entities/base.entity';
|
|
import { Delivery } from '../../delivery/entities/delivery.entity';
|
|
|
|
@Entity({ tableName: 'restaurants' })
|
|
@Index({ properties: ['isActive'] })
|
|
@Index({ properties: ['slug', 'isActive'] })
|
|
export class Restaurant extends BaseEntity {
|
|
// --- اطلاعات پایه ---
|
|
@Property()
|
|
name!: string;
|
|
|
|
@Property({ unique: true })
|
|
slug!: string;
|
|
|
|
@Property({ nullable: true })
|
|
logo?: string;
|
|
|
|
@Property({ nullable: true })
|
|
address?: string;
|
|
|
|
@Property({ nullable: true })
|
|
menuColor?: string;
|
|
|
|
// --- مختصات جغرافیایی ---
|
|
@Property({ type: 'decimal', precision: 10, scale: 7, nullable: true })
|
|
latitude?: number;
|
|
|
|
@Property({ type: 'decimal', precision: 10, scale: 7, nullable: true })
|
|
longitude?: number;
|
|
|
|
@Property({ type: 'json', nullable: true })
|
|
serviceArea?: {
|
|
type: 'Polygon';
|
|
coordinates: number[][][];
|
|
};
|
|
|
|
// --- وضعیتها ---
|
|
@Property({ default: true })
|
|
isActive: boolean = true;
|
|
|
|
@Property({ nullable: true })
|
|
establishedYear?: number;
|
|
|
|
@Property({ nullable: true })
|
|
phoneNumber?: string;
|
|
|
|
@Property({ nullable: true })
|
|
phone?: string;
|
|
|
|
@Property({ nullable: true })
|
|
instagram?: string;
|
|
|
|
@Property({ nullable: true })
|
|
telegram?: string;
|
|
|
|
@Property({ nullable: true })
|
|
whatsapp?: string;
|
|
|
|
// --- توضیحات ---
|
|
@Property({ type: 'text', nullable: true })
|
|
description?: string;
|
|
|
|
// --- سئو ---
|
|
@Property({ nullable: true })
|
|
seoTitle?: string;
|
|
|
|
@Property({ nullable: true, type: 'text' })
|
|
seoDescription?: string;
|
|
|
|
@Property({ nullable: true, type: 'json' })
|
|
tagNames?: string[];
|
|
|
|
// --- تصاویر ---
|
|
@Property({ nullable: true, type: 'json' })
|
|
images?: string[];
|
|
|
|
// --- مالیات یا VAT ---
|
|
@Property({ type: 'decimal', default: 0 })
|
|
vat?: number = 0;
|
|
|
|
@Property()
|
|
domain!: string;
|
|
|
|
// --- روشهای ارسال ---
|
|
@OneToMany(() => Delivery, delivery => delivery.restaurant)
|
|
deliveries = new Collection<Delivery>(this);
|
|
|
|
@Property({ type: 'json', nullable: true })
|
|
score: {
|
|
purchaseAmount: string;
|
|
purchaseScore: string;
|
|
scoreAmount: string;
|
|
scoreCredit: string;
|
|
// bonus score
|
|
birthdayScore: string;
|
|
registerScore: string;
|
|
marriageDateScore: string;
|
|
referrerScore: string;
|
|
} | null = null;
|
|
}
|