Commit 3799c78c authored by qinhaitao's avatar qinhaitao

fix: 🐛 dist 删除

parent ec34f1e4
/** @format */
interface Iconfig {
VIP_CALLBACK_URL: string;
VIP_MOCK: boolean;
}
export declare const getConfig: (context: Context) => Iconfig;
export {};
"use strict";
/** @format */
Object.defineProperty(exports, "__esModule", { value: true });
exports.getConfig = void 0;
var online_1 = require("./online");
var test_1 = require("./test");
var configs = {
online: online_1.default,
test: test_1.default
};
var getConfig = function (context) {
var env = context.env;
return configs[env] || configs.online;
};
exports.getConfig = getConfig;
//# sourceMappingURL=index.js.map
\ No newline at end of file
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":";AAAA,cAAc;;;AAEd,mCAA6B;AAC7B,+BAAyB;AAOzB,IAAM,OAAO,GAAG;IACd,MAAM,kBAAA;IACN,IAAI,gBAAA;CACL,CAAA;AAEM,IAAM,SAAS,GAAG,UAAC,OAAgB;IACxC,IAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAA;IACvB,OAAO,OAAO,CAAC,GAAG,CAAC,IAAI,OAAO,CAAC,MAAM,CAAA;AACvC,CAAC,CAAA;AAHY,QAAA,SAAS,aAGrB"}
\ No newline at end of file
/** @format */
declare const _default: {
VIP_CALLBACK_URL: string;
VIP_MOCK: boolean;
};
export default _default;
"use strict";
/** @format */
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = {
VIP_CALLBACK_URL: 'testUrl',
VIP_MOCK: false
};
//# sourceMappingURL=online.js.map
\ No newline at end of file
{"version":3,"file":"online.js","sourceRoot":"","sources":["../../src/config/online.ts"],"names":[],"mappings":";AAAA,cAAc;;AAEd,kBAAe;IACb,gBAAgB,EAAE,SAAS;IAC3B,QAAQ,EAAE,KAAK;CAChB,CAAA"}
\ No newline at end of file
declare const _default: {
VIP_CALLBACK_URL: string;
VIP_MOCK: boolean;
};
/** @format */
export default _default;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/** @format */
exports.default = {
VIP_CALLBACK_URL: 'onlineUrl',
VIP_MOCK: true
};
//# sourceMappingURL=test.js.map
\ No newline at end of file
{"version":3,"file":"test.js","sourceRoot":"","sources":["../../src/config/test.ts"],"names":[],"mappings":";;AAAA,cAAc;AACd,kBAAe;IACb,gBAAgB,EAAE,WAAW;IAC7B,QAAQ,EAAE,IAAI;CACf,CAAA"}
\ No newline at end of file
/** @format */
export declare const BusinessError: {
ERROR_UPDATE_RETRY: {
code: string;
defaultMsg: string;
};
ERROR_NO_ACTIVITY: {
code: string;
defaultMsg: string;
};
ERROR_ACTIVITY_NOSTART: {
code: string;
defaultMsg: string;
};
ERROR_ACTIVITY_OVER: {
code: string;
defaultMsg: string;
};
ERROR_NO_USER: {
code: string;
defaultMsg: string;
};
ERROR_NEEDMEMBER_DOHELP: {
code: string;
defaultMsg: string;
};
ERROR_NO_VIP: {
code: string;
defaultMsg: string;
};
ERROR_TASK_ALREADYRECEIVE: {
code: string;
defaultMsg: string;
};
ERROR_TASK_COMPLETE: {
code: string;
defaultMsg: string;
};
ERROR_TASK_NORECEIVE: {
code: string;
defaultMsg: string;
};
ERROR_INVALID_INVITE_ID: {
code: string;
defaultMsg: string;
};
ERROR_NO_CREDITS: {
code: string;
defaultMsg: string;
};
ERROR_TASK_LIMIT: {
code: string;
defaultMsg: string;
};
ERROR_FORBIDDEN_OPE: {
code: string;
defaultMsg: string;
};
ERROR_RECEIVE_PRIZE: {
code: string;
defaultMsg: string;
};
ERROR_SEND_PRIZE: {
code: string;
defaultMsg: string;
};
ERROR_NO_PRIZE: {
code: string;
defaultMsg: string;
};
ERROR_NO_STOCK: {
code: string;
defaultMsg: string;
};
ERROR_PRIZE_EXPIRED: {
code: string;
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;
SUCCESS: import("taobao-mini-sdk/lib/utils/codetypes").CodeType;
} & {
ERROR_UPDATE_RETRY: {
code: string;
defaultMsg: string;
};
ERROR_NO_ACTIVITY: {
code: string;
defaultMsg: string;
};
ERROR_ACTIVITY_NOSTART: {
code: string;
defaultMsg: string;
};
ERROR_ACTIVITY_OVER: {
code: string;
defaultMsg: string;
};
ERROR_NO_USER: {
code: string;
defaultMsg: string;
};
ERROR_NEEDMEMBER_DOHELP: {
code: string;
defaultMsg: string;
};
ERROR_NO_VIP: {
code: string;
defaultMsg: string;
};
ERROR_TASK_ALREADYRECEIVE: {
code: string;
defaultMsg: string;
};
ERROR_TASK_COMPLETE: {
code: string;
defaultMsg: string;
};
ERROR_TASK_NORECEIVE: {
code: string;
defaultMsg: string;
};
ERROR_INVALID_INVITE_ID: {
code: string;
defaultMsg: string;
};
ERROR_NO_CREDITS: {
code: string;
defaultMsg: string;
};
ERROR_TASK_LIMIT: {
code: string;
defaultMsg: string;
};
ERROR_FORBIDDEN_OPE: {
code: string;
defaultMsg: string;
};
ERROR_RECEIVE_PRIZE: {
code: string;
defaultMsg: string;
};
ERROR_SEND_PRIZE: {
code: string;
defaultMsg: string;
};
ERROR_NO_PRIZE: {
code: string;
defaultMsg: string;
};
ERROR_NO_STOCK: {
code: string;
defaultMsg: string;
};
ERROR_PRIZE_EXPIRED: {
code: string;
defaultMsg: 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 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 SEVEN_DAYS: number;
export declare const _48_HOURS: number;
export declare const DELETE_STATUS: {
EXIST: number;
DELETE: number;
};
export declare const TASK_TYPE_TEXT: {
member: string;
follow: string;
sign: string;
exchangeCredits: string;
invites: string;
orderGoods: string;
browseGoods: string;
jumpLink: string;
collectGoods: string;
};
export declare const TASK_CHECK_TYPE: {
value: {
list: string[];
reg: RegExp;
regName: string;
};
times: {
list: string[];
};
title: {
list: string[];
};
itemIds: {
list: string[];
};
taskRateType: {
list: string[];
};
link: {
list: string[];
};
};
export declare const PASS_URL_LIST: string[];
export declare const APP_SUB_CODE: string;
export declare const TEMPLATE_INFO: {
clients: string;
template_id: number;
template_version: string;
};
export declare const SHIP_STATUS: {
NO_ADDRESS: number;
NO_SHIP: number;
HAS_SHIP: number;
};
export declare const STOCK_TYPE: {
LIMIT: number;
NO_LIMIT: number;
};
"use strict";
/** @format */
Object.defineProperty(exports, "__esModule", { value: true });
exports.STOCK_TYPE = exports.SHIP_STATUS = exports.TEMPLATE_INFO = exports.APP_SUB_CODE = exports.PASS_URL_LIST = exports.TASK_CHECK_TYPE = exports.TASK_TYPE_TEXT = exports.DELETE_STATUS = exports._48_HOURS = exports.SEVEN_DAYS = 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 = {
// 更新重试失败(用于并发更新)
ERROR_UPDATE_RETRY: {
code: "210001",
defaultMsg: "\u7CFB\u7EDF\u9519\u8BEF"
},
// 活动不存在
ERROR_NO_ACTIVITY: {
code: "220001",
defaultMsg: "\u6D3B\u52A8\u4E0D\u5B58\u5728"
},
// 活动未开始
ERROR_ACTIVITY_NOSTART: {
code: "220002",
defaultMsg: "\u6D3B\u52A8\u672A\u5F00\u59CB"
},
// 活动已结束
ERROR_ACTIVITY_OVER: {
code: "220003",
defaultMsg: "\u6D3B\u52A8\u5DF2\u7ED3\u675F"
},
// 用户不存在
ERROR_NO_USER: {
code: "310002",
defaultMsg: "\u7528\u6237\u4E0D\u5B58\u5728"
},
// 需要成为会员才能助力哦
ERROR_NEEDMEMBER_DOHELP: {
code: "310004",
defaultMsg: '需要成为会员才能助力哦'
},
// 非店铺会员
ERROR_NO_VIP: {
code: "310005",
defaultMsg: '非店铺会员'
},
// 任务奖励已领取
ERROR_TASK_ALREADYRECEIVE: {
code: "430002",
defaultMsg: "\u4EFB\u52A1\u5956\u52B1\u5DF2\u9886\u53D6"
},
// 任务已完成
ERROR_TASK_COMPLETE: {
code: "430003",
defaultMsg: "\u4EFB\u52A1\u5DF2\u5B8C\u6210"
},
// 暂无次数可领取
ERROR_TASK_NORECEIVE: {
code: "430003",
defaultMsg: "\u6682\u65E0\u6B21\u6570\u53EF\u9886\u53D6"
},
ERROR_INVALID_INVITE_ID: {
code: "430004",
defaultMsg: "\u9080\u8BF7\u7801\u65E0\u6548"
},
ERROR_NO_CREDITS: {
code: "430005",
defaultMsg: "\u79EF\u5206\u4E0D\u8DB3"
},
ERROR_TASK_LIMIT: {
code: "430006",
defaultMsg: "\u4ECA\u65E5\u5B8C\u6210\u8BE5\u4EFB\u52A1\u6B21\u6570\u8D85\u9650"
},
ERROR_FORBIDDEN_OPE: {
code: "530001",
defaultMsg: "\u975E\u6CD5\u64CD\u4F5C"
},
ERROR_RECEIVE_PRIZE: {
code: "630002",
defaultMsg: "\u5956\u52B1\u5DF2\u9886\u53D6"
},
ERROR_SEND_PRIZE: {
code: "730001",
defaultMsg: "\u53D1\u5956\u5931\u8D25"
},
ERROR_NO_PRIZE: {
code: "730002",
defaultMsg: "\u5956\u54C1\u4E0D\u5B58\u5728"
},
ERROR_NO_STOCK: {
code: "730003",
defaultMsg: "\u5E93\u5B58\u4E0D\u8DB3"
},
ERROR_PRIZE_EXPIRED: {
code: "740001",
defaultMsg: "\u5956\u54C1\u5DF2\u8D85\u8FC7\u9886\u53D6\u65F6\u95F4"
}
};
// 活动开奖状态码
exports.OPEN_PRIZE_STATUS = {
// 待开奖
WAIT_AWARD: 1,
// 开奖中
PROCESSING: 2,
// 开奖成功
SUCCESS: 3,
// 开奖失败
FAIL: 4
};
// 领取奖品状态
exports.DRAW_STATUS = {
// 待领取
WAITAWARD: 1,
// 处理中
PROCESSING: 2,
// 领取成功
SUCCESS: 3,
// 领取失败
FAIL: 4,
// 已过期
EXPIRED: 5,
// 重新领取
RETRY: 6
};
// 日志类型: error,info
exports.LOGGER_TYPE = {
ERROR: 1,
INFO: 2
};
exports.PRIZE_TYPE = {
EQUITY: 1,
CREDITS: 2,
OBJECT: 3,
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.SEVEN_DAYS = 7 * 24 * 60 * 60 * 1000;
exports._48_HOURS = 48 * 60 * 60 * 1000;
exports.DELETE_STATUS = {
EXIST: 1,
DELETE: 2
};
exports.TASK_TYPE_TEXT = {
member: '成为会员',
follow: '关注店铺',
sign: '签到',
exchangeCredits: '兑换积分',
invites: '邀请好友',
orderGoods: '下单商品',
browseGoods: '浏览商品',
jumpLink: '跳转链接',
collectGoods: '收藏商品'
};
exports.TASK_CHECK_TYPE = {
value: {
list: ['member', 'follow', 'sign', 'exchangeCredits', 'invites', 'orderGoods', 'jumpLink', 'collectGoods'],
reg: /[1-99]/,
regName: '1-99之内'
},
times: {
list: ['exchangeCredits', 'invites', 'orderGoods', 'browseGoods', 'jumpLink', 'collectGoods']
},
title: {
list: ['invites', 'orderGoods', 'browseGoods', 'jumpLink', 'collectGoods']
},
itemIds: {
list: ['orderGoods', 'browseGoods', 'collectGoods']
},
taskRateType: {
list: ['invites', 'orderGoods', 'browseGoods', 'collectGoods']
},
link: { list: ['jumpLink'] }
};
exports.PASS_URL_LIST = [
'1688.cn',
'1688.com',
'alibaba.cn',
'alibaba.com',
'aliexpress.com',
'alimama.cn',
'alimama.com',
'alipay.com.cn',
'alipay.com',
'alipay.net',
'aliplay.com',
'alisoft.cn',
'alisoft.com',
'aliyun.com',
'aliyun.net',
'koubei.cn',
'koubei.com',
'taobao.cn',
'taobao.com',
'taobao.net',
'tb.cn',
'tmall.com',
'zhifu.com',
'zhifubao.com',
'juhuasuan.com',
'tmall.hk',
'tmall.com.hk',
'jiyoujia.com',
'pailitao.com',
'cainiao.com',
'dingtalk.com',
'yushanfang.com',
'guoguo-app.com',
'alihealth.cn',
'miaostreet.com',
'uc123.com',
'uc.cn',
'ucweb.com',
'aliyun-inc.com',
'cainiaoyizhan.com',
'umeng.com',
'aliplus.com',
'aliplay.com',
'taopiaopiao.com',
'youku.com',
'tudou.com',
'xinlingshou.cn',
'fliggy.com',
'feizhu.com',
'feizhu.cn'
];
//saas订购码 根据需求改变
exports.APP_SUB_CODE = 'FW_GOODS-1001086450';
exports.TEMPLATE_INFO = {
clients: 'taobao,tmall',
template_id: 3000000002590532,
template_version: '0.0.3'
};
//物流状态
exports.SHIP_STATUS = {
NO_ADDRESS: 1,
NO_SHIP: 2,
HAS_SHIP: 3
};
exports.STOCK_TYPE = {
LIMIT: 1,
NO_LIMIT: 2
};
//# 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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YAAY,EAAE,aAAa,EAAE,cAAc,CAAC;KAC/D;IACD,IAAI,EAAE,EAAE,IAAI,EAAE,CAAC,UAAU,CAAC,EAAE;CAC7B,CAAA;AAEY,QAAA,aAAa,GAAa;IACrC,SAAS;IACT,UAAU;IACV,YAAY;IACZ,aAAa;IACb,gBAAgB;IAChB,YAAY;IACZ,aAAa;IACb,eAAe;IACf,YAAY;IACZ,YAAY;IACZ,aAAa;IACb,YAAY;IACZ,aAAa;IACb,YAAY;IACZ,YAAY;IACZ,WAAW;IACX,YAAY;IACZ,WAAW;IACX,YAAY;IACZ,YAAY;IACZ,OAAO;IACP,WAAW;IACX,WAAW;IACX,cAAc;IACd,eAAe;IACf,UAAU;IACV,cAAc;IACd,cAAc;IACd,cAAc;IACd,aAAa;IACb,cAAc;IACd,gBAAgB;IAChB,gBAAgB;IAChB,cAAc;IACd,gBAAgB;IAChB,WAAW;IACX,OAAO;IACP,WAAW;IACX,gBAAgB;IAChB,mBAAmB;IACnB,WAAW;IACX,aAAa;IACb,aAAa;IACb,iBAAiB;IACjB,WAAW;IACX,WAAW;IACX,gBAAgB;IAChB,YAAY;IACZ,YAAY;IACZ,WAAW;CACZ,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;AAED,MAAM;AACO,QAAA,WAAW,GAAG;IACzB,UAAU,EAAE,CAAC;IACb,OAAO,EAAE,CAAC;IACV,QAAQ,EAAE,CAAC;CACZ,CAAA;AAEY,QAAA,UAAU,GAAG;IACxB,KAAK,EAAE,CAAC;IACR,QAAQ,EAAC,CAAC;CACX,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<any, false> | import("taobao-mini-sdk/lib/utils/resultmodel").Result<{
list: any;
total: any;
pageSize: number;
pageNo: number;
}, true>>;
/**
* 活动详情
*/
getActivityDetail(context: Context, {}: {}, [activityconfigService]: [ActivityconfigService]): Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result<any, false> | import("taobao-mini-sdk/lib/utils/resultmodel").Result<any, true>>;
/**
* 删除活动
*/
delActivity(context: Context, {}: {}, [activityconfigService]: [ActivityconfigService]): Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result<any, false> | import("taobao-mini-sdk/lib/utils/resultmodel").Result<false, true> | import("taobao-mini-sdk/lib/utils/resultmodel").Result<true, true>>;
/**
* 复制活动
*/
createCopyActivity(context: Context, {}: {}, [activityconfigService]: [ActivityconfigService]): Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result<any, false> | import("taobao-mini-sdk/lib/utils/resultmodel").Result<any, true>>;
}
"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 };
}
};
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
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.list = 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*/];
}
});
});
};
/**
* 复制活动
*/
ActivityController.prototype.createCopyActivity = function (context, _a, _b) {
var activityconfigService = _b[0];
return __awaiter(this, void 0, void 0, function () {
var activityId, result, _c, _id, rest, prizeInfoList, createResult, e_1;
return __generator(this, function (_d) {
switch (_d.label) {
case 0:
activityId = context.data.activityId;
_d.label = 1;
case 1:
_d.trys.push([1, 4, , 5]);
return [4 /*yield*/, activityconfigService.getActivityInfoByActivityId(activityId)];
case 2:
result = _d.sent();
if (!result)
return [2 /*return*/, sdk_1.resultsModel.error(constants_1.CODE_TYPES.SYSTEM_ERROR, "获取活动信息失败")];
_c = result.baseConfig, _id = _c._id, rest = __rest(_c, ["_id"]);
prizeInfoList = result.prizeConfig.map(function (v) {
delete v._id;
return v;
});
return [4 /*yield*/, activityconfigService.saveNewActivity(__assign(__assign({}, rest), { title: rest.title + '副本', startTime: Date.now() + constants_1.EIGHT_HOURS, endTime: Date.now() + constants_1.EIGHT_HOURS + constants_1.SEVEN_DAYS }), prizeInfoList, context.openId)];
case 3:
createResult = _d.sent();
if (createResult) {
return [2 /*return*/, sdk_1.resultsModel.success(createResult)];
}
else {
return [2 /*return*/, sdk_1.resultsModel.error(constants_1.CODE_TYPES.SYSTEM_ERROR, "复制活动失败")];
}
return [3 /*break*/, 5];
case 4:
e_1 = _d.sent();
console.log(e_1);
return [2 /*return*/, sdk_1.resultsModel.error(constants_1.CODE_TYPES.SYSTEM_ERROR, '复制活动失败')];
case 5: 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);
__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, "createCopyActivity", 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,4CAAoE;AACpE,0CAAoD;AACpD,8BAAqC;AACrC,sCAAkD;AAElD;IAAA;IAwGA,CAAC;IAvGC;;OAEG;IAEG,4CAAe,GAArB,UAAsB,OAAgB,EAAE,EAAE,EAAE,EAAgD;YAA/C,qBAAqB,QAAA;;;;;;wBACxD,MAAM,GAAK,OAAO,OAAZ,CAAY;wBAEb,qBAAM,qBAAqB,CAAC,uBAAuB,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,EAAA;;wBAAlF,MAAM,GAAG,SAAyE;wBACtF,IAAI,MAAM,EAAE;4BACV,MAAM,CAAC,IAAI,GAAG,MAAM,CAAC,IA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AAC;yBAC9D;;;;wBAED,OAAO,CAAC,GAAG,CAAC,GAAC,CAAC,CAAC;wBACf,sBAAO,kBAAY,CAAC,KAAK,CAAC,sBAAU,CAAC,YAAY,EAAE,QAAQ,CAAC,EAAA;;;;;KAE/D;IAlGD;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;IAOD;QAFC,uBAAW,CAAC,CAAC,YAAY,CAAC,CAAC;QAC3B,oBAAQ,CAAC,CAAC,+BAAqB,CAAC,CAAC;;;;gEAqCjC;IACH,yBAAC;CAAA,AAxGD,IAwGC;kBAxGoB,kBAAkB"}
\ No newline at end of file
/** @format */
import { AwardsService } from '../service';
export default class BaseController {
/**
* 活动中奖名单
*/
findWinnerInfoList(context: Context, { session }: {
session: any;
}, [awardsService]: [AwardsService]): Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result<false, true> | import("taobao-mini-sdk/lib/utils/resultmodel").Result<{
list: any;
total: any;
message: string;
pageNo: number;
pageSize: number;
}, true>>;
getAwardsList(context: Context, { session }: {
session: any;
}, [awardsService]: [AwardsService]): Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result<false, true> | import("taobao-mini-sdk/lib/utils/resultmodel").Result<{
list: any;
total: any;
message: string;
pageNo: number;
pageSize: number;
}, true>>;
/**
* 导出活动中奖名单
*/
exportAwardsList(context: Context, { session }: {
session: any;
}, [awardsService]: [AwardsService]): Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result<any, false> | import("taobao-mini-sdk/lib/utils/resultmodel").Result<any, true>>;
/**
* 导入发货
*/
downloadFile(context: Context, { session }: {
session: any;
}, [awardsService]: [AwardsService]): Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result<any, false> | import("taobao-mini-sdk/lib/utils/resultmodel").Result<{
total: number;
data: any;
}, true>>;
}
"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 };
}
};
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 constants_1 = require("./../constants");
var decorator_1 = require("../decorator");
var sdk_1 = require("../sdk");
var service_1 = require("../service");
var index_1 = require("../utils/index");
var xlsx = require("node-xlsx");
var BaseController = /** @class */ (function () {
function BaseController() {
}
/**
* 活动中奖名单
*/
BaseController.prototype.findWinnerInfoList = function (context, _a, _b) {
var session = _a.session;
var awardsService = _b[0];
return __awaiter(this, void 0, void 0, function () {
var _c, _d, activityId, _e, prizeId, _f, userNick, _g, shipStatus, _h, prizeType, _j, prizeDataType, _k, pageNo, _l, pageSize, startTime, endTime, awardList;
return __generator(this, function (_m) {
switch (_m.label) {
case 0:
_c = context.data, _d = _c.activityId, activityId = _d === void 0 ? '' : _d, _e = _c.prizeId, prizeId = _e === void 0 ? null : _e, _f = _c.userNick, userNick = _f === void 0 ? '' : _f, _g = _c.shipStatus, shipStatus = _g === void 0 ? null : _g, _h = _c.prizeType, prizeType = _h === void 0 ? null : _h, _j = _c.prizeDataType, prizeDataType = _j === void 0 ? null : _j, _k = _c.pageNo, pageNo = _k === void 0 ? 1 : _k, _l = _c.pageSize, pageSize = _l === void 0 ? 10 : _l, startTime = _c.startTime, endTime = _c.endTime;
return [4 /*yield*/, awardsService.getAwardListByActivityId({
activityId: activityId,
prizeId: prizeId,
userNick: userNick,
shipStatus: shipStatus,
type: prizeType,
prizeDataType: prizeDataType,
pageNo: pageNo,
pageSize: pageSize,
startTime: startTime,
endTime: endTime
})];
case 1:
awardList = _m.sent();
console.log("awardList: " + JSON.stringify(awardList));
return [2 /*return*/, sdk_1.resultsModel.success(awardList)];
}
});
});
};
//获取活动中奖名单 为导出做准备
BaseController.prototype.getAwardsList = function (context, _a, _b) {
var session = _a.session;
var awardsService = _b[0];
return __awaiter(this, void 0, void 0, function () {
var cloud, _c, activityId, title, prizeId, userNick, startTime, endTime, shipStatus, prizeType, prizeDataType, pageNo, pageSize, awardList;
return __generator(this, function (_d) {
switch (_d.label) {
case 0:
cloud = context.cloud;
_c = context.data, activityId = _c.activityId, title = _c.title, prizeId = _c.prizeId, userNick = _c.userNick, startTime = _c.startTime, endTime = _c.endTime, shipStatus = _c.shipStatus, prizeType = _c.prizeType, prizeDataType = _c.prizeDataType, pageNo = _c.pageNo, pageSize = _c.pageSize;
return [4 /*yield*/, awardsService.getAwardListByActivityId({
activityId: activityId,
title: title,
prizeId: prizeId,
userNick: userNick,
startTime: startTime,
endTime: endTime,
shipStatus: shipStatus,
type: prizeType,
prizeDataType: prizeDataType,
pageNo: pageNo,
pageSize: pageSize,
isExport: true
})];
case 1:
awardList = _d.sent();
return [2 /*return*/, sdk_1.resultsModel.success(awardList)];
}
});
});
};
/**
* 导出活动中奖名单
*/
BaseController.prototype.exportAwardsList = function (context, _a, _b) {
var session = _a.session;
var awardsService = _b[0];
return __awaiter(this, void 0, void 0, function () {
var cloud, _c, _d, list, title, res, _e, success, data, message, _f, _g, awwardList, total, _h, success_1, data_1, message_1, _j, awwardList_1, xlsxData, buffer, result;
return __generator(this, function (_k) {
switch (_k.label) {
case 0:
cloud = context.cloud;
_c = context.data, _d = _c.list, list = _d === void 0 ? [] : _d, title = _c.title;
res = [];
return [4 /*yield*/, this.getAwardsList(context, { session: session }, [awardsService])];
case 1:
_e = _k.sent(), success = _e.success, data = _e.data, message = _e.message;
_f = data || {}, _g = _f.list, awwardList = _g === void 0 ? [] : _g, total = _f.total;
res = __spreadArrays(res, awwardList);
_k.label = 2;
case 2:
if (!(total > res.length)) return [3 /*break*/, 4];
context.data.pageNo++;
return [4 /*yield*/, this.getAwardsList(context, { session: session }, [awardsService])];
case 3:
_h = _k.sent(), success_1 = _h.success, data_1 = _h.data, message_1 = _h.message;
_j = (data_1 || {}).list, awwardList_1 = _j === void 0 ? [] : _j;
if (success_1) {
res = __spreadArrays(res, awwardList_1);
}
else {
}
return [3 /*break*/, 2];
case 4:
console.log(list, '导出报表');
xlsxData = [
[
'奖品编号',
'用户id',
'中奖时间',
'地址填写时间',
'奖品类型',
'发奖来源',
'奖品名称',
'收货人',
'联系方式',
'收货地址',
'发货状态',
'物流公司',
'物流单号'
]
];
res.forEach(function (v, index, arr) {
var prizeDataType = '/';
var prizeType = '/';
var shipTxt = '/';
if (v) {
if (v.prizeDataType == 1)
prizeDataType = '关卡获得';
if (v.prizeDataType == 2)
prizeDataType = '排行榜';
if (v.prizeDataType == 3)
prizeDataType = '分享获得';
if (v.type == constants_1.PRIZE_TYPE.EQUITY)
prizeType = '优惠券';
if (v.type == constants_1.PRIZE_TYPE.CREDITS)
prizeType = '积分';
if (v.type == constants_1.PRIZE_TYPE.OBJECT) {
prizeType = '实物';
if (+v.shipStatus == constants_1.SHIP_STATUS.NO_ADDRESS)
shipTxt = '未填写地址';
if (+v.shipStatus == constants_1.SHIP_STATUS.NO_SHIP)
shipTxt = '未发货';
if (+v.shipStatus == constants_1.SHIP_STATUS.HAS_SHIP)
shipTxt = '已发货';
}
if (v.type == constants_1.PRIZE_TYPE.THANK)
prizeType = '谢谢参与';
}
xlsxData.push([
v._id,
v.userNick,
v.createTime ? index_1.formatTime(new Date(v.createTime + constants_1.EIGHT_HOURS)) : '',
v.type == 3 ? (v.receiveTime ? index_1.formatTime(new Date(v.receiveTime + constants_1.EIGHT_HOURS)) : '暂未填写') : '/',
prizeType,
prizeDataType,
v.type == 2 ? (v.credits || 0) + "\u79EF\u5206" : v.name || '',
v.type == 3 ? v.receiveName || '' : '/',
v.type == 3 ? (v.phone ? v.phone + '' : '暂未填写') : '/',
v.type == 3 ? v.province + v.city + v.area + v.streetName + v.addressDetail || '暂未填写' : '/',
shipTxt,
v.type == 3 ? v.shipCompany || '' : '/',
v.type == 3 ? (v.shipNum ? v.shipNum + '' : '') : '/'
]);
});
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 5:
result = _k.sent();
// result.url 需进行处理
if (result.url) {
result.url = result.url.replace('http', 'https').replace('-internal', '');
}
return [2 /*return*/, sdk_1.resultsModel.success(result)];
}
});
});
};
/**
* 导入发货
*/
BaseController.prototype.downloadFile = function (context, _a, _b) {
var session = _a.session;
var awardsService = _b[0];
return __awaiter(this, void 0, void 0, function () {
var cloud, _c, activityId, fileName, total, result, _d, sheets, data, i, prizeId, shipCompany, shipNum, result2;
return __generator(this, function (_e) {
switch (_e.label) {
case 0:
cloud = context.cloud;
_c = context.data, activityId = _c.activityId, fileName = _c.fileName;
total = 0;
_e.label = 1;
case 1:
_e.trys.push([1, 3, , 4]);
return [4 /*yield*/, cloud.file.downloadFile({ fileId: fileName })];
case 2:
result = _e.sent();
return [3 /*break*/, 4];
case 3:
_d = _e.sent();
return [2 /*return*/, sdk_1.resultsModel.error(constants_1.CODE_TYPES.SYSTEM_ERROR, 'fileId错误')];
case 4:
sheets = xlsx.parse(result);
console.log(sheets, 'sheets-------');
data = sheets[0].data;
console.log(JSON.stringify(data), 'data----------');
if (!(!data[1] || data[1].length !== 0)) return [3 /*break*/, 11];
if (!(data[1].length <= 3)) return [3 /*break*/, 9];
i = 1;
_e.label = 5;
case 5:
if (!(i < data.length)) return [3 /*break*/, 8];
prizeId = data[i][0];
shipCompany = data[i][1];
shipNum = data[i][2];
return [4 /*yield*/, awardsService.setUserShipStatus(activityId, prizeId, shipCompany, shipNum)];
case 6:
result2 = _e.sent();
total += result2;
_e.label = 7;
case 7:
i++;
return [3 /*break*/, 5];
case 8:
console.log(total, data, 'total,data');
return [2 /*return*/, sdk_1.resultsModel.success({ total: total, data: data })];
case 9:
console.log(data[1].length, 'length');
return [2 /*return*/, sdk_1.resultsModel.error(constants_1.CODE_TYPES.SYSTEM_ERROR, '导入文件格式错误')];
case 10: return [3 /*break*/, 12];
case 11: return [2 /*return*/, sdk_1.resultsModel.error(constants_1.CODE_TYPES.SYSTEM_ERROR, '导入文件出现错误')];
case 12: return [2 /*return*/];
}
});
});
};
__decorate([
decorator_1.paramsCheck(['activityId']),
decorator_1.services([service_1.AwardsService]),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, Object, Array]),
__metadata("design:returntype", Promise)
], BaseController.prototype, "findWinnerInfoList", null);
__decorate([
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)
], BaseController.prototype, "getAwardsList", null);
__decorate([
decorator_1.paramsCheck(['title']),
decorator_1.services([service_1.AwardsService]),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, Object, Array]),
__metadata("design:returntype", Promise)
], BaseController.prototype, "exportAwardsList", null);
__decorate([
decorator_1.paramsCheck(['activityId', 'fileName']),
decorator_1.services([service_1.AwardsService]),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, Object, Array]),
__metadata("design:returntype", Promise)
], BaseController.prototype, "downloadFile", null);
return BaseController;
}());
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEd,4CAA+E;AAC/E,0CAAoD;AAEpD,8BAAqC;AACrC,sCAA0C;AAC1C,wCAA2C;AAC3C,gCAAiC;AAEjC;IAAA;IAqNA,CAAC;IApNC;;OAEG;IAGG,2CAAkB,GAAxB,UAAyB,OAAgB,EAAE,EAAW,EAAE,EAAgC;YAA3C,OAAO,aAAA;YAAK,aAAa,QAAA;;;;;;wBAC9D,KAWF,OAAO,CAAC,IAAI,EAVd,kBAAe,EAAf,UAAU,mBAAG,EAAE,KAAA,EACf,eAAc,EAAd,OAAO,mBAAG,IAAI,KAAA,EACd,gBAAa,EAAb,QAAQ,mBAAG,EAAE,KAAA,EACb,kBAAiB,EAAjB,UAAU,mBAAG,IAAI,KAAA,EACjB,iBAAgB,EAAhB,SAAS,mBAAG,IAAI,KAAA,EAChB,qBAAoB,EAApB,aAAa,mBAAG,IAAI,KAAA,EACpB,cAAU,EAAV,MAAM,mBAAG,CAAC,KAAA,EACV,gBAAa,EAAb,QAAQ,mBAAG,EAAE,KAAA,EACb,SAAS,eAAA,EACT,OAAO,aAAA,CACO;wBAGA,qBAAM,aAAa,CAAC,wBAAwB,CAAC;gCAC3D,UAAU,YAAA;gCACV,OAAO,SAAA;gCACP,QAAQ,UAAA;gCACR,UAAU,YAAA;gCACV,IAAI,EAAE,SAAS;gCACf,aAAa,eAAA;gCACb,MAAM,QAAA;gCACN,QAAQ,UAAA;gCACR,SAAS,WAAA;gCACT,OAAO,SAAA;6BACR,CAAC,EAAA;;wBAXE,SAAS,GAAG,SAWd;wBAEF,OAAO,CAAC,GAAG,CAAC,gBAAc,IAAI,CAAC,SAAS,CAAC,SA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W,CAAC,CAAC,YAAY,CAAC,CAAC;QAC3B,oBAAQ,CAAC,CAAC,uBAAa,CAAC,CAAC;;;;4DA+BzB;IAKD;QAFC,uBAAW,CAAC,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;QACpC,oBAAQ,CAAC,CAAC,uBAAa,CAAC,CAAC;;;;uDAgCzB;IAOD;QAFC,uBAAW,CAAC,CAAC,OAAO,CAAC,CAAC;QACtB,oBAAQ,CAAC,CAAC,uBAAa,CAAC,CAAC;;;;0DAyFzB;IAOD;QAFC,uBAAW,CAAC,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;QACvC,oBAAQ,CAAC,CAAC,uBAAa,CAAC,CAAC;;;;sDAuCzB;IACH,qBAAC;CAAA,AArND,IAqNC;kBArNoB,cAAc"}
\ No newline at end of file
/** @format */
import { SellerService } from '../service';
export default class BaseController {
/**
* 保存授权信息
*/
sellerSave(context: Context, {}: {}, [sellerService]: [SellerService]): 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 sdk_1 = require("../sdk");
var service_1 = require("../service");
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)];
}
});
});
};
__decorate([
decorator_1.paramsCheck(['activityId']),
decorator_1.services([service_1.SellerService]),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, Object, Array]),
__metadata("design:returntype", Promise)
], BaseController.prototype, "sellerSave", null);
return BaseController;
}());
exports.default = BaseController;
//# sourceMappingURL=base.controller.js.map
\ No newline at end of file
{"version":3,"file":"base.controller.js","sourceRoot":"","sources":["../../src/controller/base.controller.ts"],"names":[],"mappings":";AAAA,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGd,0CAAoD;AAEpD,8BAAqC;AACrC,sCAA0C;AAC1C;IAAA;IAuCA,CAAC;IAtCC;;OAEG;IAGG,mCAAU,GAAhB,UAAiB,OAAgB,EAAE,EAAE,EAAE,EAA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3B,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<any, false> | import("taobao-mini-sdk/lib/utils/resultmodel").Result<string, true>>;
}
"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
{"version":3,"file":"rule.controller.js","sourceRoot":"","sources":["../../src/controller/rule.controller.ts"],"names":[],"mappings":";AAAA,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEd,4CAA2C;AAC3C,0CAAoD;AACpD,kCAAqC;AACrC,8BAAqC;AACrC,0CAA0C;AAC1C;IAAA;IA4BA,CAAC;IA3BC;;OAEG;IAGG,qCAAY,GAAlB,UAAmB,OAAgB,EAAE,EAAE;;;;gBAC/B,KAA+D,OAAO,CAAC,IAAI,EAAzE,aAAU,EAAV,KAAK,mBAAG,EAAE,KAAA,EAAE,iBAAc,EAAd,SAAS,mBAAG,EAAE,KAAA,EAAE,eAAY,EAAZ,OAAO,mBAAG,EAAE,KAAA,EAAE,iBAAc,EAAd,SAAS,mBAAG,EAAE,KAAA,CAAiB;gBAEjF,IAAI,KAAK,CAAC,MAAM,GAAG,EAAE;oBAAE,sBAAO,kBAAY,CAAC,KAAK,CAAC,sBAAU,CAAC,YAAY,EAAE,cAAc,CAAC,EAAA;gBACzF,IAAI,SAAS,GAAG,OAAO;oBAAE,sBAAO,kBAAY,CAAC,KAAK,CAAC,sBAAU,CAAC,YAAY,EAAE,cAAc,CAAC,EAAA;gBAC3F,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC;oBAAE,sBAAO,kBAAY,CAAC,KAAK,CAAC,sBAAU,CAAC,YAAY,EAAE,UAAU,CAAC,EAAA;gBAEtF,UAAU,GAAW,EAAE,CAAA;gBACrB,aAAa,GAAG,kBAAU,CAAC,IAAI,IAAI,CAAC,CAAC,SAAS,GAAG,uBAAW,CAAC,EAAE,qBAAqB,CAAC,CAAA;gBACrF,WAAW,GAAG,kBAAU,CAAC,IAAI,IAAI,CAAC,CAAC,OAAO,GAAG,uBAAW,CAAC,EAAE,qBAAqB,CAAC,CAAA;gBACvF,UAAU,GAAG,qCAAU,aAAa,UAAK,WAAW,sxBAAwJ,CAAA;gBACtM,QAAQ,GAAG,SAAS,CAAC,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';
export interface ISavePrizeParams {
prizeList?: Array<IActivityPrize>;
}
export interface ISaveActivityContext extends Context {
data: IActivityBaseInfo & ISavePrizeParams;
}
export default class ActivitSaveController {
/**
* 保存活动
*/
saveActivityInfo(context: ISaveActivityContext, {}: {}, [activityconfigService]: [ActivityconfigService]): Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result<any, false> | import("taobao-mini-sdk/lib/utils/resultmodel").Result<false, true> | import("taobao-mini-sdk/lib/utils/resultmodel").Result<true, true>>;
}
"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 };
}
};
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
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 constants_1 = require("./../constants");
var decorator_1 = require("../decorator");
var sdk_1 = require("../sdk");
var service_1 = require("../service");
var saveValidate_1 = require("../utils/saveValidate");
var ActivitSaveController = /** @class */ (function () {
function ActivitSaveController() {
}
/**
* 保存活动
*/
// @paramsCheck(['title', 'startTime', 'endTime', 'tasks', 'rule'])
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, prizeList, data, openId, baseData, allPrizeList, result, result, _g, bothIds, deleteIds, prizeResult;
return __generator(this, function (_h) {
switch (_h.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, prizeList = _c.prizeList, data = __rest(_c, ["title", "activityId", "startTime", "endTime", "tasks", "rule", "prizeList"]);
openId = context.openId;
baseData = __assign(__assign({ title: title,
startTime: startTime,
endTime: endTime,
rule: rule,
openId: openId,
tasks: tasks }, data), {
// 奖品过期时间, 根据需求领奖是否有过期时间
awardReceiveExpiredTime: endTime + constants_1._48_HOURS });
allPrizeList = __spreadArrays(prizeList.map(function (v, i) { return (__assign(__assign({}, v), { level: i + 1 })); }));
if (!!activityId) return [3 /*break*/, 2];
return [4 /*yield*/, activityconfigService.saveNewActivity(baseData, allPrizeList, openId)];
case 1:
result = _h.sent();
if (result || result === 0) {
return [2 /*return*/, sdk_1.resultsModel.success(true)];
}
else {
console.log(result, '保存活动失败');
return [2 /*return*/, sdk_1.resultsModel.error(constants_1.CODE_TYPES.SYSTEM_ERROR, '保存活动失败')];
}
return [3 /*break*/, 9];
case 2: return [4 /*yield*/, activityconfigService.updateBaseConfigInfo(activityId, baseData)
// 找到更新的和删除的奖品id
];
case 3:
result = _h.sent();
return [4 /*yield*/, activityconfigService.diffPrizeList(activityId, allPrizeList)
// 将删除的奖品逻辑删除
];
case 4:
_g = _h.sent(), bothIds = _g.bothIds, deleteIds = _g.deleteIds;
if (!(deleteIds === null || deleteIds === void 0 ? void 0 : deleteIds.length)) return [3 /*break*/, 6];
return [4 /*yield*/, activityconfigService.deletePrizeByIds(deleteIds)];
case 5:
result = _h.sent();
_h.label = 6;
case 6:
if (!(allPrizeList === null || allPrizeList === void 0 ? void 0 : allPrizeList.length)) return [3 /*break*/, 8];
return [4 /*yield*/, activityconfigService.insertAndUpdatePrize(activityId, allPrizeList, bothIds)];
case 7:
prizeResult = _h.sent();
if (prizeResult.failed.length) {
console.log(prizeResult.failed, '更新奖品失败');
return [2 /*return*/, sdk_1.resultsModel.error(constants_1.CODE_TYPES.SYSTEM_ERROR, '保存活动失败')];
}
_h.label = 8;
case 8:
if (result || result === 0) {
return [2 /*return*/, sdk_1.resultsModel.success(true)];
}
else {
console.log(result, '保存活动失败');
return [2 /*return*/, sdk_1.resultsModel.error(constants_1.CODE_TYPES.SYSTEM_ERROR, '保存活动失败')];
}
_h.label = 9;
case 9: return [2 /*return*/];
}
});
});
};
__decorate([
decorator_1.paramsValidate(saveValidate_1.saveParams),
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEd,4CAAsD;AACtD,0CAAoE;AACpE,8BAAqC;AACrC,sCAAkD;AAClD,sDAAkD;AAgBlD;IAAA;IA+EA,CAAC;IA9EC;;OAEG;IACH,mEAAmE;IAG7D,gDAAgB,GAAtB,UAAuB,OAA6B,EA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class BaseController {
/**
* 保存授权信息
*/
sellerSave(context: Context, {}: {}, [sellerService]: [SellerService]): Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result<any, false> | import("taobao-mini-sdk/lib/utils/resultmodel").Result<any, true>>;
sellerSaasSave(context: Context, {}: {}, [sellerService, taobaoTopService, InstanceService]: [SellerService, TaobaoTopService, InstanceService]): Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result<any, false> | import("taobao-mini-sdk/lib/utils/resultmodel").Result<{
deadline: any;
}, true>>;
}
"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,gBAA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;4BAC/C,aAAa;4BACb,MAAM,EAAE,cAAc,CAAC,IAAI,CAAC,GAAG;yBAChC,CAAC,EAAA;;wBAHF,SAGE,CAAA;wBACF,qBAAM,eAAe,CAAC,kBAAkB,CAAC,aAAa,EAAE;gCACtD,aAAa;gCACb,MAAM,EAAE,cAAc,CAAC,IAAI,CAAC,GAAG;6BAChC,CAAC,EAAA;;wBAHF,SAGE,CAAA;;6BAEJ,sBAAO,kBAAY,CAAC,OAAO,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,IAAI,EAAE,EAAE,CAAC,EAAA;;;;KAClE;IAzJD;QADC,oBAAQ,CAAC,CAAC,uBAAa,CAAC,CAAC;;;;oDAkCzB;IAGD;QADC,oBAAQ,CAAC,CAAC,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 { UserService, BaseService, AccessService } from '../service';
export default class Share {
/**
* 完成分享
*/
insertShareRecord(context: Context, { userInfo, vipInfo, activityInfo }: IControllerInfos, [userService, baseService, accessService]: [UserService, BaseService, AccessService]): 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 check_1 = require("../decorator/check");
var services_1 = require("../decorator/services");
var sdk_1 = require("../sdk");
var utils_1 = require("../utils");
var service_1 = require("../service");
// {
// "handler": "doFollowTask",
// "data": {
// "activityId": "5f213791964f9706aa59b192"
// }
// }
var Share = /** @class */ (function () {
function Share() {
}
/**
* 完成分享
*/
Share.prototype.insertShareRecord = function (context, _a, _b) {
var userInfo = _a.userInfo, vipInfo = _a.vipInfo, activityInfo = _a.activityInfo;
var userService = _b[0], baseService = _b[1], accessService = _b[2];
return __awaiter(this, void 0, void 0, function () {
var _c, activityId, inviteId, openId, inviteUserInfo, isFirstLogin, isValidShare, tasks, value, today, inviteUserId;
var _d;
return __generator(this, function (_e) {
switch (_e.label) {
case 0:
_c = context.data, activityId = _c.activityId, inviteId = _c.inviteId;
openId = context.openId;
return [4 /*yield*/, userService.getUserInfoByOpenId(inviteId)
// inviteId的用户信息查询不到, 则inviteId无效
];
case 1:
inviteUserInfo = _e.sent();
// inviteId的用户信息查询不到, 则inviteId无效
if (!inviteUserInfo)
return [2 /*return*/, sdk_1.resultsModel.error(constants_1.CODE_TYPES.ERROR_INVALID_INVITE_ID)];
return [4 /*yield*/, accessService.getAccessCount()];
case 2:
isFirstLogin = (_e.sent()) === 1;
isValidShare = [isFirstLogin].every(function (v) { return !!v; });
tasks = activityInfo.tasks;
value = (tasks || {}).inviteFriends.value;
today = utils_1.getToday();
if (!isValidShare) return [3 /*break*/, 4];
inviteUserId = inviteUserInfo._id;
// 增加邀请人的待领取次数和邀请记录
return [4 /*yield*/, userService.updateUser(inviteUserId, {
$inc: {
'remainTimes.invites': value
},
$push: (_d = {},
_d["taskInfo." + today + ".invites"] = { openId: openId, createTime: Date.now() },
_d)
})];
case 3:
// 增加邀请人的待领取次数和邀请记录
_e.sent();
_e.label = 4;
case 4: return [2 /*return*/, sdk_1.resultsModel.success(true)];
}
});
});
};
__decorate([
check_1.paramsCheck(['activityId', 'inviteId']),
check_1.activityTimeCheck,
services_1.services([service_1.UserService, service_1.BaseService, service_1.AccessService]),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, Object, Array]),
__metadata("design:returntype", Promise)
], Share.prototype, "insertShareRecord", null);
return Share;
}());
exports.default = Share;
//# sourceMappingURL=share.controller.js.map
\ No newline at end of file
{"version":3,"file":"share.controller.js","sourceRoot":"","sources":["../../src/controller/share.controller.ts"],"names":[],"mappings":";AAAA,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEd,4CAA2C;AAC3C,4CAA8E;AAC9E,kDAAgD;AAEhD,8BAAqC;AACrC,kCAAqD;AACrD,sCAAoE;AAEpE,IAAI;AACJ,+BAA+B;AAC/B,cAAc;AACd,+CAA+C;AAC/C,MAAM;AACN,IAAI;AACJ;IAAA;IAoDA,CAAC;IAnDC;;OAEG;IAIG,iCAAiB,GAAvB,UACE,OAAgB,EAChB,EAAqD,EACrD,EAAoF;YADlF,QAAQ,cAAA,EAAE,OAAO,aAAA,EAAE,YAAY,kBAAA;YAChC,WAAW,QAAA,EAAE,WAAW,QAAA,EAAE,aAAa,QAAA;;;;;;;wBAElC,KAA2B,OAAO,CAAC,IAAI,EAArC,UAAU,gBAAA,EAAE,QAAQ,cAAA,CAAiB;wBACrC,MAAM,GAAK,OAAO,OAAZ,CAAY;wBAEQ,qBAAM,WAAW,CAAC,mBAAmB,CAAC,QAAQ,CAAC;4BACjF,iCAAiC;0BADgD;;wBAA3E,cAAc,GAAc,SAA+C;wBACjF,iCAAiC;wBACjC,IAAI,CAAC,cAAc;4BAAE,sBAAO,kBAAY,CAAC,KAAK,CAAC,sBAAU,CAAC,uBAAuB,CAAC,EAAA;wBAEnD,qBAAM,aAAa,CAAC,cAAc,EAAE,EAAA;;wBAA7D,YAAY,GAAY,CAAC,SAAoC,CAAC,KAAK,CAAC;wBAMpE,YAAY,GAAG,CAAC,YAAY,CAAC,CAAC,KAAK,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,CAAC,EAAH,CAAG,CAAC,CAAA;wBAG3C,KAAK,GAAK,YAAY,MAAjB,CAAiB;wBAGX,KAAK,GACZ,CAAA,KAAK,IAAI,EAAE,CAAA,oBADC,CACD;wBAIjB,KAAK,GAAG,gBAAQ,EAAE,CAAA;6BACpB,YAAY,EAAZ,wBAAY;wBACD,YAAY,GAAK,cAAc,IAAnB,CAAmB;wBAC5C,mBAAmB;wBACnB,qBAAM,WAAW,CAAC,UAAU,CAAC,YAAY,EAAE;gCACzC,IAAI,EAAE;oCACJ,qBAAqB,EAAE,KAAK;iCAC7B;gCACD,KAAK;oCACH,GAAC,cAAY,KAAK,aAAU,IAAG,EAAE,MAAM,QAAA,EAAE,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE;uCAClE;6BACF,CAAC,EAAA;;wBARF,mBAAmB;wBACnB,SAOE,CAAA;;4BAGJ,sBAAO,kBAAY,CAAC,OAAO,CAAC,IAAI,CAAC,EAAA;;;;KAClC;IA5CD;QAHC,mBAAW,CAAC,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;QACvC,yBAAiB;QACjB,mBAAQ,CAAC,CAAC,qBAAW,EAAE,qBAAW,EAAE,uBAAa,CAAC,CAAC;;;;kDA6CnD;IACH,YAAC;CAAA,AApDD,IAoDC;kBApDoB,KAAK"}
\ No newline at end of file
/** @format */
/** @format */
export default class StatController {
/**
* 统计数据
*/
getStats(context: Context): Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result>;
}
"use strict";
/** @format */
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 db_1 = require("../db");
var sdk_1 = require("../sdk");
var constants_1 = require("../constants");
var xlsx = require("node-xlsx");
/** @format */
var StatController = /** @class */ (function () {
function StatController() {
}
/**
* 统计数据
*/
StatController.prototype.getStats = function (context) {
return __awaiter(this, void 0, void 0, function () {
var _a, activityId, startDay, endDay, userDao, accessDao, recordDao, awardsDao, oneDay, xlsxData, day, PV, UV, newUV, vipPV, noVipPV, vipUV, noVipUV, newVipUV, followPV, followUV, inviteSuccessUV, receiveShareUV, receiveShareVipUV, receiveShareNoVipUV, keyValueMapper, tommorrow, buffer, result, e_1;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
_a = context.data, activityId = _a.activityId, startDay = _a.startDay, endDay = _a.endDay;
userDao = new sdk_1.BaseDao(context, db_1.USER_DB_NAME);
accessDao = new sdk_1.BaseDao(context, db_1.ACCESS_DB_NAME);
recordDao = new sdk_1.BaseDao(context, db_1.RECORD_DB_NAME);
awardsDao = new sdk_1.BaseDao(context, db_1.AWARDS_DB_NAME);
oneDay = 24 * 3600 * 1000;
xlsxData = [];
_b.label = 1;
case 1:
_b.trys.push([1, 19, , 20]);
day = startDay;
_b.label = 2;
case 2:
if (!(new Date(day).getTime() <= new Date(endDay).getTime())) return [3 /*break*/, 17];
return [4 /*yield*/, accessDao.count({ activityId: activityId, createDay: day })
// 访问UV
];
case 3:
PV = _b.sent();
return [4 /*yield*/, accessDao.aggregate([
{ $match: { activityId: activityId, createDay: day } },
{ $group: { _id: '$openId', count: { $sum: 1 } } }
])];
case 4:
UV = (_b.sent()).length;
return [4 /*yield*/, userDao.count({
activityId: activityId,
createDay: day
})
// 已入会PV
];
case 5:
newUV = _b.sent();
return [4 /*yield*/, accessDao.count({ activityId: activityId, createDay: day, isVip: true })
// 未入会PV
];
case 6:
vipPV = _b.sent();
return [4 /*yield*/, accessDao.count({ activityId: activityId, createDay: day, isVip: false })
// 已入会UV
];
case 7:
noVipPV = _b.sent();
return [4 /*yield*/, accessDao.aggregate([
{ $match: { activityId: activityId, createDay: day, isVip: true } },
{ $group: { _id: '$openId', count: { $sum: 1 } } }
])];
case 8:
vipUV = (_b.sent()).length;
return [4 /*yield*/, accessDao.aggregate([
{ $match: { activityId: activityId, createDay: day, isVip: false } },
{ $group: { _id: '$openId', count: { $sum: 1 } } }
])];
case 9:
noVipUV = (_b.sent()).length;
return [4 /*yield*/, userDao.count({
activityId: activityId,
'member.newMember': true,
'member.bememberDay': day
})];
case 10:
newVipUV = _b.sent();
return [4 /*yield*/, recordDao.count({
activityId: activityId,
createDay: day,
recordType: constants_1.RECORD_TYPE.FOLLOW_TASK.type
})];
case 11:
followPV = _b.sent();
return [4 /*yield*/, recordDao.aggregate([
{ $match: { activityId: activityId, createDay: day, recordType: constants_1.RECORD_TYPE.FOLLOW_TASK.type } },
{ $group: { _id: '$openId', count: { $sum: 1 } } }
])];
case 12:
followUV = (_b.sent()).length;
return [4 /*yield*/, recordDao.aggregate([
{ $match: { activityId: activityId, createDay: day, recordType: constants_1.RECORD_TYPE.INVITE_SUCCESS.type } },
{ $group: { _id: '$inviteId', count: { $sum: 1 } } }
])];
case 13:
inviteSuccessUV = (_b.sent()).length;
return [4 /*yield*/, recordDao.aggregate([
{ $match: { activityId: activityId, createDay: day, recordType: constants_1.RECORD_TYPE.RECEIVE_INVITE.type } },
{ $group: { _id: '$openId', count: { $sum: 1 } } }
])];
case 14:
receiveShareUV = (_b.sent()).length;
return [4 /*yield*/, accessDao.aggregate([
{ $match: { activityId: activityId, createDay: day, isReceiveShare: true, isVip: true } },
{ $group: { _id: '$openId', count: { $sum: 1 } } }
])];
case 15:
receiveShareVipUV = (_b.sent()).length;
return [4 /*yield*/, accessDao.aggregate([
{ $match: { activityId: activityId, createDay: day, isReceiveShare: true, isVip: false } },
{ $group: { _id: '$openId', count: { $sum: 1 } } }
])];
case 16:
receiveShareNoVipUV = (_b.sent()).length;
keyValueMapper = {
时间: day,
访问PV: PV,
访问UV: UV,
新增UV: newUV,
已入会PV: vipPV,
已入会UV: vipUV,
未入会PV: noVipPV,
未入会UV: noVipUV,
新入会UV: newVipUV,
关注店铺完成PV: followPV,
关注店铺完成UV: followUV,
// 签到PV: signTaskPV,
// 签到UV: signTaskUV,
邀请好友完成UV: inviteSuccessUV,
带来好友UV: receiveShareUV,
带来好友已入会UV: receiveShareVipUV,
带来好友未入会UV: receiveShareNoVipUV
};
if (day === startDay) {
xlsxData.push(Object.keys(keyValueMapper));
}
// @ts-ignore
xlsxData.push(Object.values(keyValueMapper));
tommorrow = new Date(day).getTime() + oneDay;
day = sdk_1.dateFormatter(sdk_1.transformBeijingDate(tommorrow), 'yyyy/MM/dd');
return [3 /*break*/, 2];
case 17:
buffer = xlsx.build([
{
name: "\u6570\u636E\u7EDF\u8BA1" + startDay.replace(/\//g, '-') + "-" + endDay.replace(/\//g, '-'),
data: xlsxData
}
]);
return [4 /*yield*/, context.cloud.file.uploadFile({
fileContent: buffer,
fileName: "\u6570\u636E\u7EDF\u8BA1" + startDay.replace(/\//g, '-') + "-" + endDay.replace(/\//g, '-') + ".xlsx"
})];
case 18:
result = _b.sent();
console.log(xlsxData, 'xlsxData');
if (result.url) {
result.url = result.url.replace('http', 'https').replace('-internal', '');
}
return [2 /*return*/, sdk_1.resultsModel.success(result.url)];
case 19:
e_1 = _b.sent();
console.log('上传文件出错', e_1);
// 打印日志
return [2 /*return*/, sdk_1.resultsModel.error(constants_1.CODE_TYPES.SYSTEM_ERROR, "\u4E0A\u4F20\u6587\u4EF6\u9519\u8BEF")];
case 20: return [2 /*return*/];
}
});
});
};
return StatController;
}());
exports.default = StatController;
//# sourceMappingURL=stat.controller.js.map
\ No newline at end of file
{"version":3,"file":"stat.controller.js","sourceRoot":"","sources":["../../src/controller/stat.controller.ts"],"names":[],"mappings":";AAAA,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEd,4BAAoF;AACpF,8BAAmF;AACnF,0CAAsD;AACtD,gCAAiC;AAEjC,cAAc;AACd;IAAA;IAyKA,CAAC;IAxKC;;OAEG;IACG,iCAAQ,GAAd,UAAe,OAAgB;;;;;;wBACvB,KAAmC,OAAO,CAAC,IAAI,EAA7C,UAAU,gBAAA,EAAE,QAAQ,cAAA,EAAE,MAAM,YAAA,CAAiB;wBAE/C,OAAO,GAAa,IAAI,aAAO,CAAC,OAAO,EAAE,iBAAY,CAAC,CAAA;wBACtD,SAAS,GAAa,IAAI,aAAO,CAAC,OAAO,EAAE,mBAAc,CAAC,CAAA;wBAC1D,SAAS,GAAa,IAAI,aAAO,CAAC,OAAO,EAAE,mBAAc,CAAC,CAAA;wBAC1D,SAAS,G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AAC,KAAK,EAAE,GAAG,CAAG;gCACzE,IAAI,EAAE,QAAQ;6BACf;yBACF,CAAC,CAAA;wBAIW,qBAAM,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC;gCAC/C,WAAW,EAAE,MAAM;gCACnB,QAAQ,EAAE,6BAAO,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,SAAI,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,UAAO;6BACnF,CAAC,EAAA;;wBAHE,MAAM,GAAG,SAGX;wBACF,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAA;wBACjC,IAAI,MAAM,CAAC,GAAG,EAAE;4BACd,MAAM,CAAC,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAA;yBAC1E;wBACD,sBAAO,kBAAY,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,EAAA;;;wBAEvC,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAC,CAAC,CAAA;wBACxB,OAAO;wBACP,sBAAO,kBAAY,CAAC,KAAK,CAAC,sBAAU,CAAC,YAAY,EAAE,sCAAQ,CAAC,EAAA;;;;;KAE/D;IACH,qBAAC;AAAD,CAAC,AAzKD,IAyKC"}
\ 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<any, false> | import("taobao-mini-sdk/lib/utils/resultmodel").Result<{
pageNo: number;
pageSize: number;
totalPages: number;
totalCount: any;
list: any;
}, true>>;
/**
* 通过状态获取top商品列表
*/
findItemListByIds(context: Context, { session }: {
session: any;
}, [taobaoTopService]: [TaobaoTopService]): Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result<any, false> | import("taobao-mini-sdk/lib/utils/resultmodel").Result<{
list: any;
totalCount: any;
}, true>>;
/**
* 通过ename获取权益信息
*/
queryBenefitByEname(context: Context, { session }: {
session: any;
}, [taobaoTopService]: [TaobaoTopService]): Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result<any, false> | import("taobao-mini-sdk/lib/utils/resultmodel").Result<any, true>>;
}
"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;IA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BAAgB,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
/** @format */
import { UserService, TaskService } from '../service';
export default class Task {
/**
* 任务列表
*/
getTaskList(context: Context, { userInfo, vipInfo, activityInfo, session }: IControllerInfos, [taskService]: [TaskService]): Promise<Result>;
/**
* 完成关注店铺任务
*/
doFollowTask(context: Context, { userInfo, activityInfo }: IControllerInfos, [TaskService]: [TaskService]): Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result>;
/**
* 积分兑换次数
*/
doExchangeCreditsTask(context: Context, { userInfo, activityInfo, session }: IControllerInfos, [userService, taskService]: [UserService, TaskService]): Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result>;
/**
* 浏览商品
*/
doBrowseGoodsTask(context: Context, { userInfo, activityInfo }: IControllerInfos, [taskService]: [TaskService]): 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 sdk_1 = require("../sdk");
var utils_1 = require("../utils");
var service_1 = require("../service");
// {
// "handler": "getTaskList",
// "data": {
// "activityId": "5f213791964f9706aa59b192"
// }
// }
var Task = /** @class */ (function () {
function Task() {
}
/**
* 任务列表
*/
Task.prototype.getTaskList = function (context, _a, _b) {
var userInfo = _a.userInfo, vipInfo = _a.vipInfo, activityInfo = _a.activityInfo, session = _a.session;
var taskService = _b[0];
return __awaiter(this, void 0, void 0, function () {
var tasks, updatedUserInfo, _c, _d, _e, _f, vipTask, followTask;
return __generator(this, function (_g) {
switch (_g.label) {
case 0:
tasks = activityInfo.tasks;
_d = (_c = taskService).updateTasks;
_e = [userInfo._id];
_f = [taskService.updateVipTaskStatus(userInfo, vipInfo, tasks)];
return [4 /*yield*/, taskService.updateOrderGoodsTask(userInfo, tasks, session)];
case 1: return [4 /*yield*/, _d.apply(_c, _e.concat([_f.concat([
_g.sent()
])]))
// 会员任务
];
case 2:
updatedUserInfo = _g.sent();
vipTask = taskService.initVipTask(updatedUserInfo, vipInfo, tasks);
followTask = taskService.initFollowTask(updatedUserInfo, tasks);
// // 下单任务
// const orderGoodsTask = taskService.initOrderGoodsTask(updatedUserInfo, tasks)
// // 浏览商品任务
// const browseGoodsTask = taskService.initBrowseGoodsTask(updatedUserInfo, tasks)
// // 邀请任务
// const invitesTask = taskService.initInvitesTask(updatedUserInfo, tasks)
// 积分兑换
//const exchangeCreditsTask = taskService.initExchangeCreditsTask(updatedUserInfo, tasks)
return [2 /*return*/, sdk_1.resultsModel.success([vipTask, followTask])];
}
});
});
};
/**
* 完成关注店铺任务
*/
Task.prototype.doFollowTask = function (context, _a, _b) {
var userInfo = _a.userInfo, activityInfo = _a.activityInfo;
var TaskService = _b[0];
return __awaiter(this, void 0, void 0, function () {
var follow, flag, newFollow, hasFollowed, result;
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
follow = userInfo.follow;
flag = follow.flag, newFollow = follow.newFollow;
hasFollowed = flag || newFollow;
if (hasFollowed)
return [2 /*return*/, sdk_1.resultsModel.error(constants_1.CODE_TYPES.ERROR_TASK_COMPLETE)
// 更新状态
];
return [4 /*yield*/, TaskService.updateFollowTask(userInfo, activityInfo)];
case 1:
result = _c.sent();
return [2 /*return*/, result ? sdk_1.resultsModel.success(true) : sdk_1.resultsModel.error(constants_1.CODE_TYPES.SYSTEM_ERROR)];
}
});
});
};
/**
* 积分兑换次数
*/
Task.prototype.doExchangeCreditsTask = function (context, _a, _b) {
var userInfo = _a.userInfo, activityInfo = _a.activityInfo, session = _a.session;
var userService = _b[0], taskService = _b[1];
return __awaiter(this, void 0, void 0, function () {
var openId, credits, _id, taskInfo, taskType, _c, value, times, taskRateType, today, todayTimes, myCredits, result;
return __generator(this, function (_d) {
switch (_d.label) {
case 0:
openId = context.openId;
credits = context.data.credits;
_id = userInfo._id, taskInfo = userInfo.taskInfo;
taskType = "exchangeCredits";
_c = activityInfo.tasks.exchangeCredits, value = _c.value, times = _c.times, taskRateType = _c.taskRateType;
today = utils_1.getToday();
todayTimes = taskService.getTodayCompleteTask(taskType, userInfo).todayTimes;
// 如果每日限制次数并到达了限制次数
if (times && times === todayTimes && taskRateType === constants_1.TASK_RATE_TYPE.EVERYDAY) {
return [2 /*return*/, sdk_1.resultsModel.error(constants_1.CODE_TYPES.ERROR_TASK_LIMIT)];
}
return [4 /*yield*/, sdk_1.TBAPIS.queryCredits(context, session)];
case 1:
myCredits = _d.sent();
console.log('myCredits', myCredits);
// 积分不足
if (myCredits < credits)
return [2 /*return*/, sdk_1.resultsModel.error(constants_1.CODE_TYPES.ERROR_NO_CREDITS)
// 扣积分
];
return [4 /*yield*/, sdk_1.TBAPIS.changeCredits(context, session, {
quantity: +credits,
change_type: 2,
opt_type: '1',
remark: "\u79EF\u5206\u5151\u6362\u4EFB\u52A1\u51CF\u79EF\u5206"
})];
case 2:
result = _d.sent();
if (!result)
return [2 /*return*/, sdk_1.resultsModel.error(constants_1.CODE_TYPES.SYSTEM_ERROR)
// 更新user表
];
// 更新user表
return [4 /*yield*/, taskService.updateUserTaskRecord(taskType, value, userInfo)];
case 3:
// 更新user表
_d.sent();
return [2 /*return*/, sdk_1.resultsModel.success(true)];
}
});
});
};
/**
* 浏览商品
*/
Task.prototype.doBrowseGoodsTask = function (context, _a, _b) {
var userInfo = _a.userInfo, activityInfo = _a.activityInfo;
var taskService = _b[0];
return __awaiter(this, void 0, void 0, function () {
var taskType, itemId, _c, taskRateType, times, itemIds, value, itemIdArray, _d, todayTaskInfo, todayTimes, hasCompleteToday;
return __generator(this, function (_e) {
switch (_e.label) {
case 0:
taskType = 'browseGoods';
itemId = context.data.itemId;
_c = activityInfo.tasks.browseGoods, taskRateType = _c.taskRateType, times = _c.times, itemIds = _c.itemIds, value = _c.value;
itemIdArray = Array.isArray(itemIds) ? itemIds : itemIds.split(',').map(function (v) { return +v; });
// B端配置商品ids不匹配正确
if (!itemIdArray.includes(+itemId))
return [2 /*return*/, sdk_1.resultsModel.error(constants_1.CODE_TYPES.PARAMS_ERROR, '商品id不匹配')];
_d = taskService.getTodayCompleteTask('browseGoods', userInfo), todayTaskInfo = _d.todayTaskInfo, todayTimes = _d.todayTimes;
hasCompleteToday = todayTaskInfo.filter(function (v) { return v.itemId === itemId; }).length &&
taskRateType === constants_1.TASK_RATE_TYPE.EVERYDAY;
// 今日任务已经完成
if (hasCompleteToday) {
return [2 /*return*/, sdk_1.resultsModel.error(constants_1.CODE_TYPES.PARAMS_ERROR, '今日该商品任务已完成')];
}
// 次数超限
if (times && times === todayTimes && taskRateType === constants_1.TASK_RATE_TYPE.EVERYDAY) {
return [2 /*return*/, sdk_1.resultsModel.error(constants_1.CODE_TYPES.ERROR_TASK_LIMIT)];
}
// 更新user表
return [4 /*yield*/, taskService.updateUserTaskRecord(taskType, value, userInfo, {
itemId: itemId
})];
case 1:
// 更新user表
_e.sent();
return [2 /*return*/, sdk_1.resultsModel.success(true)];
}
});
});
};
__decorate([
decorator_1.paramsCheck(['activityId']),
decorator_1.userCheck({ intercept: true }),
decorator_1.activityTimeCheck,
decorator_1.services([service_1.TaskService]),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, Object, Array]),
__metadata("design:returntype", Promise)
], Task.prototype, "getTaskList", null);
__decorate([
decorator_1.paramsCheck(['activityId']),
decorator_1.activityTimeCheck,
decorator_1.services([service_1.TaskService]),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, Object, Array]),
__metadata("design:returntype", Promise)
], Task.prototype, "doFollowTask", null);
__decorate([
decorator_1.paramsCheck(['activityId', 'credits']),
decorator_1.userCheck({ intercept: true }),
decorator_1.activityTimeCheck,
decorator_1.services([service_1.UserService, service_1.TaskService]),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, Object, Array]),
__metadata("design:returntype", Promise)
], Task.prototype, "doExchangeCreditsTask", null);
__decorate([
decorator_1.paramsCheck(['activityId', 'itemId']),
decorator_1.userCheck({ intercept: true }),
decorator_1.activityTimeCheck,
decorator_1.services([service_1.TaskService]),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, Object, Array]),
__metadata("design:returntype", Promise)
], Task.prototype, "doBrowseGoodsTask", null);
return Task;
}());
exports.default = Task;
//# sourceMappingURL=task.controller.js.map
\ No newline at end of file
{"version":3,"file":"task.controller.js","sourceRoot":"","sources":["../../src/controller/task.controller.ts"],"names":[],"mappings":";AAAA,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEd,4CAA2D;AAC3D,0CAA2F;AAE3F,8BAA6C;AAC7C,kCAAqD;AACrD,sCAAkE;AAElE,IAAI;AACJ,8BAA8B;AAC9B,cAAc;AACd,+CAA+C;AAC/C,MAAM;AACN,IAAI;AACJ;IAAA;IAgKA,CAAC;IA/JC;;OAEG;IAKG,0BAAW,GAAjB,UACE,OAAgB,EAChB,EAA8D,EAC9D,EAA4B;YAD1B,QAAQ,cAAA,EAAE,OAAO,aAAA,EAAE,YAAY,kBAAA,EAAE,OAAO,aAAA;YACzC,WAAW,QAAA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AAE,SAAS,EAAE,IAAI,EAAE,CAAC;QAC9B,6BAAiB;QACjB,oBAAQ,CAAC,CAAC,qBAAW,EAAE,qBAAW,CAAC,CAAC;;;;qDA6CpC;IASD;QAJC,uBAAW,CAAC,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;QACrC,qBAAS,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;QAC9B,6BAAiB;QACjB,oBAAQ,CAAC,CAAC,qBAAW,CAAC,CAAC;;;;iDA0CvB;IACH,WAAC;CAAA,AAhKD,IAgKC;kBAhKoB,IAAI"}
\ No newline at end of file
/** @format */
import { UserService, AccessService } from '../service';
interface IVipContext extends Context {
data: {
activityId: string;
callbackUrl?: string;
};
}
interface ILoginContext extends Context {
data: {
activityId: string;
userNick: string;
avatar: string;
isFollow: boolean;
inviteId?: string;
};
}
export default class User {
/**
* 登录接口, 初始化/更新用户信息
*/
login(context: ILoginContext, { userInfo, vipInfo, activityInfo }: IControllerInfos, [userService, accessService]: [UserService, AccessService]): Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result>;
/**
* 获取会员信息
*/
getVipInfo(context: IVipContext, { session }: IControllerInfos, [userService]: [UserService]): Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result>;
}
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 sdk_1 = require("../sdk");
var service_1 = require("../service");
var config_1 = require("../config");
var User = /** @class */ (function () {
function User() {
}
/**
* 登录接口, 初始化/更新用户信息
*/
User.prototype.login = function (context, _a, _b) {
var userInfo = _a.userInfo, vipInfo = _a.vipInfo, activityInfo = _a.activityInfo;
var userService = _b[0], accessService = _b[1];
return __awaiter(this, void 0, void 0, function () {
var openId, isFollow;
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
openId = context.openId;
isFollow = context.data.isFollow;
if (!!userInfo) return [3 /*break*/, 2];
return [4 /*yield*/, userService.initUserData(vipInfo, activityInfo)];
case 1:
_c.sent();
return [3 /*break*/, 4];
case 2: return [4 /*yield*/, userService.updateUserData(vipInfo, userInfo)];
case 3:
_c.sent();
_c.label = 4;
case 4:
// access表
return [4 /*yield*/, accessService.addAccess(isFollow, vipInfo.isVip)];
case 5:
// access表
_c.sent();
return [2 /*return*/, sdk_1.resultsModel.success({
openId: openId
})];
}
});
});
};
/**
* 获取会员信息
*/
User.prototype.getVipInfo = function (context, _a, _b) {
var session = _a.session;
var userService = _b[0];
return __awaiter(this, void 0, void 0, function () {
var callbackUrl, VIP_CALLBACK_URL, result;
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
callbackUrl = context.data.callbackUrl;
VIP_CALLBACK_URL = config_1.getConfig(context).VIP_CALLBACK_URL;
return [4 /*yield*/, userService.getShopVip(session, callbackUrl || VIP_CALLBACK_URL)];
case 1:
result = _c.sent();
return [2 /*return*/, sdk_1.resultsModel.success(result)];
}
});
});
};
__decorate([
decorator_1.paramsCheck(['activityId', 'userNick', 'avatar', 'isFollow']),
decorator_1.activityTimeCheck,
decorator_1.services([service_1.UserService, service_1.AccessService]),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, Object, Array]),
__metadata("design:returntype", Promise)
], User.prototype, "login", null);
__decorate([
decorator_1.paramsCheck(['activityId']),
decorator_1.services([service_1.UserService]),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, Object, Array]),
__metadata("design:returntype", Promise)
], User.prototype, "getVipInfo", null);
return User;
}());
exports.default = User;
//# sourceMappingURL=user.controller.js.map
\ No newline at end of file
{"version":3,"file":"user.controller.js","sourceRoot":"","sources":["../../src/controller/user.controller.ts"],"names":[],"mappings":";AAAA,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEd,0CAAkF;AAElF,8BAAqC;AACrC,sCAAuD;AACvD,oCAAqC;AAiBrC;IAAA;IAyCA,CAAC;IAxCC;;OAEG;IAIG,oBAAK,GAAX,UACE,OAAsB,EACtB,EAAqD,EACrD,EAA0D;YADxD,QAAQ,cAAA,EAAE,OAAO,aAAA,EAAE,YAAY,kBAAA;YAChC,WAAW,QAAA,EAAE,aAAa,QAAA;;;;;;wBAEnB,MAAM,GAAK,OAAO,OAAZ,CAAY;wBAElB,QAAQ,GAAK,OAAO,CAAC,IAAI,SAAjB,CAAiB;6BAE7B,CAAC,QAAQ,EAAT,wBAAS;wBACX,qBAAM,WAAW,CAAC,YAAY,CAAC,OAAO,EAAE,YAAY,CAAC,EAAA;;wBAArD,SAAqD,CAAA;;4BAErD,qBAAM,WAAW,CAAC,cAAc,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAA;;wBAAnD,SAAmD,CAAA;;;oBAGrD,UAAU;oBACV,qBAAM,aAAa,CAAC,SAAS,CAAC,QAAQ,EAAE,OAAO,CAAC,KAAK,CAAC,EAAA;;wBADtD,UAAU;wBACV,SAAsD,CAAA;wBAEtD,sBAAO,kBAAY,CAAC,OAAO,CAAC;gCAC1B,MAAM,QAAA;6BACP,CAAC,EAAA;;;;KACH;IACD;;OAEG;IAGG,yBAAU,GAAhB,UAAiB,OAAoB,EAAE,EAA6B,EAAE,EAA4B;YAAzD,OAAO,aAAA;YAAuB,WAAW,QAAA;;;;;;wBACxE,WAAW,GAAK,OAAO,CAAC,IAAI,YAAjB,CAAiB;wBAC5B,gBAAgB,GAAK,kBAAS,CAAC,OAAO,CAAC,iBAAvB,CAAuB;wBAChC,qBAAM,WAAW,CAAC,UAAU,CAAC,OAAO,EAAE,WAAW,IAAI,gBAAgB,CAAC,EAAA;;wBAA/E,MAAM,GAAG,SAAsE;wBAErF,sBAAO,kBAAY,CAAC,OAAO,CAAC,MAAM,CAAC,EAAA;;;;KACpC;IAjCD;QAHC,uBAAW,CAAC,CAAC,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC;QAC7D,6BAAiB;QACjB,oBAAQ,CAAC,CAAC,qBAAW,EAAE,uBAAa,CAAC,CAAC;;;;qCAsBtC;IAMD;QAFC,uBAAW,CAAC,CAAC,YAAY,CAAC,CAAC;QAC3B,oBAAQ,CAAC,CAAC,qBAAW,CAAC,CAAC;;;;0CAOvB;IACH,WAAC;CAAA,AAzCD,IAyCC;kBAzCoB,IAAI"}
\ No newline at end of file
/** @format */
export declare const ACCESS_DB_NAME: string;
export declare const USER_DB_NAME: string;
export declare const AWARDS_DB_NAME: string;
export declare const RECORD_DB_NAME: string;
export declare const ERROR_LOG_DB_NAME: string;
export declare const 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_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';
exports.RECORD_DB_NAME = "c_user_record";
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;AAErD,QAAA,iBAAiB,GAAW,qBAAqB,CAAA"}
\ No newline at end of file
export declare const paramsCheck: (params: string[]) => (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.paramsCheck = void 0;
/** @format */
var sdk_1 = require("../sdk");
var constants_1 = require("../constants");
var paramsCheck = function (params) {
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 dataKeys = Object.keys(context.data);
for (var i = 0; i < params.length; i++) {
var param = params[i];
if (!dataKeys.includes(param))
return sdk_1.resultsModel.error(constants_1.CODE_TYPES.PARAMS_ERROR, "\u7F3A\u5C11" + param + "\u53C2\u6570");
}
return method.apply(target, [context, __assign({}, otherArgs)]);
};
};
};
exports.paramsCheck = paramsCheck;
//# sourceMappingURL=check.js.map
\ No newline at end of file
{"version":3,"file":"check.js","sourceRoot":"","sources":["../../src/decorator/check.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,cAAc;AACd,8BAAqC;AACrC,0CAAyC;AAClC,IAAM,WAAW,GAAG,UAAC,MAAgB;IAC1C,OAAO,UAAU,MAAc,EAAE,IAAY,EAAE,UAA8B;QAC3E,IAAM,MAAM,GAAG,UAAU,CAAC,KAAK,CAAA;QAE/B,UAAU,CAAC,KAAK,GAAG;YAAU,cAAc;iBAAd,UAAc,EAAd,qBAAc,EAAd,IAAc;gBAAd,yBAAc;;YAClC,IAAA,OAAO,GAAoB,IAAI,GAAxB,EAAE,KAAkB,IAAI,GAAR,EAAd,SAAS,mBAAG,EAAE,KAAA,CAAQ;YACtC,IAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;YAC1C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;gBACtC,IAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,CAAA;gBACvB,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC;oBAAE,OAAO,kBAAY,CAAC,KAAK,CAAC,sBAAU,CAAC,YAAY,EAAE,iBAAK,KAAK,iBAAI,CAAC,CAAA;aAClG;YACD,OAAO,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,OAAO,eAAO,SAAS,EAAG,CAAC,CAAA;QAC1D,CAAC,CAAA;IACH,CAAC,CAAA;AACH,CAAC,CAAA;AAdY,QAAA,WAAW,eAcvB"}
\ No newline at end of file
/** @format */
export * from './check';
export * from './services';
export * from './noCatch';
export * from './validate';
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
/** @format */
__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;AACzB,6CAA0B"}
\ No newline at end of file
/** @format */
export declare const noCatch: (target: any, name: string, descriptor: PropertyDescriptor) => void;
"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 });
exports.noCatch = void 0;
var noCatch = 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];
}
return __awaiter(this, void 0, void 0, function () {
var context, _a, otherArgs;
return __generator(this, function (_b) {
context = args[0], _a = args[1], otherArgs = _a === void 0 ? {} : _a;
return [2 /*return*/, method.apply(this, [context, __assign(__assign({}, otherArgs), { noCatch: true })])];
});
});
};
};
exports.noCatch = noCatch;
//# sourceMappingURL=noCatch.js.map
\ No newline at end of file
{"version":3,"file":"noCatch.js","sourceRoot":"","sources":["../../src/decorator/noCatch.ts"],"names":[],"mappings":";AAAA,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEP,IAAM,OAAO,GAAG,UAAC,MAAW,EAAE,IAAY,EAAE,UAA8B;IAC/E,IAAM,MAAM,GAAG,UAAU,CAAC,KAAK,CAAA;IAC/B,UAAU,CAAC,KAAK,GAAG;QAAgB,cAAc;aAAd,UAAc,EAAd,qBAAc,EAAd,IAAc;YAAd,yBAAc;;;;;gBACxC,OAAO,GAAoB,IAAI,GAAxB,EAAE,KAAkB,IAAI,GAAR,EAAd,SAAS,mBAAG,EAAE,KAAA,CAAQ;gBACtC,sBAAO,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,OAAO,wBAAO,SAAS,KAAE,OAAO,EAAE,IAAI,IAAG,CAAC,EAAA;;;KACtE,CAAA;AACH,CAAC,CAAA;AANY,QAAA,OAAO,WAMnB"}
\ No newline at end of file
export declare const services: (services: any[]) => (target: Object, name: string, descriptor: PropertyDescriptor) => void;
"use strict";
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 });
exports.services = void 0;
/** @format */
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 () {
var session;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!!baseInfos.session) return [3 /*break*/, 2];
return [4 /*yield*/, new service_1.TaobaoTopService(context).getAccessTokenByOpenId()];
case 1:
session = (_a.sent()).session;
baseInfos.session = session;
_a.label = 2;
case 2: return [2 /*return*/, baseInfos];
}
});
});
}
var 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, _d, otherArgs, servicesInstance, baseInfos, ret, error_1;
return __generator(this, function (_e) {
switch (_e.label) {
case 0:
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 = _e.sent();
// 默认全局try catch 如果有noCatch参数则直接执行
if (baseInfos.noCatch) {
delete baseInfos.noCatch;
return [2 /*return*/, method.apply(target, [context, baseInfos, servicesInstance])];
}
_e.label = 2;
case 2:
_e.trys.push([2, 4, , 6]);
utils_1.logger(context);
return [4 /*yield*/, method.apply(target, [context, baseInfos, servicesInstance])];
case 3:
ret = _e.sent();
return [3 /*break*/, 6];
case 4:
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:
_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];
}
});
});
};
};
};
exports.services = services;
//# sourceMappingURL=services.js.map
\ No newline at end of file
{"version":3,"file":"services.js","sourceRoot":"","sources":["../../src/decorator/services.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,cAAc;AACd,kCAAiD;AACjD,8BAAqC;AACrC,0CAAyC;AACzC,sCAA6C;AAC7C,SAAe,YAAY,CAAC,OAAgB,EAAE,SAA2B;;;;;;yBACnE,CAAC,SAAS,CAAC,OAAO,EAAlB,wBAAkB;oBAEA,qBAAM,IAAI,0BAAgB,CAAC,OAAO,CAAC,CAAC,sBAAsB,EAAE,EAAA;;oBAAxE,OAAO,GAAK,CAAA,SAA4D,CAAA,QAAjE;oBACf,SAAS,CAAC,OAAO,GAAG,OAAO,CAAA;;wBAG7B,sBAAO,SAAS,EAAA;;;;CACjB;AAEM,IAAM,QAAQ,GAAG,UAAC,QAAe;IACtC,OAAO,UAAC,MAAc,EAAE,IAAY,EAAE,UAA8B;QAClE,IAAM,MAAM,GAAG,UAAU,CAAC,KAAK,CAAA;QAE/B,UAA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BAAO,GAAG,EAAA;;;;SACX,CAAA;IACH,CAAC,CAAA;AACH,CAAC,CAAA;AA5BY,QAAA,QAAQ,YA4BpB"}
\ No newline at end of file
import { Rules } from 'async-validator';
export declare const paramsValidate: (validators: Rules) => (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);
};
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 });
exports.paramsValidate = void 0;
/** @format */
var sdk_1 = require("../sdk");
var constants_1 = require("../constants");
var async_validator_1 = require("async-validator");
var paramsValidate = function (validators) {
return function (target, name, descriptor) {
var method = descriptor.value;
descriptor.value = function () {
var _a;
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
return __awaiter(this, void 0, void 0, function () {
var context, _b, otherArgs, errors;
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
context = args[0], _b = args[1], otherArgs = _b === void 0 ? {} : _b;
return [4 /*yield*/, validateParams(validators, context.data)];
case 1:
errors = (_c.sent()).errors;
console.log(errors);
if (errors)
return [2 /*return*/, sdk_1.resultsModel.error(constants_1.CODE_TYPES.SYSTEM_ERROR, (_a = errors === null || errors === void 0 ? void 0 : errors[0]) === null || _a === void 0 ? void 0 : _a.message)];
return [2 /*return*/, method.apply(target, [context, __assign({}, otherArgs)])];
}
});
});
};
};
};
exports.paramsValidate = paramsValidate;
var validateParams = function (validators, data) {
var validator = new async_validator_1.default(validators);
return new Promise(function (resolve) {
validator.validate(data, {}, function (errors, fields) {
console.log('errors', errors);
console.log('fields', fields);
if (errors) {
resolve({});
}
else {
resolve({ errors: errors, fields: fields });
}
});
});
};
//# sourceMappingURL=validate.js.map
\ No newline at end of file
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../src/decorator/validate.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;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GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;YAC7B,IAAI,MAAM,EAAE;gBACV,OAAO,CAAC,EAAE,CAAC,CAAA;aACZ;iBAAM;gBACL,OAAO,CAAC,EAAE,MAAM,QAAA,EAAE,MAAM,QAAA,EAAE,CAAC,CAAA;aAC5B;QACH,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA"}
\ No newline at end of file
/** @format */
declare const _default: {
getActivityList: (context: Context, {}: {}, [activityconfigService]: [import("./service").ActivityconfigService]) => Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result<any, false> | import("taobao-mini-sdk/lib/utils/resultmodel").Result<{
list: any;
total: any;
pageSize: number;
pageNo: number;
}, true>>;
getActivityDetail: (context: Context, {}: {}, [activityconfigService]: [import("./service").ActivityconfigService]) => Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result<any, false> | import("taobao-mini-sdk/lib/utils/resultmodel").Result<any, true>>;
delActivity: (context: Context, {}: {}, [activityconfigService]: [import("./service").ActivityconfigService]) => Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result<any, false> | import("taobao-mini-sdk/lib/utils/resultmodel").Result<false, true> | import("taobao-mini-sdk/lib/utils/resultmodel").Result<true, true>>;
saveActivityInfo: (context: import("./controller/save.controller").ISaveActivityContext, {}: {}, [activityconfigService]: [import("./service").ActivityconfigService]) => Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result<any, false> | import("taobao-mini-sdk/lib/utils/resultmodel").Result<false, true> | import("taobao-mini-sdk/lib/utils/resultmodel").Result<true, true>>;
sellerSave: (context: Context, {}: {}, [sellerService]: [import("./service").SellerService]) => Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result<any, false> | import("taobao-mini-sdk/lib/utils/resultmodel").Result<any, true>>;
findWinnerInfoList: (context: Context, { session }: {
session: any;
}, [awardsService]: [import("./service").AwardsService]) => Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result<false, true> | import("taobao-mini-sdk/lib/utils/resultmodel").Result<{
list: any;
total: any;
message: string;
pageNo: number;
pageSize: number;
}, true>>;
exportAwardsList: (context: Context, { session }: {
session: any;
}, [awardsService]: [import("./service").AwardsService]) => Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result<any, false> | import("taobao-mini-sdk/lib/utils/resultmodel").Result<any, true>>;
downloadFile: (context: Context, { session }: {
session: any;
}, [awardsService]: [import("./service").AwardsService]) => Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result<any, false> | import("taobao-mini-sdk/lib/utils/resultmodel").Result<{
total: number;
data: any;
}, true>>;
findItemListByStatus: (context: Context, { session }: {
session: any;
}, [taobaoTopService]: [import("./service").TaobaoTopService]) => Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result<any, false> | import("taobao-mini-sdk/lib/utils/resultmodel").Result<{
pageNo: number;
pageSize: number;
totalPages: number;
totalCount: any;
list: any;
}, true>>;
findItemListByIds: (context: Context, { session }: {
session: any;
}, [taobaoTopService]: [import("./service").TaobaoTopService]) => Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result<any, false> | import("taobao-mini-sdk/lib/utils/resultmodel").Result<{
list: any;
totalCount: any;
}, true>>;
queryBenefitByEname: (context: Context, { session }: {
session: any;
}, [taobaoTopService]: [import("./service").TaobaoTopService]) => Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result<any, false> | import("taobao-mini-sdk/lib/utils/resultmodel").Result<any, true>>;
createCopyActivity: (context: Context, {}: {}, [activityconfigService]: [import("./service").ActivityconfigService]) => Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result<any, false> | import("taobao-mini-sdk/lib/utils/resultmodel").Result<any, true>>;
getAwardsList: (context: Context, { session }: {
session: any;
}, [awardsService]: [import("./service").AwardsService]) => Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result<false, true> | import("taobao-mini-sdk/lib/utils/resultmodel").Result<{
list: any;
total: any;
message: string;
pageNo: number;
pageSize: number;
}, true>>;
};
export default _default;
"use strict";
/** @format */
Object.defineProperty(exports, "__esModule", { value: true });
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");
var save_controller_1 = require("./controller/save.controller");
var _a = new activity_controller_1.default(), getActivityList = _a.getActivityList, getActivityDetail = _a.getActivityDetail, delActivity = _a.delActivity, createCopyActivity = _a.createCopyActivity;
var _b = new seller_controller_1.default(), sellerSaasSave = _b.sellerSaasSave, sellerSave = _b.sellerSave;
var _c = new awards_controller_1.default(), findWinnerInfoList = _c.findWinnerInfoList, exportAwardsList = _c.exportAwardsList, getAwardsList = _c.getAwardsList, downloadFile = _c.downloadFile;
var generateRule = new rule_controller_1.default().generateRule;
var _d = new taobaoItem_controller_1.default(), findItemListByStatus = _d.findItemListByStatus, findItemListByIds = _d.findItemListByIds, queryBenefitByEname = _d.queryBenefitByEname;
var saveActivityInfo = new save_controller_1.default().saveActivityInfo;
exports.default = {
getActivityList: getActivityList,
getActivityDetail: getActivityDetail,
delActivity: delActivity,
saveActivityInfo: saveActivityInfo,
sellerSave: sellerSave,
findWinnerInfoList: findWinnerInfoList,
exportAwardsList: exportAwardsList,
downloadFile: downloadFile,
findItemListByStatus: findItemListByStatus,
findItemListByIds: findItemListByIds,
queryBenefitByEname: queryBenefitByEname,
createCopyActivity: createCopyActivity,
getAwardsList: getAwardsList
};
//# 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,wEAAiE;AACjE,oEAA6D;AAC7D,oEAA6D;AAC7D,gEAAyD;AACzD,4EAAqE;AACrE,gEAAyD;AAEnD,IAAA,KAAyE,IAAI,6BAAkB,EAAE,EAA/F,eAAe,qBAAA,EAAE,iBAAiB,uBAAA,EAAE,WAAW,iBAAA,EAAC,kBAAkB,wBAA6B,CAAA;AACjG,IAAA,KAAiC,IAAI,2BAAgB,EAAE,EAArD,cAAc,oBAAA,EAAE,UAAU,gBAA2B,CAAA;AACvD,IAAA,KAKF,IAAI,2BAAgB,EAAE,EAJxB,kBAAkB,wBAAA,EAClB,gBAAgB,sBAAA,EAChB,aAAa,mBAAA,EACb,YAAY,kBACY,CAAA;AAClB,IAAA,YAAY,GAAK,IAAI,yBAAc,EAAE,aAAzB,CAAyB;AACvC,IAAA,KAAmE,IAAI,+BAAoB,EAAE,EAA3F,oBAAoB,0BAAA,EAAE,iBAAiB,uBAAA,EAAE,mBAAmB,yBAA+B,CAAA;AAC3F,IAAA,gBAAgB,GAAK,IAAI,yBAAc,EAAE,iBAAzB,CAAyB;AAEjD,kBAAe;IACb,eAAe,iBAAA;IACf,iBAAiB,mBAAA;IACjB,WAAW,aAAA;IACX,gBAAgB,kBAAA;IAChB,UAAU,YAAA;IACV,kBAAkB,oBAAA;IAClB,gBAAgB,kBAAA;IAChB,YAAY,cAAA;IACZ,oBAAoB,sBAAA;IACpB,iBAAiB,mBAAA;IACjB,mBAAmB,qBAAA;IACnB,kBAAkB,oBAAA;IAClB,aAAa,eAAA;CACd,CAAA"}
\ No newline at end of file
/** @format */
import Utils from 'taobao-mini-sdk/lib/utils/index';
import TBAPI from 'taobao-mini-sdk/lib/service/TBAPI';
declare const DEFAULT_CODE_TYPES: {
PARAMS_ERROR: import("taobao-mini-sdk/lib/utils/codetypes").CodeType;
SYSTEM_ERROR: import("taobao-mini-sdk/lib/utils/codetypes").CodeType;
SUCCESS: import("taobao-mini-sdk/lib/utils/codetypes").CodeType;
}, getStartTimestamp: (day: string) => number, getEndTimestamp: (day: string) => number;
declare const resultsModel: import("taobao-mini-sdk/lib/utils/resultmodel").ResultsModel;
export declare const TBAPIS: typeof TBAPI;
export declare const BaseDao: any;
export declare const transformBeijingDate: typeof Utils.transformBeijingDate;
export declare const dateFormatter: typeof Utils.dateFormatter;
export { DEFAULT_CODE_TYPES, resultsModel, getStartTimestamp, getEndTimestamp };
"use strict";
/** @format */
Object.defineProperty(exports, "__esModule", { value: true });
exports.getEndTimestamp = exports.getStartTimestamp = exports.resultsModel = exports.DEFAULT_CODE_TYPES = exports.dateFormatter = exports.transformBeijingDate = exports.BaseDao = exports.TBAPIS = void 0;
var index_1 = require("taobao-mini-sdk/lib/utils/index");
var base_dao_1 = require("taobao-mini-sdk/lib/dao/base.dao");
var TBAPI_1 = require("taobao-mini-sdk/lib/service/TBAPI");
var MockConfig = require('../mockServer/sdk');
var DEFAULT_CODE_TYPES = index_1.default.DEFAULT_CODE_TYPES, cloudDateFormatter = index_1.default.dateFormatter, cloudTransformBeijingDate = index_1.default.transformBeijingDate, getStartTimestamp = index_1.default.getStartTimestamp, getEndTimestamp = index_1.default.getEndTimestamp, ResultsModel = index_1.default.ResultsModel;
exports.DEFAULT_CODE_TYPES = DEFAULT_CODE_TYPES;
exports.getStartTimestamp = getStartTimestamp;
exports.getEndTimestamp = getEndTimestamp;
var resultsModel = new ResultsModel();
exports.resultsModel = resultsModel;
var env = process.argv[2];
console.log("env", env);
exports.TBAPIS = env === 'mock' ? MockConfig.TBAPIS : TBAPI_1.default;
exports.BaseDao = env === 'mock' ? MockConfig.BaseDao : base_dao_1.BaseDao;
exports.transformBeijingDate = env === 'mock' ? MockConfig.transformBeijingDate : cloudTransformBeijingDate;
exports.dateFormatter = env === 'mock' ? MockConfig.dateFormatter : cloudDateFormatter;
//# sourceMappingURL=sdk.js.map
\ No newline at end of file
{"version":3,"file":"sdk.js","sourceRoot":"","sources":["../src/sdk.ts"],"names":[],"mappings":";AAAA,cAAc;;;AAEd,yDAAmD;AACnD,6DAA0E;AAC1E,2DAAqD;AACrD,IAAI,UAAU,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAA;AAG3C,IAAA,kBAAkB,GAMhB,eAAK,mBANW,EACH,kBAAkB,GAK/B,eAAK,cAL0B,EACX,yBAAyB,GAI7C,eAAK,qBAJwC,EAC/C,iBAAiB,GAGf,eAAK,kBAHU,EACjB,eAAe,GAEb,eAAK,gBAFQ,EACf,YAAY,GACV,eAAK,aADK,CACL;AAgBA,gDAAkB;AAAgB,8CAAiB;AAAE,0CAAe;AAd7E,IAAM,YAAY,GAAG,IAAI,YAAY,EAAE,CAAA;AAcV,oCAAY;AAZzC,IAAI,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACzB,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,CAAA;AAEV,QAAA,MAAM,GAAiB,GAAG,KAAK,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,eAAK,CAAA;AAEjE,QAAA,OAAO,GAAG,GAAG,KAAK,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,kBAAY,CAAA;AAE5D,QAAA,oBAAoB,GAC/B,GAAG,KAAK,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,oBAAoB,CAAC,CAAC,CAAC,yBAAyB,CAAA;AAEjE,QAAA,aAAa,GAA+B,GAAG,KAAK,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC,kBAAkB,CAAA"}
\ No newline at end of file
/**
* 访问明细
*
* @format
*/
export default class UserAccessService {
context: Context;
accessdao: IBaseDao;
constructor(context: Context);
/**
* 增加访问记录
* @param {是否关注店铺} isFollow
*/
addAccess(isFollow: boolean, isVip: boolean): Promise<any>;
getAccessCount(): Promise<any>;
}
"use strict";
/**
* 访问明细
*
* @format
*/
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 utils_1 = require("../utils");
var db_1 = require("../db");
var UserAccessService = /** @class */ (function () {
function UserAccessService(context) {
this.context = context;
this.accessdao = new sdk_1.BaseDao(context, db_1.ACCESS_DB_NAME);
}
/**
* 增加访问记录
* @param {是否关注店铺} isFollow
*/
UserAccessService.prototype.addAccess = function (isFollow, isVip) {
return __awaiter(this, void 0, void 0, function () {
var _a, openId, data, activityId, userNick, avatar, inviteId;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
_a = this.context, openId = _a.openId, data = _a.data;
activityId = data.activityId, userNick = data.userNick, avatar = data.avatar, inviteId = data.inviteId;
return [4 /*yield*/, this.accessdao.insertOne({
openId: openId,
activityId: activityId,
userNick: userNick,
avatar: avatar,
isReceiveShare: !!inviteId,
inviteId: inviteId,
isFollow: isFollow,
isVip: isVip,
accessTime: Date.now(),
createTime: Date.now(),
updateTime: Date.now(),
createDay: utils_1.getToday()
})];
case 1: return [2 /*return*/, _b.sent()];
}
});
});
};
UserAccessService.prototype.getAccessCount = function () {
return __awaiter(this, void 0, void 0, function () {
var _a, openId, data, activityId;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
_a = this.context, openId = _a.openId, data = _a.data;
activityId = data.activityId;
return [4 /*yield*/, this.accessdao.count({
openId: openId,
activityId: activityId
})];
case 1: return [2 /*return*/, _b.sent()];
}
});
});
};
return UserAccessService;
}());
exports.default = UserAccessService;
//# sourceMappingURL=access.service.js.map
\ No newline at end of file
{"version":3,"file":"access.service.js","sourceRoot":"","sources":["../../src/service/access.service.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,8BAAgC;AAChC,kCAAmC;AACnC,4BAAsC;AAEtC;IAGE,2BAAY,OAAgB;QAC1B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,SAAS,GAAG,IAAI,aAAO,CAAC,OAAO,EAAE,mBAAc,CAAC,CAAA;IACvD,CAAC;IACD;;;OAGG;IACG,qCAAS,GAAf,UAAgB,QAAiB,EAAE,KAAc;;;;;;wBAC3C,KAAmB,IAAI,CAAC,OAAO,EAA7B,MAAM,YAAA,EAAE,IAAI,UAAA,CAAiB;wBAC7B,UAAU,GAAiC,IAAI,WAArC,EAAE,QAAQ,GAAuB,IAAI,SAA3B,EAAE,MAAM,GAAe,IAAI,OAAnB,EAAE,QAAQ,GAAK,IAAI,SAAT,CAAS;wBAE9C,qBAAM,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC;gCACpC,MAAM,QAAA;gCACN,UAAU,YAAA;gCACV,QAAQ,UAAA;gCACR,MAAM,QAAA;gCACN,cAAc,EAAE,CAAC,CAAC,QAAQ;gCAC1B,QAAQ,UAAA;gCACR,QAAQ,UAAA;gCACR,KAAK,OAAA;gCACL,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE;gCACtB,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE;gCACtB,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE;gCACtB,SAAS,EAAE,gBAAQ,EAAE;6BACtB,CAAC,EAAA;4BAbF,sBAAO,SAaL,EAAA;;;;KACH;IAEK,0CAAc,GAApB;;;;;;wBACM,KAAmB,IAAI,CAAC,OAAO,EAA7B,MAAM,YAAA,EAAE,IAAI,UAAA,CAAiB;wBAC7B,UAAU,GAAK,IAAI,WAAT,CAAS;wBAClB,qBAAM,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;gCAChC,MAAM,QAAA;gCACN,UAAU,YAAA;6BACX,CAAC,EAAA;4BAHF,sBAAO,SAGL,EAAA;;;;KACH;IACH,wBAAC;AAAD,CAAC,AAvCD,IAuCC"}
\ No newline at end of file
/** @format */
export default class ActivityConfigService {
activityconfigDao: IBaseDao;
activityconfigPrizeDao: IBaseDao;
constructor(context: Context);
saveNewActivity(baseConfig: IActivityBaseInfo, prize: Array<IActivityPrize>, openId: string): Promise<any>;
updateBaseConfigInfo(id: string, data: IActivityBaseInfo): Promise<any>;
getPrizeInfoById(id: any): Promise<any>;
updateDeleteStatusById(id: any): Promise<any>;
deletePrizeByIds(ids: string[]): Promise<any>;
insertAndUpdatePrize(activityId: string, allPrizeList: Array<IActivityPrize>, bothIds: string[]): Promise<{
success: any[];
failed: any[];
}>;
updateOnePrizeById(id: any, data: IActivityPrize): Promise<any>;
insertPrizeByActivityId(activityId: any, data: any): Promise<any>;
getAllOldPrizeList(activityId: string): Promise<any>;
diffPrizeList(activityId: string, pirzeList: Array<IActivityPrize>): Promise<{
deleteIds: string[];
bothIds: string[];
}>;
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>): {};
setPrizeProbalityRange(prizes: IActivityPrize[]): 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 utils_1 = require("../utils");
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 (baseConfig, 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.insertOne(__assign(__assign({}, baseConfig), { 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 = prize.map(function (item) {
return __assign(__assign({}, item), { activityId: result_1, openId: openId, createTime: Date.now(), updateTime: Date.now(), deleteStatus: constants_1.DELETE_STATUS.EXIST });
});
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.deletePrizeByIds = function (ids) {
return __awaiter(this, void 0, void 0, function () {
var result, i;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
result = true;
i = 0;
_a.label = 1;
case 1:
if (!(i < ids.length)) return [3 /*break*/, 4];
return [4 /*yield*/, this.updateDeleteStatusById(ids[i])];
case 2:
result = _a.sent();
_a.label = 3;
case 3:
i++;
return [3 /*break*/, 1];
case 4: return [2 /*return*/, result];
}
});
});
};
ActivityConfigService.prototype.insertAndUpdatePrize = function (activityId, allPrizeList, bothIds) {
return __awaiter(this, void 0, void 0, function () {
var result, i, isNewPrize, insertResult, isEditPrize, editResult;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
result = {
success: [],
failed: []
};
i = 0;
_a.label = 1;
case 1:
if (!(i < allPrizeList.length)) return [3 /*break*/, 6];
isNewPrize = !allPrizeList[i]._id;
if (!isNewPrize) return [3 /*break*/, 3];
return [4 /*yield*/, this.insertPrizeByActivityId(activityId, allPrizeList[i])];
case 2:
insertResult = _a.sent();
if (insertResult) {
result.success.push(insertResult);
}
else {
result.failed.push(insertResult);
}
_a.label = 3;
case 3:
isEditPrize = bothIds.includes(allPrizeList[i]._id);
if (!isEditPrize) return [3 /*break*/, 5];
if (allPrizeList[i].switchStock === constants_1.STOCK_TYPE.NO_LIMIT) {
allPrizeList[i].useStock = 0;
}
else if (allPrizeList[i].switchStock === constants_1.STOCK_TYPE.LIMIT) {
(allPrizeList[i].useStock || allPrizeList[i].useStock === 0) && delete allPrizeList[i].useStock;
}
return [4 /*yield*/, this.updateOnePrizeById(allPrizeList[i]._id, allPrizeList[i])];
case 4:
editResult = _a.sent();
if (editResult) {
result.success.push(editResult);
}
else {
result.failed.push(editResult);
}
_a.label = 5;
case 5:
i++;
return [3 /*break*/, 1];
case 6: return [2 /*return*/, result];
}
});
});
};
// 更新单条数据
ActivityConfigService.prototype.updateOnePrizeById = function (id, data) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (data.switchStock === constants_1.STOCK_TYPE.NO_LIMIT) {
data.useStock = 0;
}
else {
delete data.useStock;
}
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, useStock: 0, 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()];
}
});
});
};
// 编辑活动时, 对比新旧奖品配置, 找出删除的id和更新的id
ActivityConfigService.prototype.diffPrizeList = function (activityId, pirzeList) {
return __awaiter(this, void 0, void 0, function () {
function getIds(pirzeList) {
return pirzeList.reduce(function (s, v) {
if (v._id) {
s = __spreadArrays(s, [v._id]);
}
return s;
}, []);
}
var allNewIds, oldPrizeList, oldIds, deleteIds, bothIds;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
allNewIds = getIds(pirzeList);
return [4 /*yield*/, this.getAllOldPrizeList(activityId)];
case 1:
oldPrizeList = _a.sent();
oldIds = getIds(oldPrizeList);
deleteIds = [];
bothIds = oldIds.reduce(function (s, i) {
if (allNewIds.includes(i)) {
s = __spreadArrays(s, [i]);
}
else {
deleteIds.push(i);
}
return s;
}, []);
return [2 /*return*/, {
deleteIds: deleteIds,
bothIds: bothIds
}];
}
});
});
};
//更新活动配置
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, type: { $ne: constants_1.PRIZE_TYPE.THANK } }, { 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) {
// level 根据level排序
var prizeList = prizeConfig.sort(function (a, b) { return a.level - b.level; });
var poolConfig = % -JSON.stringify(formatPrize) % >
// 取出奖池
let, prizeData = {};
poolConfig.forEach(function (item) {
prizeData[item.key] = prizeList.filter(function (prize) {
return +item.prizeDataType == +prize.prizeDataType;
});
});
// 过滤奖池条件
poolConfig.forEach(function (item) {
var _a;
if ((_a = item.conditionKeys) === null || _a === void 0 ? void 0 : _a.length) {
item.conditionKeys.forEach(function (condition) {
prizeData[item.key] = prizeData[item.key].filter(function (prize) {
return prize[condition.key] == condition.value;
});
});
}
});
return prizeData;
};
// 概率奖品配置 properiodfrom properiodto
ActivityConfigService.prototype.setPrizeProbalityRange = function (prizes) {
var originPeriod = 1;
return prizes.map(function (v) {
if (!v.probability)
return v;
// 概率为0 跳出10000之外的区间
if (+v.probability === 0)
return __assign(__assign({}, v), { properiodfrom: 1000000, properiodto: 1000000 });
var properiodfrom = originPeriod;
var properiodto = +originPeriod + utils_1.signFigures(+v.probability * 100) - 1;
originPeriod = +originPeriod + utils_1.signFigures(+v.probability * 100);
return __assign(__assign({}, v), { properiodfrom: properiodfrom,
properiodto: properiodto });
});
};
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,0CAAuF;AACvF,kCAAsC;AAEtC;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,UAA6B,EAAE,KAA4B,EAAE,MAAc;;;;;;;wBAEhF,qBAAM,IAAI,CAAC,iBAAiB,CAAC,SAAS,uBAC9C,UAAU,KACb,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE,EACtB,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE,EACtB,YAAY,EAAE,yBAAa,CAAC,KAAK,EACjC,eAAe,EAAE,6BAAiB,CAAC,UAAU,IAC7C,EAAA;;wBANE,WAAS,SAMX;wBACF,OAAO,CAAC,GAAG,CAAC,QAAM,EAAE,cAAc,CAAC,CAAA;6BAC/B,QAAM,EAAN,wBAAM;;;;wBAEN,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,UAAA,IAAI;4BACpB,6BACK,IAAI,KACP,UAA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AAC,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,UAAA,KAAK;wBACpD,OAAO,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,SAAS,CAAC,KAAK,CAAA;oBAChD,CAAC,CAAC,CAAA;gBACJ,CAAC,CAAC,CAAA;aACH;QACL,CAAC,CAAC,CAAA;QACF,OAAO,SAAS,CAAA;IAClB,CAAC;IACD,oCAAoC;IACpC,sDAAsB,GAAtB,UAAuB,MAAwB;QAC7C,IAAI,YAAY,GAAG,CAAC,CAAA;QACpB,OAAO,MAAM,CAAC,GAAG,CAAC,UAAA,CAAC;YACjB,IAAI,CAAC,CAAC,CAAC,WAAW;gBAAE,OAAO,CAAC,CAAA;YAC5B,oBAAoB;YACpB,IAAI,CAAC,CAAC,CAAC,WAAW,KAAK,CAAC;gBACtB,6BACK,CAAC,KACJ,aAAa,EAAE,OAAO,EACtB,WAAW,EAAE,OAAO,IACrB;YACH,IAAM,aAAa,GAAG,YAAY,CAAA;YAClC,IAAM,WAAW,GAAG,CAAC,YAAY,GAAG,mBAAW,CAAC,CAAC,CAAC,CAAC,WAAW,GAAG,GAAG,CAAC,GAAG,CAAC,CAAA;YACzE,YAAY,GAAG,CAAC,YAAY,GAAG,mBAAW,CAAC,CAAC,CAAC,CAAC,WAAW,GAAG,GAAG,CAAC,CAAA;YAChE,6BACK,CAAC,KACJ,aAAa,eAAA;gBACb,WAAW,aAAA,IACZ;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;IACH,4BAAC;AAAD,CAAC,AApcD,IAocC"}
\ 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":";;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,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,OAAO;QACjB,IAAI,CAAC,iBAAiB,GAAG,IAAI,OAAO,CAAC,OAAO,EAAE,oBAAoB,CAAC,CAAC;IACtE,CAAC;IAED,UAAU;IACJ,8CAAc,GAApB,UAAqB,UAAU;;;;4BACtB,qBAAM,IAAI,CAAC,iBAAiB,CAAC,SAAS,uBACxC,UAAU,KACb,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE,EACtB,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE,IACtB,EAAA;4BAJF,sBAAO,SAIL,EAAC;;;;KACJ;IAED,UAAU;IACJ,8CAAc,GAApB,UAAqB,MAAM;;;;4BAClB,qBAAM,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC;4BACvC,MAAM,QAAA;yBACP,CAAC,EAAA;4BAFF,sBAAO,SAEL,EAAC;;;;KACJ;IAED,UAAU;IACJ,uDAAuB,GAA7B,UAA8B,QAAQ;;;;;4BAC1B,qBAAM,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC;4BAC1C,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;IAED,UAAU;IACJ,gDAAgB,GAAtB,UAAuB,MAAM,EAAE,UAAU;;;;;wBACvC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,UAAU,EAAE,oBAAoB,CAAC,CAAC;wBAC/C,qBAAM,IAAI,CAAC,iBAAiB,CAAC,MAAM,CACxC;gCACE,MAAM,EAAE,MAAM;6BACf,EACD;gCACE,IAAI,wBACC,UAAU,KACb,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE,GACvB;6BACF,CACF,EAAA;4BAVD,sBAAO,SAUN,EAAC;;;;KACH;IACH,4BAAC;AAAD,CAAC,AA/CgB,GA+ChB,CAAC"}
\ No newline at end of file
export = 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,CA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C;wBACvB,qBAAM,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC;gCAClC,GAAG,EAAE,0BAA0B;gCAC/B,IAAI,EAAE;oCACJ,YAAY,EAAE,YAAY;oCAC1B,IAAI,MAAA;iCACL;6BACF,CAAC,EAAA;;wBANE,GAAG,GAAG,SAMR;wBACF,IACE,GAAG;4BACH,GAAG,CAAC,yBAAyB,CAAC;4BAC9B,GAAG,CAAC,yBAAyB,CAAC,CAAC,wBAAwB,CAAC;4BAExD,sBAAO,GAAG,CAAC,yBAAyB,CAAC,CAAC,wBAAwB,CAAC,CAAC,CAAC,CAAC,EAAC;wBACrE,sBAAO,KAAK,EAAC;;;;KACd;IAED,SAAS;IACH,+CAAkB,GAAxB,UAAyB,YAAY;;;;;4BAChB,qBAAM,IAAI,CAAC,sBAAsB,EAAE,EAAA;;wBAAlD,YAAY,GAAG,SAAmC;wBAClD,IAAI,kCACH,aAAa,GACb,YAAY,GACZ,YAAY,CAChB,CAAC;;;;wBAEa,qBAAM,MAAM,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,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 */
export default class AwardsService {
context: Context;
awardsDao: IBaseDao;
constructor(context: Context);
addWaitAwardsList(list: any): Promise<boolean>;
setUserShipStatus(activityId: any, prizeId: any, shipCompany: any, shipNum: any): Promise<any>;
getAwardListByActivityId({ activityId, title, pageNo, pageSize, prizeId, userNick, type, prizeDataType, shipStatus, startTime, endTime, isExport }: {
activityId?: string;
title?: string;
pageNo?: number;
pageSize?: number;
prizeId?: any;
userNick?: string;
type?: any;
prizeDataType?: any;
shipStatus?: any;
startTime?: any;
endTime?: any;
isExport?: boolean;
}): Promise<false | {
list: any;
total: any;
message: string;
pageNo: number;
pageSize: number;
}>;
}
"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 constants_1 = require("../constants");
var AwardsService = /** @class */ (function () {
function AwardsService(context) {
this.awardsDao = new sdk_1.BaseDao(context, db_1.AWARDS_DB_NAME);
}
// 添加排行榜待开奖列表
AwardsService.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 = 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.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*/];
}
});
});
};
AwardsService.prototype.setUserShipStatus = function (activityId, prizeId, shipCompany, shipNum) {
return __awaiter(this, void 0, void 0, function () {
var status, result;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
prizeId = prizeId ? prizeId : '/';
shipCompany = shipCompany ? shipCompany : '';
shipNum = shipNum ? shipNum : '';
status = constants_1.SHIP_STATUS.NO_SHIP;
console.log(shipCompany, shipNum, 'shipCompany,shipNum');
if (shipCompany && shipNum) {
status = constants_1.SHIP_STATUS.HAS_SHIP;
}
else {
status = constants_1.SHIP_STATUS.NO_SHIP;
}
if (!(status == constants_1.SHIP_STATUS.HAS_SHIP)) return [3 /*break*/, 2];
console.log(activityId, prizeId, constants_1.PRIZE_TYPE.OBJECT);
return [4 /*yield*/, this.awardsDao.update({
activityId: activityId,
_id: prizeId,
type: constants_1.PRIZE_TYPE.OBJECT,
shipStatus: constants_1.SHIP_STATUS.NO_SHIP
}, {
$set: {
shipCompany: shipCompany,
shipNum: shipNum,
shipStatus: status
}
})];
case 1:
result = _a.sent();
console.log(result, 'result');
return [2 /*return*/, result];
case 2: return [2 /*return*/, 0];
}
});
});
};
// 根据活动id查找中奖名单
AwardsService.prototype.getAwardListByActivityId = function (_a) {
var _b = _a.activityId, activityId = _b === void 0 ? '' : _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, _f = _a.prizeId, prizeId = _f === void 0 ? null : _f, _g = _a.userNick, userNick = _g === void 0 ? '' : _g, _h = _a.type, type = _h === void 0 ? null : _h, _j = _a.prizeDataType, prizeDataType = _j === void 0 ? null : _j, _k = _a.shipStatus, shipStatus = _k === void 0 ? null : _k, _l = _a.startTime, startTime = _l === void 0 ? null : _l, _m = _a.endTime, endTime = _m === void 0 ? null : _m, _o = _a.isExport, isExport = _o === void 0 ? false : _o;
return __awaiter(this, void 0, void 0, function () {
var p, u, c, s, t, pt, arr, query, list, total;
return __generator(this, function (_p) {
switch (_p.label) {
case 0:
if (!activityId)
return [2 /*return*/, false];
p = prizeId ? { _id: prizeId } : null;
u = userNick ? { userNick: { $regex: '.*' + userNick + '.*' } } : null;
c = startTime > 0 && endTime > 0 ? { createTime: { $gt: startTime, $lt: endTime } } : null;
s = shipStatus
? (shipStatus == 1
? { shipStatus: { $in: [constants_1.SHIP_STATUS.NO_ADDRESS] } }
: (shipStatus == 2
? { shipStatus: { $in: [constants_1.SHIP_STATUS.NO_SHIP] } }
: { shipStatus: constants_1.SHIP_STATUS.HAS_SHIP }))
: '';
t = type ? { type: +type } : null;
pt = prizeDataType ? { prizeDataType: +prizeDataType } : null;
arr = [];
if (p)
arr.push(p);
if (u)
arr.push(u);
if (c)
arr.push(c);
if (s)
arr.push(s);
if (t)
arr.push(t);
if (pt)
arr.push(pt);
arr = arr.filter(function (i) { return i; });
console.log('arr--111---', arr, activityId);
query = { activityId: activityId };
// @ts-ignore
if (arr.length > 0)
query.$and = arr;
return [4 /*yield*/, this.awardsDao.find(query, {
limit: pageSize,
skip: (pageNo - 1) * pageSize,
sort: {
score: -1,
rankTime: -1
}
})];
case 1:
list = _p.sent();
return [4 /*yield*/, this.awardsDao.count(query)];
case 2:
total = _p.sent();
return [2 /*return*/, {
list: list,
total: total,
message: '成功',
pageNo: pageNo,
pageSize: pageSize
}];
}
});
});
};
return AwardsService;
}());
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,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEd,UAAU;AAEV,8BAAgC;AAChC,4BAAsC;AAEtC,0CAAmE;AACnE;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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C,IAAI,OAAA,CAAC,EAAD,CAAC,CAAC,CAAA;wBACxB,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,GAAG,EAAE,UAAU,CAAC,CAAA;wBAErC,KAAK,GAAG,EAAE,UAAU,YAAA,EAAE,CAAA;wBAC5B,aAAa;wBACb,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC;4BAAE,KAAK,CAAC,IAAI,GAAG,GAAG,CAAA;wBACvB,qBAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE;gCAC5C,KAAK,EAAE,QAAQ;gCACf,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,QAAQ;gCAC7B,IAAI,EAAE;oCACJ,KAAK,EAAE,CAAC,CAAC;oCACT,QAAQ,EAAE,CAAC,CAAC;iCACb;6BACF,CAAC,EAAA;;wBAPI,IAAI,GAAG,SAOX;wBACY,qBAAM,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,EAAA;;wBAAzC,KAAK,GAAG,SAAiC;wBAC/C,sBAAO;gCACL,IAAI,MAAA;gCACJ,KAAK,OAAA;gCACL,OAAO,EAAE,IAAI;gCACb,MAAM,QAAA;gCACN,QAAQ,UAAA;6BACT,EAAA;;;;KACF;IACH,oBAAC;AAAD,CAAC,AAzHD,IAyHC"}
\ No newline at end of file
/**
* 基本信息
*
* @format
*/
export default class BaseService {
context: Context;
activitydao: IBaseDao;
constructor(context: Context);
/**
* @desc 活动基本信息
* @param {活动id} activityId
* @returns 返回活动详情,若不存在活动,返回为null
*/
getBaseInfo(activityId: string): Promise<any>;
}
"use strict";
/**
* 基本信息
*
* @format
*/
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 BaseService = /** @class */ (function () {
function BaseService(context) {
this.context = context;
this.activitydao = new sdk_1.BaseDao(context, db_1.ACTIVITY_CONFIG_DB_NAME);
}
/**
* @desc 活动基本信息
* @param {活动id} activityId
* @returns 返回活动详情,若不存在活动,返回为null
*/
BaseService.prototype.getBaseInfo = function (activityId) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
console.log(process.argv[2], 'process.argv[2]');
return [4 /*yield*/, this.activitydao.findOne({ _id: activityId })];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
return BaseService;
}());
exports.default = BaseService;
//# sourceMappingURL=base.service.js.map
\ No newline at end of file
{"version":3,"file":"base.service.js","sourceRoot":"","sources":["../../src/service/base.service.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,8BAAgC;AAChC,4BAA+C;AAE/C;IAGE,qBAAY,OAAgB;QAC1B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,WAAW,GAAG,IAAI,aAAO,CAAC,OAAO,EAAE,4BAAuB,CAAC,CAAA;IAClE,CAAC;IACD;;;;OAIG;IACG,iCAAW,GAAjB,UAAkB,UAAkB;;;;;wBAClC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,iBAAiB,CAAC,CAAA;wBACxC,qBAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,UAAU,EAAE,CAAC,EAAA;4BAA1D,sBAAO,SAAmD,EAAA;;;;KAC3D;IACH,kBAAC;AAAD,CAAC,AAhBD,IAgBC"}
\ No newline at end of file
/** @format */
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 });
exports.AwardsService = exports.InstanceService = exports.SellerService = exports.TaobaoTopService = exports.ActivityconfigService = void 0;
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,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<any, false> | import("taobao-mini-sdk/lib/utils/resultmodel").Result<{
list: any;
totalCount: any;
}, true>>;
getPrizeByEname(session: string, ename: string): Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result<any, false> | import("taobao-mini-sdk/lib/utils/resultmodel").Result<any, true>>;
getShopId(): Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result<any, false> | import("taobao-mini-sdk/lib/utils/resultmodel").Result<any, true>>;
getItemListByStatus(session: string, { approveStatus, title, pageNo, pageSize }: {
approveStatus?: string;
title?: string;
pageNo?: number;
pageSize?: number;
}): Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result<any, false> | import("taobao-mini-sdk/lib/utils/resultmodel").Result<{
pageNo: number;
pageSize: number;
totalPages: number;
totalCount: any;
list: any;
}, true>>;
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, 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, 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
},
autoSession: true
})];
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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C;AAAD,CAAC,AA/PD,IA+PC"}
\ No newline at end of file
/**
* 任务相关方法
*
* @format
*/
import UserService from './user.service';
interface ITaskInfo {
taskType?: string;
url?: string;
rewards: number;
done?: boolean;
itemIds?: string;
waitReceive?: number;
title: string;
}
export default class TaskService extends UserService {
constructor(context: Context);
initVipTask(userInfo: IUserInfo, vipInfo: IVipInfo, tasks: ITasks): ITaskInfo;
initOrderGoodsTask(userInfo: IUserInfo, tasks: ITasks): ITaskInfo;
initBrowseGoodsTask(userInfo: IUserInfo, tasks: ITasks): ITaskInfo;
initInvitesTask(userInfo: IUserInfo, tasks: ITasks): ITaskInfo;
initFollowTask(userInfo: IUserInfo, tasks: ITasks): {
taskType: string;
title: string;
rewards: number;
waitReceive: number;
done: boolean;
};
initExchangeCreditsTask(userInfo: IUserInfo, tasks: ITasks): {
taskType: string;
title: string;
rewards: number;
waitReceive: number;
done: boolean;
};
updateVipTaskStatus(userInfo: IUserInfo, vipInfo: IVipInfo, tasks: ITasks): {
member: IMemberInfo;
remainTimes: IRemainTimesInfo;
};
updateOrderGoodsTask(userInfo: IUserInfo, tasks: ITasks, session?: string): Promise<{
remainTimes?: undefined;
taskInfo?: undefined;
} | {
remainTimes: IRemainTimesInfo;
taskInfo: object;
}>;
/**
*更新关注店铺任务状态
*
* @param {IUserInfo} userInfo
* @param {IActivityInfo} activityInfo
* @returns
* @memberof TaskService
*/
updateFollowTask(userInfo: IUserInfo, activityInfo: IActivityInfo): Promise<any>;
/**
*
* 获取任务今天完成的次数
*
* @param {string} taskType 任务类型
* @param {IUserInfo} userInfo 用户信息
* @returns {number} todayTimes 今日任务完成次数 todayTaskInfo 今日对应任务完成详情
* @memberof TaskService
*/
getTodayCompleteTask(taskType: string, userInfo: IUserInfo): {
todayTimes: any;
todayTaskInfo: any;
};
/**
* 根据任务类型获取任务完成情况
*
* @param {IUserInfo} userInfo
* @param {string} taskType
* @returns {array}
* @memberof TaskService
*/
getCompleteTaskByUserTaskInfo(taskType: string, userInfo: IUserInfo): any[];
/**
*根据任务类型更新任务待领取次数和任务记录
*
* @param {string} taskType
* @param {number} rewards
* @param {IUserInfo} userInfo
* @param {object} [customRecord]
* @returns {boolean}
* @memberof TaskService
*/
updateUserTaskRecord(taskType: string, rewards: number, userInfo: IUserInfo, customRecord?: object): Promise<boolean>;
updateTasks(id: string, needUpdateKeysArray: object[]): Promise<any>;
}
export {};
"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 __());
};
})();
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 user_service_1 = require("./user.service");
var utils_1 = require("../utils");
var constants_1 = require("../constants");
var TaskService = /** @class */ (function (_super) {
__extends(TaskService, _super);
function TaskService(context) {
return _super.call(this, context) || this;
}
TaskService.prototype.initVipTask = function (userInfo, vipInfo, tasks) {
var _a = userInfo.member, flag = _a.flag, newMember = _a.newMember, remainTimes = userInfo.remainTimes;
// 后台配置奖励
var value = tasks.beMembership.value;
// 会员信息
var isVipBefore = flag;
return {
taskType: "member",
title: "\u52A0\u5165\u4F1A\u5458",
url: vipInfo.url,
rewards: value,
waitReceive: remainTimes.member,
// 已经是会员, 说明完成任务
done: newMember || isVipBefore
};
};
// 初始化下单任务
TaskService.prototype.initOrderGoodsTask = function (userInfo, tasks) {
var _a;
var _b = tasks.orderGoods, value = _b.value, itemIds = _b.itemIds, taskRateType = _b.taskRateType, times = _b.times;
var remainTimes = userInfo.remainTimes, taskInfo = userInfo.taskInfo;
var orderTask = {
taskType: "orderGoods",
title: "\u4E0B\u5355\u5546\u54C1",
itemIds: itemIds,
rewards: value,
waitReceive: remainTimes.orderGoods,
done: false
};
var orderGoodsCompleteList = this.getCompleteTaskByUserTaskInfo('orderGoods', userInfo);
// 永久任务且已完成
if (taskRateType === constants_1.TASK_RATE_TYPE.FOREVER && orderGoodsCompleteList) {
orderTask.done = true;
}
// 每日限制完成且完成次数达到限制
var today = utils_1.getToday();
if (taskRateType === constants_1.TASK_RATE_TYPE.EVERYDAY && ((_a = taskInfo === null || taskInfo === void 0 ? void 0 : taskInfo[today]) === null || _a === void 0 ? void 0 : _a.orderGoods) >= times) {
orderTask.done = true;
}
return orderTask;
};
// 初始化浏览商品任务
TaskService.prototype.initBrowseGoodsTask = function (userInfo, tasks) {
var _a;
var _b = tasks.browseGoods, value = _b.value, itemIds = _b.itemIds, taskRateType = _b.taskRateType, times = _b.times;
var remainTimes = userInfo.remainTimes, taskInfo = userInfo.taskInfo;
var orderTask = {
taskType: "browseGoods",
title: "\u6D4F\u89C8\u5546\u54C1",
itemIds: itemIds,
rewards: value,
waitReceive: remainTimes.browseGoods,
done: false
};
var browseGoodsCompleteList = this.getCompleteTaskByUserTaskInfo('browseGoods', userInfo);
// 永久任务且已完成
if (taskRateType === constants_1.TASK_RATE_TYPE.FOREVER && browseGoodsCompleteList) {
orderTask.done = true;
}
// 每日限制完成且完成次数达到限制
var today = utils_1.getToday();
if (taskRateType === constants_1.TASK_RATE_TYPE.EVERYDAY && ((_a = taskInfo === null || taskInfo === void 0 ? void 0 : taskInfo[today]) === null || _a === void 0 ? void 0 : _a.browseGoods) >= times) {
orderTask.done = true;
}
return orderTask;
};
// 初始化邀请任务
TaskService.prototype.initInvitesTask = function (userInfo, tasks) {
var _a;
var _b = tasks.inviteFriends, value = _b.value, taskRateType = _b.taskRateType, times = _b.times;
var remainTimes = userInfo.remainTimes, taskInfo = userInfo.taskInfo;
var orderTask = {
taskType: "invites",
title: "\u9080\u8BF7",
rewards: value,
waitReceive: remainTimes.invites,
done: false
};
var invitesCompleteList = this.getCompleteTaskByUserTaskInfo('invites', userInfo);
// 永久任务且已完成
if (taskRateType === constants_1.TASK_RATE_TYPE.FOREVER && invitesCompleteList) {
orderTask.done = true;
}
// 每日限制完成且完成次数达到限制
var today = utils_1.getToday();
if (taskRateType === constants_1.TASK_RATE_TYPE.EVERYDAY && ((_a = taskInfo === null || taskInfo === void 0 ? void 0 : taskInfo[today]) === null || _a === void 0 ? void 0 : _a.invites) >= times) {
orderTask.done = true;
}
return orderTask;
};
// 关注店铺
TaskService.prototype.initFollowTask = function (userInfo, tasks) {
var value = tasks.attentionStore.value;
var remainTimes = userInfo.remainTimes;
var orderGoodsCompleteList = this.getCompleteTaskByUserTaskInfo('follow', userInfo);
return {
taskType: "follow",
title: "\u5173\u6CE8\u5E97\u94FA",
rewards: value,
waitReceive: remainTimes.follow,
done: !!orderGoodsCompleteList.length
};
};
// 积分兑换
TaskService.prototype.initExchangeCreditsTask = function (userInfo, tasks) {
var _a;
var _b = tasks.exchangeCredits, value = _b.value, times = _b.times;
var remainTimes = userInfo.remainTimes, taskInfo = userInfo.taskInfo;
var today = utils_1.getToday();
return {
taskType: "exchangeCredits",
title: "\u79EF\u5206\u5151\u6362",
rewards: value,
waitReceive: remainTimes.exchangeCredits,
// 积分兑换固定为每日限制
done: !!(((_a = taskInfo === null || taskInfo === void 0 ? void 0 : taskInfo[today]) === null || _a === void 0 ? void 0 : _a.exchangeCredits) >= times)
};
};
// 根据会员状态更新
TaskService.prototype.updateVipTaskStatus = function (userInfo, vipInfo, tasks) {
var member = userInfo.member, remainTimes = userInfo.remainTimes, _id = userInfo._id;
var newMember = member.newMember;
var today = utils_1.getToday();
var isNewVip = this.checkNewVipStatus(userInfo, vipInfo);
var value = tasks.beMembership.value;
if (isNewVip && !newMember) {
member.newMember = true;
member.bememberTime = Date.now();
member.bememberDay = today;
remainTimes.member = (remainTimes.member || 0) + value;
}
return {
member: member,
remainTimes: remainTimes
};
};
TaskService.prototype.updateOrderGoodsTask = function (userInfo, tasks, session) {
var _a;
return __awaiter(this, void 0, void 0, function () {
var taskInfo, remainTimes, _b, value, itemIds, taskRateType, times, orderGoodsCompleteList, today, lastOrderInfo, orderResult, itemIdsArr;
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
taskInfo = userInfo.taskInfo, remainTimes = userInfo.remainTimes;
_b = tasks.orderGoods, value = _b.value, itemIds = _b.itemIds, taskRateType = _b.taskRateType, times = _b.times;
orderGoodsCompleteList = this.getCompleteTaskByUserTaskInfo('orderGoods', userInfo);
// 永久任务且已完成
if (taskRateType === constants_1.TASK_RATE_TYPE.FOREVER && orderGoodsCompleteList) {
return [2 /*return*/, {}];
}
today = utils_1.getToday();
if (taskRateType === constants_1.TASK_RATE_TYPE.EVERYDAY && ((_a = taskInfo === null || taskInfo === void 0 ? void 0 : taskInfo[today]) === null || _a === void 0 ? void 0 : _a.orderGoods) >= times) {
return [2 /*return*/, {}];
}
lastOrderInfo = (orderGoodsCompleteList === null || orderGoodsCompleteList === void 0 ? void 0 : orderGoodsCompleteList[orderGoodsCompleteList.length - 1]) || {};
return [4 /*yield*/, utils_1.getUserOrderlist(this.context,
//@ts-ignore
lastOrderInfo.createTime || Date.now(), Date.now(), session)];
case 1:
orderResult = _c.sent();
itemIdsArr = itemIds.split(',').map(function (v) { return +v; });
orderResult.forEach(function (v) {
if (itemIdsArr.includes(v.itemId)) {
remainTimes.orderGoods += +value;
taskInfo[today] = (taskInfo === null || taskInfo === void 0 ? void 0 : taskInfo[today]) || {};
taskInfo[today].orderGoods = taskInfo[today].orderGoods || [];
taskInfo[today].orderGoods.push({
itemId: v.itemId,
createTime: Date.now()
});
}
});
return [2 /*return*/, {
remainTimes: remainTimes,
taskInfo: taskInfo
}];
}
});
});
};
/**
*更新关注店铺任务状态
*
* @param {IUserInfo} userInfo
* @param {IActivityInfo} activityInfo
* @returns
* @memberof TaskService
*/
TaskService.prototype.updateFollowTask = function (userInfo, activityInfo) {
return __awaiter(this, void 0, void 0, function () {
var today, remainTimes, _id, taskInfo, follow, tasks, value, followInfo;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
today = utils_1.getToday();
remainTimes = userInfo.remainTimes, _id = userInfo._id, taskInfo = userInfo.taskInfo, follow = userInfo.follow;
tasks = activityInfo.tasks;
value = (tasks || {}).attentionStore.value;
followInfo = __assign(__assign({}, follow), { newFollow: true, followTime: Date.now(), followDay: today });
// 记录数据
taskInfo[today] = taskInfo[today] || {};
taskInfo[today].follow = 1;
// 增加待领取次数
remainTimes.follow += value;
return [4 /*yield*/, this.updateUser(_id, {
$set: {
remainTimes: remainTimes,
follow: followInfo,
taskInfo: taskInfo
}
})];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
/**
*
* 获取任务今天完成的次数
*
* @param {string} taskType 任务类型
* @param {IUserInfo} userInfo 用户信息
* @returns {number} todayTimes 今日任务完成次数 todayTaskInfo 今日对应任务完成详情
* @memberof TaskService
*/
TaskService.prototype.getTodayCompleteTask = function (taskType, userInfo) {
var _a, _b, _c, _d, _e;
var today = utils_1.getToday();
return {
todayTimes: ((_c = (_b = (_a = userInfo === null || userInfo === void 0 ? void 0 : userInfo.taskInfo) === null || _a === void 0 ? void 0 : _a[today]) === null || _b === void 0 ? void 0 : _b[taskType]) === null || _c === void 0 ? void 0 : _c.length) || 0,
todayTaskInfo: (_e = (_d = userInfo === null || userInfo === void 0 ? void 0 : userInfo.taskInfo) === null || _d === void 0 ? void 0 : _d[today]) === null || _e === void 0 ? void 0 : _e[taskType]
};
};
/**
* 根据任务类型获取任务完成情况
*
* @param {IUserInfo} userInfo
* @param {string} taskType
* @returns {array}
* @memberof TaskService
*/
TaskService.prototype.getCompleteTaskByUserTaskInfo = function (taskType, userInfo) {
var _a = userInfo.taskInfo, taskInfo = _a === void 0 ? {} : _a;
var targetTaskList = [];
Object.keys(taskInfo).forEach(function (day) {
var _a, _b, _c, _d;
if ((_a = taskInfo[day]) === null || _a === void 0 ? void 0 : _a[taskType]) {
var dayTaskInfo = Array.isArray((_b = taskInfo[day]) === null || _b === void 0 ? void 0 : _b[taskType])
? (_c = taskInfo[day]) === null || _c === void 0 ? void 0 : _c[taskType] : [(_d = taskInfo[day]) === null || _d === void 0 ? void 0 : _d[taskType]];
targetTaskList = __spreadArrays(targetTaskList, dayTaskInfo);
}
});
return targetTaskList;
};
/**
*根据任务类型更新任务待领取次数和任务记录
*
* @param {string} taskType
* @param {number} rewards
* @param {IUserInfo} userInfo
* @param {object} [customRecord]
* @returns {boolean}
* @memberof TaskService
*/
TaskService.prototype.updateUserTaskRecord = function (taskType, rewards, userInfo, customRecord) {
return __awaiter(this, void 0, void 0, function () {
var _id, openId, today, result;
var _a, _b;
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
_id = userInfo._id;
openId = this.context.openId;
today = utils_1.getToday();
return [4 /*yield*/, this.updateUser(_id, {
$inc: (_a = {},
_a["remainTimes." + taskType] = rewards,
_a),
$push: (_b = {},
_b["taskInfo." + today + "." + taskType] = __assign({ openId: openId, createTime: Date.now() }, customRecord),
_b)
})];
case 1:
result = _c.sent();
return [2 /*return*/, result === 1];
}
});
});
};
TaskService.prototype.updateTasks = function (id, needUpdateKeysArray) {
return __awaiter(this, void 0, void 0, function () {
var updateKeys;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
updateKeys = Object.assign.apply(Object, __spreadArrays([{}], needUpdateKeysArray));
return [4 /*yield*/, this.updateUser(id, {
$set: updateKeys
})];
case 1:
_a.sent();
return [4 /*yield*/, this.getUserInfo()];
case 2: return [2 /*return*/, _a.sent()];
}
});
});
};
return TaskService;
}(user_service_1.default));
exports.default = TaskService;
//# sourceMappingURL=task.service.js.map
\ No newline at end of file
{"version":3,"file":"task.service.js","sourceRoot":"","sources":["../../src/service/task.service.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGH,+CAAwC;AAExC,kCAAqD;AACrD,0CAA6C;AAW7C;IAAyC,+BAAW;IAClD,qBAAY,OAAgB;eAC1B,kBAAM,OAAO,CAAC;IAChB,CAAC;IAED,iCAAW,GAAX,UAAY,QAAmB,EAAE,OAAiB,EAAE,KAAa;QAE7D,IAAA,KAEE,QAAQ,OAFiB,EAAjB,IAAI,UAAA,EAAE,SAAS,eAAA,EACzB,WAAW,GACT,QAAQ,YADC,CACD;QAEZ,SAAS;QAES,IAAA,KAAK,GACnB,KAAK,mBADc,CACd;QAET,OAAO;QAEP,IAAM,WAAW,GAAG,IAAI,CAAA;QAExB,OAAO;YACL,QAAQ,EAAE,QAAQ;YAClB,KAAK,EAAE,0BAAM;YACb,GAAG,EAAE,OAAO,CAAC,GAAG;YAChB,OAAO,EAAE,KAAK;YACd,WAAW,EAAE,WAAW,CAAC,MAAM;YAC/B,gBAAgB;YAChB,IAAI,EAAE,SAAS,IAAI,WAAW;SAC/B,CAAA;IACH,CAAC;IAED,UAAU;IACV,wCAAkB,GAAlB,UAAmB,QAAmB,EAAE,KAAa;;QAEjD,IAAA,KACE,KAAK,WAD4C,EAArC,KAAK,WAAA,EAAE,OAAO,aAAA,EAAE,YAAY,kBAAA,EAAE,KAAK,WAAE,CAC5C;QAED,IAAA,WAAW,GAAe,QAAQ,YAAvB,EAAE,QAAQ,GAAK,QAAQ,SAAb,CAAa;QAE1C,IAAI,SAAS,GAAc;YACzB,QAAQ,EAAE,YAAY;YACtB,KAAK,EAAE,0BAAM;YACb,OAAO,SAAA;YACP,OAAO,EAAE,KAAK;YACd,WAAW,EAAE,WAAW,CAAC,UAAU;YACnC,IAAI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
/**
* 用户相关方法
*
* @format
*/
import BaseService from './base.service';
declare class UserService extends BaseService {
userdao: IBaseDao;
constructor(context: Context);
/**
* @desc 获取当前打开活动的用户详情
* @returns 若用户不存在,返回null; 用户存在,返回用户信息(object对象)
*/
getUserInfo(): Promise<any>;
/**
* @desc 根据inviteId获取用户详情
* @desc 常用于助力分享码为用户openId, 被邀请人打开活动助力时需要获取邀请人的用户详情
* @param {邀请人的openId} inviteId
* @returns 若用户不存在,返回null; 用户存在,返回用户信息(object对象)
*/
getUserInfoByOpenId(inviteId: string): Promise<any>;
/**
* @desc 获取是否是会员
* @param {调用淘宝接口的session} session
* @returns {isVip: boolean(是否是会员), url: string(入会链接) }
*/
getShopVip(session: string, callbackUrl?: string): Promise<IVipInfo>;
/**
* 初始化用户数据
*
* @param {IVipInfo} vipInfo
* @param {IActivityInfo} activityInfo
* @returns
* @memberof UserService
*/
initUserData(vipInfo: IVipInfo, activityInfo: IActivityInfo): Promise<any>;
updateUserData(vipInfo: IVipInfo, userInfo: IUserInfo): Promise<void>;
/**
* @desc 更新用户表
* @param {用户的主键id} _id
* @param {更新的对象} document
* @returns 若更新成功,返回为1; 若更新失败,返回为 0 或系统直接报错
*/
updateUser(_id: string, projection: object): Promise<any>;
/**
* @desc 根据用户主键id查找用户详情
* @param {用户的主键id} _id
* @returns 若用户不存在,返回null; 用户存在,返回用户信息(object对象)
*/
getUserInfoById(_id: string): Promise<any>;
/**
*判断是否新会员
*
* @param {IUserInfo} userInfo
* @param {IVipInfo} vipInfo
* @returns {boolean}
* @memberof UserService
*/
checkNewVipStatus(userInfo: IUserInfo, vipInfo: IVipInfo): boolean;
}
export default UserService;
"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 __());
};
})();
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 base_service_1 = require("./base.service");
var db_1 = require("../db");
var utils_1 = require("../utils");
var config_1 = require("../config");
var UserService = /** @class */ (function (_super) {
__extends(UserService, _super);
function UserService(context) {
var _this = _super.call(this, context) || this;
_this.userdao = new sdk_1.BaseDao(context, db_1.USER_DB_NAME);
return _this;
}
/**
* @desc 获取当前打开活动的用户详情
* @returns 若用户不存在,返回null; 用户存在,返回用户信息(object对象)
*/
UserService.prototype.getUserInfo = function () {
return __awaiter(this, void 0, void 0, function () {
var _a, openId, data, activityId, record;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
_a = this.context, openId = _a.openId, data = _a.data;
activityId = data.activityId;
return [4 /*yield*/, this.userdao.findOne({ openId: openId, activityId: activityId })];
case 1:
record = _b.sent();
return [2 /*return*/, record];
}
});
});
};
/**
* @desc 根据inviteId获取用户详情
* @desc 常用于助力分享码为用户openId, 被邀请人打开活动助力时需要获取邀请人的用户详情
* @param {邀请人的openId} inviteId
* @returns 若用户不存在,返回null; 用户存在,返回用户信息(object对象)
*/
UserService.prototype.getUserInfoByOpenId = function (inviteId) {
return __awaiter(this, void 0, void 0, function () {
var activityId, record;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
activityId = this.context.data.activityId;
return [4 /*yield*/, this.userdao.findOne({ openId: inviteId, activityId: activityId })];
case 1:
record = _a.sent();
return [2 /*return*/, record];
}
});
});
};
/**
* @desc 获取是否是会员
* @param {调用淘宝接口的session} session
* @returns {isVip: boolean(是否是会员), url: string(入会链接) }
*/
UserService.prototype.getShopVip = function (session, callbackUrl) {
if (callbackUrl === void 0) { callbackUrl = ''; }
return __awaiter(this, void 0, void 0, function () {
var VIP_MOCK, result, shopUrl, e_1;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
VIP_MOCK = config_1.getConfig(this.context).VIP_MOCK;
if (VIP_MOCK) {
return [2 /*return*/, {
isVip: true
}];
}
result = {
result: {
member_info: ''
}
};
shopUrl = {
result: {
result: ''
}
};
_a.label = 1;
case 1:
_a.trys.push([1, 4, , 5]);
return [4 /*yield*/, sdk_1.TBAPIS.queryVipinfo(this.context, session)];
case 2:
result = _a.sent();
return [4 /*yield*/, sdk_1.TBAPIS.getShopVipUrl(this.context, session, {
source: 'isvapp',
entrance: 'duiba'
}, callbackUrl)];
case 3:
shopUrl = _a.sent();
return [3 /*break*/, 5];
case 4:
e_1 = _a.sent();
console.log(e_1);
return [3 /*break*/, 5];
case 5:
console.log("result, shopUrl", result, shopUrl);
return [2 /*return*/, {
isVip: !!(result.result && result.result.member_info),
url: shopUrl.result && shopUrl.result.result
}];
}
});
});
};
/**
* 初始化用户数据
*
* @param {IVipInfo} vipInfo
* @param {IActivityInfo} activityInfo
* @returns
* @memberof UserService
*/
UserService.prototype.initUserData = function (vipInfo, activityInfo) {
return __awaiter(this, void 0, void 0, function () {
var _a, openId, data, activityId, isFollow, avatar, inviteId, userNick, today, tasks, attentionStore, beMembership, user;
var _b, _c;
return __generator(this, function (_d) {
switch (_d.label) {
case 0:
_a = this.context, openId = _a.openId, data = _a.data;
activityId = data.activityId, isFollow = data.isFollow, avatar = data.avatar, inviteId = data.inviteId, userNick = data.userNick;
today = utils_1.getToday();
console.log("----------" + today + "----------", today);
tasks = activityInfo.tasks;
attentionStore = tasks.attentionStore, beMembership = tasks.beMembership;
user = {
activityId: activityId,
avatar: avatar,
inviteId: inviteId,
userNick: userNick,
openId: openId,
// 待领取次数初始化, 根据需自定义添加
remainTimes: {
follow: isFollow ? attentionStore.value : 0,
member: vipInfo.isVip ? beMembership.value : 0
},
member: {
flag: !!vipInfo.isVip
},
follow: {
flag: !!isFollow
},
login: (_b = {},
_b[today] = 1,
_b),
taskInfo: (_c = {},
_c[today] = {},
_c),
createTime: Date.now(),
createDay: today,
updateTime: Date.now()
};
return [4 /*yield*/, this.userdao.insertOne(user)];
case 1: return [2 /*return*/, _d.sent()];
}
});
});
};
UserService.prototype.updateUserData = function (vipInfo, userInfo) {
return __awaiter(this, void 0, void 0, function () {
var data, isFollow, followBefore, followNow, today, isNewVip;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
data = this.context.data;
isFollow = data.isFollow;
followBefore = userInfo.follow.flag;
followNow = isFollow;
if (!followBefore && followNow && !userInfo.follow.newFollow) {
userInfo.follow.newFollow = true;
userInfo.follow.followTime = userInfo.follow.followTime || Date.now();
}
today = utils_1.getToday();
isNewVip = this.checkNewVipStatus(userInfo, vipInfo);
if (isNewVip && !userInfo.member.newMember) {
userInfo.member.newMember = true;
userInfo.member.bememberTime = userInfo.member.bememberTime || Date.now();
}
// 添加登录次数
userInfo['login'][today] = userInfo['login'][today] ? userInfo['login'][today] + 1 : 1;
return [4 /*yield*/, this.updateUser(userInfo._id, {
$set: {
follow: userInfo.follow,
login: userInfo['login'],
member: userInfo.member
}
})];
case 1:
_a.sent();
return [2 /*return*/];
}
});
});
};
/**
* @desc 更新用户表
* @param {用户的主键id} _id
* @param {更新的对象} document
* @returns 若更新成功,返回为1; 若更新失败,返回为 0 或系统直接报错
*/
UserService.prototype.updateUser = function (_id, projection) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
console.log(projection);
if (projection['$set']) {
projection['$set'].updateTime = Date.now();
}
return [4 /*yield*/, this.userdao.update({ _id: _id }, projection)];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
/**
* @desc 根据用户主键id查找用户详情
* @param {用户的主键id} _id
* @returns 若用户不存在,返回null; 用户存在,返回用户信息(object对象)
*/
UserService.prototype.getUserInfoById = function (_id) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.userdao.findOne({ _id: _id })];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
/**
*判断是否新会员
*
* @param {IUserInfo} userInfo
* @param {IVipInfo} vipInfo
* @returns {boolean}
* @memberof UserService
*/
UserService.prototype.checkNewVipStatus = function (userInfo, vipInfo) {
var flag = userInfo.member.flag;
var isVip = vipInfo.isVip;
return !flag && isVip;
};
return UserService;
}(base_service_1.default));
exports.default = UserService;
//# sourceMappingURL=user.service.js.map
\ No newline at end of file
{"version":3,"file":"user.service.js","sourceRoot":"","sources":["../../src/service/user.service.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,8BAAwC;AACxC,+CAAwC;AACxC,4BAAoC;AACpC,kCAAmC;AACnC,oCAAqC;AAErC;IAA0B,+BAAW;IAEnC,qBAAY,OAAgB;QAA5B,YACE,kBAAM,OAAO,CAAC,SAEf;QADC,KAAI,CAAC,OAAO,GAAG,IAAI,aAAO,CAAC,OAAO,EAAE,iBAAY,CAAC,CAAA;;IACnD,CAAC;IACD;;;OAGG;IACG,iCAAW,GAAjB;;;;;;wBACM,KAAmB,IAAI,CAAC,OAAO,EAA7B,MAAM,YAAA,EAAE,IAAI,UAAA,CAAiB;wBAC7B,UAAU,GAAK,IAAI,WAAT,CAAS;wBACZ,qBAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,MAAM,QAAA,EAAE,UAAU,YAAA,EAAE,CAAC,EAAA;;wBAA3D,MAAM,GAAG,SAAkD;wBAC/D,sBAAO,MAAM,EAAA;;;;KACd;IAED;;;;;OAKG;IACG,yCAAmB,GAAzB,UAA0B,QAAgB;;;;;;wBAClC,UAAU,GAAK,IAAI,CAAC,OAAO,CAAC,IAAI,WAAtB,CAAsB;wBACzB,qBAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,YAAA,EAAE,CAAC,EAAA;;wBAArE,MAAM,GAAG,SAA4D;wBACzE,sBAAO,MAAM,EAAA;;;;KACd;IAED;;;;OAIG;IACG,gCAAU,GAAhB,UAAiB,OAAe,E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IAED;;;;;OAKG;IACG,gCAAU,GAAhB,UAAiB,GAAW,EAAE,UAAkB;;;;;wBAC9C,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAA;wBACvB,IAAI,UAAU,CAAC,MAAM,CAAC,EAAE;4BACtB,UAAU,CAAC,MAAM,CAAC,CAAC,UAAU,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;yBAC3C;wBACM,qBAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,GAAG,KAAA,EAAE,EAAE,UAAU,CAAC,EAAA;4BAArD,sBAAO,SAA8C,EAAA;;;;KACtD;IACD;;;;OAIG;IACG,qCAAe,GAArB,UAAsB,GAAW;;;;4BACxB,qBAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,GAAG,KAAA,EAAE,CAAC,EAAA;4BAA1C,sBAAO,SAAmC,EAAA;;;;KAC3C;IAED;;;;;;;OAOG;IACH,uCAAiB,GAAjB,UAAkB,QAAmB,EAAE,OAAiB;QAE1C,IAAA,IAAI,GACZ,QAAQ,YADI,CACJ;QAEJ,IAAA,KAAK,GAAK,OAAO,MAAZ,CAAY;QAEzB,OAAO,CAAC,IAAI,IAAI,KAAK,CAAA;IACvB,CAAC;IACH,kBAAC;AAAD,CAAC,AA9LD,CAA0B,sBAAW,GA8LpC;AAED,kBAAe,WAAW,CAAA"}
\ No newline at end of file
/** @format */
export declare const exportHandlers: (controllers: 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);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.exportHandlers = void 0;
var exportHandlers = function (controllers) {
var handlersMapper = controllers
.map(function (controller) {
var controllerInstance = new controller();
var handlersKeys = Object.getOwnPropertyNames(Object.getPrototypeOf(controllerInstance)).filter(function (v) { return v !== 'constructor'; });
return handlersKeys.reduce(function (prev, current) {
var _a;
return __assign(__assign({}, prev), (_a = {}, _a[current] = controllerInstance[current], _a));
}, {});
})
.reduce(function (prev, current) {
return __assign(__assign({}, current), prev);
}, {});
return handlersMapper;
};
exports.exportHandlers = exportHandlers;
//# sourceMappingURL=exportHandlers.js.map
\ No newline at end of file
{"version":3,"file":"exportHandlers.js","sourceRoot":"","sources":["../../src/utils/exportHandlers.ts"],"names":[],"mappings":";AAAA,cAAc;;;;;;;;;;;;;;AAEP,IAAM,cAAc,GAAG,UAAC,WAAkB;IAC/C,IAAM,cAAc,GAAG,WAAW;SAC/B,GAAG,CAAC,UAAA,UAAU;QACb,IAAM,kBAAkB,GAAG,IAAI,UAAU,EAAE,CAAA;QAC3C,IAAM,YAAY,GAAG,MAAM,CAAC,mBAAmB,CAAC,MAAM,CAAC,cAAc,CAAC,kBAAkB,CAAC,CAAC,CAAC,MAAM,CAC/F,UAAA,CAAC,IAAI,OAAA,CAAC,KAAK,aAAa,EAAnB,CAAmB,CACzB,CAAA;QACD,OAAO,YAAY,CAAC,MAAM,CAAC,UAAC,IAAI,EAAE,OAAO;;YACvC,6BACK,IAAI,gBACN,OAAO,IAAG,kBAAkB,CAAC,OAAO,CAAC,OACvC;QACH,CAAC,EAAE,EAAE,CAAC,CAAA;IACR,CAAC,CAAC;SACD,MAAM,CAAC,UAAC,IAAI,EAAE,OAAO;QACpB,6BACK,OAAO,GACP,IAAI,EACR;IACH,CAAC,EAAE,EAAE,CAAC,CAAA;IACR,OAAO,cAAc,CAAA;AACvB,CAAC,CAAA;AArBY,QAAA,cAAc,kBAqB1B"}
\ No newline at end of file
/** @format */
export declare const getConsumerSeller: ({ accessToken, openId }: {
accessToken: any;
openId: any;
}) => {
open_id: any;
session: any;
};
"use strict";
/** @format */
Object.defineProperty(exports, "__esModule", { value: true });
exports.getConsumerSeller = void 0;
var 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
// REST_URL: 'http://gw.api.taobao.com/router/rest'
};
};
exports.getConsumerSeller = getConsumerSeller;
//# sourceMappingURL=getSeller.js.map
\ No newline at end of file
{"version":3,"file":"getSeller.js","sourceRoot":"","sources":["../../src/utils/getSeller.ts"],"names":[],"mappings":";AAAA,cAAc;;;AAEP,IAAM,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;QACpB,mDAAmD;KACpD,CAAA;AACH,CAAC,CAAA;AATY,QAAA,iBAAiB,qBAS7B"}
\ No newline at end of file
/** @format */
export declare const getToday: () => string;
"use strict";
/** @format */
Object.defineProperty(exports, "__esModule", { value: true });
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');
};
//# sourceMappingURL=getToday.js.map
\ No newline at end of file
{"version":3,"file":"getToday.js","sourceRoot":"","sources":["../../src/utils/getToday.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"}
\ No newline at end of file
/** @format */
export * from './logger';
export * from './time';
export * from './exportHandlers';
export * from './getSeller';
export * from './math';
"use strict";
/** @format */
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./logger"), 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;;;;;;;;;;;;AAEd,2CAAwB;AACxB,yCAAsB;AACtB,mDAAgC;AAChC,8CAA2B;AAC3B,yCAAsB"}
\ No newline at end of file
export declare const logger: (context: Context) => void;
export declare const recordErrorLog: (context: Context, baseInfos: IControllerInfos, errorMsg: string, stack: string) => Promise<any>;
"use strict";
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 });
exports.recordErrorLog = exports.logger = void 0;
/** @format */
var sdk_1 = require("../sdk");
var db_1 = require("../db");
var utils_1 = require("../utils");
var logger = function (context) {
var _a, _b, _c;
var data = JSON.stringify(context.data);
console.log(context);
console.log("---------\u51FD\u6570: " + (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) + "------------");
console.log("---------\u8BF7\u6C42\u53C2\u6570: " + data + "------------");
};
exports.logger = logger;
// 记录错误日志
var recordErrorLog = function (context, baseInfos, errorMsg, stack) { return __awaiter(void 0, void 0, void 0, function () {
var openId, userNick, activityId, logdao, functionName;
var _a, _b, _c;
return __generator(this, function (_d) {
switch (_d.label) {
case 0:
openId = context.openId, userNick = context.userNick;
activityId = (context.data || {}).activityId;
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({
openId: openId,
activityId: activityId,
errorMsg: errorMsg,
errorStack: stack,
functionName: functionName,
userNick: userNick,
fcInvokeId: context.fcInvokeId,
params: context.data,
createTime: Date.now(),
createDay: utils_1.getToday(),
catchType: 1
})];
case 1: return [2 /*return*/, _d.sent()];
}
});
}); };
exports.recordErrorLog = recordErrorLog;
//# sourceMappingURL=logger.js.map
\ No newline at end of file
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,cAAc;AACd,8BAAgC;AAChC,4BAAyC;AACzC,kCAAmC;AAE5B,IAAM,MAAM,GAAG,UAAC,OAAgB;;IACrC,IAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IACzC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;IACpB,OAAO,CAAC,GAAG,CACT,6BAAgB,OAAO,CAAC,MAAM,IAAI,EAAE,WAClC,mBAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,KAAK,0CAAE,SAAS,0CAAE,OAAO,0CAAE,OAAO,KAAI,OAAO,CAAC,OAAO,kBAClD,CACf,CAAA;IACD,OAAO,CAAC,GAAG,CAAC,wCAAkB,IAAI,iBAAc,CAAC,CAAA;AACnD,CAAC,CAAA;AATY,QAAA,MAAM,UASlB;AAED,SAAS;AACF,IAAM,cAAc,GAAG,UAC5B,OAAgB,EAChB,SAA2B,EAC3B,QAAgB,EAChB,KAAa;;;;;;gBAEL,MAAM,GAAe,OAAO,OAAtB,EAAE,QAAQ,GAAK,OAAO,SAAZ,CAAY;gBAC5B,UAAU,GAAK,CAAA,OAAO,CAAC,IAAI,IAAI,EAAE,CAAA,WAAvB,CAAuB;gBACnC,MAAM,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;AAzBY,QAAA,cAAc,kBAyB1B"}
\ No newline at end of file
/** @format */
export declare function MathRand(): string;
export declare const signFigures: (num: any, rank?: number) => number;
"use strict";
/** @format */
Object.defineProperty(exports, "__esModule", { value: true });
exports.signFigures = 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;
//小数相乘
var signFigures = function (num, rank) {
if (rank === void 0) { rank = 6; }
if (!num)
return 0;
var sign = num / Math.abs(num);
var number = num * sign;
var temp = rank - 1 - Math.floor(Math.log10(number));
var ans;
if (temp > 0) {
ans = parseFloat(number.toFixed(temp));
}
else if (temp < 0) {
ans = Math.round(number / Math.pow(10, temp)) * temp;
}
else {
ans = Math.round(number);
}
return ans * sign;
};
exports.signFigures = signFigures;
//# 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;AAED,MAAM;AACC,IAAM,WAAW,GAAG,UAAU,GAAG,EAAE,IAAQ;IAAR,qBAAA,EAAA,QAAQ;IAChD,IAAI,CAAC,GAAG;QAAE,OAAO,CAAC,CAAC;IACnB,IAAM,IAAI,GAAG,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACjC,IAAM,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC;IAC1B,IAAM,IAAI,GAAG,IAAI,GAAG,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;IACvD,IAAI,GAAG,CAAC;IACR,IAAI,IAAI,GAAG,CAAC,EAAE;QACZ,GAAG,GAAG,UAAU,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;KACxC;SAAM,IAAI,IAAI,GAAG,CAAC,EAAE;QACnB,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC;KACtD;SAAM;QACL,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;KAC1B;IACD,OAAO,GAAG,GAAG,IAAI,CAAC;AACpB,CAAC,CAAC;AAdW,QAAA,WAAW,eActB"}
\ No newline at end of file
/** @format */
export declare const exportHandlers: (controllers: 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);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.exportHandlers = void 0;
exports.exportHandlers = function (controllers) {
var handlersMapper = controllers
.map(function (controller) {
var controllerInstance = new controller();
var handlersKeys = Object.getOwnPropertyNames(Object.getPrototypeOf(controllerInstance)).filter(function (v) { return v !== 'constructor'; });
return handlersKeys.reduce(function (prev, current) {
var _a;
return __assign(__assign({}, prev), (_a = {}, _a[current] = controllerInstance[current], _a));
}, {});
})
.reduce(function (prev, current) {
return __assign(__assign({}, current), prev);
}, {});
return handlersMapper;
};
//# sourceMappingURL=exportHandlers.js.map
\ No newline at end of file
{"version":3,"file":"exportHandlers.js","sourceRoot":"","sources":["../../../src/utils/package/exportHandlers.ts"],"names":[],"mappings":";AAAA,cAAc;;;;;;;;;;;;;;AAED,QAAA,cAAc,GAAG,UAAC,WAAkB;IAC/C,IAAM,cAAc,GAAG,WAAW;SAC/B,GAAG,CAAC,UAAA,UAAU;QACb,IAAM,kBAAkB,GAAG,IAAI,UAAU,EAAE,CAAA;QAC3C,IAAM,YAAY,GAAG,MAAM,CAAC,mBAAmB,CAAC,MAAM,CAAC,cAAc,CAAC,kBAAkB,CAAC,CAAC,CAAC,MAAM,CAC/F,UAAA,CAAC,IAAI,OAAA,CAAC,KAAK,aAAa,EAAnB,CAAmB,CACzB,CAAA;QACD,OAAO,YAAY,CAAC,MAAM,CAAC,UAAC,IAAI,EAAE,OAAO;;YACvC,6BACK,IAAI,gBACN,OAAO,IAAG,kBAAkB,CAAC,OAAO,CAAC,OACvC;QACH,CAAC,EAAE,EAAE,CAAC,CAAA;IACR,CAAC,CAAC;SACD,MAAM,CAAC,UAAC,IAAI,EAAE,OAAO;QACpB,6BACK,OAAO,GACP,IAAI,EACR;IACH,CAAC,EAAE,EAAE,CAAC,CAAA;IACR,OAAO,cAAc,CAAA;AACvB,CAAC,CAAA"}
\ No newline at end of file
/**
* 获取商家session
*
* @format
*/
export declare const getSellerSession: (context: Context, activityId?: string) => Promise<{
session?: undefined;
} | {
session: any;
}>;
"use strict";
/**
* 获取商家session
*
* @format
*/
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 });
exports.getSellerSession = void 0;
var db_1 = require("../../db");
var sdk_1 = require("../../sdk");
exports.getSellerSession = function (context, activityId) { return __awaiter(void 0, void 0, void 0, function () {
var activitydao, sellerdao, activityConfigResult, result;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!activityId) {
activityId = context.data.activityId;
}
activitydao = new sdk_1.BaseDao(context, db_1.ACTIVITY_CONFIG_DB_NAME);
sellerdao = new sdk_1.BaseDao(context, db_1.SELLER_INFO_DB_NAME);
return [4 /*yield*/, activitydao.find({ _id: activityId })];
case 1:
activityConfigResult = _a.sent();
if (!activityConfigResult || !activityConfigResult[0])
return [2 /*return*/, {}];
return [4 /*yield*/, sellerdao.find({
openId: activityConfigResult[0].openId
})
// console.log(`getSellerSession`, result)
];
case 2:
result = _a.sent();
// console.log(`getSellerSession`, result)
if (!result || !result[0])
return [2 /*return*/, {}];
return [2 /*return*/, {
session: result[0].accessToken
}];
}
});
}); };
//# sourceMappingURL=getSession.js.map
\ No newline at end of file
{"version":3,"file":"getSession.js","sourceRoot":"","sources":["../../../src/utils/package/getSession.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,+BAAuE;AAEvE,iCAAmC;AAEtB,QAAA,gBAAgB,GAAG,UAAO,OAAgB,EAAE,UAAmB;;;;;gBAC1E,IAAI,CAAC,UAAU,EAAE;oBACf,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,UAAU,CAAA;iBACrC;gBACG,WAAW,GAAG,IAAI,aAAO,CAAC,OAAO,EAAE,4BAAuB,CAAC,CAAA;gBAC3D,SAAS,GAAG,IAAI,aAAO,CAAC,OAAO,EAAE,wBAAmB,CAAC,CAAA;gBAC9B,qBAAM,WAAW,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,UAAU,EAAE,CAAC,EAAA;;gBAAlE,oBAAoB,GAAG,SAA2C;gBACtE,IAAI,CAAC,oBAAoB,IAAI,CAAC,oBAAoB,CAAC,CAAC,CAAC;oBAAE,sBAAO,EAAE,EAAA;gBAEnD,qBAAM,SAAS,CAAC,IAAI,CAAC;wBAChC,MAAM,EAAE,oBAAoB,CAAC,CAAC,CAAC,CAAC,MAAM;qBACvC,CAAC;oBACF,2CAA2C;kBADzC;;gBAFE,MAAM,GAAG,SAEX;gBACF,2CAA2C;gBAC3C,IAAI,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;oBAAE,sBAAO,EAAE,EAAA;gBACpC,sBAAO;wBACL,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW;qBAC/B,EAAA;;;KACF,CAAA"}
\ No newline at end of file
/** @format */
export declare const getToday: () => string;
"use strict";
/** @format */
Object.defineProperty(exports, "__esModule", { value: true });
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');
};
//# sourceMappingURL=getToday.js.map
\ No newline at end of file
{"version":3,"file":"getToday.js","sourceRoot":"","sources":["../../../src/utils/package/getToday.ts"],"names":[],"mappings":";AAAA,cAAc;;;AAEd,iCAA+D;AAE/D,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"}
\ No newline at end of file
/**
* 用户购买记录查询
*
* @format
*/
export declare const getUserOrderlist: (context: any, queryStartTime: any, queryEndTime?: any, session?: string) => Promise<any[]>;
"use strict";
/**
* 用户购买记录查询
*
* @format
*/
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 });
exports.getUserOrderlist = void 0;
var dayjs = require("dayjs");
var sdk_1 = require("../../sdk");
var getSession_1 = require("./getSession");
var constants_1 = require("../../constants");
exports.getUserOrderlist = function (context, queryStartTime, queryEndTime, session) { return __awaiter(void 0, void 0, void 0, function () {
var results_1, currentTime, lastUpdateTime, params, orderResult, trade, e_1;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 4, , 5]);
results_1 = [];
currentTime = Date.now();
lastUpdateTime = dayjs().add(-3, 'month').valueOf();
console.log("lastUpdateTime", lastUpdateTime);
// 若倒推的3个月时间小于传入的查询开始时间, 则以查询开始时间作为最后更新时间
if (lastUpdateTime < queryStartTime) {
lastUpdateTime = queryStartTime;
}
if (!!session) return [3 /*break*/, 2];
return [4 /*yield*/, getSession_1.getSellerSession(context)];
case 1:
session = (_a.sent()).session;
_a.label = 2;
case 2:
params = {
startTime: sdk_1.dateFormatter(sdk_1.transformBeijingDate(lastUpdateTime)),
endTime: sdk_1.dateFormatter(sdk_1.transformBeijingDate(queryEndTime || currentTime)),
openId: context.openId,
session: session
};
return [4 /*yield*/, sdk_1.TBAPIS.getBuyerOrderList(context, params)];
case 3:
orderResult = _a.sent();
if (orderResult.total_results > 0) {
trade = orderResult.trades.trade;
trade.forEach(function (i) {
if (constants_1.TAOBAO_SUCCESS_ORDER_STATUS.includes(i.status)) {
i.orders.order.forEach(function (s) {
results_1.push({
payTime: i.pay_time,
itemId: s.num_iid,
time: i.created,
price: s.price,
orderId: s.oid,
img: s.pic_path,
title: s.title
});
});
}
});
}
console.log("\u5DF2\u652F\u4ED8\u7684\u8BA2\u5355\u5217\u8868", results_1);
return [2 /*return*/, results_1];
case 4:
e_1 = _a.sent();
console.log("\u9519\u8BEF", e_1);
return [2 /*return*/, []];
case 5: return [2 /*return*/];
}
});
}); };
//# sourceMappingURL=getUserOrderlist.js.map
\ No newline at end of file
{"version":3,"file":"getUserOrderlist.js","sourceRoot":"","sources":["../../../src/utils/package/getUserOrderlist.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6BAA8B;AAC9B,iCAAuE;AACvE,2CAA+C;AAC/C,6CAA6D;AAEhD,QAAA,gBAAgB,GAAG,UAAO,OAAO,EAAE,cAAc,EAAE,YAAa,EAAE,OAAgB;;;;;;gBAEvF,YAAU,EAAE,CAAA;gBACZ,WAAW,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;gBAExB,cAAc,GAAG,KAAK,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,OAAO,EAAE,CAAA;gBACvD,OAAO,CAAC,GAAG,CAAC,gBAAgB,EAAE,cAAc,CAAC,CAAA;gBAC7C,yCAAyC;gBACzC,IAAI,cAAc,GAAG,cAAc,EAAE;oBACnC,cAAc,GAAG,cAAc,CAAA;iBAChC;qBACG,CAAC,OAAO,EAAR,wBAAQ;gBACC,qBAAM,6BAAgB,CAAC,OAAO,CAAC,EAAA;;gBAA1C,OAAO,GAAG,CAAC,SAA+B,CAAC,CAAC,OAAO,CAAA;;;gBAGjD,MAAM,GAAG;oBACX,SAAS,EAAE,mBAAa,CAAC,0BAAoB,CAAC,cAAc,CAAC,CAAC;oBAC9D,OAAO,EAAE,mBAAa,CAAC,0BAAoB,CAAC,YAAY,IAAI,WAAW,CAAC,CAAC;oBACzE,MAAM,EAAE,OAAO,CAAC,MAAM;oBACtB,OAAO,SAAA;iBACR,CAAA;gBACiB,qBAAM,YAAM,CAAC,iBAAiB,CAAC,OAAO,EAAE,MAAM,CAAC,EAAA;;gBAA7D,WAAW,GAAG,SAA+C;gBACjE,IAAI,WAAW,CAAC,aAAa,GAAG,CAAC,EAAE;oBACzB,KAAK,GAAK,WAAW,CAAC,MAAM,MAAvB,CAAuB;oBACpC,KAAK,CAAC,OAAO,CAAC,UAAA,CAAC;wBACb,IAAI,uCAA2B,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE;4BAClD,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,UAAA,CAAC;gCACtB,SAAO,CAAC,IAAI,CAAC;oCACX,OAAO,EAAE,CAAC,CAAC,QAAQ;oCACnB,MAAM,EAAE,CAAC,CAAC,OAAO;oCACjB,IAAI,EAAE,CAAC,CAAC,OAAO;oCACf,KAAK,EAAE,CAAC,CAAC,KAAK;oCACd,OAAO,EAAE,CAAC,CAAC,GAAG;oCACd,GAAG,EAAE,CAAC,CAAC,QAAQ;oCACf,KAAK,EAAE,CAAC,CAAC,KAAK;iCACf,CAAC,CAAA;4BACJ,CAAC,CAAC,CAAA;yBACH;oBACH,CAAC,CAAC,CAAA;iBACH;gBACD,OAAO,CAAC,GAAG,CAAC,kDAAU,EAAE,SAAO,CAAC,CAAA;gBAChC,sBAAO,SAAO,EAAA;;;gBAEd,OAAO,CAAC,GAAG,CAAC,cAAI,EAAE,GAAC,CAAC,CAAA;gBACpB,sBAAO,EAAE,EAAA;;;;KAEZ,CAAA"}
\ No newline at end of file
/** @format */
/**
* 并发更新
* @param {接收数组或对象} daoqueryArr : [{dao: userdao, query:{id:_id}}, {dao: activityprizedao, query: {id:_id}}]
* @param {*} fn
* @param {*} times
*/
export declare const lockUpdate: (daoqueryArr: any, fn: any, times?: number) => Promise<any>;
/**
* 调用示例
*/
"use strict";
/** @format */
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 });
exports.lockUpdate = void 0;
var constants_1 = require("../../constants");
/**
* 并发更新
* @param {接收数组或对象} daoqueryArr : [{dao: userdao, query:{id:_id}}, {dao: activityprizedao, query: {id:_id}}]
* @param {*} fn
* @param {*} times
*/
exports.lockUpdate = function (daoqueryArr, fn, times) {
if (times === void 0) { times = 5; }
return __awaiter(void 0, void 0, void 0, function () {
function waitFor(ms) {
return new Promise(function (resolve) {
setTimeout(resolve, ms);
});
}
var time, success, _loop_1, state_1, e_1;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (typeof daoqueryArr !== 'object' && !Array.isArray(daoqueryArr)) {
console.log("lockUpdate \u53C2\u6570\u9519\u8BEF");
return [2 /*return*/, false];
}
if (typeof daoqueryArr === 'object') {
daoqueryArr = [daoqueryArr];
}
time = 0;
console.log("\u8FDB\u5165update\u5E76\u53D1\u5904\u7406\u6B21\u6570", times);
success = false;
_a.label = 1;
case 1:
_a.trys.push([1, 5, , 6]);
_loop_1 = function () {
var updateRes, ret;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
updateRes = [];
daoqueryArr.forEach(function (daoquery) { return __awaiter(void 0, void 0, void 0, function () {
var canupdate;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, daoquery.dao.update(daoquery.query, { $set: { lockStatus: 2 } })];
case 1:
canupdate = _a.sent();
updateRes.push(canupdate);
return [2 /*return*/];
}
});
}); });
if (!!daoqueryArr.includes(0)) return [3 /*break*/, 2];
return [4 /*yield*/, fn()];
case 1:
ret = _a.sent();
daoqueryArr.forEach(function (daoquery) { return __awaiter(void 0, void 0, void 0, function () {
var ures;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, daoquery.dao.update(daoquery.query, { $set: { lockStatus: 1 } })];
case 1:
ures = _a.sent();
console.log("\u66F4\u65B0lockStatus\u4E3A0", ures);
return [2 /*return*/];
}
});
}); });
success = true;
return [2 /*return*/, { value: ret }];
case 2:
console.log("\u8FDB\u5165waitFor\u4E86\uFF0C\u9700\u7B49\u5F8530ms");
return [4 /*yield*/, waitFor(30)];
case 3:
_a.sent();
success = false;
_a.label = 4;
case 4: return [2 /*return*/];
}
});
};
_a.label = 2;
case 2:
if (!(time++ < times && !success)) return [3 /*break*/, 4];
return [5 /*yield**/, _loop_1()];
case 3:
state_1 = _a.sent();
if (typeof state_1 === "object")
return [2 /*return*/, state_1.value];
return [3 /*break*/, 2];
case 4: return [3 /*break*/, 6];
case 5:
e_1 = _a.sent();
console.log(e_1);
daoqueryArr.forEach(function (daoquery) { return __awaiter(void 0, void 0, void 0, function () {
var ures;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, daoquery.dao.update(daoquery.query, { $set: { lockStatus: 1 } })];
case 1:
ures = _a.sent();
console.log("\u66F4\u65B0lockStatus\u4E3A0", ures);
return [2 /*return*/];
}
});
}); });
success = false;
return [3 /*break*/, 6];
case 6:
// 稍后重试
if (!success) {
daoqueryArr.forEach(function (daoquery) { return __awaiter(void 0, void 0, void 0, function () {
var ures;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, daoquery.dao.update(daoquery.query, { $set: { lockStatus: 1 } })];
case 1:
ures = _a.sent();
console.log("\u64CD\u4F5C" + times + "\u6B21\u540E\u66F4\u65B0lockStatus\u4E3A0", ures);
return [2 /*return*/];
}
});
}); });
return [2 /*return*/, constants_1.CODE_TYPES.ERROR_UPDATE_RETRY];
}
return [2 /*return*/];
}
});
});
};
/**
* 调用示例
*/
// 扣库存
// let res = await lockUpdate({dao: this.activityprizedao, query: {_id}}, async ()=> {
// return await this.activityprizedao.update({_id}, {$set: {
// useStock: useStock + 1,
// updateTime: Date.now()
// }});
// });
// console.log(res);
// if (!res) {
// return CODE_TYPES.ERROR_UPDATE_RETRY;
// }
// return true;
//# sourceMappingURL=lockUpdate.js.map
\ No newline at end of file
{"version":3,"file":"lockUpdate.js","sourceRoot":"","sources":["../../../src/utils/package/lockUpdate.ts"],"names":[],"mappings":";AAAA,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEd,6CAA4C;AAE5C;;;;;GAKG;AACU,QAAA,UAAU,GAAG,UAAO,WAAW,EAAE,EAAE,EAAE,KAAS;IAAT,sBAAA,EAA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sFAAsF;AACtF,8DAA8D;AAC9D,8BAA8B;AAC9B,6BAA6B;AAC7B,SAAS;AACT,MAAM;AACN,oBAAoB;AACpB,cAAc;AACd,0CAA0C;AAC1C,IAAI;AACJ,eAAe"}
\ No newline at end of file
export declare const logger: (context: Context) => void;
export declare const recordErrorLog: (context: Context, baseInfos: IControllerInfos, errorMsg: string, stack: string) => Promise<any>;
"use strict";
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 });
exports.recordErrorLog = exports.logger = void 0;
/** @format */
var sdk_1 = require("../../sdk");
var db_1 = require("../../db");
var utils_1 = require("../../utils");
exports.logger = function (context) {
var _a, _b, _c;
var data = JSON.stringify(context.data);
console.log(context);
console.log("---------\u51FD\u6570: " + (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) + "------------");
console.log("---------\u8BF7\u6C42\u53C2\u6570: " + data + "------------");
};
// 记录错误日志
exports.recordErrorLog = function (context, baseInfos, errorMsg, stack) { return __awaiter(void 0, void 0, void 0, function () {
var openId, activityId, userInfo, userNick, logdao, functionName;
var _a, _b, _c;
return __generator(this, function (_d) {
switch (_d.label) {
case 0:
openId = context.openId;
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({
openId: openId,
activityId: activityId,
errorMsg: errorMsg,
errorStack: stack,
functionName: functionName,
userNick: userNick,
fcInvokeId: context.fcInvokeId,
params: context.data,
createTime: Date.now(),
createDay: utils_1.getToday(),
catchType: 1
})];
case 1: return [2 /*return*/, _d.sent()];
}
});
}); };
//# sourceMappingURL=logger.js.map
\ No newline at end of file
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../../src/utils/package/logger.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,cAAc;AACd,iCAAmC;AACnC,+BAA4C;AAC5C,qCAAsC;AAEzB,QAAA,MAAM,GAAG,UAAC,OAAgB;;IACrC,IAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IACzC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;IACpB,OAAO,CAAC,GAAG,CACT,6BAAgB,OAAO,CAAC,MAAM,IAAI,EAAE,WAClC,mBAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,KAAK,0CAAE,SAAS,0CAAE,OAAO,0CAAE,OAAO,KAAI,OAAO,CAAC,OAAO,kBAClD,CACf,CAAA;IACD,OAAO,CAAC,GAAG,CAAC,wCAAkB,IAAI,iBAAc,CAAC,CAAA;AACnD,CAAC,CAAA;AAED,SAAS;AACI,QAAA,cAAc,GAAG,UAC5B,OAAgB,EAChB,SAA2B,EAC3B,QAAgB,EAChB,KAAa;;;;;;gBAEL,MAAM,GAAK,OAAO,OAAZ,CAAY;gBAClB,UAAU,GAAK,CAAA,OAAO,CAAC,IAAI,IAAI,EAAE,CAAA,WAAvB,CAAuB;gBACjC,QAAQ,GAAK,SAAS,SAAd,CAAc;gBACtB,QAAQ,GAAK,CAAA,QAAQ,IAAI,EAAE,CAAA,SAAnB,CAAmB;gBAC7B,MAAM,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 const rand: (number: any) => number;
export declare const signFigures: (num: any, rank?: number) => number;
"use strict";
/** @format */
Object.defineProperty(exports, "__esModule", { value: true });
exports.signFigures = exports.rand = void 0;
exports.rand = (function () {
var seed = new Date().getTime();
function r() {
seed = (seed * 9301 + 49297) % 233280;
return seed / 233280.0;
}
return function (number) {
return Math.ceil(r() * number);
};
})();
exports.signFigures = function (num, rank) {
if (rank === void 0) { rank = 6; }
if (!num)
return 0;
var sign = num / Math.abs(num);
var number = num * sign;
var temp = rank - 1 - Math.floor(Math.log10(number));
var ans;
if (temp > 0) {
ans = parseFloat(number.toFixed(temp));
}
else if (temp < 0) {
ans = Math.round(number / Math.pow(10, temp)) * temp;
}
else {
ans = Math.round(number);
}
return ans * sign;
};
//# sourceMappingURL=rand.js.map
\ No newline at end of file
{"version":3,"file":"rand.js","sourceRoot":"","sources":["../../../src/utils/package/rand.ts"],"names":[],"mappings":";AAAA,cAAc;;;AAED,QAAA,IAAI,GAAG,CAAC;IACnB,IAAI,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAA;IAC/B,SAAS,CAAC;QACR,IAAI,GAAG,CAAC,IAAI,GAAG,IAAI,GAAG,KAAK,CAAC,GAAG,MAAM,CAAA;QACrC,OAAO,IAAI,GAAG,QAAQ,CAAA;IACxB,CAAC;IACD,OAAO,UAAU,MAAM;QACrB,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE,GAAG,MAAM,CAAC,CAAA;IAChC,CAAC,CAAA;AACH,CAAC,CAAC,EAAE,CAAA;AAES,QAAA,WAAW,GAAG,UAAU,GAAG,EAAE,IAAQ;IAAR,qBAAA,EAAA,QAAQ;IAChD,IAAI,CAAC,GAAG;QAAE,OAAO,CAAC,CAAA;IAClB,IAAM,IAAI,GAAG,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;IAChC,IAAM,MAAM,GAAG,GAAG,GAAG,IAAI,CAAA;IACzB,IAAM,IAAI,GAAG,IAAI,GAAG,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAA;IACtD,IAAI,GAAG,CAAA;IACP,IAAI,IAAI,GAAG,CAAC,EAAE;QACZ,GAAG,GAAG,UAAU,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAA;KACvC;SAAM,IAAI,IAAI,GAAG,CAAC,EAAE;QACnB,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC,GAAG,IAAI,CAAA;KACrD;SAAM;QACL,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;KACzB;IACD,OAAO,GAAG,GAAG,IAAI,CAAA;AACnB,CAAC,CAAA"}
\ No newline at end of file
/** @format */
/**
* 发奖,包含权益,实物,积分
* @param {*} document 必须要有{ type, ename, _id }
* @param {*} session
* @param {*} context
*/
export declare const sendTBAward: (context: any, session: any, document: any) => Promise<any>;
/**
* 发放积分
* @param {发放的积分数} credits
* @param {*} session
* @param {*} context
* @returns {drawStatus, remark}
*/
export declare const sendCredits: (credits: any, session: any, context: any) => Promise<{
drawStatus: number;
remark: string;
}>;
/**
* @desc 发放权益
* @param {权益名称} ename
* @param {唯一key} uniqueId
* @param {*} session
* @param {*} context
* @returns { drawStatus, remark }
*/
export declare const sendEname: (ename: any, uniqueId: any, session: any, context: any) => Promise<{
remark: string;
drawStatus: number;
}>;
"use strict";
/** @format */
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 });
exports.sendEname = exports.sendCredits = exports.sendTBAward = void 0;
var constants_1 = require("../../constants");
var sdk_1 = require("../../sdk");
/**
* 发奖,包含权益,实物,积分
* @param {*} document 必须要有{ type, ename, _id }
* @param {*} session
* @param {*} context
*/
exports.sendTBAward = function (context, session, document) { return __awaiter(void 0, void 0, void 0, function () {
var type, ename, _id, credits, _a, drawStatus, remark, _b, drawStatus, remark, e_1;
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
type = document.type, ename = document.ename, _id = document._id, credits = document.credits;
if (!type) {
return [2 /*return*/, constants_1.CODE_TYPES.PARAMS_ERROR];
}
if (type === constants_1.PRIZE_TYPE.OBJECT) {
return [2 /*return*/, document];
}
_c.label = 1;
case 1:
_c.trys.push([1, 6, , 7]);
console.log("type", type);
if (!(type === constants_1.PRIZE_TYPE.ENAME)) return [3 /*break*/, 3];
console.log("\u4E2D\u6743\u76CA");
return [4 /*yield*/, exports.sendEname(ename, _id, session, context)];
case 2:
_a = _c.sent(), drawStatus = _a.drawStatus, remark = _a.remark;
console.log("drawStatus, remark", drawStatus, remark);
document.drawStatus = drawStatus;
document.remark = remark;
return [3 /*break*/, 5];
case 3:
if (!(type === constants_1.PRIZE_TYPE.CREDITS)) return [3 /*break*/, 5];
return [4 /*yield*/, exports.sendCredits(credits, session, context)];
case 4:
_b = _c.sent(), drawStatus = _b.drawStatus, remark = _b.remark;
document.drawStatus = drawStatus;
document.remark = remark;
_c.label = 5;
case 5: return [2 /*return*/, document];
case 6:
e_1 = _c.sent();
console.log("\u53D1\u5956\u9519\u8BEF", e_1);
return [2 /*return*/, constants_1.CODE_TYPES.SYSTEM_ERROR];
case 7: return [2 /*return*/];
}
});
}); };
/**
* 发放积分
* @param {发放的积分数} credits
* @param {*} session
* @param {*} context
* @returns {drawStatus, remark}
*/
exports.sendCredits = function (credits, session, context) { return __awaiter(void 0, void 0, void 0, function () {
var drawStatus, remark, result;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
drawStatus = 0;
remark = '';
return [4 /*yield*/, sdk_1.TBAPIS.changeCredits(context, session, {
quantity: credits,
change_type: 2,
opt_type: '0',
remark: "\u53C2\u4E0E\u6D3B\u52A8\u52A0\u79EF\u5206"
})];
case 1:
result = _a.sent();
if (result) {
drawStatus = constants_1.DRAW_STATUS.SUCCESS;
}
else {
drawStatus = constants_1.DRAW_STATUS.FAIL;
remark = result.result_msg;
}
return [2 /*return*/, { drawStatus: drawStatus, remark: remark }];
}
});
}); };
/**
* @desc 发放权益
* @param {权益名称} ename
* @param {唯一key} uniqueId
* @param {*} session
* @param {*} context
* @returns { drawStatus, remark }
*/
exports.sendEname = function (ename, uniqueId, session, context) { return __awaiter(void 0, void 0, void 0, function () {
var result, e_2, drawStatus, remark, result_code;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
result = {
result_success: '',
result_code: '',
msg: '',
result_msg: '',
sub_msg: ''
};
_a.label = 1;
case 1:
_a.trys.push([1, 3, , 4]);
return [4 /*yield*/, sdk_1.TBAPIS.benefitSend(context, {
right_ename: ename,
receiver_id: context.openId,
unique_id: uniqueId,
app_name: constants_1.C_APP_NAME,
session: session
})];
case 2:
result = _a.sent();
return [3 /*break*/, 4];
case 3:
e_2 = _a.sent();
console.log("\u53D1\u653E\u6743\u76CA\u5931\u8D25", e_2);
result = e_2;
return [3 /*break*/, 4];
case 4:
drawStatus = 0;
remark = '';
if (result.result_success) {
drawStatus = constants_1.DRAW_STATUS.SUCCESS;
}
else {
result_code = result.result_code;
if ([
'APPLY_SINGLE_COUPON_COUNT_EXCEED_LIMIT',
'APPLY_ONE_SELLER_COUNT_EXCEED_LIMIT',
'USER_PERMISSION_EXCEED_MAX_RIGHT_COUNT_IN_DAY'
].includes(result_code)) {
drawStatus = constants_1.DRAW_STATUS.RETRY;
}
else {
drawStatus = constants_1.DRAW_STATUS.FAIL;
}
remark = constants_1.TBERROR[result_code || result.msg] || result.result_msg || result.sub_msg || "\u53D1\u653E\u5931\u8D25";
}
return [2 /*return*/, { remark: remark, drawStatus: drawStatus }];
}
});
}); };
//# sourceMappingURL=sendTBAward.js.map
\ No newline at end of file
{"version":3,"file":"sendTBAward.js","sourceRoot":"","sources":["../../../src/utils/package/sendTBAward.ts"],"names":[],"mappings":";AAAA,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEd,6CAA0F;AAC1F,iCAAkC;AAElC;;;;;GAKG;AACU,QAAA,WAAW,GAAG,UAAO,OAAO,EAAE,OAAO,EAAE,QAAQ;;;;;gBACpD,IAAI,GAA0B,QAAQ,KAAlC,EAAE,KAAK,GAAmB,QAAQ,MAA3B,EAAE,GAAG,GAAc,QAAQ,IAAtB,EAAE,OAAO,GAAK,QAAQ,QAAb,CAAa;gBAC5C,IAAI,CAAC,IAAI,EAAE;oBACT,sBAAO,sBAAU,CAAC,YAAY,EAAA;iBAC/B;gBACD,IAAI,IAAI,KAAK,sBAAU,CAAC,MAAM,EAAE;oBAC9B,sBAAO,QAAQ,EAAA;iBAChB;;;;gBAGC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;qBAErB,CAAA,IAAI,KAAK,sBAAU,CAAC,KAAK,CAAA,EAAzB,wBAAyB;gBAC3B,OAAO,CAAC,GAAG,CAAC,oBAAK,CAAC,CAAA;gBACW,qBAAM,iBAAS,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC,EAAA;;gBAAtE,KAAyB,SAA6C,EAApE,UAAU,gBAAA,EAAE,MAAM,YAAA;gBACxB,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,UAAU,EAAE,MAAM,CAAC,CAAA;gBACrD,QAAQ,CAAC,UAAU,GAAG,UAAU,CAAA;gBAChC,QAAQ,CAAC,MAAM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f,GAAG,EAAE,EAAE;oBACP,UAAU,EAAE,EAAE;oBACd,OAAO,EAAE,EAAE;iBACZ,CAAA;;;;gBAEU,qBAAM,YAAM,CAAC,WAAW,CAAC,OAAO,EAAE;wBACzC,WAAW,EAAE,KAAK;wBAClB,WAAW,EAAE,OAAO,CAAC,MAAM;wBAC3B,SAAS,EAAE,QAAQ;wBACnB,QAAQ,EAAE,sBAAU;wBACpB,OAAO,SAAA;qBACR,CAAC,EAAA;;gBANF,MAAM,GAAG,SAMP,CAAA;;;;gBAEF,OAAO,CAAC,GAAG,CAAC,sCAAQ,EAAE,GAAC,CAAC,CAAA;gBACxB,MAAM,GAAG,GAAC,CAAA;;;gBAGR,UAAU,GAAG,CAAC,CAAA;gBACd,MAAM,GAAG,EAAE,CAAA;gBACf,IAAI,MAAM,CAAC,cAAc,EAAE;oBACzB,UAAU,GAAG,uBAAW,CAAC,OAAO,CAAA;iBACjC;qBAAM;oBACD,WAAW,GAAG,MAAM,CAAC,WAAW,CAAA;oBACpC,IACE;wBACE,wCAAwC;wBACxC,qCAAqC;wBACrC,+CAA+C;qBAChD,CAAC,QAAQ,CAAC,WAAW,CAAC,EACvB;wBACA,UAAU,GAAG,uBAAW,CAAC,KAAK,CAAA;qBAC/B;yBAAM;wBACL,UAAU,GAAG,uBAAW,CAAC,IAAI,CAAA;qBAC9B;oBACD,MAAM,GAAG,mBAAO,CAAC,WAAW,IAAI,MAAM,CAAC,GAAG,CAAC,IAAI,MAAM,CAAC,UAAU,IAAI,MAAM,CAAC,OAAO,IAAI,0BAAM,CAAA;iBAC7F;gBACD,sBAAO,EAAE,MAAM,QAAA,EAAE,UAAU,YAAA,EAAE,EAAA;;;KAC9B,CAAA"}
\ No newline at end of file
/** @format */
import { Rules } from 'async-validator';
export declare const saveParams: Rules;
"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);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.saveParams = void 0;
var constants_1 = require("../constants");
exports.saveParams = {
title: {
required: true,
type: 'string',
validator: function (rule, value, cb, source) {
value = value.trim();
if (!value)
return new Error('活动名称为空');
if (value.length > 12)
return new Error('活动名称不可超过12个字');
return cb();
}
},
rule: {
required: true,
message: '活动规则不可为空'
},
startTime: {
required: true,
validator: function (rule, value, cb, source) {
var endTime = source.endTime, activityId = source.activityId;
if (!value)
return new Error('请配置活动开始时间');
if (value > endTime)
return new Error('开始时间不得大于结束时间');
if (!activityId && value < Date.now())
return new Error('新建活动开始时间需小于当前时间');
return cb();
}
},
endTime: {
required: true,
validator: function (rule, value, cb, source) {
if (!value)
return new Error('请配置活动结束时间');
return cb();
}
},
tasks: {
required: true,
validator: function (rule, tasks, cb, source) {
var taskList = Object.keys(tasks).map(function (type) {
return __assign(__assign({}, tasks[type]), { type: type });
});
if (taskList.length === 0)
return new Error('任务配置必须配置一项');
var canPassTask = { status: true, message: '' };
taskList.forEach(function (i) {
if (!i.type) {
canPassTask = {
status: false,
message: '任务必须配置'
};
}
if (constants_1.TASK_CHECK_TYPE.link.list.includes(i.type)) {
if (canPassTask.status) {
canPassTask = urlCheck(i.link, constants_1.PASS_URL_LIST);
}
}
if (constants_1.TASK_CHECK_TYPE.itemIds.list.includes(i.type)) {
if (!i.itemIds) {
canPassTask = {
status: false,
message: constants_1.TASK_TYPE_TEXT[i.type] + '必须配置'
};
}
}
if (constants_1.TASK_CHECK_TYPE.value.list.includes(i.type)) {
if (!i.value) {
canPassTask = {
status: false,
message: constants_1.TASK_TYPE_TEXT[i.type] + '任务值必须配置'
};
}
if (!constants_1.TASK_CHECK_TYPE.value.reg.test(i.value)) {
canPassTask = {
status: false,
message: constants_1.TASK_TYPE_TEXT[i.type] + '任务值在' + constants_1.TASK_CHECK_TYPE.value.regName
};
}
}
if (constants_1.TASK_CHECK_TYPE.times.list.includes(i.type)) {
if (!i.times) {
canPassTask = {
status: false,
message: constants_1.TASK_TYPE_TEXT[i.type] + '任务次数必须配置'
};
}
}
if (constants_1.TASK_CHECK_TYPE.title.list.includes(i.type)) {
if (!i.title) {
canPassTask = {
status: false,
message: constants_1.TASK_TYPE_TEXT[i.type] + '任务标题必须配置'
};
}
}
if (constants_1.TASK_CHECK_TYPE.taskRateType.list.includes(i.type)) {
if (!i.taskRateType) {
canPassTask = {
status: false,
message: constants_1.TASK_TYPE_TEXT[i.type] + '任务类型必须配置'
};
}
}
i.value = +i.value;
i.times = +i.times || '';
i.taskRateType = +i.taskRateType || '';
return i;
});
if (!canPassTask.status)
return new Error(canPassTask.message);
return cb();
}
}
};
var urlCheck = function (link, passUrlList) {
if (!link.startsWith('http://') && !link.startsWith('https://')) {
return { status: false, message: '页面链接必须以https://或http://开头' };
}
var passUrl = false;
passUrlList.some(function (i) {
if (~link.indexOf(i)) {
passUrl = true;
return true;
}
return false;
});
if (!passUrl)
return {
status: false,
message: '域名校验不通过'
};
return {
status: true,
message: ''
};
};
//# 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;;;;;;;;;;;;;;AAGd,0CAA6E;AAEhE,QAAA,UAAU,GAAU;IAC/B,KAAK,EAAE;QACL,QAAQ,EAAE,IAAI;QACd,IAAI,EAAE,QAAQ;QACd,SAAS,YAAC,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM;YAC/B,KAAK,GAAG,KAAK,CAAC,IAAI,EAAE,CAAA;YACpB,IAAI,CAAC,KAAK;gBAAE,OAAO,IAAI,KAAK,CAAC,QAAQ,CAAC,CAAA;YACtC,IAAI,KAAK,CAAC,MAAM,GAAG,EAAE;gBAAE,OAAO,IAAI,KAAK,CAAC,cAAc,CAAC,CAAA;YACvD,OAAO,EAAE,EAAE,CAAA;QACb,CAAC;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AAM,QAAQ,GAAG,UAAC,IAAY,EAAE,WAAqB;IACnD,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE;QAC/D,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,2BAA2B,EAAE,CAAA;KAC/D;IACD,IAAI,OAAO,GAAG,KAAK,CAAA;IACnB,WAAW,CAAC,IAAI,CAAC,UAAA,CAAC;QAChB,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;YACpB,OAAO,GAAG,IAAI,CAAA;YACd,OAAO,IAAI,CAAA;SACZ;QACD,OAAO,KAAK,CAAA;IACd,CAAC,CAAC,CAAA;IACF,IAAI,CAAC,OAAO;QACV,OAAO;YACL,MAAM,EAAE,KAAK;YACb,OAAO,EAAE,SAAS;SACnB,CAAA;IACH,OAAO;QACL,MAAM,EAAE,IAAI;QACZ,OAAO,EAAE,EAAE;KACZ,CAAA;AACH,CAAC,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");
// 获取今天的时间
var getToday = function () {
console.log(sdk_1.transformBeijingDate(Date.now()));
return sdk_1.dateFormatter(sdk_1.transformBeijingDate(Date.now()), 'yyyy/MM/dd');
};
exports.getToday = getToday;
/**
* 传入时间戳(毫秒)
* 根据时间戳转换成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;
var 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;
};
exports.formatTime = formatTime;
//# 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;AACH,IAAM,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;AAHY,QAAA,QAAQ,YAGpB;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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AAC,EAAE,EAAE,MAAM,CAAC,EAAE,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAA;IACzG,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA;AAfY,QAAA,UAAU,cAetB"}
\ No newline at end of file
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