Files
2026-04-25 16:36:34 +08:00

48 lines
1.1 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* 统计模型
* TypeGoose 定义,符合 Tailchat 插件标准模式
*/
import { db } from 'tailchat-server-sdk';
const { getModelForClass, prop, modelOptions, TimeStamps, index } = db;
@modelOptions({ options: { customName: 'p_saleschat_stats' } })
@index({ salesId: 1, date: 1, period: 1 }, { unique: true })
export class Stats extends TimeStamps implements db.Base {
_id: db.Types.ObjectId;
id: string;
/** 销售 ID关联用户 */
@prop({ required: true, ref: 'User' })
salesId: db.Types.ObjectId;
/** 统计日期 */
@prop({ required: true })
date: Date;
/** 统计周期daily / weekly / monthly */
@prop({ required: true })
period: 'daily' | 'weekly' | 'monthly';
/** 创建的邀请数 */
@prop({ default: 0 })
invitesCreated: number;
/** 加入人数 */
@prop({ default: 0 })
joins: number;
/** 转化次数 */
@prop({ default: 0 })
conversions: number;
/** 收入 */
@prop({ default: 0 })
revenue: number;
}
export type StatsDocument = db.DocumentType<Stats>;
const model = getModelForClass(Stats);
export type StatsModel = typeof model;
export default model;