@chevre/domain 21.8.0-alpha.8 → 21.8.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/example/src/chevre/countOffers.ts +32 -0
- package/example/src/chevre/findItemListElementByCatalogId.ts +30 -0
- package/example/src/chevre/importOffersFromCOA.ts +7 -1
- package/example/src/chevre/migrateOrderPaymentMethodIdentifier.ts +81 -0
- package/example/src/chevre/migratePayTransactionPaymentMethodId.ts +72 -0
- package/example/src/chevre/migratePayTransactionPaymentMethodIdentifier.ts +78 -0
- package/example/src/chevre/optimizeCatalogs.ts +54 -0
- package/example/src/chevre/processPay.ts +3 -4
- package/example/src/chevre/publishPermitOwnershipInfoToken.ts +56 -0
- package/example/src/chevre/pullAddOnsFromOffer.ts +26 -0
- package/example/src/chevre/pushIncludedInDataCatalog.ts +47 -0
- package/example/src/chevre/searchAggregateOffers.ts +48 -0
- package/example/src/chevre/searchEventTicketOffers.ts +5 -1
- package/example/src/chevre/searchEvents.ts +9 -7
- package/example/src/chevre/searchOfferCatalogs.ts +7 -3
- package/example/src/chevre/searchOffers.ts +5 -2
- package/example/src/chevre/searchOffersByCatalog.ts +15 -9
- package/example/src/chevre/searchOffersFromAggregateOffer.ts +168 -0
- package/example/src/chevre/searchOrders.ts +9 -7
- package/example/src/chevre/syncCatalogs2aggregateOffers.ts +85 -0
- package/lib/chevre/emailMessageBuilder.js +6 -5
- package/lib/chevre/repo/aggregateOffer.d.ts +62 -0
- package/lib/chevre/repo/aggregateOffer.js +562 -0
- package/lib/chevre/repo/assetTransaction.d.ts +16 -1
- package/lib/chevre/repo/assetTransaction.js +54 -2
- package/lib/chevre/repo/mongoose/schemas/aggregateOffer.d.ts +74 -0
- package/lib/chevre/repo/mongoose/schemas/aggregateOffer.js +189 -0
- package/lib/chevre/repo/mongoose/schemas/authorization.d.ts +3 -3
- package/lib/chevre/repo/mongoose/schemas/creativeWork.d.ts +3 -3
- package/lib/chevre/repo/mongoose/schemas/event.d.ts +3 -3
- package/lib/chevre/repo/mongoose/schemas/offerCatalog.d.ts +3 -0
- package/lib/chevre/repo/mongoose/schemas/offerCatalog.js +10 -1
- package/lib/chevre/repo/mongoose/schemas/order.d.ts +3 -0
- package/lib/chevre/repo/mongoose/schemas/order.js +7 -0
- package/lib/chevre/repo/mongoose/schemas/priceSpecification.d.ts +9 -9
- package/lib/chevre/repo/mongoose/schemas/product.d.ts +3 -3
- package/lib/chevre/repo/mongoose/schemas/project.d.ts +3 -3
- package/lib/chevre/repo/mongoose/schemas/task.d.ts +3 -0
- package/lib/chevre/repo/mongoose/schemas/task.js +8 -0
- package/lib/chevre/repo/offer.d.ts +87 -51
- package/lib/chevre/repo/offer.js +513 -283
- package/lib/chevre/repo/offerCatalog.d.ts +32 -3
- package/lib/chevre/repo/offerCatalog.js +97 -10
- package/lib/chevre/repo/order.d.ts +15 -0
- package/lib/chevre/repo/order.js +58 -26
- package/lib/chevre/repo/task.d.ts +6 -2
- package/lib/chevre/repo/task.js +58 -4
- package/lib/chevre/repository.d.ts +3 -0
- package/lib/chevre/repository.js +5 -1
- package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +3 -41
- package/lib/chevre/service/aggregation/event/aggregateUseActionsOnEvent.d.ts +2 -0
- package/lib/chevre/service/aggregation/event/aggregateUseActionsOnEvent.js +2 -40
- package/lib/chevre/service/aggregation/event/findEventOffers.d.ts +16 -0
- package/lib/chevre/service/aggregation/event/findEventOffers.js +58 -0
- package/lib/chevre/service/assetTransaction/pay/account/validation.js +2 -2
- package/lib/chevre/service/assetTransaction/pay/factory.js +26 -18
- package/lib/chevre/service/assetTransaction/pay/potentialActions.js +3 -3
- package/lib/chevre/service/assetTransaction/pay.js +65 -46
- package/lib/chevre/service/assetTransaction/refund/factory.js +8 -2
- package/lib/chevre/service/assetTransaction/registerService.js +2 -1
- package/lib/chevre/service/assetTransaction/reserve.js +111 -35
- package/lib/chevre/service/offer/event/authorize.js +39 -35
- package/lib/chevre/service/offer/event/factory.d.ts +1 -1
- package/lib/chevre/service/offer/event/factory.js +8 -8
- package/lib/chevre/service/offer/event/importFromCOA.d.ts +2 -0
- package/lib/chevre/service/offer/event/searchEventTicketOffers.d.ts +3 -0
- package/lib/chevre/service/offer/event/searchEventTicketOffers.js +48 -17
- package/lib/chevre/service/offer/event/voidTransaction.js +57 -36
- package/lib/chevre/service/offer/eventServiceByCOA/factory.d.ts +2 -1
- package/lib/chevre/service/offer/eventServiceByCOA/factory.js +7 -11
- package/lib/chevre/service/offer/eventServiceByCOA.js +55 -27
- package/lib/chevre/service/offer/factory.d.ts +12 -4
- package/lib/chevre/service/offer/factory.js +9 -11
- package/lib/chevre/service/offer/product/searchProductOffers.d.ts +10 -1
- package/lib/chevre/service/offer/product/searchProductOffers.js +51 -12
- package/lib/chevre/service/offer/product.d.ts +2 -0
- package/lib/chevre/service/offer/product.js +3 -2
- package/lib/chevre/service/offer.d.ts +1 -0
- package/lib/chevre/service/offer.js +7 -1
- package/lib/chevre/service/order/confirmPayTransaction.d.ts +0 -2
- package/lib/chevre/service/order/confirmPayTransaction.js +20 -42
- package/lib/chevre/service/order/onAssetTransactionStatusChanged.d.ts +27 -0
- package/lib/chevre/service/order/onAssetTransactionStatusChanged.js +226 -0
- package/lib/chevre/service/order/onOrderStatusChanged/factory.d.ts +8 -6
- package/lib/chevre/service/order/onOrderStatusChanged/factory.js +80 -57
- package/lib/chevre/service/order/onOrderStatusChanged.js +52 -9
- package/lib/chevre/service/order/payOrder.js +4 -45
- package/lib/chevre/service/order/placeOrder.js +11 -24
- package/lib/chevre/service/order.d.ts +3 -1
- package/lib/chevre/service/order.js +6 -2
- package/lib/chevre/service/payment/any/factory.js +33 -8
- package/lib/chevre/service/payment/any.js +30 -21
- package/lib/chevre/service/payment/creditCard.js +12 -12
- package/lib/chevre/service/payment/movieTicket/validation.js +2 -2
- package/lib/chevre/service/payment/movieTicket.js +10 -11
- package/lib/chevre/service/payment/paymentCard.js +9 -12
- package/lib/chevre/service/project.js +1 -1
- package/lib/chevre/service/reserve/checkInReservation.d.ts +8 -0
- package/lib/chevre/service/reserve/checkInReservation.js +3 -2
- package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.d.ts +3 -0
- package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.js +4 -5
- package/lib/chevre/service/reserve/potentialActions/onReservationCheckedIn.d.ts +8 -0
- package/lib/chevre/service/reserve/potentialActions/onReservationCheckedIn.js +16 -11
- package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.js +2 -1
- package/lib/chevre/service/reserve/potentialActions/onReservationUsed.d.ts +3 -0
- package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +3 -5
- package/lib/chevre/service/task/aggregateUseActionsOnEvent.js +2 -0
- package/lib/chevre/service/task/confirmPayTransaction.js +1 -3
- package/lib/chevre/service/task/importOffersFromCOA.js +3 -0
- package/lib/chevre/service/task/onAssetTransactionStatusChanged.d.ts +6 -0
- package/lib/chevre/service/task/onAssetTransactionStatusChanged.js +37 -0
- package/lib/chevre/service/task/onAuthorizationCreated.js +5 -1
- package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.d.ts +2 -0
- package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.js +7 -0
- package/lib/chevre/service/task/onResourceUpdated/syncOfferCatalog.d.ts +17 -0
- package/lib/chevre/service/task/onResourceUpdated/syncOfferCatalog.js +78 -0
- package/lib/chevre/service/task/onResourceUpdated.js +12 -0
- package/lib/chevre/service/task/returnPayTransaction.js +8 -3
- package/lib/chevre/service/transaction/placeOrderInProgress/result.js +32 -16
- package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateMovieTicket.js +13 -11
- package/lib/chevre/service/transaction/placeOrderInProgress/validation.js +53 -17
- package/lib/chevre/service/transaction/placeOrderInProgress.js +4 -1
- package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPaymentMethod.js +7 -6
- package/lib/chevre/service/transaction/returnOrder.js +5 -1
- package/lib/chevre/settings.d.ts +3 -3
- package/lib/chevre/settings.js +4 -12
- package/package.json +3 -3
- package/example/src/chevre/migrateAuthorizePaymentActionResult.ts +0 -83
- package/example/src/chevre/migrateEventOrganizer.ts +0 -154
- package/lib/chevre/repo/mongoose/schemas/offer.d.ts +0 -149
- package/lib/chevre/repo/mongoose/schemas/offer.js +0 -210
|
@@ -120,7 +120,8 @@ function addReservations(params) {
|
|
|
120
120
|
store: { id: (_a = params.availableAtOrFrom) === null || _a === void 0 ? void 0 : _a.id },
|
|
121
121
|
onlyValid: true,
|
|
122
122
|
addSortIndex: false,
|
|
123
|
-
validateOfferRateLimit: true
|
|
123
|
+
validateOfferRateLimit: true,
|
|
124
|
+
useIncludeInDataCatalog: false
|
|
124
125
|
})(repos);
|
|
125
126
|
ticketOffers = searchEventTicketOffersResult.ticketOffers;
|
|
126
127
|
availableOffers = searchEventTicketOffersResult.unitPriceOffers;
|
|
@@ -181,7 +182,7 @@ function addReservations(params) {
|
|
|
181
182
|
// await repos.reservation.createMany({ reservationFor, reservations: objectSubReservations });
|
|
182
183
|
// }
|
|
183
184
|
// ストックホルダー処理(stockHolderで残席数を集計しているので必要)
|
|
184
|
-
yield onReservationsCreated({ event })(repos);
|
|
185
|
+
yield onReservationsCreated({ event, transaction: { transactionNumber: transaction.transactionNumber } })(repos);
|
|
185
186
|
return { transaction, objectSubReservations, issuedThrough };
|
|
186
187
|
});
|
|
187
188
|
}
|
|
@@ -386,21 +387,62 @@ function createReservations4transactionObject(params) {
|
|
|
386
387
|
}
|
|
387
388
|
}
|
|
388
389
|
// 指定されたアドオンがオファーに存在すれば、アドオンの単価仕様作成
|
|
389
|
-
|
|
390
|
+
const acceptedAddOns = [];
|
|
390
391
|
let availableAddOns;
|
|
391
|
-
const
|
|
392
|
-
if (Array.isArray(
|
|
392
|
+
const acceptedAddOnsParams = acceptedOffer.addOn;
|
|
393
|
+
if (Array.isArray(acceptedAddOnsParams) && acceptedAddOnsParams.length > 0) {
|
|
393
394
|
// アドオンオファー検索(2023-03-02~)
|
|
394
395
|
availableAddOns = yield searchAvailableAddOns({
|
|
395
|
-
ids:
|
|
396
|
+
ids: acceptedAddOnsParams.map((acceptedAddOn) => String(acceptedAddOn.id)),
|
|
396
397
|
project: { id: params.transaction.project.id },
|
|
397
398
|
ticketOffer,
|
|
398
399
|
availableAtOrFrom: params.availableAtOrFrom
|
|
399
400
|
})(repos);
|
|
400
401
|
}
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
402
|
+
if (Array.isArray(availableAddOns) && Array.isArray(acceptedAddOnsParams)) {
|
|
403
|
+
acceptedAddOnsParams.forEach((acceptedAddOnParams) => {
|
|
404
|
+
var _a, _b, _c;
|
|
405
|
+
const availableAddOn = availableAddOns === null || availableAddOns === void 0 ? void 0 : availableAddOns.find((addOn) => addOn.id === acceptedAddOnParams.id);
|
|
406
|
+
if (availableAddOn !== undefined) {
|
|
407
|
+
// acceptedAddOnsの重複を避ける(単価オファーIDに対して)
|
|
408
|
+
if (!acceptedAddOns.some((addOn) => addOn.id === availableAddOn.id)) {
|
|
409
|
+
const availableAddOnReferenceQuantityValue = availableAddOn.priceSpecification.referenceQuantity.value;
|
|
410
|
+
if (typeof availableAddOnReferenceQuantityValue !== 'number') {
|
|
411
|
+
throw new factory.errors.NotImplemented('addOn.priceSpecification.referenceQuantity.value must be number');
|
|
412
|
+
}
|
|
413
|
+
// 受入数量はデフォルトで単価オファーの基準数量
|
|
414
|
+
let referenceQuantityValueAccepted = availableAddOnReferenceQuantityValue;
|
|
415
|
+
// 数量指定を検証(2023-08-31~)
|
|
416
|
+
const specifiedReferencedQuantityValue = (_b = (_a = acceptedAddOnParams.priceSpecification) === null || _a === void 0 ? void 0 : _a.referenceQuantity) === null || _b === void 0 ? void 0 : _b.value;
|
|
417
|
+
if (typeof specifiedReferencedQuantityValue === 'number') {
|
|
418
|
+
if (specifiedReferencedQuantityValue < 1) {
|
|
419
|
+
throw new factory.errors.Argument('addOn.priceSpecification.referenceQuantity.value must be > 0');
|
|
420
|
+
}
|
|
421
|
+
// 数量が適用単位要件を満たしていなければエラー
|
|
422
|
+
if (specifiedReferencedQuantityValue % availableAddOnReferenceQuantityValue !== 0) {
|
|
423
|
+
throw new factory.errors.Argument('addOn.priceSpecification.referenceQuantity.value', `Offer ${availableAddOn.id} requires reference quantity value ${specifiedReferencedQuantityValue}`);
|
|
424
|
+
}
|
|
425
|
+
// 基準数量上書き
|
|
426
|
+
referenceQuantityValueAccepted = specifiedReferencedQuantityValue;
|
|
427
|
+
}
|
|
428
|
+
const priceAccepted = availableAddOn.priceSpecification.price *
|
|
429
|
+
(referenceQuantityValueAccepted / availableAddOnReferenceQuantityValue);
|
|
430
|
+
const accountsReceivableAccepted = (typeof ((_c = availableAddOn.priceSpecification.accounting) === null || _c === void 0 ? void 0 : _c.accountsReceivable) === 'number')
|
|
431
|
+
? availableAddOn.priceSpecification.accounting.accountsReceivable *
|
|
432
|
+
(referenceQuantityValueAccepted / availableAddOnReferenceQuantityValue)
|
|
433
|
+
: undefined;
|
|
434
|
+
const acceptedAddOn = Object.assign(Object.assign({}, availableAddOn), { priceSpecification: Object.assign(Object.assign(Object.assign({}, availableAddOn.priceSpecification), (typeof accountsReceivableAccepted === 'number')
|
|
435
|
+
? {
|
|
436
|
+
accounting: Object.assign(Object.assign({}, availableAddOn.priceSpecification.accounting), { accountsReceivable: accountsReceivableAccepted, typeOf: 'Accounting' })
|
|
437
|
+
}
|
|
438
|
+
: undefined), { price: priceAccepted, referenceQuantity: Object.assign(Object.assign({}, availableAddOn.priceSpecification.referenceQuantity), { value: referenceQuantityValueAccepted }) }) });
|
|
439
|
+
acceptedAddOns.push(acceptedAddOn);
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
});
|
|
443
|
+
// acceptedAddOns = availableAddOns.filter(
|
|
444
|
+
// (availableAddOn) => acceptedAddOnsParams.some((acceptedAddOn) => availableAddOn.id === acceptedAddOn.id)
|
|
445
|
+
// );
|
|
404
446
|
}
|
|
405
447
|
const subReservation = (_j = (_h = acceptedOffer.itemOffered) === null || _h === void 0 ? void 0 : _h.serviceOutput) === null || _j === void 0 ? void 0 : _j.subReservation;
|
|
406
448
|
const reservationId = `${reservationNumber}-${reservationIndex}`;
|
|
@@ -435,7 +477,7 @@ function searchAvailableAddOns(params) {
|
|
|
435
477
|
if (Array.isArray(params.ticketOffer.addOn)) {
|
|
436
478
|
const addOnProductIds = [...new Set(params.ticketOffer.addOn.map((o) => String(o.itemOffered.id)))];
|
|
437
479
|
for (const addOnProductId of addOnProductIds) {
|
|
438
|
-
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')
|
|
480
|
+
const { offers, product } = yield OfferService.product.search(Object.assign({ ids: params.ids, project: { id: params.project.id }, itemOffered: { id: addOnProductId }, onlyValid: true, addSortIndex: false, useIncludeInDataCatalog: false }, (typeof ((_a = params.availableAtOrFrom) === null || _a === void 0 ? void 0 : _a.id) === 'string')
|
|
439
481
|
? { availableAt: { id: params.availableAtOrFrom.id } }
|
|
440
482
|
: undefined))(repos);
|
|
441
483
|
availableAddOns.push(...offers.map((o) => {
|
|
@@ -530,31 +572,64 @@ function validateProgramMembershipUsed(params) {
|
|
|
530
572
|
if (typeof issuedThroughId !== 'string' || issuedThroughId.length === 0) {
|
|
531
573
|
throw new factory.errors.ArgumentNull('acceptedOffer.itemOffered.serviceOutput.programMembershipUsed.issuedThrough.id');
|
|
532
574
|
}
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
575
|
+
const permitIssuedThrough = yield repos.product.findById({ id: issuedThroughId }, ['_id', 'typeOf', 'project', 'serviceType', 'serviceOutput'], []);
|
|
576
|
+
switch (permitIssuedThrough.typeOf) {
|
|
577
|
+
// 発行サービスがCreditCardのケースに対応(2023-09-01~)
|
|
578
|
+
case factory.service.paymentService.PaymentServiceType.CreditCard:
|
|
579
|
+
// 決済サービスのserviceOutputにPermitが存在すれば、設定されたメンバーシップ区分のPermitをprogramMembershipUsedとして適用する
|
|
580
|
+
let issuedThroughServiceType;
|
|
581
|
+
if (Array.isArray(permitIssuedThrough.serviceOutput)) {
|
|
582
|
+
const serviceOutputAsPermit = permitIssuedThrough.serviceOutput.find((output) => output.typeOf === factory.permit.PermitType.Permit);
|
|
583
|
+
if ((serviceOutputAsPermit === null || serviceOutputAsPermit === void 0 ? void 0 : serviceOutputAsPermit.typeOf) === factory.permit.PermitType.Permit) {
|
|
584
|
+
issuedThroughServiceType = serviceOutputAsPermit.issuedThrough.serviceType;
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
if ((issuedThroughServiceType === null || issuedThroughServiceType === void 0 ? void 0 : issuedThroughServiceType.typeOf) === 'CategoryCode') {
|
|
588
|
+
programMembershipUsed = {
|
|
589
|
+
project: permitIssuedThrough.project,
|
|
590
|
+
typeOf: factory.permit.PermitType.Permit,
|
|
591
|
+
identifier: programMembershipUsedIdentifier,
|
|
592
|
+
issuedThrough: {
|
|
593
|
+
id: permitIssuedThrough.id,
|
|
594
|
+
serviceType: issuedThroughServiceType,
|
|
595
|
+
typeOf: permitIssuedThrough.typeOf
|
|
596
|
+
}
|
|
597
|
+
};
|
|
598
|
+
}
|
|
599
|
+
else {
|
|
600
|
+
throw new factory.errors.Argument('acceptedOffer.itemOffered.serviceOutput.programMembershipUsed', 'issuedThrough has no serviceOutput as Permit');
|
|
601
|
+
}
|
|
602
|
+
break;
|
|
603
|
+
case factory.product.ProductType.MembershipService:
|
|
604
|
+
// requestedProgramMembershipUsedの発行サービスIDから外部連携設定を取得する
|
|
605
|
+
const permitService = yield createPermitService({ issuedThrough: { id: issuedThroughId } })(repos);
|
|
606
|
+
// メンバーシップの存在確認
|
|
607
|
+
const serviceOutput = yield permitService.findByIdentifier({
|
|
608
|
+
project: { id: params.project.id },
|
|
609
|
+
identifier: programMembershipUsedIdentifier,
|
|
610
|
+
issuedThrough: { typeOf: factory.product.ProductType.MembershipService }
|
|
611
|
+
});
|
|
612
|
+
// 有効期間のチェック
|
|
613
|
+
if (serviceOutput.validFrom === undefined || serviceOutput.validFrom === null
|
|
614
|
+
|| serviceOutput.validUntil === undefined || serviceOutput.validUntil === null) {
|
|
615
|
+
throw new factory.errors.Argument('acceptedOffer.itemOffered.serviceOutput.programMembershipUsed', 'not valid programMembership');
|
|
616
|
+
}
|
|
617
|
+
if (moment(serviceOutput.validFrom)
|
|
618
|
+
.isAfter(moment(now))
|
|
619
|
+
|| moment(serviceOutput.validUntil)
|
|
620
|
+
.isBefore(moment(now))) {
|
|
621
|
+
throw new factory.errors.Argument('acceptedOffer.itemOffered.serviceOutput.programMembershipUsed', 'unavailable programMembership');
|
|
622
|
+
}
|
|
623
|
+
programMembershipUsed = {
|
|
624
|
+
project: serviceOutput.project,
|
|
625
|
+
typeOf: serviceOutput.typeOf,
|
|
626
|
+
identifier: serviceOutput.identifier,
|
|
627
|
+
issuedThrough: serviceOutput.issuedThrough
|
|
628
|
+
};
|
|
629
|
+
break;
|
|
630
|
+
default:
|
|
631
|
+
throw new factory.errors.Argument('acceptedOffer.itemOffered.serviceOutput.programMembershipUsed', `${permitIssuedThrough.typeOf} not implemented`);
|
|
551
632
|
}
|
|
552
|
-
programMembershipUsed = {
|
|
553
|
-
project: serviceOutput.project,
|
|
554
|
-
typeOf: serviceOutput.typeOf,
|
|
555
|
-
identifier: serviceOutput.identifier,
|
|
556
|
-
issuedThrough: serviceOutput.issuedThrough
|
|
557
|
-
};
|
|
558
633
|
}
|
|
559
634
|
return programMembershipUsed;
|
|
560
635
|
});
|
|
@@ -729,7 +804,8 @@ function onReservationsCreated(params) {
|
|
|
729
804
|
yield OfferService.createAggregateScreeningEventIfNotExist({
|
|
730
805
|
project: params.event.project,
|
|
731
806
|
reservationFor: [{ id: params.event.id }],
|
|
732
|
-
force: false
|
|
807
|
+
force: false,
|
|
808
|
+
identifier: `onReservationsCreated:${params.transaction.transactionNumber}`
|
|
733
809
|
})({ task: repos.task });
|
|
734
810
|
});
|
|
735
811
|
}
|
|
@@ -188,6 +188,7 @@ function validateObjectWithoutDetail(params) {
|
|
|
188
188
|
var _a, _b, _c, _d;
|
|
189
189
|
const objectWithoutDetail = params.object;
|
|
190
190
|
if (Array.isArray(objectWithoutDetail.acceptedOffer)) {
|
|
191
|
+
const validatedAcceptedOffersWithoutDetail = [];
|
|
191
192
|
for (let acceptedOffer of objectWithoutDetail.acceptedOffer) {
|
|
192
193
|
let programMembershipUsed = (_b = (_a = acceptedOffer.itemOffered) === null || _a === void 0 ? void 0 : _a.serviceOutput) === null || _b === void 0 ? void 0 : _b.programMembershipUsed;
|
|
193
194
|
// トークン化されたメンバーシップがリクエストされた場合、実メンバーシップ情報へ変換する
|
|
@@ -214,7 +215,9 @@ function validateObjectWithoutDetail(params) {
|
|
|
214
215
|
};
|
|
215
216
|
acceptedOffer = Object.assign(Object.assign({}, acceptedOffer), { itemOffered: Object.assign(Object.assign({}, acceptedOffer.itemOffered), { serviceOutput: Object.assign(Object.assign({}, (_d = acceptedOffer.itemOffered) === null || _d === void 0 ? void 0 : _d.serviceOutput), { typeOf: factory.reservationType.EventReservation, programMembershipUsed }) }) });
|
|
216
217
|
}
|
|
218
|
+
validatedAcceptedOffersWithoutDetail.push(acceptedOffer);
|
|
217
219
|
}
|
|
220
|
+
objectWithoutDetail.acceptedOffer = validatedAcceptedOffersWithoutDetail;
|
|
218
221
|
}
|
|
219
222
|
return objectWithoutDetail;
|
|
220
223
|
});
|
|
@@ -236,7 +239,8 @@ function validateAcceptedOffers(params) {
|
|
|
236
239
|
store: params.store,
|
|
237
240
|
onlyValid: true,
|
|
238
241
|
addSortIndex: false,
|
|
239
|
-
validateOfferRateLimit: true
|
|
242
|
+
validateOfferRateLimit: true,
|
|
243
|
+
useIncludeInDataCatalog: false
|
|
240
244
|
})(repos);
|
|
241
245
|
// 利用可能なチケットオファーであれば受け入れる
|
|
242
246
|
const acceptedOffers = (Array.isArray(acceptedOffersWithoutDetail))
|
|
@@ -252,31 +256,35 @@ function validateAcceptedOffers(params) {
|
|
|
252
256
|
: [];
|
|
253
257
|
// オファーIDごとにオファー適用条件を確認
|
|
254
258
|
offerIds.forEach((offerId) => {
|
|
255
|
-
var _a;
|
|
259
|
+
var _a, _b, _c;
|
|
256
260
|
const acceptedOffersByOfferId = acceptedOffers.filter((o) => o.id === offerId);
|
|
261
|
+
const numAcceptedOffersByOfferId = acceptedOffersByOfferId.length;
|
|
257
262
|
let referenceQuantityValue = 1;
|
|
258
|
-
|
|
259
|
-
const
|
|
263
|
+
// 単価仕様を取り出す
|
|
264
|
+
const unitPriceSpec = acceptedOffersByOfferId[0].priceSpecification.priceComponent.find((spec) => spec.typeOf === factory.priceSpecificationType.UnitPriceSpecification && (!Array.isArray(spec.appliesToAddOn)));
|
|
265
|
+
// 単価仕様は必ず存在するはず
|
|
266
|
+
if ((unitPriceSpec === null || unitPriceSpec === void 0 ? void 0 : unitPriceSpec.typeOf) !== factory.priceSpecificationType.UnitPriceSpecification) {
|
|
267
|
+
throw new factory.errors.ServiceUnavailable(`unitPriceSpec of the offer '${offerId}' not found`);
|
|
268
|
+
}
|
|
269
|
+
const unitPriceSpecReferenceQuantityValue = (_a = unitPriceSpec.referenceQuantity) === null || _a === void 0 ? void 0 : _a.value;
|
|
260
270
|
if (typeof unitPriceSpecReferenceQuantityValue === 'number') {
|
|
261
271
|
referenceQuantityValue = unitPriceSpecReferenceQuantityValue;
|
|
262
272
|
}
|
|
263
273
|
// アイテム数が適用単位要件を満たしていなければエラー
|
|
264
|
-
if (
|
|
274
|
+
if (numAcceptedOffersByOfferId % referenceQuantityValue !== 0) {
|
|
265
275
|
throw new factory.errors.Argument('acceptedOffers', `Offer ${offerId} requires reference quantity value ${referenceQuantityValue}`);
|
|
266
276
|
}
|
|
267
277
|
// 適用アイテム数要件を満たしていなければエラー
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
if (
|
|
271
|
-
|
|
272
|
-
throw new factory.errors.Argument('acceptedOffers', `Number of offer:${offerId} must be less than or equal to ${maxValue}`);
|
|
273
|
-
}
|
|
278
|
+
const maxValue = (_b = unitPriceSpec.eligibleQuantity) === null || _b === void 0 ? void 0 : _b.maxValue;
|
|
279
|
+
if (typeof maxValue === 'number') {
|
|
280
|
+
if (numAcceptedOffersByOfferId > maxValue) {
|
|
281
|
+
throw new factory.errors.Argument('acceptedOffers', `Number of offer:${offerId} must be less than or equal to ${maxValue}`);
|
|
274
282
|
}
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
}
|
|
283
|
+
}
|
|
284
|
+
const minValue = (_c = unitPriceSpec.eligibleQuantity) === null || _c === void 0 ? void 0 : _c.minValue;
|
|
285
|
+
if (typeof minValue === 'number') {
|
|
286
|
+
if (numAcceptedOffersByOfferId < minValue) {
|
|
287
|
+
throw new factory.errors.Argument('acceptedOffers', `Number of offer:${offerId} must be more than or equal to ${minValue}`);
|
|
280
288
|
}
|
|
281
289
|
}
|
|
282
290
|
});
|
|
@@ -298,44 +306,40 @@ function acceptedOfferWithoutDetail2acceptedOffer(params) {
|
|
|
298
306
|
transaction: params.transaction
|
|
299
307
|
});
|
|
300
308
|
const acceptedAppliesToMovieTicket = (_a = offerWithoutDetail.priceSpecification) === null || _a === void 0 ? void 0 : _a.appliesToMovieTicket;
|
|
301
|
-
// let movieTicketIdentifire: string | undefined;
|
|
302
|
-
// if (Array.isArray(acceptedAppliesToMovieTicket)) {
|
|
303
|
-
// // throw new factory.errors.NotImplemented('multiple appliesToMovieTicket not implemented');
|
|
304
|
-
// // no op
|
|
305
|
-
// } else if (typeof acceptedAppliesToMovieTicket?.identifier === 'string') {
|
|
306
|
-
// movieTicketIdentifire = acceptedAppliesToMovieTicket.identifier;
|
|
307
|
-
// }
|
|
308
309
|
// 承認アクションオブジェクトのacceptedOfferにappliesToMovieTicketを連携する(2022-08-02~)
|
|
309
310
|
const priceSpecification = Object.assign(Object.assign({}, offer.priceSpecification), (Array.isArray(acceptedAppliesToMovieTicket) || typeof (acceptedAppliesToMovieTicket === null || acceptedAppliesToMovieTicket === void 0 ? void 0 : acceptedAppliesToMovieTicket.identifier) === 'string')
|
|
310
311
|
? { appliesToMovieTicket: acceptedAppliesToMovieTicket }
|
|
311
312
|
: undefined);
|
|
313
|
+
const acceptedAddOns = (Array.isArray(offerWithoutDetail.addOn))
|
|
314
|
+
? offerWithoutDetail.addOn.map((acceptedAddOnOffer) => {
|
|
315
|
+
var _a, _b;
|
|
316
|
+
if (typeof acceptedAddOnOffer.id !== 'string' || acceptedAddOnOffer.id.length === 0) {
|
|
317
|
+
throw new factory.errors.ArgumentNull('object.acceptedOffer.addOn.id');
|
|
318
|
+
}
|
|
319
|
+
const addOnOfferReferenceQuantityValue = (_b = (_a = acceptedAddOnOffer.priceSpecification) === null || _a === void 0 ? void 0 : _a.referenceQuantity) === null || _b === void 0 ? void 0 : _b.value;
|
|
320
|
+
return Object.assign({
|
|
321
|
+
// typeOf: <factory.offerType.Offer>factory.offerType.Offer,
|
|
322
|
+
id: acceptedAddOnOffer.id }, (typeof addOnOfferReferenceQuantityValue === 'number')
|
|
323
|
+
? { priceSpecification: { referenceQuantity: { value: addOnOfferReferenceQuantityValue } } }
|
|
324
|
+
: undefined);
|
|
325
|
+
})
|
|
326
|
+
: [];
|
|
312
327
|
const acceptedOffer = {
|
|
313
328
|
// オファーの中身を最適化する(必要最低限の情報のみに)
|
|
314
329
|
id: String(offer.id),
|
|
315
330
|
identifier: offer.identifier,
|
|
316
331
|
priceSpecification,
|
|
317
|
-
// project: offer.project,
|
|
318
332
|
typeOf: offer.typeOf,
|
|
319
333
|
priceCurrency: offer.priceCurrency,
|
|
320
334
|
itemOffered: Object.assign({ typeOf: factory.product.ProductType.EventService, serviceOutput: (offerWithoutDetail.itemOffered !== undefined && offerWithoutDetail.itemOffered !== null)
|
|
321
335
|
? offerWithoutDetail.itemOffered.serviceOutput
|
|
322
336
|
: undefined }, (pointAward !== undefined) ? { pointAward } : undefined),
|
|
323
|
-
addOn:
|
|
324
|
-
? offerWithoutDetail.addOn.map((a) => {
|
|
325
|
-
return {
|
|
326
|
-
typeOf: factory.offerType.Offer,
|
|
327
|
-
id: String(a.id),
|
|
328
|
-
priceCurrency: offer.priceCurrency
|
|
329
|
-
};
|
|
330
|
-
})
|
|
331
|
-
: [],
|
|
337
|
+
addOn: acceptedAddOns,
|
|
332
338
|
// 追加属性をマージ
|
|
333
339
|
additionalProperty: [
|
|
334
340
|
...(Array.isArray(offerWithoutDetail.additionalProperty)) ? offerWithoutDetail.additionalProperty : [],
|
|
335
341
|
...(Array.isArray(offer.additionalProperty)) ? offer.additionalProperty : []
|
|
336
342
|
]
|
|
337
|
-
// movieTicketIdentifireの不要を確認後に廃止(2022-09-09以降)(2022-11-02+)
|
|
338
|
-
// ...(typeof movieTicketIdentifire === 'string') ? { movieTicketIdentifire } : undefined
|
|
339
343
|
};
|
|
340
344
|
let offeredThrough = (_b = params.event.offers) === null || _b === void 0 ? void 0 : _b.offeredThrough;
|
|
341
345
|
if (typeof (offeredThrough === null || offeredThrough === void 0 ? void 0 : offeredThrough.typeOf) !== 'string') {
|
|
@@ -16,7 +16,7 @@ export declare function createReserveTransactionStartParams(params: {
|
|
|
16
16
|
export declare function createAuthorizeSeatReservationActionAttributes(params: {
|
|
17
17
|
acceptedOffers: factory.action.authorize.offer.seatReservation.IAcceptedOffer4chevre[];
|
|
18
18
|
event: IMinimizedIndividualEvent<factory.eventType.ScreeningEvent>;
|
|
19
|
-
pendingTransaction?: factory.action.authorize.offer.seatReservation.
|
|
19
|
+
pendingTransaction?: factory.action.authorize.offer.seatReservation.IChevrePendingTransaction | undefined;
|
|
20
20
|
transaction: factory.transaction.ITransaction<factory.transactionType.PlaceOrder>;
|
|
21
21
|
broker?: factory.reservation.IBroker<factory.reservationType.EventReservation>;
|
|
22
22
|
}): factory.action.authorize.offer.seatReservation.IAttributes<factory.service.webAPI.Identifier.Chevre>;
|
|
@@ -299,6 +299,7 @@ function createReservation(params) {
|
|
|
299
299
|
}
|
|
300
300
|
return reservationItem;
|
|
301
301
|
}
|
|
302
|
+
// tslint:disable-next-line:max-func-body-length
|
|
302
303
|
function coaTicket2offer(params) {
|
|
303
304
|
var _a, _b;
|
|
304
305
|
// 適用通貨区分
|
|
@@ -322,7 +323,6 @@ function coaTicket2offer(params) {
|
|
|
322
323
|
}]
|
|
323
324
|
: undefined;
|
|
324
325
|
const unitPriceSpec = {
|
|
325
|
-
// project: { typeOf: factory.organizationType.Project, id: params.project.id },
|
|
326
326
|
typeOf: factory.priceSpecificationType.UnitPriceSpecification,
|
|
327
327
|
price: 0,
|
|
328
328
|
priceCurrency: factory.priceCurrency.JPY,
|
|
@@ -332,15 +332,15 @@ function coaTicket2offer(params) {
|
|
|
332
332
|
unitCode: factory.unitCode.C62,
|
|
333
333
|
value: 1
|
|
334
334
|
}
|
|
335
|
-
// appliesToMovieTicket?: {};
|
|
336
335
|
};
|
|
337
336
|
const identifier = (0, util_1.format)('%s-%s-%s', factory.service.webAPI.Identifier.COA, params.theaterCode, params.ticketResult.ticketCode);
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
337
|
+
const offerName = {
|
|
338
|
+
ja: params.ticketResult.ticketName,
|
|
339
|
+
en: (typeof params.ticketResult.ticketNameEng === 'string')
|
|
340
|
+
? params.ticketResult.ticketNameEng
|
|
341
|
+
: ''
|
|
342
|
+
};
|
|
343
|
+
return Object.assign(Object.assign(Object.assign({ project: { typeOf: factory.organizationType.Project, id: params.project.id }, typeOf: factory.offerType.Offer, priceCurrency: factory.priceCurrency.JPY, id: '', identifier: identifier, name: offerName, description: {
|
|
344
344
|
ja: '',
|
|
345
345
|
en: ''
|
|
346
346
|
}, alternateName: {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as COA from '@motionpicture/coa-service';
|
|
2
2
|
import { MongoRepository as CategoryCodeRepo } from '../../../repo/categoryCode';
|
|
3
3
|
import { MongoRepository as OfferRepo } from '../../../repo/offer';
|
|
4
|
+
import { MongoRepository as TaskRepo } from '../../../repo/task';
|
|
4
5
|
export declare function importFromCOA(params: {
|
|
5
6
|
project: {
|
|
6
7
|
id: string;
|
|
@@ -9,6 +10,7 @@ export declare function importFromCOA(params: {
|
|
|
9
10
|
}): (repos: {
|
|
10
11
|
categoryCode: CategoryCodeRepo;
|
|
11
12
|
offer: OfferRepo;
|
|
13
|
+
task: TaskRepo;
|
|
12
14
|
masterService: COA.service.Master;
|
|
13
15
|
}) => Promise<void>;
|
|
14
16
|
/**
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { MongoRepository as EventRepo } from '../../../repo/event';
|
|
2
2
|
import { MongoRepository as OfferRepo } from '../../../repo/offer';
|
|
3
|
+
import { MongoRepository as OfferCatalogRepo } from '../../../repo/offerCatalog';
|
|
3
4
|
import { MongoRepository as PriceSpecificationRepo } from '../../../repo/priceSpecification';
|
|
4
5
|
import { MongoRepository as ProductRepo } from '../../../repo/product';
|
|
5
6
|
import { RedisRepository as OfferRateLimitRepo } from '../../../repo/rateLimit/offer';
|
|
@@ -8,6 +9,7 @@ interface ISearchEventTicketOffersRepos {
|
|
|
8
9
|
event: EventRepo;
|
|
9
10
|
priceSpecification: PriceSpecificationRepo;
|
|
10
11
|
offer: OfferRepo;
|
|
12
|
+
offerCatalog: OfferCatalogRepo;
|
|
11
13
|
offerRateLimit: OfferRateLimitRepo;
|
|
12
14
|
product: ProductRepo;
|
|
13
15
|
}
|
|
@@ -47,6 +49,7 @@ declare function searchEventTicketOffers(params: {
|
|
|
47
49
|
page?: number;
|
|
48
50
|
addSortIndex: boolean;
|
|
49
51
|
validateOfferRateLimit: boolean;
|
|
52
|
+
useIncludeInDataCatalog: boolean;
|
|
50
53
|
}): ISearchEventTicketOffersOperation<{
|
|
51
54
|
ticketOffers: ITicketOfferWithSortIndex[];
|
|
52
55
|
unitPriceOffers: factory.unitPriceOffer.IUnitPriceOffer[];
|
|
@@ -15,7 +15,7 @@ const factory = require("../../../factory");
|
|
|
15
15
|
const factory_1 = require("../factory");
|
|
16
16
|
function searchTicketOffersByItemOffered(params) {
|
|
17
17
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
18
|
-
var _a, _b, _c, _d;
|
|
18
|
+
var _a, _b, _c, _d, _e;
|
|
19
19
|
let catalogId;
|
|
20
20
|
if (typeof ((_a = params.itemOffered) === null || _a === void 0 ? void 0 : _a.id) === 'string') {
|
|
21
21
|
const eventService = yield repos.product.findById({ id: (_b = params.itemOffered) === null || _b === void 0 ? void 0 : _b.id }, ['hasOfferCatalog'], []);
|
|
@@ -26,19 +26,47 @@ function searchTicketOffersByItemOffered(params) {
|
|
|
26
26
|
if (typeof catalogId !== 'string') {
|
|
27
27
|
throw new factory.errors.NotFound('itemOffered.hasOfferCatalog');
|
|
28
28
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
//
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
29
|
+
// サブカタログIDを決定
|
|
30
|
+
let subOfferCatalogId = catalogId;
|
|
31
|
+
const offerCatalogFirstElement = yield repos.offerCatalog.findFirstItemListElementById({ id: catalogId });
|
|
32
|
+
if (offerCatalogFirstElement.typeOf === 'OfferCatalog') {
|
|
33
|
+
subOfferCatalogId = offerCatalogFirstElement.id;
|
|
34
|
+
}
|
|
35
|
+
if (params.withSortIndex) {
|
|
36
|
+
// addSortIndexの場合はid指定廃止(2023-09-13~)
|
|
37
|
+
if (Array.isArray(params.ids)) {
|
|
38
|
+
throw new factory.errors.NotImplemented('id specification on addSortIndex not implemented');
|
|
39
|
+
}
|
|
40
|
+
const { offers, sortedOfferIds } = yield repos.offer.searchByOfferCatalogIdWithSortIndex({
|
|
41
|
+
// ids: params.ids,
|
|
42
|
+
subOfferCatalog: { id: subOfferCatalogId },
|
|
43
|
+
availableAtOrFrom: { id: (_d = params.store) === null || _d === void 0 ? void 0 : _d.id },
|
|
44
|
+
unacceptedPaymentMethod: params.unacceptedPaymentMethod,
|
|
45
|
+
excludeAppliesToMovieTicket: params.excludeAppliesToMovieTicket,
|
|
46
|
+
onlyValid: params.onlyValid === true,
|
|
47
|
+
useIncludeInDataCatalog: params.useIncludeInDataCatalog,
|
|
48
|
+
limit: params.limit,
|
|
49
|
+
page: params.page
|
|
50
|
+
});
|
|
51
|
+
return { availableOffers: offers, sortedOfferIds };
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
// addSortIndexの場合はid指定廃止(2023-09-13~)
|
|
55
|
+
if (!Array.isArray(params.ids)) {
|
|
56
|
+
throw new factory.errors.ArgumentNull('ids', 'ids must be specified');
|
|
57
|
+
}
|
|
58
|
+
const { offers } = yield repos.offer.searchByIdsAndOfferCatalogId({
|
|
59
|
+
ids: params.ids,
|
|
60
|
+
subOfferCatalog: { id: subOfferCatalogId },
|
|
61
|
+
availableAtOrFrom: { id: (_e = params.store) === null || _e === void 0 ? void 0 : _e.id },
|
|
62
|
+
unacceptedPaymentMethod: params.unacceptedPaymentMethod,
|
|
63
|
+
excludeAppliesToMovieTicket: params.excludeAppliesToMovieTicket,
|
|
64
|
+
onlyValid: params.onlyValid === true,
|
|
65
|
+
limit: params.limit,
|
|
66
|
+
page: params.page
|
|
67
|
+
});
|
|
68
|
+
return { availableOffers: offers };
|
|
69
|
+
}
|
|
42
70
|
});
|
|
43
71
|
}
|
|
44
72
|
/**
|
|
@@ -84,7 +112,9 @@ function searchEventTicketOffersByEvent(params) {
|
|
|
84
112
|
page: params.page,
|
|
85
113
|
onlyValid: params.onlyValid,
|
|
86
114
|
unacceptedPaymentMethod,
|
|
87
|
-
excludeAppliesToMovieTicket
|
|
115
|
+
excludeAppliesToMovieTicket,
|
|
116
|
+
withSortIndex: params.addSortIndex,
|
|
117
|
+
useIncludeInDataCatalog: params.useIncludeInDataCatalog
|
|
88
118
|
})(repos);
|
|
89
119
|
// 冗長な検索について最適化(2023-03-03~)
|
|
90
120
|
const { soundFormatChargeSpecs, videoFormatChargeSpecs, movieTicketTypeChargeSpecs } = yield searchPriceSpecs4event({
|
|
@@ -98,7 +128,7 @@ function searchEventTicketOffersByEvent(params) {
|
|
|
98
128
|
for (const availableOffer of availableOffers) {
|
|
99
129
|
let sortIndex;
|
|
100
130
|
if (params.addSortIndex) {
|
|
101
|
-
sortIndex = sortedOfferIds.indexOf(String(availableOffer.id));
|
|
131
|
+
sortIndex = sortedOfferIds === null || sortedOfferIds === void 0 ? void 0 : sortedOfferIds.indexOf(String(availableOffer.id));
|
|
102
132
|
}
|
|
103
133
|
let availability;
|
|
104
134
|
if (params.validateOfferRateLimit) {
|
|
@@ -248,7 +278,8 @@ function searchEventTicketOffers(params) {
|
|
|
248
278
|
page: params.page,
|
|
249
279
|
addSortIndex: params.addSortIndex,
|
|
250
280
|
validateOfferRateLimit: params.validateOfferRateLimit,
|
|
251
|
-
onlyValid: params.onlyValid === true
|
|
281
|
+
onlyValid: params.onlyValid === true,
|
|
282
|
+
useIncludeInDataCatalog: params.useIncludeInDataCatalog
|
|
252
283
|
})(repos);
|
|
253
284
|
offers = searchOffersResult.ticketOffers;
|
|
254
285
|
unitPriceOffers = searchOffersResult.unitPriceOffers;
|