Commit e51cef0d authored by 王波's avatar 王波

Merge branch 'c_server_opt_3.0' into c_server_ts_cultivate

* c_server_opt_3.0:
  feat: 🎸 获取年份等api
  feat: 🎸 时间格式化
  优化修改
  养成类模板提交
  fix: 🐛 bug
  feat: 🎸 获取年份等api
  feat: 🎸 时间格式化
  fix: 🐛 bug
  fix: 🐛 领取权益异常拦截

# Conflicts:
#	v2.0/src/utils/common/date.ts
parents 7ae6dc4f f9b7b5a9
...@@ -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 // 是否补签
} }
......
...@@ -24,7 +24,7 @@ export default function checkValidPrize(prizeTypes: number[]) { ...@@ -24,7 +24,7 @@ export default function checkValidPrize(prizeTypes: number[]) {
// 状态不是1,6 // 状态不是1,6
if (![DRAW_STATUS.WAITAWARD, DRAW_STATUS.RETRY].includes(awardInfo.drawStatus)) { if (![DRAW_STATUS.WAITAWARD, DRAW_STATUS.RETRY].includes(awardInfo.drawStatus)) {
return CODE_TYPES.ERROR_FORBIDDEN_OPE return resultsModel.error(CODE_TYPES.ERROR_FORBIDDEN_OPE)
} }
return { return {
......
...@@ -27,7 +27,6 @@ const EIGHT_HOURS = 8 * 60 * 60 * 1000 ...@@ -27,7 +27,6 @@ const EIGHT_HOURS = 8 * 60 * 60 * 1000
* getMinute 获取分钟 * getMinute 获取分钟
* geSecond 获取秒数 * geSecond 获取秒数
* getMillisecond 获取毫秒 * getMillisecond 获取毫秒
* } * }
*/ */
export function formatDate(date: string | number = Date.now()) { export function formatDate(date: string | number = Date.now()) {
......
...@@ -25,7 +25,6 @@ export async function updateHelpRecord( ...@@ -25,7 +25,6 @@ export async function updateHelpRecord(
{ userInfo }: IControllerInfos { userInfo }: IControllerInfos
): Promise<IPreUpdateQuery | undefined> { ): Promise<IPreUpdateQuery | undefined> {
const { inviteId } = context.data const { inviteId } = context.data
if (inviteId) return {}
if (!userInfo) return {} if (!userInfo) return {}
return { return {
$set: { $set: {
......
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