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
29ebade8
Commit
29ebade8
authored
Nov 03, 2020
by
qinhaitao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:
🎸
任务优化
parent
0e1d8117
Changes
33
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
33 changed files
with
337 additions
and
804 deletions
+337
-804
share.controller.js
v2.0/dist/controller/share.controller.js
+1
-1
share.controller.js.map
v2.0/dist/controller/share.controller.js.map
+1
-1
task.controller.d.ts
v2.0/dist/controller/task.controller.d.ts
+7
-17
task.controller.js
v2.0/dist/controller/task.controller.js
+28
-186
task.controller.js.map
v2.0/dist/controller/task.controller.js.map
+1
-1
index.d.ts
v2.0/dist/index.d.ts
+8
-3
index.js
v2.0/dist/index.js
+3
-2
index.js.map
v2.0/dist/index.js.map
+1
-1
task.service.d.ts
v2.0/dist/service/task.service.d.ts
+13
-40
task.service.js
v2.0/dist/service/task.service.js
+29
-148
task.service.js.map
v2.0/dist/service/task.service.js.map
+1
-1
user.service.js
v2.0/dist/service/user.service.js
+1
-1
user.service.js.map
v2.0/dist/service/user.service.js.map
+1
-1
index.d.ts
v2.0/dist/utils/index.d.ts
+0
-1
index.js
v2.0/dist/utils/index.js
+0
-1
index.js.map
v2.0/dist/utils/index.js.map
+1
-1
share.controller.ts
v2.0/src/controller/share.controller.ts
+1
-1
task.controller.ts
v2.0/src/controller/task.controller.ts
+29
-174
update.ts
v2.0/src/decorator/common/update.ts
+7
-2
index.ts
v2.0/src/index.ts
+2
-4
task.service.ts
v2.0/src/service/task.service.ts
+25
-145
user.service.ts
v2.0/src/service/user.service.ts
+1
-1
dao.d.ts
v2.0/src/typings/dao.d.ts
+6
-3
checkExchangeCreditsTask.ts
v2.0/src/utils/common/check/checkExchangeCreditsTask.ts
+33
-0
checkInviteId.ts
v2.0/src/utils/common/check/checkInviteId.ts
+1
-0
checkNewVip.ts
v2.0/src/utils/common/check/checkNewVip.ts
+0
-5
checkTaskLimit.ts
v2.0/src/utils/common/check/checkTaskLimit.ts
+49
-9
exportHandlers.ts
v2.0/src/utils/common/exportHandlers.ts
+0
-25
format.ts
v2.0/src/utils/common/format.ts
+26
-1
task.ts
v2.0/src/utils/common/task.ts
+41
-1
updateVip.ts
v2.0/src/utils/common/update/updateVip.ts
+19
-24
userUpdate.ts
v2.0/src/utils/common/userUpdate.ts
+1
-1
index.ts
v2.0/src/utils/index.ts
+0
-2
No files found.
v2.0/dist/controller/share.controller.js
View file @
29ebade8
...
...
@@ -88,7 +88,7 @@ var Share = /** @class */ (function () {
switch
(
_c
.
label
)
{
case
0
:
openId
=
context
.
openId
;
return
[
4
/*yield*/
,
taskService
.
completeTask
(
'invites'
,
inviteUserInfo
,
activity
Info
,
{
return
[
4
/*yield*/
,
taskService
.
completeTask
(
'invites'
,
activityInfo
,
inviteUser
Info
,
{
openId
:
openId
})];
case
1
:
...
...
v2.0/dist/controller/share.controller.js.map
View file @
29ebade8
{"version":3,"file":"share.controller.js","sourceRoot":"","sources":["../../src/controller/share.controller.ts"],"names":[],"mappings":";AAAA,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEd,+CAAkD;AAClD,+CAAuE;AACvE,8BAAqC;AACrC,sCAAkE;AAClE,0CAAwC;AACxC,6EAA2E;AAC3E,qEAAmE;AACnE,yEAAuE;AACvE,iEAA+D;AAC/D,0CAAyC;AACzC,qDAAmD;AACnD,8DAA4D;AAK5D;IAAA;IA8CA,CAAC;IA7CC;;OAEG;IAGG,4BAAY,GAAlB,UACE,OAAyC,EACzC,EAA8B;YAA5B,QAAQ,cAAA;;;;gBAGO,OAAO,GACpB,QAAQ,oBADY,CACZ;gBAEZ,sBAAO,kBAAY,CAAC,OAAO,CAAC;wBAC1B,OAAO,EAAE,OAAO;qBACjB,CAAC,EAAA;;;KACH;IACD;;OAEG;IAMG,sBAAM,GAAZ,UACE,OAGE,EACF,EAAwD,EACxD,EAAsD;YADpD,QAAQ,cAAA,EAAE,YAAY,kBAAA,EAAE,cAAc,oBAAA;YACvC,WAAW,QAAA,EAAE,WAAW,QAAA;;;;;;wBAEjB,MAAM,GAAK,OAAO,OAAZ,CAAY;wBAEX,qBAAM,WAAW,CAAC,YAAY,CAAC,SAAS,EAAE,cAAc,EAAE,YAAY,EAAE;gCACrF,MAAM,QAAA;6BACP,CAAC,EAAA;;wBAFI,MAAM,GAAG,SAEb;wBAEF,IAAI,CAAC,MAAM;4BAAE,sBAAO,kBAAY,CAAC,KAAK,CAAC,sBAAU,CAAC,YAAY,EAAE,OAAO,CAAC,EAAA;wBAExE,qBAAM,WAAW,CAAC,OAAO,CAAC,qBAAS,CAAC,aAAa,EAAE,QAAQ,CAAC,EAAA;;wBAA5D,SAA4D,CAAA;wBAE5D,sBAAO,kBAAY,CAAC,OAAO,CAAC,IAAI,CAAC,EAAA;;;;KAClC;IAvCD;QAFC,oBAAW,CAAC,CAAC,YAAY,CAAC,CAAC;QAC3B,iBAAQ,CAAC,CAAC,qBAAW,CAAC,CAAC;;;;6CAYvB;IASD;QALC,oBAAW,CAAC,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;QACvC,qBAAY,CAAC,CAAC,SAAS,CAAC,CAAC;QACzB,iBAAQ,CAAC,CAAC,qBAAW,EAAE,qBAAW,CAAC,CAAC;QACpC,iBAAQ,CAAC,CAAC,qCAAiB,EAAE,6BAAa,EAAE,yBAAW,EAAE,iCAAe,CAAC,CAAC;QAC1E,eAAM,CAAC,CAAC,qBAAS,CAAC,CAAC;;;;uCAoBnB;IACH,YAAC;CAAA,AA9CD,IA8CC;kBA9CoB,KAAK"}
\ No newline at end of file
{"version":3,"file":"share.controller.js","sourceRoot":"","sources":["../../src/controller/share.controller.ts"],"names":[],"mappings":";AAAA,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEd,+CAAkD;AAClD,+CAAuE;AACvE,8BAAqC;AACrC,sCAAkE;AAClE,0CAAwC;AACxC,6EAA2E;AAC3E,qEAAmE;AACnE,yEAAuE;AACvE,iEAA+D;AAC/D,0CAAyC;AACzC,qDAAmD;AACnD,8DAA4D;AAK5D;IAAA;IA8CA,CAAC;IA7CC;;OAEG;IAGG,4BAAY,GAAlB,UACE,OAAyC,EACzC,EAA8B;YAA5B,QAAQ,cAAA;;;;gBAGO,OAAO,GACpB,QAAQ,oBADY,CACZ;gBAEZ,sBAAO,kBAAY,CAAC,OAAO,CAAC;wBAC1B,OAAO,EAAE,OAAO;qBACjB,CAAC,EAAA;;;KACH;IACD;;OAEG;IAMG,sBAAM,GAAZ,UACE,OAGE,EACF,EAAwD,EACxD,EAAsD;YADpD,QAAQ,cAAA,EAAE,YAAY,kBAAA,EAAE,cAAc,oBAAA;YACvC,WAAW,QAAA,EAAE,WAAW,QAAA;;;;;;wBAEjB,MAAM,GAAK,OAAO,OAAZ,CAAY;wBAEX,qBAAM,WAAW,CAAC,YAAY,CAAC,SAAS,EAAE,YAAY,EAAE,cAAc,EAAE;gCACrF,MAAM,QAAA;6BACP,CAAC,EAAA;;wBAFI,MAAM,GAAG,SAEb;wBAEF,IAAI,CAAC,MAAM;4BAAE,sBAAO,kBAAY,CAAC,KAAK,CAAC,sBAAU,CAAC,YAAY,EAAE,OAAO,CAAC,EAAA;wBAExE,qBAAM,WAAW,CAAC,OAAO,CAAC,qBAAS,CAAC,aAAa,EAAE,QAAQ,CAAC,EAAA;;wBAA5D,SAA4D,CAAA;wBAE5D,sBAAO,kBAAY,CAAC,OAAO,CAAC,IAAI,CAAC,EAAA;;;;KAClC;IAvCD;QAFC,oBAAW,CAAC,CAAC,YAAY,CAAC,CAAC;QAC3B,iBAAQ,CAAC,CAAC,qBAAW,CAAC,CAAC;;;;6CAYvB;IASD;QALC,oBAAW,CAAC,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;QACvC,qBAAY,CAAC,CAAC,SAAS,CAAC,CAAC;QACzB,iBAAQ,CAAC,CAAC,qBAAW,EAAE,qBAAW,CAAC,CAAC;QACpC,iBAAQ,CAAC,CAAC,qCAAiB,EAAE,6BAAa,EAAE,yBAAW,EAAE,iCAAe,CAAC,CAAC;QAC1E,eAAM,CAAC,CAAC,qBAAS,CAAC,CAAC;;;;uCAoBnB;IACH,YAAC;CAAA,AA9CD,IA8CC;kBA9CoB,KAAK"}
\ No newline at end of file
v2.0/dist/controller/task.controller.d.ts
View file @
29ebade8
...
...
@@ -7,29 +7,19 @@ export default class Task {
*/
getTaskList
(
context
:
IContext
<
{
activityId
:
string
;
}
>
,
{
userInfo
,
vipInfo
,
activityInfo
}:
IControllerInfos
,
[
taskService
]:
[
TaskService
]):
Promise
<
IResult
<
ITaskInfo
[]
>>
;
/**
* 完成关注店铺任务
*/
doFollowTask
(
context
:
IContext
<
{
activityId
:
string
;
}
>
,
{
userInfo
,
activityInfo
}:
IControllerInfos
,
[
TaskService
]:
[
TaskService
]):
Promise
<
IResult
<
boolean
>>
;
}
>
,
{
userInfo
,
activityInfo
}:
IControllerInfos
,
[
taskService
]:
[
TaskService
]):
Promise
<
IResult
<
ITaskInfo
[]
>>
;
/**
* 积分兑换次数
*/
doExchangeCreditsTask
(
context
:
IContext
<
IParams
>
,
{
userInfo
,
activityInfo
,
session
}:
IControllerInfos
,
[
taskService
]:
[
TaskService
]):
Promise
<
IResult
<
boolean
>>
;
/**
* 浏览商品
*/
doBrowseGoodsTask
(
context
:
IContext
<
IParams
>
,
{
userInfo
,
activityInfo
}:
IControllerInfos
,
[
taskService
]:
[
TaskService
]):
Promise
<
IResult
<
boolean
>>
;
/**
* 收藏商品
*/
doCollectGoodsTask
(
context
:
IContext
<
IParams
>
,
{
userInfo
,
activityInfo
}:
IControllerInfos
,
[
taskService
]:
[
TaskService
]):
Promise
<
IResult
<
boolean
>>
;
/**
* 浏览链接
* 完成任务
*/
doJumpLinkTask
(
context
:
IContext
<
IParams
>
,
{
userInfo
,
activityInfo
}:
IControllerInfos
,
[
taskService
]:
[
TaskService
]):
Promise
<
IResult
<
boolean
>>
;
doCompleteTask
(
context
:
IContext
<
{
activityId
:
string
;
taskType
:
ITaskType
;
itemId
?:
string
;
}
>
,
{
userInfo
,
activityInfo
}:
IControllerInfos
,
[
taskService
]:
[
TaskService
]):
Promise
<
IResult
<
boolean
>>
;
/**
* 领取任务奖励
*/
...
...
v2.0/dist/controller/task.controller.js
View file @
29ebade8
This diff is collapsed.
Click to expand it.
v2.0/dist/controller/task.controller.js.map
View file @
29ebade8
This diff is collapsed.
Click to expand it.
v2.0/dist/index.d.ts
View file @
29ebade8
...
...
@@ -6,7 +6,12 @@ declare const _default: {
getVipInfo
:
(
context
:
IContext
<
import
(
"./controller/user.controller"
).
IVipParams
>
,
{
session
,
activityUserNick
}:
IControllerInfos
)
=>
Promise
<
IResult
<
IVipInfo
>>
;
getTaskList
:
(
context
:
IContext
<
{
activityId
:
string
;
}
>
,
{
userInfo
,
vipInfo
,
activityInfo
}:
IControllerInfos
,
[
taskService
]:
[
import
(
"./service"
).
TaskService
])
=>
Promise
<
IResult
<
import
(
"./service/task.service"
).
ITaskInfo
[]
>>
;
}
>
,
{
userInfo
,
activityInfo
}:
IControllerInfos
,
[
taskService
]:
[
import
(
"./service"
).
TaskService
])
=>
Promise
<
IResult
<
import
(
"./service/task.service"
).
ITaskInfo
[]
>>
;
doCompleteTask
:
(
context
:
IContext
<
{
activityId
:
string
;
taskType
:
ITaskType
;
itemId
?:
string
;
}
>
,
{
userInfo
,
activityInfo
}:
IControllerInfos
,
[
taskService
]:
[
import
(
"./service"
).
TaskService
])
=>
Promise
<
IResult
<
boolean
>>
;
receiveTaskRewards
:
(
context
:
IContext
<
IParams
>
,
{
userInfo
}:
IControllerInfos
,
[
taskService
]:
[
import
(
"./service"
).
TaskService
])
=>
Promise
<
IResult
<
{
rewards
:
number
;
}
>>
;
...
...
@@ -17,12 +22,12 @@ declare const _default: {
list
:
IAwards
[];
}
>>
;
receiveObjectPrize
:
(
context
:
IContext
<
import
(
"./controller/awards.controller"
).
IReceiveOjectParams
>
,
{
activityInfo
}:
IControllerInfos
,
[
awardSer
]:
[
import
(
"./service"
).
AwardsService
])
=>
Promise
<
IResult
<
boolean
>>
;
receiveEnamePrize
:
(
context
:
IContext
<
import
(
"./controller/awards.controller"
).
IReceiveEnameParams
>
,
{}:
{},
[
awardSer
]:
[
import
(
"./service"
).
AwardsService
])
=>
Promise
<
import
(
"taobao-mini-sdk/lib/utils/resultmodel"
).
Result
<
string
|
boolean
|
object
|
string
[]
|
object
[]
|
number
[],
false
>
|
import
(
"taobao-mini-sdk/lib/utils/resultmodel"
).
Result
<
import
(
"taobao-mini-sdk/lib/utils/codetypes"
).
CodeType
|
IAwards
,
true
>>
;
receiveEnamePrize
:
(
context
:
IContext
<
import
(
"./controller/awards.controller"
).
IReceiveEnameParams
>
,
{}:
{},
[
awardSer
]:
[
import
(
"./service"
).
AwardsService
])
=>
Promise
<
import
(
"taobao-mini-sdk/lib/utils/resultmodel"
).
Result
<
string
|
boolean
|
object
|
string
[]
|
number
[]
|
object
[],
false
>
|
import
(
"taobao-mini-sdk/lib/utils/resultmodel"
).
Result
<
import
(
"taobao-mini-sdk/lib/utils/codetypes"
).
CodeType
|
IAwards
,
true
>>
;
doHelp
:
(
context
:
IContext
<
{
activityId
:
string
;
inviteId
:
string
;
}
>
,
{
userInfo
,
activityInfo
,
inviteUserInfo
}:
import
(
"./controller/share.controller"
).
IdoHelpInfos
,
[
taskService
,
statService
]:
[
import
(
"./service"
).
TaskService
,
import
(
"./service"
).
StatService
])
=>
Promise
<
IResult
<
boolean
>>
;
getStats
:
(
context
:
IContext
<
import
(
"./controller/stat.controller"
).
IGetStatsParams
>
)
=>
Promise
<
import
(
"taobao-mini-sdk/lib/utils/resultmodel"
).
Result
<
string
|
boolean
|
object
|
string
[]
|
object
[]
|
number
[],
false
>
|
import
(
"taobao-mini-sdk/lib/utils/resultmodel"
).
Result
<
any
,
true
>>
;
getStats
:
(
context
:
IContext
<
import
(
"./controller/stat.controller"
).
IGetStatsParams
>
)
=>
Promise
<
import
(
"taobao-mini-sdk/lib/utils/resultmodel"
).
Result
<
string
|
boolean
|
object
|
string
[]
|
number
[]
|
object
[],
false
>
|
import
(
"taobao-mini-sdk/lib/utils/resultmodel"
).
Result
<
any
,
true
>>
;
addStat
:
(
context
:
IContext
<
import
(
"./controller/stat.controller"
).
IAddStatsParams
>
,
{
userInfo
}:
IControllerInfos
,
[
statService
]:
[
import
(
"./service"
).
StatService
])
=>
Promise
<
import
(
"taobao-mini-sdk/lib/utils/resultmodel"
).
Result
<
boolean
,
true
>>
;
getRankList
:
(
context
:
IContext
<
{
activityId
:
string
;
...
...
v2.0/dist/index.js
View file @
29ebade8
...
...
@@ -11,8 +11,8 @@ var stat_controller_1 = require("./controller/stat.controller");
var
login_controller_1
=
require
(
"./controller/login.controller"
);
var
_a
=
new
user_controller_1
.
default
(),
getVipInfo
=
_a
.
getVipInfo
,
getRankList
=
_a
.
getRankList
;
var
login
=
new
login_controller_1
.
default
().
login
;
var
_b
=
new
task_controller_1
.
default
(),
getTaskList
=
_b
.
getTaskList
,
receiveTaskRewards
=
_b
.
receiveTaskRewards
,
getCollectGoodsList
=
_b
.
getCollectGoodsList
,
// 获取收藏商品列表,包含收藏状态
do
FollowTask
=
_b
.
doFollowTask
,
doJumpLinkTask
=
_b
.
doJumpLinkTask
,
doBrowseGoodsTask
=
_b
.
doBrowseGoodsTask
,
doCollectGoodsTask
=
_b
.
doCollectGoodsTask
,
do
ExchangeCreditsTask
=
_b
.
doExchangeCreditsTask
;
var
_b
=
new
task_controller_1
.
default
(),
getTaskList
=
_b
.
getTaskList
,
receiveTaskRewards
=
_b
.
receiveTaskRewards
,
doCompleteTask
=
_b
.
doCompleteTask
,
getCollectGoodsList
=
_b
.
getCollectGoodsList
,
// 获取收藏商品列表,包含收藏状态
doExchangeCreditsTask
=
_b
.
doExchangeCreditsTask
;
var
_c
=
new
base_controller_1
.
default
(),
getActivityBaseInfoById
=
_c
.
getActivityBaseInfoById
,
getItemListByItemIds
=
_c
.
getItemListByItemIds
;
var
_d
=
new
awards_controller_1
.
default
(),
getMyPrizeList
=
_d
.
getMyPrizeList
,
receiveObjectPrize
=
_d
.
receiveObjectPrize
,
receiveEnamePrize
=
_d
.
receiveEnamePrize
,
drawLotteryPrize
=
_d
.
drawLotteryPrize
;
var
doHelp
=
new
share_controller_1
.
default
().
doHelp
;
...
...
@@ -21,6 +21,7 @@ exports.default = {
login
:
login
,
getVipInfo
:
getVipInfo
,
getTaskList
:
getTaskList
,
doCompleteTask
:
doCompleteTask
,
receiveTaskRewards
:
receiveTaskRewards
,
getActivityBaseInfoById
:
getActivityBaseInfoById
,
getMyPrizeList
:
getMyPrizeList
,
...
...
v2.0/dist/index.js.map
View file @
29ebade8
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,cAAc;;AAEd,2CAA2C;AAC3C,gEAAyD;AACzD,gEAAyD;AACzD,gEAAyD;AACzD,oEAA6D;AAC7D,kEAA2D;AAC3D,gEAAyD;AACzD,kEAA2D;AAErD,IAAA,KAA8B,IAAI,yBAAc,EAAE,EAAhD,UAAU,gBAAA,EAAE,WAAW,iBAAyB,CAAA;AAChD,IAAA,KAAK,GAAK,IAAI,0BAAe,EAAE,MAA1B,CAA0B;AAEjC,IAAA,KASF,IAAI,yBAAc,EAAE,EARtB,WAAW,iBAAA,EACX,kBAAkB,wBAAA,EAClB,mBAAmB,yBAAA,EAAE,kBAAkB;AACvC,YAAY,kBAAA,EACZ,cAAc,oBAAA,EACd,iBAAiB,uBAAA,EACjB,kBAAkB,wBAAA,EAClB,qBAAqB,2BACC,CAAA;AAElB,IAAA,KAAoD,IAAI,yBAAc,EAAE,EAAtE,uBAAuB,6BAAA,EAAE,oBAAoB,0BAAyB,CAAA;AAExE,IAAA,KAA8E,IAAI,2BAAgB,EAAE,EAAlG,cAAc,oBAAA,EAAE,kBAAkB,wBAAA,EAAE,iBAAiB,uBAAA,EAAE,gBAAgB,sBAA2B,CAAA;AAElG,IAAA,MAAM,GAAK,IAAI,0BAAe,EAAE,OAA1B,CAA0B;AAElC,IAAA,KAAwB,IAAI,yBAAc,EAAE,EAA1C,QAAQ,cAAA,EAAE,OAAO,aAAyB,CAAA;AAElD,kBAAe;IACb,KAAK,OAAA;IACL,UAAU,YAAA;IACV,WAAW,aAAA;IACX,kBAAkB,oBAAA;IAClB,uBAAuB,yBAAA;IACvB,cAAc,gBAAA;IACd,kBAAkB,oBAAA;IAClB,iBAAiB,mBAAA;IACjB,MAAM,QAAA;IACN,QAAQ,UAAA;IACR,OAAO,SAAA;IACP,WAAW,aAAA;CACZ,CAAA"}
\ No newline at end of file
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,cAAc;;AAEd,2CAA2C;AAC3C,gEAAyD;AACzD,gEAAyD;AACzD,gEAAyD;AACzD,oEAA6D;AAC7D,kEAA2D;AAC3D,gEAAyD;AACzD,kEAA2D;AAErD,IAAA,KAA8B,IAAI,yBAAc,EAAE,EAAhD,UAAU,gBAAA,EAAE,WAAW,iBAAyB,CAAA;AAChD,IAAA,KAAK,GAAK,IAAI,0BAAe,EAAE,MAA1B,CAA0B;AAEjC,IAAA,KAMF,IAAI,yBAAc,EAAE,EALtB,WAAW,iBAAA,EACX,kBAAkB,wBAAA,EAClB,cAAc,oBAAA,EACd,mBAAmB,yBAAA,EAAE,kBAAkB;AACvC,qBAAqB,2BACC,CAAA;AAElB,IAAA,KAAoD,IAAI,yBAAc,EAAE,EAAtE,uBAAuB,6BAAA,EAAE,oBAAoB,0BAAyB,CAAA;AAExE,IAAA,KAA8E,IAAI,2BAAgB,EAAE,EAAlG,cAAc,oBAAA,EAAE,kBAAkB,wBAAA,EAAE,iBAAiB,uBAAA,EAAE,gBAAgB,sBAA2B,CAAA;AAElG,IAAA,MAAM,GAAK,IAAI,0BAAe,EAAE,OAA1B,CAA0B;AAElC,IAAA,KAAwB,IAAI,yBAAc,EAAE,EAA1C,QAAQ,cAAA,EAAE,OAAO,aAAyB,CAAA;AAElD,kBAAe;IACb,KAAK,OAAA;IACL,UAAU,YAAA;IACV,WAAW,aAAA;IACX,cAAc,gBAAA;IACd,kBAAkB,oBAAA;IAClB,uBAAuB,yBAAA;IACvB,cAAc,gBAAA;IACd,kBAAkB,oBAAA;IAClB,iBAAiB,mBAAA;IACjB,MAAM,QAAA;IACN,QAAQ,UAAA;IACR,OAAO,SAAA;IACP,WAAW,aAAA;CACZ,CAAA"}
\ No newline at end of file
v2.0/dist/service/task.service.d.ts
View file @
29ebade8
...
...
@@ -24,18 +24,23 @@ export default class TaskService extends UserService {
*
* @param {ITaskType} taskType 任务类型
* @param {string} title 任务标题
* @param {I
Tasks} tasks
任务配置
* @param {I
ActivityInfo} activityInfo
任务配置
* @param {IUserInfo} userInfo 用户信息
* @return {ITaskInfo} {ITaskInfo} 任务信息
* @memberof TaskService
*/
initTask
(
taskType
:
ITaskType
,
title
:
string
,
tasks
:
ITasks
,
userInfo
:
IUserInfo
):
ITaskInfo
;
completeTask
(
taskType
:
ITaskType
,
userInfo
:
IUserInfo
,
activityInfo
:
IActivityInfo
,
customRecord
?:
object
):
Promise
<
number
>
;
updateVipTask
(
userInfo
:
IUserInfo
,
vipInfo
:
IVipInfo
,
tasks
:
ITasks
):
{
$set
:
{};
$inc
:
{};
$push
:
{};
};
initTask
(
taskType
:
ITaskType
,
title
:
string
,
activityInfo
:
IActivityInfo
,
userInfo
:
IUserInfo
):
ITaskInfo
;
/**
*根据任务类型更新任务待领取次数和任务记录
*
* @param {string} taskType
* @param {number} activityInfo
* @param {IActivityInfo} userInfo
* @param {object} [customRecord]
* @returns {boolean}
* @memberof TaskService
*/
completeTask
(
taskType
:
ITaskType
,
activityInfo
:
IActivityInfo
,
userInfo
:
IUserInfo
,
customRecord
?:
object
):
Promise
<
number
>
;
updateOrderGoodsTask
(
userInfo
:
IUserInfo
,
tasks
:
ITasks
,
activityStartTime
:
number
,
session
?:
string
):
Promise
<
{}
>
;
updateSignTask
(
userInfo
:
IUserInfo
,
tasks
:
ITasks
):
{
$inc
:
{
...
...
@@ -50,38 +55,6 @@ export default class TaskService extends UserService {
$inc
?:
undefined
;
$push
?:
undefined
;
};
/**
*更新关注店铺任务状态
*
* @param {IUserInfo} userInfo
* @param {IActivityInfo} activityInfo
* @returns
* @memberof TaskService
*/
updateFollowTask
(
userInfo
:
IUserInfo
,
activityInfo
:
IActivityInfo
):
Promise
<
number
>
;
/**
*
* 根据用户和任务完成情况,设置任务状态
*
* @param {IUserInfo} useInfo
* @param {string} taskType
* @param {number} taskRateType
* @param {number} [limitTimesEverday] 每天限制次数 任务频率为每天的时候必填
* @return {taskTatus} 1未完成 2 待领取 3 已完成
* @memberof TaskService
*/
setTaskStatus
(
useInfo
:
IUserInfo
,
taskType
:
string
,
taskRateType
:
number
,
limitTimesEveryday
?:
number
):
number
;
/**
*根据任务类型更新任务待领取次数和任务记录
*
* @param {string} taskType
* @param {number} rewards
* @param {IUserInfo} userInfo
* @param {object} [customRecord]
* @returns {boolean}
* @memberof TaskService
*/
updateUserTaskRecord
(
taskType
:
string
,
rewards
:
number
,
userInfo
:
IUserInfo
,
customRecord
?:
object
):
Promise
<
boolean
>
;
/**
*
* 更新user表中,任务相关字段
...
...
v2.0/dist/service/task.service.js
View file @
29ebade8
This diff is collapsed.
Click to expand it.
v2.0/dist/service/task.service.js.map
View file @
29ebade8
This diff is collapsed.
Click to expand it.
v2.0/dist/service/user.service.js
View file @
29ebade8
...
...
@@ -213,7 +213,7 @@ var UserService = /** @class */ (function (_super) {
projection
.
$inc
[
"remainTimes.follow"
]
=
follow
.
value
;
}
newVip
=
userUpdate_1
.
isNewVip
(
userInfo
,
vipInfo
);
if
(
newVip
&&
!
userInfo
.
member
.
newMember
)
{
if
(
newVip
)
{
// @ts-ignore
projection
.
$set
.
member
=
this
.
setNewVipUserData
(
userInfo
.
member
);
projection
.
$push
[
"taskInfo."
+
today
+
".member"
]
=
{
createTime
:
Date
.
now
()
};
...
...
v2.0/dist/service/user.service.js.map
View file @
29ebade8
This diff is collapsed.
Click to expand it.
v2.0/dist/utils/index.d.ts
View file @
29ebade8
...
...
@@ -7,7 +7,6 @@ export * from './common/logger';
export
*
from
'./common/rand'
;
export
*
from
'./common/getUserOrderlist'
;
export
*
from
'./common/vip'
;
export
*
from
'./common/exportHandlers'
;
export
*
from
'./common/helper'
;
export
*
from
'./common/userUpdate'
;
export
*
from
'./common/format'
;
...
...
v2.0/dist/utils/index.js
View file @
29ebade8
...
...
@@ -23,7 +23,6 @@ __exportStar(require("./common/logger"), exports);
__exportStar
(
require
(
"./common/rand"
),
exports
);
__exportStar
(
require
(
"./common/getUserOrderlist"
),
exports
);
__exportStar
(
require
(
"./common/vip"
),
exports
);
__exportStar
(
require
(
"./common/exportHandlers"
),
exports
);
__exportStar
(
require
(
"./common/helper"
),
exports
);
__exportStar
(
require
(
"./common/userUpdate"
),
exports
);
__exportStar
(
require
(
"./common/format"
),
exports
);
...
...
v2.0/dist/utils/index.js.map
View file @
29ebade8
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";AAAA,cAAc;;;;;;;;;;;;AAEd,cAAc;AACd,sDAAmC;AAEnC,iBAAiB;AACjB,oDAAiC;AAEjC,gBAAgB;AAChB,uDAAoC;AAEpC,SAAS;AACT,sDAAmC;AAEnC,kDAA+B;AAE/B,gDAA6B;AAE7B,4DAAyC;AAEzC,+CAA4B;AAE5B,0DAAuC;AAEvC,kDAA+B;AAE/B,sDAAmC;AAEnC,kDAA+B;AAE/B,qDAAkC"}
\ No newline at end of file
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";AAAA,cAAc;;;;;;;;;;;;AAEd,cAAc;AACd,sDAAmC;AAEnC,iBAAiB;AACjB,oDAAiC;AAEjC,gBAAgB;AAChB,uDAAoC;AAEpC,SAAS;AACT,sDAAmC;AAEnC,kDAA+B;AAE/B,gDAA6B;AAE7B,4DAAyC;AAEzC,+CAA4B;AAE5B,kDAA+B;AAE/B,sDAAmC;AAEnC,kDAA+B;AAE/B,qDAAkC"}
\ No newline at end of file
v2.0/src/controller/share.controller.ts
View file @
29ebade8
...
...
@@ -52,7 +52,7 @@ export default class Share {
):
Promise
<
IResult
<
boolean
>>
{
const
{
openId
}
=
context
const
result
=
await
taskService
.
completeTask
(
'invites'
,
inviteUserInfo
,
activity
Info
,
{
const
result
=
await
taskService
.
completeTask
(
'invites'
,
activityInfo
,
inviteUser
Info
,
{
openId
})
...
...
v2.0/src/controller/task.controller.ts
View file @
29ebade8
...
...
@@ -2,12 +2,14 @@
import
{
CODE_TYPES
,
TASK_RATE_TYPE
}
from
'./../constants'
import
{
checkParams
,
services
,
registeInfos
,
preCheck
}
from
'../decorator/common'
import
{
resultsModel
,
TBAPIS
}
from
'../sdk'
import
{
TaskService
,
BaseService
}
from
'../service'
import
{
ITaskInfo
}
from
'../service/task.service'
import
{
checkActivityTime
}
from
'../utils/common/check/checkActivityTime'
import
{
getCompleteTaskByUserTaskInfo
,
getTodayCompleteTask
}
from
'../utils/common/task'
import
{
getTotalCompleteTask
,
getTodayCompleteTask
}
from
'../utils/common/task'
import
{
update
}
from
'../decorator/common/update'
import
{
updateVip
}
from
'../utils/common/update/updateVip'
import
{
checkTaskLimit
}
from
'../utils/common/check/checkTaskLimit'
export
default
class
Task
{
/**
...
...
@@ -17,66 +19,25 @@ export default class Task {
@
registeInfos
([
'vipInfo'
])
@
services
([
TaskService
])
@
preCheck
([
checkActivityTime
])
@
update
([
updateVip
])
async
getTaskList
(
context
:
IContext
<
{
activityId
:
string
}
>
,
{
userInfo
,
vipInfo
,
activityInfo
}:
IControllerInfos
,
{
userInfo
,
activityInfo
}:
IControllerInfos
,
[
taskService
]:
[
TaskService
]
):
Promise
<
IResult
<
ITaskInfo
[]
>>
{
const
{
tasks
,
startTime
}
=
activityInfo
// 更新user状态
let
updatedUserInfo
=
await
taskService
.
updateTasks
(
userInfo
.
_id
,
// 需要查询更新的任务
[
taskService
.
updateVipTask
(
userInfo
,
vipInfo
,
tasks
)
// taskService.updateSignTask(userInfo, tasks),
// await taskService.updateOrderGoodsTask(userInfo, tasks, startTime, session)
],
userInfo
)
if
(
!
updatedUserInfo
)
return
resultsModel
.
error
(
CODE_TYPES
.
SYSTEM_ERROR
,
'更新任务列表失败'
)
// 返回对应的任务时, B端b_activity_config tasks 需配置对应的任务
return
resultsModel
.
success
([
taskService
.
initTask
(
'member'
,
'加入会员'
,
tasks
,
updatedU
serInfo
),
taskService
.
initTask
(
'follow'
,
'关注店铺'
,
tasks
,
updatedU
serInfo
)
// taskService.initTask('sign', '签到',
tasks, updatedU
serInfo),
// taskService.initTask('orderGoods', '购买商品',
tasks, updatedU
serInfo),
// taskService.initTask('browseGoods', '浏览商品',
tasks, updatedU
serInfo),
// taskService.initTask('collectGoods', '收藏商品',
tasks, updatedU
serInfo),
// taskService.initTask('jumpLink', '浏览页面',
tasks, updatedU
serInfo),
// taskService.initTask('invites', '邀请好友',
tasks, updatedUserInfo),
// taskService.initTask('exchangeCredits', '积分兑换',
tasks
, updatedUserInfo)
taskService
.
initTask
(
'member'
,
'加入会员'
,
activityInfo
,
u
serInfo
),
taskService
.
initTask
(
'follow'
,
'关注店铺'
,
activityInfo
,
u
serInfo
)
// taskService.initTask('sign', '签到',
activityInfo, u
serInfo),
// taskService.initTask('orderGoods', '购买商品',
activityInfo, u
serInfo),
// taskService.initTask('browseGoods', '浏览商品',
activityInfo, u
serInfo),
// taskService.initTask('collectGoods', '收藏商品',
activityInfo, u
serInfo),
// taskService.initTask('jumpLink', '浏览页面',
activityInfo, u
serInfo),
// taskService.initTask('invites', '邀请好友',
activityInfo, userInfo)
// taskService.initTask('exchangeCredits', '积分兑换',
activityInfo
, updatedUserInfo)
])
}
/**
* 完成关注店铺任务
*/
@
checkParams
([
'activityId'
])
@
services
([
TaskService
])
@
preCheck
([
checkActivityTime
])
async
doFollowTask
(
context
:
IContext
<
{
activityId
:
string
}
>
,
{
userInfo
,
activityInfo
}:
IControllerInfos
,
[
TaskService
]:
[
TaskService
]
):
Promise
<
IResult
<
boolean
>>
{
let
{
follow
}
=
userInfo
const
{
flag
,
newFollow
}
=
follow
// 已经关注过店铺,不可完成
const
hasFollowed
=
flag
||
newFollow
if
(
hasFollowed
)
return
resultsModel
.
error
(
CODE_TYPES
.
ERROR_TASK_COMPLETE
)
// 更新状态
const
result
=
await
TaskService
.
updateFollowTask
(
userInfo
,
activityInfo
)
return
result
?
resultsModel
.
success
(
true
)
:
resultsModel
.
error
(
CODE_TYPES
.
SYSTEM_ERROR
)
}
/**
* 积分兑换次数
*/
...
...
@@ -122,138 +83,32 @@ export default class Task {
if
(
!
result
)
return
resultsModel
.
error
(
CODE_TYPES
.
SYSTEM_ERROR
)
// 更新user表
await
taskService
.
updateUserTaskRecord
(
taskType
,
value
,
userInfo
)
return
resultsModel
.
success
(
true
)
}
/**
* 浏览商品
*/
@
checkParams
([
'activityId'
,
'itemId'
])
@
services
([
TaskService
])
@
preCheck
([
checkActivityTime
])
async
doBrowseGoodsTask
(
context
:
IContext
<
IParams
>
,
{
userInfo
,
activityInfo
}:
IControllerInfos
,
[
taskService
]:
[
TaskService
]
):
Promise
<
IResult
<
boolean
>>
{
const
taskType
=
'browseGoods'
const
{
itemId
}
=
context
.
data
const
{
tasks
:
{
browseGoods
:
{
taskRateType
,
times
,
itemIds
,
value
}
}
}
=
activityInfo
const
itemIdArray
:
number
[]
=
Array
.
isArray
(
itemIds
)
?
itemIds
:
itemIds
.
split
(
','
).
map
(
v
=>
+
v
)
// B端配置商品ids不匹配正确
if
(
!
itemIdArray
.
includes
(
+
itemId
))
return
resultsModel
.
error
(
CODE_TYPES
.
PARAMS_ERROR
,
'商品id不匹配'
)
const
{
todayTaskInfo
,
todayCompleteTimes
}
=
getTodayCompleteTask
(
'browseGoods'
,
userInfo
)
const
hasCompleteToday
=
todayTaskInfo
.
some
(
v
=>
v
.
itemId
===
itemId
)
&&
taskRateType
===
TASK_RATE_TYPE
.
EVERYDAY
// 今日任务已经完成
if
(
hasCompleteToday
)
{
return
resultsModel
.
error
(
CODE_TYPES
.
PARAMS_ERROR
,
'今日该浏览商品任务已完成'
)
}
// 次数超限
if
(
times
&&
times
===
todayCompleteTimes
&&
taskRateType
===
TASK_RATE_TYPE
.
EVERYDAY
)
{
return
resultsModel
.
error
(
CODE_TYPES
.
ERROR_TASK_LIMIT
)
}
// 更新user表
await
taskService
.
updateUserTaskRecord
(
taskType
,
value
,
userInfo
,
{
itemId
})
await
taskService
.
completeTask
(
taskType
,
activityInfo
,
userInfo
)
return
resultsModel
.
success
(
true
)
}
/**
*
收藏商品
*
完成任务
*/
@
checkParams
([
'activityId'
,
'itemId'
])
@
services
([
TaskService
])
@
preCheck
([
checkActivityTime
])
async
doCollectGoodsTask
(
context
:
IContext
<
IParams
>
,
{
userInfo
,
activityInfo
}:
IControllerInfos
,
[
taskService
]:
[
TaskService
]
):
Promise
<
IResult
<
boolean
>>
{
const
taskType
=
'collectGoods'
const
{
itemId
}
=
context
.
data
const
{
tasks
:
{
collectGoods
:
{
taskRateType
,
times
,
itemIds
,
value
}
}
}
=
activityInfo
const
itemIdArray
:
number
[]
=
Array
.
isArray
(
itemIds
)
?
itemIds
:
itemIds
.
split
(
','
).
map
(
v
=>
+
v
)
// B端配置商品ids不匹配正确
if
(
!
itemIdArray
.
includes
(
+
itemId
))
return
resultsModel
.
error
(
CODE_TYPES
.
PARAMS_ERROR
,
'商品id不匹配'
)
const
{
todayTaskInfo
,
todayCompleteTimes
}
=
getTodayCompleteTask
(
taskType
,
userInfo
)
const
hasCompleteToday
=
todayTaskInfo
.
filter
(
v
=>
v
.
itemId
===
itemId
).
length
&&
taskRateType
===
TASK_RATE_TYPE
.
EVERYDAY
// 今日任务已经完成
if
(
hasCompleteToday
)
{
return
resultsModel
.
error
(
CODE_TYPES
.
PARAMS_ERROR
,
'今日该收藏商品任务已完成'
)
}
// 次数超限
if
(
times
&&
times
===
todayCompleteTimes
&&
taskRateType
===
TASK_RATE_TYPE
.
EVERYDAY
)
{
return
resultsModel
.
error
(
CODE_TYPES
.
ERROR_TASK_LIMIT
)
}
// 更新user表
await
taskService
.
updateUserTaskRecord
(
taskType
,
value
,
userInfo
,
{
itemId
})
return
resultsModel
.
success
(
true
)
}
/**
* 浏览链接
*/
@
checkParams
([
'activityId'
])
@
checkParams
([
'activityId'
,
'taskType'
])
@
services
([
TaskService
])
@
preCheck
([
checkActivityTime
])
async
doJumpLinkTask
(
context
:
IContext
<
IParams
>
,
@
preCheck
([
checkActivityTime
,
checkTaskLimit
])
async
doCompleteTask
(
context
:
IContext
<
{
activityId
:
string
taskType
:
ITaskType
itemId
?:
string
// 涉及到商品的任务需传itemId
}
>
,
{
userInfo
,
activityInfo
}:
IControllerInfos
,
[
taskService
]:
[
TaskService
]
):
Promise
<
IResult
<
boolean
>>
{
const
taskType
=
'jumpLink'
const
{
tasks
:
{
jumpLink
:
{
taskRateType
,
times
,
value
,
link
}
}
}
=
activityInfo
const
{
todayCompleteTimes
}
=
getTodayCompleteTask
(
taskType
,
userInfo
)
const
hasCompleteToday
=
times
&&
todayCompleteTimes
===
times
&&
taskRateType
===
TASK_RATE_TYPE
.
EVERYDAY
// 今日任务已经完成
if
(
hasCompleteToday
)
{
return
resultsModel
.
error
(
CODE_TYPES
.
PARAMS_ERROR
,
'今日跳转链接任务已完成'
)
}
// 次数超限
if
(
times
&&
times
===
todayCompleteTimes
&&
taskRateType
===
TASK_RATE_TYPE
.
EVERYDAY
)
{
return
resultsModel
.
error
(
CODE_TYPES
.
ERROR_TASK_LIMIT
)
}
const
{
taskType
,
itemId
}
=
context
.
data
// 更新user表
await
taskService
.
updateUserTaskRecord
(
taskType
,
value
,
userInfo
)
const
result
=
await
taskService
.
completeTask
(
taskType
,
activityInfo
,
userInfo
,
{
itemId
}
)
return
result
sModel
.
success
(
true
)
return
result
?
resultsModel
.
success
(
true
)
:
resultsModel
.
error
(
CODE_TYPES
.
SYSTEM_ERROR
,
'任务完成失败'
)
}
/**
...
...
@@ -307,7 +162,7 @@ export default class Task {
const
{
itemIds
}
=
context
.
data
const
list
=
await
baseService
.
getItemListByIds
(
itemIds
,
session
)
const
{
taskInfo
}
=
get
CompleteTaskByUserTaskInfo
(
'collectGoods'
,
userInfo
)
const
{
taskInfo
}
=
get
TotalCompleteTask
(
'collectGoods'
,
userInfo
)
const
listWithCollectStatus
=
list
.
map
(
v
=>
{
return
{
...
...
v2.0/src/decorator/common/update.ts
View file @
29ebade8
/** @format */
import
{
merge
}
from
'lodash'
// 检验参数是否存在
export
const
update
=
(
checks
:
IFunction
[])
=>
{
return
function
(
target
:
Object
,
name
:
string
,
descriptor
:
PropertyDescriptor
)
{
...
...
@@ -7,17 +9,20 @@ export const update = (checks: IFunction[]) => {
descriptor
.
value
=
async
function
(...
args
:
any
[])
{
let
[
context
,
otherArgs
=
{},
services
=
[]]
=
args
let
totalUpdateProjection
:
IDecoratorUpdateQuery
=
{}
for
(
let
i
=
0
;
i
<
checks
.
length
;
i
++
)
{
const
checkFn
=
checks
[
i
]
let
result
=
await
checkFn
.
apply
(
target
,
[
context
,
{
...
otherArgs
},
services
])
let
result
:
IDecoratorUpdateQuery
=
await
checkFn
.
apply
(
target
,
[
context
,
{
...
otherArgs
},
services
])
result
=
result
||
{}
// 校验报错
if
((
result
as
IErrorResult
)?.
success
===
false
&&
(
result
as
IErrorResult
)?.
code
)
{
return
result
}
otherArgs
=
{
...
otherArgs
,
...
result
}
totalUpdateProjection
=
merge
({},
totalUpdateProjection
,
result
)
otherArgs
=
{
...
otherArgs
}
}
return
method
.
apply
(
target
,
[
context
,
{
...
otherArgs
},
services
])
}
...
...
v2.0/src/index.ts
View file @
29ebade8
...
...
@@ -15,11 +15,8 @@ const { login } = new LoginController()
const
{
getTaskList
,
receiveTaskRewards
,
doCompleteTask
,
getCollectGoodsList
,
// 获取收藏商品列表,包含收藏状态
doFollowTask
,
doJumpLinkTask
,
doBrowseGoodsTask
,
doCollectGoodsTask
,
doExchangeCreditsTask
}
=
new
TaskController
()
...
...
@@ -35,6 +32,7 @@ export default {
login
,
getVipInfo
,
getTaskList
,
doCompleteTask
,
receiveTaskRewards
,
getActivityBaseInfoById
,
getMyPrizeList
,
...
...
v2.0/src/service/task.service.ts
View file @
29ebade8
...
...
@@ -18,7 +18,7 @@ import {
isNewVip
}
from
'../utils'
import
{
TASK_RATE_TYPE
,
TASK_STATUS
}
from
'../constants'
import
{
getTodayCompleteTask
,
get
CompleteTaskByUserTaskInfo
}
from
'../utils/common/task'
import
{
getTodayCompleteTask
,
get
TotalCompleteTask
,
setTaskStatus
}
from
'../utils/common/task'
export
interface
ITaskInfo
{
taskType
?:
string
// 任务类型
...
...
@@ -42,19 +42,16 @@ export default class TaskService extends UserService {
*
* @param {ITaskType} taskType 任务类型
* @param {string} title 任务标题
* @param {I
Tasks} tasks
任务配置
* @param {I
ActivityInfo} activityInfo
任务配置
* @param {IUserInfo} userInfo 用户信息
* @return {ITaskInfo} {ITaskInfo} 任务信息
* @memberof TaskService
*/
initTask
(
taskType
:
ITaskType
,
title
:
string
,
tasks
:
ITasks
,
userInfo
:
IUserInfo
):
ITaskInfo
{
const
{
[
taskType
]:
{
value
,
itemIds
=
''
,
taskRateType
,
times
=
1
,
link
=
''
}
}
=
tasks
initTask
(
taskType
:
ITaskType
,
title
:
string
,
activityInfo
:
IActivityInfo
,
userInfo
:
IUserInfo
):
ITaskInfo
{
const
{
value
,
itemIds
=
''
,
taskRateType
,
times
=
1
,
link
=
''
}
=
activityInfo
?.
tasks
?.[
taskType
]
||
{}
const
{
remainTimes
}
=
userInfo
const
{
todayCompleteTimes
}
=
getTodayCompleteTask
(
taskType
,
userInfo
)
const
{
completeTimes
}
=
get
CompleteTaskByUserTaskInfo
(
taskType
,
userInfo
)
const
{
completeTimes
}
=
get
TotalCompleteTask
(
taskType
,
userInfo
)
return
{
taskType
,
...
...
@@ -66,17 +63,32 @@ export default class TaskService extends UserService {
url
:
taskType
===
'member'
?
generateVipUrl
(
formatVipCbUrl
(
this
.
context
))
:
link
,
todayCompleteTimes
,
completeTimes
,
status
:
this
.
setTaskStatus
(
userInfo
,
taskType
,
taskRateType
,
times
),
waitReceive
:
remainTimes
[
taskType
]
status
:
setTaskStatus
(
userInfo
,
taskType
,
taskRateType
,
times
),
waitReceive
:
remainTimes
?.
[
taskType
]
}
}
async
completeTask
(
taskType
:
ITaskType
,
userInfo
:
IUserInfo
,
activityInfo
:
IActivityInfo
,
customRecord
:
object
=
{})
{
/**
*根据任务类型更新任务待领取次数和任务记录
*
* @param {string} taskType
* @param {number} activityInfo
* @param {IActivityInfo} userInfo
* @param {object} [customRecord]
* @returns {boolean}
* @memberof TaskService
*/
async
completeTask
(
taskType
:
ITaskType
,
activityInfo
:
IActivityInfo
,
userInfo
:
IUserInfo
,
customRecord
:
object
=
{}
):
Promise
<
number
>
{
const
today
=
getToday
()
const
rewards
=
activityInfo
?.
tasks
?.[
taskType
]?.
value
||
0
return
await
this
.
updateUser
(
userInfo
.
_id
,
{
$inc
:
{
'remainTimes.invites'
:
rewards
[
`remainTimes.
${
taskType
}
`
]
:
rewards
},
$push
:
{
[
`taskInfo.
${
today
}
.
${
taskType
}
`
]:
{
...
customRecord
,
createTime
:
Date
.
now
()
}
...
...
@@ -84,45 +96,13 @@ export default class TaskService extends UserService {
})
}
// 根据会员状态更新
updateVipTask
(
userInfo
:
IUserInfo
,
vipInfo
:
IVipInfo
,
tasks
:
ITasks
)
{
let
{
member
}
=
userInfo
const
{
newMember
}
=
member
const
today
=
getToday
()
const
newVip
=
isNewVip
(
userInfo
,
vipInfo
)
const
{
member
:
{
value
}
}
=
tasks
let
projection
=
{
$set
:
{},
$inc
:
{},
$push
:
{}
}
if
(
newVip
&&
!
newMember
)
{
member
=
setNewVipUserData
(
member
)
// @ts-ignore
projection
.
$set
.
member
=
member
projection
.
$inc
[
'remainTimes.member'
]
=
+
value
projection
.
$push
[
`taskInfo.
${
today
}
.member`
]
=
{
creatTime
:
Date
.
now
()
}
}
return
projection
}
// 根据下单下单记录,更新状态
async
updateOrderGoodsTask
(
userInfo
:
IUserInfo
,
tasks
:
ITasks
,
activityStartTime
:
number
,
session
?:
string
)
{
const
taskType
=
'orderGoods'
const
{
[
taskType
]:
{
value
,
itemIds
,
taskRateType
,
times
}
}
=
tasks
const
{
completeTimes
,
taskInfo
}
=
get
CompleteTaskByUserTaskInfo
(
taskType
,
userInfo
)
const
{
completeTimes
,
taskInfo
}
=
get
TotalCompleteTask
(
taskType
,
userInfo
)
const
{
todayCompleteTimes
}
=
getTodayCompleteTask
(
taskType
,
userInfo
)
// 永久任务且已完成
if
(
taskRateType
===
TASK_RATE_TYPE
.
FOREVER
&&
completeTimes
)
{
...
...
@@ -199,106 +179,6 @@ export default class TaskService extends UserService {
:
{}
}
/**
*更新关注店铺任务状态
*
* @param {IUserInfo} userInfo
* @param {IActivityInfo} activityInfo
* @returns
* @memberof TaskService
*/
async
updateFollowTask
(
userInfo
:
IUserInfo
,
activityInfo
:
IActivityInfo
)
{
const
today
=
getToday
()
let
{
_id
,
follow
}
=
userInfo
// 获取活动基本信息
const
{
tasks
}
=
activityInfo
// 获取关注店铺奖励
const
{
follow
:
{
value
}
}
=
tasks
||
{}
// 更新follow信息
const
followInfo
:
IFollowInfo
=
setNewFollowUserData
(
follow
)
// 增加待领取次数
return
await
this
.
updateUser
(
_id
,
{
$set
:
{
follow
:
followInfo
},
$inc
:
{
'remainTimes.follow'
:
value
},
$push
:
{
[
`taskInfo.
${
today
}
.follow`
]:
{
creatTime
:
Date
.
now
()
}
}
})
}
/**
*
* 根据用户和任务完成情况,设置任务状态
*
* @param {IUserInfo} useInfo
* @param {string} taskType
* @param {number} taskRateType
* @param {number} [limitTimesEverday] 每天限制次数 任务频率为每天的时候必填
* @return {taskTatus} 1未完成 2 待领取 3 已完成
* @memberof TaskService
*/
setTaskStatus
(
useInfo
:
IUserInfo
,
taskType
:
string
,
taskRateType
:
number
,
limitTimesEveryday
:
number
=
1
):
number
{
const
waitReceive
=
useInfo
?.
remainTimes
?.[
taskType
]
||
0
if
(
waitReceive
)
return
TASK_STATUS
.
WAIT_RECEIVE
// 当天的完成次数
const
{
todayCompleteTimes
}
=
getTodayCompleteTask
(
taskType
,
useInfo
)
// 总共的完成次数
const
{
completeTimes
}
=
getCompleteTaskByUserTaskInfo
(
taskType
,
useInfo
)
switch
(
taskRateType
)
{
case
TASK_RATE_TYPE
.
FOREVER
:
return
completeTimes
>
0
?
TASK_STATUS
.
DONE
:
TASK_STATUS
.
WAIT_DO
break
case
TASK_RATE_TYPE
.
EVERYDAY
:
return
todayCompleteTimes
>=
limitTimesEveryday
?
TASK_STATUS
.
DONE
:
TASK_STATUS
.
WAIT_DO
break
case
TASK_RATE_TYPE
.
NOLIMIT
:
return
TASK_STATUS
.
WAIT_DO
break
}
}
/**
*根据任务类型更新任务待领取次数和任务记录
*
* @param {string} taskType
* @param {number} rewards
* @param {IUserInfo} userInfo
* @param {object} [customRecord]
* @returns {boolean}
* @memberof TaskService
*/
async
updateUserTaskRecord
(
taskType
:
string
,
rewards
:
number
,
userInfo
:
IUserInfo
,
customRecord
?:
object
):
Promise
<
boolean
>
{
const
{
_id
}
=
userInfo
const
today
=
getToday
()
const
result
=
await
this
.
updateUser
(
_id
,
{
$inc
:
{
[
`remainTimes.
${
taskType
}
`
]:
rewards
},
$push
:
{
[
`taskInfo.
${
today
}
.
${
taskType
}
`
]:
{
createTime
:
Date
.
now
(),
...
customRecord
}
}
})
return
result
===
1
}
/**
*
* 更新user表中,任务相关字段
...
...
v2.0/src/service/user.service.ts
View file @
29ebade8
...
...
@@ -127,7 +127,7 @@ class UserService extends BaseService {
// 之前进入活动非会员,现在进入会员,则视为新会员用户
const
newVip
=
isNewVip
(
userInfo
,
vipInfo
)
if
(
newVip
&&
!
userInfo
.
member
.
newMember
)
{
if
(
newVip
)
{
// @ts-ignore
projection
.
$set
.
member
=
this
.
setNewVipUserData
(
userInfo
.
member
)
projection
.
$push
[
`taskInfo.
${
today
}
.member`
]
=
{
createTime
:
Date
.
now
()
}
...
...
v2.0/src/typings/dao.d.ts
View file @
29ebade8
...
...
@@ -109,18 +109,21 @@ interface IUpdateQuery {
$set
?:
{
[
key
:
string
]:
any
}
$setOnInsert
?:
{
[
key
:
string
]:
any
}
$unset
?:
{
[
key
:
string
]:
any
}
$addToSet
?:
{
[
key
:
string
]:
any
}
$pop
?:
{
[
key
:
string
]:
any
}
$pull
?:
{
[
key
:
string
]:
any
}
$push
?:
{
[
key
:
string
]:
any
}
$pullAll
?:
{
[
key
:
string
]:
any
}
$bit
?:
{
[
key
:
string
]:
{
[
key
in
'and'
|
'or'
|
'xor'
]?:
number
}
}
}
interface
IDecoratorUpdateQuery
{
$inc
?:
{
[
key
:
string
]:
number
|
undefined
}
$set
?:
{
[
key
:
string
]:
any
}
$push
?:
{
[
key
:
string
]:
any
}
}
interface
IFindProjection
{
projection
?:
{
[
key
:
string
]:
number
|
boolean
|
any
...
...
v2.0/src/utils/common/check/checkExchangeCreditsTask.ts
0 → 100644
View file @
29ebade8
/** @format */
import
{
resultsModel
,
TBAPIS
}
from
'../../../sdk'
import
{
CODE_TYPES
}
from
'../../../errorCode'
import
{
getTodayCompleteTask
,
getTotalCompleteTask
}
from
'../task'
import
{
TASK_RATE_TYPE
}
from
'../../../constants'
export
const
checkExchangeCreditsTask
=
async
(
context
:
IContext
<
{
activityId
:
string
;
taskType
:
ITaskType
;
credits
?:
number
}
>
,
{
session
}:
IControllerInfos
)
=>
{
const
{
taskType
,
credits
}
=
context
.
data
// 不是兑换积分类型不校验
if
(
taskType
!==
'exchangeCredits'
)
return
const
myCredits
=
await
TBAPIS
.
queryCredits
(
context
,
session
)
console
.
log
(
'myCredits'
,
myCredits
)
// 积分不足
if
(
myCredits
<
credits
)
return
resultsModel
.
error
(
CODE_TYPES
.
ERROR_NO_CREDITS
)
// 扣积分
let
result
=
await
TBAPIS
.
changeCredits
(
context
,
session
,
{
quantity
:
+
credits
,
change_type
:
2
,
//变更类型:0交易,1:互动活动,2:权益兑换,3:手工调整
opt_type
:
1
,
// 操作类型,'0':增加,1:扣减
remark
:
`积分兑换任务减积分`
})
if
(
!
result
)
return
resultsModel
.
error
(
CODE_TYPES
.
SYSTEM_ERROR
)
}
v2.0/src/utils/common/check/checkInviteId.ts
View file @
29ebade8
...
...
@@ -14,6 +14,7 @@ export const checkInviteId = async (context: IContext<{ activityId: string; invi
// 自己邀请自己
if
(
openId
===
inviteId
)
return
resultsModel
.
error
(
CODE_TYPES
.
ERROR_NO_INVITE_SELF
)
// 获取邀请者信息
const
inviteUserInfo
=
await
dbFindOne
<
IUserInfo
>
(
context
,
USER_DB_NAME
,
{
activityId
,
openId
:
inviteId
...
...
v2.0/src/utils/common/check/checkNewVip.ts
View file @
29ebade8
...
...
@@ -4,11 +4,6 @@ import { resultsModel } from '../../../sdk'
import
{
CODE_TYPES
}
from
'../../../errorCode'
export
const
checkNewVip
=
async
(
context
:
IContext
<
IParams
>
,
{
vipInfo
,
userInfo
}:
IControllerInfos
)
=>
{
const
{
openId
,
data
:
{
activityId
,
inviteId
}
}
=
context
if
(
!
vipInfo
)
{
console
.
error
(
`使用checkNewVip registeInfos必须注册vipInfo`
)
}
...
...
v2.0/src/utils/common/check/checkTaskLimit.ts
View file @
29ebade8
/** @format */
export
const
checkTaskLimit
=
(
taskType
:
ITaskType
)
=>
{
return
async
function
(
context
:
IContext
<
IParams
>
,
{
activityInfo
,
userInfo
}:
IControllerInfos
)
{
const
{
tasks
:
{
[
taskType
]:
{
value
,
taskRateType
,
times
}
}
}
=
activityInfo
const
{}
=
userInfo
import
{
resultsModel
}
from
'../../../sdk'
import
{
CODE_TYPES
}
from
'../../../errorCode'
import
{
getTodayCompleteTask
,
getTotalCompleteTask
}
from
'../task'
import
{
TASK_RATE_TYPE
}
from
'../../../constants'
export
const
checkTaskLimit
=
async
(
context
:
IContext
<
{
activityId
:
string
;
taskType
:
ITaskType
;
itemId
?:
string
}
>
,
{
userInfo
,
activityInfo
}:
IControllerInfos
)
=>
{
const
{
taskType
,
itemId
}
=
context
.
data
const
{
itemIds
}
=
activityInfo
?.
tasks
?.[
taskType
]
||
{}
if
(
!
taskType
)
{
console
.
error
(
'使用checkTaskLimit, 云函数必须传入taskType参数'
)
return
}
if
(
!
activityInfo
?.
tasks
?.[
taskType
])
{
return
resultsModel
.
error
(
CODE_TYPES
.
SYSTEM_ERROR
,
`该活动缺少
${
taskType
}
配置项`
)
}
if
(
itemId
&&
!
itemIds
)
{
return
resultsModel
.
error
(
CODE_TYPES
.
SYSTEM_ERROR
,
`该任务缺少商品配置项`
)
}
// B端配置商品ids不匹配正确
if
(
itemId
&&
itemIds
)
{
const
itemIdArray
:
number
[]
=
Array
.
isArray
(
itemIds
)
?
itemIds
:
itemIds
.
split
(
','
).
map
(
v
=>
+
v
)
if
(
!
itemIdArray
.
includes
(
+
itemId
))
return
resultsModel
.
error
(
CODE_TYPES
.
PARAMS_ERROR
,
'商品id不匹配'
)
}
const
{
taskRateType
,
times
}
=
activityInfo
?.
tasks
?.[
taskType
]
// 永久任务已经完成
const
{
completeTimes
}
=
getTotalCompleteTask
(
taskType
,
userInfo
)
const
hasComplete
=
completeTimes
&&
taskRateType
===
TASK_RATE_TYPE
.
FOREVER
if
(
hasComplete
)
return
resultsModel
.
error
(
CODE_TYPES
.
ERROR_TASK_LIMIT
,
`该任务已完成,去看看其它任务吧~`
)
// 每日任务今天已经完成
const
{
todayCompleteTimes
,
todayTaskInfo
}
=
getTodayCompleteTask
(
taskType
,
userInfo
)
const
hasCompleteToday
=
times
&&
todayCompleteTimes
===
times
&&
taskRateType
===
TASK_RATE_TYPE
.
EVERYDAY
if
(
hasCompleteToday
)
{
return
resultsModel
.
error
(
CODE_TYPES
.
ERROR_TASK_LIMIT
,
`该任务今天已完成,明天再来吧~`
)
}
// 今日任务该商品已经完成
const
itemHasCompleteToday
=
todayTaskInfo
.
find
(
v
=>
v
.
itemId
&&
v
.
itemId
===
itemId
)
&&
taskRateType
===
TASK_RATE_TYPE
.
EVERYDAY
if
(
itemHasCompleteToday
)
{
return
resultsModel
.
error
(
CODE_TYPES
.
PARAMS_ERROR
,
'今日该商品任务已完成'
)
}
}
v2.0/src/utils/common/exportHandlers.ts
deleted
100644 → 0
View file @
0e1d8117
/** @format */
// 遍历Controller中的方法, 暴露出来
export
const
exportHandlers
=
(
controllers
:
any
[])
=>
{
const
handlersMapper
=
controllers
.
map
(
controller
=>
{
const
controllerInstance
=
new
controller
()
const
handlersKeys
=
Object
.
getOwnPropertyNames
(
Object
.
getPrototypeOf
(
controllerInstance
)).
filter
(
v
=>
v
!==
'constructor'
)
return
handlersKeys
.
reduce
((
prev
,
current
)
=>
{
return
{
...
prev
,
[
current
]:
controllerInstance
[
current
]
}
},
{})
})
.
reduce
((
prev
,
current
)
=>
{
return
{
...
current
,
...
prev
}
},
{})
return
handlersMapper
}
v2.0/src/utils/common/format.ts
View file @
29ebade8
/** @format */
import
{
assign
,
isEmpty
,
merge
}
from
'lodash'
/**
* updateUser projection 格式化
*
...
...
@@ -6,7 +10,6 @@
* @return {*}
* @memberof UserService
*/
export
function
formatUpdateUserProjection
(
projection
:
IUpdateQuery
):
IUpdateQuery
{
projection
[
'$set'
]
=
projection
[
'$set'
]
||
{}
projection
[
'$set'
].
updateTime
=
Date
.
now
()
...
...
@@ -31,3 +34,25 @@ export function formatUserNick(name: string) {
}
return
newStr
}
/**
* 不通过数据库select的情况下 获取更新后的数据
*
* @export
* @param {IUserInfo} userInfo
* @param {IDecoratorUpdateQuery} projection
*/
export
function
formatUpdatedUserInfo
(
userInfo
:
IUserInfo
,
projection
:
IDecoratorUpdateQuery
)
{
let
updatedUserInfo
=
assign
({},
userInfo
)
if
(
!
isEmpty
(
projection
.
$set
))
{
updatedUserInfo
=
merge
({},
userInfo
,
projection
.
$set
)
}
if
(
!
isEmpty
(
projection
.
$inc
))
{
Object
.
keys
(
projection
.
$inc
).
forEach
(
key
=>
{
// let splitKey
})
updatedUserInfo
=
merge
({},
userInfo
,
projection
.
$set
)
}
}
v2.0/src/utils/common/task.ts
View file @
29ebade8
/** @format */
import
{
getToday
}
from
'./getToday'
import
{
TASK_STATUS
,
TASK_RATE_TYPE
}
from
'../../constants'
/**
* 根据任务类型获取任务完成情况
...
...
@@ -10,7 +11,7 @@ import { getToday } from './getToday'
* @returns {array}
* @memberof TaskService
*/
export
function
get
CompleteTaskByUserTaskInfo
(
export
function
get
TotalCompleteTask
(
taskType
:
string
,
userInfo
:
IUserInfo
):
{
...
...
@@ -57,3 +58,42 @@ export function getTodayCompleteTask(
todayTaskInfo
:
userInfo
?.
taskInfo
?.[
today
]?.[
taskType
]
||
[]
}
}
/**
*
* 根据用户和任务完成情况,设置任务状态
*
* @param {IUserInfo} useInfo
* @param {string} taskType
* @param {number} taskRateType
* @param {number} [limitTimesEverday] 每天限制次数 任务频率为每天的时候必填
* @return {taskTatus} 1未完成 2 待领取 3 已完成
* @memberof TaskService
*/
export
function
setTaskStatus
(
useInfo
:
IUserInfo
,
taskType
:
string
,
taskRateType
:
number
,
limitTimesEveryday
:
number
=
1
):
number
{
const
waitReceive
=
useInfo
?.
remainTimes
?.[
taskType
]
||
0
if
(
waitReceive
)
return
TASK_STATUS
.
WAIT_RECEIVE
// 当天的完成次数
const
{
todayCompleteTimes
}
=
getTodayCompleteTask
(
taskType
,
useInfo
)
// 总共的完成次数
const
{
completeTimes
}
=
getTotalCompleteTask
(
taskType
,
useInfo
)
switch
(
taskRateType
)
{
case
TASK_RATE_TYPE
.
FOREVER
:
return
completeTimes
>
0
?
TASK_STATUS
.
DONE
:
TASK_STATUS
.
WAIT_DO
break
case
TASK_RATE_TYPE
.
EVERYDAY
:
return
todayCompleteTimes
>=
limitTimesEveryday
?
TASK_STATUS
.
DONE
:
TASK_STATUS
.
WAIT_DO
break
case
TASK_RATE_TYPE
.
NOLIMIT
:
return
TASK_STATUS
.
WAIT_DO
break
}
}
v2.0/src/utils/common/update/updateVip.ts
View file @
29ebade8
...
...
@@ -3,35 +3,30 @@
import
{
resultsModel
}
from
'../../../sdk'
import
{
CODE_TYPES
}
from
'../../../errorCode'
import
{
dbCount
}
from
'../../common/db'
import
{
STAT_DB_NAME
}
from
'../../../db'
import
{
STAT_DB_NAME
,
USER_DB_NAME
}
from
'../../../db'
import
{
getToday
}
from
'../getToday'
import
{
isNewVip
,
setNewVipUserData
}
from
'../userUpdate'
import
{
update
}
from
'../../../decorator/common/update'
export
function
updateVip
(
context
:
IContext
<
IParams
>
,
{
vipInfo
,
userInfo
,
activityInfo
}:
IControllerInfos
)
{
export
async
function
updateVip
(
context
:
IContext
<
IParams
>
,
{
vipInfo
,
userInfo
,
activityInfo
}:
IControllerInfos
):
Promise
<
IDecoratorUpdateQuery
>
{
let
{
member
}
=
userInfo
const
{
newMember
}
=
member
const
today
=
getToday
()
const
newVip
=
isNewVip
(
userInfo
,
vipInfo
)
const
memberReWards
=
activityInfo
?.
tasks
?.
member
?.
value
let
projection
=
{
$set
:
{},
$inc
:
{},
$push
:
{}
}
if
(
newVip
&&
!
newMember
)
{
member
=
setNewVipUserData
(
member
)
// @ts-ignore
projection
.
$set
.
member
=
member
projection
.
$inc
[
'remainTimes.member'
]
=
+
memberReWards
projection
.
$push
[
`taskInfo.
${
today
}
.member`
]
=
{
creatTime
:
Date
.
now
()
}
}
return
projection
return
isNewVip
(
userInfo
,
vipInfo
)
?
{
$set
:
{
member
:
setNewVipUserData
(
member
)
},
$inc
:
{
'remainTimes.member'
:
+
memberReWards
},
$push
:
{
[
`taskInfo.
${
getToday
()}
.member`
]:
{
creatTime
:
Date
.
now
()
}
}
}
:
{}
}
v2.0/src/utils/common/userUpdate.ts
View file @
29ebade8
...
...
@@ -18,7 +18,7 @@ export function isNewVip(userInfo: IUserInfo, vipInfo: IVipInfo): boolean {
const
{
isVip
}
=
vipInfo
return
!
flag
&&
isVip
return
!
flag
&&
isVip
&&
!
userInfo
.
member
.
newMember
}
export
function
setNewVipUserData
(
member
:
IMemberInfo
):
IMemberInfo
{
...
...
v2.0/src/utils/index.ts
View file @
29ebade8
...
...
@@ -20,8 +20,6 @@ export * from './common/getUserOrderlist'
export
*
from
'./common/vip'
export
*
from
'./common/exportHandlers'
export
*
from
'./common/helper'
export
*
from
'./common/userUpdate'
...
...
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