Commit d2813b8e authored by maggie's avatar maggie

save

parents 3d277a1e e33364a0
......@@ -19,6 +19,9 @@ export interface IReceiveEnameParams {
activityId: string;
id: string;
}
export interface IReceivePrizeControllerInfos extends IControllerInfos {
awardInfo: IAwards;
}
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");
var utils_1 = require("../utils/");
var preCheck_1 = require("../decorator/common/preCheck");
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 () {
function AwardsController() {
}
......@@ -88,7 +90,7 @@ var AwardsController = /** @class */ (function () {
city: 1,
area: 1,
remark: 1,
useUrk: 1,
useUrl: 1,
shipCompany: 1,
shipNum: 1
},
......@@ -99,7 +101,7 @@ var AwardsController = /** @class */ (function () {
case 1:
myPrizeList = _c.sent();
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 () {
var activityInfo = _a.activityInfo;
var awardSer = _b[0];
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) {
switch (_d.label) {
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;
awardReceiveExpiredTime = activityInfo.awardReceiveExpiredTime;
if (awardReceiveExpiredTime && Date.now() > awardReceiveExpiredTime) {
return [2 /*return*/, sdk_1.resultsModel.error(constants_1.CODE_TYPES.ERROR_PRIZE_EXPIRED)];
}
_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;
return [4 /*yield*/, awardSer.recieveObjectPrize(id, {
activityId: activityId,
province: province,
city: city,
area: area,
......@@ -145,16 +142,17 @@ var AwardsController = /** @class */ (function () {
* 权益重新领取
*/
AwardsController.prototype.receiveEnamePrize = function (context, _a, _b) {
var awardInfo = _a.awardInfo, session = _a.session;
var awardSer = _b[0];
return __awaiter(this, void 0, void 0, function () {
var _c, id, activityId, result;
return __generator(this, function (_d) {
switch (_d.label) {
var id, result;
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
_c = context.data, id = _c.id, activityId = _c.activityId;
return [4 /*yield*/, awardSer.recieveEnamePrize(id, activityId)];
id = context.data.id;
return [4 /*yield*/, awardSer.recieveEnamePrize(id, awardInfo, session)];
case 1:
result = _d.sent();
result = _c.sent();
if (result.code) {
return [2 /*return*/, sdk_1.resultsModel.error(result)];
}
......@@ -252,13 +250,16 @@ var AwardsController = /** @class */ (function () {
__decorate([
common_1.checkParams(['activityId', 'id', 'name', 'phone', 'province', 'city', 'area', 'addressDetail', 'streetName']),
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:paramtypes", [Object, Object, Array]),
__metadata("design:returntype", Promise)
], AwardsController.prototype, "receiveObjectPrize", null);
__decorate([
common_1.checkParams(['activityId', 'id']),
common_1.registeInfos(['session']),
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:paramtypes", [Object, Object, Array]),
__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;6BACj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U,YAAA;4BACV,UAAU,EAAE,uBAAW,CAAC,SAAS;4BACjC,aAAa,eAAA;4BACb,MAAM,EAAE,EAAE;4BACV,MAAM,QAAA;4BACN,IAAI,MAAA;4BACJ,KAAK,OAAA;4BACL,IAAI,MAAA;4BACJ,KAAK,OAAA;4BACL,QAAQ,UAAA;4BACR,SAAS,EAAE,gBAAQ,EAAE;yBACtB,CAAA;wBAGc,qBAAM,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAA;;wBAAxC,MAAM,GAAG,SAA+B;wBAE9C,sBAAO,kBAAY,CAAC,OAAO,CAAC;gCAC1B,EAAE,EAAE,MAAM;gCACV,IAAI,MAAA;gCACJ,IAAI,MAAA;gCACJ,KAAK,OAAA;6BACN,CAAC,EAAA;;;;KACH;IA5KD;QAFC,oBAAW,CAAC,CAAC,YAAY,CAAC,CAAC;QAC3B,iBAAQ,CAAC,CAAC,uBAAa,CAAC,CAAC;;;;0DA+CzB;IAOD;QAFC,oBAAW,CAAC,CAAC,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,YAAY,CAAC,CAAC;QAC7G,iBAAQ,CAAC,CAAC,uBAAa,CAAC,CAAC;;;;8DA6BzB;IAOD;QAFC,oBAAW,CAAC,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;QACjC,iBAAQ,CAAC,CAAC,uBAAa,CAAC,CAAC;;;;6DAYzB;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,AAnLD,IAmLC;kBAnLoB,gBAAgB"}
\ No newline at end of file
{"version":3,"file":"awards.controller.js","sourceRoot":"","sources":["../../src/controller/awards.controller.ts"],"names":[],"mappings":";AAAA,c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U,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;;;;8DAsBnE;IASD;QAJC,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
......@@ -88,7 +88,7 @@ var Share = /** @class */ (function () {
switch (_c.label) {
case 0:
openId = context.openId;
return [4 /*yield*/, taskService.completeTask('invites', inviteUserInfo, activityInfo, {
return [4 /*yield*/, taskService.completeTask('invites', activityInfo, inviteUserInfo, {
openId: openId
})];
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,oBADY,CACZ;gBAEZ,sBAAO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C;;;;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
......@@ -7,39 +7,33 @@ export default class Task {
*/
getTaskList(context: IContext<{
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;
}>, { 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>>;
taskType: ITaskType;
itemId?: string;
credits?: number;
}>, { 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;
}>>;
/**
* 获取收藏商品列表
*/
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;
itemId: string;
name: string;
......
......@@ -63,6 +63,11 @@ var sdk_1 = require("../sdk");
var service_1 = require("../service");
var checkActivityTime_1 = require("../utils/common/check/checkActivityTime");
var task_1 = require("../utils/common/task");
var update_1 = require("../decorator/common/update");
var updateVip_1 = require("../utils/common/update/updateVip");
var checkTaskLimit_1 = require("../utils/common/check/checkTaskLimit");
var checkExchangeCreditsTask_1 = require("../utils/common/check/checkExchangeCreditsTask");
var checkRemainTimes_1 = require("../utils/common/check/checkRemainTimes");
var Task = /** @class */ (function () {
function Task() {
}
......@@ -70,228 +75,43 @@ var Task = /** @class */ (function () {
* 任务列表
*/
Task.prototype.getTaskList = function (context, _a, _b) {
var userInfo = _a.userInfo, vipInfo = _a.vipInfo, activityInfo = _a.activityInfo;
var userInfo = _a.userInfo, activityInfo = _a.activityInfo;
var taskService = _b[0];
return __awaiter(this, void 0, void 0, function () {
var tasks, startTime, updatedUserInfo;
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
tasks = activityInfo.tasks, startTime = activityInfo.startTime;
return [4 /*yield*/, taskService.updateTasks(userInfo._id,
// 需要查询更新的任务
[
taskService.updateVipTask(userInfo, vipInfo, tasks)
// taskService.updateSignTask(userInfo, tasks),
// await taskService.updateOrderGoodsTask(userInfo, tasks, startTime, session)
], userInfo)];
case 1:
updatedUserInfo = _c.sent();
if (!updatedUserInfo)
return [2 /*return*/, sdk_1.resultsModel.error(constants_1.CODE_TYPES.SYSTEM_ERROR, '更新任务列表失败')
// 返回对应的任务时, B端b_activity_config tasks 需配置对应的任务
];
// 返回对应的任务时, B端b_activity_config tasks 需配置对应的任务
return [2 /*return*/, sdk_1.resultsModel.success([
taskService.initTask('member', '加入会员', tasks, updatedUserInfo),
taskService.initTask('follow', '关注店铺', tasks, updatedUserInfo)
// taskService.initTask('sign', '签到', tasks, updatedUserInfo),
// taskService.initTask('orderGoods', '购买商品', tasks, updatedUserInfo),
// taskService.initTask('browseGoods', '浏览商品', tasks, updatedUserInfo),
// taskService.initTask('collectGoods', '收藏商品', tasks, updatedUserInfo),
// taskService.initTask('jumpLink', '浏览页面', tasks, updatedUserInfo),
// taskService.initTask('invites', '邀请好友', tasks, updatedUserInfo),
// taskService.initTask('exchangeCredits', '积分兑换', tasks, updatedUserInfo)
])];
}
return [2 /*return*/, sdk_1.resultsModel.success([
taskService.initTask('member', '加入会员', activityInfo, userInfo),
taskService.initTask('follow', '关注店铺', activityInfo, userInfo)
// taskService.initTask('sign', '签到', activityInfo, userInfo),
// taskService.initTask('orderGoods', '购买商品', activityInfo, userInfo),
// taskService.initTask('browseGoods', '浏览商品', activityInfo, userInfo),
// taskService.initTask('collectGoods', '收藏商品', activityInfo, userInfo),
// taskService.initTask('jumpLink', '浏览页面', activityInfo, userInfo),
// taskService.initTask('invites', '邀请好友', activityInfo, userInfo)
// taskService.initTask('exchangeCredits', '积分兑换', activityInfo, updatedUserInfo)
])];
});
});
};
/**
* 完成关注店铺任务
* 完成任务
*
* 商品相关任务 需要传itemId参数
* 积分兑换任务 需要传credits参数
*/
Task.prototype.doFollowTask = function (context, _a, _b) {
Task.prototype.doCompleteTask = function (context, _a, _b) {
var userInfo = _a.userInfo, activityInfo = _a.activityInfo;
var TaskService = _b[0];
return __awaiter(this, void 0, void 0, function () {
var follow, flag, newFollow, hasFollowed, result;
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
follow = userInfo.follow;
flag = follow.flag, newFollow = follow.newFollow;
hasFollowed = flag || newFollow;
if (hasFollowed)
return [2 /*return*/, sdk_1.resultsModel.error(constants_1.CODE_TYPES.ERROR_TASK_COMPLETE)
// 更新状态
];
return [4 /*yield*/, TaskService.updateFollowTask(userInfo, activityInfo)];
case 1:
result = _c.sent();
return [2 /*return*/, result ? sdk_1.resultsModel.success(true) : sdk_1.resultsModel.error(constants_1.CODE_TYPES.SYSTEM_ERROR)];
}
});
});
};
/**
* 积分兑换次数
*/
Task.prototype.doExchangeCreditsTask = function (context, _a, _b) {
var userInfo = _a.userInfo, activityInfo = _a.activityInfo, session = _a.session;
var taskService = _b[0];
return __awaiter(this, void 0, void 0, function () {
var credits, taskType, _c, value, times, taskRateType, todayCompleteTimes, myCredits, result;
var _c, taskType, itemId, result;
return __generator(this, function (_d) {
switch (_d.label) {
case 0:
credits = context.data.credits;
taskType = "exchangeCredits";
_c = activityInfo.tasks.exchangeCredits, value = _c.value, times = _c.times, taskRateType = _c.taskRateType;
todayCompleteTimes = task_1.getTodayCompleteTask(taskType, userInfo).todayCompleteTimes;
// 如果每日限制次数并到达了限制次数
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)];
}
return [4 /*yield*/, sdk_1.TBAPIS.queryCredits(context, session)];
_c = context.data, taskType = _c.taskType, itemId = _c.itemId;
return [4 /*yield*/, taskService.completeTask(taskType, activityInfo, userInfo, { itemId: itemId })];
case 1:
myCredits = _d.sent();
console.log('myCredits', myCredits);
// 积分不足
if (myCredits < credits)
return [2 /*return*/, sdk_1.resultsModel.error(constants_1.CODE_TYPES.ERROR_NO_CREDITS)
// 扣积分
];
return [4 /*yield*/, sdk_1.TBAPIS.changeCredits(context, session, {
quantity: +credits,
change_type: 2,
opt_type: 1,
remark: "\u79EF\u5206\u5151\u6362\u4EFB\u52A1\u51CF\u79EF\u5206"
})];
case 2:
result = _d.sent();
if (!result)
return [2 /*return*/, sdk_1.resultsModel.error(constants_1.CODE_TYPES.SYSTEM_ERROR)
// 更新user表
];
// 更新user表
return [4 /*yield*/, taskService.updateUserTaskRecord(taskType, value, userInfo)];
case 3:
// 更新user表
_d.sent();
return [2 /*return*/, sdk_1.resultsModel.success(true)];
}
});
});
};
/**
* 浏览商品
*/
Task.prototype.doBrowseGoodsTask = 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 = 'browseGoods';
itemId = context.data.itemId;
_c = activityInfo.tasks.browseGoods, 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 = task_1.getTodayCompleteTask('browseGoods', userInfo), todayTaskInfo = _d.todayTaskInfo, todayCompleteTimes = _d.todayCompleteTimes;
hasCompleteToday = todayTaskInfo.some(function (v) { return v.itemId === itemId; }) && 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.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 = task_1.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 = task_1.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)];
return [2 /*return*/, result ? sdk_1.resultsModel.success(true) : sdk_1.resultsModel.error(constants_1.CODE_TYPES.SYSTEM_ERROR, '任务完成失败')];
}
});
});
......@@ -303,30 +123,17 @@ var Task = /** @class */ (function () {
var userInfo = _a.userInfo;
var taskService = _b[0];
return __awaiter(this, void 0, void 0, function () {
var awardsTargetKey, taskType, remainTimes, _id, waitReceiveTimes;
var _c, _d;
return __generator(this, function (_e) {
switch (_e.label) {
var rewardsKey, taskType, rewards;
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
awardsTargetKey = "gameTimes";
rewardsKey = context.data.rewardsKey;
taskType = context.data.taskType;
remainTimes = userInfo.remainTimes, _id = userInfo._id;
// 暂无领取次数
if (!(remainTimes === null || remainTimes === void 0 ? void 0 : remainTimes[taskType]))
return [2 /*return*/, sdk_1.resultsModel.error(constants_1.CODE_TYPES.ERROR_TASK_NORECEIVE)];
waitReceiveTimes = remainTimes === null || remainTimes === void 0 ? void 0 : remainTimes[taskType];
return [4 /*yield*/, taskService.updateUser(_id, {
$set: (_c = {},
_c["remainTimes." + taskType] = 0,
_c),
$inc: (_d = {},
_d[awardsTargetKey] = waitReceiveTimes,
_d)
})];
return [4 /*yield*/, taskService.receiveTaskRewards(taskType, rewardsKey, userInfo)];
case 1:
_e.sent();
rewards = _c.sent();
return [2 /*return*/, sdk_1.resultsModel.success({
rewards: waitReceiveTimes
rewards: rewards
})];
}
});
......@@ -337,7 +144,7 @@ var Task = /** @class */ (function () {
*/
Task.prototype.getCollectGoodsList = function (context, _a, _b) {
var session = _a.session, userInfo = _a.userInfo;
var baseService = _b[0], taskService = _b[1];
var baseService = _b[0];
return __awaiter(this, void 0, void 0, function () {
var itemIds, list, taskInfo, listWithCollectStatus;
return __generator(this, function (_c) {
......@@ -347,7 +154,7 @@ var Task = /** @class */ (function () {
return [4 /*yield*/, baseService.getItemListByIds(itemIds, session)];
case 1:
list = _c.sent();
taskInfo = task_1.getCompleteTaskByUserTaskInfo('collectGoods', userInfo).taskInfo;
taskInfo = task_1.getTotalCompleteTask('collectGoods', userInfo).taskInfo;
listWithCollectStatus = list.map(function (v) {
return __assign(__assign({}, v), {
// 完成列表是否含有itemId
......@@ -363,55 +170,24 @@ var Task = /** @class */ (function () {
common_1.registeInfos(['vipInfo']),
common_1.services([service_1.TaskService]),
common_1.preCheck([checkActivityTime_1.checkActivityTime]),
update_1.update([updateVip_1.updateVip]),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, Object, Array]),
__metadata("design:returntype", Promise)
], Task.prototype, "getTaskList", null);
__decorate([
common_1.checkParams(['activityId']),
common_1.services([service_1.TaskService]),
common_1.preCheck([checkActivityTime_1.checkActivityTime]),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, Object, Array]),
__metadata("design:returntype", Promise)
], Task.prototype, "doFollowTask", null);
__decorate([
common_1.checkParams(['activityId', 'credits']),
common_1.checkParams(['activityId', 'taskType']),
common_1.registeInfos(['session']),
common_1.services([service_1.TaskService]),
common_1.preCheck([checkActivityTime_1.checkActivityTime]),
common_1.preCheck([checkActivityTime_1.checkActivityTime, checkTaskLimit_1.checkTaskLimit, checkExchangeCreditsTask_1.checkExchangeCreditsTask]),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, Object, Array]),
__metadata("design:returntype", Promise)
], Task.prototype, "doExchangeCreditsTask", null);
], Task.prototype, "doCompleteTask", null);
__decorate([
common_1.checkParams(['activityId', 'itemId']),
common_1.checkParams(['activityId', 'taskType', 'rewardsKey']),
common_1.services([service_1.TaskService]),
common_1.preCheck([checkActivityTime_1.checkActivityTime]),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, Object, Array]),
__metadata("design:returntype", Promise)
], Task.prototype, "doBrowseGoodsTask", null);
__decorate([
common_1.checkParams(['activityId', 'itemId']),
common_1.services([service_1.TaskService]),
common_1.preCheck([checkActivityTime_1.checkActivityTime]),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, Object, Array]),
__metadata("design:returntype", Promise)
], Task.prototype, "doCollectGoodsTask", null);
__decorate([
common_1.checkParams(['activityId']),
common_1.services([service_1.TaskService]),
common_1.preCheck([checkActivityTime_1.checkActivityTime]),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, Object, Array]),
__metadata("design:returntype", Promise)
], Task.prototype, "doJumpLinkTask", null);
__decorate([
common_1.checkParams(['activityId', 'taskType']),
common_1.services([service_1.TaskService]),
common_1.preCheck([checkActivityTime_1.checkActivityTime]),
common_1.preCheck([checkActivityTime_1.checkActivityTime, checkRemainTimes_1.checkRemainTimes]),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, Object, Array]),
__metadata("design:returntype", Promise)
......@@ -419,7 +195,7 @@ var Task = /** @class */ (function () {
__decorate([
common_1.checkParams(['activityId', 'itemIds']),
common_1.registeInfos(['session']),
common_1.services([service_1.BaseService, service_1.TaskService]),
common_1.services([service_1.BaseService]),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, Object, Array]),
__metadata("design:returntype", Promise)
......
{"version":3,"file":"task.controller.js","sourceRoot":"","sources":["../../src/controller/task.controller.ts"],"names":[],"mappings":";AAAA,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEd,4CAA2D;AAC3D,8CAAmF;AAEnF,8BAA6C;AAC7C,sCAAqD;AAErD,6EAA2E;AAC3E,6CAA0F;AAE1F;IAAA;IAsTA,CAAC;IArTC;;OAEG;IAKG,0BAAW,GAAjB,UACE,OAAyC,EACzC,EAAqD,EACrD,EAA4B;YAD1B,QAAQ,cAAA,EAAE,OAAO,aAAA,EAAE,YAAY,kBAAA;YAChC,WAAW,QAAA;;;;;;wBAEJ,KAAK,GAAgB,YAAY,MAA5B,EAAE,SAAS,GAAK,YAAY,UAAjB,CAAiB;wBAGnB,qBAAM,WAAW,CAAC,WAAW,CACjD,QAAQ,CAAC,GAAG;4BACZ,YAAY;4BACZ;gCACE,WAAW,CAAC,aAAa,CAAC,QAAQ,EAAE,OAAO,EAAE,KAAK,CAAC;gCACnD,+CAA+C;gCAC/C,8EAA8E;6BAC/E,EACD,QAAQ,CACT,EAAA;;wBATG,eAAe,GAAG,SASrB;wBAED,IAAI,CAAC,eAAe;4BAAE,sBAAO,kBAAY,CAAC,KAAK,CAAC,sBAAU,CAAC,YAAY,EAAE,UAAU,CAAC;gCAEpF,+CAA+C;8BAFqC;wBAEpF,+CAA+C;wBAE/C,sBAAO,kBAAY,CAAC,OAAO,CAAC;gCAC1B,WAAW,CAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,eAAe,CAAC;gCAC9D,WAAW,CAAC,QAAQ,CAAC,QAAQ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C,qBAAW,CAAC,CAAC;QACvB,iBAAQ,CAAC,CAAC,qCAAiB,CAAC,CAAC;;;;kDAuC7B;IAQD;QAHC,oBAAW,CAAC,CAAC,YAAY,CAAC,CAAC;QAC3B,iBAAQ,CAAC,CAAC,qBAAW,CAAC,CAAC;QACvB,iBAAQ,CAAC,CAAC,qCAAiB,CAAC,CAAC;;;;8CA+B7B;IAQD;QAHC,oBAAW,CAAC,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;QACvC,iBAAQ,CAAC,CAAC,qBAAW,CAAC,CAAC;QACvB,iBAAQ,CAAC,CAAC,qCAAiB,CAAC,CAAC;;;;kDA8B7B;IAQD;QAHC,oBAAW,CAAC,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC;QACtC,qBAAY,CAAC,CAAC,SAAS,CAAC,CAAC;QACzB,iBAAQ,CAAC,CAAC,qBAAW,EAAE,qBAAW,CAAC,CAAC;;;;mDAoBpC;IACH,WAAC;CAAA,AAtTD,IAsTC;kBAtToB,IAAI"}
\ No newline at end of file
{"version":3,"file":"task.controller.js","sourceRoot":"","sources":["../../src/controller/task.controller.ts"],"names":[],"mappings":";AAAA,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEd,4CAA2C;AAC3C,8CAAmF;AACnF,8BAAqC;AACrC,sCAAqD;AAErD,6EAA2E;AAC3E,6CAA2D;AAC3D,qDAAmD;AACnD,8DAA4D;AAC5D,uEAAqE;AACrE,2FAAyF;AACzF,2EAAyE;AAEzE;IAAA;IA0GA,CAAC;IAzGC;;OAEG;IAMG,0BAAW,GAAjB,UACE,OAAyC,EACzC,EAA4C,EAC5C,EAA4B;YAD1B,QAAQ,cAAA,EAAE,YAAY,kBAAA;YACvB,WAAW,QAAA;;;gBAEZ,sBAAO,kBAAY,CAAC,OAAO,CAAC;wBAC1B,WAAW,CAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,QAA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AW,CAAC,CAAC;QACvB,iBAAQ,CAAC,CAAC,qCAAiB,EAAE,mCAAgB,CAAC,CAAC;;;;kDAkB/C;IAQD;QAHC,oBAAW,CAAC,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC;QACtC,qBAAY,CAAC,CAAC,SAAS,CAAC,CAAC;QACzB,iBAAQ,CAAC,CAAC,qBAAW,CAAC,CAAC;;;;mDAoBvB;IACH,WAAC;CAAA,AA1GD,IA0GC;kBA1GoB,IAAI"}
\ No newline at end of file
......@@ -15,6 +15,9 @@ export default class User {
*/
getRankList(context: IContext<{
activityId: string;
key: string;
timeKey: string;
limit: number;
}>, { userInfo }: IControllerInfos, [userService]: [UserService]): Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result<{
userNick: string;
avatar: string;
......
......@@ -79,25 +79,23 @@ var User = /** @class */ (function () {
var userInfo = _a.userInfo;
var userService = _b[0];
return __awaiter(this, void 0, void 0, function () {
var sortKey, sortTime, limit, userNick, avatar, rank, list;
return __generator(this, function (_c) {
switch (_c.label) {
var _c, key, timeKey, _d, limit, userNick, avatar, rank, list;
return __generator(this, function (_e) {
switch (_e.label) {
case 0:
sortKey = 'score';
sortTime = 'updateScoreTime';
limit = 200;
_c = context.data, key = _c.key, timeKey = _c.timeKey, _d = _c.limit, limit = _d === void 0 ? 200 : _d;
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:
rank = _c.sent();
return [4 /*yield*/, userService.getRank(sortKey, sortTime, limit)];
rank = _e.sent();
return [4 /*yield*/, userService.getRank(key, timeKey, limit)];
case 2:
list = _c.sent();
list = _e.sent();
return [2 /*return*/, sdk_1.resultsModel.success({
userNick: userNick,
avatar: avatar,
rank: rank,
score: userInfo[sortKey],
score: userInfo[key],
list: list
})];
}
......
{"version":3,"file":"user.controller.js","sourceRoot":"","sources":["../../src/controller/user.contro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BACL,CAAC,EAAA;;;;KACH;IAxCD;QAHC,oBAAW,CAAC,CAAC,YAAY,CAAC,CAAC;QAC3B,qBAAY,CAAC,CAAC,SAAS,CAAC,CAAC;QACzB,iBAAQ,CAAC,EAAE,CAAC;;;;0CAUZ;IAOD;QAFC,oBAAW,CAAC,CAAC,YAAY,CAAC,CAAC;QAC3B,iBAAQ,CAAC,CAAC,qBAAW,CAAC,CAAC;;;;2CAyBvB;IACH,WAAC;CAAA,AAhDD,IAgDC;kBAhDoB,IAAI"}
\ No newline at end of file
{"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;IAiDA,CAAC;IAhDC;;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,OAAO,CAAC,MAAM,CAAC,EAAA;;;;KACpC;IAED;;OAEG;IAGG,0BAAW,GAAjB,UACE,OAKE,EACF,EAA8B,EAC9B,EAA4B;YAD1B,QAAQ,cAAA;YACT,WAAW,QAAA;;;;;;wBAEN,KAAgC,OAAO,CAAC,IAAI,EAA1C,GAAG,SAAA,EAAE,OAAO,aAAA,EAAE,aAAW,EAAX,KAAK,mBAAG,GAAG,KAAA,CAAiB;wBAE1C,QAAQ,GAAa,QAAQ,SAArB,EAAE,MAAM,GAAK,QAAQ,OAAb,CAAa;wBAExB,qBAAM,WAAW,CAAC,SAAS,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAA;;wBAA/D,IAAI,GAAG,SAAwD;wBAExD,qBAAM,WAAW,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,CAAC,EAAA;;wBAArD,IAAI,GAAG,SAA8C;wBAE3D,sBAAO,kBAAY,CAAC,OAAO,CAAC;gCAC1B,QAAQ,UAAA;gCACR,MAAM,QAAA;gCACN,IAAI,MAAA;gCACJ,KAAK,EAAE,QAAQ,CAAC,GAAG,CAAC;gCACpB,IAAI,MAAA;6BACL,CAAC,EAAA;;;;KACH;IAzCD;QAHC,oBAAW,CAAC,CAAC,YAAY,CAAC,CAAC;QAC3B,qBAAY,CAAC,CAAC,SAAS,CAAC,CAAC;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
......@@ -6,8 +6,18 @@ declare const _default: {
getVipInfo: (context: IContext<import("./controller/user.controller").IVipParams>, { session, activityUserNick }: IControllerInfos) => Promise<IResult<IVipInfo>>;
getTaskList: (context: IContext<{
activityId: string;
}>, { userInfo, vipInfo, activityInfo }: IControllerInfos, [taskService]: [import("./service").TaskService]) => Promise<IResult<import("./service/task.service").ITaskInfo[]>>;
receiveTaskRewards: (context: IContext<IParams>, { userInfo }: IControllerInfos, [taskService]: [import("./service").TaskService]) => Promise<IResult<{
}>, { userInfo, activityInfo }: IControllerInfos, [taskService]: [import("./service").TaskService]) => Promise<IResult<import("./service/task.service").ITaskInfo[]>>;
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;
}>>;
getActivityBaseInfoById: (context: IContext<{
......@@ -16,16 +26,19 @@ declare const _default: {
getMyPrizeList: (context: IContext<import("./controller/awards.controller").IPrizeListParams>, { activityInfo }: IControllerInfos, [awardSer]: [import("./service").AwardsService]) => Promise<IResult<{
list: IAwards[];
}>>;
receiveObjectPrize: (context: IContext<import("./controller/awards.controller").IReceiveOjectParams>, { activityInfo }: IControllerInfos, [awardSer]: [import("./service").AwardsService]) => Promise<IResult<boolean>>;
receiveEnamePrize: (context: IContext<import("./controller/awards.controller").IReceiveEnameParams>, {}: {}, [awardSer]: [import("./service").AwardsService]) => Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result<string | boolean | object | string[] | object[] | number[], false> | import("taobao-mini-sdk/lib/utils/resultmodel").Result<import("taobao-mini-sdk/lib/utils/codetypes").CodeType | IAwards, true>>;
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>, { 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<{
activityId: string;
inviteId: string;
}>, { userInfo, activityInfo, inviteUserInfo }: import("./controller/share.controller").IdoHelpInfos, [taskService, statService]: [import("./service").TaskService, import("./service").StatService]) => Promise<IResult<boolean>>;
getStats: (context: IContext<import("./controller/stat.controller").IGetStatsParams>) => Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result<string | boolean | object | string[] | object[] | number[], false> | import("taobao-mini-sdk/lib/utils/resultmodel").Result<any, true>>;
getStats: (context: IContext<import("./controller/stat.controller").IGetStatsParams>) => Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result<string | boolean | object | 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>>;
getRankList: (context: IContext<{
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<{
userNick: string;
avatar: string;
......
"use strict";
/** @format */
Object.defineProperty(exports, "__esModule", { value: true });
// import { exportHandlers } from './utils'
var user_controller_1 = require("./controller/user.controller");
var task_controller_1 = require("./controller/task.controller");
var base_controller_1 = require("./controller/base.controller");
......@@ -11,8 +10,8 @@ var stat_controller_1 = require("./controller/stat.controller");
var login_controller_1 = require("./controller/login.controller");
var _a = new user_controller_1.default(), getVipInfo = _a.getVipInfo, getRankList = _a.getRankList;
var login = new login_controller_1.default().login;
var _b = new task_controller_1.default(), getTaskList = _b.getTaskList, receiveTaskRewards = _b.receiveTaskRewards, getCollectGoodsList = _b.getCollectGoodsList, // 获取收藏商品列表,包含收藏状态
doFollowTask = _b.doFollowTask, doJumpLinkTask = _b.doJumpLinkTask, doBrowseGoodsTask = _b.doBrowseGoodsTask, doCollectGoodsTask = _b.doCollectGoodsTask, doExchangeCreditsTask = _b.doExchangeCreditsTask;
var _b = new task_controller_1.default(), getTaskList = _b.getTaskList, receiveTaskRewards = _b.receiveTaskRewards, doCompleteTask = _b.doCompleteTask, getCollectGoodsList = _b.getCollectGoodsList // 获取收藏商品列表,包含收藏状态
;
var _c = new base_controller_1.default(), getActivityBaseInfoById = _c.getActivityBaseInfoById, getItemListByItemIds = _c.getItemListByItemIds;
var _d = new awards_controller_1.default(), getMyPrizeList = _d.getMyPrizeList, receiveObjectPrize = _d.receiveObjectPrize, receiveEnamePrize = _d.receiveEnamePrize, drawLotteryPrize = _d.drawLotteryPrize;
var doHelp = new share_controller_1.default().doHelp;
......@@ -21,6 +20,7 @@ exports.default = {
login: login,
getVipInfo: getVipInfo,
getTaskList: getTaskList,
doCompleteTask: doCompleteTask,
receiveTaskRewards: receiveTaskRewards,
getActivityBaseInfoById: getActivityBaseInfoById,
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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;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
......@@ -21,7 +21,7 @@ export default class AwardsService extends UserService {
*/
sendAward(document: IAwards): Promise<CodeType | IAwards>;
getAwardsInfoList(query: object, projection?: IFindProjection): Promise<IAwards[]>;
formateMyPrizeList(myPrizeList: IAwards[], awardReceiveExpiredTime?: number): {
formatMyPrizeList(myPrizeList: IAwards[], awardReceiveExpiredTime?: number): {
expiredTime: number;
id: string;
_id?: string;
......@@ -50,8 +50,7 @@ export default class AwardsService extends UserService {
updateTime?: number;
awardsType?: string;
}[];
recieveObjectPrize(_id: string, { activityId, province, city, area, streetName, addressDetail, name, phone }: {
activityId: string;
recieveObjectPrize(_id: string, { province, city, area, streetName, addressDetail, name, phone }: {
province: string;
city: string;
area: string;
......@@ -60,7 +59,7 @@ export default class AwardsService extends UserService {
name: string;
phone: string | number;
}): Promise<true | CodeType>;
recieveEnamePrize(_id: string, activityId: string): Promise<CodeType | IAwards>;
recieveEnamePrize(_id: string, awardInfo: IAwards, session: string): Promise<CodeType | IAwards>;
getPrizeConfig(query: {
activityId: string;
[queryParam: string]: any;
......
......@@ -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();
return myPrizeList.map(function (v) {
if (awardReceiveExpiredTime &&
......@@ -210,43 +210,27 @@ var AwardsService = /** @class */ (function (_super) {
};
// 领取实物
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 () {
var award, result;
var result;
return __generator(this, function (_b) {
switch (_b.label) {
case 0: return [4 /*yield*/, this.awardsdao.findOne({ _id: _id })];
case 0: return [4 /*yield*/, this.awardsdao.update({ _id: _id }, {
$set: {
receiveName: name,
phone: phone,
drawStatus: constants_1.DRAW_STATUS.SUCCESS,
shipStatus: constants_1.SHIP_STATUS.NO_SHIP,
province: province,
city: city,
area: area,
streetName: streetName,
addressDetail: addressDetail,
receiveTime: Date.now(),
updateTime: Date.now()
}
})];
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: {
receiveName: name,
phone: phone,
drawStatus: constants_1.DRAW_STATUS.SUCCESS,
shipStatus: constants_1.SHIP_STATUS.NO_SHIP,
province: province,
city: city,
area: area,
streetName: streetName,
addressDetail: addressDetail,
receiveTime: Date.now(),
updateTime: Date.now()
}
})];
case 2:
result = _b.sent();
return [2 /*return*/, result ? true : constants_1.CODE_TYPES.SYSTEM_ERROR];
}
......@@ -254,44 +238,15 @@ var AwardsService = /** @class */ (function (_super) {
});
};
// 发放淘宝权益(奖品数据已插入到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 () {
var awardReceiveExpiredTime, award, session, result;
var result;
return __generator(this, function (_a) {
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:
result = _a.sent();
// 更新
return [4 /*yield*/, this.awardsdao.update({ _id: _id }, {
......@@ -303,7 +258,7 @@ var AwardsService = /** @class */ (function (_super) {
updateTime: Date.now()
}
})];
case 5:
case 2:
// 更新
_a.sent();
return [2 /*return*/, result];
......
{"version":3,"file":"awards.service.js","sourceRoot":"","sources":["../../src/service/awards.service.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,8BAAgC;AAChC,+CAAwC;AACxC,0CAQqB;AACrB,4B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AgB,CAAC,IAAI,YAC/B,YAAY,oBACT,KAAK,EACR,EAAA;;;KACH;IAED,WAAW;IACL,6CAAqB,GAA3B,UAA4B,MAA6B;;;;gBAEjD,WAAW,GAAG,YAAI,CAAC,KAAK,CAAC,CAAA;gBAE/B,sBAAO,MAAM,CAAC,IAAI,CAAC,UAAA,CAAC,IAAI,OAAA,WAAW,IAAI,CAAC,CAAC,WAAW,IAAI,WAAW,IAAI,CAAC,CAAC,aAAa,EAA9D,CAA8D,CAAC,EAAA;;;KACxF;IAED;;;OAGG;IACG,4CAAoB,GAA1B,UAA2B,GAAW;;;;4BAC7B,qBAAM,IAAI,CAAC,gBAAgB,CAAC,OAAO,CACxC,EAAE,GAAG,KAAA,EAAE,YAAY,gBAAwB,EAAE,EAC7C;4BACE,IAAI,EAAE;gCACJ,KAAK,EAAE,CAAC;6BACT;yBACF,CACF,EAAA;4BAPD,sBAAO,SAON,EAAA;;;;KACF;IACH,oBAAC;AAAD,CAAC,AAlPD,CAA2C,sBAAW,GAkPrD"}
\ No newline at end of file
{"version":3,"file":"awards.service.js","sourceRoot":"","sources":["../../src/service/awards.service.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,8BAAgC;AAChC,+CAAwC;AACxC,0CAQqB;AACrB,4BAA4D;AAC5D,kCAA2E;AAG3E;IAA2C,iCAAW;IAGpD,uBAAY,OAA0B;QAAtC,YACE,kBAAM,OAAO,CAAC,SAGf;QAFC,KAAI,CAAC,SAAS,GAAG,IAAI,aAAO,CAAC,OAAO,EAAE,mBAAc,CAAC,CAAA;QACrD,KAAI,CAAC,gBAAgB,GAAG,IAAI,aAAO,CAAC,OAAO,EAAE,yBAAoB,CAAC,CAAA;;IACpE,CAAC;IAED,uBAAuB;IACjB,mCAAW,GAAjB,UAAkB,GAAW;;;;;4BACd,qBAAM,IAAI,CAAC,gBAAgB,CAAC,OAAO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MrD"}
\ No newline at end of file
......@@ -24,18 +24,34 @@ export default class TaskService extends UserService {
*
* @param {ITaskType} taskType 任务类型
* @param {string} title 任务标题
* @param {ITasks} tasks 任务配置
* @param {IActivityInfo} activityInfo 任务配置
* @param {IUserInfo} userInfo 用户信息
* @return {ITaskInfo} {ITaskInfo} 任务信息
* @memberof TaskService
*/
initTask(taskType: ITaskType, title: string, tasks: ITasks, userInfo: IUserInfo): ITaskInfo;
completeTask(taskType: ITaskType, userInfo: IUserInfo, activityInfo: IActivityInfo, customRecord?: object): Promise<number>;
updateVipTask(userInfo: IUserInfo, vipInfo: IVipInfo, tasks: ITasks): {
$set: {};
$inc: {};
$push: {};
};
initTask(taskType: ITaskType, title: string, activityInfo: IActivityInfo, userInfo: IUserInfo): ITaskInfo;
/**
*
* 领取任务奖励
*
* @param {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<{}>;
updateSignTask(userInfo: IUserInfo, tasks: ITasks): {
$inc: {
......@@ -50,38 +66,6 @@ export default class TaskService extends UserService {
$inc?: undefined;
$push?: undefined;
};
/**
*更新关注店铺任务状态
*
* @param {IUserInfo} userInfo
* @param {IActivityInfo} activityInfo
* @returns
* @memberof TaskService
*/
updateFollowTask(userInfo: IUserInfo, activityInfo: IActivityInfo): Promise<number>;
/**
*
* 根据用户和任务完成情况,设置任务状态
*
* @param {IUserInfo} useInfo
* @param {string} taskType
* @param {number} taskRateType
* @param {number} [limitTimesEverday] 每天限制次数 任务频率为每天的时候必填
* @return {taskTatus} 1未完成 2 待领取 3 已完成
* @memberof TaskService
*/
setTaskStatus(useInfo: IUserInfo, taskType: string, taskRateType: number, limitTimesEveryday?: number): number;
/**
*根据任务类型更新任务待领取次数和任务记录
*
* @param {string} taskType
* @param {number} rewards
* @param {IUserInfo} userInfo
* @param {object} [customRecord]
* @returns {boolean}
* @memberof TaskService
*/
updateUserTaskRecord(taskType: string, rewards: number, userInfo: IUserInfo, customRecord?: object): Promise<boolean>;
/**
*
* 更新user表中,任务相关字段
......
......@@ -87,16 +87,17 @@ var TaskService = /** @class */ (function (_super) {
*
* @param {ITaskType} taskType 任务类型
* @param {string} title 任务标题
* @param {ITasks} tasks 任务配置
* @param {IActivityInfo} activityInfo 任务配置
* @param {IUserInfo} userInfo 用户信息
* @return {ITaskInfo} {ITaskInfo} 任务信息
* @memberof TaskService
*/
TaskService.prototype.initTask = function (taskType, title, tasks, userInfo) {
var _a = tasks, _b = taskType, _c = _a[_b], value = _c.value, _d = _c.itemIds, itemIds = _d === void 0 ? '' : _d, taskRateType = _c.taskRateType, _e = _c.times, times = _e === void 0 ? 1 : _e, _f = _c.link, link = _f === void 0 ? '' : _f;
TaskService.prototype.initTask = function (taskType, title, activityInfo, userInfo) {
var _a;
var _b = ((_a = activityInfo === null || activityInfo === void 0 ? void 0 : activityInfo.tasks) === null || _a === void 0 ? void 0 : _a[taskType]) || {}, value = _b.value, _c = _b.itemIds, itemIds = _c === void 0 ? '' : _c, taskRateType = _b.taskRateType, _d = _b.times, times = _d === void 0 ? 1 : _d, _e = _b.link, link = _e === void 0 ? '' : _e;
var remainTimes = userInfo.remainTimes;
var todayCompleteTimes = task_1.getTodayCompleteTask(taskType, userInfo).todayCompleteTimes;
var completeTimes = task_1.getCompleteTaskByUserTaskInfo(taskType, userInfo).completeTimes;
var completeTimes = task_1.getTotalCompleteTask(taskType, userInfo).completeTimes;
return {
taskType: taskType,
title: title,
......@@ -107,57 +108,78 @@ var TaskService = /** @class */ (function (_super) {
url: taskType === 'member' ? utils_1.generateVipUrl(utils_1.formatVipCbUrl(this.context)) : link,
todayCompleteTimes: todayCompleteTimes,
completeTimes: completeTimes,
status: this.setTaskStatus(userInfo, taskType, taskRateType, times),
waitReceive: remainTimes[taskType]
status: task_1.setTaskStatus(userInfo, taskType, taskRateType, times),
waitReceive: remainTimes === null || remainTimes === void 0 ? void 0 : remainTimes[taskType]
};
};
TaskService.prototype.completeTask = function (taskType, userInfo, activityInfo, customRecord) {
/**
*
* 领取任务奖励
*
* @param {ITaskType} taskType
* @param {string} awardsTargetKey
* @param {IUserInfo} userInfo
* @return {number} rewards
* @memberof TaskService
*/
TaskService.prototype.receiveTaskRewards = function (taskType, awardsTargetKey, userInfo) {
var _a;
return __awaiter(this, void 0, void 0, function () {
var waitReceiveTimes;
var _b, _c;
return __generator(this, function (_d) {
switch (_d.label) {
case 0:
waitReceiveTimes = (_a = userInfo === null || userInfo === void 0 ? void 0 : userInfo.remainTimes) === null || _a === void 0 ? void 0 : _a[taskType];
return [4 /*yield*/, this.updateUser(userInfo._id, {
$set: (_b = {},
_b["remainTimes." + taskType] = 0,
_b),
$inc: (_c = {},
_c[awardsTargetKey] = waitReceiveTimes,
_c)
})];
case 1:
_d.sent();
return [2 /*return*/, waitReceiveTimes];
}
});
});
};
/**
*根据任务类型更新任务待领取次数和任务记录
*
* @param {string} taskType
* @param {number} activityInfo
* @param {IActivityInfo} userInfo
* @param {object} [customRecord]
* @returns {boolean}
* @memberof TaskService
*/
TaskService.prototype.completeTask = function (taskType, activityInfo, userInfo, customRecord) {
var _a, _b;
if (customRecord === void 0) { customRecord = {}; }
return __awaiter(this, void 0, void 0, function () {
var today, rewards;
var _c;
return __generator(this, function (_d) {
switch (_d.label) {
var _c, _d;
return __generator(this, function (_e) {
switch (_e.label) {
case 0:
today = utils_1.getToday();
rewards = ((_b = (_a = activityInfo === null || activityInfo === void 0 ? void 0 : activityInfo.tasks) === null || _a === void 0 ? void 0 : _a[taskType]) === null || _b === void 0 ? void 0 : _b.value) || 0;
return [4 /*yield*/, this.updateUser(userInfo._id, {
$inc: {
'remainTimes.invites': rewards
},
$push: (_c = {},
_c["taskInfo." + today + "." + taskType] = __assign(__assign({}, customRecord), { createTime: Date.now() }),
_c)
$inc: (_c = {},
_c["remainTimes." + taskType] = rewards,
_c),
$push: (_d = {},
_d["taskInfo." + today + "." + taskType] = __assign(__assign({}, customRecord), { createTime: Date.now() }),
_d)
})];
case 1: return [2 /*return*/, _d.sent()];
case 1: return [2 /*return*/, _e.sent()];
}
});
});
};
// 根据会员状态更新
TaskService.prototype.updateVipTask = function (userInfo, vipInfo, tasks) {
var member = userInfo.member;
var newMember = member.newMember;
var today = utils_1.getToday();
var newVip = utils_1.isNewVip(userInfo, vipInfo);
var value = tasks.member.value;
var projection = {
$set: {},
$inc: {},
$push: {}
};
if (newVip && !newMember) {
member = utils_1.setNewVipUserData(member);
// @ts-ignore
projection.$set.member = member;
projection.$inc['remainTimes.member'] = +value;
projection.$push["taskInfo." + today + ".member"] = {
creatTime: Date.now()
};
}
return projection;
};
// 根据下单下单记录,更新状态
TaskService.prototype.updateOrderGoodsTask = function (userInfo, tasks, activityStartTime, session) {
var _a, _b;
......@@ -169,7 +191,7 @@ var TaskService = /** @class */ (function (_super) {
case 0:
taskType = 'orderGoods';
_c = tasks, _d = taskType, _e = _c[_d], value = _e.value, itemIds = _e.itemIds, taskRateType = _e.taskRateType, times = _e.times;
_f = task_1.getCompleteTaskByUserTaskInfo(taskType, userInfo), completeTimes = _f.completeTimes, taskInfo = _f.taskInfo;
_f = task_1.getTotalCompleteTask(taskType, userInfo), completeTimes = _f.completeTimes, taskInfo = _f.taskInfo;
todayCompleteTimes = task_1.getTodayCompleteTask(taskType, userInfo).todayCompleteTimes;
// 永久任务且已完成
if (taskRateType === constants_1.TASK_RATE_TYPE.FOREVER && completeTimes) {
......@@ -235,113 +257,6 @@ var TaskService = /** @class */ (function (_super) {
}
: {};
};
/**
*更新关注店铺任务状态
*
* @param {IUserInfo} userInfo
* @param {IActivityInfo} activityInfo
* @returns
* @memberof TaskService
*/
TaskService.prototype.updateFollowTask = function (userInfo, activityInfo) {
return __awaiter(this, void 0, void 0, function () {
var today, _id, follow, tasks, value, followInfo;
var _a;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
today = utils_1.getToday();
_id = userInfo._id, follow = userInfo.follow;
tasks = activityInfo.tasks;
value = (tasks || {}).follow.value;
followInfo = utils_1.setNewFollowUserData(follow);
return [4 /*yield*/, this.updateUser(_id, {
$set: {
follow: followInfo
},
$inc: {
'remainTimes.follow': value
},
$push: (_a = {},
_a["taskInfo." + today + ".follow"] = {
creatTime: Date.now()
},
_a)
})];
case 1:
// 增加待领取次数
return [2 /*return*/, _b.sent()];
}
});
});
};
/**
*
* 根据用户和任务完成情况,设置任务状态
*
* @param {IUserInfo} useInfo
* @param {string} taskType
* @param {number} taskRateType
* @param {number} [limitTimesEverday] 每天限制次数 任务频率为每天的时候必填
* @return {taskTatus} 1未完成 2 待领取 3 已完成
* @memberof TaskService
*/
TaskService.prototype.setTaskStatus = function (useInfo, taskType, taskRateType, limitTimesEveryday) {
var _a;
if (limitTimesEveryday === void 0) { limitTimesEveryday = 1; }
var waitReceive = ((_a = useInfo === null || useInfo === void 0 ? void 0 : useInfo.remainTimes) === null || _a === void 0 ? void 0 : _a[taskType]) || 0;
if (waitReceive)
return constants_1.TASK_STATUS.WAIT_RECEIVE;
// 当天的完成次数
var todayCompleteTimes = task_1.getTodayCompleteTask(taskType, useInfo).todayCompleteTimes;
// 总共的完成次数
var completeTimes = task_1.getCompleteTaskByUserTaskInfo(taskType, useInfo).completeTimes;
switch (taskRateType) {
case constants_1.TASK_RATE_TYPE.FOREVER:
return completeTimes > 0 ? constants_1.TASK_STATUS.DONE : constants_1.TASK_STATUS.WAIT_DO;
break;
case constants_1.TASK_RATE_TYPE.EVERYDAY:
return todayCompleteTimes >= limitTimesEveryday ? constants_1.TASK_STATUS.DONE : constants_1.TASK_STATUS.WAIT_DO;
break;
case constants_1.TASK_RATE_TYPE.NOLIMIT:
return constants_1.TASK_STATUS.WAIT_DO;
break;
}
};
/**
*根据任务类型更新任务待领取次数和任务记录
*
* @param {string} taskType
* @param {number} rewards
* @param {IUserInfo} userInfo
* @param {object} [customRecord]
* @returns {boolean}
* @memberof TaskService
*/
TaskService.prototype.updateUserTaskRecord = function (taskType, rewards, userInfo, customRecord) {
return __awaiter(this, void 0, void 0, function () {
var _id, today, result;
var _a, _b;
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
_id = userInfo._id;
today = utils_1.getToday();
return [4 /*yield*/, this.updateUser(_id, {
$inc: (_a = {},
_a["remainTimes." + taskType] = rewards,
_a),
$push: (_b = {},
_b["taskInfo." + today + "." + taskType] = __assign({ createTime: Date.now() }, customRecord),
_b)
})];
case 1:
result = _c.sent();
return [2 /*return*/, result === 1];
}
});
});
};
/**
*
* 更新user表中,任务相关字段
......
{"version":3,"file":"task.service.js","sourceRoot":"","sources":["../../src/service/task.service.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,iCAA8B;AAC9B,+CAAwC;AACxC,kCAUiB;AACjB,0CAA0D;AAC1D,6CAA0F;AAe1F;IAAyC,+BAAW;IAClD,qBAAY,OAA0B;eACpC,kBAAM,OAAO,CAAC;IAChB,CAAC;IACD;;;;;;;;;OASG;IACH,8BAAQ,GAAR,UAAS,QAAmB,EAAE,KAAa,EAAE,KAAa,EAAE,QAAmB;QAE3E,IACE,KAAA,KAAK,EADP,KAAC,QAAS,EAAV,WAAuE,EAAzD,KAAK,WAAA,EAAE,eAAY,EAAZ,OAAO,mBAAG,EAAE,KAAA,EAAE,YAAY,kBAAA,EAAE,aAAS,EAAT,KAAK,mBAAG,CAAC,KAAA,EAAE,YAAS,EAAT,IAAI,mBAAG,EAAE,KAC9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4BACjD,OAAO,UAAU,CAAC,IAAI,CAAA;yBACvB;wBACD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,IAAI,UAAU,CAAC,KAAK,EAAE;4BACnD,OAAO,UAAU,CAAC,KAAK,CAAA;yBACxB;wBAED,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,EAAE;4BACnC,sBAAO,QAAQ,EAAA;yBAChB;wBAED,qBAAM,IAAI,CAAC,UAAU,CAAC,EAAE,EAAE,UAAU,CAAC;4BAErC,mBAAmB;0BAFkB;;wBAArC,SAAqC,CAAA;wBAErC,mBAAmB;wBACnB,qBAAM,aAAK,CAAC,EAAE,CAAC,EAAA;;wBADf,mBAAmB;wBACnB,SAAe,CAAA;wBAER,qBAAM,IAAI,CAAC,WAAW,EAAE,EAAA;4BAA/B,sBAAO,SAAwB,EAAA;;;;KAChC;IACH,kBAAC;AAAD,CAAC,AApTD,CAAyC,sBAAW,GAoTnD"}
\ No newline at end of file
{"version":3,"file":"task.service.js","sourceRoot":"","sources":["../../src/service/task.service.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,iCAA8B;AAC9B,+CAAwC;AACxC,kCAUiB;AACjB,0CAA0D;AAC1D,6CAAgG;AAehG;IAAyC,+BAAW;IAClD,qBAAY,OAA0B;eACpC,kBAAM,OAAO,CAAC;IAChB,CAAC;IACD;;;;;;;;;OASG;IACH,8BAAQ,GAAR,UAAS,QAAmB,EAAE,KAAa,EAAE,YAA2B,EAAE,QAAmB;;QACrF,IAAA,KAA8D,OAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,KAAK,0CAAG,QAAQ,MAAK,EAAE,EAAjG,KAAK,WAAA,EAAE,eAAY,EAAZ,OAAO,mBAAG,EAAE,KAAA,EAAE,YAAY,kBAAA,E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AAI,EAAE;4BACjD,OAAO,UAAU,CAAC,IAAI,CAAA;yBACvB;wBACD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,IAAI,UAAU,CAAC,IAAI,EAAE;4BACjD,OAAO,UAAU,CAAC,IAAI,CAAA;yBACvB;wBACD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,IAAI,UAAU,CAAC,KAAK,EAAE;4BACnD,OAAO,UAAU,CAAC,KAAK,CAAA;yBACxB;wBAED,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,EAAE;4BACnC,sBAAO,QAAQ,EAAA;yBAChB;wBAED,qBAAM,IAAI,CAAC,UAAU,CAAC,EAAE,EAAE,UAAU,CAAC;4BAErC,mBAAmB;0BAFkB;;wBAArC,SAAqC,CAAA;wBAErC,mBAAmB;wBACnB,qBAAM,aAAK,CAAC,EAAE,CAAC,EAAA;;wBADf,mBAAmB;wBACnB,SAAe,CAAA;wBAER,qBAAM,IAAI,CAAC,WAAW,EAAE,EAAA;4BAA/B,sBAAO,SAAwB,EAAA;;;;KAChC;IACH,kBAAC;AAAD,CAAC,AArND,CAAyC,sBAAW,GAqNnD"}
\ No newline at end of file
......@@ -213,7 +213,7 @@ var UserService = /** @class */ (function (_super) {
projection.$inc["remainTimes.follow"] = follow.value;
}
newVip = userUpdate_1.isNewVip(userInfo, vipInfo);
if (newVip && !userInfo.member.newMember) {
if (newVip) {
// @ts-ignore
projection.$set.member = this.setNewVipUserData(userInfo.member);
projection.$push["taskInfo." + today + ".member"] = { createTime: Date.now() };
......
{"version":3,"file":"user.service.js","sourceRoot":"","sources":["../../src/service/user.service.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,8BAAwC;AACxC,+CAAwC;AACxC,4BAAoC;AACpC,kCAA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,sBAAO,IAAI,EAAA;;;;KACZ;IAED;;;;OAIG;IACG,qCAAe,GAArB,UAAsB,GAAW;;;;4BACxB,qBAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,GAAG,KAAA,EAAE,CAAC,EAAA;4BAA1C,sBAAO,SAAmC,EAAA;;;;KAC3C;IACH,kBAAC;AAAD,CAAC,AAlND,CAA0B,sBAAW,GAkNpC;AAED,kBAAe,WAAW,CAAA"}
\ No newline at end of file
{"version":3,"file":"user.service.js","sourceRoot":"","sources":["../../src/service/user.service.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,8BAAwC;AACxC,+CAAwC;AACxC,4BAAoC;AACpC,kCAA+D;AAC/D,yDAAqD;AACrD,iDAAuD;AACvD;IAA0B,+BAAW;IAEnC,qBAAY,OAA0B;QAAtC,YACE,kBAAM,OAAO,CAAC,SAEf;QADC,KAAI,CAAC,OAAO,GAAG,IAAI,aAAO,CAAC,OAAO,EAAE,iBAAY,CAAC,CAAA;;IACnD,CAAC;IACD;;;OAGG;IACG,iCAAW,GAAjB;;;;;;wBACM,KAAmB,IAAI,CAAC,OAAO,EAA7B,MAAM,YAAA,EAAE,IAAI,UAAA,CAAiB;wBAC7B,UAAU,GAAK,IAAI,WAAT,CAAS;wBACZ,qBAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CAAY,EAAE,MAAM,QAAA,EAAE,UAAU,YAAA,EAAE,CAAC,EAAA;;wBAAtE,MAAM,GAAG,SAA6D;wBAC1E,sBAAO,MAAM,EAAA;;;;KACd;IAED;;;;;OAKG;IACG,yCAAmB,GAAzB,UAA0B,MAAc;;;;;;wBAChC,UAAU,GAAK,IAAI,CAAC,OAAO,CAAC,IAAI,WAAtB,CAAsB;wBACzB,qBAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CAAY,EAAE,MAAM,QAAA,EAAE,UAAU,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AG,GAAG,CAAC,CAAA;wBAEX,eAAe;wBACf,KAAS,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,aAAa,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;4BAC7C,IAAI,aAAa,CAAC,CAAC,CAAC,CAAC,MAAM,KAAK,MAAM,EAAE;gCACtC,GAAG,GAAG,CAAC,CAAA;6BACR;yBACF;wBACM,qBAAM,IAAI,CAAC,OAAO,CAAC,KAAK,WAAG,GAAC,YAAY,IAAG,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE,aAAU,aAAA,MAAG,EAAA;;wBAAnF,IAAI,GAAG,SAA4E,CAAA;wBACnF,IAAI,GAAG,IAAI,GAAG,CAAC,GAAG,GAAG,CAAA;wBACrB,sBAAO,IAAI,EAAA;;;;KACZ;IAED;;;;OAIG;IACG,qCAAe,GAArB,UAAsB,GAAW;;;;4BACxB,qBAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,GAAG,KAAA,EAAE,CAAC,EAAA;4BAA1C,sBAAO,SAAmC,EAAA;;;;KAC3C;IACH,kBAAC;AAAD,CAAC,AAlND,CAA0B,sBAAW,GAkNpC;AAED,kBAAe,WAAW,CAAA"}
\ No newline at end of file
......@@ -7,7 +7,6 @@ export * from './common/logger';
export * from './common/rand';
export * from './common/getUserOrderlist';
export * from './common/vip';
export * from './common/exportHandlers';
export * from './common/helper';
export * from './common/userUpdate';
export * from './common/format';
......
......@@ -23,7 +23,6 @@ __exportStar(require("./common/logger"), exports);
__exportStar(require("./common/rand"), exports);
__exportStar(require("./common/getUserOrderlist"), exports);
__exportStar(require("./common/vip"), exports);
__exportStar(require("./common/exportHandlers"), exports);
__exportStar(require("./common/helper"), exports);
__exportStar(require("./common/userUpdate"), exports);
__exportStar(require("./common/format"), exports);
......
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";AAAA,cAAc;;;;;;;;;;;;AAEd,cAAc;AACd,sDAAmC;AAEnC,iBAAiB;AACjB,oDAAiC;AAEjC,gBAAgB;AAChB,uDAAoC;AAEpC,SAAS;AACT,sDAAmC;AAEnC,kDAA+B;AAE/B,gDAA6B;AAE7B,4DAAyC;AAEzC,+CAA4B;AAE5B,0DAAuC;AAEvC,kDAA+B;AAE/B,sDAAmC;AAEnC,kDAA+B;AAE/B,qDAAkC"}
\ No newline at end of file
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";AAAA,cAAc;;;;;;;;;;;;AAEd,cAAc;AACd,sDAAmC;AAEnC,iBAAiB;AACjB,oDAAiC;AAEjC,gBAAgB;AAChB,uDAAoC;AAEpC,SAAS;AACT,sDAAmC;AAEnC,kDAA+B;AAE/B,gDAA6B;AAE7B,4DAAyC;AAEzC,+CAA4B;AAE5B,kDAA+B;AAE/B,sDAAmC;AAEnC,kDAA+B;AAE/B,qDAAkC"}
\ No newline at end of file
/** @format */
<<<<<<< HEAD
import { checkParams, services } from '../decorator/common'
=======
import { services, checkParams, registeInfos } from '../decorator/common'
>>>>>>> e33364a0a782681f36d5822ff2bb1882608c197d
import { resultsModel } from '../sdk'
import { AwardsService } from '../service'
import { PRIZE_TYPE, DRAW_STATUS, CODE_TYPES } from '../constants'
......@@ -8,6 +12,8 @@ import { getToday } from '../utils/'
import { CodeType } from 'taobao-mini-sdk/lib/utils/codetypes'
import preCheck from '../decorator/common/preCheck'
import { checkActivityTime } from '../utils/common/check/checkActivityTime'
import { checkPrizeExpired } from '../utils/common/check/checkPrizeExpired'
import { checkValidPrize } from '../utils/common/check/checkValidPrize'
export interface IPrizeListParams {
activityId: string
......@@ -30,6 +36,10 @@ export interface IReceiveEnameParams {
id: string
}
export interface IReceivePrizeControllerInfos extends IControllerInfos {
awardInfo: IAwards
}
export default class AwardsController {
/**
* 我的奖品列表
......@@ -69,7 +79,7 @@ export default class AwardsController {
city: 1,
area: 1,
remark: 1,
useUrk: 1,
useUrl: 1,
shipCompany: 1,
shipNum: 1
},
......@@ -80,7 +90,7 @@ export default class AwardsController {
)
return resultsModel.success({
list: awardSer.formateMyPrizeList(myPrizeList, awardReceiveExpiredTime)
list: awardSer.formatMyPrizeList(myPrizeList, awardReceiveExpiredTime)
})
}
......@@ -89,21 +99,15 @@ export default class AwardsController {
*/
@checkParams(['activityId', 'id', 'name', 'phone', 'province', 'city', 'area', 'addressDetail', 'streetName'])
@services([AwardsService])
@preCheck([checkPrizeExpired, checkValidPrize([PRIZE_TYPE.OBJECT])])
async receiveObjectPrize(
context: IContext<IReceiveOjectParams>,
{ activityInfo }: IControllerInfos,
{ activityInfo }: IReceivePrizeControllerInfos,
[awardSer]: [AwardsService]
): Promise<IResult<boolean>> {
let { province, city, area, streetName, addressDetail, id, name, phone, activityId } = context.data
// 若有过期时间,且已过期
let { awardReceiveExpiredTime } = activityInfo
if (awardReceiveExpiredTime && Date.now() > awardReceiveExpiredTime) {
return resultsModel.error(CODE_TYPES.ERROR_PRIZE_EXPIRED)
}
let { province, city, area, streetName, addressDetail, id, name, phone } = context.data
let result = await awardSer.recieveObjectPrize(id, {
activityId,
province,
city,
area,
......@@ -123,11 +127,18 @@ export default class AwardsController {
* 权益重新领取
*/
@checkParams(['activityId', 'id'])
@registeInfos(['session'])
@services([AwardsService])
async receiveEnamePrize(context: IContext<IReceiveEnameParams>, {}, [awardSer]: [AwardsService]) {
let { id, activityId } = context.data
@preCheck([checkPrizeExpired, checkValidPrize([PRIZE_TYPE.ENAME, PRIZE_TYPE.CREDITS])])
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) {
return resultsModel.error(result as CodeType)
}
......
......@@ -52,7 +52,7 @@ export default class Share {
): Promise<IResult<boolean>> {
const { openId } = context
const result = await taskService.completeTask('invites', inviteUserInfo, activityInfo, {
const result = await taskService.completeTask('invites', activityInfo, inviteUserInfo, {
openId
})
......
/** @format */
import { CODE_TYPES, TASK_RATE_TYPE } from './../constants'
import { CODE_TYPES } from './../constants'
import { checkParams, services, registeInfos, preCheck } from '../decorator/common'
import { resultsModel, TBAPIS } from '../sdk'
import { resultsModel } from '../sdk'
import { TaskService, BaseService } from '../service'
import { ITaskInfo } from '../service/task.service'
import { checkActivityTime } from '../utils/common/check/checkActivityTime'
import { getCompleteTaskByUserTaskInfo, getTodayCompleteTask } from '../utils/common/task'
import { getTotalCompleteTask } from '../utils/common/task'
import { update } from '../decorator/common/update'
import { updateVip } from '../utils/common/update/updateVip'
import { checkTaskLimit } from '../utils/common/check/checkTaskLimit'
import { checkExchangeCreditsTask } from '../utils/common/check/checkExchangeCreditsTask'
import { checkRemainTimes } from '../utils/common/check/checkRemainTimes'
export default class Task {
/**
......@@ -17,279 +21,75 @@ export default class Task {
@registeInfos(['vipInfo'])
@services([TaskService])
@preCheck([checkActivityTime])
@update([updateVip])
async getTaskList(
context: IContext<{ activityId: string }>,
{ userInfo, vipInfo, activityInfo }: IControllerInfos,
{ userInfo, activityInfo }: IControllerInfos,
[taskService]: [TaskService]
): Promise<IResult<ITaskInfo[]>> {
const { tasks, startTime } = activityInfo
// 更新user状态
let updatedUserInfo = await taskService.updateTasks(
userInfo._id,
// 需要查询更新的任务
[
taskService.updateVipTask(userInfo, vipInfo, tasks)
// taskService.updateSignTask(userInfo, tasks),
// await taskService.updateOrderGoodsTask(userInfo, tasks, startTime, session)
],
userInfo
)
if (!updatedUserInfo) return resultsModel.error(CODE_TYPES.SYSTEM_ERROR, '更新任务列表失败')
// 返回对应的任务时, B端b_activity_config tasks 需配置对应的任务
return resultsModel.success([
taskService.initTask('member', '加入会员', tasks, updatedUserInfo),
taskService.initTask('follow', '关注店铺', tasks, updatedUserInfo)
// taskService.initTask('sign', '签到', tasks, updatedUserInfo),
// taskService.initTask('orderGoods', '购买商品', tasks, updatedUserInfo),
// taskService.initTask('browseGoods', '浏览商品', tasks, updatedUserInfo),
// taskService.initTask('collectGoods', '收藏商品', tasks, updatedUserInfo),
// taskService.initTask('jumpLink', '浏览页面', tasks, updatedUserInfo),
// taskService.initTask('invites', '邀请好友', tasks, updatedUserInfo),
// taskService.initTask('exchangeCredits', '积分兑换', tasks, updatedUserInfo)
taskService.initTask('member', '加入会员', activityInfo, userInfo),
taskService.initTask('follow', '关注店铺', activityInfo, userInfo)
// taskService.initTask('sign', '签到', activityInfo, userInfo),
// taskService.initTask('orderGoods', '购买商品', activityInfo, userInfo),
// taskService.initTask('browseGoods', '浏览商品', activityInfo, userInfo),
// taskService.initTask('collectGoods', '收藏商品', activityInfo, userInfo),
// taskService.initTask('jumpLink', '浏览页面', activityInfo, userInfo),
// taskService.initTask('invites', '邀请好友', activityInfo, userInfo)
// taskService.initTask('exchangeCredits', '积分兑换', activityInfo, updatedUserInfo)
])
}
/**
* 完成关注店铺任务
* 完成任务
*
* 商品相关任务 需要传itemId参数
* 积分兑换任务 需要传credits参数
*/
@checkParams(['activityId'])
@services([TaskService])
@preCheck([checkActivityTime])
async doFollowTask(
context: IContext<{ activityId: string }>,
{ userInfo, activityInfo }: IControllerInfos,
[TaskService]: [TaskService]
): Promise<IResult<boolean>> {
let { follow } = userInfo
const { flag, newFollow } = follow
// 已经关注过店铺,不可完成
const hasFollowed = flag || newFollow
if (hasFollowed) return resultsModel.error(CODE_TYPES.ERROR_TASK_COMPLETE)
// 更新状态
const result = await TaskService.updateFollowTask(userInfo, activityInfo)
return result ? resultsModel.success(true) : resultsModel.error(CODE_TYPES.SYSTEM_ERROR)
}
/**
* 积分兑换次数
*/
@checkParams(['activityId', 'credits'])
@checkParams(['activityId', 'taskType'])
@registeInfos(['session'])
@services([TaskService])
@preCheck([checkActivityTime])
async doExchangeCreditsTask(
context: IContext<IParams>,
{ userInfo, activityInfo, session }: IControllerInfos,
[taskService]: [TaskService]
): Promise<IResult<boolean>> {
const { credits } = context.data
const taskType = `exchangeCredits`
const {
tasks: {
exchangeCredits: { value, times, taskRateType }
}
} = activityInfo
const { todayCompleteTimes } = getTodayCompleteTask(taskType, userInfo)
// 如果每日限制次数并到达了限制次数
if (times && times === todayCompleteTimes && taskRateType === TASK_RATE_TYPE.EVERYDAY) {
return resultsModel.error(CODE_TYPES.ERROR_TASK_LIMIT)
}
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)
// 更新user表
await taskService.updateUserTaskRecord(taskType, value, userInfo)
return resultsModel.success(true)
}
/**
* 浏览商品
*/
@checkParams(['activityId', 'itemId'])
@services([TaskService])
@preCheck([checkActivityTime])
async doBrowseGoodsTask(
context: IContext<IParams>,
{ userInfo, activityInfo }: IControllerInfos,
[taskService]: [TaskService]
): Promise<IResult<boolean>> {
const taskType = 'browseGoods'
const { itemId } = context.data
const {
tasks: {
browseGoods: { taskRateType, times, itemIds, value }
}
} = activityInfo
const itemIdArray: number[] = Array.isArray(itemIds) ? itemIds : itemIds.split(',').map(v => +v)
// B端配置商品ids不匹配正确
if (!itemIdArray.includes(+itemId)) return resultsModel.error(CODE_TYPES.PARAMS_ERROR, '商品id不匹配')
const { todayTaskInfo, todayCompleteTimes } = getTodayCompleteTask('browseGoods', userInfo)
const hasCompleteToday = todayTaskInfo.some(v => v.itemId === itemId) && taskRateType === TASK_RATE_TYPE.EVERYDAY
// 今日任务已经完成
if (hasCompleteToday) {
return resultsModel.error(CODE_TYPES.PARAMS_ERROR, '今日该浏览商品任务已完成')
}
// 次数超限
if (times && times === todayCompleteTimes && taskRateType === TASK_RATE_TYPE.EVERYDAY) {
return resultsModel.error(CODE_TYPES.ERROR_TASK_LIMIT)
}
// 更新user表
await taskService.updateUserTaskRecord(taskType, value, userInfo, {
itemId
})
return resultsModel.success(true)
}
/**
* 收藏商品
*/
@checkParams(['activityId', 'itemId'])
@services([TaskService])
@preCheck([checkActivityTime])
async doCollectGoodsTask(
context: IContext<IParams>,
@preCheck([checkActivityTime, checkTaskLimit, checkExchangeCreditsTask])
async doCompleteTask(
context: IContext<{
activityId: string
taskType: ITaskType
itemId?: string // 涉及到商品的任务需传itemId
credits?: number
}>,
{ userInfo, activityInfo }: IControllerInfos,
[taskService]: [TaskService]
): Promise<IResult<boolean>> {
const taskType = 'collectGoods'
const { itemId } = context.data
const {
tasks: {
collectGoods: { taskRateType, times, itemIds, value }
}
} = activityInfo
const itemIdArray: number[] = Array.isArray(itemIds) ? itemIds : itemIds.split(',').map(v => +v)
// B端配置商品ids不匹配正确
if (!itemIdArray.includes(+itemId)) return resultsModel.error(CODE_TYPES.PARAMS_ERROR, '商品id不匹配')
const { todayTaskInfo, todayCompleteTimes } = getTodayCompleteTask(taskType, userInfo)
const hasCompleteToday =
todayTaskInfo.filter(v => v.itemId === itemId).length && taskRateType === TASK_RATE_TYPE.EVERYDAY
// 今日任务已经完成
if (hasCompleteToday) {
return resultsModel.error(CODE_TYPES.PARAMS_ERROR, '今日该收藏商品任务已完成')
}
// 次数超限
if (times && times === todayCompleteTimes && taskRateType === TASK_RATE_TYPE.EVERYDAY) {
return resultsModel.error(CODE_TYPES.ERROR_TASK_LIMIT)
}
const { taskType, itemId } = context.data
// 更新user表
await taskService.updateUserTaskRecord(taskType, value, userInfo, {
itemId
})
const result = await taskService.completeTask(taskType, activityInfo, userInfo, { itemId })
return resultsModel.success(true)
}
/**
* 浏览链接
*/
@checkParams(['activityId'])
@services([TaskService])
@preCheck([checkActivityTime])
async doJumpLinkTask(
context: IContext<IParams>,
{ userInfo, activityInfo }: IControllerInfos,
[taskService]: [TaskService]
): Promise<IResult<boolean>> {
const taskType = 'jumpLink'
const {
tasks: {
jumpLink: { taskRateType, times, value, link }
}
} = activityInfo
const { todayCompleteTimes } = getTodayCompleteTask(taskType, userInfo)
const hasCompleteToday = times && todayCompleteTimes === times && taskRateType === TASK_RATE_TYPE.EVERYDAY
// 今日任务已经完成
if (hasCompleteToday) {
return resultsModel.error(CODE_TYPES.PARAMS_ERROR, '今日跳转链接任务已完成')
}
// 次数超限
if (times && times === todayCompleteTimes && taskRateType === TASK_RATE_TYPE.EVERYDAY) {
return resultsModel.error(CODE_TYPES.ERROR_TASK_LIMIT)
}
// 更新user表
await taskService.updateUserTaskRecord(taskType, value, userInfo)
return resultsModel.success(true)
return result ? resultsModel.success(true) : resultsModel.error(CODE_TYPES.SYSTEM_ERROR, '任务完成失败')
}
/**
* 领取任务奖励
*/
@checkParams(['activityId', 'taskType'])
@checkParams(['activityId', 'taskType', 'rewardsKey'])
@services([TaskService])
@preCheck([checkActivityTime])
@preCheck([checkActivityTime, checkRemainTimes])
async receiveTaskRewards(
context: IContext<IParams>,
context: IContext<{
activityId: string
taskType: ITaskType
rewardsKey: string //领取的奖励增加的key值 如: gameTimes 前端传入
}>,
{ userInfo }: IControllerInfos,
[taskService]: [TaskService]
): Promise<IResult<{ rewards: number }>> {
// 根据需求自定义领取任务增加的key值 如: gameTimes
const awardsTargetKey = `gameTimes`
const { rewardsKey } = context.data
const { taskType } = context.data
const { remainTimes, _id } = userInfo
// 暂无领取次数
if (!remainTimes?.[taskType]) return resultsModel.error(CODE_TYPES.ERROR_TASK_NORECEIVE)
const waitReceiveTimes = remainTimes?.[taskType]
await taskService.updateUser(_id, {
$set: {
[`remainTimes.${taskType}`]: 0
},
$inc: {
[awardsTargetKey]: waitReceiveTimes
}
})
const rewards = await taskService.receiveTaskRewards(taskType, rewardsKey, userInfo)
return resultsModel.success({
rewards: waitReceiveTimes
rewards
})
}
......@@ -298,16 +98,16 @@ export default class Task {
*/
@checkParams(['activityId', 'itemIds'])
@registeInfos(['session'])
@services([BaseService, TaskService])
@services([BaseService])
async getCollectGoodsList(
context: IContext<IParams>,
{ session, userInfo }: IControllerInfos,
[baseService, taskService]: [BaseService, TaskService]
[baseService]: [BaseService]
) {
const { itemIds } = context.data
const list = await baseService.getItemListByIds(itemIds, session)
const { taskInfo } = getCompleteTaskByUserTaskInfo('collectGoods', userInfo)
const { taskInfo } = getTotalCompleteTask('collectGoods', userInfo)
const listWithCollectStatus = list.map(v => {
return {
......
......@@ -36,25 +36,26 @@ export default class User {
async getRankList(
context: IContext<{
activityId: string
key: string // 排序的key值 如 score
timeKey: string // 排序时间的key值 如:updateScoreTime
limit: number
}>,
{ userInfo }: IControllerInfos,
[userService]: [UserService]
) {
const sortKey = 'score'
const sortTime = 'updateScoreTime'
const limit = 200
const { key, timeKey, limit = 200 } = context.data
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({
userNick,
avatar,
rank,
score: userInfo[sortKey],
score: userInfo[key],
list
})
}
......
/** @format */
import { merge } from 'lodash'
// 检验参数是否存在
const update = (checks: IFunction[]) => {
return function (target: Object, name: string, descriptor: PropertyDescriptor) {
......@@ -7,17 +9,20 @@ const update = (checks: IFunction[]) => {
descriptor.value = async function (...args: any[]) {
let [context, otherArgs = {}, services = []] = args
let totalUpdateProjection: IDecoratorUpdateQuery = {}
for (let i = 0; i < checks.length; i++) {
const checkFn = checks[i]
let result = await checkFn.apply(target, [context, { ...otherArgs }, services])
let result: IDecoratorUpdateQuery = await checkFn.apply(target, [context, { ...otherArgs }, services])
result = result || {}
// 校验报错
if ((result as IErrorResult)?.success === false && (result as IErrorResult)?.code) {
return result
}
otherArgs = { ...otherArgs, ...result }
totalUpdateProjection = merge({}, totalUpdateProjection, result)
otherArgs = { ...otherArgs }
}
return method.apply(target, [context, { ...otherArgs }, services])
}
......
/** @format */
// import { exportHandlers } from './utils'
import UserController from './controller/user.controller'
import TaskController from './controller/task.controller'
import BaseController from './controller/base.controller'
......@@ -15,12 +14,8 @@ const { login } = new LoginController()
const {
getTaskList,
receiveTaskRewards,
getCollectGoodsList, // 获取收藏商品列表,包含收藏状态
doFollowTask,
doJumpLinkTask,
doBrowseGoodsTask,
doCollectGoodsTask,
doExchangeCreditsTask
doCompleteTask,
getCollectGoodsList // 获取收藏商品列表,包含收藏状态
} = new TaskController()
const { getActivityBaseInfoById, getItemListByItemIds } = new BaseController()
......@@ -35,6 +30,7 @@ export default {
login,
getVipInfo,
getTaskList,
doCompleteTask,
receiveTaskRewards,
getActivityBaseInfoById,
getMyPrizeList,
......
......@@ -114,7 +114,7 @@ export default class AwardsService extends UserService {
return await this.awardsdao.find<IAwards>(query, projection)
}
formateMyPrizeList(myPrizeList: IAwards[], awardReceiveExpiredTime?: number) {
formatMyPrizeList(myPrizeList: IAwards[], awardReceiveExpiredTime?: number) {
const now = Date.now()
return myPrizeList.map(v => {
if (
......@@ -137,7 +137,6 @@ export default class AwardsService extends UserService {
async recieveObjectPrize(
_id: string,
{
activityId,
province,
city,
area,
......@@ -146,7 +145,6 @@ export default class AwardsService extends UserService {
name,
phone
}: {
activityId: string
province: string
city: string
area: string
......@@ -156,20 +154,6 @@ export default class AwardsService extends UserService {
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(
{ _id },
{
......@@ -192,29 +176,9 @@ export default class AwardsService extends UserService {
}
// 发放淘宝权益(奖品数据已插入到awards_info表,且状态drawStatus 为1或者6)
async recieveEnamePrize(_id: string, activityId: 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)
async recieveEnamePrize(_id: string, awardInfo: IAwards, session: string) {
// 发放淘宝权益
let result = await sendTBAward(this.context, session, award)
let result = await sendTBAward(this.context, session, awardInfo)
// 更新
await this.awardsdao.update(
{ _id },
......
......@@ -18,7 +18,7 @@ import {
isNewVip
} from '../utils'
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 {
taskType?: string // 任务类型
......@@ -42,19 +42,16 @@ export default class TaskService extends UserService {
*
* @param {ITaskType} taskType 任务类型
* @param {string} title 任务标题
* @param {ITasks} tasks 任务配置
* @param {IActivityInfo} activityInfo 任务配置
* @param {IUserInfo} userInfo 用户信息
* @return {ITaskInfo} {ITaskInfo} 任务信息
* @memberof TaskService
*/
initTask(taskType: ITaskType, title: string, tasks: ITasks, userInfo: IUserInfo): ITaskInfo {
const {
[taskType]: { value, itemIds = '', taskRateType, times = 1, link = '' }
} = tasks
initTask(taskType: ITaskType, title: string, activityInfo: IActivityInfo, userInfo: IUserInfo): ITaskInfo {
const { value, itemIds = '', taskRateType, times = 1, link = '' } = activityInfo?.tasks?.[taskType] || {}
const { remainTimes } = userInfo
const { todayCompleteTimes } = getTodayCompleteTask(taskType, userInfo)
const { completeTimes } = getCompleteTaskByUserTaskInfo(taskType, userInfo)
const { completeTimes } = getTotalCompleteTask(taskType, userInfo)
return {
taskType,
......@@ -66,17 +63,57 @@ export default class TaskService extends UserService {
url: taskType === 'member' ? generateVipUrl(formatVipCbUrl(this.context)) : link,
todayCompleteTimes,
completeTimes,
status: this.setTaskStatus(userInfo, taskType, taskRateType, times),
waitReceive: remainTimes[taskType]
status: setTaskStatus(userInfo, taskType, taskRateType, times),
waitReceive: remainTimes?.[taskType]
}
}
async completeTask(taskType: ITaskType, userInfo: IUserInfo, activityInfo: IActivityInfo, customRecord: object = {}) {
/**
*
* 领取任务奖励
*
* @param {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 rewards = activityInfo?.tasks?.[taskType]?.value || 0
return await this.updateUser(userInfo._id, {
$inc: {
'remainTimes.invites': rewards
[`remainTimes.${taskType}`]: rewards
},
$push: {
[`taskInfo.${today}.${taskType}`]: { ...customRecord, createTime: Date.now() }
......@@ -84,45 +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) {
const taskType = 'orderGoods'
const {
[taskType]: { value, itemIds, taskRateType, times }
} = tasks
const { completeTimes, taskInfo } = getCompleteTaskByUserTaskInfo(taskType, userInfo)
const { completeTimes, taskInfo } = getTotalCompleteTask(taskType, userInfo)
const { todayCompleteTimes } = getTodayCompleteTask(taskType, userInfo)
// 永久任务且已完成
if (taskRateType === TASK_RATE_TYPE.FOREVER && completeTimes) {
......@@ -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表中,任务相关字段
......
......@@ -127,7 +127,7 @@ class UserService extends BaseService {
// 之前进入活动非会员,现在进入会员,则视为新会员用户
const newVip = isNewVip(userInfo, vipInfo)
if (newVip && !userInfo.member.newMember) {
if (newVip) {
// @ts-ignore
projection.$set.member = this.setNewVipUserData(userInfo.member)
projection.$push[`taskInfo.${today}.member`] = { createTime: Date.now() }
......
......@@ -109,18 +109,21 @@ interface IUpdateQuery {
$set?: { [key: string]: any }
$setOnInsert?: { [key: string]: any }
$unset?: { [key: string]: any }
$addToSet?: { [key: string]: any }
$pop?: { [key: string]: any }
$pull?: { [key: string]: any }
$push?: { [key: string]: any }
$pullAll?: { [key: string]: any }
$bit?: {
[key: string]: { [key in 'and' | 'or' | 'xor']?: number }
}
}
interface IDecoratorUpdateQuery {
$inc?: { [key: string]: number | undefined }
$set?: { [key: string]: any }
$push?: { [key: string]: any }
}
interface IFindProjection {
projection?: {
[key: string]: number | boolean | any
......
......@@ -44,3 +44,5 @@ interface IVipInfo {
}
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
// 自己邀请自己
if (openId === inviteId) return resultsModel.error(CODE_TYPES.ERROR_NO_INVITE_SELF)
// 获取邀请者信息
const inviteUserInfo = await dbFindOne<IUserInfo>(context, USER_DB_NAME, {
activityId,
openId: inviteId
......
......@@ -4,11 +4,6 @@ import { resultsModel } from '../../../sdk'
import { CODE_TYPES } from '../../../errorCode'
export const checkNewVip = async (context: IContext<IParams>, { vipInfo, userInfo }: IControllerInfos) => {
const {
openId,
data: { activityId, inviteId }
} = context
if (!vipInfo) {
console.error(`使用checkNewVip registeInfos必须注册vipInfo`)
}
......
/** @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 */
export const checkTaskLimit = (taskType: ITaskType) => {
return async function (context: IContext<IParams>, { activityInfo, userInfo }: IControllerInfos) {
const {
tasks: {
[taskType]: { value, taskRateType, times }
}
} = activityInfo
const {} = userInfo
import { resultsModel } from '../../../sdk'
import { CODE_TYPES } from '../../../errorCode'
import { getTodayCompleteTask, getTotalCompleteTask } from '../task'
import { TASK_RATE_TYPE } from '../../../constants'
export const checkTaskLimit = async (
context: IContext<{ activityId: string; taskType: ITaskType; itemId?: string }>,
{ userInfo, activityInfo }: IControllerInfos
) => {
const { taskType, itemId } = context.data
const { itemIds } = activityInfo?.tasks?.[taskType] || {}
if (!taskType) {
console.error('使用checkTaskLimit, 云函数必须传入taskType参数')
return
}
if (!activityInfo?.tasks?.[taskType]) {
return resultsModel.error(CODE_TYPES.SYSTEM_ERROR, `该活动缺少${taskType}配置项`)
}
if (itemId && !itemIds) {
return resultsModel.error(CODE_TYPES.SYSTEM_ERROR, `该任务缺少商品配置项`)
}
// B端配置商品ids不匹配正确
if (itemId && itemIds) {
const itemIdArray: number[] = Array.isArray(itemIds) ? itemIds : itemIds.split(',').map(v => +v)
if (!itemIdArray.includes(+itemId)) return resultsModel.error(CODE_TYPES.PARAMS_ERROR, '商品id不匹配')
}
const { taskRateType, times } = activityInfo?.tasks?.[taskType]
// 永久任务已经完成
const { completeTimes } = getTotalCompleteTask(taskType, userInfo)
const hasComplete = completeTimes && taskRateType === TASK_RATE_TYPE.FOREVER
if (hasComplete) return resultsModel.error(CODE_TYPES.ERROR_TASK_LIMIT, `该任务已完成,去看看其它任务吧~`)
// 每日任务今天已经完成
const { todayCompleteTimes, todayTaskInfo } = getTodayCompleteTask(taskType, userInfo)
const hasCompleteToday = times && todayCompleteTimes === times && taskRateType === TASK_RATE_TYPE.EVERYDAY
if (hasCompleteToday) {
return resultsModel.error(CODE_TYPES.ERROR_TASK_LIMIT, `该任务今天已完成,明天再来吧~`)
}
// 今日任务该商品已经完成
const itemHasCompleteToday =
todayTaskInfo.find(v => v.itemId && v.itemId === itemId) && taskRateType === TASK_RATE_TYPE.EVERYDAY
if (itemHasCompleteToday) {
return resultsModel.error(CODE_TYPES.PARAMS_ERROR, '今日该商品任务已完成')
}
}
/** @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 */
import { BaseDao } from '../../sdk'
/** @format */
export async function dbFindOne<T>(context: IContext<IParams>, dbName: string, query: IMongoQuery) {
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 格式化
*
......@@ -6,7 +10,6 @@
* @return {*}
* @memberof UserService
*/
export function formatUpdateUserProjection(projection: IUpdateQuery): IUpdateQuery {
projection['$set'] = projection['$set'] || {}
projection['$set'].updateTime = Date.now()
......@@ -31,3 +34,25 @@ export function formatUserNick(name: string) {
}
return newStr
}
/**
* 不通过数据库select的情况下 获取更新后的数据
*
* @export
* @param {IUserInfo} userInfo
* @param {IDecoratorUpdateQuery} projection
*/
export function formatUpdatedUserInfo(userInfo: IUserInfo, projection: IDecoratorUpdateQuery) {
let updatedUserInfo = assign({}, userInfo)
if (!isEmpty(projection.$set)) {
updatedUserInfo = merge({}, userInfo, projection.$set)
}
if (!isEmpty(projection.$inc)) {
Object.keys(projection.$inc).forEach(key => {
// let splitKey
})
updatedUserInfo = merge({}, userInfo, projection.$set)
}
}
......@@ -13,35 +13,31 @@ import { CodeType } from 'taobao-mini-sdk/lib/utils/codetypes'
export const sendTBAward = async (
context: IContext<IParams>,
session: string,
document: IAwards
awardInfo: IAwards
): Promise<IAwards | CodeType> => {
let { type, ename, _id, credits } = document
let { type, ename, _id, credits } = awardInfo
if (!type) {
return CODE_TYPES.PARAMS_ERROR
}
if (type === PRIZE_TYPE.OBJECT) {
return document
return awardInfo
}
// 发奖
try {
console.log(`type`, type)
// 若中奖为权益
if (type === PRIZE_TYPE.ENAME) {
console.log(`中权益`)
let { drawStatus, remark } = await sendEname(ename, _id, session, context)
console.log(`drawStatus, remark`, drawStatus, remark)
document.drawStatus = drawStatus
document.remark = remark
} else if (type === PRIZE_TYPE.CREDITS) {
let { drawStatus, remark } = await sendCredits(credits, session, context)
document.drawStatus = drawStatus
document.remark = remark
}
return document
} catch (e) {
console.log(`发奖错误`, e)
return CODE_TYPES.PARAMS_ERROR
console.log(`type`, type)
// 若中奖为权益
if (type === PRIZE_TYPE.ENAME) {
console.log(`中权益`)
let { drawStatus, remark } = await sendEname(ename, _id, session, context)
console.log(`drawStatus, remark`, drawStatus, remark)
awardInfo.drawStatus = drawStatus
awardInfo.remark = remark
}
if (type === PRIZE_TYPE.CREDITS) {
let { drawStatus, remark } = await sendCredits(credits, session, context)
awardInfo.drawStatus = drawStatus
awardInfo.remark = remark
}
return awardInfo
}
/**
......
/** @format */
import { getToday } from './getToday'
import { TASK_STATUS, TASK_RATE_TYPE } from '../../constants'
/**
* 根据任务类型获取任务完成情况
......@@ -10,7 +11,7 @@ import { getToday } from './getToday'
* @returns {array}
* @memberof TaskService
*/
export function getCompleteTaskByUserTaskInfo(
export function getTotalCompleteTask(
taskType: string,
userInfo: IUserInfo
): {
......@@ -57,3 +58,42 @@ export function getTodayCompleteTask(
todayTaskInfo: userInfo?.taskInfo?.[today]?.[taskType] || []
}
}
/**
*
* 根据用户和任务完成情况,设置任务状态
*
* @param {IUserInfo} useInfo
* @param {string} taskType
* @param {number} taskRateType
* @param {number} [limitTimesEverday] 每天限制次数 任务频率为每天的时候必填
* @return {taskTatus} 1未完成 2 待领取 3 已完成
* @memberof TaskService
*/
export function setTaskStatus(
useInfo: IUserInfo,
taskType: string,
taskRateType: number,
limitTimesEveryday: number = 1
): number {
const waitReceive = useInfo?.remainTimes?.[taskType] || 0
if (waitReceive) return TASK_STATUS.WAIT_RECEIVE
// 当天的完成次数
const { todayCompleteTimes } = getTodayCompleteTask(taskType, useInfo)
// 总共的完成次数
const { completeTimes } = getTotalCompleteTask(taskType, useInfo)
switch (taskRateType) {
case TASK_RATE_TYPE.FOREVER:
return completeTimes > 0 ? TASK_STATUS.DONE : TASK_STATUS.WAIT_DO
break
case TASK_RATE_TYPE.EVERYDAY:
return todayCompleteTimes >= limitTimesEveryday ? TASK_STATUS.DONE : TASK_STATUS.WAIT_DO
break
case TASK_RATE_TYPE.NOLIMIT:
return TASK_STATUS.WAIT_DO
break
}
}
......@@ -3,35 +3,30 @@
import { resultsModel } from '../../../sdk'
import { CODE_TYPES } from '../../../errorCode'
import { dbCount } from '../../common/db'
import { STAT_DB_NAME } from '../../../db'
import { STAT_DB_NAME, USER_DB_NAME } from '../../../db'
import { getToday } from '../getToday'
import { isNewVip, setNewVipUserData } from '../userUpdate'
import { update } from '../../../decorator/common/update'
export function updateVip(context: IContext<IParams>, { vipInfo, userInfo, activityInfo }: IControllerInfos) {
export async function updateVip(
context: IContext<IParams>,
{ vipInfo, userInfo, activityInfo }: IControllerInfos
): Promise<IDecoratorUpdateQuery> {
let { member } = userInfo
const { newMember } = member
const today = getToday()
const newVip = isNewVip(userInfo, vipInfo)
const memberReWards = activityInfo?.tasks?.member?.value
let projection = {
$set: {},
$inc: {},
$push: {}
}
if (newVip && !newMember) {
member = setNewVipUserData(member)
// @ts-ignore
projection.$set.member = member
projection.$inc['remainTimes.member'] = +memberReWards
projection.$push[`taskInfo.${today}.member`] = {
creatTime: Date.now()
}
}
return projection
return isNewVip(userInfo, vipInfo)
? {
$set: {
member: setNewVipUserData(member)
},
$inc: {
'remainTimes.member': +memberReWards
},
$push: {
[`taskInfo.${getToday()}.member`]: { creatTime: Date.now() }
}
}
: {}
}
......@@ -18,7 +18,7 @@ export function isNewVip(userInfo: IUserInfo, vipInfo: IVipInfo): boolean {
const { isVip } = vipInfo
return !flag && isVip
return !flag && isVip && !userInfo.member.newMember
}
export function setNewVipUserData(member: IMemberInfo): IMemberInfo {
......
......@@ -20,8 +20,6 @@ export * from './common/getUserOrderlist'
export * from './common/vip'
export * from './common/exportHandlers'
export * from './common/helper'
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