@eventista/ticketing-common 1.3.36-dev.1 → 1.3.38-dev.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/constants/index.d.ts +2 -0
- package/dist/constants/index.js +19 -0
- package/dist/constants/index.js.map +1 -0
- package/dist/constants/order-amount.d.ts +19 -0
- package/dist/constants/order-amount.js +82 -0
- package/dist/constants/order-amount.js.map +1 -0
- package/dist/database/redis/benefit-stock.d.ts +41 -0
- package/dist/database/redis/benefit-stock.js +112 -0
- package/dist/database/redis/benefit-stock.js.map +1 -0
- package/dist/database/redis/index.d.ts +1 -0
- package/dist/database/redis/index.js +1 -0
- package/dist/database/redis/index.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/schemas/benefit/benefit.schema.d.ts +28 -0
- package/dist/schemas/benefit/benefit.schema.js +84 -0
- package/dist/schemas/benefit/benefit.schema.js.map +1 -0
- package/dist/schemas/event/event.interfaces.d.ts +4 -67
- package/dist/schemas/event/event.interfaces.js +1 -28
- package/dist/schemas/event/event.interfaces.js.map +1 -1
- package/dist/schemas/event/event.schema.d.ts +5 -40
- package/dist/schemas/event/event.schema.js +1 -152
- package/dist/schemas/event/event.schema.js.map +1 -1
- package/dist/schemas/index.d.ts +1 -0
- package/dist/schemas/index.js +1 -0
- package/dist/schemas/index.js.map +1 -1
- package/dist/schemas/order/order.interfaces.d.ts +22 -11
- package/dist/schemas/order/order.interfaces.js +3 -1
- package/dist/schemas/order/order.interfaces.js.map +1 -1
- package/dist/schemas/order/order.schema.d.ts +12 -1
- package/dist/schemas/order/order.schema.js +53 -0
- package/dist/schemas/order/order.schema.js.map +1 -1
- package/dist/schemas/promotions/promotions.interfaces.d.ts +0 -17
- package/dist/schemas/promotions/promotions.interfaces.js +1 -6
- package/dist/schemas/promotions/promotions.interfaces.js.map +1 -1
- package/dist/schemas/promotions/promotions.schema.d.ts +1 -12
- package/dist/schemas/promotions/promotions.schema.js +0 -49
- package/dist/schemas/promotions/promotions.schema.js.map +1 -1
- package/dist/schemas/schema.module.d.ts +181 -0
- package/dist/schemas/schema.module.js +6 -4
- package/dist/schemas/schema.module.js.map +1 -1
- package/dist/schemas/ticket-classes/ticket-classes.interfaces.d.ts +0 -15
- package/dist/schemas/ticket-classes/ticket-classes.interfaces.js +1 -13
- package/dist/schemas/ticket-classes/ticket-classes.interfaces.js.map +1 -1
- package/dist/schemas/ticket-classes/ticket-classes.schemas.d.ts +1 -6
- package/dist/schemas/ticket-classes/ticket-classes.schemas.js +0 -27
- package/dist/schemas/ticket-classes/ticket-classes.schemas.js.map +1 -1
- package/dist/schemas/tickets/tickets.interfaces.d.ts +10 -0
- package/dist/schemas/tickets/tickets.interfaces.js +3 -1
- package/dist/schemas/tickets/tickets.interfaces.js.map +1 -1
- package/dist/schemas/tickets/tickets.schema.d.ts +4 -0
- package/dist/schemas/tickets/tickets.schema.js +17 -0
- package/dist/schemas/tickets/tickets.schema.js.map +1 -1
- package/dist/schemas/zones/zone.interfaces.d.ts +0 -19
- package/dist/schemas/zones/zone.interfaces.js +0 -11
- package/dist/schemas/zones/zone.interfaces.js.map +1 -1
- package/dist/schemas/zones/zone.schema.d.ts +0 -4
- package/dist/schemas/zones/zone.schema.js +0 -23
- package/dist/schemas/zones/zone.schema.js.map +1 -1
- package/dist/services/benefit-release.d.ts +46 -0
- package/dist/services/benefit-release.js +148 -0
- package/dist/services/benefit-release.js.map +1 -0
- package/dist/services/index.d.ts +1 -0
- package/dist/services/index.js +18 -0
- package/dist/services/index.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -1
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./payment-fee"), exports);
|
|
18
|
+
__exportStar(require("./order-amount"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/constants/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,iDAA+B"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { IBenefitSelection, IBenefitSnapshot, IPromotionUsed } from '../schemas/order/order.interfaces';
|
|
2
|
+
export interface OrderLine {
|
|
3
|
+
ticketClassId: string;
|
|
4
|
+
quantity: number;
|
|
5
|
+
finalPriceVn: number;
|
|
6
|
+
finalPriceUsd: number;
|
|
7
|
+
}
|
|
8
|
+
export interface OrderAmount {
|
|
9
|
+
originalAmount: number;
|
|
10
|
+
originalAmountInUSD: number;
|
|
11
|
+
amount: number;
|
|
12
|
+
amountInUSD: number;
|
|
13
|
+
benefitAmount: number;
|
|
14
|
+
benefitAmountInUSD: number;
|
|
15
|
+
discountAmount: number;
|
|
16
|
+
discountAmountInUSD: number;
|
|
17
|
+
}
|
|
18
|
+
export declare function buildBenefitLines(tickets: OrderLine[], selections: IBenefitSelection[], snapshots: IBenefitSnapshot[]): OrderLine[];
|
|
19
|
+
export declare function computeOrderAmount(tickets: OrderLine[], selections: IBenefitSelection[], snapshots: IBenefitSnapshot[], promotion?: IPromotionUsed | null): OrderAmount;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildBenefitLines = buildBenefitLines;
|
|
4
|
+
exports.computeOrderAmount = computeOrderAmount;
|
|
5
|
+
const round2 = (n) => Math.round(n * 100) / 100;
|
|
6
|
+
function buildBenefitLines(tickets, selections, snapshots) {
|
|
7
|
+
const ticketClassId = tickets[0]?.ticketClassId ?? '';
|
|
8
|
+
const counts = {};
|
|
9
|
+
for (const selection of selections) {
|
|
10
|
+
for (const benefitId of selection.benefitIds || [])
|
|
11
|
+
counts[benefitId] = (counts[benefitId] || 0) + 1;
|
|
12
|
+
}
|
|
13
|
+
return Object.entries(counts).map(([benefitId, quantity]) => {
|
|
14
|
+
const snapshot = snapshots.find((s) => s.benefitId === benefitId);
|
|
15
|
+
if (!snapshot)
|
|
16
|
+
throw new Error(`BENEFIT_SNAPSHOT_MISSING:${benefitId}`);
|
|
17
|
+
return { ticketClassId, quantity, finalPriceVn: snapshot.finalPriceVn, finalPriceUsd: snapshot.finalPriceUsd };
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
function hasPromotion(promotion) {
|
|
21
|
+
return !!promotion && !!promotion.code;
|
|
22
|
+
}
|
|
23
|
+
function promotionApplies(promotion, ticketClassId) {
|
|
24
|
+
if (promotion.appliesTo !== 'ticket')
|
|
25
|
+
return true;
|
|
26
|
+
return (promotion.tickets ?? []).some((id) => String(id) === ticketClassId);
|
|
27
|
+
}
|
|
28
|
+
function unitDiscount(price, percent, maxValue) {
|
|
29
|
+
let discount = price * ((percent || 0) / 100);
|
|
30
|
+
if (maxValue && discount > maxValue)
|
|
31
|
+
discount = maxValue;
|
|
32
|
+
return discount;
|
|
33
|
+
}
|
|
34
|
+
function computeOrderAmount(tickets, selections, snapshots, promotion) {
|
|
35
|
+
const lines = [
|
|
36
|
+
...tickets.map((t) => ({ ...t, isBenefit: false })),
|
|
37
|
+
...buildBenefitLines(tickets, selections, snapshots).map((b) => ({ ...b, isBenefit: true })),
|
|
38
|
+
];
|
|
39
|
+
const promo = hasPromotion(promotion) ? promotion : null;
|
|
40
|
+
let originalVn = 0, originalUsd = 0, amountVn = 0, amountUsd = 0;
|
|
41
|
+
let discountVn = 0, discountUsd = 0, benefitVn = 0, benefitUsd = 0;
|
|
42
|
+
for (const line of lines) {
|
|
43
|
+
originalVn += round2(line.finalPriceVn * line.quantity);
|
|
44
|
+
originalUsd += line.finalPriceUsd * line.quantity;
|
|
45
|
+
const applies = !!promo && !line.isBenefit && promotionApplies(promo, line.ticketClassId);
|
|
46
|
+
const unitVn = applies ? unitDiscount(line.finalPriceVn, promo.discountPercent, promo.maxValue) : 0;
|
|
47
|
+
const unitUsd = applies ? unitDiscount(line.finalPriceUsd, promo.discountPercentInUSD, promo.maxValueInUSD) : 0;
|
|
48
|
+
const lineVn = round2((line.finalPriceVn - unitVn) * line.quantity);
|
|
49
|
+
const lineUsd = (line.finalPriceUsd - unitUsd) * line.quantity;
|
|
50
|
+
amountVn += lineVn;
|
|
51
|
+
amountUsd += lineUsd;
|
|
52
|
+
discountVn += unitVn * line.quantity;
|
|
53
|
+
discountUsd += unitUsd * line.quantity;
|
|
54
|
+
if (line.isBenefit) {
|
|
55
|
+
benefitVn += lineVn;
|
|
56
|
+
benefitUsd += lineUsd;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
const originalAmount = Math.round(originalVn);
|
|
60
|
+
const originalAmountInUSD = round2(originalUsd);
|
|
61
|
+
const discountAmount = Math.round(discountVn);
|
|
62
|
+
const discountAmountInUSD = round2(discountUsd);
|
|
63
|
+
let amount = Math.round(amountVn);
|
|
64
|
+
let amountInUSD = round2(amountUsd);
|
|
65
|
+
if (promo && promo.maxValuePerOrder && discountAmount > promo.maxValuePerOrder) {
|
|
66
|
+
amount = originalAmount - promo.maxValuePerOrder;
|
|
67
|
+
}
|
|
68
|
+
if (promo && promo.maxValuePerOrderInUSD && discountAmountInUSD > promo.maxValuePerOrderInUSD) {
|
|
69
|
+
amountInUSD = originalAmountInUSD - promo.maxValuePerOrderInUSD;
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
originalAmount,
|
|
73
|
+
originalAmountInUSD,
|
|
74
|
+
amount,
|
|
75
|
+
amountInUSD,
|
|
76
|
+
benefitAmount: Math.round(benefitVn),
|
|
77
|
+
benefitAmountInUSD: round2(benefitUsd),
|
|
78
|
+
discountAmount,
|
|
79
|
+
discountAmountInUSD,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=order-amount.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"order-amount.js","sourceRoot":"","sources":["../../src/constants/order-amount.ts"],"names":[],"mappings":";;AA2BA,8CAWC;AAkBD,gDA0DC;AAzFD,MAAM,MAAM,GAAG,CAAC,CAAS,EAAU,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC;AAEhE,SAAgB,iBAAiB,CAAC,OAAoB,EAAE,UAA+B,EAAE,SAA6B;IACpH,MAAM,aAAa,GAAG,OAAO,CAAC,CAAC,CAAC,EAAE,aAAa,IAAI,EAAE,CAAC;IACtD,MAAM,MAAM,GAA2B,EAAE,CAAC;IAC1C,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACnC,KAAK,MAAM,SAAS,IAAI,SAAS,CAAC,UAAU,IAAI,EAAE;YAAE,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;IACvG,CAAC;IACD,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,EAAE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ACL,cAAc;QACd,mBAAmB;QACnB,MAAM;QACN,WAAW;QACX,aAAa,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC;QACpC,kBAAkB,EAAE,MAAM,CAAC,UAAU,CAAC;QACtC,cAAc;QACd,mBAAmB;KACpB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { IBenefitSelection } from '../../schemas/order/order.interfaces';
|
|
2
|
+
export declare const BENEFIT_LIST_CACHE_TTL_SECONDS = 3600;
|
|
3
|
+
export declare const BENEFIT_REMAINING_CACHE_TTL_SECONDS = 10;
|
|
4
|
+
export declare const BENEFIT_APPLY_MARKER_TTL_SECONDS = 86400;
|
|
5
|
+
export declare const BENEFIT_RELEASE_MARKER_TTL_SECONDS: number;
|
|
6
|
+
export type BenefitOp = 'apply' | 'undo' | 'release';
|
|
7
|
+
export declare function benefitStockKey(eventId: string, ticketClassId: string, benefitId: string): string;
|
|
8
|
+
export declare function benefitOpKey(ticketClassId: string, op: BenefitOp, id: string): string;
|
|
9
|
+
export declare function benefitNoopKey(ticketClassId: string): string;
|
|
10
|
+
export declare function benefitListCacheKey(ticketClassId: string): string;
|
|
11
|
+
export declare function benefitRemainingCacheKey(ticketClassId: string): string;
|
|
12
|
+
export declare const BENEFIT_MOVE_SCRIPT = "\nif redis.call('EXISTS', KEYS[1]) == 1 then\n return cjson.encode({ success = true, replay = true })\nend\nlocal short = {}\nfor i = 3, #KEYS do\n local d = tonumber(ARGV[i - 2])\n if d > 0 then\n local a = tonumber(redis.call('GET', KEYS[i] .. ':available') or '0')\n if a < d then table.insert(short, { key = KEYS[i], available = a, need = d }) end\n elseif d < 0 then\n local h = tonumber(redis.call('GET', KEYS[i] .. ':hold') or '0')\n if h < -d then table.insert(short, { key = KEYS[i], hold = h, need = -d }) end\n end\nend\nif #short > 0 then\n return cjson.encode({ success = false, short = short })\nend\nfor i = 3, #KEYS do\n local d = tonumber(ARGV[i - 2])\n redis.call('DECRBY', KEYS[i] .. ':available', d)\n redis.call('INCRBY', KEYS[i] .. ':hold', d)\nend\nredis.call('SET', KEYS[1], '1', 'EX', tonumber(ARGV[#ARGV]))\nif KEYS[2] ~= '' then redis.call('DEL', KEYS[2]) end\nreturn cjson.encode({ success = true, replay = false })\n";
|
|
13
|
+
export declare const BENEFIT_ADJUST_SCRIPT = "\nlocal a = tonumber(redis.call('GET', KEYS[1] .. ':available') or '0')\nlocal d = tonumber(ARGV[1])\nif a + d < 0 then return 0 end\nredis.call('INCRBY', KEYS[1] .. ':available', d)\nreturn 1\n";
|
|
14
|
+
export declare const BENEFIT_RESEED_SCRIPT = "\nredis.call('SET', KEYS[1] .. ':hold', ARGV[2])\nredis.call('SET', KEYS[1] .. ':available', tonumber(ARGV[1]) - tonumber(ARGV[2]))\nreturn 1\n";
|
|
15
|
+
export interface BenefitMoveInput {
|
|
16
|
+
eventId: string;
|
|
17
|
+
ticketClassId: string;
|
|
18
|
+
marker: string;
|
|
19
|
+
deleteMarker?: string;
|
|
20
|
+
deltas: Record<string, number>;
|
|
21
|
+
ttlSeconds: number;
|
|
22
|
+
}
|
|
23
|
+
export interface BenefitMoveCommand {
|
|
24
|
+
keys: string[];
|
|
25
|
+
args: string[];
|
|
26
|
+
}
|
|
27
|
+
export declare function buildBenefitMoveCommand(input: BenefitMoveInput): BenefitMoveCommand;
|
|
28
|
+
export type BenefitMoveOutcome = 'ok' | 'refused' | 'ambiguous';
|
|
29
|
+
export interface BenefitMoveShort {
|
|
30
|
+
key: string;
|
|
31
|
+
need: number;
|
|
32
|
+
available?: number;
|
|
33
|
+
hold?: number;
|
|
34
|
+
}
|
|
35
|
+
export interface BenefitMoveResult {
|
|
36
|
+
outcome: BenefitMoveOutcome;
|
|
37
|
+
replay: boolean;
|
|
38
|
+
short: BenefitMoveShort[];
|
|
39
|
+
}
|
|
40
|
+
export declare function classifyBenefitMove(result: unknown): BenefitMoveResult;
|
|
41
|
+
export declare function countBenefitSelections(selections: IBenefitSelection[]): Record<string, number>;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BENEFIT_RESEED_SCRIPT = exports.BENEFIT_ADJUST_SCRIPT = exports.BENEFIT_MOVE_SCRIPT = exports.BENEFIT_RELEASE_MARKER_TTL_SECONDS = exports.BENEFIT_APPLY_MARKER_TTL_SECONDS = exports.BENEFIT_REMAINING_CACHE_TTL_SECONDS = exports.BENEFIT_LIST_CACHE_TTL_SECONDS = void 0;
|
|
4
|
+
exports.benefitStockKey = benefitStockKey;
|
|
5
|
+
exports.benefitOpKey = benefitOpKey;
|
|
6
|
+
exports.benefitNoopKey = benefitNoopKey;
|
|
7
|
+
exports.benefitListCacheKey = benefitListCacheKey;
|
|
8
|
+
exports.benefitRemainingCacheKey = benefitRemainingCacheKey;
|
|
9
|
+
exports.buildBenefitMoveCommand = buildBenefitMoveCommand;
|
|
10
|
+
exports.classifyBenefitMove = classifyBenefitMove;
|
|
11
|
+
exports.countBenefitSelections = countBenefitSelections;
|
|
12
|
+
exports.BENEFIT_LIST_CACHE_TTL_SECONDS = 3600;
|
|
13
|
+
exports.BENEFIT_REMAINING_CACHE_TTL_SECONDS = 10;
|
|
14
|
+
exports.BENEFIT_APPLY_MARKER_TTL_SECONDS = 86400;
|
|
15
|
+
exports.BENEFIT_RELEASE_MARKER_TTL_SECONDS = 7 * 24 * 3600;
|
|
16
|
+
function benefitStockKey(eventId, ticketClassId, benefitId) {
|
|
17
|
+
return `benefit:${eventId}:{${ticketClassId}}:${benefitId}`;
|
|
18
|
+
}
|
|
19
|
+
function benefitOpKey(ticketClassId, op, id) {
|
|
20
|
+
return `benefit:op:{${ticketClassId}}:${op}:${id}`;
|
|
21
|
+
}
|
|
22
|
+
function benefitNoopKey(ticketClassId) {
|
|
23
|
+
return `benefit:op:{${ticketClassId}}:noop`;
|
|
24
|
+
}
|
|
25
|
+
function benefitListCacheKey(ticketClassId) {
|
|
26
|
+
return `benefit:{${ticketClassId}}:list`;
|
|
27
|
+
}
|
|
28
|
+
function benefitRemainingCacheKey(ticketClassId) {
|
|
29
|
+
return `benefit:{${ticketClassId}}:remaining`;
|
|
30
|
+
}
|
|
31
|
+
exports.BENEFIT_MOVE_SCRIPT = `
|
|
32
|
+
if redis.call('EXISTS', KEYS[1]) == 1 then
|
|
33
|
+
return cjson.encode({ success = true, replay = true })
|
|
34
|
+
end
|
|
35
|
+
local short = {}
|
|
36
|
+
for i = 3, #KEYS do
|
|
37
|
+
local d = tonumber(ARGV[i - 2])
|
|
38
|
+
if d > 0 then
|
|
39
|
+
local a = tonumber(redis.call('GET', KEYS[i] .. ':available') or '0')
|
|
40
|
+
if a < d then table.insert(short, { key = KEYS[i], available = a, need = d }) end
|
|
41
|
+
elseif d < 0 then
|
|
42
|
+
local h = tonumber(redis.call('GET', KEYS[i] .. ':hold') or '0')
|
|
43
|
+
if h < -d then table.insert(short, { key = KEYS[i], hold = h, need = -d }) end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
if #short > 0 then
|
|
47
|
+
return cjson.encode({ success = false, short = short })
|
|
48
|
+
end
|
|
49
|
+
for i = 3, #KEYS do
|
|
50
|
+
local d = tonumber(ARGV[i - 2])
|
|
51
|
+
redis.call('DECRBY', KEYS[i] .. ':available', d)
|
|
52
|
+
redis.call('INCRBY', KEYS[i] .. ':hold', d)
|
|
53
|
+
end
|
|
54
|
+
redis.call('SET', KEYS[1], '1', 'EX', tonumber(ARGV[#ARGV]))
|
|
55
|
+
if KEYS[2] ~= '' then redis.call('DEL', KEYS[2]) end
|
|
56
|
+
return cjson.encode({ success = true, replay = false })
|
|
57
|
+
`;
|
|
58
|
+
exports.BENEFIT_ADJUST_SCRIPT = `
|
|
59
|
+
local a = tonumber(redis.call('GET', KEYS[1] .. ':available') or '0')
|
|
60
|
+
local d = tonumber(ARGV[1])
|
|
61
|
+
if a + d < 0 then return 0 end
|
|
62
|
+
redis.call('INCRBY', KEYS[1] .. ':available', d)
|
|
63
|
+
return 1
|
|
64
|
+
`;
|
|
65
|
+
exports.BENEFIT_RESEED_SCRIPT = `
|
|
66
|
+
redis.call('SET', KEYS[1] .. ':hold', ARGV[2])
|
|
67
|
+
redis.call('SET', KEYS[1] .. ':available', tonumber(ARGV[1]) - tonumber(ARGV[2]))
|
|
68
|
+
return 1
|
|
69
|
+
`;
|
|
70
|
+
function buildBenefitMoveCommand(input) {
|
|
71
|
+
const keys = [input.marker, input.deleteMarker ?? benefitNoopKey(input.ticketClassId)];
|
|
72
|
+
const args = [];
|
|
73
|
+
for (const [benefitId, delta] of Object.entries(input.deltas)) {
|
|
74
|
+
if (delta === 0)
|
|
75
|
+
continue;
|
|
76
|
+
keys.push(benefitStockKey(input.eventId, input.ticketClassId, benefitId));
|
|
77
|
+
args.push(String(delta));
|
|
78
|
+
}
|
|
79
|
+
args.push(String(input.ttlSeconds));
|
|
80
|
+
return { keys, args };
|
|
81
|
+
}
|
|
82
|
+
const AMBIGUOUS = { outcome: 'ambiguous', replay: false, short: [] };
|
|
83
|
+
function classifyBenefitMove(result) {
|
|
84
|
+
let parsed = result;
|
|
85
|
+
if (typeof result === 'string') {
|
|
86
|
+
try {
|
|
87
|
+
parsed = JSON.parse(result);
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
return { ...AMBIGUOUS };
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed))
|
|
94
|
+
return { ...AMBIGUOUS };
|
|
95
|
+
const body = parsed;
|
|
96
|
+
if (body.success === true)
|
|
97
|
+
return { outcome: 'ok', replay: body.replay === true, short: [] };
|
|
98
|
+
if (body.success === false) {
|
|
99
|
+
return { outcome: 'refused', replay: false, short: Array.isArray(body.short) ? body.short : [] };
|
|
100
|
+
}
|
|
101
|
+
return { ...AMBIGUOUS };
|
|
102
|
+
}
|
|
103
|
+
function countBenefitSelections(selections) {
|
|
104
|
+
const counts = {};
|
|
105
|
+
for (const selection of selections) {
|
|
106
|
+
for (const benefitId of selection.benefitIds || []) {
|
|
107
|
+
counts[benefitId] = (counts[benefitId] || 0) + 1;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return counts;
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=benefit-stock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"benefit-stock.js","sourceRoot":"","sources":["../../../src/database/redis/benefit-stock.ts"],"names":[],"mappings":";;;AAUA,0CAEC;AAED,oCAEC;AAID,wCAEC;AAED,kDAEC;AAED,4DAEC;AA6DD,0DAUC;AAoBD,kDAgBC;AAED,wDAQC;AAhJY,QAAA,8BAA8B,GAAG,IAAI,CAAC;AACtC,QAAA,mCAAmC,GAAG,EAAE,CAAC;AACzC,QAAA,gCAAgC,GAAG,KAAK,CAAC;AACzC,QAAA,kCAAkC,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;AAIhE,SAAgB,eAAe,CAAC,OAAe,EAAE,aAAqB,EAAE,SAAiB;IACvF,OAAO,WAAW,OAAO,KAAK,aAAa,KAAK,SAAS,EAAE,CAAC;AAC9D,CAAC;AAED,SAAgB,YAAY,CAAC,aAAqB,EAAE,EAAa,EAAE,EAAU;IAC3E,OAAO,eAAe,aAAa,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC;AACrD,CAAC;AAID,SAAgB,cAAc,CAAC,aAAqB;IAClD,OAAO,eAAe,aAAa,QAAQ,CAAC;AAC9C,CAAC;AAED,SAAgB,mBAAmB,CAAC,aAAqB;IACvD,OAAO,YAAY,aAAa,QAAQ,CAAC;AAC3C,CAAC;AAED,SAAgB,wBAAwB,CAAC,aAAqB;IAC5D,OAAO,YAAY,aAAa,aAAa,CAAC;AAChD,CAAC;AAGY,QAAA,mBAAmB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;CA0BlC,CAAC;AAGW,QAAA,qBAAqB,GAAG;;;;;;CAMpC,CAAC;AA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AC;QAAE,OAAO,EAAE,GAAG,SAAS,EAAE,CAAC;IAC5F,MAAM,IAAI,GAAG,MAAkE,CAAC;IAChF,IAAI,IAAI,CAAC,OAAO,KAAK,IAAI;QAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,KAAK,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;IAC7F,IAAI,IAAI,CAAC,OAAO,KAAK,KAAK,EAAE,CAAC;QAC3B,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAE,IAAI,CAAC,KAA4B,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;IAC3H,CAAC;IACD,OAAO,EAAE,GAAG,SAAS,EAAE,CAAC;AAC1B,CAAC;AAED,SAAgB,sBAAsB,CAAC,UAA+B;IACpE,MAAM,MAAM,GAA2B,EAAE,CAAC;IAC1C,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACnC,KAAK,MAAM,SAAS,IAAI,SAAS,CAAC,UAAU,IAAI,EAAE,EAAE,CAAC;YACnD,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;QACnD,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -17,4 +17,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./redis.module"), exports);
|
|
18
18
|
__exportStar(require("./redis.service"), exports);
|
|
19
19
|
__exportStar(require("./record-lock.service"), exports);
|
|
20
|
+
__exportStar(require("./benefit-stock"), exports);
|
|
20
21
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/database/redis/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA+B;AAC/B,kDAAgC;AAChC,wDAAsC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/database/redis/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA+B;AAC/B,kDAAgC;AAChC,wDAAsC;AACtC,kDAAgC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,8 @@ export * from './logger';
|
|
|
6
6
|
export * from './pipes/custom-validation.pipe';
|
|
7
7
|
export * from './response/response.interceptor';
|
|
8
8
|
export * from './response/skip-response.interceptor';
|
|
9
|
-
export * from './constants
|
|
9
|
+
export * from './constants';
|
|
10
|
+
export * from './services';
|
|
10
11
|
export * from './schemas';
|
|
11
12
|
export * from './schemas/schema.module';
|
|
12
13
|
export * from './cluster/index';
|
package/dist/index.js
CHANGED
|
@@ -22,7 +22,8 @@ __exportStar(require("./logger"), exports);
|
|
|
22
22
|
__exportStar(require("./pipes/custom-validation.pipe"), exports);
|
|
23
23
|
__exportStar(require("./response/response.interceptor"), exports);
|
|
24
24
|
__exportStar(require("./response/skip-response.interceptor"), exports);
|
|
25
|
-
__exportStar(require("./constants
|
|
25
|
+
__exportStar(require("./constants"), exports);
|
|
26
|
+
__exportStar(require("./services"), exports);
|
|
26
27
|
__exportStar(require("./schemas"), exports);
|
|
27
28
|
__exportStar(require("./schemas/schema.module"), exports);
|
|
28
29
|
__exportStar(require("./cluster/index"), exports);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AACA,6CAA2B;AAC3B,+DAA6C;AAC7C,uEAAqD;AACrD,uDAAqC;AAErC,2CAAyB;AAEzB,iEAA+C;AAC/C,kEAA+C;AAC/C,uEAAqD;AAErD,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AACA,6CAA2B;AAC3B,+DAA6C;AAC7C,uEAAqD;AACrD,uDAAqC;AAErC,2CAAyB;AAEzB,iEAA+C;AAC/C,kEAA+C;AAC/C,uEAAqD;AAErD,8CAA4B;AAE5B,6CAA2B;AAE3B,4CAA0B;AAC1B,0DAAwC;AAExC,kDAAgC;AAEhC,qDAAmC;AAEnC,uDAAqC;AAErC,+CAA6B;AAE7B,iDAA+B;AAG/B,kDAAgC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { HydratedDocument } from 'mongoose';
|
|
2
|
+
import { BaseDocument, BaseSchema } from '../index';
|
|
3
|
+
export type BenefitDocument = HydratedDocument<Benefit> & BaseDocument;
|
|
4
|
+
export declare class Benefit extends BaseSchema {
|
|
5
|
+
eventId: string;
|
|
6
|
+
calendarId: string;
|
|
7
|
+
ticketClassId: string;
|
|
8
|
+
name: string;
|
|
9
|
+
description: string;
|
|
10
|
+
thumbnail: string;
|
|
11
|
+
originalPriceVn: number;
|
|
12
|
+
originalPriceUsd: number;
|
|
13
|
+
finalPriceVn: number;
|
|
14
|
+
finalPriceUsd: number;
|
|
15
|
+
discountPercent: number;
|
|
16
|
+
quantity: number;
|
|
17
|
+
position: number;
|
|
18
|
+
isActive: boolean;
|
|
19
|
+
}
|
|
20
|
+
export declare const BenefitSchema: import("mongoose").Schema<Benefit, import("mongoose").Model<Benefit, any, any, any, import("mongoose").Document<unknown, any, Benefit, any> & Benefit & {
|
|
21
|
+
_id: import("mongoose").Types.ObjectId;
|
|
22
|
+
} & {
|
|
23
|
+
__v: number;
|
|
24
|
+
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, Benefit, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<Benefit>, {}> & import("mongoose").FlatRecord<Benefit> & {
|
|
25
|
+
_id: import("mongoose").Types.ObjectId;
|
|
26
|
+
} & {
|
|
27
|
+
__v: number;
|
|
28
|
+
}>;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.BenefitSchema = exports.Benefit = void 0;
|
|
13
|
+
const mongoose_1 = require("@nestjs/mongoose");
|
|
14
|
+
const index_1 = require("../index");
|
|
15
|
+
let Benefit = class Benefit extends index_1.BaseSchema {
|
|
16
|
+
};
|
|
17
|
+
exports.Benefit = Benefit;
|
|
18
|
+
__decorate([
|
|
19
|
+
(0, mongoose_1.Prop)({ required: true }),
|
|
20
|
+
__metadata("design:type", String)
|
|
21
|
+
], Benefit.prototype, "eventId", void 0);
|
|
22
|
+
__decorate([
|
|
23
|
+
(0, mongoose_1.Prop)({ required: true }),
|
|
24
|
+
__metadata("design:type", String)
|
|
25
|
+
], Benefit.prototype, "calendarId", void 0);
|
|
26
|
+
__decorate([
|
|
27
|
+
(0, mongoose_1.Prop)({ required: true }),
|
|
28
|
+
__metadata("design:type", String)
|
|
29
|
+
], Benefit.prototype, "ticketClassId", void 0);
|
|
30
|
+
__decorate([
|
|
31
|
+
(0, mongoose_1.Prop)({ required: true }),
|
|
32
|
+
__metadata("design:type", String)
|
|
33
|
+
], Benefit.prototype, "name", void 0);
|
|
34
|
+
__decorate([
|
|
35
|
+
(0, mongoose_1.Prop)({ default: '' }),
|
|
36
|
+
__metadata("design:type", String)
|
|
37
|
+
], Benefit.prototype, "description", void 0);
|
|
38
|
+
__decorate([
|
|
39
|
+
(0, mongoose_1.Prop)({ default: '' }),
|
|
40
|
+
__metadata("design:type", String)
|
|
41
|
+
], Benefit.prototype, "thumbnail", void 0);
|
|
42
|
+
__decorate([
|
|
43
|
+
(0, mongoose_1.Prop)({ default: 0 }),
|
|
44
|
+
__metadata("design:type", Number)
|
|
45
|
+
], Benefit.prototype, "originalPriceVn", void 0);
|
|
46
|
+
__decorate([
|
|
47
|
+
(0, mongoose_1.Prop)({ default: 0 }),
|
|
48
|
+
__metadata("design:type", Number)
|
|
49
|
+
], Benefit.prototype, "originalPriceUsd", void 0);
|
|
50
|
+
__decorate([
|
|
51
|
+
(0, mongoose_1.Prop)({ default: 0 }),
|
|
52
|
+
__metadata("design:type", Number)
|
|
53
|
+
], Benefit.prototype, "finalPriceVn", void 0);
|
|
54
|
+
__decorate([
|
|
55
|
+
(0, mongoose_1.Prop)({ default: 0 }),
|
|
56
|
+
__metadata("design:type", Number)
|
|
57
|
+
], Benefit.prototype, "finalPriceUsd", void 0);
|
|
58
|
+
__decorate([
|
|
59
|
+
(0, mongoose_1.Prop)({ default: 0 }),
|
|
60
|
+
__metadata("design:type", Number)
|
|
61
|
+
], Benefit.prototype, "discountPercent", void 0);
|
|
62
|
+
__decorate([
|
|
63
|
+
(0, mongoose_1.Prop)({ required: true, default: 0 }),
|
|
64
|
+
__metadata("design:type", Number)
|
|
65
|
+
], Benefit.prototype, "quantity", void 0);
|
|
66
|
+
__decorate([
|
|
67
|
+
(0, mongoose_1.Prop)({ default: 0 }),
|
|
68
|
+
__metadata("design:type", Number)
|
|
69
|
+
], Benefit.prototype, "position", void 0);
|
|
70
|
+
__decorate([
|
|
71
|
+
(0, mongoose_1.Prop)({ default: true }),
|
|
72
|
+
__metadata("design:type", Boolean)
|
|
73
|
+
], Benefit.prototype, "isActive", void 0);
|
|
74
|
+
exports.Benefit = Benefit = __decorate([
|
|
75
|
+
(0, mongoose_1.Schema)({
|
|
76
|
+
collection: 'benefits',
|
|
77
|
+
...index_1.defaultSchemaOptions,
|
|
78
|
+
})
|
|
79
|
+
], Benefit);
|
|
80
|
+
exports.BenefitSchema = mongoose_1.SchemaFactory.createForClass(Benefit);
|
|
81
|
+
(0, index_1.addSoftDeleteHooks)(exports.BenefitSchema);
|
|
82
|
+
(0, index_1.addUpdateHooks)(exports.BenefitSchema);
|
|
83
|
+
exports.BenefitSchema.index({ eventId: 1, ticketClassId: 1 });
|
|
84
|
+
//# sourceMappingURL=benefit.schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"benefit.schema.js","sourceRoot":"","sources":["../../../src/schemas/benefit/benefit.schema.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+CAA+D;AAE/D,oCAA8G;AASvG,IAAM,OAAO,GAAb,MAAM,OAAQ,SAAQ,kBAAU;CA6CtC,CAAA;AA7CY,0BAAO;AAElB;IADC,IAAA,eAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;wCACT;AAGhB;IADC,IAAA,eAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;2CACN;AAGnB;IADC,IAAA,eAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;8CACH;AAGtB;IADC,IAAA,eAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;qCACZ;AAIb;IADC,IAAA,eAAI,EAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;;4CACF;AAIpB;IADC,IAAA,eAAI,EAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;;0CACJ;AAGlB;IADC,IAAA,eAAI,EAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;gDACG;AAGxB;IADC,IAAA,eAAI,EAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;iDACI;AAGzB;IADC,IAAA,eAAI,EAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;6CACA;AAGrB;IADC,IAAA,eAAI,EAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;8CACC;AAItB;IADC,IAAA,eAAI,EAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;gDACG;AAGxB;IADC,IAAA,eAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;yCACpB;AAGjB;IADC,IAAA,eAAI,EAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;yCACJ;AAGjB;IADC,IAAA,eAAI,EAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;;yCACN;kBA5CP,OAAO;IAJnB,IAAA,iBAAM,EAAC;QACN,UAAU,EAAE,UAAU;QACtB,GAAG,4BAAoB;KACxB,CAAC;GACW,OAAO,CA6CnB;AAEY,QAAA,aAAa,GAAG,wBAAa,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;AAEnE,IAAA,0BAAkB,EAAC,qBAAa,CAAC,CAAC;AAClC,IAAA,sBAAc,EAAC,qBAAa,CAAC,CAAC;AAC9B,qBAAa,CAAC,KAAK,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,aAAa,EAAE,CAAC,EAAE,CAAC,CAAC"}
|
|
@@ -1,60 +1,14 @@
|
|
|
1
1
|
import { ICurrencyCode } from '../order/order.interfaces';
|
|
2
2
|
export declare enum IStatusEvent {
|
|
3
|
-
DRAFT = "DRAFT",
|
|
4
3
|
OPEN = "OPEN",
|
|
5
4
|
CLOSE = "CLOSE"
|
|
6
5
|
}
|
|
7
|
-
export declare enum IEventSaleOpenMode {
|
|
8
|
-
IMMEDIATELY_ON_PUBLISH = "immediately_on_publish",
|
|
9
|
-
SCHEDULED = "scheduled"
|
|
10
|
-
}
|
|
11
|
-
export declare enum IEventSaleCloseMode {
|
|
12
|
-
AT_EVENT_START = "at_event_start",
|
|
13
|
-
SCHEDULED = "scheduled",
|
|
14
|
-
WHEN_SOLD_OUT = "when_sold_out"
|
|
15
|
-
}
|
|
16
|
-
export declare enum ICollectInfoMode {
|
|
17
|
-
PER_ORDER = "per_order",
|
|
18
|
-
PER_TICKET = "per_ticket"
|
|
19
|
-
}
|
|
20
|
-
export declare enum IEventSalesMode {
|
|
21
|
-
BY_TICKET_CLASS = "by_ticket_class",
|
|
22
|
-
BY_SEATMAP = "by_seatmap"
|
|
23
|
-
}
|
|
24
|
-
export declare enum IDisplayMode {
|
|
25
|
-
LIGHT = "light",
|
|
26
|
-
DARK = "dark"
|
|
27
|
-
}
|
|
28
|
-
export interface IEventDescription {
|
|
29
|
-
title: string;
|
|
30
|
-
description: string;
|
|
31
|
-
order?: number;
|
|
32
|
-
}
|
|
33
|
-
export interface IEventOrganizer {
|
|
34
|
-
name?: string;
|
|
35
|
-
logo?: string;
|
|
36
|
-
description?: string;
|
|
37
|
-
}
|
|
38
|
-
export interface IEventPolicy {
|
|
39
|
-
key: string;
|
|
40
|
-
title: string;
|
|
41
|
-
content: string;
|
|
42
|
-
order?: number;
|
|
43
|
-
}
|
|
44
|
-
export interface IEventFaq {
|
|
45
|
-
question: string;
|
|
46
|
-
answer: string;
|
|
47
|
-
order?: number;
|
|
48
|
-
}
|
|
49
6
|
export interface IPaymentInfoField {
|
|
50
7
|
key: string;
|
|
51
8
|
text: string;
|
|
52
9
|
type?: string;
|
|
53
10
|
isDefault?: boolean;
|
|
54
11
|
isRequired?: boolean;
|
|
55
|
-
options?: string[];
|
|
56
|
-
order?: number;
|
|
57
|
-
isShown?: boolean;
|
|
58
12
|
}
|
|
59
13
|
export interface IGeneral {
|
|
60
14
|
collaboration?: 'eventista' | 'agency' | 'seatmap' | 'seatmap_zone' | 'mixed';
|
|
@@ -72,7 +26,6 @@ export interface IEventCalendar {
|
|
|
72
26
|
startDate: Date;
|
|
73
27
|
endDate: Date;
|
|
74
28
|
maxTicketPerUser?: number;
|
|
75
|
-
location?: string;
|
|
76
29
|
}
|
|
77
30
|
export interface ITicketCalendar {
|
|
78
31
|
thumbnail?: string;
|
|
@@ -94,7 +47,10 @@ export interface IEvent {
|
|
|
94
47
|
ticketCalendar?: ITicketCalendar;
|
|
95
48
|
hostedBy?: string;
|
|
96
49
|
tickets: Record<string, any>[];
|
|
97
|
-
eventDescriptions?:
|
|
50
|
+
eventDescriptions?: {
|
|
51
|
+
title: string;
|
|
52
|
+
description: string;
|
|
53
|
+
}[];
|
|
98
54
|
maxTicketPerUser: number;
|
|
99
55
|
note: string;
|
|
100
56
|
general?: IGeneral;
|
|
@@ -122,23 +78,4 @@ export interface IEvent {
|
|
|
122
78
|
saleMode?: string;
|
|
123
79
|
resaleEnabled?: boolean;
|
|
124
80
|
sendTicketPdfEnabled?: boolean;
|
|
125
|
-
displayMode?: IDisplayMode;
|
|
126
|
-
guestCheckoutEnabled?: boolean;
|
|
127
|
-
giftEnabled?: boolean;
|
|
128
|
-
collectInfoMode?: ICollectInfoMode;
|
|
129
|
-
maxTicketPerOrder?: number;
|
|
130
|
-
organizer?: IEventOrganizer;
|
|
131
|
-
policies?: IEventPolicy[];
|
|
132
|
-
faqs?: IEventFaq[];
|
|
133
|
-
saleOpenMode?: IEventSaleOpenMode;
|
|
134
|
-
saleStartAt?: Date | null;
|
|
135
|
-
saleCloseMode?: IEventSaleCloseMode;
|
|
136
|
-
saleEndAt?: Date | null;
|
|
137
|
-
saleEndAtEffective?: Date | null;
|
|
138
|
-
publishedAt?: Date | null;
|
|
139
|
-
saleOpenedAt?: Date | null;
|
|
140
|
-
saleClosedAt?: Date | null;
|
|
141
|
-
saleConfig?: Record<string, any>[];
|
|
142
|
-
systemVersion?: string;
|
|
143
|
-
salesMode?: IEventSalesMode;
|
|
144
81
|
}
|
|
@@ -1,36 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.IStatusEvent = void 0;
|
|
4
4
|
var IStatusEvent;
|
|
5
5
|
(function (IStatusEvent) {
|
|
6
|
-
IStatusEvent["DRAFT"] = "DRAFT";
|
|
7
6
|
IStatusEvent["OPEN"] = "OPEN";
|
|
8
7
|
IStatusEvent["CLOSE"] = "CLOSE";
|
|
9
8
|
})(IStatusEvent || (exports.IStatusEvent = IStatusEvent = {}));
|
|
10
|
-
var IEventSaleOpenMode;
|
|
11
|
-
(function (IEventSaleOpenMode) {
|
|
12
|
-
IEventSaleOpenMode["IMMEDIATELY_ON_PUBLISH"] = "immediately_on_publish";
|
|
13
|
-
IEventSaleOpenMode["SCHEDULED"] = "scheduled";
|
|
14
|
-
})(IEventSaleOpenMode || (exports.IEventSaleOpenMode = IEventSaleOpenMode = {}));
|
|
15
|
-
var IEventSaleCloseMode;
|
|
16
|
-
(function (IEventSaleCloseMode) {
|
|
17
|
-
IEventSaleCloseMode["AT_EVENT_START"] = "at_event_start";
|
|
18
|
-
IEventSaleCloseMode["SCHEDULED"] = "scheduled";
|
|
19
|
-
IEventSaleCloseMode["WHEN_SOLD_OUT"] = "when_sold_out";
|
|
20
|
-
})(IEventSaleCloseMode || (exports.IEventSaleCloseMode = IEventSaleCloseMode = {}));
|
|
21
|
-
var ICollectInfoMode;
|
|
22
|
-
(function (ICollectInfoMode) {
|
|
23
|
-
ICollectInfoMode["PER_ORDER"] = "per_order";
|
|
24
|
-
ICollectInfoMode["PER_TICKET"] = "per_ticket";
|
|
25
|
-
})(ICollectInfoMode || (exports.ICollectInfoMode = ICollectInfoMode = {}));
|
|
26
|
-
var IEventSalesMode;
|
|
27
|
-
(function (IEventSalesMode) {
|
|
28
|
-
IEventSalesMode["BY_TICKET_CLASS"] = "by_ticket_class";
|
|
29
|
-
IEventSalesMode["BY_SEATMAP"] = "by_seatmap";
|
|
30
|
-
})(IEventSalesMode || (exports.IEventSalesMode = IEventSalesMode = {}));
|
|
31
|
-
var IDisplayMode;
|
|
32
|
-
(function (IDisplayMode) {
|
|
33
|
-
IDisplayMode["LIGHT"] = "light";
|
|
34
|
-
IDisplayMode["DARK"] = "dark";
|
|
35
|
-
})(IDisplayMode || (exports.IDisplayMode = IDisplayMode = {}));
|
|
36
9
|
//# sourceMappingURL=event.interfaces.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event.interfaces.js","sourceRoot":"","sources":["../../../src/schemas/event/event.interfaces.ts"],"names":[],"mappings":";;;AACA,IAAY,
|
|
1
|
+
{"version":3,"file":"event.interfaces.js","sourceRoot":"","sources":["../../../src/schemas/event/event.interfaces.ts"],"names":[],"mappings":";;;AACA,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,6BAAa,CAAA;IACb,+BAAe,CAAA;AACjB,CAAC,EAHW,YAAY,4BAAZ,YAAY,QAGvB"}
|