81 lines
2.1 KiB
JavaScript
81 lines
2.1 KiB
JavaScript
'use strict'
|
||
import mongoose from 'mongoose'
|
||
|
||
/**
|
||
* 奖品库
|
||
*/
|
||
const GameGiftSchema = new mongoose.Schema(
|
||
{
|
||
gift_id: {type: String},
|
||
gift_name: {type: String},
|
||
gift_url: {type: String},
|
||
game_id: {type: String},
|
||
type: {type: Number}, // 奖品类型
|
||
codes: [{type: String}], // 兑换码
|
||
used_codes: [{type: String}], // 已使用兑换码
|
||
status: {type: Number, default: 0}, // 0-正常, 1-停用
|
||
deleted: {type: Boolean, default: false},
|
||
extraData: {type: Object, default: {}}, // 用于拓展
|
||
},
|
||
{
|
||
collection: 'game_gift',
|
||
timestamps: true,
|
||
}
|
||
)
|
||
|
||
/**
|
||
* 游戏礼品列表
|
||
*/
|
||
const GiftListSchema = new mongoose.Schema(
|
||
{
|
||
game_id: {type: String},
|
||
platform_id: {type: String, default: '6001'},
|
||
title: {type: String},
|
||
cond_name: {type: String}, // 兑换条件名称
|
||
condition: {type: Number}, // 兑换条件
|
||
list: [{type: String, ref: 'GameGift'}],
|
||
numList: {type: Object, default: {}}, // 物品显示数量,对应 list
|
||
usedList: {type: Object, default: {}}, // 随机的已使用数量,对应list
|
||
type: {type: Number, default: 0}, // 时间类型: 永久/时段
|
||
time: {type: String}, // 填写的发放配置
|
||
cfg: {type: Array, default: []}, // 生成的配置
|
||
deleted: {type: Boolean, default: false},
|
||
extraData: {type: String, default: ''} //用于扩展
|
||
},
|
||
{
|
||
collection: 'gift_list',
|
||
timestamps: true,
|
||
}
|
||
)
|
||
|
||
/**
|
||
* 兑换记录
|
||
*/
|
||
const GiftRecordSchema = new mongoose.Schema(
|
||
{
|
||
user_id: {type: String},
|
||
game_id: {type: String},
|
||
platform_id: {type: String},
|
||
gift_id: {type: String},
|
||
gift_info: {
|
||
gift_id: {type: String},
|
||
gift_name: {type: String},
|
||
gift_url: {type: String},
|
||
type: {type: Number},
|
||
extraData: {type: Object}
|
||
},
|
||
code: {type: String},
|
||
used: {type: Boolean, default: false},
|
||
},
|
||
{
|
||
collection: 'gift_record',
|
||
timestamps: true,
|
||
}
|
||
)
|
||
|
||
const GameGift = mongoose.model('GameGift', GameGiftSchema)
|
||
const GiftList = mongoose.model('GiftList', GiftListSchema)
|
||
const GiftRecord = mongoose.model('GiftRecord', GiftRecordSchema)
|
||
|
||
export {GameGift, GiftList, GiftRecord}
|