@chevre/domain 20.2.0-alpha.4 → 20.2.0-alpha.40

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 (116) 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/findScreeningRoomsByBranchCode.ts +27 -0
  4. package/example/src/chevre/importEventsFromCOA.ts +8 -1
  5. package/example/src/chevre/migrateEventOffersItemOfferedAvailableChannel.ts +2 -1
  6. package/example/src/chevre/migrateProjectSubscription.ts +51 -0
  7. package/example/src/chevre/processReserve.ts +2 -0
  8. package/example/src/chevre/searchEventIds.ts +24 -0
  9. package/example/src/chevre/searchEventTicketOffers.ts +4 -4
  10. package/example/src/chevre/searchEvents.ts +20 -41
  11. package/example/src/chevre/searchOffersByCatalog.ts +27 -0
  12. package/example/src/chevre/updateTransaction.ts +38 -0
  13. package/lib/chevre/factory/event.d.ts +2 -0
  14. package/lib/chevre/factory/event.js +2 -0
  15. package/lib/chevre/repo/action.d.ts +67 -0
  16. package/lib/chevre/repo/action.js +209 -0
  17. package/lib/chevre/repo/aggregation.d.ts +37 -0
  18. package/lib/chevre/repo/aggregation.js +67 -0
  19. package/lib/chevre/repo/assetTransaction.d.ts +32 -0
  20. package/lib/chevre/repo/assetTransaction.js +148 -0
  21. package/lib/chevre/repo/event.d.ts +62 -16
  22. package/lib/chevre/repo/event.js +458 -156
  23. package/lib/chevre/repo/mongoose/model/aggregation.d.ts +7 -0
  24. package/lib/chevre/repo/mongoose/model/aggregation.js +47 -0
  25. package/lib/chevre/repo/mongoose/model/event.js +4 -3
  26. package/lib/chevre/repo/mongoose/model/offer.js +2 -1
  27. package/lib/chevre/repo/mongoose/model/project.js +7 -1
  28. package/lib/chevre/repo/mongoose/model/telemetry.js +4 -28
  29. package/lib/chevre/repo/offer.d.ts +10 -0
  30. package/lib/chevre/repo/offer.js +47 -16
  31. package/lib/chevre/repo/order.d.ts +2 -0
  32. package/lib/chevre/repo/order.js +29 -7
  33. package/lib/chevre/repo/place.d.ts +26 -1
  34. package/lib/chevre/repo/place.js +216 -12
  35. package/lib/chevre/repo/product.d.ts +1 -0
  36. package/lib/chevre/repo/product.js +5 -0
  37. package/lib/chevre/repo/project.d.ts +4 -1
  38. package/lib/chevre/repo/project.js +9 -10
  39. package/lib/chevre/repo/reservation.d.ts +0 -6
  40. package/lib/chevre/repo/reservation.js +106 -66
  41. package/lib/chevre/repo/task.d.ts +31 -3
  42. package/lib/chevre/repo/task.js +141 -27
  43. package/lib/chevre/repo/transaction.d.ts +45 -5
  44. package/lib/chevre/repo/transaction.js +187 -29
  45. package/lib/chevre/repo/trip.js +33 -27
  46. package/lib/chevre/repository.d.ts +3 -0
  47. package/lib/chevre/repository.js +5 -1
  48. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.d.ts +1 -1
  49. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +86 -59
  50. package/lib/chevre/service/aggregation/event/aggregateUseActionsOnEvent.js +5 -8
  51. package/lib/chevre/service/aggregation/system.d.ts +93 -0
  52. package/lib/chevre/service/aggregation/system.js +377 -0
  53. package/lib/chevre/service/aggregation.d.ts +2 -0
  54. package/lib/chevre/service/aggregation.js +3 -1
  55. package/lib/chevre/service/assetTransaction/pay/movieTicket/validation.js +5 -1
  56. package/lib/chevre/service/assetTransaction/pay/potentialActions.js +2 -4
  57. package/lib/chevre/service/assetTransaction/pay.d.ts +19 -4
  58. package/lib/chevre/service/assetTransaction/pay.js +65 -32
  59. package/lib/chevre/service/assetTransaction/registerService.js +4 -1
  60. package/lib/chevre/service/assetTransaction/reserve/factory.d.ts +3 -0
  61. package/lib/chevre/service/assetTransaction/reserve/factory.js +33 -2
  62. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.d.ts +16 -0
  63. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.js +84 -0
  64. package/lib/chevre/service/assetTransaction/reserve.d.ts +38 -6
  65. package/lib/chevre/service/assetTransaction/reserve.js +119 -94
  66. package/lib/chevre/service/delivery/factory.d.ts +1 -1
  67. package/lib/chevre/service/delivery/factory.js +1 -0
  68. package/lib/chevre/service/event.d.ts +2 -4
  69. package/lib/chevre/service/event.js +35 -14
  70. package/lib/chevre/service/offer/event/authorize.d.ts +4 -7
  71. package/lib/chevre/service/offer/event/authorize.js +26 -87
  72. package/lib/chevre/service/offer/event/cancel.js +0 -1
  73. package/lib/chevre/service/offer/event/factory.d.ts +3 -2
  74. package/lib/chevre/service/offer/event/factory.js +25 -5
  75. package/lib/chevre/service/offer/event/searchEventTicketOffers.d.ts +13 -7
  76. package/lib/chevre/service/offer/event/searchEventTicketOffers.js +81 -45
  77. package/lib/chevre/service/offer/event/voidTransaction.js +0 -2
  78. package/lib/chevre/service/offer/eventServiceByCOA/factory.d.ts +2 -1
  79. package/lib/chevre/service/offer/eventServiceByCOA.js +10 -2
  80. package/lib/chevre/service/offer/factory.js +10 -3
  81. package/lib/chevre/service/offer/product/searchProductOffers.d.ts +1 -0
  82. package/lib/chevre/service/offer/product/searchProductOffers.js +1 -1
  83. package/lib/chevre/service/offer/product.d.ts +1 -0
  84. package/lib/chevre/service/offer/product.js +6 -2
  85. package/lib/chevre/service/offer.d.ts +5 -1
  86. package/lib/chevre/service/offer.js +67 -46
  87. package/lib/chevre/service/order/onOrderStatusChanged/factory.js +2 -1
  88. package/lib/chevre/service/order/onOrderStatusChanged.js +2 -1
  89. package/lib/chevre/service/order/placeOrder.js +16 -0
  90. package/lib/chevre/service/order/returnOrder.js +1 -1
  91. package/lib/chevre/service/order/sendOrder.js +4 -2
  92. package/lib/chevre/service/payment/any.d.ts +5 -0
  93. package/lib/chevre/service/payment/any.js +1 -1
  94. package/lib/chevre/service/payment/movieTicket.d.ts +2 -2
  95. package/lib/chevre/service/payment/movieTicket.js +8 -2
  96. package/lib/chevre/service/reserve/confirmReservation.js +7 -10
  97. package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.js +2 -1
  98. package/lib/chevre/service/reserve/potentialActions/onReservationCheckedIn.js +2 -1
  99. package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.js +2 -1
  100. package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +2 -1
  101. package/lib/chevre/service/reserve/useReservation.js +7 -2
  102. package/lib/chevre/service/task/confirmPayTransaction.js +20 -1
  103. package/lib/chevre/service/task/confirmReserveTransaction.d.ts +4 -0
  104. package/lib/chevre/service/task/confirmReserveTransaction.js +5 -5
  105. package/lib/chevre/service/task/importEventsFromCOA.js +3 -1
  106. package/lib/chevre/service/task/returnPayTransaction.js +5 -1
  107. package/lib/chevre/service/task.js +6 -9
  108. package/lib/chevre/service/transaction/orderProgramMembership.js +2 -1
  109. package/lib/chevre/service/transaction/placeOrderInProgress/result/acceptedOffers.js +42 -27
  110. package/lib/chevre/service/transaction/placeOrderInProgress.js +7 -7
  111. package/lib/chevre/service/transaction/returnOrder.js +3 -3
  112. package/lib/chevre/settings.d.ts +2 -0
  113. package/lib/chevre/settings.js +7 -2
  114. package/package.json +3 -3
  115. package/example/src/chevre/aggregateReservationOnProject.ts +0 -32
  116. package/example/src/chevre/migratePlaceAdditionalProperties.ts +0 -162
@@ -89,8 +89,18 @@ function importFromCOA(params) {
89
89
  endpoint: credentials_1.credentials.coa.endpoint,
90
90
  auth: coaAuthClient
91
91
  }, { timeout: credentials_1.credentials.coa.timeout });
92
+ // 同ブランチコードの販売者を検索する
93
+ const sellersWithSameBranchCode = yield repos.seller.search({
94
+ limit: 1,
95
+ page: 1,
96
+ branchCode: { $eq: params.locationBranchCode }
97
+ });
98
+ const seller = sellersWithSameBranchCode.shift();
99
+ if (typeof (seller === null || seller === void 0 ? void 0 : seller.id) !== 'string') {
100
+ throw new factory.errors.NotFound('Seller', `Seller with branchCod '${params.locationBranchCode}' not found`);
101
+ }
92
102
  // 施設取得
93
- let movieTheater = createMovieTheaterFromCOA(project, yield masterService.theater({ theaterCode: params.locationBranchCode }), yield masterService.screen({ theaterCode: params.locationBranchCode }));
103
+ let movieTheater = createMovieTheaterFromCOA(project, { id: seller.id }, yield masterService.theater({ theaterCode: params.locationBranchCode }), yield masterService.screen({ theaterCode: params.locationBranchCode }));
94
104
  // saveMovieTheater:trueの場合のみ、施設保管(2022-10-10~)
95
105
  if (params.saveMovieTheater === true) {
96
106
  movieTheater = yield repos.place.saveMovieTheaterByBranchCode4coa(movieTheater);
@@ -346,8 +356,19 @@ function createScreeningEvents(params) {
346
356
  }
347
357
  function cancelDeletedEvents(params) {
348
358
  return (repos) => __awaiter(this, void 0, void 0, function* () {
359
+ // distinctでidのみ取得(2023-01-25~)
349
360
  // COAから削除されたイベントをキャンセル済ステータスへ変更
350
- const ids = yield repos.event.search({
361
+ // const ids = await repos.event.search<factory.eventType.ScreeningEvent>({
362
+ // project: { id: { $eq: params.project.id } },
363
+ // typeOf: factory.eventType.ScreeningEvent,
364
+ // superEvent: {
365
+ // locationBranchCodes: [params.locationBranchCode]
366
+ // },
367
+ // startFrom: params.targetImportFrom,
368
+ // startThrough: params.targetImportThrough
369
+ // })
370
+ // .then((events) => events.map((e) => e.id));
371
+ const ids = yield repos.event.searchIds({
351
372
  project: { id: { $eq: params.project.id } },
352
373
  typeOf: factory.eventType.ScreeningEvent,
353
374
  superEvent: {
@@ -355,8 +376,7 @@ function cancelDeletedEvents(params) {
355
376
  },
356
377
  startFrom: params.targetImportFrom,
357
378
  startThrough: params.targetImportThrough
358
- })
359
- .then((events) => events.map((e) => e.id));
379
+ });
360
380
  const idsShouldBe = params.idsShouldBe;
361
381
  const cancelledIds = difference(ids, idsShouldBe);
362
382
  debug(`cancelling ${cancelledIds.length} events...`);
@@ -539,11 +559,12 @@ function createScreeningEventSeriesFromCOA(params) {
539
559
  kanaName: params.movieTheater.kanaName,
540
560
  typeOf: params.movieTheater.typeOf
541
561
  },
542
- organizer: {
543
- typeOf: factory.organizationType.Corporation,
544
- identifier: params.movieTheater.id,
545
- name: params.movieTheater.name
546
- },
562
+ // 不要なので廃止(2023-01-12~)
563
+ // organizer: {
564
+ // typeOf: factory.organizationType.Corporation,
565
+ // identifier: params.movieTheater.id,
566
+ // name: params.movieTheater.name
567
+ // },
547
568
  videoFormat: params.eizouKubuns.filter((kubun) => kubun.kubunCode === params.filmFromCOA.kbnEizou)[0],
548
569
  soundFormat: [],
549
570
  workPerformed: {
@@ -617,7 +638,7 @@ function createScreeningEventSeriesId(params) {
617
638
  */
618
639
  // tslint:disable-next-line:no-single-line-block-comment
619
640
  /* istanbul ignore next */
620
- function createMovieTheaterFromCOA(project, theaterFromCOA, screensFromCOA) {
641
+ function createMovieTheaterFromCOA(project, seller, theaterFromCOA, screensFromCOA) {
621
642
  const id = `MovieTheater-${theaterFromCOA.theaterCode}`;
622
643
  return {
623
644
  project: { typeOf: project.typeOf, id: project.id },
@@ -663,7 +684,8 @@ function createMovieTheaterFromCOA(project, theaterFromCOA, screensFromCOA) {
663
684
  value: 2678400,
664
685
  unitCode: factory.unitCode.Sec
665
686
  }
666
- }
687
+ },
688
+ parentOrganization: { id: seller.id, typeOf: factory.organizationType.Corporation }
667
689
  };
668
690
  }
669
691
  /**
@@ -731,8 +753,7 @@ function updateEvent4ttts(params) {
731
753
  try {
732
754
  event = yield repos.event.save4ttts({
733
755
  oldEventId: params.oldEventId,
734
- attributes: params.attributes,
735
- useOldEventId: params.useOldEventId
756
+ attributes: params.attributes
736
757
  });
737
758
  }
738
759
  catch (error) {
@@ -748,7 +769,7 @@ function updateEvent4ttts(params) {
748
769
  }
749
770
  // アクション完了
750
771
  yield repos.action.complete({ typeOf: action.typeOf, id: action.id, result: {} });
751
- yield (0, offer_1.onEventChanged)(event)({
772
+ yield (0, offer_1.onEventChanged)({ event, isNew: false })({
752
773
  event: repos.event,
753
774
  project: repos.project,
754
775
  task: repos.task
@@ -37,7 +37,7 @@ declare type IAuthorizeOfferAction = factory.action.authorize.offer.seatReservat
37
37
  /**
38
38
  * イベントオファー承認
39
39
  */
40
- export declare function authorize(params: {
40
+ declare function authorize(params: {
41
41
  project: {
42
42
  id: string;
43
43
  typeOf: factory.organizationType.Project;
@@ -49,11 +49,8 @@ export declare function authorize(params: {
49
49
  transaction: {
50
50
  id: string;
51
51
  };
52
- validateEventOfferPeriod?: boolean;
53
- validateEvent?: boolean;
54
- /**
55
- * どの店舗に対して
56
- */
52
+ validateEventOfferPeriod: boolean;
53
+ validateEvent: boolean;
57
54
  store: {
58
55
  /**
59
56
  * 販売アプリケーションID
@@ -61,4 +58,4 @@ export declare function authorize(params: {
61
58
  id: string;
62
59
  };
63
60
  }): IAuthorizeOperation<IAuthorizeOfferAction>;
64
- export {};
61
+ export { authorize };
@@ -10,7 +10,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.authorize = void 0;
13
- const moment = require("moment");
14
13
  const factory = require("../../../factory");
15
14
  const ReserveTransactionService = require("../../assetTransaction/reserve");
16
15
  const CodeService = require("../../code");
@@ -22,9 +21,8 @@ const factory_1 = require("./factory");
22
21
  function authorize(params) {
23
22
  // tslint:disable-next-line:max-func-body-length
24
23
  return (repos) => __awaiter(this, void 0, void 0, function* () {
25
- const now = new Date();
26
- const { transaction, event, bookingServiceIdentifire } = yield validateCreateRequest(Object.assign(Object.assign({}, params), { now, store: params.store }))({ event: repos.event, transaction: repos.transaction });
27
- const acceptedOffers = yield validateAcceptedOffers({
24
+ const { transaction, event, bookingServiceIdentifire } = yield validateCreateRequest(params)({ event: repos.event, transaction: repos.transaction });
25
+ const { acceptedOffers, ticketOffers, unitPriceOffers } = yield validateAcceptedOffers({
28
26
  object: params.object,
29
27
  event,
30
28
  seller: { typeOf: transaction.seller.typeOf, id: String(transaction.seller.id) },
@@ -63,7 +61,12 @@ function authorize(params) {
63
61
  action,
64
62
  event,
65
63
  transactionNumber,
66
- transaction
64
+ transaction,
65
+ availableAtOrFrom: { id: params.store.id },
66
+ ticketOffers,
67
+ unitPriceOffers,
68
+ validateEvent: params.validateEvent === true,
69
+ validateEventOfferPeriod: params.validateEventOfferPeriod === true
67
70
  })(repos);
68
71
  // requestBody = processStartReserveResult.requestBody;
69
72
  // responseBody = processStartReserveResult.responseBody;
@@ -113,7 +116,6 @@ exports.authorize = authorize;
113
116
  function validateCreateRequest(params) {
114
117
  return (repos) => __awaiter(this, void 0, void 0, function* () {
115
118
  var _a, _b;
116
- const now = params.now;
117
119
  const transaction = yield repos.transaction.findInProgressById({
118
120
  typeOf: factory.transactionType.PlaceOrder,
119
121
  id: params.transaction.id
@@ -124,20 +126,16 @@ function validateCreateRequest(params) {
124
126
  if (typeof ((_a = params.object.reservationFor) === null || _a === void 0 ? void 0 : _a.id) !== 'string' || params.object.reservationFor.id.length === 0) {
125
127
  throw new factory.errors.ArgumentNull('object.reservationFor.id');
126
128
  }
127
- const event = yield repos.event.findById({ id: params.object.reservationFor.id });
129
+ // イベント取得属性最適化(2023-01-23~)
130
+ // const event = await repos.event.findById<factory.eventType.ScreeningEvent>({ id: params.object.reservationFor.id });
131
+ const event = yield repos.event.findMinimizedIndividualEventById({
132
+ id: params.object.reservationFor.id
133
+ });
128
134
  let offeredThrough = (_b = event.offers) === null || _b === void 0 ? void 0 : _b.offeredThrough;
129
135
  if (offeredThrough === undefined) {
130
136
  offeredThrough = { typeOf: 'WebAPI', identifier: factory.service.webAPI.Identifier.Chevre };
131
137
  }
132
138
  const bookingServiceIdentifire = offeredThrough.identifier;
133
- if (bookingServiceIdentifire === factory.service.webAPI.Identifier.Chevre) {
134
- if (params.validateEventOfferPeriod === true) {
135
- validateEventOfferPeriod({ event, now, availableAt: { id: params.store.id } });
136
- }
137
- if (params.validateEvent === true) {
138
- validateEvent({ event, object: params.object });
139
- }
140
- }
141
139
  return { transaction, event, bookingServiceIdentifire };
142
140
  });
143
141
  }
@@ -164,7 +162,7 @@ function processStartReserve4chevre(params) {
164
162
  // requestBody = startParams;
165
163
  const startParamObject = yield validateObjectWithoutDetail(startParams)(repos);
166
164
  // 予約取引開始
167
- responseBody = yield ReserveTransactionService.start(Object.assign(Object.assign({}, startParams), { object: startParamObject, validateAppliesToMovieTicket: true }))(repos);
165
+ responseBody = yield ReserveTransactionService.start(Object.assign(Object.assign({}, startParams), { object: startParamObject, preSearchedEvent: event, preSearchedTicketOffers: params.ticketOffers, preSearchedUnitPriceOffers: params.unitPriceOffers, availableAtOrFrom: { id: params.availableAtOrFrom.id }, validateEvent: params.validateEvent, validateEventOfferPeriod: params.validateEventOfferPeriod, validateAppliesToMovieTicket: true }))(repos);
168
166
  // 予約取引からオファー情報を生成する
169
167
  acceptedOffers4result = (0, factory_1.responseBody2acceptedOffers4result)({
170
168
  responseBody: responseBody,
@@ -205,87 +203,29 @@ function validateObjectWithoutDetail(params) {
205
203
  return objectWithoutDetail;
206
204
  });
207
205
  }
208
- /**
209
- * イベントのオファー有効期間を検証する
210
- */
211
- function validateEventOfferPeriod(params) {
212
- const acceptedDate = moment(params.now);
213
- const eventOffers = params.event.offers;
214
- // アプリケーションごとの設定を参照する(2022-11-19~)
215
- const makesOfferOnApplication = eventOffers === null || eventOffers === void 0 ? void 0 : eventOffers.seller.makesOffer.find((offer) => {
216
- return Array.isArray(offer.availableAtOrFrom) && offer.availableAtOrFrom[0].id === params.availableAt.id;
217
- });
218
- if (makesOfferOnApplication === undefined) {
219
- throw new factory.errors.Argument('reservationFor.id', `seller makes no available offer at ${params.availableAt.id}`);
220
- }
221
- const validFrom = makesOfferOnApplication.validFrom;
222
- const validThrough = makesOfferOnApplication.validThrough;
223
- // const validFrom = eventOffers?.validFrom;
224
- // const validThrough = eventOffers?.validThrough;
225
- if (validFrom !== undefined && validFrom !== null) {
226
- if (acceptedDate.isBefore(moment(validFrom))) {
227
- throw new factory.errors.Argument('reservationFor.id', `Offer of ${params.event.id} is valid from ${validFrom}`);
228
- }
229
- }
230
- if (validThrough !== undefined && validThrough !== null) {
231
- if (acceptedDate.isAfter(moment(validThrough))) {
232
- throw new factory.errors.Argument('reservationFor.id', `Offer of ${params.event.id} is valid through ${validThrough}`);
233
- }
234
- }
235
- }
236
- /**
237
- * イベントの上限座席数を検証する
238
- */
239
- function validateEvent(params) {
240
- var _a, _b;
241
- // const acceptedDate = moment(params.now);
242
- const eventOffers = params.event.offers;
243
- // const validFrom = eventOffers?.validFrom;
244
- // const validThrough = eventOffers?.validThrough;
245
- // if (validFrom !== undefined && validFrom !== null) {
246
- // if (acceptedDate.isBefore(moment(validFrom))) {
247
- // throw new factory.errors.Argument(
248
- // 'reservationFor.id',
249
- // `Offer of ${params.event.id} is valid from ${validFrom}`
250
- // );
251
- // }
252
- // }
253
- // if (validThrough !== undefined && validThrough !== null) {
254
- // if (acceptedDate.isAfter(moment(validThrough))) {
255
- // throw new factory.errors.Argument(
256
- // 'reservationFor.id',
257
- // `Offer of ${params.event.id} is valid through ${validThrough}`
258
- // );
259
- // }
260
- // }
261
- // イベントのmaxValueを検証
262
- const maxValue = (_a = eventOffers === null || eventOffers === void 0 ? void 0 : eventOffers.eligibleQuantity) === null || _a === void 0 ? void 0 : _a.maxValue;
263
- if (typeof maxValue === 'number') {
264
- const numAcceptedOffers = (_b = params.object.acceptedOffer) === null || _b === void 0 ? void 0 : _b.length;
265
- if (typeof numAcceptedOffers === 'number' && numAcceptedOffers > 0) {
266
- if (numAcceptedOffers > maxValue) {
267
- throw new factory.errors.Argument('reservationFor.id', `Maximum number of offers exceeded`);
268
- }
269
- }
270
- }
271
- }
272
206
  /**
273
207
  * 受け入れらたオファーの内容を検証
274
208
  */
275
209
  function validateAcceptedOffers(params) {
276
210
  return (repos) => __awaiter(this, void 0, void 0, function* () {
211
+ const acceptedOffersWithoutDetail = params.object.acceptedOffer;
212
+ const offerIds = (Array.isArray(acceptedOffersWithoutDetail))
213
+ ? [...new Set(acceptedOffersWithoutDetail.map((o) => o.id))]
214
+ : [];
277
215
  // 利用可能なチケットオファーを検索
278
- const availableTicketOffers = yield (0, searchEventTicketOffers_1.searchEventTicketOffers)({
216
+ const { ticketOffers, unitPriceOffers } = yield (0, searchEventTicketOffers_1.searchEventTicketOffers)({
217
+ // 受け入れたオファーIDだけ取得する(2023-01-26~)
218
+ ids: offerIds,
279
219
  event: { id: params.event.id },
280
- seller: params.seller,
281
- store: params.store
220
+ // seller: params.seller,
221
+ store: params.store,
222
+ sort: false // ソート不要(2023-01-27~)
282
223
  })(repos);
283
- const acceptedOffersWithoutDetail = params.object.acceptedOffer;
284
224
  // 利用可能なチケットオファーであれば受け入れる
285
225
  const acceptedOffers = (Array.isArray(acceptedOffersWithoutDetail))
286
226
  ? yield Promise.all(acceptedOffersWithoutDetail.map((offerWithoutDetail) => __awaiter(this, void 0, void 0, function* () {
287
227
  return acceptedOfferWithoutDetail2acceptedOffer({
288
- availableTicketOffers,
228
+ availableTicketOffers: ticketOffers,
289
229
  offerWithoutDetail,
290
230
  event: params.event,
291
231
  transaction: params.transaction,
@@ -294,7 +234,6 @@ function validateAcceptedOffers(params) {
294
234
  })))
295
235
  : [];
296
236
  // オファーIDごとにオファー適用条件を確認
297
- const offerIds = [...new Set(acceptedOffers.map((o) => o.id))];
298
237
  offerIds.forEach((offerId) => {
299
238
  var _a;
300
239
  const acceptedOffersByOfferId = acceptedOffers.filter((o) => o.id === offerId);
@@ -324,7 +263,7 @@ function validateAcceptedOffers(params) {
324
263
  }
325
264
  }
326
265
  });
327
- return acceptedOffers;
266
+ return { acceptedOffers, ticketOffers, unitPriceOffers };
328
267
  });
329
268
  }
330
269
  function acceptedOfferWithoutDetail2acceptedOffer(params) {
@@ -37,7 +37,6 @@ function cancel(params) {
37
37
  const transactionNumber = (_a = action.object.pendingTransaction) === null || _a === void 0 ? void 0 : _a.transactionNumber;
38
38
  if (typeof transactionNumber === 'string') {
39
39
  // すでに取消済であったとしても、すべて取消処理(actionStatusに関係なく)
40
- // await repos.reserveTransaction.cancel({ transactionNumber: action.object.pendingTransaction?.transactionNumber });
41
40
  yield ReserveTransactionService.cancel({ transactionNumber })(repos);
42
41
  }
43
42
  }
@@ -1,5 +1,6 @@
1
1
  import * as COA from '@motionpicture/coa-service';
2
2
  import * as factory from '../../../factory';
3
+ import { IMinimizedIndividualEvent } from '../../../factory/event';
3
4
  export declare type IReservationFor = factory.reservation.IReservationFor<factory.reservationType.EventReservation>;
4
5
  export declare type IUnitPriceSpecification = factory.priceSpecification.IPriceSpecification<factory.priceSpecificationType.UnitPriceSpecification>;
5
6
  export declare type IObjectWithoutDetail = factory.action.authorize.offer.seatReservation.IObjectWithoutDetail4chevre;
@@ -14,7 +15,7 @@ export declare function createReserveTransactionStartParams(params: {
14
15
  }): factory.assetTransaction.reserve.IStartParamsWithoutDetail;
15
16
  export declare function createAuthorizeSeatReservationActionAttributes(params: {
16
17
  acceptedOffers: factory.action.authorize.offer.seatReservation.IAcceptedOffer4chevre[];
17
- event: factory.event.IEvent<factory.eventType.ScreeningEvent>;
18
+ event: IMinimizedIndividualEvent<factory.eventType.ScreeningEvent>;
18
19
  pendingTransaction?: factory.action.authorize.offer.seatReservation.IPendingTransaction | undefined;
19
20
  transaction: factory.transaction.ITransaction<factory.transactionType.PlaceOrder>;
20
21
  broker?: factory.reservation.IBroker<factory.reservationType.EventReservation>;
@@ -25,7 +26,7 @@ export declare function acceptedOffers2amount(params: {
25
26
  declare type IResultAcceptedOffer = factory.action.authorize.offer.seatReservation.IResultAcceptedOffer;
26
27
  export declare function responseBody2acceptedOffers4result(params: {
27
28
  responseBody: factory.assetTransaction.reserve.ITransaction;
28
- event: factory.event.IEvent<factory.eventType.ScreeningEvent>;
29
+ event: IMinimizedIndividualEvent<factory.eventType.ScreeningEvent>;
29
30
  project: {
30
31
  id: string;
31
32
  typeOf: factory.organizationType.Project;
@@ -211,7 +211,7 @@ exports.responseBody2acceptedOffers4result = responseBody2acceptedOffers4result;
211
211
  */
212
212
  // tslint:disable-next-line:max-func-body-length
213
213
  function createReservation(params) {
214
- var _a;
214
+ var _a, _b, _c, _d;
215
215
  const itemOffered = params.itemOffered;
216
216
  const event = params.event;
217
217
  let reservationItem;
@@ -243,16 +243,36 @@ function createReservation(params) {
243
243
  .toDate(),
244
244
  // 最適化(2022-05-31~)
245
245
  superEvent: Object.assign(Object.assign({ typeOf: event.superEvent.typeOf, id: event.superEvent.id, kanaName: event.superEvent.kanaName, location: event.superEvent.location, name: event.superEvent.name, soundFormat: event.superEvent.soundFormat, videoFormat: event.superEvent.videoFormat, workPerformed }, (typeof event.superEvent.duration === 'string') ? { duration: event.superEvent.duration } : undefined), (event.superEvent.headline !== undefined) ? { headline: event.superEvent.headline } : undefined)
246
- // 廃止(superEvent.workPerformedへ完全移行)
247
- // workPerformed: {},
248
246
  };
249
- reservationItem = Object.assign({ project: itemOffered.project, typeOf: itemOffered.typeOf, additionalProperty: itemOffered.additionalProperty, additionalTicketText: itemOffered.additionalTicketText, id: itemOffered.id, issuedThrough: itemOffered.issuedThrough, reservationNumber: itemOffered.reservationNumber, reservationFor: reservationFor, reservedTicket: reservedTicket }, (typeof ((_a = itemOffered.programMembershipUsed) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string')
247
+ reservationItem = Object.assign({ project: itemOffered.project, typeOf: itemOffered.typeOf, additionalProperty: itemOffered.additionalProperty, additionalTicketText: itemOffered.additionalTicketText, id: itemOffered.id, issuedThrough: itemOffered.issuedThrough, reservationNumber: itemOffered.reservationNumber, reservationFor,
248
+ reservedTicket }, (typeof ((_a = itemOffered.programMembershipUsed) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string')
250
249
  ? { programMembershipUsed: itemOffered.programMembershipUsed }
251
250
  : undefined);
252
251
  }
253
252
  else if (itemOffered.typeOf === factory.reservationType.BusReservation
254
253
  && event.typeOf === factory.eventType.Event) {
255
- throw new factory.errors.NotImplemented(`${itemOffered.typeOf} not impelemented`);
254
+ const tripByEvent = (_c = (_b = event.offers) === null || _b === void 0 ? void 0 : _b.itemOffered.serviceOutput) === null || _c === void 0 ? void 0 : _c.reservationFor;
255
+ if (typeof (tripByEvent === null || tripByEvent === void 0 ? void 0 : tripByEvent.typeOf) !== 'string') {
256
+ throw new factory.errors.NotFound('event.offers.itemOffered.serviceOutput.reservationFor');
257
+ }
258
+ const reservationFor = {
259
+ typeOf: tripByEvent.typeOf,
260
+ id: event.id,
261
+ arrivalBusStop: tripByEvent.arrivalBusStop,
262
+ departureBusStop: tripByEvent.departureBusStop,
263
+ name: event.name,
264
+ departureTime: moment(tripByEvent.departureTime)
265
+ .toDate(),
266
+ arrivalTime: moment(tripByEvent.arrivalTime)
267
+ .toDate(),
268
+ busName: tripByEvent.busName,
269
+ busNumber: tripByEvent.busNumber,
270
+ identifier: tripByEvent.identifier
271
+ };
272
+ reservationItem = Object.assign({ project: itemOffered.project, typeOf: itemOffered.typeOf, additionalProperty: itemOffered.additionalProperty, additionalTicketText: itemOffered.additionalTicketText, id: itemOffered.id, issuedThrough: itemOffered.issuedThrough, reservationNumber: itemOffered.reservationNumber, reservationFor,
273
+ reservedTicket }, (typeof ((_d = itemOffered.programMembershipUsed) === null || _d === void 0 ? void 0 : _d.typeOf) === 'string')
274
+ ? { programMembershipUsed: itemOffered.programMembershipUsed }
275
+ : undefined);
256
276
  }
257
277
  else {
258
278
  throw new factory.errors.Argument('itemOffered');
@@ -16,7 +16,11 @@ declare type IAcceptedPaymentMethod = factory.paymentMethod.paymentCard.movieTic
16
16
  /**
17
17
  * 興行オファー検索
18
18
  */
19
- export declare function searchEventTicketOffers(params: {
19
+ declare function searchEventTicketOffers(params: {
20
+ /**
21
+ * 指定したIDのオファーだけ取得する場合
22
+ */
23
+ ids?: string[];
20
24
  /**
21
25
  * どのイベントに対して
22
26
  */
@@ -25,12 +29,10 @@ export declare function searchEventTicketOffers(params: {
25
29
  };
26
30
  /**
27
31
  * どの販売者に対して
32
+ * 不要なので廃止(2023-01-27~)
28
33
  */
29
- seller?: {
30
- id?: string;
31
- };
32
34
  /**
33
- * どの店舗に対して
35
+ * どのアプリケーションに対して
34
36
  */
35
37
  store?: {
36
38
  id?: string;
@@ -72,5 +74,9 @@ export declare function searchEventTicketOffers(params: {
72
74
  */
73
75
  kbnEisyahousiki: string;
74
76
  };
75
- }): ISearchEventTicketOffersOperation<factory.product.ITicketOffer[]>;
76
- export {};
77
+ sort: boolean;
78
+ }): ISearchEventTicketOffersOperation<{
79
+ ticketOffers: factory.product.ITicketOffer[];
80
+ unitPriceOffers: factory.unitPriceOffer.IUnitPriceOffer[];
81
+ }>;
82
+ export { searchEventTicketOffers };