@chevre/domain 20.4.0-alpha.22 → 20.4.0-alpha.23
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.
|
@@ -38,18 +38,25 @@ function searchTicketOffersByItemOffered(params) {
|
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
40
|
/**
|
|
41
|
-
*
|
|
41
|
+
* イベントから興行(旅客)オファーを検索する
|
|
42
42
|
*/
|
|
43
|
-
function
|
|
43
|
+
function searchEventTicketOffersByEvent(params) {
|
|
44
44
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
45
45
|
var _a, _b;
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
46
|
+
const event = params.event;
|
|
47
|
+
let soundFormatTypes = [];
|
|
48
|
+
let videoFormatTypes = [];
|
|
49
|
+
if (event.typeOf === factory.eventType.ScreeningEvent) {
|
|
50
|
+
// 取得属性最適化(2023-01-25~)
|
|
51
|
+
const superEvent = yield repos.event.findById({ id: event.superEvent.id }, { soundFormat: 1, videoFormat: 1 });
|
|
52
|
+
soundFormatTypes = (Array.isArray(superEvent.soundFormat)) ? superEvent.soundFormat.map((f) => f.typeOf) : [];
|
|
53
|
+
videoFormatTypes = (Array.isArray(superEvent.videoFormat)) ? superEvent.videoFormat.map((f) => f.typeOf) : [];
|
|
54
|
+
}
|
|
55
|
+
const unacceptedPaymentMethod = getUnacceptedPaymentMethodByEvent({ event });
|
|
50
56
|
// 上映方式がなければMovieTicket除外(2023-02-21~)
|
|
51
57
|
const excludeAppliesToMovieTicket = videoFormatTypes.length === 0;
|
|
52
|
-
|
|
58
|
+
// 興行設定があれば興行のカタログを参照する(2022-08-31~)
|
|
59
|
+
const eventOffers = event.offers;
|
|
53
60
|
const { availableOffers, sortedOfferIds } = yield searchTicketOffersByItemOffered({
|
|
54
61
|
itemOffered: { id: (_a = eventOffers === null || eventOffers === void 0 ? void 0 : eventOffers.itemOffered) === null || _a === void 0 ? void 0 : _a.id },
|
|
55
62
|
ids: params.ids,
|
|
@@ -61,120 +68,44 @@ function searchTransportationEventTicketOffers(params) {
|
|
|
61
68
|
unacceptedPaymentMethod,
|
|
62
69
|
excludeAppliesToMovieTicket
|
|
63
70
|
})(repos);
|
|
64
|
-
const { soundFormatChargeSpecifications, videoFormatChargeSpecifications, movieTicketTypeChargeSpecs } = yield searchPriceSpecs4event({ project: { id:
|
|
71
|
+
const { soundFormatChargeSpecifications, videoFormatChargeSpecifications, movieTicketTypeChargeSpecs } = yield searchPriceSpecs4event({ project: { id: event.project.id }, soundFormatTypes, videoFormatTypes })(repos);
|
|
65
72
|
// 決済カード加算料金が存在しない場合自動補完する(2023-02-21~)
|
|
66
73
|
// if (!settings.useOffersAppliedToMovieTicketWithoutChargeSpecification) {
|
|
67
74
|
// }
|
|
68
|
-
|
|
75
|
+
const offers4event = [];
|
|
76
|
+
// 単価オファーから興行オファーを生成(順に処理)
|
|
77
|
+
for (const availableOffer of availableOffers) {
|
|
69
78
|
let sortIndex;
|
|
70
79
|
if (params.addSortIndex) {
|
|
71
80
|
sortIndex = sortedOfferIds.indexOf(String(availableOffer.id));
|
|
72
81
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
videoFormatTypes,
|
|
80
|
-
sortIndex
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
if (params.validateOfferRateLimit) {
|
|
84
|
-
// レート制限を確認
|
|
85
|
-
offers4event = yield Promise.all(offers4event.map((offer) => __awaiter(this, void 0, void 0, function* () {
|
|
86
|
-
return checkAvailability({ event: screeningEvent, offer })(repos);
|
|
87
|
-
})));
|
|
88
|
-
}
|
|
89
|
-
// アドオン設定があれば、プロダクトオファーを検索
|
|
90
|
-
for (const offer of offers4event) {
|
|
82
|
+
let availability;
|
|
83
|
+
if (params.validateOfferRateLimit) {
|
|
84
|
+
// レート制限を確認
|
|
85
|
+
availability = yield checkAvailability({ event, unitPriceOffer: availableOffer })(repos);
|
|
86
|
+
}
|
|
87
|
+
// アドオン設定があれば、プロダクトオファーを検索
|
|
91
88
|
const offerAddOn = [];
|
|
92
|
-
if (Array.isArray(
|
|
93
|
-
for (const addOn of
|
|
89
|
+
if (Array.isArray(availableOffer.addOn)) {
|
|
90
|
+
for (const addOn of availableOffer.addOn) {
|
|
94
91
|
const productId = (_b = addOn.itemOffered) === null || _b === void 0 ? void 0 : _b.id;
|
|
95
92
|
if (typeof productId === 'string') {
|
|
96
|
-
const productOffers = yield searchAddOns({
|
|
97
|
-
product: { id: productId },
|
|
98
|
-
store: params.store
|
|
99
|
-
})(repos);
|
|
93
|
+
const productOffers = yield searchAddOns({ product: { id: productId }, onlyValid: params.onlyValid })(repos);
|
|
100
94
|
offerAddOn.push(...productOffers);
|
|
101
95
|
}
|
|
102
96
|
}
|
|
103
97
|
}
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
return {
|
|
107
|
-
ticketOffers: offers4event,
|
|
108
|
-
unitPriceOffers: availableOffers
|
|
109
|
-
};
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* 興行オファー全検索
|
|
114
|
-
*/
|
|
115
|
-
function searchScreeningEventTicketOffers(params) {
|
|
116
|
-
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
117
|
-
var _a, _b;
|
|
118
|
-
// イベント取得属性最適化(2023-01-23~)
|
|
119
|
-
const screeningEvent = params.event;
|
|
120
|
-
// 取得属性最適化(2023-01-25~)
|
|
121
|
-
const superEvent = yield repos.event.findById({ id: screeningEvent.superEvent.id }, { soundFormat: 1, videoFormat: 1 });
|
|
122
|
-
const soundFormatTypes = (Array.isArray(superEvent.soundFormat)) ? superEvent.soundFormat.map((f) => f.typeOf) : [];
|
|
123
|
-
const videoFormatTypes = (Array.isArray(superEvent.videoFormat)) ? superEvent.videoFormat.map((f) => f.typeOf) : [];
|
|
124
|
-
const unacceptedPaymentMethod = getUnacceptedPaymentMethodByEvent({ event: screeningEvent });
|
|
125
|
-
// 上映方式がなければMovieTicket除外(2023-02-21~)
|
|
126
|
-
const excludeAppliesToMovieTicket = videoFormatTypes.length === 0;
|
|
127
|
-
// 興行設定があれば興行のカタログを参照する(2022-08-31~)
|
|
128
|
-
const eventOffers = screeningEvent.offers;
|
|
129
|
-
const { availableOffers, sortedOfferIds } = yield searchTicketOffersByItemOffered({
|
|
130
|
-
itemOffered: { id: (_a = eventOffers === null || eventOffers === void 0 ? void 0 : eventOffers.itemOffered) === null || _a === void 0 ? void 0 : _a.id },
|
|
131
|
-
ids: params.ids,
|
|
132
|
-
store: params.store,
|
|
133
|
-
limit: params.limit,
|
|
134
|
-
page: params.page,
|
|
135
|
-
sort: params.sort,
|
|
136
|
-
onlyValid: params.onlyValid,
|
|
137
|
-
unacceptedPaymentMethod,
|
|
138
|
-
excludeAppliesToMovieTicket
|
|
139
|
-
})(repos);
|
|
140
|
-
const { soundFormatChargeSpecifications, videoFormatChargeSpecifications, movieTicketTypeChargeSpecs } = yield searchPriceSpecs4event({ project: { id: screeningEvent.project.id }, soundFormatTypes, videoFormatTypes })(repos);
|
|
141
|
-
// 決済カード加算料金が存在しない場合自動補完する(2023-02-21~)
|
|
142
|
-
// if (!settings.useOffersAppliedToMovieTicketWithoutChargeSpecification) {
|
|
143
|
-
// }
|
|
144
|
-
let offers4event = availableOffers.map((availableOffer) => {
|
|
145
|
-
let sortIndex;
|
|
146
|
-
if (params.addSortIndex) {
|
|
147
|
-
sortIndex = sortedOfferIds.indexOf(String(availableOffer.id));
|
|
148
|
-
}
|
|
149
|
-
return (0, factory_1.createCompoundPriceSpec4event)({
|
|
98
|
+
offers4event.push((0, factory_1.createCompoundPriceSpec4event)({
|
|
150
99
|
eligibleQuantity: eventOffers.eligibleQuantity,
|
|
151
100
|
offer: availableOffer,
|
|
152
101
|
videoFormatChargeSpecifications,
|
|
153
102
|
soundFormatChargeSpecifications,
|
|
154
103
|
movieTicketTypeChargeSpecs,
|
|
155
104
|
videoFormatTypes,
|
|
105
|
+
availability,
|
|
106
|
+
addOn: offerAddOn,
|
|
156
107
|
sortIndex
|
|
157
|
-
});
|
|
158
|
-
});
|
|
159
|
-
if (params.validateOfferRateLimit) {
|
|
160
|
-
// レート制限を確認
|
|
161
|
-
offers4event = yield Promise.all(offers4event.map((offer) => __awaiter(this, void 0, void 0, function* () {
|
|
162
|
-
return checkAvailability({ event: screeningEvent, offer })(repos);
|
|
163
|
-
})));
|
|
164
|
-
}
|
|
165
|
-
// アドオン設定があれば、プロダクトオファーを検索
|
|
166
|
-
for (const offer of offers4event) {
|
|
167
|
-
const offerAddOn = [];
|
|
168
|
-
if (Array.isArray(offer.addOn)) {
|
|
169
|
-
for (const addOn of offer.addOn) {
|
|
170
|
-
const productId = (_b = addOn.itemOffered) === null || _b === void 0 ? void 0 : _b.id;
|
|
171
|
-
if (typeof productId === 'string') {
|
|
172
|
-
const productOffers = yield searchAddOns({ product: { id: productId } })(repos);
|
|
173
|
-
offerAddOn.push(...productOffers);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
offer.addOn = offerAddOn;
|
|
108
|
+
}));
|
|
178
109
|
}
|
|
179
110
|
return {
|
|
180
111
|
ticketOffers: offers4event,
|
|
@@ -232,10 +163,11 @@ function searchPriceSpecs4event(params) {
|
|
|
232
163
|
function checkAvailability(params) {
|
|
233
164
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
234
165
|
var _a, _b;
|
|
235
|
-
const
|
|
166
|
+
const unitPriceOffer = params.unitPriceOffer;
|
|
167
|
+
let availability;
|
|
236
168
|
// レート制限を確認
|
|
237
|
-
const scope = (_a =
|
|
238
|
-
const unitInSeconds = (_b =
|
|
169
|
+
const scope = (_a = unitPriceOffer.validRateLimit) === null || _a === void 0 ? void 0 : _a.scope;
|
|
170
|
+
const unitInSeconds = (_b = unitPriceOffer.validRateLimit) === null || _b === void 0 ? void 0 : _b.unitInSeconds;
|
|
239
171
|
if (typeof scope === 'string' && typeof unitInSeconds === 'number') {
|
|
240
172
|
const rateLimitKey = {
|
|
241
173
|
reservedTicket: {
|
|
@@ -255,10 +187,10 @@ function checkAvailability(params) {
|
|
|
255
187
|
const holder = yield repos.offerRateLimit.getHolder(rateLimitKey);
|
|
256
188
|
// ロックされていればOutOfStock
|
|
257
189
|
if (typeof holder === 'string' && holder.length > 0) {
|
|
258
|
-
|
|
190
|
+
availability = factory.itemAvailability.OutOfStock;
|
|
259
191
|
}
|
|
260
192
|
}
|
|
261
|
-
return
|
|
193
|
+
return availability;
|
|
262
194
|
});
|
|
263
195
|
}
|
|
264
196
|
/**
|
|
@@ -277,6 +209,7 @@ function searchAddOns(params) {
|
|
|
277
209
|
offerCatalog: { id: offerCatalogId },
|
|
278
210
|
availableAtOrFrom: { id: (_c = params.store) === null || _c === void 0 ? void 0 : _c.id },
|
|
279
211
|
excludeAppliesToMovieTicket: false,
|
|
212
|
+
onlyValid: params.onlyValid === true,
|
|
280
213
|
sort: true
|
|
281
214
|
});
|
|
282
215
|
offers = findOffersByOfferCatalogIdResult.offers;
|
|
@@ -299,15 +232,9 @@ function searchAddOns(params) {
|
|
|
299
232
|
* 興行オファー検索
|
|
300
233
|
*/
|
|
301
234
|
function searchEventTicketOffers(params) {
|
|
302
|
-
// tslint:disable-next-line:max-func-body-length
|
|
303
235
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
304
|
-
const now = moment();
|
|
305
|
-
|
|
306
|
-
// イベント取得属性最適化(2023-01-23~)
|
|
307
|
-
// event = await repos.event.findById<factory.eventType.ScreeningEvent | factory.eventType.Event>({ id: params.event.id });
|
|
308
|
-
event = yield repos.event.findMinimizedIndividualEventById({
|
|
309
|
-
id: params.event.id
|
|
310
|
-
});
|
|
236
|
+
// const now = moment();
|
|
237
|
+
const event = yield repos.event.findMinimizedIndividualEventById({ id: params.event.id });
|
|
311
238
|
let offers;
|
|
312
239
|
let unitPriceOffers;
|
|
313
240
|
const eventOffers = event.offers;
|
|
@@ -321,95 +248,55 @@ function searchEventTicketOffers(params) {
|
|
|
321
248
|
case factory.service.webAPI.Identifier.COA:
|
|
322
249
|
throw new factory.errors.NotImplemented(`booking service '${eventOffers.offeredThrough.identifier}' not implemented`);
|
|
323
250
|
default:
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
// .isAfter(now)) {
|
|
374
|
-
// isvalid = false;
|
|
375
|
-
// }
|
|
376
|
-
// if (o.validThrough !== undefined && moment(o.validThrough)
|
|
377
|
-
// .isBefore(now)) {
|
|
378
|
-
// isvalid = false;
|
|
379
|
-
// }
|
|
380
|
-
// return isvalid;
|
|
381
|
-
// });
|
|
382
|
-
// }
|
|
383
|
-
for (const offer of offers) {
|
|
384
|
-
if (Array.isArray(offer.addOn)) {
|
|
385
|
-
// store.idでのフィルターをmongoに移行(2023-01-27~)
|
|
386
|
-
// addOnsに対しても利用可能アプリケーション設定を適用
|
|
387
|
-
// if (typeof specifiedStoreId === 'string') {
|
|
388
|
-
// // アプリケーションが利用可能なオファーに絞る
|
|
389
|
-
// offer.addOn = offer.addOn.filter((offer4addOn) => {
|
|
390
|
-
// return Array.isArray(offer4addOn.availableAtOrFrom)
|
|
391
|
-
// && offer4addOn.availableAtOrFrom.some(
|
|
392
|
-
// (availableApplication) => availableApplication.id === specifiedStoreId
|
|
393
|
-
// );
|
|
394
|
-
// });
|
|
395
|
-
// }
|
|
396
|
-
// addOnsに対しても有効期間を適用
|
|
397
|
-
if (params.onlyValid === true) {
|
|
398
|
-
offer.addOn = offer.addOn.filter((offer4addOn) => {
|
|
399
|
-
let isvalid = true;
|
|
400
|
-
if (offer4addOn.validFrom !== undefined && moment(offer4addOn.validFrom)
|
|
401
|
-
.isAfter(now)) {
|
|
402
|
-
isvalid = false;
|
|
403
|
-
}
|
|
404
|
-
if (offer4addOn.validThrough !== undefined && moment(offer4addOn.validThrough)
|
|
405
|
-
.isBefore(now)) {
|
|
406
|
-
isvalid = false;
|
|
407
|
-
}
|
|
408
|
-
return isvalid;
|
|
409
|
-
});
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
}
|
|
251
|
+
const searchOffersResult = yield searchEventTicketOffersByEvent({
|
|
252
|
+
ids: params.ids,
|
|
253
|
+
event,
|
|
254
|
+
store: params.store,
|
|
255
|
+
limit: params.limit,
|
|
256
|
+
page: params.page,
|
|
257
|
+
sort: params.sort,
|
|
258
|
+
addSortIndex: params.addSortIndex,
|
|
259
|
+
validateOfferRateLimit: params.validateOfferRateLimit,
|
|
260
|
+
onlyValid: params.onlyValid === true
|
|
261
|
+
})(repos);
|
|
262
|
+
offers = searchOffersResult.ticketOffers;
|
|
263
|
+
unitPriceOffers = searchOffersResult.unitPriceOffers;
|
|
264
|
+
// mongo条件へ移行(2023-02-24~)
|
|
265
|
+
// 有効期間を適用
|
|
266
|
+
// if (params.onlyValid === true) {
|
|
267
|
+
// offers = offers.filter((o) => {
|
|
268
|
+
// let isvalid = true;
|
|
269
|
+
// if (o.validFrom !== undefined && moment(o.validFrom)
|
|
270
|
+
// .isAfter(now)) {
|
|
271
|
+
// isvalid = false;
|
|
272
|
+
// }
|
|
273
|
+
// if (o.validThrough !== undefined && moment(o.validThrough)
|
|
274
|
+
// .isBefore(now)) {
|
|
275
|
+
// isvalid = false;
|
|
276
|
+
// }
|
|
277
|
+
// return isvalid;
|
|
278
|
+
// });
|
|
279
|
+
// }
|
|
280
|
+
// mongo条件へ移行(2023-02-27~)
|
|
281
|
+
// for (const offer of offers) {
|
|
282
|
+
// if (Array.isArray(offer.addOn)) {
|
|
283
|
+
// // addOnsに対しても有効期間を適用
|
|
284
|
+
// if (params.onlyValid === true) {
|
|
285
|
+
// offer.addOn = offer.addOn.filter((offer4addOn) => {
|
|
286
|
+
// let isvalid = true;
|
|
287
|
+
// if (offer4addOn.validFrom !== undefined && moment(offer4addOn.validFrom)
|
|
288
|
+
// .isAfter(now)) {
|
|
289
|
+
// isvalid = false;
|
|
290
|
+
// }
|
|
291
|
+
// if (offer4addOn.validThrough !== undefined && moment(offer4addOn.validThrough)
|
|
292
|
+
// .isBefore(now)) {
|
|
293
|
+
// isvalid = false;
|
|
294
|
+
// }
|
|
295
|
+
// return isvalid;
|
|
296
|
+
// });
|
|
297
|
+
// }
|
|
298
|
+
// }
|
|
299
|
+
// }
|
|
413
300
|
}
|
|
414
301
|
return { ticketOffers: offers, unitPriceOffers };
|
|
415
302
|
});
|
|
@@ -8,6 +8,8 @@ declare function createCompoundPriceSpec4event(params: {
|
|
|
8
8
|
videoFormatChargeSpecifications: ICategoryCodeChargeSpecification[];
|
|
9
9
|
soundFormatChargeSpecifications: ICategoryCodeChargeSpecification[];
|
|
10
10
|
videoFormatTypes: string[];
|
|
11
|
+
availability?: factory.itemAvailability;
|
|
12
|
+
addOn: factory.offer.IAddOn[];
|
|
11
13
|
sortIndex?: number;
|
|
12
14
|
}): factory.product.ITicketOffer & {
|
|
13
15
|
sortIndex?: number;
|
|
@@ -78,14 +78,16 @@ function createCompoundPriceSpec4event(params) {
|
|
|
78
78
|
};
|
|
79
79
|
// 必要な属性のみに限定(2023-02-24~)
|
|
80
80
|
// const { project, ...unitOfferFields4ticketOffer } = params.offer;
|
|
81
|
-
const { name, description, alternateName, color, typeOf, id,
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
addOn,
|
|
81
|
+
const { name, description, alternateName, color, typeOf, id,
|
|
82
|
+
// addOn,
|
|
83
|
+
availability, availableAtOrFrom, category, eligibleMembershipType, eligibleSeatingType, eligibleMonetaryAmount, eligibleSubReservation, priceCurrency, validFrom, validThrough, validRateLimit, additionalProperty, identifier, itemOffered } = params.offer;
|
|
84
|
+
return Object.assign(Object.assign({ name, description, alternateName, color, typeOf, id,
|
|
85
|
+
// addOn,
|
|
86
|
+
// availability,
|
|
87
|
+
availableAtOrFrom, category,
|
|
86
88
|
eligibleMembershipType, eligibleSeatingType, eligibleMonetaryAmount, eligibleSubReservation,
|
|
87
89
|
priceCurrency,
|
|
88
90
|
validFrom, validThrough, validRateLimit, additionalProperty,
|
|
89
|
-
identifier, itemOffered, eligibleQuantity: params.eligibleQuantity, priceSpecification: compoundPriceSpecification }, (typeof params.sortIndex === 'number') ? { sortIndex: params.sortIndex } : undefined);
|
|
91
|
+
identifier, itemOffered, addOn: params.addOn, eligibleQuantity: params.eligibleQuantity, priceSpecification: compoundPriceSpecification }, (typeof params.availability === 'string') ? { availability: params.availability } : { availability }), (typeof params.sortIndex === 'number') ? { sortIndex: params.sortIndex } : undefined);
|
|
90
92
|
}
|
|
91
93
|
exports.createCompoundPriceSpec4event = createCompoundPriceSpec4event;
|
package/package.json
CHANGED