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
b5973b30
Commit
b5973b30
authored
Jan 29, 2021
by
maggie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
排行榜开奖
parent
1e833915
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
108 additions
and
7 deletions
+108
-7
constants.ts
v2.0/src/constants.ts
+3
-2
awards.controller.ts
v2.0/src/controller/awards.controller.ts
+30
-2
awards.service.ts
v2.0/src/service/common/awards.service.ts
+63
-1
base.service.ts
v2.0/src/service/common/base.service.ts
+11
-1
prizeConfig.d.ts
v2.0/src/typings/prizeConfig.d.ts
+1
-1
No files found.
v2.0/src/constants.ts
View file @
b5973b30
...
...
@@ -42,8 +42,9 @@ export const TAOBAO_SUCCESS_ORDER_STATUS: string[] = [
export
const
ACTIVITY_OPEN_PRIZE_STATUS
=
{
//开奖状态
AWAIT
:
1
,
FAIL
:
2
,
SUCCESS
:
3
OPENING
:
2
,
SUCCESS
:
3
,
FAIL
:
4
}
// 活动状态
...
...
v2.0/src/controller/awards.controller.ts
View file @
b5973b30
/** @format */
import
{
services
,
checkParams
,
registeInfos
}
from
'../decorator/common'
import
{
services
,
checkParams
,
registeInfos
,
noCheckUser
}
from
'../decorator/common'
import
{
resultsModel
}
from
'../sdk'
import
{
CommonAwardsService
}
from
'../service/common'
import
{
CommonAwardsService
,
CommonBaseService
}
from
'../service/common'
import
preCheck
from
'../decorator/common/preCheck'
import
{
checkActivityTime
,
...
...
@@ -10,6 +10,7 @@ import {
checkValidEnamePrize
,
checkValidObjectPrize
}
from
'../utils/common/check/'
import
{
PRIZE_DATA_TYPE
}
from
'../constants'
export
interface
IReceivePrizeControllerInfos
extends
IControllerInfos
{
awardInfo
:
IAwards
...
...
@@ -90,4 +91,31 @@ export default class AwardsController {
return
resultsModel
.
success
(
drawResult
)
}
/**
* 活动结束开奖
*/
@
noCheckUser
@
services
([
CommonBaseService
,
CommonAwardsService
])
async
endOfActivityRewards
(
context
:
IContext
<
IParams
>
,
{},
[
commonBaseService
,
commonAwardsService
]:
[
CommonBaseService
,
CommonAwardsService
]
)
{
const
activityList
=
await
commonBaseService
.
getNeedRewardsActivityList
()
const
fail
=
[]
const
success
=
[]
for
(
let
activity
of
activityList
)
{
const
res
=
await
commonAwardsService
.
openPrize
(
activity
,
PRIZE_DATA_TYPE
.
RANKING
,
'sortKey'
,
'sortTimeKey'
,
200
)
if
(
res
)
{
success
.
push
(
activity
.
_id
)
}
else
{
fail
.
push
(
activity
.
_id
)
}
}
return
resultsModel
.
success
({
fail
,
success
})
}
}
v2.0/src/service/common/awards.service.ts
View file @
b5973b30
...
...
@@ -13,7 +13,8 @@ import {
ACTIVITY_STATUS
,
DELETE_STATUS
,
SWICH_TOCK
,
SHIP_STATUS
SHIP_STATUS
,
ACTIVITY_OPEN_PRIZE_STATUS
}
from
'../../constants'
import
{
AWARDS_DB_NAME
,
PRIZE_CONFIG_DB_NAME
}
from
'../../db'
import
{
sendTBAward
,
getSellerSession
,
rand
,
formatPrizeProbalityRange
}
from
'../../utils'
...
...
@@ -315,4 +316,65 @@ export default class AwardsService extends UserService {
}
)
}
/**
* 排行榜开奖
* @param activityInfo
*/
async
openPrize
(
activityInfo
,
prizeDataType
,
sortKey
:
string
,
sortTimeKey
:
string
,
limit
?:
number
)
{
const
{
_id
}
=
activityInfo
await
this
.
activitydao
.
update
({
_id
},
{
$set
:
{
openPrizeStatus
:
ACTIVITY_OPEN_PRIZE_STATUS
.
OPENING
}
})
const
prizeConfigList
=
await
this
.
getPrizeConfig
({
activityId
:
_id
,
prizeDataType
})
const
userList
=
await
this
.
userdao
.
find
<
IUserInfo
>
(
{
activityId
:
_id
},
{
sort
:
{
[
sortKey
]:
-
1
,
[
sortTimeKey
]:
1
},
limit
:
limit
||
100
}
)
const
prizeList
=
[]
prizeConfigList
.
forEach
(
prizeConfig
=>
{
const
{
rank
,
_id
:
prizeId
,
type
,
name
,
image
,
credits
}
=
prizeConfig
let
[
min
,
max
]
=
rank
.
split
(
'-'
)
if
(
!
max
)
max
=
min
for
(
let
i
=
+
min
-
1
;
i
<
+
max
+
1
;
i
++
)
{
if
(
userList
[
i
])
{
const
{
openId
,
userNick
}
=
userList
[
i
]
prizeList
.
push
({
openId
,
prizeId
,
activityId
:
_id
,
drawStatus
:
DRAW_STATUS
.
WAITAWARD
,
prizeDataType
,
remark
:
''
,
credits
:
+
credits
,
type
,
name
,
image
,
userNick
,
createDay
:
getToday
(),
shipStatus
:
type
===
PRIZE_TYPE
.
OBJECT
?
SHIP_STATUS
.
NO_ADDRESS
:
''
,
createTime
:
Date
.
now
(),
updateTime
:
Date
.
now
()
})
}
}
})
let
result
=
null
if
(
prizeList
.
length
)
{
result
=
await
this
.
awardsdao
.
insertMany
(
prizeList
)
}
if
(
result
)
{
await
this
.
activitydao
.
update
({
_id
},
{
$set
:
{
openPrizeStatus
:
ACTIVITY_OPEN_PRIZE_STATUS
.
SUCCESS
}
})
return
true
}
else
{
await
this
.
activitydao
.
update
({
_id
},
{
$set
:
{
openPrizeStatus
:
ACTIVITY_OPEN_PRIZE_STATUS
.
FAIL
}
})
return
false
}
}
}
v2.0/src/service/common/base.service.ts
View file @
b5973b30
...
...
@@ -6,7 +6,7 @@
import
{
BaseDao
,
TBAPIS
}
from
'../../sdk'
import
{
ACTIVITY_CONFIG_DB_NAME
}
from
'../../db'
import
{
ACTIVITY_STATUS
}
from
'../../constants'
import
{
ACTIVITY_
OPEN_PRIZE_STATUS
,
ACTIVITY_
STATUS
}
from
'../../constants'
export
default
class
BaseService
{
context
:
IContext
<
any
>
...
...
@@ -52,4 +52,14 @@ export default class BaseService {
)
return
{
list
}
}
/**
* 获取需要开奖的活动列表
*/
async
getNeedRewardsActivityList
()
{
return
await
this
.
activitydao
.
find
<
IActivityInfo
>
({
endTime
:
{
$lt
:
Date
.
now
()
},
openPrizeStatus
:
{
$in
:
[
ACTIVITY_OPEN_PRIZE_STATUS
.
AWAIT
,
ACTIVITY_OPEN_PRIZE_STATUS
.
FAIL
]
}
})
}
}
v2.0/src/typings/prizeConfig.d.ts
View file @
b5973b30
...
...
@@ -20,7 +20,7 @@ interface ICommonActivityPrize {
properiodfrom
?:
number
lockStatus
?:
number
switchStock
?:
number
rank
?:
string
|
number
rank
?:
string
credits
?:
string
|
number
useUrl
?:
string
stock
?:
number
...
...
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