AddServiceLoyalty
This commit is contained in:
@@ -86,6 +86,10 @@ export class BookingEntity {
|
||||
@Column({ type: 'timestamptz', nullable: true })
|
||||
reviewPromptedAt!: Date | null;
|
||||
|
||||
/** True when this booking used a loyalty free redeem for its service. */
|
||||
@Column({ default: false })
|
||||
loyaltyRedeemed!: boolean;
|
||||
|
||||
@CreateDateColumn()
|
||||
createdAt!: Date;
|
||||
|
||||
|
||||
@@ -47,6 +47,14 @@ export class BusinessServiceEntity {
|
||||
@Column({ default: true })
|
||||
isActive!: boolean;
|
||||
|
||||
/** When true, customers earn a free visit of this service after N paid completions. */
|
||||
@Column({ default: false })
|
||||
loyaltyEnabled!: boolean;
|
||||
|
||||
/** Number of paid completions required before the next visit is free (e.g. 3 or 5). */
|
||||
@Column({ type: 'int', nullable: true })
|
||||
loyaltyEveryN!: number | null;
|
||||
|
||||
@OneToMany(() => BookingEntity, (booking) => booking.businessService)
|
||||
bookings!: BookingEntity[];
|
||||
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
import {
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
Entity,
|
||||
JoinColumn,
|
||||
ManyToOne,
|
||||
PrimaryGeneratedColumn,
|
||||
Unique,
|
||||
UpdateDateColumn,
|
||||
} from 'typeorm';
|
||||
import { BookingEntity } from './booking.entity';
|
||||
import { BusinessServiceEntity } from './business-service.entity';
|
||||
import { UserEntity } from './user.entity';
|
||||
|
||||
@Entity('customer_service_loyalty')
|
||||
@Unique('UQ_customer_service_loyalty', ['customerId', 'businessServiceId'])
|
||||
export class CustomerServiceLoyaltyEntity {
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id!: string;
|
||||
|
||||
@ManyToOne(() => UserEntity, { onDelete: 'CASCADE' })
|
||||
@JoinColumn({ name: 'customerId' })
|
||||
customer!: UserEntity;
|
||||
|
||||
@Column('uuid')
|
||||
customerId!: string;
|
||||
|
||||
@ManyToOne(() => BusinessServiceEntity, { onDelete: 'CASCADE' })
|
||||
@JoinColumn({ name: 'businessServiceId' })
|
||||
businessService!: BusinessServiceEntity;
|
||||
|
||||
@Column('uuid')
|
||||
businessServiceId!: string;
|
||||
|
||||
/** Number of paid completed visits toward the next free service. */
|
||||
@Column({ type: 'int', default: 0 })
|
||||
paidCount!: number;
|
||||
|
||||
/** Booking currently holding a reserved free redeem (awaiting payment / confirmed). */
|
||||
@ManyToOne(() => BookingEntity, { nullable: true, onDelete: 'SET NULL' })
|
||||
@JoinColumn({ name: 'reservedBookingId' })
|
||||
reservedBooking!: BookingEntity | null;
|
||||
|
||||
@Column({ type: 'uuid', nullable: true })
|
||||
reservedBookingId!: string | null;
|
||||
|
||||
@CreateDateColumn()
|
||||
createdAt!: Date;
|
||||
|
||||
@UpdateDateColumn()
|
||||
updatedAt!: Date;
|
||||
}
|
||||
Reference in New Issue
Block a user