Files
indee-demo/backend/src/discounts/entities/discount.entity.ts
Dorian 0da83f461c Enhance payment processing and rental features
- Updated the BTCPay service to support internal Lightning invoices with private route hints, improving payment routing for users with private channels.
- Added reconciliation methods for pending rents and subscriptions to ensure missed payments are processed on startup.
- Enhanced the rental and subscription services to handle payments in satoshis, aligning with Lightning Network standards.
- Improved the rental modal and content detail components to display rental status and pricing more clearly, including a countdown for rental expiration.
- Refactored various components to streamline user experience and ensure accurate rental access checks.
2026-02-12 23:24:25 +00:00

104 lines
2.3 KiB
TypeScript

import { Content } from 'src/contents/entities/content.entity';
import { DiscountRedemption } from 'src/discount-redemption/entities/discount-redemption.entity';
import {
Entity,
Column,
ManyToOne,
OneToMany,
CreateDateColumn,
UpdateDateColumn,
JoinColumn,
DeleteDateColumn,
PrimaryColumn,
} from 'typeorm';
import {
DiscountType,
DiscountTypes,
} from '../constants/discount-type.constant';
import { User } from 'src/users/entities/user.entity';
import { Season } from 'src/season/entities/season.entity';
@Entity('discounts')
export class Discount {
@PrimaryColumn()
id: string;
@ManyToOne(() => Content, (content) => content.discounts, {
nullable: true,
onDelete: 'CASCADE',
})
@JoinColumn({ name: 'content_id' })
content: Content | null;
@Column({ type: 'varchar', nullable: true })
contentId: string | null;
@ManyToOne(() => Season, (season) => season.discounts, {
nullable: true,
onDelete: 'CASCADE',
})
@JoinColumn({ name: 'season_id' })
season: Season | null;
@Column({ type: 'varchar', nullable: true })
seasonId: string | null;
@Column({ type: 'varchar', length: 50, nullable: false })
couponCode: string;
@Column({
type: 'decimal',
precision: 15,
scale: 2,
nullable: false,
transformer: {
to: (value) => value,
from: (value) => Number.parseFloat(value),
},
})
value: number;
@Column({
type: 'varchar',
length: 20,
default: DiscountTypes.PERCENTAGE,
})
type: DiscountType;
// Start date (null = no start date)
@Column({ type: 'timestamp', nullable: true })
startDate: Date | null;
// End date (null = no expiration date)
@Column({ type: 'timestamp', nullable: true })
expirationDate: Date | null;
// Total usage limit (null = unlimited)
@Column({ type: 'int', nullable: true })
maxUses: number | null;
@Column({ type: 'varchar', length: 255, nullable: true })
email: string | null;
@OneToMany(() => DiscountRedemption, (redemption) => redemption.discount)
redemptions: DiscountRedemption[];
@ManyToOne(() => User, { nullable: false })
@JoinColumn({ name: 'created_by_id' })
createdBy: User;
@Column({ type: 'varchar' })
createdById: string;
@CreateDateColumn()
createdAt: Date;
@UpdateDateColumn()
updatedAt: Date;
// Soft delete
@DeleteDateColumn()
deletedAt: Date | null;
}