Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
taobao-mini-template
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
2
Issues
2
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
qinhaitao
taobao-mini-template
Commits
e50a7390
Commit
e50a7390
authored
Nov 24, 2020
by
qinhaitao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:
🎸
发奖情况
parent
610099a0
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
77 additions
and
14 deletions
+77
-14
.DS_Store
.DS_Store
+0
-0
constants.ts
v2.0/src/constants.ts
+7
-0
game.controller.ts
v2.0/src/controller/game.controller.ts
+29
-8
user.controller.ts
v2.0/src/controller/user.controller.ts
+4
-4
errorCode.ts
v2.0/src/errorCode.ts
+10
-0
checkOpenPrizeStatus.ts
v2.0/src/utils/common/check/checkOpenPrizeStatus.ts
+22
-0
index.ts
v2.0/src/utils/common/check/index.ts
+5
-2
No files found.
.DS_Store
View file @
e50a7390
No preview for this file type
v2.0/src/constants.ts
View file @
e50a7390
...
...
@@ -39,6 +39,13 @@ export const TAOBAO_SUCCESS_ORDER_STATUS: string[] = [
'PAID_FORBID_CONSIGN'
]
export
const
ACTIVITY_OPEN_PRIZE_STATUS
=
{
//开奖状态
AWAIT
:
1
,
FAIL
:
2
,
SUCCESS
:
3
}
// 活动状态
export
const
enum
ACTIVITY_STATUS
{
NORMAL
=
1
,
...
...
v2.0/src/controller/game.controller.ts
View file @
e50a7390
...
...
@@ -3,7 +3,14 @@
import
{
services
,
checkParams
,
preCheck
,
preUpdate
}
from
'../decorator/common'
import
{
resultsModel
}
from
'../sdk'
import
{
CommonUserService
,
CommonGameService
}
from
'../service/common'
import
{
checkActivityTime
,
checkJoinId
,
checkUserInfo
,
checkVip
,
checkGameTimes
}
from
'../utils/common/check'
import
{
checkActivityTime
,
checkJoinId
,
checkUserInfo
,
checkVip
,
checkGameTimes
,
checkOpenPrizeStatus
}
from
'../utils/common/check'
import
{
updateUserInfo
,
reduceGameTimes
}
from
'../utils/common/update'
export
interface
ISumitGameControllerInfos
extends
IControllerInfos
{
...
...
@@ -46,19 +53,33 @@ export default class Game {
})
}
@
checkParams
([
'activityId'
,
'id'
,
'score'
])
@
checkParams
([
'activityId'
,
'id'
,
'score'
,
'rankKey?'
,
'timeKey?'
])
@
services
([
CommonGameService
])
@
preCheck
([
checkJoinId
])
async
submitGame
(
context
:
IContext
<
IParams
>
,
{
userInfo
,
joinInfo
}:
ISumitGameControllerInfos
,
[
gameService
]:
[
CommonGameService
]
{
userInfo
}:
ISumitGameControllerInfos
,
[
gameService
]:
[
CommonGameService
],
{
joinInfo
}:
IPreCheckData
)
{
const
{
id
,
score
}
=
context
.
data
const
rankKey
=
'totalScore'
const
rankTime
=
'updateScoreTime'
const
result
=
await
gameService
.
submitGame
(
id
,
score
,
rankKey
,
rankTime
,
userInfo
,
joinInfo
)
const
{
id
,
score
,
rankKey
=
'totalScore'
,
timeKey
=
'updateScoreTime'
}
=
context
.
data
const
result
=
await
gameService
.
submitGame
(
id
,
score
,
rankKey
,
timeKey
,
userInfo
,
joinInfo
)
return
resultsModel
.
success
(
result
)
}
@
checkParams
([
'activityId'
,
'rankKey?'
,
'timeKey?'
])
@
services
([
CommonGameService
])
@
preCheck
([
checkOpenPrizeStatus
])
async
getMyRankPrize
(
context
:
IContext
<
IParams
>
,
{
userInfo
,
activityInfo
}:
IControllerInfos
,
[
gameService
]:
[
CommonGameService
]
)
{
const
{
rankKey
=
'totalScore'
,
timeKey
=
'updateScoreTime'
}
=
context
.
data
const
myRankInfo
=
await
gameService
.
getMyRankInfo
(
rankKey
,
timeKey
,
userInfo
)
return
resultsModel
.
success
({})
}
}
v2.0/src/controller/user.controller.ts
View file @
e50a7390
...
...
@@ -38,14 +38,14 @@ export default class User {
/**
* 获取排行榜
*/
@
checkParams
([
'activityId'
,
'
k
ey?'
,
'timeKey?'
,
'limit?'
])
@
checkParams
([
'activityId'
,
'
rankK
ey?'
,
'timeKey?'
,
'limit?'
])
@
services
([
CommonUserService
])
async
getRankList
(
context
:
IContext
<
IParams
>
,
{
userInfo
}:
IControllerInfos
,
[
userService
]:
[
CommonUserService
])
{
const
{
k
ey
=
'totalScore'
,
timeKey
=
'updateScoreTime'
,
limit
=
200
}
=
context
.
data
const
{
rankK
ey
=
'totalScore'
,
timeKey
=
'updateScoreTime'
,
limit
=
200
}
=
context
.
data
const
rankInfo
=
await
userService
.
getMyRankInfo
(
k
ey
,
timeKey
,
userInfo
)
const
rankInfo
=
await
userService
.
getMyRankInfo
(
rankK
ey
,
timeKey
,
userInfo
)
const
list
=
await
userService
.
getRank
(
k
ey
,
timeKey
,
limit
)
const
list
=
await
userService
.
getRank
(
rankK
ey
,
timeKey
,
limit
)
return
resultsModel
.
success
({
...
rankInfo
,
...
...
v2.0/src/errorCode.ts
View file @
e50a7390
...
...
@@ -23,6 +23,16 @@ export const BusinessError = {
code
:
`220003`
,
defaultMsg
:
`活动已结束`
},
// 活动未结束
ERROR_ACTIVITY_NO_OVER
:
{
code
:
`220004`
,
defaultMsg
:
`活动未结束`
},
// 活动已开奖
ERROR_ACTIVITY_OPENED_PRIZE
:
{
code
:
`220005`
,
defaultMsg
:
`活动已开奖`
},
// 用户不存在
ERROR_NO_USER
:
{
code
:
`310002`
,
...
...
v2.0/src/utils/common/check/checkOpenPrizeStatus.ts
0 → 100644
View file @
e50a7390
/** @format */
import
{
resultsModel
}
from
'../../../sdk'
import
{
CODE_TYPES
}
from
'../../../errorCode'
import
{
ACTIVITY_OPEN_PRIZE_STATUS
}
from
'../../../constants'
// 检查开奖
export
default
async
function
checkOpenPrizeStatus
(
context
:
IContext
<
IParams
>
,
{
activityInfo
}:
IControllerInfos
)
{
const
now
=
Date
.
now
()
const
{
startTime
,
endTime
,
openPrizeStatus
}
=
activityInfo
// 活动未结束
if
(
endTime
>
now
)
{
return
resultsModel
.
error
(
CODE_TYPES
.
ERROR_ACTIVITY_NO_OVER
,
'活动未结束'
)
}
if
(
now
<
startTime
)
{
return
resultsModel
.
error
(
CODE_TYPES
.
ERROR_ACTIVITY_NOSTART
,
`活动未开始`
)
}
if
(
openPrizeStatus
===
ACTIVITY_OPEN_PRIZE_STATUS
.
SUCCESS
)
{
return
resultsModel
.
error
(
CODE_TYPES
.
ERROR_ACTIVITY_OPENED_PRIZE
,
`活动已开奖`
)
}
}
v2.0/src/utils/common/check/index.ts
View file @
e50a7390
...
...
@@ -11,6 +11,7 @@ import checkValidPrize, { checkValidEnamePrize, checkValidObjectPrize } from './
import
checkVip
from
'./checkVip'
import
checkUserInfo
,
{
checkGameTimes
}
from
'./checkUserInfo'
import
checkJoinId
from
'./checkJoinId'
import
checkOpenPrizeStatus
from
'./checkOpenPrizeStatus'
const
check
=
{
checkActivityTime
,
...
...
@@ -27,7 +28,8 @@ const check = {
checkVip
,
checkUserInfo
,
checkJoinId
,
checkGameTimes
checkGameTimes
,
checkOpenPrizeStatus
}
export
default
check
...
...
@@ -47,5 +49,6 @@ export {
checkVip
,
checkUserInfo
,
checkJoinId
,
checkGameTimes
checkGameTimes
,
checkOpenPrizeStatus
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment