@chevre/domain 21.8.0-alpha.6 → 21.8.0-alpha.60

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 (129) hide show
  1. package/example/src/chevre/countOffers.ts +32 -0
  2. package/example/src/chevre/findItemListElementByCatalogId.ts +23 -0
  3. package/example/src/chevre/importOffersFromCOA.ts +7 -1
  4. package/example/src/chevre/migrateAggregateOffers.ts +89 -0
  5. package/example/src/chevre/migrateOrderPaymentMethodIdentifier.ts +81 -0
  6. package/example/src/chevre/migratePayTransactionPaymentMethodId.ts +72 -0
  7. package/example/src/chevre/migratePayTransactionPaymentMethodIdentifier.ts +78 -0
  8. package/example/src/chevre/processPay.ts +3 -4
  9. package/example/src/chevre/publishPermitOwnershipInfoToken.ts +56 -0
  10. package/example/src/chevre/pullAddOnsFromOffer.ts +26 -0
  11. package/example/src/chevre/searchAggregateOffers.ts +48 -0
  12. package/example/src/chevre/searchEventTicketOffers.ts +3 -1
  13. package/example/src/chevre/searchEvents.ts +9 -7
  14. package/example/src/chevre/searchOffersByCatalog.ts +9 -5
  15. package/example/src/chevre/searchOffersFromAggregateOffer.ts +168 -0
  16. package/example/src/chevre/searchOrders.ts +9 -7
  17. package/example/src/chevre/sync2aggregateOffer.ts +27 -0
  18. package/example/src/chevre/syncAggregateOffer.ts +25 -0
  19. package/lib/chevre/emailMessageBuilder.js +6 -5
  20. package/lib/chevre/repo/aggregateOffer.d.ts +62 -0
  21. package/lib/chevre/repo/aggregateOffer.js +534 -0
  22. package/lib/chevre/repo/assetTransaction.d.ts +16 -1
  23. package/lib/chevre/repo/assetTransaction.js +54 -2
  24. package/lib/chevre/repo/mongoose/schemas/aggregateOffer.d.ts +74 -0
  25. package/lib/chevre/repo/mongoose/schemas/aggregateOffer.js +177 -0
  26. package/lib/chevre/repo/mongoose/schemas/authorization.d.ts +3 -3
  27. package/lib/chevre/repo/mongoose/schemas/creativeWork.d.ts +3 -3
  28. package/lib/chevre/repo/mongoose/schemas/event.d.ts +3 -3
  29. package/lib/chevre/repo/mongoose/schemas/offer.d.ts +24 -33
  30. package/lib/chevre/repo/mongoose/schemas/offer.js +4 -3
  31. package/lib/chevre/repo/mongoose/schemas/order.d.ts +3 -0
  32. package/lib/chevre/repo/mongoose/schemas/order.js +7 -0
  33. package/lib/chevre/repo/mongoose/schemas/priceSpecification.d.ts +9 -9
  34. package/lib/chevre/repo/mongoose/schemas/product.d.ts +3 -3
  35. package/lib/chevre/repo/mongoose/schemas/project.d.ts +3 -3
  36. package/lib/chevre/repo/mongoose/schemas/task.d.ts +3 -0
  37. package/lib/chevre/repo/mongoose/schemas/task.js +8 -0
  38. package/lib/chevre/repo/offer.d.ts +82 -47
  39. package/lib/chevre/repo/offer.js +1279 -289
  40. package/lib/chevre/repo/offerCatalog.d.ts +6 -0
  41. package/lib/chevre/repo/offerCatalog.js +13 -0
  42. package/lib/chevre/repo/order.d.ts +15 -0
  43. package/lib/chevre/repo/order.js +58 -26
  44. package/lib/chevre/repo/task.d.ts +7 -1
  45. package/lib/chevre/repo/task.js +100 -0
  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.js +2 -1
  49. package/lib/chevre/service/aggregation/event/aggregateUseActionsOnEvent.js +2 -1
  50. package/lib/chevre/service/assetTransaction/pay/account/validation.js +2 -2
  51. package/lib/chevre/service/assetTransaction/pay/factory.js +26 -18
  52. package/lib/chevre/service/assetTransaction/pay/potentialActions.js +3 -3
  53. package/lib/chevre/service/assetTransaction/pay.js +65 -46
  54. package/lib/chevre/service/assetTransaction/refund/factory.js +8 -2
  55. package/lib/chevre/service/assetTransaction/registerService.js +2 -1
  56. package/lib/chevre/service/assetTransaction/reserve.js +111 -35
  57. package/lib/chevre/service/delivery.js +17 -0
  58. package/lib/chevre/service/offer/event/authorize.js +39 -35
  59. package/lib/chevre/service/offer/event/factory.d.ts +1 -1
  60. package/lib/chevre/service/offer/event/factory.js +8 -8
  61. package/lib/chevre/service/offer/event/importFromCOA.d.ts +2 -0
  62. package/lib/chevre/service/offer/event/searchEventTicketOffers.d.ts +1 -0
  63. package/lib/chevre/service/offer/event/searchEventTicketOffers.js +6 -3
  64. package/lib/chevre/service/offer/event/voidTransaction.js +57 -36
  65. package/lib/chevre/service/offer/eventServiceByCOA/factory.d.ts +2 -1
  66. package/lib/chevre/service/offer/eventServiceByCOA/factory.js +7 -11
  67. package/lib/chevre/service/offer/eventServiceByCOA.js +55 -27
  68. package/lib/chevre/service/offer/factory.d.ts +12 -4
  69. package/lib/chevre/service/offer/factory.js +9 -11
  70. package/lib/chevre/service/offer/product/searchProductOffers.d.ts +8 -1
  71. package/lib/chevre/service/offer/product/searchProductOffers.js +10 -3
  72. package/lib/chevre/service/offer/product.d.ts +1 -0
  73. package/lib/chevre/service/offer/product.js +3 -2
  74. package/lib/chevre/service/offer.d.ts +1 -0
  75. package/lib/chevre/service/offer.js +7 -1
  76. package/lib/chevre/service/order/confirmPayTransaction.d.ts +0 -2
  77. package/lib/chevre/service/order/confirmPayTransaction.js +29 -40
  78. package/lib/chevre/service/order/onAssetTransactionStatusChanged.d.ts +27 -0
  79. package/lib/chevre/service/order/onAssetTransactionStatusChanged.js +226 -0
  80. package/lib/chevre/service/order/onOrderStatusChanged/factory.d.ts +8 -6
  81. package/lib/chevre/service/order/onOrderStatusChanged/factory.js +80 -57
  82. package/lib/chevre/service/order/onOrderStatusChanged.js +81 -54
  83. package/lib/chevre/service/order/payOrder.d.ts +2 -10
  84. package/lib/chevre/service/order/payOrder.js +4 -45
  85. package/lib/chevre/service/order/placeOrder.js +11 -13
  86. package/lib/chevre/service/order.d.ts +3 -1
  87. package/lib/chevre/service/order.js +6 -2
  88. package/lib/chevre/service/payment/any/factory.js +33 -8
  89. package/lib/chevre/service/payment/any.js +30 -21
  90. package/lib/chevre/service/payment/creditCard.js +12 -12
  91. package/lib/chevre/service/payment/movieTicket/validation.js +2 -2
  92. package/lib/chevre/service/payment/movieTicket.js +10 -11
  93. package/lib/chevre/service/payment/paymentCard.js +9 -12
  94. package/lib/chevre/service/project.js +1 -1
  95. package/lib/chevre/service/reserve/checkInReservation.d.ts +8 -0
  96. package/lib/chevre/service/reserve/checkInReservation.js +3 -2
  97. package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.d.ts +3 -0
  98. package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.js +4 -5
  99. package/lib/chevre/service/reserve/potentialActions/onReservationCheckedIn.d.ts +8 -0
  100. package/lib/chevre/service/reserve/potentialActions/onReservationCheckedIn.js +16 -11
  101. package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.js +2 -1
  102. package/lib/chevre/service/reserve/potentialActions/onReservationUsed.d.ts +3 -0
  103. package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +3 -5
  104. package/lib/chevre/service/task/confirmPayTransaction.js +1 -3
  105. package/lib/chevre/service/task/importOffersFromCOA.js +3 -0
  106. package/lib/chevre/service/task/onAssetTransactionStatusChanged.d.ts +6 -0
  107. package/lib/chevre/service/task/onAssetTransactionStatusChanged.js +37 -0
  108. package/lib/chevre/service/task/onAuthorizationCreated.js +5 -1
  109. package/lib/chevre/service/task/onOrderPaymentCompleted.d.ts +6 -0
  110. package/lib/chevre/service/task/onOrderPaymentCompleted.js +35 -0
  111. package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.d.ts +2 -0
  112. package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.js +7 -0
  113. package/lib/chevre/service/task/onResourceUpdated/syncOfferCatalog.d.ts +17 -0
  114. package/lib/chevre/service/task/onResourceUpdated/syncOfferCatalog.js +60 -0
  115. package/lib/chevre/service/task/onResourceUpdated.js +12 -0
  116. package/lib/chevre/service/task/returnPayTransaction.js +8 -3
  117. package/lib/chevre/service/task/syncAggregateOffer.d.ts +7 -0
  118. package/lib/chevre/service/task/syncAggregateOffer.js +23 -0
  119. package/lib/chevre/service/transaction/placeOrderInProgress/result.js +32 -16
  120. package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateMovieTicket.js +13 -11
  121. package/lib/chevre/service/transaction/placeOrderInProgress/validation.js +53 -17
  122. package/lib/chevre/service/transaction/placeOrderInProgress.js +4 -1
  123. package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPaymentMethod.js +7 -6
  124. package/lib/chevre/service/transaction/returnOrder.js +5 -1
  125. package/lib/chevre/settings.d.ts +5 -3
  126. package/lib/chevre/settings.js +6 -6
  127. package/package.json +3 -3
  128. package/example/src/chevre/migrateAuthorizePaymentActionResult.ts +0 -83
  129. package/example/src/chevre/migrateEventOrganizer.ts +0 -154
@@ -299,6 +299,7 @@ function createReservation(params) {
299
299
  }
300
300
  return reservationItem;
301
301
  }
302
+ // tslint:disable-next-line:max-func-body-length
302
303
  function coaTicket2offer(params) {
303
304
  var _a, _b;
304
305
  // 適用通貨区分
@@ -322,7 +323,6 @@ function coaTicket2offer(params) {
322
323
  }]
323
324
  : undefined;
324
325
  const unitPriceSpec = {
325
- // project: { typeOf: factory.organizationType.Project, id: params.project.id },
326
326
  typeOf: factory.priceSpecificationType.UnitPriceSpecification,
327
327
  price: 0,
328
328
  priceCurrency: factory.priceCurrency.JPY,
@@ -332,15 +332,15 @@ function coaTicket2offer(params) {
332
332
  unitCode: factory.unitCode.C62,
333
333
  value: 1
334
334
  }
335
- // appliesToMovieTicket?: {};
336
335
  };
337
336
  const identifier = (0, util_1.format)('%s-%s-%s', factory.service.webAPI.Identifier.COA, params.theaterCode, params.ticketResult.ticketCode);
338
- return Object.assign(Object.assign(Object.assign({ project: { typeOf: factory.organizationType.Project, id: params.project.id }, typeOf: factory.offerType.Offer, priceCurrency: factory.priceCurrency.JPY, id: '', identifier: identifier, name: {
339
- ja: params.ticketResult.ticketName,
340
- en: (typeof params.ticketResult.ticketNameEng === 'string')
341
- ? params.ticketResult.ticketNameEng
342
- : ''
343
- }, description: {
337
+ const offerName = {
338
+ ja: params.ticketResult.ticketName,
339
+ en: (typeof params.ticketResult.ticketNameEng === 'string')
340
+ ? params.ticketResult.ticketNameEng
341
+ : ''
342
+ };
343
+ return Object.assign(Object.assign(Object.assign({ project: { typeOf: factory.organizationType.Project, id: params.project.id }, typeOf: factory.offerType.Offer, priceCurrency: factory.priceCurrency.JPY, id: '', identifier: identifier, name: offerName, description: {
344
344
  ja: '',
345
345
  en: ''
346
346
  }, alternateName: {
@@ -1,6 +1,7 @@
1
1
  import * as COA from '@motionpicture/coa-service';
2
2
  import { MongoRepository as CategoryCodeRepo } from '../../../repo/categoryCode';
3
3
  import { MongoRepository as OfferRepo } from '../../../repo/offer';
4
+ import { MongoRepository as TaskRepo } from '../../../repo/task';
4
5
  export declare function importFromCOA(params: {
5
6
  project: {
6
7
  id: string;
@@ -9,6 +10,7 @@ export declare function importFromCOA(params: {
9
10
  }): (repos: {
10
11
  categoryCode: CategoryCodeRepo;
11
12
  offer: OfferRepo;
13
+ task: TaskRepo;
12
14
  masterService: COA.service.Master;
13
15
  }) => Promise<void>;
14
16
  /**
@@ -47,6 +47,7 @@ declare function searchEventTicketOffers(params: {
47
47
  page?: number;
48
48
  addSortIndex: boolean;
49
49
  validateOfferRateLimit: boolean;
50
+ useOffersAsPrimaryForcible: boolean;
50
51
  }): ISearchEventTicketOffersOperation<{
51
52
  ticketOffers: ITicketOfferWithSortIndex[];
52
53
  unitPriceOffers: factory.unitPriceOffer.IUnitPriceOffer[];
@@ -36,7 +36,8 @@ function searchTicketOffersByItemOffered(params) {
36
36
  // Mongoのpagingを利用するオプション(2023-02-21~)
37
37
  limit: params.limit,
38
38
  page: params.page,
39
- sort: false
39
+ useOffersAsPrimaryForcible: params.useOffersAsPrimaryForcible
40
+ // sort: false // 完全廃止(2023-09-04~)
40
41
  });
41
42
  return { availableOffers: offers, sortedOfferIds };
42
43
  });
@@ -84,7 +85,8 @@ function searchEventTicketOffersByEvent(params) {
84
85
  page: params.page,
85
86
  onlyValid: params.onlyValid,
86
87
  unacceptedPaymentMethod,
87
- excludeAppliesToMovieTicket
88
+ excludeAppliesToMovieTicket,
89
+ useOffersAsPrimaryForcible: params.useOffersAsPrimaryForcible
88
90
  })(repos);
89
91
  // 冗長な検索について最適化(2023-03-03~)
90
92
  const { soundFormatChargeSpecs, videoFormatChargeSpecs, movieTicketTypeChargeSpecs } = yield searchPriceSpecs4event({
@@ -248,7 +250,8 @@ function searchEventTicketOffers(params) {
248
250
  page: params.page,
249
251
  addSortIndex: params.addSortIndex,
250
252
  validateOfferRateLimit: params.validateOfferRateLimit,
251
- onlyValid: params.onlyValid === true
253
+ onlyValid: params.onlyValid === true,
254
+ useOffersAsPrimaryForcible: params.useOffersAsPrimaryForcible
252
255
  })(repos);
253
256
  offers = searchOffersResult.ticketOffers;
254
257
  unitPriceOffers = searchOffersResult.unitPriceOffers;
@@ -26,6 +26,7 @@ exports.WebAPIIdentifier = factory.service.webAPI.Identifier;
26
26
  */
27
27
  function voidTransaction(params) {
28
28
  return (repos) => __awaiter(this, void 0, void 0, function* () {
29
+ var _a, _b;
29
30
  const transaction = yield repos.transaction.findById({
30
31
  typeOf: params.purpose.typeOf,
31
32
  id: params.purpose.id,
@@ -46,8 +47,12 @@ function voidTransaction(params) {
46
47
  throw new factory.errors.NotImplemented(`${transaction.status} not implemented`);
47
48
  // 確定取引に対応(2023-05-07~)
48
49
  case factory.transactionStatusType.Confirmed:
49
- // アクションステータスを検証する
50
- authorizeActions = authorizeActions.filter((a) => a.actionStatus !== factory.actionStatusType.CompletedActionStatus);
50
+ // OrderCancelledを考慮(2023-08-30~)
51
+ const orderCancelled = ((_b = (_a = params.purpose.result) === null || _a === void 0 ? void 0 : _a.order) === null || _b === void 0 ? void 0 : _b.orderStatus) === factory.orderStatus.OrderCancelled;
52
+ if (!orderCancelled) {
53
+ // 取り消すべきアクションに絞る
54
+ authorizeActions = authorizeActions.filter((a) => a.actionStatus !== factory.actionStatusType.CompletedActionStatus);
55
+ }
51
56
  break;
52
57
  default:
53
58
  // no op
@@ -71,44 +76,60 @@ function voidTransaction(params) {
71
76
  }
72
77
  exports.voidTransaction = voidTransaction;
73
78
  function processVoidTransaction4coa(params) {
79
+ var _a, _b;
74
80
  return __awaiter(this, void 0, void 0, function* () {
75
- const action = params.action;
76
- // COAの場合、resultに連携内容情報が記録されているので、その情報を元に仮予約を取り消す
77
- if (action.result !== undefined) {
78
- const coaRequestBody = action.result.requestBody;
79
- const coaResponseBody = action.result.responseBody;
81
+ // COAの場合、objectあるいはresultに連携内容情報が記録されているので、その情報を元に仮予約を取り消す
82
+ let delTmpReserveParams;
83
+ // objectに進行中取引情報があれば利用する(2023-09-11~)
84
+ const pendingTransaction = params.action.object.pendingTransaction;
85
+ if (typeof (pendingTransaction === null || pendingTransaction === void 0 ? void 0 : pendingTransaction.typeOf) === 'string') {
86
+ delTmpReserveParams = {
87
+ theaterCode: pendingTransaction.theaterCode,
88
+ dateJouei: pendingTransaction.dateJouei,
89
+ titleCode: pendingTransaction.titleCode,
90
+ titleBranchNum: pendingTransaction.titleBranchNum,
91
+ timeBegin: pendingTransaction.timeBegin,
92
+ tmpReserveNum: pendingTransaction.tmpReserveNum
93
+ };
94
+ }
95
+ else {
96
+ const coaRequestBody = (_a = params.action.result) === null || _a === void 0 ? void 0 : _a.requestBody;
97
+ const coaResponseBody = (_b = params.action.result) === null || _b === void 0 ? void 0 : _b.responseBody;
80
98
  if (coaRequestBody !== undefined && coaResponseBody !== undefined) {
81
- // COAで仮予約取消
82
- try {
83
- const reserveService = new COA.service.Reserve({
84
- endpoint: credentials_1.credentials.coa.endpoint,
85
- auth: coaAuthClient
86
- }, { timeout: credentials_1.credentials.coa.timeout });
87
- yield reserveService.delTmpReserve({
88
- theaterCode: coaRequestBody.theaterCode,
89
- dateJouei: coaRequestBody.dateJouei,
90
- titleCode: coaRequestBody.titleCode,
91
- titleBranchNum: coaRequestBody.titleBranchNum,
92
- timeBegin: coaRequestBody.timeBegin,
93
- tmpReserveNum: coaResponseBody.tmpReserveNum
94
- });
95
- }
96
- catch (error) {
97
- let deleted = false;
98
- // COAサービスエラーの場合ハンドリング
99
- // tslint:disable-next-line:no-single-line-block-comment
100
- /* istanbul ignore if */
101
- if (error.name === 'COAServiceError') {
102
- if (Number.isInteger(error.code) && error.code < http_status_1.INTERNAL_SERVER_ERROR) {
103
- // すでに取消済の場合こうなるので、okとする
104
- if (error.message === '座席取消失敗') {
105
- deleted = true;
106
- }
99
+ delTmpReserveParams = {
100
+ theaterCode: coaRequestBody.theaterCode,
101
+ dateJouei: coaRequestBody.dateJouei,
102
+ titleCode: coaRequestBody.titleCode,
103
+ titleBranchNum: coaRequestBody.titleBranchNum,
104
+ timeBegin: coaRequestBody.timeBegin,
105
+ tmpReserveNum: coaResponseBody.tmpReserveNum
106
+ };
107
+ }
108
+ }
109
+ if (delTmpReserveParams !== undefined) {
110
+ // COAで仮予約取消
111
+ try {
112
+ const reserveService = new COA.service.Reserve({
113
+ endpoint: credentials_1.credentials.coa.endpoint,
114
+ auth: coaAuthClient
115
+ }, { timeout: credentials_1.credentials.coa.timeout });
116
+ yield reserveService.delTmpReserve(delTmpReserveParams);
117
+ }
118
+ catch (error) {
119
+ let deleted = false;
120
+ // COAサービスエラーの場合ハンドリング
121
+ // tslint:disable-next-line:no-single-line-block-comment
122
+ /* istanbul ignore if */
123
+ if (error.name === 'COAServiceError') {
124
+ if (Number.isInteger(error.code) && error.code < http_status_1.INTERNAL_SERVER_ERROR) {
125
+ // すでに取消済の場合こうなるので、okとする
126
+ if (error.message === '座席取消失敗') {
127
+ deleted = true;
107
128
  }
108
129
  }
109
- if (!deleted) {
110
- throw error;
111
- }
130
+ }
131
+ if (!deleted) {
132
+ throw error;
112
133
  }
113
134
  }
114
135
  }
@@ -4,8 +4,9 @@ export import WebAPIIdentifier = factory.service.webAPI.Identifier;
4
4
  export type IAcceptedOffer4COA = factory.action.authorize.offer.seatReservation.IAcceptedOffer<factory.service.webAPI.Identifier.COA>;
5
5
  export declare function createAuthorizeSeatReservationActionAttributes(params: {
6
6
  acceptedOffers: factory.action.authorize.offer.seatReservation.IAcceptedOffer<factory.service.webAPI.Identifier.COA>[];
7
- event: IMinimizedIndividualEvent<factory.eventType.ScreeningEvent>;
7
+ event: Pick<IMinimizedIndividualEvent<factory.eventType.ScreeningEvent>, 'id' | 'typeOf'>;
8
8
  transaction: factory.transaction.ITransaction<factory.transactionType.PlaceOrder>;
9
+ pendingTransaction: factory.action.authorize.offer.seatReservation.ICOAPendingTransaction;
9
10
  }): factory.action.authorize.offer.seatReservation.IAttributes<WebAPIIdentifier.COA>;
10
11
  /**
11
12
  * 供給情報から承認アクションの価格を導き出す
@@ -17,20 +17,18 @@ function createAuthorizeSeatReservationActionAttributes(params) {
17
17
  typeOf: 'WebAPI'
18
18
  }
19
19
  },
20
- // ↓不要なので廃止(少なくともapiレスポンスにはevent自体含んでいない)(2022-08-19~)
21
- // superEvent: params.event.superEvent,
22
20
  typeOf: params.event.typeOf
23
21
  };
22
+ const authorizeObject = {
23
+ typeOf: factory.action.authorize.offer.seatReservation.ObjectType.SeatReservation,
24
+ acceptedOffer: params.acceptedOffers,
25
+ event: authorizeObjectEvent,
26
+ pendingTransaction: params.pendingTransaction
27
+ };
24
28
  return {
25
29
  project: transaction.project,
26
30
  typeOf: factory.actionType.AuthorizeAction,
27
- object: {
28
- typeOf: factory.action.authorize.offer.seatReservation.ObjectType.SeatReservation,
29
- acceptedOffer: params.acceptedOffers,
30
- event: authorizeObjectEvent
31
- // 不要なので廃止(2022-07-29~)
32
- // ...{ offers: params.acceptedOffers } // 互換性維持のため
33
- },
31
+ object: authorizeObject,
34
32
  agent: {
35
33
  id: transaction.seller.id,
36
34
  typeOf: transaction.seller.typeOf,
@@ -41,8 +39,6 @@ function createAuthorizeSeatReservationActionAttributes(params) {
41
39
  recipient: {
42
40
  typeOf: transaction.agent.typeOf,
43
41
  id: transaction.agent.id
44
- // ↓不要なので廃止(2022-08-19~)
45
- // ...(transaction.agent.identifier !== undefined) ? { identifier: transaction.agent.identifier } : undefined
46
42
  },
47
43
  purpose: { typeOf: transaction.typeOf, id: transaction.id },
48
44
  instrument: { typeOf: 'WebAPI', identifier: factory.service.webAPI.Identifier.COA }
@@ -18,8 +18,8 @@ exports.WebAPIIdentifier = factory.service.webAPI.Identifier;
18
18
  /**
19
19
  * COA興行オファー承認
20
20
  */
21
- // tslint:disable-next-line:max-func-body-length
22
21
  function authorize(params) {
22
+ // tslint:disable-next-line:max-func-body-length
23
23
  return (repos) => __awaiter(this, void 0, void 0, function* () {
24
24
  const transaction = yield repos.transaction.findInProgressById({
25
25
  typeOf: factory.transactionType.PlaceOrder,
@@ -28,34 +28,64 @@ function authorize(params) {
28
28
  if (transaction.agent.id !== params.agent.id) {
29
29
  throw new factory.errors.Forbidden('Transaction not yours');
30
30
  }
31
- // イベント取得属性最適化(2023-01-23~)
32
- const screeningEvent = yield repos.event.findMinimizedIndividualEventById({ id: params.object.event.id });
33
- const availablePaymentMethodTypes = yield repos.categoryCode.search({
34
- project: { id: { $eq: transaction.project.id } },
35
- inCodeSet: { identifier: { $eq: factory.categoryCode.CategorySetIdentifier.PaymentMethodType } }
36
- }, [], []);
37
- const seatingTypes = yield repos.categoryCode.search({
38
- project: { id: { $eq: transaction.project.id } },
39
- inCodeSet: { identifier: { $eq: factory.categoryCode.CategorySetIdentifier.SeatingType } }
40
- }, [], []);
41
- const videoFormatTypes = yield repos.categoryCode.search({
42
- project: { id: { $eq: transaction.project.id } },
43
- inCodeSet: { identifier: { $eq: factory.categoryCode.CategorySetIdentifier.VideoFormatType } }
44
- }, [], []);
45
- // COA仮予約後にリクエストが来る前提
46
- const { acceptedOffers } = yield (0, validateAcceptedOffers_1.validateAcceptedOffers)({
47
- object: params.object,
48
- project: { id: transaction.project.id },
49
- screeningEvent,
50
- availablePaymentMethodTypes,
51
- seatingTypes,
52
- videoFormatTypes
53
- })(repos);
31
+ let screeningEvent;
32
+ let acceptedOffers;
33
+ const pendingTransaction = {
34
+ theaterCode: params.result.requestBody.theaterCode,
35
+ dateJouei: params.result.requestBody.dateJouei,
36
+ titleCode: params.result.requestBody.titleCode,
37
+ titleBranchNum: params.result.requestBody.titleBranchNum,
38
+ timeBegin: params.result.requestBody.timeBegin,
39
+ tmpReserveNum: params.result.responseBody.tmpReserveNum,
40
+ transactionNumber: params.result.responseBody.tmpReserveNum,
41
+ typeOf: 'COAReserveTransaction'
42
+ };
43
+ try {
44
+ // イベント取得属性最適化(2023-01-23~)
45
+ screeningEvent =
46
+ yield repos.event.findMinimizedIndividualEventById({ id: params.object.event.id });
47
+ const availablePaymentMethodTypes = yield repos.categoryCode.search({
48
+ project: { id: { $eq: transaction.project.id } },
49
+ inCodeSet: { identifier: { $eq: factory.categoryCode.CategorySetIdentifier.PaymentMethodType } }
50
+ }, [], []);
51
+ const seatingTypes = yield repos.categoryCode.search({
52
+ project: { id: { $eq: transaction.project.id } },
53
+ inCodeSet: { identifier: { $eq: factory.categoryCode.CategorySetIdentifier.SeatingType } }
54
+ }, [], []);
55
+ const videoFormatTypes = yield repos.categoryCode.search({
56
+ project: { id: { $eq: transaction.project.id } },
57
+ inCodeSet: { identifier: { $eq: factory.categoryCode.CategorySetIdentifier.VideoFormatType } }
58
+ }, [], []);
59
+ // COA仮予約後にリクエストが来る前提
60
+ const validateAcceptedOffersResult = yield (0, validateAcceptedOffers_1.validateAcceptedOffers)({
61
+ object: params.object,
62
+ project: { id: transaction.project.id },
63
+ screeningEvent,
64
+ availablePaymentMethodTypes,
65
+ seatingTypes,
66
+ videoFormatTypes
67
+ })(repos);
68
+ acceptedOffers = validateAcceptedOffersResult.acceptedOffers;
69
+ }
70
+ catch (error) {
71
+ // アクション開始前に例外がthrowされてもCOA仮予約を取り消す機会をつくるためにFailedアクションを作成する(2023-09-12~)
72
+ const failedActionAttributes = (0, factory_1.createAuthorizeSeatReservationActionAttributes)({
73
+ acceptedOffers: [],
74
+ event: { id: params.object.event.id, typeOf: factory.eventType.ScreeningEvent },
75
+ transaction,
76
+ pendingTransaction
77
+ });
78
+ const failedAction = yield repos.action.start(failedActionAttributes);
79
+ const actionError = Object.assign(Object.assign({}, error), { message: error.message, name: error.name });
80
+ yield repos.action.giveUp({ typeOf: failedAction.typeOf, id: failedAction.id, error: actionError });
81
+ throw error;
82
+ }
54
83
  // 承認アクションを開始
55
84
  const actionAttributes = (0, factory_1.createAuthorizeSeatReservationActionAttributes)({
56
85
  acceptedOffers,
57
86
  event: screeningEvent,
58
- transaction: transaction
87
+ transaction,
88
+ pendingTransaction
59
89
  });
60
90
  const action = yield repos.action.start(actionAttributes);
61
91
  try {
@@ -97,8 +127,6 @@ function authorize(params) {
97
127
  requestBody: params.result.requestBody,
98
128
  responseBody: params.result.responseBody,
99
129
  acceptedOffers: acceptedOffers4result
100
- // 不要なので廃止(2023-03-27~)
101
- // ...{ updTmpReserveSeatArgs, updTmpReserveSeatResult } // 互換性維持のため
102
130
  };
103
131
  return yield repos.action.complete({ typeOf: action.typeOf, id: action.id, result: result });
104
132
  });
@@ -1,9 +1,19 @@
1
1
  import * as factory from '../../factory';
2
2
  type IMovieTicketTypeChargeSpecification = factory.priceSpecification.IPriceSpecification<factory.priceSpecificationType.MovieTicketTypeChargeSpecification>;
3
3
  type ICategoryCodeChargeSpecification = factory.priceSpecification.IPriceSpecification<factory.priceSpecificationType.CategoryCodeChargeSpecification>;
4
+ type ITicketOffer = factory.product.ITicketOffer & {
5
+ parentOffer?: {
6
+ id: string;
7
+ };
8
+ };
4
9
  declare function createCompoundPriceSpec4event(params: {
5
10
  eligibleQuantity: factory.quantitativeValue.IQuantitativeValue<factory.unitCode.C62>;
6
- offer: factory.unitPriceOffer.IUnitPriceOffer;
11
+ offer: factory.unitPriceOffer.IUnitPriceOffer & {
12
+ offerIndex?: number;
13
+ parentOffer?: {
14
+ id: string;
15
+ };
16
+ };
7
17
  movieTicketTypeChargeSpecs: IMovieTicketTypeChargeSpecification[];
8
18
  videoFormatChargeSpecs: ICategoryCodeChargeSpecification[];
9
19
  soundFormatChargeSpecs: ICategoryCodeChargeSpecification[];
@@ -11,7 +21,5 @@ declare function createCompoundPriceSpec4event(params: {
11
21
  availability?: factory.itemAvailability;
12
22
  addOn: factory.product.IMinimizedTicketAddOn[];
13
23
  sortIndex?: number;
14
- }): factory.product.ITicketOffer & {
15
- sortIndex?: number;
16
- };
24
+ }): ITicketOffer;
17
25
  export { createCompoundPriceSpec4event };
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createCompoundPriceSpec4event = void 0;
4
4
  const factory = require("../../factory");
5
+ const settings_1 = require("../../settings");
5
6
  function categoryCodeChargePriceSpec2component(params) {
6
7
  var _a;
7
8
  return Object.assign({ id: params.id, typeOf: params.typeOf, name: params.name, price: params.price, priceCurrency: params.priceCurrency, valueAddedTaxIncluded: params.valueAddedTaxIncluded, appliesToCategoryCode: params.appliesToCategoryCode }, (typeof ((_a = params.accounting) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string') ? { accounting: params.accounting } : undefined);
@@ -69,25 +70,22 @@ function createCompoundPriceSpec4event(params) {
69
70
  ...mvtkPriceComponents
70
71
  ];
71
72
  const compoundPriceSpecification = {
72
- // 不要な属性を除外(2022-11-02~)
73
- // project: params.offer.project,
74
73
  typeOf: factory.priceSpecificationType.CompoundPriceSpecification,
75
74
  priceCurrency: factory.priceCurrency.JPY,
76
75
  valueAddedTaxIncluded: true,
77
76
  priceComponent
78
77
  };
79
78
  // 必要な属性のみに限定(2023-02-24~)
80
- // const { project, ...unitOfferFields4ticketOffer } = params.offer;
81
- const { name, description, alternateName, color, typeOf, id,
82
- // addOn,
83
- availability, availableAtOrFrom, category, eligibleMembershipType, eligibleSeatingType, eligibleMonetaryAmount, eligibleSubReservation, priceCurrency, validFrom, validThrough, validRateLimit, additionalProperty, identifier, itemOffered } = params.offer;
84
- return Object.assign(Object.assign({ name, description, alternateName, color, typeOf, id,
85
- // addOn,
86
- // availability,
87
- availableAtOrFrom, category,
79
+ const { name, description, alternateName, color, typeOf, id, availability, availableAtOrFrom, category, eligibleMembershipType, eligibleSeatingType, eligibleMonetaryAmount, eligibleSubReservation, priceCurrency, validFrom, validThrough, validRateLimit, additionalProperty, identifier, itemOffered, offerIndex, parentOffer } = params.offer;
80
+ return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ name, description, alternateName, color, typeOf, id,
81
+ category,
88
82
  eligibleMembershipType, eligibleSeatingType, eligibleMonetaryAmount, eligibleSubReservation,
89
83
  priceCurrency,
90
84
  validFrom, validThrough, validRateLimit, additionalProperty,
91
- identifier, itemOffered, addOn: params.addOn, eligibleQuantity: params.eligibleQuantity, priceSpecification: compoundPriceSpecification }, (typeof params.availability === 'string') ? { availability: params.availability } : { availability }), (typeof params.sortIndex === 'number') ? { sortIndex: params.sortIndex } : undefined);
85
+ identifier, itemOffered, addOn: params.addOn, eligibleQuantity: params.eligibleQuantity, priceSpecification: compoundPriceSpecification }, (!settings_1.USE_OPTIMIZE_TICKET_OFFER)
86
+ ? {
87
+ availableAtOrFrom // 最適化(2023-09-10~)
88
+ }
89
+ : undefined), (typeof params.availability === 'string') ? { availability: params.availability } : { availability }), (typeof params.sortIndex === 'number') ? { sortIndex: params.sortIndex } : undefined), (typeof offerIndex === 'number') ? { offerIndex } : undefined), (typeof (parentOffer === null || parentOffer === void 0 ? void 0 : parentOffer.id) === 'string') ? { parentOffer: { id: parentOffer.id } } : undefined);
92
90
  }
93
91
  exports.createCompoundPriceSpec4event = createCompoundPriceSpec4event;
@@ -1,6 +1,11 @@
1
1
  import * as factory from '../../../factory';
2
2
  import { MongoRepository as OfferRepo } from '../../../repo/offer';
3
3
  import { MongoRepository as ProductRepo } from '../../../repo/product';
4
+ type ITicketOffer = factory.product.ITicketOffer & {
5
+ parentOffer?: {
6
+ id: string;
7
+ };
8
+ };
4
9
  /**
5
10
  * プロダクトオファーを検索する
6
11
  */
@@ -19,7 +24,9 @@ export declare function searchProductOffers(params: {
19
24
  addSortIndex: boolean;
20
25
  limit?: number;
21
26
  page?: number;
27
+ useOffersAsPrimaryForcible: boolean;
22
28
  }): (repos: {
23
29
  offer: OfferRepo;
24
30
  product: ProductRepo;
25
- }) => Promise<factory.product.ITicketOffer[]>;
31
+ }) => Promise<ITicketOffer[]>;
32
+ export {};
@@ -11,6 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.searchProductOffers = void 0;
13
13
  const factory = require("../../../factory");
14
+ const settings_1 = require("../../../settings");
14
15
  /**
15
16
  * プロダクトオファーを検索する
16
17
  */
@@ -29,11 +30,13 @@ function searchProductOffers(params) {
29
30
  excludeAppliesToMovieTicket: false,
30
31
  limit: params.limit,
31
32
  page: params.page,
32
- sort: false,
33
+ // sort: false, // 完全廃止(2023-09-04~)
33
34
  onlyValid: params.onlyValid === true,
34
- availableAtOrFrom: params.availableAt
35
+ availableAtOrFrom: params.availableAt,
36
+ useOffersAsPrimaryForcible: params.useOffersAsPrimaryForcible
35
37
  });
36
38
  return offers.map((o) => {
39
+ var _a;
37
40
  let sortIndex;
38
41
  if (params.addSortIndex) {
39
42
  sortIndex = sortedOfferIds.indexOf(String(o.id));
@@ -47,7 +50,11 @@ function searchProductOffers(params) {
47
50
  ...(unitSpec !== undefined) ? [unitSpec] : []
48
51
  ]
49
52
  };
50
- return Object.assign(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: o.itemOffered, name: o.name, priceCurrency: o.priceCurrency, typeOf: o.typeOf, priceSpecification: compoundPriceSpecification }, (o.validFrom instanceof Date) ? { validFrom: o.validFrom } : undefined), (o.validThrough instanceof Date) ? { validThrough: o.validThrough } : undefined), (typeof sortIndex === 'number') ? { sortIndex } : undefined);
53
+ return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ additionalProperty: (Array.isArray(o.additionalProperty)) ? o.additionalProperty : [], alternateName: o.alternateName, availability: o.availability, color: o.color, description: o.description, id: o.id, identifier: o.identifier, itemOffered: o.itemOffered, name: o.name, priceCurrency: o.priceCurrency, typeOf: o.typeOf, priceSpecification: compoundPriceSpecification }, (!settings_1.USE_OPTIMIZE_TICKET_OFFER)
54
+ ? {
55
+ availableAtOrFrom: o.availableAtOrFrom // 最適化(2023-09-10~)
56
+ }
57
+ : undefined), (o.validFrom instanceof Date) ? { validFrom: o.validFrom } : undefined), (o.validThrough instanceof Date) ? { validThrough: o.validThrough } : undefined), (typeof sortIndex === 'number') ? { sortIndex } : undefined), (typeof o.offerIndex === 'number') ? { offerIndex: o.offerIndex } : undefined), (typeof ((_a = o.parentOffer) === null || _a === void 0 ? void 0 : _a.id) === 'string') ? { parentOffer: { id: o.parentOffer.id } } : undefined);
51
58
  });
52
59
  });
53
60
  }
@@ -55,6 +55,7 @@ export declare function search(params: {
55
55
  limit?: number;
56
56
  page?: number;
57
57
  addSortIndex: boolean;
58
+ useOffersAsPrimaryForcible: boolean;
58
59
  }): (repos: {
59
60
  offer: OfferRepo;
60
61
  product: ProductRepo;
@@ -66,7 +66,8 @@ function search(params) {
66
66
  itemOffered: { id: params.itemOffered.id },
67
67
  availableAt: params.availableAt,
68
68
  onlyValid: params.onlyValid,
69
- addSortIndex: params.addSortIndex
69
+ addSortIndex: params.addSortIndex,
70
+ useOffersAsPrimaryForcible: params.useOffersAsPrimaryForcible
70
71
  })(repos);
71
72
  return { offers, product };
72
73
  // Mongoへ移行(2023-03-01~)
@@ -211,7 +212,7 @@ function fixProductAndOffers(params) {
211
212
  if (product === undefined) {
212
213
  throw new factory.errors.NotFound('Product');
213
214
  }
214
- const { offers } = yield search(Object.assign({ ids: params.object.map((o) => String(o.id)), project: { id: params.project.id }, itemOffered: { id: String(product.id) }, onlyValid: true, addSortIndex: false }, (typeof ((_c = params.location) === null || _c === void 0 ? void 0 : _c.id) === 'string') ? { availableAt: { id: params.location.id } } : undefined))(repos);
215
+ const { offers } = yield search(Object.assign({ ids: params.object.map((o) => String(o.id)), project: { id: params.project.id }, itemOffered: { id: String(product.id) }, onlyValid: true, addSortIndex: false, useOffersAsPrimaryForcible: false }, (typeof ((_c = params.location) === null || _c === void 0 ? void 0 : _c.id) === 'string') ? { availableAt: { id: params.location.id } } : undefined))(repos);
215
216
  return { product, availableOffers: offers };
216
217
  });
217
218
  }
@@ -71,6 +71,7 @@ export declare function createAggregateScreeningEventIfNotExist(params: {
71
71
  id: string;
72
72
  }[];
73
73
  force: boolean;
74
+ identifier: string;
74
75
  }): (repos: {
75
76
  task: TaskRepo;
76
77
  }) => Promise<void>;
@@ -135,7 +135,8 @@ function onEventChanged(params) {
135
135
  return { id };
136
136
  }),
137
137
  // 新規作成の場合は強制的に集計
138
- force: params.isNew
138
+ force: params.isNew,
139
+ identifier: `onEventChanged`
139
140
  })(repos);
140
141
  }
141
142
  // 通知タスク作成(2023-06-08~)
@@ -184,9 +185,12 @@ function createAggregateScreeningEventIfNotExist(params) {
184
185
  const project = {
185
186
  id: params.project.id, typeOf: factory.organizationType.Project
186
187
  };
188
+ const nowInMilliseconds = Date.now();
187
189
  if (params.force) {
188
190
  aggregateTasks = params.reservationFor.map((reservationFor) => {
191
+ const taskIdentifier = `${params.project.id}:${factory.taskName.AggregateScreeningEvent}:${reservationFor.id}:${params.identifier}:${nowInMilliseconds}`;
189
192
  return {
193
+ identifier: taskIdentifier,
190
194
  project,
191
195
  name: factory.taskName.AggregateScreeningEvent,
192
196
  status: factory.taskStatus.Ready,
@@ -209,7 +213,9 @@ function createAggregateScreeningEventIfNotExist(params) {
209
213
  }, { _id: 1 })
210
214
  .exec();
211
215
  if (readyAggregateScreeningEventTaskDoc === null) {
216
+ const taskIdentifier = `${params.project.id}:${factory.taskName.AggregateScreeningEvent}:${reservationFor.id}:${params.identifier}:${nowInMilliseconds}`;
212
217
  aggregateTasks.push({
218
+ identifier: taskIdentifier,
213
219
  project,
214
220
  name: factory.taskName.AggregateScreeningEvent,
215
221
  status: factory.taskStatus.Ready,
@@ -1,7 +1,6 @@
1
1
  import * as factory from '../../factory';
2
2
  import { MongoRepository as AccountingReportRepo } from '../../repo/accountingReport';
3
3
  import { MongoRepository as ActionRepo } from '../../repo/action';
4
- import { RedisRepository as RegisterServiceInProgressRepo } from '../../repo/action/registerServiceInProgress';
5
4
  import { MongoRepository as AssetTransactionRepo } from '../../repo/assetTransaction';
6
5
  import { MongoRepository as EventRepo } from '../../repo/event';
7
6
  import { MongoRepository as OrderRepo } from '../../repo/order';
@@ -21,6 +20,5 @@ declare function confirmPayTransaction(data: factory.task.IData<factory.taskName
21
20
  seller: SellerRepo;
22
21
  task: TaskRepo;
23
22
  transaction: TransactionRepo;
24
- registerServiceInProgress: RegisterServiceInProgressRepo;
25
23
  }) => Promise<void>;
26
24
  export { confirmPayTransaction };