Commit e49cd988 authored by qinhaitao's avatar qinhaitao

ts

parent 72de2b97
......@@ -77,6 +77,30 @@ export declare const BusinessError: {
defaultMsg: string;
};
};
export declare const OPEN_PRIZE_STATUS: {
WAIT_AWARD: number;
PROCESSING: number;
SUCCESS: number;
FAIL: number;
};
export declare const DRAW_STATUS: {
WAITAWARD: number;
PROCESSING: number;
SUCCESS: number;
FAIL: number;
EXPIRED: number;
RETRY: number;
};
export declare const LOGGER_TYPE: {
ERROR: number;
INFO: number;
};
export declare const PRIZE_TYPE: {
EQUITY: number;
CREDITS: number;
OBJECT: number;
THANK: number;
};
export declare const CODE_TYPES: {
PARAMS_ERROR: import("taobao-mini-sdk/lib/utils/codetypes").CodeType;
SYSTEM_ERROR: import("taobao-mini-sdk/lib/utils/codetypes").CodeType;
......@@ -159,55 +183,78 @@ export declare const CODE_TYPES: {
defaultMsg: string;
};
};
export declare const TBERROR: {
USER_PERMISSION_EXCEED_MAX_RIGHT_COUNT_IN_DAY: string;
COUPON_INVALID_OR_DELETED: string;
APPLY_OWNSELF_COUPON: string;
APPLY_SINGLE_COUPON_COUNT_EXCEED_LIMIT: string;
NO_RIGHT_QUANTITY: string;
ERRORA_3_567: string;
'Invalid session': string;
export declare const errorCode: {
'000000': string;
'000001': string;
'000002': string;
'000003': string;
'000004': string;
'000005': string;
'000006': string;
'000007': string;
'000008': string;
'000010': string;
'000011': string;
'000012': string;
'000013': string;
'000014': string;
'000015': string;
'000016': string;
'000017': string;
'000020': string;
'000021': string;
'000022': string;
'000023': string;
'000024': string;
'000025': string;
'000026': string;
'000027': string;
'000030': string;
'000031': string;
};
export declare const DRAW_STATUS: {
WAITAWARD: number;
PROCESSING: number;
SUCCESS: number;
FAIL: number;
EXPIRED: number;
RETRY: number;
export declare const B_APP_NAME: string;
export declare const GOODSINFO = "detail_url,approve_status,num_iid,title,nick,type,cid,pic_url,num,props,valid_thru,list_time,price,has_discount,has_invoice,has_warranty,has_showcase,modified,delist_time,postage_id,seller_cids,outer_id,sold_quantity";
export declare const EIGHT_HOURS: number;
export declare const DELETE_STATUS: {
DELETE: number;
EXIST: number;
};
export declare const PRIZE_TYPE: {
ENAME: number;
CREDITS: number;
OBJECT: number;
THANKS: number;
};
export declare const C_APP_NAME: string;
export declare const TAOBAO_SUCCESS_ORDER_STATUS: string[];
export declare const enum ACTIVITY_STATUS {
NORMAL = 1,
DELETE = 2
}
export declare const TASK_RATE_TYPE: {
FOREVER: number;
EVERYDAY: number;
NOLIMIT: number;
export declare const TASK_TYPE_TEXT: {
beMembership: string;
attentionStore: string;
sign: string;
exchangeCredits: string;
inviteFriends: string;
orderGoods: string;
browseGoods: string;
jumpLink: string;
collectGoods: string;
};
export declare const RECORD_TYPE: {
FOLLOW_TASK: {
type: number;
name: string;
export declare const TASK_CHECK_TYPE: {
value: {
list: string[];
reg: RegExp;
regName: string;
};
SIGN_TASK: {
type: number;
name: string;
times: {
list: string[];
};
RECEIVE_INVITE: {
type: number;
name: string;
title: {
list: string[];
};
INVITE_SUCCESS: {
type: number;
name: string;
itemIds: {
list: string[];
};
taskRateType: {
list: string[];
};
link: {
list: string[];
};
};
export declare const APP_SUB_CODE: string;
export declare const TEMPLATE_INFO: {
clients: string;
template_id: number;
template_version: string;
};
"use strict";
/** @format */
Object.defineProperty(exports, "__esModule", { value: true });
exports.RECORD_TYPE = 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.TEMPLATE_INFO = exports.APP_SUB_CODE = exports.TASK_CHECK_TYPE = exports.TASK_TYPE_TEXT = exports.DELETE_STATUS = exports.EIGHT_HOURS = exports.GOODSINFO = exports.B_APP_NAME = exports.errorCode = exports.CODE_TYPES = exports.PRIZE_TYPE = exports.LOGGER_TYPE = exports.DRAW_STATUS = exports.OPEN_PRIZE_STATUS = exports.BusinessError = void 0;
var sdk_1 = require("./sdk");
exports.BusinessError = {
// 更新重试失败(用于并发更新)
......@@ -91,16 +91,16 @@ exports.BusinessError = {
defaultMsg: "\u5956\u54C1\u5DF2\u8D85\u8FC7\u9886\u53D6\u65F6\u95F4"
}
};
exports.CODE_TYPES = Object.assign({}, sdk_1.DEFAULT_CODE_TYPES, exports.BusinessError);
// tb 接口返回部分错误
exports.TBERROR = {
USER_PERMISSION_EXCEED_MAX_RIGHT_COUNT_IN_DAY: '今日领取达到上限,明日再来领取哦',
COUPON_INVALID_OR_DELETED: '权益无效或者被删除,请联系商家',
APPLY_OWNSELF_COUPON: '不能领取自己家店铺权益',
APPLY_SINGLE_COUPON_COUNT_EXCEED_LIMIT: '请至卡券包删除无用权益再领取',
NO_RIGHT_QUANTITY: '权益库存不足,请联系商家',
ERRORA_3_567: '领取失败,为风险用户',
'Invalid session': '订购应用已过期,请联系商家处理'
// 活动开奖状态码
exports.OPEN_PRIZE_STATUS = {
// 待开奖
WAIT_AWARD: 1,
// 开奖中
PROCESSING: 2,
// 开奖成功
SUCCESS: 3,
// 开奖失败
FAIL: 4
};
// 领取奖品状态
exports.DRAW_STATUS = {
......@@ -117,34 +117,100 @@ exports.DRAW_STATUS = {
// 重新领取
RETRY: 6
};
// 奖品类型
// 日志类型: error,info
exports.LOGGER_TYPE = {
ERROR: 1,
INFO: 2
};
exports.PRIZE_TYPE = {
ENAME: 1,
EQUITY: 1,
CREDITS: 2,
OBJECT: 3,
THANKS: 5
THANK: 5
};
exports.CODE_TYPES = Object.assign({}, sdk_1.DEFAULT_CODE_TYPES, exports.BusinessError);
exports.errorCode = {
'000000': 'ok',
'000001': '请填写活动名称',
'000002': '请填写活动副标题',
'000003': '活动名称不得大于12个字符',
'000004': '活动副标题不得大于16个字符',
'000005': '任务配置至少选择一项',
'000006': '浏览链接配置错误',
'000007': '奖品至少配置三名',
'000008': '浏览宝贝最多选择20个商品',
'000010': '请先生成规则',
'000011': '请配置活动时间',
'000012': '新建活动开始时间需小于当前时间',
'000013': '开始时间不得大于结束时间',
'000014': '奖品最多配置8个档位',
'000015': '查询列表错误',
'000016': '查询列表总数错误',
'000017': '更新奖品列表出错',
'000020': '删除活动失败',
'000021': '保存活动失败',
'000022': '删除活动id不存在',
'000023': '当前活动不存在',
'000024': '获取授权信息失败',
'000025': '保存授权信息失败',
'000026': '获取商家在售列表失败',
'000027': '获取商家ids列表失败',
'000030': '获取ename商品信息失败',
'000031': '奖品配置不正确'
};
// B端的APP NAME
exports.B_APP_NAME = 'promotioncenter-<%=bizCode%>';
exports.GOODSINFO = 'detail_url,approve_status,num_iid,title,nick,type,cid,pic_url,num,props,valid_thru,list_time,price,has_discount,has_invoice,has_warranty,has_showcase,modified,delist_time,postage_id,seller_cids,outer_id,sold_quantity';
exports.EIGHT_HOURS = 60 * 60 * 8 * 1000;
exports.DELETE_STATUS = {
DELETE: 2,
EXIST: 1
};
exports.TASK_TYPE_TEXT = {
beMembership: '成为会员',
attentionStore: '关注店铺',
sign: '签到',
exchangeCredits: '兑换积分',
inviteFriends: '邀请好友',
orderGoods: '下单商品',
browseGoods: '浏览商品',
jumpLink: '跳转链接',
collectGoods: '收藏商品'
};
// C端的APP NAME
exports.C_APP_NAME = 'promotioncenter-${需要补充}';
// 订单状态
exports.TAOBAO_SUCCESS_ORDER_STATUS = [
'WAIT_SELLER_SEND_GOODS',
'SELLER_CONSIGNED_PART',
'WAIT_BUYER_CONFIRM_GOODS',
'TRADE_BUYER_SIGNED',
'TRADE_FINISHED',
'PAID_FORBID_CONSIGN'
];
//任务频率类型常量
exports.TASK_RATE_TYPE = {
FOREVER: 1,
EVERYDAY: 2,
NOLIMIT: 3
exports.TASK_CHECK_TYPE = {
value: {
list: [
'beMembership',
'attentionStore',
'sign',
'exchangeCredits',
'inviteFriends',
'orderGoods',
'jumpLink',
'collectGoods'
],
reg: /[1-99]/,
regName: '1-99之内'
},
times: {
list: ['exchangeCredits', 'inviteFriends', 'orderGoods', 'browseGoods', 'jumpLink', 'collectGoods']
},
title: {
list: ['inviteFriends', 'orderGoods', 'browseGoods', 'jumpLink', 'collectGoods']
},
itemIds: {
list: ['orderGoods', 'browseGoods', 'collectGoods']
},
taskRateType: {
list: ['inviteFriends', 'orderGoods', 'browseGoods', 'collectGoods']
},
link: { list: ['jumpLink'] }
};
exports.RECORD_TYPE = {
FOLLOW_TASK: { type: 1, name: '关注店铺任务' },
SIGN_TASK: { type: 2, name: '签到任务' },
RECEIVE_INVITE: { type: 3, name: '接受邀请' },
INVITE_SUCCESS: { type: 4, name: '邀请成功' }
//saas订购码 根据需求改变
exports.APP_SUB_CODE = 'FW_GOODS-1001086450';
exports.TEMPLATE_INFO = {
clients: 'taobao,tmall',
template_id: 3000000002590532,
template_version: '0.0.3'
};
//# 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,cAAc;IACd,uBAAuB,EAAE;QACvB,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE,aAAa;KAC1B;IACD,QAAQ;IACR,YAAY,EAAE;QACZ,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE,OAAO;KACpB;IACD,UAAU;IACV,yBAAyB,EAAE;QACzB,IA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AAED,SAAS;AACI,QAAA,WAAW,GAAG;IACzB,MAAM;IACN,SAAS,EAAE,CAAC;IACZ,MAAM;IACN,UAAU,EAAE,CAAC;IACb,OAAO;IACP,OAAO,EAAE,CAAC;IACV,OAAO;IACP,IAAI,EAAE,CAAC;IACP,MAAM;IACN,OAAO,EAAE,CAAC;IACV,OAAO;IACP,KAAK,EAAE,CAAC;CACT,CAAA;AAED,OAAO;AACM,QAAA,UAAU,GAAG;IACxB,KAAK,EAAE,CAAC;IACR,OAAO,EAAE,CAAC;IACV,MAAM,EAAE,CAAC;IACT,MAAM,EAAE,CAAC;CACV,CAAA;AACD,cAAc;AACD,QAAA,UAAU,GAAW,yBAAyB,CAAA;AAE3D,OAAO;AACM,QAAA,2BAA2B,GAAa;IACnD,wBAAwB;IACxB,uBAAuB;IACvB,0BAA0B;IAC1B,oBAAoB;IACpB,gBAAgB;IAChB,qBAAqB;CACtB,CAAA;AAQD,UAAU;AACG,QAAA,cAAc,GAAG;IAC5B,OAAO,EAAE,CAAC;IACV,QAAQ,EAAE,CAAC;IACX,OAAO,EAAE,CAAC;CACX,CAAA;AAEY,QAAA,WAAW,GAAG;IACzB,WAAW,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE;IACxC,SAAS,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE;IACpC,cAAc,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE;IACzC,cAAc,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE;CAC1C,CAAA"}
\ 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;K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,eAAe,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,cAAc,CAAC;KACpG;IACD,KAAK,EAAE;QACL,IAAI,EAAE,CAAC,eAAe,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,cAAc,CAAC;KACjF;IACD,OAAO,EAAE;QACP,IAAI,EAAE,CAAC,YAAY,EAAE,aAAa,EAAE,cAAc,CAAC;KACpD;IACD,YAAY,EAAE;QACZ,IAAI,EAAE,CAAC,eAAe,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,CAAC;KACrE;IACD,IAAI,EAAE,EAAE,IAAI,EAAE,CAAC,UAAU,CAAC,EAAE;CAC7B,CAAA;AAED,gBAAgB;AACH,QAAA,YAAY,GAAW,qBAAqB,CAAA;AAE5C,QAAA,aAAa,GAAG;IAC3B,OAAO,EAAE,cAAc;IACvB,WAAW,EAAE,gBAAgB;IAC7B,gBAAgB,EAAE,OAAO;CAC1B,CAAA"}
\ No newline at end of file
/** @format */
import { ActivityconfigService } from '../service';
export default class ActivityController {
/**
* 活动基本信息
*/
getActivityList(context: Context, {}: {}, [activityconfigService]: [ActivityconfigService]): Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result>;
/**
* 活动详情
*/
getActivityDetail(context: Context, {}: {}, [activityconfigService]: [ActivityconfigService]): Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result>;
/**
* 删除活动
*/
delActivity(context: Context, {}: {}, [activityconfigService]: [ActivityconfigService]): 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);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
var constants_1 = require("./../constants");
var decorator_1 = require("../decorator");
var sdk_1 = require("../sdk");
var service_1 = require("../service");
var ActivityController = /** @class */ (function () {
function ActivityController() {
}
/**
* 活动基本信息
*/
ActivityController.prototype.getActivityList = function (context, _a, _b) {
var activityconfigService = _b[0];
return __awaiter(this, void 0, void 0, function () {
var openId, result;
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
openId = context.openId;
return [4 /*yield*/, activityconfigService.getActivityListByOpenId(openId, context.data)];
case 1:
result = _c.sent();
if (result) {
result = result.list.map(function (item) {
return __assign(__assign({}, item), { activityId: item._id });
});
return [2 /*return*/, sdk_1.resultsModel.success(result)];
}
return [2 /*return*/, sdk_1.resultsModel.error(constants_1.CODE_TYPES.SYSTEM_ERROR, '查询活动列表失败')];
}
});
});
};
/**
* 活动详情
*/
ActivityController.prototype.getActivityDetail = function (context, _a, _b) {
var activityconfigService = _b[0];
return __awaiter(this, void 0, void 0, function () {
var activityId, result, _c, prizeConfig, baseConfig, prizes, activityInfo;
return __generator(this, function (_d) {
switch (_d.label) {
case 0:
activityId = context.data.activityId;
return [4 /*yield*/, activityconfigService.getActivityInfoByActivityId(activityId)];
case 1:
result = _d.sent();
if (!result)
return [2 /*return*/, sdk_1.resultsModel.error(constants_1.CODE_TYPES.PARAMS_ERROR, '当前活动不存在')];
_c = result || {}, prizeConfig = _c.prizeConfig, baseConfig = _c.baseConfig;
prizes = activityconfigService.formatPrizeConfig(prizeConfig);
activityInfo = __assign(__assign({ activityId: activityId }, baseConfig), prizes);
return [2 /*return*/, sdk_1.resultsModel.success(activityInfo)];
}
});
});
};
/**
* 删除活动
*/
ActivityController.prototype.delActivity = function (context, _a, _b) {
var activityconfigService = _b[0];
return __awaiter(this, void 0, void 0, function () {
var activityId, result, deleteSuccess;
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
activityId = context.data.activityId;
return [4 /*yield*/, activityconfigService.deleteActivityByActivityId(activityId)];
case 1:
result = _c.sent();
deleteSuccess = result === 0 || result;
if (deleteSuccess) {
return [2 /*return*/, sdk_1.resultsModel.success(true)];
}
else {
return [2 /*return*/, sdk_1.resultsModel.error(constants_1.CODE_TYPES.SYSTEM_ERROR, '删除活动失败')];
}
return [2 /*return*/];
}
});
});
};
__decorate([
decorator_1.services([service_1.ActivityconfigService]),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, Object, Array]),
__metadata("design:returntype", Promise)
], ActivityController.prototype, "getActivityList", null);
__decorate([
decorator_1.paramsCheck(['activityId']),
decorator_1.services([service_1.ActivityconfigService]),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, Object, Array]),
__metadata("design:returntype", Promise)
], ActivityController.prototype, "getActivityDetail", null);
__decorate([
decorator_1.paramsCheck(['activityId']),
decorator_1.services([service_1.ActivityconfigService]),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, Object, Array]),
__metadata("design:returntype", Promise)
], ActivityController.prototype, "delActivity", null);
return ActivityController;
}());
exports.default = ActivityController;
//# sourceMappingURL=activity.controller.js.map
\ No newline at end of file
{"version":3,"file":"activity.controller.js","sourceRoot":"","sources":["../../src/controller/activity.controller.ts"],"names":[],"mappings":";AAAA,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEd,4CAA2C;AAC3C,0CAAoD;AACpD,8BAAqC;AACrC,sCAAkD;AAElD;IAAA;IA6DA,CAAC;IA5DC;;OAEG;IAEG,4CAAe,GAArB,UAAsB,OAAgB,EAAE,EAAE,EAAE,EAAgD;YAA/C,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AA;;;;;;wBACpD,UAAU,GAAK,OAAO,CAAC,IAAI,WAAjB,CAAiB;wBAEtB,qBAAM,qBAAqB,CAAC,0BAA0B,CAAC,UAAU,CAAC,EAAA;;wBAA3E,MAAM,GAAG,SAAkE;wBACzE,aAAa,GAAY,MAAM,KAAK,CAAC,IAAI,MAAM,CAAA;wBACrD,IAAI,aAAa,EAAE;4BACjB,sBAAO,kBAAY,CAAC,OAAO,CAAC,IAAI,CAAC,EAAA;yBAClC;6BAAM;4BACL,sBAAO,kBAAY,CAAC,KAAK,CAAC,sBAAU,CAAC,YAAY,EAAE,QAAQ,CAAC,EAAA;yBAC7D;;;;;KACF;IAvDD;QADC,oBAAQ,CAAC,CAAC,+BAAqB,CAAC,CAAC;;;;6DAejC;IAOD;QAFC,uBAAW,CAAC,CAAC,YAAY,CAAC,CAAC;QAC3B,oBAAQ,CAAC,CAAC,+BAAqB,CAAC,CAAC;;;;+DAkBjC;IAOD;QAFC,uBAAW,CAAC,CAAC,YAAY,CAAC,CAAC;QAC3B,oBAAQ,CAAC,CAAC,+BAAqB,CAAC,CAAC;;;;yDAWjC;IACH,yBAAC;CAAA,AA7DD,IA6DC;kBA7DoB,kBAAkB"}
\ No newline at end of file
/** @format */
import { AwardsService, BaseService } from '../service';
export default class AwardsController {
import { AwardsService } from '../service';
export default class BaseController {
/**
* 我的奖品列表
* 活动中奖名单
*/
getMyPrizeList(context: Context, {}: {}, [awardSer]: [AwardsService]): Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result>;
findWinnerInfoList(context: Context, { session }: {
session: any;
}, [awardsService]: [AwardsService]): Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result>;
/**
* 领取实物
* 导出活动中奖名单
*/
receiveObjectPrize(context: Context, {}: {}, [awardSer]: [AwardsService]): Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result>;
/**
* 权益重新领取
*/
receiveEnamePrize(context: Context, {}: {}, [awardSer, baseService]: [AwardsService, BaseService]): Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result>;
exportAwardsList(context: Context, { session }: {
session: any;
}, [awardsService]: [AwardsService]): Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result>;
}
......@@ -49,85 +49,88 @@ Object.defineProperty(exports, "__esModule", { value: true });
var decorator_1 = require("../decorator");
var sdk_1 = require("../sdk");
var service_1 = require("../service");
var AwardsController = /** @class */ (function () {
function AwardsController() {
var xlsx = require("node-xlsx");
var BaseController = /** @class */ (function () {
function BaseController() {
}
/**
* 我的奖品列表
* 活动中奖名单
*/
AwardsController.prototype.getMyPrizeList = function (context, _a, _b) {
var awardSer = _b[0];
BaseController.prototype.findWinnerInfoList = function (context, _a, _b) {
var session = _a.session;
var awardsService = _b[0];
return __awaiter(this, void 0, void 0, function () {
var result;
var activityId, awardslist, winnersObj, results;
return __generator(this, function (_c) {
switch (_c.label) {
case 0: return [4 /*yield*/, awardSer.getMyPrizeList({ openId: context.openId, activityId: context.data.activityId })];
case 1:
result = _c.sent();
return [2 /*return*/, sdk_1.resultsModel.success(result)];
}
});
});
};
/**
* 领取实物
*/
AwardsController.prototype.receiveObjectPrize = function (context, _a, _b) {
var awardSer = _b[0];
return __awaiter(this, void 0, void 0, function () {
var _c, province, city, area, addressdetail, _id, name, phone, activityId, result;
return __generator(this, function (_d) {
switch (_d.label) {
case 0:
_c = context.data, province = _c.province, city = _c.city, area = _c.area, addressdetail = _c.addressdetail, _id = _c._id, name = _c.name, phone = _c.phone, activityId = _c.activityId;
return [4 /*yield*/, awardSer.recieveObjectPrize(_id, {
activityId: activityId,
province: province,
city: city,
area: area,
addressdetail: addressdetail,
name: name,
phone: phone
})
//@ts-ignore
];
activityId = context.data.activityId;
return [4 /*yield*/, awardsService.getAwardslistByActivityId(activityId)];
case 1:
result = _d.sent();
//@ts-ignore
if (result.code) {
//@ts-ignore
return [2 /*return*/, sdk_1.resultsModel.error(result)];
}
return [2 /*return*/, sdk_1.resultsModel.success(result)];
awardslist = _c.sent();
console.log("awardslist: " + JSON.stringify(awardslist));
winnersObj = {};
awardslist.forEach(function (v) {
if (!winnersObj[v.rank]) {
winnersObj[v.rank] = [];
}
winnersObj[v.rank].push({
userNick: v.userNick,
id: v.openId
});
});
console.log("winnersObj: " + JSON.stringify(winnersObj));
results = [];
new Map(Object.entries(winnersObj)).forEach(function (v, index) {
results.push({
rank: index,
winnerDetailList: v
});
});
return [2 /*return*/, sdk_1.resultsModel.success(results)];
}
});
});
};
/**
* 权益重新领取
* 导出活动中奖名单
*/
AwardsController.prototype.receiveEnamePrize = function (context, _a, _b) {
var awardSer = _b[0], baseService = _b[1];
BaseController.prototype.exportAwardsList = function (context, _a, _b) {
var session = _a.session;
var awardsService = _b[0];
return __awaiter(this, void 0, void 0, function () {
var _c, _id, activityId, result;
var cloud, _c, activityId, title, awardslist, xlsxData, buffer, result;
return __generator(this, function (_d) {
switch (_d.label) {
case 0:
_c = context.data, _id = _c._id, activityId = _c.activityId;
return [4 /*yield*/, awardSer.recieveEnamePrize(_id, activityId)
//@ts-ignore
];
cloud = context.cloud;
_c = context.data, activityId = _c.activityId, title = _c.title;
return [4 /*yield*/, awardsService.getAwardslistByActivityId(activityId)];
case 1:
awardslist = _d.sent();
console.log("awardslist: " + JSON.stringify(awardslist));
xlsxData = [['序列', '名次', '昵称', '中奖名称']];
awardslist.forEach(function (v, index, arr) {
xlsxData.push([index + 1, v.rank, v.userNick, v.prizeName]);
});
buffer = xlsx.build([
{
name: title + new Date().getTime(),
data: xlsxData
}
]);
console.log("xlsxData: " + JSON.stringify(xlsxData));
return [4 /*yield*/, cloud.file.uploadFile({
fileContent: buffer,
fileName: title + new Date().getTime() + '.xlsx'
})
// result.url 需进行处理
];
case 2:
result = _d.sent();
//@ts-ignore
if (result.code) {
//@ts-ignore
return [2 /*return*/, sdk_1.resultsModel.error(result)];
}
//@ts-ignore
if (result.remark) {
//@ts-ignore
return [2 /*return*/, sdk_1.resultsModel.error(result, result.remark)];
// result.url 需进行处理
if (result.url) {
result.url = result.url.replace('http', 'https').replace('-internal', '');
}
return [2 /*return*/, sdk_1.resultsModel.success(result)];
}
......@@ -136,29 +139,19 @@ var AwardsController = /** @class */ (function () {
};
__decorate([
decorator_1.paramsCheck(['activityId']),
decorator_1.userCheck({ intercept: true }),
decorator_1.services([service_1.AwardsService]),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, Object, Array]),
__metadata("design:returntype", Promise)
], AwardsController.prototype, "getMyPrizeList", null);
], BaseController.prototype, "findWinnerInfoList", null);
__decorate([
decorator_1.paramsCheck(['activityId', '_id', 'name', 'phone', 'province', 'city', 'area', 'addressdetail']),
decorator_1.userCheck({ intercept: true }),
decorator_1.paramsCheck(['activityId', 'title']),
decorator_1.services([service_1.AwardsService]),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, Object, Array]),
__metadata("design:returntype", Promise)
], AwardsController.prototype, "receiveObjectPrize", null);
__decorate([
decorator_1.paramsCheck(['activityId', '_id']),
decorator_1.userCheck({ intercept: true }),
decorator_1.services([service_1.AwardsService, service_1.BaseService]),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, Object, Array]),
__metadata("design:returntype", Promise)
], AwardsController.prototype, "receiveEnamePrize", null);
return AwardsController;
], BaseController.prototype, "exportAwardsList", null);
return BaseController;
}());
exports.default = AwardsController;
exports.default = BaseController;
//# sourceMappingURL=awards.controller.js.map
\ No newline at end of file
{"version":3,"file":"awards.controller.js","sourceRoot":"","sources":["../../src/controller/awards.controller.ts"],"names":[],"mappings":";AAAA,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGd,0CAA+D;AAE/D,8BAAqC;AACrC,sCAAuD;AACvD;IAAA;IA4DA,CAAC;IA3DC;;OAEG;IAIG,yCAAc,GAApB,UAAqB,OAAgB,EAAE,EAAE,EAAE,EAA2B;YAA1B,QAAQ,QAAA;;;;;4BACrC,qBAAM,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM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AAM,CAAC,IAAI,EAAE;4BACf,YAAY;4BACZ,sBAAO,kBAAY,CAAC,KAAK,CAAC,MAAM,CAAC,EAAA;yBAClC;wBACD,YAAY;wBACZ,IAAI,MAAM,CAAC,MAAM,EAAE;4BACjB,YAAY;4BACZ,sBAAO,kBAAY,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,EAAA;yBACjD;wBACD,sBAAO,kBAAY,CAAC,OAAO,CAAC,MAAM,CAAC,EAAA;;;;KACpC;IApDD;QAHC,uBAAW,CAAC,CAAC,YAAY,CAAC,CAAC;QAC3B,qBAAS,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;QAC9B,oBAAQ,CAAC,CAAC,uBAAa,CAAC,CAAC;;;;0DAIzB;IAQD;QAHC,uBAAW,CAAC,CAAC,YAAY,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,CAAC,CAAC;QAChG,qBAAS,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;QAC9B,oBAAQ,CAAC,CAAC,uBAAa,CAAC,CAAC;;;;8DAmBzB;IAQD;QAHC,uBAAW,CAAC,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;QAClC,qBAAS,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;QAC9B,oBAAQ,CAAC,CAAC,uBAAa,EAAE,qBAAW,CAAC,CAAC;;;;6DAgBtC;IACH,uBAAC;CAAA,AA5DD,IA4DC;kBA5DoB,gBAAgB"}
\ No newline at end of file
{"version":3,"file":"awards.controller.js","sourceRoot":"","sources":["../../src/controller/awards.controller.ts"],"names":[],"mappings":";AAAA,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGd,0CAAoD;AAEpD,8BAAqC;AACrC,sCAA0C;AAC1C,gCAAiC;AAEjC;IAAA;IAqEA,CAAC;IApEC;;OAEG;IAGG,2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CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAA;yBAC1E;wBACD,sBAAO,kBAAY,CAAC,OAAO,CAAC,MAAM,CAAC,EAAA;;;;KACpC;IA9DD;QAFC,uBAAW,CAAC,CAAC,YAAY,CAAC,CAAC;QAC3B,oBAAQ,CAAC,CAAC,uBAAa,CAAC,CAAC;;;;4DA6BzB;IAOD;QAFC,uBAAW,CAAC,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;QACpC,oBAAQ,CAAC,CAAC,uBAAa,CAAC,CAAC;;;;0DA4BzB;IACH,qBAAC;CAAA,AArED,IAqEC;kBArEoB,cAAc"}
\ No newline at end of file
/** @format */
import { BaseService } from '../service';
import { SellerService } from '../service';
export default class BaseController {
/**
* 活动基本信息
* 保存授权信息
*/
getActivityBaseInfoById(context: Context, {}: {}, [baseService]: [BaseService]): Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result>;
sellerSave(context: Context, {}: {}, [sellerService]: [SellerService]): Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result>;
}
......@@ -46,7 +46,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
}
};
Object.defineProperty(exports, "__esModule", { value: true });
var constants_1 = require("./../constants");
var decorator_1 = require("../decorator");
var sdk_1 = require("../sdk");
var service_1 = require("../service");
......@@ -54,35 +53,56 @@ var BaseController = /** @class */ (function () {
function BaseController() {
}
/**
* 活动基本信息
* 保存授权信息
*/
BaseController.prototype.getActivityBaseInfoById = function (context, _a, _b) {
var baseService = _b[0];
BaseController.prototype.sellerSave = function (context, _a, _b) {
var sellerService = _b[0];
return __awaiter(this, void 0, void 0, function () {
var activityId, activityInfo;
var openId, accessToken, appKey, userNick, appOwnerOpenId, isPrimaryAccount, primaryUserNick, sellerInfo, hasSellerInfo, result;
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
activityId = context.data.activityId;
// 参数校验
if (!activityId) {
return [2 /*return*/, sdk_1.resultsModel.error(constants_1.CODE_TYPES.PARAMS_ERROR, "activityId\u5FC5\u586B")];
}
return [4 /*yield*/, baseService.getBaseInfo(activityId)];
openId = context.openId, accessToken = context.accessToken, appKey = context.appKey, userNick = context.userNick, appOwnerOpenId = context.appOwnerOpenId;
isPrimaryAccount = userNick.indexOf(':') === -1;
console.log(userNick, isPrimaryAccount, 'userNick------');
if (!!isPrimaryAccount) return [3 /*break*/, 2];
primaryUserNick = userNick.split(':')[0];
return [4 /*yield*/, sellerService.getSellerInfoByUserNick(primaryUserNick)];
case 1:
activityInfo = _c.sent();
return [2 /*return*/, sdk_1.resultsModel.success(activityInfo)];
sellerInfo = _c.sent();
if (sellerInfo) {
accessToken = sellerInfo.accessToken;
}
_c.label = 2;
case 2: return [4 /*yield*/, sellerService.findSellerInfo(openId)];
case 3:
hasSellerInfo = _c.sent();
if (!hasSellerInfo) return [3 /*break*/, 5];
return [4 /*yield*/, sellerService.updateSellerInfo(openId, { accessToken: accessToken })];
case 4:
_c.sent();
return [2 /*return*/, sdk_1.resultsModel.success(true)];
case 5: return [4 /*yield*/, sellerService.saveSellerInfo({
accessToken: accessToken,
openId: openId,
appKey: appKey,
userNick: userNick,
appOwnerOpenId: appOwnerOpenId
})];
case 6:
result = _c.sent();
return [2 /*return*/, sdk_1.resultsModel.success(result)];
}
});
});
};
__decorate([
decorator_1.paramsCheck(['activityId']),
decorator_1.services([service_1.BaseService]),
decorator_1.services([service_1.SellerService]),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, Object, Array]),
__metadata("design:returntype", Promise)
], BaseController.prototype, "getActivityBaseInfoById", null);
], BaseController.prototype, "sellerSave", 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;A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GAAG,CAAC,QAAQ,EAAE,gBAAgB,EAAE,gBAAgB,CAAC,CAAA;6BAGrD,CAAC,gBAAgB,EAAjB,wBAAiB;wBACf,eAAe,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;wBAC3B,qBAAM,aAAa,CAAC,uBAAuB,CAAC,eAAe,CAAC,EAAA;;wBAAzE,UAAU,GAAG,SAA4D;wBAC7E,IAAI,UAAU,EAAE;4BACd,WAAW,GAAG,UAAU,CAAC,WAAW,CAAA;yBACrC;;4BAIiB,qBAAM,aAAa,CAAC,cAAc,CAAC,MAAM,CAAC,EAAA;;wBAA1D,aAAa,GAAG,SAA0C;6BAC1D,aAAa,EAAb,wBAAa;wBACf,qBAAM,aAAa,CAAC,gBAAgB,CAAC,MAAM,EAAE,EAAE,WAAW,aAAA,EAAE,CAAC,EAAA;;wBAA7D,SAA6D,CAAA;wBAC7D,sBAAO,kBAAY,CAAC,OAAO,CAAC,IAAI,CAAC,EAAA;4BAGpB,qBAAM,aAAa,CAAC,cAAc,CAAC;4BAC9C,WAAW,aAAA;4BACX,MAAM,QAAA;4BACN,MAAM,QAAA;4BACN,QAAQ,UAAA;4BACR,cAAc,gBAAA;yBACf,CAAC,EAAA;;wBANE,MAAM,GAAG,SAMX;wBACF,sBAAO,kBAAY,CAAC,OAAO,CAAC,MAAM,CAAC,EAAA;;;;KAEtC;IAhCD;QAFC,uBAAW,CAAC,CAAC,YAAY,CAAC,CAAC;QAC3B,oBAAQ,CAAC,CAAC,uBAAa,CAAC,CAAC;;;;oDAiCzB;IACH,qBAAC;CAAA,AAvCD,IAuCC;kBAvCoB,cAAc"}
\ No newline at end of file
/** @format */
export default class RuleController {
/**
* 生成活动规则
*/
generateRule(context: Context, {}: {}): Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result>;
}
"use strict";
/** @format */
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);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
var constants_1 = require("./../constants");
var decorator_1 = require("../decorator");
var utils_1 = require("../utils");
var sdk_1 = require("../sdk");
var constants_2 = require("../constants");
var RuleController = /** @class */ (function () {
function RuleController() {
}
/**
* 生成活动规则
*/
RuleController.prototype.generateRule = function (context, _a) {
return __awaiter(this, void 0, void 0, function () {
var _b, _c, title, _d, startTime, _e, endTime, _f, prizeList, resultRule, startTimeDate, endTimeDate, prizeStr;
return __generator(this, function (_g) {
_b = context.data, _c = _b.title, title = _c === void 0 ? '' : _c, _d = _b.startTime, startTime = _d === void 0 ? '' : _d, _e = _b.endTime, endTime = _e === void 0 ? '' : _e, _f = _b.prizeList, prizeList = _f === void 0 ? [] : _f;
if (title.length > 12)
return [2 /*return*/, sdk_1.resultsModel.error(constants_1.CODE_TYPES.PARAMS_ERROR, '活动名称不可超过12个字')];
if (startTime > endTime)
return [2 /*return*/, sdk_1.resultsModel.error(constants_1.CODE_TYPES.PARAMS_ERROR, '开始时间不得大于结束时间')];
if (prizeList.length === 0)
return [2 /*return*/, sdk_1.resultsModel.error(constants_1.CODE_TYPES.PARAMS_ERROR, '奖品至少配置一个')];
resultRule = '';
startTimeDate = utils_1.formatTime(new Date(+startTime + constants_2.EIGHT_HOURS), 'yyyy-MM-dd hh:mm:ss');
endTimeDate = utils_1.formatTime(new Date(+endTime + constants_2.EIGHT_HOURS), 'yyyy-MM-dd hh:mm:ss');
resultRule = "1.\u6D3B\u52A8\u65F6\u95F4\uFF1A" + startTimeDate + "--" + endTimeDate + "\uFF1B\n2.\u6D3B\u52A8\u7ED3\u675F\u6839\u636E\u6392\u884C\u699C\u6392\u540D\u83B7\u5F97\u5BF9\u5E94\u7684\u5956\u52B1\uFF0C\u6BCF\u4E2A\u4EBA\u53D6\u6D3B\u52A8\u4E2D\u5355\u5C40\u6700\u9AD8\u5206\uFF1B\n3.\u6BCF\u59293\u6B21\u514D\u8D39\u53C2\u4E0E\u8D44\u683C\uFF0C\u8D85\u8FC7\u6B21\u6570\u540E\u9080\u8BF7\u7FA4\u5185\u597D\u53CB\u53C2\u4E0E\u6E38\u620F\u53EF\u83B7\u5F97\u989D\u5916\u6B21\u6570(\u6BCF\u4E2A\u7528\u6237\u53EF\u52A9\u529B\u4E00\u6B21)\uFF1B\n4.\u53C2\u4E0E\u7B7E\u5230\u53EF\u83B7\u5F97\u9053\u5177\uFF0C\u6BCF\u5C40\u7ED3\u675F\u6E38\u620F\u540E\u53EF\u4F7F\u7528\u9053\u5177\uFF1B\n5.\u5B8C\u6210\u4EFB\u52A1\u6BCF\u5929\u53EF\u83B7\u5F97\u989D\u5916\u7684\u590D\u6D3B\u673A\u4F1A\uFF0C\u6BCF\u5C40\u53EA\u80FD\u4F7F\u7528\u4E00\u5F20\u590D\u6D3B\u5361\uFF1B\n\n";
prizeStr = prizeList.reduce(function (s, v) {
var rankArr = v.rank.split('-');
if (rankArr[0] == rankArr[1]) {
return (s += "\u7B2C" + rankArr[0] + "\u540D: " + v.name + "\n");
}
else {
return (s += "\u7B2C" + v.rank + "\u540D: " + v.name + "\n");
}
}, '奖品:\n');
resultRule += prizeStr;
return [2 /*return*/, sdk_1.resultsModel.success(resultRule)];
});
});
};
__decorate([
decorator_1.paramsCheck(['title', 'startTime', 'endTime', 'prizeList']),
decorator_1.services([]),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, Object]),
__metadata("design:returntype", Promise)
], RuleController.prototype, "generateRule", null);
return RuleController;
}());
exports.default = RuleController;
//# sourceMappingURL=rule.controller.js.map
\ No newline at end of file
{"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MAAM,CAAC,UAAC,CAAC,EAAE,CAAC;oBACrC,IAAM,OAAO,GAAG,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;oBACjC,IAAI,OAAO,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE;wBAC5B,OAAO,CAAC,CAAC,IAAI,WAAI,OAAO,CAAC,CAAC,CAAC,iBAAO,CAAC,CAAC,IAAI,OAAI,CAAC,CAAA;qBAC9C;yBAAM;wBACL,OAAO,CAAC,CAAC,IAAI,WAAI,CAAC,CAAC,IAAI,iBAAO,CAAC,CAAC,IAAI,OAAI,CAAC,CAAA;qBAC1C;gBACH,CAAC,EAAE,OAAO,CAAC,CAAA;gBACX,UAAU,IAAI,QAAQ,CAAA;gBACtB,sBAAO,kBAAY,CAAC,OAAO,CAAC,UAAU,CAAC,EAAA;;;KACxC;IArBD;QAFC,uBAAW,CAAC,CAAC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC;QAC3D,oBAAQ,CAAC,EAAE,CAAC;;;;sDAsBZ;IACH,qBAAC;CAAA,AA5BD,IA4BC;kBA5BoB,cAAc"}
\ No newline at end of file
/** @format */
import { ActivityconfigService } from '../service';
interface ISaveActivityContext extends Context {
data: {
activityId?: string;
title: string;
startTime: number;
endTime: number;
tasks: ITasks;
rule: string;
};
}
export default class ActivitSaveController {
/**
* 保存活动
*/
saveActivityInfo(context: ISaveActivityContext, {}: {}, [activityconfigService]: [ActivityconfigService]): Promise<void>;
}
export {};
"use strict";
/** @format */
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);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
var decorator_1 = require("../decorator");
var service_1 = require("../service");
// const activityValidate: <T><RuleItem> = {
// title: {
// require: true,
// type: 'string',
// validator: (rule, value, callback, data) => {}
// }
// }
var ActivitSaveController = /** @class */ (function () {
function ActivitSaveController() {
}
/**
* 保存活动
*/
ActivitSaveController.prototype.saveActivityInfo = function (context, _a, _b) {
var activityconfigService = _b[0];
return __awaiter(this, void 0, void 0, function () {
var _c, _d, title, _e, activityId, startTime, endTime, _f, tasks, rule, nowTime, initialData;
return __generator(this, function (_g) {
switch (_g.label) {
case 0:
_c = context.data, _d = _c.title, title = _d === void 0 ? '' : _d, _e = _c.activityId, activityId = _e === void 0 ? '' : _e, startTime = _c.startTime, endTime = _c.endTime, _f = _c.tasks, tasks = _f === void 0 ? {} : _f, rule = _c.rule;
nowTime = Date.now();
if (!activityId) return [3 /*break*/, 2];
return [4 /*yield*/, activityconfigService.getActivityInfoByActivityId(activityId)];
case 1:
initialData = _g.sent();
_g.label = 2;
case 2: return [2 /*return*/];
}
});
});
};
__decorate([
decorator_1.paramsCheck(['title', 'startTime', 'endTime', 'tasks', 'rule'])
// @paramsValidate(activityValidate)
,
decorator_1.services([service_1.ActivityconfigService]),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, Object, Array]),
__metadata("design:returntype", Promise)
], ActivitSaveController.prototype, "saveActivityInfo", null);
return ActivitSaveController;
}());
exports.default = ActivitSaveController;
//# sourceMappingURL=save.controller.js.map
\ No newline at end of file
{"version":3,"file":"save.controller.js","sourceRoot":"","sources":["../../src/controller/save.controller.ts"],"names":[],"mappings":";AAAA,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGd,0CAAoE;AAEpE,sCAAkD;AAclD,4CAA4C;AAC5C,aAAa;AACb,qBAAqB;AACrB,sBAAsB;AACtB,qDAAqD;AACrD,MAAM;AACN,IAAI;AAEJ;IAAA;IAiBA,CAAC;IAhBC;;OAEG;IAIG,gDAAgB,GAAtB,UAAuB,OAA6B,EAAE,EAAE,EAAE,EAAgD;YAA/C,qBAAqB,QAAA;;;;;;wBACxE,KAAwE,OAAO,CAAC,IAAI,EAAlF,aAAU,EAAV,KAAK,mBAAG,EAAE,KAAA,EAAE,kBAAe,EAAf,UAAU,mBAAG,EAAE,KAAA,EAAE,SAAS,eAAA,EAAE,OAAO,aAAA,EAAE,aAAU,EAAV,KAAK,mBAAG,EAAE,KAAA,EAAE,IAAI,UAAA,CAAiB;wBAEpF,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;6BAGtB,UAAU,EAAV,wBAAU;wBACE,qBAAM,qBAAqB,CAAC,2BAA2B,CAAC,UAAU,CAAC,EAAA;;wBAAjF,WAAW,GAAG,SAAmE,CAAA;;;;;;KAEpF;IATD;QAHC,uBAAW,CAAC,CAAC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;QAChE,oCAAoC;;QACnC,oBAAQ,CAAC,CAAC,+BAAqB,CAAC,CAAC;;;;iEAUjC;IACH,4BAAC;CAAA,AAjBD,IAiBC;kBAjBoB,qBAAqB"}
\ No newline at end of file
/** @format */
import { SellerService, TaobaoTopService, InstanceService } from '../service';
export default class BaseController {
/**
* 保存授权信息
*/
sellerSave(context: Context, {}: {}, [sellerService]: [SellerService]): Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result>;
sellerSaasSave(context: Context, {}: {}, [sellerService, taobaoTopService, InstanceService]: [SellerService, TaobaoTopService, InstanceService]): 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);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
var decorator_1 = require("../decorator");
var sdk_1 = require("../sdk");
var service_1 = require("../service");
var constants_1 = require("../constants");
var BaseController = /** @class */ (function () {
function BaseController() {
}
/**
* 保存授权信息
*/
BaseController.prototype.sellerSave = function (context, _a, _b) {
var sellerService = _b[0];
return __awaiter(this, void 0, void 0, function () {
var openId, accessToken, appKey, userNick, appOwnerOpenId, isPrimaryAccount, primaryUserNick, sellerInfo, hasSellerInfo, result;
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
openId = context.openId, accessToken = context.accessToken, appKey = context.appKey, userNick = context.userNick, appOwnerOpenId = context.appOwnerOpenId;
isPrimaryAccount = userNick.indexOf(':') === -1;
console.log(userNick, isPrimaryAccount, 'userNick------');
if (!!isPrimaryAccount) return [3 /*break*/, 2];
primaryUserNick = userNick.split(':')[0];
return [4 /*yield*/, sellerService.getSellerInfoByUserNick(primaryUserNick)];
case 1:
sellerInfo = _c.sent();
if (sellerInfo) {
accessToken = sellerInfo.accessToken;
}
_c.label = 2;
case 2: return [4 /*yield*/, sellerService.findSellerInfo(openId)];
case 3:
hasSellerInfo = _c.sent();
if (!hasSellerInfo) return [3 /*break*/, 5];
return [4 /*yield*/, sellerService.updateSellerInfo(openId, { accessToken: accessToken })];
case 4:
_c.sent();
return [2 /*return*/, sdk_1.resultsModel.success(true)];
case 5: return [4 /*yield*/, sellerService.saveSellerInfo({
accessToken: accessToken,
openId: openId,
appKey: appKey,
userNick: userNick,
appOwnerOpenId: appOwnerOpenId
})];
case 6:
result = _c.sent();
return [2 /*return*/, sdk_1.resultsModel.success(result)];
}
});
});
};
BaseController.prototype.sellerSaasSave = function (context, _a, _b) {
var sellerService = _b[0], taobaoTopService = _b[1], InstanceService = _b[2];
return __awaiter(this, void 0, void 0, function () {
var openId, accessToken, appKey, userNick, appOwnerOpenId, consumeMiniAppId, primaryAccountNick, isPrimaryAccount, primaryOpenId, shopId, userNickArr, sellerInfo, hasResult, subInfo, shopInfoResult, instanceOldInfo, instanceInfo, app_id, app_version, onlineInstance, clients, app_id, template_id, updateInfo, updateInstanceInfo, onlineInstance;
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
openId = context.openId, accessToken = context.accessToken, appKey = context.appKey, userNick = context.userNick, appOwnerOpenId = context.appOwnerOpenId, consumeMiniAppId = context.consumeMiniAppId;
primaryAccountNick = userNick || 'duiba2';
isPrimaryAccount = true;
primaryOpenId = openId;
shopId = '';
if (!(userNick && ~userNick.indexOf(':'))) return [3 /*break*/, 2];
userNickArr = userNick.split(':');
isPrimaryAccount = false;
primaryAccountNick = userNickArr[0];
if (!!isPrimaryAccount) return [3 /*break*/, 2];
return [4 /*yield*/, sellerService.getSellerInfoByUserNick(primaryAccountNick)];
case 1:
sellerInfo = _c.sent();
if (sellerInfo) {
accessToken = sellerInfo.accessToken;
primaryOpenId = sellerInfo.openId;
shopId = sellerInfo.shopId;
}
else {
return [2 /*return*/, sdk_1.resultsModel.error(constants_1.CODE_TYPES.SYSTEM_ERROR, '请用主账号进入后台进行授权')];
}
_c.label = 2;
case 2: return [4 /*yield*/, sellerService.findSellerInfo(openId)];
case 3:
hasResult = _c.sent();
return [4 /*yield*/, taobaoTopService.getSubRelationship(primaryAccountNick)];
case 4:
subInfo = _c.sent();
return [4 /*yield*/, taobaoTopService.getShopId()];
case 5:
shopInfoResult = _c.sent();
if (!(hasResult && hasResult[0])) return [3 /*break*/, 8];
return [4 /*yield*/, sellerService.updateSellerInfo(openId, {
accessToken: accessToken
})];
case 6:
_c.sent();
return [4 /*yield*/, InstanceService.updateInstanceInfo(openId, {
accessToken: accessToken
})
// return resultsModel.success({ deadline: subInfo.deadline || "" });
];
case 7:
_c.sent();
return [3 /*break*/, 10];
case 8:
if (!shopInfoResult.success) {
return [2 /*return*/, sdk_1.resultsModel.error(constants_1.CODE_TYPES.SYSTEM_ERROR, '获取淘宝店铺信息失败')];
}
return [4 /*yield*/, sellerService.saveSellerInfo({
accessToken: accessToken,
openId: openId,
appKey: appKey,
// @ts-ignore
shopId: shopInfoResult.data.sid,
userNick: userNick,
appOwnerOpenId: appOwnerOpenId
})
// return resultsModel.success({ deadline: subInfo.deadline || "" });
];
case 9:
_c.sent();
_c.label = 10;
case 10: return [4 /*yield*/, InstanceService.getMiniAppInstanceInfoByNick(primaryAccountNick)];
case 11:
instanceOldInfo = _c.sent();
if (!!instanceOldInfo) return [3 /*break*/, 17];
if (!isPrimaryAccount) {
return [2 /*return*/, sdk_1.resultsModel.error(constants_1.CODE_TYPES.SYSTEM_ERROR, '请用主账号进入后台进行授权')];
}
return [4 /*yield*/, taobaoTopService.getTemplateInstantiate()];
case 12:
instanceInfo = _c.sent();
app_id = instanceInfo.app_id, app_version = instanceInfo.app_version;
if (!instanceInfo) return [3 /*break*/, 15];
return [4 /*yield*/, taobaoTopService.pushOnlineInstance({
app_id: app_id,
app_version: app_version
})];
case 13:
onlineInstance = _c.sent();
return [4 /*yield*/, InstanceService.saveInstanceInfo(__assign(__assign(__assign(__assign({}, instanceInfo), { clients: onlineInstance.online_results.miniapp_instance_app_online_dto.reduce(function (s, v) {
return (s += v.client + ',');
}, '') }), onlineInstance.app_info), { accessToken: accessToken, template_version: constants_1.TEMPLATE_INFO.template_version, template_id: constants_1.TEMPLATE_INFO.template_id, openId: openId,
appKey: appKey,
consumeMiniAppId: consumeMiniAppId,
// @ts-ignore
shopId: shopInfoResult.data.sid, userNick: userNick,
appOwnerOpenId: appOwnerOpenId }))];
case 14:
_c.sent();
return [3 /*break*/, 16];
case 15:
console.log('实例化信息获取失败');
_c.label = 16;
case 16: return [3 /*break*/, 24];
case 17:
if (!(constants_1.TEMPLATE_INFO.template_version !== instanceOldInfo.template_version)) return [3 /*break*/, 21];
clients = instanceOldInfo.clients, app_id = instanceOldInfo.app_id, template_id = instanceOldInfo.template_id;
updateInfo = {
clients: clients,
app_id: app_id,
template_id: template_id,
ext_json: {
name: 'online'
},
template_version: constants_1.TEMPLATE_INFO.template_version
};
return [4 /*yield*/, taobaoTopService.updateMiniInstance(updateInfo)];
case 18:
updateInstanceInfo = _c.sent();
return [4 /*yield*/, taobaoTopService.pushOnlineInstance({
app_id: updateInstanceInfo.app_id,
app_version: updateInstanceInfo.app_version
})];
case 19:
onlineInstance = _c.sent();
return [4 /*yield*/, InstanceService.updateInstanceInfo(openId, __assign(__assign({ template_version: constants_1.TEMPLATE_INFO.template_version }, onlineInstance.app_info), { app_version: updateInstanceInfo.app_version, pre_view_url: updateInstanceInfo.pre_view_url }))];
case 20:
_c.sent();
_c.label = 21;
case 21: return [4 /*yield*/, InstanceService.updateInstanceInfo(openId, {
// @ts-ignore
shopId: shopInfoResult.data.sid
})];
case 22:
_c.sent();
return [4 /*yield*/, InstanceService.updateInstanceInfo(primaryOpenId, {
// @ts-ignore
shopId: shopInfoResult.data.sid
})];
case 23:
_c.sent();
_c.label = 24;
case 24: return [2 /*return*/, sdk_1.resultsModel.success({ deadline: subInfo.deadline || '' })];
}
});
});
};
__decorate([
decorator_1.services([service_1.SellerService]),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, Object, Array]),
__metadata("design:returntype", Promise)
], BaseController.prototype, "sellerSave", null);
__decorate([
decorator_1.services([service_1.SellerService, service_1.TaobaoTopService, service_1.InstanceService]),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, Object, Array]),
__metadata("design:returntype", Promise)
], BaseController.prototype, "sellerSaasSave", null);
return BaseController;
}());
exports.default = BaseController;
//# sourceMappingURL=seller.controller.js.map
\ No newline at end of file
{"version":3,"file":"seller.controller.js","sourceRoot":"","sources":["../../src/controller/seller.controller.ts"],"names":[],"mappings":";AAAA,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEd,0CAAuC;AACvC,8BAAqC;AACrC,sCAA6E;AAC7E,0CAAwD;AACxD;IAAA;IA+JA,CAAC;IA9JC;;OAEG;IAEG,mCAAU,GAAhB,UAAiB,OAAgB,EAAE,EAAE,EAAE,EAAgC;YAA/B,aAAa,QAAA;;;;;;wBAC7C,MAAM,GAAoD,OAAO,OAA3D,EAAE,WAAW,GAAuC,OAAO,YAA9C,EAAE,MAAM,GAA+B,OAAO,OAAtC,EAAE,QAAQ,GAAqB,OAAO,SAA5B,EAAE,cAAc,GAAK,OAAO,eAAZ,CAAY;wBAEnE,gBAAgB,GAAY,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAA;wBAE5D,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,gBAAgB,EAAE,gBAAgB,CAAC,CAAA;6BAGrD,CAAC,gBAAgB,EAAjB,wBAAiB;wBACf,eAAe,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;wBAC3B,qBAAM,aAAa,CAAC,uBAAuB,CAAC,eAAe,CAAC,EAAA;;wBAAzE,UAAU,GAAG,SAA4D;wBAC7E,IAAI,UAAU,EAAE;4BACd,WAAW,GAAG,UAAU,CAAC,WAAW,CAAA;yBACrC;;4BAIiB,qBAAM,aAAa,CAAC,cAAc,CAAC,MAAM,CAAC,EAAA;;wBAA1D,aAAa,GAAG,SAA0C;6BAE1D,aAAa,EAAb,wBAAa;wBACf,qBAAM,aAAa,CAAC,gBAAgB,CAAC,MAAM,EAAE,EAAE,WAAW,aAAA,EAAE,CAAC,EAAA;;wBA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,uBAAa,EAAE,0BAAgB,EAAE,yBAAe,CAAC,CAAC;;;;wDAsH5D;IACH,qBAAC;CAAA,AA/JD,IA+JC;kBA/JoB,cAAc"}
\ No newline at end of file
/** @format */
import { TaobaoTopService } from '../service';
export default class BaseController {
/**
* 通过状态获取top商品列表
*/
findItemListByStatus(context: Context, { session }: {
session: any;
}, [taobaoTopService]: [TaobaoTopService]): Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result>;
/**
* 通过状态获取top商品列表
*/
findItemListByIds(context: Context, { session }: {
session: any;
}, [taobaoTopService]: [TaobaoTopService]): Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result>;
/**
* 通过ename获取权益信息
*/
queryBenefitByEname(context: Context, { session }: {
session: any;
}, [taobaoTopService]: [TaobaoTopService]): Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result>;
}
"use strict";
/** @format */
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);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
var decorator_1 = require("../decorator");
var service_1 = require("../service");
var BaseController = /** @class */ (function () {
function BaseController() {
}
/**
* 通过状态获取top商品列表
*/
BaseController.prototype.findItemListByStatus = function (context, _a, _b) {
var session = _a.session;
var taobaoTopService = _b[0];
return __awaiter(this, void 0, void 0, function () {
var _c, _d, approveStatus, _e, title, _f, pageNo, _g, pageSize, result;
return __generator(this, function (_h) {
switch (_h.label) {
case 0:
_c = context.data, _d = _c.approveStatus, approveStatus = _d === void 0 ? 'onsale' : _d, _e = _c.title, title = _e === void 0 ? '' : _e, _f = _c.pageNo, pageNo = _f === void 0 ? 1 : _f, _g = _c.pageSize, pageSize = _g === void 0 ? 10 : _g;
return [4 /*yield*/, taobaoTopService.getItemListByStatus(session, {
approveStatus: approveStatus,
title: title,
pageNo: pageNo,
pageSize: pageSize
})];
case 1:
result = _h.sent();
return [2 /*return*/, result];
}
});
});
};
/**
* 通过状态获取top商品列表
*/
BaseController.prototype.findItemListByIds = function (context, _a, _b) {
var session = _a.session;
var taobaoTopService = _b[0];
return __awaiter(this, void 0, void 0, function () {
var itemIds;
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
itemIds = context.data.itemIds;
return [4 /*yield*/, taobaoTopService.getItemListByIds(itemIds, session)];
case 1: return [2 /*return*/, _c.sent()];
}
});
});
};
/**
* 通过ename获取权益信息
*/
BaseController.prototype.queryBenefitByEname = function (context, _a, _b) {
var session = _a.session;
var taobaoTopService = _b[0];
return __awaiter(this, void 0, void 0, function () {
var ename;
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
ename = context.data.ename;
return [4 /*yield*/, taobaoTopService.getPrizeByEname(session, ename)];
case 1: return [2 /*return*/, _c.sent()];
}
});
});
};
__decorate([
decorator_1.paramsCheck(['approveStatus', 'title', 'pageNo', 'pageSize']),
decorator_1.services([service_1.TaobaoTopService]),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, Object, Array]),
__metadata("design:returntype", Promise)
], BaseController.prototype, "findItemListByStatus", null);
__decorate([
decorator_1.paramsCheck(['itemIds']),
decorator_1.services([service_1.TaobaoTopService]),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, Object, Array]),
__metadata("design:returntype", Promise)
], BaseController.prototype, "findItemListByIds", null);
__decorate([
decorator_1.paramsCheck(['ename']),
decorator_1.services([service_1.TaobaoTopService]),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, Object, Array]),
__metadata("design:returntype", Promise)
], BaseController.prototype, "queryBenefitByEname", null);
return BaseController;
}());
exports.default = BaseController;
//# sourceMappingURL=taobaoItem.controller.js.map
\ No newline at end of file
{"version":3,"file":"taobaoItem.controller.js","sourceRoot":"","sources":["../../src/controller/taobaoItem.controller.ts"],"names":[],"mappings":";AAAA,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGd,0CAAoD;AAGpD,sCAA6C;AAC7C;IAAA;IAoCA,CAAC;IAnCC;;OAEG;IAGG,6CAAoB,GAA1B,UAA2B,OAAgB,EAAE,EAAW,EAAE,EAAsC;YAAjD,OAAO,aAAA;YAAK,gBAAgB,QAAA;;;;;;wBACnE,KAAsE,OAAO,CAAC,IAAI,EAAhF,qBAAwB,EAAxB,aAAa,mBAAG,QAAQ,KAAA,EAAE,aAAU,EAAV,KAAK,mBAAG,EAAE,KAAA,EAAE,cAAU,EAAV,MAAM,mBAAG,CAAC,KAAA,EAAE,gBAAa,EAAb,QAAQ,mBAAG,EAAE,KAAA,CAAiB;wBAC3E,qBAAM,gBAAgB,CAAC,mBAAmB,CAAC,OAAO,EAAE;gCAC/D,aAAa,eAAA;gCACb,KAAK,OAAA;gCACL,MAAM,QAAA;gCACN,QAAQ,UAAA;6BACT,CAAC,EAAA;;wBALE,MAAM,GAAG,SAKX;wBACF,sBAAO,MAAM,EAAA;;;;KACd;IAED;;OAEG;IAGG,0CAAiB,GAAvB,UAAwB,OAAgB,EAAE,EAAW,EAAE,EAAsC;YAAjD,OAAO,aAAA;YAAK,gBAAgB,QAAA;;;;;;wBAC9D,OAAO,GAAK,OAAO,CAAC,IAAI,QAAjB,CAAiB;wBACzB,qBAAM,gBAAgB,CAAC,gBAAgB,CAAC,OAAO,EAAE,OAAO,CAAC,EAAA;4BAAhE,sBAAO,SAAyD,EAAA;;;;KACjE;IAED;;OAEG;IAGG,4CAAmB,GAAzB,UAA0B,OAAgB,EAAE,EAAW,EAAE,EAAsC;YAAjD,OAAO,aAAA;YAAK,gBAAgB,QAAA;;;;;;wBAChE,KAAK,GAAK,OAAO,CAAC,IAAI,MAAjB,CAAiB;wBACvB,qBAAM,gBAAgB,CAAC,eAAe,CAAC,OAAO,EAAE,KAAK,CAAC,EAAA;4BAA7D,sBAAO,SAAsD,EAAA;;;;KAC9D;IA7BD;QAFC,uBAAW,CAAC,CAAC,eAAe,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC;QAC7D,oBAAQ,CAAC,CAAC,0BAAgB,CAAC,CAAC;;;;8DAU5B;IAOD;QAFC,uBAAW,CAAC,CAAC,SAAS,CAAC,CAAC;QACxB,oBAAQ,CAAC,CAAC,0BAAgB,CAAC,CAAC;;;;2DAI5B;IAOD;QAFC,uBAAW,CAAC,CAAC,OAAO,CAAC,CAAC;QACtB,oBAAQ,CAAC,CAAC,0BAAgB,CAAC,CAAC;;;;6DAI5B;IACH,qBAAC;CAAA,AApCD,IAoCC;kBApCoB,cAAc"}
\ No newline at end of file
......@@ -7,3 +7,4 @@ export declare const ERROR_LOG_DB_NAME: string;
export declare const SELLER_INFO_DB_NAME: string;
export declare const PRIZE_CONFIG_DB_NAME: string;
export declare const ACTIVITY_CONFIG_DB_NAME: string;
export declare const ACTIVITY_INSTANCE: string;
"use strict";
/** @format */
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_INSTANCE = 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.ACCESS_DB_NAME = 'c_user_access';
exports.USER_DB_NAME = 'c_user';
exports.AWARDS_DB_NAME = 'c_awards_info';
......@@ -10,4 +10,5 @@ exports.ERROR_LOG_DB_NAME = 'error_log';
exports.SELLER_INFO_DB_NAME = 'a_seller_info';
exports.PRIZE_CONFIG_DB_NAME = 'b_prize_config';
exports.ACTIVITY_CONFIG_DB_NAME = 'b_activity_config';
exports.ACTIVITY_INSTANCE = 'miniapp_instantiate';
//# sourceMappingURL=db.js.map
\ No newline at end of file
{"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"}
\ No newline at end of file
{"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;AAErD,QAAA,iBAAiB,GAAW,qBAAqB,CAAA"}
\ No newline at end of file
......@@ -2,3 +2,4 @@
export * from './check';
export * from './services';
export * from './noCatch';
export * from './validate';
......@@ -14,4 +14,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./check"), exports);
__exportStar(require("./services"), exports);
__exportStar(require("./noCatch"), exports);
__exportStar(require("./validate"), exports);
//# sourceMappingURL=index.js.map
\ No newline at end of file
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/decorator/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,cAAc;AACd,0CAAuB;AACvB,6CAA0B;AAC1B,4CAAyB"}
\ No newline at end of file
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/decorator/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,cAAc;AACd,0CAAuB;AACvB,6CAA0B;AAC1B,4CAAyB;AACzB,6CAA0B"}
\ No newline at end of file
......@@ -41,10 +41,23 @@ exports.services = void 0;
var utils_1 = require("../utils");
var sdk_1 = require("../sdk");
var constants_1 = require("../constants");
var service_1 = require("../service");
function initBaseInfo(context, baseInfos) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, baseInfos];
var _a;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
if (!!baseInfos.session) return [3 /*break*/, 2];
// @ts-ignore
_a = baseInfos;
return [4 /*yield*/, new service_1.TaobaoTopService(context).getAccessTokenByOpenId()];
case 1:
// @ts-ignore
_a.session = _b.sent();
_b.label = 2;
case 2: return [2 /*return*/, baseInfos];
}
});
});
}
......@@ -52,42 +65,43 @@ exports.services = function (services) {
return function (target, name, descriptor) {
var method = descriptor.value;
descriptor.value = function () {
var _a, _b, _c;
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
return __awaiter(this, void 0, void 0, function () {
var context, _a, otherArgs, servicesInstance, baseInfos, ret, error_1;
return __generator(this, function (_b) {
switch (_b.label) {
var context, _d, otherArgs, servicesInstance, baseInfos, ret, error_1;
return __generator(this, function (_e) {
switch (_e.label) {
case 0:
context = args[0], _a = args[1], otherArgs = _a === void 0 ? {} : _a;
context = args[0], _d = args[1], otherArgs = _d === void 0 ? {} : _d;
servicesInstance = services.map(function (v) { return new v(context); });
return [4 /*yield*/, initBaseInfo(context, otherArgs)
// 默认全局try catch 如果有noCatch参数则直接执行
];
case 1:
baseInfos = _b.sent();
baseInfos = _e.sent();
// 默认全局try catch 如果有noCatch参数则直接执行
if (baseInfos.noCatch) {
delete baseInfos.noCatch;
return [2 /*return*/, method.apply(target, [context, baseInfos, servicesInstance])];
}
_b.label = 2;
_e.label = 2;
case 2:
_b.trys.push([2, 4, , 6]);
_e.trys.push([2, 4, , 6]);
utils_1.logger(context);
return [4 /*yield*/, method.apply(target, [context, baseInfos, servicesInstance])];
case 3:
ret = _b.sent();
ret = _e.sent();
return [3 /*break*/, 6];
case 4:
error_1 = _b.sent();
error_1 = _e.sent();
console.log('error', error_1);
return [4 /*yield*/, utils_1.recordErrorLog(context, baseInfos, error_1.toString(), error_1.stack)];
case 5:
_b.sent();
ret = sdk_1.resultsModel.error(constants_1.CODE_TYPES.SYSTEM_ERROR);
_e.sent();
ret = sdk_1.resultsModel.error(constants_1.CODE_TYPES.SYSTEM_ERROR, (((_c = (_b = (_a = context === null || context === void 0 ? void 0 : context.cloud) === null || _a === void 0 ? void 0 : _a.dataspace) === null || _b === void 0 ? void 0 : _b.context) === null || _c === void 0 ? void 0 : _c.handler) || context.handler) + "\u7CFB\u7EDF\u9519\u8BEF");
return [3 /*break*/, 6];
case 6: return [2 /*return*/, ret];
}
......
{"version":3,"file":"services.js","sourceRoot":"","sources":["../../src/decorator/services.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,cAAc;AACd,kCAAgD;AAChD,8BAAqC;AACrC,0CAAyC;AACzC,SAAe,YAAY,CAAC,OAAgB,EAAE,SAA2B;;;YAGvE,sBAAO,SAAS,EAAA;;;CACjB;AAEY,QAAA,QAAQ,GAAG,UAAC,QAAe;IACtC,OAAO,UAAC,MAAc,EAAE,IAAY,EAAE,UAA8B;QAClE,IAAM,MAAM,GAAG,UAAU,CAAC,KAAK,CAAA;QAE/B,UAAU,CAAC,KAAK,GAAG;YAAgB,cAAc;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AAK,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE,SAAS,EAAE,gBAAgB,CAAC,CAAC,EAAA;;4BAAxE,GAAG,GAAG,SAAkE,CAAA;;;;4BAExE,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,OAAK,CAAC,CAAA;4BAC3B,qBAAM,sBAAc,CAAC,OAAO,EAAE,SAAS,EAAE,OAAK,CAAC,QAAQ,EAAE,EAAE,OAAK,CAAC,KAAK,CAAC,EAAA;;4BAAvE,SAAuE,CAAA;4BACvE,GAAG,GAAG,kBAAY,CAAC,KAAK,CACtB,sBAAU,CAAC,YAAY,EACvB,CAAG,mBAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,KAAK,0CAAE,SAAS,0CAAE,OAAO,0CAAE,OAAO,KAAI,OAAO,CAAC,OAAO,8BAAM,CACxE,CAAA;;gCAEH,sBAAO,GAAG,EAAA;;;;SACX,CAAA;IACH,CAAC,CAAA;AACH,CAAC,CAAA"}
\ No newline at end of file
export declare const paramsValidate: (validator: object) => (target: Object, name: string, descriptor: PropertyDescriptor) => void;
"use strict";
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);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.paramsValidate = void 0;
exports.paramsValidate = function (validator) {
return function (target, name, descriptor) {
var method = descriptor.value;
descriptor.value = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
var context = args[0], _a = args[1], otherArgs = _a === void 0 ? {} : _a;
var params = Object.keys(context.data);
return method.apply(target, [context, __assign({}, otherArgs)]);
};
};
};
//# sourceMappingURL=validate.js.map
\ No newline at end of file
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../src/decorator/validate.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAGa,QAAA,cAAc,GAAG,UAAC,SAAiB;IAC9C,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,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;YAExC,OAAO,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,OAAO,eAAO,SAAS,EAAG,CAAC,CAAA;QAC1D,CAAC,CAAA;IACH,CAAC,CAAA;AACH,CAAC,CAAA"}
\ No newline at end of file
......@@ -2,5 +2,16 @@
/** @format */
Object.defineProperty(exports, "__esModule", { value: true });
var utils_1 = require("./utils");
exports.default = utils_1.exportHandlers([]);
var activity_controller_1 = require("./controller/activity.controller");
var seller_controller_1 = require("./controller/seller.controller");
var awards_controller_1 = require("./controller/awards.controller");
var rule_controller_1 = require("./controller/rule.controller");
var taobaoItem_controller_1 = require("./controller/taobaoItem.controller");
exports.default = utils_1.exportHandlers([
activity_controller_1.default,
seller_controller_1.default,
awards_controller_1.default,
rule_controller_1.default,
taobaoItem_controller_1.default
]);
//# sourceMappingURL=index.js.map
\ No newline at end of file
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,cAAc;;AAEd,iCAAwC;AAGxC,kBAAe,sBAAc,CAAC,EAAE,CAAC,CAAA"}
\ No newline at end of file
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,cAAc;;AAEd,iCAAwC;AACxC,wEAAiE;AACjE,oEAA6D;AAC7D,oEAA6D;AAC7D,gEAAyD;AACzD,4EAAqE;AAErE,kBAAe,sBAAc,CAAC;IAC5B,6BAAkB;IAClB,2BAAgB;IAChB,2BAAgB;IAChB,yBAAc;IACd,+BAAoB;CACrB,CAAC,CAAA"}
\ No newline at end of file
/** @format */
export default class ActivityConfigService {
activityconfigDao: IBaseDao;
activityconfigPrizeDao: IBaseDao;
constructor(context: Context);
saveNewActivity(data: any, prize: any, openId: any): Promise<any>;
updateBaseConfigInfo(id: any, data: any): Promise<any>;
getPrizeInfoById(id: any): Promise<any>;
updateDeleteStatusById(id: any): Promise<any>;
updateOnePrizeById(id: any, data: any): Promise<any>;
insertPrizeByActivityId(activityId: any, data: any): Promise<any>;
getAllOldPrizeList(activityId: any): Promise<any>;
updateActivity(activityId: any, data: any, prizeNoId: any): Promise<[unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown]>;
getActivityListByOpenId(openId: string, { pageSize, pageNo }: {
pageSize?: number;
pageNo?: number;
}): Promise<{
list: any;
total: any;
pageSize: number;
pageNo: number;
}>;
getActivityInfoByActivityId(activityId: string): Promise<{
baseConfig: any;
prizeConfig: any;
}>;
deleteActivityByActivityId(activityId: string): Promise<any>;
getNodifyList(serverTime: any): Promise<any>;
update2Process(_id: any): Promise<boolean>;
update2Success(_id: any): Promise<boolean>;
update2Fail(_id: any, message: any): Promise<boolean>;
/**
* 组装奖品数据
*
* @param {Array<IActivityPrize>} prizeConfig
* @returns
* @memberof ActivityConfigService
*/
formatPrizeConfig(prizeConfig: Array<IActivityPrize>): {
prizeList: IActivityPrize[];
};
}
"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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
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 sdk_1 = require("../sdk");
var db_1 = require("../db");
var constants_1 = require("../constants");
var ActivityConfigService = /** @class */ (function () {
function ActivityConfigService(context) {
this.activityconfigDao = new sdk_1.BaseDao(context, db_1.ACTIVITY_CONFIG_DB_NAME);
this.activityconfigPrizeDao = new sdk_1.BaseDao(context, db_1.PRIZE_CONFIG_DB_NAME);
}
//保存新建活动
ActivityConfigService.prototype.saveNewActivity = function (data, prize, openId) {
return __awaiter(this, void 0, void 0, function () {
var result_1, e_1, e_2;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 7, , 8]);
return [4 /*yield*/, this.activityconfigDao.count(__assign(__assign({}, data), { createTime: Date.now(), updateTime: Date.now(), deleteStatus: constants_1.DELETE_STATUS.EXIST, openPrizeStatus: constants_1.OPEN_PRIZE_STATUS.WAIT_AWARD }))];
case 1:
result_1 = _a.sent();
console.log(result_1, '保存基础配置result');
if (!result_1) return [3 /*break*/, 6];
_a.label = 2;
case 2:
_a.trys.push([2, 4, , 6]);
prize.map(function (item) {
item.activityId = result_1;
item.openId = openId;
item.createTime = Date.now();
item.updateTime = Date.now();
item.deleteStatus = constants_1.DELETE_STATUS.EXIST;
return item;
});
return [4 /*yield*/, this.activityconfigPrizeDao.insertMany(prize)];
case 3: return [2 /*return*/, _a.sent()];
case 4:
e_1 = _a.sent();
console.log(e_1, '保存奖品配置出错');
// 如果奖品未保存删除之前的活动
return [4 /*yield*/, this.activityconfigDao.delete({
_id: result_1
})];
case 5:
// 如果奖品未保存删除之前的活动
_a.sent();
return [3 /*break*/, 6];
case 6: return [3 /*break*/, 8];
case 7:
e_2 = _a.sent();
//保存活动失败
console.log(e_2, '保存活动失败');
return [3 /*break*/, 8];
case 8: return [2 /*return*/];
}
});
});
};
// 更新活动基本信息
ActivityConfigService.prototype.updateBaseConfigInfo = function (id, data) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.activityconfigDao.update({
_id: id
}, {
$set: __assign(__assign({}, data), { updateTime: Date.now(), deleteStatus: constants_1.DELETE_STATUS.EXIST })
})];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
// 通过id获取奖品信息
ActivityConfigService.prototype.getPrizeInfoById = function (id) {
return __awaiter(this, void 0, void 0, function () {
var result;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.activityconfigPrizeDao.find({
_id: id
})];
case 1:
result = _a.sent();
if (result && result[0]) {
return [2 /*return*/, result[0]];
}
return [2 /*return*/, false];
}
});
});
};
// 奖品置为删除状态
ActivityConfigService.prototype.updateDeleteStatusById = function (id) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.activityconfigPrizeDao.update({
_id: id
}, {
$set: {
deleteStatus: constants_1.DELETE_STATUS.DELETE
}
})];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
// 更新单条数据
ActivityConfigService.prototype.updateOnePrizeById = function (id, data) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.activityconfigPrizeDao.update({
_id: id
}, {
$set: __assign(__assign({}, data), { updateTime: Date.now(), deleteStatus: constants_1.DELETE_STATUS.EXIST })
})];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
// 插入单条奖品数据
ActivityConfigService.prototype.insertPrizeByActivityId = function (activityId, data) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.activityconfigPrizeDao.insertOne(__assign(__assign({}, data), { activityId: activityId, createTime: Date.now(), updateTime: Date.now(), deleteStatus: constants_1.DELETE_STATUS.EXIST }))];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
// 获取奖品所有配置
ActivityConfigService.prototype.getAllOldPrizeList = function (activityId) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.activityconfigPrizeDao.find({
activityId: activityId
})];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
//更新活动配置
ActivityConfigService.prototype.updateActivity = function (activityId, data, prizeNoId) {
return __awaiter(this, void 0, void 0, function () {
var originalData, result, prizeOldIdsByActivity, prizeResult, deleteOldPrizeList, e_3, e_4;
var _this = this;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
console.log(activityId, data, prizeNoId, 'activityId, data, prizeNoId, oldPrizeIds');
_a.label = 1;
case 1:
_a.trys.push([1, 12, , 13]);
return [4 /*yield*/, this.activityconfigDao.findOne({
_id: activityId
})];
case 2:
originalData = _a.sent();
return [4 /*yield*/, this.activityconfigDao.update({
_id: activityId
}, {
$set: __assign(__assign({}, data), { createTime: originalData.createTime, updateTime: Date.now() })
})];
case 3:
result = _a.sent();
if (!result) return [3 /*break*/, 11];
_a.label = 4;
case 4:
_a.trys.push([4, 9, , 11]);
return [4 /*yield*/, this.activityconfigPrizeDao.find({
activityId: activityId
})];
case 5:
prizeOldIdsByActivity = (_a.sent()).reduce(function (s, v) {
return (s = __spreadArrays(s, [v._id]));
}, []);
return [4 /*yield*/, this.activityconfigPrizeDao.insertMany(prizeNoId)];
case 6:
prizeResult = _a.sent();
if (!prizeResult) return [3 /*break*/, 8];
deleteOldPrizeList = prizeOldIdsByActivity.reduce(function (s, item) {
return (s = __spreadArrays(s, [
_this.activityconfigPrizeDao.delete({
_id: item
})
]));
}, []);
return [4 /*yield*/, Promise.all(deleteOldPrizeList)];
case 7: return [2 /*return*/, _a.sent()];
case 8: return [3 /*break*/, 11];
case 9:
e_3 = _a.sent();
return [4 /*yield*/, this.activityconfigDao.update({
_id: activityId
}, {
$set: __assign({}, originalData[0])
})];
case 10:
_a.sent();
return [3 /*break*/, 11];
case 11: return [3 /*break*/, 13];
case 12:
e_4 = _a.sent();
return [3 /*break*/, 13];
case 13: return [2 /*return*/];
}
});
});
};
//通过openId去获取当前商家活动列表
ActivityConfigService.prototype.getActivityListByOpenId = function (openId, _a) {
var _b = _a.pageSize, pageSize = _b === void 0 ? 10 : _b, _c = _a.pageNo, pageNo = _c === void 0 ? 1 : _c;
return __awaiter(this, void 0, void 0, function () {
var _d;
return __generator(this, function (_e) {
switch (_e.label) {
case 0:
_d = {};
return [4 /*yield*/, this.activityconfigDao.find({
openId: openId,
deleteStatus: constants_1.DELETE_STATUS.EXIST
}, {
projection: {
startTime: 1,
endTime: 1,
title: 1
},
sort: {
createTime: -1
},
limit: pageSize,
skip: (pageNo - 1) * pageSize
})];
case 1:
_d.list = _e.sent();
return [4 /*yield*/, this.activityconfigDao.count({
openId: openId,
deleteStatus: constants_1.DELETE_STATUS.EXIST
})];
case 2: return [2 /*return*/, (_d.total = _e.sent(),
_d.pageSize = pageSize,
_d.pageNo = pageNo,
_d)];
}
});
});
};
//通过activityId去获取活动配置信息
ActivityConfigService.prototype.getActivityInfoByActivityId = function (activityId) {
return __awaiter(this, void 0, void 0, function () {
var _a;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
_a = {};
return [4 /*yield*/, this.activityconfigDao.findOne({ _id: activityId, deleteStatus: constants_1.DELETE_STATUS.EXIST })];
case 1:
_a.baseConfig = _b.sent();
return [4 /*yield*/, this.activityconfigPrizeDao.find({ activityId: activityId, deleteStatus: constants_1.DELETE_STATUS.EXIST }, { sort: { level: 1 } })];
case 2: return [2 /*return*/, (_a.prizeConfig = _b.sent(),
_a)];
}
});
});
};
//通过activityId去删除活动
ActivityConfigService.prototype.deleteActivityByActivityId = function (activityId) {
return __awaiter(this, void 0, void 0, function () {
var result;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.activityconfigDao.update({ _id: activityId }, { $set: { deleteStatus: constants_1.DELETE_STATUS.DELETE } })
// 删除活动奖品配置
];
case 1:
result = _a.sent();
if (!result) return [3 /*break*/, 3];
return [4 /*yield*/, this.activityconfigPrizeDao.update({ activityId: activityId }, { $set: { deleteStatus: constants_1.DELETE_STATUS.DELETE } })];
case 2: return [2 /*return*/, _a.sent()];
case 3: return [2 /*return*/, false];
}
});
});
};
// 查询待开奖列表
ActivityConfigService.prototype.getNodifyList = function (serverTime) {
return __awaiter(this, void 0, void 0, function () {
var list;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.activityconfigDao.find({
endTime: {
$lt: serverTime
},
openPrizeStatus: {
$in: [constants_1.OPEN_PRIZE_STATUS.WAIT_AWARD, constants_1.OPEN_PRIZE_STATUS.FAIL]
},
deleteStatus: constants_1.DELETE_STATUS.EXIST
})];
case 1:
list = _a.sent();
console.log(list);
return [2 /*return*/, list];
}
});
});
};
// 更新openPrizeStatus为处理中
ActivityConfigService.prototype.update2Process = function (_id) {
return __awaiter(this, void 0, void 0, function () {
var e_5;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 2, , 3]);
return [4 /*yield*/, this.activityconfigDao.update({
_id: _id
}, {
$set: {
openPrizeStatus: constants_1.OPEN_PRIZE_STATUS.PROCESSING,
updateTime: Date.now()
}
})];
case 1:
_a.sent();
return [2 /*return*/, true];
case 2:
e_5 = _a.sent();
// 日志记录
console.log(e_5);
return [2 /*return*/, false];
case 3: return [2 /*return*/];
}
});
});
};
// 更新openPrizeStatus为成功
ActivityConfigService.prototype.update2Success = function (_id) {
return __awaiter(this, void 0, void 0, function () {
var e_6;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 2, , 3]);
return [4 /*yield*/, this.activityconfigDao.update({
_id: _id
}, {
$set: {
openPrizeStatus: constants_1.OPEN_PRIZE_STATUS.SUCCESS,
openPrizeMsg: '',
updateTime: Date.now()
}
})];
case 1:
_a.sent();
return [2 /*return*/, true];
case 2:
e_6 = _a.sent();
// 日志记录
console.log(e_6);
return [2 /*return*/, false];
case 3: return [2 /*return*/];
}
});
});
};
// 更新openPrizeStatus为失败
ActivityConfigService.prototype.update2Fail = function (_id, message) {
return __awaiter(this, void 0, void 0, function () {
var e_7;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 2, , 3]);
return [4 /*yield*/, this.activityconfigDao.update({
_id: _id
}, {
$set: {
openPrizeStatus: constants_1.OPEN_PRIZE_STATUS.FAIL,
openPrizeMsg: message || '',
updateTime: Date.now()
}
})];
case 1:
_a.sent();
return [2 /*return*/, true];
case 2:
e_7 = _a.sent();
// 日志记录
console.log(e_7);
return [2 /*return*/, false];
case 3: return [2 /*return*/];
}
});
});
};
/**
* 组装奖品数据
*
* @param {Array<IActivityPrize>} prizeConfig
* @returns
* @memberof ActivityConfigService
*/
ActivityConfigService.prototype.formatPrizeConfig = function (prizeConfig) {
return {
prizeList: prizeConfig
};
};
return ActivityConfigService;
}());
exports.default = ActivityConfigService;
//# sourceMappingURL=activityconfig.service.js.map
\ No newline at end of file
{"version":3,"file":"activityconfig.service.js","sourceRoot":"","sources":["../../src/service/activityconfig.service.ts"],"names":[],"mappings":";AAAA,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEd,8BAAgC;AAChC,4BAAqE;AAErE,0CAA+D;AAE/D;IAGE,+BAAY,OAAgB;QAC1B,IAAI,CAAC,iBAAiB,GAAG,IAAI,aAAO,CAAC,OAAO,EAAE,4BAAuB,CAAC,CAAA;QACtE,IAAI,CAAC,sBAAsB,GAAG,IAAI,aAAO,CAAC,OAAO,EAAE,yBAAoB,CAAC,CAAA;IAC1E,CAAC;IAED,QAAQ;IACF,+CAAe,GAArB,UAAsB,IAAI,EAAE,KAAK,EAAE,MAAM;;;;;;;wBAExB,qBAAM,IAAI,CAAC,iBAAiB,CAAC,KAAK,uBAC1C,IAAI,KACP,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE,EACtB,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE,EACtB,YAAY,EAAE,yBAAa,CAAC,KAAK,E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,EAAE;iCACvB;6BACF,CACF,EAAA;;wBAXD,SAWC,CAAA;wBACD,sBAAO,IAAI,EAAA;;;wBAEX,OAAO;wBACP,OAAO,CAAC,GAAG,CAAC,GAAC,CAAC,CAAA;wBACd,sBAAO,KAAK,EAAA;;;;;KAEf;IACD;;;;;;OAMG;IACH,iDAAiB,GAAjB,UAAkB,WAAkC;QAClD,OAAO;YACL,SAAS,EAAE,WAAW;SACvB,CAAA;IACH,CAAC;IACH,4BAAC;AAAD,CAAC,AAvUD,IAuUC"}
\ No newline at end of file
export = ActivitySellerService;
declare class ActivitySellerService {
constructor(context: any);
activityinstanceDao: any;
saveInstanceInfo(instanceInfo: any): Promise<any>;
findInstanceInfo(openId: any): Promise<any>;
updateInstanceInfo(openId: any, updateinfo: any): Promise<any>;
getMiniAppInstanceInfoByNick(userNick: any): Promise<any>;
}
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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
var BaseDao = require("../dao/base.dao");
var ACTIVITY_INSTANCE = require("../config/db_config").ACTIVITY_INSTANCE;
module.exports = /** @class */ (function () {
function ActivitySellerService(context) {
this.activityinstanceDao = new BaseDao(context, ACTIVITY_INSTANCE);
}
//保存商家授权信息
ActivitySellerService.prototype.saveInstanceInfo = function (instanceInfo) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.activityinstanceDao.insertOne(__assign(__assign({}, instanceInfo), { updateTime: Date.now(), createTime: Date.now() }))];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
//查找商家授权信息
ActivitySellerService.prototype.findInstanceInfo = function (openId) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.activityinstanceDao.find({
openId: openId,
})];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
//更新商家授权信息
ActivitySellerService.prototype.updateInstanceInfo = function (openId, updateinfo) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.activityinstanceDao.update({
openId: openId,
}, {
$set: __assign(__assign({}, updateinfo), { updateTime: Date.now() }),
})];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
ActivitySellerService.prototype.getMiniAppInstanceInfoByNick = function (userNick) {
return __awaiter(this, void 0, void 0, function () {
var res;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.activityinstanceDao.find({
userNick: userNick,
})];
case 1:
res = _a.sent();
if (res && res[0]) {
return [2 /*return*/, res[0]];
}
return [2 /*return*/, false];
}
});
});
};
return ActivitySellerService;
}());
//# sourceMappingURL=activityinstance.service.js.map
\ No newline at end of file
{"version":3,"file":"activityinstance.service.js","sourceRoot":"","sources":["../../src/service/activityinstance.service.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAM,OAAO,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AACnC,IAAA,iBAAiB,GAAK,OAAO,CAAC,qBAAqB,CAAC,kBAAnC,CAAoC;AAE7D,MAAM,CAAC,OAAO;IACZ,+BAAY,OAAO;QACjB,IAAI,CAAC,mBAAmB,GAAG,IAAI,OAAO,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC;IACrE,CAAC;IAED,UAAU;IACJ,gDAAgB,GAAtB,UAAuB,YAAY;;;;4BAC1B,qBAAM,IAAI,CAAC,mBAAmB,CAAC,SAAS,uBAC1C,YAAY,KACf,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE,EACtB,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE,IACtB,EAAA;4BAJF,sBAAO,SAIL,EAAC;;;;KACJ;IAED,UAAU;IACJ,gDAAgB,GAAtB,UAAuB,MAAM;;;;4BACpB,qBAAM,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC;4BACzC,MAAM,QAAA;yBACP,CAAC,EAAA;4BAFF,sBAAO,SAEL,EAAC;;;;KACJ;IAED,UAAU;IACJ,kDAAkB,GAAxB,UAAyB,MAAM,EAAE,UAAU;;;;4BAClC,qBAAM,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAC1C;4BACE,MAAM,QAAA;yBACP,EACD;4BACE,IAAI,wBACC,UAAU,KACb,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE,GACvB;yBACF,CACF,EAAA;4BAVD,sBAAO,SAUN,EAAC;;;;KACH;IAEK,4DAA4B,GAAlC,UAAmC,QAAQ;;;;;4BAC/B,qBAAM,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC;4BAC5C,QAAQ,UAAA;yBACT,CAAC,EAAA;;wBAFE,GAAG,GAAG,SAER;wBACF,IAAI,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE;4BACjB,sBAAO,GAAG,CAAC,CAAC,CAAC,EAAC;yBACf;wBACD,sBAAO,KAAK,EAAC;;;;KACd;IACH,4BAAC;AAAD,CAAC,AA7CgB,GA6ChB,CAAC"}
\ No newline at end of file
export = ActivitySellerService;
declare class ActivitySellerService {
constructor(context: any);
activitysellerDao: any;
saveSellerInfo(sellerInfo: any): Promise<any>;
findSellerInfo(openId: any): Promise<any>;
getSellerInfoByUserNick(userNick: any): Promise<any>;
updateSellerInfo(openId: any, sellerInfo: any): Promise<any>;
}
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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
var BaseDao = require("../dao/base.dao");
var ACTIVITY_SELLER_SAVE = require("../config/db_config").ACTIVITY_SELLER_SAVE;
module.exports = /** @class */ (function () {
function ActivitySellerService(context) {
this.activitysellerDao = new BaseDao(context, ACTIVITY_SELLER_SAVE);
}
//保存商家授权信息
ActivitySellerService.prototype.saveSellerInfo = function (sellerInfo) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.activitysellerDao.insertOne(__assign(__assign({}, sellerInfo), { updateTime: Date.now(), createTime: Date.now() }))];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
//查找商家授权信息
ActivitySellerService.prototype.findSellerInfo = function (openId) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.activitysellerDao.find({
openId: openId,
})];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
//查找商家授权信息
ActivitySellerService.prototype.getSellerInfoByUserNick = function (userNick) {
return __awaiter(this, void 0, void 0, function () {
var res;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.activitysellerDao.find({
userNick: userNick,
})];
case 1:
res = _a.sent();
if (res && res[0]) {
return [2 /*return*/, res[0]];
}
return [2 /*return*/, false];
}
});
});
};
//更新商家授权信息
ActivitySellerService.prototype.updateSellerInfo = function (openId, sellerInfo) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
console.log(openId, sellerInfo, "openId, sellerInfo");
return [4 /*yield*/, this.activitysellerDao.update({
openId: openId,
}, {
$set: __assign(__assign({}, sellerInfo), { updateTime: Date.now() }),
})];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
return ActivitySellerService;
}());
//# sourceMappingURL=activityseller.service.js.map
\ No newline at end of file
{"version":3,"file":"activityseller.service.js","sourceRoot":"","sources":["../../src/service/activityseller.service.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAM,OAAO,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AACnC,IAAA,oBAAoB,GAAK,OAAO,CAAC,qBAAqB,CAAC,qBAAnC,CAAoC;AAEhE,MAAM,CAAC,OAAO;IACZ,+BAAY,OAA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ActivityTopService;
declare class ActivityTopService {
constructor(context: any);
activitySellerDao: any;
activityBaseDao: any;
context: any;
getAccessToken(activityId: any): Promise<{
session: any;
}>;
getAccessTokenByOpenId(): Promise<{
session: any;
}>;
getItemListByIds(activityId: any, itemIds: any): Promise<any>;
getPrizeByEname(activityId: any, ename: any): Promise<any>;
getVipUrlByActivity(activityId: any): Promise<any>;
getShopId(): Promise<any>;
getItemListByStatus(): Promise<any>;
getTemplateInstantiate(): Promise<any>;
pushOnlineInstance(instanceInfo: any): Promise<any>;
getSubRelationship(nick: any): Promise<any>;
updateMiniInstance(instanceInfo: any): Promise<any>;
}
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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
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;
};
var _a = require("../config/db_config"), ACTIVITY_SELLER_SAVE = _a.ACTIVITY_SELLER_SAVE, ACTIVITY_BASE_CONFIG = _a.ACTIVITY_BASE_CONFIG;
var _b = require("../config/seller_config"), getConsumerSeller = _b.getConsumerSeller, getSellerInfoByContext = _b.getSellerInfoByContext;
var _c = require("../utils/constants"), CODE_TYPES = _c.CODE_TYPES, GOODSINFO = _c.GOODSINFO, B_APP_NAME = _c.B_APP_NAME, TEMPLATE_INFO = _c.TEMPLATE_INFO, TBAPIS = _c.TBAPIS, APP_SUB_CODE = _c.APP_SUB_CODE;
var ResultsModel = require("../utils/results.model");
var MathRand = require("../utils/utils").MathRand;
var resultsModel = new ResultsModel();
var BaseDao = require("../dao/base.dao");
var ActivityTopService = /** @class */ (function () {
function ActivityTopService(context) {
this.activitySellerDao = new BaseDao(context, ACTIVITY_SELLER_SAVE);
this.activityBaseDao = new BaseDao(context, ACTIVITY_BASE_CONFIG);
this.context = context;
}
//获取商家授权session
ActivityTopService.prototype.getAccessToken = function (activityId) {
return __awaiter(this, void 0, void 0, function () {
var result, shopId, sellResult, accessToken;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.activityBaseDao.find({
_id: activityId,
})];
case 1:
result = _a.sent();
if (!result[0]) return [3 /*break*/, 3];
shopId = result[0].shopId;
return [4 /*yield*/, this.activitySellerDao.find({
shopId: shopId,
}, {
sort: {
createTime: 1,
},
})];
case 2:
sellResult = _a.sent();
console.log(sellResult, "sellResult");
if (sellResult[0]) {
accessToken = sellResult[0].accessToken;
return [2 /*return*/, {
session: accessToken,
}];
}
_a.label = 3;
case 3: return [2 /*return*/];
}
});
});
};
//通过openId去查找session
ActivityTopService.prototype.getAccessTokenByOpenId = function () {
return __awaiter(this, void 0, void 0, function () {
var openId, result;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
openId = this.context.openId;
return [4 /*yield*/, this.activitySellerDao.find({
openId: openId,
})];
case 1:
result = _a.sent();
return [2 /*return*/, { session: (result.length && result[0].accessToken) || this.context.accessToken }];
}
});
});
};
//淘宝top接口获取商品列表
ActivityTopService.prototype.getItemListByIds = function (activityId, itemIds) {
return __awaiter(this, void 0, void 0, function () {
var sellerConfig, businessSeller, result, itemsData, e_1;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!activityId) return [3 /*break*/, 2];
return [4 /*yield*/, this.getAccessToken(activityId)];
case 1:
businessSeller = _a.sent();
sellerConfig = getConsumerSeller(businessSeller);
return [3 /*break*/, 4];
case 2: return [4 /*yield*/, this.getAccessTokenByOpenId()];
case 3:
sellerConfig = _a.sent();
itemIds = this.context.data.itemIds;
_a.label = 4;
case 4:
console.log(sellerConfig, "sellerConfig");
_a.label = 5;
case 5:
_a.trys.push([5, 7, , 8]);
return [4 /*yield*/, TBAPIS.getItemListByItemIds(this.context, sellerConfig.session, itemIds, { fields: GOODSINFO })];
case 6:
result = _a.sent();
// let result = await this.context.cloud.topApi.invoke({
// api: "taobao.items.seller.list.get",
// data: {
// ...sellerConfig,
// fields: GOODSINFO,
// num_iids: itemIds,
// },
// });
// console.log(JSON.stringify(result), '获取商品通过ids')
if (result) {
itemsData = {
list: (result &&
result.items &&
result.items.item.reduce(function (s, v) {
return (s = __spreadArrays(s, [
{
itemId: v.num_iid,
name: v.title,
price: v.price,
detailUrl: v.detail_url,
picUrl: v.pic_url,
},
]));
}, [])) ||
[],
totalCount: result.items.item.length,
};
return [2 /*return*/, resultsModel.success(itemsData)];
}
return [2 /*return*/, resultsModel.error(CODE_TYPES.SYSTEM_ERROR, "获取商家ids列表失败")];
case 7:
e_1 = _a.sent();
console.log(e_1, "获取ids商品列表失败");
return [2 /*return*/, resultsModel.error(CODE_TYPES.SYSTEM_ERROR, "获取商家ids列表失败")];
case 8: return [2 /*return*/];
}
});
});
};
//淘宝top接口获取权益商品信息
ActivityTopService.prototype.getPrizeByEname = function (activityId, ename) {
return __awaiter(this, void 0, void 0, function () {
var sellerConfig, businessSeller, benefitData, result, data, e_2;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!activityId) return [3 /*break*/, 2];
return [4 /*yield*/, this.getAccessToken(activityId)];
case 1:
businessSeller = _a.sent();
sellerConfig = getConsumerSeller(businessSeller);
return [3 /*break*/, 4];
case 2: return [4 /*yield*/, this.getAccessTokenByOpenId()];
case 3:
sellerConfig = _a.sent();
ename = this.context.data.ename;
_a.label = 4;
case 4:
console.log(sellerConfig, "sellerConfig");
_a.label = 5;
case 5:
_a.trys.push([5, 7, , 8]);
return [4 /*yield*/, TBAPIS.getPrizeByEname(this.context, sellerConfig.session, ename, B_APP_NAME)];
case 6:
benefitData = _a.sent();
console.log(benefitData, benefitData.result, "benefitData.result.");
if (benefitData.result.success) {
result = benefitData.result;
data = result.datas &&
result.datas["oright_dto"].reduce(function (s, v) {
return (s = __spreadArrays(s, [
{
benefitName: v.benefit_name,
rightTypeId: v.right_type_id == 3 ? 1 : v.right_type_id,
startTime: new Date(v.start_date).getTime(),
endTime: new Date(v.end_date).getTime(),
amount: v.amount ? v.amount / 100 + "" : "",
},
]));
}, []);
console.log(JSON.stringify(result), "alibaba.benefit.query");
return [2 /*return*/, resultsModel.success(data)];
}
return [2 /*return*/, resultsModel.error(CODE_TYPES.SYSTEM_ERROR, "获取ename商品信息失败")];
case 7:
e_2 = _a.sent();
console.log(e_2, "权益获取失败");
return [2 /*return*/, resultsModel.error(CODE_TYPES.SYSTEM_ERROR, "获取ename商品信息失败")];
case 8: return [2 /*return*/];
}
});
});
};
//淘宝top接口获取店铺会员链接
ActivityTopService.prototype.getVipUrlByActivity = function (activityId) {
return __awaiter(this, void 0, void 0, function () {
var businessSeller, consumerSellerInfo, result, e_3;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.getAccessToken(activityId)];
case 1:
businessSeller = _a.sent();
consumerSellerInfo = getConsumerSeller(businessSeller);
_a.label = 2;
case 2:
_a.trys.push([2, 4, , 5]);
return [4 /*yield*/, this.context.cloud.topApi.invoke({
api: "taobao.crm.member.joinurl.get",
data: __assign(__assign({}, consumerSellerInfo), { extra_info: {
source: "isvapp",
activityId: activityId,
entrance: "duiba",
} }),
})];
case 3:
result = _a.sent();
if (result) {
return [2 /*return*/, resultsModel.success(result)];
}
console.log(JSON.stringify(result), "获取商家会员链接");
return [2 /*return*/, resultsModel.error(CODE_TYPES.SYSTEM_ERROR, "获取商家会员链接失败")];
case 4:
e_3 = _a.sent();
console.log(e_3, "获取商家会员链接失败");
return [2 /*return*/, resultsModel.error(CODE_TYPES.SYSTEM_ERROR, "获取商家会员链接失败")];
case 5: return [2 /*return*/];
}
});
});
};
//淘宝top接口获取店铺信息
ActivityTopService.prototype.getShopId = function () {
return __awaiter(this, void 0, void 0, function () {
var sellerInfo, result, e_4;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.getAccessTokenByOpenId()];
case 1:
sellerInfo = _a.sent();
console.log(sellerInfo, "getShopId sellerInfo");
_a.label = 2;
case 2:
_a.trys.push([2, 4, , 5]);
return [4 /*yield*/, TBAPIS.getShopInfo(this.context, {
session: sellerInfo.session,
fields: "sid,title,pic_path",
})];
case 3:
result = _a.sent();
console.log(result, "getShopId result");
if (result) {
return [2 /*return*/, resultsModel.success(result.shop)];
}
else {
return [2 /*return*/, resultsModel.error(CODE_TYPES.SYSTEM_ERROR, "获取淘宝top店铺信息失败")];
}
return [3 /*break*/, 5];
case 4:
e_4 = _a.sent();
console.log(e_4, "获取店铺信息失败");
return [2 /*return*/, resultsModel.error(CODE_TYPES.SYSTEM_ERROR, "获取淘宝top店铺信息失败")];
case 5: return [2 /*return*/];
}
});
});
};
ActivityTopService.prototype.getItemListByStatus = function () {
return __awaiter(this, void 0, void 0, function () {
var sellerConfig, _a, _b, approveStatus, _c, title, _d, pageNo, _e, pageSize, data, result, _f, items, total_results, itemsData, e_5;
return __generator(this, function (_g) {
switch (_g.label) {
case 0: return [4 /*yield*/, this.getAccessTokenByOpenId()];
case 1:
sellerConfig = _g.sent();
_a = this.context.data, _b = _a.approveStatus, approveStatus = _b === void 0 ? "onsale" : _b, _c = _a.title, title = _c === void 0 ? "" : _c, _d = _a.pageNo, pageNo = _d === void 0 ? 1 : _d, _e = _a.pageSize, pageSize = _e === void 0 ? 10 : _e;
data = __assign({ fields: GOODSINFO, page_no: pageNo, q: title, page_size: pageSize }, sellerConfig);
console.log(data, "data");
_g.label = 2;
case 2:
_g.trys.push([2, 7, , 8]);
if (!(approveStatus === "onsale")) return [3 /*break*/, 4];
return [4 /*yield*/, TBAPIS.getItemListOnSale(this.context, data)];
case 3:
_f = _g.sent();
return [3 /*break*/, 6];
case 4: return [4 /*yield*/, TBAPIS.getItemListInStock(this.context, data)];
case 5:
_f = _g.sent();
_g.label = 6;
case 6:
result = _f;
if (result) {
items = result.items, total_results = result.total_results;
itemsData = {
pageNo: pageNo,
pageSize: pageSize,
totalPages: Math.ceil(total_results / pageSize),
totalCount: total_results,
list: (items &&
items.item &&
items.item.reduce(function (s, v) {
return (s = __spreadArrays(s, [
{
itemId: v.num_iid,
name: v.title,
price: v.price,
approveStatus: v.approveStatus || approveStatus,
picUrl: v.pic_url,
},
]));
}, [])) ||
[],
};
return [2 /*return*/, resultsModel.success(itemsData)];
}
return [2 /*return*/, resultsModel.error(CODE_TYPES.SYSTEM_ERROR, "获取商家在售列表失败")];
case 7:
e_5 = _g.sent();
console.log(e_5, "获取商家在售列表失败");
return [2 /*return*/, resultsModel.error(CODE_TYPES.SYSTEM_ERROR, "获取商家在售列表失败")];
case 8: return [2 /*return*/];
}
});
});
};
ActivityTopService.prototype.getTemplateInstantiate = function () {
return __awaiter(this, void 0, void 0, function () {
var sellerConfig, data, result, e_6;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.getAccessTokenByOpenId()];
case 1:
sellerConfig = _a.sent();
data = __assign(__assign({ description: "此应用用于商家引导活动,商家可设置对应的奖品,在一定时间 内出奖,提升店铺用户活跃以及引导购买", ext_json: {
name: "online",
}, icon: "https://ossgw.alicdn.com/taobao-miniapp/img/0193eaa9cc037b568acd9ccfe68a8499.jpg", name: "店铺漂流" + MathRand() }, TEMPLATE_INFO), sellerConfig);
console.log("getTemplateInstantiateParams", data);
_a.label = 2;
case 2:
_a.trys.push([2, 4, , 5]);
return [4 /*yield*/, TBAPIS.getTemplateInstantiate(this.context, data)];
case 3:
result = _a.sent();
if (result) {
console.log(JSON.stringify(result), "getTemplateInstantiate");
return [2 /*return*/, result];
}
return [2 /*return*/, false];
case 4:
e_6 = _a.sent();
console.log(e_6, "获取getTemplateInstantiate失败");
return [2 /*return*/, false];
case 5: return [2 /*return*/];
}
});
});
};
//模板小程序上线
ActivityTopService.prototype.pushOnlineInstance = function (instanceInfo) {
return __awaiter(this, void 0, void 0, function () {
var sellerConfig, data, result, e_7;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.getAccessTokenByOpenId()];
case 1:
sellerConfig = _a.sent();
data = __assign(__assign(__assign({}, TEMPLATE_INFO), instanceInfo), sellerConfig);
console.log("pushOnlineInstanceParams", data);
_a.label = 2;
case 2:
_a.trys.push([2, 4, , 5]);
return [4 /*yield*/, TBAPIS.pushInstanceOnline(this.context, data)];
case 3:
result = _a.sent();
if (result) {
console.log(JSON.stringify(result), "pushOnlineInstance");
return [2 /*return*/, result];
}
return [2 /*return*/, false];
case 4:
e_7 = _a.sent();
console.log(e_7, "pushOnlineInstance失败");
return [2 /*return*/, false];
case 5: return [2 /*return*/];
}
});
});
};
ActivityTopService.prototype.getSubRelationship = function (nick) {
return __awaiter(this, void 0, void 0, function () {
var cloud, res;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
cloud = this.context.cloud;
return [4 /*yield*/, cloud.topApi.invoke({
api: "taobao.vas.subscribe.get",
data: {
article_code: APP_SUB_CODE,
nick: nick,
},
})];
case 1:
res = _a.sent();
if (res &&
res["article_user_subscribes"] &&
res["article_user_subscribes"]["article_user_subscribe"])
return [2 /*return*/, res["article_user_subscribes"]["article_user_subscribe"][0]];
return [2 /*return*/, false];
}
});
});
};
//模板小程序更新
ActivityTopService.prototype.updateMiniInstance = function (instanceInfo) {
return __awaiter(this, void 0, void 0, function () {
var sellerConfig, data, result, e_8;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.getAccessTokenByOpenId()];
case 1:
sellerConfig = _a.sent();
data = __assign(__assign(__assign({}, TEMPLATE_INFO), instanceInfo), sellerConfig);
_a.label = 2;
case 2:
_a.trys.push([2, 4, , 5]);
return [4 /*yield*/, TBAPIS.updateMiniInstance(this.context, data)];
case 3:
result = _a.sent();
if (result) {
console.log(JSON.stringify(result), "updateMiniInstance");
return [2 /*return*/, result];
}
return [2 /*return*/, false];
case 4:
e_8 = _a.sent();
console.log(e_8, "updateMiniInstance失败");
return [2 /*return*/, false];
case 5: return [2 /*return*/];
}
});
});
};
return ActivityTopService;
}());
module.exports = ActivityTopService;
//# sourceMappingURL=activitytop.service.js.map
\ No newline at end of file
{"version":3,"file":"activitytop.service.js","sourceRoot":"","sources":["../../src/service/activitytop.service.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAM,IAAA,KAGF,OAAO,CAAC,qBAAqB,CAAC,EAFhC,oBAAoB,0BAAA,EACpB,oBAAoB,0BACY,CAAC;AAC7B,IAAA,KAGF,OAAO,CAAC,yBAAyB,CAAC,EAFpC,iBAAiB,uBAAA,EACjB,sBAAsB,4BACc,CAAC;AACjC,IAAA,KAOF,OAAO,CAAC,oBAAoB,CAAC,EAN/B,UAAU,gBAAA,EACV,SAAS,eAAA,EACT,UAAU,gBAAA,EACV,aAAa,mBAAA,EACb,MAAM,YAAA,EACN,YAAY,kBACmB,CAAC;AAClC,IAAM,YAAY,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;AAC/C,IAAA,QAAQ,GAAK,OAAO,CAAC,gBAAgB,CAAC,SAA9B,CAA+B;AAC/C,IAAI,YAAY,GAAG,IAAI,YAAY,EAAE,CAAC;AACtC,IAAM,OAAO,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAC3C;IACE,4BAAY,OAAO;QACjB,IAAI,CAAC,iBAAiB,GAAG,IAAI,OAAO,CAAC,OAAO,EAAE,oBAAoB,CAAC,CAAC;QACpE,IAAI,CAAC,eAAe,GAAG,IAAI,OAAO,CAAC,OAAO,EAAE,oBAAoB,CAAC,CAAC;QAClE,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,eAAe;IACT,2CAAc,GAApB,UAAqB,UAAU;;;;;4BAChB,qBAAM,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC;4BAC3C,GAAG,EAAE,UAAU;yBAChB,CAAC,EAAA;;wBAFE,MAAM,GAAG,SAEX;6BACE,MAAM,CAAC,CAAC,CAAC,EAAT,wBAAS;wBACP,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AAkB,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,EAAA;;wBAA5D,MAAM,GAAG,SAAmD;wBAChE,IAAI,MAAM,EAAE;4BACV,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,oBAAoB,CAAC,CAAC;4BAC1D,sBAAO,MAAM,EAAC;yBACf;wBACD,sBAAO,KAAK,EAAC;;;wBAEb,OAAO,CAAC,GAAG,CAAC,GAAC,EAAE,sBAAsB,CAAC,CAAC;wBACvC,sBAAO,KAAK,EAAC;;;;;KAEhB;IACH,yBAAC;AAAD,CAAC,AA3WD,IA2WC;AAED,MAAM,CAAC,OAAO,GAAG,kBAAkB,CAAC"}
\ No newline at end of file
/**
* 奖励
*
* @format
*/
import UserService from './user.service';
export default class AwardsService extends UserService {
/** @format */
export default class AwardsService {
context: Context;
awardsdao: IBaseDao;
activityprizedao: IBaseDao;
constructor(context: Context);
reduceStock(_id: string): Promise<true | import("taobao-mini-sdk/lib/utils/codetypes").CodeType>;
/**
* 插入奖品记录
* @param {*} award
*/
addAward(award: any): Promise<any>;
/**
* 发放奖品
* @param {*} document
*/
sendAward(document: any): Promise<any>;
/**
* 我的奖品
* @param {*} param0
*/
getMyPrizeList({ openId, activityId }: {
openId: any;
activityId: any;
}): Promise<any>;
recieveObjectPrize(_id: any, { activityId, province, city, area, addressdetail, name, phone }: {
activityId: any;
province: any;
city: any;
area: any;
addressdetail: any;
name: any;
phone: any;
}): Promise<true | import("taobao-mini-sdk/lib/utils/codetypes").CodeType>;
recieveEnamePrize(_id: any, activityId: any): Promise<{}>;
/**
* 获取活动配置项奖品
* @param {*} _id
*/
getActivityPrizeById(_id: string): Promise<any>;
addWaitAwardsList(list: any): Promise<boolean>;
getAwardslistByActivityId(activityId: string): Promise<any>;
}
"use strict";
/**
* 奖励
*
* @format
*/
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
/** @format */
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
......@@ -65,297 +48,62 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
}
};
Object.defineProperty(exports, "__esModule", { value: true });
// 排行榜开奖记录
var sdk_1 = require("../sdk");
var user_service_1 = require("./user.service");
var constants_1 = require("../constants");
var db_1 = require("../db");
var utils_1 = require("../utils");
var AwardsService = /** @class */ (function (_super) {
__extends(AwardsService, _super);
var constants_1 = require("../constants");
var AwardsService = /** @class */ (function () {
function AwardsService(context) {
var _this = _super.call(this, context) || this;
_this.awardsdao = new sdk_1.BaseDao(context, db_1.AWARDS_DB_NAME);
_this.activityprizedao = new sdk_1.BaseDao(context, db_1.PRIZE_CONFIG_DB_NAME);
return _this;
this.awardsdao = new sdk_1.BaseDao(context, db_1.AWARDS_DB_NAME);
}
// 根据奖品Id扣库存
AwardsService.prototype.reduceStock = function (_id) {
// 添加排行榜待开奖列表
AwardsService.prototype.addWaitAwardsList = function (list) {
return __awaiter(this, void 0, void 0, function () {
var result, limitStock, stock, useStock, e_1;
var e_1;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.activityprizedao.findOne({ _id: _id })
// 奖品不存在
];
case 1:
result = _a.sent();
// 奖品不存在
if (!result) {
return [2 /*return*/, constants_1.CODE_TYPES.ERROR_NO_PRIZE];
}
limitStock = result.limitStock, stock = result.stock, useStock = result.useStock;
// 若不限制库存
if (limitStock === 0) {
case 0:
if (!list.length)
return [2 /*return*/, true];
}
// 若库存不足
if (useStock >= stock) {
return [2 /*return*/, constants_1.CODE_TYPES.ERROR_NO_STOCK];
}
_a.label = 2;
list = list.map(function (v) {
return __assign(__assign({}, v), { drawStatus: constants_1.DRAW_STATUS.WAITAWARD, message: '' });
});
_a.label = 1;
case 1:
_a.trys.push([1, 3, , 4]);
return [4 /*yield*/, this.awardsdao.insertMany(list)];
case 2:
_a.trys.push([2, 4, , 5]);
return [4 /*yield*/, this.activityprizedao.update({ _id: _id }, {
$set: {
useStock: useStock + 1
}
})];
case 3:
_a.sent();
return [2 /*return*/, true];
case 4:
case 3:
e_1 = _a.sent();
console.log("\u6263\u5E93\u5B58\u5931\u8D25\uFF1A", e_1);
return [2 /*return*/, constants_1.CODE_TYPES.SYSTEM_ERROR];
case 5: return [2 /*return*/];
console.log("\u6DFB\u52A0\u6392\u884C\u699C\u5F85\u5F00\u5956\u5217\u8868\u51FA\u9519\uFF1A" + e_1);
return [2 /*return*/, false];
case 4: return [2 /*return*/];
}
});
});
};
/**
* 插入奖品记录
* @param {*} award
*/
AwardsService.prototype.addAward = function (award) {
// 根据活动id查找中奖名单
AwardsService.prototype.getAwardslistByActivityId = function (activityId) {
return __awaiter(this, void 0, void 0, function () {
var e_2;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 2, , 3]);
return [4 /*yield*/, this.awardsdao.insertOne(__assign(__assign({}, award), { createTime: Date.now(), updateTime: Date.now() }))];
case 1: return [2 /*return*/, _a.sent()];
case 2:
e_2 = _a.sent();
console.log("\u63D2\u5165\u4E2D\u5956\u8BB0\u5F55\u9519\u8BEF:", e_2);
return [2 /*return*/, constants_1.CODE_TYPES.SYSTEM_ERROR];
case 3: return [2 /*return*/];
}
});
});
};
/**
* 发放奖品
* @param {*} document
*/
AwardsService.prototype.sendAward = function (document) {
return __awaiter(this, void 0, void 0, function () {
var session, result, _id, update;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, utils_1.getSellerSession(this.context)
// 发放淘宝权益
];
case 1:
session = (_a.sent()).session;
return [4 /*yield*/, utils_1.sendTBAward(this.context, session, document)];
case 2:
result = _a.sent();
if (result.code) {
return [2 /*return*/, result];
}
_id = document._id;
return [4 /*yield*/, this.awardsdao.update({ _id: _id }, {
$set: {
drawStatus: document.drawStatus,
remark: document.remark,
updateTime: Date.now()
}
})];
case 3:
update = _a.sent();
console.log("\u66F4\u65B0\u5956\u54C1\u72B6\u6001", update, document);
return [2 /*return*/, document];
}
});
});
};
/**
* 我的奖品
* @param {*} param0
*/
AwardsService.prototype.getMyPrizeList = function (_a) {
var openId = _a.openId, activityId = _a.activityId;
return __awaiter(this, void 0, void 0, function () {
var awardReceiveExpiredTime, myprizeList, currentTime_1;
return __generator(this, function (_b) {
switch (_b.label) {
case 0: return [4 /*yield*/, this.getBaseInfo(activityId)];
case 1:
awardReceiveExpiredTime = (_b.sent()).awardReceiveExpiredTime;
return [4 /*yield*/, this.awardsdao.find({ openId: openId, activityId: activityId }, {
if (!activityId)
return [2 /*return*/, false];
return [4 /*yield*/, this.awardsdao.find({ activityId: activityId }, {
sort: {
createTime: -1
}
})
// 若有过期时间,且已过期
];
case 2:
myprizeList = _b.sent();
// 若有过期时间,且已过期
if (awardReceiveExpiredTime) {
currentTime_1 = Date.now();
myprizeList.map(function (v) {
if (currentTime_1 > awardReceiveExpiredTime) {
if ([constants_1.DRAW_STATUS.WAITAWARD, constants_1.DRAW_STATUS.RETRY].includes(v.drawStatus)) {
v.drawStatus = constants_1.DRAW_STATUS.EXPIRED;
v.remark = "\u5956\u54C1\u5DF2\u8FC7\u671F";
}
}
v.expiredTime = awardReceiveExpiredTime;
});
}
return [2 /*return*/, myprizeList];
}
});
});
};
// 领取实物
AwardsService.prototype.recieveObjectPrize = function (_id, _a) {
var activityId = _a.activityId, province = _a.province, city = _a.city, area = _a.area, addressdetail = _a.addressdetail, name = _a.name, phone = _a.phone;
return __awaiter(this, void 0, void 0, function () {
var awardReceiveExpiredTime, award, result, e_3;
return __generator(this, function (_b) {
switch (_b.label) {
case 0: return [4 /*yield*/, this.getBaseInfo(activityId)];
case 1:
awardReceiveExpiredTime = (_b.sent()).awardReceiveExpiredTime;
if (awardReceiveExpiredTime && Date.now() > awardReceiveExpiredTime) {
return [2 /*return*/, constants_1.CODE_TYPES.ERROR_PRIZE_EXPIRED];
}
return [4 /*yield*/, this.awardsdao.findOne({ _id: _id })];
case 2:
award = _b.sent();
console.log("receiveObject-award", award);
// 奖品不存在
if (!award) {
return [2 /*return*/, constants_1.CODE_TYPES.ERROR_NO_PRIZE];
}
// 已领取
if (award.drawStatus === constants_1.DRAW_STATUS.SUCCESS) {
return [2 /*return*/, constants_1.CODE_TYPES.ERROR_RECEIVE_PRIZE];
}
// 不是实物,非法操作
if (award.type !== constants_1.PRIZE_TYPE.OBJECT) {
return [2 /*return*/, constants_1.CODE_TYPES.ERROR_FORBIDDEN_OPE];
}
_b.label = 3;
case 3:
_b.trys.push([3, 5, , 6]);
return [4 /*yield*/, this.awardsdao.update({ _id: _id }, {
$set: {
receiveName: name,
phone: phone,
drawStatus: constants_1.DRAW_STATUS.SUCCESS,
province: province,
city: city,
area: area,
addressdetail: addressdetail,
receiveTime: Date.now(),
updateTime: Date.now()
score: -1,
rankTime: -1
}
})];
case 4:
result = _b.sent();
return [2 /*return*/, true];
case 5:
e_3 = _b.sent();
console.log("\u9886\u53D6\u5B9E\u7269\u9519\u8BEF\uFF1A", e_3);
return [2 /*return*/, constants_1.CODE_TYPES.SYSTEM_ERROR];
case 6: return [2 /*return*/];
}
});
});
};
// 发放淘宝权益(奖品数据已插入到awards_info表,且状态drawStatus 为1或者6)
AwardsService.prototype.recieveEnamePrize = function (_id, activityId) {
return __awaiter(this, void 0, void 0, function () {
var awardReceiveExpiredTime, result, award, session;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.getBaseInfo(activityId)];
case 1:
awardReceiveExpiredTime = (_a.sent()).awardReceiveExpiredTime;
if (awardReceiveExpiredTime && Date.now() > awardReceiveExpiredTime) {
return [2 /*return*/, constants_1.CODE_TYPES.ERROR_PRIZE_EXPIRED];
}
result = {};
return [4 /*yield*/, this.awardsdao.findOne({ _id: _id })
// 奖品不存在
];
case 2:
award = _a.sent();
// 奖品不存在
if (!award) {
return [2 /*return*/, constants_1.CODE_TYPES.ERROR_NO_PRIZE];
}
// 已领取
if (award.drawStatus === constants_1.DRAW_STATUS.SUCCESS) {
return [2 /*return*/, constants_1.CODE_TYPES.ERROR_RECEIVE_PRIZE];
}
console.log("award.drawStatus", award.drawStatus);
// 状态不是1,6
if (![constants_1.DRAW_STATUS.WAITAWARD, constants_1.DRAW_STATUS.RETRY].includes(award.drawStatus)) {
return [2 /*return*/, constants_1.CODE_TYPES.ERROR_FORBIDDEN_OPE];
}
return [4 /*yield*/, utils_1.getSellerSession(this.context)
// 发放淘宝权益
];
case 3:
session = (_a.sent()).session;
return [4 /*yield*/, utils_1.sendTBAward(this.context, session, award)
// 更新
];
case 4:
// 发放淘宝权益
result = _a.sent();
// 更新
return [4 /*yield*/, this.awardsdao.update({ _id: _id }, {
$set: {
// @ts-ignore
drawStatus: result.drawStatus,
// @ts-ignore
remark: result.remark,
updateTime: Date.now()
}
})];
case 5:
// 更新
_a.sent();
return [2 /*return*/, result];
}
});
});
};
/**
* 获取活动配置项奖品
* @param {*} _id
*/
AwardsService.prototype.getActivityPrizeById = function (_id) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.activityprizedao.findOne({ _id: _id, deleteStatus: 1 /* NORMAL */ }, {
sort: {
index: 1
}
})];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
return AwardsService;
}(user_service_1.default));
}());
exports.default = AwardsService;
//# sourceMappingURL=awards.service.js.map
\ No newline at end of file
{"version":3,"file":"awards.service.js","sourceRoot":"","sources":["../../src/service/awards.service.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,8BAAgC;AAChC,+CAAwC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6BACF,CACF,EAAA;;wBAZD,KAAK;wBACL,SAWC,CAAA;wBACD,sBAAO,MAAM,EAAA;;;;KACd;IAED;;;OAGG;IACG,4CAAoB,GAA1B,UAA2B,GAAW;;;;4BAC7B,qBAAM,IAAI,CAAC,gBAAgB,CAAC,OAAO,CACxC,EAAE,GAAG,KAAA,EAAE,YAAY,gBAAwB,EAAE,EAC7C;4BACE,IAAI,EAAE;gCACJ,KAAK,EAAE,CAAC;6BACT;yBACF,CACF,EAAA;4BAPD,sBAAO,SAON,EAAA;;;;KACF;IACH,oBAAC;AAAD,CAAC,AAzND,CAA2C,sBAAW,GAyNrD"}
\ No newline at end of file
{"version":3,"file":"awards.service.js","sourceRoot":"","sources":["../../src/service/awards.service.ts"],"names":[],"mappings":";AAAA,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEd,UAAU;AAEV,8BAAgC;AAChC,4BAAsC;AAEtC,0CAA0C;AAC1C;IAGE,uBAAY,OAAgB;QAC1B,IAAI,CAAC,SAAS,GAAG,IAAI,aAAO,CAAC,OAAO,EAAE,mBAAc,CAAC,CAAA;IACvD,CAAC;IAED,aAAa;IACP,yCAAiB,GAAvB,UAAwB,IAAI;;;;;;wBAC1B,IAAI,CAAC,IAAI,CAAC,MAAM;4BAAE,sBAAO,IAAI,EAAA;wBAC7B,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,UAAA,CAAC;4BACf,6BACK,CAAC,KACJ,UAAU,EAAE,uBAAW,CAAC,SAAS,EACjC,OAAO,EAAE,EAAE,IACZ;wBACH,CAAC,CAAC,CAAA;;;;wBAEA,qBAAM,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,EAAA;;wBAArC,SAAqC,CAAA;wBACrC,sBAAO,IAAI,EAAA;;;wBAEX,OAAO,CAAC,GAAG,CAAC,mFAAgB,GAAG,CAAC,CAAA;wBAChC,sBAAO,KAAK,EAAA;;;;;KAEf;IAED,eAAe;IACT,iDAAyB,GAA/B,UAAgC,UAAkB;;;;;wBAChD,IAAI,CAAC,UAAU;4BAAE,sBAAO,KAAK,EAAA;wBACtB,qBAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CAC9B,EAAE,UAAU,YAAA,EAAE,EACd;gCACE,IAAI,EAAE;oCACJ,KAAK,EAAE,CAAC,CAAC;oCACT,QAAQ,EAAE,CAAC,CAAC;iCACb;6BACF,CACF,EAAA;4BARD,sBAAO,SAQN,EAAA;;;;KACF;IACH,oBAAC;AAAD,CAAC,AAvCD,IAuCC"}
\ No newline at end of file
/** @format */
export { default as BaseService } from './base.service';
export { default as ActivityconfigService } from './activityconfig.service';
export { default as TaobaoTopService } from './taobaoTop.service';
export { default as SellerService } from './seller.service';
export { default as InstanceService } from './instance.service';
export { default as AwardsService } from './awards.service';
"use strict";
/** @format */
Object.defineProperty(exports, "__esModule", { value: true });
var base_service_1 = require("./base.service");
Object.defineProperty(exports, "BaseService", { enumerable: true, get: function () { return base_service_1.default; } });
var activityconfig_service_1 = require("./activityconfig.service");
Object.defineProperty(exports, "ActivityconfigService", { enumerable: true, get: function () { return activityconfig_service_1.default; } });
var taobaoTop_service_1 = require("./taobaoTop.service");
Object.defineProperty(exports, "TaobaoTopService", { enumerable: true, get: function () { return taobaoTop_service_1.default; } });
var seller_service_1 = require("./seller.service");
Object.defineProperty(exports, "SellerService", { enumerable: true, get: function () { return seller_service_1.default; } });
var instance_service_1 = require("./instance.service");
Object.defineProperty(exports, "InstanceService", { enumerable: true, get: function () { return instance_service_1.default; } });
var awards_service_1 = require("./awards.service");
Object.defineProperty(exports, "AwardsService", { enumerable: true, get: function () { return awards_service_1.default; } });
//# sourceMappingURL=index.js.map
\ No newline at end of file
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/service/index.ts"],"names":[],"mappings":";AAAA,cAAc;;AAEd,+CAAuD;AAA9C,2GAAA,OAAO,OAAe"}
\ No newline at end of file
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/service/index.ts"],"names":[],"mappings":";AAAA,cAAc;;AAEd,mEAA2E;AAAlE,+HAAA,OAAO,OAAyB;AACzC,yDAAiE;AAAxD,qHAAA,OAAO,OAAoB;AACpC,mDAA2D;AAAlD,+GAAA,OAAO,OAAiB;AACjC,uDAA+D;AAAtD,mHAAA,OAAO,OAAmB;AACnC,mDAA2D;AAAlD,+GAAA,OAAO,OAAiB"}
\ No newline at end of file
/** @format */
export default class InstanceService {
activityinstanceDao: IBaseDao;
context: Context;
constructor(context: Context);
saveInstanceInfo(instanceInfo: any): Promise<any>;
findInstanceInfo(openId: string): Promise<any>;
updateInstanceInfo(openId: string, updateinfo: any): Promise<any>;
getMiniAppInstanceInfoByNick(userNick: string): Promise<any>;
}
"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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
var sdk_1 = require("../sdk");
var db_1 = require("../db");
var InstanceService = /** @class */ (function () {
function InstanceService(context) {
this.activityinstanceDao = new sdk_1.BaseDao(context, db_1.ACTIVITY_INSTANCE);
}
//保存商家授权信息
InstanceService.prototype.saveInstanceInfo = function (instanceInfo) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.activityinstanceDao.insertOne(__assign(__assign({}, instanceInfo), { updateTime: Date.now(), createTime: Date.now() }))];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
//查找商家授权信息
InstanceService.prototype.findInstanceInfo = function (openId) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.activityinstanceDao.find({ openId: openId })];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
//更新商家授权信息
InstanceService.prototype.updateInstanceInfo = function (openId, updateinfo) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.activityinstanceDao.update({ openId: openId }, {
$set: __assign(__assign({}, updateinfo), { updateTime: Date.now() })
})];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
InstanceService.prototype.getMiniAppInstanceInfoByNick = function (userNick) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.activityinstanceDao.find({ userNick: userNick })];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
return InstanceService;
}());
exports.default = InstanceService;
//# sourceMappingURL=instance.service.js.map
\ No newline at end of file
{"version":3,"file":"instance.service.js","sourceRoot":"","sources":["../../src/service/instance.service.ts"],"names":[],"mappings":";AAAA,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEd,8BAAgC;AAChC,4BAAyC;AAEzC;IAGE,yBAAY,OAAgB;QAC1B,IAAI,CAAC,mBAAmB,GAAG,IAAI,aAAO,CAAC,OAAO,EAAE,sBAAiB,CAAC,CAAA;IACpE,CAAC;IAED,UAAU;IACJ,0CAAgB,GAAtB,UAAuB,YAAY;;;;4BAC1B,qBAAM,IAAI,CAAC,mBAAmB,CAAC,SAAS,uBAC1C,YAAY,KACf,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE,EACtB,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE,IACtB,EAAA;4BAJF,sBAAO,SAIL,EAAA;;;;KACH;IAED,UAAU;IACJ,0CAAgB,GAAtB,UAAuB,MAAc;;;;4BAC5B,qBAAM,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,EAAE,MAAM,QAAA,EAAE,CAAC,EAAA;4BAAtD,sBAAO,SAA+C,EAAA;;;;KACvD;IAED,UAAU;IACJ,4CAAkB,GAAxB,UAAyB,MAAc,EAAE,UAAU;;;;4BAC1C,qBAAM,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAC1C,EAAE,MAAM,QAAA,EAAE,EACV;4BACE,IAAI,wBACC,UAAU,KACb,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE,GACvB;yBACF,CACF,EAAA;4BARD,sBAAO,SAQN,EAAA;;;;KACF;IAEK,sDAA4B,GAAlC,UAAmC,QAAgB;;;;4BAC1C,qBAAM,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,EAAE,QAAQ,UAAA,EAAE,CAAC,EAAA;4BAAxD,sBAAO,SAAiD,EAAA;;;;KACzD;IACH,sBAAC;AAAD,CAAC,AArCD,IAqCC"}
\ No newline at end of file
export = RankopenprizeService;
declare class RankopenprizeService {
constructor(context: any);
rankopenprizeDao: any;
addWaitAwardsList(list: any): Promise<boolean>;
getAwardslistByActivityId(activityId: any): Promise<any>;
}
// 排行榜开奖记录
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
var BaseDao = require("../dao/base.dao");
var DRAW_STATUS = require("../utils/constants").DRAW_STATUS;
var USER_PRIZE = require("../config/db_config").USER_PRIZE;
var DBName = USER_PRIZE;
var RankopenprizeService = /** @class */ (function () {
function RankopenprizeService(context) {
this.rankopenprizeDao = new BaseDao(context, DBName);
}
// 添加排行榜待开奖列表
RankopenprizeService.prototype.addWaitAwardsList = function (list) {
return __awaiter(this, void 0, void 0, function () {
var e_1;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!list.length) {
return [2 /*return*/, true];
}
list.map(function (v) {
(v.drawStatus = DRAW_STATUS.WAITAWARD), (v.message = "");
});
_a.label = 1;
case 1:
_a.trys.push([1, 3, , 4]);
return [4 /*yield*/, this.rankopenprizeDao.insertMany(list)];
case 2:
_a.sent();
return [2 /*return*/, true];
case 3:
e_1 = _a.sent();
console.log("\u6DFB\u52A0\u6392\u884C\u699C\u5F85\u5F00\u5956\u5217\u8868\u51FA\u9519\uFF1A" + e_1);
return [2 /*return*/, false];
case 4: return [2 /*return*/];
}
});
});
};
// 根据活动id查找中奖名单
RankopenprizeService.prototype.getAwardslistByActivityId = function (activityId) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!activityId) {
return [2 /*return*/, false];
}
return [4 /*yield*/, this.rankopenprizeDao.find({
activityId: activityId,
}, {
sort: {
score: -1,
rankTime: -1,
},
})];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
return RankopenprizeService;
}());
module.exports = RankopenprizeService;
//# sourceMappingURL=rankopenprize.service.js.map
\ No newline at end of file
{"version":3,"file":"rankopenprize.service.js","sourceRoot":"","sources":["../../src/service/rankopenprize.service.js"],"names":[],"mappings":"AAAA,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEV,IAAM,OAAO,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AACnC,IAAA,WAAW,GAAK,OAAO,CAAC,oBAAoB,CAAC,YAAlC,CAAmC;AAE9C,IAAA,UAAU,GAAK,OAAO,CAAC,qBAAqB,CAAC,WAAnC,CAAoC;AACtD,IAAM,MAAM,GAAG,UAAU,CAAC;AAC1B;IACE,8BAAY,OAAO;QACjB,IAAI,CAAC,gBAAgB,GAAG,IAAI,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACvD,CAAC;IAED,aAAa;IACP,gDAAiB,GAAvB,UAAwB,IAAI;;;;;;wBAC1B,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;4BAChB,sBAAO,IAAI,EAAC;yBACb;wBACD,IAAI,CAAC,GAAG,CAAC,UAAC,CAAC;4BACT,CAAC,CAAC,CAAC,UAAU,GAAG,WAAW,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,GAAG,EAAE,CAAC,CAAC;wBAC3D,CAAC,CAAC,CAAC;;;;wBAED,qBAAM,IAAI,CAAC,gBAAgB,CAAC,UAAU,CAAC,IAAI,CAAC,EAAA;;wBAA5C,SAA4C,CAAC;wBAC7C,sBAAO,IAAI,EAAC;;;wBAEZ,OAAO,CAAC,GAAG,CAAC,mFAAgB,GAAG,CAAC,CAAC;wBACjC,sBAAO,KAAK,EAAC;;;;;KAEhB;IAED,eAAe;IACT,wDAAyB,GAA/B,UAAgC,UAAU;;;;;wBACxC,IAAI,CAAC,UAAU,EAAE;4BACf,sBAAO,KAAK,EAAC;yBACd;wBACM,qBAAM,IAAI,CAAC,gBAAgB,CAAC,IAAI,CACrC;gCACE,UAAU,EAAE,UAAU;6BACvB,EACD;gCACE,IAAI,EAAE;oCACJ,KAAK,EAAE,CAAC,CAAC;oCACT,QAAQ,EAAE,CAAC,CAAC;iCACb;6BACF,CACF,EAAA;4BAVD,sBAAO,SAUN,EAAC;;;;KACH;IACH,2BAAC;AAAD,CAAC,AAvCD,IAuCC;AAED,MAAM,CAAC,OAAO,GAAG,oBAAoB,CAAC"}
\ No newline at end of file
/** @format */
export default class ActivitySellerService {
context: Context;
sellerdao: IBaseDao;
constructor(context: Context);
saveSellerInfo(sellerInfo: ISellerSaveInfo): Promise<any>;
findSellerInfo(openId: string): Promise<any>;
getSellerInfoByUserNick(userNick: string): Promise<any>;
updateSellerInfo(openId: string, sellerInfo: object): Promise<any>;
}
"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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
var sdk_1 = require("../sdk");
var db_1 = require("../db");
// import { DELETE_STATUS, OPEN_PRIZE_STATUS } from '../constants'
var ActivitySellerService = /** @class */ (function () {
function ActivitySellerService(context) {
this.sellerdao = new sdk_1.BaseDao(context, db_1.SELLER_INFO_DB_NAME);
}
//保存商家授权信息
ActivitySellerService.prototype.saveSellerInfo = function (sellerInfo) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.sellerdao.insertOne(__assign(__assign({}, sellerInfo), { updateTime: Date.now(), createTime: Date.now() }))];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
//查找商家授权信息
ActivitySellerService.prototype.findSellerInfo = function (openId) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.sellerdao.findOne({ openId: openId })];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
//查找商家授权信息
ActivitySellerService.prototype.getSellerInfoByUserNick = function (userNick) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.sellerdao.findOne({ userNick: userNick })];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
//更新商家授权信息
ActivitySellerService.prototype.updateSellerInfo = function (openId, sellerInfo) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.sellerdao.update({ openId: openId }, {
$set: __assign(__assign({}, sellerInfo), { updateTime: Date.now() })
})];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
return ActivitySellerService;
}());
exports.default = ActivitySellerService;
//# sourceMappingURL=seller.service.js.map
\ No newline at end of file
{"version":3,"file":"seller.service.js","sourceRoot":"","sources":["../../src/service/seller.service.ts"],"names":[],"mappings":";AAAA,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEd,8BAAgC;AAChC,4BAA2C;AAE3C,kEAAkE;AAClE;IAGE,+BAAY,OAAgB;QAC1B,IAAI,CAAC,SAAS,GAAG,IAAI,aAAO,CAAC,OAAO,EAAE,wBAAmB,CAAC,CAAA;IAC5D,CAAC;IAED,UAAU;IACJ,8CAAc,GAApB,UAAqB,UAA2B;;;;4BACvC,qBAAM,IAAI,CAAC,SAAS,CAAC,SAAS,uBAChC,UAAU,KACb,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE,EACtB,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE,IACtB,EAAA;4BAJF,sBAAO,SAIL,EAAA;;;;KACH;IAED,UAAU;IACJ,8CAAc,GAApB,UAAqB,MAAc;;;;4BAC1B,qBAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,MAAM,QAAA,EAAE,CAAC,EAAA;4BAA/C,sBAAO,SAAwC,EAAA;;;;KAChD;IAED,UAAU;IACJ,uDAAuB,GAA7B,UAA8B,QAAgB;;;;4BACrC,qBAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,QAAQ,UAAA,EAAE,CAAC,EAAA;4BAAjD,sBAAO,SAA0C,EAAA;;;;KAClD;IAED,UAAU;IACJ,gDAAgB,GAAtB,UAAuB,MAAc,EAAE,UAAkB;;;;4BAChD,qBAAM,IAAI,CAAC,SAAS,CAAC,MAAM,CAChC,EAAE,MAAM,QAAA,EAAE,EACV;4BACE,IAAI,wBAAO,UAAU,KAAE,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE,GAAE;yBAChD,CACF,EAAA;4BALD,sBAAO,SAKN,EAAA;;;;KACF;IACH,4BAAC;AAAD,CAAC,AAnCD,IAmCC"}
\ No newline at end of file
/** @format */
export default class ActivityTopService {
activitySellerDao: IBaseDao;
activityBaseDao: IBaseDao;
context: Context;
constructor(context: Context);
getAccessTokenByShopId(activityId: string): Promise<{
session?: undefined;
} | {
session: any;
}>;
getAccessTokenByOpenId(): Promise<{
session: any;
}>;
getItemListByIds(itemIds: string, seesion: string): Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result>;
getPrizeByEname(session: string, ename: string): Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result>;
getShopId(): Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result>;
getItemListByStatus(session: string, { approveStatus, title, pageNo, pageSize }: {
approveStatus?: string;
title?: string;
pageNo?: number;
pageSize?: number;
}): Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result>;
getTemplateInstantiate(): Promise<any>;
pushOnlineInstance(instanceInfo: {
app_id: any;
app_version: any;
}): Promise<any>;
getSubRelationship(nick: string): Promise<any>;
updateMiniInstance(instanceInfo: {
clients: any;
app_id: any;
template_id: any;
ext_json: {
name: string;
};
template_version: string;
}): Promise<any>;
}
"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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
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 sdk_1 = require("../sdk");
var db_1 = require("../db");
var constants_1 = require("../constants");
var utils_1 = require("../utils");
var ActivityTopService = /** @class */ (function () {
function ActivityTopService(context) {
this.activitySellerDao = new sdk_1.BaseDao(context, db_1.SELLER_INFO_DB_NAME);
this.activityBaseDao = new sdk_1.BaseDao(context, db_1.ACTIVITY_CONFIG_DB_NAME);
this.context = context;
}
//获取商家授权session
ActivityTopService.prototype.getAccessTokenByShopId = function (activityId) {
return __awaiter(this, void 0, void 0, function () {
var result, shopId, sellResult;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.activityBaseDao.findOne({ _id: activityId })];
case 1:
result = _a.sent();
if (!result)
return [2 /*return*/, {}];
shopId = (result || {}).shopId;
return [4 /*yield*/, this.activitySellerDao.findOne({ shopId: shopId }, { sort: { createTime: 1 } })];
case 2:
sellResult = (_a.sent()).sellResult;
console.log(sellResult, 'sellResult');
return [2 /*return*/, { session: sellResult === null || sellResult === void 0 ? void 0 : sellResult.accessToken }];
}
});
});
};
//通过openId去查找session
ActivityTopService.prototype.getAccessTokenByOpenId = function () {
return __awaiter(this, void 0, void 0, function () {
var openId, result;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
openId = this.context.openId;
return [4 /*yield*/, this.activitySellerDao.findOne({ openId: openId })];
case 1:
result = _a.sent();
return [2 /*return*/, { session: (result === null || result === void 0 ? void 0 : result.accessToken) || this.context.accessToken }];
}
});
});
};
//淘宝top接口获取商品列表
ActivityTopService.prototype.getItemListByIds = function (itemIds, seesion) {
return __awaiter(this, void 0, void 0, function () {
var result, itemsData, e_1;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 2, , 3]);
return [4 /*yield*/, sdk_1.TBAPIS.getItemListByItemIds(this.context, seesion, itemIds, { fields: constants_1.GOODSINFO })];
case 1:
result = _a.sent();
if (result) {
itemsData = {
list: (result &&
result.items &&
result.items.item.reduce(function (s, v) {
return (s = __spreadArrays(s, [
{
itemId: v.num_iid,
name: v.title,
price: v.price,
detailUrl: v.detail_url,
picUrl: v.pic_url
}
]));
}, [])) ||
[],
totalCount: result.items.item.length
};
return [2 /*return*/, sdk_1.resultsModel.success(itemsData)];
}
return [2 /*return*/, sdk_1.resultsModel.error(constants_1.CODE_TYPES.SYSTEM_ERROR, '获取商家ids列表失败')];
case 2:
e_1 = _a.sent();
console.log(e_1, '获取ids商品列表失败');
return [2 /*return*/, sdk_1.resultsModel.error(constants_1.CODE_TYPES.SYSTEM_ERROR, '获取商家ids列表失败')];
case 3: return [2 /*return*/];
}
});
});
};
//淘宝top接口获取权益商品信息
ActivityTopService.prototype.getPrizeByEname = function (session, ename) {
var _a, _b;
return __awaiter(this, void 0, void 0, function () {
var benefitData, result, data;
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
// sellerConfig = await this.getAccessTokenByOpenId()
// ename = this.context.data.ename
console.log(session, 'session');
return [4 /*yield*/, sdk_1.TBAPIS.getPrizeByEname(this.context, session, ename, constants_1.B_APP_NAME)];
case 1:
benefitData = _c.sent();
console.log(benefitData, benefitData.result, 'benefitData.result.');
if ((_a = benefitData === null || benefitData === void 0 ? void 0 : benefitData.result) === null || _a === void 0 ? void 0 : _a.success) {
result = benefitData.result;
data = (_b = result === null || result === void 0 ? void 0 : result.datas) === null || _b === void 0 ? void 0 : _b['oright_dto'].reduce(function (s, v) {
return (s = __spreadArrays(s, [
{
benefitName: v.benefit_name,
rightTypeId: v.right_type_id == 3 ? 1 : v.right_type_id,
startTime: new Date(v.start_date).getTime(),
endTime: new Date(v.end_date).getTime(),
amount: v.amount ? v.amount / 100 + '' : ''
}
]));
}, []);
console.log(JSON.stringify(result), 'alibaba.benefit.query');
return [2 /*return*/, sdk_1.resultsModel.success(data)];
}
return [2 /*return*/, sdk_1.resultsModel.error(constants_1.CODE_TYPES.SYSTEM_ERROR, '获取ename商品信息失败')];
}
});
});
};
//淘宝top接口获取店铺信息
ActivityTopService.prototype.getShopId = function () {
return __awaiter(this, void 0, void 0, function () {
var sellerInfo, result, e_2;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.getAccessTokenByOpenId()];
case 1:
sellerInfo = _a.sent();
console.log(sellerInfo, 'getShopId sellerInfo');
_a.label = 2;
case 2:
_a.trys.push([2, 4, , 5]);
return [4 /*yield*/, sdk_1.TBAPIS.getShopInfo(this.context, {
session: sellerInfo.session,
fields: 'sid,title,pic_path'
})];
case 3:
result = _a.sent();
console.log(result, 'getShopId result');
if (result) {
return [2 /*return*/, sdk_1.resultsModel.success(result.shop)];
}
else {
return [2 /*return*/, sdk_1.resultsModel.error(constants_1.CODE_TYPES.SYSTEM_ERROR, '获取淘宝top店铺信息失败')];
}
return [3 /*break*/, 5];
case 4:
e_2 = _a.sent();
console.log(e_2, '获取店铺信息失败');
return [2 /*return*/, sdk_1.resultsModel.error(constants_1.CODE_TYPES.SYSTEM_ERROR, '获取淘宝top店铺信息失败')];
case 5: return [2 /*return*/];
}
});
});
};
ActivityTopService.prototype.getItemListByStatus = function (session, _a) {
var _b;
var _c = _a.approveStatus, approveStatus = _c === void 0 ? 'onsale' : _c, _d = _a.title, title = _d === void 0 ? '' : _d, _e = _a.pageNo, pageNo = _e === void 0 ? 1 : _e, _f = _a.pageSize, pageSize = _f === void 0 ? 10 : _f;
return __awaiter(this, void 0, void 0, function () {
var data, result, _g, items, total_results, itemsData;
return __generator(this, function (_h) {
switch (_h.label) {
case 0:
data = { fields: constants_1.GOODSINFO, pageNo: pageNo, q: title, title: title, pageSize: pageSize, session: session };
console.log(data, 'data');
if (!(approveStatus === 'onsale')) return [3 /*break*/, 2];
return [4 /*yield*/, sdk_1.TBAPIS.getItemListOnSale(this.context, data)];
case 1:
_g = _h.sent();
return [3 /*break*/, 4];
case 2: return [4 /*yield*/, sdk_1.TBAPIS.getItemListInStock(this.context, data)];
case 3:
_g = _h.sent();
_h.label = 4;
case 4:
result = _g;
if (!result)
return [2 /*return*/, sdk_1.resultsModel.error(constants_1.CODE_TYPES.SYSTEM_ERROR, '获取商家在售列表失败')];
items = result.items, total_results = result.total_results;
itemsData = {
pageNo: pageNo,
pageSize: pageSize,
totalPages: Math.ceil(total_results / pageSize),
totalCount: total_results,
list: ((_b = items === null || items === void 0 ? void 0 : items.item) === null || _b === void 0 ? void 0 : _b.reduce(function (s, v) {
return (s = __spreadArrays(s, [
{
itemId: v.num_iid,
name: v.title,
price: v.price,
approveStatus: v.approveStatus || approveStatus,
picUrl: v.pic_url
}
]));
}, [])) || []
};
return [2 /*return*/, sdk_1.resultsModel.success(itemsData)];
}
});
});
};
ActivityTopService.prototype.getTemplateInstantiate = function () {
return __awaiter(this, void 0, void 0, function () {
var sellerConfig, data, result, e_3;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.getAccessTokenByOpenId()];
case 1:
sellerConfig = _a.sent();
data = __assign(__assign({ description: '此应用用于商家引导活动,商家可设置对应的奖品,在一定时间 内出奖,提升店铺用户活跃以及引导购买', ext_json: {
name: 'online'
}, icon: 'https://ossgw.alicdn.com/taobao-miniapp/img/0193eaa9cc037b568acd9ccfe68a8499.jpg', name: '店铺漂流' + utils_1.MathRand() }, constants_1.TEMPLATE_INFO), sellerConfig);
console.log('getTemplateInstantiateParams', data);
_a.label = 2;
case 2:
_a.trys.push([2, 4, , 5]);
return [4 /*yield*/, sdk_1.TBAPIS.getTemplateInstantiate(this.context, data)];
case 3:
result = _a.sent();
if (result) {
console.log(JSON.stringify(result), 'getTemplateInstantiate');
return [2 /*return*/, result];
}
return [2 /*return*/, false];
case 4:
e_3 = _a.sent();
console.log(e_3, '获取getTemplateInstantiate失败');
return [2 /*return*/, false];
case 5: return [2 /*return*/];
}
});
});
};
//模板小程序上线
ActivityTopService.prototype.pushOnlineInstance = function (instanceInfo) {
return __awaiter(this, void 0, void 0, function () {
var sellerConfig, data, result, e_4;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.getAccessTokenByOpenId()];
case 1:
sellerConfig = _a.sent();
data = __assign(__assign(__assign({}, constants_1.TEMPLATE_INFO), instanceInfo), sellerConfig);
console.log('pushOnlineInstanceParams', data);
_a.label = 2;
case 2:
_a.trys.push([2, 4, , 5]);
return [4 /*yield*/, sdk_1.TBAPIS.pushInstanceOnline(this.context, data)];
case 3:
result = _a.sent();
if (result) {
console.log(JSON.stringify(result), 'pushOnlineInstance');
return [2 /*return*/, result];
}
return [2 /*return*/, false];
case 4:
e_4 = _a.sent();
console.log(e_4, 'pushOnlineInstance失败');
return [2 /*return*/, false];
case 5: return [2 /*return*/];
}
});
});
};
ActivityTopService.prototype.getSubRelationship = function (nick) {
return __awaiter(this, void 0, void 0, function () {
var cloud, res;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
cloud = this.context.cloud;
return [4 /*yield*/, cloud.topApi.invoke({
api: 'taobao.vas.subscribe.get',
data: {
article_code: constants_1.APP_SUB_CODE,
nick: nick
}
})];
case 1:
res = _a.sent();
if (res && res['article_user_subscribes'] && res['article_user_subscribes']['article_user_subscribe'])
return [2 /*return*/, res['article_user_subscribes']['article_user_subscribe'][0]];
return [2 /*return*/, false];
}
});
});
};
//模板小程序更新
ActivityTopService.prototype.updateMiniInstance = function (instanceInfo) {
return __awaiter(this, void 0, void 0, function () {
var sellerConfig, data, result, e_5;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.getAccessTokenByOpenId()];
case 1:
sellerConfig = _a.sent();
data = __assign(__assign(__assign({}, constants_1.TEMPLATE_INFO), instanceInfo), sellerConfig);
_a.label = 2;
case 2:
_a.trys.push([2, 4, , 5]);
return [4 /*yield*/, sdk_1.TBAPIS.updateMiniInstance(this.context, data)];
case 3:
result = _a.sent();
if (result) {
console.log(JSON.stringify(result), 'updateMiniInstance');
return [2 /*return*/, result];
}
return [2 /*return*/, false];
case 4:
e_5 = _a.sent();
console.log(e_5, 'updateMiniInstance失败');
return [2 /*return*/, false];
case 5: return [2 /*return*/];
}
});
});
};
return ActivityTopService;
}());
exports.default = ActivityTopService;
//# sourceMappingURL=taobaoTop.service.js.map
\ No newline at end of file
{"version":3,"file":"taobaoTop.service.js","sourceRoot":"","sources":["../../src/service/taobaoTop.service.ts"],"names":[],"mappings":";AAAA,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEd,8BAAsD;AACtD,4BAAoE;AAEpE,0CAQqB;AACrB,kCAAsD;AAEtD;IAIE,4BAAY,OAAgB;QAC1B,IAAI,CAAC,iBAAiB,GAAG,IAAI,aAAO,CAAC,OAAO,EAAE,wBAAmB,CAAC,CAAA;QAClE,IAAI,CAAC,eAAe,GAAG,IAAI,aAAO,CAAC,OAAO,EAAE,4BAAuB,CAAC,CAAA;QACpE,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IACxB,CAAC;IAED,eAAe;IACT,mDAAsB,GAA5B,UAA6B,UAAkB;;;;;4BAChC,qBAAM,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,UAAU,EAAE,CAAC,EAAA;;wBAAhE,MAAM,GAAG,SAAuD;wBAEpE,IAAI,CAAC,MAAM;4BAAE,sBAAO,EAAE,EAAA;wBACd,MAAM,GAAK,CAAA,MAAM,IAAI,EAAE,CAAA,OAAjB,CAAiB;wBACV,qBAAM,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC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E,sBAAO,KAAK,EAAA;;;;KACb;IAED,SAAS;IACH,+CAAkB,GAAxB,UAAyB,YAMxB;;;;;4BACoB,qBAAM,IAAI,CAAC,sBAAsB,EAAE,EAAA;;wBAAlD,YAAY,GAAG,SAAmC;wBAClD,IAAI,kCACH,yBAAa,GACb,YAAY,GACZ,YAAY,CAChB,CAAA;;;;wBAEc,qBAAM,YAAM,CAAC,kBAAkB,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,EAAA;;wBAA5D,MAAM,GAAG,SAAmD;wBAChE,IAAI,MAAM,EAAE;4BACV,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,oBAAoB,CAAC,CAAA;4BACzD,sBAAO,MAAM,EAAA;yBACd;wBACD,sBAAO,KAAK,EAAA;;;wBAEZ,OAAO,CAAC,GAAG,CAAC,GAAC,EAAE,sBAAsB,CAAC,CAAA;wBACtC,sBAAO,KAAK,EAAA;;;;;KAEf;IACH,yBAAC;AAAD,CAAC,AA9PD,IA8PC"}
\ No newline at end of file
export declare const getConsumerSeller: ({ accessToken, openId }: {
accessToken: any;
openId: any;
}) => {
open_id: any;
session: any;
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getConsumerSeller = void 0;
exports.getConsumerSeller = function (_a) {
var accessToken = _a.accessToken, openId = _a.openId;
return {
// timestamp: formatTime(new Date(), "yyyy-MM-dd hh:mm:ss"),
open_id: openId,
// 'appkey': appKey,
// 'appsecret': secret,
session: accessToken,
};
};
//# sourceMappingURL=getSeller.js.map
\ No newline at end of file
{"version":3,"file":"getSeller.js","sourceRoot":"","sources":["../../src/utils/getSeller.ts"],"names":[],"mappings":";;;AAAa,QAAA,iBAAiB,GAAG,UAAC,EAAuB;QAArB,WAAW,iBAAA,EAAE,MAAM,YAAA;IACrD,OAAO;QACL,4DAA4D;QAC5D,OAAO,EAAE,MAAM;QACf,oBAAoB;QACpB,uBAAuB;QACvB,OAAO,EAAE,WAAW;KAErB,CAAC;AACJ,CAAC,CAAC"}
\ No newline at end of file
/** @format */
export * from './logger';
export * from './getToday';
export * from './time';
export * from './exportHandlers';
export * from './getSeller';
export * from './math';
......@@ -12,6 +12,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./logger"), exports);
__exportStar(require("./getToday"), exports);
__exportStar(require("./time"), exports);
__exportStar(require("./exportHandlers"), exports);
__exportStar(require("./getSeller"), exports);
__exportStar(require("./math"), exports);
//# sourceMappingURL=index.js.map
\ No newline at end of file
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";AAAA,cAAc;;;;;;;;;;;;AAGd,2CAAwB;AACxB,6CAA0B;AAC1B,mDAAgC"}
\ No newline at end of file
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";AAAA,cAAc;;;;;;;;;;;;AAEd,2CAAwB;AACxB,yCAAsB;AACtB,mDAAgC;AAChC,8CAA2B;AAC3B,yCAAsB"}
\ No newline at end of file
......@@ -50,15 +50,13 @@ exports.logger = function (context) {
};
// 记录错误日志
exports.recordErrorLog = function (context, baseInfos, errorMsg, stack) { return __awaiter(void 0, void 0, void 0, function () {
var openId, activityId, userInfo, userNick, logdao, functionName;
var openId, userNick, activityId, logdao, functionName;
var _a, _b, _c;
return __generator(this, function (_d) {
switch (_d.label) {
case 0:
openId = context.openId;
openId = context.openId, userNick = context.userNick;
activityId = (context.data || {}).activityId;
userInfo = baseInfos.userInfo;
userNick = (userInfo || {}).userNick;
logdao = new sdk_1.BaseDao(context, db_1.ERROR_LOG_DB_NAME);
functionName = (context.fcName || '') + "." + (((_c = (_b = (_a = context === null || context === void 0 ? void 0 : context.cloud) === null || _a === void 0 ? void 0 : _a.dataspace) === null || _b === void 0 ? void 0 : _b.context) === null || _c === void 0 ? void 0 : _c.handler) || context.handler);
return [4 /*yield*/, logdao.insertOne({
......
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AAM,GAAa,IAAI,aAAO,CAAC,OAAO,EAAE,sBAAiB,CAAC,CAAA;gBAC1D,YAAY,GAAW,CAAG,OAAO,CAAC,MAAM,IAAI,EAAE,WAClD,mBAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,KAAK,0CAAE,SAAS,0CAAE,OAAO,0CAAE,OAAO,KAAI,OAAO,CAAC,OAAO,CAC9D,CAAA;gBACK,qBAAM,MAAM,CAAC,SAAS,CAAC;wBAC5B,MAAM,QAAA;wBACN,UAAU,YAAA;wBACV,QAAQ,UAAA;wBACR,UAAU,EAAE,KAAK;wBACjB,YAAY,cAAA;wBACZ,QAAQ,UAAA;wBACR,UAAU,EAAE,OAAO,CAAC,UAAU;wBAC9B,MAAM,EAAE,OAAO,CAAC,IAAI;wBACpB,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE;wBACtB,SAAS,EAAE,gBAAQ,EAAE;wBACrB,SAAS,EAAE,CAAC;qBACb,CAAC,EAAA;oBAZF,sBAAO,SAYL,EAAA;;;KACH,CAAA"}
\ No newline at end of file
/** @format */
export declare function MathRand(): string;
"use strict";
/** @format */
Object.defineProperty(exports, "__esModule", { value: true });
exports.MathRand = void 0;
function MathRand() {
var Num = '';
for (var i = 0; i < 6; i++) {
Num += Math.floor(Math.random() * 10);
}
return Num;
}
exports.MathRand = MathRand;
//# sourceMappingURL=math.js.map
\ No newline at end of file
{"version":3,"file":"math.js","sourceRoot":"","sources":["../../src/utils/math.ts"],"names":[],"mappings":";AAAA,cAAc;;;AAEd,SAAgB,QAAQ;IACtB,IAAI,GAAG,GAAG,EAAE,CAAA;IACZ,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;QAC1B,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,CAAA;KACtC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC;AAND,4BAMC"}
\ No newline at end of file
/** @format */
export declare const activityValidate: {
title: string;
};
"use strict";
/** @format */
Object.defineProperty(exports, "__esModule", { value: true });
exports.activityValidate = void 0;
exports.activityValidate = {
title: ''
};
//# sourceMappingURL=saveValidate.js.map
\ No newline at end of file
{"version":3,"file":"saveValidate.js","sourceRoot":"","sources":["../../src/utils/saveValidate.ts"],"names":[],"mappings":";AAAA,cAAc;;;AAED,QAAA,gBAAgB,GAAG;IAC9B,KAAK,EAAE,EAAE;CACV,CAAA"}
\ No newline at end of file
/** @format */
export declare const getToday: () => string;
/**
* 传入时间戳(毫秒)
* 根据时间戳转换成number型日期进行差值结算,比如:2020318-2020317
*/
export declare function isNewDay(time: number): boolean;
export declare const formatTime: (thisDate: Date, fmt?: string) => string;
"use strict";
/** @format */
Object.defineProperty(exports, "__esModule", { value: true });
exports.formatTime = exports.isNewDay = exports.getToday = void 0;
var sdk_1 = require("../sdk");
// 获取今天的时间
exports.getToday = function () {
console.log(sdk_1.transformBeijingDate(Date.now()));
return sdk_1.dateFormatter(sdk_1.transformBeijingDate(Date.now()), 'yyyy/MM/dd');
};
/**
* 传入时间戳(毫秒)
* 根据时间戳转换成number型日期进行差值结算,比如:2020318-2020317
*/
function isNewDay(time) {
var date = new Date(time);
var dateNum = +(date.getFullYear() + '' + (date.getMonth() + 1) + '' + date.getDate());
var nowdate = new Date(Date.now());
var nowdateNum = +(nowdate.getFullYear() + '' + (nowdate.getMonth() + 1) + '' + nowdate.getDate());
return nowdateNum - dateNum > 0;
}
exports.isNewDay = isNewDay;
exports.formatTime = function (thisDate, fmt) {
if (fmt === void 0) { fmt = 'yyyy-MM-dd hh:mm:ss'; }
var o = {
'M+': thisDate.getMonth() + 1,
'd+': thisDate.getDate(),
'h+': thisDate.getHours(),
'm+': thisDate.getMinutes(),
's+': thisDate.getSeconds(),
'q+': Math.floor((thisDate.getMonth() + 3) / 3),
S: thisDate.getMilliseconds()
};
if (/(y+)/.test(fmt))
fmt = fmt.replace(RegExp.$1, (thisDate.getFullYear() + '').substr(4 - RegExp.$1.length));
for (var k in o)
if (new RegExp('(' + k + ')').test(fmt))
fmt = fmt.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ('00' + o[k]).substr(('' + o[k]).length));
return fmt;
};
//# sourceMappingURL=time.js.map
\ No newline at end of file
{"version":3,"file":"time.js","sourceRoot":"","sources":["../../src/utils/time.ts"],"names":[],"mappings":";AAAA,cAAc;;;AAEd,8BAA4D;AAE5D,UAAU;AACG,QAAA,QAAQ,GAAG;IACtB,OAAO,CAAC,GAAG,CAAC,0BAAoB,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAA;IAC7C,OAAO,mBAAa,CAAC,0BAAoB,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,EAAE,YAAY,CAAC,CAAA;AACtE,CAAC,CAAA;AAED;;;GAGG;AACH,SAAgB,QAAQ,CAAC,IAAY;IACnC,IAAI,IAAI,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,CAAA;IACzB,IAAI,OAAO,GAAG,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,GAAG,EAAE,GAAG,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC,CAAA;IAEtF,IAAI,OAAO,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAA;IAClC,IAAI,UAAU,GAAG,CAAC,CAAC,OAAO,CAAC,WAAW,EAAE,GAAG,EAAE,GAAG,CAAC,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAAA;IAClG,OAAO,UAAU,GAAG,OAAO,GAAG,CAAC,CAAA;AACjC,CAAC;AAPD,4BAOC;AAEY,QAAA,UAAU,GAAG,UAAC,QAAc,EAAE,GAAmC;IAAnC,oBAAA,EAAA,2BAAmC;IAC5E,IAAI,CAAC,GA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Id) {
res.json({ message: `参数错误,缺少openId` })
}
// if (!openId) {
// res.json({ message: `参数错误,缺少openId` })
// }
try {
let query = JSON.parse(JSON.stringify(data))
} catch (e) {
......@@ -45,11 +45,15 @@ app.post('/handler', async (req, res) => {
process.db = db
}
req.context = {
openId,
openId: 'AAHbOf3jAJ9vbna7X6pnrL',
appOwnerOpenId: 'dsass',
db,
env: 'mock',
data: queryData,
handler
handler,
userNick: 'duiba2',
session: '50000500b08gZQsAc2up167a06fccD2GWjMsf0tjBEhwfqWvllgyIXfztqJzA5w1U7y',
appKey: '28640163'
}
if (routers[handler]) {
let result = await routers[handler](req.context)
......
......@@ -7,6 +7,7 @@
"license": "ISC",
"sdkVersion": "*",
"dependencies": {
"async-validator": "^3.4.0",
"dayjs": "^1.8.28",
"node-xlsx": "^0.15.0",
"source-map-support": "^0.5.19",
......
......@@ -90,18 +90,16 @@ export const BusinessError = {
defaultMsg: `奖品已超过领取时间`
}
}
export const CODE_TYPES = Object.assign({}, DEFAULT_CODE_TYPES, BusinessError)
// tb 接口返回部分错误
export const TBERROR = {
USER_PERMISSION_EXCEED_MAX_RIGHT_COUNT_IN_DAY: '今日领取达到上限,明日再来领取哦',
COUPON_INVALID_OR_DELETED: '权益无效或者被删除,请联系商家',
APPLY_OWNSELF_COUPON: '不能领取自己家店铺权益',
APPLY_SINGLE_COUPON_COUNT_EXCEED_LIMIT: '请至卡券包删除无用权益再领取',
NO_RIGHT_QUANTITY: '权益库存不足,请联系商家',
ERRORA_3_567: '领取失败,为风险用户',
'Invalid session': '订购应用已过期,请联系商家处理'
// 活动开奖状态码
export const OPEN_PRIZE_STATUS = {
// 待开奖
WAIT_AWARD: 1,
// 开奖中
PROCESSING: 2,
// 开奖成功
SUCCESS: 3,
// 开奖失败
FAIL: 4
}
// 领取奖品状态
......@@ -120,42 +118,110 @@ export const DRAW_STATUS = {
RETRY: 6
}
// 奖品类型
// 日志类型: error,info
export const LOGGER_TYPE = {
ERROR: 1,
INFO: 2
}
export const PRIZE_TYPE = {
ENAME: 1,
EQUITY: 1,
CREDITS: 2,
OBJECT: 3,
THANKS: 5
THANK: 5
}
// C端的APP NAME
export const C_APP_NAME: string = 'promotioncenter-${需要补充}'
// 订单状态
export const TAOBAO_SUCCESS_ORDER_STATUS: string[] = [
'WAIT_SELLER_SEND_GOODS',
'SELLER_CONSIGNED_PART',
'WAIT_BUYER_CONFIRM_GOODS',
'TRADE_BUYER_SIGNED',
'TRADE_FINISHED',
'PAID_FORBID_CONSIGN'
]
export const CODE_TYPES = Object.assign({}, DEFAULT_CODE_TYPES, BusinessError)
// 活动状态
export const enum ACTIVITY_STATUS {
NORMAL = 1,
DELETE = 2
export const errorCode = {
'000000': 'ok',
'000001': '请填写活动名称',
'000002': '请填写活动副标题',
'000003': '活动名称不得大于12个字符',
'000004': '活动副标题不得大于16个字符',
'000005': '任务配置至少选择一项',
'000006': '浏览链接配置错误',
'000007': '奖品至少配置三名',
'000008': '浏览宝贝最多选择20个商品',
'000010': '请先生成规则',
'000011': '请配置活动时间',
'000012': '新建活动开始时间需小于当前时间',
'000013': '开始时间不得大于结束时间',
'000014': '奖品最多配置8个档位',
'000015': '查询列表错误',
'000016': '查询列表总数错误',
'000017': '更新奖品列表出错',
'000020': '删除活动失败',
'000021': '保存活动失败',
'000022': '删除活动id不存在',
'000023': '当前活动不存在',
'000024': '获取授权信息失败',
'000025': '保存授权信息失败',
'000026': '获取商家在售列表失败',
'000027': '获取商家ids列表失败',
'000030': '获取ename商品信息失败',
'000031': '奖品配置不正确'
}
// B端的APP NAME
export const B_APP_NAME: string = 'promotioncenter-<%=bizCode%>'
//任务频率类型常量
export const TASK_RATE_TYPE = {
FOREVER: 1,
EVERYDAY: 2,
NOLIMIT: 3
export const GOODSINFO =
'detail_url,approve_status,num_iid,title,nick,type,cid,pic_url,num,props,valid_thru,list_time,price,has_discount,has_invoice,has_warranty,has_showcase,modified,delist_time,postage_id,seller_cids,outer_id,sold_quantity'
export const EIGHT_HOURS = 60 * 60 * 8 * 1000
export const DELETE_STATUS = {
DELETE: 2,
EXIST: 1
}
export const TASK_TYPE_TEXT = {
beMembership: '成为会员',
attentionStore: '关注店铺',
sign: '签到',
exchangeCredits: '兑换积分',
inviteFriends: '邀请好友',
orderGoods: '下单商品',
browseGoods: '浏览商品',
jumpLink: '跳转链接',
collectGoods: '收藏商品'
}
export const RECORD_TYPE = {
FOLLOW_TASK: { type: 1, name: '关注店铺任务' },
SIGN_TASK: { type: 2, name: '签到任务' },
RECEIVE_INVITE: { type: 3, name: '接受邀请' },
INVITE_SUCCESS: { type: 4, name: '邀请成功' }
export const TASK_CHECK_TYPE = {
value: {
list: [
'beMembership',
'attentionStore',
'sign',
'exchangeCredits',
'inviteFriends',
'orderGoods',
'jumpLink',
'collectGoods'
],
reg: /[1-99]/,
regName: '1-99之内'
},
times: {
list: ['exchangeCredits', 'inviteFriends', 'orderGoods', 'browseGoods', 'jumpLink', 'collectGoods']
},
title: {
list: ['inviteFriends', 'orderGoods', 'browseGoods', 'jumpLink', 'collectGoods']
},
itemIds: {
list: ['orderGoods', 'browseGoods', 'collectGoods']
},
taskRateType: {
list: ['inviteFriends', 'orderGoods', 'browseGoods', 'collectGoods']
},
link: { list: ['jumpLink'] }
}
//saas订购码 根据需求改变
export const APP_SUB_CODE: string = 'FW_GOODS-1001086450'
export const TEMPLATE_INFO = {
clients: 'taobao,tmall',
template_id: 3000000002590532,
template_version: '0.0.3'
}
/** @format */
import { CODE_TYPES } from './../constants'
import { services, paramsCheck } from '../decorator'
import { resultsModel } from '../sdk'
import { ActivityconfigService } from '../service'
export default class ActivityController {
/**
* 活动基本信息
*/
@services([ActivityconfigService])
async getActivityList(context: Context, {}, [activityconfigService]: [ActivityconfigService]) {
const { openId } = context
let result = await activityconfigService.getActivityListByOpenId(openId, context.data)
if (result) {
result = result.list.map((item: { _id: string }) => {
return {
...item,
activityId: item._id
}
})
return resultsModel.success(result)
}
return resultsModel.error(CODE_TYPES.SYSTEM_ERROR, '查询活动列表失败')
}
/**
* 活动详情
*/
@paramsCheck(['activityId'])
@services([ActivityconfigService])
async getActivityDetail(context: Context, {}, [activityconfigService]: [ActivityconfigService]) {
const { activityId } = context.data
let result = await activityconfigService.getActivityInfoByActivityId(activityId)
if (!result) return resultsModel.error(CODE_TYPES.PARAMS_ERROR, '当前活动不存在')
const { prizeConfig, baseConfig } = result || {}
// 奖品配置统一存在b_prize_config表中, 接口返回时根据需求重新组装
const prizes = activityconfigService.formatPrizeConfig(prizeConfig)
let activityInfo = {
activityId,
...baseConfig,
...prizes
}
return resultsModel.success(activityInfo)
}
/**
* 删除活动
*/
@paramsCheck(['activityId'])
@services([ActivityconfigService])
async delActivity(context: Context, {}, [activityconfigService]: [ActivityconfigService]) {
const { activityId } = context.data
let result = await activityconfigService.deleteActivityByActivityId(activityId)
const deleteSuccess: boolean = result === 0 || result
if (deleteSuccess) {
return resultsModel.success(true)
} else {
return resultsModel.error(CODE_TYPES.SYSTEM_ERROR, '删除活动失败')
}
}
}
/** @format */
import { CODE_TYPES } from './../constants'
import { services, paramsCheck } from '../decorator'
import { resultsModel } from '../sdk'
import { AwardsService } from '../service'
import * as xlsx from 'node-xlsx'
export default class BaseController {
/**
* 活动中奖名单
*/
@paramsCheck(['activityId'])
@services([AwardsService])
async findWinnerInfoList(context: Context, { session }, [awardsService]: [AwardsService]) {
const { activityId } = context.data
// 获取活动中奖列表
let awardslist = await awardsService.getAwardslistByActivityId(activityId)
console.log(`awardslist: ${JSON.stringify(awardslist)}`)
let winnersObj = {}
awardslist.forEach(v => {
if (!winnersObj[v.rank]) {
winnersObj[v.rank] = []
}
winnersObj[v.rank].push({
userNick: v.userNick,
id: v.openId
})
})
console.log(`winnersObj: ${JSON.stringify(winnersObj)}`)
let results = []
new Map(Object.entries(winnersObj)).forEach((v, index) => {
results.push({
rank: index,
winnerDetailList: v
})
})
return resultsModel.success(results)
}
/**
* 导出活动中奖名单
*/
@paramsCheck(['activityId', 'title'])
@services([AwardsService])
async exportAwardsList(context: Context, { session }, [awardsService]: [AwardsService]) {
const { cloud } = context
const { activityId, title } = context.data
// 获取活动中奖列表
let awardslist = await awardsService.getAwardslistByActivityId(activityId)
console.log(`awardslist: ${JSON.stringify(awardslist)}`)
let xlsxData = [['序列', '名次', '昵称', '中奖名称']]
awardslist.forEach((v, index, arr) => {
xlsxData.push([index + 1, v.rank, v.userNick, v.prizeName])
})
let buffer = xlsx.build([
{
name: title + new Date().getTime(),
data: xlsxData
}
])
console.log(`xlsxData: ${JSON.stringify(xlsxData)}`)
let result = await cloud.file.uploadFile({
fileContent: buffer,
fileName: title + new Date().getTime() + '.xlsx'
})
// result.url 需进行处理
if (result.url) {
result.url = result.url.replace('http', 'https').replace('-internal', '')
}
return resultsModel.success(result)
}
}
/** @format */
import { CODE_TYPES } from './../constants'
import { services, paramsCheck } from '../decorator'
import { resultsModel } from '../sdk'
import { BaseService } from '../service'
export default class BaseController {
/**
* 活动基本信息
*/
@paramsCheck(['activityId'])
@services([BaseService])
async getActivityBaseInfoById(context: Context, {}, [baseService]: [BaseService]) {
const { activityId } = context.data
// 参数校验
if (!activityId) {
return resultsModel.error(CODE_TYPES.PARAMS_ERROR, `activityId必填`)
}
// 活动基本情况
const activityInfo = await baseService.getBaseInfo(activityId)
return resultsModel.success(activityInfo)
}
}
/** @format */
import { CODE_TYPES } from './../constants'
import { services, paramsCheck } from '../decorator'
import { formatTime } from '../utils'
import { resultsModel } from '../sdk'
import { EIGHT_HOURS } from '../constants'
export default class RuleController {
/**
* 生成活动规则
*/
@paramsCheck(['title', 'startTime', 'endTime', 'prizeList'])
@services([])
async generateRule(context: Context, {}) {
const { title = '', startTime = '', endTime = '', prizeList = [] } = context.data
if (title.length > 12) return resultsModel.error(CODE_TYPES.PARAMS_ERROR, '活动名称不可超过12个字')
if (startTime > endTime) return resultsModel.error(CODE_TYPES.PARAMS_ERROR, '开始时间不得大于结束时间')
if (prizeList.length === 0) return resultsModel.error(CODE_TYPES.PARAMS_ERROR, '奖品至少配置一个')
let resultRule: string = ''
const startTimeDate = formatTime(new Date(+startTime + EIGHT_HOURS), 'yyyy-MM-dd hh:mm:ss')
const endTimeDate = formatTime(new Date(+endTime + EIGHT_HOURS), 'yyyy-MM-dd hh:mm:ss')
resultRule = `1.活动时间:${startTimeDate}--${endTimeDate};\n2.活动结束根据排行榜排名获得对应的奖励,每个人取活动中单局最高分;\n3.每天3次免费参与资格,超过次数后邀请群内好友参与游戏可获得额外次数(每个用户可助力一次);\n4.参与签到可获得道具,每局结束游戏后可使用道具;\n5.完成任务每天可获得额外的复活机会,每局只能使用一张复活卡;\n\n`
const prizeStr = prizeList.reduce((s, v) => {
const rankArr = v.rank.split('-')
if (rankArr[0] == rankArr[1]) {
return (s += `第${rankArr[0]}名: ${v.name}\n`)
} else {
return (s += `第${v.rank}名: ${v.name}\n`)
}
}, '奖品:\n')
resultRule += prizeStr
return resultsModel.success(resultRule)
}
}
/** @format */
import { CODE_TYPES } from './../constants'
import { services, paramsCheck, paramsValidate } from '../decorator'
import { resultsModel } from '../sdk'
import { ActivityconfigService } from '../service'
import { RuleItem } from 'async-validator'
interface ISaveActivityContext extends Context {
data: {
activityId?: string
title: string
startTime: number
endTime: number
tasks: ITasks
rule: string
}
}
// const activityValidate: <T><RuleItem> = {
// title: {
// require: true,
// type: 'string',
// validator: (rule, value, callback, data) => {}
// }
// }
export default class ActivitSaveController {
/**
* 保存活动
*/
@paramsCheck(['title', 'startTime', 'endTime', 'tasks', 'rule'])
// @paramsValidate(activityValidate)
@services([ActivityconfigService])
async saveActivityInfo(context: ISaveActivityContext, {}, [activityconfigService]: [ActivityconfigService]) {
const { title = '', activityId = '', startTime, endTime, tasks = {}, rule } = context.data
const nowTime = Date.now()
let initialData
if (activityId) {
initialData = await activityconfigService.getActivityInfoByActivityId(activityId)
}
}
}
/** @format */
import { services } from '../decorator'
import { resultsModel } from '../sdk'
import { SellerService, TaobaoTopService, InstanceService } from '../service'
import { CODE_TYPES, TEMPLATE_INFO } from '../constants'
export default class BaseController {
/**
* 保存授权信息
*/
@services([SellerService])
async sellerSave(context: Context, {}, [sellerService]: [SellerService]) {
let { openId, accessToken, appKey, userNick, appOwnerOpenId } = context
let isPrimaryAccount: boolean = userNick.indexOf(':') === -1
console.log(userNick, isPrimaryAccount, 'userNick------')
// 子账号
if (!isPrimaryAccount) {
let primaryUserNick = userNick.split(':')[0]
let sellerInfo = await sellerService.getSellerInfoByUserNick(primaryUserNick)
if (sellerInfo) {
accessToken = sellerInfo.accessToken
}
}
// 已经有accessToken的记录 更新记录
let hasSellerInfo = await sellerService.findSellerInfo(openId)
if (hasSellerInfo) {
await sellerService.updateSellerInfo(openId, { accessToken })
return resultsModel.success(true)
} else {
// 新增记录
let result = await sellerService.saveSellerInfo({
accessToken,
openId,
appKey,
userNick,
appOwnerOpenId
})
return resultsModel.success(result)
}
}
@services([SellerService, TaobaoTopService, InstanceService])
async sellerSaasSave(
context: Context,
{},
[sellerService, taobaoTopService, InstanceService]: [SellerService, TaobaoTopService, InstanceService]
) {
let { openId, accessToken, appKey, userNick, appOwnerOpenId, consumeMiniAppId } = context
let primaryAccountNick = userNick || 'duiba2'
let isPrimaryAccount = true
let primaryOpenId = openId
let shopId = ''
if (userNick && ~userNick.indexOf(':')) {
let userNickArr = userNick.split(':')
isPrimaryAccount = false
primaryAccountNick = userNickArr[0]
if (!isPrimaryAccount) {
let sellerInfo = await sellerService.getSellerInfoByUserNick(primaryAccountNick)
if (sellerInfo) {
accessToken = sellerInfo.accessToken
primaryOpenId = sellerInfo.openId
shopId = sellerInfo.shopId
} else {
return resultsModel.error(CODE_TYPES.SYSTEM_ERROR, '请用主账号进入后台进行授权')
}
}
}
let hasResult = await sellerService.findSellerInfo(openId)
let subInfo = await taobaoTopService.getSubRelationship(primaryAccountNick)
let shopInfoResult = await taobaoTopService.getShopId()
if (hasResult && hasResult[0]) {
await sellerService.updateSellerInfo(openId, {
accessToken
})
await InstanceService.updateInstanceInfo(openId, {
accessToken
})
// return resultsModel.success({ deadline: subInfo.deadline || "" });
} else {
if (!shopInfoResult.success) {
return resultsModel.error(CODE_TYPES.SYSTEM_ERROR, '获取淘宝店铺信息失败')
}
await sellerService.saveSellerInfo({
accessToken,
openId,
appKey,
// @ts-ignore
shopId: shopInfoResult.data.sid,
userNick,
appOwnerOpenId
})
// return resultsModel.success({ deadline: subInfo.deadline || "" });
}
let instanceOldInfo = await InstanceService.getMiniAppInstanceInfoByNick(primaryAccountNick)
if (!instanceOldInfo) {
if (!isPrimaryAccount) {
return resultsModel.error(CODE_TYPES.SYSTEM_ERROR, '请用主账号进入后台进行授权')
}
let instanceInfo = await taobaoTopService.getTemplateInstantiate()
const { app_id, app_version } = instanceInfo
if (instanceInfo) {
let onlineInstance = await taobaoTopService.pushOnlineInstance({
app_id,
app_version
})
await InstanceService.saveInstanceInfo({
...instanceInfo,
clients: onlineInstance.online_results.miniapp_instance_app_online_dto.reduce((s, v) => {
return (s += v.client + ',')
}, ''),
...onlineInstance.app_info,
accessToken,
template_version: TEMPLATE_INFO.template_version,
template_id: TEMPLATE_INFO.template_id,
openId,
appKey,
consumeMiniAppId,
// @ts-ignore
shopId: shopInfoResult.data.sid,
userNick,
appOwnerOpenId
})
} else {
console.log('实例化信息获取失败')
}
} else {
if (TEMPLATE_INFO.template_version !== instanceOldInfo.template_version) {
const { clients, app_id, template_id } = instanceOldInfo
let updateInfo = {
clients,
app_id,
template_id,
ext_json: {
name: 'online'
},
template_version: TEMPLATE_INFO.template_version
}
let updateInstanceInfo = await taobaoTopService.updateMiniInstance(updateInfo)
let onlineInstance = await taobaoTopService.pushOnlineInstance({
app_id: updateInstanceInfo.app_id,
app_version: updateInstanceInfo.app_version
})
await InstanceService.updateInstanceInfo(openId, {
template_version: TEMPLATE_INFO.template_version,
...onlineInstance.app_info,
app_version: updateInstanceInfo.app_version,
pre_view_url: updateInstanceInfo.pre_view_url
})
}
await InstanceService.updateInstanceInfo(openId, {
// @ts-ignore
shopId: shopInfoResult.data.sid
})
await InstanceService.updateInstanceInfo(primaryOpenId, {
// @ts-ignore
shopId: shopInfoResult.data.sid
})
}
return resultsModel.success({ deadline: subInfo.deadline || '' })
}
}
/** @format */
import { CODE_TYPES } from './../constants'
import { services, paramsCheck } from '../decorator'
import { resultsModel } from '../sdk'
import { TaobaoTopService } from '../service'
export default class BaseController {
/**
* 通过状态获取top商品列表
*/
@paramsCheck(['approveStatus', 'title', 'pageNo', 'pageSize'])
@services([TaobaoTopService])
async findItemListByStatus(context: Context, { session }, [taobaoTopService]: [TaobaoTopService]) {
const { approveStatus = 'onsale', title = '', pageNo = 1, pageSize = 10 } = context.data
let result = await taobaoTopService.getItemListByStatus(session, {
approveStatus,
title,
pageNo,
pageSize
})
return result
}
/**
* 通过状态获取top商品列表
*/
@paramsCheck(['itemIds'])
@services([TaobaoTopService])
async findItemListByIds(context: Context, { session }, [taobaoTopService]: [TaobaoTopService]) {
const { itemIds } = context.data
return await taobaoTopService.getItemListByIds(itemIds, session)
}
/**
* 通过ename获取权益信息
*/
@paramsCheck(['ename'])
@services([TaobaoTopService])
async queryBenefitByEname(context: Context, { session }, [taobaoTopService]: [TaobaoTopService]) {
const { ename } = context.data
return await taobaoTopService.getPrizeByEname(session, ename)
}
}
......@@ -15,3 +15,5 @@ export const SELLER_INFO_DB_NAME: string = 'a_seller_info'
export const PRIZE_CONFIG_DB_NAME: string = 'b_prize_config'
export const ACTIVITY_CONFIG_DB_NAME: string = 'b_activity_config'
export const ACTIVITY_INSTANCE: string = 'miniapp_instantiate'
......@@ -2,3 +2,4 @@
export * from './check'
export * from './services'
export * from './noCatch'
export * from './validate'
/** @format */
import {logger, recordErrorLog } from '../utils'
import { logger, recordErrorLog } from '../utils'
import { resultsModel } from '../sdk'
import { CODE_TYPES } from '../constants'
import { TaobaoTopService } from '../service'
async function initBaseInfo(context: Context, baseInfos: IControllerInfos) {
if (!baseInfos.session) {
// @ts-ignore
baseInfos.session = await new TaobaoTopService(context).getAccessTokenByOpenId()
}
return baseInfos
}
......@@ -28,7 +32,10 @@ export const services = (services: any[]) => {
} catch (error) {
console.log('error', error)
await recordErrorLog(context, baseInfos, error.toString(), error.stack)
ret = resultsModel.error(CODE_TYPES.SYSTEM_ERROR)
ret = resultsModel.error(
CODE_TYPES.SYSTEM_ERROR,
`${context?.cloud?.dataspace?.context?.handler || context.handler}系统错误`
)
}
return ret
}
......
/** @format */
import { resultsModel } from '../sdk'
import { CODE_TYPES } from '../constants'
export const paramsValidate = (validator: object) => {
return function (target: Object, name: string, descriptor: PropertyDescriptor) {
const method = descriptor.value
descriptor.value = function (...args: any[]) {
const [context, otherArgs = {}] = args
const params = Object.keys(context.data)
return method.apply(target, [context, { ...otherArgs }])
}
}
}
/** @format */
import { exportHandlers } from './utils'
import ActivityController from './controller/activity.controller'
import SellerController from './controller/seller.controller'
import AwardsController from './controller/awards.controller'
import RuleController from './controller/rule.controller'
import RaobaoItemController from './controller/taobaoItem.controller'
export default exportHandlers([])
export default exportHandlers([
ActivityController,
SellerController,
AwardsController,
RuleController,
RaobaoItemController
])
/** @format */
import { BaseDao } from '../sdk'
import { ACTIVITY_CONFIG_DB_NAME, PRIZE_CONFIG_DB_NAME } from '../db'
import { DELETE_STATUS, OPEN_PRIZE_STATUS } from '../constants'
export default class ActivityConfigService {
activityconfigDao: IBaseDao
activityconfigPrizeDao: IBaseDao
constructor(context: Context) {
this.activityconfigDao = new BaseDao(context, ACTIVITY_CONFIG_DB_NAME)
this.activityconfigPrizeDao = new BaseDao(context, PRIZE_CONFIG_DB_NAME)
}
//保存新建活动
async saveNewActivity(data, prize, openId) {
try {
let result = await this.activityconfigDao.count({
...data,
createTime: Date.now(),
updateTime: Date.now(),
deleteStatus: DELETE_STATUS.EXIST,
openPrizeStatus: OPEN_PRIZE_STATUS.WAIT_AWARD
})
console.log(result, '保存基础配置result')
if (result) {
try {
prize.map(item => {
item.activityId = result
item.openId = openId
item.createTime = Date.now()
item.updateTime = Date.now()
item.deleteStatus = DELETE_STATUS.EXIST
return item
})
return await this.activityconfigPrizeDao.insertMany(prize)
} catch (e) {
console.log(e, '保存奖品配置出错')
// 如果奖品未保存删除之前的活动
await this.activityconfigDao.delete({
_id: result
})
}
}
} catch (e) {
//保存活动失败
console.log(e, '保存活动失败')
}
}
// 更新活动基本信息
async updateBaseConfigInfo(id, data) {
return await this.activityconfigDao.update(
{
_id: id
},
{
$set: {
...data,
updateTime: Date.now(),
deleteStatus: DELETE_STATUS.EXIST
}
}
)
}
// 通过id获取奖品信息
async getPrizeInfoById(id) {
let result = await this.activityconfigPrizeDao.find({
_id: id
})
if (result && result[0]) {
return result[0]
}
return false
}
// 奖品置为删除状态
async updateDeleteStatusById(id) {
return await this.activityconfigPrizeDao.update(
{
_id: id
},
{
$set: {
deleteStatus: DELETE_STATUS.DELETE
}
}
)
}
// 更新单条数据
async updateOnePrizeById(id, data) {
return await this.activityconfigPrizeDao.update(
{
_id: id
},
{
$set: {
...data,
updateTime: Date.now(),
deleteStatus: DELETE_STATUS.EXIST
}
}
)
}
// 插入单条奖品数据
async insertPrizeByActivityId(activityId, data) {
return await this.activityconfigPrizeDao.insertOne({
...data,
activityId,
createTime: Date.now(),
updateTime: Date.now(),
deleteStatus: DELETE_STATUS.EXIST
})
}
// 获取奖品所有配置
async getAllOldPrizeList(activityId) {
return await this.activityconfigPrizeDao.find({
activityId
})
}
//更新活动配置
async updateActivity(activityId, data, prizeNoId) {
console.log(activityId, data, prizeNoId, 'activityId, data, prizeNoId, oldPrizeIds')
try {
let originalData = await this.activityconfigDao.findOne({
_id: activityId
})
let result = await this.activityconfigDao.update(
{
_id: activityId
},
{
$set: {
...data,
createTime: originalData.createTime,
updateTime: Date.now()
}
}
)
if (result) {
try {
let prizeOldIdsByActivity = (
await this.activityconfigPrizeDao.find({
activityId
})
).reduce((s, v) => {
return (s = [...s, v._id])
}, [])
let prizeResult = await this.activityconfigPrizeDao.insertMany(prizeNoId)
if (prizeResult) {
//删除之前的奖品
let deleteOldPrizeList = prizeOldIdsByActivity.reduce((s, item) => {
return (s = [
...s,
this.activityconfigPrizeDao.delete({
_id: item
})
])
}, [])
return await Promise.all(deleteOldPrizeList)
}
} catch (e) {
await this.activityconfigDao.update(
{
_id: activityId
},
{
$set: {
...originalData[0]
}
}
)
}
}
} catch (e) {
//更新失败
}
}
//通过openId去获取当前商家活动列表
async getActivityListByOpenId(openId: string, { pageSize = 10, pageNo = 1 }) {
return {
list: await this.activityconfigDao.find(
{
openId,
deleteStatus: DELETE_STATUS.EXIST
},
{
projection: {
startTime: 1,
endTime: 1,
title: 1
},
sort: {
createTime: -1
},
limit: pageSize,
skip: (pageNo - 1) * pageSize
}
),
total: await this.activityconfigDao.count({
openId,
deleteStatus: DELETE_STATUS.EXIST
}),
pageSize,
pageNo
}
}
//通过activityId去获取活动配置信息
async getActivityInfoByActivityId(activityId: string) {
return {
baseConfig: await this.activityconfigDao.findOne({ _id: activityId, deleteStatus: DELETE_STATUS.EXIST }),
prizeConfig: await this.activityconfigPrizeDao.find(
{ activityId, deleteStatus: DELETE_STATUS.EXIST },
{ sort: { level: 1 } }
)
}
}
//通过activityId去删除活动
async deleteActivityByActivityId(activityId: string) {
// 删除活动基础配置
let result = await this.activityconfigDao.update(
{ _id: activityId },
{ $set: { deleteStatus: DELETE_STATUS.DELETE } }
)
// 删除活动奖品配置
if (result) {
return await this.activityconfigPrizeDao.update({ activityId }, { $set: { deleteStatus: DELETE_STATUS.DELETE } })
}
return false
}
// 查询待开奖列表
async getNodifyList(serverTime) {
let list = await this.activityconfigDao.find({
endTime: {
$lt: serverTime
},
openPrizeStatus: {
$in: [OPEN_PRIZE_STATUS.WAIT_AWARD, OPEN_PRIZE_STATUS.FAIL]
},
deleteStatus: DELETE_STATUS.EXIST
})
console.log(list)
return list
}
// 更新openPrizeStatus为处理中
async update2Process(_id) {
try {
await this.activityconfigDao.update(
{
_id
},
{
$set: {
openPrizeStatus: OPEN_PRIZE_STATUS.PROCESSING,
updateTime: Date.now()
}
}
)
return true
} catch (e) {
// 日志记录
console.log(e)
return false
}
}
// 更新openPrizeStatus为成功
async update2Success(_id) {
try {
await this.activityconfigDao.update(
{
_id
},
{
$set: {
openPrizeStatus: OPEN_PRIZE_STATUS.SUCCESS,
openPrizeMsg: '',
updateTime: Date.now()
}
}
)
return true
} catch (e) {
// 日志记录
console.log(e)
return false
}
}
// 更新openPrizeStatus为失败
async update2Fail(_id, message) {
try {
await this.activityconfigDao.update(
{
_id
},
{
$set: {
openPrizeStatus: OPEN_PRIZE_STATUS.FAIL,
openPrizeMsg: message || '',
updateTime: Date.now()
}
}
)
return true
} catch (e) {
// 日志记录
console.log(e)
return false
}
}
/**
* 组装奖品数据
*
* @param {Array<IActivityPrize>} prizeConfig
* @returns
* @memberof ActivityConfigService
*/
formatPrizeConfig(prizeConfig: Array<IActivityPrize>) {
return {
prizeList: prizeConfig
}
}
}
/** @format */
// 排行榜开奖记录
import { BaseDao } from '../sdk'
import { AWARDS_DB_NAME } from '../db'
import { DRAW_STATUS } from '../constants'
export default class AwardsService {
context: Context
awardsdao: IBaseDao
constructor(context: Context) {
this.awardsdao = new BaseDao(context, AWARDS_DB_NAME)
}
// 添加排行榜待开奖列表
async addWaitAwardsList(list) {
if (!list.length) return true
list = list.map(v => {
return {
...v,
drawStatus: DRAW_STATUS.WAITAWARD,
message: ''
}
})
try {
await this.awardsdao.insertMany(list)
return true
} catch (e) {
console.log(`添加排行榜待开奖列表出错:${e}`)
return false
}
}
// 根据活动id查找中奖名单
async getAwardslistByActivityId(activityId: string) {
if (!activityId) return false
return await this.awardsdao.find(
{ activityId },
{
sort: {
score: -1,
rankTime: -1
}
}
)
}
}
/**
* 基本信息
*
* @format
*/
import { BaseDao } from '../sdk'
import { ACTIVITY_CONFIG_DB_NAME } from '../db'
export default class BaseService {
context: Context
activitydao: IBaseDao
constructor(context: Context) {
this.context = context
this.activitydao = new BaseDao(context, ACTIVITY_CONFIG_DB_NAME)
}
/**
* @desc 活动基本信息
* @param {活动id} activityId
* @returns 返回活动详情,若不存在活动,返回为null
*/
async getBaseInfo(activityId: string) {
console.log(process.argv[2], 'process.argv[2]')
return await this.activitydao.findOne({ _id: activityId })
}
}
/** @format */
export { default as BaseService } from './base.service'
export { default as ActivityconfigService } from './activityconfig.service'
export { default as TaobaoTopService } from './taobaoTop.service'
export { default as SellerService } from './seller.service'
export { default as InstanceService } from './instance.service'
export { default as AwardsService } from './awards.service'
/** @format */
import { BaseDao } from '../sdk'
import { ACTIVITY_INSTANCE } from '../db'
export default class InstanceService {
activityinstanceDao: IBaseDao
context: Context
constructor(context: Context) {
this.activityinstanceDao = new BaseDao(context, ACTIVITY_INSTANCE)
}
//保存商家授权信息
async saveInstanceInfo(instanceInfo) {
return await this.activityinstanceDao.insertOne({
...instanceInfo,
updateTime: Date.now(),
createTime: Date.now()
})
}
//查找商家授权信息
async findInstanceInfo(openId: string) {
return await this.activityinstanceDao.find({ openId })
}
//更新商家授权信息
async updateInstanceInfo(openId: string, updateinfo) {
return await this.activityinstanceDao.update(
{ openId },
{
$set: {
...updateinfo,
updateTime: Date.now()
}
}
)
}
async getMiniAppInstanceInfoByNick(userNick: string) {
return await this.activityinstanceDao.find({ userNick })
}
}
/** @format */
import { BaseDao } from '../sdk'
import { SELLER_INFO_DB_NAME } from '../db'
// import { DELETE_STATUS, OPEN_PRIZE_STATUS } from '../constants'
export default class ActivitySellerService {
context: Context
sellerdao: IBaseDao
constructor(context: Context) {
this.sellerdao = new BaseDao(context, SELLER_INFO_DB_NAME)
}
//保存商家授权信息
async saveSellerInfo(sellerInfo: ISellerSaveInfo) {
return await this.sellerdao.insertOne({
...sellerInfo,
updateTime: Date.now(),
createTime: Date.now()
})
}
//查找商家授权信息
async findSellerInfo(openId: string) {
return await this.sellerdao.findOne({ openId })
}
//查找商家授权信息
async getSellerInfoByUserNick(userNick: string) {
return await this.sellerdao.findOne({ userNick })
}
//更新商家授权信息
async updateSellerInfo(openId: string, sellerInfo: object) {
return await this.sellerdao.update(
{ openId },
{
$set: { ...sellerInfo, updateTime: Date.now() }
}
)
}
}
/** @format */
import { BaseDao, TBAPIS, resultsModel } from '../sdk'
import { SELLER_INFO_DB_NAME, ACTIVITY_CONFIG_DB_NAME } from '../db'
import {
DELETE_STATUS,
OPEN_PRIZE_STATUS,
CODE_TYPES,
GOODSINFO,
B_APP_NAME,
TEMPLATE_INFO,
APP_SUB_CODE
} from '../constants'
import { MathRand, getConsumerSeller } from '../utils'
export default class ActivityTopService {
activitySellerDao: IBaseDao
activityBaseDao: IBaseDao
context: Context
constructor(context: Context) {
this.activitySellerDao = new BaseDao(context, SELLER_INFO_DB_NAME)
this.activityBaseDao = new BaseDao(context, ACTIVITY_CONFIG_DB_NAME)
this.context = context
}
//获取商家授权session
async getAccessTokenByShopId(activityId: string) {
let result = await this.activityBaseDao.findOne({ _id: activityId })
if (!result) return {}
const { shopId } = result || {}
let { sellResult } = await this.activitySellerDao.findOne({ shopId }, { sort: { createTime: 1 } })
console.log(sellResult, 'sellResult')
return { session: sellResult?.accessToken }
}
//通过openId去查找session
async getAccessTokenByOpenId() {
const { openId } = this.context
let result = await this.activitySellerDao.findOne({ openId })
return { session: result?.accessToken || this.context.accessToken }
}
//淘宝top接口获取商品列表
async getItemListByIds(itemIds: string, seesion: string) {
try {
let result = await TBAPIS.getItemListByItemIds(this.context, seesion, itemIds, { fields: GOODSINFO })
if (result) {
let itemsData = {
list:
(result &&
result.items &&
result.items.item.reduce(
(s: any[], v: { num_iid: any; title: any; price: any; detail_url: any; pic_url: any }) => {
return (s = [
...s,
{
itemId: v.num_iid,
name: v.title,
price: v.price,
detailUrl: v.detail_url,
picUrl: v.pic_url
}
])
},
[]
)) ||
[],
totalCount: result.items.item.length
}
return resultsModel.success(itemsData)
}
return resultsModel.error(CODE_TYPES.SYSTEM_ERROR, '获取商家ids列表失败')
} catch (e) {
console.log(e, '获取ids商品列表失败')
return resultsModel.error(CODE_TYPES.SYSTEM_ERROR, '获取商家ids列表失败')
}
}
//淘宝top接口获取权益商品信息
async getPrizeByEname(session: string, ename: string) {
// sellerConfig = await this.getAccessTokenByOpenId()
// ename = this.context.data.ename
console.log(session, 'session')
let benefitData = await TBAPIS.getPrizeByEname(this.context, session, ename, B_APP_NAME)
console.log(benefitData, benefitData.result, 'benefitData.result.')
if (benefitData?.result?.success) {
const { result } = benefitData
let data = result?.datas?.['oright_dto'].reduce(
(
s: any[],
v: {
benefit_name: any
right_type_id: number
start_date: string | number | Date
end_date: string | number | Date
amount: number
}
) => {
return (s = [
...s,
{
benefitName: v.benefit_name,
rightTypeId: v.right_type_id == 3 ? 1 : v.right_type_id,
startTime: new Date(v.start_date).getTime(),
endTime: new Date(v.end_date).getTime(),
amount: v.amount ? v.amount / 100 + '' : ''
}
])
},
[]
)
console.log(JSON.stringify(result), 'alibaba.benefit.query')
return resultsModel.success(data)
}
return resultsModel.error(CODE_TYPES.SYSTEM_ERROR, '获取ename商品信息失败')
}
//淘宝top接口获取店铺信息
async getShopId() {
let sellerInfo = await this.getAccessTokenByOpenId()
console.log(sellerInfo, 'getShopId sellerInfo')
try {
let result = await TBAPIS.getShopInfo(this.context, {
session: sellerInfo.session,
fields: 'sid,title,pic_path'
})
console.log(result, 'getShopId result')
if (result) {
return resultsModel.success(result.shop)
} else {
return resultsModel.error(CODE_TYPES.SYSTEM_ERROR, '获取淘宝top店铺信息失败')
}
} catch (e) {
console.log(e, '获取店铺信息失败')
return resultsModel.error(CODE_TYPES.SYSTEM_ERROR, '获取淘宝top店铺信息失败')
}
}
async getItemListByStatus(session: string, { approveStatus = 'onsale', title = '', pageNo = 1, pageSize = 10 }) {
// let sellerConfig = await this.getAccessTokenByOpenId()
const data = { fields: GOODSINFO, pageNo, q: title, title, pageSize, session }
console.log(data, 'data')
const result =
approveStatus === 'onsale'
? await TBAPIS.getItemListOnSale(this.context, data)
: await TBAPIS.getItemListInStock(this.context, data)
if (!result) return resultsModel.error(CODE_TYPES.SYSTEM_ERROR, '获取商家在售列表失败')
const { items, total_results } = result
const itemsData = {
pageNo,
pageSize,
totalPages: Math.ceil(total_results / pageSize),
totalCount: total_results,
list:
items?.item?.reduce(
(s: any[], v: { num_iid: string; title: string; price: string; approveStatus: string; pic_url: string }) => {
return (s = [
...s,
{
itemId: v.num_iid,
name: v.title,
price: v.price,
approveStatus: v.approveStatus || approveStatus,
picUrl: v.pic_url
}
])
},
[]
) || []
}
return resultsModel.success(itemsData)
}
async getTemplateInstantiate() {
let sellerConfig = await this.getAccessTokenByOpenId()
let data = {
description: '此应用用于商家引导活动,商家可设置对应的奖品,在一定时间 内出奖,提升店铺用户活跃以及引导购买',
ext_json: {
name: 'online'
},
icon: 'https://ossgw.alicdn.com/taobao-miniapp/img/0193eaa9cc037b568acd9ccfe68a8499.jpg',
name: '店铺漂流' + MathRand(),
...TEMPLATE_INFO,
...sellerConfig
}
console.log('getTemplateInstantiateParams', data)
try {
let result = await TBAPIS.getTemplateInstantiate(this.context, data)
if (result) {
console.log(JSON.stringify(result), 'getTemplateInstantiate')
return result
}
return false
} catch (e) {
console.log(e, '获取getTemplateInstantiate失败')
return false
}
}
//模板小程序上线
async pushOnlineInstance(instanceInfo: { app_id: any; app_version: any }) {
let sellerConfig = await this.getAccessTokenByOpenId()
let data = {
...TEMPLATE_INFO,
...instanceInfo,
...sellerConfig
}
console.log('pushOnlineInstanceParams', data)
try {
let result = await TBAPIS.pushInstanceOnline(this.context, data)
if (result) {
console.log(JSON.stringify(result), 'pushOnlineInstance')
return result
}
return false
} catch (e) {
console.log(e, 'pushOnlineInstance失败')
return false
}
}
async getSubRelationship(nick: string) {
const cloud = this.context.cloud
let res = await cloud.topApi.invoke({
api: 'taobao.vas.subscribe.get',
data: {
article_code: APP_SUB_CODE,
nick
}
})
if (res && res['article_user_subscribes'] && res['article_user_subscribes']['article_user_subscribe'])
return res['article_user_subscribes']['article_user_subscribe'][0]
return false
}
//模板小程序更新
async updateMiniInstance(instanceInfo: {
clients: any
app_id: any
template_id: any
ext_json: { name: string }
template_version: string
}) {
let sellerConfig = await this.getAccessTokenByOpenId()
let data = {
...TEMPLATE_INFO,
...instanceInfo,
...sellerConfig
}
try {
let result = await TBAPIS.updateMiniInstance(this.context, data)
if (result) {
console.log(JSON.stringify(result), 'updateMiniInstance')
return result
}
return false
} catch (e) {
console.log(e, 'updateMiniInstance失败')
return false
}
}
}
/** @format */
interface IActivityInfo {
interface IActivityBaseInfo {
_id: string
openId: string
activityId?: string
openId?: string
rule: string
startTime: number
endTime: number
......@@ -9,12 +10,33 @@ interface IActivityInfo {
deleteStatus: 1 | 2
openPrizeStatus?: 1 | 2 | 3 | 4
remark?: string
createTime: number
updateTime: number
createTime?: number
updateTime?: number
awardReceiveExpiredTime?: number
tasks?: ITasks
}
interface IActivityPrize {
activityId?: string
ename?: string
prizeType: 1 | 2
type: 1 | 2 | 3 | 4 | 5
image: string
name: string
probability?: string | number
properiodto: number
properiodfrom: number
lockStatus?: 1 | 2
switchStock?: 1 | 2
rank?: string | number
useUrl?: string
stock: number
useStock: number
deleteStatus: 1 | 2
createTime: number
updateTime: number
}
interface ITasks {
attentionStore?: ITaskConfig
beMembership?: ITaskConfig
......
......@@ -15,15 +15,13 @@ interface Context {
appOwnerOpenId: string
fcInvokeId: string
cloud: any
data: {
[queryParam: string]: any
}
consumeMiniAppId?: string
appKey: string
data: any
}
interface IControllerInfos {
userInfo: IUserInfo
vipInfo: IVipInfo
activityInfo?: IActivityInfo
activityInfo?: IActivityBaseInfo
session: string
noCatch?: boolean
}
......
/** @format */
interface ISellerSaveInfo {
accessToken: string
openId: string
appKey: string
userNick: string
appOwnerOpenId: string
shopId?: string
createTime?: number
updateTime?: number
}
export const getConsumerSeller = ({ accessToken, openId }) => {
return {
// timestamp: formatTime(new Date(), "yyyy-MM-dd hh:mm:ss"),
open_id: openId,
// 'appkey': appKey,
// 'appsecret': secret,
session: accessToken,
// REST_URL: 'http://gw.api.taobao.com/router/rest'
};
};
\ No newline at end of file
/** @format */
import { transformBeijingDate, dateFormatter } from '../sdk'
// 获取今天的时间
export const getToday = () => {
console.log(transformBeijingDate(Date.now()))
return dateFormatter(transformBeijingDate(Date.now()), 'yyyy/MM/dd')
}
/** @format */
export * from './logger'
export * from './getToday'
export * from './time'
export * from './exportHandlers'
export * from './getSeller'
export * from './math'
......@@ -21,10 +21,8 @@ export const recordErrorLog = async (
errorMsg: string,
stack: string
) => {
const { openId } = context
const { openId, userNick } = context
const { activityId } = context.data || {}
const { userInfo } = baseInfos
const { userNick } = userInfo || {}
const logdao: IBaseDao = new BaseDao(context, ERROR_LOG_DB_NAME)
const functionName: string = `${context.fcName || ''}.${
context?.cloud?.dataspace?.context?.handler || context.handler
......
/** @format */
export function MathRand() {
var Num = ''
for (var i = 0; i < 6; i++) {
Num += Math.floor(Math.random() * 10)
}
return Num
}
/** @format */
import { transformBeijingDate, dateFormatter } from '../sdk'
// 获取今天的时间
export const getToday = () => {
console.log(transformBeijingDate(Date.now()))
return dateFormatter(transformBeijingDate(Date.now()), 'yyyy/MM/dd')
}
/**
* 传入时间戳(毫秒)
* 根据时间戳转换成number型日期进行差值结算,比如:2020318-2020317
*/
export function isNewDay(time: number) {
let date = new Date(time)
let dateNum = +(date.getFullYear() + '' + (date.getMonth() + 1) + '' + date.getDate())
let nowdate = new Date(Date.now())
let nowdateNum = +(nowdate.getFullYear() + '' + (nowdate.getMonth() + 1) + '' + nowdate.getDate())
return nowdateNum - dateNum > 0
}
export const formatTime = (thisDate: Date, fmt: string = 'yyyy-MM-dd hh:mm:ss') => {
var o = {
'M+': thisDate.getMonth() + 1,
'd+': thisDate.getDate(),
'h+': thisDate.getHours(),
'm+': thisDate.getMinutes(),
's+': thisDate.getSeconds(),
'q+': Math.floor((thisDate.getMonth() + 3) / 3),
S: thisDate.getMilliseconds()
}
if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (thisDate.getFullYear() + '').substr(4 - RegExp.$1.length))
for (var k in o)
if (new RegExp('(' + k + ')').test(fmt))
fmt = fmt.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ('00' + o[k]).substr(('' + o[k]).length))
return fmt
}
......@@ -173,6 +173,11 @@ astral-regex@^1.0.0:
resolved "https://registry.npm.taobao.org/astral-regex/download/astral-regex-1.0.0.tgz#6c8c3fb827dd43ee3918f27b82782ab7658a6fd9"
integrity sha1-bIw/uCfdQ+45GPJ7gngqt2WKb9k=
async-validator@^3.4.0:
version "3.4.0"
resolved "https://registry.npm.taobao.org/async-validator/download/async-validator-3.4.0.tgz?cache=0&sync_timestamp=1596623608639&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fasync-validator%2Fdownload%2Fasync-validator-3.4.0.tgz#871b3e594124bf4c4eb7bcd1a9e78b44f3b09cae"
integrity sha1-hxs+WUEkv0xOt7zRqeeLRPOwnK4=
balanced-match@^1.0.0:
version "1.0.0"
resolved "https://registry.npm.taobao.org/balanced-match/download/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767"
......
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