@chevre/domain 20.2.0-alpha.3 → 20.2.0-alpha.5
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.
|
@@ -13,6 +13,116 @@ exports.searchEventTicketOffers = void 0;
|
|
|
13
13
|
const moment = require("moment-timezone");
|
|
14
14
|
const factory = require("../../../factory");
|
|
15
15
|
const factory_1 = require("../factory");
|
|
16
|
+
/**
|
|
17
|
+
* 旅客オファー検索
|
|
18
|
+
*/
|
|
19
|
+
function searchTransportationEventTicketOffers(params) {
|
|
20
|
+
// tslint:disable-next-line:max-func-body-length
|
|
21
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
var _a, _b, _c;
|
|
23
|
+
const screeningEvent = yield repos.event.findById({ id: params.eventId });
|
|
24
|
+
const soundFormatTypes = [];
|
|
25
|
+
const videoFormatTypes = [];
|
|
26
|
+
let availableOffers = [];
|
|
27
|
+
// 興行設定があれば興行のカタログを参照する(2022-08-31~)
|
|
28
|
+
const eventOffers = screeningEvent.offers;
|
|
29
|
+
if (typeof ((_a = eventOffers === null || eventOffers === void 0 ? void 0 : eventOffers.itemOffered) === null || _a === void 0 ? void 0 : _a.id) === 'string') {
|
|
30
|
+
const transportation = yield repos.product.findById({ id: eventOffers.itemOffered.id });
|
|
31
|
+
if (typeof ((_b = transportation.hasOfferCatalog) === null || _b === void 0 ? void 0 : _b.id) === 'string') {
|
|
32
|
+
availableOffers = yield repos.offer.findOffersByOfferCatalogId({
|
|
33
|
+
offerCatalog: { id: transportation.hasOfferCatalog.id }
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
// hasOfferCatalog参照廃止(2022-09-02~)
|
|
39
|
+
throw new factory.errors.NotFound('event.offers.itemOffered.id');
|
|
40
|
+
}
|
|
41
|
+
const { soundFormatChargeSpecifications, videoFormatChargeSpecifications, movieTicketTypeChargeSpecs } = yield searchPriceSpecs4event({ project: { id: screeningEvent.project.id }, soundFormatTypes, videoFormatTypes })(repos);
|
|
42
|
+
const screeningEventOfferSettings = screeningEvent.offers;
|
|
43
|
+
if (screeningEventOfferSettings === undefined) {
|
|
44
|
+
throw new factory.errors.NotFound('event.offers');
|
|
45
|
+
}
|
|
46
|
+
const unacceptedPaymentMethod = getUnacceptedPaymentMethodByEvent({ event: screeningEvent });
|
|
47
|
+
// 不許可決済方法があれば、該当オファーを除外
|
|
48
|
+
if (Array.isArray(unacceptedPaymentMethod) && unacceptedPaymentMethod.length > 0) {
|
|
49
|
+
availableOffers = availableOffers.filter((o) => {
|
|
50
|
+
var _a;
|
|
51
|
+
// 複数決済カード対応(2022-07-11~)
|
|
52
|
+
const priceSpecificationAppliesToMovieTicket = (_a = o.priceSpecification) === null || _a === void 0 ? void 0 : _a.appliesToMovieTicket;
|
|
53
|
+
if (Array.isArray(priceSpecificationAppliesToMovieTicket)) {
|
|
54
|
+
return priceSpecificationAppliesToMovieTicket.every((appliesToMovieTicket) => {
|
|
55
|
+
return !unacceptedPaymentMethod.includes(appliesToMovieTicket.serviceOutput.typeOf);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
// Arrayでないケースは廃止(2022-09-10~)
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
// 適用決済カード条件がある場合、決済カード加算料金が存在しないオファーは除外する
|
|
65
|
+
availableOffers = availableOffers.filter((o) => {
|
|
66
|
+
var _a;
|
|
67
|
+
// 複数決済カード対応(2022-07-26~)
|
|
68
|
+
const priceSpecificationAppliesToMovieTicket = (_a = o.priceSpecification) === null || _a === void 0 ? void 0 : _a.appliesToMovieTicket;
|
|
69
|
+
if (Array.isArray(priceSpecificationAppliesToMovieTicket)) {
|
|
70
|
+
// 適用決済カード数が0であれば除外
|
|
71
|
+
if (priceSpecificationAppliesToMovieTicket.length === 0) {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
// 上映方式がなければ除外(2022-11-03~)
|
|
75
|
+
if (videoFormatTypes.length === 0) {
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
return priceSpecificationAppliesToMovieTicket.every((appliesToMovieTicket) => {
|
|
79
|
+
// すべての上映方式について検証する(2022-10-29~)
|
|
80
|
+
return videoFormatTypes.every((videoFormat) => {
|
|
81
|
+
return movieTicketTypeChargeSpecs.some((s) => {
|
|
82
|
+
var _a, _b, _c, _d;
|
|
83
|
+
return ((_b = (_a = s.appliesToMovieTicket) === null || _a === void 0 ? void 0 : _a.serviceOutput) === null || _b === void 0 ? void 0 : _b.typeOf) === ((_c = appliesToMovieTicket.serviceOutput) === null || _c === void 0 ? void 0 : _c.typeOf)
|
|
84
|
+
&& ((_d = s.appliesToMovieTicket) === null || _d === void 0 ? void 0 : _d.serviceType) === appliesToMovieTicket.serviceType
|
|
85
|
+
&& s.appliesToVideoFormat === videoFormat;
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
// Arrayでないケースは廃止(2022-09-10~)
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
let offers4event = availableOffers.map((availableOffer) => {
|
|
96
|
+
return (0, factory_1.createCompoundPriceSpec4event)({
|
|
97
|
+
eligibleQuantity: screeningEventOfferSettings.eligibleQuantity,
|
|
98
|
+
offer: availableOffer,
|
|
99
|
+
videoFormatChargeSpecifications,
|
|
100
|
+
soundFormatChargeSpecifications,
|
|
101
|
+
movieTicketTypeChargeSpecs,
|
|
102
|
+
videoFormatTypes
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
// レート制限を確認
|
|
106
|
+
offers4event = yield Promise.all(offers4event.map((offer) => __awaiter(this, void 0, void 0, function* () {
|
|
107
|
+
return checkAvailability({ event: screeningEvent, offer })(repos);
|
|
108
|
+
})));
|
|
109
|
+
// アドオン設定があれば、プロダクトオファーを検索
|
|
110
|
+
for (const offer of offers4event) {
|
|
111
|
+
const offerAddOn = [];
|
|
112
|
+
if (Array.isArray(offer.addOn)) {
|
|
113
|
+
for (const addOn of offer.addOn) {
|
|
114
|
+
const productId = (_c = addOn.itemOffered) === null || _c === void 0 ? void 0 : _c.id;
|
|
115
|
+
if (typeof productId === 'string') {
|
|
116
|
+
const productOffers = yield searchAddOns({ product: { id: productId } })(repos);
|
|
117
|
+
offerAddOn.push(...productOffers);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
offer.addOn = offerAddOn;
|
|
122
|
+
}
|
|
123
|
+
return offers4event;
|
|
124
|
+
});
|
|
125
|
+
}
|
|
16
126
|
/**
|
|
17
127
|
* 興行オファー全検索
|
|
18
128
|
*/
|
|
@@ -243,9 +353,7 @@ function searchEventTicketOffers(params) {
|
|
|
243
353
|
var _a;
|
|
244
354
|
const now = moment();
|
|
245
355
|
let event;
|
|
246
|
-
event = yield repos.event.findById({
|
|
247
|
-
id: params.event.id
|
|
248
|
-
});
|
|
356
|
+
event = yield repos.event.findById({ id: params.event.id });
|
|
249
357
|
let offers;
|
|
250
358
|
const eventOffers = event.offers;
|
|
251
359
|
if (eventOffers === undefined) {
|
|
@@ -259,7 +367,15 @@ function searchEventTicketOffers(params) {
|
|
|
259
367
|
throw new factory.errors.NotImplemented(`booking service '${eventOffers.offeredThrough.identifier}' not implemented`);
|
|
260
368
|
default:
|
|
261
369
|
// Chevreで券種オファーを検索
|
|
262
|
-
|
|
370
|
+
if (event.typeOf === factory.eventType.ScreeningEvent) {
|
|
371
|
+
offers = yield searchScreeningEventTicketOffers({ eventId: params.event.id })(repos);
|
|
372
|
+
}
|
|
373
|
+
else if (event.typeOf === factory.eventType.Event) {
|
|
374
|
+
offers = yield searchTransportationEventTicketOffers({ eventId: params.event.id })(repos);
|
|
375
|
+
}
|
|
376
|
+
else {
|
|
377
|
+
throw new factory.errors.NotImplemented(`'${event.typeOf}' not implemented`);
|
|
378
|
+
}
|
|
263
379
|
const specifiedStoreId = (_a = params.store) === null || _a === void 0 ? void 0 : _a.id;
|
|
264
380
|
if (typeof specifiedStoreId === 'string') {
|
|
265
381
|
// アプリケーションが利用可能なオファーに絞る
|
|
@@ -135,31 +135,35 @@ function searchEventSeatOffersWithPaging(params) {
|
|
|
135
135
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
136
136
|
var _a, _b, _c, _d, _e, _f;
|
|
137
137
|
let offers = [];
|
|
138
|
-
const
|
|
138
|
+
const event = yield repos.event.findById({
|
|
139
139
|
id: params.event.id
|
|
140
140
|
});
|
|
141
141
|
// 座席指定利用可能かどうか
|
|
142
|
-
const eventOffers =
|
|
142
|
+
const eventOffers = event.offers;
|
|
143
143
|
const reservedSeatsAvailable = ((_b = (_a = eventOffers === null || eventOffers === void 0 ? void 0 : eventOffers.itemOffered.serviceOutput) === null || _a === void 0 ? void 0 : _a.reservedTicket) === null || _b === void 0 ? void 0 : _b.ticketedSeat) !== undefined;
|
|
144
144
|
if (reservedSeatsAvailable) {
|
|
145
145
|
// 座席タイプ価格仕様を検索
|
|
146
146
|
const priceSpecs = yield repos.priceSpecification.search({
|
|
147
|
-
project: { id: { $eq:
|
|
147
|
+
project: { id: { $eq: event.project.id } },
|
|
148
148
|
typeOf: factory.priceSpecificationType.CategoryCodeChargeSpecification,
|
|
149
149
|
appliesToCategoryCode: {
|
|
150
150
|
inCodeSet: { identifier: { $eq: factory.categoryCode.CategorySetIdentifier.SeatingType } }
|
|
151
151
|
}
|
|
152
152
|
});
|
|
153
|
-
const
|
|
153
|
+
// const roomBranchCode = event.location.branchCode;
|
|
154
|
+
// const movieTheaterBranchCode = event.superEvent.location.branchCode;
|
|
155
|
+
const roomBranchCode = eventOffers.itemOffered.availableChannel.serviceLocation.branchCode;
|
|
156
|
+
const movieTheaterBranchCode = eventOffers.itemOffered.availableChannel.serviceLocation.containedInPlace.branchCode;
|
|
157
|
+
const seats = yield repos.place.searchSeats(Object.assign(Object.assign({}, params), { project: { id: { $eq: event.project.id } }, containedInPlace: {
|
|
154
158
|
branchCode: {
|
|
155
159
|
$eq: (typeof ((_d = (_c = params.containedInPlace) === null || _c === void 0 ? void 0 : _c.branchCode) === null || _d === void 0 ? void 0 : _d.$eq) === 'string')
|
|
156
160
|
? (_f = (_e = params.containedInPlace) === null || _e === void 0 ? void 0 : _e.branchCode) === null || _f === void 0 ? void 0 : _f.$eq
|
|
157
161
|
: undefined
|
|
158
162
|
},
|
|
159
163
|
containedInPlace: {
|
|
160
|
-
branchCode: { $eq:
|
|
164
|
+
branchCode: { $eq: roomBranchCode },
|
|
161
165
|
containedInPlace: {
|
|
162
|
-
branchCode: { $eq:
|
|
166
|
+
branchCode: { $eq: movieTheaterBranchCode }
|
|
163
167
|
}
|
|
164
168
|
}
|
|
165
169
|
} }));
|
|
@@ -177,7 +181,7 @@ function searchEventSeatOffersWithPaging(params) {
|
|
|
177
181
|
offers = seats.map((seat, index) => {
|
|
178
182
|
var _a;
|
|
179
183
|
return addOffers2Seat({
|
|
180
|
-
project:
|
|
184
|
+
project: event.project,
|
|
181
185
|
seat: seat,
|
|
182
186
|
seatSection: (_a = seat.containedInPlace) === null || _a === void 0 ? void 0 : _a.branchCode,
|
|
183
187
|
unavailableOffers: [],
|
package/package.json
CHANGED