48 lines
1.1 KiB
TypeScript
48 lines
1.1 KiB
TypeScript
/**
|
||
* 统计模型
|
||
* 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;
|