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
bc63fb49
Commit
bc63fb49
authored
Nov 11, 2020
by
qinhaitao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:
🎸
逻辑处理
parent
bd634c74
Changes
20
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
224 additions
and
87 deletions
+224
-87
awards.controller.ts
v2.0/src/controller/awards.controller.ts
+5
-14
awards.controller.ts
v2.0/src/controller/common/awards.controller.ts
+98
-0
base.controller.ts
v2.0/src/controller/common/base.controller.ts
+1
-1
login.controller.ts
v2.0/src/controller/common/login.controller.ts
+1
-1
share.controller.ts
v2.0/src/controller/common/share.controller.ts
+47
-0
stat.controller.ts
v2.0/src/controller/common/stat.controller.ts
+4
-12
task.controller.ts
v2.0/src/controller/common/task.controller.ts
+4
-4
user.controller.ts
v2.0/src/controller/common/user.controller.ts
+2
-2
test1.controller.ts
v2.0/src/controller/custom/test1.controller.ts
+2
-2
test2.controller.ts
v2.0/src/controller/custom/test2.controller.ts
+2
-2
share.controller.ts
v2.0/src/controller/share.controller.ts
+6
-17
task.controller.ts
v2.0/src/controller/task.controller.ts
+7
-1
preCheck.ts
v2.0/src/decorator/common/preCheck.ts
+3
-3
preUpdate.ts
v2.0/src/decorator/common/preUpdate.ts
+2
-2
registeInfos.ts
v2.0/src/decorator/common/registeInfos.ts
+2
-2
services.ts
v2.0/src/decorator/common/services.ts
+7
-2
index.ts
v2.0/src/index.ts
+10
-0
awards.service.ts
v2.0/src/service/common/awards.service.ts
+7
-22
user.service.ts
v2.0/src/service/common/user.service.ts
+8
-0
index.d.ts
v2.0/src/typings/index.d.ts
+6
-0
No files found.
v2.0/src/controller/awards.controller.ts
View file @
bc63fb49
...
...
@@ -40,18 +40,8 @@ export default class AwardsController {
context
:
IContext
<
IParams
>
,
{
activityInfo
}:
IReceivePrizeControllerInfos
,
[
awardSer
]:
[
CommonAwardsService
]
):
Promise
<
IResult
<
boolean
>>
{
let
{
province
,
city
,
area
,
streetName
,
addressDetail
,
id
,
name
,
phone
}
=
context
.
data
let
result
=
await
awardSer
.
recieveObjectPrize
(
id
,
{
province
,
city
,
area
,
streetName
,
addressDetail
,
name
,
phone
})
)
{
let
result
=
await
awardSer
.
recieveObjectPrize
(
context
)
return
resultsModel
.
success
(
result
)
}
...
...
@@ -65,8 +55,9 @@ export default class AwardsController {
@
preCheck
([
checkPrizeExpired
,
checkValidEnamePrize
])
async
receiveEnamePrize
(
context
:
IContext
<
IParams
>
,
{
awardInfo
,
session
}:
IReceivePrizeControllerInfos
,
[
awardSer
]:
[
CommonAwardsService
]
{
session
}:
IReceivePrizeControllerInfos
,
[
awardSer
]:
[
CommonAwardsService
],
{
awardInfo
}:
IPreCheckData
)
{
let
{
id
}
=
context
.
data
...
...
v2.0/src/controller/common/awards.controller.ts
0 → 100644
View file @
bc63fb49
/** @format */
import
commonDecorator
,
{
services
}
from
'../../decorator/common'
import
commonUtilCheck
from
'../../utils/common/check'
import
commonUtilUpdate
from
'../../utils/common/update'
import
customDecorator
from
'../../decorator/custom'
import
customUtil
from
'../../utils/custom'
import
{
resultsModel
}
from
'../../sdk'
import
{
CommonAwardsService
}
from
'../../service/common'
export
default
class
AwardsController
{
/**
* 我的奖品列表
*/
@
commonDecorator
.
checkParams
([
'activityId'
])
@
services
([
CommonAwardsService
])
async
getMyPrizeList
(
context
:
IContext
<
IParams
>
,
{
activityInfo
,
userInfo
}:
IControllerInfos
,
[
commonAwardsService
]:
[
CommonAwardsService
]
)
{
const
commonAwardsGetMyPrizeListResult1
=
await
commonAwardsService
.
getMyPrizeList
(
activityInfo
)
return
resultsModel
.
success
({
...
commonAwardsGetMyPrizeListResult1
})
}
/**
* 领取实物
*/
@
commonDecorator
.
checkParams
([
'activityId'
,
'id'
,
'name'
,
'phone'
,
'province'
,
'city'
,
'area'
,
'addressDetail'
,
'streetName'
])
@
commonDecorator
.
preCheck
([
commonUtilCheck
.
checkPrizeExpired
,
commonUtilCheck
.
checkValidObjectPrize
])
@
services
([
CommonAwardsService
])
async
receiveObjectPrize
(
context
:
IContext
<
IParams
>
,
{
activityInfo
,
userInfo
}:
IControllerInfos
,
[
commonAwardsService
]:
[
CommonAwardsService
],
{
awardInfo
}:
IPreCheckData
)
{
const
commonAwardsRecieveObjectPrizeResult1
=
await
commonAwardsService
.
recieveObjectPrize
(
context
)
return
resultsModel
.
success
({
...
commonAwardsRecieveObjectPrizeResult1
})
}
/**
* 领取权益
*/
@
commonDecorator
.
checkParams
([
'activityId'
,
'id'
])
@
commonDecorator
.
registeInfos
([
'session'
])
@
commonDecorator
.
preCheck
([
commonUtilCheck
.
checkPrizeExpired
,
commonUtilCheck
.
checkValidEnamePrize
])
@
services
([
CommonAwardsService
])
async
receiveEnamePrize
(
context
:
IContext
<
IParams
>
,
{
activityInfo
,
userInfo
,
session
}:
IControllerInfos
,
[
commonAwardsService
]:
[
CommonAwardsService
],
{
awardInfo
}:
IPreCheckData
)
{
const
commonAwardsRecieveEnamePrizeResult1
=
await
commonAwardsService
.
recieveEnamePrize
(
context
.
data
.
id
,
awardInfo
,
session
)
return
resultsModel
.
success
({
...
commonAwardsRecieveEnamePrizeResult1
})
}
/**
* 概率抽奖
*/
@
commonDecorator
.
checkParams
([
'activityId'
,
'prizeDataType'
])
@
commonDecorator
.
registeInfos
([
'session'
])
@
commonDecorator
.
preCheck
([
commonUtilCheck
.
checkActivityTime
])
@
services
([
CommonAwardsService
])
async
drawLotteryPrize
(
context
:
IContext
<
IParams
>
,
{
activityInfo
,
userInfo
,
session
}:
IControllerInfos
,
[
commonAwardsService
]:
[
CommonAwardsService
]
)
{
const
commonAwardsDrawLotteryResult1
=
await
commonAwardsService
.
drawLottery
(
context
.
data
.
activityId
,
context
.
data
.
prizeDataType
,
userInfo
)
return
resultsModel
.
success
({
...
commonAwardsDrawLotteryResult1
})
}
}
v2.0/src/controller/common/base.controller.ts
View file @
bc63fb49
...
...
@@ -19,7 +19,7 @@ export default class BaseController {
async
getActivityBaseInfoById
(
context
:
IContext
<
IParams
>
,
{
activityInfo
,
userInfo
}:
IControllerInfos
,
[
commonBaseService
]:
[
CommonBaseService
]
[
commonBaseService
]:
[
CommonBaseService
]
,
)
{
const
commonBaseGetBaseInfoResult1
=
await
commonBaseService
.
getBaseInfo
(
context
.
data
.
activityId
)
return
resultsModel
.
success
({
...
...
v2.0/src/controller/common/login.controller.ts
View file @
bc63fb49
...
...
@@ -20,7 +20,7 @@ export default class LoginController {
async
login
(
context
:
IContext
<
IParams
>
,
{
activityInfo
,
userInfo
,
vipInfo
}:
IControllerInfos
,
[
commonUserService
,
commonAccessService
]:
[
CommonUserService
,
CommonAccessService
]
[
commonUserService
,
commonAccessService
]:
[
CommonUserService
,
CommonAccessService
]
,
)
{
const
commonUserDoLoginResult1
=
await
commonUserService
.
doLogin
(
userInfo
,
vipInfo
,
activityInfo
)
const
commonAccessAddAccessResult2
=
await
commonAccessService
.
addAccess
(
commonUserDoLoginResult1
,
vipInfo
)
...
...
v2.0/src/controller/common/share.controller.ts
0 → 100644
View file @
bc63fb49
/** @format */
import
commonDecorator
,
{
services
}
from
'../../decorator/common'
import
commonUtilCheck
from
'../../utils/common/check'
import
commonUtilUpdate
from
'../../utils/common/update'
import
customDecorator
from
'../../decorator/custom'
import
customUtil
from
'../../utils/custom'
import
{
resultsModel
}
from
'../../sdk'
import
{
CommonUserService
,
CommonTaskService
,
CommonStatService
}
from
'../../service/common'
export
default
class
ShareController
{
/**
* 获取邀请信息
*/
@
commonDecorator
.
checkParams
([
'activityId'
])
@
services
([
CommonUserService
])
async
getShareInfo
(
context
:
IContext
<
IParams
>
,
{
activityInfo
,
userInfo
}:
IControllerInfos
,
[
commonUserService
]:
[
CommonUserService
],
)
{
const
commonUserQueryDataByKeyResult1
=
await
commonUserService
.
queryDataByKey
(
'remainTimes.invites'
,
userInfo
,
'rewards'
)
return
resultsModel
.
success
({
...
commonUserQueryDataByKeyResult1
})
}
/**
* 完成分享
*/
@
commonDecorator
.
checkParams
([
'activityId'
,
'inviteId'
])
@
commonDecorator
.
registeInfos
([
'vipInfo'
])
@
commonDecorator
.
preCheck
([
commonUtilCheck
.
checkActivityTime
,
commonUtilCheck
.
checkInviteId
,
commonUtilCheck
.
checkNewVip
,
commonUtilCheck
.
checkHelpRecord
])
@
services
([
CommonTaskService
,
CommonStatService
])
async
doHelp
(
context
:
IContext
<
IParams
>
,
{
activityInfo
,
userInfo
,
vipInfo
}:
IControllerInfos
,
[
commonTaskService
,
commonStatService
]:
[
CommonTaskService
,
CommonStatService
],
{
inviteUserInfo
}:
IPreCheckData
)
{
const
commonTaskCompleteTaskResult1
=
await
commonTaskService
.
completeTask
(
'invites'
,
activityInfo
,
inviteUserInfo
)
const
commonStatAddStatResult2
=
await
commonStatService
.
addStat
(
0
,
userInfo
)
return
resultsModel
.
success
({
...
commonStatAddStatResult2
})
}
}
v2.0/src/controller/common/stat.controller.ts
View file @
bc63fb49
...
...
@@ -18,7 +18,7 @@ export default class StatController {
async
addStat
(
context
:
IContext
<
IParams
>
,
{
activityInfo
,
userInfo
}:
IControllerInfos
,
[
commonStatService
]:
[
CommonStatService
]
[
commonStatService
]:
[
CommonStatService
]
,
)
{
const
commonStatAddStatResult1
=
await
commonStatService
.
addStat
(
context
.
data
.
type
,
userInfo
)
return
resultsModel
.
success
({
...
...
@@ -33,18 +33,10 @@ export default class StatController {
async
getStats
(
context
:
IContext
<
IParams
>
,
{
activityInfo
,
userInfo
}:
IControllerInfos
,
[
commonStatService
]:
[
CommonStatService
]
[
commonStatService
]:
[
CommonStatService
]
,
)
{
const
commonStatGetStatsResult1
=
await
commonStatService
.
getStats
(
context
.
data
.
activityId
,
context
.
data
.
startDay
,
context
.
data
.
endDay
)
const
commonStatBuildExcelResult2
=
await
commonStatService
.
buildExcel
(
context
.
data
.
startDay
,
context
.
data
.
endDay
,
commonStatGetStatsResult1
)
const
commonStatGetStatsResult1
=
await
commonStatService
.
getStats
(
context
.
data
.
activityId
,
context
.
data
.
startDay
,
context
.
data
.
endDay
)
const
commonStatBuildExcelResult2
=
await
commonStatService
.
buildExcel
(
context
.
data
.
startDay
,
context
.
data
.
endDay
,
commonStatGetStatsResult1
)
return
resultsModel
.
success
({
...
commonStatBuildExcelResult2
})
...
...
v2.0/src/controller/common/task.controller.ts
View file @
bc63fb49
...
...
@@ -21,7 +21,7 @@ export default class TaskController {
async
getTaskList
(
context
:
IContext
<
IParams
>
,
{
activityInfo
,
userInfo
,
vipInfo
}:
IControllerInfos
,
[
commonTaskService
]:
[
CommonTaskService
]
[
commonTaskService
]:
[
CommonTaskService
]
,
)
{
const
commonTaskInitTaskListResult1
=
await
commonTaskService
.
initTaskList
(
userInfo
,
activityInfo
)
return
resultsModel
.
success
({
...
...
@@ -38,7 +38,7 @@ export default class TaskController {
async
doCompleteTask
(
context
:
IContext
<
IParams
>
,
{
activityInfo
,
userInfo
,
session
}:
IControllerInfos
,
[
commonTaskService
]:
[
CommonTaskService
]
[
commonTaskService
]:
[
CommonTaskService
]
,
)
{
const
commonTaskCompleteTaskResult1
=
await
commonTaskService
.
completeTask
(
context
.
data
.
taskType
,
activityInfo
,
userInfo
)
return
resultsModel
.
success
({
...
...
@@ -54,7 +54,7 @@ export default class TaskController {
async
receiveTaskRewards
(
context
:
IContext
<
IParams
>
,
{
activityInfo
,
userInfo
}:
IControllerInfos
,
[
commonTaskService
]:
[
CommonTaskService
]
[
commonTaskService
]:
[
CommonTaskService
]
,
)
{
const
commonTaskReceiveTaskRewardsResult1
=
await
commonTaskService
.
receiveTaskRewards
(
context
.
data
.
taskType
,
context
.
data
.
rewardsKey
,
userInfo
)
return
resultsModel
.
success
({
...
...
@@ -70,7 +70,7 @@ export default class TaskController {
async
getCollectGoodsList
(
context
:
IContext
<
IParams
>
,
{
activityInfo
,
userInfo
,
session
}:
IControllerInfos
,
[
commonBaseService
,
commonTaskService
]:
[
CommonBaseService
,
CommonTaskService
]
[
commonBaseService
,
commonTaskService
]:
[
CommonBaseService
,
CommonTaskService
]
,
)
{
const
commonBaseGetItemListByIdsResult1
=
await
commonBaseService
.
getItemListByIds
(
context
.
data
.
itemIds
,
session
)
const
commonTaskGetItemListWithCollectStatusResult2
=
await
commonTaskService
.
getItemListWithCollectStatus
(
commonBaseGetItemListByIdsResult1
,
userInfo
)
...
...
v2.0/src/controller/common/user.controller.ts
View file @
bc63fb49
...
...
@@ -18,7 +18,7 @@ export default class UserController {
async
getVipInfo
(
context
:
IContext
<
IParams
>
,
{
activityInfo
,
userInfo
}:
IControllerInfos
,
[
commonUserService
]:
[
CommonUserService
]
[
commonUserService
]:
[
CommonUserService
]
,
)
{
const
commonUserGetShopVipResult1
=
await
commonUserService
.
getShopVip
(
context
,
activityInfo
)
return
resultsModel
.
success
({
...
...
@@ -33,7 +33,7 @@ export default class UserController {
async
getRankList
(
context
:
IContext
<
IParams
>
,
{
activityInfo
,
userInfo
}:
IControllerInfos
,
[
commonUserService
]:
[
CommonUserService
]
[
commonUserService
]:
[
CommonUserService
]
,
)
{
const
commonUserGetMyRankInfoResult1
=
await
commonUserService
.
getMyRankInfo
(
context
.
data
.
key
,
context
.
data
.
timeKey
,
userInfo
)
const
commonUserGetRankResult2
=
await
commonUserService
.
getRank
(
context
.
data
.
key
,
context
.
data
.
timeKey
,
context
.
data
.
limit
)
...
...
v2.0/src/controller/custom/test1.controller.ts
View file @
bc63fb49
...
...
@@ -21,7 +21,7 @@ export default class Test1Controller {
async
addStat
(
context
:
IContext
<
IParams
>
,
{
activityInfo
,
userInfo
}:
IControllerInfos
,
[
commonStatService
,
customTestService
]:
[
CommonStatService
,
CustomTestService
]
[
commonStatService
,
customTestService
]:
[
CommonStatService
,
CustomTestService
]
,
)
{
const
commonStatAddStatResult1
=
await
commonStatService
.
addStat
(
context
.
data
.
type
,
userInfo
)
const
customTestTest1Result2
=
await
customTestService
.
test1
()
...
...
@@ -38,7 +38,7 @@ export default class Test1Controller {
async
getStats
(
context
:
IContext
<
IParams
>
,
{
activityInfo
,
userInfo
}:
IControllerInfos
,
[
commonStatService
]:
[
CommonStatService
]
[
commonStatService
]:
[
CommonStatService
]
,
)
{
const
commonStatGetStatsResult1
=
await
commonStatService
.
getStats
(
context
.
data
.
activityId
,
context
.
data
.
startDay
,
context
.
data
.
endDay
)
const
commonStatBuildExcelResult2
=
await
commonStatService
.
buildExcel
(
context
.
data
.
startDay
,
context
.
data
.
endDay
,
commonStatGetStatsResult1
)
...
...
v2.0/src/controller/custom/test2.controller.ts
View file @
bc63fb49
...
...
@@ -18,7 +18,7 @@ export default class Test2Controller {
async
addStat
(
context
:
IContext
<
IParams
>
,
{
activityInfo
,
userInfo
}:
IControllerInfos
,
[
commonStatService
]:
[
CommonStatService
]
[
commonStatService
]:
[
CommonStatService
]
,
)
{
const
commonStatAddStatResult1
=
await
commonStatService
.
addStat
(
context
.
data
.
type
,
userInfo
)
return
resultsModel
.
success
({
...
...
@@ -33,7 +33,7 @@ export default class Test2Controller {
async
getStats
(
context
:
IContext
<
IParams
>
,
{
activityInfo
,
userInfo
}:
IControllerInfos
,
[
commonStatService
]:
[
CommonStatService
]
[
commonStatService
]:
[
CommonStatService
]
,
)
{
const
commonStatGetStatsResult1
=
await
commonStatService
.
getStats
(
context
.
data
.
activityId
,
context
.
data
.
startDay
,
context
.
data
.
endDay
)
const
commonStatBuildExcelResult2
=
await
commonStatService
.
buildExcel
(
context
.
data
.
startDay
,
context
.
data
.
endDay
,
commonStatGetStatsResult1
)
...
...
v2.0/src/controller/share.controller.ts
View file @
bc63fb49
...
...
@@ -6,9 +6,6 @@ import { CommonUserService, CommonStatService, CommonTaskService } from '../serv
import
{
STAT_TYPE
}
from
'../constants'
import
{
checkActivityTime
,
checkInviteId
,
checkHelpRecord
,
checkNewVip
}
from
'../utils/common/check'
import
{
updateVip
}
from
'../utils/common/update/'
export
interface
IdoHelpInfos
extends
IControllerInfos
{
inviteUserInfo
:
IUserInfo
}
export
default
class
Share
{
/**
...
...
@@ -16,17 +13,10 @@ export default class Share {
*/
@
checkParams
([
'activityId'
])
@
services
([
CommonUserService
])
async
getShareInfo
(
context
:
IContext
<
IParams
>
,
{
userInfo
}:
IControllerInfos
):
Promise
<
IResult
<
{
rewards
:
number
}
>>
{
const
{
remainTimes
:
{
invites
}
}
=
userInfo
async
getShareInfo
(
context
:
IContext
<
IParams
>
,
{
userInfo
}:
IControllerInfos
,
[
userService
]:
[
CommonUserService
])
{
const
result
=
await
userService
.
queryDataByKey
(
'remainTimes.invites'
,
userInfo
,
'rewards'
)
return
resultsModel
.
success
({
rewards
:
invites
})
return
resultsModel
.
success
(
result
)
}
/**
* 完成分享
...
...
@@ -38,11 +28,10 @@ export default class Share {
@
preUpdate
([
updateVip
])
async
doHelp
(
context
:
IContext
<
IParams
>
,
{
userInfo
,
activityInfo
,
inviteUserInfo
}:
IdoHelpInfos
,
[
taskService
,
statService
]:
[
CommonTaskService
,
CommonStatService
]
{
userInfo
,
activityInfo
}:
IControllerInfos
,
[
taskService
,
statService
]:
[
CommonTaskService
,
CommonStatService
],
{
inviteUserInfo
}:
IPreCheckData
)
{
const
{
openId
}
=
context
const
result
=
await
taskService
.
completeTask
(
'invites'
,
activityInfo
,
inviteUserInfo
)
await
statService
.
addStat
(
STAT_TYPE
.
INITE_SUCCESS
,
userInfo
)
...
...
v2.0/src/controller/task.controller.ts
View file @
bc63fb49
...
...
@@ -4,7 +4,13 @@ import { checkParams, services, registeInfos, preCheck } from '../decorator/comm
import
{
resultsModel
}
from
'../sdk'
import
{
CommonTaskService
,
CommonBaseService
}
from
'../service/common'
import
{
ITaskInfo
}
from
'../service/common/task.service'
import
{
checkActivityTime
,
checkTaskLimit
,
checkExchangeCreditsTask
,
checkRemainTimes
}
from
'../utils/common/check/'
import
{
checkActivityTime
,
checkTaskLimit
,
checkExchangeCreditsTask
,
checkRemainTimes
,
checkInviteId
}
from
'../utils/common/check/'
import
{
preUpdate
}
from
'../decorator/common'
import
{
updateVip
,
updateSignTask
,
updateOrderGoods
}
from
'../utils/common/update'
...
...
v2.0/src/decorator/common/preCheck.ts
View file @
bc63fb49
...
...
@@ -6,7 +6,7 @@ export default function preCheck(checks: IFunction[]) {
const
method
=
descriptor
.
value
descriptor
.
value
=
async
function
(...
args
:
any
[])
{
let
[
context
,
otherArgs
=
{},
services
=
[]]
=
args
let
[
context
,
otherArgs
=
{},
services
=
[]
,
preCheckData
=
{}
]
=
args
for
(
let
i
=
0
;
i
<
checks
.
length
;
i
++
)
{
const
checkFn
=
checks
[
i
]
...
...
@@ -17,9 +17,9 @@ export default function preCheck(checks: IFunction[]) {
return
result
}
otherArgs
=
{
...
otherArgs
,
...
result
}
preCheckData
=
{
...
preCheckData
,
...
result
}
}
return
method
.
apply
(
target
,
[
context
,
{
...
otherArgs
},
services
])
return
method
.
apply
(
target
,
[
context
,
{
...
otherArgs
},
services
,
preCheckData
])
}
}
}
v2.0/src/decorator/common/preUpdate.ts
View file @
bc63fb49
...
...
@@ -14,7 +14,7 @@ export default function preUpdate(checks: IFunction[]) {
const
method
=
descriptor
.
value
descriptor
.
value
=
async
function
(...
args
:
any
[])
{
let
[
context
,
otherArgs
=
{}
as
IControllerInfos
,
services
=
[]]
=
args
let
[
context
,
otherArgs
=
{}
as
IControllerInfos
,
services
=
[]
,
preCheckData
=
{}
]
=
args
let
totalUpdateProjection
:
IPreUpdateQuery
=
{}
for
(
let
i
=
0
;
i
<
checks
.
length
;
i
++
)
{
const
checkFn
=
checks
[
i
]
...
...
@@ -42,7 +42,7 @@ export default function preUpdate(checks: IFunction[]) {
recordErrorLog
(
context
,
otherArgs
,
error
.
toString
(),
error
.
stack
)
return
resultsModel
.
error
(
CODE_TYPES
.
SYSTEM_ERROR
)
}
return
method
.
apply
(
target
,
[
context
,
{
...
otherArgs
},
services
])
return
method
.
apply
(
target
,
[
context
,
{
...
otherArgs
},
services
,
preCheckData
])
}
}
}
...
...
v2.0/src/decorator/common/registeInfos.ts
View file @
bc63fb49
...
...
@@ -46,13 +46,13 @@ export default function registeInfos(needInfos: IInfo[]) {
return
function
(
target
:
any
,
name
:
string
,
descriptor
:
PropertyDescriptor
)
{
const
method
=
descriptor
.
value
descriptor
.
value
=
async
function
(...
args
:
any
[])
{
const
[
context
,
otherArgs
=
{}]
=
args
const
[
context
,
otherArgs
=
{}
,
services
=
[],
preCheckData
=
{}
]
=
args
const
baseInfo
=
await
initBaseInfo
(
context
,
otherArgs
,
needInfos
)
if
((
baseInfo
as
ICodeType
).
code
)
return
resultsModel
.
error
(
baseInfo
as
ICodeType
)
return
method
.
apply
(
target
,
[
context
,
{
...
baseInfo
,
registed
:
true
}])
return
method
.
apply
(
target
,
[
context
,
{
...
baseInfo
,
registed
:
true
}
,
services
,
preCheckData
])
}
}
}
v2.0/src/decorator/common/services.ts
View file @
bc63fb49
...
...
@@ -36,7 +36,7 @@ export default function services(services: Constructor[]) {
const
method
=
descriptor
.
value
descriptor
.
value
=
async
function
(...
args
:
any
[])
{
let
[
context
,
otherArgs
=
{}]
=
args
let
[
context
,
otherArgs
=
{}
,
originServices
=
[],
preCheckData
=
{}
]
=
args
const
servicesInstance
=
services
.
map
(
v
=>
new
v
(
context
))
logFn
(
context
)
...
...
@@ -53,7 +53,12 @@ export default function services(services: Constructor[]) {
return
method
.
apply
(
target
,
[
context
,
baseInfos
,
servicesInstance
])
}
return
await
doHandler
(
target
,
method
,
[
context
,
baseInfos
,
servicesInstance
])
return
await
doHandler
(
target
,
method
,
[
context
,
baseInfos
,
[...
originServices
,
...
servicesInstance
],
preCheckData
])
}
}
}
v2.0/src/index.ts
View file @
bc63fb49
...
...
@@ -9,6 +9,10 @@ import CommonBaseController from './controller/common/base.controller'
const
CommonBaseControllerInstance
=
new
CommonBaseController
()
import
CommonStatController
from
'./controller/common/stat.controller'
const
CommonStatControllerInstance
=
new
CommonStatController
()
import
CommonAwardsController
from
'./controller/common/awards.controller'
const
CommonAwardsControllerInstance
=
new
CommonAwardsController
()
import
CommonShareController
from
'./controller/common/share.controller'
const
CommonShareControllerInstance
=
new
CommonShareController
()
import
CustomTest1Controller
from
'./controller/custom/test1.controller'
const
CustomTest1ControllerInstance
=
new
CustomTest1Controller
()
import
CustomTest2Controller
from
'./controller/custom/test2.controller'
...
...
@@ -25,6 +29,12 @@ export default {
commonBaseGetactivitybaseinfobyid
:
CommonBaseControllerInstance
.
getActivityBaseInfoById
,
commonStatAddstat
:
CommonStatControllerInstance
.
addStat
,
commonStatGetstats
:
CommonStatControllerInstance
.
getStats
,
commonAwardsGetmyprizelist
:
CommonAwardsControllerInstance
.
getMyPrizeList
,
commonAwardsReceiveobjectprize
:
CommonAwardsControllerInstance
.
receiveObjectPrize
,
commonAwardsReceiveenameprize
:
CommonAwardsControllerInstance
.
receiveEnamePrize
,
commonAwardsDrawlotteryprize
:
CommonAwardsControllerInstance
.
drawLotteryPrize
,
commonShareGetshareinfo
:
CommonShareControllerInstance
.
getShareInfo
,
commonShareDohelp
:
CommonShareControllerInstance
.
doHelp
,
customTest1Addstat
:
CustomTest1ControllerInstance
.
addStat
,
customTest1Getstats
:
CustomTest1ControllerInstance
.
getStats
,
customTest2Addstat
:
CustomTest2ControllerInstance
.
addStat
,
...
...
v2.0/src/service/common/awards.service.ts
View file @
bc63fb49
...
...
@@ -169,28 +169,11 @@ export default class AwardsService extends UserService {
}
// 领取实物
async
recieveObjectPrize
(
_id
:
string
,
{
province
,
city
,
area
,
streetName
,
addressDetail
,
name
,
phone
}:
{
province
:
string
city
:
string
area
:
string
streetName
:
string
addressDetail
:
string
name
:
string
phone
:
string
|
number
}
)
{
async
recieveObjectPrize
(
context
:
IContext
<
IParams
>
)
{
let
{
province
,
city
,
area
,
streetName
,
addressDetail
,
id
,
name
,
phone
}
=
context
.
data
let
result
=
await
this
.
awardsdao
.
update
(
{
_id
},
{
_id
:
id
},
{
$set
:
{
receiveName
:
name
,
...
...
@@ -207,7 +190,9 @@ export default class AwardsService extends UserService {
}
}
)
return
result
?
true
:
CODE_TYPES
.
ERROR_RECEIVE_PRIZE
return
result
?
{
province
,
city
,
area
,
streetName
,
addressDetail
,
id
,
name
,
phone
}
:
CODE_TYPES
.
ERROR_RECEIVE_PRIZE
}
// 发放淘宝权益(奖品数据已插入到awards_info表,且状态drawStatus 为1或者6)
...
...
v2.0/src/service/common/user.service.ts
View file @
bc63fb49
...
...
@@ -11,6 +11,8 @@ import { getToday, formatUpdateUserProjection } from '../../utils'
import
{
isNewVip
}
from
'../../utils/common/userUpdate'
import
{
formatUserNick
,
formatUpdatedDataByProjection
}
from
'../../utils/common/format'
import
{
getShopVip
,
formatVipCbUrl
}
from
'../../utils/common/vip'
import
{
get
}
from
'mpath'
class
UserService
extends
BaseService
{
userdao
:
IBaseDao
constructor
(
context
:
IContext
<
IParams
>
)
{
...
...
@@ -239,6 +241,12 @@ class UserService extends BaseService {
const
{
callbackUrl
}
=
context
.
data
return
await
getShopVip
(
context
,
activityInfo
,
callbackUrl
||
formatVipCbUrl
(
context
))
}
async
queryDataByKey
(
key
:
string
,
userInfo
:
IUserInfo
,
customKey
?:
string
)
{
return
{
[
customKey
||
key
]:
get
(
key
,
userInfo
)
}
}
}
export
default
UserService
v2.0/src/typings/index.d.ts
View file @
bc63fb49
...
...
@@ -37,6 +37,12 @@ interface ICheckControllerInfos extends IControllerInfos {
registed
?:
boolean
}
// preCeck返回的数据
interface
IPreCheckData
{
inviteUserInfo
?:
IUserInfo
// checkValidInviteId
awardInfo
?:
IAwards
// checkValidPrize
}
interface
IVipInfo
{
isVip
:
boolean
url
?:
string
...
...
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