Commit d2813b8e authored by maggie's avatar maggie

save

parents 3d277a1e e33364a0
...@@ -19,6 +19,9 @@ export interface IReceiveEnameParams { ...@@ -19,6 +19,9 @@ export interface IReceiveEnameParams {
activityId: string; activityId: string;
id: string; id: string;
} }
export interface IReceivePrizeControllerInfos extends IControllerInfos {
awardInfo: IAwards;
}
export default class AwardsController { export default class AwardsController {
/** /**
* 我的奖品列表 * 我的奖品列表
...@@ -29,11 +32,11 @@ export default class AwardsController { ...@@ -29,11 +32,11 @@ export default class AwardsController {
/** /**
* 领取实物 * 领取实物
*/ */
receiveObjectPrize(context: IContext<IReceiveOjectParams>, { activityInfo }: IControllerInfos, [awardSer]: [AwardsService]): Promise<IResult<boolean>>; receiveObjectPrize(context: IContext<IReceiveOjectParams>, { activityInfo }: IReceivePrizeControllerInfos, [awardSer]: [AwardsService]): Promise<IResult<boolean>>;
/** /**
* 权益重新领取 * 权益重新领取
*/ */
receiveEnamePrize(context: IContext<IReceiveEnameParams>, {}: {}, [awardSer]: [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<CodeType | IAwards, true>>; receiveEnamePrize(context: IContext<IReceiveEnameParams>, { awardInfo, session }: IReceivePrizeControllerInfos, [awardSer]: [AwardsService]): Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result<string | boolean | object | number[] | object[] | string[], false> | import("taobao-mini-sdk/lib/utils/resultmodel").Result<CodeType | IAwards, true>>;
/** /**
* 概率抽奖 * 概率抽奖
*/ */
......
...@@ -53,6 +53,8 @@ var constants_1 = require("../constants"); ...@@ -53,6 +53,8 @@ var constants_1 = require("../constants");
var utils_1 = require("../utils/"); var utils_1 = require("../utils/");
var preCheck_1 = require("../decorator/common/preCheck"); var preCheck_1 = require("../decorator/common/preCheck");
var checkActivityTime_1 = require("../utils/common/check/checkActivityTime"); var checkActivityTime_1 = require("../utils/common/check/checkActivityTime");
var checkPrizeExpired_1 = require("../utils/common/check/checkPrizeExpired");
var checkValidPrize_1 = require("../utils/common/check/checkValidPrize");
var AwardsController = /** @class */ (function () { var AwardsController = /** @class */ (function () {
function AwardsController() { function AwardsController() {
} }
...@@ -88,7 +90,7 @@ var AwardsController = /** @class */ (function () { ...@@ -88,7 +90,7 @@ var AwardsController = /** @class */ (function () {
city: 1, city: 1,
area: 1, area: 1,
remark: 1, remark: 1,
useUrk: 1, useUrl: 1,
shipCompany: 1, shipCompany: 1,
shipNum: 1 shipNum: 1
}, },
...@@ -99,7 +101,7 @@ var AwardsController = /** @class */ (function () { ...@@ -99,7 +101,7 @@ var AwardsController = /** @class */ (function () {
case 1: case 1:
myPrizeList = _c.sent(); myPrizeList = _c.sent();
return [2 /*return*/, sdk_1.resultsModel.success({ return [2 /*return*/, sdk_1.resultsModel.success({
list: awardSer.formateMyPrizeList(myPrizeList, awardReceiveExpiredTime) list: awardSer.formatMyPrizeList(myPrizeList, awardReceiveExpiredTime)
})]; })];
} }
}); });
...@@ -112,17 +114,12 @@ var AwardsController = /** @class */ (function () { ...@@ -112,17 +114,12 @@ var AwardsController = /** @class */ (function () {
var activityInfo = _a.activityInfo; var activityInfo = _a.activityInfo;
var awardSer = _b[0]; var awardSer = _b[0];
return __awaiter(this, void 0, void 0, function () { return __awaiter(this, void 0, void 0, function () {
var _c, province, city, area, streetName, addressDetail, id, name, phone, activityId, awardReceiveExpiredTime, result; var _c, province, city, area, streetName, addressDetail, id, name, phone, result;
return __generator(this, function (_d) { return __generator(this, function (_d) {
switch (_d.label) { switch (_d.label) {
case 0: case 0:
_c = context.data, province = _c.province, city = _c.city, area = _c.area, streetName = _c.streetName, addressDetail = _c.addressDetail, id = _c.id, name = _c.name, phone = _c.phone, activityId = _c.activityId; _c = context.data, province = _c.province, city = _c.city, area = _c.area, streetName = _c.streetName, addressDetail = _c.addressDetail, id = _c.id, name = _c.name, phone = _c.phone;
awardReceiveExpiredTime = activityInfo.awardReceiveExpiredTime;
if (awardReceiveExpiredTime && Date.now() > awardReceiveExpiredTime) {
return [2 /*return*/, sdk_1.resultsModel.error(constants_1.CODE_TYPES.ERROR_PRIZE_EXPIRED)];
}
return [4 /*yield*/, awardSer.recieveObjectPrize(id, { return [4 /*yield*/, awardSer.recieveObjectPrize(id, {
activityId: activityId,
province: province, province: province,
city: city, city: city,
area: area, area: area,
...@@ -145,16 +142,17 @@ var AwardsController = /** @class */ (function () { ...@@ -145,16 +142,17 @@ var AwardsController = /** @class */ (function () {
* 权益重新领取 * 权益重新领取
*/ */
AwardsController.prototype.receiveEnamePrize = function (context, _a, _b) { AwardsController.prototype.receiveEnamePrize = function (context, _a, _b) {
var awardInfo = _a.awardInfo, session = _a.session;
var awardSer = _b[0]; var awardSer = _b[0];
return __awaiter(this, void 0, void 0, function () { return __awaiter(this, void 0, void 0, function () {
var _c, id, activityId, result; var id, result;
return __generator(this, function (_d) { return __generator(this, function (_c) {
switch (_d.label) { switch (_c.label) {
case 0: case 0:
_c = context.data, id = _c.id, activityId = _c.activityId; id = context.data.id;
return [4 /*yield*/, awardSer.recieveEnamePrize(id, activityId)]; return [4 /*yield*/, awardSer.recieveEnamePrize(id, awardInfo, session)];
case 1: case 1:
result = _d.sent(); result = _c.sent();
if (result.code) { if (result.code) {
return [2 /*return*/, sdk_1.resultsModel.error(result)]; return [2 /*return*/, sdk_1.resultsModel.error(result)];
} }
...@@ -252,13 +250,16 @@ var AwardsController = /** @class */ (function () { ...@@ -252,13 +250,16 @@ var AwardsController = /** @class */ (function () {
__decorate([ __decorate([
common_1.checkParams(['activityId', 'id', 'name', 'phone', 'province', 'city', 'area', 'addressDetail', 'streetName']), common_1.checkParams(['activityId', 'id', 'name', 'phone', 'province', 'city', 'area', 'addressDetail', 'streetName']),
common_1.services([service_1.AwardsService]), common_1.services([service_1.AwardsService]),
preCheck_1.preCheck([checkPrizeExpired_1.checkPrizeExpired, checkValidPrize_1.checkValidPrize([constants_1.PRIZE_TYPE.OBJECT])]),
__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)
], AwardsController.prototype, "receiveObjectPrize", null); ], AwardsController.prototype, "receiveObjectPrize", null);
__decorate([ __decorate([
common_1.checkParams(['activityId', 'id']), common_1.checkParams(['activityId', 'id']),
common_1.registeInfos(['session']),
common_1.services([service_1.AwardsService]), common_1.services([service_1.AwardsService]),
preCheck_1.preCheck([checkPrizeExpired_1.checkPrizeExpired, checkValidPrize_1.checkValidPrize([constants_1.PRIZE_TYPE.ENAME, constants_1.PRIZE_TYPE.CREDITS])]),
__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)
......
{"version":3,"file":"awards.controller.js","sourceRoot":"","sources":["../../src/controller/awards.controller.ts"],"names":[],"mappings":";AAAA,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEd,8CAA2D;AAC3D,8BAAqC;AACrC,sCAA0C;AAC1C,0CAAkE;AAClE,mCAAoC;AAEpC,yDAAuD;AACvD,6EAA2E;AAuB3E;IAAA;IAmLA,CAAC;IAlLC;;OAEG;IAGG,yCAAc,GAApB,UACE,OAAmC,EACnC,EAAkC,EAClC,EAA2B;YADzB,YAAY,kBAAA;YACb,QAAQ,QAAA;;;;;;wBAGP,MAAM,GAEJ,OAAO,OAFH,EACE,UAAU,GAChB,OAAO,gBADS,CACT;wBAEH,uBAAuB,GAAK,YAAY,wBAAjB,CAAiB;wBAE5B,qBAAM,QAAQ,CAAC,iBAAiB,CAClD;gCACE,MAAM,QAAA;gCACN,UAAU,YAAA;gCACV,IAAI,EAAE,EAAE,GAAG,EAAE,sBAAU,CAAC,MAAM,EAAE;6BACjC,EACD;gCACE,UAAU,EAAE;oCACV,GAAG,EAAE,CAAC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,oBAAW,CAAC,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;QACjC,qBAAY,CAAC,CAAC,SAAS,CAAC,CAAC;QACzB,iBAAQ,CAAC,CAAC,uBAAa,CAAC,CAAC;QACzB,mBAAQ,CAAC,CAAC,qCAAiB,EAAE,iCAAe,CAAC,CAAC,sBAAU,CAAC,KAAK,EAAE,sBAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;;;;6DAiBtF;IAQD;QAHC,oBAAW,CAAC,CAAC,YAAY,EAAE,eAAe,CAAC,CAAC;QAC5C,iBAAQ,CAAC,CAAC,uBAAa,CAAC,CAAC;QACzB,mBAAQ,CAAC,CAAC,qCAAiB,CAAC,CAAC;;;;4DAkE7B;IACH,uBAAC;CAAA,AApLD,IAoLC;kBApLoB,gBAAgB"}
\ No newline at end of file \ No newline at end of file
...@@ -88,7 +88,7 @@ var Share = /** @class */ (function () { ...@@ -88,7 +88,7 @@ var Share = /** @class */ (function () {
switch (_c.label) { switch (_c.label) {
case 0: case 0:
openId = context.openId; openId = context.openId;
return [4 /*yield*/, taskService.completeTask('invites', inviteUserInfo, activityInfo, { return [4 /*yield*/, taskService.completeTask('invites', activityInfo, inviteUserInfo, {
openId: openId openId: openId
})]; })];
case 1: case 1:
......
{"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,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AW,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 \ No newline at end of file
...@@ -7,39 +7,33 @@ export default class Task { ...@@ -7,39 +7,33 @@ export default class Task {
*/ */
getTaskList(context: IContext<{ getTaskList(context: IContext<{
activityId: string; activityId: string;
}>, { userInfo, vipInfo, activityInfo }: IControllerInfos, [taskService]: [TaskService]): Promise<IResult<ITaskInfo[]>>; }>, { userInfo, activityInfo }: IControllerInfos, [taskService]: [TaskService]): Promise<IResult<ITaskInfo[]>>;
/** /**
* 完成关注店铺任务 * 完成任务
*
* 商品相关任务 需要传itemId参数
* 积分兑换任务 需要传credits参数
*/ */
doFollowTask(context: IContext<{ doCompleteTask(context: IContext<{
activityId: string; activityId: string;
}>, { userInfo, activityInfo }: IControllerInfos, [TaskService]: [TaskService]): Promise<IResult<boolean>>; taskType: ITaskType;
/** itemId?: string;
* 积分兑换次数 credits?: number;
*/ }>, { userInfo, activityInfo }: IControllerInfos, [taskService]: [TaskService]): Promise<IResult<boolean>>;
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>>;
/** /**
* 领取任务奖励 * 领取任务奖励
*/ */
receiveTaskRewards(context: IContext<IParams>, { userInfo }: IControllerInfos, [taskService]: [TaskService]): Promise<IResult<{ receiveTaskRewards(context: IContext<{
activityId: string;
taskType: ITaskType;
rewardsKey: string;
}>, { userInfo }: IControllerInfos, [taskService]: [TaskService]): Promise<IResult<{
rewards: number; rewards: number;
}>>; }>>;
/** /**
* 获取收藏商品列表 * 获取收藏商品列表
*/ */
getCollectGoodsList(context: IContext<IParams>, { session, userInfo }: IControllerInfos, [baseService, taskService]: [BaseService, TaskService]): Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result<{ getCollectGoodsList(context: IContext<IParams>, { session, userInfo }: IControllerInfos, [baseService]: [BaseService]): Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result<{
collected: boolean; collected: boolean;
itemId: string; itemId: string;
name: string; name: string;
......
This diff is collapsed.
This diff is collapsed.
...@@ -15,6 +15,9 @@ export default class User { ...@@ -15,6 +15,9 @@ export default class User {
*/ */
getRankList(context: IContext<{ getRankList(context: IContext<{
activityId: string; activityId: string;
key: string;
timeKey: string;
limit: number;
}>, { userInfo }: IControllerInfos, [userService]: [UserService]): Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result<{ }>, { userInfo }: IControllerInfos, [userService]: [UserService]): Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result<{
userNick: string; userNick: string;
avatar: string; avatar: string;
......
...@@ -79,25 +79,23 @@ var User = /** @class */ (function () { ...@@ -79,25 +79,23 @@ var User = /** @class */ (function () {
var userInfo = _a.userInfo; var userInfo = _a.userInfo;
var userService = _b[0]; var userService = _b[0];
return __awaiter(this, void 0, void 0, function () { return __awaiter(this, void 0, void 0, function () {
var sortKey, sortTime, limit, userNick, avatar, rank, list; var _c, key, timeKey, _d, limit, userNick, avatar, rank, list;
return __generator(this, function (_c) { return __generator(this, function (_e) {
switch (_c.label) { switch (_e.label) {
case 0: case 0:
sortKey = 'score'; _c = context.data, key = _c.key, timeKey = _c.timeKey, _d = _c.limit, limit = _d === void 0 ? 200 : _d;
sortTime = 'updateScoreTime';
limit = 200;
userNick = userInfo.userNick, avatar = userInfo.avatar; userNick = userInfo.userNick, avatar = userInfo.avatar;
return [4 /*yield*/, userService.getMyRank(sortKey, sortTime, userInfo[sortKey])]; return [4 /*yield*/, userService.getMyRank(key, timeKey, userInfo[key])];
case 1: case 1:
rank = _c.sent(); rank = _e.sent();
return [4 /*yield*/, userService.getRank(sortKey, sortTime, limit)]; return [4 /*yield*/, userService.getRank(key, timeKey, limit)];
case 2: case 2:
list = _c.sent(); list = _e.sent();
return [2 /*return*/, sdk_1.resultsModel.success({ return [2 /*return*/, sdk_1.resultsModel.success({
userNick: userNick, userNick: userNick,
avatar: avatar, avatar: avatar,
rank: rank, rank: rank,
score: userInfo[sortKey], score: userInfo[key],
list: list list: list
})]; })];
} }
......
{"version":3,"file":"user.controller.js","sourceRoot":"","sources":["../../src/controller/user.controller.ts"],"names":[],"mappings":";AAAA,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEd,8CAAyE;AACzE,8BAAqC;AACrC,sCAAwC;AACxC,2CAAgE;AAOhE;IAAA;IAgDA,CAAC;IA/CC;;OAEG;IAIG,yBAAU,GAAhB,UACE,OAA6B,EAC7B,EAA+C;YAA7C,OAAO,aAAA,EAAE,gBAAgB,sBAAA;;;;;;wBAEnB,WAAW,GAAK,OAAO,CAAC,IAAI,YAAjB,CAAiB;wBAErB,qBAAM,gBAAU,CAAC,OAAO,EAAE,OAAO,EAAE,WAAW,IAAI,oBAAc,CAAC,OAAO,CAAC,EAAE,gBAAgB,CAAC,EAAA;;wBAArG,MAAM,GAAG,SAA4F;wBAE3G,sBAAO,kBAAY,CAAC,O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AC;QACzB,iBAAQ,CAAC,EAAE,CAAC;;;;0CAUZ;IAOD;QAFC,oBAAW,CAAC,CAAC,YAAY,CAAC,CAAC;QAC3B,iBAAQ,CAAC,CAAC,qBAAW,CAAC,CAAC;;;;2CA0BvB;IACH,WAAC;CAAA,AAjDD,IAiDC;kBAjDoB,IAAI"}
\ No newline at end of file \ No newline at end of file
...@@ -6,8 +6,18 @@ declare const _default: { ...@@ -6,8 +6,18 @@ declare const _default: {
getVipInfo: (context: IContext<import("./controller/user.controller").IVipParams>, { session, activityUserNick }: IControllerInfos) => Promise<IResult<IVipInfo>>; getVipInfo: (context: IContext<import("./controller/user.controller").IVipParams>, { session, activityUserNick }: IControllerInfos) => Promise<IResult<IVipInfo>>;
getTaskList: (context: IContext<{ getTaskList: (context: IContext<{
activityId: string; 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[]>>;
receiveTaskRewards: (context: IContext<IParams>, { userInfo }: IControllerInfos, [taskService]: [import("./service").TaskService]) => Promise<IResult<{ doCompleteTask: (context: IContext<{
activityId: string;
taskType: ITaskType;
itemId?: string;
credits?: number;
}>, { userInfo, activityInfo }: IControllerInfos, [taskService]: [import("./service").TaskService]) => Promise<IResult<boolean>>;
receiveTaskRewards: (context: IContext<{
activityId: string;
taskType: ITaskType;
rewardsKey: string;
}>, { userInfo }: IControllerInfos, [taskService]: [import("./service").TaskService]) => Promise<IResult<{
rewards: number; rewards: number;
}>>; }>>;
getActivityBaseInfoById: (context: IContext<{ getActivityBaseInfoById: (context: IContext<{
...@@ -16,16 +26,19 @@ declare const _default: { ...@@ -16,16 +26,19 @@ declare const _default: {
getMyPrizeList: (context: IContext<import("./controller/awards.controller").IPrizeListParams>, { activityInfo }: IControllerInfos, [awardSer]: [import("./service").AwardsService]) => Promise<IResult<{ getMyPrizeList: (context: IContext<import("./controller/awards.controller").IPrizeListParams>, { activityInfo }: IControllerInfos, [awardSer]: [import("./service").AwardsService]) => Promise<IResult<{
list: IAwards[]; list: IAwards[];
}>>; }>>;
receiveObjectPrize: (context: IContext<import("./controller/awards.controller").IReceiveOjectParams>, { activityInfo }: IControllerInfos, [awardSer]: [import("./service").AwardsService]) => Promise<IResult<boolean>>; receiveObjectPrize: (context: IContext<import("./controller/awards.controller").IReceiveOjectParams>, { activityInfo }: import("./controller/awards.controller").IReceivePrizeControllerInfos, [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>, { awardInfo, session }: import("./controller/awards.controller").IReceivePrizeControllerInfos, [awardSer]: [import("./service").AwardsService]) => Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result<string | boolean | object | number[] | object[] | string[], false> | import("taobao-mini-sdk/lib/utils/resultmodel").Result<import("taobao-mini-sdk/lib/utils/codetypes").CodeType | IAwards, true>>;
doHelp: (context: IContext<{ doHelp: (context: IContext<{
activityId: string; activityId: string;
inviteId: string; inviteId: string;
}>, { userInfo, activityInfo, inviteUserInfo }: import("./controller/share.controller").IdoHelpInfos, [taskService, statService]: [import("./service").TaskService, import("./service").StatService]) => Promise<IResult<boolean>>; }>, { 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 | number[] | object[] | string[], 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>>; 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<{ getRankList: (context: IContext<{
activityId: string; activityId: string;
key: string;
timeKey: string;
limit: number;
}>, { userInfo }: IControllerInfos, [userService]: [import("./service/user.service").default]) => Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result<{ }>, { userInfo }: IControllerInfos, [userService]: [import("./service/user.service").default]) => Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result<{
userNick: string; userNick: string;
avatar: string; avatar: string;
......
"use strict"; "use strict";
/** @format */ /** @format */
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
// import { exportHandlers } from './utils'
var user_controller_1 = require("./controller/user.controller"); var user_controller_1 = require("./controller/user.controller");
var task_controller_1 = require("./controller/task.controller"); var task_controller_1 = require("./controller/task.controller");
var base_controller_1 = require("./controller/base.controller"); var base_controller_1 = require("./controller/base.controller");
...@@ -11,8 +10,8 @@ var stat_controller_1 = require("./controller/stat.controller"); ...@@ -11,8 +10,8 @@ var stat_controller_1 = require("./controller/stat.controller");
var login_controller_1 = require("./controller/login.controller"); var login_controller_1 = require("./controller/login.controller");
var _a = new user_controller_1.default(), getVipInfo = _a.getVipInfo, getRankList = _a.getRankList; var _a = new user_controller_1.default(), getVipInfo = _a.getVipInfo, getRankList = _a.getRankList;
var login = new login_controller_1.default().login; var login = new login_controller_1.default().login;
var _b = new task_controller_1.default(), getTaskList = _b.getTaskList, receiveTaskRewards = _b.receiveTaskRewards, getCollectGoodsList = _b.getCollectGoodsList, // 获取收藏商品列表,包含收藏状态 var _b = new task_controller_1.default(), getTaskList = _b.getTaskList, receiveTaskRewards = _b.receiveTaskRewards, doCompleteTask = _b.doCompleteTask, getCollectGoodsList = _b.getCollectGoodsList // 获取收藏商品列表,包含收藏状态
doFollowTask = _b.doFollowTask, doJumpLinkTask = _b.doJumpLinkTask, doBrowseGoodsTask = _b.doBrowseGoodsTask, doCollectGoodsTask = _b.doCollectGoodsTask, doExchangeCreditsTask = _b.doExchangeCreditsTask; ;
var _c = new base_controller_1.default(), getActivityBaseInfoById = _c.getActivityBaseInfoById, getItemListByItemIds = _c.getItemListByItemIds; 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 _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; var doHelp = new share_controller_1.default().doHelp;
...@@ -21,6 +20,7 @@ exports.default = { ...@@ -21,6 +20,7 @@ exports.default = {
login: login, login: login,
getVipInfo: getVipInfo, getVipInfo: getVipInfo,
getTaskList: getTaskList, getTaskList: getTaskList,
doCompleteTask: doCompleteTask,
receiveTaskRewards: receiveTaskRewards, receiveTaskRewards: receiveTaskRewards,
getActivityBaseInfoById: getActivityBaseInfoById, getActivityBaseInfoById: getActivityBaseInfoById,
getMyPrizeList: getMyPrizeList, getMyPrizeList: getMyPrizeList,
......
{"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"} {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,cAAc;;AAEd,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,KAKF,IAAI,yBAAc,EAAE,EAJtB,WAAW,iBAAA,EACX,kBAAkB,wBAAA,EAClB,cAAc,oBAAA,EACd,mBAAmB,yBAAA,CAAC,kBAAkB;AAChB,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 \ No newline at end of file
...@@ -21,7 +21,7 @@ export default class AwardsService extends UserService { ...@@ -21,7 +21,7 @@ export default class AwardsService extends UserService {
*/ */
sendAward(document: IAwards): Promise<CodeType | IAwards>; sendAward(document: IAwards): Promise<CodeType | IAwards>;
getAwardsInfoList(query: object, projection?: IFindProjection): Promise<IAwards[]>; getAwardsInfoList(query: object, projection?: IFindProjection): Promise<IAwards[]>;
formateMyPrizeList(myPrizeList: IAwards[], awardReceiveExpiredTime?: number): { formatMyPrizeList(myPrizeList: IAwards[], awardReceiveExpiredTime?: number): {
expiredTime: number; expiredTime: number;
id: string; id: string;
_id?: string; _id?: string;
...@@ -50,8 +50,7 @@ export default class AwardsService extends UserService { ...@@ -50,8 +50,7 @@ export default class AwardsService extends UserService {
updateTime?: number; updateTime?: number;
awardsType?: string; awardsType?: string;
}[]; }[];
recieveObjectPrize(_id: string, { activityId, province, city, area, streetName, addressDetail, name, phone }: { recieveObjectPrize(_id: string, { province, city, area, streetName, addressDetail, name, phone }: {
activityId: string;
province: string; province: string;
city: string; city: string;
area: string; area: string;
...@@ -60,7 +59,7 @@ export default class AwardsService extends UserService { ...@@ -60,7 +59,7 @@ export default class AwardsService extends UserService {
name: string; name: string;
phone: string | number; phone: string | number;
}): Promise<true | CodeType>; }): Promise<true | CodeType>;
recieveEnamePrize(_id: string, activityId: string): Promise<CodeType | IAwards>; recieveEnamePrize(_id: string, awardInfo: IAwards, session: string): Promise<CodeType | IAwards>;
getPrizeConfig(query: { getPrizeConfig(query: {
activityId: string; activityId: string;
[queryParam: string]: any; [queryParam: string]: any;
......
...@@ -196,7 +196,7 @@ var AwardsService = /** @class */ (function (_super) { ...@@ -196,7 +196,7 @@ var AwardsService = /** @class */ (function (_super) {
}); });
}); });
}; };
AwardsService.prototype.formateMyPrizeList = function (myPrizeList, awardReceiveExpiredTime) { AwardsService.prototype.formatMyPrizeList = function (myPrizeList, awardReceiveExpiredTime) {
var now = Date.now(); var now = Date.now();
return myPrizeList.map(function (v) { return myPrizeList.map(function (v) {
if (awardReceiveExpiredTime && if (awardReceiveExpiredTime &&
...@@ -210,28 +210,12 @@ var AwardsService = /** @class */ (function (_super) { ...@@ -210,28 +210,12 @@ var AwardsService = /** @class */ (function (_super) {
}; };
// 领取实物 // 领取实物
AwardsService.prototype.recieveObjectPrize = function (_id, _a) { AwardsService.prototype.recieveObjectPrize = function (_id, _a) {
var activityId = _a.activityId, province = _a.province, city = _a.city, area = _a.area, streetName = _a.streetName, addressDetail = _a.addressDetail, name = _a.name, phone = _a.phone; var province = _a.province, city = _a.city, area = _a.area, streetName = _a.streetName, addressDetail = _a.addressDetail, name = _a.name, phone = _a.phone;
return __awaiter(this, void 0, void 0, function () { return __awaiter(this, void 0, void 0, function () {
var award, result; var result;
return __generator(this, function (_b) { return __generator(this, function (_b) {
switch (_b.label) { switch (_b.label) {
case 0: return [4 /*yield*/, this.awardsdao.findOne({ _id: _id })]; case 0: return [4 /*yield*/, this.awardsdao.update({ _id: _id }, {
case 1:
award = _b.sent();
console.log("receiveObject-award", award);
// 奖品不存在
if (!award) {
return [2 /*return*/, constants_1.CODE_TYPES.ERROR_NO_PRIZE];
}
// 已领取
if (award.drawStatus === constants_1.DRAW_STATUS.SUCCESS) {
return [2 /*return*/, constants_1.CODE_TYPES.ERROR_RECEIVE_PRIZE];
}
// 不是实物,非法操作
if (award.type !== constants_1.PRIZE_TYPE.OBJECT) {
return [2 /*return*/, constants_1.CODE_TYPES.ERROR_FORBIDDEN_OPE];
}
return [4 /*yield*/, this.awardsdao.update({ _id: _id }, {
$set: { $set: {
receiveName: name, receiveName: name,
phone: phone, phone: phone,
...@@ -246,7 +230,7 @@ var AwardsService = /** @class */ (function (_super) { ...@@ -246,7 +230,7 @@ var AwardsService = /** @class */ (function (_super) {
updateTime: Date.now() updateTime: Date.now()
} }
})]; })];
case 2: case 1:
result = _b.sent(); result = _b.sent();
return [2 /*return*/, result ? true : constants_1.CODE_TYPES.SYSTEM_ERROR]; return [2 /*return*/, result ? true : constants_1.CODE_TYPES.SYSTEM_ERROR];
} }
...@@ -254,44 +238,15 @@ var AwardsService = /** @class */ (function (_super) { ...@@ -254,44 +238,15 @@ var AwardsService = /** @class */ (function (_super) {
}); });
}; };
// 发放淘宝权益(奖品数据已插入到awards_info表,且状态drawStatus 为1或者6) // 发放淘宝权益(奖品数据已插入到awards_info表,且状态drawStatus 为1或者6)
AwardsService.prototype.recieveEnamePrize = function (_id, activityId) { AwardsService.prototype.recieveEnamePrize = function (_id, awardInfo, session) {
return __awaiter(this, void 0, void 0, function () { return __awaiter(this, void 0, void 0, function () {
var awardReceiveExpiredTime, award, session, result; var result;
return __generator(this, function (_a) { return __generator(this, function (_a) {
switch (_a.label) { switch (_a.label) {
case 0: return [4 /*yield*/, this.getBaseInfo(activityId)]; case 0: return [4 /*yield*/, utils_1.sendTBAward(this.context, session, awardInfo)
case 1:
awardReceiveExpiredTime = (_a.sent()).awardReceiveExpiredTime;
if (awardReceiveExpiredTime && Date.now() > awardReceiveExpiredTime) {
return [2 /*return*/, constants_1.CODE_TYPES.ERROR_PRIZE_EXPIRED];
}
return [4 /*yield*/, this.awardsdao.findOne({ _id: _id })
// 奖品不存在
];
case 2:
award = _a.sent();
// 奖品不存在
if (!award) {
return [2 /*return*/, constants_1.CODE_TYPES.ERROR_NO_PRIZE];
}
// 已领取
if (award.drawStatus === constants_1.DRAW_STATUS.SUCCESS) {
return [2 /*return*/, constants_1.CODE_TYPES.ERROR_RECEIVE_PRIZE];
}
console.log("award.drawStatus", award.drawStatus);
// 状态不是1,6
if (![constants_1.DRAW_STATUS.WAITAWARD, constants_1.DRAW_STATUS.RETRY].includes(award.drawStatus)) {
return [2 /*return*/, constants_1.CODE_TYPES.ERROR_FORBIDDEN_OPE];
}
return [4 /*yield*/, utils_1.getSellerSession(this.context)
// 发放淘宝权益
];
case 3:
session = (_a.sent()).session;
return [4 /*yield*/, utils_1.sendTBAward(this.context, session, award)
// 更新 // 更新
]; ];
case 4: case 1:
result = _a.sent(); result = _a.sent();
// 更新 // 更新
return [4 /*yield*/, this.awardsdao.update({ _id: _id }, { return [4 /*yield*/, this.awardsdao.update({ _id: _id }, {
...@@ -303,7 +258,7 @@ var AwardsService = /** @class */ (function (_super) { ...@@ -303,7 +258,7 @@ var AwardsService = /** @class */ (function (_super) {
updateTime: Date.now() updateTime: Date.now()
} }
})]; })];
case 5: case 2:
// 更新 // 更新
_a.sent(); _a.sent();
return [2 /*return*/, result]; return [2 /*return*/, result];
......
This diff is collapsed.
...@@ -24,18 +24,34 @@ export default class TaskService extends UserService { ...@@ -24,18 +24,34 @@ export default class TaskService extends UserService {
* *
* @param {ITaskType} taskType 任务类型 * @param {ITaskType} taskType 任务类型
* @param {string} title 任务标题 * @param {string} title 任务标题
* @param {ITasks} tasks 任务配置 * @param {IActivityInfo} activityInfo 任务配置
* @param {IUserInfo} userInfo 用户信息 * @param {IUserInfo} userInfo 用户信息
* @return {ITaskInfo} {ITaskInfo} 任务信息 * @return {ITaskInfo} {ITaskInfo} 任务信息
* @memberof TaskService * @memberof TaskService
*/ */
initTask(taskType: ITaskType, title: string, tasks: ITasks, userInfo: IUserInfo): ITaskInfo; initTask(taskType: ITaskType, title: string, activityInfo: IActivityInfo, userInfo: IUserInfo): ITaskInfo;
completeTask(taskType: ITaskType, userInfo: IUserInfo, activityInfo: IActivityInfo, customRecord?: object): Promise<number>; /**
updateVipTask(userInfo: IUserInfo, vipInfo: IVipInfo, tasks: ITasks): { *
$set: {}; * 领取任务奖励
$inc: {}; *
$push: {}; * @param {ITaskType} taskType
}; * @param {string} awardsTargetKey
* @param {IUserInfo} userInfo
* @return {number} rewards
* @memberof TaskService
*/
receiveTaskRewards(taskType: ITaskType, awardsTargetKey: string, userInfo: IUserInfo): Promise<number>;
/**
*根据任务类型更新任务待领取次数和任务记录
*
* @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<{}>; updateOrderGoodsTask(userInfo: IUserInfo, tasks: ITasks, activityStartTime: number, session?: string): Promise<{}>;
updateSignTask(userInfo: IUserInfo, tasks: ITasks): { updateSignTask(userInfo: IUserInfo, tasks: ITasks): {
$inc: { $inc: {
...@@ -50,38 +66,6 @@ export default class TaskService extends UserService { ...@@ -50,38 +66,6 @@ export default class TaskService extends UserService {
$inc?: undefined; $inc?: undefined;
$push?: 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表中,任务相关字段 * 更新user表中,任务相关字段
......
This diff is collapsed.
This diff is collapsed.
...@@ -213,7 +213,7 @@ var UserService = /** @class */ (function (_super) { ...@@ -213,7 +213,7 @@ var UserService = /** @class */ (function (_super) {
projection.$inc["remainTimes.follow"] = follow.value; projection.$inc["remainTimes.follow"] = follow.value;
} }
newVip = userUpdate_1.isNewVip(userInfo, vipInfo); newVip = userUpdate_1.isNewVip(userInfo, vipInfo);
if (newVip && !userInfo.member.newMember) { if (newVip) {
// @ts-ignore // @ts-ignore
projection.$set.member = this.setNewVipUserData(userInfo.member); projection.$set.member = this.setNewVipUserData(userInfo.member);
projection.$push["taskInfo." + today + ".member"] = { createTime: Date.now() }; projection.$push["taskInfo." + today + ".member"] = { createTime: Date.now() };
......
This diff is collapsed.
...@@ -7,7 +7,6 @@ export * from './common/logger'; ...@@ -7,7 +7,6 @@ export * from './common/logger';
export * from './common/rand'; export * from './common/rand';
export * from './common/getUserOrderlist'; export * from './common/getUserOrderlist';
export * from './common/vip'; export * from './common/vip';
export * from './common/exportHandlers';
export * from './common/helper'; export * from './common/helper';
export * from './common/userUpdate'; export * from './common/userUpdate';
export * from './common/format'; export * from './common/format';
......
...@@ -23,7 +23,6 @@ __exportStar(require("./common/logger"), exports); ...@@ -23,7 +23,6 @@ __exportStar(require("./common/logger"), exports);
__exportStar(require("./common/rand"), exports); __exportStar(require("./common/rand"), exports);
__exportStar(require("./common/getUserOrderlist"), exports); __exportStar(require("./common/getUserOrderlist"), exports);
__exportStar(require("./common/vip"), exports); __exportStar(require("./common/vip"), exports);
__exportStar(require("./common/exportHandlers"), exports);
__exportStar(require("./common/helper"), exports); __exportStar(require("./common/helper"), exports);
__exportStar(require("./common/userUpdate"), exports); __exportStar(require("./common/userUpdate"), exports);
__exportStar(require("./common/format"), exports); __exportStar(require("./common/format"), exports);
......
{"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"} {"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 \ No newline at end of file
/** @format */ /** @format */
<<<<<<< HEAD
import { checkParams, services } from '../decorator/common' import { checkParams, services } from '../decorator/common'
=======
import { services, checkParams, registeInfos } from '../decorator/common'
>>>>>>> e33364a0a782681f36d5822ff2bb1882608c197d
import { resultsModel } from '../sdk' import { resultsModel } from '../sdk'
import { AwardsService } from '../service' import { AwardsService } from '../service'
import { PRIZE_TYPE, DRAW_STATUS, CODE_TYPES } from '../constants' import { PRIZE_TYPE, DRAW_STATUS, CODE_TYPES } from '../constants'
...@@ -8,6 +12,8 @@ import { getToday } from '../utils/' ...@@ -8,6 +12,8 @@ import { getToday } from '../utils/'
import { CodeType } from 'taobao-mini-sdk/lib/utils/codetypes' import { CodeType } from 'taobao-mini-sdk/lib/utils/codetypes'
import preCheck from '../decorator/common/preCheck' import preCheck from '../decorator/common/preCheck'
import { checkActivityTime } from '../utils/common/check/checkActivityTime' import { checkActivityTime } from '../utils/common/check/checkActivityTime'
import { checkPrizeExpired } from '../utils/common/check/checkPrizeExpired'
import { checkValidPrize } from '../utils/common/check/checkValidPrize'
export interface IPrizeListParams { export interface IPrizeListParams {
activityId: string activityId: string
...@@ -30,6 +36,10 @@ export interface IReceiveEnameParams { ...@@ -30,6 +36,10 @@ export interface IReceiveEnameParams {
id: string id: string
} }
export interface IReceivePrizeControllerInfos extends IControllerInfos {
awardInfo: IAwards
}
export default class AwardsController { export default class AwardsController {
/** /**
* 我的奖品列表 * 我的奖品列表
...@@ -69,7 +79,7 @@ export default class AwardsController { ...@@ -69,7 +79,7 @@ export default class AwardsController {
city: 1, city: 1,
area: 1, area: 1,
remark: 1, remark: 1,
useUrk: 1, useUrl: 1,
shipCompany: 1, shipCompany: 1,
shipNum: 1 shipNum: 1
}, },
...@@ -80,7 +90,7 @@ export default class AwardsController { ...@@ -80,7 +90,7 @@ export default class AwardsController {
) )
return resultsModel.success({ return resultsModel.success({
list: awardSer.formateMyPrizeList(myPrizeList, awardReceiveExpiredTime) list: awardSer.formatMyPrizeList(myPrizeList, awardReceiveExpiredTime)
}) })
} }
...@@ -89,21 +99,15 @@ export default class AwardsController { ...@@ -89,21 +99,15 @@ export default class AwardsController {
*/ */
@checkParams(['activityId', 'id', 'name', 'phone', 'province', 'city', 'area', 'addressDetail', 'streetName']) @checkParams(['activityId', 'id', 'name', 'phone', 'province', 'city', 'area', 'addressDetail', 'streetName'])
@services([AwardsService]) @services([AwardsService])
@preCheck([checkPrizeExpired, checkValidPrize([PRIZE_TYPE.OBJECT])])
async receiveObjectPrize( async receiveObjectPrize(
context: IContext<IReceiveOjectParams>, context: IContext<IReceiveOjectParams>,
{ activityInfo }: IControllerInfos, { activityInfo }: IReceivePrizeControllerInfos,
[awardSer]: [AwardsService] [awardSer]: [AwardsService]
): Promise<IResult<boolean>> { ): Promise<IResult<boolean>> {
let { province, city, area, streetName, addressDetail, id, name, phone, activityId } = context.data let { province, city, area, streetName, addressDetail, id, name, phone } = context.data
// 若有过期时间,且已过期
let { awardReceiveExpiredTime } = activityInfo
if (awardReceiveExpiredTime && Date.now() > awardReceiveExpiredTime) {
return resultsModel.error(CODE_TYPES.ERROR_PRIZE_EXPIRED)
}
let result = await awardSer.recieveObjectPrize(id, { let result = await awardSer.recieveObjectPrize(id, {
activityId,
province, province,
city, city,
area, area,
...@@ -123,11 +127,18 @@ export default class AwardsController { ...@@ -123,11 +127,18 @@ export default class AwardsController {
* 权益重新领取 * 权益重新领取
*/ */
@checkParams(['activityId', 'id']) @checkParams(['activityId', 'id'])
@registeInfos(['session'])
@services([AwardsService]) @services([AwardsService])
async receiveEnamePrize(context: IContext<IReceiveEnameParams>, {}, [awardSer]: [AwardsService]) { @preCheck([checkPrizeExpired, checkValidPrize([PRIZE_TYPE.ENAME, PRIZE_TYPE.CREDITS])])
let { id, activityId } = context.data async receiveEnamePrize(
context: IContext<IReceiveEnameParams>,
{ awardInfo, session }: IReceivePrizeControllerInfos,
[awardSer]: [AwardsService]
) {
let { id } = context.data
let result = await awardSer.recieveEnamePrize(id, awardInfo, session)
let result = await awardSer.recieveEnamePrize(id, activityId)
if ((result as CodeType).code) { if ((result as CodeType).code) {
return resultsModel.error(result as CodeType) return resultsModel.error(result as CodeType)
} }
......
...@@ -52,7 +52,7 @@ export default class Share { ...@@ -52,7 +52,7 @@ export default class Share {
): Promise<IResult<boolean>> { ): Promise<IResult<boolean>> {
const { openId } = context const { openId } = context
const result = await taskService.completeTask('invites', inviteUserInfo, activityInfo, { const result = await taskService.completeTask('invites', activityInfo, inviteUserInfo, {
openId openId
}) })
......
This diff is collapsed.
...@@ -36,25 +36,26 @@ export default class User { ...@@ -36,25 +36,26 @@ export default class User {
async getRankList( async getRankList(
context: IContext<{ context: IContext<{
activityId: string activityId: string
key: string // 排序的key值 如 score
timeKey: string // 排序时间的key值 如:updateScoreTime
limit: number
}>, }>,
{ userInfo }: IControllerInfos, { userInfo }: IControllerInfos,
[userService]: [UserService] [userService]: [UserService]
) { ) {
const sortKey = 'score' const { key, timeKey, limit = 200 } = context.data
const sortTime = 'updateScoreTime'
const limit = 200
const { userNick, avatar } = userInfo const { userNick, avatar } = userInfo
const rank = await userService.getMyRank(sortKey, sortTime, userInfo[sortKey]) const rank = await userService.getMyRank(key, timeKey, userInfo[key])
const list = await userService.getRank(sortKey, sortTime, limit) const list = await userService.getRank(key, timeKey, limit)
return resultsModel.success({ return resultsModel.success({
userNick, userNick,
avatar, avatar,
rank, rank,
score: userInfo[sortKey], score: userInfo[key],
list list
}) })
} }
......
/** @format */ /** @format */
import { merge } from 'lodash'
// 检验参数是否存在 // 检验参数是否存在
const update = (checks: IFunction[]) => { const update = (checks: IFunction[]) => {
return function (target: Object, name: string, descriptor: PropertyDescriptor) { return function (target: Object, name: string, descriptor: PropertyDescriptor) {
...@@ -7,17 +9,20 @@ const update = (checks: IFunction[]) => { ...@@ -7,17 +9,20 @@ const update = (checks: IFunction[]) => {
descriptor.value = async function (...args: any[]) { descriptor.value = async function (...args: any[]) {
let [context, otherArgs = {}, services = []] = args let [context, otherArgs = {}, services = []] = args
let totalUpdateProjection: IDecoratorUpdateQuery = {}
for (let i = 0; i < checks.length; i++) { for (let i = 0; i < checks.length; i++) {
const checkFn = checks[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 || {} result = result || {}
// 校验报错 // 校验报错
if ((result as IErrorResult)?.success === false && (result as IErrorResult)?.code) { if ((result as IErrorResult)?.success === false && (result as IErrorResult)?.code) {
return result return result
} }
otherArgs = { ...otherArgs, ...result } totalUpdateProjection = merge({}, totalUpdateProjection, result)
otherArgs = { ...otherArgs }
} }
return method.apply(target, [context, { ...otherArgs }, services]) return method.apply(target, [context, { ...otherArgs }, services])
} }
......
/** @format */ /** @format */
// import { exportHandlers } from './utils'
import UserController from './controller/user.controller' import UserController from './controller/user.controller'
import TaskController from './controller/task.controller' import TaskController from './controller/task.controller'
import BaseController from './controller/base.controller' import BaseController from './controller/base.controller'
...@@ -15,12 +14,8 @@ const { login } = new LoginController() ...@@ -15,12 +14,8 @@ const { login } = new LoginController()
const { const {
getTaskList, getTaskList,
receiveTaskRewards, receiveTaskRewards,
getCollectGoodsList, // 获取收藏商品列表,包含收藏状态 doCompleteTask,
doFollowTask, getCollectGoodsList // 获取收藏商品列表,包含收藏状态
doJumpLinkTask,
doBrowseGoodsTask,
doCollectGoodsTask,
doExchangeCreditsTask
} = new TaskController() } = new TaskController()
const { getActivityBaseInfoById, getItemListByItemIds } = new BaseController() const { getActivityBaseInfoById, getItemListByItemIds } = new BaseController()
...@@ -35,6 +30,7 @@ export default { ...@@ -35,6 +30,7 @@ export default {
login, login,
getVipInfo, getVipInfo,
getTaskList, getTaskList,
doCompleteTask,
receiveTaskRewards, receiveTaskRewards,
getActivityBaseInfoById, getActivityBaseInfoById,
getMyPrizeList, getMyPrizeList,
......
...@@ -114,7 +114,7 @@ export default class AwardsService extends UserService { ...@@ -114,7 +114,7 @@ export default class AwardsService extends UserService {
return await this.awardsdao.find<IAwards>(query, projection) return await this.awardsdao.find<IAwards>(query, projection)
} }
formateMyPrizeList(myPrizeList: IAwards[], awardReceiveExpiredTime?: number) { formatMyPrizeList(myPrizeList: IAwards[], awardReceiveExpiredTime?: number) {
const now = Date.now() const now = Date.now()
return myPrizeList.map(v => { return myPrizeList.map(v => {
if ( if (
...@@ -137,7 +137,6 @@ export default class AwardsService extends UserService { ...@@ -137,7 +137,6 @@ export default class AwardsService extends UserService {
async recieveObjectPrize( async recieveObjectPrize(
_id: string, _id: string,
{ {
activityId,
province, province,
city, city,
area, area,
...@@ -146,7 +145,6 @@ export default class AwardsService extends UserService { ...@@ -146,7 +145,6 @@ export default class AwardsService extends UserService {
name, name,
phone phone
}: { }: {
activityId: string
province: string province: string
city: string city: string
area: string area: string
...@@ -156,20 +154,6 @@ export default class AwardsService extends UserService { ...@@ -156,20 +154,6 @@ export default class AwardsService extends UserService {
phone: string | number phone: string | number
} }
) { ) {
let award = await this.awardsdao.findOne<IAwards>({ _id })
console.log(`receiveObject-award`, award)
// 奖品不存在
if (!award) {
return CODE_TYPES.ERROR_NO_PRIZE
}
// 已领取
if (award.drawStatus === DRAW_STATUS.SUCCESS) {
return CODE_TYPES.ERROR_RECEIVE_PRIZE
}
// 不是实物,非法操作
if (award.type !== PRIZE_TYPE.OBJECT) {
return CODE_TYPES.ERROR_FORBIDDEN_OPE
}
let result = await this.awardsdao.update( let result = await this.awardsdao.update(
{ _id }, { _id },
{ {
...@@ -192,29 +176,9 @@ export default class AwardsService extends UserService { ...@@ -192,29 +176,9 @@ export default class AwardsService extends UserService {
} }
// 发放淘宝权益(奖品数据已插入到awards_info表,且状态drawStatus 为1或者6) // 发放淘宝权益(奖品数据已插入到awards_info表,且状态drawStatus 为1或者6)
async recieveEnamePrize(_id: string, activityId: string) { async recieveEnamePrize(_id: string, awardInfo: IAwards, session: string) {
// 若有过期时间,且已过期
let { awardReceiveExpiredTime } = await this.getBaseInfo(activityId)
if (awardReceiveExpiredTime && Date.now() > awardReceiveExpiredTime) {
return CODE_TYPES.ERROR_PRIZE_EXPIRED
}
let award = await this.awardsdao.findOne<IAwards>({ _id })
// 奖品不存在
if (!award) {
return CODE_TYPES.ERROR_NO_PRIZE
}
// 已领取
if (award.drawStatus === DRAW_STATUS.SUCCESS) {
return CODE_TYPES.ERROR_RECEIVE_PRIZE
}
console.log(`award.drawStatus`, award.drawStatus)
// 状态不是1,6
if (![DRAW_STATUS.WAITAWARD, DRAW_STATUS.RETRY].includes(award.drawStatus)) {
return CODE_TYPES.ERROR_FORBIDDEN_OPE
}
let { session } = await getSellerSession(this.context)
// 发放淘宝权益 // 发放淘宝权益
let result = await sendTBAward(this.context, session, award) let result = await sendTBAward(this.context, session, awardInfo)
// 更新 // 更新
await this.awardsdao.update( await this.awardsdao.update(
{ _id }, { _id },
......
...@@ -18,7 +18,7 @@ import { ...@@ -18,7 +18,7 @@ import {
isNewVip isNewVip
} from '../utils' } from '../utils'
import { TASK_RATE_TYPE, TASK_STATUS } from '../constants' import { TASK_RATE_TYPE, TASK_STATUS } from '../constants'
import { getTodayCompleteTask, getCompleteTaskByUserTaskInfo } from '../utils/common/task' import { getTodayCompleteTask, getTotalCompleteTask, setTaskStatus } from '../utils/common/task'
export interface ITaskInfo { export interface ITaskInfo {
taskType?: string // 任务类型 taskType?: string // 任务类型
...@@ -42,19 +42,16 @@ export default class TaskService extends UserService { ...@@ -42,19 +42,16 @@ export default class TaskService extends UserService {
* *
* @param {ITaskType} taskType 任务类型 * @param {ITaskType} taskType 任务类型
* @param {string} title 任务标题 * @param {string} title 任务标题
* @param {ITasks} tasks 任务配置 * @param {IActivityInfo} activityInfo 任务配置
* @param {IUserInfo} userInfo 用户信息 * @param {IUserInfo} userInfo 用户信息
* @return {ITaskInfo} {ITaskInfo} 任务信息 * @return {ITaskInfo} {ITaskInfo} 任务信息
* @memberof TaskService * @memberof TaskService
*/ */
initTask(taskType: ITaskType, title: string, tasks: ITasks, userInfo: IUserInfo): ITaskInfo { initTask(taskType: ITaskType, title: string, activityInfo: IActivityInfo, userInfo: IUserInfo): ITaskInfo {
const { const { value, itemIds = '', taskRateType, times = 1, link = '' } = activityInfo?.tasks?.[taskType] || {}
[taskType]: { value, itemIds = '', taskRateType, times = 1, link = '' }
} = tasks
const { remainTimes } = userInfo const { remainTimes } = userInfo
const { todayCompleteTimes } = getTodayCompleteTask(taskType, userInfo) const { todayCompleteTimes } = getTodayCompleteTask(taskType, userInfo)
const { completeTimes } = getCompleteTaskByUserTaskInfo(taskType, userInfo) const { completeTimes } = getTotalCompleteTask(taskType, userInfo)
return { return {
taskType, taskType,
...@@ -66,17 +63,57 @@ export default class TaskService extends UserService { ...@@ -66,17 +63,57 @@ export default class TaskService extends UserService {
url: taskType === 'member' ? generateVipUrl(formatVipCbUrl(this.context)) : link, url: taskType === 'member' ? generateVipUrl(formatVipCbUrl(this.context)) : link,
todayCompleteTimes, todayCompleteTimes,
completeTimes, completeTimes,
status: this.setTaskStatus(userInfo, taskType, taskRateType, times), status: setTaskStatus(userInfo, taskType, taskRateType, times),
waitReceive: remainTimes[taskType] waitReceive: remainTimes?.[taskType]
} }
} }
async completeTask(taskType: ITaskType, userInfo: IUserInfo, activityInfo: IActivityInfo, customRecord: object = {}) { /**
*
* 领取任务奖励
*
* @param {ITaskType} taskType
* @param {string} awardsTargetKey
* @param {IUserInfo} userInfo
* @return {number} rewards
* @memberof TaskService
*/
async receiveTaskRewards(taskType: ITaskType, awardsTargetKey: string, userInfo: IUserInfo): Promise<number> {
const waitReceiveTimes = userInfo?.remainTimes?.[taskType]
await this.updateUser(userInfo._id, {
$set: {
[`remainTimes.${taskType}`]: 0
},
$inc: {
[awardsTargetKey]: waitReceiveTimes
}
})
return waitReceiveTimes
}
/**
*根据任务类型更新任务待领取次数和任务记录
*
* @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 today = getToday()
const rewards = activityInfo?.tasks?.[taskType]?.value || 0 const rewards = activityInfo?.tasks?.[taskType]?.value || 0
return await this.updateUser(userInfo._id, { return await this.updateUser(userInfo._id, {
$inc: { $inc: {
'remainTimes.invites': rewards [`remainTimes.${taskType}`]: rewards
}, },
$push: { $push: {
[`taskInfo.${today}.${taskType}`]: { ...customRecord, createTime: Date.now() } [`taskInfo.${today}.${taskType}`]: { ...customRecord, createTime: Date.now() }
...@@ -84,45 +121,13 @@ export default class TaskService extends UserService { ...@@ -84,45 +121,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) { async updateOrderGoodsTask(userInfo: IUserInfo, tasks: ITasks, activityStartTime: number, session?: string) {
const taskType = 'orderGoods' const taskType = 'orderGoods'
const { const {
[taskType]: { value, itemIds, taskRateType, times } [taskType]: { value, itemIds, taskRateType, times }
} = tasks } = tasks
const { completeTimes, taskInfo } = getCompleteTaskByUserTaskInfo(taskType, userInfo) const { completeTimes, taskInfo } = getTotalCompleteTask(taskType, userInfo)
const { todayCompleteTimes } = getTodayCompleteTask(taskType, userInfo) const { todayCompleteTimes } = getTodayCompleteTask(taskType, userInfo)
// 永久任务且已完成 // 永久任务且已完成
if (taskRateType === TASK_RATE_TYPE.FOREVER && completeTimes) { if (taskRateType === TASK_RATE_TYPE.FOREVER && completeTimes) {
...@@ -199,106 +204,6 @@ export default class TaskService extends UserService { ...@@ -199,106 +204,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表中,任务相关字段 * 更新user表中,任务相关字段
......
...@@ -127,7 +127,7 @@ class UserService extends BaseService { ...@@ -127,7 +127,7 @@ class UserService extends BaseService {
// 之前进入活动非会员,现在进入会员,则视为新会员用户 // 之前进入活动非会员,现在进入会员,则视为新会员用户
const newVip = isNewVip(userInfo, vipInfo) const newVip = isNewVip(userInfo, vipInfo)
if (newVip && !userInfo.member.newMember) { if (newVip) {
// @ts-ignore // @ts-ignore
projection.$set.member = this.setNewVipUserData(userInfo.member) projection.$set.member = this.setNewVipUserData(userInfo.member)
projection.$push[`taskInfo.${today}.member`] = { createTime: Date.now() } projection.$push[`taskInfo.${today}.member`] = { createTime: Date.now() }
......
...@@ -109,18 +109,21 @@ interface IUpdateQuery { ...@@ -109,18 +109,21 @@ interface IUpdateQuery {
$set?: { [key: string]: any } $set?: { [key: string]: any }
$setOnInsert?: { [key: string]: any } $setOnInsert?: { [key: string]: any }
$unset?: { [key: string]: any } $unset?: { [key: string]: any }
$addToSet?: { [key: string]: any } $addToSet?: { [key: string]: any }
$pop?: { [key: string]: any } $pop?: { [key: string]: any }
$pull?: { [key: string]: any } $pull?: { [key: string]: any }
$push?: { [key: string]: any } $push?: { [key: string]: any }
$pullAll?: { [key: string]: any }
$bit?: { $bit?: {
[key: string]: { [key in 'and' | 'or' | 'xor']?: number } [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 { interface IFindProjection {
projection?: { projection?: {
[key: string]: number | boolean | any [key: string]: number | boolean | any
......
...@@ -44,3 +44,5 @@ interface IVipInfo { ...@@ -44,3 +44,5 @@ interface IVipInfo {
} }
type IFunction = (...args: any[]) => any type IFunction = (...args: any[]) => any
type ValueOf<T> = T extends any[] ? T[number] : T[keyof T]
/** @format */
import { resultsModel, TBAPIS } from '../../../sdk'
import { CODE_TYPES } from '../../../errorCode'
export const checkExchangeCreditsTask = async (
context: IContext<{ activityId: string; taskType: ITaskType; credits?: number }>,
{ session }: IControllerInfos
) => {
const { taskType, credits } = context.data
// 不是兑换积分类型不校验
if (taskType !== 'exchangeCredits') return
if (taskType === 'exchangeCredits' && !credits) resultsModel.error(CODE_TYPES.PARAMS_ERROR, '缺少credits字段')
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)
}
...@@ -14,6 +14,7 @@ export const checkInviteId = async (context: IContext<{ activityId: string; invi ...@@ -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) if (openId === inviteId) return resultsModel.error(CODE_TYPES.ERROR_NO_INVITE_SELF)
// 获取邀请者信息
const inviteUserInfo = await dbFindOne<IUserInfo>(context, USER_DB_NAME, { const inviteUserInfo = await dbFindOne<IUserInfo>(context, USER_DB_NAME, {
activityId, activityId,
openId: inviteId openId: inviteId
......
...@@ -4,11 +4,6 @@ import { resultsModel } from '../../../sdk' ...@@ -4,11 +4,6 @@ import { resultsModel } from '../../../sdk'
import { CODE_TYPES } from '../../../errorCode' import { CODE_TYPES } from '../../../errorCode'
export const checkNewVip = async (context: IContext<IParams>, { vipInfo, userInfo }: IControllerInfos) => { export const checkNewVip = async (context: IContext<IParams>, { vipInfo, userInfo }: IControllerInfos) => {
const {
openId,
data: { activityId, inviteId }
} = context
if (!vipInfo) { if (!vipInfo) {
console.error(`使用checkNewVip registeInfos必须注册vipInfo`) console.error(`使用checkNewVip registeInfos必须注册vipInfo`)
} }
......
/** @format */
import { resultsModel } from '../../../sdk'
import { CODE_TYPES } from '../../../errorCode'
export const checkPrizeExpired = async (context: IContext<IParams>, { activityInfo }: IControllerInfos) => {
// 若有过期时间,且已过期
let { awardReceiveExpiredTime } = activityInfo
if (awardReceiveExpiredTime && Date.now() > awardReceiveExpiredTime) {
return resultsModel.error(CODE_TYPES.ERROR_PRIZE_EXPIRED)
}
}
/** @format */
import { resultsModel } from '../../../sdk'
import { CODE_TYPES } from '../../../errorCode'
export const checkRemainTimes = async (context: IContext<{ taskType: ITaskType }>, { userInfo }: IControllerInfos) => {
const { taskType } = context.data
const { remainTimes } = userInfo
// 暂无领取次数
if (!remainTimes?.[taskType]) return resultsModel.error(CODE_TYPES.ERROR_TASK_NORECEIVE)
}
/** @format */ /** @format */
export const checkTaskLimit = (taskType: ITaskType) => { import { resultsModel } from '../../../sdk'
return async function (context: IContext<IParams>, { activityInfo, userInfo }: IControllerInfos) { import { CODE_TYPES } from '../../../errorCode'
const { import { getTodayCompleteTask, getTotalCompleteTask } from '../task'
tasks: { import { TASK_RATE_TYPE } from '../../../constants'
[taskType]: { value, taskRateType, times }
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不匹配')
} }
} = activityInfo
const {} = userInfo 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, '今日该商品任务已完成')
} }
} }
/** @format */
import { resultsModel } from '../../../sdk'
import { CODE_TYPES } from '../../../errorCode'
import { DRAW_STATUS } from '../../../constants'
import { dbFindOne } from '../db'
import { AWARDS_DB_NAME } from '../../../db'
export const checkValidPrize = (prizeTypes: number[]) => {
return async (context: IContext<{ id: string }>, { activityInfo }: IControllerInfos) => {
const { id } = context.data
let awardInfo = await dbFindOne<IAwards>(context, AWARDS_DB_NAME, {
_id: id
})
console.log(`receive-award`, awardInfo)
// 奖品不存在
if (!awardInfo) {
return resultsModel.error(CODE_TYPES.ERROR_NO_PRIZE)
}
// 不是校验的奖品类型,非法操作
if (!prizeTypes.includes(awardInfo.type)) {
return resultsModel.error(CODE_TYPES.ERROR_FORBIDDEN_OPE)
}
// 状态不是1,6
if (![DRAW_STATUS.WAITAWARD, DRAW_STATUS.RETRY].includes(awardInfo.drawStatus)) {
return CODE_TYPES.ERROR_FORBIDDEN_OPE
}
return {
awardInfo
}
}
}
/** @format */ /** @format */
import { BaseDao } from '../../sdk' import { BaseDao } from '../../sdk'
/** @format */
export async function dbFindOne<T>(context: IContext<IParams>, dbName: string, query: IMongoQuery) { export async function dbFindOne<T>(context: IContext<IParams>, dbName: string, query: IMongoQuery) {
const dao: IBaseDao = new BaseDao(context, dbName) const dao: IBaseDao = new BaseDao(context, dbName)
......
/** @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
}
/** @format */
import { assign, isEmpty, merge } from 'lodash'
/** /**
* updateUser projection 格式化 * updateUser projection 格式化
* *
...@@ -6,7 +10,6 @@ ...@@ -6,7 +10,6 @@
* @return {*} * @return {*}
* @memberof UserService * @memberof UserService
*/ */
export function formatUpdateUserProjection(projection: IUpdateQuery): IUpdateQuery { export function formatUpdateUserProjection(projection: IUpdateQuery): IUpdateQuery {
projection['$set'] = projection['$set'] || {} projection['$set'] = projection['$set'] || {}
projection['$set'].updateTime = Date.now() projection['$set'].updateTime = Date.now()
...@@ -31,3 +34,25 @@ export function formatUserNick(name: string) { ...@@ -31,3 +34,25 @@ export function formatUserNick(name: string) {
} }
return newStr 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)
}
}
...@@ -13,35 +13,31 @@ import { CodeType } from 'taobao-mini-sdk/lib/utils/codetypes' ...@@ -13,35 +13,31 @@ import { CodeType } from 'taobao-mini-sdk/lib/utils/codetypes'
export const sendTBAward = async ( export const sendTBAward = async (
context: IContext<IParams>, context: IContext<IParams>,
session: string, session: string,
document: IAwards awardInfo: IAwards
): Promise<IAwards | CodeType> => { ): Promise<IAwards | CodeType> => {
let { type, ename, _id, credits } = document let { type, ename, _id, credits } = awardInfo
if (!type) { if (!type) {
return CODE_TYPES.PARAMS_ERROR return CODE_TYPES.PARAMS_ERROR
} }
if (type === PRIZE_TYPE.OBJECT) { if (type === PRIZE_TYPE.OBJECT) {
return document return awardInfo
} }
// 发奖
try {
console.log(`type`, type) console.log(`type`, type)
// 若中奖为权益 // 若中奖为权益
if (type === PRIZE_TYPE.ENAME) { if (type === PRIZE_TYPE.ENAME) {
console.log(`中权益`) console.log(`中权益`)
let { drawStatus, remark } = await sendEname(ename, _id, session, context) let { drawStatus, remark } = await sendEname(ename, _id, session, context)
console.log(`drawStatus, remark`, drawStatus, remark) console.log(`drawStatus, remark`, drawStatus, remark)
document.drawStatus = drawStatus awardInfo.drawStatus = drawStatus
document.remark = remark awardInfo.remark = remark
} else if (type === PRIZE_TYPE.CREDITS) {
let { drawStatus, remark } = await sendCredits(credits, session, context)
document.drawStatus = drawStatus
document.remark = remark
} }
return document if (type === PRIZE_TYPE.CREDITS) {
} catch (e) { let { drawStatus, remark } = await sendCredits(credits, session, context)
console.log(`发奖错误`, e) awardInfo.drawStatus = drawStatus
return CODE_TYPES.PARAMS_ERROR awardInfo.remark = remark
} }
return awardInfo
} }
/** /**
......
/** @format */ /** @format */
import { getToday } from './getToday' import { getToday } from './getToday'
import { TASK_STATUS, TASK_RATE_TYPE } from '../../constants'
/** /**
* 根据任务类型获取任务完成情况 * 根据任务类型获取任务完成情况
...@@ -10,7 +11,7 @@ import { getToday } from './getToday' ...@@ -10,7 +11,7 @@ import { getToday } from './getToday'
* @returns {array} * @returns {array}
* @memberof TaskService * @memberof TaskService
*/ */
export function getCompleteTaskByUserTaskInfo( export function getTotalCompleteTask(
taskType: string, taskType: string,
userInfo: IUserInfo userInfo: IUserInfo
): { ): {
...@@ -57,3 +58,42 @@ export function getTodayCompleteTask( ...@@ -57,3 +58,42 @@ export function getTodayCompleteTask(
todayTaskInfo: userInfo?.taskInfo?.[today]?.[taskType] || [] 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
}
}
...@@ -3,35 +3,30 @@ ...@@ -3,35 +3,30 @@
import { resultsModel } from '../../../sdk' import { resultsModel } from '../../../sdk'
import { CODE_TYPES } from '../../../errorCode' import { CODE_TYPES } from '../../../errorCode'
import { dbCount } from '../../common/db' 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 { getToday } from '../getToday'
import { isNewVip, setNewVipUserData } from '../userUpdate' 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 let { member } = userInfo
const { newMember } = member
const today = getToday()
const newVip = isNewVip(userInfo, vipInfo)
const memberReWards = activityInfo?.tasks?.member?.value const memberReWards = activityInfo?.tasks?.member?.value
let projection = { return isNewVip(userInfo, vipInfo)
$set: {}, ? {
$inc: {}, $set: {
$push: {} member: setNewVipUserData(member)
} },
$inc: {
if (newVip && !newMember) { 'remainTimes.member': +memberReWards
member = setNewVipUserData(member) },
$push: {
// @ts-ignore [`taskInfo.${getToday()}.member`]: { creatTime: Date.now() }
projection.$set.member = member
projection.$inc['remainTimes.member'] = +memberReWards
projection.$push[`taskInfo.${today}.member`] = {
creatTime: Date.now()
} }
} }
return projection : {}
} }
...@@ -18,7 +18,7 @@ export function isNewVip(userInfo: IUserInfo, vipInfo: IVipInfo): boolean { ...@@ -18,7 +18,7 @@ export function isNewVip(userInfo: IUserInfo, vipInfo: IVipInfo): boolean {
const { isVip } = vipInfo const { isVip } = vipInfo
return !flag && isVip return !flag && isVip && !userInfo.member.newMember
} }
export function setNewVipUserData(member: IMemberInfo): IMemberInfo { export function setNewVipUserData(member: IMemberInfo): IMemberInfo {
......
...@@ -20,8 +20,6 @@ export * from './common/getUserOrderlist' ...@@ -20,8 +20,6 @@ export * from './common/getUserOrderlist'
export * from './common/vip' export * from './common/vip'
export * from './common/exportHandlers'
export * from './common/helper' export * from './common/helper'
export * from './common/userUpdate' export * from './common/userUpdate'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment