活动:礼包商店添加刷新判断
This commit is contained in:
@@ -4,6 +4,7 @@ import { ACTIVITY_TYPE, FIRST_GIFT_STATE, STATUS } from '../../../consts';
|
|||||||
import { newPlayerLimitPackageActivity, getPlayerLimitPackageData } from '../../../services/limitPackageService';
|
import { newPlayerLimitPackageActivity, getPlayerLimitPackageData } from '../../../services/limitPackageService';
|
||||||
import { addReward, stringToRewardParam, useGiftPackage } from '../../../services/giftPackageService';
|
import { addReward, stringToRewardParam, useGiftPackage } from '../../../services/giftPackageService';
|
||||||
import { ActivityShopModel } from '../../../db/ActivityShop';
|
import { ActivityShopModel } from '../../../db/ActivityShop';
|
||||||
|
import moment = require('moment');
|
||||||
|
|
||||||
export default function (app: Application) {
|
export default function (app: Application) {
|
||||||
return new limitPackageHandler(app);
|
return new limitPackageHandler(app);
|
||||||
@@ -59,7 +60,7 @@ export class limitPackageHandler {
|
|||||||
switch (playerData.type) {
|
switch (playerData.type) {
|
||||||
case ACTIVITY_TYPE.NEW_PLAYER_LIMIT_PACKAGE:
|
case ACTIVITY_TYPE.NEW_PLAYER_LIMIT_PACKAGE:
|
||||||
{
|
{
|
||||||
if (playerData.endTime < new Date) {
|
if (playerData.endTime < moment(new Date).valueOf()) {
|
||||||
return resResult(STATUS.ACTIVITY_NEW_PLAYER_LIMIT_PACKAGE_END);
|
return resResult(STATUS.ACTIVITY_NEW_PLAYER_LIMIT_PACKAGE_END);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
|
import moment = require('moment');
|
||||||
import { ActivityModelType } from '../../db/Activity';
|
import { ActivityModelType } from '../../db/Activity';
|
||||||
import { deltaDays } from '../../pubUtils/util';
|
import { deltaDays } from '../../pubUtils/util';
|
||||||
|
|
||||||
// 活动数据
|
// 活动数据
|
||||||
export abstract class ActivityBase {
|
export abstract class ActivityBase {
|
||||||
activityId: number = 0;
|
activityId: number = 0;
|
||||||
beginTime: Date = null;
|
beginTime: number = 0;
|
||||||
endTime: Date = null;
|
endTime: number = 0;
|
||||||
type: number = 0;
|
type: number = 0;
|
||||||
todayIndex: number = 0;//从1开始
|
todayIndex: number = 0;//从1开始
|
||||||
|
|
||||||
@@ -18,8 +19,8 @@ export abstract class ActivityBase {
|
|||||||
|
|
||||||
constructor(activityData: ActivityModelType) {
|
constructor(activityData: ActivityModelType) {
|
||||||
this.activityId = activityData.activityId;
|
this.activityId = activityData.activityId;
|
||||||
this.beginTime = activityData.beginTime;
|
this.beginTime = moment(activityData.beginTime).valueOf();
|
||||||
this.endTime = activityData.endTime;
|
this.endTime = moment(activityData.endTime).valueOf();
|
||||||
this.type = activityData.type;
|
this.type = activityData.type;
|
||||||
// this.data = activityData.data;
|
// this.data = activityData.data;
|
||||||
this.todayIndex = deltaDays(activityData.beginTime, new Date) + 1;
|
this.todayIndex = deltaDays(activityData.beginTime, new Date) + 1;
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import moment = require('moment');
|
||||||
import { ACTIVITY_RESOURCES_TYPE } from '../../consts';
|
import { ACTIVITY_RESOURCES_TYPE } from '../../consts';
|
||||||
import { ActivityModelType } from '../../db/Activity';
|
import { ActivityModelType } from '../../db/Activity';
|
||||||
import { ActivityShopModelType } from '../../db/ActivityShop';
|
import { ActivityShopModelType } from '../../db/ActivityShop';
|
||||||
@@ -25,7 +26,7 @@ export class LimitShopData extends ActivityBase {
|
|||||||
name: string = '';//活动名称
|
name: string = '';//活动名称
|
||||||
interval: number = 0;//周期间隔(秒)
|
interval: number = 0;//周期间隔(秒)
|
||||||
list: Array<ShopItem> = [];//商品列表
|
list: Array<ShopItem> = [];//商品列表
|
||||||
refreshTime: Date;//下次刷新时间
|
nextRefreshTime: number;//下次刷新时间
|
||||||
roundIndex: number = 1;//周期数从1开始
|
roundIndex: number = 1;//周期数从1开始
|
||||||
|
|
||||||
public findItem(id: number) {
|
public findItem(id: number) {
|
||||||
@@ -58,10 +59,15 @@ export class LimitShopData extends ActivityBase {
|
|||||||
|
|
||||||
|
|
||||||
public initData(data: string) {
|
public initData(data: string) {
|
||||||
|
this.nextRefreshTime = this.endTime;
|
||||||
let dataObj = JSON.parse(data);
|
let dataObj = JSON.parse(data);
|
||||||
this.name = dataObj.name;
|
this.name = dataObj.name;
|
||||||
this.interval = dataObj.interval;
|
this.interval = dataObj.interval;
|
||||||
|
if (this.interval > 0) {
|
||||||
|
this.roundIndex = Math.ceil((moment(new Date).valueOf() - this.beginTime) / (this.interval * 1000));
|
||||||
|
this.nextRefreshTime = moment(this.beginTime).add(this.interval * this.roundIndex, 'second').valueOf();
|
||||||
|
}
|
||||||
|
console.log(moment(new Date).valueOf(), moment(this.beginTime).valueOf(), this.roundIndex,)
|
||||||
let arr = dataObj.data;
|
let arr = dataObj.data;
|
||||||
for (let obj of arr) {
|
for (let obj of arr) {
|
||||||
this.list.push(new ShopItem(obj))
|
this.list.push(new ShopItem(obj))
|
||||||
|
|||||||
Reference in New Issue
Block a user