sms-setting and campain

This commit is contained in:
2026-07-09 19:12:23 +03:30
parent 1dd2813a01
commit ffb95149cf
33 changed files with 2745 additions and 6 deletions
@@ -0,0 +1,85 @@
import {
Column,
CreateDateColumn,
Entity,
Index,
JoinColumn,
ManyToOne,
PrimaryGeneratedColumn,
UpdateDateColumn,
} from 'typeorm';
import { Salon } from '../../salons/entities/salon.entity';
import { User } from '../../users/entities/user.entity';
import { CampaignRunStatus } from '../enums/campaign-run-status.enum';
import { CampaignTrigger } from '../enums/campaign-trigger.enum';
import { CampaignType } from '../enums/campaign-type.enum';
@Entity('campaign_runs')
@Index(['salonId', 'createdAt'])
@Index(['salonId', 'type'])
export class CampaignRun {
@PrimaryGeneratedColumn('uuid')
id: string;
@Column()
salonId: string;
@ManyToOne(() => Salon, { onDelete: 'CASCADE' })
@JoinColumn({ name: 'salonId' })
salon: Salon;
@Column({
type: 'enum',
enum: CampaignType,
enumName: 'campaign_type_enum',
})
type: CampaignType;
@Column({
type: 'enum',
enum: CampaignTrigger,
enumName: 'campaign_trigger_enum',
})
trigger: CampaignTrigger;
@Column({
type: 'enum',
enum: CampaignRunStatus,
enumName: 'campaign_run_status_enum',
})
status: CampaignRunStatus;
@Column({ type: 'int', default: 0 })
targetCount: number;
@Column({ type: 'int', default: 0 })
sentCount: number;
@Column({ type: 'int', default: 0 })
failedCount: number;
@Column({
type: 'decimal',
precision: 14,
scale: 2,
default: 0,
transformer: {
to: (value: number) => value,
from: (value: string) => parseFloat(value),
},
})
estimatedRevenue: number;
@Column({ type: 'uuid', nullable: true })
triggeredByUserId: string | null;
@ManyToOne(() => User, { onDelete: 'SET NULL', nullable: true })
@JoinColumn({ name: 'triggeredByUserId' })
triggeredByUser: User | null;
@CreateDateColumn()
createdAt: Date;
@UpdateDateColumn()
updatedAt: Date;
}