@chevre/domain 20.2.0-alpha.9 → 20.2.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.
Files changed (135) hide show
  1. package/example/src/chevre/aggregateEventReservation.ts +37 -0
  2. package/example/src/chevre/aggregation/aggregateSystem.ts +116 -0
  3. package/example/src/chevre/attendIfNotAttended.ts +22 -0
  4. package/example/src/chevre/createManyEventsIfNotExist.ts +209 -0
  5. package/example/src/chevre/findByOrderNumberAndReservationId.ts +20 -0
  6. package/example/src/chevre/findScreeningRoomsByBranchCode.ts +27 -0
  7. package/example/src/chevre/importEventsFromCOA.ts +8 -1
  8. package/example/src/chevre/migrateEventOffersItemOfferedAvailableChannel.ts +2 -1
  9. package/example/src/chevre/migrateOwnershipInfos2newUserPool.ts +1 -1
  10. package/example/src/chevre/migrateProjectSubscription.ts +51 -0
  11. package/example/src/chevre/ownershipInfosCsv2peopleJson.ts +2 -2
  12. package/example/src/chevre/processReserve.ts +2 -0
  13. package/example/src/chevre/searchEventIds.ts +24 -0
  14. package/example/src/chevre/searchEventTicketOffers.ts +5 -4
  15. package/example/src/chevre/searchEvents.ts +20 -41
  16. package/example/src/chevre/searchOffersByCatalog.ts +27 -0
  17. package/example/src/chevre/updateTransaction.ts +38 -0
  18. package/lib/chevre/factory/event.d.ts +2 -0
  19. package/lib/chevre/factory/event.js +2 -0
  20. package/lib/chevre/repo/action.d.ts +77 -1
  21. package/lib/chevre/repo/action.js +249 -6
  22. package/lib/chevre/repo/aggregation.d.ts +38 -0
  23. package/lib/chevre/repo/aggregation.js +68 -0
  24. package/lib/chevre/repo/assetTransaction.d.ts +32 -0
  25. package/lib/chevre/repo/assetTransaction.js +148 -0
  26. package/lib/chevre/repo/code.d.ts +13 -16
  27. package/lib/chevre/repo/code.js +33 -19
  28. package/lib/chevre/repo/creativeWork.js +13 -12
  29. package/lib/chevre/repo/event.d.ts +64 -17
  30. package/lib/chevre/repo/event.js +456 -156
  31. package/lib/chevre/repo/mongoose/model/aggregation.d.ts +7 -0
  32. package/lib/chevre/repo/mongoose/model/aggregation.js +47 -0
  33. package/lib/chevre/repo/mongoose/model/event.js +4 -3
  34. package/lib/chevre/repo/mongoose/model/offer.js +2 -1
  35. package/lib/chevre/repo/mongoose/model/project.js +7 -1
  36. package/lib/chevre/repo/mongoose/model/telemetry.js +4 -28
  37. package/lib/chevre/repo/offer.d.ts +10 -0
  38. package/lib/chevre/repo/offer.js +47 -16
  39. package/lib/chevre/repo/order.d.ts +6 -0
  40. package/lib/chevre/repo/order.js +53 -7
  41. package/lib/chevre/repo/place.d.ts +26 -1
  42. package/lib/chevre/repo/place.js +216 -12
  43. package/lib/chevre/repo/product.d.ts +1 -0
  44. package/lib/chevre/repo/product.js +5 -0
  45. package/lib/chevre/repo/project.d.ts +7 -1
  46. package/lib/chevre/repo/project.js +15 -6
  47. package/lib/chevre/repo/reservation.d.ts +7 -8
  48. package/lib/chevre/repo/reservation.js +181 -76
  49. package/lib/chevre/repo/task.d.ts +31 -4
  50. package/lib/chevre/repo/task.js +146 -33
  51. package/lib/chevre/repo/transaction.d.ts +57 -5
  52. package/lib/chevre/repo/transaction.js +228 -34
  53. package/lib/chevre/repo/trip.js +33 -27
  54. package/lib/chevre/repository.d.ts +3 -0
  55. package/lib/chevre/repository.js +5 -1
  56. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +72 -60
  57. package/lib/chevre/service/aggregation/event/aggregateUseActionsOnEvent.js +5 -8
  58. package/lib/chevre/service/aggregation/system.d.ts +100 -0
  59. package/lib/chevre/service/aggregation/system.js +409 -0
  60. package/lib/chevre/service/aggregation.d.ts +2 -0
  61. package/lib/chevre/service/aggregation.js +3 -1
  62. package/lib/chevre/service/assetTransaction/pay/movieTicket/validation.js +5 -1
  63. package/lib/chevre/service/assetTransaction/pay/potentialActions.js +0 -3
  64. package/lib/chevre/service/assetTransaction/pay.d.ts +19 -4
  65. package/lib/chevre/service/assetTransaction/pay.js +65 -32
  66. package/lib/chevre/service/assetTransaction/registerService.js +4 -1
  67. package/lib/chevre/service/assetTransaction/reserve/factory.d.ts +3 -0
  68. package/lib/chevre/service/assetTransaction/reserve/factory.js +33 -2
  69. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.d.ts +16 -0
  70. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.js +84 -0
  71. package/lib/chevre/service/assetTransaction/reserve.d.ts +38 -6
  72. package/lib/chevre/service/assetTransaction/reserve.js +120 -94
  73. package/lib/chevre/service/assetTransaction.d.ts +1 -1
  74. package/lib/chevre/service/code.d.ts +2 -3
  75. package/lib/chevre/service/delivery/factory.d.ts +1 -1
  76. package/lib/chevre/service/delivery/product/factory.js +9 -3
  77. package/lib/chevre/service/event.d.ts +2 -4
  78. package/lib/chevre/service/event.js +35 -14
  79. package/lib/chevre/service/offer/event/authorize.d.ts +4 -7
  80. package/lib/chevre/service/offer/event/authorize.js +33 -87
  81. package/lib/chevre/service/offer/event/cancel.js +0 -1
  82. package/lib/chevre/service/offer/event/factory.d.ts +3 -2
  83. package/lib/chevre/service/offer/event/searchEventTicketOffers.d.ts +14 -7
  84. package/lib/chevre/service/offer/event/searchEventTicketOffers.js +95 -53
  85. package/lib/chevre/service/offer/event/voidTransaction.js +0 -2
  86. package/lib/chevre/service/offer/eventServiceByCOA/factory.d.ts +2 -1
  87. package/lib/chevre/service/offer/eventServiceByCOA.js +10 -2
  88. package/lib/chevre/service/offer/factory.js +10 -3
  89. package/lib/chevre/service/offer/product/searchProductOffers.d.ts +1 -0
  90. package/lib/chevre/service/offer/product/searchProductOffers.js +1 -1
  91. package/lib/chevre/service/offer/product.d.ts +1 -0
  92. package/lib/chevre/service/offer/product.js +7 -2
  93. package/lib/chevre/service/offer.d.ts +13 -2
  94. package/lib/chevre/service/offer.js +68 -46
  95. package/lib/chevre/service/order/onOrderStatusChanged/factory.js +23 -26
  96. package/lib/chevre/service/order/returnOrder.js +6 -4
  97. package/lib/chevre/service/order/sendOrder.js +4 -2
  98. package/lib/chevre/service/payment/any.d.ts +9 -0
  99. package/lib/chevre/service/payment/any.js +16 -1
  100. package/lib/chevre/service/payment/movieTicket.d.ts +2 -2
  101. package/lib/chevre/service/payment/movieTicket.js +8 -2
  102. package/lib/chevre/service/product.js +5 -3
  103. package/lib/chevre/service/report/telemetry.js +1 -1
  104. package/lib/chevre/service/reserve/checkInReservation.js +2 -2
  105. package/lib/chevre/service/reserve/confirmReservation.js +7 -10
  106. package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.js +2 -1
  107. package/lib/chevre/service/reserve/potentialActions/onReservationCheckedIn.js +2 -1
  108. package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.js +2 -1
  109. package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +32 -35
  110. package/lib/chevre/service/reserve/useReservation.d.ts +0 -3
  111. package/lib/chevre/service/reserve/useReservation.js +58 -33
  112. package/lib/chevre/service/task/confirmPayTransaction.js +20 -1
  113. package/lib/chevre/service/task/confirmReserveTransaction.d.ts +4 -0
  114. package/lib/chevre/service/task/confirmReserveTransaction.js +5 -5
  115. package/lib/chevre/service/task/importEventsFromCOA.js +3 -1
  116. package/lib/chevre/service/task/returnPayTransaction.js +10 -4
  117. package/lib/chevre/service/task.js +6 -9
  118. package/lib/chevre/service/transaction/moneyTransfer.js +9 -1
  119. package/lib/chevre/service/transaction/orderProgramMembership/findPaymentCardPermit.d.ts +1 -1
  120. package/lib/chevre/service/transaction/orderProgramMembership.js +6 -6
  121. package/lib/chevre/service/transaction/placeOrder.js +5 -3
  122. package/lib/chevre/service/transaction/placeOrderInProgress/factory.d.ts +1 -1
  123. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions.d.ts +0 -2
  124. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions.js +2 -11
  125. package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateSeller.d.ts +1 -1
  126. package/lib/chevre/service/transaction/placeOrderInProgress.d.ts +3 -8
  127. package/lib/chevre/service/transaction/placeOrderInProgress.js +92 -107
  128. package/lib/chevre/service/transaction/returnOrder.js +8 -6
  129. package/lib/chevre/settings.d.ts +2 -0
  130. package/lib/chevre/settings.js +20 -12
  131. package/package.json +3 -3
  132. package/example/src/chevre/aggregateReservationOnProject.ts +0 -32
  133. package/example/src/chevre/migratePlaceAdditionalProperties.ts +0 -162
  134. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/confirmPay.d.ts +0 -6
  135. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/confirmPay.js +0 -65
@@ -19,8 +19,8 @@ const factory_1 = require("../factory");
19
19
  function searchTransportationEventTicketOffers(params) {
20
20
  // tslint:disable-next-line:max-func-body-length
21
21
  return (repos) => __awaiter(this, void 0, void 0, function* () {
22
- var _a, _b, _c;
23
- const screeningEvent = yield repos.event.findById({ id: params.eventId });
22
+ var _a, _b, _c, _d;
23
+ const screeningEvent = params.event;
24
24
  const soundFormatTypes = [];
25
25
  const videoFormatTypes = [];
26
26
  let availableOffers = [];
@@ -30,7 +30,10 @@ function searchTransportationEventTicketOffers(params) {
30
30
  const transportation = yield repos.product.findById({ id: eventOffers.itemOffered.id });
31
31
  if (typeof ((_b = transportation.hasOfferCatalog) === null || _b === void 0 ? void 0 : _b.id) === 'string') {
32
32
  availableOffers = yield repos.offer.findOffersByOfferCatalogId({
33
- offerCatalog: { id: transportation.hasOfferCatalog.id }
33
+ ids: params.ids,
34
+ offerCatalog: { id: transportation.hasOfferCatalog.id },
35
+ availableAtOrFrom: { id: (_c = params.store) === null || _c === void 0 ? void 0 : _c.id },
36
+ sort: params.sort
34
37
  });
35
38
  }
36
39
  }
@@ -39,10 +42,6 @@ function searchTransportationEventTicketOffers(params) {
39
42
  throw new factory.errors.NotFound('event.offers.itemOffered.id');
40
43
  }
41
44
  const { soundFormatChargeSpecifications, videoFormatChargeSpecifications, movieTicketTypeChargeSpecs } = yield searchPriceSpecs4event({ project: { id: screeningEvent.project.id }, soundFormatTypes, videoFormatTypes })(repos);
42
- const screeningEventOfferSettings = screeningEvent.offers;
43
- if (screeningEventOfferSettings === undefined) {
44
- throw new factory.errors.NotFound('event.offers');
45
- }
46
45
  const unacceptedPaymentMethod = getUnacceptedPaymentMethodByEvent({ event: screeningEvent });
47
46
  // 不許可決済方法があれば、該当オファーを除外
48
47
  if (Array.isArray(unacceptedPaymentMethod) && unacceptedPaymentMethod.length > 0) {
@@ -94,7 +93,7 @@ function searchTransportationEventTicketOffers(params) {
94
93
  });
95
94
  let offers4event = availableOffers.map((availableOffer) => {
96
95
  return (0, factory_1.createCompoundPriceSpec4event)({
97
- eligibleQuantity: screeningEventOfferSettings.eligibleQuantity,
96
+ eligibleQuantity: eventOffers.eligibleQuantity,
98
97
  offer: availableOffer,
99
98
  videoFormatChargeSpecifications,
100
99
  soundFormatChargeSpecifications,
@@ -102,25 +101,33 @@ function searchTransportationEventTicketOffers(params) {
102
101
  videoFormatTypes
103
102
  });
104
103
  });
105
- // レート制限を確認
106
- offers4event = yield Promise.all(offers4event.map((offer) => __awaiter(this, void 0, void 0, function* () {
107
- return checkAvailability({ event: screeningEvent, offer })(repos);
108
- })));
104
+ if (params.validateOfferRateLimit) {
105
+ // レート制限を確認
106
+ offers4event = yield Promise.all(offers4event.map((offer) => __awaiter(this, void 0, void 0, function* () {
107
+ return checkAvailability({ event: screeningEvent, offer })(repos);
108
+ })));
109
+ }
109
110
  // アドオン設定があれば、プロダクトオファーを検索
110
111
  for (const offer of offers4event) {
111
112
  const offerAddOn = [];
112
113
  if (Array.isArray(offer.addOn)) {
113
114
  for (const addOn of offer.addOn) {
114
- const productId = (_c = addOn.itemOffered) === null || _c === void 0 ? void 0 : _c.id;
115
+ const productId = (_d = addOn.itemOffered) === null || _d === void 0 ? void 0 : _d.id;
115
116
  if (typeof productId === 'string') {
116
- const productOffers = yield searchAddOns({ product: { id: productId } })(repos);
117
+ const productOffers = yield searchAddOns({
118
+ product: { id: productId },
119
+ store: params.store
120
+ })(repos);
117
121
  offerAddOn.push(...productOffers);
118
122
  }
119
123
  }
120
124
  }
121
125
  offer.addOn = offerAddOn;
122
126
  }
123
- return offers4event;
127
+ return {
128
+ ticketOffers: offers4event,
129
+ unitPriceOffers: availableOffers
130
+ };
124
131
  });
125
132
  }
126
133
  /**
@@ -129,9 +136,12 @@ function searchTransportationEventTicketOffers(params) {
129
136
  function searchScreeningEventTicketOffers(params) {
130
137
  // tslint:disable-next-line:max-func-body-length
131
138
  return (repos) => __awaiter(this, void 0, void 0, function* () {
132
- var _a, _b, _c;
133
- const screeningEvent = yield repos.event.findById({ id: params.eventId });
134
- const superEvent = yield repos.event.findById({ id: screeningEvent.superEvent.id });
139
+ var _a, _b, _c, _d;
140
+ // イベント取得属性最適化(2023-01-23~)
141
+ // const screeningEvent = await repos.event.findById<factory.eventType.ScreeningEvent>({ id: params.eventId });
142
+ const screeningEvent = params.event;
143
+ // 取得属性最適化(2023-01-25~)
144
+ const superEvent = yield repos.event.findById({ id: screeningEvent.superEvent.id }, { soundFormat: 1, videoFormat: 1 });
135
145
  const soundFormatTypes = (Array.isArray(superEvent.soundFormat)) ? superEvent.soundFormat.map((f) => f.typeOf) : [];
136
146
  const videoFormatTypes = (Array.isArray(superEvent.videoFormat)) ? superEvent.videoFormat.map((f) => f.typeOf) : [];
137
147
  let availableOffers = [];
@@ -141,7 +151,10 @@ function searchScreeningEventTicketOffers(params) {
141
151
  const eventService = yield repos.product.findById({ id: eventOffers.itemOffered.id });
142
152
  if (typeof ((_b = eventService.hasOfferCatalog) === null || _b === void 0 ? void 0 : _b.id) === 'string') {
143
153
  availableOffers = yield repos.offer.findOffersByOfferCatalogId({
144
- offerCatalog: { id: eventService.hasOfferCatalog.id }
154
+ ids: params.ids,
155
+ offerCatalog: { id: eventService.hasOfferCatalog.id },
156
+ availableAtOrFrom: { id: (_c = params.store) === null || _c === void 0 ? void 0 : _c.id },
157
+ sort: params.sort
145
158
  });
146
159
  }
147
160
  }
@@ -150,10 +163,6 @@ function searchScreeningEventTicketOffers(params) {
150
163
  throw new factory.errors.NotFound('event.offers.itemOffered.id');
151
164
  }
152
165
  const { soundFormatChargeSpecifications, videoFormatChargeSpecifications, movieTicketTypeChargeSpecs } = yield searchPriceSpecs4event({ project: { id: screeningEvent.project.id }, soundFormatTypes, videoFormatTypes })(repos);
153
- const screeningEventOfferSettings = screeningEvent.offers;
154
- if (screeningEventOfferSettings === undefined) {
155
- throw new factory.errors.NotFound('event.offers');
156
- }
157
166
  const unacceptedPaymentMethod = getUnacceptedPaymentMethodByEvent({ event: screeningEvent });
158
167
  // 不許可決済方法があれば、該当オファーを除外
159
168
  if (Array.isArray(unacceptedPaymentMethod) && unacceptedPaymentMethod.length > 0) {
@@ -205,7 +214,7 @@ function searchScreeningEventTicketOffers(params) {
205
214
  });
206
215
  let offers4event = availableOffers.map((availableOffer) => {
207
216
  return (0, factory_1.createCompoundPriceSpec4event)({
208
- eligibleQuantity: screeningEventOfferSettings.eligibleQuantity,
217
+ eligibleQuantity: eventOffers.eligibleQuantity,
209
218
  offer: availableOffer,
210
219
  videoFormatChargeSpecifications,
211
220
  soundFormatChargeSpecifications,
@@ -213,16 +222,18 @@ function searchScreeningEventTicketOffers(params) {
213
222
  videoFormatTypes
214
223
  });
215
224
  });
216
- // レート制限を確認
217
- offers4event = yield Promise.all(offers4event.map((offer) => __awaiter(this, void 0, void 0, function* () {
218
- return checkAvailability({ event: screeningEvent, offer })(repos);
219
- })));
225
+ if (params.validateOfferRateLimit) {
226
+ // レート制限を確認
227
+ offers4event = yield Promise.all(offers4event.map((offer) => __awaiter(this, void 0, void 0, function* () {
228
+ return checkAvailability({ event: screeningEvent, offer })(repos);
229
+ })));
230
+ }
220
231
  // アドオン設定があれば、プロダクトオファーを検索
221
232
  for (const offer of offers4event) {
222
233
  const offerAddOn = [];
223
234
  if (Array.isArray(offer.addOn)) {
224
235
  for (const addOn of offer.addOn) {
225
- const productId = (_c = addOn.itemOffered) === null || _c === void 0 ? void 0 : _c.id;
236
+ const productId = (_d = addOn.itemOffered) === null || _d === void 0 ? void 0 : _d.id;
226
237
  if (typeof productId === 'string') {
227
238
  const productOffers = yield searchAddOns({ product: { id: productId } })(repos);
228
239
  offerAddOn.push(...productOffers);
@@ -231,7 +242,10 @@ function searchScreeningEventTicketOffers(params) {
231
242
  }
232
243
  offer.addOn = offerAddOn;
233
244
  }
234
- return offers4event;
245
+ return {
246
+ ticketOffers: offers4event,
247
+ unitPriceOffers: availableOffers
248
+ };
235
249
  });
236
250
  }
237
251
  function getUnacceptedPaymentMethodByEvent(params) {
@@ -321,14 +335,18 @@ function checkAvailability(params) {
321
335
  */
322
336
  function searchAddOns(params) {
323
337
  return (repos) => __awaiter(this, void 0, void 0, function* () {
324
- var _a, _b;
338
+ var _a, _b, _c;
325
339
  let offers = [];
326
340
  const productId = (_a = params.product) === null || _a === void 0 ? void 0 : _a.id;
327
341
  if (typeof productId === 'string') {
328
342
  const productWithAddOns = yield repos.product.findById({ id: productId });
329
343
  const offerCatalogId = (_b = productWithAddOns.hasOfferCatalog) === null || _b === void 0 ? void 0 : _b.id;
330
344
  if (typeof offerCatalogId === 'string') {
331
- offers = yield repos.offer.findOffersByOfferCatalogId({ offerCatalog: { id: offerCatalogId } });
345
+ offers = yield repos.offer.findOffersByOfferCatalogId({
346
+ offerCatalog: { id: offerCatalogId },
347
+ availableAtOrFrom: { id: (_c = params.store) === null || _c === void 0 ? void 0 : _c.id },
348
+ sort: true
349
+ });
332
350
  offers = offers.map((o) => {
333
351
  return Object.assign(Object.assign({ additionalProperty: Array.isArray(o.additionalProperty) ? o.additionalProperty : [], alternateName: o.alternateName, availability: o.availability, availableAtOrFrom: o.availableAtOrFrom, color: o.color, description: o.description, id: o.id, identifier: o.identifier, itemOffered: {
334
352
  description: productWithAddOns.description,
@@ -347,14 +365,18 @@ function searchAddOns(params) {
347
365
  /**
348
366
  * 興行オファー検索
349
367
  */
350
- // tslint:disable-next-line:max-func-body-length
351
368
  function searchEventTicketOffers(params) {
369
+ // tslint:disable-next-line:max-func-body-length
352
370
  return (repos) => __awaiter(this, void 0, void 0, function* () {
353
- var _a;
354
371
  const now = moment();
355
372
  let event;
356
- event = yield repos.event.findById({ id: params.event.id });
373
+ // イベント取得属性最適化(2023-01-23~)
374
+ // event = await repos.event.findById<factory.eventType.ScreeningEvent | factory.eventType.Event>({ id: params.event.id });
375
+ event = yield repos.event.findMinimizedIndividualEventById({
376
+ id: params.event.id
377
+ });
357
378
  let offers;
379
+ let unitPriceOffers;
358
380
  const eventOffers = event.offers;
359
381
  if (eventOffers === undefined) {
360
382
  throw new factory.errors.NotFound('EventOffers', 'Event offers undefined');
@@ -368,22 +390,39 @@ function searchEventTicketOffers(params) {
368
390
  default:
369
391
  // Chevreで券種オファーを検索
370
392
  if (event.typeOf === factory.eventType.ScreeningEvent) {
371
- offers = yield searchScreeningEventTicketOffers({ eventId: params.event.id })(repos);
393
+ const searchOffersResult = yield searchScreeningEventTicketOffers({
394
+ ids: params.ids,
395
+ event,
396
+ store: params.store,
397
+ sort: params.sort,
398
+ validateOfferRateLimit: params.validateOfferRateLimit
399
+ })(repos);
400
+ offers = searchOffersResult.ticketOffers;
401
+ unitPriceOffers = searchOffersResult.unitPriceOffers;
372
402
  }
373
403
  else if (event.typeOf === factory.eventType.Event) {
374
- offers = yield searchTransportationEventTicketOffers({ eventId: params.event.id })(repos);
404
+ const searchOffersResult = yield searchTransportationEventTicketOffers({
405
+ ids: params.ids,
406
+ event,
407
+ store: params.store,
408
+ sort: params.sort,
409
+ validateOfferRateLimit: params.validateOfferRateLimit
410
+ })(repos);
411
+ offers = searchOffersResult.ticketOffers;
412
+ unitPriceOffers = searchOffersResult.unitPriceOffers;
375
413
  }
376
414
  else {
377
415
  throw new factory.errors.NotImplemented(`'${event.typeOf}' not implemented`);
378
416
  }
379
- const specifiedStoreId = (_a = params.store) === null || _a === void 0 ? void 0 : _a.id;
380
- if (typeof specifiedStoreId === 'string') {
381
- // アプリケーションが利用可能なオファーに絞る
382
- offers = offers.filter((o) => {
383
- return Array.isArray(o.availableAtOrFrom)
384
- && o.availableAtOrFrom.some((availableApplication) => availableApplication.id === specifiedStoreId);
385
- });
386
- }
417
+ // store.idでのフィルターをmongoに移行(2023-01-27~)
418
+ // const specifiedStoreId = params.store?.id;
419
+ // if (typeof specifiedStoreId === 'string') {
420
+ // // アプリケーションが利用可能なオファーに絞る
421
+ // offers = offers.filter((o) => {
422
+ // return Array.isArray(o.availableAtOrFrom)
423
+ // && o.availableAtOrFrom.some((availableApplication) => availableApplication.id === specifiedStoreId);
424
+ // });
425
+ // }
387
426
  // 有効期間を適用
388
427
  if (params.onlyValid === true) {
389
428
  offers = offers.filter((o) => {
@@ -401,14 +440,17 @@ function searchEventTicketOffers(params) {
401
440
  }
402
441
  for (const offer of offers) {
403
442
  if (Array.isArray(offer.addOn)) {
443
+ // store.idでのフィルターをmongoに移行(2023-01-27~)
404
444
  // addOnsに対しても利用可能アプリケーション設定を適用
405
- if (typeof specifiedStoreId === 'string') {
406
- // アプリケーションが利用可能なオファーに絞る
407
- offer.addOn = offer.addOn.filter((offer4addOn) => {
408
- return Array.isArray(offer4addOn.availableAtOrFrom)
409
- && offer4addOn.availableAtOrFrom.some((availableApplication) => availableApplication.id === specifiedStoreId);
410
- });
411
- }
445
+ // if (typeof specifiedStoreId === 'string') {
446
+ // // アプリケーションが利用可能なオファーに絞る
447
+ // offer.addOn = offer.addOn.filter((offer4addOn) => {
448
+ // return Array.isArray(offer4addOn.availableAtOrFrom)
449
+ // && offer4addOn.availableAtOrFrom.some(
450
+ // (availableApplication) => availableApplication.id === specifiedStoreId
451
+ // );
452
+ // });
453
+ // }
412
454
  // addOnsに対しても有効期間を適用
413
455
  if (params.onlyValid === true) {
414
456
  offer.addOn = offer.addOn.filter((offer4addOn) => {
@@ -427,7 +469,7 @@ function searchEventTicketOffers(params) {
427
469
  }
428
470
  }
429
471
  }
430
- return offers;
472
+ return { ticketOffers: offers, unitPriceOffers };
431
473
  });
432
474
  }
433
475
  exports.searchEventTicketOffers = searchEventTicketOffers;
@@ -114,8 +114,6 @@ function processVoidTransaction4chevre(params) {
114
114
  transactionNumber: { $eq: transactionNumber }
115
115
  });
116
116
  if (assetTransactions.length > 0) {
117
- // 予約取引サービスで中止
118
- // await repos.reserveTransaction.cancel({ transactionNumber });
119
117
  yield ReserveTransactionService.cancel({ transactionNumber })(repos);
120
118
  }
121
119
  }
@@ -1,4 +1,5 @@
1
1
  import * as factory from '../../../factory';
2
+ import { IMinimizedIndividualEvent } from '../../../factory/event';
2
3
  export import WebAPIIdentifier = factory.service.webAPI.Identifier;
3
4
  export declare function createAuthorizeSeatReservationActionAttributes(params: {
4
5
  acceptedOffers: factory.action.authorize.offer.seatReservation.IAcceptedOffer<factory.service.webAPI.Identifier.COA>[];
@@ -19,7 +20,7 @@ declare type IResultAcceptedOffer = factory.action.authorize.offer.seatReservati
19
20
  export declare function responseBody2acceptedOffers4result(params: {
20
21
  responseBody: factory.action.authorize.offer.seatReservation.IResponseBody<factory.service.webAPI.Identifier.COA>;
21
22
  object: factory.action.authorize.offer.seatReservation.IObject<factory.service.webAPI.Identifier.COA>;
22
- event: factory.event.IEvent<factory.eventType.ScreeningEvent>;
23
+ event: IMinimizedIndividualEvent<factory.eventType.ScreeningEvent>;
23
24
  seller: factory.transaction.placeOrder.ISeller;
24
25
  bookingTime: Date;
25
26
  totalPrice: number;
@@ -27,7 +27,11 @@ function authorize(params) {
27
27
  if (transaction.agent.id !== params.agent.id) {
28
28
  throw new factory.errors.Forbidden('Transaction not yours');
29
29
  }
30
- const screeningEvent = yield repos.event.findById({ id: params.object.event.id });
30
+ // イベント取得属性最適化(2023-01-23~)
31
+ // const screeningEvent = await repos.event.findById<factory.eventType.ScreeningEvent>({ id: params.object.event.id });
32
+ const screeningEvent = yield repos.event.findMinimizedIndividualEventById({
33
+ id: params.object.event.id
34
+ });
31
35
  // 必ず定義されている前提
32
36
  // const coaInfo = <factory.event.screeningEvent.ICOAInfo>screeningEvent.coaInfo;
33
37
  // const acceptedOffersWithoutDetails = await createAcceptedOffersWithoutDetails({
@@ -158,7 +162,11 @@ function changeOffers(params) {
158
162
  throw new factory.errors.Argument('Transaction', 'Action not found in the transaction');
159
163
  }
160
164
  validate4changeOffer({ action: authorizeAction, object: params.object });
161
- const screeningEvent = yield repos.event.findById({ id: params.object.event.id });
165
+ // イベント取得属性最適化(2023-01-23~)
166
+ // const screeningEvent = await repos.event.findById<factory.eventType.ScreeningEvent>({ id: params.object.event.id });
167
+ const screeningEvent = yield repos.event.findMinimizedIndividualEventById({
168
+ id: params.object.event.id
169
+ });
162
170
  // COA仮予約後にリクエストが来る前提
163
171
  const acceptedOffer = params.object.acceptedOffer;
164
172
  // 座席区分加算料金などを補完
@@ -22,13 +22,20 @@ function mvtkChargePriceSpec2component(params) {
22
22
  return Object.assign({ id: params.id, typeOf: params.typeOf, name: params.name, price: params.price, priceCurrency: params.priceCurrency, valueAddedTaxIncluded: params.valueAddedTaxIncluded, appliesToVideoFormat: params.appliesToVideoFormat, appliesToMovieTicket: params.appliesToMovieTicket }, (typeof ((_a = params.accounting) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string') ? { accounting: params.accounting } : undefined);
23
23
  }
24
24
  function createCompoundPriceSpec4event(params) {
25
+ var _a;
25
26
  // priceSpecificationはマスタ管理の仕様上必ず存在するはず
26
27
  if (params.offer.priceSpecification === undefined) {
27
28
  throw new factory.errors.NotFound(`priceSpecification of the offer: ${params.offer.id}`);
28
29
  }
29
30
  const unitPriceSpec = Object.assign(Object.assign({}, params.offer.priceSpecification), { name: params.offer.name });
30
- const videoFormatChargeSpecComponents = params.videoFormatChargeSpecifications.map(categoryCodeChargePriceSpec2component);
31
- const soundFormatChargeSpecComponents = params.soundFormatChargeSpecifications.map(categoryCodeChargePriceSpec2component);
31
+ let videoFormatChargeSpecComponents = [];
32
+ let soundFormatChargeSpecComponents = [];
33
+ // 区分加算料金を適用しないオプションを追加(2023-01-26~)
34
+ const ignoreCategoryCodeChargeSpec = ((_a = params.offer.settings) === null || _a === void 0 ? void 0 : _a.ignoreCategoryCodeChargeSpec) === true;
35
+ if (!ignoreCategoryCodeChargeSpec) {
36
+ videoFormatChargeSpecComponents = params.videoFormatChargeSpecifications.map(categoryCodeChargePriceSpec2component);
37
+ soundFormatChargeSpecComponents = params.soundFormatChargeSpecifications.map(categoryCodeChargePriceSpec2component);
38
+ }
32
39
  const mvtkPriceComponents = [];
33
40
  // 複数決済カード対応(2022-07-11~)
34
41
  if (Array.isArray(unitPriceSpec.appliesToMovieTicket)) {
@@ -62,7 +69,7 @@ function createCompoundPriceSpec4event(params) {
62
69
  priceComponent
63
70
  };
64
71
  // 不要な属性を除外(2022-11-07~)
65
- const _a = params.offer, { project } = _a, unitOfferFields4ticketOffer = __rest(_a, ["project"]);
72
+ const _b = params.offer, { project } = _b, unitOfferFields4ticketOffer = __rest(_b, ["project"]);
66
73
  return Object.assign(Object.assign({}, unitOfferFields4ticketOffer), { eligibleQuantity: params.eligibleQuantity, priceSpecification: compoundPriceSpecification });
67
74
  }
68
75
  exports.createCompoundPriceSpec4event = createCompoundPriceSpec4event;
@@ -8,6 +8,7 @@ export declare function searchProductOffers(params: {
8
8
  itemOffered: {
9
9
  id: string;
10
10
  };
11
+ sort: boolean;
11
12
  }): (repos: {
12
13
  offer: OfferRepo;
13
14
  product: ProductRepo;
@@ -23,7 +23,7 @@ function searchProductOffers(params) {
23
23
  if (typeof offerCatalogId !== 'string') {
24
24
  return [];
25
25
  }
26
- const offers = yield repos.offer.findOffersByOfferCatalogId({ offerCatalog: { id: offerCatalogId } });
26
+ const offers = yield repos.offer.findOffersByOfferCatalogId({ offerCatalog: { id: offerCatalogId }, sort: params.sort });
27
27
  return offers.map((o) => {
28
28
  const unitSpec = o.priceSpecification;
29
29
  const compoundPriceSpecification = {
@@ -50,6 +50,7 @@ export declare function search(params: {
50
50
  id: string;
51
51
  };
52
52
  onlyValid: boolean;
53
+ sort: boolean;
53
54
  }): (repos: {
54
55
  offer: OfferRepo;
55
56
  product: ProductRepo;
@@ -58,7 +58,10 @@ function search(params) {
58
58
  return offers;
59
59
  }
60
60
  }
61
- offers = yield (0, searchProductOffers_1.searchProductOffers)({ itemOffered: { id: params.itemOffered.id } })(repos);
61
+ offers = yield (0, searchProductOffers_1.searchProductOffers)({
62
+ itemOffered: { id: params.itemOffered.id },
63
+ sort: params.sort
64
+ })(repos);
62
65
  // 店舗条件によって対象を絞る
63
66
  const storeId = (_b = params.availableAt) === null || _b === void 0 ? void 0 : _b.id;
64
67
  if (typeof storeId === 'string') {
@@ -114,6 +117,7 @@ function authorize(params) {
114
117
  }
115
118
  // ポイント特典の識別子に利用するため注文番号を先に発行
116
119
  const orderNumber = yield (0, placeOrderInProgress_1.publishOrderNumberIfNotExist)({
120
+ project: { id: transaction.project.id },
117
121
  id: transaction.id,
118
122
  object: { orderDate: new Date() }
119
123
  })(repos);
@@ -198,7 +202,8 @@ function fixProductAndOffers(params) {
198
202
  if (product === undefined) {
199
203
  throw new factory.errors.NotFound('Product');
200
204
  }
201
- const availableOffers = yield search(Object.assign({ project: { id: params.project.id }, itemOffered: { id: String(product.id) }, onlyValid: true }, (typeof ((_c = params.location) === null || _c === void 0 ? void 0 : _c.id) === 'string') ? { availableAt: { id: params.location.id } } : undefined))(repos);
205
+ const availableOffers = yield search(Object.assign(Object.assign({ project: { id: params.project.id }, itemOffered: { id: String(product.id) }, onlyValid: true }, (typeof ((_c = params.location) === null || _c === void 0 ? void 0 : _c.id) === 'string') ? { availableAt: { id: params.location.id } } : undefined), { sort: false // ソート不要(2023-01-27~)
206
+ }))(repos);
202
207
  return { product, availableOffers };
203
208
  });
204
209
  }
@@ -60,10 +60,20 @@ export declare function searchEventSeatOffersWithPaging(params: {
60
60
  eventAvailability: EventAvailabilityRepo;
61
61
  place: PlaceRepo;
62
62
  }) => Promise<factory.place.seat.IPlaceWithOffer[]>;
63
+ interface IChangedEvent {
64
+ id: string;
65
+ typeOf: factory.eventType;
66
+ project: {
67
+ id: string;
68
+ };
69
+ }
63
70
  /**
64
71
  * イベント変更時処理
65
72
  */
66
- export declare function onEventChanged(params: factory.event.IEvent<factory.eventType>): (repos: {
73
+ export declare function onEventChanged(params: {
74
+ event: IChangedEvent | IChangedEvent[];
75
+ isNew: boolean;
76
+ }): (repos: {
67
77
  event: EventRepo;
68
78
  project: ProjectRepo;
69
79
  task: TaskRepo;
@@ -74,7 +84,8 @@ export declare function createAggregateScreeningEventIfNotExist(params: {
74
84
  };
75
85
  reservationFor: {
76
86
  id: string;
77
- };
87
+ }[];
88
+ force: boolean;
78
89
  }): (repos: {
79
90
  task: TaskRepo;
80
91
  }) => Promise<void>;
@@ -69,7 +69,11 @@ function searchEventSeatOffers(params) {
69
69
  return (repos) => __awaiter(this, void 0, void 0, function* () {
70
70
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
71
71
  let offers = [];
72
- const event = yield repos.event.findById({
72
+ // イベント取得属性最適化(2023-01-23~)
73
+ // const event = await repos.event.findById<factory.eventType.ScreeningEvent | factory.eventType.Event>({
74
+ // id: params.event.id
75
+ // });
76
+ const event = yield repos.event.findMinimizedIndividualEventById({
73
77
  id: params.event.id
74
78
  });
75
79
  // 座席指定利用可能かどうか
@@ -139,7 +143,11 @@ function searchEventSeatOffersWithPaging(params) {
139
143
  return (repos) => __awaiter(this, void 0, void 0, function* () {
140
144
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
141
145
  let offers = [];
142
- const event = yield repos.event.findById({
146
+ // イベント取得属性最適化(2023-01-23~)
147
+ // const event = await repos.event.findById<factory.eventType.ScreeningEvent | factory.eventType.Event>({
148
+ // id: params.event.id
149
+ // });
150
+ const event = yield repos.event.findMinimizedIndividualEventById({
143
151
  id: params.event.id
144
152
  });
145
153
  // 座席指定利用可能かどうか
@@ -204,57 +212,71 @@ exports.searchEventSeatOffersWithPaging = searchEventSeatOffersWithPaging;
204
212
  */
205
213
  function onEventChanged(params) {
206
214
  return (repos) => __awaiter(this, void 0, void 0, function* () {
207
- const changedEvent = params;
208
- // ScreeningEventであれば集計タスク
209
- if (changedEvent.typeOf === factory.eventType.ScreeningEvent) {
210
- yield createAggregateScreeningEventIfNotExist({
211
- project: changedEvent.project,
212
- reservationFor: { id: changedEvent.id }
213
- })(repos);
214
- // const aggregateTask: factory.task.aggregateScreeningEvent.IAttributes = {
215
- // project: event.project,
216
- // name: factory.taskName.AggregateScreeningEvent,
217
- // status: factory.taskStatus.Ready,
218
- // runsAt: new Date(),
219
- // remainingNumberOfTries: 3,
220
- // numberOfTried: 0,
221
- // executionResults: [],
222
- // data: { id: event.id, typeOf: event.typeOf }
223
- // };
224
- // await repos.task.save(aggregateTask);
225
- }
226
- else {
227
- // イベント通知タスク
228
- // const project = await repos.project.findById({ id: event.project.id });
215
+ const changedEvents = (Array.isArray(params.event)) ? params.event : [params.event];
216
+ if (changedEvents.length > 0) {
217
+ // ScreeningEventであれば集計タスク
218
+ if (changedEvents[0].typeOf === factory.eventType.ScreeningEvent) {
219
+ yield createAggregateScreeningEventIfNotExist({
220
+ project: { id: changedEvents[0].project.id },
221
+ reservationFor: changedEvents.map((changedEvent) => {
222
+ return { id: changedEvent.id };
223
+ }),
224
+ // 新規作成の場合は強制的に集計
225
+ force: params.isNew
226
+ })(repos);
227
+ }
229
228
  }
230
229
  });
231
230
  }
232
231
  exports.onEventChanged = onEventChanged;
233
232
  function createAggregateScreeningEventIfNotExist(params) {
234
233
  return (repos) => __awaiter(this, void 0, void 0, function* () {
235
- // 冗長な作成を避ける
236
- const readyAggregateScreeningEventTaskDoc = yield repos.task.taskModel.findOne({
237
- 'project.id': { $eq: params.project.id },
238
- name: { $eq: factory.taskName.AggregateScreeningEvent },
239
- status: { $eq: factory.taskStatus.Ready },
240
- 'data.id': { $exists: true, $eq: params.reservationFor.id }
241
- }, { _id: 1 })
242
- .exec();
243
- if (readyAggregateScreeningEventTaskDoc === null) {
244
- const aggregateTask = {
245
- project: { id: params.project.id, typeOf: factory.organizationType.Project },
246
- name: factory.taskName.AggregateScreeningEvent,
247
- status: factory.taskStatus.Ready,
248
- runsAt: new Date(),
249
- remainingNumberOfTries: 3,
250
- numberOfTried: 0,
251
- executionResults: [],
252
- data: {
253
- typeOf: factory.eventType.ScreeningEvent,
254
- id: params.reservationFor.id
234
+ let aggregateTasks = [];
235
+ const runsAt = new Date();
236
+ const remainingNumberOfTries = 2;
237
+ const project = {
238
+ id: params.project.id, typeOf: factory.organizationType.Project
239
+ };
240
+ if (params.force) {
241
+ aggregateTasks = params.reservationFor.map((reservationFor) => {
242
+ return {
243
+ project,
244
+ name: factory.taskName.AggregateScreeningEvent,
245
+ status: factory.taskStatus.Ready,
246
+ runsAt,
247
+ remainingNumberOfTries,
248
+ numberOfTried: 0,
249
+ executionResults: [],
250
+ data: { typeOf: factory.eventType.ScreeningEvent, id: reservationFor.id }
251
+ };
252
+ });
253
+ }
254
+ else {
255
+ for (const reservationFor of params.reservationFor) {
256
+ // 冗長な作成を避ける
257
+ const readyAggregateScreeningEventTaskDoc = yield repos.task.taskModel.findOne({
258
+ 'project.id': { $eq: project.id },
259
+ name: { $eq: factory.taskName.AggregateScreeningEvent },
260
+ status: { $eq: factory.taskStatus.Ready },
261
+ 'data.id': { $exists: true, $eq: reservationFor.id }
262
+ }, { _id: 1 })
263
+ .exec();
264
+ if (readyAggregateScreeningEventTaskDoc === null) {
265
+ aggregateTasks.push({
266
+ project,
267
+ name: factory.taskName.AggregateScreeningEvent,
268
+ status: factory.taskStatus.Ready,
269
+ runsAt,
270
+ remainingNumberOfTries,
271
+ numberOfTried: 0,
272
+ executionResults: [],
273
+ data: { typeOf: factory.eventType.ScreeningEvent, id: reservationFor.id }
274
+ });
255
275
  }
256
- };
257
- yield repos.task.save(aggregateTask);
276
+ }
277
+ }
278
+ if (aggregateTasks.length > 0) {
279
+ yield repos.task.saveMany(aggregateTasks);
258
280
  }
259
281
  });
260
282
  }