@chevre/domain 21.1.0 → 21.2.0-alpha.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/lib/chevre/repo/itemAvailability/screeningEvent.d.ts +10 -0
- package/lib/chevre/repo/itemAvailability/screeningEvent.js +20 -8
- package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +9 -1
- package/lib/chevre/service/assetTransaction/reserve.js +4 -0
- package/lib/chevre/service/offer.js +5 -0
- package/lib/chevre/service/reserve/cancelReservation.js +21 -3
- package/lib/chevre/settings.d.ts +2 -0
- package/lib/chevre/settings.js +5 -1
- package/package.json +1 -1
|
@@ -14,22 +14,29 @@ export interface IOffer {
|
|
|
14
14
|
}
|
|
15
15
|
export interface ILockKey {
|
|
16
16
|
eventId: string;
|
|
17
|
+
startDate: Date;
|
|
17
18
|
offers: IOffer[];
|
|
18
19
|
expires: Date;
|
|
19
20
|
holder: string;
|
|
20
21
|
}
|
|
21
22
|
export interface IUnlockKey {
|
|
22
23
|
eventId: string;
|
|
24
|
+
startDate: Date;
|
|
23
25
|
offer: IOffer;
|
|
24
26
|
}
|
|
25
27
|
/**
|
|
26
28
|
* イベントの座席在庫リポジトリ
|
|
27
29
|
*/
|
|
28
30
|
export declare class RedisRepository {
|
|
31
|
+
static KEY_PREFIX_NEW: string;
|
|
29
32
|
static KEY_PREFIX: string;
|
|
30
33
|
private readonly redisClient;
|
|
31
34
|
constructor(redisClient: RedisClientType);
|
|
32
35
|
static OFFER2FIELD(params: IOffer): string;
|
|
36
|
+
static CREATE_KEY(params: {
|
|
37
|
+
eventId: string;
|
|
38
|
+
startDate: Date;
|
|
39
|
+
}): string;
|
|
33
40
|
/**
|
|
34
41
|
* 座席をロックする(maxキャパシティチェック有)
|
|
35
42
|
*/
|
|
@@ -47,6 +54,7 @@ export declare class RedisRepository {
|
|
|
47
54
|
*/
|
|
48
55
|
findUnavailableOffersByEventId(params: {
|
|
49
56
|
eventId: string;
|
|
57
|
+
startDate: Date;
|
|
50
58
|
}): Promise<IOffer[]>;
|
|
51
59
|
/**
|
|
52
60
|
* 空席でない座席をカウントする
|
|
@@ -54,6 +62,7 @@ export declare class RedisRepository {
|
|
|
54
62
|
countUnavailableOffers(params: {
|
|
55
63
|
event: {
|
|
56
64
|
id: string;
|
|
65
|
+
startDate: Date;
|
|
57
66
|
};
|
|
58
67
|
}): Promise<number>;
|
|
59
68
|
/**
|
|
@@ -66,6 +75,7 @@ export declare class RedisRepository {
|
|
|
66
75
|
*/
|
|
67
76
|
searchAvailability(params: {
|
|
68
77
|
eventId: string;
|
|
78
|
+
startDate: Date;
|
|
69
79
|
offers: IOffer[];
|
|
70
80
|
}): Promise<{
|
|
71
81
|
seatSection: string;
|
|
@@ -13,6 +13,7 @@ exports.RedisRepository = void 0;
|
|
|
13
13
|
const createDebug = require("debug");
|
|
14
14
|
const moment = require("moment");
|
|
15
15
|
const factory = require("../../factory");
|
|
16
|
+
const settings_1 = require("../../settings");
|
|
16
17
|
const debug = createDebug('chevre-domain:repo');
|
|
17
18
|
/**
|
|
18
19
|
* イベントの座席在庫リポジトリ
|
|
@@ -30,12 +31,23 @@ class RedisRepository {
|
|
|
30
31
|
}
|
|
31
32
|
return `${params.seatSection}:${params.seatNumber}`;
|
|
32
33
|
}
|
|
34
|
+
static CREATE_KEY(params) {
|
|
35
|
+
const useNewKey = params.startDate instanceof Date
|
|
36
|
+
&& moment(params.startDate)
|
|
37
|
+
.isAfter(settings_1.USE_NEW_EVENT_AVAILABILITY_KEY_FROM);
|
|
38
|
+
if (useNewKey) {
|
|
39
|
+
return `${RedisRepository.KEY_PREFIX_NEW}:${params.eventId}`;
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
return `${RedisRepository.KEY_PREFIX}:${params.eventId}`;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
33
45
|
/**
|
|
34
46
|
* 座席をロックする(maxキャパシティチェック有)
|
|
35
47
|
*/
|
|
36
48
|
lockIfNotLimitExceeded(lockKey, maximum) {
|
|
37
49
|
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
-
const key =
|
|
50
|
+
const key = RedisRepository.CREATE_KEY({ eventId: lockKey.eventId, startDate: lockKey.startDate });
|
|
39
51
|
yield this.redisClient.watch(key);
|
|
40
52
|
const hashCount = yield this.redisClient.hLen(key);
|
|
41
53
|
// Process result
|
|
@@ -52,8 +64,7 @@ class RedisRepository {
|
|
|
52
64
|
*/
|
|
53
65
|
lock(lockKey) {
|
|
54
66
|
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
-
|
|
56
|
-
const key = `${RedisRepository.KEY_PREFIX}:${lockKey.eventId}`;
|
|
67
|
+
const key = RedisRepository.CREATE_KEY({ eventId: lockKey.eventId, startDate: lockKey.startDate });
|
|
57
68
|
const value = lockKey.holder;
|
|
58
69
|
const multi = this.redisClient.multi();
|
|
59
70
|
const fields = lockKey.offers.map((offer) => RedisRepository.OFFER2FIELD(offer));
|
|
@@ -92,7 +103,7 @@ class RedisRepository {
|
|
|
92
103
|
*/
|
|
93
104
|
unlock(params) {
|
|
94
105
|
return __awaiter(this, void 0, void 0, function* () {
|
|
95
|
-
const key =
|
|
106
|
+
const key = RedisRepository.CREATE_KEY({ eventId: params.eventId, startDate: params.startDate });
|
|
96
107
|
const field = RedisRepository.OFFER2FIELD(params.offer);
|
|
97
108
|
yield this.redisClient.multi()
|
|
98
109
|
.hDel(key, field)
|
|
@@ -104,7 +115,7 @@ class RedisRepository {
|
|
|
104
115
|
*/
|
|
105
116
|
findUnavailableOffersByEventId(params) {
|
|
106
117
|
return __awaiter(this, void 0, void 0, function* () {
|
|
107
|
-
const key =
|
|
118
|
+
const key = RedisRepository.CREATE_KEY({ eventId: params.eventId, startDate: params.startDate });
|
|
108
119
|
const reply = yield this.redisClient.hGetAll(key);
|
|
109
120
|
let offers = [];
|
|
110
121
|
if (reply !== null) {
|
|
@@ -123,7 +134,7 @@ class RedisRepository {
|
|
|
123
134
|
*/
|
|
124
135
|
countUnavailableOffers(params) {
|
|
125
136
|
return __awaiter(this, void 0, void 0, function* () {
|
|
126
|
-
const key =
|
|
137
|
+
const key = RedisRepository.CREATE_KEY({ eventId: params.event.id, startDate: params.event.startDate });
|
|
127
138
|
const reply = yield this.redisClient.hLen(key);
|
|
128
139
|
let fieldCount = 0;
|
|
129
140
|
if (typeof reply === 'number') {
|
|
@@ -137,7 +148,7 @@ class RedisRepository {
|
|
|
137
148
|
*/
|
|
138
149
|
getHolder(params) {
|
|
139
150
|
return __awaiter(this, void 0, void 0, function* () {
|
|
140
|
-
const key =
|
|
151
|
+
const key = RedisRepository.CREATE_KEY({ eventId: params.eventId, startDate: params.startDate });
|
|
141
152
|
const field = RedisRepository.OFFER2FIELD(params.offer);
|
|
142
153
|
return this.redisClient.hGet(key, field);
|
|
143
154
|
});
|
|
@@ -148,7 +159,7 @@ class RedisRepository {
|
|
|
148
159
|
*/
|
|
149
160
|
searchAvailability(params) {
|
|
150
161
|
return __awaiter(this, void 0, void 0, function* () {
|
|
151
|
-
const key =
|
|
162
|
+
const key = RedisRepository.CREATE_KEY({ eventId: params.eventId, startDate: params.startDate });
|
|
152
163
|
const fields = params.offers.map((o) => {
|
|
153
164
|
return RedisRepository.OFFER2FIELD(o);
|
|
154
165
|
});
|
|
@@ -165,5 +176,6 @@ class RedisRepository {
|
|
|
165
176
|
});
|
|
166
177
|
}
|
|
167
178
|
}
|
|
179
|
+
RedisRepository.KEY_PREFIX_NEW = 'stockHolder';
|
|
168
180
|
RedisRepository.KEY_PREFIX = 'chevre:itemAvailability:screeningEvent';
|
|
169
181
|
exports.RedisRepository = RedisRepository;
|
|
@@ -389,6 +389,8 @@ function filterByEligibleSeatingType(params) {
|
|
|
389
389
|
if (maximumAttendeeCapacity > 0) {
|
|
390
390
|
const availabilities = yield repos.eventAvailability.searchAvailability({
|
|
391
391
|
eventId: params.event.id,
|
|
392
|
+
startDate: moment(params.event.startDate)
|
|
393
|
+
.toDate(),
|
|
392
394
|
offers: eligibleSeatOffers
|
|
393
395
|
});
|
|
394
396
|
remainingAttendeeCapacity = availabilities.filter((a) => a.availability === factory.itemAvailability.InStock).length;
|
|
@@ -436,7 +438,13 @@ function aggregateReservationByEvent(params) {
|
|
|
436
438
|
// remainingAttendeeCapacityを決定
|
|
437
439
|
if (typeof maximumAttendeeCapacity === 'number') {
|
|
438
440
|
// 残席数を座席ロック数から計算
|
|
439
|
-
const unavailableOfferCount = yield repos.eventAvailability.countUnavailableOffers({
|
|
441
|
+
const unavailableOfferCount = yield repos.eventAvailability.countUnavailableOffers({
|
|
442
|
+
event: {
|
|
443
|
+
id: params.event.id,
|
|
444
|
+
startDate: moment(params.event.startDate)
|
|
445
|
+
.toDate()
|
|
446
|
+
}
|
|
447
|
+
});
|
|
440
448
|
remainingAttendeeCapacity = maximumAttendeeCapacity - unavailableOfferCount;
|
|
441
449
|
if (remainingAttendeeCapacity < 0) {
|
|
442
450
|
remainingAttendeeCapacity = 0;
|
|
@@ -577,6 +577,8 @@ function processLockSeats(params) {
|
|
|
577
577
|
if (typeof maximumAttendeeCapacity4event === 'number') {
|
|
578
578
|
yield repos.eventAvailability.lockIfNotLimitExceeded({
|
|
579
579
|
eventId: params.event.id,
|
|
580
|
+
startDate: moment(params.event.startDate)
|
|
581
|
+
.toDate(),
|
|
580
582
|
offers,
|
|
581
583
|
expires,
|
|
582
584
|
holder
|
|
@@ -585,6 +587,8 @@ function processLockSeats(params) {
|
|
|
585
587
|
else {
|
|
586
588
|
yield repos.eventAvailability.lock({
|
|
587
589
|
eventId: params.event.id,
|
|
590
|
+
startDate: moment(params.event.startDate)
|
|
591
|
+
.toDate(),
|
|
588
592
|
offers,
|
|
589
593
|
expires,
|
|
590
594
|
holder
|
|
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.createAggregateScreeningEventIfNotExist = exports.onEventChanged = exports.searchEventSeatOffersWithPaging = exports.searchEventSeatOffers = exports.product = exports.moneyTransfer = exports.eventServiceByCOA = exports.event = void 0;
|
|
13
|
+
const moment = require("moment");
|
|
13
14
|
const factory = require("../factory");
|
|
14
15
|
const EventOfferService = require("./offer/event");
|
|
15
16
|
exports.event = EventOfferService;
|
|
@@ -111,6 +112,8 @@ function searchEventSeatOffers(params) {
|
|
|
111
112
|
if (seats.length > 0) {
|
|
112
113
|
const availabilities = yield repos.eventAvailability.searchAvailability({
|
|
113
114
|
eventId: params.event.id,
|
|
115
|
+
startDate: moment(event.startDate)
|
|
116
|
+
.toDate(),
|
|
114
117
|
offers: seats.map((s) => {
|
|
115
118
|
var _a;
|
|
116
119
|
return {
|
|
@@ -182,6 +185,8 @@ function searchEventSeatOffersWithPaging(params) {
|
|
|
182
185
|
if (seats.length > 0) {
|
|
183
186
|
const availabilities = yield repos.eventAvailability.searchAvailability({
|
|
184
187
|
eventId: params.event.id,
|
|
188
|
+
startDate: moment(event.startDate)
|
|
189
|
+
.toDate(),
|
|
185
190
|
offers: seats.map((s) => {
|
|
186
191
|
var _a;
|
|
187
192
|
return {
|
|
@@ -62,7 +62,12 @@ function cancelPendingReservation(actionAttributesList) {
|
|
|
62
62
|
id: cancelingSubReservation.id,
|
|
63
63
|
reservedTicket: cancelingSubReservation.reservedTicket,
|
|
64
64
|
subReservation: cancelingSubReservation.subReservation,
|
|
65
|
-
reservationFor: {
|
|
65
|
+
reservationFor: {
|
|
66
|
+
id: String(reservationFor.id),
|
|
67
|
+
startDate: (reservationFor.typeOf === factory.eventType.ScreeningEvent)
|
|
68
|
+
? reservationFor.startDate
|
|
69
|
+
: reservationFor.departureTime
|
|
70
|
+
}
|
|
66
71
|
},
|
|
67
72
|
expectedHolder: reserveTransactionId
|
|
68
73
|
})(repos);
|
|
@@ -199,7 +204,12 @@ function cancelReservation(actionAttributesList) {
|
|
|
199
204
|
id: cancelingSubReservation.id,
|
|
200
205
|
reservedTicket: cancelingSubReservation.reservedTicket,
|
|
201
206
|
subReservation: cancelingSubReservation.subReservation,
|
|
202
|
-
reservationFor: {
|
|
207
|
+
reservationFor: {
|
|
208
|
+
id: String(reservationFor.id),
|
|
209
|
+
startDate: (reservationFor.typeOf === factory.eventType.ScreeningEvent)
|
|
210
|
+
? reservationFor.startDate
|
|
211
|
+
: reservationFor.departureTime
|
|
212
|
+
}
|
|
203
213
|
},
|
|
204
214
|
expectedHolder: reserveTransaction.id
|
|
205
215
|
})(repos);
|
|
@@ -241,7 +251,10 @@ function cancelReservation(actionAttributesList) {
|
|
|
241
251
|
id: reservation.id,
|
|
242
252
|
reservedTicket: reservation.reservedTicket,
|
|
243
253
|
subReservation: reservation.subReservation,
|
|
244
|
-
reservationFor: {
|
|
254
|
+
reservationFor: {
|
|
255
|
+
id: reservation.reservationFor.id,
|
|
256
|
+
startDate: reservation.reservationFor.startDate
|
|
257
|
+
}
|
|
245
258
|
},
|
|
246
259
|
expectedHolder
|
|
247
260
|
})(repos);
|
|
@@ -319,9 +332,12 @@ exports.cancelReservation = cancelReservation;
|
|
|
319
332
|
function processUnlockSeat(params) {
|
|
320
333
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
321
334
|
const reservation = params.reservation;
|
|
335
|
+
const eventStartDate = moment(reservation.reservationFor.startDate)
|
|
336
|
+
.toDate();
|
|
322
337
|
// 予約IDでロックされていれば解除
|
|
323
338
|
let lockKey = {
|
|
324
339
|
eventId: reservation.reservationFor.id,
|
|
340
|
+
startDate: eventStartDate,
|
|
325
341
|
offer: {
|
|
326
342
|
itemOffered: { serviceOutput: { id: reservation.id } },
|
|
327
343
|
seatNumber: '',
|
|
@@ -337,6 +353,7 @@ function processUnlockSeat(params) {
|
|
|
337
353
|
if (ticketedSeat !== undefined) {
|
|
338
354
|
lockKey = {
|
|
339
355
|
eventId: reservation.reservationFor.id,
|
|
356
|
+
startDate: eventStartDate,
|
|
340
357
|
offer: {
|
|
341
358
|
seatNumber: ticketedSeat.seatNumber,
|
|
342
359
|
seatSection: ticketedSeat.seatSection
|
|
@@ -357,6 +374,7 @@ function processUnlockSeat(params) {
|
|
|
357
374
|
if (typeof seatSection4sub === 'string' && typeof seatNumber4sub === 'string') {
|
|
358
375
|
const lockKey4sub = {
|
|
359
376
|
eventId: reservation.reservationFor.id,
|
|
377
|
+
startDate: eventStartDate,
|
|
360
378
|
offer: {
|
|
361
379
|
seatNumber: seatNumber4sub,
|
|
362
380
|
seatSection: seatSection4sub
|
package/lib/chevre/settings.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as moment from 'moment';
|
|
1
2
|
import * as factory from './factory';
|
|
2
3
|
export declare const ABORTED_TASKS_WITHOUT_REPORT: string[];
|
|
3
4
|
/**
|
|
@@ -28,6 +29,7 @@ export type ISettings = factory.project.ISettings & {
|
|
|
28
29
|
export declare const DEFAULT_PAYMENT_METHOD_TYPE_FOR_CREDIT_CARD: string;
|
|
29
30
|
export declare const USE_ASSET_TRANSACTION_SYNC_PROCESSING: boolean;
|
|
30
31
|
export declare const USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING: boolean;
|
|
32
|
+
export declare const USE_NEW_EVENT_AVAILABILITY_KEY_FROM: moment.Moment;
|
|
31
33
|
/**
|
|
32
34
|
* グローバル設定
|
|
33
35
|
*/
|
package/lib/chevre/settings.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.settings = exports.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING = exports.USE_ASSET_TRANSACTION_SYNC_PROCESSING = exports.DEFAULT_PAYMENT_METHOD_TYPE_FOR_CREDIT_CARD = exports.DEFAULT_SENDER_EMAIL = exports.TRANSACTION_CANCELED_STORAGE_PERIOD_IN_DAYS = exports.TRANSACTION_CONFIRMED_STORAGE_PERIOD_IN_DAYS = exports.ASSET_TRANSACTION_STORAGE_PERIOD_IN_DAYS = exports.ABORTED_TASKS_WITHOUT_REPORT = void 0;
|
|
3
|
+
exports.settings = exports.USE_NEW_EVENT_AVAILABILITY_KEY_FROM = exports.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING = exports.USE_ASSET_TRANSACTION_SYNC_PROCESSING = exports.DEFAULT_PAYMENT_METHOD_TYPE_FOR_CREDIT_CARD = exports.DEFAULT_SENDER_EMAIL = exports.TRANSACTION_CANCELED_STORAGE_PERIOD_IN_DAYS = exports.TRANSACTION_CONFIRMED_STORAGE_PERIOD_IN_DAYS = exports.ASSET_TRANSACTION_STORAGE_PERIOD_IN_DAYS = exports.ABORTED_TASKS_WITHOUT_REPORT = void 0;
|
|
4
|
+
const moment = require("moment");
|
|
4
5
|
const factory = require("./factory");
|
|
5
6
|
const transactionWebhookUrls = (typeof process.env.INFORM_TRANSACTION_URL === 'string')
|
|
6
7
|
? process.env.INFORM_TRANSACTION_URL.split(' ')
|
|
@@ -45,6 +46,9 @@ exports.DEFAULT_SENDER_EMAIL = process.env.DEFAULT_SENDER_EMAIL;
|
|
|
45
46
|
exports.DEFAULT_PAYMENT_METHOD_TYPE_FOR_CREDIT_CARD = String(process.env.DEFAULT_PAYMENT_METHOD_TYPE_FOR_CREDIT_CARD);
|
|
46
47
|
exports.USE_ASSET_TRANSACTION_SYNC_PROCESSING = process.env.USE_ASSET_TRANSACTION_SYNC_PROCESSING === '1';
|
|
47
48
|
exports.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING = process.env.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING === '1';
|
|
49
|
+
exports.USE_NEW_EVENT_AVAILABILITY_KEY_FROM = (typeof process.env.USE_NEW_EVENT_AVAILABILITY_KEY_FROM === 'string')
|
|
50
|
+
? moment(process.env.USE_NEW_EVENT_AVAILABILITY_KEY_FROM)
|
|
51
|
+
: moment('2023-07-23T15:00:00Z');
|
|
48
52
|
/**
|
|
49
53
|
* グローバル設定
|
|
50
54
|
*/
|
package/package.json
CHANGED