@chevre/domain 21.29.0-alpha.8 → 21.29.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/migrateCancelReservationObject.ts +71 -0
- package/example/src/chevre/{migrateOrderAcceptedOfferSerialNumber.ts → migrateOrderAcceptedOfferReservedTicketIdentifier.ts} +27 -16
- package/example/src/chevre/migratePayTransactionReservedTicketIdentifier.ts +95 -0
- package/example/src/chevre/searchAssetTransactions.ts +38 -0
- package/example/src/chevre/searchOrders.ts +6 -1
- package/lib/chevre/repo/acceptedOffer.d.ts +7 -2
- package/lib/chevre/repo/acceptedOffer.js +8 -4
- package/lib/chevre/repo/account.js +1 -1
- package/lib/chevre/repo/aggregateOffer.js +1 -1
- package/lib/chevre/repo/assetTransaction.d.ts +24 -3
- package/lib/chevre/repo/assetTransaction.js +96 -72
- package/lib/chevre/repo/creativeWork.js +1 -1
- package/lib/chevre/repo/event.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/assetTransaction.d.ts +1 -1
- package/lib/chevre/repo/mongoose/schemas/assetTransaction.js +31 -23
- package/lib/chevre/repo/mongoose/schemas/order.js +12 -3
- package/lib/chevre/repo/order.js +14 -5
- package/lib/chevre/repo/paymentServiceProvider.js +1 -1
- package/lib/chevre/repo/product.js +1 -1
- package/lib/chevre/repo/productModel.d.ts +22 -3
- package/lib/chevre/repo/productModel.js +40 -3
- package/lib/chevre/repo/seller.js +1 -1
- package/lib/chevre/repo/serviceOutput.js +1 -1
- package/lib/chevre/repo/transaction.js +1 -1
- package/lib/chevre/service/assetTransaction/cancelReservation/factory.js +8 -1
- package/lib/chevre/service/assetTransaction/pay/potentialActions/createPayObjectServiceOutput.d.ts +4 -0
- package/lib/chevre/service/assetTransaction/pay/potentialActions/createPayObjectServiceOutput.js +36 -28
- package/lib/chevre/service/payment/any/factory.d.ts +1 -0
- package/lib/chevre/service/payment/any/factory.js +2 -1
- package/lib/chevre/service/payment/any.js +2 -1
- package/lib/chevre/service/report/telemetry.js +1 -1
- package/lib/chevre/service/task/onResourceUpdated/onCategoryCodeUpdated.d.ts +15 -0
- package/lib/chevre/service/task/onResourceUpdated/onCategoryCodeUpdated.js +26 -0
- package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.d.ts +2 -0
- package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.js +9 -0
- package/lib/chevre/service/task/onResourceUpdated/syncCategoryCode.d.ts +15 -0
- package/lib/chevre/service/task/onResourceUpdated/syncCategoryCode.js +54 -0
- package/lib/chevre/service/task/onResourceUpdated.js +11 -0
- package/lib/chevre/service/transaction/deleteTransaction.js +25 -3
- package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateMovieTicket.d.ts +1 -5
- package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateMovieTicket.js +94 -57
- package/lib/chevre/service/transaction/placeOrderInProgress/validation.js +18 -0
- package/lib/chevre/service/validation/validateOrder.js +13 -1
- package/lib/chevre/settings.d.ts +1 -4
- package/lib/chevre/settings.js +2 -8
- package/package.json +2 -2
- package/example/src/chevre/migrateOrderSeller.ts +0 -65
- package/example/src/chevre/migrateScreeningEventSeriesOffers.ts +0 -87
- package/example/src/chevre/playAroundProductModel.ts +0 -64
package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateMovieTicket.js
CHANGED
|
@@ -6,6 +6,7 @@ exports.validateMovieTicket = void 0;
|
|
|
6
6
|
*/
|
|
7
7
|
const createDebug = require("debug");
|
|
8
8
|
const factory = require("../../../../factory");
|
|
9
|
+
const settings_1 = require("../../../../settings");
|
|
9
10
|
const debug = createDebug('chevre-domain:service:validateMovieTicket');
|
|
10
11
|
/**
|
|
11
12
|
* 興行オファー承認に対して決済承認条件が整っているかどうか検証する
|
|
@@ -58,9 +59,11 @@ eventReservationAcceptedOffers) {
|
|
|
58
59
|
// イベントとムビチケ券種区分ごとに枚数OK?
|
|
59
60
|
const eventIds = [...new Set(requiredMovieTickets.map((t) => t.serviceOutput.reservationFor.id))];
|
|
60
61
|
debug('movie ticket event ids:', eventIds, 'transaction:', transaction.id);
|
|
62
|
+
// tslint:disable-next-line:max-func-body-length
|
|
61
63
|
eventIds.forEach((eventId) => {
|
|
62
64
|
const requiredMovieTicketsByEvent = requiredMovieTickets.filter((t) => t.serviceOutput.reservationFor.id === eventId);
|
|
63
65
|
const authorizedMovieTicketsByEvent = authorizedMovieTickets.filter((t) => t.serviceOutput.reservationFor.id === eventId);
|
|
66
|
+
debug('validating authorizedMovieTicketsByEvent,requiredMovieTicketsByEvent by eventId...', eventId, JSON.stringify(authorizedMovieTicketsByEvent), JSON.stringify(requiredMovieTicketsByEvent));
|
|
64
67
|
// 合計枚数OK?
|
|
65
68
|
if (requiredMovieTicketsByEvent.length !== authorizedMovieTicketsByEvent.length) {
|
|
66
69
|
throw new factory.errors.Argument('transactionId', `required movie tickets for the event '${eventId}' not satisfied`);
|
|
@@ -77,6 +80,22 @@ eventReservationAcceptedOffers) {
|
|
|
77
80
|
if (!authorizedMovieTicketExists) {
|
|
78
81
|
throw new factory.errors.Argument('transactionId', `required movie tickets for the event '${eventId}' not satisfied`);
|
|
79
82
|
}
|
|
83
|
+
// チケット識別子での検証に対応(2024-04-16)
|
|
84
|
+
if (settings_1.USE_VALIDATE_MOVIE_TICKET_BY_TICKET_IDENTIFIER) {
|
|
85
|
+
const authorizedMovieTicketByTicketIdentifierExists = authorizedMovieTicketsByEvent.some((authorizedMovieTicket) => {
|
|
86
|
+
return authorizedMovieTicket.serviceType === requiredMovieTicket.serviceType
|
|
87
|
+
&& authorizedMovieTicket.serviceOutput.reservedTicket.ticketedSeat.seatNumber
|
|
88
|
+
=== requiredMovieTicket.serviceOutput.reservedTicket.ticketedSeat.seatNumber
|
|
89
|
+
&& authorizedMovieTicket.serviceOutput.reservedTicket.ticketedSeat.seatSection
|
|
90
|
+
=== requiredMovieTicket.serviceOutput.reservedTicket.ticketedSeat.seatSection
|
|
91
|
+
&& typeof authorizedMovieTicket.serviceOutput.reservedTicket.identifier === 'string'
|
|
92
|
+
&& authorizedMovieTicket.serviceOutput.reservedTicket.identifier
|
|
93
|
+
=== requiredMovieTicket.serviceOutput.reservedTicket.identifier;
|
|
94
|
+
});
|
|
95
|
+
if (!authorizedMovieTicketByTicketIdentifierExists) {
|
|
96
|
+
throw new factory.errors.Argument('transactionId', `required movie tickets(reservedTicket.identifier) for the event '${eventId}' not satisfied`);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
80
99
|
});
|
|
81
100
|
// 券種ごとに枚数が適切か確認
|
|
82
101
|
const serviceTypesAuthorized = [...new Set(authorizedMovieTicketsByEvent.map(({ serviceType }) => serviceType))];
|
|
@@ -109,6 +128,26 @@ eventReservationAcceptedOffers) {
|
|
|
109
128
|
throw new factory.errors.Argument('transactionId', `required movie tickets for seatNumber '${seatNumber}' not satisfied`);
|
|
110
129
|
}
|
|
111
130
|
});
|
|
131
|
+
if (settings_1.USE_VALIDATE_MOVIE_TICKET_BY_TICKET_IDENTIFIER) {
|
|
132
|
+
// チケット識別子リストが一致しているか確認
|
|
133
|
+
const reservedTicketIdentifierAuthorized = authorizedMovieTicketsByEvent.map(({ serviceOutput }) => serviceOutput.reservedTicket.identifier);
|
|
134
|
+
const reservedTicketIdentifiers = requiredMovieTicketsByEvent.map(({ serviceOutput }) => serviceOutput.reservedTicket.identifier);
|
|
135
|
+
if (reservedTicketIdentifierAuthorized.length !== reservedTicketIdentifiers.length) {
|
|
136
|
+
throw new factory.errors.Argument('transactionId', `required movie tickets(reservedTicket.identifier) for event '${eventId}' not satisfied`);
|
|
137
|
+
}
|
|
138
|
+
reservedTicketIdentifiers.forEach((reservedTicketIdentifier) => {
|
|
139
|
+
if (typeof reservedTicketIdentifier !== 'string') {
|
|
140
|
+
throw new factory.errors.Argument('transactionId', `reservedTicket.identifier for event '${eventId}' required`);
|
|
141
|
+
}
|
|
142
|
+
const requiredMovieTicketsByReservedTicketIdentifier = requiredMovieTicketsByEvent.filter((t) => t.serviceOutput.reservedTicket.identifier === reservedTicketIdentifier);
|
|
143
|
+
const authorizedMovieTicketsByReservedTicketIdentifier = authorizedMovieTicketsByEvent.filter((t) => {
|
|
144
|
+
return t.serviceOutput.reservedTicket.identifier === reservedTicketIdentifier;
|
|
145
|
+
});
|
|
146
|
+
if (requiredMovieTicketsByReservedTicketIdentifier.length !== authorizedMovieTicketsByReservedTicketIdentifier.length) {
|
|
147
|
+
throw new factory.errors.Argument('transactionId', `required movie tickets for reservedTicket.identifier '${reservedTicketIdentifier}' not satisfied`);
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
}
|
|
112
151
|
validateAppliesToMovieTicketIdentifiers({
|
|
113
152
|
requiredMovieTicketsByEvent,
|
|
114
153
|
authorizedMovieTicketsByEvent,
|
|
@@ -136,73 +175,71 @@ function validateAppliesToMovieTicketIdentifiers(params) {
|
|
|
136
175
|
*/
|
|
137
176
|
function authorizeSeatReservationActions2requiredMovieTickets(params) {
|
|
138
177
|
const paymentMethodType = params.paymentMethodType;
|
|
139
|
-
//
|
|
140
|
-
// ムビチケオファーを受け付けた座席予約を検索する
|
|
178
|
+
// 決済カードオファーを受け付けた座席予約を検索する
|
|
141
179
|
const requiredMovieTickets = [];
|
|
142
|
-
// tslint:disable-next-line:max-func-body-length
|
|
143
|
-
// seatReservationAuthorizeActions.forEach((action) => {
|
|
144
|
-
// const acceptedOffers = action.result?.acceptedOffers;
|
|
145
|
-
// });
|
|
146
180
|
if (Array.isArray(params.acceptedOffers)) {
|
|
147
181
|
params.acceptedOffers.forEach((offer) => {
|
|
148
|
-
var _a, _b, _c
|
|
149
|
-
|
|
150
|
-
const
|
|
151
|
-
|
|
152
|
-
|
|
182
|
+
var _a, _b, _c;
|
|
183
|
+
// 単価仕様のappliesToMovieTicketを参照してrequiredMovieTicketsを作成する(2022-07-28~)
|
|
184
|
+
const unitPriceSpec = (_a = offer.priceSpecification) === null || _a === void 0 ? void 0 : _a.priceComponent.find((component) => {
|
|
185
|
+
return component.typeOf === factory.priceSpecificationType.UnitPriceSpecification
|
|
186
|
+
&& (!Array.isArray(component.appliesToAddOn));
|
|
187
|
+
});
|
|
188
|
+
if (unitPriceSpec === undefined) {
|
|
189
|
+
throw new factory.errors.NotFound('UnitPriceSpecification of acceptedOffer');
|
|
153
190
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
const eventOfferedThroughIdentifier = (_c = offer.offeredThrough) === null || _c === void 0 ? void 0 : _c.identifier;
|
|
157
|
-
// tslint:disable-next-line:no-single-line-block-comment
|
|
158
|
-
/* istanbul ignore if */
|
|
159
|
-
if (typeof eventOfferedThroughIdentifier !== 'string') {
|
|
160
|
-
throw new factory.errors.NotFound('offer.offeredThrough.identifier', `offer.offeredThrough.identifier undefined [serialNumber:${offer.serialNumber}]`);
|
|
161
|
-
}
|
|
162
|
-
// シンプルに単価仕様のappliesToMovieTicketを参照してrequiredMovieTicketsを作成する(2022-07-28~)
|
|
163
|
-
const unitPriceSpec = (_d = offer.priceSpecification) === null || _d === void 0 ? void 0 : _d.priceComponent.find((component) => {
|
|
164
|
-
return component.typeOf === factory.priceSpecificationType.UnitPriceSpecification
|
|
165
|
-
&& (!Array.isArray(component.appliesToAddOn));
|
|
166
|
-
});
|
|
167
|
-
// tslint:disable-next-line:no-single-line-block-comment
|
|
168
|
-
/* istanbul ignore if */
|
|
169
|
-
if (unitPriceSpec === undefined) {
|
|
170
|
-
throw new factory.errors.NotFound('UnitPriceSpecification of acceptedOffer');
|
|
171
|
-
}
|
|
172
|
-
// tslint:disable-next-line:no-single-line-block-comment
|
|
173
|
-
/* istanbul ignore if */
|
|
174
|
-
if (offer.itemOffered.reservationFor.typeOf !== factory.eventType.ScreeningEvent) {
|
|
175
|
-
throw new factory.errors.NotImplemented(`offer.itemOffered.reservationFor.typeOf not imelemented [${offer.itemOffered.reservationFor.typeOf}]`);
|
|
176
|
-
}
|
|
191
|
+
// 現状、ScreeningEventのみ対応で十分(2024-04-16~)
|
|
192
|
+
if (offer.itemOffered.reservationFor.typeOf === factory.eventType.ScreeningEvent) {
|
|
177
193
|
const reservationFor4movieTicket = {
|
|
178
194
|
typeOf: offer.itemOffered.reservationFor.typeOf,
|
|
179
195
|
id: offer.itemOffered.reservationFor.id
|
|
180
196
|
};
|
|
181
|
-
//
|
|
182
|
-
let
|
|
183
|
-
|
|
184
|
-
if (
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
197
|
+
// 座席無に対応(2024-04-16~)
|
|
198
|
+
let ticketedSeat4MovieTicket;
|
|
199
|
+
// USE_VALIDATE_MOVIE_TICKET_BY_TICKET_IDENTIFIERのみ座席無に対応(2024-04-16~)
|
|
200
|
+
if (settings_1.USE_VALIDATE_MOVIE_TICKET_BY_TICKET_IDENTIFIER) {
|
|
201
|
+
ticketedSeat4MovieTicket = {
|
|
202
|
+
typeOf: factory.placeType.Seat,
|
|
203
|
+
seatNumber: '',
|
|
204
|
+
seatRow: '',
|
|
205
|
+
seatSection: ''
|
|
206
|
+
};
|
|
188
207
|
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
208
|
+
const offeredTicketedSeat = (_c = (_b = offer.itemOffered) === null || _b === void 0 ? void 0 : _b.reservedTicket) === null || _c === void 0 ? void 0 : _c.ticketedSeat;
|
|
209
|
+
const ticketedSeatExists = (offeredTicketedSeat === null || offeredTicketedSeat === void 0 ? void 0 : offeredTicketedSeat.typeOf) === factory.placeType.Seat;
|
|
210
|
+
if (ticketedSeatExists) {
|
|
211
|
+
ticketedSeat4MovieTicket = offeredTicketedSeat;
|
|
212
|
+
}
|
|
213
|
+
if (ticketedSeat4MovieTicket !== undefined) {
|
|
214
|
+
// チケット識別子(決済カード承認との照合に必要)
|
|
215
|
+
const reservedTicketIdentifier = (typeof offer.itemOffered.reservedTicket.identifier === 'string')
|
|
216
|
+
? offer.itemOffered.reservedTicket.identifier
|
|
217
|
+
: `${reservationFor4movieTicket.id}:${offer.itemOffered.id}`;
|
|
218
|
+
const movieTicketServiceOutput4validate = {
|
|
219
|
+
reservationFor: reservationFor4movieTicket,
|
|
220
|
+
reservedTicket: {
|
|
221
|
+
identifier: reservedTicketIdentifier,
|
|
222
|
+
ticketedSeat: ticketedSeat4MovieTicket
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
// 指定された決済方法の適用決済カードリスト
|
|
226
|
+
let appliesToMovieTickets4paymentMethod = [];
|
|
227
|
+
const appliesToMovieTickets4reservation = unitPriceSpec.appliesToMovieTicket;
|
|
228
|
+
if (Array.isArray(appliesToMovieTickets4reservation)) {
|
|
229
|
+
appliesToMovieTickets4paymentMethod = appliesToMovieTickets4reservation.filter((a) => {
|
|
230
|
+
return a.serviceOutput.typeOf === paymentMethodType;
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
if (Array.isArray(appliesToMovieTickets4paymentMethod) && appliesToMovieTickets4paymentMethod.length > 0) {
|
|
234
|
+
appliesToMovieTickets4paymentMethod.forEach((appliesToMovieTicket) => {
|
|
235
|
+
requiredMovieTickets.push({
|
|
236
|
+
typeOf: paymentMethodType,
|
|
237
|
+
identifier: String(appliesToMovieTicket.identifier),
|
|
238
|
+
serviceType: appliesToMovieTicket.serviceType,
|
|
239
|
+
serviceOutput: movieTicketServiceOutput4validate
|
|
240
|
+
});
|
|
204
241
|
});
|
|
205
|
-
}
|
|
242
|
+
}
|
|
206
243
|
}
|
|
207
244
|
}
|
|
208
245
|
});
|
|
@@ -241,6 +241,24 @@ function validateAcceptedOffers(params) {
|
|
|
241
241
|
throw new factory.errors.Argument('Transaction', (0, util_1.format)('Number of reservationNumbers must be less than or equal to %s', maxNumCOAReservationNumbers));
|
|
242
242
|
}
|
|
243
243
|
}
|
|
244
|
+
// チケット識別子ユニークネス検証(2024-04-16~)
|
|
245
|
+
let ticketIdentifiers = [];
|
|
246
|
+
params.acceptedOffers.forEach(({ itemOffered }) => {
|
|
247
|
+
if (itemOffered.typeOf === factory.reservationType.BusReservation
|
|
248
|
+
|| itemOffered.typeOf === factory.reservationType.EventReservation) {
|
|
249
|
+
if (typeof itemOffered.reservedTicket.identifier === 'string') {
|
|
250
|
+
ticketIdentifiers.push(itemOffered.reservedTicket.identifier);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
if (ticketIdentifiers.length > 0) {
|
|
255
|
+
ticketIdentifiers = [...new Set(ticketIdentifiers)];
|
|
256
|
+
debug('ticketIdentifiers unique?', ticketIdentifiers.join(' '), 'numAcceptedOffers:', numAcceptedOffers);
|
|
257
|
+
// チケット識別子が注文内ユニークなので、注文オファー数に一致するはず
|
|
258
|
+
if (ticketIdentifiers.length !== numAcceptedOffers) {
|
|
259
|
+
throw new factory.errors.Argument('Transaction', 'ticketIdentifiers must be unique');
|
|
260
|
+
}
|
|
261
|
+
}
|
|
244
262
|
// チケット識別子ユニークネス検証(2024-04-15~)
|
|
245
263
|
let ticketNumbers = [];
|
|
246
264
|
params.acceptedOffers.forEach(({ itemOffered }) => {
|
|
@@ -18,7 +18,7 @@ const factory_2 = require("../offer/product/factory");
|
|
|
18
18
|
const validateMovieTicket_1 = require("../transaction/placeOrderInProgress/validation/validateMovieTicket");
|
|
19
19
|
// const debug = createDebug('chevre-domain:service:validation');
|
|
20
20
|
function validateOrder(params) {
|
|
21
|
-
// tslint:disable-next-line:max-func-body-length
|
|
21
|
+
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
22
22
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
23
23
|
const order = yield repos.order.findByOrderNumber({
|
|
24
24
|
orderNumber: params.orderNumber,
|
|
@@ -79,11 +79,15 @@ function validateOrder(params) {
|
|
|
79
79
|
});
|
|
80
80
|
let reservationForIds = [];
|
|
81
81
|
let itemOfferedTypeOfs = [];
|
|
82
|
+
let reservationReservedTicketIdentifiers = [];
|
|
82
83
|
acceptedOffers.forEach(({ itemOffered }) => {
|
|
83
84
|
itemOfferedTypeOfs.push(itemOffered.typeOf);
|
|
84
85
|
if (itemOffered.typeOf === factory.reservationType.BusReservation
|
|
85
86
|
|| itemOffered.typeOf === factory.reservationType.EventReservation) {
|
|
86
87
|
reservationForIds.push(itemOffered.reservationFor.id);
|
|
88
|
+
if (typeof itemOffered.reservedTicket.identifier === 'string') {
|
|
89
|
+
reservationReservedTicketIdentifiers.push(itemOffered.reservedTicket.identifier);
|
|
90
|
+
}
|
|
87
91
|
}
|
|
88
92
|
});
|
|
89
93
|
reservationForIds = [...new Set(reservationForIds)];
|
|
@@ -179,6 +183,14 @@ function validateOrder(params) {
|
|
|
179
183
|
});
|
|
180
184
|
(0, validateMovieTicket_1.validateMovieTicket)(paymentMethod.identifier, { id: 'xxxx' }, authorizedMovieTickets, acceptedOffers);
|
|
181
185
|
});
|
|
186
|
+
// チケット識別子ユニークネス検証(2024-04-17~)
|
|
187
|
+
if (reservationReservedTicketIdentifiers.length > 0) {
|
|
188
|
+
reservationReservedTicketIdentifiers = [...new Set(reservationReservedTicketIdentifiers)];
|
|
189
|
+
// チケット識別子が注文内ユニークなので、注文オファー数に一致するはず
|
|
190
|
+
if (reservationReservedTicketIdentifiers.length !== acceptedOffers.length) {
|
|
191
|
+
throw new Error(`invalid ticketIdentifiers.length:${reservationReservedTicketIdentifiers.length} [expected:${acceptedOffers.length}]`);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
182
194
|
});
|
|
183
195
|
}
|
|
184
196
|
exports.validateOrder = validateOrder;
|
package/lib/chevre/settings.d.ts
CHANGED
|
@@ -4,10 +4,6 @@ export declare const TRIGGER_WEBHOOK_RETRY_INTERVAL_IN_MS: number;
|
|
|
4
4
|
export declare const MAXIMUM_RESERVATION_GRACE_PERIOD_IN_DAYS: number;
|
|
5
5
|
export declare const ABORTED_TASKS_WITHOUT_REPORT: string[];
|
|
6
6
|
export declare const MAX_NUM_CREDIT_CARD_PAYMENT_METHOD: number;
|
|
7
|
-
/**
|
|
8
|
-
* 資産取引保管期間
|
|
9
|
-
*/
|
|
10
|
-
export declare const ASSET_TRANSACTION_STORAGE_PERIOD_IN_DAYS: number;
|
|
11
7
|
/**
|
|
12
8
|
* 取引保管期間(Confirmed)
|
|
13
9
|
*/
|
|
@@ -43,6 +39,7 @@ export declare const USE_OWNERSHIP_INFO_BY_WEB_APPLICATION: boolean;
|
|
|
43
39
|
export declare const USE_CHECK_RESOURCE_TASK: boolean;
|
|
44
40
|
export declare const USE_OPTIMIZE_RESERVATION_EXCEPTIONS: string[];
|
|
45
41
|
export declare const USE_OPTIMIZE_INFORM_EVENT: boolean;
|
|
42
|
+
export declare const USE_VALIDATE_MOVIE_TICKET_BY_TICKET_IDENTIFIER: boolean;
|
|
46
43
|
export declare const MONGO_MAX_TIME_MS: number;
|
|
47
44
|
export declare const MONGO_READ_PREFERENCE: string;
|
|
48
45
|
export declare const MONGO_AUTO_INDEX: boolean;
|
package/lib/chevre/settings.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.settings = exports.DELIVER_ORDER_LIMIT = exports.MONGO_AUTO_INDEX = exports.MONGO_READ_PREFERENCE = exports.MONGO_MAX_TIME_MS = exports.USE_OPTIMIZE_INFORM_EVENT = exports.USE_OPTIMIZE_RESERVATION_EXCEPTIONS = exports.USE_CHECK_RESOURCE_TASK = exports.USE_OWNERSHIP_INFO_BY_WEB_APPLICATION = exports.USE_SEND_EMAIL_MESSAGE_ON_ORDER_PROCESSING = exports.USE_FETCH_API = exports.USE_OPTIMIZE_TICKET_OFFER = exports.USE_DELETE_EVENT_BY_ORDER = exports.USE_ASSET_TRANSACTION_SYNC_PROCESSING = exports.DEFAULT_TASKS_EXPORT_AGENT_NAME = exports.DEFAULT_SENDER_EMAIL = exports.TRANSACTION_CANCELED_STORAGE_PERIOD_IN_DAYS = exports.TRANSACTION_CONFIRMED_STORAGE_PERIOD_IN_DAYS = exports.
|
|
3
|
+
exports.settings = exports.DELIVER_ORDER_LIMIT = exports.MONGO_AUTO_INDEX = exports.MONGO_READ_PREFERENCE = exports.MONGO_MAX_TIME_MS = exports.USE_VALIDATE_MOVIE_TICKET_BY_TICKET_IDENTIFIER = exports.USE_OPTIMIZE_INFORM_EVENT = exports.USE_OPTIMIZE_RESERVATION_EXCEPTIONS = exports.USE_CHECK_RESOURCE_TASK = exports.USE_OWNERSHIP_INFO_BY_WEB_APPLICATION = exports.USE_SEND_EMAIL_MESSAGE_ON_ORDER_PROCESSING = exports.USE_FETCH_API = exports.USE_OPTIMIZE_TICKET_OFFER = exports.USE_DELETE_EVENT_BY_ORDER = exports.USE_ASSET_TRANSACTION_SYNC_PROCESSING = exports.DEFAULT_TASKS_EXPORT_AGENT_NAME = exports.DEFAULT_SENDER_EMAIL = exports.TRANSACTION_CANCELED_STORAGE_PERIOD_IN_DAYS = exports.TRANSACTION_CONFIRMED_STORAGE_PERIOD_IN_DAYS = exports.MAX_NUM_CREDIT_CARD_PAYMENT_METHOD = exports.ABORTED_TASKS_WITHOUT_REPORT = exports.MAXIMUM_RESERVATION_GRACE_PERIOD_IN_DAYS = exports.TRIGGER_WEBHOOK_RETRY_INTERVAL_IN_MS = exports.TRIGGER_WEBHOOK_MAX_RETRY_COUNT = void 0;
|
|
4
4
|
const factory = require("./factory");
|
|
5
5
|
const transactionWebhookUrls = (typeof process.env.INFORM_TRANSACTION_URL === 'string')
|
|
6
6
|
? process.env.INFORM_TRANSACTION_URL.split(' ')
|
|
@@ -35,13 +35,6 @@ exports.ABORTED_TASKS_WITHOUT_REPORT = (typeof process.env.ABORTED_TASKS_WITHOUT
|
|
|
35
35
|
exports.MAX_NUM_CREDIT_CARD_PAYMENT_METHOD = (typeof process.env.MAX_NUM_CREDIT_CARD_PAYMENT_METHOD === 'string')
|
|
36
36
|
? Number(process.env.MAX_NUM_CREDIT_CARD_PAYMENT_METHOD)
|
|
37
37
|
: 1;
|
|
38
|
-
/**
|
|
39
|
-
* 資産取引保管期間
|
|
40
|
-
*/
|
|
41
|
-
exports.ASSET_TRANSACTION_STORAGE_PERIOD_IN_DAYS = (typeof process.env.ASSET_TRANSACTION_STORAGE_PERIOD_IN_DAYS === 'string')
|
|
42
|
-
? Number(process.env.ASSET_TRANSACTION_STORAGE_PERIOD_IN_DAYS)
|
|
43
|
-
// tslint:disable-next-line:no-magic-numbers
|
|
44
|
-
: 500;
|
|
45
38
|
/**
|
|
46
39
|
* 取引保管期間(Confirmed)
|
|
47
40
|
*/
|
|
@@ -69,6 +62,7 @@ exports.USE_OPTIMIZE_RESERVATION_EXCEPTIONS = (typeof process.env.USE_OPTIMIZE_R
|
|
|
69
62
|
? process.env.USE_OPTIMIZE_RESERVATION_EXCEPTIONS.split(' ')
|
|
70
63
|
: [];
|
|
71
64
|
exports.USE_OPTIMIZE_INFORM_EVENT = process.env.USE_OPTIMIZE_INFORM_EVENT === '1';
|
|
65
|
+
exports.USE_VALIDATE_MOVIE_TICKET_BY_TICKET_IDENTIFIER = process.env.USE_VALIDATE_MOVIE_TICKET_BY_TICKET_IDENTIFIER === '1';
|
|
72
66
|
exports.MONGO_MAX_TIME_MS = (typeof process.env.MONGO_MAX_TIME_MS === 'string')
|
|
73
67
|
? Number(process.env.MONGO_MAX_TIME_MS)
|
|
74
68
|
// tslint:disable-next-line:no-magic-numbers
|
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.367.0
|
|
13
|
+
"@chevre/factory": "4.367.0",
|
|
14
14
|
"@cinerino/sdk": "5.17.1",
|
|
15
15
|
"@motionpicture/coa-service": "9.4.0",
|
|
16
16
|
"@motionpicture/gmo-service": "5.3.0",
|
|
@@ -110,5 +110,5 @@
|
|
|
110
110
|
"postversion": "git push origin --tags",
|
|
111
111
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
112
112
|
},
|
|
113
|
-
"version": "21.29.0
|
|
113
|
+
"version": "21.29.0"
|
|
114
114
|
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
// tslint:disable:no-console
|
|
2
|
-
import * as moment from 'moment';
|
|
3
|
-
import * as mongoose from 'mongoose';
|
|
4
|
-
|
|
5
|
-
import { chevre } from '../../../lib/index';
|
|
6
|
-
|
|
7
|
-
// const project = { id: String(process.env.PROJECT_ID) };
|
|
8
|
-
|
|
9
|
-
// tslint:disable-next-line:max-func-body-length
|
|
10
|
-
async function main() {
|
|
11
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
12
|
-
|
|
13
|
-
const orderRepo = await chevre.repository.Order.createInstance(mongoose.connection);
|
|
14
|
-
|
|
15
|
-
const cursor = orderRepo.getCursor(
|
|
16
|
-
{
|
|
17
|
-
orderDate: {
|
|
18
|
-
$gte: moment()
|
|
19
|
-
// tslint:disable-next-line:no-magic-numbers
|
|
20
|
-
.add(-12, 'months')
|
|
21
|
-
.toDate()
|
|
22
|
-
// $lte: moment()
|
|
23
|
-
// // tslint:disable-next-line:no-magic-numbers
|
|
24
|
-
// .add(-6, 'months')
|
|
25
|
-
// .toDate()
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
orderDate: 1,
|
|
30
|
-
orderNumber: 1,
|
|
31
|
-
project: 1,
|
|
32
|
-
seller: 1
|
|
33
|
-
}
|
|
34
|
-
);
|
|
35
|
-
console.log('orders found');
|
|
36
|
-
|
|
37
|
-
let i = 0;
|
|
38
|
-
let updateCount = 0;
|
|
39
|
-
await cursor.eachAsync(async (doc) => {
|
|
40
|
-
i += 1;
|
|
41
|
-
const order: Pick<
|
|
42
|
-
chevre.factory.order.IOrder,
|
|
43
|
-
'orderDate' | 'orderNumber' | 'project' | 'seller'
|
|
44
|
-
> = doc.toObject();
|
|
45
|
-
console.log(order);
|
|
46
|
-
|
|
47
|
-
const alreadyMigrated = (<any>order.seller).telephone === undefined
|
|
48
|
-
&& (<any>order.seller).url === undefined;
|
|
49
|
-
|
|
50
|
-
if (alreadyMigrated) {
|
|
51
|
-
console.log('already exist.', order.project.id, order.orderNumber, order.orderDate, i, updateCount);
|
|
52
|
-
} else {
|
|
53
|
-
console.log('updating...', order.project.id, order.orderNumber, order.orderDate, i, updateCount);
|
|
54
|
-
updateCount += 1;
|
|
55
|
-
console.log('updated.', order.project.id, order.orderNumber, order.orderDate, i, updateCount);
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
console.log(i, 'orders checked');
|
|
60
|
-
console.log(updateCount, 'orders updated');
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
main()
|
|
64
|
-
.then()
|
|
65
|
-
.catch(console.error);
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
// tslint:disable:no-console
|
|
2
|
-
import * as moment from 'moment';
|
|
3
|
-
import * as mongoose from 'mongoose';
|
|
4
|
-
|
|
5
|
-
import { chevre } from '../../../lib/index';
|
|
6
|
-
|
|
7
|
-
// const project = { id: String(process.env.PROJECT_ID) };
|
|
8
|
-
const EXCLUDED_PROJECT_ID = process.env.EXCLUDED_PROJECT_ID;
|
|
9
|
-
|
|
10
|
-
// tslint:disable-next-line:max-func-body-length
|
|
11
|
-
async function main() {
|
|
12
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
13
|
-
|
|
14
|
-
const eventRepo = await chevre.repository.Event.createInstance(mongoose.connection);
|
|
15
|
-
|
|
16
|
-
const cursor = eventRepo.getCursor(
|
|
17
|
-
{
|
|
18
|
-
typeOf: { $eq: chevre.factory.eventType.ScreeningEventSeries },
|
|
19
|
-
// typeOf: { $eq: chevre.factory.eventType.ScreeningEvent },
|
|
20
|
-
'project.id': { $ne: EXCLUDED_PROJECT_ID }
|
|
21
|
-
// 'offers.availabilityEnds': { $exists: true }
|
|
22
|
-
},
|
|
23
|
-
{}
|
|
24
|
-
);
|
|
25
|
-
console.log('events found');
|
|
26
|
-
|
|
27
|
-
let i = 0;
|
|
28
|
-
let updateCount = 0;
|
|
29
|
-
const projectIds: string[] = [];
|
|
30
|
-
let createdAtLatest: Date | undefined;
|
|
31
|
-
let updatedAtLatest: Date | undefined;
|
|
32
|
-
await cursor.eachAsync(async (doc) => {
|
|
33
|
-
i += 1;
|
|
34
|
-
const event: chevre.factory.event.screeningEventSeries.IEvent = doc.toObject();
|
|
35
|
-
|
|
36
|
-
const unacceptedPaymentMethod = event.offers?.unacceptedPaymentMethod;
|
|
37
|
-
const alreadyMigrated =
|
|
38
|
-
(!Array.isArray(unacceptedPaymentMethod))
|
|
39
|
-
|| (Array.isArray(unacceptedPaymentMethod) && unacceptedPaymentMethod.length === 0)
|
|
40
|
-
|| (Array.isArray(unacceptedPaymentMethod) && unacceptedPaymentMethod.length === 1 && unacceptedPaymentMethod[0] === 'MovieTicket');
|
|
41
|
-
|
|
42
|
-
if (alreadyMigrated) {
|
|
43
|
-
console.log(
|
|
44
|
-
'already migrated.', event.project.id, event.id, event.startDate, i);
|
|
45
|
-
} else {
|
|
46
|
-
projectIds.push(event.project.id);
|
|
47
|
-
if (createdAtLatest instanceof Date) {
|
|
48
|
-
if (moment(createdAtLatest)
|
|
49
|
-
.isBefore(moment((<any>event).createdAt))) {
|
|
50
|
-
createdAtLatest = (<any>event).createdAt;
|
|
51
|
-
}
|
|
52
|
-
} else {
|
|
53
|
-
createdAtLatest = (<any>event).createdAt;
|
|
54
|
-
}
|
|
55
|
-
if (updatedAtLatest instanceof Date) {
|
|
56
|
-
if (moment(updatedAtLatest)
|
|
57
|
-
.isBefore(moment((<any>event).updatedAt))) {
|
|
58
|
-
updatedAtLatest = (<any>event).updatedAt;
|
|
59
|
-
}
|
|
60
|
-
} else {
|
|
61
|
-
updatedAtLatest = (<any>event).updatedAt;
|
|
62
|
-
}
|
|
63
|
-
console.log(
|
|
64
|
-
'updating event...', event.project.id, event.id, event.startDate, unacceptedPaymentMethod,
|
|
65
|
-
(<any>event).createdAt,
|
|
66
|
-
(<any>event).updatedAt,
|
|
67
|
-
i
|
|
68
|
-
);
|
|
69
|
-
// await creativeWorkRepo.saveMovie(<any>{
|
|
70
|
-
// id: String(movie.id),
|
|
71
|
-
// 'offers.availabilityStarts': availabilityStarts
|
|
72
|
-
// });
|
|
73
|
-
updateCount += 1;
|
|
74
|
-
console.log('updated.', event.project.id, event.id, event.startDate, i);
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
console.log(i, 'events checked');
|
|
79
|
-
console.log(updateCount, 'events updated');
|
|
80
|
-
console.log('projectIds:', [...new Set(projectIds)]);
|
|
81
|
-
console.log('createdAtLatest:', createdAtLatest);
|
|
82
|
-
console.log('updatedAtLatest:', updatedAtLatest);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
main()
|
|
86
|
-
.then()
|
|
87
|
-
.catch(console.error);
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
// tslint:disable:no-console
|
|
2
|
-
import * as mongoose from 'mongoose';
|
|
3
|
-
|
|
4
|
-
import { chevre } from '../../../lib/index';
|
|
5
|
-
|
|
6
|
-
const project = { id: String(process.env.PROJECT_ID) };
|
|
7
|
-
|
|
8
|
-
async function main() {
|
|
9
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
10
|
-
|
|
11
|
-
const productModelRepo = await chevre.repository.ProductModel.createInstance(mongoose.connection);
|
|
12
|
-
const result = await productModelRepo.search(
|
|
13
|
-
{
|
|
14
|
-
limit: 100,
|
|
15
|
-
page: 1,
|
|
16
|
-
category: {
|
|
17
|
-
codeValue: { $in: ['Premium'] },
|
|
18
|
-
inCodeSet: { identifier: { $eq: chevre.factory.categoryCode.CategorySetIdentifier.SeatingType } }
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
[],
|
|
22
|
-
[]
|
|
23
|
-
);
|
|
24
|
-
console.log('result:', result);
|
|
25
|
-
|
|
26
|
-
const productModel = {
|
|
27
|
-
project: {
|
|
28
|
-
id: project.id,
|
|
29
|
-
typeOf: <chevre.factory.organizationType.Project>chevre.factory.organizationType.Project
|
|
30
|
-
},
|
|
31
|
-
typeOf: <'ProductModel'>'ProductModel',
|
|
32
|
-
category: {
|
|
33
|
-
codeValue: 'Premium',
|
|
34
|
-
inCodeSet: {
|
|
35
|
-
identifier: chevre.factory.categoryCode.CategorySetIdentifier.SeatingType,
|
|
36
|
-
typeOf: <'CategoryCodeSet'>'CategoryCodeSet'
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
name: { ja: 'プレミアムシート' },
|
|
40
|
-
offers: [{
|
|
41
|
-
typeOf: <chevre.factory.offerType.Offer>chevre.factory.offerType.Offer
|
|
42
|
-
}]
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
const createdModel = await productModelRepo.save({
|
|
46
|
-
$set: productModel
|
|
47
|
-
});
|
|
48
|
-
console.log('created. id:', createdModel);
|
|
49
|
-
|
|
50
|
-
await productModelRepo.save({
|
|
51
|
-
id: createdModel.id,
|
|
52
|
-
$set: productModel
|
|
53
|
-
});
|
|
54
|
-
console.log('updated. id:', createdModel.id);
|
|
55
|
-
|
|
56
|
-
await productModelRepo.deleteById({
|
|
57
|
-
id: createdModel.id
|
|
58
|
-
});
|
|
59
|
-
console.log('deleted. id:', createdModel.id);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
main()
|
|
63
|
-
.then(console.log)
|
|
64
|
-
.catch(console.error);
|