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
9075a0be
Commit
9075a0be
authored
Nov 05, 2020
by
qinhaitao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor:
💡
getTaskList
parent
fee2d5a8
Changes
17
Show whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
68 additions
and
52 deletions
+68
-52
awards.controller.ts
v2.0/src/controller/awards.controller.ts
+1
-1
user.controller.ts
v2.0/src/controller/common/user.controller.ts
+2
-6
game.controller.ts
v2.0/src/controller/game.controller.ts
+20
-0
login.controller.ts
v2.0/src/controller/login.controller.ts
+2
-2
task.controller.ts
v2.0/src/controller/task.controller.ts
+7
-12
user.controller.ts
v2.0/src/controller/user.controller.ts
+2
-4
registeInfos.ts
v2.0/src/decorator/common/registeInfos.ts
+1
-3
access.service.ts
v2.0/src/service/access.service.ts
+2
-1
awards.service.ts
v2.0/src/service/awards.service.ts
+1
-1
task.service.ts
v2.0/src/service/task.service.ts
+10
-1
user.service.ts
v2.0/src/service/user.service.ts
+2
-6
activityConfig.d.ts
v2.0/src/typings/activityConfig.d.ts
+1
-0
index.d.ts
v2.0/src/typings/index.d.ts
+0
-1
updateOrderGoods.ts
v2.0/src/utils/common/update/updateOrderGoods.ts
+3
-1
updateSignTask.ts
v2.0/src/utils/common/update/updateSignTask.ts
+2
-1
vip.ts
v2.0/src/utils/common/vip.ts
+11
-10
vipMock.ts
v2.0/src/vipMock.ts
+1
-2
No files found.
v2.0/src/controller/awards.controller.ts
View file @
9075a0be
...
...
@@ -116,7 +116,7 @@ export default class AwardsController {
>
{
const
{
activityId
,
prizeDataType
}
=
context
.
data
const
drawResult
=
await
awardSer
.
draw
Prize
(
activityId
,
prizeDataType
,
userInfo
)
const
drawResult
=
await
awardSer
.
draw
Lottery
(
activityId
,
prizeDataType
,
userInfo
)
return
resultsModel
.
success
(
drawResult
)
}
...
...
v2.0/src/controller/common/user.controller.ts
View file @
9075a0be
...
...
@@ -32,14 +32,10 @@ export default class User {
@
services
([
UserService
])
async
getVipInfo
(
context
:
IContext
<
IVipParams
>
,
{
activityInfo
,
userInfo
,
session
}:
IControllerInfos
,
{
activityInfo
}:
IControllerInfos
,
[
userService
]:
[
UserService
]
):
Promise
<
IResult
<
IVipInfo
>>
{
const
commonUserGetshopvipResult
=
await
userService
.
getShopVip
(
context
,
session
,
activityUserNick
)
const
commonUserGetshopvipResult
=
await
userService
.
getShopVip
(
context
,
activityInfo
)
return
resultsModel
.
success
({
...
commonUserGetshopvipResult
})
...
...
v2.0/src/controller/game.controller.ts
0 → 100644
View file @
9075a0be
/** @format */
import
{
services
,
checkParams
,
registeInfos
}
from
'../decorator/common'
import
{
resultsModel
}
from
'../sdk'
import
{
UserService
,
AccessService
}
from
'../service'
export
default
class
User
{
/**
* 获取游戏信息
*/
@
checkParams
([
'activityId'
])
@
services
([
UserService
,
AccessService
])
async
getGameInfo
(
context
:
IContext
<
IParams
>
,
{
userInfo
,
activityInfo
,
vipInfo
}:
IControllerInfos
,
[
userService
,
accessService
]:
[
UserService
,
AccessService
]
)
{
const
{
openId
}
=
context
}
}
v2.0/src/controller/login.controller.ts
View file @
9075a0be
...
...
@@ -30,10 +30,10 @@ export default class User {
const
updatedUserInfo
=
await
userService
.
doLogin
(
userInfo
,
vipInfo
,
activityInfo
)
// access表
await
accessService
.
addAccess
(
updatedUserInfo
,
vipInfo
)
const
openIdResult
=
await
accessService
.
addAccess
(
updatedUserInfo
,
vipInfo
)
return
resultsModel
.
success
({
openId
...
openIdResult
})
}
}
v2.0/src/controller/task.controller.ts
View file @
9075a0be
...
...
@@ -21,18 +21,13 @@ export default class Task {
context
:
IContext
<
{
activityId
:
string
}
>
,
{
userInfo
,
activityInfo
}:
IControllerInfos
,
[
taskService
]:
[
TaskService
]
):
Promise
<
IResult
<
ITaskInfo
[]
>>
{
return
resultsModel
.
success
([
taskService
.
initTask
(
'member'
,
'加入会员'
,
activityInfo
,
userInfo
),
taskService
.
initTask
(
'follow'
,
'关注店铺'
,
activityInfo
,
userInfo
)
// taskService.initTask('sign', '签到', activityInfo, userInfo),
// taskService.initTask('orderGoods', '购买商品', activityInfo, userInfo),
// taskService.initTask('browseGoods', '浏览商品', activityInfo, userInfo),
// taskService.initTask('collectGoods', '收藏商品', activityInfo, userInfo),
// taskService.initTask('jumpLink', '浏览页面', activityInfo, userInfo),
// taskService.initTask('invites', '邀请好友', activityInfo, userInfo)
// taskService.initTask('exchangeCredits', '积分兑换', activityInfo, userInfo)
])
):
Promise
<
IResult
<
{
list
:
ITaskInfo
[]
}
>>
{
// 读取B端 tasks字段配置自动生成任务列表
const
result
=
taskService
.
initTaskList
(
userInfo
,
activityInfo
)
return
resultsModel
.
success
({
...
result
})
}
/**
...
...
v2.0/src/controller/user.controller.ts
View file @
9075a0be
...
...
@@ -3,7 +3,6 @@
import
{
services
,
checkParams
,
registeInfos
}
from
'../decorator/common'
import
{
resultsModel
}
from
'../sdk'
import
{
UserService
}
from
'../service'
import
{
formatVipCbUrl
,
getShopVip
}
from
'../utils/common/vip'
export
interface
IVipParams
{
activityId
:
string
...
...
@@ -30,15 +29,14 @@ export default class User {
* 获取会员信息
*/
@
checkParams
([
'activityId'
])
@
registeInfos
([
'session'
])
@
services
([
UserService
])
async
getVipInfo
(
context
:
IContext
<
IVipParams
>
,
{
session
,
activityUserNick
}:
IControllerInfos
,
{
activityInfo
}:
IControllerInfos
,
[
userService
]:
[
UserService
]
):
Promise
<
IResult
<
IVipInfo
>>
{
// 拼接回调参数
const
result
=
await
userService
.
getShopVip
(
context
,
session
,
activityUserNick
)
const
result
=
await
userService
.
getShopVip
(
context
,
activityInfo
)
return
resultsModel
.
success
(
result
)
}
...
...
v2.0/src/decorator/common/registeInfos.ts
View file @
9075a0be
...
...
@@ -29,16 +29,14 @@ async function initBaseInfo(context: IContext<IParams>, baseInfos: ICheckControl
if
(
needInfos
.
includes
(
'session'
)
&&
!
baseInfos
.
session
)
{
const
{
session
,
userNick
}
=
await
getSellerSession
(
context
)
baseInfos
.
session
=
session
baseInfos
.
activityUserNick
=
userNick
}
if
(
needInfos
.
includes
(
'vipInfo'
)
&&
!
baseInfos
.
vipInfo
&&
handler
!==
'getVipInfo'
)
{
if
(
!
baseInfos
.
session
)
{
const
{
session
,
userNick
}
=
await
getSellerSession
(
context
)
baseInfos
.
session
=
session
baseInfos
.
activityUserNick
=
userNick
}
const
vipInfo
=
await
getShopVip
(
context
,
baseInfos
.
session
,
formatVipCbUrl
(
context
),
baseInfos
.
activityUserNick
)
const
vipInfo
=
await
getShopVip
(
context
,
baseInfos
.
activityInfo
,
formatVipCbUrl
(
context
)
)
baseInfos
.
vipInfo
=
vipInfo
}
return
baseInfos
...
...
v2.0/src/service/access.service.ts
View file @
9075a0be
...
...
@@ -23,7 +23,7 @@ export default class UserAccessService {
let
{
openId
,
data
}
=
this
.
context
let
{
activityId
,
userNick
,
avatar
,
inviteId
}
=
data
return
await
this
.
accessdao
.
insertOne
({
await
this
.
accessdao
.
insertOne
({
openId
,
activityId
,
userNick
,
...
...
@@ -39,6 +39,7 @@ export default class UserAccessService {
updateTime
:
Date
.
now
(),
createDay
:
getToday
()
})
return
{
openId
}
}
async
getAccessCount
()
{
...
...
v2.0/src/service/awards.service.ts
View file @
9075a0be
...
...
@@ -233,7 +233,7 @@ export default class AwardsService extends UserService {
return
result
}
async
draw
Prize
(
activityId
:
string
,
prizeDataType
:
number
,
userInfo
:
IUserInfo
)
{
async
draw
Lottery
(
activityId
:
string
,
prizeDataType
:
number
,
userInfo
:
IUserInfo
)
{
const
{
openId
}
=
this
.
context
// 获取奖池配置
const
prizesPool
=
await
this
.
getPrizeConfig
({
...
...
v2.0/src/service/task.service.ts
View file @
9075a0be
...
...
@@ -20,6 +20,7 @@ import {
import
{
TASK_RATE_TYPE
,
TASK_STATUS
}
from
'../constants'
import
{
getTodayCompleteTask
,
getTotalCompleteTask
,
setTaskStatus
}
from
'../utils/common/task'
import
{
CODE_TYPES
}
from
'../errorCode'
import
{
userInfo
}
from
'os'
export
interface
ITaskInfo
{
taskType
?:
string
// 任务类型
...
...
@@ -38,6 +39,14 @@ export default class TaskService extends UserService {
constructor
(
context
:
IContext
<
IParams
>
)
{
super
(
context
)
}
initTaskList
(
userInfo
:
IUserInfo
,
activityInfo
:
IActivityInfo
)
{
return
{
list
:
Object
.
keys
(
activityInfo
?.
tasks
||
{}).
map
((
task
:
ITaskType
)
=>
{
return
this
.
initTask
(
task
,
activityInfo
?.
tasks
?.[
task
]?.
title
,
userInfo
,
activityInfo
)
})
}
}
/**
* 根据任务类型初始化 b端 tasks字段必须有相应的配置
*
...
...
@@ -48,7 +57,7 @@ export default class TaskService extends UserService {
* @return {ITaskInfo} {ITaskInfo} 任务信息
* @memberof TaskService
*/
initTask
(
taskType
:
ITaskType
,
title
:
string
,
activityInfo
:
IActivityInfo
,
userInfo
:
IUser
Info
):
ITaskInfo
{
initTask
(
taskType
:
ITaskType
,
title
:
string
,
userInfo
:
IUserInfo
,
activityInfo
:
IActivity
Info
):
ITaskInfo
{
if
(
!
activityInfo
?.
tasks
?.[
taskType
])
{
console
.
error
(
`活动缺少
${
taskType
}
任务配置项`
)
}
...
...
v2.0/src/service/user.service.ts
View file @
9075a0be
...
...
@@ -235,13 +235,9 @@ class UserService extends BaseService {
return
await
this
.
userdao
.
findOne
({
_id
})
}
async
getShopVip
(
context
:
IContext
<
{
activityId
:
string
;
callbackUrl
?:
string
}
>
,
session
:
string
,
activityUserNick
:
string
)
{
async
getShopVip
(
context
:
IContext
<
{
activityId
:
string
;
callbackUrl
?:
string
}
>
,
activityInfo
:
IActivityInfo
)
{
const
{
callbackUrl
}
=
context
.
data
return
await
getShopVip
(
context
,
session
,
callbackUrl
||
formatVipCbUrl
(
context
),
activityUserNick
)
return
await
getShopVip
(
context
,
activityInfo
,
callbackUrl
||
formatVipCbUrl
(
context
)
)
}
}
...
...
v2.0/src/typings/activityConfig.d.ts
View file @
9075a0be
...
...
@@ -13,6 +13,7 @@ interface IActivityInfo {
createTime
:
number
updateTime
:
number
awardReceiveExpiredTime
?:
number
activtiyInfoUserNick
:
string
tasks
?:
ITasks
}
type
ITaskType
=
...
...
v2.0/src/typings/index.d.ts
View file @
9075a0be
...
...
@@ -28,7 +28,6 @@ interface IControllerInfos {
vipInfo
?:
IVipInfo
activityInfo
:
IActivityInfo
session
?:
string
activityUserNick
?:
string
// 活动创建账号昵称
}
interface
ICheckControllerInfos
extends
IControllerInfos
{
...
...
v2.0/src/utils/common/update/updateOrderGoods.ts
View file @
9075a0be
...
...
@@ -12,6 +12,8 @@ export default async function updateOrderGoods(
const
{
value
,
itemIds
,
taskRateType
,
times
}
=
activityInfo
?.
tasks
?.[
taskType
]
||
{}
const
{
completeTimes
,
taskInfo
}
=
getTotalCompleteTask
(
taskType
,
userInfo
)
const
{
todayCompleteTimes
}
=
getTodayCompleteTask
(
taskType
,
userInfo
)
if
(
!
activityInfo
?.
tasks
?.[
taskType
])
return
{}
// 永久任务且已完成
if
(
taskRateType
===
TASK_RATE_TYPE
.
FOREVER
&&
completeTimes
)
{
return
{}
...
...
@@ -26,7 +28,7 @@ export default async function updateOrderGoods(
const
orderResult
=
await
getUserOrderlist
(
this
.
context
,
//@ts-ignore
activity
S
tartTime
||
Date
.
now
(),
activity
Info
?.
s
tartTime
||
Date
.
now
(),
Date
.
now
()
)
...
...
v2.0/src/utils/common/update/updateSignTask.ts
View file @
9075a0be
...
...
@@ -6,7 +6,8 @@ import { getTodayCompleteTask } from '../task'
export
default
async
function
updateSignTask
(
context
:
IContext
<
IParams
>
,
{
userInfo
,
activityInfo
}:
IControllerInfos
):
Promise
<
IPreUpdateQuery
>
{
):
Promise
<
IPreUpdateQuery
|
undefined
>
{
if
(
!
activityInfo
?.
tasks
?.
sign
)
return
// 获取签到奖励
const
{
value
}
=
activityInfo
?.
tasks
?.
sign
||
{}
...
...
v2.0/src/utils/common/vip.ts
View file @
9075a0be
...
...
@@ -9,10 +9,10 @@ import { TBAPIS } from '../../sdk'
/** @format */
// 测试环境 duib2账户mock数据 或者本地
export
const
isUseVipMock
=
(
context
:
IContext
<
IParams
>
,
userNick
:
string
)
=>
{
export
const
isUseVipMock
=
(
context
:
IContext
<
IParams
>
,
activtiyInfo
:
IActivityInfo
)
=>
{
const
isTestEnv
=
context
.
env
===
'test'
const
isMockEnv
=
context
.
env
===
'mock'
const
isDuibaAccount
=
userNick
.
startsWith
(
'duiba2'
)
const
isDuibaAccount
=
activtiyInfo
?.
activtiyInfoUserNick
?
.
startsWith
(
'duiba2'
)
return
(
isTestEnv
&&
isDuibaAccount
)
||
isMockEnv
}
...
...
@@ -24,21 +24,22 @@ export const isUseVipMock = (context: IContext<IParams>, userNick: string) => {
*/
export
const
getShopVip
=
async
(
context
:
IContext
<
any
>
,
session
:
string
,
callbackUrl
:
string
=
''
,
activityUserNick
:
string
=
''
activityInfo
:
IActivityInfo
,
callbackUrl
:
string
=
''
):
Promise
<
IVipInfo
>
=>
{
if
(
isUseVipMock
(
context
,
activityUserNick
))
{
return
VIP_MOCK
const
shopUrl
=
generateVipUrl
(
callbackUrl
)
if
(
isUseVipMock
(
context
,
activityInfo
))
{
return
{
...
VIP_MOCK
,
url
:
shopUrl
}
}
let
result
=
{
result
:
{
member_info
:
''
}
}
result
=
await
TBAPIS
.
queryVipinfo
(
context
,
session
)
const
shopUrl
=
generateVipUrl
(
callbackUrl
)
result
=
await
TBAPIS
.
queryVipinfo
(
context
)
return
{
isVip
:
!!
(
result
.
result
&&
result
.
result
.
member_info
),
...
...
v2.0/src/vipMock.ts
View file @
9075a0be
...
...
@@ -2,6 +2,5 @@
// 测试环境下 duiba2及其子账号自动开启VIP_MOCK, 返回数据可在此设置
export
const
VIP_MOCK
=
{
isVip
:
false
,
url
:
'//taobao.com'
isVip
:
false
}
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