Commit 8a58fc7d authored by qinhaitao's avatar qinhaitao

feat: 🎸 access 增加记录

parent 19706925
......@@ -69,15 +69,15 @@ var User = /** @class */ (function () {
if (!!userInfo) return [3 /*break*/, 2];
return [4 /*yield*/, userService.initUserData(vipInfo, activityInfo)];
case 1:
_c.sent();
userInfo = _c.sent();
return [3 /*break*/, 4];
case 2: return [4 /*yield*/, userService.updateUserData(vipInfo, userInfo, activityInfo)];
case 3:
_c.sent();
userInfo = _c.sent();
_c.label = 4;
case 4:
// access表
return [4 /*yield*/, accessService.addAccess(isFollow, vipInfo.isVip)];
return [4 /*yield*/, accessService.addAccess(userInfo)];
case 5:
// access表
_c.sent();
......
{"version":3,"file":"user.controller.js","sourceRoot":"","sources":["../../src/controller/user.controller.ts"],"names":[],"mappings":";AAAA,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEd,0CAAuE;AAEvE,8BAAqC;AACrC,sCAAuD;AAEvD,4CAAqD;AAcrD;IAAA;IA6CA,CAAC;IA5CC;;OAEG;IAIG,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;wBAElB,QAAQ,GAAK,OAAO,CAAC,IAAI,SAAjB,CAAiB;6BAE7B,CAAC,QAAQ,EAAT,wBAAS;wBACX,qBAAM,WAAW,CAAC,YAAY,CAAC,OAAO,EAAE,YAAY,CAAC,EAAA;;wBAArD,SAAqD,CAAA;;4BAErD,qBAAM,WAAW,CAAC,cAAc,CAAC,OAAO,EAAE,QAAQ,EAAE,YAAY,CAAC,EAAA;;wBAAjE,SAAiE,CAAA;;;oBAGnE,UAAU;oBACV,qBAAM,aAAa,CAAC,SAAS,CAAC,QAAQ,EAAE,OAAO,CAAC,KAAK,CAAC,EAAA;;wBADtD,UAAU;wBACV,SAAsD,CAAA;wBAEtD,sBAAO,kBAAY,CAAC,OAAO,CAAC;gCAC1B,MAAM,QAAA;6BACP,CAAC,EAAA;;;;KACH;IACD;;OAEG;IAGG,yBAAU,GAAhB,UACE,OAA6B,EAC7B,EAA+C,EAC/C,EAA4B;YAD1B,OAAO,aAAA,EAAE,gBAAgB,sBAAA;YAC1B,WAAW,QAAA;;;;;;wBAEJ,WAAW,GAAK,OAAO,CAAC,IAAI,YAAjB,CAAiB;wBAErB,qBAAM,WAAW,CAAC,UAAU,CAAC,OAAO,EAAE,WAAW,IAAI,oBAAc,CAAC,OAAO,CAAC,EAAE,gBAAgB,CAAC,EAAA;;wBAAxG,MAAM,GAAG,SAA+F;wBAE9G,sBAAO,kBAAY,CAAC,OAAO,CAAC,MAAM,CAAC,EAAA;;;;KACpC;IArCD;QAHC,uBAAW,CAAC,CAAC,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC;QAC7D,6BAAiB;QACjB,oBAAQ,CAAC,CAAC,qBAAW,EAAE,uBAAa,CAAC,CAAC;;;;qCAsBtC;IAMD;QAFC,uBAAW,CAAC,CAAC,YAAY,CAAC,CAAC;QAC3B,oBAAQ,CAAC,CAAC,qBAAW,CAAC,CAAC;;;;0CAWvB;IACH,WAAC;CAAA,AA7CD,IA6CC;kBA7CoB,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,0CAAuE;AAEvE,8BAAqC;AACrC,sCAAuD;AAEvD,4CAAqD;AAcrD;IAAA;IA6CA,CAAC;IA5CC;;OAEG;IAIG,oBAAK,GAAX,UACE,OAA+B,EAC/B,EAAqD,EACrD,EAA0D;YADxD,QAAQ,cAAA,EAAE,OAAO,aAAA,EAAE,YAAY,kBAAA;YAChC,WAAW,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BAAW,CAAC,CAAC;;;;0CAWvB;IACH,WAAC;CAAA,AA7CD,IA6CC;kBA7CoB,IAAI"}
\ No newline at end of file
......@@ -11,6 +11,6 @@ export default class UserAccessService {
* 增加访问记录
* @param {是否关注店铺} isFollow
*/
addAccess(isFollow: boolean, isVip: boolean): Promise<number>;
addAccess(userInfo: IUserInfo): Promise<number>;
getAccessCount(): Promise<number>;
}
......@@ -53,7 +53,7 @@ var UserAccessService = /** @class */ (function () {
* 增加访问记录
* @param {是否关注店铺} isFollow
*/
UserAccessService.prototype.addAccess = function (isFollow, isVip) {
UserAccessService.prototype.addAccess = function (userInfo) {
return __awaiter(this, void 0, void 0, function () {
var _a, openId, data, activityId, userNick, avatar, inviteId;
return __generator(this, function (_b) {
......@@ -68,8 +68,10 @@ var UserAccessService = /** @class */ (function () {
avatar: avatar,
isReceiveShare: !!inviteId,
inviteId: inviteId,
isFollow: isFollow,
isVip: isVip,
isFollow: userInfo.follow.flag || userInfo.follow.newFollow,
isVip: userInfo.member.flag || userInfo.member.newMember,
follow: userInfo.follow,
member: userInfo.member,
accessTime: Date.now(),
createTime: Date.now(),
updateTime: Date.now(),
......
{"version":3,"file":"access.service.js","sourceRoot":"","sources":["../../src/service/access.service.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,8BAAgC;AAChC,kCAAmC;AACnC,4BAAsC;AAEtC;IAGE,2BAAY,OAA0B;QACpC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,SAAS,GAAG,IAAI,aAAO,CAAC,OAAO,EAAE,mBAAc,CAAC,CAAA;IACvD,CAAC;IACD;;;OAGG;IACG,qCAAS,GAAf,UAAgB,QAAiB,EAAE,KAAc;;;;;;wBAC3C,KAAmB,IAAI,CAAC,OAAO,EAA7B,MAAM,YAAA,EAAE,IAAI,UAAA,CAAiB;wBAC7B,UAAU,GAAiC,IAAI,WAArC,EAAE,QAAQ,GAAuB,IAAI,SAA3B,EAAE,MAAM,GAAe,IAAI,OAAnB,EAAE,QAAQ,GAAK,IAAI,SAAT,CAAS;wBAE9C,qBAAM,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC;gCACpC,MAAM,QAAA;gCACN,UAAU,YAAA;gCACV,QAAQ,UAAA;gCACR,MAAM,QAAA;gCACN,cAAc,EAAE,CAAC,CAAC,QAAQ;gCAC1B,QAAQ,UAAA;gCACR,QAAQ,UAAA;gCACR,KAAK,OAAA;gCACL,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE;gCACtB,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE;gCACtB,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE;gCACtB,SAAS,EAAE,gBAAQ,EAAE;6BACtB,CAAC,EAAA;4BAbF,sBAAO,SAaL,EAAA;;;;KACH;IAEK,0CAAc,GAApB;;;;;;wBACM,KAAmB,IAAI,CAAC,OAAO,EAA7B,MAAM,YAAA,EAAE,IAAI,UAAA,CAAiB;wBAC7B,UAAU,GAAK,IAAI,WAAT,CAAS;wBAClB,qBAAM,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;gCAChC,MAAM,QAAA;gCACN,UAAU,YAAA;6BACX,CAAC,EAAA;4BAHF,sBAAO,SAGL,EAAA;;;;KACH;IACH,wBAAC;AAAD,CAAC,AAvCD,IAuCC"}
\ No newline at end of file
{"version":3,"file":"access.service.js","sourceRoot":"","sources":["../../src/service/access.service.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,8BAAgC;AAChC,kCAAmC;AACnC,4BAAsC;AAEtC;IAGE,2BAAY,OAA0B;QACpC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,SAAS,GAAG,IAAI,aAAO,CAAC,OAAO,EAAE,mBAAc,CAAC,CAAA;IACvD,CAAC;IACD;;;OAGG;IACG,qCAAS,GAAf,UAAgB,Q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 @@ declare class UserService extends BaseService {
* @returns
* @memberof UserService
*/
initUserData(vipInfo: IVipInfo, activityInfo: IActivityInfo): Promise<number>;
updateUserData(vipInfo: IVipInfo, userInfo: IUserInfo, activityInfo: IActivityInfo): Promise<void>;
initUserData(vipInfo: IVipInfo, activityInfo: IActivityInfo): Promise<IUserInfo>;
updateUserData(vipInfo: IVipInfo, userInfo: IUserInfo, activityInfo: IActivityInfo): Promise<IUserInfo>;
/**
* @desc 更新用户表
* @param {用户的主键id} _id
......
......@@ -225,7 +225,9 @@ var UserService = /** @class */ (function (_super) {
user.taskInfo[today].follow = [{ createTime: Date.now() }];
}
return [4 /*yield*/, this.userdao.insertOne(user)];
case 1: return [2 /*return*/, _d.sent()];
case 1:
_d.sent();
return [2 /*return*/, user];
}
});
});
......@@ -269,7 +271,11 @@ var UserService = /** @class */ (function (_super) {
return [4 /*yield*/, this.updateUser(userInfo._id, projection)];
case 1:
_b.sent();
return [2 /*return*/];
return [2 /*return*/, __assign(__assign({}, userInfo), {
// @ts-ignore
follow: projection.$set.follow || userInfo.follow,
// @ts-ignore
member: projection.$set.member || userInfo.member })];
}
});
});
......
This diff is collapsed.
......@@ -36,13 +36,13 @@ export default class User {
const { isFollow } = context.data
if (!userInfo) {
await userService.initUserData(vipInfo, activityInfo)
userInfo = await userService.initUserData(vipInfo, activityInfo)
} else {
await userService.updateUserData(vipInfo, userInfo, activityInfo)
userInfo = await userService.updateUserData(vipInfo, userInfo, activityInfo)
}
// access表
await accessService.addAccess(isFollow, vipInfo.isVip)
await accessService.addAccess(userInfo)
return resultsModel.success({
openId
......
......@@ -19,7 +19,7 @@ export default class UserAccessService {
* 增加访问记录
* @param {是否关注店铺} isFollow
*/
async addAccess(isFollow: boolean, isVip: boolean) {
async addAccess(userInfo: IUserInfo) {
let { openId, data } = this.context
let { activityId, userNick, avatar, inviteId } = data
......@@ -30,8 +30,10 @@ export default class UserAccessService {
avatar,
isReceiveShare: !!inviteId,
inviteId,
isFollow,
isVip,
isFollow: userInfo.follow.flag || userInfo.follow.newFollow,
isVip: userInfo.member.flag || userInfo.member.newMember,
follow: userInfo.follow,
member: userInfo.member,
accessTime: Date.now(),
createTime: Date.now(),
updateTime: Date.now(),
......
......@@ -129,10 +129,12 @@ class UserService extends BaseService {
user.taskInfo[today].follow = [{ createTime: Date.now() }]
}
return await this.userdao.insertOne(user)
await this.userdao.insertOne(user)
return user
}
async updateUserData(vipInfo: IVipInfo, userInfo: IUserInfo, activityInfo: IActivityInfo) {
async updateUserData(vipInfo: IVipInfo, userInfo: IUserInfo, activityInfo: IActivityInfo): Promise<IUserInfo> {
const { data } = this.context
const { isFollow } = data
......@@ -171,6 +173,14 @@ class UserService extends BaseService {
}
await this.updateUser(userInfo._id, projection)
return {
...userInfo,
// @ts-ignore
follow: projection.$set.follow || userInfo.follow,
// @ts-ignore
member: projection.$set.member || userInfo.member
}
}
/**
......
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