@chevre/domain 20.4.0-alpha.33 → 20.4.0-alpha.35
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/deleteTasksByName.ts +1 -1
- package/example/src/chevre/searchEventTicketOffers.ts +3 -2
- package/example/src/chevre/searchProductOffers.ts +38 -0
- package/lib/chevre/service/assetTransaction/reserve.js +42 -64
- package/lib/chevre/service/offer/event/authorize.js +1 -1
- package/lib/chevre/service/offer/event/searchEventTicketOffers.js +60 -41
- package/lib/chevre/service/offer/factory.d.ts +2 -2
- package/lib/chevre/service/offer/factory.js +2 -2
- package/package.json +1 -1
|
@@ -11,7 +11,7 @@ async function main() {
|
|
|
11
11
|
const taskRepo = new chevre.repository.Task(mongoose.connection);
|
|
12
12
|
|
|
13
13
|
const result = await taskRepo.deleteByName({
|
|
14
|
-
name: <any>'
|
|
14
|
+
name: <any>'deleteAuthorization'
|
|
15
15
|
});
|
|
16
16
|
|
|
17
17
|
console.log('deleted', result);
|
|
@@ -22,12 +22,13 @@ async function main() {
|
|
|
22
22
|
const productRepo = new chevre.repository.Product(mongoose.connection);
|
|
23
23
|
|
|
24
24
|
const { ticketOffers } = await chevre.service.offer.event.searchEventTicketOffers({
|
|
25
|
-
event: { id: '
|
|
25
|
+
event: { id: 'ale6qiedq' },
|
|
26
26
|
onlyValid: true,
|
|
27
27
|
validateOfferRateLimit: true,
|
|
28
28
|
addSortIndex: true,
|
|
29
29
|
limit: 100,
|
|
30
|
-
page: 1
|
|
30
|
+
page: 1,
|
|
31
|
+
searchAddOns: true
|
|
31
32
|
// ...(typeof availableAtId === 'string') ? { store: { id: availableAtId } } : undefined
|
|
32
33
|
})({
|
|
33
34
|
event: eventRepo,
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../lib/index';
|
|
5
|
+
|
|
6
|
+
const PROJECT_ID = process.env.PROJECT_ID;
|
|
7
|
+
|
|
8
|
+
async function main() {
|
|
9
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
10
|
+
|
|
11
|
+
const offerRepo = new chevre.repository.Offer(mongoose.connection);
|
|
12
|
+
const productRepo = new chevre.repository.Product(mongoose.connection);
|
|
13
|
+
|
|
14
|
+
const { offers } = await chevre.service.offer.product.search({
|
|
15
|
+
ids: ['7k7bbepxp', 'yyyyyy'],
|
|
16
|
+
project: { id: String(PROJECT_ID) },
|
|
17
|
+
itemOffered: { id: '62b90fef5b3eb4000b75150f' },
|
|
18
|
+
// seller?: {
|
|
19
|
+
// id: string;
|
|
20
|
+
// },
|
|
21
|
+
// availableAt?: {
|
|
22
|
+
// id: string;
|
|
23
|
+
// },
|
|
24
|
+
onlyValid: true,
|
|
25
|
+
// limit?: number,
|
|
26
|
+
// page?: number,
|
|
27
|
+
addSortIndex: false
|
|
28
|
+
})({
|
|
29
|
+
offer: offerRepo,
|
|
30
|
+
product: productRepo
|
|
31
|
+
});
|
|
32
|
+
console.log(offers.map((o) => `${o.sortIndex} ${o.id}`));
|
|
33
|
+
console.log(offers.length);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
main()
|
|
37
|
+
.then(console.log)
|
|
38
|
+
.catch(console.error);
|
|
@@ -120,7 +120,7 @@ function addReservations(params) {
|
|
|
120
120
|
onlyValid: true,
|
|
121
121
|
addSortIndex: false,
|
|
122
122
|
validateOfferRateLimit: true,
|
|
123
|
-
searchAddOns:
|
|
123
|
+
searchAddOns: false // false化(2023-03-02~)
|
|
124
124
|
})(repos);
|
|
125
125
|
ticketOffers = searchEventTicketOffersResult.ticketOffers;
|
|
126
126
|
availableOffers = searchEventTicketOffersResult.unitPriceOffers;
|
|
@@ -310,12 +310,16 @@ function createReservations4transactionObject(params) {
|
|
|
310
310
|
let acceptedAddOns = [];
|
|
311
311
|
let availableAddOns;
|
|
312
312
|
const acceptedAddOnParams = acceptedOffer.addOn;
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
313
|
+
if (Array.isArray(acceptedAddOnParams) && acceptedAddOnParams.length > 0) {
|
|
314
|
+
// アドオンオファー検索(2023-03-02~)
|
|
315
|
+
availableAddOns = yield searchAvailableAddOns({
|
|
316
|
+
ids: acceptedAddOnParams.map((acceptedAddOn) => String(acceptedAddOn.id)),
|
|
317
|
+
project: { id: params.transaction.project.id },
|
|
318
|
+
ticketOffer,
|
|
319
|
+
availableAtOrFrom: params.availableAtOrFrom
|
|
320
|
+
})(repos);
|
|
321
|
+
}
|
|
322
|
+
// availableAddOns = <factory.product.ITicketAddOn[] | undefined>ticketOffer.addOn;
|
|
319
323
|
if (Array.isArray(availableAddOns) && Array.isArray(acceptedAddOnParams)) {
|
|
320
324
|
acceptedAddOns = availableAddOns.filter((availableAddOn) => acceptedAddOnParams.some((acceptedAddOn) => availableAddOn.id === acceptedAddOn.id));
|
|
321
325
|
}
|
|
@@ -345,63 +349,37 @@ function createReservations4transactionObject(params) {
|
|
|
345
349
|
return reservations;
|
|
346
350
|
});
|
|
347
351
|
}
|
|
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
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
// const unitPriceSpec = o.priceSpecification.priceComponent.find((component) => {
|
|
380
|
-
// return component.typeOf === factory.priceSpecificationType.UnitPriceSpecification;
|
|
381
|
-
// });
|
|
382
|
-
// if (unitPriceSpec?.typeOf !== factory.priceSpecificationType.UnitPriceSpecification) {
|
|
383
|
-
// throw new factory.errors.NotFound('UnitPriceSpecification of an addOn');
|
|
384
|
-
// }
|
|
385
|
-
// return {
|
|
386
|
-
// alternateName: o.alternateName,
|
|
387
|
-
// availability: o.availability,
|
|
388
|
-
// description: o.description,
|
|
389
|
-
// id: String(o.id),
|
|
390
|
-
// identifier: o.identifier,
|
|
391
|
-
// itemOffered: itemOffered4addOn,
|
|
392
|
-
// name: o.name,
|
|
393
|
-
// priceCurrency: o.priceCurrency,
|
|
394
|
-
// priceSpecification: unitPriceSpec,
|
|
395
|
-
// typeOf: o.typeOf,
|
|
396
|
-
// ...(o.validFrom instanceof Date) ? { validFrom: o.validFrom } : undefined,
|
|
397
|
-
// ...(o.validThrough instanceof Date) ? { validThrough: o.validThrough } : undefined
|
|
398
|
-
// };
|
|
399
|
-
// }));
|
|
400
|
-
// }
|
|
401
|
-
// }
|
|
402
|
-
// return availableAddOns;
|
|
403
|
-
// };
|
|
404
|
-
// }
|
|
352
|
+
function searchAvailableAddOns(params) {
|
|
353
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
354
|
+
var _a;
|
|
355
|
+
const availableAddOns = [];
|
|
356
|
+
if (Array.isArray(params.ticketOffer.addOn)) {
|
|
357
|
+
const addOnProductIds = [...new Set(params.ticketOffer.addOn.map((o) => String(o.itemOffered.id)))];
|
|
358
|
+
for (const addOnProductId of addOnProductIds) {
|
|
359
|
+
const { offers, product } = yield OfferService.product.search(Object.assign({ ids: params.ids, project: { id: params.project.id }, itemOffered: { id: addOnProductId }, onlyValid: true, addSortIndex: false }, (typeof ((_a = params.availableAtOrFrom) === null || _a === void 0 ? void 0 : _a.id) === 'string')
|
|
360
|
+
? { availableAt: { id: params.availableAtOrFrom.id } }
|
|
361
|
+
: undefined))(repos);
|
|
362
|
+
availableAddOns.push(...offers.map((o) => {
|
|
363
|
+
const itemOffered4addOn = {
|
|
364
|
+
description: product.description,
|
|
365
|
+
id: product.id,
|
|
366
|
+
name: product.name,
|
|
367
|
+
productID: product.productID,
|
|
368
|
+
typeOf: product.typeOf
|
|
369
|
+
};
|
|
370
|
+
const unitPriceSpec = o.priceSpecification.priceComponent.find((component) => {
|
|
371
|
+
return component.typeOf === factory.priceSpecificationType.UnitPriceSpecification;
|
|
372
|
+
});
|
|
373
|
+
if ((unitPriceSpec === null || unitPriceSpec === void 0 ? void 0 : unitPriceSpec.typeOf) !== factory.priceSpecificationType.UnitPriceSpecification) {
|
|
374
|
+
throw new factory.errors.NotFound('UnitPriceSpecification of an addOn');
|
|
375
|
+
}
|
|
376
|
+
return Object.assign(Object.assign({ alternateName: o.alternateName, availability: o.availability, description: o.description, id: String(o.id), identifier: o.identifier, itemOffered: itemOffered4addOn, name: o.name, priceCurrency: o.priceCurrency, priceSpecification: unitPriceSpec, typeOf: o.typeOf }, (o.validFrom instanceof Date) ? { validFrom: o.validFrom } : undefined), (o.validThrough instanceof Date) ? { validThrough: o.validThrough } : undefined);
|
|
377
|
+
}));
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
return availableAddOns;
|
|
381
|
+
});
|
|
382
|
+
}
|
|
405
383
|
function getAcceptedSeatNumbersAndSeatSections(params) {
|
|
406
384
|
const acceptedSeatNumbers = [];
|
|
407
385
|
const acceptedSeatSections = [];
|
|
@@ -227,7 +227,7 @@ function validateAcceptedOffers(params) {
|
|
|
227
227
|
onlyValid: true,
|
|
228
228
|
addSortIndex: false,
|
|
229
229
|
validateOfferRateLimit: true,
|
|
230
|
-
searchAddOns:
|
|
230
|
+
searchAddOns: false // false化(2023-03-02~)
|
|
231
231
|
})(repos);
|
|
232
232
|
// 利用可能なチケットオファーであれば受け入れる
|
|
233
233
|
const acceptedOffers = (Array.isArray(acceptedOffersWithoutDetail))
|
|
@@ -26,7 +26,7 @@ function searchTicketOffersByItemOffered(params) {
|
|
|
26
26
|
if (typeof catalogId !== 'string') {
|
|
27
27
|
throw new factory.errors.NotFound('itemOffered.hasOfferCatalog');
|
|
28
28
|
}
|
|
29
|
-
const
|
|
29
|
+
const { offers, sortedOfferIds } = yield repos.offer.findOffersByOfferCatalogId({
|
|
30
30
|
ids: params.ids,
|
|
31
31
|
offerCatalog: { id: catalogId },
|
|
32
32
|
availableAtOrFrom: { id: (_d = params.store) === null || _d === void 0 ? void 0 : _d.id },
|
|
@@ -38,9 +38,7 @@ function searchTicketOffersByItemOffered(params) {
|
|
|
38
38
|
page: params.page,
|
|
39
39
|
sort: false
|
|
40
40
|
});
|
|
41
|
-
|
|
42
|
-
const sortedOfferIds = findOffersByOfferCatalogIdResult.sortedOfferIds;
|
|
43
|
-
return { availableOffers, sortedOfferIds };
|
|
41
|
+
return { availableOffers: offers, sortedOfferIds };
|
|
44
42
|
});
|
|
45
43
|
}
|
|
46
44
|
/**
|
|
@@ -74,10 +72,13 @@ function searchEventTicketOffersByEvent(params) {
|
|
|
74
72
|
unacceptedPaymentMethod,
|
|
75
73
|
excludeAppliesToMovieTicket
|
|
76
74
|
})(repos);
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
75
|
+
// 冗長な検索について最適化(2023-03-03~)
|
|
76
|
+
const { soundFormatChargeSpecs, videoFormatChargeSpecs, movieTicketTypeChargeSpecs } = yield searchPriceSpecs4event({
|
|
77
|
+
project: { id: event.project.id },
|
|
78
|
+
soundFormatTypes,
|
|
79
|
+
videoFormatTypes,
|
|
80
|
+
availableOffers
|
|
81
|
+
})(repos);
|
|
81
82
|
const offers4event = [];
|
|
82
83
|
// 単価オファーから興行オファーを生成(順に処理)
|
|
83
84
|
for (const availableOffer of availableOffers) {
|
|
@@ -114,8 +115,8 @@ function searchEventTicketOffersByEvent(params) {
|
|
|
114
115
|
offers4event.push((0, factory_1.createCompoundPriceSpec4event)({
|
|
115
116
|
eligibleQuantity: eventOffers.eligibleQuantity,
|
|
116
117
|
offer: availableOffer,
|
|
117
|
-
|
|
118
|
-
|
|
118
|
+
videoFormatChargeSpecs,
|
|
119
|
+
soundFormatChargeSpecs,
|
|
119
120
|
movieTicketTypeChargeSpecs,
|
|
120
121
|
videoFormatTypes,
|
|
121
122
|
availability,
|
|
@@ -134,7 +135,6 @@ function getUnacceptedPaymentMethodByEvent(params) {
|
|
|
134
135
|
const eventOffers = params.event.offers;
|
|
135
136
|
const unacceptedPaymentMethodByEvent = eventOffers === null || eventOffers === void 0 ? void 0 : eventOffers.unacceptedPaymentMethod;
|
|
136
137
|
// 施設コンテンツを参照する必要はない(2022-10-31~)
|
|
137
|
-
// イベントにunacceptedPaymentMethod設定があれば上書き
|
|
138
138
|
if (Array.isArray(unacceptedPaymentMethodByEvent)) {
|
|
139
139
|
unacceptedPaymentMethod = unacceptedPaymentMethodByEvent;
|
|
140
140
|
}
|
|
@@ -142,38 +142,57 @@ function getUnacceptedPaymentMethodByEvent(params) {
|
|
|
142
142
|
}
|
|
143
143
|
function searchPriceSpecs4event(params) {
|
|
144
144
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
codeValue: { $in: params.soundFormatTypes },
|
|
152
|
-
'inCodeSet.identifier': { $eq: factory.categoryCode.CategorySetIdentifier.SoundFormatType }
|
|
153
|
-
}
|
|
145
|
+
let soundFormatChargeSpecs = [];
|
|
146
|
+
let videoFormatChargeSpecs = [];
|
|
147
|
+
let movieTicketTypeChargeSpecs = [];
|
|
148
|
+
const movieTicketServiceTypes = [...new Set(params.availableOffers.reduce((a, b) => {
|
|
149
|
+
if (!Array.isArray(b.priceSpecification.appliesToMovieTicket)) {
|
|
150
|
+
return a;
|
|
154
151
|
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
152
|
+
return [
|
|
153
|
+
...a,
|
|
154
|
+
...b.priceSpecification.appliesToMovieTicket.map((movieTicket) => movieTicket.serviceType)
|
|
155
|
+
];
|
|
156
|
+
}, []))];
|
|
157
|
+
if (params.soundFormatTypes.length > 0) {
|
|
158
|
+
soundFormatChargeSpecs =
|
|
159
|
+
yield repos.priceSpecification.search({
|
|
160
|
+
project: { id: { $eq: params.project.id } },
|
|
161
|
+
typeOf: factory.priceSpecificationType.CategoryCodeChargeSpecification,
|
|
162
|
+
appliesToCategoryCode: {
|
|
163
|
+
$elemMatch: {
|
|
164
|
+
codeValue: { $in: params.soundFormatTypes },
|
|
165
|
+
'inCodeSet.identifier': { $eq: factory.categoryCode.CategorySetIdentifier.SoundFormatType }
|
|
166
|
+
}
|
|
165
167
|
}
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
if ((params.videoFormatTypes.length > 0)) {
|
|
171
|
+
videoFormatChargeSpecs =
|
|
172
|
+
yield repos.priceSpecification.search({
|
|
173
|
+
project: { id: { $eq: params.project.id } },
|
|
174
|
+
typeOf: factory.priceSpecificationType.CategoryCodeChargeSpecification,
|
|
175
|
+
appliesToCategoryCode: {
|
|
176
|
+
$elemMatch: {
|
|
177
|
+
codeValue: { $in: params.videoFormatTypes },
|
|
178
|
+
'inCodeSet.identifier': { $eq: factory.categoryCode.CategorySetIdentifier.VideoFormatType }
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
// 存在する適用決済カード区分の分だけ検索する(2023-03-03~)
|
|
183
|
+
if (movieTicketServiceTypes.length > 0) {
|
|
184
|
+
movieTicketTypeChargeSpecs =
|
|
185
|
+
yield repos.priceSpecification.search({
|
|
186
|
+
project: { id: { $eq: params.project.id } },
|
|
187
|
+
typeOf: factory.priceSpecificationType.MovieTicketTypeChargeSpecification,
|
|
188
|
+
appliesToVideoFormats: params.videoFormatTypes,
|
|
189
|
+
appliesToMovieTicket: {
|
|
190
|
+
serviceTypes: movieTicketServiceTypes
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
return { soundFormatChargeSpecs, videoFormatChargeSpecs, movieTicketTypeChargeSpecs };
|
|
177
196
|
});
|
|
178
197
|
}
|
|
179
198
|
function checkAvailability(params) {
|
|
@@ -5,8 +5,8 @@ declare function createCompoundPriceSpec4event(params: {
|
|
|
5
5
|
eligibleQuantity: factory.quantitativeValue.IQuantitativeValue<factory.unitCode.C62>;
|
|
6
6
|
offer: factory.unitPriceOffer.IUnitPriceOffer;
|
|
7
7
|
movieTicketTypeChargeSpecs: IMovieTicketTypeChargeSpecification[];
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
videoFormatChargeSpecs: ICategoryCodeChargeSpecification[];
|
|
9
|
+
soundFormatChargeSpecs: ICategoryCodeChargeSpecification[];
|
|
10
10
|
videoFormatTypes: string[];
|
|
11
11
|
availability?: factory.itemAvailability;
|
|
12
12
|
addOn: factory.product.ITicketAddOn[] | factory.product.IMinimizedTicketAddOn[];
|
|
@@ -23,8 +23,8 @@ function createCompoundPriceSpec4event(params) {
|
|
|
23
23
|
// 区分加算料金を適用しないオプションを追加(2023-01-26~)
|
|
24
24
|
const ignoreCategoryCodeChargeSpec = ((_a = params.offer.settings) === null || _a === void 0 ? void 0 : _a.ignoreCategoryCodeChargeSpec) === true;
|
|
25
25
|
if (!ignoreCategoryCodeChargeSpec) {
|
|
26
|
-
videoFormatChargeSpecComponents = params.
|
|
27
|
-
soundFormatChargeSpecComponents = params.
|
|
26
|
+
videoFormatChargeSpecComponents = params.videoFormatChargeSpecs.map(categoryCodeChargePriceSpec2component);
|
|
27
|
+
soundFormatChargeSpecComponents = params.soundFormatChargeSpecs.map(categoryCodeChargePriceSpec2component);
|
|
28
28
|
}
|
|
29
29
|
const mvtkPriceComponents = [];
|
|
30
30
|
// 複数決済カード対応(2022-07-11~)
|
package/package.json
CHANGED