import { CreationOptional, DataTypes, InferAttributes, InferCreationAttributes } from 'sequelize'; import type { LiteralUnion } from 'type-fest'; import { TenantModel } from '../tenant-model'; import { CreditGrantApplicabilityConfig, CreditGrantChainDetail, CreditGrantChainStatus } from './types'; import { TPaymentCurrency } from './payment-currency'; import { TMeter } from './meter'; type CreditGrantSummary = { paymentCurrency: TPaymentCurrency; meter?: TMeter; totalAmount: string; remainingAmount: string; grantCount: number; }; export declare const nextCreditGrantId: (size?: number) => string; export declare class CreditGrant extends TenantModel, InferCreationAttributes> { id: CreationOptional; object: CreationOptional; amount: string; currency_id: string; applicability_config?: CreditGrantApplicabilityConfig; category: LiteralUnion<'paid' | 'promotional', string>; customer_id: string; effective_at?: number; expires_at?: number; livemode: boolean; instance_did?: string; metadata?: Record; name?: string; priority: number; test_clock?: string; voided_at?: number; status: LiteralUnion<'pending' | 'granted' | 'depleted' | 'expired' | 'voided', string>; remaining_amount: string; chain_status?: CreditGrantChainStatus; chain_detail?: CreditGrantChainDetail; created_by?: string; updated_by?: string; created_via: LiteralUnion<'api' | 'dashboard' | 'portal', string>; created_at: CreationOptional; updated_at: CreationOptional; static readonly GENESIS_ATTRIBUTES: { id: { type: DataTypes.StringDataType; primaryKey: boolean; allowNull: boolean; defaultValue: (size?: number) => string; }; object: { type: DataTypes.StringDataType; defaultValue: string; allowNull: boolean; }; amount: { type: DataTypes.StringDataType; allowNull: boolean; }; currency_id: { type: DataTypes.StringDataType; allowNull: boolean; }; applicability_config: { type: DataTypes.AbstractDataTypeConstructor; allowNull: boolean; }; category: { type: DataTypes.EnumDataType<"paid" | "promotional">; allowNull: boolean; }; customer_id: { type: DataTypes.StringDataType; allowNull: boolean; }; effective_at: { type: DataTypes.IntegerDataTypeConstructor; allowNull: boolean; }; expires_at: { type: DataTypes.IntegerDataTypeConstructor; allowNull: boolean; }; livemode: { type: DataTypes.AbstractDataTypeConstructor; allowNull: boolean; }; metadata: { type: DataTypes.AbstractDataTypeConstructor; allowNull: boolean; }; name: { type: DataTypes.StringDataType; allowNull: boolean; }; priority: { type: DataTypes.IntegerDataTypeConstructor; defaultValue: number; allowNull: boolean; validate: { min: number; max: number; }; }; test_clock: { type: DataTypes.StringDataType; allowNull: boolean; }; voided_at: { type: DataTypes.IntegerDataTypeConstructor; allowNull: boolean; }; status: { type: DataTypes.EnumDataType<"pending" | "expired" | "voided" | "depleted" | "granted">; defaultValue: string; allowNull: boolean; }; remaining_amount: { type: DataTypes.StringDataType; allowNull: boolean; }; chain_status: { type: DataTypes.EnumDataType<"mint_pending" | "mint_completed" | "mint_failed" | "burn_pending" | "burn_completed" | "burn_failed">; allowNull: boolean; }; chain_detail: { type: DataTypes.AbstractDataTypeConstructor; allowNull: boolean; }; created_by: { type: DataTypes.StringDataType; allowNull: boolean; }; updated_by: { type: DataTypes.StringDataType; allowNull: boolean; }; created_via: { type: DataTypes.EnumDataType<"api" | "dashboard" | "portal">; allowNull: boolean; }; created_at: { type: DataTypes.DateDataTypeConstructor; defaultValue: DataTypes.AbstractDataTypeConstructor; allowNull: boolean; }; updated_at: { type: DataTypes.DateDataTypeConstructor; defaultValue: DataTypes.AbstractDataTypeConstructor; allowNull: boolean; }; }; isAvailable(): boolean; consumeCredit(amount: string, _context: { subscription_id?: string; meter_event_id?: string; }, dryRun?: boolean): Promise<{ consumed: string; remaining: string; depleted: boolean; }>; isApplicableToPrice(priceId: string): boolean; hasOnchainToken(): boolean; static hasOnchainToken(grant: { chain_status?: string | null; }): boolean; static initialize(sequelize: any): void; static associate(models: any): void; static getAvailableCreditsForCustomer(customerId: string, currencyId: string, priceIds?: string[] | string): Promise; static expireCredits(grantIds: string[]): Promise; /** * 获取客户的有效信用额度总额(按货币分组) */ static getEffectiveCreditSummary({ customerId, currencyId: searchCurrencyId, priceIds, }: { customerId: string; currencyId?: string[] | string; priceIds?: string[]; }): Promise>; } export type TCreditGrant = InferAttributes; export {};