feat(gvg): 组建期

This commit is contained in:
luying
2023-01-05 19:18:56 +08:00
parent 94c69089ac
commit 03fa74f3d1
50 changed files with 10354 additions and 38 deletions

View File

@@ -1,21 +1,22 @@
import { REFRESH_TIME, TIME_OUTPUT_TYPE, SHOP_REFRESH_TYPE } from '../consts';
import { isDebugTime } from './sdkUtil';
export const WEEK_TO_MS = 7 * 24 * 60 * 60 * 1000;
export const WEEK_TO_SECOND = 7 * 24 * 60 * 60;
export const DAY_TO_HOUR = 24;
export const DAY_TO_SECOND = 24 * 60 * 60;
export const DAY_TO_MS = 24 * 60 * 60 * 1000;
export const HOUR_TO_MINUTE = 60;
export const HOUR_TO_SECOND = 60 * 60;
export const HOUR_TO_MS = 60 * 60 * 1000;
export const MINUTE_TO_MS = 60 * 1000;
export const SECOND_TO_MS = 1000;
/**
* 时间
* @class
*/
class Time {
WEEK_TO_MS = 7 * 24 * 60 * 60 * 1000;
DAY_TO_HOUR = 24;
DAY_TO_SECOND = 24 * 60 * 60;
DAY_TO_MS = 24 * 60 * 60 * 1000;
HOUR_TO_MINUTE = 60;
HOUR_TO_SECOND = 60 * 60;
HOUR_TO_MS = 60 * 60 * 1000;
MINUTE_TO_MS = 60 * 1000;
SECOND_TO_MS = 1000;
now: Date; // 当前时间
time: Date; // 处理时间原料
outputType: number; // 输出格式
@@ -106,7 +107,7 @@ class Time {
if(time >= t) {
return t;
} else {
return new Date(t.getTime() - this.DAY_TO_MS);
return new Date(t.getTime() - DAY_TO_MS);
}
}
@@ -187,7 +188,7 @@ class Time {
let cur = this._getDayZeroPoint(curDate);
let pre = this._getDayZeroPoint(preDate);
return Math.floor((cur.getTime() - pre.getTime()) / this.DAY_TO_MS)
return Math.floor((cur.getTime() - pre.getTime()) / DAY_TO_MS)
}
/**
@@ -256,7 +257,7 @@ class Time {
if(this.time >= t) {
return this._returnResult(t);
} else {
return this._returnResult(t.getTime() - this.WEEK_TO_MS);
return this._returnResult(t.getTime() - WEEK_TO_MS);
}
}
@@ -287,10 +288,10 @@ class Time {
public getBeforeDayWithHour(day: number = 0, hour = REFRESH_TIME, minute = 0, seconds = 0) {
let t = this._setHour(this.time.getTime(), hour, minute, seconds);
if(this.time >= t) {
let timestamp = t.getTime() - day * this.DAY_TO_MS;
let timestamp = t.getTime() - day * DAY_TO_MS;
return this._returnResult(timestamp);
} else {
let timestamp = t.getTime() - (day + 1) * this.DAY_TO_MS;
let timestamp = t.getTime() - (day + 1) * DAY_TO_MS;
return this._returnResult(timestamp);
}
}
@@ -306,10 +307,10 @@ class Time {
let t = this._setHour(this.time.getTime(), hour, minute, seconds, 0);
// console.log(t.getTime(), this.time.getTime());
if(this.time.getTime() > t.getTime()) {
let timestamp = t.getTime() + (day + 1) * this.DAY_TO_MS;
let timestamp = t.getTime() + (day + 1) * DAY_TO_MS;
return this._returnResult(timestamp);
} else {
let timestamp = t.getTime() + day * this.DAY_TO_MS;
let timestamp = t.getTime() + day * DAY_TO_MS;
return this._returnResult(timestamp);
}
}
@@ -323,7 +324,7 @@ class Time {
*/
public getBeforeDayAndSetHour(day: number = 0, hour = REFRESH_TIME, minute = 0, seconds = 0) {
let t = this._setHour(this.time.getTime(), hour, minute, seconds);
let timestamp = t.getTime() - day * this.DAY_TO_MS;
let timestamp = t.getTime() - day * DAY_TO_MS;
return this._returnResult(timestamp);
}
@@ -336,7 +337,7 @@ class Time {
*/
public getAfterDayAndSetHour(day: number = 0, hour = REFRESH_TIME, minute = 0, seconds = 0) {
let t = this._setHour(this.time.getTime(), hour, minute, seconds);
let timestamp = t.getTime() + day * this.DAY_TO_MS;
let timestamp = t.getTime() + day * DAY_TO_MS;
return this._returnResult(timestamp);
}
@@ -345,7 +346,7 @@ class Time {
* @param day 几天前
*/
public getBeforeDay(day: number) {
let timestamp = this.time.getTime() - day * this.DAY_TO_MS;
let timestamp = this.time.getTime() - day * DAY_TO_MS;
return this._returnResult(timestamp);
}
@@ -354,7 +355,7 @@ class Time {
* @param day 几天后
*/
public getAfterDay(day: number) {
let timestamp = this.time.getTime() + day * this.DAY_TO_MS;
let timestamp = this.time.getTime() + day * DAY_TO_MS;
return this._returnResult(timestamp);
}
@@ -363,7 +364,7 @@ class Time {
* @param hour 几小时前
*/
public getBeforeHour(hour: number) {
let timestamp = this.time.getTime() - hour * this.HOUR_TO_MS;
let timestamp = this.time.getTime() - hour * HOUR_TO_MS;
return this._returnResult(timestamp);
}
@@ -372,7 +373,7 @@ class Time {
* @param hour 几分钟前
*/
public getBeforeMinute(minute: number) {
let timestamp = this.time.getTime() - minute * this.MINUTE_TO_MS;
let timestamp = this.time.getTime() - minute * MINUTE_TO_MS;
return this._returnResult(timestamp);
}
@@ -393,7 +394,7 @@ class Time {
public getAfterDayByGap(preDate: Date, day: number) {
let gap = this._getDayGap(preDate, this.time);
let n = Math.floor(gap / day);
return this._returnResult(preDate.getTime() + n * day * this.DAY_TO_MS);
return this._returnResult(preDate.getTime() + n * day * DAY_TO_MS);
}
/**
@@ -401,7 +402,7 @@ class Time {
* @param day day天以内
*/
public checkDay(day: number = 1) {
if (this.time.getTime() - this.now.getTime() <= day * this.DAY_TO_MS) {
if (this.time.getTime() - this.now.getTime() <= day * DAY_TO_MS) {
return true;
}
return false;