后台:礼包码

This commit is contained in:
luying
2021-12-10 17:36:01 +08:00
parent ecca95b40b
commit cb999cec10
12 changed files with 255 additions and 174 deletions

View File

@@ -1,7 +1,9 @@
import { GM_MAIL_TYPE, MAIL_TIME_TYPE, SERVER_TIMER } from "../../consts";
import { isArray } from 'underscore';
import { GIFT_GENERATE_TYPE, GM_MAIL_TYPE, MAIL_TIME_TYPE, SERVER_TIMER } from "../../consts";
import { isArray, isNumber, isString } from 'underscore';
import ServerStategy, { GMMail } from "../../db/ServerStategy";
import { RegionType } from "../../db/Region";
import { RewardInter } from "../../pubUtils/interface";
import { isTimestamp } from '../../pubUtils/util';
export class UpdateMailParams {
hasGoods: boolean = false; // 是否有道具
@@ -156,4 +158,71 @@ export class CreateServerParam {
if(this.hasCircleMail && !this.circleMail) return false;
return true;
}
}
export class CreateGiftCode {
name: string; // 礼包码名
goods: RewardInter[]; // 奖励
beginTime: number; // 开始时间
endTime: number; // 结束时间
codeLen: number; // 礼包码位数
remark: string = ''; // 备注
generateType: GIFT_GENERATE_TYPE; // 生成类型
constructor(obj: any) {
this.name = obj.name;
this.goods = obj.goods;
this.beginTime = obj.beginTime;
this.endTime = obj.endTime;
this.codeLen = obj.codeLen;
this.remark = obj.remark;
this.generateType = obj.generateType;
}
checkParams() {
if(!isString(this.name)) return false;
if(!isArray(this.goods)) return false;
for(let { id, count } of this.goods) {
if(!isNumber(id) || !isNumber(count)) return false;
}
if(!isTimestamp(this.beginTime) || !isTimestamp(this.endTime)) return false;
if(!isNumber(this.codeLen) || this.codeLen <= 0) return false;
if(this.generateType != GIFT_GENERATE_TYPE.ONE_TO_MANY && this.generateType != GIFT_GENERATE_TYPE.ONE_TO_ONE) {
return false
}
return true;
}
}
export class UpdateGiftCode {
id: number;
name: string; // 礼包码名
goods: RewardInter[]; // 奖励
beginTime: number; // 开始时间
endTime: number; // 结束时间
codeLen: number; // 礼包码位数
remark: string = ''; // 备注
constructor(id: number, obj: any) {
this.id = id;
this.name = obj.name;
this.goods = obj.goods;
this.beginTime = obj.beginTime;
this.endTime = obj.endTime;
this.codeLen = obj.codeLen;
this.remark = obj.remark;
}
checkParams() {
if(!isNumber(this.id) || this.id <= 0) return false
if(!isString(this.name)) return false;
if(!isArray(this.goods)) return false;
for(let { id, count } of this.goods) {
if(!isNumber(id) || !isNumber(count)) return false;
}
if(!isTimestamp(this.beginTime) || !isTimestamp(this.endTime)) return false;
if(!isNumber(this.codeLen) || this.codeLen <= 0) return false;
return true;
}
}

View File

@@ -43,4 +43,12 @@ export interface SearchMarqueeParam {
createTimeEnd?: number;
sendTimeStart?: number;
sendTimeEnd?: number;
}
export interface SearchGiftCodeParam {
env?: string;
id?: number;
name?: string;
createTimeStart?: number;
createTimeEnd?: number;
}