@chevre/domain 20.4.0-alpha.13 → 20.4.0-alpha.14
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/example/src/chevre/searchEventTicketOffers.ts +6 -2
- package/example/src/chevre/searchOffersByCatalog.ts +1 -1
- package/lib/chevre/repo/offer.d.ts +4 -1
- package/lib/chevre/repo/offer.js +5 -3
- package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +2 -1
- package/lib/chevre/service/aggregation/event/aggregateUseActionsOnEvent.js +2 -1
- package/lib/chevre/service/assetTransaction/reserve.js +1 -0
- package/lib/chevre/service/offer/event/authorize.js +1 -0
- package/lib/chevre/service/offer/event/searchEventTicketOffers.d.ts +5 -1
- package/lib/chevre/service/offer/event/searchEventTicketOffers.js +48 -27
- package/lib/chevre/service/offer/factory.d.ts +4 -1
- package/lib/chevre/service/offer/factory.js +1 -1
- package/lib/chevre/service/offer/product/searchProductOffers.js +1 -1
- package/package.json +1 -1
|
@@ -24,8 +24,11 @@ async function main() {
|
|
|
24
24
|
const { ticketOffers } = await chevre.service.offer.event.searchEventTicketOffers({
|
|
25
25
|
event: { id: 'ale6qiedf' },
|
|
26
26
|
onlyValid: true,
|
|
27
|
-
sort:
|
|
28
|
-
validateOfferRateLimit: true
|
|
27
|
+
sort: false,
|
|
28
|
+
validateOfferRateLimit: true,
|
|
29
|
+
addSortIndex: true,
|
|
30
|
+
limit: 100,
|
|
31
|
+
page: 1
|
|
29
32
|
// ...(typeof availableAtId === 'string') ? { store: { id: availableAtId } } : undefined
|
|
30
33
|
})({
|
|
31
34
|
event: eventRepo,
|
|
@@ -34,6 +37,7 @@ async function main() {
|
|
|
34
37
|
priceSpecification: priceSpecificationRepo,
|
|
35
38
|
product: productRepo
|
|
36
39
|
});
|
|
40
|
+
console.log(ticketOffers.map((o) => o.sortIndex));
|
|
37
41
|
console.log(ticketOffers.length);
|
|
38
42
|
}
|
|
39
43
|
|
|
@@ -9,7 +9,7 @@ async function main() {
|
|
|
9
9
|
|
|
10
10
|
const offerRepo = new chevre.repository.Offer(mongoose.connection);
|
|
11
11
|
|
|
12
|
-
const offers = await offerRepo.findOffersByOfferCatalogId({
|
|
12
|
+
const { offers } = await offerRepo.findOffersByOfferCatalogId({
|
|
13
13
|
ids: ['al96nqj7z', 'xxx', '1001'],
|
|
14
14
|
// ids: ['xx', 'xxx'],
|
|
15
15
|
offerCatalog: {
|
|
@@ -28,7 +28,10 @@ export declare class MongoRepository {
|
|
|
28
28
|
limit?: number;
|
|
29
29
|
page?: number;
|
|
30
30
|
sort: boolean;
|
|
31
|
-
}): Promise<
|
|
31
|
+
}): Promise<{
|
|
32
|
+
offers: factory.unitPriceOffer.IUnitPriceOffer[];
|
|
33
|
+
sortedOfferIds: string[];
|
|
34
|
+
}>;
|
|
32
35
|
findById(params: {
|
|
33
36
|
id: string;
|
|
34
37
|
}): Promise<factory.unitPriceOffer.IUnitPriceOffer>;
|
package/lib/chevre/repo/offer.js
CHANGED
|
@@ -342,7 +342,7 @@ class MongoRepository {
|
|
|
342
342
|
: [];
|
|
343
343
|
let offers = [];
|
|
344
344
|
if (sortedOfferIds.length > 0) {
|
|
345
|
-
const searchOffersConditions = Object.assign(Object.assign({ id: { $in: sortedOfferIds } }, (typeof ((_a = params.availableAtOrFrom) === null || _a === void 0 ? void 0 : _a.id) === 'string')
|
|
345
|
+
const searchOffersConditions = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ id: { $in: sortedOfferIds } }, (typeof ((_a = params.availableAtOrFrom) === null || _a === void 0 ? void 0 : _a.id) === 'string')
|
|
346
346
|
? { availableAtOrFrom: { id: { $eq: params.availableAtOrFrom.id } } }
|
|
347
347
|
: undefined), { priceSpecification: {
|
|
348
348
|
appliesToMovieTicket: Object.assign(Object.assign({}, (Array.isArray(params.unacceptedPaymentMethod) && params.unacceptedPaymentMethod.length > 0)
|
|
@@ -356,14 +356,16 @@ class MongoRepository {
|
|
|
356
356
|
serviceType: { $exists: false }
|
|
357
357
|
}
|
|
358
358
|
: undefined)
|
|
359
|
-
} })
|
|
359
|
+
} }), (typeof params.limit === 'number' && typeof params.page === 'number')
|
|
360
|
+
? { sort: { _id: factory.sortType.Ascending } }
|
|
361
|
+
: undefined), (typeof params.limit === 'number') ? { limit: params.limit } : undefined), (typeof params.page === 'number') ? { page: params.page } : undefined);
|
|
360
362
|
offers = yield this.search(searchOffersConditions);
|
|
361
363
|
if (params.sort) {
|
|
362
364
|
// sorting
|
|
363
365
|
offers = offers.sort((a, b) => sortedOfferIds.indexOf(String(a.id)) - sortedOfferIds.indexOf(String(b.id)));
|
|
364
366
|
}
|
|
365
367
|
}
|
|
366
|
-
return offers;
|
|
368
|
+
return { offers, sortedOfferIds };
|
|
367
369
|
});
|
|
368
370
|
}
|
|
369
371
|
findById(params) {
|
|
@@ -208,11 +208,12 @@ function findOffers(params) {
|
|
|
208
208
|
if (typeof ((_a = eventOffers === null || eventOffers === void 0 ? void 0 : eventOffers.itemOffered) === null || _a === void 0 ? void 0 : _a.id) === 'string') {
|
|
209
209
|
const eventService = yield repos.product.findById({ id: eventOffers.itemOffered.id });
|
|
210
210
|
if (typeof ((_b = eventService.hasOfferCatalog) === null || _b === void 0 ? void 0 : _b.id) === 'string') {
|
|
211
|
-
|
|
211
|
+
const findOffersByOfferCatalogIdResult = yield repos.offer.findOffersByOfferCatalogId({
|
|
212
212
|
offerCatalog: { id: eventService.hasOfferCatalog.id },
|
|
213
213
|
excludeAppliesToMovieTicket: false,
|
|
214
214
|
sort: false // ソート不要(2023-01-27~)
|
|
215
215
|
});
|
|
216
|
+
availableOffers = findOffersByOfferCatalogIdResult.offers;
|
|
216
217
|
}
|
|
217
218
|
}
|
|
218
219
|
else {
|
|
@@ -91,11 +91,12 @@ function findOffers(params) {
|
|
|
91
91
|
if (typeof ((_a = eventOffers === null || eventOffers === void 0 ? void 0 : eventOffers.itemOffered) === null || _a === void 0 ? void 0 : _a.id) === 'string') {
|
|
92
92
|
const eventService = yield repos.product.findById({ id: eventOffers.itemOffered.id });
|
|
93
93
|
if (typeof ((_b = eventService.hasOfferCatalog) === null || _b === void 0 ? void 0 : _b.id) === 'string') {
|
|
94
|
-
|
|
94
|
+
const findOffersByOfferCatalogIdResult = yield repos.offer.findOffersByOfferCatalogId({
|
|
95
95
|
offerCatalog: { id: eventService.hasOfferCatalog.id },
|
|
96
96
|
excludeAppliesToMovieTicket: false,
|
|
97
97
|
sort: false // ソート不要(2023-01-27~)
|
|
98
98
|
});
|
|
99
|
+
availableOffers = findOffersByOfferCatalogIdResult.offers;
|
|
99
100
|
}
|
|
100
101
|
}
|
|
101
102
|
else {
|
|
@@ -118,6 +118,7 @@ function addReservations(params) {
|
|
|
118
118
|
// 対応アプリケーション条件追加(2023-01-27~)
|
|
119
119
|
store: { id: (_a = params.availableAtOrFrom) === null || _a === void 0 ? void 0 : _a.id },
|
|
120
120
|
sort: false,
|
|
121
|
+
addSortIndex: false,
|
|
121
122
|
validateOfferRateLimit: true
|
|
122
123
|
})(repos);
|
|
123
124
|
ticketOffers = searchEventTicketOffersResult.ticketOffers;
|
|
@@ -13,6 +13,9 @@ interface ISearchEventTicketOffersRepos {
|
|
|
13
13
|
}
|
|
14
14
|
declare type ISearchEventTicketOffersOperation<T> = (repos: ISearchEventTicketOffersRepos) => Promise<T>;
|
|
15
15
|
declare type IAcceptedPaymentMethod = factory.paymentMethod.paymentCard.movieTicket.IMovieTicket;
|
|
16
|
+
declare type ITicketOfferWithSortIndex = factory.product.ITicketOffer & {
|
|
17
|
+
sortIndex?: number;
|
|
18
|
+
};
|
|
16
19
|
/**
|
|
17
20
|
* 興行オファー検索
|
|
18
21
|
*/
|
|
@@ -73,9 +76,10 @@ declare function searchEventTicketOffers(params: {
|
|
|
73
76
|
limit?: number;
|
|
74
77
|
page?: number;
|
|
75
78
|
sort: boolean;
|
|
79
|
+
addSortIndex: boolean;
|
|
76
80
|
validateOfferRateLimit: boolean;
|
|
77
81
|
}): ISearchEventTicketOffersOperation<{
|
|
78
|
-
ticketOffers:
|
|
82
|
+
ticketOffers: ITicketOfferWithSortIndex[];
|
|
79
83
|
unitPriceOffers: factory.unitPriceOffer.IUnitPriceOffer[];
|
|
80
84
|
}>;
|
|
81
85
|
export { searchEventTicketOffers };
|
|
@@ -28,19 +28,21 @@ function searchTransportationEventTicketOffers(params) {
|
|
|
28
28
|
// 上映方式がなければMovieTicket除外(2023-02-21~)
|
|
29
29
|
const excludeAppliesToMovieTicket = videoFormatTypes.length === 0;
|
|
30
30
|
let availableOffers = [];
|
|
31
|
+
let sortedOfferIds = [];
|
|
31
32
|
// 興行設定があれば興行のカタログを参照する(2022-08-31~)
|
|
32
33
|
const eventOffers = screeningEvent.offers;
|
|
33
34
|
if (typeof ((_a = eventOffers === null || eventOffers === void 0 ? void 0 : eventOffers.itemOffered) === null || _a === void 0 ? void 0 : _a.id) === 'string') {
|
|
34
35
|
const transportation = yield repos.product.findById({ id: eventOffers.itemOffered.id });
|
|
35
36
|
if (typeof ((_b = transportation.hasOfferCatalog) === null || _b === void 0 ? void 0 : _b.id) === 'string') {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
37
|
+
const findOffersByOfferCatalogIdResult = yield repos.offer.findOffersByOfferCatalogId(Object.assign({ ids: params.ids, offerCatalog: { id: transportation.hasOfferCatalog.id }, availableAtOrFrom: { id: (_c = params.store) === null || _c === void 0 ? void 0 : _c.id }, unacceptedPaymentMethod,
|
|
38
|
+
excludeAppliesToMovieTicket, sort: params.sort }, (!params.sort)
|
|
39
|
+
? {
|
|
40
|
+
limit: params.limit,
|
|
41
|
+
page: params.page
|
|
42
|
+
}
|
|
43
|
+
: undefined));
|
|
44
|
+
availableOffers = findOffersByOfferCatalogIdResult.offers;
|
|
45
|
+
sortedOfferIds = findOffersByOfferCatalogIdResult.sortedOfferIds;
|
|
44
46
|
}
|
|
45
47
|
}
|
|
46
48
|
else {
|
|
@@ -80,19 +82,26 @@ function searchTransportationEventTicketOffers(params) {
|
|
|
80
82
|
}
|
|
81
83
|
});
|
|
82
84
|
// paging処理を追加(2023-02-21~)
|
|
83
|
-
if (
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
85
|
+
if (params.sort) {
|
|
86
|
+
if (typeof params.limit === 'number' && typeof params.page === 'number') {
|
|
87
|
+
const start = params.limit * (params.page - 1);
|
|
88
|
+
const end = params.limit * params.page;
|
|
89
|
+
availableOffers = availableOffers.slice(start, end);
|
|
90
|
+
}
|
|
87
91
|
}
|
|
88
92
|
let offers4event = availableOffers.map((availableOffer) => {
|
|
93
|
+
let sortIndex;
|
|
94
|
+
if (params.addSortIndex) {
|
|
95
|
+
sortIndex = sortedOfferIds.indexOf(String(availableOffer.id));
|
|
96
|
+
}
|
|
89
97
|
return (0, factory_1.createCompoundPriceSpec4event)({
|
|
90
98
|
eligibleQuantity: eventOffers.eligibleQuantity,
|
|
91
99
|
offer: availableOffer,
|
|
92
100
|
videoFormatChargeSpecifications,
|
|
93
101
|
soundFormatChargeSpecifications,
|
|
94
102
|
movieTicketTypeChargeSpecs,
|
|
95
|
-
videoFormatTypes
|
|
103
|
+
videoFormatTypes,
|
|
104
|
+
sortIndex
|
|
96
105
|
});
|
|
97
106
|
});
|
|
98
107
|
if (params.validateOfferRateLimit) {
|
|
@@ -141,19 +150,21 @@ function searchScreeningEventTicketOffers(params) {
|
|
|
141
150
|
// 上映方式がなければMovieTicket除外(2023-02-21~)
|
|
142
151
|
const excludeAppliesToMovieTicket = videoFormatTypes.length === 0;
|
|
143
152
|
let availableOffers = [];
|
|
153
|
+
let sortedOfferIds = [];
|
|
144
154
|
// 興行設定があれば興行のカタログを参照する(2022-08-31~)
|
|
145
155
|
const eventOffers = screeningEvent.offers;
|
|
146
156
|
if (typeof ((_a = eventOffers === null || eventOffers === void 0 ? void 0 : eventOffers.itemOffered) === null || _a === void 0 ? void 0 : _a.id) === 'string') {
|
|
147
157
|
const eventService = yield repos.product.findById({ id: eventOffers.itemOffered.id });
|
|
148
158
|
if (typeof ((_b = eventService.hasOfferCatalog) === null || _b === void 0 ? void 0 : _b.id) === 'string') {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
159
|
+
const findOffersByOfferCatalogIdResult = yield repos.offer.findOffersByOfferCatalogId(Object.assign({ ids: params.ids, offerCatalog: { id: eventService.hasOfferCatalog.id }, availableAtOrFrom: { id: (_c = params.store) === null || _c === void 0 ? void 0 : _c.id }, unacceptedPaymentMethod,
|
|
160
|
+
excludeAppliesToMovieTicket, sort: params.sort }, (!params.sort)
|
|
161
|
+
? {
|
|
162
|
+
limit: params.limit,
|
|
163
|
+
page: params.page
|
|
164
|
+
}
|
|
165
|
+
: undefined));
|
|
166
|
+
availableOffers = findOffersByOfferCatalogIdResult.offers;
|
|
167
|
+
sortedOfferIds = findOffersByOfferCatalogIdResult.sortedOfferIds;
|
|
157
168
|
}
|
|
158
169
|
}
|
|
159
170
|
else {
|
|
@@ -212,19 +223,26 @@ function searchScreeningEventTicketOffers(params) {
|
|
|
212
223
|
});
|
|
213
224
|
}
|
|
214
225
|
// paging処理を追加(2023-02-21~)
|
|
215
|
-
if (
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
226
|
+
if (params.sort) {
|
|
227
|
+
if (typeof params.limit === 'number' && typeof params.page === 'number') {
|
|
228
|
+
const start = params.limit * (params.page - 1);
|
|
229
|
+
const end = params.limit * params.page;
|
|
230
|
+
availableOffers = availableOffers.slice(start, end);
|
|
231
|
+
}
|
|
219
232
|
}
|
|
220
233
|
let offers4event = availableOffers.map((availableOffer) => {
|
|
234
|
+
let sortIndex;
|
|
235
|
+
if (params.addSortIndex) {
|
|
236
|
+
sortIndex = sortedOfferIds.indexOf(String(availableOffer.id));
|
|
237
|
+
}
|
|
221
238
|
return (0, factory_1.createCompoundPriceSpec4event)({
|
|
222
239
|
eligibleQuantity: eventOffers.eligibleQuantity,
|
|
223
240
|
offer: availableOffer,
|
|
224
241
|
videoFormatChargeSpecifications,
|
|
225
242
|
soundFormatChargeSpecifications,
|
|
226
243
|
movieTicketTypeChargeSpecs,
|
|
227
|
-
videoFormatTypes
|
|
244
|
+
videoFormatTypes,
|
|
245
|
+
sortIndex
|
|
228
246
|
});
|
|
229
247
|
});
|
|
230
248
|
if (params.validateOfferRateLimit) {
|
|
@@ -344,12 +362,13 @@ function searchAddOns(params) {
|
|
|
344
362
|
const productWithAddOns = yield repos.product.findById({ id: productId });
|
|
345
363
|
const offerCatalogId = (_b = productWithAddOns.hasOfferCatalog) === null || _b === void 0 ? void 0 : _b.id;
|
|
346
364
|
if (typeof offerCatalogId === 'string') {
|
|
347
|
-
|
|
365
|
+
const findOffersByOfferCatalogIdResult = yield repos.offer.findOffersByOfferCatalogId({
|
|
348
366
|
offerCatalog: { id: offerCatalogId },
|
|
349
367
|
availableAtOrFrom: { id: (_c = params.store) === null || _c === void 0 ? void 0 : _c.id },
|
|
350
368
|
excludeAppliesToMovieTicket: false,
|
|
351
369
|
sort: true
|
|
352
370
|
});
|
|
371
|
+
offers = findOffersByOfferCatalogIdResult.offers;
|
|
353
372
|
offers = offers.map((o) => {
|
|
354
373
|
return Object.assign(Object.assign({ additionalProperty: Array.isArray(o.additionalProperty) ? o.additionalProperty : [], alternateName: o.alternateName, availability: o.availability, availableAtOrFrom: o.availableAtOrFrom, color: o.color, description: o.description, id: o.id, identifier: o.identifier, itemOffered: {
|
|
355
374
|
description: productWithAddOns.description,
|
|
@@ -400,6 +419,7 @@ function searchEventTicketOffers(params) {
|
|
|
400
419
|
limit: params.limit,
|
|
401
420
|
page: params.page,
|
|
402
421
|
sort: params.sort,
|
|
422
|
+
addSortIndex: params.addSortIndex,
|
|
403
423
|
validateOfferRateLimit: params.validateOfferRateLimit
|
|
404
424
|
})(repos);
|
|
405
425
|
offers = searchOffersResult.ticketOffers;
|
|
@@ -413,6 +433,7 @@ function searchEventTicketOffers(params) {
|
|
|
413
433
|
limit: params.limit,
|
|
414
434
|
page: params.page,
|
|
415
435
|
sort: params.sort,
|
|
436
|
+
addSortIndex: params.addSortIndex,
|
|
416
437
|
validateOfferRateLimit: params.validateOfferRateLimit
|
|
417
438
|
})(repos);
|
|
418
439
|
offers = searchOffersResult.ticketOffers;
|
|
@@ -8,5 +8,8 @@ declare function createCompoundPriceSpec4event(params: {
|
|
|
8
8
|
videoFormatChargeSpecifications: ICategoryCodeChargeSpecification[];
|
|
9
9
|
soundFormatChargeSpecifications: ICategoryCodeChargeSpecification[];
|
|
10
10
|
videoFormatTypes: string[];
|
|
11
|
-
|
|
11
|
+
sortIndex?: number;
|
|
12
|
+
}): factory.product.ITicketOffer & {
|
|
13
|
+
sortIndex?: number;
|
|
14
|
+
};
|
|
12
15
|
export { createCompoundPriceSpec4event };
|
|
@@ -104,6 +104,6 @@ function createCompoundPriceSpec4event(params) {
|
|
|
104
104
|
};
|
|
105
105
|
// 不要な属性を除外(2022-11-07~)
|
|
106
106
|
const _b = params.offer, { project } = _b, unitOfferFields4ticketOffer = __rest(_b, ["project"]);
|
|
107
|
-
return Object.assign(Object.assign({}, unitOfferFields4ticketOffer), { eligibleQuantity: params.eligibleQuantity, priceSpecification: compoundPriceSpecification });
|
|
107
|
+
return Object.assign(Object.assign(Object.assign({}, unitOfferFields4ticketOffer), { eligibleQuantity: params.eligibleQuantity, priceSpecification: compoundPriceSpecification }), (typeof params.sortIndex === 'number') ? { sortIndex: params.sortIndex } : undefined);
|
|
108
108
|
}
|
|
109
109
|
exports.createCompoundPriceSpec4event = createCompoundPriceSpec4event;
|
|
@@ -23,7 +23,7 @@ function searchProductOffers(params) {
|
|
|
23
23
|
if (typeof offerCatalogId !== 'string') {
|
|
24
24
|
return [];
|
|
25
25
|
}
|
|
26
|
-
const offers = yield repos.offer.findOffersByOfferCatalogId({
|
|
26
|
+
const { offers } = yield repos.offer.findOffersByOfferCatalogId({
|
|
27
27
|
offerCatalog: { id: offerCatalogId },
|
|
28
28
|
excludeAppliesToMovieTicket: false,
|
|
29
29
|
sort: params.sort
|
package/package.json
CHANGED