Commit 46d532cb authored by qinhaitao's avatar qinhaitao

feat: 🎸 增加排名

parent 6b9ac21a
...@@ -56,8 +56,7 @@ export declare const SHIP_STATUS: { ...@@ -56,8 +56,7 @@ export declare const SHIP_STATUS: {
HAS_SHIP: number; HAS_SHIP: number;
}; };
export declare enum STAT_TYPE { export declare enum STAT_TYPE {
CLICK_INVITE = 1, INITE_SUCCESS = 0
CLICK_FOLLOW_TASK = 2
} }
export declare const appId = "${\u9700\u8981\u8865\u5145}"; export declare const appId = "${\u9700\u8981\u8865\u5145}";
export declare const sellerId = "${\u5546\u94FAid}"; export declare const sellerId = "${\u5546\u94FAid}";
......
...@@ -86,8 +86,7 @@ exports.SHIP_STATUS = { ...@@ -86,8 +86,7 @@ exports.SHIP_STATUS = {
// 记录数据 // 记录数据
var STAT_TYPE; var STAT_TYPE;
(function (STAT_TYPE) { (function (STAT_TYPE) {
STAT_TYPE[STAT_TYPE["CLICK_INVITE"] = 1] = "CLICK_INVITE"; STAT_TYPE[STAT_TYPE["INITE_SUCCESS"] = 0] = "INITE_SUCCESS";
STAT_TYPE[STAT_TYPE["CLICK_FOLLOW_TASK"] = 2] = "CLICK_FOLLOW_TASK";
})(STAT_TYPE = exports.STAT_TYPE || (exports.STAT_TYPE = {})); })(STAT_TYPE = exports.STAT_TYPE || (exports.STAT_TYPE = {}));
exports.appId = '${需要补充}'; exports.appId = '${需要补充}';
// 商铺id 拼接vip链接用 // 商铺id 拼接vip链接用
......
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";AAAA,cAAc;;;;;;;;;;;;;AAEd,8CAA2B;AAE3B,cAAc;AACD,QAAA,OAAO,GAAG;IACrB,6CAA6C,EAAE,kBAAkB;IACjE,yBAAyB,EAAE,iBAAiB;IAC5C,oBAAoB,EAAE,aAAa;IACnC,sCAAsC,EAAE,gBAAgB;IACxD,iBAAiB,EAAE,cAAc;IACjC,YAAY,EAAE,YAAY;IAC1B,iBAAiB,EAAE,iBAAi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nB,CAAC,EAHW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAGpB;AAEY,QAAA,KAAK,GAAG,SAAS,CAAA;AAE9B,gBAAgB;AACH,QAAA,QAAQ,GAAG,SAAS,CAAA;AAEjC,cAAc;AACD,QAAA,UAAU,GAAW,qBAAmB,aAAO,CAAA"} {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";AAAA,cAAc;;;;;;;;;;;;;AAEd,8CAA2B;AAE3B,cAAc;AACD,QAAA,OAAO,GAAG;IACrB,6CAA6C,EAAE,kBAAkB;IACjE,yBAAyB,EAAE,iBAAiB;IAC5C,oBAAoB,EAAE,aAAa;IACnC,sCAAsC,EAAE,gBAAgB;IACxD,iBAAiB,EAAE,cAAc;IACjC,YAAY,EAAE,YAAY;IAC1B,iBAAiB,EAAE,iBAAiB;CACrC,CAAA;AAED,SAAS;AACI,QAAA,WAAW,GAAG;IACzB,MAAM;IACN,SAAS,EAAE,CAAC;IACZ,MAAM;IACN,UAAU,EAAE,CAAC;IACb,OAAO;IACP,OAAO,EAAE,CAAC;IACV,OAAO;IACP,IAAI,EAAE,CAAC;IACP,MAAM;IACN,OAAO,EAAE,CAAC;IACV,OAAO;IACP,KAAK,EAAE,CAAC;CACT,CAAA;AAED,OAAO;AACM,QAAA,2BAA2B,GAAa;IACnD,wBAAwB;IACxB,uBAAuB;IACvB,0BAA0B;IAC1B,oBAAoB;IACpB,gBAAgB;IAChB,qBAAqB;CACtB,CAAA;AAcD,UAAU;AACG,QAAA,cAAc,GAAG;IAC5B,OAAO,EAAE,CAAC;IACV,QAAQ,EAAE,CAAC;IACX,OAAO,EAAE,CAAC;CACX,CAAA;AAED,MAAM;AACO,QAAA,WAAW,GAAG;IACzB,OAAO,EAAE,CAAC;IACV,YAAY,EAAE,CAAC;IACf,IAAI,EAAE,CAAC,CAAC,MAAM;CACf,CAAA;AAED,OAAO;AACM,QAAA,UAAU,GAAG;IACxB,KAAK,EAAE,CAAC;IACR,OAAO,EAAE,CAAC;IACV,MAAM,EAAE,CAAC;IACT,MAAM,EAAE,CAAC;CACV,CAAA;AAED,OAAO;AACM,QAAA,eAAe,GAAG;IAC7B,OAAO,EAAE,CAAC;IACV,WAAW,EAAE,CAAC,CAAC,KAAK;CACrB,CAAA;AAED,WAAW;AACX,IAAY,UAGX;AAHD,WAAY,UAAU;IACpB,6CAAS,CAAA;IACT,mDAAY,CAAA;AACd,CAAC,EAHW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAGrB;AAED,MAAM;AACO,QAAA,WAAW,GAAG;IACzB,UAAU,EAAE,CAAC;IACb,OAAO,EAAE,CAAC;IACV,QAAQ,EAAE,CAAC;CACZ,CAAA;AAED,OAAO;AACP,IAAY,SAEX;AAFD,WAAY,SAAS;IACnB,2DAAa,CAAA;AACf,CAAC,EAFW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAEpB;AAEY,QAAA,KAAK,GAAG,SAAS,CAAA;AAE9B,gBAAgB;AACH,QAAA,QAAQ,GAAG,SAAS,CAAA;AAEjC,cAAc;AACD,QAAA,UAAU,GAAW,qBAAmB,aAAO,CAAA"}
\ No newline at end of file \ No newline at end of file
/** @format */ /** @format */
import { UserService, TaskService } from '../service'; import { UserService, AccessService, TaskService, StatService } from '../service';
export default class Share { export default class Share {
/** /**
* 获取邀请信息 * 获取邀请信息
...@@ -15,5 +15,5 @@ export default class Share { ...@@ -15,5 +15,5 @@ export default class Share {
doHelp(context: IContext<{ doHelp(context: IContext<{
activityId: string; activityId: string;
inviteId: string; inviteId: string;
}>, { userInfo, vipInfo, activityInfo }: IControllerInfos, [userService, taskService]: [UserService, TaskService]): Promise<IResult<boolean>>; }>, { userInfo, vipInfo, activityInfo }: IControllerInfos, [userService, taskService, statService]: [UserService, TaskService, StatService, AccessService]): Promise<IResult<boolean>>;
} }
...@@ -53,6 +53,7 @@ var sdk_1 = require("../sdk"); ...@@ -53,6 +53,7 @@ var sdk_1 = require("../sdk");
var utils_1 = require("../utils"); var utils_1 = require("../utils");
var service_1 = require("../service"); var service_1 = require("../service");
var registeInfos_1 = require("../decorator/registeInfos"); var registeInfos_1 = require("../decorator/registeInfos");
var constants_2 = require("../constants");
var Share = /** @class */ (function () { var Share = /** @class */ (function () {
function Share() { function Share() {
} }
...@@ -76,14 +77,14 @@ var Share = /** @class */ (function () { ...@@ -76,14 +77,14 @@ var Share = /** @class */ (function () {
*/ */
Share.prototype.doHelp = function (context, _a, _b) { Share.prototype.doHelp = function (context, _a, _b) {
var userInfo = _a.userInfo, vipInfo = _a.vipInfo, activityInfo = _a.activityInfo; var userInfo = _a.userInfo, vipInfo = _a.vipInfo, activityInfo = _a.activityInfo;
var userService = _b[0], taskService = _b[1]; var userService = _b[0], taskService = _b[1], statService = _b[2];
return __awaiter(this, void 0, void 0, function () { return __awaiter(this, void 0, void 0, function () {
var inviteId, openId, inviteUserInfo, taskInfo, tasks, value, isNewVip, isValidShare, today, inviteUserId; var _c, inviteId, activityId, openId, inviteUserInfo, userInviteSuccessCount, tasks, value, isNewVip, isValidShare, today, inviteUserId;
var _c; var _d;
return __generator(this, function (_d) { return __generator(this, function (_e) {
switch (_d.label) { switch (_e.label) {
case 0: case 0:
inviteId = context.data.inviteId; _c = context.data, inviteId = _c.inviteId, activityId = _c.activityId;
openId = context.openId; openId = context.openId;
if (openId === inviteId) if (openId === inviteId)
return [2 /*return*/, sdk_1.resultsModel.error(constants_1.CODE_TYPES.ERROR_NO_INVITE_SELF)]; return [2 /*return*/, sdk_1.resultsModel.error(constants_1.CODE_TYPES.ERROR_NO_INVITE_SELF)];
...@@ -91,52 +92,66 @@ var Share = /** @class */ (function () { ...@@ -91,52 +92,66 @@ var Share = /** @class */ (function () {
// inviteId的用户信息查询不到, 则inviteId无效 // inviteId的用户信息查询不到, 则inviteId无效
]; ];
case 1: case 1:
inviteUserInfo = _d.sent(); inviteUserInfo = _e.sent();
// inviteId的用户信息查询不到, 则inviteId无效 // inviteId的用户信息查询不到, 则inviteId无效
if (!inviteUserInfo) if (!inviteUserInfo)
return [2 /*return*/, sdk_1.resultsModel.error(constants_1.CODE_TYPES.ERROR_INVALID_INVITE_ID)]; return [2 /*return*/, sdk_1.resultsModel.error(constants_1.CODE_TYPES.ERROR_INVALID_INVITE_ID)
taskInfo = taskService.getCompleteTaskByUserTaskInfo('invites', inviteUserInfo).taskInfo; // 邀请成功有该用户信息
// 邀请成功列表有该用户信息 ];
if (taskInfo.some(function (v) { return v.openId === openId; })) { return [4 /*yield*/, statService.getStatCountByquery({
return [2 /*return*/, sdk_1.resultsModel.error(constants_1.CODE_TYPES.ERROR_AREADY_INVITE_SUCCESS)]; activityId: activityId,
} openId: openId,
type: constants_2.STAT_TYPE.INITE_SUCCESS
})];
case 2:
userInviteSuccessCount = _e.sent();
if (userInviteSuccessCount)
return [2 /*return*/, sdk_1.resultsModel.error(constants_1.CODE_TYPES.ERROR_AREADY_INVITE_SUCCESS)
// 获取活动基本信息
];
tasks = activityInfo.tasks; tasks = activityInfo.tasks;
value = tasks.invites.value; value = tasks.invites.value;
isNewVip = userService.checkNewVip(userInfo, vipInfo); isNewVip = utils_1.checkNewVip(userInfo, vipInfo);
if (!(isNewVip && !userInfo.member.newMember)) return [3 /*break*/, 3]; if (!(isNewVip && !userInfo.member.newMember)) return [3 /*break*/, 4];
return [4 /*yield*/, userService.updateUser(userInfo._id, { return [4 /*yield*/, userService.updateUser(userInfo._id, {
$set: { $set: {
member: userService.setNewVipUserData(userInfo.member) member: utils_1.setNewVipUserData(userInfo.member)
} }
})]; })];
case 2:
_d.sent();
_d.label = 3;
case 3: case 3:
_e.sent();
_e.label = 4;
case 4:
isValidShare = [isNewVip].every(function (v) { return !!v; }); isValidShare = [isNewVip].every(function (v) { return !!v; });
today = utils_1.getToday(); today = utils_1.getToday();
if (!isValidShare) return [3 /*break*/, 5]; if (!isValidShare)
return [2 /*return*/, sdk_1.resultsModel.error(constants_1.CODE_TYPES.ERROR_INVITE)
// 成功邀请
];
inviteUserId = inviteUserInfo._id; inviteUserId = inviteUserInfo._id;
// 增加邀请人的待领取次数和邀请记录 // 增加邀请人的待领取次数和邀请记录
return [4 /*yield*/, userService.updateUser(inviteUserId, { return [4 /*yield*/, userService.updateUser(inviteUserId, {
$inc: { $inc: {
'remainTimes.invites': value 'remainTimes.invites': value
}, },
$push: (_c = {}, $push: (_d = {},
_c["taskInfo." + today + ".invites"] = { openId: openId, createTime: Date.now() }, _d["taskInfo." + today + ".invites"] = { openId: openId, createTime: Date.now() },
_c) _d)
})]; })];
case 4: case 5:
// 增加邀请人的待领取次数和邀请记录 // 增加邀请人的待领取次数和邀请记录
_d.sent(); _e.sent();
_d.label = 5; return [4 /*yield*/, statService.addStat(constants_2.STAT_TYPE.INITE_SUCCESS, userInfo)];
case 5: return [2 /*return*/, sdk_1.resultsModel.success(true)]; case 6:
_e.sent();
return [2 /*return*/, sdk_1.resultsModel.success(true)];
} }
}); });
}); });
}; };
__decorate([ __decorate([
check_1.paramsCheck(['activityId']), check_1.paramsCheck(['activityId']),
check_1.userCheck({ intercept: true }),
registeInfos_1.registeInfos(['userInfo', 'activityInfo']), registeInfos_1.registeInfos(['userInfo', 'activityInfo']),
services_1.services([service_1.UserService]), services_1.services([service_1.UserService]),
__metadata("design:type", Function), __metadata("design:type", Function),
...@@ -146,8 +161,9 @@ var Share = /** @class */ (function () { ...@@ -146,8 +161,9 @@ var Share = /** @class */ (function () {
__decorate([ __decorate([
check_1.paramsCheck(['activityId', 'inviteId']), check_1.paramsCheck(['activityId', 'inviteId']),
check_1.activityTimeCheck, check_1.activityTimeCheck,
check_1.userCheck({ intercept: true }),
registeInfos_1.registeInfos(['userInfo', 'vipInfo', 'activityInfo']), registeInfos_1.registeInfos(['userInfo', 'vipInfo', 'activityInfo']),
services_1.services([service_1.UserService, service_1.TaskService, service_1.AccessService]), services_1.services([service_1.UserService, service_1.TaskService, service_1.StatService, service_1.AccessService]),
__metadata("design:type", Function), __metadata("design:type", Function),
__metadata("design:paramtypes", [Object, Object, Array]), __metadata("design:paramtypes", [Object, Object, Array]),
__metadata("design:returntype", Promise) __metadata("design:returntype", Promise)
......
{"version":3,"file":"share.controller.js","sourceRoot":"","sources":["../../src/controller/share.controller.ts"],"names":[],"mappings":";AAAA,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEd,4CAA2C;AAC3C,4CAA8E;AAC9E,kDAAgD;AAEhD,8BAAqC;AACrC,kCAAmC;AACnC,sCAAoE;AACpE,0DAAwD;AAExD;IAAA;IA8FA,CAAC;IA7FC;;OAEG;IAIG,4BAAY,GAAlB,UACE,OAEE,EACF,EAA8B;YAA5B,QAAQ,cAAA;;;;gBAOO,OAAO,GACpB,QAAQ,oBADY,CACZ;gBAEZ,sBAAO,kBAAY,CAAC,OAAO,CAAC;wBAC1B,OAAO,EAAE,OAAO;qBACjB,CAAC,EAAA;;;KACH;IACD;;OAEG;IAKG,sBAAM,GAAZ,UACE,OAGE,EACF,EAAqD,EACrD,EAAsD;YADpD,QAAQ,cAAA,EAAE,OAAO,aAAA,EAAE,YAAY,kBAAA;YAChC,WAAW,QAAA,EAAE,WAAW,QAAA;;;;;;;wBAEjB,QAAQ,GAAK,OAAO,CAAC,IAAI,SAAjB,CAAiB;wBACzB,MAAM,GAAK,OAAO,OAAZ,CAAY;wBAE1B,IAAI,MAAM,KAAK,QAAQ;4BAAE,sBAAO,kBAAY,CAAC,KAAK,CAAC,sBAAU,CAAC,oBAAoB,CAAC,EAAA;wBAEjD,qBAAM,WAAW,CAAC,mBAAmB,CAAC,QAAQ,CAAC;4BACjF,iCAAiC;0BADgD;;wBAA3E,cAAc,GAAc,SAA+C;wBACjF,iCAAiC;wBACjC,IAAI,CAAC,cAAc;4BAAE,sBAAO,kBAAY,CAAC,KAAK,CAAC,sBAAU,CAAC,uBAAuB,CAAC,EAAA;wBAE1E,QAAQ,GAAK,WAAW,CAAC,6BAA6B,CAAC,SAAS,EAAE,cAAc,CAAC,SAAzE,CAAyE;wBAE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@ export default class User { ...@@ -23,4 +23,33 @@ export default class User {
* 获取会员信息 * 获取会员信息
*/ */
getVipInfo(context: IContext<IVipParams>, { session, activityUserNick }: IControllerInfos): Promise<IResult<IVipInfo>>; getVipInfo(context: IContext<IVipParams>, { session, activityUserNick }: IControllerInfos): Promise<IResult<IVipInfo>>;
/**
* 获取排行榜
*/
getRankList(context: IContext<{
activityId: string;
}>, { userInfo }: IControllerInfos, [userService]: [UserService]): Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result<{
userNick: string;
avatar: string;
rank: number;
score: any;
list: {
userNick: string;
rank: number;
_id?: string;
id?: string;
activityId: string;
avatar: string;
openId: string;
createTime: number;
updateTime: number;
createDay?: string;
inviteId?: string;
member?: IMemberInfo;
follow?: IFollowInfo;
remainTimes?: IRemainTimesInfo;
taskInfo?: object;
login?: object;
}[];
}, true>>;
} }
...@@ -106,6 +106,37 @@ var User = /** @class */ (function () { ...@@ -106,6 +106,37 @@ var User = /** @class */ (function () {
}); });
}); });
}; };
/**
* 获取排行榜
*/
User.prototype.getRankList = function (context, _a, _b) {
var userInfo = _a.userInfo;
var userService = _b[0];
return __awaiter(this, void 0, void 0, function () {
var sortKey, sortTime, userNick, avatar, rank, list;
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
sortKey = 'score';
sortTime = 'updateScoreTime';
userNick = userInfo.userNick, avatar = userInfo.avatar;
return [4 /*yield*/, userService.getMyRank(sortKey, sortTime, userInfo[sortKey])];
case 1:
rank = _c.sent();
return [4 /*yield*/, userService.getRank(sortKey, sortTime, 200)];
case 2:
list = _c.sent();
return [2 /*return*/, sdk_1.resultsModel.success({
userNick: userNick,
avatar: avatar,
rank: rank,
score: userInfo[sortKey],
list: list
})];
}
});
});
};
__decorate([ __decorate([
decorator_1.paramsCheck(['activityId', 'userNick', 'avatar', 'isFollow']), decorator_1.paramsCheck(['activityId', 'userNick', 'avatar', 'isFollow']),
decorator_1.activityTimeCheck, decorator_1.activityTimeCheck,
...@@ -123,6 +154,14 @@ var User = /** @class */ (function () { ...@@ -123,6 +154,14 @@ var User = /** @class */ (function () {
__metadata("design:paramtypes", [Object, Object]), __metadata("design:paramtypes", [Object, Object]),
__metadata("design:returntype", Promise) __metadata("design:returntype", Promise)
], User.prototype, "getVipInfo", null); ], User.prototype, "getVipInfo", null);
__decorate([
decorator_1.paramsCheck(['activityId']),
decorator_1.userCheck({ intercept: true }),
decorator_1.services([service_1.UserService]),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, Object, Array]),
__metadata("design:returntype", Promise)
], User.prototype, "getRankList", null);
return User; return User;
}()); }());
exports.default = User; exports.default = User;
......
{"version":3,"file":"user.controller.js","sourceRoot":"","sources":["../../src/controller/user.controller.ts"],"names":[],"mappings":";AAAA,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEd,0CAAqF;AACrF,8BAAqC;AACrC,sCAAuD;AACvD,4CAAiE;AAcjE;IAAA;IA4CA,CAAC;IA3CC;;OAEG;IAKG,oBAAK,GAAX,UACE,OAA+B,EAC/B,EAAqD,EACrD,EAA0D;YADxD,QAAQ,cAAA,EAAE,OAAO,aAAA,EAAE,YAAY,kBAAA;YAChC,WAAW,QAAA,EAAE,aAAa,QAAA;;;;;;wBAEnB,MAAM,GAAK,OAAO,OAAZ,CAAY;6BAEtB,CAAC,QAAQ,EAAT,wBAAS;wBACA,qBAAM,WAAW,CAAC,YAAY,CAAC,OAAO,EAAE,YAAY,CAAC,EAAA;;wBAAhE,QAAQ,GAAG,SAAqD,CAAA;;4BAErD,qBAAM,WAAW,CAAC,cAAc,CAAC,OAAO,EAAE,QAAQ,EAAE,YAAY,CAAC,EAAA;;wBAA5E,QAAQ,GAAG,SAAiE,CAAA;;;oBAG9E,UAAU;oBACV,qBAAM,aAAa,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAA;;wBADvC,UAAU;wBACV,SAAuC,CAAA;wBAEvC,sBAAO,kBAAY,CAAC,OAAO,CAAC;gCA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I,GAAG,SAAiE;wBAEjE,qBAAM,WAAW,CAAC,OAAO,CAAC,OAAO,EAAE,QAAQ,EAAE,GAAG,CAAC,EAAA;;wBAAxD,IAAI,GAAG,SAAiD;wBAE9D,sBAAO,kBAAY,CAAC,OAAO,CAAC;gCAC1B,QAAQ,UAAA;gCACR,MAAM,QAAA;gCACN,IAAI,MAAA;gCACJ,KAAK,EAAE,QAAQ,CAAC,OAAO,CAAC;gCACxB,IAAI,MAAA;6BACL,CAAC,EAAA;;;;KACH;IAlED;QAJC,uBAAW,CAAC,CAAC,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC;QAC7D,6BAAiB;QACjB,wBAAY,CAAC,CAAC,UAAU,EAAE,SAAS,EAAE,cAAc,CAAC,CAAC;QACrD,oBAAQ,CAAC,CAAC,qBAAW,EAAE,uBAAa,CAAC,CAAC;;;;qCAoBtC;IAOD;QAHC,uBAAW,CAAC,CAAC,YAAY,CAAC,CAAC;QAC3B,wBAAY,CAAC,CAAC,SAAS,CAAC,CAAC;QACzB,oBAAQ,CAAC,EAAE,CAAC;;;;0CAUZ;IAQD;QAHC,uBAAW,CAAC,CAAC,YAAY,CAAC,CAAC;QAC3B,qBAAS,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;QAC9B,oBAAQ,CAAC,CAAC,qBAAW,CAAC,CAAC;;;;2CAwBvB;IACH,WAAC;CAAA,AA3ED,IA2EC;kBA3EoB,IAAI"}
\ No newline at end of file \ No newline at end of file
...@@ -17,12 +17,38 @@ declare const _default: { ...@@ -17,12 +17,38 @@ declare const _default: {
list: IAwards[]; list: IAwards[];
}>>; }>>;
receiveObjectPrize: (context: IContext<import("./controller/awards.controller").IReceiveOjectParams>, {}: {}, [awardSer]: [import("./service").AwardsService]) => Promise<IResult<boolean>>; receiveObjectPrize: (context: IContext<import("./controller/awards.controller").IReceiveOjectParams>, {}: {}, [awardSer]: [import("./service").AwardsService]) => Promise<IResult<boolean>>;
receiveEnamePrize: (context: IContext<import("./controller/awards.controller").IReceiveEnameParams>, {}: {}, [awardSer]: [import("./service").AwardsService]) => Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result<string | boolean | object | string[] | object[] | number[], false> | import("taobao-mini-sdk/lib/utils/resultmodel").Result<import("taobao-mini-sdk/lib/utils/codetypes").CodeType | IAwards, true>>; receiveEnamePrize: (context: IContext<import("./controller/awards.controller").IReceiveEnameParams>, {}: {}, [awardSer]: [import("./service").AwardsService]) => Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result<string | boolean | object | string[] | object[] | number[], false> | import("taobao-mini-sdk/lib/utils/resultmodel").Result<IAwards | import("taobao-mini-sdk/lib/utils/codetypes").CodeType, true>>;
doHelp: (context: IContext<{ doHelp: (context: IContext<{
activityId: string; activityId: string;
inviteId: string; inviteId: string;
}>, { userInfo, vipInfo, activityInfo }: IControllerInfos, [userService, taskService]: [import("./service/user.service").default, import("./service").TaskService]) => Promise<IResult<boolean>>; }>, { userInfo, vipInfo, activityInfo }: IControllerInfos, [userService, taskService, statService]: [import("./service/user.service").default, import("./service").TaskService, import("./service").StatService, import("./service").AccessService]) => Promise<IResult<boolean>>;
getStats: (context: IContext<import("./controller/stat.controller").IGetStatsParams>) => Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result<string | boolean | object | string[] | object[] | number[], false> | import("taobao-mini-sdk/lib/utils/resultmodel").Result<any, true>>; getStats: (context: IContext<import("./controller/stat.controller").IGetStatsParams>) => Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result<string | boolean | object | string[] | object[] | number[], false> | import("taobao-mini-sdk/lib/utils/resultmodel").Result<any, true>>;
addStat: (context: IContext<import("./controller/stat.controller").IAddStatsParams>, { userInfo }: IControllerInfos, [statService]: [import("./service").StatService]) => Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result<boolean, true>>; addStat: (context: IContext<import("./controller/stat.controller").IAddStatsParams>, { userInfo }: IControllerInfos, [statService]: [import("./service").StatService]) => Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result<boolean, true>>;
getRankList: (context: IContext<{
activityId: string;
}>, { userInfo }: IControllerInfos, [userService]: [import("./service/user.service").default]) => Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result<{
userNick: string;
avatar: string;
rank: number;
score: any;
list: {
userNick: string;
rank: number;
_id?: string;
id?: string;
activityId: string;
avatar: string;
openId: string;
createTime: number;
updateTime: number;
createDay?: string;
inviteId?: string;
member?: IMemberInfo;
follow?: IFollowInfo;
remainTimes?: IRemainTimesInfo;
taskInfo?: object;
login?: object;
}[];
}, true>>;
}; };
export default _default; export default _default;
...@@ -8,7 +8,7 @@ var base_controller_1 = require("./controller/base.controller"); ...@@ -8,7 +8,7 @@ var base_controller_1 = require("./controller/base.controller");
var awards_controller_1 = require("./controller/awards.controller"); var awards_controller_1 = require("./controller/awards.controller");
var share_controller_1 = require("./controller/share.controller"); var share_controller_1 = require("./controller/share.controller");
var stat_controller_1 = require("./controller/stat.controller"); var stat_controller_1 = require("./controller/stat.controller");
var _a = new user_controller_1.default(), login = _a.login, getVipInfo = _a.getVipInfo; var _a = new user_controller_1.default(), login = _a.login, getVipInfo = _a.getVipInfo, getRankList = _a.getRankList;
var _b = new task_controller_1.default(), getTaskList = _b.getTaskList, receiveTaskRewards = _b.receiveTaskRewards, getCollectGoodsList = _b.getCollectGoodsList, // 获取收藏商品列表,包含收藏状态 var _b = new task_controller_1.default(), getTaskList = _b.getTaskList, receiveTaskRewards = _b.receiveTaskRewards, getCollectGoodsList = _b.getCollectGoodsList, // 获取收藏商品列表,包含收藏状态
doFollowTask = _b.doFollowTask, doJumpLinkTask = _b.doJumpLinkTask, doBrowseGoodsTask = _b.doBrowseGoodsTask, doCollectGoodsTask = _b.doCollectGoodsTask, doExchangeCreditsTask = _b.doExchangeCreditsTask; doFollowTask = _b.doFollowTask, doJumpLinkTask = _b.doJumpLinkTask, doBrowseGoodsTask = _b.doBrowseGoodsTask, doCollectGoodsTask = _b.doCollectGoodsTask, doExchangeCreditsTask = _b.doExchangeCreditsTask;
var _c = new base_controller_1.default(), getActivityBaseInfoById = _c.getActivityBaseInfoById, getItemListByItemIds = _c.getItemListByItemIds; var _c = new base_controller_1.default(), getActivityBaseInfoById = _c.getActivityBaseInfoById, getItemListByItemIds = _c.getItemListByItemIds;
...@@ -26,6 +26,7 @@ exports.default = { ...@@ -26,6 +26,7 @@ exports.default = {
receiveEnamePrize: receiveEnamePrize, receiveEnamePrize: receiveEnamePrize,
doHelp: doHelp, doHelp: doHelp,
getStats: getStats, getStats: getStats,
addStat: addStat addStat: addStat,
getRankList: getRankList
}; };
//# sourceMappingURL=index.js.map //# sourceMappingURL=index.js.map
\ No newline at end of file
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,cAAc;;AAEd,2CAA2C;AAC3C,gEAAyD;AACzD,gEAAyD;AACzD,gEAAyD;AACzD,oEAA6D;AAC7D,kEAA2D;AAC3D,gEAAyD;AAEnD,IAAA,KAAwB,IAAI,yBAAc,EAAE,EAA1C,KAAK,WAAA,EAAE,UAAU,gBAAyB,CAAA;AAC5C,IAAA,KASF,IAAI,yBAAc,EAAE,EARtB,WAAW,iBAAA,EACX,kBAAkB,wBAAA,EAClB,mBAAmB,yBAAA,EAAE,kBAAkB;AACvC,YAAY,kBAAA,EACZ,cAAc,oBAAA,EACd,iBAAiB,uBAAA,EACjB,kBAAkB,wBAAA,EAClB,qBAAqB,2BACC,CAAA;AAElB,IAAA,KAAoD,IAAI,yBAAc,EAAE,EAAtE,uBAAuB,6BAAA,EAAE,oBAAoB,0BAAyB,CAAA;AAExE,IAAA,KAA8E,IAAI,2BAAgB,EAAE,EAAlG,cAAc,oBAAA,EAAE,kBAAkB,wBAAA,EAAE,iBAAiB,uBAAA,EAAE,gBAAgB,sBAA2B,CAAA;AAElG,IAAA,MAAM,GAAK,IAAI,0BAAe,EAAE,OAA1B,CAA0B;AAElC,IAAA,KAAwB,IAAI,yBAAc,EA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B,uBAAuB,yBAAA;IACvB,cAAc,gBAAA;IACd,kBAAkB,oBAAA;IAClB,iBAAiB,mBAAA;IACjB,MAAM,QAAA;IACN,QAAQ,UAAA;IACR,OAAO,SAAA;IACP,WAAW,aAAA;CACZ,CAAA"}
\ No newline at end of file \ No newline at end of file
...@@ -17,4 +17,5 @@ export default class StatService { ...@@ -17,4 +17,5 @@ export default class StatService {
* @memberof StatService * @memberof StatService
*/ */
addStat(type: number, userInfo?: IUserInfo, customStatData?: object): Promise<string>; addStat(type: number, userInfo?: IUserInfo, customStatData?: object): Promise<string>;
getStatCountByquery(query: IMongoQuery): Promise<number>;
} }
...@@ -89,6 +89,16 @@ var StatService = /** @class */ (function () { ...@@ -89,6 +89,16 @@ var StatService = /** @class */ (function () {
}); });
}); });
}; };
StatService.prototype.getStatCountByquery = function (query) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.statdao.count(query)];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
return StatService; return StatService;
}()); }());
exports.default = StatService; exports.default = StatService;
......
{"version":3,"file":"stat.service.js","sourceRoot":"","sources":["../../src/service/stat.service.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,8BAAgC;AAChC,4BAAoC;AACpC,kCAAmC;AACnC,0CAAwC;AAExC;IAGE,qBAAY,OAA0B;QACpC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,OAAO,GAAG,IAAI,aAAO,CAAC,OAAO,EAAE,iBAAY,CAAC,CAAA;IACnD,CAAC;IAED;;;;;;;;OAQG;IACG,6BAAO,GAAb,UAAc,IAAY,EAAE,QAAqC,EAAE,cAA2B;QAAlE,yBAAA,EAAA,WAAsB,EAAe;QAAE,+BAAA,EAAA,mBAA2B;;;;;;wBACpF,MAAM,GAAK,IAAI,CAAC,OAAO,OAAjB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B,QAAQ,UAAA;gCACR,MAAM,QAAA,IACH,cAAc,KACjB,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE,EACtB,SAAS,EAAE,gBAAQ,EAAE,IACrB,EAAA;4BATF,sBAAO,SASL,EAAA;;;;KACH;IAEK,yCAAmB,GAAzB,UAA0B,KAAkB;;;;4BACnC,qBAAM,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,EAAA;4BAAtC,sBAAO,SAA+B,EAAA;;;;KACvC;IACH,kBAAC;AAAD,CAAC,AApCD,IAoCC"}
\ No newline at end of file \ No newline at end of file
...@@ -115,7 +115,7 @@ var TaskService = /** @class */ (function (_super) { ...@@ -115,7 +115,7 @@ var TaskService = /** @class */ (function (_super) {
var member = userInfo.member; var member = userInfo.member;
var newMember = member.newMember; var newMember = member.newMember;
var today = utils_1.getToday(); var today = utils_1.getToday();
var isNewVip = this.checkNewVip(userInfo, vipInfo); var isNewVip = utils_1.checkNewVip(userInfo, vipInfo);
var value = tasks.member.value; var value = tasks.member.value;
var projection = { var projection = {
$set: {}, $set: {},
...@@ -123,7 +123,7 @@ var TaskService = /** @class */ (function (_super) { ...@@ -123,7 +123,7 @@ var TaskService = /** @class */ (function (_super) {
$push: {} $push: {}
}; };
if (isNewVip && !newMember) { if (isNewVip && !newMember) {
member = this.setNewVipUserData(member); member = utils_1.setNewVipUserData(member);
// @ts-ignore // @ts-ignore
projection.$set.member = member; projection.$set.member = member;
projection.$inc['remainTimes.member'] = +value; projection.$inc['remainTimes.member'] = +value;
...@@ -229,7 +229,7 @@ var TaskService = /** @class */ (function (_super) { ...@@ -229,7 +229,7 @@ var TaskService = /** @class */ (function (_super) {
_id = userInfo._id, follow = userInfo.follow; _id = userInfo._id, follow = userInfo.follow;
tasks = activityInfo.tasks; tasks = activityInfo.tasks;
value = (tasks || {}).follow.value; value = (tasks || {}).follow.value;
followInfo = this.setNewFollowUserData(follow); followInfo = utils_1.setNewFollowUserData(follow);
return [4 /*yield*/, this.updateUser(_id, { return [4 /*yield*/, this.updateUser(_id, {
$set: { $set: {
follow: followInfo follow: followInfo
......
This diff is collapsed.
...@@ -36,47 +36,39 @@ declare class UserService extends BaseService { ...@@ -36,47 +36,39 @@ declare class UserService extends BaseService {
* @returns 若更新成功,返回为1; 若更新失败,返回为 0 或系统直接报错 * @returns 若更新成功,返回为1; 若更新失败,返回为 0 或系统直接报错
*/ */
updateUser(_id: string, projection: IUpdateQuery): Promise<number>; updateUser(_id: string, projection: IUpdateQuery): Promise<number>;
/** getRank(sortValueKey: string, sortTimeKey: string, limit?: number): Promise<{
* @desc 排行榜 userNick: string;
* @param {查询条件} match rank: number;
* @param {排序规则} sort _id?: string;
* @param {查询条数} limit id?: string;
*/ activityId: string;
getRank(match: Object, sort: Object, limit: number): Promise<any>; avatar: string;
/** openId: string;
* @desc 获取我的排名 createTime: number;
* @param {查询条件} match updateTime: number;
* @param {排序规则} sort createDay?: string;
*/ inviteId?: string;
getMyRank(match: Object, sort: Object): Promise<any>; member?: IMemberInfo;
follow?: IFollowInfo;
remainTimes?: IRemainTimesInfo;
taskInfo?: object;
login?: object;
}[]>;
/** /**
* 获取用户排名 * 获取用户排名
*/
getUserRank(hotValue: number): Promise<string | number>;
/**
* updateUser projection 格式化
* *
* @param {object} projection * @param {string} sortValueKey 排名字段
* @return {*} * @param {number} userValue
* @param {string} sortTimeKey
* @return {number} 排行
* @memberof UserService * @memberof UserService
*/ */
formatUpdateUserProjection(projection: IUpdateQuery): IUpdateQuery; getMyRank(sortValueKey: string, sortTimeKey: string, userValue: number): Promise<number>;
/** /**
* @desc 根据用户主键id查找用户详情 * @desc 根据用户主键id查找用户详情
* @param {用户的主键id} _id * @param {用户的主键id} _id
* @returns 若用户不存在,返回null; 用户存在,返回用户信息(object对象) * @returns 若用户不存在,返回null; 用户存在,返回用户信息(object对象)
*/ */
getUserInfoById(_id: string): Promise<unknown>; getUserInfoById(_id: string): Promise<unknown>;
/**
*判断是否新会员
*
* @param {IUserInfo} userInfo
* @param {IVipInfo} vipInfo
* @returns {boolean}
* @memberof UserService
*/
checkNewVip(userInfo: IUserInfo, vipInfo: IVipInfo): boolean;
setNewVipUserData(member: IMemberInfo): IMemberInfo;
setNewFollowUserData(follow: IFollowInfo): IFollowInfo;
} }
export default UserService; export default UserService;
This diff is collapsed.
This diff is collapsed.
...@@ -9,3 +9,5 @@ export * from './package/getUserOrderlist'; ...@@ -9,3 +9,5 @@ export * from './package/getUserOrderlist';
export * from './package/vip'; export * from './package/vip';
export * from './package/exportHandlers'; export * from './package/exportHandlers';
export * from './package/helper'; export * from './package/helper';
export * from './package/userUpdate';
export * from './package/format';
...@@ -25,4 +25,6 @@ __exportStar(require("./package/getUserOrderlist"), exports); ...@@ -25,4 +25,6 @@ __exportStar(require("./package/getUserOrderlist"), exports);
__exportStar(require("./package/vip"), exports); __exportStar(require("./package/vip"), exports);
__exportStar(require("./package/exportHandlers"), exports); __exportStar(require("./package/exportHandlers"), exports);
__exportStar(require("./package/helper"), exports); __exportStar(require("./package/helper"), exports);
__exportStar(require("./package/userUpdate"), exports);
__exportStar(require("./package/format"), exports);
//# sourceMappingURL=index.js.map //# sourceMappingURL=index.js.map
\ No newline at end of file
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";AAAA,cAAc;;;;;;;;;;;;AAEd,cAAc;AACd,uDAAoC;AAEpC,iBAAiB;AACjB,qDAAkC;AAElC,gBAAgB;AAChB,wDAAqC;AAErC,SAAS;AACT,uDAAoC;AAEpC,mDAAgC;AAEhC,iDAA8B;AAE9B,6DAA0C;AAE1C,gDAA6B;AAE7B,2DAAwC;AAExC,mDAAgC"} {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";AAAA,cAAc;;;;;;;;;;;;AAEd,cAAc;AACd,uDAAoC;AAEpC,iBAAiB;AACjB,qDAAkC;AAElC,gBAAgB;AAChB,wDAAqC;AAErC,SAAS;AACT,uDAAoC;AAEpC,mDAAgC;AAEhC,iDAA8B;AAE9B,6DAA0C;AAE1C,gDAA6B;AAE7B,2DAAwC;AAExC,mDAAgC;AAEhC,uDAAoC;AAEpC,mDAAgC"}
\ No newline at end of file \ No newline at end of file
...@@ -94,8 +94,7 @@ export const SHIP_STATUS = { ...@@ -94,8 +94,7 @@ export const SHIP_STATUS = {
// 记录数据 // 记录数据
export enum STAT_TYPE { export enum STAT_TYPE {
CLICK_INVITE = 1, INITE_SUCCESS
CLICK_FOLLOW_TASK
} }
export const appId = '${需要补充}' export const appId = '${需要补充}'
......
...@@ -5,15 +5,17 @@ import { paramsCheck, userCheck, activityTimeCheck } from '../decorator/check' ...@@ -5,15 +5,17 @@ import { paramsCheck, userCheck, activityTimeCheck } from '../decorator/check'
import { services } from '../decorator/services' import { services } from '../decorator/services'
import { resultsModel } from '../sdk' import { resultsModel } from '../sdk'
import { getToday } from '../utils' import { getToday, setNewVipUserData, checkNewVip } from '../utils'
import { UserService, AccessService, TaskService } from '../service' import { UserService, AccessService, TaskService, StatService } from '../service'
import { registeInfos } from '../decorator/registeInfos' import { registeInfos } from '../decorator/registeInfos'
import { STAT_TYPE } from '../constants'
export default class Share { export default class Share {
/** /**
* 获取邀请信息 * 获取邀请信息
*/ */
@paramsCheck(['activityId']) @paramsCheck(['activityId'])
@userCheck({ intercept: true })
@registeInfos(['userInfo', 'activityInfo']) @registeInfos(['userInfo', 'activityInfo'])
@services([UserService]) @services([UserService])
async getShareInfo( async getShareInfo(
...@@ -39,31 +41,34 @@ export default class Share { ...@@ -39,31 +41,34 @@ export default class Share {
*/ */
@paramsCheck(['activityId', 'inviteId']) @paramsCheck(['activityId', 'inviteId'])
@activityTimeCheck @activityTimeCheck
@userCheck({ intercept: true })
@registeInfos(['userInfo', 'vipInfo', 'activityInfo']) @registeInfos(['userInfo', 'vipInfo', 'activityInfo'])
@services([UserService, TaskService, AccessService]) @services([UserService, TaskService, StatService, AccessService])
async doHelp( async doHelp(
context: IContext<{ context: IContext<{
activityId: string activityId: string
inviteId: string inviteId: string
}>, }>,
{ userInfo, vipInfo, activityInfo }: IControllerInfos, { userInfo, vipInfo, activityInfo }: IControllerInfos,
[userService, taskService]: [UserService, TaskService] [userService, taskService, statService]: [UserService, TaskService, StatService, AccessService]
): Promise<IResult<boolean>> { ): Promise<IResult<boolean>> {
const { inviteId } = context.data const { inviteId, activityId } = context.data
const { openId } = context const { openId } = context
if (openId === inviteId) return resultsModel.error(CODE_TYPES.ERROR_NO_INVITE_SELF) if (openId === inviteId) return resultsModel.error(CODE_TYPES.ERROR_NO_INVITE_SELF)
const inviteUserInfo: IUserInfo = await userService.getUserInfoByOpenId(inviteId) const inviteUserInfo: IUserInfo = await userService.getUserInfoByOpenId(inviteId)
// inviteId的用户信息查询不到, 则inviteId无效 // inviteId的用户信息查询不到, 则inviteId无效
if (!inviteUserInfo) return resultsModel.error(CODE_TYPES.ERROR_INVALID_INVITE_ID) if (!inviteUserInfo) return resultsModel.error(CODE_TYPES.ERROR_INVALID_INVITE_ID)
const { taskInfo } = taskService.getCompleteTaskByUserTaskInfo('invites', inviteUserInfo) // 邀请成功有该用户信息
const userInviteSuccessCount = await statService.getStatCountByquery({
// 邀请成功列表有该用户信息 activityId,
if (taskInfo.some(v => v.openId === openId)) { openId,
return resultsModel.error(CODE_TYPES.ERROR_AREADY_INVITE_SUCCESS) type: STAT_TYPE.INITE_SUCCESS
} })
if (userInviteSuccessCount) return resultsModel.error(CODE_TYPES.ERROR_AREADY_INVITE_SUCCESS)
// 获取活动基本信息 // 获取活动基本信息
const { tasks } = activityInfo const { tasks } = activityInfo
...@@ -73,13 +78,13 @@ export default class Share { ...@@ -73,13 +78,13 @@ export default class Share {
}: ITasks = tasks }: ITasks = tasks
// 新会员 // 新会员
const isNewVip = userService.checkNewVip(userInfo, vipInfo) const isNewVip = checkNewVip(userInfo, vipInfo)
// 新会员更新状态 // 新会员更新状态
if (isNewVip && !userInfo.member.newMember) { if (isNewVip && !userInfo.member.newMember) {
await userService.updateUser(userInfo._id, { await userService.updateUser(userInfo._id, {
$set: { $set: {
member: userService.setNewVipUserData(userInfo.member) member: setNewVipUserData(userInfo.member)
} }
}) })
} }
...@@ -88,7 +93,9 @@ export default class Share { ...@@ -88,7 +93,9 @@ export default class Share {
const isValidShare = [isNewVip].every(v => !!v) const isValidShare = [isNewVip].every(v => !!v)
const today = getToday() const today = getToday()
if (isValidShare) { if (!isValidShare) return resultsModel.error(CODE_TYPES.ERROR_INVITE)
// 成功邀请
const { _id: inviteUserId } = inviteUserInfo const { _id: inviteUserId } = inviteUserInfo
// 增加邀请人的待领取次数和邀请记录 // 增加邀请人的待领取次数和邀请记录
await userService.updateUser(inviteUserId, { await userService.updateUser(inviteUserId, {
...@@ -99,7 +106,8 @@ export default class Share { ...@@ -99,7 +106,8 @@ export default class Share {
[`taskInfo.${today}.invites`]: { openId, createTime: Date.now() } [`taskInfo.${today}.invites`]: { openId, createTime: Date.now() }
} }
}) })
}
await statService.addStat(STAT_TYPE.INITE_SUCCESS, userInfo)
return resultsModel.success(true) return resultsModel.success(true)
} }
......
/** @format */ /** @format */
import { services, paramsCheck, activityTimeCheck, registeInfos } from '../decorator' import { services, paramsCheck, activityTimeCheck, registeInfos, userCheck } from '../decorator'
import { resultsModel } from '../sdk' import { resultsModel } from '../sdk'
import { UserService, AccessService } from '../service' import { UserService, AccessService } from '../service'
import { formatVipCbUrl, getShopVip } from '../utils/package/vip' import { formatVipCbUrl, getShopVip } from '../utils/package/vip'
...@@ -61,4 +61,35 @@ export default class User { ...@@ -61,4 +61,35 @@ export default class User {
return resultsModel.success(result) return resultsModel.success(result)
} }
/**
* 获取排行榜
*/
@paramsCheck(['activityId'])
@userCheck({ intercept: true })
@services([UserService])
async getRankList(
context: IContext<{
activityId: string
}>,
{ userInfo }: IControllerInfos,
[userService]: [UserService]
) {
const sortKey = 'score'
const sortTime = 'updateScoreTime'
const { userNick, avatar } = userInfo
const rank = await userService.getMyRank(sortKey, sortTime, userInfo[sortKey])
const list = await userService.getRank(sortKey, sortTime, 200)
return resultsModel.success({
userNick,
avatar,
rank,
score: userInfo[sortKey],
list
})
}
} }
...@@ -68,6 +68,10 @@ export const BusinessError = { ...@@ -68,6 +68,10 @@ export const BusinessError = {
code: `430008`, code: `430008`,
defaultMsg: `自己不能给自己助力` defaultMsg: `自己不能给自己助力`
}, },
ERROR_INVITE: {
code: `430009`,
defaultMsg: `只有新会员才能助力哦~`
},
ERROR_FORBIDDEN_OPE: { ERROR_FORBIDDEN_OPE: {
code: `530001`, code: `530001`,
defaultMsg: `非法操作` defaultMsg: `非法操作`
......
...@@ -8,7 +8,7 @@ import AwardsController from './controller/awards.controller' ...@@ -8,7 +8,7 @@ import AwardsController from './controller/awards.controller'
import ShareController from './controller/share.controller' import ShareController from './controller/share.controller'
import StatController from './controller/stat.controller' import StatController from './controller/stat.controller'
const { login, getVipInfo } = new UserController() const { login, getVipInfo, getRankList } = new UserController()
const { const {
getTaskList, getTaskList,
receiveTaskRewards, receiveTaskRewards,
...@@ -39,5 +39,6 @@ export default { ...@@ -39,5 +39,6 @@ export default {
receiveEnamePrize, receiveEnamePrize,
doHelp, doHelp,
getStats, getStats,
addStat addStat,
getRankList
} }
...@@ -41,4 +41,8 @@ export default class StatService { ...@@ -41,4 +41,8 @@ export default class StatService {
createDay: getToday() createDay: getToday()
}) })
} }
async getStatCountByquery(query: IMongoQuery) {
return await this.statdao.count(query)
}
} }
...@@ -6,7 +6,17 @@ ...@@ -6,7 +6,17 @@
import { merge } from 'lodash' import { merge } from 'lodash'
import UserService from './user.service' import UserService from './user.service'
import { getToday, getUserOrderlist, logger, generateVipUrl, formatVipCbUrl, sleep } from '../utils' import {
getToday,
getUserOrderlist,
logger,
generateVipUrl,
formatVipCbUrl,
sleep,
setNewVipUserData,
setNewFollowUserData,
checkNewVip
} from '../utils'
import { TASK_RATE_TYPE, TASK_STATUS } from '../constants' import { TASK_RATE_TYPE, TASK_STATUS } from '../constants'
export interface ITaskInfo { export interface ITaskInfo {
...@@ -67,7 +77,7 @@ export default class TaskService extends UserService { ...@@ -67,7 +77,7 @@ export default class TaskService extends UserService {
const { newMember } = member const { newMember } = member
const today = getToday() const today = getToday()
const isNewVip = this.checkNewVip(userInfo, vipInfo) const isNewVip = checkNewVip(userInfo, vipInfo)
const { const {
member: { value } member: { value }
...@@ -80,7 +90,7 @@ export default class TaskService extends UserService { ...@@ -80,7 +90,7 @@ export default class TaskService extends UserService {
} }
if (isNewVip && !newMember) { if (isNewVip && !newMember) {
member = this.setNewVipUserData(member) member = setNewVipUserData(member)
// @ts-ignore // @ts-ignore
projection.$set.member = member projection.$set.member = member
...@@ -194,7 +204,7 @@ export default class TaskService extends UserService { ...@@ -194,7 +204,7 @@ export default class TaskService extends UserService {
} = tasks || {} } = tasks || {}
// 更新follow信息 // 更新follow信息
const followInfo: IFollowInfo = this.setNewFollowUserData(follow) const followInfo: IFollowInfo = setNewFollowUserData(follow)
// 增加待领取次数 // 增加待领取次数
return await this.updateUser(_id, { return await this.updateUser(_id, {
......
...@@ -7,9 +7,9 @@ ...@@ -7,9 +7,9 @@
import { BaseDao, TBAPIS } from '../sdk' import { BaseDao, TBAPIS } from '../sdk'
import BaseService from './base.service' import BaseService from './base.service'
import { USER_DB_NAME } from '../db' import { USER_DB_NAME } from '../db'
import { formatVipCbUrl, getToday, isUseVipMock, generateVipUrl } from '../utils' import { getToday, formatUpdateUserProjection } from '../utils'
import { VIP_MOCK } from '../vipMock' import { checkNewVip } from '../utils/package/userUpdate'
import { sellerId } from '../constants' import { formatUserNick } from '../utils/package/format'
class UserService extends BaseService { class UserService extends BaseService {
userdao: IBaseDao userdao: IBaseDao
constructor(context: IContext<IParams>) { constructor(context: IContext<IParams>) {
...@@ -126,7 +126,7 @@ class UserService extends BaseService { ...@@ -126,7 +126,7 @@ class UserService extends BaseService {
} }
// 之前进入活动非会员,现在进入会员,则视为新会员用户 // 之前进入活动非会员,现在进入会员,则视为新会员用户
const isNewVip = this.checkNewVip(userInfo, vipInfo) const isNewVip = checkNewVip(userInfo, vipInfo)
if (isNewVip && !userInfo.member.newMember) { if (isNewVip && !userInfo.member.newMember) {
// @ts-ignore // @ts-ignore
projection.$set.member = this.setNewVipUserData(userInfo.member) projection.$set.member = this.setNewVipUserData(userInfo.member)
...@@ -152,115 +152,66 @@ class UserService extends BaseService { ...@@ -152,115 +152,66 @@ class UserService extends BaseService {
* @returns 若更新成功,返回为1; 若更新失败,返回为 0 或系统直接报错 * @returns 若更新成功,返回为1; 若更新失败,返回为 0 或系统直接报错
*/ */
async updateUser(_id: string, projection: IUpdateQuery) { async updateUser(_id: string, projection: IUpdateQuery) {
return await this.userdao.update({ _id }, this.formatUpdateUserProjection(projection)) return await this.userdao.update({ _id }, formatUpdateUserProjection(projection))
} }
/** // 获取排名列表
* @desc 排行榜 async getRank(sortValueKey: string, sortTimeKey: string, limit: number = 200) {
* @param {查询条件} match let { activityId } = this.context.data
* @param {排序规则} sort //获取排名
* @param {查询条数} limit let list = await this.userdao.find<IUserInfo>(
*/
async getRank(match: Object, sort: Object, limit: number) {
const { data } = this.context
const { activityId } = data
return await this.userdao.aggregate([
{ $match: { ...match, activityId } },
{ $sort: sort },
{ $group: { _id: null, table: { $push: '$$ROOT' } } },
{ $unwind: { path: '$table', includeArrayIndex: 'no' } },
{ {
$project: { activityId: activityId,
_id: 0, [sortValueKey]: { $gt: 0 }
openId: '$table.openId',
userNick: '$table.userNick',
no: {
$add: ['$no', 1]
}
}
}, },
{ $limit: limit }
])
}
/**
* @desc 获取我的排名
* @param {查询条件} match
* @param {排序规则} sort
*/
async getMyRank(match: Object, sort: Object) {
const { openId, data } = this.context
const { activityId } = data
return await this.userdao.aggregate([
{ $match: { ...match, activityId } },
{ $sort: sort },
{ $group: { _id: null, table: { $push: '$$ROOT' } } },
{ $unwind: { path: '$table', includeArrayIndex: 'no' } },
{ {
$project: { projection: { [sortValueKey]: 1, userNick: 1, avatar: 1, _id: 0 },
_id: 0, sort: { [sortValueKey]: -1, [sortTimeKey]: 1 },
openId: '$table.openId', limit
userNick: '$table.userNick',
no: {
$add: ['$no', 1]
} }
)
return list.map((v, i) => {
return {
...v,
userNick: formatUserNick(v.userNick),
rank: i + 1
} }
}, })
{ $match: { openId } }
])
} }
/** /**
* 获取用户排名 * 获取用户排名
*
* @param {string} sortValueKey 排名字段
* @param {number} userValue
* @param {string} sortTimeKey
* @return {number} 排行
* @memberof UserService
*/ */
async getUserRank(hotValue: number) { async getMyRank(sortValueKey: string, sortTimeKey: string, userValue: number): Promise<number> {
let { activityId } = this.context.data let { activityId } = this.context.data
const { openId } = this.context const { openId } = this.context
let sameScoreList = await this.userdao.find<IUserInfo>( let sameScoreList = await this.userdao.find<IUserInfo>(
{ hotValue, activityId }, { [sortValueKey]: userValue, activityId },
{ {
sort: { updateTime: 1 } sort: { [sortTimeKey]: 1 }
} }
) )
let rank: string | number = '未上榜' let rank: number
let gap = 0 let gap = 0
//说明有多个跟自己同分数的人 //说明有多个跟自己同分数的人
for (let j = 0; j < sameScoreList.length; j++) { for (let j = 0; j < sameScoreList.length; j++) {
if (sameScoreList[j].openId == openId) { if (sameScoreList[j].openId === openId) {
gap = j gap = j
} }
} }
rank = await this.userdao.count({ hotValue: { $gt: hotValue }, activityId }) rank = await this.userdao.count({ [sortValueKey]: { $gt: userValue }, activityId })
rank = rank + 1 + gap rank = rank + 1 + gap
if (rank > 1000) {
rank = '1000+'
}
return rank return rank
} }
/**
* updateUser projection 格式化
*
* @param {object} projection
* @return {*}
* @memberof UserService
*/
formatUpdateUserProjection(projection: IUpdateQuery): IUpdateQuery {
projection['$set'] = projection['$set'] || {}
projection['$set'].updateTime = Date.now()
// $push不存在属性 删除$push
if (projection['$push'] && !Object.keys(projection['$push']).length) {
delete projection['$push']
}
// $pushAll不存在属性 删除$pushAll
if (projection['$pushAll'] && !Object.keys(projection['$pushAll']).length) {
delete projection['$pushAll']
}
console.log(projection)
return projection
}
/** /**
* @desc 根据用户主键id查找用户详情 * @desc 根据用户主键id查找用户详情
* @param {用户的主键id} _id * @param {用户的主键id} _id
...@@ -269,44 +220,6 @@ class UserService extends BaseService { ...@@ -269,44 +220,6 @@ class UserService extends BaseService {
async getUserInfoById(_id: string) { async getUserInfoById(_id: string) {
return await this.userdao.findOne({ _id }) return await this.userdao.findOne({ _id })
} }
/**
*判断是否新会员
*
* @param {IUserInfo} userInfo
* @param {IVipInfo} vipInfo
* @returns {boolean}
* @memberof UserService
*/
checkNewVip(userInfo: IUserInfo, vipInfo: IVipInfo): boolean {
const {
member: { flag }
} = userInfo
const { isVip } = vipInfo
return !flag && isVip
}
setNewVipUserData(member: IMemberInfo): IMemberInfo {
const today = getToday()
return {
...member,
newMember: true,
bememberTime: Date.now(),
bememberDay: today
}
}
setNewFollowUserData(follow: IFollowInfo): IFollowInfo {
const today = getToday()
return {
...follow,
newFollow: true,
followTime: Date.now(),
followDay: today
}
}
} }
export default UserService export default UserService
...@@ -130,6 +130,8 @@ interface IFindProjection { ...@@ -130,6 +130,8 @@ interface IFindProjection {
} }
maxTimeMS?: number maxTimeMS?: number
upsert?: boolean upsert?: boolean
limit?: number
skip?: number
returnOriginal?: boolean returnOriginal?: boolean
collation?: CollationDocument collation?: CollationDocument
} }
......
...@@ -23,3 +23,7 @@ export * from './package/vip' ...@@ -23,3 +23,7 @@ export * from './package/vip'
export * from './package/exportHandlers' export * from './package/exportHandlers'
export * from './package/helper' export * from './package/helper'
export * from './package/userUpdate'
export * from './package/format'
/**
* updateUser projection 格式化
*
* @format
* @param {object} projection
* @return {*}
* @memberof UserService
*/
export function formatUpdateUserProjection(projection: IUpdateQuery): IUpdateQuery {
projection['$set'] = projection['$set'] || {}
projection['$set'].updateTime = Date.now()
// $push不存在属性 删除$push
if (projection['$push'] && !Object.keys(projection['$push']).length) {
delete projection['$push']
}
console.log(projection)
return projection
}
// 用户昵称脱敏
export function formatUserNick(name: string) {
let newStr: string
if (name.length === 2) {
newStr = name.substr(0, 1) + '***' + name.substr(-1, 1)
} else if (name.length > 2) {
let char = '***'
newStr = name.substr(0, 1) + char + name.substr(-1, 1)
} else {
newStr = name + '***'
}
return newStr
}
/** @format */
import { getToday } from './getToday'
/**
* 判断是否新会员
*
* @format
* @param {IUserInfo} userInfo
* @param {IVipInfo} vipInfo
* @returns {boolean}
* @memberof UserService
*/
export function checkNewVip(userInfo: IUserInfo, vipInfo: IVipInfo): boolean {
const {
member: { flag }
} = userInfo
const { isVip } = vipInfo
return !flag && isVip
}
export function setNewVipUserData(member: IMemberInfo): IMemberInfo {
const today = getToday()
return {
...member,
newMember: true,
bememberTime: Date.now(),
bememberDay: today
}
}
export function setNewFollowUserData(follow: IFollowInfo): IFollowInfo {
const today = getToday()
return {
...follow,
newFollow: true,
followTime: Date.now(),
followDay: today
}
}
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