@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
@@ -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,
@@ -189,6 +187,12 @@ function validateObjectWithoutDetail(params) {
189
187
  agent: params.project,
190
188
  token: String(programMembershipUsed)
191
189
  })({ action: repos.action });
190
+ if (permitOwnershipInfo.typeOf !== 'OwnershipInfo') {
191
+ throw new factory.errors.Argument('programMembershipUsed', 'must be OwnershipInfo');
192
+ }
193
+ if (permitOwnershipInfo.typeOfGood.typeOf !== factory.permit.PermitType.Permit) {
194
+ throw new factory.errors.Argument('programMembershipUsed', 'must be Permit');
195
+ }
192
196
  const typeOfGood = permitOwnershipInfo.typeOfGood;
193
197
  const issuedThroughId = (_c = typeOfGood.issuedThrough) === null || _c === void 0 ? void 0 : _c.id;
194
198
  if (typeof issuedThroughId !== 'string' || issuedThroughId.length === 0) {
@@ -205,87 +209,30 @@ function validateObjectWithoutDetail(params) {
205
209
  return objectWithoutDetail;
206
210
  });
207
211
  }
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
212
  /**
273
213
  * 受け入れらたオファーの内容を検証
274
214
  */
275
215
  function validateAcceptedOffers(params) {
276
216
  return (repos) => __awaiter(this, void 0, void 0, function* () {
217
+ const acceptedOffersWithoutDetail = params.object.acceptedOffer;
218
+ const offerIds = (Array.isArray(acceptedOffersWithoutDetail))
219
+ ? [...new Set(acceptedOffersWithoutDetail.map((o) => o.id))]
220
+ : [];
277
221
  // 利用可能なチケットオファーを検索
278
- const availableTicketOffers = yield (0, searchEventTicketOffers_1.searchEventTicketOffers)({
222
+ const { ticketOffers, unitPriceOffers } = yield (0, searchEventTicketOffers_1.searchEventTicketOffers)({
223
+ // 受け入れたオファーIDだけ取得する(2023-01-26~)
224
+ ids: offerIds,
279
225
  event: { id: params.event.id },
280
- seller: params.seller,
281
- store: params.store
226
+ // seller: params.seller,
227
+ store: params.store,
228
+ sort: false,
229
+ validateOfferRateLimit: true
282
230
  })(repos);
283
- const acceptedOffersWithoutDetail = params.object.acceptedOffer;
284
231
  // 利用可能なチケットオファーであれば受け入れる
285
232
  const acceptedOffers = (Array.isArray(acceptedOffersWithoutDetail))
286
233
  ? yield Promise.all(acceptedOffersWithoutDetail.map((offerWithoutDetail) => __awaiter(this, void 0, void 0, function* () {
287
234
  return acceptedOfferWithoutDetail2acceptedOffer({
288
- availableTicketOffers,
235
+ availableTicketOffers: ticketOffers,
289
236
  offerWithoutDetail,
290
237
  event: params.event,
291
238
  transaction: params.transaction,
@@ -294,7 +241,6 @@ function validateAcceptedOffers(params) {
294
241
  })))
295
242
  : [];
296
243
  // オファーIDごとにオファー適用条件を確認
297
- const offerIds = [...new Set(acceptedOffers.map((o) => o.id))];
298
244
  offerIds.forEach((offerId) => {
299
245
  var _a;
300
246
  const acceptedOffersByOfferId = acceptedOffers.filter((o) => o.id === offerId);
@@ -324,7 +270,7 @@ function validateAcceptedOffers(params) {
324
270
  }
325
271
  }
326
272
  });
327
- return acceptedOffers;
273
+ return { acceptedOffers, ticketOffers, unitPriceOffers };
328
274
  });
329
275
  }
330
276
  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;
@@ -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,10 @@ export declare function searchEventTicketOffers(params: {
72
74
  */
73
75
  kbnEisyahousiki: string;
74
76
  };
75
- }): ISearchEventTicketOffersOperation<factory.product.ITicketOffer[]>;
76
- export {};
77
+ sort: boolean;
78
+ validateOfferRateLimit: boolean;
79
+ }): ISearchEventTicketOffersOperation<{
80
+ ticketOffers: factory.product.ITicketOffer[];
81
+ unitPriceOffers: factory.unitPriceOffer.IUnitPriceOffer[];
82
+ }>;
83
+ export { searchEventTicketOffers };