Commit 35b6b5fc authored by maggie's avatar maggie

Merge branch 'c_server_ts_perf' of...

Merge branch 'c_server_ts_perf' of http://gitlab2.dui88.com/qinhaitao/taobao-mini-template into c_server_ts_perf
parents ff0eace9 137dfd58
/** @format */
const fs = require('fs-extra')
const config = require('./config.json')
const serverTemplatePath = 'templates'
const run = async (gulp, nunjucksRender, rename, nunjucksRenderConfig) => {
//编译controller.common
for (let commonController in config.controllers.common) {
await gulp
.src(`${serverTemplatePath}/controllers/common/${commonController}.controller.njk`)
.pipe(
nunjucksRender({
...nunjucksRenderConfig,
data: {
model: config.controllers.common[commonController]
}
})
)
.pipe(rename(`${commonController}.controller.ts`))
.pipe(gulp.dest(nunjucksRenderConfig.ServerFullPath + '/controller/common'))
}
}
module.exports = {
run
}
// module.exports = {
// run: async function(gulp, nunjucksRender, rename, nunjucksRenderConfig) {
// nunjucksRenderConfig.data = {
// model: CodeGenerateConfig.model,
// config: CodeGenerateConfig.config
// }
// const ServerProjectRootPath = nunjucksRenderConfig.ServerFullPath
// //server
// const serverTemplatePath = 'templates/taobao_mini'
// const customService = {}
// for(let controller in Model) {
// const fnServices = {}
// for(let fn in Model[controller]) {
// fnServices[fn] = {}
// for(let decorator of Model[controller][fn].decorator) {
// if(decorator.type === 'custom') {
// await gulp.src(`${serverTemplatePath}/decorator/decorator.njk`)
// .pipe(nunjucksRender({
// ...nunjucksRenderConfig,
// data: {
// model: decorator,
// }
// }))
// .pipe(rename(`${decorator.name}.ts`))
// .pipe(
// gulp.dest(
// ServerProjectRootPath +
// CodeGenerateConfig.config.CustomDecoratorRelativePath
// )
// )
// }
// }
// for(let main of Model[controller][fn].main) {
// if(main.type === 'custom') {
// if(!customService[main.service]) {
// customService[main.service] = {}
// }
// if(!customService[main.service][main.function]) {
// customService[main.service][main.function] = main
// }
// }
// fnServices[fn][`${main.type}_${main.service}`] = main
// }
// }
// // 编译common/controller
// await gulp.src(`${serverTemplatePath}/controller/${controller}.controller.njk`)
// .pipe(nunjucksRender({
// ...nunjucksRenderConfig,
// data: {
// model: CodeGenerateConfig.model[controller],
// config: CodeGenerateConfig.config,
// services: fnServices
// }
// }))
// .pipe(rename(`${controller}.controller.ts`))
// .pipe(
// gulp.dest(
// ServerProjectRootPath +
// CodeGenerateConfig.config.ControllerRelativePath + 'common/'
// )
// )
// }
// // 编译custom/service
// for(let service in customService) {
// await gulp.src(`${serverTemplatePath}/service/service.njk`)
// .pipe(nunjucksRender({
// ...nunjucksRenderConfig,
// data: {
// model: {
// name: service,
// functions: customService[service]
// },
// }
// }))
// .pipe(rename(`${service}.service.ts`))
// .pipe(
// gulp.dest(
// ServerProjectRootPath +
// CodeGenerateConfig.config.CustomServiceRelativePath
// )
// )
// }
// await gulp.src(`${serverTemplatePath}/service/index.njk`)
// .pipe(nunjucksRender({
// ...nunjucksRenderConfig,
// data: {
// model: {
// customService
// }
// }
// }))
// .pipe(rename(`index.ts`))
// .pipe(
// gulp.dest(
// ServerProjectRootPath +
// CodeGenerateConfig.config.CustomServiceRelativePath
// )
// )
// }
// }
\ No newline at end of file
/** @format */
const gulp = require('gulp')
const rename = require('gulp-rename')
const nunjucksRender = require('gulp-nunjucks-render')
const codeGenerate = require('./generate')
var jsScript = 'node'
if (process.env.npm_config_argv !== undefined && process.env.npm_config_argv.indexOf('debug') > 0) {
jsScript = 'node debug'
}
const ServerFullPath = '../src'
const nunjucksRenderConfig = {
path: 'templates',
ext: '.ts',
ServerFullPath
}
gulp.task('code', function () {
require('events').EventEmitter.defaultMaxListeners = 0
return codeGenerate.run(gulp, nunjucksRender, rename, nunjucksRenderConfig)
})
{
"name": "nunjucks-test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"devDependencies": {
"gulp": "^4.0.2",
"gulp-nunjucks-render": "^2.2.3",
"gulp-rename": "^2.0.0"
},
"dependencies": {
"fs-extra": "^9.0.1"
}
}
/** @format */
export const <$ decoratorName $> = (target: any, name: string, descriptor: PropertyDescriptor) => {
const method = descriptor.value
descriptor.value = async function (...args: any[]) {
const [context, otherArgs = {}] = args
return method.apply(this, [context, { ...otherArgs }])
}
}
\ No newline at end of file
/**
* @format
*/
export default class <$ serviceName $> {
context: IContext<any>
constructor(context: IContext<any>) {
this.context = context
}
/**
* @desc 活动基本信息
* @param {活动id} activityId
* @returns 返回活动详情,若不存在活动,返回为null
*/
async getBaseInfo(activityId: string): Promise<IActivityInfo> {
return await this.activitydao.findOne({ _id: activityId, deleteStatus: ACTIVITY_STATUS.NORMAL })
}
/**
*
* 根据itemIds获取商品列表
*
* @param {string} itemIds
* @param {string} session
* @return {Array}
* @memberof BaseService
*/
async getItemListByIds(itemIds: string, session: string): Promise<Array<ITaoBaoItems>> {
const GOODSINFO =
'detail_url,approve_status,num_iid,title,nick,type,cid,pic_url,num,props,valid_thru,list_time,desc,price,has_discount,has_invoice,has_warranty,has_showcase,modified,delist_time,postage_id,seller_cids,outer_id,sold_quantity'
const result = await TBAPIS.getItemListByItemIds(this.context, session, itemIds, { fields: GOODSINFO })
const items = result?.items?.item || []
const list = items.map(
(v: { num_iid: string; title: string; price: string; detail_url: string; pic_url: string; desc: string }) => {
return {
itemId: v.num_iid,
name: v.title,
price: v.price,
url: v.detail_url,
image: v.pic_url,
desc: v.desc
}
}
)
return list
}
}
\ No newline at end of file
This diff is collapsed.
......@@ -36,7 +36,7 @@ export default class AwardsController {
/**
* 权益重新领取
*/
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>>;
receiveEnamePrize(context: IContext<IReceiveEnameParams>, { awardInfo, session }: IReceivePrizeControllerInfos, [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>>;
/**
* 概率抽奖
*/
......
......@@ -52,9 +52,7 @@ var service_1 = require("../service");
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 check_1 = require("../utils/common/check/");
var AwardsController = /** @class */ (function () {
function AwardsController() {
}
......@@ -65,43 +63,14 @@ var AwardsController = /** @class */ (function () {
var activityInfo = _a.activityInfo;
var awardSer = _b[0];
return __awaiter(this, void 0, void 0, function () {
var openId, activityId, awardReceiveExpiredTime, myPrizeList;
var list;
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
openId = context.openId, activityId = context.data.activityId;
awardReceiveExpiredTime = activityInfo.awardReceiveExpiredTime;
return [4 /*yield*/, awardSer.getAwardsInfoList({
openId: openId,
activityId: activityId,
type: { $ne: constants_1.PRIZE_TYPE.THANKS }
}, {
projection: {
_id: 1,
name: 1,
image: 1,
type: 1,
drawStatus: 1,
shipStatus: 1,
receiveName: 1,
phone: 1,
address: 1,
provice: 1,
city: 1,
area: 1,
remark: 1,
useUrl: 1,
shipCompany: 1,
shipNum: 1
},
sort: {
createTime: -1
}
})];
case 0: return [4 /*yield*/, awardSer.getMyPrizeList(activityInfo)];
case 1:
myPrizeList = _c.sent();
list = _c.sent();
return [2 /*return*/, sdk_1.resultsModel.success({
list: awardSer.formatMyPrizeList(myPrizeList, awardReceiveExpiredTime)
list: list
})];
}
});
......@@ -250,7 +219,7 @@ 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])]),
preCheck_1.default([check_1.checkPrizeExpired]),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, Object, Array]),
__metadata("design:returntype", Promise)
......@@ -259,7 +228,7 @@ var AwardsController = /** @class */ (function () {
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])]),
preCheck_1.default([check_1.checkPrizeExpired]),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, Object, Array]),
__metadata("design:returntype", Promise)
......@@ -267,7 +236,7 @@ var AwardsController = /** @class */ (function () {
__decorate([
common_1.checkParams(['activityId', 'prizeDataType']),
common_1.services([service_1.AwardsService]),
preCheck_1.preCheck([checkActivityTime_1.checkActivityTime]),
preCheck_1.default([check_1.checkActivityTime]),
__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,8CAAyE;AACzE,8BAAqC;AACrC,sCAA0C;AAC1C,0CAAkE;AAClE,mCAAoC;AAEpC,yDAAuD;AACvD,6EAA2E;AAC3E,6EAA2E;AAC3E,yEAAuE;AA2BvE;IAAA;IAoLA,CAAC;IAnLC;;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,iBA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AAiB,CAAC,CAAC;;;;4DAkE7B;IACH,uBAAC;CAAA,AApLD,IAoLC;kBApLoB,gBAAgB"}
\ No newline at end of file
{"version":3,"file":"awards.controller.js","sourceRoot":"","sources":["../../src/controller/awards.controller.ts"],"names":[],"mappings":";AAAA,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEd,8CAAyE;AACzE,8BAAqC;AACrC,sCAA0C;AAC1C,0CAAkE;AAClE,mCAAoC;AAEpC,yDAAmD;AACnD,gDAA8F;AA2B9F;IAAA;IAgJA,CAAC;IA/IC;;OAEG;IAGG,yCAAc,GAApB,UACE,OAAmC,EACnC,EAAkC,EAClC,EAA2B;YADzB,YAAY,kBAAA;YACb,QAAQ,QAAA;;;;;4BAEI,qBAAM,QAAQ,CAAC,cAAc,CAAC,YAAY,CAAC,EAAA;;wBAAlD,IAAI,GAAG,SAA2C;wBAExD,sBAAO,kBAAY,CAAC,OAAO,CAAC;gCAC1B,IAAI,MAAA;6BACL,CAAC,EAAA;;;;KACH;IAED;;OAEG;IAIG,6CAAkB,GAAxB,UACE,OAAsC,EACtC,EAA8C,EAC9C,EAA2B;YADzB,YAAY,kBAAA;YACb,QAAQ,QAAA;;;;;;wBAEL,KAAuE,OAAO,CAAC,IAAI,EAAjF,QAAQ,cAAA,EAAE,IAAI,UAAA,EAAE,IAAI,UAAA,EAAE,UAAU,gBAAA,EAAE,aAAa,mBAAA,EAAE,EAAE,QAAA,EAAE,IAAI,UAAA,EAAE,KAAK,WAAA,CAAiB;wBAE1E,qBAAM,QAAQ,CAAC,kBAAkB,CAAC,EAAE,EAAE;gCACjD,QAAQ,UAAA;gCACR,IAAI,MAAA;gCACJ,IAAI,MAAA;gCACJ,UAAU,YAAA;gCACV,aAAa,eAAA;gCACb,IAAI,MAAA;gCACJ,KAAK,OAAA;6BACN,CAAC,EAAA;;wBARE,MAAM,GAAG,SAQX;wBAEF,IAAK,MAAmB,CAAC,IAAI,EAAE;4BAC7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AQ,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;IAzID;QAFC,oBAAW,CAAC,CAAC,YAAY,CAAC,CAAC;QAC3B,iBAAQ,CAAC,CAAC,uBAAa,CAAC,CAAC;;;;0DAWzB;IAQD;QAHC,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;QACzB,kBAAQ,CAAC,CAAC,yBAAiB,CAAC,CAAC;;;;8DAsB7B;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,kBAAQ,CAAC,CAAC,yBAAiB,CAAC,CAAC;;;;6DAiB7B;IAQD;QAHC,oBAAW,CAAC,CAAC,YAAY,EAAE,eAAe,CAAC,CAAC;QAC5C,iBAAQ,CAAC,CAAC,uBAAa,CAAC,CAAC;QACzB,kBAAQ,CAAC,CAAC,yBAAiB,CAAC,CAAC;;;;4DAkE7B;IACH,uBAAC;CAAA,AAhJD,IAgJC;kBAhJoB,gBAAgB"}
\ No newline at end of file
......@@ -47,17 +47,12 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
};
Object.defineProperty(exports, "__esModule", { value: true });
var common_1 = require("../decorator/common/");
var common_2 = require("../decorator/common/");
var sdk_1 = require("../sdk");
var service_1 = require("../service");
var constants_1 = require("../constants");
var checkActivityTime_1 = require("../utils/common/check/checkActivityTime");
var checkInviteId_1 = require("../utils/common/check/checkInviteId");
var checkHelpRecord_1 = require("../utils/common/check/checkHelpRecord");
var checkNewVip_1 = require("../utils/common/check/checkNewVip");
var check_1 = require("../utils/common/check");
var errorCode_1 = require("../errorCode");
var update_1 = require("../decorator/common/update");
var updateVip_1 = require("../utils/common/update/updateVip");
var update_1 = require("../utils/common/update/");
var Share = /** @class */ (function () {
function Share() {
}
......@@ -105,17 +100,17 @@ var Share = /** @class */ (function () {
};
__decorate([
common_1.checkParams(['activityId']),
common_2.services([service_1.UserService]),
common_1.services([service_1.UserService]),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, Object]),
__metadata("design:returntype", Promise)
], Share.prototype, "getShareInfo", null);
__decorate([
common_1.checkParams(['activityId', 'inviteId']),
common_2.registeInfos(['vipInfo']),
common_2.services([service_1.TaskService, service_1.StatService]),
common_2.preCheck([checkActivityTime_1.checkActivityTime, checkInviteId_1.checkInviteId, checkNewVip_1.checkNewVip, checkHelpRecord_1.checkHelpRecord]),
update_1.update([updateVip_1.updateVip]),
common_1.registeInfos(['vipInfo']),
common_1.services([service_1.TaskService, service_1.StatService]),
common_1.preCheck([check_1.checkActivityTime, check_1.checkInviteId, check_1.checkNewVip, check_1.checkHelpRecord]),
common_1.preUpdate([update_1.updateVip]),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, Object, Array]),
__metadata("design:returntype", Promise)
......
{"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;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AM,CAAC,CAAC,qBAAS,CAAC,CAAC;;;;uCAoBnB;IACH,YAAC;CAAA,AA9CD,IA8CC;kBA9CoB,KAAK"}
\ No newline at end of file
{"version":3,"file":"share.controller.js","sourceRoot":"","sources":["../../src/controller/share.controller.ts"],"names":[],"mappings":";AAAA,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEd,+CAA+F;AAC/F,8BAAqC;AACrC,sCAAkE;AAClE,0CAAwC;AACxC,+CAAsG;AACtG,0CAAyC;AACzC,kDAAmD;AAKnD;IAAA;IA8CA,CAAC;IA7CC;;OAEG;IAGG,4BAAY,GAAlB,UACE,OAAyC,EACzC,EAA8B;YAA5B,QAAQ,cAAA;;;;gBAGO,OAAO,GACpB,QAAQ,oBADY,CACZ;gBAEZ,sBAAO,kBAAY,CAAC,OAAO,CAAC;wBAC1B,OAAO,EAAE,OAAO;qBACjB,CAAC,EAAA;;;KACH;IACD;;OAEG;IAMG,sBAAM,GAAZ,UACE,OAGE,EACF,EAAwD,EACxD,EAAsD;YADpD,QAAQ,cAAA,EAAE,YAAY,kBAAA,EAAE,cAAc,oBAAA;YACvC,WAAW,QAAA,EAAE,WAAW,QAAA;;;;;;wBAEjB,MAAM,GAAK,OAAO,OAAZ,CAAY;wBAEX,qBAAM,WAAW,CAAC,YAAY,CAAC,SAAS,EAAE,YAAY,EAAE,cAAc,EAAE;gCACrF,MAAM,QAAA;6BACP,CAAC,EAAA;;wBAFI,MAAM,GAAG,SAEb;wBAEF,IAAI,CAAC,MAAM;4BAAE,sBAAO,kBAAY,CAAC,KAAK,CAAC,sBAAU,CAAC,YAAY,EAAE,OAAO,CAAC,EAAA;wBAExE,qBAAM,WAAW,CAAC,OAAO,CAAC,qBAAS,CAAC,aAAa,EAAE,QAAQ,CAAC,EAAA;;wBAA5D,SAA4D,CAAA;wBAE5D,sBAAO,kBAAY,CAAC,OAAO,CAAC,IAAI,CAAC,EAAA;;;;KAClC;IAvCD;QAFC,oBAAW,CAAC,CAAC,YAAY,CAAC,CAAC;QAC3B,iBAAQ,CAAC,CAAC,qBAAW,CAAC,CAAC;;;;6CAYvB;IASD;QALC,oBAAW,CAAC,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;QACvC,qBAAY,CAAC,CAAC,SAAS,CAAC,CAAC;QACzB,iBAAQ,CAAC,CAAC,qBAAW,EAAE,qBAAW,CAAC,CAAC;QACpC,iBAAQ,CAAC,CAAC,yBAAiB,EAAE,qBAAa,EAAE,mBAAW,EAAE,uBAAe,CAAC,CAAC;QAC1E,kBAAS,CAAC,CAAC,kBAAS,CAAC,CAAC;;;;uCAoBtB;IACH,YAAC;CAAA,AA9CD,IA8CC;kBA9CoB,KAAK"}
\ No newline at end of file
......@@ -33,7 +33,7 @@ export default class Task {
/**
* 获取收藏商品列表
*/
getCollectGoodsList(context: IContext<IParams>, { session, userInfo }: IControllerInfos, [baseService]: [BaseService]): Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result<{
getCollectGoodsList(context: IContext<IParams>, { session, userInfo }: IControllerInfos, [baseService, taskService]: [BaseService, TaskService]): Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result<{
collected: boolean;
itemId: string;
name: string;
......
"use strict";
/** @format */
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
......@@ -61,13 +50,9 @@ var constants_1 = require("./../constants");
var common_1 = require("../decorator/common");
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 check_1 = require("../utils/common/check/");
var common_2 = require("../decorator/common");
var update_1 = require("../utils/common/update");
var Task = /** @class */ (function () {
function Task() {
}
......@@ -88,7 +73,7 @@ var Task = /** @class */ (function () {
// taskService.initTask('collectGoods', '收藏商品', activityInfo, userInfo),
// taskService.initTask('jumpLink', '浏览页面', activityInfo, userInfo),
// taskService.initTask('invites', '邀请好友', activityInfo, userInfo)
// taskService.initTask('exchangeCredits', '积分兑换', activityInfo, updatedUserInfo)
// taskService.initTask('exchangeCredits', '积分兑换', activityInfo, userInfo)
])];
});
});
......@@ -144,9 +129,9 @@ var Task = /** @class */ (function () {
*/
Task.prototype.getCollectGoodsList = function (context, _a, _b) {
var session = _a.session, userInfo = _a.userInfo;
var baseService = _b[0];
var baseService = _b[0], taskService = _b[1];
return __awaiter(this, void 0, void 0, function () {
var itemIds, list, taskInfo, listWithCollectStatus;
var itemIds, list, listWithCollectStatus;
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
......@@ -154,12 +139,7 @@ var Task = /** @class */ (function () {
return [4 /*yield*/, baseService.getItemListByIds(itemIds, session)];
case 1:
list = _c.sent();
taskInfo = task_1.getTotalCompleteTask('collectGoods', userInfo).taskInfo;
listWithCollectStatus = list.map(function (v) {
return __assign(__assign({}, v), {
// 完成列表是否含有itemId
collected: taskInfo.some(function (completeItem) { return completeItem.itemId === v.itemId; }) });
});
listWithCollectStatus = taskService.getItemListWithCollectStatus(list, userInfo);
return [2 /*return*/, sdk_1.resultsModel.success(listWithCollectStatus)];
}
});
......@@ -169,8 +149,8 @@ var Task = /** @class */ (function () {
common_1.checkParams(['activityId']),
common_1.registeInfos(['vipInfo']),
common_1.services([service_1.TaskService]),
common_1.preCheck([checkActivityTime_1.checkActivityTime]),
update_1.update([updateVip_1.updateVip]),
common_1.preCheck([check_1.checkActivityTime]),
common_2.preUpdate([update_1.updateVip, update_1.updateSignTask]),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, Object, Array]),
__metadata("design:returntype", Promise)
......@@ -179,7 +159,7 @@ var Task = /** @class */ (function () {
common_1.checkParams(['activityId', 'taskType']),
common_1.registeInfos(['session']),
common_1.services([service_1.TaskService]),
common_1.preCheck([checkActivityTime_1.checkActivityTime, checkTaskLimit_1.checkTaskLimit, checkExchangeCreditsTask_1.checkExchangeCreditsTask]),
common_1.preCheck([check_1.checkActivityTime, check_1.checkTaskLimit, check_1.checkExchangeCreditsTask]),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, Object, Array]),
__metadata("design:returntype", Promise)
......@@ -187,7 +167,7 @@ var Task = /** @class */ (function () {
__decorate([
common_1.checkParams(['activityId', 'taskType', 'rewardsKey']),
common_1.services([service_1.TaskService]),
common_1.preCheck([checkActivityTime_1.checkActivityTime, checkRemainTimes_1.checkRemainTimes]),
common_1.preCheck([check_1.checkActivityTime, check_1.checkRemainTimes]),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, Object, Array]),
__metadata("design:returntype", Promise)
......@@ -195,7 +175,7 @@ var Task = /** @class */ (function () {
__decorate([
common_1.checkParams(['activityId', 'itemIds']),
common_1.registeInfos(['session']),
common_1.services([service_1.BaseService]),
common_1.services([service_1.BaseService, service_1.TaskService]),
__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,4CAA2C;AAC3C,8CAAmF;AACnF,8BAAqC;AACrC,sCAAqD;AAErD,6EAA2E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AC;;;;mDAapC;IACH,WAAC;CAAA,AAnGD,IAmGC;kBAnGoB,IAAI"}
\ No newline at end of file
......@@ -5,11 +5,24 @@ export interface IVipParams {
callbackUrl?: string;
inviteId?: string;
}
interface IRankList {
userNick: string;
avatar: string;
score: any;
rank: number;
}
export interface IRankResult {
rank: number;
userNick: string;
avatar: string;
score: number;
list: IRankList[];
}
export default class User {
/**
* 获取会员信息
*/
getVipInfo(context: IContext<IVipParams>, { session, activityUserNick }: IControllerInfos): Promise<IResult<IVipInfo>>;
getVipInfo(context: IContext<IVipParams>, { session, activityUserNick }: IControllerInfos, [userService]: [UserService]): Promise<IResult<IVipInfo>>;
/**
* 获取排行榜
*/
......@@ -19,27 +32,16 @@ export default class User {
timeKey: string;
limit: number;
}>, { userInfo }: IControllerInfos, [userService]: [UserService]): Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result<{
userNick: string;
avatar: string;
rank: number;
score: any;
list: {
score: any;
avatar: string;
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;
}[];
rank: number;
userNick: string;
avatar: string;
score: any;
}, true>>;
}
export {};
"use strict";
/** @format */
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
......@@ -49,24 +60,22 @@ Object.defineProperty(exports, "__esModule", { value: true });
var common_1 = require("../decorator/common");
var sdk_1 = require("../sdk");
var service_1 = require("../service");
var vip_1 = require("../utils/common/vip");
var User = /** @class */ (function () {
function User() {
}
/**
* 获取会员信息
*/
User.prototype.getVipInfo = function (context, _a) {
User.prototype.getVipInfo = function (context, _a, _b) {
var session = _a.session, activityUserNick = _a.activityUserNick;
var userService = _b[0];
return __awaiter(this, void 0, void 0, function () {
var callbackUrl, result;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
callbackUrl = context.data.callbackUrl;
return [4 /*yield*/, vip_1.getShopVip(context, session, callbackUrl || vip_1.formatVipCbUrl(context), activityUserNick)];
var result;
return __generator(this, function (_c) {
switch (_c.label) {
case 0: return [4 /*yield*/, userService.getShopVip(context, session, activityUserNick)];
case 1:
result = _b.sent();
result = _c.sent();
return [2 /*return*/, sdk_1.resultsModel.success(result)];
}
});
......@@ -79,25 +88,18 @@ var User = /** @class */ (function () {
var userInfo = _a.userInfo;
var userService = _b[0];
return __awaiter(this, void 0, void 0, function () {
var _c, key, timeKey, _d, limit, userNick, avatar, rank, list;
var _c, key, timeKey, _d, limit, rankInfo, list;
return __generator(this, function (_e) {
switch (_e.label) {
case 0:
_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(key, timeKey, userInfo[key])];
return [4 /*yield*/, userService.getMyRankInfo(key, timeKey, userInfo)];
case 1:
rank = _e.sent();
rankInfo = _e.sent();
return [4 /*yield*/, userService.getRank(key, timeKey, limit)];
case 2:
list = _e.sent();
return [2 /*return*/, sdk_1.resultsModel.success({
userNick: userNick,
avatar: avatar,
rank: rank,
score: userInfo[key],
list: list
})];
return [2 /*return*/, sdk_1.resultsModel.success(__assign(__assign({}, rankInfo), list))];
}
});
});
......@@ -105,9 +107,9 @@ var User = /** @class */ (function () {
__decorate([
common_1.checkParams(['activityId']),
common_1.registeInfos(['session']),
common_1.services([]),
common_1.services([service_1.UserService]),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, Object]),
__metadata("design:paramtypes", [Object, Object, Array]),
__metadata("design:returntype", Promise)
], User.prototype, "getVipInfo", null);
__decorate([
......
{"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
{"version":3,"file":"user.controller.js","sourceRoot":"","sources":["../../src/controller/user.controller.ts"],"names":[],"mappings":";AAAA,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEd,8CAAyE;AACzE,8BAAqC;AACrC,sCAAwC;AAuBxC;IAAA;IA4CA,CAAC;IA3CC;;OAEG;IAIG,yBAAU,GAAhB,UACE,OAA6B,EAC7B,EAA+C,EAC/C,EAA4B;YAD1B,OAAO,aAAA,EAAE,gBAAgB,sBAAA;YAC1B,WAAW,QAAA;;;;;4BAGG,qBAAM,WAAW,CAAC,UAAU,CAAC,OAAO,EAAE,OAAO,EAAE,gBAAgB,CAAC,EAAA;;wBAAzE,MAAM,GAAG,SAAgE;wBAE/E,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;wBAEjC,qBAAM,WAAW,CAAC,aAAa,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAA;;wBAAlE,QAAQ,GAAG,SAAuD;wBAE3D,qBAAM,WAAW,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,CAAC,EAAA;;wBAArD,IAAI,GAAG,SAA8C;wBAE3D,sBAAO,kBAAY,CAAC,OAAO,uBACtB,QAAQ,GACR,IAAI,EACP,EAAA;;;;KACH;IApCD;QAHC,oBAAW,CAAC,CAAC,YAAY,CAAC,CAAC;QAC3B,qBAAY,CAAC,CAAC,SAAS,CAAC,CAAC;QACzB,iBAAQ,CAAC,CAAC,qBAAW,CAAC,CAAC;;;;0CAUvB;IAOD;QAFC,oBAAW,CAAC,CAAC,YAAY,CAAC,CAAC;QAC3B,iBAAQ,CAAC,CAAC,qBAAW,CAAC,CAAC;;;;2CAqBvB;IACH,WAAC;CAAA,AA5CD,IA4CC;kBA5CoB,IAAI"}
\ No newline at end of file
/** @format */
declare const _default: {
login: (context: IContext<import("./controller/login.controller").ILoginParams>, { userInfo, vipInfo, activityInfo }: IControllerInfos, [userService, accessService]: [import("./service/user.service").default, import("./service").AccessService]) => Promise<IResult<{
login: (context: IContext<import("./controller/login.controller").ILoginParams>, { userInfo, activityInfo, vipInfo }: IControllerInfos, [userService, accessService]: [import("./service/user.service").default, import("./service").AccessService]) => Promise<IResult<{
openId: string;
}>>;
getVipInfo: (context: IContext<import("./controller/user.controller").IVipParams>, { session, activityUserNick }: IControllerInfos) => Promise<IResult<IVipInfo>>;
getVipInfo: (context: IContext<import("./controller/user.controller").IVipParams>, { session, activityUserNick }: IControllerInfos, [userService]: [import("./service/user.service").default]) => Promise<IResult<IVipInfo>>;
getTaskList: (context: IContext<{
activityId: string;
}>, { userInfo, activityInfo }: IControllerInfos, [taskService]: [import("./service").TaskService]) => Promise<IResult<import("./service/task.service").ITaskInfo[]>>;
......@@ -27,12 +27,12 @@ declare const _default: {
list: IAwards[];
}>>;
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>>;
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 | string[] | number[] | object[], 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 | number[] | object[] | string[], 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[] | number[] | object[], 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;
......@@ -40,28 +40,16 @@ declare const _default: {
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;
rank: number;
score: any;
list: {
score: any;
avatar: string;
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;
}[];
rank: number;
userNick: string;
avatar: string;
score: any;
}, true>>;
};
export default _default;
......@@ -10,6 +10,7 @@ export default class AwardsService extends UserService {
activityprizedao: IBaseDao;
constructor(context: IContext<IParams>);
reduceStock(_id: string): Promise<1 | CodeType>;
getMyPrizeList(activityInfo: IActivityInfo): Promise<IAwards[]>;
/**
* 插入奖品记录
* @param {*} award
......@@ -21,35 +22,7 @@ export default class AwardsService extends UserService {
*/
sendAward(document: IAwards): Promise<CodeType | IAwards>;
getAwardsInfoList(query: object, projection?: IFindProjection): Promise<IAwards[]>;
formatMyPrizeList(myPrizeList: IAwards[], awardReceiveExpiredTime?: number): {
expiredTime: number;
id: string;
_id?: string;
openId: string;
activityId: string;
prizeId: string;
ename?: string;
credits?: number;
type: number;
image: string;
name: string;
drawStatus: number;
receiveName?: string;
userNick?: string;
phone?: string;
addressDetail?: string;
provice?: string;
city?: string;
area?: string;
receiveTime?: number;
shipStatus?: number;
shipCompany?: string;
shipNum?: string | number;
remark: string;
createTime?: number;
updateTime?: number;
awardsType?: string;
}[];
formatMyPrizeList(myPrizeList: IAwards[], awardReceiveExpiredTime?: number): IAwards[];
recieveObjectPrize(_id: string, { province, city, area, streetName, addressDetail, name, phone }: {
province: string;
city: string;
......
......@@ -125,6 +125,48 @@ var AwardsService = /** @class */ (function (_super) {
});
});
};
AwardsService.prototype.getMyPrizeList = function (activityInfo) {
return __awaiter(this, void 0, void 0, function () {
var openId, activityId, myPrizeList;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
openId = this.context.openId;
activityId = this.context.data.activityId;
return [4 /*yield*/, this.getAwardsInfoList({
openId: openId,
activityId: activityId,
type: { $ne: constants_1.PRIZE_TYPE.THANKS }
}, {
projection: {
_id: 1,
name: 1,
image: 1,
type: 1,
drawStatus: 1,
shipStatus: 1,
receiveName: 1,
phone: 1,
address: 1,
provice: 1,
city: 1,
area: 1,
remark: 1,
useUrl: 1,
shipCompany: 1,
shipNum: 1
},
sort: {
createTime: -1
}
})];
case 1:
myPrizeList = _a.sent();
return [2 /*return*/, this.formatMyPrizeList(myPrizeList, activityInfo.awardReceiveExpiredTime)];
}
});
});
};
/**
* 插入奖品记录
* @param {*} award
......
This diff is collapsed.
......@@ -53,28 +53,13 @@ export default class TaskService extends UserService {
*/
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: {
'remainTimes.sign': number;
};
$push: {
[x: string]: {
createTime: number;
};
};
} | {
$inc?: undefined;
$push?: undefined;
};
/**
*
* 更新user表中,任务相关字段
*
* @param {string} id
* @param {object[]} needUpdateKeysArray
* @param {IUserInfo} userInfo
* @returns {IUserInfo | boolean} userInfo
* @memberof TaskService
*/
updateTasks(id: string, needUpdateKeysArray: object[], userInfo: IUserInfo): Promise<false | IUserInfo>;
getItemListWithCollectStatus(list: ITaoBaoItems[], userInfo: IUserInfo): {
collected: boolean;
itemId: string;
name: string;
price: string;
url: string;
image: string;
desc: string;
}[];
}
......@@ -64,15 +64,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
var __spreadArrays = (this && this.__spreadArrays) || function () {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
};
Object.defineProperty(exports, "__esModule", { value: true });
var lodash_1 = require("lodash");
var user_service_1 = require("./user.service");
var utils_1 = require("../utils");
var constants_1 = require("../constants");
......@@ -238,74 +230,12 @@ var TaskService = /** @class */ (function (_super) {
});
});
};
// 更新签到任务数据
TaskService.prototype.updateSignTask = function (userInfo, tasks) {
var _a;
// 获取签到奖励
var value = (tasks || {}).sign.value;
var todayCompleteTimes = task_1.getTodayCompleteTask('sign', userInfo).todayCompleteTimes;
var today = utils_1.getToday();
// 今天没有有完成记录
return todayCompleteTimes === 0
? {
$inc: {
'remainTimes.sign': value
},
$push: (_a = {},
_a["taskInfo." + today + ".sign"] = { createTime: Date.now() },
_a)
}
: {};
};
/**
*
* 更新user表中,任务相关字段
*
* @param {string} id
* @param {object[]} needUpdateKeysArray
* @param {IUserInfo} userInfo
* @returns {IUserInfo | boolean} userInfo
* @memberof TaskService
*/
TaskService.prototype.updateTasks = function (id, needUpdateKeysArray, userInfo) {
return __awaiter(this, void 0, void 0, function () {
var updateKeys, _$inc, _$set, _$push;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
utils_1.logger(needUpdateKeysArray);
updateKeys = lodash_1.merge.apply(void 0, __spreadArrays([{}], needUpdateKeysArray));
utils_1.logger(updateKeys);
_$inc = updateKeys.$inc || {};
_$set = updateKeys.$set || {};
_$push = updateKeys.$push || {};
// 删除空的操作
if (!Object.keys(_$inc).length && updateKeys.$inc) {
delete updateKeys.$inc;
}
if (!Object.keys(_$set).length && updateKeys.$set) {
delete updateKeys.$set;
}
if (!Object.keys(_$push).length && updateKeys.$push) {
delete updateKeys.$push;
}
if (!Object.keys(updateKeys).length) {
return [2 /*return*/, userInfo];
}
return [4 /*yield*/, this.updateUser(id, updateKeys)
// 更新数据库后 延迟10ms 执行
];
case 1:
_a.sent();
// 更新数据库后 延迟10ms 执行
return [4 /*yield*/, utils_1.sleep(10)];
case 2:
// 更新数据库后 延迟10ms 执行
_a.sent();
return [4 /*yield*/, this.getUserInfo()];
case 3: return [2 /*return*/, _a.sent()];
}
});
TaskService.prototype.getItemListWithCollectStatus = function (list, userInfo) {
var taskInfo = task_1.getTotalCompleteTask('collectGoods', userInfo).taskInfo;
return list.map(function (v) {
return __assign(__assign({}, v), {
// 完成列表是否含有itemId
collected: taskInfo.some(function (completeItem) { return completeItem.itemId === v.itemId; }) });
});
};
return TaskService;
......
{"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,EAAE,aAAS,EAAT,KAAK,mBAAG,CAAC,KAAA,EAAE,YAAS,EAAT,IAAI,mBAAG,EAAE,KAA0C,CAAA;QACjG,IAAA,WAAW,GAAK,QAAQ,YAAb,CAAa;QACxB,IAAA,kBAAkB,GAAK,2BAAoB,CAAC,QAAQ,EAAE,QAAQ,CAAC,mB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I,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
{"version":3,"file":"task.service.js","sourceRoot":"","sources":["../../src/service/task.service.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGH,+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,EAAE,aAAS,EAAT,KAAK,mBAAG,CAAC,KAAA,EAAE,YAAS,EAAT,IAAI,mBAAG,EAAE,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AC,IAAI,CAAC,cAAY,KAAK,SAAI,QAAU,CAAC,GAAG,YAAY,CAAA;6BAChE;wBACH,CAAC,CAAC,CAAA;wBAEF,sBAAO,UAAU,EAAA;;;;KAClB;IAED,kDAA4B,GAA5B,UAA6B,IAAoB,EAAE,QAAmB;QAC5D,IAAA,QAAQ,GAAK,2BAAoB,CAAC,cAAc,EAAE,QAAQ,CAAC,SAAnD,CAAmD;QAEnE,OAAO,IAAI,CAAC,GAAG,CAAC,UAAA,CAAC;YACf,6BACK,CAAC;gBACJ,iBAAiB;gBACjB,SAAS,EAAE,QAAQ,CAAC,IAAI,CAAC,UAAA,YAAY,IAAI,OAAA,YAAY,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM,EAAhC,CAAgC,CAAC,IAC3E;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;IACH,kBAAC;AAAD,CAAC,AA/JD,CAAyC,sBAAW,GA+JnD"}
\ No newline at end of file
......@@ -19,6 +19,7 @@ declare class UserService extends BaseService {
* @returns 若用户不存在,返回null; 用户存在,返回用户信息(object对象)
*/
getUserInfoByOpenId(openId: string): Promise<IUserInfo>;
doLogin(userInfo: IUserInfo, vipInfo: IVipInfo, activityInfo: IActivityInfo): Promise<IUserInfo>;
/**
* 初始化用户数据
*
......@@ -37,38 +38,37 @@ declare class UserService extends BaseService {
*/
updateUser(_id: string, projection: IUpdateQuery): Promise<number>;
getRank(sortValueKey: string, sortTimeKey: string, limit?: number): Promise<{
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;
}[]>;
list: {
score: any;
avatar: string;
userNick: string;
rank: number;
}[];
}>;
/**
* 获取用户排名
*
* @param {string} sortValueKey 排名字段
* @param {number} userValue
* @param {userInfo} IUserInfo
* @param {string} sortTimeKey
* @return {number} 排行
* @memberof UserService
*/
getMyRank(sortValueKey: string, sortTimeKey: string, userValue: number): Promise<number>;
getMyRankInfo(sortValueKey: string, sortTimeKey: string, userInfo: IUserInfo): Promise<{
rank: number;
userNick: string;
avatar: string;
score: any;
}>;
/**
* @desc 根据用户主键id查找用户详情
* @param {用户的主键id} _id
* @returns 若用户不存在,返回null; 用户存在,返回用户信息(object对象)
*/
getUserInfoById(_id: string): Promise<unknown>;
getShopVip(context: IContext<{
activityId: string;
callbackUrl?: string;
}>, session: string, activityUserNick: string): Promise<IVipInfo>;
}
export default UserService;
......@@ -71,6 +71,7 @@ var db_1 = require("../db");
var utils_1 = require("../utils");
var userUpdate_1 = require("../utils/common/userUpdate");
var format_1 = require("../utils/common/format");
var vip_1 = require("../utils/common/vip");
var UserService = /** @class */ (function (_super) {
__extends(UserService, _super);
function UserService(context) {
......@@ -119,6 +120,25 @@ var UserService = /** @class */ (function (_super) {
});
});
};
UserService.prototype.doLogin = function (userInfo, vipInfo, activityInfo) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!!userInfo) return [3 /*break*/, 2];
return [4 /*yield*/, this.initUserData(vipInfo, activityInfo)];
case 1:
userInfo = _a.sent();
return [3 /*break*/, 4];
case 2: return [4 /*yield*/, this.updateUserData(vipInfo, userInfo, activityInfo)];
case 3:
userInfo = _a.sent();
_a.label = 4;
case 4: return [2 /*return*/, userInfo];
}
});
});
};
/**
* 初始化用户数据
*
......@@ -129,17 +149,17 @@ var UserService = /** @class */ (function (_super) {
*/
UserService.prototype.initUserData = function (vipInfo, activityInfo) {
return __awaiter(this, void 0, void 0, function () {
var _a, openId, data, activityId, isFollow, avatar, inviteId, userNick, today, tasks, follow, member, user;
var _b, _c;
return __generator(this, function (_d) {
switch (_d.label) {
var _a, openId, data, activityId, isFollow, avatar, inviteId, userNick, today, tasks, _b, follow, _c, member, user;
var _d, _e;
return __generator(this, function (_f) {
switch (_f.label) {
case 0:
_a = this.context, openId = _a.openId, data = _a.data;
activityId = data.activityId, isFollow = data.isFollow, avatar = data.avatar, inviteId = data.inviteId, userNick = data.userNick;
today = utils_1.getToday();
console.log("----------" + today + "----------", today);
tasks = activityInfo.tasks;
follow = tasks.follow, member = tasks.member;
_b = tasks.follow, follow = _b === void 0 ? {} : _b, _c = tasks.member, member = _c === void 0 ? {} : _c;
user = {
activityId: activityId,
avatar: avatar,
......@@ -157,12 +177,12 @@ var UserService = /** @class */ (function (_super) {
follow: {
flag: !!isFollow
},
login: (_b = {},
_b[today] = 1,
_b),
taskInfo: (_c = {},
_c[today] = {},
_c),
login: (_d = {},
_d[today] = 1,
_d),
taskInfo: (_e = {},
_e[today] = {},
_e),
createTime: Date.now(),
createDay: today,
updateTime: Date.now()
......@@ -177,7 +197,7 @@ var UserService = /** @class */ (function (_super) {
}
return [4 /*yield*/, this.userdao.insertOne(user)];
case 1:
_d.sent();
_f.sent();
return [2 /*return*/, user];
}
});
......@@ -268,9 +288,16 @@ var UserService = /** @class */ (function (_super) {
})];
case 1:
list = _d.sent();
return [2 /*return*/, list.map(function (v, i) {
return __assign(__assign({}, v), { userNick: format_1.formatUserNick(v.userNick), rank: i + 1 });
})];
return [2 /*return*/, {
list: list.map(function (v, i) {
return {
score: v[sortValueKey],
avatar: v.avatar,
userNick: format_1.formatUserNick(v.userNick),
rank: i + 1
};
})
}];
}
});
});
......@@ -279,20 +306,22 @@ var UserService = /** @class */ (function (_super) {
* 获取用户排名
*
* @param {string} sortValueKey 排名字段
* @param {number} userValue
* @param {userInfo} IUserInfo
* @param {string} sortTimeKey
* @return {number} 排行
* @memberof UserService
*/
UserService.prototype.getMyRank = function (sortValueKey, sortTimeKey, userValue) {
UserService.prototype.getMyRankInfo = function (sortValueKey, sortTimeKey, userInfo) {
return __awaiter(this, void 0, void 0, function () {
var activityId, openId, sameScoreList, rank, gap, j;
var activityId, openId, userValue, userNick, avatar, sameScoreList, rank, gap, j;
var _a, _b, _c;
return __generator(this, function (_d) {
switch (_d.label) {
case 0:
activityId = this.context.data.activityId;
openId = this.context.openId;
userValue = userInfo[sortValueKey];
userNick = userInfo.userNick, avatar = userInfo.avatar;
return [4 /*yield*/, this.userdao.find((_a = {}, _a[sortValueKey] = userValue, _a.activityId = activityId, _a), {
sort: (_b = {}, _b[sortTimeKey] = 1, _b)
})];
......@@ -309,7 +338,12 @@ var UserService = /** @class */ (function (_super) {
case 2:
rank = _d.sent();
rank = rank + 1 + gap;
return [2 /*return*/, rank];
return [2 /*return*/, {
rank: rank,
userNick: userNick,
avatar: avatar,
score: userValue
}];
}
});
});
......@@ -329,6 +363,19 @@ var UserService = /** @class */ (function (_super) {
});
});
};
UserService.prototype.getShopVip = function (context, session, activityUserNick) {
return __awaiter(this, void 0, void 0, function () {
var callbackUrl;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
callbackUrl = context.data.callbackUrl;
return [4 /*yield*/, vip_1.getShopVip(context, session, callbackUrl || vip_1.formatVipCbUrl(context), activityUserNick)];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
return UserService;
}(base_service_1.default));
exports.default = UserService;
......
This diff is collapsed.
......@@ -7,9 +7,7 @@ import { PRIZE_TYPE, DRAW_STATUS, CODE_TYPES } from '../constants'
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'
import { checkActivityTime, checkPrizeExpired, checkValidPrize } from '../utils/common/check/'
export interface IPrizeListParams {
activityId: string
......@@ -47,46 +45,10 @@ export default class AwardsController {
{ activityInfo }: IControllerInfos,
[awardSer]: [AwardsService]
): Promise<IResult<{ list: IAwards[] }>> {
const {
openId,
data: { activityId }
} = context
const { awardReceiveExpiredTime } = activityInfo
const myPrizeList = await awardSer.getAwardsInfoList(
{
openId,
activityId,
type: { $ne: PRIZE_TYPE.THANKS }
},
{
projection: {
_id: 1,
name: 1,
image: 1,
type: 1,
drawStatus: 1,
shipStatus: 1,
receiveName: 1,
phone: 1,
address: 1,
provice: 1,
city: 1,
area: 1,
remark: 1,
useUrl: 1,
shipCompany: 1,
shipNum: 1
},
sort: {
createTime: -1
}
}
)
const list = await awardSer.getMyPrizeList(activityInfo)
return resultsModel.success({
list: awardSer.formatMyPrizeList(myPrizeList, awardReceiveExpiredTime)
list
})
}
......@@ -95,7 +57,7 @@ export default class AwardsController {
*/
@checkParams(['activityId', 'id', 'name', 'phone', 'province', 'city', 'area', 'addressDetail', 'streetName'])
@services([AwardsService])
@preCheck([checkPrizeExpired, checkValidPrize([PRIZE_TYPE.OBJECT])])
@preCheck([checkPrizeExpired])
async receiveObjectPrize(
context: IContext<IReceiveOjectParams>,
{ activityInfo }: IReceivePrizeControllerInfos,
......@@ -125,7 +87,7 @@ export default class AwardsController {
@checkParams(['activityId', 'id'])
@registeInfos(['session'])
@services([AwardsService])
@preCheck([checkPrizeExpired, checkValidPrize([PRIZE_TYPE.ENAME, PRIZE_TYPE.CREDITS])])
@preCheck([checkPrizeExpired])
async receiveEnamePrize(
context: IContext<IReceiveEnameParams>,
{ awardInfo, session }: IReceivePrizeControllerInfos,
......
......@@ -3,9 +3,8 @@
import { services, checkParams, registeInfos } from '../decorator/common'
import { resultsModel } from '../sdk'
import { UserService, AccessService } from '../service'
import preCheck from '../decorator/common/preCheck'
import { checkActivityTime } from '../utils/common/check/checkActivityTime'
import noCheckUser from '../decorator/common/noCheckUser'
import { noCheckUser } from '../decorator/common'
export interface ILoginParams {
activityId: string
......@@ -24,19 +23,14 @@ export default class User {
@services([UserService, AccessService])
async login(
context: IContext<ILoginParams>,
{ userInfo, vipInfo, activityInfo }: IControllerInfos,
{ userInfo, activityInfo, vipInfo }: IControllerInfos,
[userService, accessService]: [UserService, AccessService]
): Promise<IResult<{ openId: string }>> {
const { openId } = context
if (!userInfo) {
userInfo = await userService.initUserData(vipInfo, activityInfo)
} else {
userInfo = await userService.updateUserData(vipInfo, userInfo, activityInfo)
}
const updatedUserInfo = await userService.doLogin(userInfo, vipInfo, activityInfo)
// access表
await accessService.addAccess(userInfo)
await accessService.addAccess(updatedUserInfo)
return resultsModel.success({
openId
......
/** @format */
import { checkParams } from '../decorator/common/'
import { services, preCheck, registeInfos } from '../decorator/common/'
import { services, preCheck, registeInfos, preUpdate, checkParams } from '../decorator/common/'
import { resultsModel } from '../sdk'
import { UserService, StatService, TaskService } from '../service'
import { STAT_TYPE } from '../constants'
import { checkActivityTime } from '../utils/common/check/checkActivityTime'
import { checkInviteId } from '../utils/common/check/checkInviteId'
import { checkHelpRecord } from '../utils/common/check/checkHelpRecord'
import { checkNewVip } from '../utils/common/check/checkNewVip'
import { checkActivityTime, checkInviteId, checkHelpRecord, checkNewVip } from '../utils/common/check'
import { CODE_TYPES } from '../errorCode'
import update from '../decorator/common/update'
import { updateVip } from '../utils/common/update/updateVip'
import { updateVip } from '../utils/common/update/'
export interface IdoHelpInfos extends IControllerInfos {
inviteUserInfo: IUserInfo
}
......@@ -41,7 +36,7 @@ export default class Share {
@registeInfos(['vipInfo'])
@services([TaskService, StatService])
@preCheck([checkActivityTime, checkInviteId, checkNewVip, checkHelpRecord])
@update([updateVip])
@preUpdate([updateVip])
async doHelp(
context: IContext<{
activityId: string
......
......@@ -5,13 +5,9 @@ import { checkParams, services, registeInfos, preCheck } from '../decorator/comm
import { resultsModel } from '../sdk'
import { TaskService, BaseService } from '../service'
import { ITaskInfo } from '../service/task.service'
import { checkActivityTime } from '../utils/common/check/checkActivityTime'
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'
import { checkActivityTime, checkTaskLimit, checkExchangeCreditsTask, checkRemainTimes } from '../utils/common/check/'
import { preUpdate } from '../decorator/common'
import { updateVip, updateSignTask } from '../utils/common/update'
export default class Task {
/**
......@@ -21,7 +17,7 @@ export default class Task {
@registeInfos(['vipInfo'])
@services([TaskService])
@preCheck([checkActivityTime])
@update([updateVip])
@preUpdate([updateVip, updateSignTask])
async getTaskList(
context: IContext<{ activityId: string }>,
{ userInfo, activityInfo }: IControllerInfos,
......@@ -36,7 +32,7 @@ export default class Task {
// taskService.initTask('collectGoods', '收藏商品', activityInfo, userInfo),
// taskService.initTask('jumpLink', '浏览页面', activityInfo, userInfo),
// taskService.initTask('invites', '邀请好友', activityInfo, userInfo)
// taskService.initTask('exchangeCredits', '积分兑换', activityInfo, updatedUserInfo)
// taskService.initTask('exchangeCredits', '积分兑换', activityInfo, userInfo)
])
}
......@@ -98,24 +94,17 @@ export default class Task {
*/
@checkParams(['activityId', 'itemIds'])
@registeInfos(['session'])
@services([BaseService])
@services([BaseService, TaskService])
async getCollectGoodsList(
context: IContext<IParams>,
{ session, userInfo }: IControllerInfos,
[baseService]: [BaseService]
[baseService, taskService]: [BaseService, TaskService]
) {
const { itemIds } = context.data
const list = await baseService.getItemListByIds(itemIds, session)
const { taskInfo } = getTotalCompleteTask('collectGoods', userInfo)
const list = await baseService.getItemListByIds(itemIds, session)
const listWithCollectStatus = list.map(v => {
return {
...v,
// 完成列表是否含有itemId
collected: taskInfo.some(completeItem => completeItem.itemId === v.itemId)
}
})
const listWithCollectStatus = taskService.getItemListWithCollectStatus(list, userInfo)
return resultsModel.success(listWithCollectStatus)
}
......
......@@ -10,17 +10,35 @@ export interface IVipParams {
callbackUrl?: string
inviteId?: string // 需要助力回调时请求该接口
}
interface IRankList {
userNick: string
avatar: string
score: any
rank: number
}
export interface IRankResult {
rank: number
userNick: string
avatar: string
score: number
list: IRankList[]
}
export default class User {
/**
* 获取会员信息
*/
@checkParams(['activityId'])
@registeInfos(['session'])
@services([UserService])
async getVipInfo(
context: IContext<IVipParams>,
{ session, activityUserNick }: IControllerInfos
{ session, activityUserNick }: IControllerInfos,
[userService]: [UserService]
): Promise<IResult<IVipInfo>> {
const { callbackUrl } = context.data
// 拼接回调参数
const result = await getShopVip(context, session, callbackUrl || formatVipCbUrl(context), activityUserNick)
const result = await userService.getShopVip(context, session, activityUserNick)
return resultsModel.success(result)
}
......@@ -42,18 +60,13 @@ export default class User {
) {
const { key, timeKey, limit = 200 } = context.data
const { userNick, avatar } = userInfo
const rank = await userService.getMyRank(key, timeKey, userInfo[key])
const rankInfo = await userService.getMyRankInfo(key, timeKey, userInfo)
const list = await userService.getRank(key, timeKey, limit)
return resultsModel.success({
userNick,
avatar,
rank,
score: userInfo[key],
list
...rankInfo,
...list
})
}
}
......@@ -3,7 +3,7 @@ import { resultsModel } from '../../sdk'
import { CODE_TYPES } from '../../constants'
import { logFn } from '../../utils'
// 检验参数是否存在
const checkParams = (params: string[]) => {
export default function checkParams(params: string[]) {
return function (target: Object, name: string, descriptor: PropertyDescriptor) {
const method = descriptor.value
......@@ -21,5 +21,3 @@ const checkParams = (params: string[]) => {
}
}
}
export default checkParams
......@@ -5,7 +5,7 @@ import checkParams from './checkParams'
import preCheck from './preCheck'
import registeInfos from './registeInfos'
import noCheckUser from './noCheckUser'
import update from './update'
import preUpdate from './preUpdate'
const common = {
services,
......@@ -14,9 +14,9 @@ const common = {
preCheck,
registeInfos,
noCheckUser,
update
preUpdate
}
export default common
export { services, noCatch, checkParams, preCheck, registeInfos, noCheckUser, update }
export { services, noCatch, checkParams, preCheck, registeInfos, noCheckUser, preUpdate }
/** @format */
const noCatch = (target: any, name: string, descriptor: PropertyDescriptor) => {
export default function noCatch(target: any, name: string, descriptor: PropertyDescriptor) {
const method = descriptor.value
descriptor.value = async function (...args: any[]) {
const [context, otherArgs = {}] = args
return method.apply(this, [context, { ...otherArgs, noCatch: true }])
}
}
export default noCatch
/** @format */
const noCheckUser = (target: any, name: string, descriptor: PropertyDescriptor) => {
export default function noCheckUser(target: any, name: string, descriptor: PropertyDescriptor) {
const method = descriptor.value
descriptor.value = async function (...args: any[]) {
const [context, otherArgs = {}] = args
return method.apply(this, [context, { ...otherArgs, noCheckUser: true }])
}
}
export default noCheckUser
/** @format */
// 检验参数是否存在
const preCheck = (checks: IFunction[]) => {
export default function preCheck(checks: IFunction[]) {
return function (target: Object, name: string, descriptor: PropertyDescriptor) {
const method = descriptor.value
......@@ -23,5 +23,3 @@ const preCheck = (checks: IFunction[]) => {
}
}
}
export default preCheck
/** @format */
import { merge } from 'lodash'
import { isEmpty, merge } from 'lodash'
import { UserService } from '../../service'
import { recordErrorLog } from '../../utils/common/logger'
import { resultsModel } from '../../sdk'
import { CODE_TYPES } from '../../errorCode'
import { formatUpdatedUserInfo } from '../../utils/common/format'
import { userInfo } from 'os'
// 检验参数是否存在
const update = (checks: IFunction[]) => {
export default function preUpdate(checks: IFunction[]) {
return function (target: Object, name: string, descriptor: PropertyDescriptor) {
const method = descriptor.value
descriptor.value = async function (...args: any[]) {
let [context, otherArgs = {}, services = []] = args
let totalUpdateProjection: IDecoratorUpdateQuery = {}
let [context, otherArgs = {} as IControllerInfos, services = []] = args
let totalUpdateProjection: IPreUpdateQuery = {}
for (let i = 0; i < checks.length; i++) {
const checkFn = checks[i]
let result: IDecoratorUpdateQuery = await checkFn.apply(target, [context, { ...otherArgs }, services])
let result: IPreUpdateQuery = await checkFn.apply(target, [context, { ...otherArgs }, services])
result = result || {}
// 校验报错
if ((result as IErrorResult)?.success === false && (result as IErrorResult)?.code) {
......@@ -24,9 +30,36 @@ const update = (checks: IFunction[]) => {
otherArgs = { ...otherArgs }
}
console.log(formatUpdatedUserInfo(otherArgs.userInfo, totalUpdateProjection))
// 更新数据
try {
await preUpdateUser(context, otherArgs.userInfo, totalUpdateProjection)
} catch (error) {
console.log(error, 'preUpdateUser-error')
recordErrorLog(context, otherArgs, error.toString(), error.stack)
return resultsModel.error(CODE_TYPES.SYSTEM_ERROR)
}
return method.apply(target, [context, { ...otherArgs }, services])
}
}
}
export default update
async function preUpdateUser(context: IContext<IParams>, userInfo: IUserInfo, updateProjection: IPreUpdateQuery) {
return true
// 删除空的操作
if (isEmpty(updateProjection.$inc)) {
delete updateProjection.$inc
}
if (isEmpty(updateProjection.$set)) {
delete updateProjection.$set
}
if (isEmpty(updateProjection.$push)) {
delete updateProjection.$push
}
if (isEmpty(updateProjection)) return true
const userService = new UserService(context)
return await userService.updateUser(userInfo._id, updateProjection)
}
......@@ -44,7 +44,7 @@ async function initBaseInfo(context: IContext<IParams>, baseInfos: ICheckControl
return baseInfos
}
const registeInfos = (needInfos: IInfo[]) => {
export default function registeInfos(needInfos: IInfo[]) {
return function (target: any, name: string, descriptor: PropertyDescriptor) {
const method = descriptor.value
descriptor.value = async function (...args: any[]) {
......@@ -58,5 +58,3 @@ const registeInfos = (needInfos: IInfo[]) => {
}
}
}
export default registeInfos
......@@ -31,7 +31,7 @@ async function formatBaseInfos(context: IContext<IParams>, baseInfos: ICheckCont
}
// 注入服务
const services = (services: Constructor[]) => {
export default function services(services: Constructor[]) {
return (target: Object, name: string, descriptor: PropertyDescriptor) => {
const method = descriptor.value
......@@ -57,5 +57,3 @@ const services = (services: Constructor[]) => {
}
}
}
export default services
......@@ -63,6 +63,43 @@ export default class AwardsService extends UserService {
}
}
async getMyPrizeList(activityInfo: IActivityInfo) {
const { openId } = this.context
const { activityId } = this.context.data
const myPrizeList = await this.getAwardsInfoList(
{
openId,
activityId,
type: { $ne: PRIZE_TYPE.THANKS }
},
{
projection: {
_id: 1,
name: 1,
image: 1,
type: 1,
drawStatus: 1,
shipStatus: 1,
receiveName: 1,
phone: 1,
address: 1,
provice: 1,
city: 1,
area: 1,
remark: 1,
useUrl: 1,
shipCompany: 1,
shipNum: 1
},
sort: {
createTime: -1
}
}
)
return this.formatMyPrizeList(myPrizeList, activityInfo.awardReceiveExpiredTime)
}
/**
* 插入奖品记录
* @param {*} award
......@@ -114,7 +151,7 @@ export default class AwardsService extends UserService {
return await this.awardsdao.find<IAwards>(query, projection)
}
formatMyPrizeList(myPrizeList: IAwards[], awardReceiveExpiredTime?: number) {
formatMyPrizeList(myPrizeList: IAwards[], awardReceiveExpiredTime?: number): IAwards[] {
const now = Date.now()
return myPrizeList.map(v => {
if (
......
......@@ -181,69 +181,15 @@ export default class TaskService extends UserService {
return projection
}
// 更新签到任务数据
updateSignTask(userInfo: IUserInfo, tasks: ITasks) {
// 获取签到奖励
const {
sign: { value }
} = tasks || {}
const { todayCompleteTimes } = getTodayCompleteTask('sign', userInfo)
const today = getToday()
// 今天没有有完成记录
return todayCompleteTimes === 0
? {
$inc: {
'remainTimes.sign': value
},
$push: {
[`taskInfo.${today}.sign`]: { createTime: Date.now() }
}
}
: {}
}
/**
*
* 更新user表中,任务相关字段
*
* @param {string} id
* @param {object[]} needUpdateKeysArray
* @param {IUserInfo} userInfo
* @returns {IUserInfo | boolean} userInfo
* @memberof TaskService
*/
async updateTasks(id: string, needUpdateKeysArray: object[], userInfo: IUserInfo): Promise<false | IUserInfo> {
logger(needUpdateKeysArray)
const updateKeys = merge({}, ...needUpdateKeysArray)
logger(updateKeys)
const _$inc = updateKeys.$inc || {}
const _$set = updateKeys.$set || {}
const _$push = updateKeys.$push || {}
// 删除空的操作
if (!Object.keys(_$inc).length && updateKeys.$inc) {
delete updateKeys.$inc
}
if (!Object.keys(_$set).length && updateKeys.$set) {
delete updateKeys.$set
}
if (!Object.keys(_$push).length && updateKeys.$push) {
delete updateKeys.$push
}
if (!Object.keys(updateKeys).length) {
return userInfo
}
await this.updateUser(id, updateKeys)
// 更新数据库后 延迟10ms 执行
await sleep(10)
return await this.getUserInfo()
getItemListWithCollectStatus(list: ITaoBaoItems[], userInfo: IUserInfo) {
const { taskInfo } = getTotalCompleteTask('collectGoods', userInfo)
return list.map(v => {
return {
...v,
// 完成列表是否含有itemId
collected: taskInfo.some(completeItem => completeItem.itemId === v.itemId)
}
})
}
}
......@@ -10,6 +10,8 @@ import { USER_DB_NAME } from '../db'
import { getToday, formatUpdateUserProjection } from '../utils'
import { isNewVip } from '../utils/common/userUpdate'
import { formatUserNick } from '../utils/common/format'
import { getShopVip, formatVipCbUrl } from '../utils/common/vip'
import { userInfo } from 'os'
class UserService extends BaseService {
userdao: IBaseDao
constructor(context: IContext<IParams>) {
......@@ -39,6 +41,15 @@ class UserService extends BaseService {
return record
}
async doLogin(userInfo: IUserInfo, vipInfo: IVipInfo, activityInfo: IActivityInfo) {
if (!userInfo) {
userInfo = await this.initUserData(vipInfo, activityInfo)
} else {
userInfo = await this.updateUserData(vipInfo, userInfo, activityInfo)
}
return userInfo
}
/**
* 初始化用户数据
*
......@@ -53,7 +64,7 @@ class UserService extends BaseService {
const today = getToday()
console.log(`----------${today}----------`, today)
const { tasks } = activityInfo
const { follow, member } = tasks
const { follow = {} as ITaskConfig, member = {} as ITaskConfig } = tasks
const user: IUserInfo = {
activityId,
avatar,
......@@ -171,27 +182,33 @@ class UserService extends BaseService {
}
)
return list.map((v, i) => {
return {
...v,
userNick: formatUserNick(v.userNick),
rank: i + 1
}
})
return {
list: list.map((v, i) => {
return {
score: v[sortValueKey],
avatar: v.avatar,
userNick: formatUserNick(v.userNick),
rank: i + 1
}
})
}
}
/**
* 获取用户排名
*
* @param {string} sortValueKey 排名字段
* @param {number} userValue
* @param {userInfo} IUserInfo
* @param {string} sortTimeKey
* @return {number} 排行
* @memberof UserService
*/
async getMyRank(sortValueKey: string, sortTimeKey: string, userValue: number): Promise<number> {
async getMyRankInfo(sortValueKey: string, sortTimeKey: string, userInfo: IUserInfo) {
let { activityId } = this.context.data
const { openId } = this.context
const userValue = userInfo[sortValueKey]
const { userNick, avatar } = userInfo
let sameScoreList = await this.userdao.find<IUserInfo>(
{ [sortValueKey]: userValue, activityId },
{
......@@ -209,7 +226,12 @@ class UserService extends BaseService {
}
rank = await this.userdao.count({ [sortValueKey]: { $gt: userValue }, activityId })
rank = rank + 1 + gap
return rank
return {
rank,
userNick,
avatar,
score: userValue
}
}
/**
......@@ -220,6 +242,15 @@ class UserService extends BaseService {
async getUserInfoById(_id: string) {
return await this.userdao.findOne({ _id })
}
async getShopVip(
context: IContext<{ activityId: string; callbackUrl?: string }>,
session: string,
activityUserNick: string
) {
const { callbackUrl } = context.data
return await getShopVip(context, session, callbackUrl || formatVipCbUrl(context), activityUserNick)
}
}
export default UserService
......@@ -118,7 +118,7 @@ interface IUpdateQuery {
}
}
interface IDecoratorUpdateQuery {
interface IPreUpdateQuery {
$inc?: { [key: string]: number | undefined }
$set?: { [key: string]: any }
$push?: { [key: string]: any }
......
......@@ -3,7 +3,7 @@
import { resultsModel } from '../../../sdk'
import { CODE_TYPES } from '../../../errorCode'
export const checkActivityTime = async (context: IContext<IParams>, { activityInfo }: IControllerInfos) => {
export default async function checkActivityTime(context: IContext<IParams>, { activityInfo }: IControllerInfos) {
// 活动不存在
if (!activityInfo) {
return resultsModel.error(CODE_TYPES.ERROR_NO_ACTIVITY)
......
......@@ -3,10 +3,10 @@
import { resultsModel, TBAPIS } from '../../../sdk'
import { CODE_TYPES } from '../../../errorCode'
export const checkExchangeCreditsTask = async (
export default async function checkExchangeCreditsTask(
context: IContext<{ activityId: string; taskType: ITaskType; credits?: number }>,
{ session }: IControllerInfos
) => {
) {
const { taskType, credits } = context.data
// 不是兑换积分类型不校验
......
......@@ -6,7 +6,7 @@ import { dbCount } from '../../common/db'
import { STAT_DB_NAME } from '../../../db'
import { STAT_TYPE } from '../../../constants'
export const checkHelpRecord = async (context: IContext<{ activityId: string; inviteId: string }>) => {
export default async function checkHelpRecord(context: IContext<{ activityId: string; inviteId: string }>) {
const {
openId,
data: { activityId, inviteId }
......
......@@ -5,7 +5,7 @@ import { CODE_TYPES } from '../../../errorCode'
import { dbFindOne } from '../../common/db'
import { USER_DB_NAME } from '../../../db'
export const checkInviteId = async (context: IContext<{ activityId: string; inviteId: string }>) => {
export default async function checkInviteId(context: IContext<{ activityId: string; inviteId: string }>) {
const {
openId,
data: { activityId, inviteId }
......
......@@ -3,7 +3,7 @@
import { resultsModel } from '../../../sdk'
import { CODE_TYPES } from '../../../errorCode'
export const checkNewVip = async (context: IContext<IParams>, { vipInfo, userInfo }: IControllerInfos) => {
export default async function checkNewVip(context: IContext<IParams>, { vipInfo, userInfo }: IControllerInfos) {
if (!vipInfo) {
console.error(`使用checkNewVip registeInfos必须注册vipInfo`)
}
......
......@@ -3,7 +3,7 @@
import { resultsModel } from '../../../sdk'
import { CODE_TYPES } from '../../../errorCode'
export const checkPrizeExpired = async (context: IContext<IParams>, { activityInfo }: IControllerInfos) => {
export default async function checkPrizeExpired(context: IContext<IParams>, { activityInfo }: IControllerInfos) {
// 若有过期时间,且已过期
let { awardReceiveExpiredTime } = activityInfo
if (awardReceiveExpiredTime && Date.now() > awardReceiveExpiredTime) {
......
......@@ -3,7 +3,10 @@
import { resultsModel } from '../../../sdk'
import { CODE_TYPES } from '../../../errorCode'
export const checkRemainTimes = async (context: IContext<{ taskType: ITaskType }>, { userInfo }: IControllerInfos) => {
export default async function checkRemainTimes(
context: IContext<{ taskType: ITaskType }>,
{ userInfo }: IControllerInfos
) {
const { taskType } = context.data
const { remainTimes } = userInfo
......
......@@ -5,10 +5,10 @@ import { CODE_TYPES } from '../../../errorCode'
import { getTodayCompleteTask, getTotalCompleteTask } from '../task'
import { TASK_RATE_TYPE } from '../../../constants'
export const checkTaskLimit = async (
export default async function checkTaskLimit(
context: IContext<{ activityId: string; taskType: ITaskType; itemId?: string }>,
{ userInfo, activityInfo }: IControllerInfos
) => {
) {
const { taskType, itemId } = context.data
const { itemIds } = activityInfo?.tasks?.[taskType] || {}
if (!taskType) {
......
......@@ -6,7 +6,7 @@ import { DRAW_STATUS } from '../../../constants'
import { dbFindOne } from '../db'
import { AWARDS_DB_NAME } from '../../../db'
export const checkValidPrize = (prizeTypes: number[]) => {
export default async function checkValidPrize(prizeTypes: number[]) {
return async (context: IContext<{ id: string }>, { activityInfo }: IControllerInfos) => {
const { id } = context.data
let awardInfo = await dbFindOne<IAwards>(context, AWARDS_DB_NAME, {
......
......@@ -3,7 +3,7 @@
import { resultsModel } from '../../../sdk'
import { CODE_TYPES } from '../../../errorCode'
export const checkVip = async (context: IContext<IParams>, { vipInfo }: IControllerInfos) => {
export default async function checkVip(context: IContext<IParams>, { vipInfo }: IControllerInfos) {
if (!vipInfo) {
console.error(`使用checkVip registeInfos必须注册vipInfo`)
}
......
/** @format */
import checkActivityTime from './checkActivityTime'
import checkExchangeCreditsTask from './checkExchangeCreditsTask'
import checkHelpRecord from './checkHelpRecord'
import checkInviteId from './checkInviteId'
import checkNewVip from './checkNewVip'
import checkPrizeExpired from './checkPrizeExpired'
import checkRemainTimes from './checkRemainTimes'
import checkTaskLimit from './checkTaskLimit'
import checkValidPrize from './checkValidPrize'
import checkVip from './checkVip'
import { checkActivityTime } from './checkActivityTime'
import { checkHelpRecord } from './checkHelpRecord'
import { checkInviteId } from './checkInviteId'
import { checkNewVip } from './checkNewVip'
import { checkTaskLimit } from './checkTaskLimit'
import { checkVip } from './checkVip'
const check = {
checkActivityTime,
checkExchangeCreditsTask,
checkHelpRecord,
checkInviteId,
checkNewVip,
checkPrizeExpired,
checkRemainTimes,
checkTaskLimit,
checkValidPrize,
checkVip
}
export default check
export default {
export {
checkActivityTime,
checkExchangeCreditsTask,
checkHelpRecord,
checkInviteId,
checkNewVip,
checkPrizeExpired,
checkRemainTimes,
checkTaskLimit,
checkValidPrize,
checkVip
}
......@@ -11,7 +11,7 @@ export async function doHandler(target: Object, method: IFunction, args: any[])
ret = await method.apply(target, args)
} catch (error) {
console.log('error', error)
await recordErrorLog(args[0], args[1], error.toString(), error.stack)
recordErrorLog(args[0], args[1], error.toString(), error.stack)
ret = resultsModel.error(CODE_TYPES.SYSTEM_ERROR)
}
return ret
......
......@@ -42,7 +42,7 @@ export function formatUserNick(name: string) {
* @param {IUserInfo} userInfo
* @param {IDecoratorUpdateQuery} projection
*/
export function formatUpdatedUserInfo(userInfo: IUserInfo, projection: IDecoratorUpdateQuery) {
export function formatUpdatedUserInfo(userInfo: IUserInfo, projection: IPreUpdateQuery) {
let updatedUserInfo = assign({}, userInfo)
if (!isEmpty(projection.$set)) {
......@@ -56,3 +56,13 @@ export function formatUpdatedUserInfo(userInfo: IUserInfo, projection: IDecorato
updatedUserInfo = merge({}, userInfo, projection.$set)
}
}
function format$Set(userInfo: IUserInfo, setProjection: object) {
Object.keys(setProjection).forEach(setKey => {
const splitKey = setKey.split('.')
let result = {}
splitKey.forEach((key, i) => {
result[key] = i === splitKey.length - 1 ? setProjection[setKey] : {}
})
})
}
/** @format */
import * as check from './check'
import * as update from './update'
export default {
check,
update
}
/** @format */
import updateVip from './updateVip'
import updateSignTask from './updateSignTask'
import { updateVip } from './updateVip'
export default {
updateVip
const update = {
updateVip,
updateSignTask
}
export default update
export { updateVip, updateSignTask }
/** @format */
import { getToday } from '../getToday'
import { getTodayCompleteTask } from '../task'
export default async function updateSignTask(
context: IContext<IParams>,
{ userInfo, activityInfo }: IControllerInfos
): Promise<IPreUpdateQuery> {
// 获取签到奖励
const { value } = activityInfo?.tasks?.sign || {}
const { todayCompleteTimes } = getTodayCompleteTask('sign', userInfo)
const today = getToday()
// 今天没有有完成记录
return todayCompleteTimes === 0
? {
$inc: {
'remainTimes.sign': value || 0
},
$push: {
[`taskInfo.${today}.sign`]: { createTime: Date.now() }
}
}
: {}
}
/** @format */
import { resultsModel } from '../../../sdk'
import { CODE_TYPES } from '../../../errorCode'
import { dbCount } from '../../common/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 async function updateVip(
export default async function updateVip(
context: IContext<IParams>,
{ vipInfo, userInfo, activityInfo }: IControllerInfos
): Promise<IDecoratorUpdateQuery> {
): Promise<IPreUpdateQuery> {
let { member } = userInfo
const memberReWards = activityInfo?.tasks?.member?.value
......
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