@chevre/domain 20.2.0-alpha.5 → 20.2.0-alpha.51

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 (134) hide show
  1. package/example/src/chevre/aggregateEventReservation.ts +37 -0
  2. package/example/src/chevre/aggregation/aggregateSystem.ts +112 -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 +68 -1
  21. package/lib/chevre/repo/action.js +227 -6
  22. package/lib/chevre/repo/aggregation.d.ts +37 -0
  23. package/lib/chevre/repo/aggregation.js +67 -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 +4 -1
  46. package/lib/chevre/repo/project.js +9 -10
  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 +45 -5
  52. package/lib/chevre/repo/transaction.js +187 -29
  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.d.ts +1 -1
  57. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +86 -59
  58. package/lib/chevre/service/aggregation/event/aggregateUseActionsOnEvent.js +5 -8
  59. package/lib/chevre/service/aggregation/system.d.ts +93 -0
  60. package/lib/chevre/service/aggregation/system.js +377 -0
  61. package/lib/chevre/service/aggregation.d.ts +2 -0
  62. package/lib/chevre/service/aggregation.js +3 -1
  63. package/lib/chevre/service/assetTransaction/pay/movieTicket/validation.js +5 -1
  64. package/lib/chevre/service/assetTransaction/pay/potentialActions.js +2 -4
  65. package/lib/chevre/service/assetTransaction/pay.d.ts +19 -4
  66. package/lib/chevre/service/assetTransaction/pay.js +65 -32
  67. package/lib/chevre/service/assetTransaction/registerService.js +4 -1
  68. package/lib/chevre/service/assetTransaction/reserve/factory.d.ts +3 -0
  69. package/lib/chevre/service/assetTransaction/reserve/factory.js +33 -2
  70. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.d.ts +16 -0
  71. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.js +84 -0
  72. package/lib/chevre/service/assetTransaction/reserve.d.ts +38 -6
  73. package/lib/chevre/service/assetTransaction/reserve.js +120 -94
  74. package/lib/chevre/service/assetTransaction.d.ts +1 -1
  75. package/lib/chevre/service/code.d.ts +2 -3
  76. package/lib/chevre/service/delivery/factory.d.ts +1 -1
  77. package/lib/chevre/service/delivery/factory.js +1 -0
  78. package/lib/chevre/service/delivery/product/factory.js +9 -3
  79. package/lib/chevre/service/event.d.ts +2 -4
  80. package/lib/chevre/service/event.js +35 -14
  81. package/lib/chevre/service/offer/event/authorize.d.ts +4 -7
  82. package/lib/chevre/service/offer/event/authorize.js +33 -87
  83. package/lib/chevre/service/offer/event/cancel.js +0 -1
  84. package/lib/chevre/service/offer/event/factory.d.ts +3 -2
  85. package/lib/chevre/service/offer/event/factory.js +25 -5
  86. package/lib/chevre/service/offer/event/searchEventTicketOffers.d.ts +14 -7
  87. package/lib/chevre/service/offer/event/searchEventTicketOffers.js +95 -53
  88. package/lib/chevre/service/offer/event/voidTransaction.js +0 -2
  89. package/lib/chevre/service/offer/eventServiceByCOA/factory.d.ts +2 -1
  90. package/lib/chevre/service/offer/eventServiceByCOA.js +10 -2
  91. package/lib/chevre/service/offer/factory.js +10 -3
  92. package/lib/chevre/service/offer/product/searchProductOffers.d.ts +1 -0
  93. package/lib/chevre/service/offer/product/searchProductOffers.js +1 -1
  94. package/lib/chevre/service/offer/product.d.ts +1 -0
  95. package/lib/chevre/service/offer/product.js +6 -2
  96. package/lib/chevre/service/offer.d.ts +13 -2
  97. package/lib/chevre/service/offer.js +86 -60
  98. package/lib/chevre/service/order/onOrderStatusChanged/factory.js +25 -27
  99. package/lib/chevre/service/order/onOrderStatusChanged.js +2 -1
  100. package/lib/chevre/service/order/placeOrder.js +16 -0
  101. package/lib/chevre/service/order/returnOrder.js +6 -4
  102. package/lib/chevre/service/order/sendOrder.js +4 -2
  103. package/lib/chevre/service/payment/any.d.ts +5 -0
  104. package/lib/chevre/service/payment/any.js +7 -1
  105. package/lib/chevre/service/payment/movieTicket.d.ts +2 -2
  106. package/lib/chevre/service/payment/movieTicket.js +8 -2
  107. package/lib/chevre/service/product.js +5 -3
  108. package/lib/chevre/service/report/telemetry.js +1 -1
  109. package/lib/chevre/service/reserve/checkInReservation.js +2 -2
  110. package/lib/chevre/service/reserve/confirmReservation.js +7 -10
  111. package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.js +2 -1
  112. package/lib/chevre/service/reserve/potentialActions/onReservationCheckedIn.js +2 -1
  113. package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.js +2 -1
  114. package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +32 -35
  115. package/lib/chevre/service/reserve/useReservation.d.ts +0 -3
  116. package/lib/chevre/service/reserve/useReservation.js +58 -32
  117. package/lib/chevre/service/task/confirmPayTransaction.js +20 -1
  118. package/lib/chevre/service/task/confirmReserveTransaction.d.ts +4 -0
  119. package/lib/chevre/service/task/confirmReserveTransaction.js +5 -5
  120. package/lib/chevre/service/task/importEventsFromCOA.js +3 -1
  121. package/lib/chevre/service/task/returnPayTransaction.js +10 -4
  122. package/lib/chevre/service/task.js +6 -9
  123. package/lib/chevre/service/transaction/moneyTransfer.js +9 -1
  124. package/lib/chevre/service/transaction/orderProgramMembership/findPaymentCardPermit.d.ts +1 -1
  125. package/lib/chevre/service/transaction/orderProgramMembership.js +2 -1
  126. package/lib/chevre/service/transaction/placeOrder.js +5 -3
  127. package/lib/chevre/service/transaction/placeOrderInProgress/result/acceptedOffers.js +42 -27
  128. package/lib/chevre/service/transaction/placeOrderInProgress.js +7 -7
  129. package/lib/chevre/service/transaction/returnOrder.js +8 -6
  130. package/lib/chevre/settings.d.ts +2 -0
  131. package/lib/chevre/settings.js +20 -12
  132. package/package.json +3 -3
  133. package/example/src/chevre/aggregateReservationOnProject.ts +0 -32
  134. package/example/src/chevre/migratePlaceAdditionalProperties.ts +0 -162
@@ -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') {
@@ -198,7 +201,8 @@ function fixProductAndOffers(params) {
198
201
  if (product === undefined) {
199
202
  throw new factory.errors.NotFound('Product');
200
203
  }
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);
204
+ 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~)
205
+ }))(repos);
202
206
  return { product, availableOffers };
203
207
  });
204
208
  }
@@ -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>;