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