Commit 1e833915 authored by qinhaitao's avatar qinhaitao

fix: 🐛 bug

parent f2a2c3ad
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
import { resultsModel } from '../../sdk' import { resultsModel } from '../../sdk'
import { CODE_TYPES } from '../../constants' import { CODE_TYPES } from '../../constants'
import { logFn, recordErrorLog } from '../../utils' import { logFn, recordErrorLog } from '../../utils'
import { formatDate } from '../../utils/common/date'
// 限制请求频率 rate单位 ms // 限制请求频率 rate单位 ms
export default function requestRateLimit(rate = 500) { export default function requestRateLimit(rate = 500) {
...@@ -29,7 +30,7 @@ export default function requestRateLimit(rate = 500) { ...@@ -29,7 +30,7 @@ export default function requestRateLimit(rate = 500) {
[activityId, openId, handler, 1] [activityId, openId, handler, 1]
) )
} else { } else {
const lastRequestTime = new Date(handlerRecord.gmt_modified).getTime() const lastRequestTime = formatDate(handlerRecord.gmt_modified).getTimestamp()
const now = Date.now() const now = Date.now()
if (now - lastRequestTime < rate) { if (now - lastRequestTime < rate) {
......
...@@ -10,6 +10,7 @@ import { ACTIVITY_STATUS } from '../../constants' ...@@ -10,6 +10,7 @@ import { ACTIVITY_STATUS } from '../../constants'
import UserService from './user.service' import UserService from './user.service'
import { getToday } from '../../utils' import { getToday } from '../../utils'
import { CODE_TYPES } from '../../errorCode' import { CODE_TYPES } from '../../errorCode'
import { formatDate } from '../../utils/common/date'
export default class SignService extends UserService { export default class SignService extends UserService {
context: IContext<any> context: IContext<any>
...@@ -29,9 +30,11 @@ export default class SignService extends UserService { ...@@ -29,9 +30,11 @@ export default class SignService extends UserService {
userNick, userNick,
isSignLater: !!subscribeSignDay, isSignLater: !!subscribeSignDay,
createDay: today, createDay: today,
signTime: subscribeSignDay ? new Date(subscribeSignDay) : new Date(), signTime: subscribeSignDay
? formatDate(subscribeSignDay).format('YYYY-MM-DD')
: formatDate().format('YYYY-MM-DD'),
signDay: subscribeSignDay || today, signDay: subscribeSignDay || today,
createTime: new Date() createTime: Date.now()
}) })
if (!signResult) return CODE_TYPES.SYSTEM_ERROR if (!signResult) return CODE_TYPES.SYSTEM_ERROR
......
...@@ -9,6 +9,7 @@ import { STAT_DB_NAME, ACCESS_DB_NAME, USER_DB_NAME, AWARDS_DB_NAME, JOIN_DB_NAM ...@@ -9,6 +9,7 @@ import { STAT_DB_NAME, ACCESS_DB_NAME, USER_DB_NAME, AWARDS_DB_NAME, JOIN_DB_NAM
import * as xlsx from 'node-xlsx' import * as xlsx from 'node-xlsx'
import { getToday } from '../../utils' import { getToday } from '../../utils'
import { STAT_TYPE } from '../../constants' import { STAT_TYPE } from '../../constants'
import { formatDate } from '../../utils/common/date'
export default class StatService { export default class StatService {
context: IContext<any> context: IContext<any>
...@@ -60,8 +61,8 @@ export default class StatService { ...@@ -60,8 +61,8 @@ export default class StatService {
let day = startDay let day = startDay
const oneDay = 24 * 3600 * 1000 const oneDay = 24 * 3600 * 1000
let xlsxData = [] let xlsxData = []
let curDayTimestamp = new Date(day).getTime() let curDayTimestamp = formatDate(day).getTimestamp()
const endDayTimestamp = new Date(endDay).getTime() const endDayTimestamp = formatDate(endDay).getTimestamp()
while (curDayTimestamp <= endDayTimestamp) { while (curDayTimestamp <= endDayTimestamp) {
// 访问PV // 访问PV
const PV = await this.accessdao.count({ activityId, createDay: day }) const PV = await this.accessdao.count({ activityId, createDay: day })
......
...@@ -4,9 +4,9 @@ interface IUserSign { ...@@ -4,9 +4,9 @@ interface IUserSign {
activityId: string activityId: string
openId: string openId: string
userNick: string userNick: string
createTime: Date createTime: number
createDay: string createDay: string
signTime: Date signTime: string
signDay: string signDay: string
isSignLater?: boolean // 是否补签 isSignLater?: boolean // 是否补签
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment