@chevre/domain 20.7.0-alpha.3 → 20.7.0-alpha.4
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.
|
@@ -11,10 +11,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.validateAcceptedOffers = void 0;
|
|
13
13
|
const factory = require("../../../factory");
|
|
14
|
+
const MENBERSHIP_COUPON_PAYMENT_METHOD_TYPE = 'MembershipCoupon'; // ひとまず固定
|
|
14
15
|
/**
|
|
15
16
|
* 受け入れらたオファーの内容を検証
|
|
16
17
|
*/
|
|
17
18
|
function validateAcceptedOffers(params) {
|
|
19
|
+
// tslint:disable-next-line:max-func-body-length
|
|
18
20
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
19
21
|
const offerIds = (Array.isArray(params.object.acceptedOffer))
|
|
20
22
|
? [...new Set(params.object.acceptedOffer.map((o) => o.id))]
|
|
@@ -29,12 +31,59 @@ function validateAcceptedOffers(params) {
|
|
|
29
31
|
}
|
|
30
32
|
// 利用可能なチケットオファーであれば受け入れる
|
|
31
33
|
const acceptedOffers = params.object.acceptedOffer.map((acceptedOffer) => {
|
|
32
|
-
var _a, _b, _c, _d, _e, _f;
|
|
34
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
33
35
|
const availableUnitPriceOffer = availableUnitPriceOffers.find((unitPriceOffer) => unitPriceOffer.id === acceptedOffer.id);
|
|
34
36
|
if (availableUnitPriceOffer === undefined) {
|
|
35
37
|
throw new factory.errors.NotFound(factory.offerType.Offer, `${acceptedOffer.identifier} not found`);
|
|
36
38
|
}
|
|
37
39
|
const { additionalProperty, itemOffered, name, price, priceSpecification, ticketInfo } = acceptedOffer;
|
|
40
|
+
if (priceSpecification === undefined) {
|
|
41
|
+
throw new factory.errors.NotFound('priceSpecification');
|
|
42
|
+
}
|
|
43
|
+
// appliesToSurfrockの指定があれば強制的にMovieTicket決済
|
|
44
|
+
let eligibleMonetaryAmount;
|
|
45
|
+
const surfrockIdentifier = (_b = (_a = acceptedOffer.priceSpecification) === null || _a === void 0 ? void 0 : _a.appliesToSurfrock) === null || _b === void 0 ? void 0 : _b.identifier;
|
|
46
|
+
if (typeof surfrockIdentifier === 'string') {
|
|
47
|
+
// serviceTypeはticketCode
|
|
48
|
+
const serviceType = (_d = (_c = availableUnitPriceOffer.additionalProperty) === null || _c === void 0 ? void 0 : _c.find((p) => p.name === 'ticketCode')) === null || _d === void 0 ? void 0 : _d.value;
|
|
49
|
+
if (typeof serviceType !== 'string') {
|
|
50
|
+
throw new factory.errors.NotFound('ticketCode of unitPriceOffer');
|
|
51
|
+
}
|
|
52
|
+
const surfrockChargePriceSpec = {
|
|
53
|
+
typeOf: factory.priceSpecificationType.MovieTicketTypeChargeSpecification,
|
|
54
|
+
price: 0,
|
|
55
|
+
priceCurrency: factory.priceCurrency.JPY,
|
|
56
|
+
valueAddedTaxIncluded: true,
|
|
57
|
+
appliesToMovieTicket: {
|
|
58
|
+
typeOf: factory.service.paymentService.PaymentServiceType.MovieTicket,
|
|
59
|
+
serviceOutput: { typeOf: MENBERSHIP_COUPON_PAYMENT_METHOD_TYPE },
|
|
60
|
+
serviceType
|
|
61
|
+
},
|
|
62
|
+
appliesToVideoFormat: 'Default'
|
|
63
|
+
};
|
|
64
|
+
// priceComponentに追加
|
|
65
|
+
priceSpecification.priceComponent = priceSpecification.priceComponent.map((component) => {
|
|
66
|
+
if (component.typeOf === factory.priceSpecificationType.UnitPriceSpecification) {
|
|
67
|
+
if (!Array.isArray(component.appliesToMovieTicket)) {
|
|
68
|
+
component.appliesToMovieTicket = [];
|
|
69
|
+
}
|
|
70
|
+
component.appliesToMovieTicket.push({
|
|
71
|
+
typeOf: factory.service.paymentService.PaymentServiceType.MovieTicket,
|
|
72
|
+
identifier: surfrockIdentifier,
|
|
73
|
+
serviceOutput: { typeOf: MENBERSHIP_COUPON_PAYMENT_METHOD_TYPE },
|
|
74
|
+
serviceType
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
return component;
|
|
78
|
+
});
|
|
79
|
+
priceSpecification.priceComponent.push(surfrockChargePriceSpec);
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
// appliesToSurfrockの指定がなければ単価オファーの適用通貨条件を強制適用
|
|
83
|
+
if (Array.isArray(availableUnitPriceOffer.eligibleMonetaryAmount)) {
|
|
84
|
+
eligibleMonetaryAmount = availableUnitPriceOffer.eligibleMonetaryAmount;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
38
87
|
return Object.assign(Object.assign({ additionalProperty,
|
|
39
88
|
itemOffered,
|
|
40
89
|
name,
|
|
@@ -42,15 +91,13 @@ function validateAcceptedOffers(params) {
|
|
|
42
91
|
priceSpecification,
|
|
43
92
|
ticketInfo,
|
|
44
93
|
// 以下属性については単価オファーから読む(2023-03-09~)
|
|
45
|
-
priceCurrency: availableUnitPriceOffer.priceCurrency, id: String(availableUnitPriceOffer.id), identifier: String(availableUnitPriceOffer.identifier), typeOf: availableUnitPriceOffer.typeOf }, (Array.isArray(
|
|
46
|
-
? { eligibleMonetaryAmount: availableUnitPriceOffer.eligibleMonetaryAmount }
|
|
47
|
-
: undefined), {
|
|
94
|
+
priceCurrency: availableUnitPriceOffer.priceCurrency, id: String(availableUnitPriceOffer.id), identifier: String(availableUnitPriceOffer.identifier), typeOf: availableUnitPriceOffer.typeOf }, (Array.isArray(eligibleMonetaryAmount)) ? { eligibleMonetaryAmount } : undefined), {
|
|
48
95
|
// tslint:disable-next-line:no-suspicious-comment
|
|
49
96
|
// TODO itemOfferedに完全置き換え
|
|
50
|
-
seatNumber: (
|
|
97
|
+
seatNumber: (_g = (_f = (_e = itemOffered.serviceOutput) === null || _e === void 0 ? void 0 : _e.reservedTicket) === null || _f === void 0 ? void 0 : _f.ticketedSeat) === null || _g === void 0 ? void 0 : _g.seatNumber,
|
|
51
98
|
// tslint:disable-next-line:no-suspicious-comment
|
|
52
99
|
// TODO itemOfferedに完全置き換え
|
|
53
|
-
seatSection: (
|
|
100
|
+
seatSection: (_k = (_j = (_h = itemOffered.serviceOutput) === null || _h === void 0 ? void 0 : _h.reservedTicket) === null || _j === void 0 ? void 0 : _j.ticketedSeat) === null || _k === void 0 ? void 0 : _k.seatSection
|
|
54
101
|
});
|
|
55
102
|
});
|
|
56
103
|
return { acceptedOffers };
|
package/package.json
CHANGED
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
}
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@chevre/factory": "4.
|
|
13
|
-
"@cinerino/sdk": "3.
|
|
12
|
+
"@chevre/factory": "4.301.0-alpha.0",
|
|
13
|
+
"@cinerino/sdk": "3.149.0-alpha.0",
|
|
14
14
|
"@motionpicture/coa-service": "9.2.0",
|
|
15
15
|
"@motionpicture/gmo-service": "5.2.0",
|
|
16
16
|
"@sendgrid/mail": "6.4.0",
|
|
@@ -120,5 +120,5 @@
|
|
|
120
120
|
"postversion": "git push origin --tags",
|
|
121
121
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
122
122
|
},
|
|
123
|
-
"version": "20.7.0-alpha.
|
|
123
|
+
"version": "20.7.0-alpha.4"
|
|
124
124
|
}
|