✨ feat(活动): 微信公众号口令
This commit is contained in:
49
shared/db/ActivityPublicAccountCode.ts
Normal file
49
shared/db/ActivityPublicAccountCode.ts
Normal file
@@ -0,0 +1,49 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoose';
|
||||
|
||||
|
||||
/**
|
||||
* 自助商店
|
||||
*/
|
||||
@index({ activityId: 1, channelId: 1 })
|
||||
|
||||
export default class Activity_Public_Account_Code extends BaseModel {
|
||||
@prop({ required: true })
|
||||
activityId: number; // 对应礼包码
|
||||
|
||||
@prop({ required: true })
|
||||
channelId: string; // 37平台id
|
||||
|
||||
@prop({ required: true })
|
||||
serverId: number; // 服
|
||||
|
||||
@prop({ required: true })
|
||||
roleId: string; // 玩家id
|
||||
|
||||
@prop({ required: true })
|
||||
orderId: string; // 收到回调的订单号
|
||||
|
||||
@prop({ required: true })
|
||||
hasReceived: boolean; // 是否领取
|
||||
|
||||
public static async findByChannel(activityId: number, channelId: string) {
|
||||
let result: ActivityPublicAccountCodeType = await ActivityPublicAccountCodeModel.findOne({ activityId, channelId }).lean();
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async sendGift(activityId: number, channelId: string, serverId: number, roleId: string, orderId: string) {
|
||||
let result: ActivityPublicAccountCodeType = await ActivityPublicAccountCodeModel.findOneAndUpdate({ activityId, channelId }, { $set: { serverId, roleId, orderId }, $setOnInsert: { hasReceived: false } }, { new: true, upsert: true }).lean();
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async receive(activityId: number, channelId: string) {
|
||||
let result: ActivityPublicAccountCodeType = await ActivityPublicAccountCodeModel.findOneAndUpdate({ activityId, channelId, hasReceived: false }, { $set: { hasReceived: true }}, { new: true }).lean();
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export const ActivityPublicAccountCodeModel = getModelForClass(Activity_Public_Account_Code);
|
||||
|
||||
export interface ActivityPublicAccountCodeType extends Pick<DocumentType<Activity_Public_Account_Code>, keyof Activity_Public_Account_Code> { }
|
||||
export type ActivityPublicAccountCodeTypeParam = Partial<ActivityPublicAccountCodeType>; // 将所有字段变成可选项
|
||||
Reference in New Issue
Block a user