Commit 759fff76 authored by qinhaitao's avatar qinhaitao

feat: 🎸 商品列表接口

parent e17c0c3e
......@@ -9,8 +9,9 @@ var configs = {
test: test_1.default,
mock: test_1.default
};
// 根据服务环境获取配置
exports.getConfig = function (context) {
var env = context.env;
return configs[env] || configs.test;
return configs[env] || configs.online;
};
//# sourceMappingURL=index.js.map
\ No newline at end of file
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":";AAAA,cAAc;;;AAEd,mCAA6B;AAC7B,+BAAyB;AAMzB,IAAM,OAAO,GAAG;IACd,MAAM,kBAAA;IACN,IAAI,gBAAA;IACJ,IAAI,EAAE,cAAI;CACX,CAAA;AAEY,QAAA,SAAS,GAAG,UAAC,OAAgB;IACxC,IAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAA;IACvB,OAAO,OAAO,CAAC,GAAG,CAAC,IAAI,OAAO,CAAC,IAAI,CAAA;AACrC,CAAC,CAAA"}
\ No newline at end of file
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":";AAAA,cAAc;;;AAEd,mCAA6B;AAC7B,+BAAyB;AAMzB,IAAM,OAAO,GAAG;IACd,MAAM,kBAAA;IACN,IAAI,gBAAA;IACJ,IAAI,EAAE,cAAI;CACX,CAAA;AAED,aAAa;AACA,QAAA,SAAS,GAAG,UAAC,OAAgB;IACxC,IAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAA;IACvB,OAAO,OAAO,CAAC,GAAG,CAAC,IAAI,OAAO,CAAC,MAAM,CAAA;AACvC,CAAC,CAAA"}
\ No newline at end of file
......@@ -5,4 +5,8 @@ export default class BaseController {
* 活动基本信息
*/
getActivityBaseInfoById(context: Context, {}: {}, [baseService]: [BaseService]): Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result>;
/**
* 获取商品列表
*/
getItemListByItemIds(context: Context, { session }: IControllerInfos, [baseService]: [BaseService]): Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result>;
}
......@@ -49,6 +49,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
var constants_1 = require("./../constants");
var decorator_1 = require("../decorator");
var sdk_1 = require("../sdk");
var utils_1 = require("../utils");
var service_1 = require("../service");
var BaseController = /** @class */ (function () {
function BaseController() {
......@@ -76,6 +77,27 @@ var BaseController = /** @class */ (function () {
});
});
};
/**
* 获取商品列表
*/
BaseController.prototype.getItemListByItemIds = function (context, _a, _b) {
var session = _a.session;
var baseService = _b[0];
return __awaiter(this, void 0, void 0, function () {
var itemIds, list;
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
itemIds = context.data.itemIds;
return [4 /*yield*/, baseService.getItemListByIds(itemIds, session)];
case 1:
list = _c.sent();
utils_1.logger(list);
return [2 /*return*/, sdk_1.resultsModel.success(list)];
}
});
});
};
__decorate([
decorator_1.paramsCheck(['activityId']),
decorator_1.services([service_1.BaseService]),
......@@ -83,6 +105,13 @@ var BaseController = /** @class */ (function () {
__metadata("design:paramtypes", [Object, Object, Array]),
__metadata("design:returntype", Promise)
], BaseController.prototype, "getActivityBaseInfoById", null);
__decorate([
decorator_1.paramsCheck(['itemIds']),
decorator_1.services([service_1.BaseService]),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, Object, Array]),
__metadata("design:returntype", Promise)
], BaseController.prototype, "getItemListByItemIds", null);
return BaseController;
}());
exports.default = BaseController;
......
{"version":3,"file":"base.controller.js","sourceRoot":"","sources":["../../src/controller/base.controller.ts"],"names":[],"mappings":";AAAA,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEd,4CAA2C;AAC3C,0CAAoD;AAEpD,8BAAqC;AACrC,sCAAwC;AACxC;IAAA;IAgBA,CAAC;IAfC;;OAEG;IAGG,gDAAuB,GAA7B,UAA8B,OAAgB,EAAE,EAAE,EAAE,EAA4B;YAA3B,WAAW,QAAA;;;;;;wBACtD,UAAU,GAAK,OAAO,CAAC,IAAI,WAAjB,CAAiB;wBACnC,OAAO;wBACP,IAAI,CAAC,UAAU,EAAE;4BACf,sBAAO,kBAAY,CAAC,KAAK,CAAC,sBAAU,CAAC,YAAY,EAAE,wBAAc,CAAC,EAAA;yBACnE;wBAEoB,qBAAM,WAAW,CAAC,WAAW,CAAC,UAAU,CAAC,EAAA;;wBAAxD,YAAY,GAAG,SAAyC;wBAC9D,sBAAO,kBAAY,CAAC,OAAO,CAAC,YAAY,CAAC,EAAA;;;;KAC1C;IATD;QAFC,uBAAW,CAAC,CAAC,YAAY,CAAC,CAAC;QAC3B,oBAAQ,CAAC,CAAC,qBAAW,CAAC,CAAC;;;;iEAUvB;IACH,qBAAC;CAAA,AAhBD,IAgBC;kBAhBoB,cAAc"}
\ No newline at end of file
{"version":3,"file":"base.controller.js","sourceRoot":"","sources":["../../src/controller/base.controller.ts"],"names":[],"mappings":";AAAA,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEd,4CAA2C;AAC3C,0CAAoD;AAEpD,8BAAqC;AACrC,kCAAiC;AACjC,sCAAwC;AACxC;IAAA;IA8BA,CAAC;IA7BC;;OAEG;IAGG,gDAAuB,GAA7B,UAA8B,OAAgB,EAAE,EAAE,EAAE,EAA4B;YAA3B,WAAW,QAAA;;;;;;wBACtD,UAAU,GAAK,OAAO,CAAC,IAAI,WAAjB,CAAiB;wBACnC,OAAO;wBACP,IAAI,CAAC,UAAU,EAAE;4BACf,sBAAO,kBAAY,CAAC,KAAK,CAAC,sBAAU,CAAC,YAAY,EAAE,wBAAc,CAAC,EAAA;yBACnE;wBAEoB,qBAAM,WAAW,CAAC,WAAW,CAAC,UAAU,CAAC,EAAA;;wBAAxD,YAAY,GAAG,SAAyC;wBAC9D,sBAAO,kBAAY,CAAC,OAAO,CAAC,YAAY,CAAC,EAAA;;;;KAC1C;IAED;;OAEG;IAGG,6CAAoB,GAA1B,UAA2B,OAAgB,EAAE,EAA6B,EAAE,EAA4B;YAAzD,OAAO,aAAA;YAAuB,WAAW,QAAA;;;;;;wBAC9E,OAAO,GAAK,OAAO,CAAC,IAAI,QAAjB,CAAiB;wBAEnB,qBAAM,WAAW,CAAC,gBAAgB,CAAC,OAAO,EAAE,OAAO,CAAC,EAAA;;wBAA3D,IAAI,GAAG,SAAoD;wBACjE,cAAM,CAAC,IAAI,CAAC,CAAA;wBAEZ,sBAAO,kBAAY,CAAC,OAAO,CAAC,IAAI,CAAC,EAAA;;;;KAClC;IAvBD;QAFC,uBAAW,CAAC,CAAC,YAAY,CAAC,CAAC;QAC3B,oBAAQ,CAAC,CAAC,qBAAW,CAAC,CAAC;;;;iEAUvB;IAOD;QAFC,uBAAW,CAAC,CAAC,SAAS,CAAC,CAAC;QACxB,oBAAQ,CAAC,CAAC,qBAAW,CAAC,CAAC;;;;8DAQvB;IACH,qBAAC;CAAA,AA9BD,IA8BC;kBA9BoB,cAAc"}
\ No newline at end of file
/** @format */
import { TaskService } from '../service';
import { TaskService, BaseService } from '../service';
export default class Task {
/**
* 任务列表
......@@ -18,7 +18,7 @@ export default class Task {
*/
doBrowseGoodsTask(context: Context, { userInfo, activityInfo }: IControllerInfos, [taskService]: [TaskService]): Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result>;
/**
* 浏览商品
* 收藏商品
*/
doCollectGoodsTask(context: Context, { userInfo, activityInfo }: IControllerInfos, [taskService]: [TaskService]): Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result>;
/**
......@@ -29,4 +29,8 @@ export default class Task {
* 领取任务奖励
*/
receiveTaskRewards(context: Context, { userInfo }: IControllerInfos, [taskService]: [TaskService]): Promise<IResult>;
/**
* 方法注释
*/
getCollectGoodsList(context: Context, { session, userInfo }: IControllerInfos, [baseService, taskService]: [BaseService, TaskService]): Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result>;
}
"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);
......@@ -224,7 +235,7 @@ var Task = /** @class */ (function () {
});
};
/**
* 浏览商品
* 收藏商品
*/
Task.prototype.doCollectGoodsTask = function (context, _a, _b) {
var userInfo = _a.userInfo, activityInfo = _a.activityInfo;
......@@ -331,6 +342,32 @@ var Task = /** @class */ (function () {
});
});
};
/**
* 方法注释
*/
Task.prototype.getCollectGoodsList = function (context, _a, _b) {
var session = _a.session, userInfo = _a.userInfo;
var baseService = _b[0], taskService = _b[1];
return __awaiter(this, void 0, void 0, function () {
var itemIds, list, completeList, listWithCollectStatus;
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
itemIds = context.data.itemIds;
return [4 /*yield*/, baseService.getItemListByIds(itemIds, session)];
case 1:
list = _c.sent();
completeList = taskService.getCompleteTaskByUserTaskInfo('collectGoods', userInfo);
listWithCollectStatus = list.map(function (v) {
return __assign(__assign({}, v), {
// 完成列表是否含有itemId
collected: completeList.some(function (completeItem) { return completeItem.itemId === v.itemId; }) });
});
return [2 /*return*/, sdk_1.resultsModel.success(listWithCollectStatus)];
}
});
});
};
__decorate([
decorator_1.paramsCheck(['activityId']),
decorator_1.userCheck({ intercept: true }),
......@@ -393,6 +430,13 @@ var Task = /** @class */ (function () {
__metadata("design:paramtypes", [Object, Object, Array]),
__metadata("design:returntype", Promise)
], Task.prototype, "receiveTaskRewards", null);
__decorate([
decorator_1.paramsCheck(['activityId', 'itemIds']),
decorator_1.services([service_1.BaseService, service_1.TaskService]),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, Object, Array]),
__metadata("design:returntype", Promise)
], Task.prototype, "getCollectGoodsList", null);
return Task;
}());
exports.default = Task;
......
This diff is collapsed.
......@@ -53,6 +53,7 @@ var sdk_1 = require("../sdk");
var constants_1 = require("../constants");
var service_1 = require("../service");
var utils_1 = require("../utils");
// 检验参数是否存在
exports.paramsCheck = function (params) {
return function (target, name, descriptor) {
var method = descriptor.value;
......@@ -72,6 +73,7 @@ exports.paramsCheck = function (params) {
};
};
};
// 检验用户是否存在
exports.userCheck = function (_a) {
var _b = _a.intercept, intercept = _b === void 0 ? true : _b;
return function (target, name, descriptor) {
......@@ -100,6 +102,7 @@ exports.userCheck = function (_a) {
};
};
};
// 是否是会员
exports.vipCheck = function (_a) {
var _b = _a.intercept, intercept = _b === void 0 ? true : _b, _c = _a.callbackUrl, callbackUrl = _c === void 0 ? '' : _c;
return function (target, name, descriptor) {
......@@ -131,6 +134,7 @@ exports.vipCheck = function (_a) {
};
};
};
// 活动时间校验
exports.activityTimeCheck = function (target, name, descriptor) {
var method = descriptor.value;
descriptor.value = function () {
......
{"version":3,"file":"check.js","sourceRoot":"","sources":["../../src/decorator/check.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,cAAc;AACd,8BAAqC;AACrC,0CAAyC;AACzC,sCAAqD;AACrD,kCAA2C;AAE9B,QAAA,WAAW,GAAG,UAAC,MAAgB;IAC1C,OAAO,UAAU,MAAc,EAAE,IAAY,EAAE,UAA8B;QAC3E,IAAM,MAAM,GAAG,UAAU,CAAC,KAAK,CAAA;QAE/B,UAAU,CAAC,KAAK,GAAG;YAAU,cAAc;iBAAd,UAAc,EAAd,qBAAc,EAAd,IAAc;gBAAd,yBAAc;;YAClC,IAAA,OAAO,GAAoB,IAAI,GAAxB,EAAE,KAAkB,IAAI,GAAR,EAAd,SAAS,mBAAG,EAAE,KAAA,CAAQ;YACtC,IAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;YAC1C,KAAK,IAAI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AK,CAAC,sBAAU,CAAC,sBAAsB,EAAE,gCAAO,CAAC,EAAA;yBACtE;wBACD,IAAI,WAAW,GAAG,OAAO,EAAE;4BACzB,sBAAO,kBAAY,CAAC,KAAK,CAAC,sBAAU,CAAC,mBAAmB,EAAE,gCAAO,CAAC,EAAA;yBACnE;wBACD,sBAAO,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,OAAO,wBAAO,SAAS,KAAE,YAAY,cAAA,IAAG,CAAC,EAAA;;;;KACvE,CAAA;AACH,CAAC,CAAA"}
\ No newline at end of file
......@@ -75,6 +75,7 @@ function initBaseInfo(context, baseInfos) {
});
});
}
// 注入服务
exports.services = function (services) {
return function (target, name, descriptor) {
var method = descriptor.value;
......
{"version":3,"file":"services.js","sourceRoot":"","sources":["../../src/decorator/services.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,cAAc;AACd,sCAAwC;AACxC,kCAAkE;AAClE,8BAAqC;AACrC,0CAAyC;AACzC,SAAe,YAAY,CAAC,OAAgB,EAAE,SAA2B;;;;;;oBACjE,WAAW,GAAG,IAAI,qBAAW,CAAC,OAAO,CAAC,CAAA;yBAExC,CAAC,SAAS,CAAC,QAAQ,EAAnB,wBAAmB;oBACJ,qBAAM,WAAW,CAAC,WAAW,EAAE,EAAA;;oBAA1C,QAAQ,GAAG,SAA+B;oBAChD,SAAS,CAAC,QAAQ,GAAG,QAAQ,CAAA;;;yBAG3B,CAAC,SAAS,CAAC,OAAO,EAAlB,wBAAkB;oBACU,qBAAM,wBAAgB,CAAC,OAAO,CAAC,EAAA;;oBAAvD,KAAwB,SAA+B,EAArD,OAAO,aAAA,EAAE,QAAQ,cAAA;oBACzB,SAAS,CAAC,OAAO,GAAG,OAAO,CAAA;oBAC3B,SAAS,CAAC,gBAAgB,GAAG,QAAQ,CAAA;;;yBAGnC,CAAC,SAAS,CAAC,OAAO,EAAlB,wBAAkB;oBACJ,qBAAM,WAAW,CAA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AA;IACH,CAAC,CAAA;AACH,CAAC,CAAA"}
\ No newline at end of file
......@@ -13,4 +13,14 @@ export default class BaseService {
* @returns 返回活动详情,若不存在活动,返回为null
*/
getBaseInfo(activityId: string): Promise<any>;
/**
*
* 根据itemIds获取商品列表
*
* @param {string} itemIds
* @param {string} session
* @return {Array}
* @memberof BaseService
*/
getItemListByIds(itemIds: string, session: string): Promise<Array<ITaoBaoItems>>;
}
......@@ -65,6 +65,42 @@ var BaseService = /** @class */ (function () {
});
});
};
/**
*
* 根据itemIds获取商品列表
*
* @param {string} itemIds
* @param {string} session
* @return {Array}
* @memberof BaseService
*/
BaseService.prototype.getItemListByIds = function (itemIds, session) {
var _a;
return __awaiter(this, void 0, void 0, function () {
var GOODSINFO, result, items, list;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
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';
return [4 /*yield*/, sdk_1.TBAPIS.getItemListByItemIds(this.context, session, itemIds, { fields: GOODSINFO })];
case 1:
result = _b.sent();
items = ((_a = result === null || result === void 0 ? void 0 : result.items) === null || _a === void 0 ? void 0 : _a.item) || [];
list = items.map(function (v) {
return {
itemId: v.num_iid,
name: v.title,
price: v.price,
url: v.detail_url,
image: v.pic_url,
desc: v.desc
};
});
return [2 /*return*/, list];
}
});
});
};
return BaseService;
}());
exports.default = BaseService;
......
{"version":3,"file":"base.service.js","sourceRoot":"","sources":["../../src/service/base.service.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,8BAAgC;AAChC,4BAA+C;AAG/C;IAGE,qBAAY,OAAgB;QAC1B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,WAAW,GAAG,IAAI,aAAO,CAAC,OAAO,EAAE,4BAAuB,CAAC,CAAA;IAClE,CAAC;IACD;;;;OAIG;IACG,iCAAW,GAAjB,UAAkB,UAAkB;;;;;wBAClC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,iBAAiB,CAAC,CAAA;wBACxC,qBAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,UAAU,EAAE,YAAY,gBAAwB,EAAE,CAAC,EAAA;4BAAhG,sBAAO,SAAyF,EAAA;;;;KACjG;IACH,kBAAC;AAAD,CAAC,AAhBD,IAgBC"}
\ No newline at end of file
{"version":3,"file":"base.service.js","sourceRoot":"","sources":["../../src/service/base.service.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,8BAAwC;AACxC,4BAA+C;AAG/C;IAGE,qBAAY,OAAgB;QAC1B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,WAAW,GAAG,IAAI,aAAO,CAAC,OAAO,EAAE,4BAAuB,CAAC,CAAA;IAClE,CAAC;IACD;;;;OAIG;IACG,iCAAW,GAAjB,UAAkB,UAAkB;;;;;wBAClC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,iBAAiB,CAAC,CAAA;wBACxC,qBAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,UAAU,EAAE,YAAY,gBAAwB,EAAE,CAAC,EAAA;4BAAhG,sBAAO,SAAyF,EAAA;;;;KACjG;IAED;;;;;;;;OAQG;IACG,sCAAgB,GAAtB,UAAuB,OAAe,EAAE,OAAe;;;;;;;wBAC/C,SAAS,GACb,+NAA+N,CAAA;wBAClN,qBAAM,YAAM,CAAC,oBAAoB,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,EAAA;;wBAAjG,MAAM,GAAG,SAAwF;wBACjG,KAAK,GAAG,OAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,KAAK,0CAAE,IAAI,KAAI,EAAE,CAAA;wBACjC,IAAI,GAAG,KAAK,CAAC,GAAG,CACpB,UAAC,CAAuG;4BACtG,OAAO;gCACL,MAAM,EAAE,CAAC,CAAC,OAAO;gCACjB,IAAI,EAAE,CAAC,CAAC,KAAK;gCACb,KAAK,EAAE,CAAC,CAAC,KAAK;gCACd,GAAG,EAAE,CAAC,CAAC,UAAU;gCACjB,KAAK,EAAE,CAAC,CAAC,OAAO;gCAChB,IAAI,EAAE,CAAC,CAAC,IAAI;6BACb,CAAA;wBACH,CAAC,CACF,CAAA;wBACD,sBAAO,IAAI,EAAA;;;;KACZ;IACH,kBAAC;AAAD,CAAC,AA7CD,IA6CC"}
\ No newline at end of file
......@@ -422,20 +422,19 @@ var TaskService = /** @class */ (function (_super) {
*/
TaskService.prototype.updateUserTaskRecord = function (taskType, rewards, userInfo, customRecord) {
return __awaiter(this, void 0, void 0, function () {
var _id, openId, today, result;
var _id, today, result;
var _a, _b;
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
_id = userInfo._id;
openId = this.context.openId;
today = utils_1.getToday();
return [4 /*yield*/, this.updateUser(_id, {
$inc: (_a = {},
_a["remainTimes." + taskType] = rewards,
_a),
$push: (_b = {},
_b["taskInfo." + today + "." + taskType] = __assign({ openId: openId, createTime: Date.now() }, customRecord),
_b["taskInfo." + today + "." + taskType] = __assign({ createTime: Date.now() }, customRecord),
_b)
})];
case 1:
......
This diff is collapsed.
......@@ -13,7 +13,8 @@ const configs = {
mock: test
}
// 根据服务环境获取配置
export const getConfig = (context: Context): Iconfig => {
const env = context.env
return configs[env] || configs.test
return configs[env] || configs.online
}
......@@ -4,6 +4,7 @@ import { CODE_TYPES } from './../constants'
import { services, paramsCheck } from '../decorator'
import { resultsModel } from '../sdk'
import { logger } from '../utils'
import { BaseService } from '../service'
export default class BaseController {
/**
......@@ -21,4 +22,18 @@ export default class BaseController {
const activityInfo = await baseService.getBaseInfo(activityId)
return resultsModel.success(activityInfo)
}
/**
* 获取商品列表
*/
@paramsCheck(['itemIds'])
@services([BaseService])
async getItemListByItemIds(context: Context, { session }: IControllerInfos, [baseService]: [BaseService]) {
const { itemIds } = context.data
const list = await baseService.getItemListByIds(itemIds, session)
logger(list)
return resultsModel.success(list)
}
}
......@@ -4,7 +4,7 @@ import { CODE_TYPES, TASK_RATE_TYPE } from './../constants'
import { paramsCheck, userCheck, activityTimeCheck, noCatch, services } from '../decorator'
import { resultsModel, TBAPIS } from '../sdk'
import { TaskService } from '../service'
import { TaskService, BaseService } from '../service'
import { logger } from '../utils'
import { time } from 'console'
......@@ -189,7 +189,7 @@ export default class Task {
}
/**
* 浏览商品
* 收藏商品
*/
@paramsCheck(['activityId', 'itemId'])
@userCheck({ intercept: true })
......@@ -306,4 +306,30 @@ export default class Task {
return resultsModel.success(true)
}
/**
* 方法注释
*/
@paramsCheck(['activityId', 'itemIds'])
@services([BaseService, TaskService])
async getCollectGoodsList(
context: Context,
{ session, userInfo }: IControllerInfos,
[baseService, taskService]: [BaseService, TaskService]
) {
const { itemIds } = context.data
const list = await baseService.getItemListByIds(itemIds, session)
const completeList = taskService.getCompleteTaskByUserTaskInfo('collectGoods', userInfo)
const listWithCollectStatus = list.map(v => {
return {
...v,
// 完成列表是否含有itemId
collected: completeList.some(completeItem => completeItem.itemId === v.itemId)
}
})
return resultsModel.success(listWithCollectStatus)
}
}
......@@ -4,6 +4,7 @@ import { CODE_TYPES } from '../constants'
import { UserService, BaseService } from '../service'
import { getSellerSession } from '../utils'
// 检验参数是否存在
export const paramsCheck = (params: string[]) => {
return function (target: Object, name: string, descriptor: PropertyDescriptor) {
const method = descriptor.value
......@@ -20,6 +21,7 @@ export const paramsCheck = (params: string[]) => {
}
}
// 检验用户是否存在
export const userCheck = ({ intercept = true }) => {
return function (target: any, name: string, descriptor: PropertyDescriptor) {
const method = descriptor.value
......@@ -37,6 +39,7 @@ export const userCheck = ({ intercept = true }) => {
}
}
// 是否是会员
export const vipCheck = ({ intercept = true, callbackUrl = '' }) => {
return function (target: any, name: string, descriptor: PropertyDescriptor) {
const method = descriptor.value
......@@ -53,6 +56,7 @@ export const vipCheck = ({ intercept = true, callbackUrl = '' }) => {
}
}
// 活动时间校验
export const activityTimeCheck = (target: any, name: string, descriptor: PropertyDescriptor) => {
const method = descriptor.value
descriptor.value = async function (...args: any[]) {
......
......@@ -24,6 +24,7 @@ async function initBaseInfo(context: Context, baseInfos: IControllerInfos) {
return baseInfos
}
// 注入服务
export const services = (services: any[]) => {
return (target: Object, name: string, descriptor: PropertyDescriptor) => {
const method = descriptor.value
......
......@@ -4,7 +4,7 @@
* @format
*/
import { BaseDao } from '../sdk'
import { BaseDao, TBAPIS } from '../sdk'
import { ACTIVITY_CONFIG_DB_NAME } from '../db'
import { ACTIVITY_STATUS } from '../constants'
......@@ -24,4 +24,33 @@ export default class BaseService {
console.log(process.argv[2], 'process.argv[2]')
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
}
}
......@@ -434,14 +434,13 @@ export default class TaskService extends UserService {
customRecord?: object
): Promise<boolean> {
const { _id } = userInfo
const { openId } = this.context
const today = getToday()
const result = await this.updateUser(_id, {
$inc: {
[`remainTimes.${taskType}`]: rewards
},
$push: {
[`taskInfo.${today}.${taskType}`]: { openId, createTime: Date.now(), ...customRecord }
[`taskInfo.${today}.${taskType}`]: { createTime: Date.now(), ...customRecord }
}
})
return result === 1
......
......@@ -27,6 +27,16 @@ interface ITasks {
inviteFriends?: ITaskConfig
}
interface ITaskConfig {
title?: string // 任务标题
value: number // 任奖奖励
times?: number // 任务为每日限次次数值
taskRateType?: number // 任务频率类型
link?: string // 任务链接
itemIds?: string // 任务商品
checked?: boolean // 是否选中(B端需勾选时)
}
interface IActivityPrize {
_id?: string
activityId?: string
......@@ -50,13 +60,3 @@ interface IActivityPrize {
createTime: number
updateTime: number
}
interface ITaskConfig {
title?: string // 任务标题
value: number // 任奖奖励
times?: number // 任务为每日限次次数值
taskRateType?: number // 任务频率类型
link?: string // 任务链接
itemIds?: string // 任务商品
checked?: boolean // 是否选中(B端需勾选时)
}
/** @format */
interface ITaoBaoItems {
itemId: string
name: string
price: string
url: string
image: string
desc: string
}
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