活动:vip签到判断购买条件
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import moment = require('moment');
|
||||
import { SERVER_OPEN_TIME, SIGNIN_VIP_OPEN_LIMIT } from '../consts';
|
||||
import { ActivityModel, ActivityModelType } from '../db/Activity';
|
||||
import { ActivitySignInModel, ActivitySignInModelType } from '../db/ActivitySignIn';
|
||||
import { SignInData, SignInItem } from '../domain/activityField/signInField';
|
||||
@@ -29,12 +31,43 @@ export async function signInActivity(type: number, serverId: number, roleId: str
|
||||
*/
|
||||
export async function getPlayerSignInData(activityId: number, serverId: number, roleId: string) {
|
||||
let activityData: ActivityModelType = await ActivityModel.findActivity(activityId, true);
|
||||
let playerRecords: ActivitySignInModelType[] = await ActivitySignInModel.findData(activityId, roleId);
|
||||
|
||||
let playerData = new SignInData(activityData);
|
||||
let playerRecords: ActivitySignInModelType[] = await ActivitySignInModel.findData(activityId, roleId, playerData.roundIndex);
|
||||
|
||||
playerData.setPlayerRecords(playerRecords);
|
||||
|
||||
return playerData;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 购买vip签到
|
||||
*
|
||||
* @param {number} serverId 区Id
|
||||
* @param {number} activityId 活动Id
|
||||
* @param {string} roleId 角色Id
|
||||
* @param {string} productID 商品ID
|
||||
*
|
||||
*/
|
||||
export async function makeSignInVIP(roleId: string, roleName: string, sid: string, serverId: number, funcs: number[],
|
||||
activityId: number, productID: string) {
|
||||
let activityData: ActivityModelType = await ActivityModel.findActivity(activityId, true);
|
||||
let playerData = new SignInData(activityData);
|
||||
|
||||
await ActivitySignInModel.buyVIP(activityId, roleId, playerData.roundIndex);
|
||||
}
|
||||
|
||||
//高级签到开启条件
|
||||
export async function canBuyVip(lv: number) {
|
||||
//高级签到开启条件
|
||||
let openTime = SERVER_OPEN_TIME;
|
||||
if (moment(openTime).valueOf() + 24 * 60 * 60 * 1000 * 8 > moment(new Date()).valueOf()) {//开服时间8天后才能开启vip签到
|
||||
return false;
|
||||
}
|
||||
// let { lv } = await RoleModel.findByRoleId(roleId);
|
||||
if (lv < SIGNIN_VIP_OPEN_LIMIT) {//玩家等级大于等于15级才能开启vip签到
|
||||
return false
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user