Commit ee157e51 authored by qinhaitao's avatar qinhaitao

feat: 🎸 概率抽奖 接口

parent 4c01f617
# 通用模板 # 数据模拟
```bash
yarn
```
```bash
cd mockServer
```
```bash
cnpm install
```
编译ts代码
```bash
➜ npm start
```
启动mockServr
```bash
➜ npm run mock
```
## 库表规范 ## 库表规范
http://cf.dui88.com/pages/viewpage.action?pageId=63937755 http://cf.dui88.com/pages/viewpage.action?pageId=63937755
## sdk 接口文档说明 ## sdk 接口文档说明
http://cf.dui88.com/pages/viewpage.action?pageId=66194323 http://cf.dui88.com/pages/viewpage.action?pageId=66194323
## 模板说明
...@@ -176,42 +176,32 @@ export declare const DRAW_STATUS: { ...@@ -176,42 +176,32 @@ export declare const DRAW_STATUS: {
EXPIRED: number; EXPIRED: number;
RETRY: number; RETRY: number;
}; };
export declare const PRIZE_TYPE: {
ENAME: number;
CREDITS: number;
OBJECT: number;
THANKS: number;
};
export declare const C_APP_NAME: string; export declare const C_APP_NAME: string;
export declare const TAOBAO_SUCCESS_ORDER_STATUS: string[]; export declare const TAOBAO_SUCCESS_ORDER_STATUS: string[];
export declare const enum ACTIVITY_STATUS { export declare const enum ACTIVITY_STATUS {
NORMAL = 1, NORMAL = 1,
DELETE = 2 DELETE = 2
} }
export declare const enum DELETE_STATUS {
NORMAL = 1,
DELETE = 2
}
export declare const TASK_RATE_TYPE: { export declare const TASK_RATE_TYPE: {
FOREVER: number; FOREVER: number;
EVERYDAY: number; EVERYDAY: number;
NOLIMIT: number; NOLIMIT: number;
}; };
export declare const PRIZE_TYPE: {
ENAME: number;
CREDITS: number;
OBJECT: number;
THANKS: number;
};
export declare const PRIZE_DATA_TYPE: {
RANKING: number;
PROBABILITY: number;
};
export declare enum SWICH_TOCK { export declare enum SWICH_TOCK {
LIMIT = 1, LIMIT = 1,
NO_LIMIT = 2 NO_LIMIT = 2
} }
export declare const RECORD_TYPE: {
FOLLOW_TASK: {
type: number;
name: string;
};
SIGN_TASK: {
type: number;
name: string;
};
RECEIVE_INVITE: {
type: number;
name: string;
};
INVITE_SUCCESS: {
type: number;
name: string;
};
};
"use strict"; "use strict";
/** @format */ /** @format */
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.RECORD_TYPE = exports.SWICH_TOCK = exports.TASK_RATE_TYPE = exports.TAOBAO_SUCCESS_ORDER_STATUS = exports.C_APP_NAME = exports.PRIZE_TYPE = exports.DRAW_STATUS = exports.TBERROR = exports.CODE_TYPES = exports.BusinessError = void 0; exports.SWICH_TOCK = exports.PRIZE_DATA_TYPE = exports.PRIZE_TYPE = exports.TASK_RATE_TYPE = exports.TAOBAO_SUCCESS_ORDER_STATUS = exports.C_APP_NAME = exports.DRAW_STATUS = exports.TBERROR = exports.CODE_TYPES = exports.BusinessError = void 0;
var sdk_1 = require("./sdk"); var sdk_1 = require("./sdk");
exports.BusinessError = { exports.BusinessError = {
// 更新重试失败(用于并发更新) // 更新重试失败(用于并发更新)
...@@ -116,13 +116,6 @@ exports.DRAW_STATUS = { ...@@ -116,13 +116,6 @@ exports.DRAW_STATUS = {
// 重新领取 // 重新领取
RETRY: 6 RETRY: 6
}; };
// 奖品类型
exports.PRIZE_TYPE = {
ENAME: 1,
CREDITS: 2,
OBJECT: 3,
THANKS: 5
};
// C端的APP NAME // C端的APP NAME
exports.C_APP_NAME = 'promotioncenter-${需要补充}'; exports.C_APP_NAME = 'promotioncenter-${需要补充}';
// 订单状态 // 订单状态
...@@ -140,16 +133,22 @@ exports.TASK_RATE_TYPE = { ...@@ -140,16 +133,22 @@ exports.TASK_RATE_TYPE = {
EVERYDAY: 2, EVERYDAY: 2,
NOLIMIT: 3 NOLIMIT: 3
}; };
// 奖品类型
exports.PRIZE_TYPE = {
ENAME: 1,
CREDITS: 2,
OBJECT: 3,
THANKS: 5
};
// 奖品分类
exports.PRIZE_DATA_TYPE = {
RANKING: 1,
PROBABILITY: 2 // 概率
};
// 奖品是否限制库存 // 奖品是否限制库存
var SWICH_TOCK; var SWICH_TOCK;
(function (SWICH_TOCK) { (function (SWICH_TOCK) {
SWICH_TOCK[SWICH_TOCK["LIMIT"] = 1] = "LIMIT"; SWICH_TOCK[SWICH_TOCK["LIMIT"] = 1] = "LIMIT";
SWICH_TOCK[SWICH_TOCK["NO_LIMIT"] = 2] = "NO_LIMIT"; SWICH_TOCK[SWICH_TOCK["NO_LIMIT"] = 2] = "NO_LIMIT";
})(SWICH_TOCK = exports.SWICH_TOCK || (exports.SWICH_TOCK = {})); })(SWICH_TOCK = exports.SWICH_TOCK || (exports.SWICH_TOCK = {}));
exports.RECORD_TYPE = {
FOLLOW_TASK: { type: 1, name: '关注店铺任务' },
SIGN_TASK: { type: 2, name: '签到任务' },
RECEIVE_INVITE: { type: 3, name: '接受邀请' },
INVITE_SUCCESS: { type: 4, name: '邀请成功' }
};
//# sourceMappingURL=constants.js.map //# sourceMappingURL=constants.js.map
\ No newline at end of file
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";AAAA,cAAc;;;AAEd,6BAA0C;AAE7B,QAAA,aAAa,GAAG;IAC3B,iBAAiB;IACjB,kBAAkB,EAAE;QAClB,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE,0BAAM;KACnB;IACD,QAAQ;IACR,iBAAiB,EAAE;QACjB,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE,gCAAO;KACpB;IACD,QAAQ;IACR,sBAAsB,EAAE;QACtB,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE,gCAAO;KACpB;IACD,QAAQ;IACR,mBAAmB,EAAE;QACnB,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE,gCAAO;KACpB;IACD,QAAQ;IACR,aAAa,EAAE;QACb,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE,gCAAO;KACpB;IACD,QAAQ;IACR,YAAY,EAAE;QACZ,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE,OAAO;KACpB;IACD,UAAU;IACV,oBAAoB,EAAE;QACpB,IAAI,E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AC;IACV,QAAQ,EAAE,CAAC;IACX,OAAO,EAAE,CAAC;CACX,CAAA;AAED,OAAO;AACM,QAAA,UAAU,GAAG;IACxB,KAAK,EAAE,CAAC;IACR,OAAO,EAAE,CAAC;IACV,MAAM,EAAE,CAAC;IACT,MAAM,EAAE,CAAC;CACV,CAAA;AAED,OAAO;AACM,QAAA,eAAe,GAAG;IAC7B,OAAO,EAAE,CAAC;IACV,WAAW,EAAE,CAAC,CAAC,KAAK;CACrB,CAAA;AAED,WAAW;AACX,IAAY,UAGX;AAHD,WAAY,UAAU;IACpB,6CAAS,CAAA;IACT,mDAAY,CAAA;AACd,CAAC,EAHW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAGrB"}
\ No newline at end of file \ No newline at end of file
...@@ -13,4 +13,8 @@ export default class AwardsController { ...@@ -13,4 +13,8 @@ export default class AwardsController {
* 权益重新领取 * 权益重新领取
*/ */
receiveEnamePrize(context: Context, {}: {}, [awardSer]: [AwardsService]): Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result>; receiveEnamePrize(context: Context, {}: {}, [awardSer]: [AwardsService]): Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result>;
/**
* 概率抽奖
*/
drawLotteryPrize(context: Context, { userInfo }: IControllerInfos, [awardSer]: [AwardsService]): Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result>;
} }
...@@ -49,6 +49,8 @@ Object.defineProperty(exports, "__esModule", { value: true }); ...@@ -49,6 +49,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
var decorator_1 = require("../decorator"); var decorator_1 = require("../decorator");
var sdk_1 = require("../sdk"); var sdk_1 = require("../sdk");
var service_1 = require("../service"); var service_1 = require("../service");
var constants_1 = require("../constants");
var utils_1 = require("../utils");
var AwardsController = /** @class */ (function () { var AwardsController = /** @class */ (function () {
function AwardsController() { function AwardsController() {
} }
...@@ -136,6 +138,81 @@ var AwardsController = /** @class */ (function () { ...@@ -136,6 +138,81 @@ var AwardsController = /** @class */ (function () {
}); });
}); });
}; };
/**
* 概率抽奖
*/
AwardsController.prototype.drawLotteryPrize = function (context, _a, _b) {
var userInfo = _a.userInfo;
var awardSer = _b[0];
return __awaiter(this, void 0, void 0, function () {
var openId, activityId, prizesPool, prize, reduceResult, type, _id, ename, image, userNick, record, result;
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
openId = context.openId;
activityId = context.data.activityId;
return [4 /*yield*/, awardSer.getPrizeConfig({
activityId: activityId
// 根据需求配置筛选条件
// prizeDataType: PRIZE_DATA_TYPE.PROBABILITY
})
// 根据概率获取
];
case 1:
prizesPool = _c.sent();
return [4 /*yield*/, awardSer.getPrizeByProbability(prizesPool)
// 未找到奖品,降级到谢谢参与
];
case 2:
prize = _c.sent();
// 未找到奖品,降级到谢谢参与
if (prize) {
return [2 /*return*/, sdk_1.resultsModel.success({
data: {
type: constants_1.PRIZE_TYPE.THANKS,
name: '谢谢参与'
}
})];
}
reduceResult = 1;
if (!(prize.type !== constants_1.PRIZE_TYPE.CREDITS)) return [3 /*break*/, 4];
return [4 /*yield*/, awardSer.reduceStock(prize._id)];
case 3:
reduceResult = _c.sent();
_c.label = 4;
case 4:
// 扣库存失败
if (reduceResult.code)
return [2 /*return*/, sdk_1.resultsModel.error(reduceResult)];
type = prize.type, _id = prize._id, ename = prize.ename, image = prize.image;
userNick = userInfo.userNick;
record = {
openId: openId,
prizeId: _id,
activityId: activityId,
drawStatus: constants_1.DRAW_STATUS.WAITAWARD,
// prizeDataType,
remark: '',
type: type,
ename: ename,
name: name,
image: image,
userNick: userNick,
createDay: utils_1.getToday()
};
return [4 /*yield*/, awardSer.addAward(record)];
case 5:
result = _c.sent();
return [2 /*return*/, sdk_1.resultsModel.success({
id: result,
type: type,
name: name,
image: image
})];
}
});
});
};
__decorate([ __decorate([
decorator_1.paramsCheck(['activityId']), decorator_1.paramsCheck(['activityId']),
decorator_1.userCheck({ intercept: true }), decorator_1.userCheck({ intercept: true }),
...@@ -160,6 +237,14 @@ var AwardsController = /** @class */ (function () { ...@@ -160,6 +237,14 @@ var AwardsController = /** @class */ (function () {
__metadata("design:paramtypes", [Object, Object, Array]), __metadata("design:paramtypes", [Object, Object, Array]),
__metadata("design:returntype", Promise) __metadata("design:returntype", Promise)
], AwardsController.prototype, "receiveEnamePrize", null); ], AwardsController.prototype, "receiveEnamePrize", null);
__decorate([
decorator_1.paramsCheck(['activityId']),
decorator_1.activityTimeCheck,
decorator_1.services([service_1.AwardsService]),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, Object, Array]),
__metadata("design:returntype", Promise)
], AwardsController.prototype, "drawLotteryPrize", null);
return AwardsController; return AwardsController;
}()); }());
exports.default = AwardsController; exports.default = AwardsController;
......
{"version":3,"file":"awards.controller.js","sourceRoot":"","sources":["../../src/controller/awards.controller.ts"],"names":[],"mappings":";AAAA,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEd,0CAA+D;AAC/D,8BAAqC;AACrC,sCAA0C;AAE1C;IAAA;IAgEA,CAAC;IA/DC;;OAEG;IAIG,yCAAc,GAApB,UAAqB,OAAgB,EAAE,EAAE,EAAE,EAA2B;YAA1B,QAAQ,QAAA;;;;;;wBAEhD,MAAM,GAEJ,OAAO,OAFH,EACE,UAAU,GAChB,OAAO,gBADS,CACT;wBACE,qBAAM,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,QAAA,EAAE,UAAU,YAAA,EAAE,CAAC,EAAA;;wBAA9D,MAAM,GAAG,SAAqD;wBAClE,sBAAO,kBAAY,CAAC,OAAO,CAAC,MAAM,CAAC,EAAA;;;;KACpC;IAED;;OAEG;IAIG,6CAAkB,GAAxB,UAAyB,OAAgB,EAAE,EAAE,EAAE,EAA2B;YAA1B,QAAQ,QAAA;;;;;;wBAClD,KAAwE,OAAO,CAAC,IAAI,EAAlF,QAAQ,cAAA,EAAE,IAAI,UAAA,EAAE,IAAI,UAAA,EAAE,aAAa,mBAAA,EAAE,GAAG,SAAA,EAAE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AAC;CAAA,AArID,IAqIC;kBArIoB,gBAAgB"}
\ No newline at end of file \ No newline at end of file
...@@ -50,24 +50,22 @@ var StatController = /** @class */ (function () { ...@@ -50,24 +50,22 @@ var StatController = /** @class */ (function () {
*/ */
StatController.prototype.getStats = function (context) { StatController.prototype.getStats = function (context) {
return __awaiter(this, void 0, void 0, function () { return __awaiter(this, void 0, void 0, function () {
var _a, activityId, startDay, endDay, userDao, accessDao, recordDao, awardsDao, oneDay, xlsxData, day, PV, UV, newUV, vipPV, noVipPV, vipUV, noVipUV, newVipUV, followPV, followUV, inviteSuccessUV, receiveShareUV, receiveShareVipUV, receiveShareNoVipUV, keyValueMapper, tommorrow, buffer, result, e_1; var _a, activityId, startDay, endDay, userDao, accessDao, oneDay, xlsxData, day, PV, UV, newUV, vipPV, noVipPV, vipUV, noVipUV, newVipUV, newFollowUV, keyValueMapper, tommorrow, buffer, result, e_1;
return __generator(this, function (_b) { return __generator(this, function (_b) {
switch (_b.label) { switch (_b.label) {
case 0: case 0:
_a = context.data, activityId = _a.activityId, startDay = _a.startDay, endDay = _a.endDay; _a = context.data, activityId = _a.activityId, startDay = _a.startDay, endDay = _a.endDay;
userDao = new sdk_1.BaseDao(context, db_1.USER_DB_NAME); userDao = new sdk_1.BaseDao(context, db_1.USER_DB_NAME);
accessDao = new sdk_1.BaseDao(context, db_1.ACCESS_DB_NAME); accessDao = new sdk_1.BaseDao(context, db_1.ACCESS_DB_NAME);
recordDao = new sdk_1.BaseDao(context, db_1.RECORD_DB_NAME);
awardsDao = new sdk_1.BaseDao(context, db_1.AWARDS_DB_NAME);
oneDay = 24 * 3600 * 1000; oneDay = 24 * 3600 * 1000;
xlsxData = []; xlsxData = [];
_b.label = 1; _b.label = 1;
case 1: case 1:
_b.trys.push([1, 19, , 20]); _b.trys.push([1, 14, , 15]);
day = startDay; day = startDay;
_b.label = 2; _b.label = 2;
case 2: case 2:
if (!(new Date(day).getTime() <= new Date(endDay).getTime())) return [3 /*break*/, 17]; if (!(new Date(day).getTime() <= new Date(endDay).getTime())) return [3 /*break*/, 12];
return [4 /*yield*/, accessDao.count({ activityId: activityId, createDay: day }) return [4 /*yield*/, accessDao.count({ activityId: activityId, createDay: day })
// 访问UV // 访问UV
]; ];
...@@ -116,43 +114,13 @@ var StatController = /** @class */ (function () { ...@@ -116,43 +114,13 @@ var StatController = /** @class */ (function () {
})]; })];
case 10: case 10:
newVipUV = _b.sent(); newVipUV = _b.sent();
return [4 /*yield*/, recordDao.count({ return [4 /*yield*/, userDao.count({
activityId: activityId, activityId: activityId,
createDay: day, 'member.follow': true,
recordType: constants_1.RECORD_TYPE.FOLLOW_TASK.type 'member.followDay': day
})]; })];
case 11: case 11:
followPV = _b.sent(); newFollowUV = _b.sent();
return [4 /*yield*/, recordDao.aggregate([
{ $match: { activityId: activityId, createDay: day, recordType: constants_1.RECORD_TYPE.FOLLOW_TASK.type } },
{ $group: { _id: '$openId', count: { $sum: 1 } } }
])];
case 12:
followUV = (_b.sent()).length;
return [4 /*yield*/, recordDao.aggregate([
{ $match: { activityId: activityId, createDay: day, recordType: constants_1.RECORD_TYPE.INVITE_SUCCESS.type } },
{ $group: { _id: '$inviteId', count: { $sum: 1 } } }
])];
case 13:
inviteSuccessUV = (_b.sent()).length;
return [4 /*yield*/, recordDao.aggregate([
{ $match: { activityId: activityId, createDay: day, recordType: constants_1.RECORD_TYPE.RECEIVE_INVITE.type } },
{ $group: { _id: '$openId', count: { $sum: 1 } } }
])];
case 14:
receiveShareUV = (_b.sent()).length;
return [4 /*yield*/, accessDao.aggregate([
{ $match: { activityId: activityId, createDay: day, isReceiveShare: true, isVip: true } },
{ $group: { _id: '$openId', count: { $sum: 1 } } }
])];
case 15:
receiveShareVipUV = (_b.sent()).length;
return [4 /*yield*/, accessDao.aggregate([
{ $match: { activityId: activityId, createDay: day, isReceiveShare: true, isVip: false } },
{ $group: { _id: '$openId', count: { $sum: 1 } } }
])];
case 16:
receiveShareNoVipUV = (_b.sent()).length;
keyValueMapper = { keyValueMapper = {
时间: day, 时间: day,
访问PV: PV, 访问PV: PV,
...@@ -163,14 +131,7 @@ var StatController = /** @class */ (function () { ...@@ -163,14 +131,7 @@ var StatController = /** @class */ (function () {
未入会PV: noVipPV, 未入会PV: noVipPV,
未入会UV: noVipUV, 未入会UV: noVipUV,
新入会UV: newVipUV, 新入会UV: newVipUV,
关注店铺完成PV: followPV, 新增关注UV: newFollowUV
关注店铺完成UV: followUV,
// 签到PV: signTaskPV,
// 签到UV: signTaskUV,
邀请好友完成UV: inviteSuccessUV,
带来好友UV: receiveShareUV,
带来好友已入会UV: receiveShareVipUV,
带来好友未入会UV: receiveShareNoVipUV
}; };
if (day === startDay) { if (day === startDay) {
xlsxData.push(Object.keys(keyValueMapper)); xlsxData.push(Object.keys(keyValueMapper));
...@@ -180,7 +141,7 @@ var StatController = /** @class */ (function () { ...@@ -180,7 +141,7 @@ var StatController = /** @class */ (function () {
tommorrow = new Date(day).getTime() + oneDay; tommorrow = new Date(day).getTime() + oneDay;
day = sdk_1.dateFormatter(sdk_1.transformBeijingDate(tommorrow), 'yyyy/MM/dd'); day = sdk_1.dateFormatter(sdk_1.transformBeijingDate(tommorrow), 'yyyy/MM/dd');
return [3 /*break*/, 2]; return [3 /*break*/, 2];
case 17: case 12:
buffer = xlsx.build([ buffer = xlsx.build([
{ {
name: "\u6570\u636E\u7EDF\u8BA1" + startDay.replace(/\//g, '-') + "-" + endDay.replace(/\//g, '-'), name: "\u6570\u636E\u7EDF\u8BA1" + startDay.replace(/\//g, '-') + "-" + endDay.replace(/\//g, '-'),
...@@ -191,19 +152,19 @@ var StatController = /** @class */ (function () { ...@@ -191,19 +152,19 @@ var StatController = /** @class */ (function () {
fileContent: buffer, fileContent: buffer,
fileName: "\u6570\u636E\u7EDF\u8BA1" + startDay.replace(/\//g, '-') + "-" + endDay.replace(/\//g, '-') + ".xlsx" fileName: "\u6570\u636E\u7EDF\u8BA1" + startDay.replace(/\//g, '-') + "-" + endDay.replace(/\//g, '-') + ".xlsx"
})]; })];
case 18: case 13:
result = _b.sent(); result = _b.sent();
console.log(xlsxData, 'xlsxData'); console.log(xlsxData, 'xlsxData');
if (result.url) { if (result.url) {
result.url = result.url.replace('http', 'https').replace('-internal', ''); result.url = result.url.replace('http', 'https').replace('-internal', '');
} }
return [2 /*return*/, sdk_1.resultsModel.success(result.url)]; return [2 /*return*/, sdk_1.resultsModel.success(result.url)];
case 19: case 14:
e_1 = _b.sent(); e_1 = _b.sent();
console.log('上传文件出错', e_1); console.log('上传文件出错', e_1);
// 打印日志 // 打印日志
return [2 /*return*/, sdk_1.resultsModel.error(constants_1.CODE_TYPES.SYSTEM_ERROR, "\u4E0A\u4F20\u6587\u4EF6\u9519\u8BEF")]; return [2 /*return*/, sdk_1.resultsModel.error(constants_1.CODE_TYPES.SYSTEM_ERROR, "\u4E0A\u4F20\u6587\u4EF6\u9519\u8BEF")];
case 20: return [2 /*return*/]; case 15: return [2 /*return*/];
} }
}); });
}); });
......
{"version":3,"file":"stat.controller.js","sourceRoot":"","sources":["../../src/controller/stat.controller.ts"],"names":[],"mappings":";AAAA,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEd,4BAAoF;AACpF,8BAAmF;AACnF,0CAAsD;AACtD,gCAAiC;AAEjC,cAAc;AACd;IAAA;IAyKA,CAAC;IAxKC;;OAEG;IACG,iCAAQ,GAAd,UAAe,OAAgB;;;;;;wBACvB,KAAmC,OAAO,CAAC,IAAI,EAA7C,UAAU,gBAAA,EAAE,QAAQ,cAAA,EAAE,MAAM,YAAA,CAAiB;wBAE/C,OAAO,GAAa,IAAI,aAAO,CAAC,OAAO,EAAE,iBAAY,CAAC,CAAA;wBACtD,SAAS,GAAa,IAAI,aAAO,CAAC,OAAO,EAAE,mBAAc,CAAC,CAAA;wBAC1D,SAAS,GAAa,IAAI,aAAO,CAAC,OAAO,EAAE,mBAAc,CAAC,CAAA;wBAC1D,SAAS,GAAa,IAAI,aAAO,CAAC,OAAO,EA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AAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,EAAA;;;wBAEvC,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAC,CAAC,CAAA;wBACxB,OAAO;wBACP,sBAAO,kBAAY,CAAC,KAAK,CAAC,sBAAU,CAAC,YAAY,EAAE,sCAAQ,CAAC,EAAA;;;;;KAE/D;IACH,qBAAC;AAAD,CAAC,AA/GD,IA+GC"}
\ No newline at end of file \ No newline at end of file
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
export declare const ACCESS_DB_NAME: string; export declare const ACCESS_DB_NAME: string;
export declare const USER_DB_NAME: string; export declare const USER_DB_NAME: string;
export declare const AWARDS_DB_NAME: string; export declare const AWARDS_DB_NAME: string;
export declare const RECORD_DB_NAME: string;
export declare const ERROR_LOG_DB_NAME: string; export declare const ERROR_LOG_DB_NAME: string;
export declare const SELLER_INFO_DB_NAME: string; export declare const SELLER_INFO_DB_NAME: string;
export declare const PRIZE_CONFIG_DB_NAME: string; export declare const PRIZE_CONFIG_DB_NAME: string;
......
"use strict"; "use strict";
/** @format */ /** @format */
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.ACTIVITY_CONFIG_DB_NAME = exports.PRIZE_CONFIG_DB_NAME = exports.SELLER_INFO_DB_NAME = exports.ERROR_LOG_DB_NAME = exports.RECORD_DB_NAME = exports.AWARDS_DB_NAME = exports.USER_DB_NAME = exports.ACCESS_DB_NAME = void 0; exports.ACTIVITY_CONFIG_DB_NAME = exports.PRIZE_CONFIG_DB_NAME = exports.SELLER_INFO_DB_NAME = exports.ERROR_LOG_DB_NAME = exports.AWARDS_DB_NAME = exports.USER_DB_NAME = exports.ACCESS_DB_NAME = void 0;
exports.ACCESS_DB_NAME = 'c_user_access'; exports.ACCESS_DB_NAME = 'c_user_access';
exports.USER_DB_NAME = 'c_user'; exports.USER_DB_NAME = 'c_user';
exports.AWARDS_DB_NAME = 'c_awards_info'; exports.AWARDS_DB_NAME = 'c_awards_info';
exports.RECORD_DB_NAME = "c_user_record";
exports.ERROR_LOG_DB_NAME = 'error_log'; exports.ERROR_LOG_DB_NAME = 'error_log';
exports.SELLER_INFO_DB_NAME = 'a_seller_info'; exports.SELLER_INFO_DB_NAME = 'a_seller_info';
exports.PRIZE_CONFIG_DB_NAME = 'b_prize_config'; exports.PRIZE_CONFIG_DB_NAME = 'b_prize_config';
......
{"version":3,"file":"db.js","sourceRoot":"","sources":["../src/db.ts"],"names":[],"mappings":";AAAA,cAAc;;;AAED,QAAA,cAAc,GAAW,eAAe,CAAA;AAExC,QAAA,YAAY,GAAW,QAAQ,CAAA;AAE/B,QAAA,cAAc,GAAW,eAAe,CAAA;AAExC,QAAA,cAAc,GAAW,eAAe,CAAA;AAExC,QAAA,iBAAiB,GAAW,WAAW,CAAA;AAEvC,QAAA,mBAAmB,GAAW,eAAe,CAAA;AAE7C,QAAA,oBAAoB,GAAW,gBAAgB,CAAA;AAE/C,QAAA,uBAAuB,GAAW,mBAAmB,CAAA"} {"version":3,"file":"db.js","sourceRoot":"","sources":["../src/db.ts"],"names":[],"mappings":";AAAA,cAAc;;;AAED,QAAA,cAAc,GAAW,eAAe,CAAA;AAExC,QAAA,YAAY,GAAW,QAAQ,CAAA;AAE/B,QAAA,cAAc,GAAW,eAAe,CAAA;AAExC,QAAA,iBAAiB,GAAW,WAAW,CAAA;AAEvC,QAAA,mBAAmB,GAAW,eAAe,CAAA;AAE7C,QAAA,oBAAoB,GAAW,gBAAgB,CAAA;AAE/C,QAAA,uBAAuB,GAAW,mBAAmB,CAAA"}
\ No newline at end of file \ No newline at end of file
...@@ -13,7 +13,7 @@ export default class AwardsService extends UserService { ...@@ -13,7 +13,7 @@ export default class AwardsService extends UserService {
* 插入奖品记录 * 插入奖品记录
* @param {*} award * @param {*} award
*/ */
addAward(award: any): Promise<any>; addAward(award: IAwards): Promise<any>;
/** /**
* 发放奖品 * 发放奖品
* @param {*} document * @param {*} document
...@@ -24,9 +24,9 @@ export default class AwardsService extends UserService { ...@@ -24,9 +24,9 @@ export default class AwardsService extends UserService {
* @param {*} param0 * @param {*} param0
*/ */
getMyPrizeList({ openId, activityId }: { getMyPrizeList({ openId, activityId }: {
openId: any; openId: string;
activityId: any; activityId: string;
}): Promise<any>; }): Promise<Array<IAwards>>;
recieveObjectPrize(_id: string, { activityId, province, city, area, addressdetail, name, phone }: { recieveObjectPrize(_id: string, { activityId, province, city, area, addressdetail, name, phone }: {
activityId: string; activityId: string;
province: string; province: string;
...@@ -36,10 +36,15 @@ export default class AwardsService extends UserService { ...@@ -36,10 +36,15 @@ export default class AwardsService extends UserService {
name: string; name: string;
phone: string | number; phone: string | number;
}): Promise<true | import("taobao-mini-sdk/lib/utils/codetypes").CodeType>; }): Promise<true | import("taobao-mini-sdk/lib/utils/codetypes").CodeType>;
recieveEnamePrize(_id: any, activityId: string): Promise<{}>; recieveEnamePrize(_id: string, activityId: string): Promise<{}>;
getPrizeConfig(query: {
activityId: string;
[queryParam: string]: any;
}): Promise<Array<IActivityPrize>>;
getPrizeByProbability(prizes: Array<IActivityPrize>): Promise<IActivityPrize>;
/** /**
* 获取活动配置项奖品 * 获取活动配置项奖品
* @param {*} _id * @param {string} _id
*/ */
getActivityPrizeById(_id: string): Promise<any>; getActivityPrizeById(_id: string): Promise<any>;
} }
...@@ -209,7 +209,7 @@ var AwardsService = /** @class */ (function (_super) { ...@@ -209,7 +209,7 @@ var AwardsService = /** @class */ (function (_super) {
// 若有过期时间,且已过期 // 若有过期时间,且已过期
if (awardReceiveExpiredTime) { if (awardReceiveExpiredTime) {
currentTime_1 = Date.now(); currentTime_1 = Date.now();
myprizeList.map(function (v) { myprizeList = myprizeList.map(function (v) {
if (currentTime_1 > awardReceiveExpiredTime) { if (currentTime_1 > awardReceiveExpiredTime) {
if ([constants_1.DRAW_STATUS.WAITAWARD, constants_1.DRAW_STATUS.RETRY].includes(v.drawStatus)) { if ([constants_1.DRAW_STATUS.WAITAWARD, constants_1.DRAW_STATUS.RETRY].includes(v.drawStatus)) {
v.drawStatus = constants_1.DRAW_STATUS.EXPIRED; v.drawStatus = constants_1.DRAW_STATUS.EXPIRED;
...@@ -341,9 +341,27 @@ var AwardsService = /** @class */ (function (_super) { ...@@ -341,9 +341,27 @@ var AwardsService = /** @class */ (function (_super) {
}); });
}); });
}; };
// 根据查询条件获取奖品配置
AwardsService.prototype.getPrizeConfig = function (query) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this.activityprizedao.find(__assign({ deleteStatus: 1 /* NORMAL */ }, query))];
});
});
};
// 根据概率抽取奖品
AwardsService.prototype.getPrizeByProbability = function (prizes) {
return __awaiter(this, void 0, void 0, function () {
var probability;
return __generator(this, function (_a) {
probability = utils_1.rand(10000);
return [2 /*return*/, prizes.find(function (v) { return probability <= v.properiodto && probability >= v.properiodfrom; })];
});
});
};
/** /**
* 获取活动配置项奖品 * 获取活动配置项奖品
* @param {*} _id * @param {string} _id
*/ */
AwardsService.prototype.getActivityPrizeById = function (_id) { AwardsService.prototype.getActivityPrizeById = function (_id) {
return __awaiter(this, void 0, void 0, function () { return __awaiter(this, void 0, void 0, function () {
......
This diff is collapsed.
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
"taobao-mini-sdk": "^0.1.6" "taobao-mini-sdk": "^0.1.6"
}, },
"scripts": { "scripts": {
"start": "npx tsc", "start": "tsc",
"mock": "cd mockServer && npm start", "mock": "cd mockServer && npm start",
"preinstall": "cd mockServer && yarn" "preinstall": "cd mockServer && yarn"
}, },
......
...@@ -119,13 +119,6 @@ export const DRAW_STATUS = { ...@@ -119,13 +119,6 @@ export const DRAW_STATUS = {
RETRY: 6 RETRY: 6
} }
// 奖品类型
export const PRIZE_TYPE = {
ENAME: 1,
CREDITS: 2,
OBJECT: 3,
THANKS: 5
}
// C端的APP NAME // C端的APP NAME
export const C_APP_NAME: string = 'promotioncenter-${需要补充}' export const C_APP_NAME: string = 'promotioncenter-${需要补充}'
...@@ -145,6 +138,12 @@ export const enum ACTIVITY_STATUS { ...@@ -145,6 +138,12 @@ export const enum ACTIVITY_STATUS {
DELETE = 2 DELETE = 2
} }
// 奖品状态
export const enum DELETE_STATUS {
NORMAL = 1,
DELETE = 2
}
//任务频率类型常量 //任务频率类型常量
export const TASK_RATE_TYPE = { export const TASK_RATE_TYPE = {
FOREVER: 1, FOREVER: 1,
...@@ -152,15 +151,22 @@ export const TASK_RATE_TYPE = { ...@@ -152,15 +151,22 @@ export const TASK_RATE_TYPE = {
NOLIMIT: 3 NOLIMIT: 3
} }
// 奖品类型
export const PRIZE_TYPE = {
ENAME: 1,
CREDITS: 2,
OBJECT: 3,
THANKS: 5
}
// 奖品分类
export const PRIZE_DATA_TYPE = {
RANKING: 1, // 排行榜
PROBABILITY: 2 // 概率
}
// 奖品是否限制库存 // 奖品是否限制库存
export enum SWICH_TOCK { export enum SWICH_TOCK {
LIMIT = 1, LIMIT = 1,
NO_LIMIT = 2 NO_LIMIT = 2
} }
export const RECORD_TYPE = {
FOLLOW_TASK: { type: 1, name: '关注店铺任务' },
SIGN_TASK: { type: 2, name: '签到任务' },
RECEIVE_INVITE: { type: 3, name: '接受邀请' },
INVITE_SUCCESS: { type: 4, name: '邀请成功' }
}
/** @format */ /** @format */
import { services, paramsCheck, userCheck } from '../decorator' import { services, paramsCheck, userCheck, activityTimeCheck } from '../decorator'
import { resultsModel } from '../sdk' import { resultsModel } from '../sdk'
import { AwardsService } from '../service' import { AwardsService } from '../service'
import { PRIZE_TYPE, PRIZE_DATA_TYPE, DRAW_STATUS } from '../constants'
import { getToday } from '../utils'
export default class AwardsController { export default class AwardsController {
/** /**
* 我的奖品列表 * 我的奖品列表
...@@ -68,4 +69,73 @@ export default class AwardsController { ...@@ -68,4 +69,73 @@ export default class AwardsController {
} }
return resultsModel.success(result) return resultsModel.success(result)
} }
/**
* 概率抽奖
*/
@paramsCheck(['activityId'])
@activityTimeCheck
@services([AwardsService])
async drawLotteryPrize(context: Context, { userInfo }: IControllerInfos, [awardSer]: [AwardsService]) {
const { openId } = context
const { activityId } = context.data
// 获取奖池配置
const prizesPool = await awardSer.getPrizeConfig({
activityId
// 根据需求配置筛选条件
// prizeDataType: PRIZE_DATA_TYPE.PROBABILITY
})
// 根据概率获取
const prize = await awardSer.getPrizeByProbability(prizesPool)
// 未找到奖品,降级到谢谢参与
if (prize) {
return resultsModel.success({
data: {
type: PRIZE_TYPE.THANKS,
name: '谢谢参与'
}
})
}
let reduceResult: ICodeType | 1 = 1
// 不是积分奖品, 检查是否扣库存
if (prize.type !== PRIZE_TYPE.CREDITS) {
reduceResult = await awardSer.reduceStock(prize._id)
}
// 扣库存失败
if ((reduceResult as ICodeType).code) return resultsModel.error(reduceResult as ICodeType)
const { type, _id, ename, image } = prize
const { userNick } = userInfo
let record = {
openId,
prizeId: _id,
activityId,
drawStatus: DRAW_STATUS.WAITAWARD,
// prizeDataType,
remark: '',
type,
ename,
name,
image,
userNick,
createDay: getToday()
}
// 奖品信息 insert c_awards表
const result = await awardSer.addAward(record)
return resultsModel.success({
id: result,
type,
name,
image
})
}
} }
/** @format */ /** @format */
import { USER_DB_NAME, ACCESS_DB_NAME, RECORD_DB_NAME, AWARDS_DB_NAME } from '../db' import { USER_DB_NAME, ACCESS_DB_NAME, AWARDS_DB_NAME } from '../db'
import { resultsModel, dateFormatter, transformBeijingDate, BaseDao } from '../sdk' import { resultsModel, dateFormatter, transformBeijingDate, BaseDao } from '../sdk'
import { CODE_TYPES, RECORD_TYPE } from '../constants' import { CODE_TYPES } from '../constants'
import * as xlsx from 'node-xlsx' import * as xlsx from 'node-xlsx'
/** @format */ /** @format */
...@@ -15,8 +15,6 @@ export default class StatController { ...@@ -15,8 +15,6 @@ export default class StatController {
const userDao: IBaseDao = new BaseDao(context, USER_DB_NAME) const userDao: IBaseDao = new BaseDao(context, USER_DB_NAME)
const accessDao: IBaseDao = new BaseDao(context, ACCESS_DB_NAME) const accessDao: IBaseDao = new BaseDao(context, ACCESS_DB_NAME)
const recordDao: IBaseDao = new BaseDao(context, RECORD_DB_NAME)
const awardsDao: IBaseDao = new BaseDao(context, AWARDS_DB_NAME)
const oneDay = 24 * 3600 * 1000 const oneDay = 24 * 3600 * 1000
const xlsxData = [] const xlsxData = []
...@@ -32,7 +30,6 @@ export default class StatController { ...@@ -32,7 +30,6 @@ export default class StatController {
{ $group: { _id: '$openId', count: { $sum: 1 } } } { $group: { _id: '$openId', count: { $sum: 1 } } }
]) ])
).length ).length
// 新增UV // 新增UV
const newUV = await userDao.count({ const newUV = await userDao.count({
activityId, activityId,
...@@ -68,60 +65,12 @@ export default class StatController { ...@@ -68,60 +65,12 @@ export default class StatController {
'member.bememberDay': day 'member.bememberDay': day
}) })
const followPV = await recordDao.count({ const newFollowUV = await userDao.count({
activityId, activityId,
createDay: day, 'member.follow': true,
recordType: RECORD_TYPE.FOLLOW_TASK.type 'member.followDay': day
}) })
const followUV = (
await recordDao.aggregate([
{ $match: { activityId, createDay: day, recordType: RECORD_TYPE.FOLLOW_TASK.type } },
{ $group: { _id: '$openId', count: { $sum: 1 } } }
])
).length
// const signTaskPV = await recordDao.count({
// activityId,
// createDay: day,
// recordType: RECORD_TYPE.SIGN_TASK.type
// })
// const signTaskUV = (
// await recordDao.aggregate([
// { $match: { activityId, createDay: day, recordType: RECORD_TYPE.SIGN_TASK.type } },
// { $group: { _id: '$openId', count: { $sum: 1 } } }
// ])
// ).length
const inviteSuccessUV = (
await recordDao.aggregate([
{ $match: { activityId, createDay: day, recordType: RECORD_TYPE.INVITE_SUCCESS.type } },
{ $group: { _id: '$inviteId', count: { $sum: 1 } } }
])
).length
const receiveShareUV = (
await recordDao.aggregate([
{ $match: { activityId, createDay: day, recordType: RECORD_TYPE.RECEIVE_INVITE.type } },
{ $group: { _id: '$openId', count: { $sum: 1 } } }
])
).length
const receiveShareVipUV = (
await accessDao.aggregate([
{ $match: { activityId, createDay: day, isReceiveShare: true, isVip: true } },
{ $group: { _id: '$openId', count: { $sum: 1 } } }
])
).length
const receiveShareNoVipUV = (
await accessDao.aggregate([
{ $match: { activityId, createDay: day, isReceiveShare: true, isVip: false } },
{ $group: { _id: '$openId', count: { $sum: 1 } } }
])
).length
const keyValueMapper = { const keyValueMapper = {
时间: day, 时间: day,
访问PV: PV, 访问PV: PV,
...@@ -132,14 +81,7 @@ export default class StatController { ...@@ -132,14 +81,7 @@ export default class StatController {
未入会PV: noVipPV, 未入会PV: noVipPV,
未入会UV: noVipUV, 未入会UV: noVipUV,
新入会UV: newVipUV, 新入会UV: newVipUV,
关注店铺完成PV: followPV, 新增关注UV: newFollowUV
关注店铺完成UV: followUV,
// 签到PV: signTaskPV,
// 签到UV: signTaskUV,
邀请好友完成UV: inviteSuccessUV,
带来好友UV: receiveShareUV,
带来好友已入会UV: receiveShareVipUV,
带来好友未入会UV: receiveShareNoVipUV
} }
if (day === startDay) { if (day === startDay) {
......
...@@ -6,8 +6,6 @@ export const USER_DB_NAME: string = 'c_user' ...@@ -6,8 +6,6 @@ export const USER_DB_NAME: string = 'c_user'
export const AWARDS_DB_NAME: string = 'c_awards_info' export const AWARDS_DB_NAME: string = 'c_awards_info'
export const RECORD_DB_NAME: string = `c_user_record`
export const ERROR_LOG_DB_NAME: string = 'error_log' export const ERROR_LOG_DB_NAME: string = 'error_log'
export const SELLER_INFO_DB_NAME: string = 'a_seller_info' export const SELLER_INFO_DB_NAME: string = 'a_seller_info'
......
...@@ -6,9 +6,9 @@ ...@@ -6,9 +6,9 @@
import { BaseDao } from '../sdk' import { BaseDao } from '../sdk'
import UserService from './user.service' import UserService from './user.service'
import { CODE_TYPES, DRAW_STATUS, PRIZE_TYPE, ACTIVITY_STATUS, SWICH_TOCK } from '../constants' import { CODE_TYPES, DRAW_STATUS, PRIZE_TYPE, ACTIVITY_STATUS, DELETE_STATUS, SWICH_TOCK } from '../constants'
import { AWARDS_DB_NAME, PRIZE_CONFIG_DB_NAME } from '../db' import { AWARDS_DB_NAME, PRIZE_CONFIG_DB_NAME } from '../db'
import { sendTBAward, getSellerSession } from '../utils' import { sendTBAward, getSellerSession, rand, signFigures } from '../utils'
export default class AwardsService extends UserService { export default class AwardsService extends UserService {
awardsdao: IBaseDao awardsdao: IBaseDao
...@@ -57,7 +57,7 @@ export default class AwardsService extends UserService { ...@@ -57,7 +57,7 @@ export default class AwardsService extends UserService {
* 插入奖品记录 * 插入奖品记录
* @param {*} award * @param {*} award
*/ */
async addAward(award: any) { async addAward(award: IAwards) {
try { try {
return await this.awardsdao.insertOne({ return await this.awardsdao.insertOne({
...award, ...award,
...@@ -103,7 +103,7 @@ export default class AwardsService extends UserService { ...@@ -103,7 +103,7 @@ export default class AwardsService extends UserService {
* 我的奖品 * 我的奖品
* @param {*} param0 * @param {*} param0
*/ */
async getMyPrizeList({ openId, activityId }) { async getMyPrizeList({ openId, activityId }: { openId: string; activityId: string }): Promise<Array<IAwards>> {
// 获取奖品领取过期时间 // 获取奖品领取过期时间
let { awardReceiveExpiredTime } = await this.getBaseInfo(activityId) let { awardReceiveExpiredTime } = await this.getBaseInfo(activityId)
let myprizeList = await this.awardsdao.find( let myprizeList = await this.awardsdao.find(
...@@ -117,7 +117,7 @@ export default class AwardsService extends UserService { ...@@ -117,7 +117,7 @@ export default class AwardsService extends UserService {
// 若有过期时间,且已过期 // 若有过期时间,且已过期
if (awardReceiveExpiredTime) { if (awardReceiveExpiredTime) {
let currentTime = Date.now() let currentTime = Date.now()
myprizeList.map((v: { drawStatus: number; remark: string; expiredTime: any }) => { myprizeList = myprizeList.map((v: { drawStatus: number; remark: string; expiredTime: any }) => {
if (currentTime > awardReceiveExpiredTime) { if (currentTime > awardReceiveExpiredTime) {
if ([DRAW_STATUS.WAITAWARD, DRAW_STATUS.RETRY].includes(v.drawStatus)) { if ([DRAW_STATUS.WAITAWARD, DRAW_STATUS.RETRY].includes(v.drawStatus)) {
v.drawStatus = DRAW_STATUS.EXPIRED v.drawStatus = DRAW_STATUS.EXPIRED
...@@ -195,7 +195,7 @@ export default class AwardsService extends UserService { ...@@ -195,7 +195,7 @@ export default class AwardsService extends UserService {
} }
// 发放淘宝权益(奖品数据已插入到awards_info表,且状态drawStatus 为1或者6) // 发放淘宝权益(奖品数据已插入到awards_info表,且状态drawStatus 为1或者6)
async recieveEnamePrize(_id: any, activityId: string) { async recieveEnamePrize(_id: string, activityId: string) {
// 若有过期时间,且已过期 // 若有过期时间,且已过期
let { awardReceiveExpiredTime } = await this.getBaseInfo(activityId) let { awardReceiveExpiredTime } = await this.getBaseInfo(activityId)
if (awardReceiveExpiredTime && Date.now() > awardReceiveExpiredTime) { if (awardReceiveExpiredTime && Date.now() > awardReceiveExpiredTime) {
...@@ -235,9 +235,25 @@ export default class AwardsService extends UserService { ...@@ -235,9 +235,25 @@ export default class AwardsService extends UserService {
return result return result
} }
// 根据查询条件获取奖品配置
async getPrizeConfig(query: { activityId: string; [queryParam: string]: any }): Promise<Array<IActivityPrize>> {
return this.activityprizedao.find({
deleteStatus: DELETE_STATUS.NORMAL,
...query
})
}
// 根据概率抽取奖品
async getPrizeByProbability(prizes: Array<IActivityPrize>): Promise<IActivityPrize> {
// 获取 1-10000的随机数
const probability = rand(10000)
return prizes.find(v => probability <= v.properiodto && probability >= v.properiodfrom)
}
/** /**
* 获取活动配置项奖品 * 获取活动配置项奖品
* @param {*} _id * @param {string} _id
*/ */
async getActivityPrizeById(_id: string) { async getActivityPrizeById(_id: string) {
return await this.activityprizedao.findOne( return await this.activityprizedao.findOne(
......
...@@ -6,8 +6,8 @@ interface IActivityInfo { ...@@ -6,8 +6,8 @@ interface IActivityInfo {
startTime: number startTime: number
endTime: number endTime: number
title: string title: string
deleteStatus: 1 | 2 deleteStatus: number
openPrizeStatus?: 1 | 2 | 3 | 4 openPrizeStatus?: number
remark?: string remark?: string
createTime: number createTime: number
updateTime: number updateTime: number
...@@ -41,15 +41,15 @@ interface IActivityPrize { ...@@ -41,15 +41,15 @@ interface IActivityPrize {
_id?: string _id?: string
activityId?: string activityId?: string
ename?: string ename?: string
prizeType: 1 | 2 prizeDataType: number
type: 1 | 2 | 3 | 4 | 5 type: number
image: string image: string
name: string name: string
probability?: string | number probability?: string | number
properiodto: number properiodto: number
properiodfrom: number properiodfrom: number
lockStatus?: 1 | 2 lockStatus?: number
switchStock?: 1 | 2 switchStock?: number
rank?: string | number rank?: string | number
credits?: string | number credits?: string | number
useUrl?: string useUrl?: string
...@@ -57,6 +57,6 @@ interface IActivityPrize { ...@@ -57,6 +57,6 @@ interface IActivityPrize {
useStock: number useStock: number
openId?: string openId?: string
deleteStatus: number deleteStatus: number
createTime: number createTime?: number
updateTime: number updateTime?: number
} }
...@@ -23,7 +23,7 @@ interface IAwards { ...@@ -23,7 +23,7 @@ interface IAwards {
shipCompany?: string shipCompany?: string
shipNum?: string | number shipNum?: string | number
remark: string remark: string
createTime: number createTime?: number
updateTime: number updateTime?: number
awardsType?: string awardsType?: string
} }
...@@ -34,13 +34,6 @@ interface IVipInfo { ...@@ -34,13 +34,6 @@ interface IVipInfo {
url?: string url?: string
} }
interface IResult {
success: boolean
code: string
message?: string
data?: object[] | object | number[] | string[] | boolean | string
}
interface IBaseDao { interface IBaseDao {
dbName: string dbName: string
db: object db: object
......
/** @format */
interface IResult {
success: boolean
code: string
message?: string
data?: object[] | object | number[] | string[] | boolean | string
}
interface ICodeType {
code: string
defaultMsg?: 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