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
e17c0c3e
Commit
e17c0c3e
authored
Aug 27, 2020
by
qinhaitao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor:
💡
优化updateUser
parent
71b9ea9f
Changes
17
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
371 additions
and
56 deletions
+371
-56
share.controller.d.ts
v2.0/dist/controller/share.controller.d.ts
+1
-1
share.controller.js
v2.0/dist/controller/share.controller.js
+15
-21
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
+8
-0
task.controller.js
v2.0/dist/controller/task.controller.js
+105
-3
task.controller.js.map
v2.0/dist/controller/task.controller.js.map
+1
-1
task.service.d.ts
v2.0/dist/service/task.service.d.ts
+2
-0
task.service.js
v2.0/dist/service/task.service.js
+54
-0
task.service.js.map
v2.0/dist/service/task.service.js.map
+1
-1
user.service.js
v2.0/dist/service/user.service.js
+2
-3
user.service.js.map
v2.0/dist/service/user.service.js.map
+1
-1
share.controller.ts
v2.0/src/controller/share.controller.ts
+7
-15
task.controller.ts
v2.0/src/controller/task.controller.ts
+103
-5
task.service.ts
v2.0/src/service/task.service.ts
+64
-0
user.service.ts
v2.0/src/service/user.service.ts
+3
-3
activity.d.ts
v2.0/src/typings/activity.d.ts
+1
-1
user.d.ts
v2.0/src/typings/user.d.ts
+2
-0
No files found.
v2.0/dist/controller/share.controller.d.ts
View file @
e17c0c3e
...
@@ -4,5 +4,5 @@ export default class Share {
...
@@ -4,5 +4,5 @@ export default class Share {
/**
/**
* 完成分享
* 完成分享
*/
*/
insertShareRecord
(
context
:
Context
,
{
userInfo
,
vipInfo
,
activityInfo
}:
IControllerInfos
,
[
userService
,
taskService
,
accessService
]:
[
UserService
,
TaskService
,
AccessService
]):
Promise
<
import
(
"taobao-mini-sdk/lib/utils/resultmodel"
).
Result
>
;
doHelp
(
context
:
Context
,
{
userInfo
,
vipInfo
,
activityInfo
}:
IControllerInfos
,
[
userService
,
taskService
,
accessService
]:
[
UserService
,
TaskService
,
AccessService
]):
Promise
<
import
(
"taobao-mini-sdk/lib/utils/resultmodel"
).
Result
>
;
}
}
v2.0/dist/controller/share.controller.js
View file @
e17c0c3e
...
@@ -52,34 +52,28 @@ var services_1 = require("../decorator/services");
...
@@ -52,34 +52,28 @@ var services_1 = require("../decorator/services");
var
sdk_1
=
require
(
"../sdk"
);
var
sdk_1
=
require
(
"../sdk"
);
var
utils_1
=
require
(
"../utils"
);
var
utils_1
=
require
(
"../utils"
);
var
service_1
=
require
(
"../service"
);
var
service_1
=
require
(
"../service"
);
// {
// "handler": "doFollowTask",
// "data": {
// "activityId": "5f213791964f9706aa59b192"
// }
// }
var
Share
=
/** @class */
(
function
()
{
var
Share
=
/** @class */
(
function
()
{
function
Share
()
{
function
Share
()
{
}
}
/**
/**
* 完成分享
* 完成分享
*/
*/
Share
.
prototype
.
insertShareRecord
=
function
(
context
,
_a
,
_b
)
{
Share
.
prototype
.
doHelp
=
function
(
context
,
_a
,
_b
)
{
var
userInfo
=
_a
.
userInfo
,
vipInfo
=
_a
.
vipInfo
,
activityInfo
=
_a
.
activityInfo
;
var
userInfo
=
_a
.
userInfo
,
vipInfo
=
_a
.
vipInfo
,
activityInfo
=
_a
.
activityInfo
;
var
userService
=
_b
[
0
],
taskService
=
_b
[
1
],
accessService
=
_b
[
2
];
var
userService
=
_b
[
0
],
taskService
=
_b
[
1
],
accessService
=
_b
[
2
];
return
__awaiter
(
this
,
void
0
,
void
0
,
function
()
{
return
__awaiter
(
this
,
void
0
,
void
0
,
function
()
{
var
_c
,
activityId
,
inviteId
,
openId
,
inviteUserInfo
,
inviteCompleteList
,
isNewVip
,
isValidShare
,
tasks
,
valu
e
,
today
,
inviteUserId
;
var
inviteId
,
openId
,
inviteUserInfo
,
inviteCompleteList
,
tasks
,
value
,
isNewVip
,
isValidShar
e
,
today
,
inviteUserId
;
var
_
d
;
var
_
c
;
return
__generator
(
this
,
function
(
_
e
)
{
return
__generator
(
this
,
function
(
_
d
)
{
switch
(
_
e
.
label
)
{
switch
(
_
d
.
label
)
{
case
0
:
case
0
:
_c
=
context
.
data
,
activityId
=
_c
.
activityId
,
inviteId
=
_c
.
inviteId
;
inviteId
=
context
.
data
.
inviteId
;
openId
=
context
.
openId
;
openId
=
context
.
openId
;
return
[
4
/*yield*/
,
userService
.
getUserInfoByOpenId
(
inviteId
)
return
[
4
/*yield*/
,
userService
.
getUserInfoByOpenId
(
inviteId
)
// inviteId的用户信息查询不到, 则inviteId无效
// inviteId的用户信息查询不到, 则inviteId无效
];
];
case
1
:
case
1
:
inviteUserInfo
=
_
e
.
sent
();
inviteUserInfo
=
_
d
.
sent
();
// inviteId的用户信息查询不到, 则inviteId无效
// inviteId的用户信息查询不到, 则inviteId无效
if
(
!
inviteUserInfo
)
if
(
!
inviteUserInfo
)
return
[
2
/*return*/
,
sdk_1
.
resultsModel
.
error
(
constants_1
.
CODE_TYPES
.
ERROR_INVALID_INVITE_ID
)];
return
[
2
/*return*/
,
sdk_1
.
resultsModel
.
error
(
constants_1
.
CODE_TYPES
.
ERROR_INVALID_INVITE_ID
)];
...
@@ -88,10 +82,10 @@ var Share = /** @class */ (function () {
...
@@ -88,10 +82,10 @@ var Share = /** @class */ (function () {
if
(
inviteCompleteList
.
some
(
function
(
v
)
{
return
v
.
openId
===
openId
;
}))
{
if
(
inviteCompleteList
.
some
(
function
(
v
)
{
return
v
.
openId
===
openId
;
}))
{
return
[
2
/*return*/
,
sdk_1
.
resultsModel
.
error
(
constants_1
.
CODE_TYPES
.
ERROR_AREADY_INVITE_SUCCESS
)];
return
[
2
/*return*/
,
sdk_1
.
resultsModel
.
error
(
constants_1
.
CODE_TYPES
.
ERROR_AREADY_INVITE_SUCCESS
)];
}
}
isNewVip
=
userService
.
checkNewVipStatus
(
userInfo
,
vipInfo
);
isValidShare
=
[
isNewVip
].
every
(
function
(
v
)
{
return
!!
v
;
});
tasks
=
activityInfo
.
tasks
;
tasks
=
activityInfo
.
tasks
;
value
=
(
tasks
||
{}).
inviteFriends
.
value
;
value
=
(
tasks
||
{}).
inviteFriends
.
value
;
isNewVip
=
userService
.
checkNewVipStatus
(
userInfo
,
vipInfo
);
isValidShare
=
[
isNewVip
].
every
(
function
(
v
)
{
return
!!
v
;
});
today
=
utils_1
.
getToday
();
today
=
utils_1
.
getToday
();
if
(
!
isValidShare
)
return
[
3
/*break*/
,
3
];
if
(
!
isValidShare
)
return
[
3
/*break*/
,
3
];
inviteUserId
=
inviteUserInfo
.
_id
;
inviteUserId
=
inviteUserInfo
.
_id
;
...
@@ -100,14 +94,14 @@ var Share = /** @class */ (function () {
...
@@ -100,14 +94,14 @@ var Share = /** @class */ (function () {
$inc
:
{
$inc
:
{
'remainTimes.invites'
:
value
'remainTimes.invites'
:
value
},
},
$push
:
(
_
d
=
{},
$push
:
(
_
c
=
{},
_
d
[
"taskInfo."
+
today
+
".invites"
]
=
{
openId
:
openId
,
createTime
:
Date
.
now
()
},
_
c
[
"taskInfo."
+
today
+
".invites"
]
=
{
openId
:
openId
,
createTime
:
Date
.
now
()
},
_
d
)
_
c
)
})];
})];
case
2
:
case
2
:
// 增加邀请人的待领取次数和邀请记录
// 增加邀请人的待领取次数和邀请记录
_
e
.
sent
();
_
d
.
sent
();
_
e
.
label
=
3
;
_
d
.
label
=
3
;
case
3
:
return
[
2
/*return*/
,
sdk_1
.
resultsModel
.
success
(
true
)];
case
3
:
return
[
2
/*return*/
,
sdk_1
.
resultsModel
.
success
(
true
)];
}
}
});
});
...
@@ -120,7 +114,7 @@ var Share = /** @class */ (function () {
...
@@ -120,7 +114,7 @@ var Share = /** @class */ (function () {
__metadata
(
"design:type"
,
Function
),
__metadata
(
"design:type"
,
Function
),
__metadata
(
"design:paramtypes"
,
[
Object
,
Object
,
Array
]),
__metadata
(
"design:paramtypes"
,
[
Object
,
Object
,
Array
]),
__metadata
(
"design:returntype"
,
Promise
)
__metadata
(
"design:returntype"
,
Promise
)
],
Share
.
prototype
,
"
insertShareRecord
"
,
null
);
],
Share
.
prototype
,
"
doHelp
"
,
null
);
return
Share
;
return
Share
;
}());
}());
exports
.
default
=
Share
;
exports
.
default
=
Share
;
...
...
v2.0/dist/controller/share.controller.js.map
View file @
e17c0c3e
{"version":3,"file":"share.controller.js","sourceRoot":"","sources":["../../src/controller/share.controller.ts"],"names":[],"mappings":";AAAA,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEd,4CAA2C;AAC3C,4CAA8E;AAC9E,kDAAgD;AAEhD,8BAAqC;AACrC,kCAAmC;AACnC,sCAAoE;AAEpE,IAAI;AACJ,+BAA+B;AAC/B,cAAc;AACd,+CAA+C;AAC/C,MAAM;AACN,IAAI;AACJ;IAAA;IA2DA,CAAC;IA1DC;;OAEG;IAIG,iCAAiB,GAAvB,UACE,OAAgB,EAChB,EAAqD,EACrD,EAAoF;YADlF,QAAQ,cAAA,EAAE,OAAO,aAAA,EAAE,YAAY,kBAAA;YAChC,WAAW,QAAA,EAAE,WAAW,QAAA,EAAE,aAAa,QAAA;;;;;;;wBAElC,KAA2B,OAAO,CAAC,IAAI,EAArC,UAAU,gBAAA,EAAE,QAAQ,cAAA,CAAiB;wBACrC,MAAM,GAAK,OAAO,OAAZ,CAAY;wBAEQ,qBAAM,WAAW,CAAC,mBAAmB,CAAC,QAAQ,CAAC;4BACjF,iCAAiC;0BADgD;;wBAA3E,cAAc,GAAc,SAA+C;wBACjF,iCAAiC;wBACjC,IAAI,CAAC,cAAc;4BAAE,sBAAO,kBAAY,CAAC,KAAK,CAAC,sBAAU,CAAC,uBAAuB,CAAC,EAAA;wBAE5E,kBAAkB,GAAG,WAAW,CAAC,6BAA6B,CAAC,SAAS,EAAE,cAAc,CAAC,CAAA;wBAE/F,eAAe;wBACf,IAAI,kBAAkB,CAAC,IAAI,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,MAAM,KAAK,MAAM,EAAnB,CAAmB,CAAC,EAAE;4BACrD,sBAAO,kBAAY,CAAC,KAAK,CAAC,sBAAU,CAAC,2BAA2B,CAAC,EAAA;yBAClE;wBAKK,QAAQ,GAAG,WAAW,CAAC,iBAAiB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;wBAG3D,YAAY,GAAG,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,CAAC,EAAH,CAAG,CAAC,CAAA;wBAGvC,KAAK,GAAK,YAAY,MAAjB,CAAiB;wBAGX,KAAK,GACZ,CAAA,KAAK,IAAI,EAAE,CAAA,oBADC,CACD;wBAIjB,KAAK,GAAG,gBAAQ,EAAE,CAAA;6BACpB,YAAY,EAAZ,wBAAY;wBACD,YAAY,GAAK,cAAc,IAAnB,CAAmB;wBAC5C,mBAAmB;wBACnB,qBAAM,WAAW,CAAC,UAAU,CAAC,YAAY,EAAE;gCACzC,IAAI,EAAE;oCACJ,qBAAqB,EAAE,KAAK;iCAC7B;gCACD,KAAK;oCACH,GAAC,cAAY,KAAK,aAAU,IAAG,EAAE,MAAM,QAAA,EAAE,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE;uCAClE;6BACF,CAAC,EAAA;;wBARF,mBAAmB;wBACnB,SAOE,CAAA;;4BAGJ,sBAAO,kBAAY,CAAC,OAAO,CAAC,IAAI,CAAC,EAAA;;;;KAClC;IAnDD;QAHC,mBAAW,CAAC,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;QACvC,yBAAiB;QACjB,mBAAQ,CAAC,CAAC,qBAAW,EAAE,qBAAW,EAAE,uBAAa,CAAC,CAAC;;;;kDAoDnD;IACH,YAAC;CAAA,AA3DD,IA2DC;kBA3DoB,KAAK"}
{"version":3,"file":"share.controller.js","sourceRoot":"","sources":["../../src/controller/share.controller.ts"],"names":[],"mappings":";AAAA,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEd,4CAA2C;AAC3C,4CAA8E;AAC9E,kDAAgD;AAEhD,8BAAqC;AACrC,kCAAmC;AACnC,sCAAoE;AAEpE;IAAA;IAyDA,CAAC;IAxDC;;OAEG;IAIG,sBAAM,GAAZ,UACE,OAAgB,EAChB,EAAqD,EACrD,EAAoF;YADlF,QAAQ,cAAA,EAAE,OAAO,aAAA,EAAE,YAAY,kBAAA;YAChC,WAAW,QAAA,EAAE,WAAW,QAAA,EAAE,aAAa,QAAA;;;;;;;wBAEhC,QAAQ,GAAK,OAAO,CAAC,IAAI,SAAjB,CAAiB;wBACzB,MAAM,GAAK,OAAO,OAAZ,CAAY;wBAEQ,qBAAM,WAAW,CAAC,mBAAmB,CAAC,QAAQ,CAAC;4BACjF,iCAAiC;0BADgD;;wBAA3E,cAAc,GAAc,SAA+C;wBACjF,iCAAiC;wBACjC,IAAI,CAAC,cAAc;4BAAE,sBAAO,kBAAY,CAAC,KAAK,CAAC,sBAAU,CAAC,uBAAuB,CAAC,EAAA;wBAE5E,kBAAkB,GAAG,WAAW,CAAC,6BAA6B,CAAC,SAAS,EAAE,cAAc,CAAC,CAAA;wBAE/F,eAAe;wBACf,IAAI,kBAAkB,CAAC,IAAI,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,MAAM,KAAK,MAAM,EAAnB,CAAmB,CAAC,EAAE;4BACrD,sBAAO,kBAAY,CAAC,KAAK,CAAC,sBAAU,CAAC,2BAA2B,CAAC,EAAA;yBAClE;wBAKO,KAAK,GAAK,YAAY,MAAjB,CAAiB;wBAGX,KAAK,GACZ,CAAA,KAAK,IAAI,EAAE,CAAA,oBADC,CACD;wBAGjB,QAAQ,GAAG,WAAW,CAAC,iBAAiB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;wBAG3D,YAAY,GAAG,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,CAAC,EAAH,CAAG,CAAC,CAAA;wBAEzC,KAAK,GAAG,gBAAQ,EAAE,CAAA;6BACpB,YAAY,EAAZ,wBAAY;wBACD,YAAY,GAAK,cAAc,IAAnB,CAAmB;wBAC5C,mBAAmB;wBACnB,qBAAM,WAAW,CAAC,UAAU,CAAC,YAAY,EAAE;gCACzC,IAAI,EAAE;oCACJ,qBAAqB,EAAE,KAAK;iCAC7B;gCACD,KAAK;oCACH,GAAC,cAAY,KAAK,aAAU,IAAG,EAAE,MAAM,QAAA,EAAE,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE;uCAClE;6BACF,CAAC,EAAA;;wBARF,mBAAmB;wBACnB,SAOE,CAAA;;4BAGJ,sBAAO,kBAAY,CAAC,OAAO,CAAC,IAAI,CAAC,EAAA;;;;KAClC;IAjDD;QAHC,mBAAW,CAAC,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;QACvC,yBAAiB;QACjB,mBAAQ,CAAC,CAAC,qBAAW,EAAE,qBAAW,EAAE,uBAAa,CAAC,CAAC;;;;uCAkDnD;IACH,YAAC;CAAA,AAzDD,IAyDC;kBAzDoB,KAAK"}
\ No newline at end of file
\ No newline at end of file
v2.0/dist/controller/task.controller.d.ts
View file @
e17c0c3e
...
@@ -17,6 +17,14 @@ export default class Task {
...
@@ -17,6 +17,14 @@ export default class Task {
* 浏览商品
* 浏览商品
*/
*/
doBrowseGoodsTask
(
context
:
Context
,
{
userInfo
,
activityInfo
}:
IControllerInfos
,
[
taskService
]:
[
TaskService
]):
Promise
<
import
(
"taobao-mini-sdk/lib/utils/resultmodel"
).
Result
>
;
doBrowseGoodsTask
(
context
:
Context
,
{
userInfo
,
activityInfo
}:
IControllerInfos
,
[
taskService
]:
[
TaskService
]):
Promise
<
import
(
"taobao-mini-sdk/lib/utils/resultmodel"
).
Result
>
;
/**
* 浏览商品
*/
doCollectGoodsTask
(
context
:
Context
,
{
userInfo
,
activityInfo
}:
IControllerInfos
,
[
taskService
]:
[
TaskService
]):
Promise
<
import
(
"taobao-mini-sdk/lib/utils/resultmodel"
).
Result
>
;
/**
* 浏览链接
*/
doJumpLinkTask
(
context
:
Context
,
{
userInfo
,
activityInfo
}:
IControllerInfos
,
[
taskService
]:
[
TaskService
]):
Promise
<
import
(
"taobao-mini-sdk/lib/utils/resultmodel"
).
Result
>
;
/**
/**
* 领取任务奖励
* 领取任务奖励
*/
*/
...
...
v2.0/dist/controller/task.controller.js
View file @
e17c0c3e
...
@@ -66,7 +66,7 @@ var Task = /** @class */ (function () {
...
@@ -66,7 +66,7 @@ var Task = /** @class */ (function () {
var
userInfo
=
_a
.
userInfo
,
vipInfo
=
_a
.
vipInfo
,
activityInfo
=
_a
.
activityInfo
,
session
=
_a
.
session
;
var
userInfo
=
_a
.
userInfo
,
vipInfo
=
_a
.
vipInfo
,
activityInfo
=
_a
.
activityInfo
,
session
=
_a
.
session
;
var
taskService
=
_b
[
0
];
var
taskService
=
_b
[
0
];
return
__awaiter
(
this
,
void
0
,
void
0
,
function
()
{
return
__awaiter
(
this
,
void
0
,
void
0
,
function
()
{
var
tasks
,
startTime
,
updatedUserInfo
,
_c
,
_d
,
_e
,
_f
,
vipTask
,
followTask
,
orderGoodsTask
,
browseGoodsTask
,
invitesTask
;
var
tasks
,
startTime
,
updatedUserInfo
,
_c
,
_d
,
_e
,
_f
,
vipTask
,
followTask
,
orderGoodsTask
,
browseGoodsTask
,
collectGoodsTask
,
jumpLinkTask
,
invitesTask
;
return
__generator
(
this
,
function
(
_g
)
{
return
__generator
(
this
,
function
(
_g
)
{
switch
(
_g
.
label
)
{
switch
(
_g
.
label
)
{
case
0
:
case
0
:
...
@@ -88,10 +88,20 @@ var Task = /** @class */ (function () {
...
@@ -88,10 +88,20 @@ var Task = /** @class */ (function () {
followTask
=
taskService
.
initFollowTask
(
updatedUserInfo
,
tasks
);
followTask
=
taskService
.
initFollowTask
(
updatedUserInfo
,
tasks
);
orderGoodsTask
=
taskService
.
initOrderGoodsTask
(
updatedUserInfo
,
tasks
);
orderGoodsTask
=
taskService
.
initOrderGoodsTask
(
updatedUserInfo
,
tasks
);
browseGoodsTask
=
taskService
.
initBrowseGoodsTask
(
updatedUserInfo
,
tasks
);
browseGoodsTask
=
taskService
.
initBrowseGoodsTask
(
updatedUserInfo
,
tasks
);
collectGoodsTask
=
taskService
.
initCollectGoodsTask
(
updatedUserInfo
,
tasks
);
jumpLinkTask
=
taskService
.
initJumpLinkTask
(
updatedUserInfo
,
tasks
);
invitesTask
=
taskService
.
initInvitesTask
(
updatedUserInfo
,
tasks
);
invitesTask
=
taskService
.
initInvitesTask
(
updatedUserInfo
,
tasks
);
// 积分兑换
// 积分兑换
//const exchangeCreditsTask = taskService.initExchangeCreditsTask(updatedUserInfo, tasks)
//const exchangeCreditsTask = taskService.initExchangeCreditsTask(updatedUserInfo, tasks)
return
[
2
/*return*/
,
sdk_1
.
resultsModel
.
success
([
vipTask
,
followTask
,
orderGoodsTask
,
browseGoodsTask
,
invitesTask
])];
return
[
2
/*return*/
,
sdk_1
.
resultsModel
.
success
([
vipTask
,
followTask
,
orderGoodsTask
,
browseGoodsTask
,
invitesTask
,
collectGoodsTask
,
jumpLinkTask
])];
}
}
});
});
});
});
...
@@ -195,7 +205,7 @@ var Task = /** @class */ (function () {
...
@@ -195,7 +205,7 @@ var Task = /** @class */ (function () {
taskRateType
===
constants_1
.
TASK_RATE_TYPE
.
EVERYDAY
;
taskRateType
===
constants_1
.
TASK_RATE_TYPE
.
EVERYDAY
;
// 今日任务已经完成
// 今日任务已经完成
if
(
hasCompleteToday
)
{
if
(
hasCompleteToday
)
{
return
[
2
/*return*/
,
sdk_1
.
resultsModel
.
error
(
constants_1
.
CODE_TYPES
.
PARAMS_ERROR
,
'今日该商品任务已完成'
)];
return
[
2
/*return*/
,
sdk_1
.
resultsModel
.
error
(
constants_1
.
CODE_TYPES
.
PARAMS_ERROR
,
'今日该
浏览
商品任务已完成'
)];
}
}
// 次数超限
// 次数超限
if
(
times
&&
times
===
todayCompleteTimes
&&
taskRateType
===
constants_1
.
TASK_RATE_TYPE
.
EVERYDAY
)
{
if
(
times
&&
times
===
todayCompleteTimes
&&
taskRateType
===
constants_1
.
TASK_RATE_TYPE
.
EVERYDAY
)
{
...
@@ -213,6 +223,80 @@ var Task = /** @class */ (function () {
...
@@ -213,6 +223,80 @@ var Task = /** @class */ (function () {
});
});
});
});
};
};
/**
* 浏览商品
*/
Task
.
prototype
.
doCollectGoodsTask
=
function
(
context
,
_a
,
_b
)
{
var
userInfo
=
_a
.
userInfo
,
activityInfo
=
_a
.
activityInfo
;
var
taskService
=
_b
[
0
];
return
__awaiter
(
this
,
void
0
,
void
0
,
function
()
{
var
taskType
,
itemId
,
_c
,
taskRateType
,
times
,
itemIds
,
value
,
itemIdArray
,
_d
,
todayTaskInfo
,
todayCompleteTimes
,
hasCompleteToday
;
return
__generator
(
this
,
function
(
_e
)
{
switch
(
_e
.
label
)
{
case
0
:
taskType
=
'collectGoods'
;
itemId
=
context
.
data
.
itemId
;
_c
=
activityInfo
.
tasks
.
collectGoods
,
taskRateType
=
_c
.
taskRateType
,
times
=
_c
.
times
,
itemIds
=
_c
.
itemIds
,
value
=
_c
.
value
;
itemIdArray
=
Array
.
isArray
(
itemIds
)
?
itemIds
:
itemIds
.
split
(
','
).
map
(
function
(
v
)
{
return
+
v
;
});
// B端配置商品ids不匹配正确
if
(
!
itemIdArray
.
includes
(
+
itemId
))
return
[
2
/*return*/
,
sdk_1
.
resultsModel
.
error
(
constants_1
.
CODE_TYPES
.
PARAMS_ERROR
,
'商品id不匹配'
)];
_d
=
taskService
.
getTodayCompleteTask
(
taskType
,
userInfo
),
todayTaskInfo
=
_d
.
todayTaskInfo
,
todayCompleteTimes
=
_d
.
todayCompleteTimes
;
hasCompleteToday
=
todayTaskInfo
.
filter
(
function
(
v
)
{
return
v
.
itemId
===
itemId
;
}).
length
&&
taskRateType
===
constants_1
.
TASK_RATE_TYPE
.
EVERYDAY
;
// 今日任务已经完成
if
(
hasCompleteToday
)
{
return
[
2
/*return*/
,
sdk_1
.
resultsModel
.
error
(
constants_1
.
CODE_TYPES
.
PARAMS_ERROR
,
'今日该收藏商品任务已完成'
)];
}
// 次数超限
if
(
times
&&
times
===
todayCompleteTimes
&&
taskRateType
===
constants_1
.
TASK_RATE_TYPE
.
EVERYDAY
)
{
return
[
2
/*return*/
,
sdk_1
.
resultsModel
.
error
(
constants_1
.
CODE_TYPES
.
ERROR_TASK_LIMIT
)];
}
// 更新user表
return
[
4
/*yield*/
,
taskService
.
updateUserTaskRecord
(
taskType
,
value
,
userInfo
,
{
itemId
:
itemId
})];
case
1
:
// 更新user表
_e
.
sent
();
return
[
2
/*return*/
,
sdk_1
.
resultsModel
.
success
(
true
)];
}
});
});
};
/**
* 浏览链接
*/
Task
.
prototype
.
doJumpLinkTask
=
function
(
context
,
_a
,
_b
)
{
var
userInfo
=
_a
.
userInfo
,
activityInfo
=
_a
.
activityInfo
;
var
taskService
=
_b
[
0
];
return
__awaiter
(
this
,
void
0
,
void
0
,
function
()
{
var
taskType
,
_c
,
taskRateType
,
times
,
value
,
link
,
todayCompleteTimes
,
hasCompleteToday
;
return
__generator
(
this
,
function
(
_d
)
{
switch
(
_d
.
label
)
{
case
0
:
taskType
=
'jumpLink'
;
_c
=
activityInfo
.
tasks
.
jumpLink
,
taskRateType
=
_c
.
taskRateType
,
times
=
_c
.
times
,
value
=
_c
.
value
,
link
=
_c
.
link
;
todayCompleteTimes
=
taskService
.
getTodayCompleteTask
(
taskType
,
userInfo
).
todayCompleteTimes
;
hasCompleteToday
=
times
&&
todayCompleteTimes
===
times
&&
taskRateType
===
constants_1
.
TASK_RATE_TYPE
.
EVERYDAY
;
// 今日任务已经完成
if
(
hasCompleteToday
)
{
return
[
2
/*return*/
,
sdk_1
.
resultsModel
.
error
(
constants_1
.
CODE_TYPES
.
PARAMS_ERROR
,
'今日跳转链接任务已完成'
)];
}
// 次数超限
if
(
times
&&
times
===
todayCompleteTimes
&&
taskRateType
===
constants_1
.
TASK_RATE_TYPE
.
EVERYDAY
)
{
return
[
2
/*return*/
,
sdk_1
.
resultsModel
.
error
(
constants_1
.
CODE_TYPES
.
ERROR_TASK_LIMIT
)];
}
// 更新user表
return
[
4
/*yield*/
,
taskService
.
updateUserTaskRecord
(
taskType
,
value
,
userInfo
)];
case
1
:
// 更新user表
_d
.
sent
();
return
[
2
/*return*/
,
sdk_1
.
resultsModel
.
success
(
true
)];
}
});
});
};
/**
/**
* 领取任务奖励
* 领取任务奖励
*/
*/
...
@@ -282,6 +366,24 @@ var Task = /** @class */ (function () {
...
@@ -282,6 +366,24 @@ var Task = /** @class */ (function () {
__metadata
(
"design:paramtypes"
,
[
Object
,
Object
,
Array
]),
__metadata
(
"design:paramtypes"
,
[
Object
,
Object
,
Array
]),
__metadata
(
"design:returntype"
,
Promise
)
__metadata
(
"design:returntype"
,
Promise
)
],
Task
.
prototype
,
"doBrowseGoodsTask"
,
null
);
],
Task
.
prototype
,
"doBrowseGoodsTask"
,
null
);
__decorate
([
decorator_1
.
paramsCheck
([
'activityId'
,
'itemId'
]),
decorator_1
.
userCheck
({
intercept
:
true
}),
decorator_1
.
activityTimeCheck
,
decorator_1
.
services
([
service_1
.
TaskService
]),
__metadata
(
"design:type"
,
Function
),
__metadata
(
"design:paramtypes"
,
[
Object
,
Object
,
Array
]),
__metadata
(
"design:returntype"
,
Promise
)
],
Task
.
prototype
,
"doCollectGoodsTask"
,
null
);
__decorate
([
decorator_1
.
paramsCheck
([
'activityId'
]),
decorator_1
.
userCheck
({
intercept
:
true
}),
decorator_1
.
activityTimeCheck
,
decorator_1
.
services
([
service_1
.
TaskService
]),
__metadata
(
"design:type"
,
Function
),
__metadata
(
"design:paramtypes"
,
[
Object
,
Object
,
Array
]),
__metadata
(
"design:returntype"
,
Promise
)
],
Task
.
prototype
,
"doJumpLinkTask"
,
null
);
__decorate
([
__decorate
([
decorator_1
.
paramsCheck
([
'activityId'
,
'taskType'
]),
decorator_1
.
paramsCheck
([
'activityId'
,
'taskType'
]),
decorator_1
.
userCheck
({
intercept
:
true
}),
decorator_1
.
userCheck
({
intercept
:
true
}),
...
...
v2.0/dist/controller/task.controller.js.map
View file @
e17c0c3e
This diff is collapsed.
Click to expand it.
v2.0/dist/service/task.service.d.ts
View file @
e17c0c3e
...
@@ -21,6 +21,8 @@ export default class TaskService extends UserService {
...
@@ -21,6 +21,8 @@ export default class TaskService extends UserService {
initVipTask
(
userInfo
:
IUserInfo
,
vipInfo
:
IVipInfo
,
tasks
:
ITasks
):
ITaskInfo
;
initVipTask
(
userInfo
:
IUserInfo
,
vipInfo
:
IVipInfo
,
tasks
:
ITasks
):
ITaskInfo
;
initOrderGoodsTask
(
userInfo
:
IUserInfo
,
tasks
:
ITasks
):
ITaskInfo
;
initOrderGoodsTask
(
userInfo
:
IUserInfo
,
tasks
:
ITasks
):
ITaskInfo
;
initBrowseGoodsTask
(
userInfo
:
IUserInfo
,
tasks
:
ITasks
):
ITaskInfo
;
initBrowseGoodsTask
(
userInfo
:
IUserInfo
,
tasks
:
ITasks
):
ITaskInfo
;
initCollectGoodsTask
(
userInfo
:
IUserInfo
,
tasks
:
ITasks
):
ITaskInfo
;
initJumpLinkTask
(
userInfo
:
IUserInfo
,
tasks
:
ITasks
):
ITaskInfo
;
initInvitesTask
(
userInfo
:
IUserInfo
,
tasks
:
ITasks
):
ITaskInfo
;
initInvitesTask
(
userInfo
:
IUserInfo
,
tasks
:
ITasks
):
ITaskInfo
;
initFollowTask
(
userInfo
:
IUserInfo
,
tasks
:
ITasks
):
ITaskInfo
;
initFollowTask
(
userInfo
:
IUserInfo
,
tasks
:
ITasks
):
ITaskInfo
;
initExchangeCreditsTask
(
userInfo
:
IUserInfo
,
tasks
:
ITasks
):
ITaskInfo
;
initExchangeCreditsTask
(
userInfo
:
IUserInfo
,
tasks
:
ITasks
):
ITaskInfo
;
...
...
v2.0/dist/service/task.service.js
View file @
e17c0c3e
...
@@ -148,6 +148,60 @@ var TaskService = /** @class */ (function (_super) {
...
@@ -148,6 +148,60 @@ var TaskService = /** @class */ (function (_super) {
// }
// }
return
orderTask
;
return
orderTask
;
};
};
// 初始化收藏商品任务
TaskService
.
prototype
.
initCollectGoodsTask
=
function
(
userInfo
,
tasks
)
{
var
_a
=
tasks
.
collectGoods
,
value
=
_a
.
value
,
itemIds
=
_a
.
itemIds
,
taskRateType
=
_a
.
taskRateType
,
times
=
_a
.
times
;
var
remainTimes
=
userInfo
.
remainTimes
;
var
todayCompleteTimes
=
this
.
getTodayCompleteTask
(
'collectGoods'
,
userInfo
).
todayCompleteTimes
;
var
completeList
=
this
.
getCompleteTaskByUserTaskInfo
(
'collectGoods'
,
userInfo
);
var
orderTask
=
{
taskType
:
"collectGoods"
,
title
:
"
\
u6536
\
u85CF
\
u5546
\
u54C1"
,
itemIds
:
itemIds
,
times
:
times
,
rewards
:
value
,
waitReceive
:
remainTimes
.
collectGoods
,
todayCompleteTimes
:
todayCompleteTimes
,
completeTimes
:
completeList
.
length
,
taskRateType
:
taskRateType
};
// // 永久任务且已完成
// if (taskRateType === TASK_RATE_TYPE.FOREVER && browseGoodsCompleteList.length) {
// orderTask.done = true
// }
// // 每日限制完成且完成次数达到限制
// if (taskRateType === TASK_RATE_TYPE.EVERYDAY && todayCompleteTimes >= times) {
// orderTask.done = true
// }
return
orderTask
;
};
// 初始化收藏商品任务
TaskService
.
prototype
.
initJumpLinkTask
=
function
(
userInfo
,
tasks
)
{
var
_a
=
tasks
.
jumpLink
,
value
=
_a
.
value
,
link
=
_a
.
link
,
taskRateType
=
_a
.
taskRateType
,
times
=
_a
.
times
;
var
remainTimes
=
userInfo
.
remainTimes
;
var
todayCompleteTimes
=
this
.
getTodayCompleteTask
(
'jumpLink'
,
userInfo
).
todayCompleteTimes
;
var
completeList
=
this
.
getCompleteTaskByUserTaskInfo
(
'jumpLink'
,
userInfo
);
var
orderTask
=
{
taskType
:
"jumpLink"
,
title
:
"
\
u8DF3
\
u8F6C
\
u94FE
\
u63A5"
,
url
:
link
,
times
:
times
,
rewards
:
value
,
waitReceive
:
remainTimes
.
jumpLink
,
todayCompleteTimes
:
todayCompleteTimes
,
completeTimes
:
completeList
.
length
,
taskRateType
:
taskRateType
};
// // 永久任务且已完成
// if (taskRateType === TASK_RATE_TYPE.FOREVER && browseGoodsCompleteList.length) {
// orderTask.done = true
// }
// // 每日限制完成且完成次数达到限制
// if (taskRateType === TASK_RATE_TYPE.EVERYDAY && todayCompleteTimes >= times) {
// orderTask.done = true
// }
return
orderTask
;
};
// 初始化邀请任务
// 初始化邀请任务
TaskService
.
prototype
.
initInvitesTask
=
function
(
userInfo
,
tasks
)
{
TaskService
.
prototype
.
initInvitesTask
=
function
(
userInfo
,
tasks
)
{
var
_a
=
tasks
.
inviteFriends
,
value
=
_a
.
value
,
taskRateType
=
_a
.
taskRateType
,
times
=
_a
.
times
;
var
_a
=
tasks
.
inviteFriends
,
value
=
_a
.
value
,
taskRateType
=
_a
.
taskRateType
,
times
=
_a
.
times
;
...
...
v2.0/dist/service/task.service.js.map
View file @
e17c0c3e
This diff is collapsed.
Click to expand it.
v2.0/dist/service/user.service.js
View file @
e17c0c3e
...
@@ -281,10 +281,9 @@ var UserService = /** @class */ (function (_super) {
...
@@ -281,10 +281,9 @@ var UserService = /** @class */ (function (_super) {
return
__generator
(
this
,
function
(
_a
)
{
return
__generator
(
this
,
function
(
_a
)
{
switch
(
_a
.
label
)
{
switch
(
_a
.
label
)
{
case
0
:
case
0
:
projection
[
'$set'
]
=
projection
[
'$set'
]
||
{};
projection
[
'$set'
].
updateTime
=
Date
.
now
();
console
.
log
(
projection
);
console
.
log
(
projection
);
if
(
projection
[
'$set'
])
{
projection
[
'$set'
].
updateTime
=
Date
.
now
();
}
return
[
4
/*yield*/
,
this
.
userdao
.
update
({
_id
:
_id
},
projection
)];
return
[
4
/*yield*/
,
this
.
userdao
.
update
({
_id
:
_id
},
projection
)];
case
1
:
return
[
2
/*return*/
,
_a
.
sent
()];
case
1
:
return
[
2
/*return*/
,
_a
.
sent
()];
}
}
...
...
v2.0/dist/service/user.service.js.map
View file @
e17c0c3e
This diff is collapsed.
Click to expand it.
v2.0/src/controller/share.controller.ts
View file @
e17c0c3e
...
@@ -8,12 +8,6 @@ import { resultsModel } from '../sdk'
...
@@ -8,12 +8,6 @@ import { resultsModel } from '../sdk'
import
{
getToday
}
from
'../utils'
import
{
getToday
}
from
'../utils'
import
{
UserService
,
AccessService
,
TaskService
}
from
'../service'
import
{
UserService
,
AccessService
,
TaskService
}
from
'../service'
// {
// "handler": "doFollowTask",
// "data": {
// "activityId": "5f213791964f9706aa59b192"
// }
// }
export
default
class
Share
{
export
default
class
Share
{
/**
/**
* 完成分享
* 完成分享
...
@@ -21,12 +15,12 @@ export default class Share {
...
@@ -21,12 +15,12 @@ export default class Share {
@
paramsCheck
([
'activityId'
,
'inviteId'
])
@
paramsCheck
([
'activityId'
,
'inviteId'
])
@
activityTimeCheck
@
activityTimeCheck
@
services
([
UserService
,
TaskService
,
AccessService
])
@
services
([
UserService
,
TaskService
,
AccessService
])
async
insertShareRecord
(
async
doHelp
(
context
:
Context
,
context
:
Context
,
{
userInfo
,
vipInfo
,
activityInfo
}:
IControllerInfos
,
{
userInfo
,
vipInfo
,
activityInfo
}:
IControllerInfos
,
[
userService
,
taskService
,
accessService
]:
[
UserService
,
TaskService
,
AccessService
]
[
userService
,
taskService
,
accessService
]:
[
UserService
,
TaskService
,
AccessService
]
)
{
)
{
const
{
activityId
,
inviteId
}
=
context
.
data
const
{
inviteId
}
=
context
.
data
const
{
openId
}
=
context
const
{
openId
}
=
context
const
inviteUserInfo
:
IUserInfo
=
await
userService
.
getUserInfoByOpenId
(
inviteId
)
const
inviteUserInfo
:
IUserInfo
=
await
userService
.
getUserInfoByOpenId
(
inviteId
)
...
@@ -42,12 +36,6 @@ export default class Share {
...
@@ -42,12 +36,6 @@ export default class Share {
// const isFirstLogin: boolean = (await accessService.getAccessCount()) === 1
// const isFirstLogin: boolean = (await accessService.getAccessCount()) === 1
// 新会员
const
isNewVip
=
userService
.
checkNewVipStatus
(
userInfo
,
vipInfo
)
// 满足邀请标准的条件, 根据需求变化
const
isValidShare
=
[
isNewVip
].
every
(
v
=>
!!
v
)
// 获取活动基本信息
// 获取活动基本信息
const
{
tasks
}
=
activityInfo
const
{
tasks
}
=
activityInfo
// 获取分享奖励
// 获取分享奖励
...
@@ -55,7 +43,11 @@ export default class Share {
...
@@ -55,7 +43,11 @@ export default class Share {
inviteFriends
:
{
value
}
inviteFriends
:
{
value
}
}:
ITasks
=
tasks
||
{}
}:
ITasks
=
tasks
||
{}
// 新用户
// 新会员
const
isNewVip
=
userService
.
checkNewVipStatus
(
userInfo
,
vipInfo
)
// 满足邀请标准的条件, 根据需求变化
const
isValidShare
=
[
isNewVip
].
every
(
v
=>
!!
v
)
const
today
=
getToday
()
const
today
=
getToday
()
if
(
isValidShare
)
{
if
(
isValidShare
)
{
...
...
v2.0/src/controller/task.controller.ts
View file @
e17c0c3e
...
@@ -5,6 +5,8 @@ import { paramsCheck, userCheck, activityTimeCheck, noCatch, services } from '..
...
@@ -5,6 +5,8 @@ import { paramsCheck, userCheck, activityTimeCheck, noCatch, services } from '..
import
{
resultsModel
,
TBAPIS
}
from
'../sdk'
import
{
resultsModel
,
TBAPIS
}
from
'../sdk'
import
{
TaskService
}
from
'../service'
import
{
TaskService
}
from
'../service'
import
{
logger
}
from
'../utils'
import
{
time
}
from
'console'
// {
// {
// "handler": "getTaskList",
// "handler": "getTaskList",
...
@@ -43,16 +45,29 @@ export default class Task {
...
@@ -43,16 +45,29 @@ export default class Task {
const
vipTask
=
taskService
.
initVipTask
(
updatedUserInfo
,
vipInfo
,
tasks
)
const
vipTask
=
taskService
.
initVipTask
(
updatedUserInfo
,
vipInfo
,
tasks
)
// 关注店铺
// 关注店铺
const
followTask
=
taskService
.
initFollowTask
(
updatedUserInfo
,
tasks
)
const
followTask
=
taskService
.
initFollowTask
(
updatedUserInfo
,
tasks
)
//
//
下单任务
// 下单任务
const
orderGoodsTask
=
taskService
.
initOrderGoodsTask
(
updatedUserInfo
,
tasks
)
const
orderGoodsTask
=
taskService
.
initOrderGoodsTask
(
updatedUserInfo
,
tasks
)
//
//
浏览商品任务
// 浏览商品任务
const
browseGoodsTask
=
taskService
.
initBrowseGoodsTask
(
updatedUserInfo
,
tasks
)
const
browseGoodsTask
=
taskService
.
initBrowseGoodsTask
(
updatedUserInfo
,
tasks
)
// // 邀请任务
// 收藏商品任务
const
collectGoodsTask
=
taskService
.
initCollectGoodsTask
(
updatedUserInfo
,
tasks
)
// 跳转链接任务
const
jumpLinkTask
=
taskService
.
initJumpLinkTask
(
updatedUserInfo
,
tasks
)
// 邀请任务
const
invitesTask
=
taskService
.
initInvitesTask
(
updatedUserInfo
,
tasks
)
const
invitesTask
=
taskService
.
initInvitesTask
(
updatedUserInfo
,
tasks
)
// 积分兑换
// 积分兑换
//const exchangeCreditsTask = taskService.initExchangeCreditsTask(updatedUserInfo, tasks)
//const exchangeCreditsTask = taskService.initExchangeCreditsTask(updatedUserInfo, tasks)
return
resultsModel
.
success
([
vipTask
,
followTask
,
orderGoodsTask
,
browseGoodsTask
,
invitesTask
])
return
resultsModel
.
success
([
vipTask
,
followTask
,
orderGoodsTask
,
browseGoodsTask
,
invitesTask
,
collectGoodsTask
,
jumpLinkTask
])
}
}
/**
/**
...
@@ -158,7 +173,7 @@ export default class Task {
...
@@ -158,7 +173,7 @@ export default class Task {
// 今日任务已经完成
// 今日任务已经完成
if
(
hasCompleteToday
)
{
if
(
hasCompleteToday
)
{
return
resultsModel
.
error
(
CODE_TYPES
.
PARAMS_ERROR
,
'今日该商品任务已完成'
)
return
resultsModel
.
error
(
CODE_TYPES
.
PARAMS_ERROR
,
'今日该
浏览
商品任务已完成'
)
}
}
// 次数超限
// 次数超限
if
(
times
&&
times
===
todayCompleteTimes
&&
taskRateType
===
TASK_RATE_TYPE
.
EVERYDAY
)
{
if
(
times
&&
times
===
todayCompleteTimes
&&
taskRateType
===
TASK_RATE_TYPE
.
EVERYDAY
)
{
...
@@ -173,6 +188,89 @@ export default class Task {
...
@@ -173,6 +188,89 @@ export default class Task {
return
resultsModel
.
success
(
true
)
return
resultsModel
.
success
(
true
)
}
}
/**
* 浏览商品
*/
@
paramsCheck
([
'activityId'
,
'itemId'
])
@
userCheck
({
intercept
:
true
})
@
activityTimeCheck
@
services
([
TaskService
])
async
doCollectGoodsTask
(
context
:
Context
,
{
userInfo
,
activityInfo
}:
IControllerInfos
,
[
taskService
]:
[
TaskService
]
)
{
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
}
=
taskService
.
getTodayCompleteTask
(
taskType
,
userInfo
)
const
hasCompleteToday
=
todayTaskInfo
.
filter
((
v
:
{
itemId
:
string
})
=>
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
)
}
/**
* 浏览链接
*/
@
paramsCheck
([
'activityId'
])
@
userCheck
({
intercept
:
true
})
@
activityTimeCheck
@
services
([
TaskService
])
async
doJumpLinkTask
(
context
:
Context
,
{
userInfo
,
activityInfo
}:
IControllerInfos
,
[
taskService
]:
[
TaskService
])
{
const
taskType
=
'jumpLink'
const
{
tasks
:
{
jumpLink
:
{
taskRateType
,
times
,
value
,
link
}
}
}
=
activityInfo
const
{
todayCompleteTimes
}
=
taskService
.
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
)
}
// 更新user表
await
taskService
.
updateUserTaskRecord
(
taskType
,
value
,
userInfo
)
return
resultsModel
.
success
(
true
)
}
/**
/**
* 领取任务奖励
* 领取任务奖励
*/
*/
...
...
v2.0/src/service/task.service.ts
View file @
e17c0c3e
...
@@ -117,6 +117,70 @@ export default class TaskService extends UserService {
...
@@ -117,6 +117,70 @@ export default class TaskService extends UserService {
return
orderTask
return
orderTask
}
}
// 初始化收藏商品任务
initCollectGoodsTask
(
userInfo
:
IUserInfo
,
tasks
:
ITasks
):
ITaskInfo
{
const
{
value
,
itemIds
,
taskRateType
,
times
}
=
tasks
.
collectGoods
const
{
remainTimes
}
=
userInfo
const
{
todayCompleteTimes
}
=
this
.
getTodayCompleteTask
(
'collectGoods'
,
userInfo
)
const
completeList
:
object
[]
=
this
.
getCompleteTaskByUserTaskInfo
(
'collectGoods'
,
userInfo
)
let
orderTask
:
ITaskInfo
=
{
taskType
:
`collectGoods`
,
title
:
`收藏商品`
,
itemIds
,
times
,
rewards
:
value
,
waitReceive
:
remainTimes
.
collectGoods
,
todayCompleteTimes
,
completeTimes
:
completeList
.
length
,
taskRateType
}
// // 永久任务且已完成
// if (taskRateType === TASK_RATE_TYPE.FOREVER && browseGoodsCompleteList.length) {
// orderTask.done = true
// }
// // 每日限制完成且完成次数达到限制
// if (taskRateType === TASK_RATE_TYPE.EVERYDAY && todayCompleteTimes >= times) {
// orderTask.done = true
// }
return
orderTask
}
// 初始化收藏商品任务
initJumpLinkTask
(
userInfo
:
IUserInfo
,
tasks
:
ITasks
):
ITaskInfo
{
const
{
value
,
link
,
taskRateType
,
times
}
=
tasks
.
jumpLink
const
{
remainTimes
}
=
userInfo
const
{
todayCompleteTimes
}
=
this
.
getTodayCompleteTask
(
'jumpLink'
,
userInfo
)
const
completeList
:
object
[]
=
this
.
getCompleteTaskByUserTaskInfo
(
'jumpLink'
,
userInfo
)
let
orderTask
:
ITaskInfo
=
{
taskType
:
`jumpLink`
,
title
:
`跳转链接`
,
url
:
link
,
times
,
rewards
:
value
,
waitReceive
:
remainTimes
.
jumpLink
,
todayCompleteTimes
,
completeTimes
:
completeList
.
length
,
taskRateType
}
// // 永久任务且已完成
// if (taskRateType === TASK_RATE_TYPE.FOREVER && browseGoodsCompleteList.length) {
// orderTask.done = true
// }
// // 每日限制完成且完成次数达到限制
// if (taskRateType === TASK_RATE_TYPE.EVERYDAY && todayCompleteTimes >= times) {
// orderTask.done = true
// }
return
orderTask
}
// 初始化邀请任务
// 初始化邀请任务
initInvitesTask
(
userInfo
:
IUserInfo
,
tasks
:
ITasks
):
ITaskInfo
{
initInvitesTask
(
userInfo
:
IUserInfo
,
tasks
:
ITasks
):
ITaskInfo
{
const
{
const
{
...
...
v2.0/src/service/user.service.ts
View file @
e17c0c3e
...
@@ -175,10 +175,10 @@ class UserService extends BaseService {
...
@@ -175,10 +175,10 @@ class UserService extends BaseService {
* @returns 若更新成功,返回为1; 若更新失败,返回为 0 或系统直接报错
* @returns 若更新成功,返回为1; 若更新失败,返回为 0 或系统直接报错
*/
*/
async
updateUser
(
_id
:
string
,
projection
:
object
)
{
async
updateUser
(
_id
:
string
,
projection
:
object
)
{
projection
[
'$set'
]
=
projection
[
'$set'
]
||
{}
projection
[
'$set'
].
updateTime
=
Date
.
now
()
console
.
log
(
projection
)
console
.
log
(
projection
)
if
(
projection
[
'$set'
])
{
projection
[
'$set'
].
updateTime
=
Date
.
now
()
}
return
await
this
.
userdao
.
update
({
_id
},
projection
)
return
await
this
.
userdao
.
update
({
_id
},
projection
)
}
}
/**
/**
...
...
v2.0/src/typings/activity.d.ts
View file @
e17c0c3e
...
@@ -56,7 +56,7 @@ interface ITaskConfig {
...
@@ -56,7 +56,7 @@ interface ITaskConfig {
value
:
number
// 任奖奖励
value
:
number
// 任奖奖励
times
?:
number
// 任务为每日限次次数值
times
?:
number
// 任务为每日限次次数值
taskRateType
?:
number
// 任务频率类型
taskRateType
?:
number
// 任务频率类型
link
?:
number
// 任务链接
link
?:
string
// 任务链接
itemIds
?:
string
// 任务商品
itemIds
?:
string
// 任务商品
checked
?:
boolean
// 是否选中(B端需勾选时)
checked
?:
boolean
// 是否选中(B端需勾选时)
}
}
v2.0/src/typings/user.d.ts
View file @
e17c0c3e
...
@@ -24,7 +24,9 @@ interface IRemainTimesInfo {
...
@@ -24,7 +24,9 @@ interface IRemainTimesInfo {
member
?:
number
member
?:
number
follow
?:
number
follow
?:
number
orderGoods
?:
number
orderGoods
?:
number
collectGoods
?:
number
exchangeCredits
?:
number
exchangeCredits
?:
number
jumpLink
?:
number
}
}
interface
IMemberInfo
{
interface
IMemberInfo
{
...
...
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