@chevre/domain 21.16.0 → 21.17.0-alpha.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/lib/chevre/repo/offer.js +1 -0
- package/lib/chevre/service/offer/event/authorize.js +7 -12
- package/lib/chevre/service/offer/factory.js +3 -3
- package/lib/chevre/service/transaction/placeOrderInProgress/validation.d.ts +1 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/validation.js +57 -16
- package/package.json +2 -2
package/lib/chevre/repo/offer.js
CHANGED
|
@@ -405,6 +405,7 @@ class MongoRepository {
|
|
|
405
405
|
description: '$offers.description',
|
|
406
406
|
category: '$offers.category',
|
|
407
407
|
color: '$offers.color',
|
|
408
|
+
acceptedPaymentMethod: '$offers.acceptedPaymentMethod',
|
|
408
409
|
additionalProperty: '$offers.additionalProperty',
|
|
409
410
|
advanceBookingRequirement: '$offers.advanceBookingRequirement',
|
|
410
411
|
alternateName: '$offers.alternateName',
|
|
@@ -276,7 +276,7 @@ function validateAcceptedOffers(params) {
|
|
|
276
276
|
if (numAcceptedOffersByOfferId % referenceQuantityValue !== 0) {
|
|
277
277
|
throw new factory.errors.Argument('acceptedOffers', `Offer ${offerId} requires reference quantity value ${referenceQuantityValue}`);
|
|
278
278
|
}
|
|
279
|
-
//
|
|
279
|
+
// 適用数量要件を満たしていなければエラー
|
|
280
280
|
const maxValue = (_b = unitPriceSpec.eligibleQuantity) === null || _b === void 0 ? void 0 : _b.maxValue;
|
|
281
281
|
if (typeof maxValue === 'number') {
|
|
282
282
|
if (numAcceptedOffersByOfferId > maxValue) {
|
|
@@ -326,23 +326,18 @@ function acceptedOfferWithoutDetail2acceptedOffer(params) {
|
|
|
326
326
|
: undefined);
|
|
327
327
|
})
|
|
328
328
|
: [];
|
|
329
|
-
const acceptedOffer = {
|
|
329
|
+
const acceptedOffer = Object.assign({
|
|
330
330
|
// オファーの中身を最適化する(必要最低限の情報のみに)
|
|
331
|
-
id: String(offer.id),
|
|
332
|
-
identifier: offer.identifier,
|
|
333
|
-
priceSpecification,
|
|
334
|
-
typeOf: offer.typeOf,
|
|
335
|
-
priceCurrency: offer.priceCurrency,
|
|
336
|
-
itemOffered: Object.assign({ typeOf: factory.product.ProductType.EventService, serviceOutput: (offerWithoutDetail.itemOffered !== undefined && offerWithoutDetail.itemOffered !== null)
|
|
331
|
+
id: String(offer.id), identifier: offer.identifier, priceSpecification, typeOf: offer.typeOf, priceCurrency: offer.priceCurrency, itemOffered: Object.assign({ typeOf: factory.product.ProductType.EventService, serviceOutput: (offerWithoutDetail.itemOffered !== undefined && offerWithoutDetail.itemOffered !== null)
|
|
337
332
|
? offerWithoutDetail.itemOffered.serviceOutput
|
|
338
|
-
: undefined }, (pointAward !== undefined) ? { pointAward } : undefined),
|
|
339
|
-
addOn: acceptedAddOns,
|
|
333
|
+
: undefined }, (pointAward !== undefined) ? { pointAward } : undefined), addOn: acceptedAddOns,
|
|
340
334
|
// 追加属性をマージ
|
|
341
335
|
additionalProperty: [
|
|
342
336
|
...(Array.isArray(offerWithoutDetail.additionalProperty)) ? offerWithoutDetail.additionalProperty : [],
|
|
343
337
|
...(Array.isArray(offer.additionalProperty)) ? offer.additionalProperty : []
|
|
344
|
-
]
|
|
345
|
-
|
|
338
|
+
] }, (Array.isArray(offer.acceptedPaymentMethod))
|
|
339
|
+
? { acceptedPaymentMethod: offer.acceptedPaymentMethod } // add(2023-11-15~)
|
|
340
|
+
: undefined);
|
|
346
341
|
let offeredThrough = (_b = params.event.offers) === null || _b === void 0 ? void 0 : _b.offeredThrough;
|
|
347
342
|
if (typeof (offeredThrough === null || offeredThrough === void 0 ? void 0 : offeredThrough.typeOf) !== 'string') {
|
|
348
343
|
offeredThrough = { typeOf: 'WebAPI', identifier: factory.service.webAPI.Identifier.Chevre };
|
|
@@ -76,8 +76,8 @@ function createCompoundPriceSpec4event(params) {
|
|
|
76
76
|
priceComponent
|
|
77
77
|
};
|
|
78
78
|
// 必要な属性のみに限定(2023-02-24~)
|
|
79
|
-
const { name, description, alternateName, color, typeOf, id, availability, availableAtOrFrom, category, eligibleMembershipType, eligibleSeatingType, eligibleMonetaryAmount, eligibleSubReservation, priceCurrency, validFrom, validThrough, validRateLimit, additionalProperty, identifier, itemOffered, offerIndex, parentOffer } = params.offer;
|
|
80
|
-
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ name, description, alternateName, color, typeOf, id,
|
|
79
|
+
const { acceptedPaymentMethod, name, description, alternateName, color, typeOf, id, availability, availableAtOrFrom, category, eligibleMembershipType, eligibleSeatingType, eligibleMonetaryAmount, eligibleSubReservation, priceCurrency, validFrom, validThrough, validRateLimit, additionalProperty, identifier, itemOffered, offerIndex, parentOffer } = params.offer;
|
|
80
|
+
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ name, description, alternateName, color, typeOf, id,
|
|
81
81
|
category,
|
|
82
82
|
eligibleMembershipType, eligibleSeatingType, eligibleMonetaryAmount, eligibleSubReservation,
|
|
83
83
|
priceCurrency,
|
|
@@ -86,6 +86,6 @@ function createCompoundPriceSpec4event(params) {
|
|
|
86
86
|
? {
|
|
87
87
|
availableAtOrFrom // 最適化(2023-09-10~)
|
|
88
88
|
}
|
|
89
|
-
: undefined), (typeof params.availability === 'string') ? { availability: params.availability } : { availability }), (typeof params.sortIndex === 'number') ? { sortIndex: params.sortIndex } : undefined), (typeof offerIndex === 'number') ? { offerIndex } : undefined), (typeof (parentOffer === null || parentOffer === void 0 ? void 0 : parentOffer.id) === 'string') ? { parentOffer: { id: parentOffer.id } } : undefined);
|
|
89
|
+
: undefined), (typeof params.availability === 'string') ? { availability: params.availability } : { availability }), (typeof params.sortIndex === 'number') ? { sortIndex: params.sortIndex } : undefined), (typeof offerIndex === 'number') ? { offerIndex } : undefined), (typeof (parentOffer === null || parentOffer === void 0 ? void 0 : parentOffer.id) === 'string') ? { parentOffer: { id: parentOffer.id } } : undefined), (Array.isArray(acceptedPaymentMethod)) ? { acceptedPaymentMethod } : undefined);
|
|
90
90
|
}
|
|
91
91
|
exports.createCompoundPriceSpec4event = createCompoundPriceSpec4event;
|
|
@@ -41,7 +41,7 @@ export declare function validatePaymentMethods(params: {
|
|
|
41
41
|
order: factory.order.IOrder;
|
|
42
42
|
}): void;
|
|
43
43
|
/**
|
|
44
|
-
*
|
|
44
|
+
* 興行オファー適用条件確認
|
|
45
45
|
*/
|
|
46
46
|
export declare function validateEventOffers(params: {
|
|
47
47
|
transaction: factory.transaction.placeOrder.ITransaction;
|
|
@@ -254,32 +254,73 @@ function validatePaymentMethods(params) {
|
|
|
254
254
|
}
|
|
255
255
|
exports.validatePaymentMethods = validatePaymentMethods;
|
|
256
256
|
/**
|
|
257
|
-
*
|
|
257
|
+
* 興行オファー適用条件確認
|
|
258
258
|
*/
|
|
259
259
|
function validateEventOffers(params) {
|
|
260
|
+
var _a, _b;
|
|
261
|
+
const firstOrderPaymentMethodIdentifier = (_b = (_a = params.order.paymentMethods[0]) === null || _a === void 0 ? void 0 : _a.paymentMethod) === null || _b === void 0 ? void 0 : _b.identifier;
|
|
262
|
+
const numCreditCardOrFaceToFacePaymentMethod = params.order.paymentMethods.filter((referenceInvoice) => {
|
|
263
|
+
return referenceInvoice.issuedThrough.typeOf === factory.service.paymentService.PaymentServiceType.CreditCard
|
|
264
|
+
|| referenceInvoice.issuedThrough.typeOf === factory.service.paymentService.PaymentServiceType.FaceToFace;
|
|
265
|
+
}).length;
|
|
260
266
|
const seatReservationAuthorizeActions = params.authorizeActions
|
|
261
267
|
.filter((a) => a.actionStatus === factory.actionStatusType.CompletedActionStatus)
|
|
262
268
|
.filter((a) => a.object.typeOf === factory.action.authorize.offer.seatReservation.ObjectType.SeatReservation);
|
|
263
269
|
seatReservationAuthorizeActions.forEach((a) => {
|
|
264
|
-
const acceptedOffers = a.object.acceptedOffer;
|
|
265
270
|
// オファーIDごとにオファー適用条件を確認
|
|
266
|
-
const offerIds = [...new Set(
|
|
271
|
+
const offerIds = [...new Set(a.object.acceptedOffer.map((o) => o.id))];
|
|
267
272
|
offerIds.forEach((offerId) => {
|
|
268
|
-
var _a, _b;
|
|
269
|
-
const acceptedOffersByOfferId = acceptedOffers.filter((o) => o.id === offerId);
|
|
270
|
-
let acceptedOffer = acceptedOffersByOfferId[0];
|
|
273
|
+
var _a, _b, _c, _d;
|
|
271
274
|
let unitPriceSpec;
|
|
272
|
-
if (
|
|
275
|
+
if (a.instrument.identifier === factory.service.webAPI.Identifier.Chevre) {
|
|
276
|
+
const acceptedOffersByOfferId = a.object.acceptedOffer.filter((o) => o.id === offerId);
|
|
277
|
+
const acceptedOffer = acceptedOffersByOfferId[0];
|
|
273
278
|
// Chevre予約の場合、priceSpecificationに複合価格仕様が含まれるので、そこから単価仕様を取り出す
|
|
274
|
-
acceptedOffer = acceptedOffer;
|
|
275
|
-
unitPriceSpec = acceptedOffer.priceSpecification.priceComponent.find((spec) => spec.typeOf === factory.priceSpecificationType.UnitPriceSpecification
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
279
|
+
// acceptedOffer = <factory.action.authorize.offer.seatReservation.IAcceptedOffer4chevre>acceptedOffer;
|
|
280
|
+
unitPriceSpec = acceptedOffer.priceSpecification.priceComponent.find((spec) => spec.typeOf === factory.priceSpecificationType.UnitPriceSpecification
|
|
281
|
+
&& (!Array.isArray(spec.appliesToAddOn)) // アドオン単価ではない
|
|
282
|
+
);
|
|
283
|
+
// if (acceptedOffer.priceSpecification !== undefined) {
|
|
284
|
+
// // Chevre予約の場合、priceSpecificationに複合価格仕様が含まれるので、そこから単価仕様を取り出す
|
|
285
|
+
// acceptedOffer = <factory.action.authorize.offer.seatReservation.IAcceptedOffer4chevre>acceptedOffer;
|
|
286
|
+
// unitPriceSpec = <IUnitPriceSpecification>acceptedOffer.priceSpecification.priceComponent.find(
|
|
287
|
+
// (spec) => spec.typeOf === factory.priceSpecificationType.UnitPriceSpecification
|
|
288
|
+
// );
|
|
289
|
+
// }
|
|
290
|
+
// 適用金額要件を満たしていなければエラー
|
|
291
|
+
const eligibleTransactionVolumePrice = (_a = unitPriceSpec === null || unitPriceSpec === void 0 ? void 0 : unitPriceSpec.eligibleTransactionVolume) === null || _a === void 0 ? void 0 : _a.price;
|
|
292
|
+
const eligibleTransactionVolumePriceCurrency = (_b = unitPriceSpec === null || unitPriceSpec === void 0 ? void 0 : unitPriceSpec.eligibleTransactionVolume) === null || _b === void 0 ? void 0 : _b.priceCurrency;
|
|
293
|
+
if (typeof eligibleTransactionVolumePrice === 'number') {
|
|
294
|
+
if (params.order.price < eligibleTransactionVolumePrice) {
|
|
295
|
+
throw new factory.errors.Argument('Transaction', (0, util_1.format)('Transaction volume must be more than or equal to %s %s for offer:%s', eligibleTransactionVolumePrice, eligibleTransactionVolumePriceCurrency, offerId));
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
// 適用数量検証(全興行オファー承認アクションについて)(2023-11-15~)
|
|
299
|
+
// 適用数量要件を満たしていなければエラー
|
|
300
|
+
const numAcceptedOffersByOfferId = seatReservationAuthorizeActions.reduce((previousNumOffer, currentAction) => {
|
|
301
|
+
return previousNumOffer + currentAction.object.acceptedOffer.filter((o) => o.id === offerId).length;
|
|
302
|
+
}, 0);
|
|
303
|
+
const eligibleQuantityMaxValue = (_c = unitPriceSpec === null || unitPriceSpec === void 0 ? void 0 : unitPriceSpec.eligibleQuantity) === null || _c === void 0 ? void 0 : _c.maxValue;
|
|
304
|
+
if (typeof eligibleQuantityMaxValue === 'number') {
|
|
305
|
+
if (numAcceptedOffersByOfferId > eligibleQuantityMaxValue) {
|
|
306
|
+
throw new factory.errors.Argument('Transaction', `Number of offer:${offerId} must be less than or equal to ${eligibleQuantityMaxValue}`);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
const eligibleQuantityMinValue = (_d = unitPriceSpec === null || unitPriceSpec === void 0 ? void 0 : unitPriceSpec.eligibleQuantity) === null || _d === void 0 ? void 0 : _d.minValue;
|
|
310
|
+
if (typeof eligibleQuantityMinValue === 'number') {
|
|
311
|
+
if (numAcceptedOffersByOfferId < eligibleQuantityMinValue) {
|
|
312
|
+
throw new factory.errors.Argument('Transaction', `Number of offer:${offerId} must be more than or equal to ${eligibleQuantityMinValue}`);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
// 利用可能決済方法検証(2023-11-15~)
|
|
316
|
+
if (Array.isArray(acceptedOffer.acceptedPaymentMethod)) {
|
|
317
|
+
const acceptedPaymentMethodTypes = acceptedOffer.acceptedPaymentMethod.map((paymentMethod) => paymentMethod.identifier);
|
|
318
|
+
const satisfyAcceptedPaymentMethod = numCreditCardOrFaceToFacePaymentMethod === 1
|
|
319
|
+
&& typeof firstOrderPaymentMethodIdentifier === 'string'
|
|
320
|
+
&& acceptedPaymentMethodTypes.includes(firstOrderPaymentMethodIdentifier);
|
|
321
|
+
if (!satisfyAcceptedPaymentMethod) {
|
|
322
|
+
throw new factory.errors.Argument('Transaction', `acceptedPaymentMethod requirement not satisfied`);
|
|
323
|
+
}
|
|
283
324
|
}
|
|
284
325
|
}
|
|
285
326
|
});
|
package/package.json
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@aws-sdk/credential-providers": "3.433.0",
|
|
13
|
-
"@chevre/factory": "4.
|
|
13
|
+
"@chevre/factory": "4.343.0-alpha.0",
|
|
14
14
|
"@cinerino/sdk": "5.0.0",
|
|
15
15
|
"@motionpicture/coa-service": "9.2.0",
|
|
16
16
|
"@motionpicture/gmo-service": "5.2.0",
|
|
@@ -117,5 +117,5 @@
|
|
|
117
117
|
"postversion": "git push origin --tags",
|
|
118
118
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
119
119
|
},
|
|
120
|
-
"version": "21.
|
|
120
|
+
"version": "21.17.0-alpha.0"
|
|
121
121
|
}
|