@chevre/domain 20.4.0-alpha.2 → 20.4.0-alpha.21

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 (65) hide show
  1. package/example/src/chevre/aggregateEventReservation.ts +1 -1
  2. package/example/src/chevre/createManyEventsIfNotExist.ts +10 -10
  3. package/example/src/chevre/deleteMovieTicketCategoryChargePriceSpecs.ts +21 -0
  4. package/example/src/chevre/migrateMoneyTransferPendingTransactionIdentifier.ts +96 -0
  5. package/example/src/chevre/searchEventTicketOffers.ts +7 -4
  6. package/example/src/chevre/searchOffersByCatalog.ts +2 -1
  7. package/example/src/chevre/unsetUnnecessaryFields.ts +21 -0
  8. package/lib/chevre/repo/account.d.ts +4 -10
  9. package/lib/chevre/repo/account.js +72 -60
  10. package/lib/chevre/repo/assetTransaction.d.ts +1 -0
  11. package/lib/chevre/repo/assetTransaction.js +5 -0
  12. package/lib/chevre/repo/event.d.ts +5 -4
  13. package/lib/chevre/repo/event.js +12 -30
  14. package/lib/chevre/repo/mongoose/model/comments.d.ts +1 -1
  15. package/lib/chevre/repo/mongoose/model/comments.js +1 -1
  16. package/lib/chevre/repo/mongoose/model/offer.js +12 -0
  17. package/lib/chevre/repo/offer.d.ts +17 -2
  18. package/lib/chevre/repo/offer.js +77 -44
  19. package/lib/chevre/repo/priceSpecification.d.ts +10 -0
  20. package/lib/chevre/repo/priceSpecification.js +9 -0
  21. package/lib/chevre/repo/serviceOutput.d.ts +4 -0
  22. package/lib/chevre/repo/serviceOutput.js +6 -0
  23. package/lib/chevre/repository.d.ts +6 -0
  24. package/lib/chevre/repository.js +8 -1
  25. package/lib/chevre/service/account.d.ts +0 -8
  26. package/lib/chevre/service/account.js +16 -10
  27. package/lib/chevre/service/accountTransaction/deposit.js +2 -1
  28. package/lib/chevre/service/accountTransaction/factory.js +25 -20
  29. package/lib/chevre/service/accountTransaction/transfer.js +4 -2
  30. package/lib/chevre/service/accountTransaction/withdraw.js +2 -1
  31. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +46 -83
  32. package/lib/chevre/service/aggregation/event/aggregateUseActionsOnEvent.js +3 -1
  33. package/lib/chevre/service/assetTransaction/moneyTransfer.js +19 -11
  34. package/lib/chevre/service/assetTransaction/pay.js +19 -14
  35. package/lib/chevre/service/assetTransaction/registerService/factory.js +9 -4
  36. package/lib/chevre/service/assetTransaction/reserve.js +2 -0
  37. package/lib/chevre/service/delivery.js +12 -3
  38. package/lib/chevre/service/event.js +3 -23
  39. package/lib/chevre/service/moneyTransfer.d.ts +1 -1
  40. package/lib/chevre/service/moneyTransfer.js +7 -8
  41. package/lib/chevre/service/offer/event/authorize.js +2 -1
  42. package/lib/chevre/service/offer/event/factory.js +1 -1
  43. package/lib/chevre/service/offer/event/searchEventTicketOffers.d.ts +6 -6
  44. package/lib/chevre/service/offer/event/searchEventTicketOffers.js +106 -91
  45. package/lib/chevre/service/offer/factory.d.ts +4 -1
  46. package/lib/chevre/service/offer/factory.js +57 -26
  47. package/lib/chevre/service/offer/moneyTransfer/authorize.js +0 -1
  48. package/lib/chevre/service/offer/moneyTransfer/returnMoneyTransfer.js +0 -1
  49. package/lib/chevre/service/offer/product/searchProductOffers.js +5 -1
  50. package/lib/chevre/service/payment/any/factory.js +29 -2
  51. package/lib/chevre/service/payment/any.js +11 -4
  52. package/lib/chevre/service/payment/movieTicket.d.ts +7 -2
  53. package/lib/chevre/service/payment/movieTicket.js +17 -8
  54. package/lib/chevre/service/payment/paymentCard.d.ts +6 -2
  55. package/lib/chevre/service/payment/paymentCard.js +16 -8
  56. package/lib/chevre/service/permit.d.ts +5 -1
  57. package/lib/chevre/service/permit.js +18 -11
  58. package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +25 -53
  59. package/lib/chevre/service/transaction/moneyTransfer.js +0 -1
  60. package/lib/chevre/settings.d.ts +6 -0
  61. package/lib/chevre/settings.js +8 -2
  62. package/package.json +3 -3
  63. package/example/src/chevre/migrateAccountTitleAdditionalProperties.ts +0 -157
  64. package/example/src/chevre/migrateProjectSubscription.ts +0 -51
  65. package/example/src/chevre/migrateSection.ts +0 -105
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.searchEventTicketOffers = void 0;
13
13
  const moment = require("moment-timezone");
14
14
  const factory = require("../../../factory");
15
+ const settings_1 = require("../../../settings");
15
16
  const factory_1 = require("../factory");
16
17
  /**
17
18
  * 旅客オファー検索
@@ -23,18 +24,25 @@ function searchTransportationEventTicketOffers(params) {
23
24
  const screeningEvent = params.event;
24
25
  const soundFormatTypes = [];
25
26
  const videoFormatTypes = [];
27
+ const unacceptedPaymentMethod = getUnacceptedPaymentMethodByEvent({ event: screeningEvent });
28
+ // 上映方式がなければMovieTicket除外(2023-02-21~)
29
+ const excludeAppliesToMovieTicket = videoFormatTypes.length === 0;
26
30
  let availableOffers = [];
31
+ let sortedOfferIds = [];
27
32
  // 興行設定があれば興行のカタログを参照する(2022-08-31~)
28
33
  const eventOffers = screeningEvent.offers;
29
34
  if (typeof ((_a = eventOffers === null || eventOffers === void 0 ? void 0 : eventOffers.itemOffered) === null || _a === void 0 ? void 0 : _a.id) === 'string') {
30
35
  const transportation = yield repos.product.findById({ id: eventOffers.itemOffered.id });
31
36
  if (typeof ((_b = transportation.hasOfferCatalog) === null || _b === void 0 ? void 0 : _b.id) === 'string') {
32
- availableOffers = yield repos.offer.findOffersByOfferCatalogId({
33
- ids: params.ids,
34
- offerCatalog: { id: transportation.hasOfferCatalog.id },
35
- availableAtOrFrom: { id: (_c = params.store) === null || _c === void 0 ? void 0 : _c.id },
36
- sort: params.sort
37
- });
37
+ const findOffersByOfferCatalogIdResult = yield repos.offer.findOffersByOfferCatalogId(Object.assign({ ids: params.ids, offerCatalog: { id: transportation.hasOfferCatalog.id }, availableAtOrFrom: { id: (_c = params.store) === null || _c === void 0 ? void 0 : _c.id }, unacceptedPaymentMethod,
38
+ excludeAppliesToMovieTicket, onlyValid: params.onlyValid === true, sort: params.sort }, (!params.sort)
39
+ ? {
40
+ limit: params.limit,
41
+ page: params.page
42
+ }
43
+ : undefined));
44
+ availableOffers = findOffersByOfferCatalogIdResult.offers;
45
+ sortedOfferIds = findOffersByOfferCatalogIdResult.sortedOfferIds;
38
46
  }
39
47
  }
40
48
  else {
@@ -42,24 +50,6 @@ function searchTransportationEventTicketOffers(params) {
42
50
  throw new factory.errors.NotFound('event.offers.itemOffered.id');
43
51
  }
44
52
  const { soundFormatChargeSpecifications, videoFormatChargeSpecifications, movieTicketTypeChargeSpecs } = yield searchPriceSpecs4event({ project: { id: screeningEvent.project.id }, soundFormatTypes, videoFormatTypes })(repos);
45
- const unacceptedPaymentMethod = getUnacceptedPaymentMethodByEvent({ event: screeningEvent });
46
- // 不許可決済方法があれば、該当オファーを除外
47
- if (Array.isArray(unacceptedPaymentMethod) && unacceptedPaymentMethod.length > 0) {
48
- availableOffers = availableOffers.filter((o) => {
49
- var _a;
50
- // 複数決済カード対応(2022-07-11~)
51
- const priceSpecificationAppliesToMovieTicket = (_a = o.priceSpecification) === null || _a === void 0 ? void 0 : _a.appliesToMovieTicket;
52
- if (Array.isArray(priceSpecificationAppliesToMovieTicket)) {
53
- return priceSpecificationAppliesToMovieTicket.every((appliesToMovieTicket) => {
54
- return !unacceptedPaymentMethod.includes(appliesToMovieTicket.serviceOutput.typeOf);
55
- });
56
- }
57
- else {
58
- // Arrayでないケースは廃止(2022-09-10~)
59
- return true;
60
- }
61
- });
62
- }
63
53
  // 適用決済カード条件がある場合、決済カード加算料金が存在しないオファーは除外する
64
54
  availableOffers = availableOffers.filter((o) => {
65
55
  var _a;
@@ -71,9 +61,9 @@ function searchTransportationEventTicketOffers(params) {
71
61
  return false;
72
62
  }
73
63
  // 上映方式がなければ除外(2022-11-03~)
74
- if (videoFormatTypes.length === 0) {
75
- return false;
76
- }
64
+ // if (videoFormatTypes.length === 0) {
65
+ // return false;
66
+ // }
77
67
  return priceSpecificationAppliesToMovieTicket.every((appliesToMovieTicket) => {
78
68
  // すべての上映方式について検証する(2022-10-29~)
79
69
  return videoFormatTypes.every((videoFormat) => {
@@ -92,13 +82,18 @@ function searchTransportationEventTicketOffers(params) {
92
82
  }
93
83
  });
94
84
  let offers4event = availableOffers.map((availableOffer) => {
85
+ let sortIndex;
86
+ if (params.addSortIndex) {
87
+ sortIndex = sortedOfferIds.indexOf(String(availableOffer.id));
88
+ }
95
89
  return (0, factory_1.createCompoundPriceSpec4event)({
96
90
  eligibleQuantity: eventOffers.eligibleQuantity,
97
91
  offer: availableOffer,
98
92
  videoFormatChargeSpecifications,
99
93
  soundFormatChargeSpecifications,
100
94
  movieTicketTypeChargeSpecs,
101
- videoFormatTypes
95
+ videoFormatTypes,
96
+ sortIndex
102
97
  });
103
98
  });
104
99
  if (params.validateOfferRateLimit) {
@@ -138,24 +133,30 @@ function searchScreeningEventTicketOffers(params) {
138
133
  return (repos) => __awaiter(this, void 0, void 0, function* () {
139
134
  var _a, _b, _c, _d;
140
135
  // イベント取得属性最適化(2023-01-23~)
141
- // const screeningEvent = await repos.event.findById<factory.eventType.ScreeningEvent>({ id: params.eventId });
142
136
  const screeningEvent = params.event;
143
137
  // 取得属性最適化(2023-01-25~)
144
138
  const superEvent = yield repos.event.findById({ id: screeningEvent.superEvent.id }, { soundFormat: 1, videoFormat: 1 });
145
139
  const soundFormatTypes = (Array.isArray(superEvent.soundFormat)) ? superEvent.soundFormat.map((f) => f.typeOf) : [];
146
140
  const videoFormatTypes = (Array.isArray(superEvent.videoFormat)) ? superEvent.videoFormat.map((f) => f.typeOf) : [];
141
+ const unacceptedPaymentMethod = getUnacceptedPaymentMethodByEvent({ event: screeningEvent });
142
+ // 上映方式がなければMovieTicket除外(2023-02-21~)
143
+ const excludeAppliesToMovieTicket = videoFormatTypes.length === 0;
147
144
  let availableOffers = [];
145
+ let sortedOfferIds = [];
148
146
  // 興行設定があれば興行のカタログを参照する(2022-08-31~)
149
147
  const eventOffers = screeningEvent.offers;
150
148
  if (typeof ((_a = eventOffers === null || eventOffers === void 0 ? void 0 : eventOffers.itemOffered) === null || _a === void 0 ? void 0 : _a.id) === 'string') {
151
149
  const eventService = yield repos.product.findById({ id: eventOffers.itemOffered.id });
152
150
  if (typeof ((_b = eventService.hasOfferCatalog) === null || _b === void 0 ? void 0 : _b.id) === 'string') {
153
- availableOffers = yield repos.offer.findOffersByOfferCatalogId({
154
- ids: params.ids,
155
- offerCatalog: { id: eventService.hasOfferCatalog.id },
156
- availableAtOrFrom: { id: (_c = params.store) === null || _c === void 0 ? void 0 : _c.id },
157
- sort: params.sort
158
- });
151
+ const findOffersByOfferCatalogIdResult = yield repos.offer.findOffersByOfferCatalogId(Object.assign({ ids: params.ids, offerCatalog: { id: eventService.hasOfferCatalog.id }, availableAtOrFrom: { id: (_c = params.store) === null || _c === void 0 ? void 0 : _c.id }, unacceptedPaymentMethod,
152
+ excludeAppliesToMovieTicket, onlyValid: params.onlyValid === true, sort: params.sort }, (!params.sort)
153
+ ? {
154
+ limit: params.limit,
155
+ page: params.page
156
+ }
157
+ : undefined));
158
+ availableOffers = findOffersByOfferCatalogIdResult.offers;
159
+ sortedOfferIds = findOffersByOfferCatalogIdResult.sortedOfferIds;
159
160
  }
160
161
  }
161
162
  else {
@@ -163,16 +164,48 @@ function searchScreeningEventTicketOffers(params) {
163
164
  throw new factory.errors.NotFound('event.offers.itemOffered.id');
164
165
  }
165
166
  const { soundFormatChargeSpecifications, videoFormatChargeSpecifications, movieTicketTypeChargeSpecs } = yield searchPriceSpecs4event({ project: { id: screeningEvent.project.id }, soundFormatTypes, videoFormatTypes })(repos);
166
- const unacceptedPaymentMethod = getUnacceptedPaymentMethodByEvent({ event: screeningEvent });
167
167
  // 不許可決済方法があれば、該当オファーを除外
168
- if (Array.isArray(unacceptedPaymentMethod) && unacceptedPaymentMethod.length > 0) {
168
+ // Mongoオファー検索条件へ移行(2023-02-21~)
169
+ // if (Array.isArray(unacceptedPaymentMethod) && unacceptedPaymentMethod.length > 0) {
170
+ // availableOffers = availableOffers.filter((o) => {
171
+ // // 複数決済カード対応(2022-07-11~)
172
+ // const priceSpecificationAppliesToMovieTicket = o.priceSpecification?.appliesToMovieTicket;
173
+ // if (Array.isArray(priceSpecificationAppliesToMovieTicket)) {
174
+ // return priceSpecificationAppliesToMovieTicket.every((appliesToMovieTicket) => {
175
+ // return !unacceptedPaymentMethod.includes(appliesToMovieTicket.serviceOutput.typeOf);
176
+ // });
177
+ // } else {
178
+ // // Arrayでないケースは廃止(2022-09-10~)
179
+ // return true;
180
+ // }
181
+ // });
182
+ // }
183
+ // 決済カード加算料金が存在しない場合自動補完する(2023-02-21~)
184
+ if (!settings_1.settings.useOffersAppliedToMovieTicketWithoutChargeSpecification) {
185
+ // 適用決済カード条件がある場合、決済カード加算料金が存在しないオファーは除外する
169
186
  availableOffers = availableOffers.filter((o) => {
170
187
  var _a;
171
- // 複数決済カード対応(2022-07-11~)
188
+ // 複数決済カード対応(2022-07-26~)
172
189
  const priceSpecificationAppliesToMovieTicket = (_a = o.priceSpecification) === null || _a === void 0 ? void 0 : _a.appliesToMovieTicket;
173
190
  if (Array.isArray(priceSpecificationAppliesToMovieTicket)) {
191
+ // 適用決済カード数が0であれば除外
192
+ if (priceSpecificationAppliesToMovieTicket.length === 0) {
193
+ return false;
194
+ }
195
+ // 上映方式がなければ除外(2022-11-03~)
196
+ // if (videoFormatTypes.length === 0) {
197
+ // return false;
198
+ // }
174
199
  return priceSpecificationAppliesToMovieTicket.every((appliesToMovieTicket) => {
175
- return !unacceptedPaymentMethod.includes(appliesToMovieTicket.serviceOutput.typeOf);
200
+ // すべての上映方式について検証する(2022-10-29~)
201
+ return videoFormatTypes.every((videoFormat) => {
202
+ return movieTicketTypeChargeSpecs.some((s) => {
203
+ var _a, _b, _c, _d;
204
+ return ((_b = (_a = s.appliesToMovieTicket) === null || _a === void 0 ? void 0 : _a.serviceOutput) === null || _b === void 0 ? void 0 : _b.typeOf) === ((_c = appliesToMovieTicket.serviceOutput) === null || _c === void 0 ? void 0 : _c.typeOf)
205
+ && ((_d = s.appliesToMovieTicket) === null || _d === void 0 ? void 0 : _d.serviceType) === appliesToMovieTicket.serviceType
206
+ && s.appliesToVideoFormat === videoFormat;
207
+ });
208
+ });
176
209
  });
177
210
  }
178
211
  else {
@@ -181,45 +214,19 @@ function searchScreeningEventTicketOffers(params) {
181
214
  }
182
215
  });
183
216
  }
184
- // 適用決済カード条件がある場合、決済カード加算料金が存在しないオファーは除外する
185
- availableOffers = availableOffers.filter((o) => {
186
- var _a;
187
- // 複数決済カード対応(2022-07-26~)
188
- const priceSpecificationAppliesToMovieTicket = (_a = o.priceSpecification) === null || _a === void 0 ? void 0 : _a.appliesToMovieTicket;
189
- if (Array.isArray(priceSpecificationAppliesToMovieTicket)) {
190
- // 適用決済カード数が0であれば除外
191
- if (priceSpecificationAppliesToMovieTicket.length === 0) {
192
- return false;
193
- }
194
- // 上映方式がなければ除外(2022-11-03~)
195
- if (videoFormatTypes.length === 0) {
196
- return false;
197
- }
198
- return priceSpecificationAppliesToMovieTicket.every((appliesToMovieTicket) => {
199
- // すべての上映方式について検証する(2022-10-29~)
200
- return videoFormatTypes.every((videoFormat) => {
201
- return movieTicketTypeChargeSpecs.some((s) => {
202
- var _a, _b, _c, _d;
203
- return ((_b = (_a = s.appliesToMovieTicket) === null || _a === void 0 ? void 0 : _a.serviceOutput) === null || _b === void 0 ? void 0 : _b.typeOf) === ((_c = appliesToMovieTicket.serviceOutput) === null || _c === void 0 ? void 0 : _c.typeOf)
204
- && ((_d = s.appliesToMovieTicket) === null || _d === void 0 ? void 0 : _d.serviceType) === appliesToMovieTicket.serviceType
205
- && s.appliesToVideoFormat === videoFormat;
206
- });
207
- });
208
- });
209
- }
210
- else {
211
- // Arrayでないケースは廃止(2022-09-10~)
212
- return true;
213
- }
214
- });
215
217
  let offers4event = availableOffers.map((availableOffer) => {
218
+ let sortIndex;
219
+ if (params.addSortIndex) {
220
+ sortIndex = sortedOfferIds.indexOf(String(availableOffer.id));
221
+ }
216
222
  return (0, factory_1.createCompoundPriceSpec4event)({
217
223
  eligibleQuantity: eventOffers.eligibleQuantity,
218
224
  offer: availableOffer,
219
225
  videoFormatChargeSpecifications,
220
226
  soundFormatChargeSpecifications,
221
227
  movieTicketTypeChargeSpecs,
222
- videoFormatTypes
228
+ videoFormatTypes,
229
+ sortIndex
223
230
  });
224
231
  });
225
232
  if (params.validateOfferRateLimit) {
@@ -253,9 +260,6 @@ function getUnacceptedPaymentMethodByEvent(params) {
253
260
  const eventOffers = params.event.offers;
254
261
  const unacceptedPaymentMethodByEvent = eventOffers === null || eventOffers === void 0 ? void 0 : eventOffers.unacceptedPaymentMethod;
255
262
  // 施設コンテンツを参照する必要はない(2022-10-31~)
256
- // if (Array.isArray(unacceptedPaymentMethodBySuperEvent)) {
257
- // unacceptedPaymentMethod = unacceptedPaymentMethodBySuperEvent;
258
- // }
259
263
  // イベントにunacceptedPaymentMethod設定があれば上書き
260
264
  if (Array.isArray(unacceptedPaymentMethodByEvent)) {
261
265
  unacceptedPaymentMethod = unacceptedPaymentMethodByEvent;
@@ -342,11 +346,13 @@ function searchAddOns(params) {
342
346
  const productWithAddOns = yield repos.product.findById({ id: productId });
343
347
  const offerCatalogId = (_b = productWithAddOns.hasOfferCatalog) === null || _b === void 0 ? void 0 : _b.id;
344
348
  if (typeof offerCatalogId === 'string') {
345
- offers = yield repos.offer.findOffersByOfferCatalogId({
349
+ const findOffersByOfferCatalogIdResult = yield repos.offer.findOffersByOfferCatalogId({
346
350
  offerCatalog: { id: offerCatalogId },
347
351
  availableAtOrFrom: { id: (_c = params.store) === null || _c === void 0 ? void 0 : _c.id },
352
+ excludeAppliesToMovieTicket: false,
348
353
  sort: true
349
354
  });
355
+ offers = findOffersByOfferCatalogIdResult.offers;
350
356
  offers = offers.map((o) => {
351
357
  return Object.assign(Object.assign({ additionalProperty: Array.isArray(o.additionalProperty) ? o.additionalProperty : [], alternateName: o.alternateName, availability: o.availability, availableAtOrFrom: o.availableAtOrFrom, color: o.color, description: o.description, id: o.id, identifier: o.identifier, itemOffered: {
352
358
  description: productWithAddOns.description,
@@ -394,8 +400,12 @@ function searchEventTicketOffers(params) {
394
400
  ids: params.ids,
395
401
  event,
396
402
  store: params.store,
403
+ limit: params.limit,
404
+ page: params.page,
397
405
  sort: params.sort,
398
- validateOfferRateLimit: params.validateOfferRateLimit
406
+ addSortIndex: params.addSortIndex,
407
+ validateOfferRateLimit: params.validateOfferRateLimit,
408
+ onlyValid: params.onlyValid === true
399
409
  })(repos);
400
410
  offers = searchOffersResult.ticketOffers;
401
411
  unitPriceOffers = searchOffersResult.unitPriceOffers;
@@ -405,8 +415,12 @@ function searchEventTicketOffers(params) {
405
415
  ids: params.ids,
406
416
  event,
407
417
  store: params.store,
418
+ limit: params.limit,
419
+ page: params.page,
408
420
  sort: params.sort,
409
- validateOfferRateLimit: params.validateOfferRateLimit
421
+ addSortIndex: params.addSortIndex,
422
+ validateOfferRateLimit: params.validateOfferRateLimit,
423
+ onlyValid: params.onlyValid === true
410
424
  })(repos);
411
425
  offers = searchOffersResult.ticketOffers;
412
426
  unitPriceOffers = searchOffersResult.unitPriceOffers;
@@ -423,21 +437,22 @@ function searchEventTicketOffers(params) {
423
437
  // && o.availableAtOrFrom.some((availableApplication) => availableApplication.id === specifiedStoreId);
424
438
  // });
425
439
  // }
440
+ // mongo条件へ移行(2023-02-24~)
426
441
  // 有効期間を適用
427
- if (params.onlyValid === true) {
428
- offers = offers.filter((o) => {
429
- let isvalid = true;
430
- if (o.validFrom !== undefined && moment(o.validFrom)
431
- .isAfter(now)) {
432
- isvalid = false;
433
- }
434
- if (o.validThrough !== undefined && moment(o.validThrough)
435
- .isBefore(now)) {
436
- isvalid = false;
437
- }
438
- return isvalid;
439
- });
440
- }
442
+ // if (params.onlyValid === true) {
443
+ // offers = offers.filter((o) => {
444
+ // let isvalid = true;
445
+ // if (o.validFrom !== undefined && moment(o.validFrom)
446
+ // .isAfter(now)) {
447
+ // isvalid = false;
448
+ // }
449
+ // if (o.validThrough !== undefined && moment(o.validThrough)
450
+ // .isBefore(now)) {
451
+ // isvalid = false;
452
+ // }
453
+ // return isvalid;
454
+ // });
455
+ // }
441
456
  for (const offer of offers) {
442
457
  if (Array.isArray(offer.addOn)) {
443
458
  // store.idでのフィルターをmongoに移行(2023-01-27~)
@@ -8,5 +8,8 @@ declare function createCompoundPriceSpec4event(params: {
8
8
  videoFormatChargeSpecifications: ICategoryCodeChargeSpecification[];
9
9
  soundFormatChargeSpecifications: ICategoryCodeChargeSpecification[];
10
10
  videoFormatTypes: string[];
11
- }): factory.product.ITicketOffer;
11
+ sortIndex?: number;
12
+ }): factory.product.ITicketOffer & {
13
+ sortIndex?: number;
14
+ };
12
15
  export { createCompoundPriceSpec4event };
@@ -1,18 +1,8 @@
1
1
  "use strict";
2
- var __rest = (this && this.__rest) || function (s, e) {
3
- var t = {};
4
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
- t[p] = s[p];
6
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
- t[p[i]] = s[p[i]];
10
- }
11
- return t;
12
- };
13
2
  Object.defineProperty(exports, "__esModule", { value: true });
14
3
  exports.createCompoundPriceSpec4event = void 0;
15
4
  const factory = require("../../factory");
5
+ const settings_1 = require("../../settings");
16
6
  function categoryCodeChargePriceSpec2component(params) {
17
7
  var _a;
18
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);
@@ -21,6 +11,7 @@ function mvtkChargePriceSpec2component(params) {
21
11
  var _a;
22
12
  return Object.assign({ id: params.id, typeOf: params.typeOf, name: params.name, price: params.price, priceCurrency: params.priceCurrency, valueAddedTaxIncluded: params.valueAddedTaxIncluded, appliesToVideoFormat: params.appliesToVideoFormat, appliesToMovieTicket: params.appliesToMovieTicket }, (typeof ((_a = params.accounting) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string') ? { accounting: params.accounting } : undefined);
23
13
  }
14
+ // tslint:disable-next-line:max-func-body-length
24
15
  function createCompoundPriceSpec4event(params) {
25
16
  var _a;
26
17
  // priceSpecificationはマスタ管理の仕様上必ず存在するはず
@@ -39,19 +30,51 @@ function createCompoundPriceSpec4event(params) {
39
30
  const mvtkPriceComponents = [];
40
31
  // 複数決済カード対応(2022-07-11~)
41
32
  if (Array.isArray(unitPriceSpec.appliesToMovieTicket)) {
42
- unitPriceSpec.appliesToMovieTicket.forEach((appliesToMovieTicket) => {
43
- // すべての上映方式に該当する加算料金を追加(2022-10-29~)
44
- const mvtkSpecs4appliesToMovieTicket = params.movieTicketTypeChargeSpecs.filter((s) => {
45
- var _a;
46
- return ((_a = s.appliesToMovieTicket.serviceOutput) === null || _a === void 0 ? void 0 : _a.typeOf) === appliesToMovieTicket.serviceOutput.typeOf
47
- && s.appliesToMovieTicket.serviceType === appliesToMovieTicket.serviceType
48
- && params.videoFormatTypes.includes(s.appliesToVideoFormat);
33
+ // 決済カード加算料金自動補完(2023-02-21~)
34
+ if (settings_1.settings.useOffersAppliedToMovieTicketWithoutChargeSpecification) {
35
+ unitPriceSpec.appliesToMovieTicket.forEach((appliesToMovieTicket) => {
36
+ // すべての上映方式に該当する加算料金を追加
37
+ params.videoFormatTypes.forEach((videoFormatType) => {
38
+ let existingMvtkSpec4appliesToMovieTicket = params.movieTicketTypeChargeSpecs.find((s) => {
39
+ var _a;
40
+ return ((_a = s.appliesToMovieTicket.serviceOutput) === null || _a === void 0 ? void 0 : _a.typeOf) === appliesToMovieTicket.serviceOutput.typeOf
41
+ && s.appliesToMovieTicket.serviceType === appliesToMovieTicket.serviceType
42
+ && s.appliesToVideoFormat === videoFormatType;
43
+ });
44
+ // 加算料金が存在しなければprice: 0で自動補完
45
+ if (existingMvtkSpec4appliesToMovieTicket === undefined) {
46
+ existingMvtkSpec4appliesToMovieTicket = {
47
+ typeOf: factory.priceSpecificationType.MovieTicketTypeChargeSpecification,
48
+ price: 0,
49
+ priceCurrency: factory.priceCurrency.JPY,
50
+ appliesToVideoFormat: videoFormatType,
51
+ valueAddedTaxIncluded: true,
52
+ project: params.offer.project,
53
+ id: '',
54
+ name: params.offer.name,
55
+ appliesToMovieTicket: {
56
+ typeOf: factory.service.paymentService.PaymentServiceType.MovieTicket,
57
+ serviceType: appliesToMovieTicket.serviceType,
58
+ serviceOutput: { typeOf: appliesToMovieTicket.serviceOutput.typeOf }
59
+ }
60
+ };
61
+ }
62
+ mvtkPriceComponents.push(mvtkChargePriceSpec2component(existingMvtkSpec4appliesToMovieTicket));
63
+ });
49
64
  });
50
- mvtkPriceComponents.push(...mvtkSpecs4appliesToMovieTicket.map(mvtkChargePriceSpec2component));
51
- });
52
- }
53
- else {
54
- // Arrayでないケースは廃止(2022-09-12~)
65
+ }
66
+ else {
67
+ unitPriceSpec.appliesToMovieTicket.forEach((appliesToMovieTicket) => {
68
+ // すべての上映方式に該当する加算料金を追加(2022-10-29~)
69
+ const mvtkSpecs4appliesToMovieTicket = params.movieTicketTypeChargeSpecs.filter((s) => {
70
+ var _a;
71
+ return ((_a = s.appliesToMovieTicket.serviceOutput) === null || _a === void 0 ? void 0 : _a.typeOf) === appliesToMovieTicket.serviceOutput.typeOf
72
+ && s.appliesToMovieTicket.serviceType === appliesToMovieTicket.serviceType
73
+ && params.videoFormatTypes.includes(s.appliesToVideoFormat);
74
+ });
75
+ mvtkPriceComponents.push(...mvtkSpecs4appliesToMovieTicket.map(mvtkChargePriceSpec2component));
76
+ });
77
+ }
55
78
  }
56
79
  // 区分加算料金は決済カード適用でも価格要素に含まれるはず(2022-11-02~)
57
80
  const priceComponent = [
@@ -68,8 +91,16 @@ function createCompoundPriceSpec4event(params) {
68
91
  valueAddedTaxIncluded: true,
69
92
  priceComponent
70
93
  };
71
- // 不要な属性を除外(2022-11-07~)
72
- const _b = params.offer, { project } = _b, unitOfferFields4ticketOffer = __rest(_b, ["project"]);
73
- return Object.assign(Object.assign({}, unitOfferFields4ticketOffer), { eligibleQuantity: params.eligibleQuantity, priceSpecification: compoundPriceSpecification });
94
+ // 必要な属性のみに限定(2023-02-24~)
95
+ // const { project, ...unitOfferFields4ticketOffer } = params.offer;
96
+ const { name, description, alternateName, color, typeOf, id, addOn, availability, availableAtOrFrom, category, eligibleMembershipType, eligibleSeatingType, eligibleMonetaryAmount, eligibleSubReservation, priceCurrency, validFrom, validThrough, validRateLimit, additionalProperty, identifier, itemOffered } = params.offer;
97
+ return Object.assign({
98
+ // ...unitOfferFields4ticketOffer,
99
+ name, description, alternateName, color, typeOf, id,
100
+ addOn, availability, availableAtOrFrom, category,
101
+ eligibleMembershipType, eligibleSeatingType, eligibleMonetaryAmount, eligibleSubReservation,
102
+ priceCurrency,
103
+ validFrom, validThrough, validRateLimit, additionalProperty,
104
+ identifier, itemOffered, eligibleQuantity: params.eligibleQuantity, priceSpecification: compoundPriceSpecification }, (typeof params.sortIndex === 'number') ? { sortIndex: params.sortIndex } : undefined);
74
105
  }
75
106
  exports.createCompoundPriceSpec4event = createCompoundPriceSpec4event;
@@ -158,7 +158,6 @@ function processStartDepositTransaction(params) {
158
158
  description: description,
159
159
  pendingTransaction: {
160
160
  typeOf: factory.account.transactionType.Deposit,
161
- id: '',
162
161
  transactionNumber: params.transactionNumber
163
162
  }
164
163
  },
@@ -57,7 +57,6 @@ function returnMoneyTransfer(params) {
57
57
  toLocation: depositTransaction.object.fromLocation,
58
58
  pendingTransaction: {
59
59
  typeOf: factory.account.transactionType.Withdraw,
60
- id: '',
61
60
  transactionNumber: publishTransactionNumber4returnMoneyTransferResult.transactionNumber
62
61
  }
63
62
  }
@@ -23,7 +23,11 @@ function searchProductOffers(params) {
23
23
  if (typeof offerCatalogId !== 'string') {
24
24
  return [];
25
25
  }
26
- const offers = yield repos.offer.findOffersByOfferCatalogId({ offerCatalog: { id: offerCatalogId }, sort: params.sort });
26
+ const { offers } = yield repos.offer.findOffersByOfferCatalogId({
27
+ offerCatalog: { id: offerCatalogId },
28
+ excludeAppliesToMovieTicket: false,
29
+ sort: params.sort
30
+ });
27
31
  return offers.map((o) => {
28
32
  const unitSpec = o.priceSpecification;
29
33
  const compoundPriceSpecification = {
@@ -13,8 +13,9 @@ function creatPayTransactionStartParams(params) {
13
13
  const accountId = (typeof params.accountId === 'string')
14
14
  ? params.accountId
15
15
  : (typeof params.object.accountId === 'string') ? params.object.accountId : undefined;
16
+ // movieTickets最適化(2023-02-24~)
17
+ const movieTickets = (Array.isArray(params.object.movieTickets)) ? params.object.movieTickets.map(createMovieTicket) : undefined;
16
18
  return Object.assign(Object.assign({ project: { id: params.transaction.project.id, typeOf: factory.organizationType.Project }, typeOf: factory.assetTransactionType.Pay, transactionNumber: params.transactionNumber, agent: {
17
- // Sellerに変更(2022-05-30~)
18
19
  typeOf: params.transaction.seller.typeOf,
19
20
  id: String(params.transaction.seller.id),
20
21
  name: (typeof params.transaction.seller.name === 'string')
@@ -38,7 +39,7 @@ function creatPayTransactionStartParams(params) {
38
39
  typeOf: params.paymentServiceType,
39
40
  // 決済サービスIDを連携(2022-04-12~)
40
41
  id: issuedThroughId,
41
- paymentMethod: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ typeOf: params.object.paymentMethod, amount: params.object.amount, additionalProperty: (Array.isArray(params.object.additionalProperty)) ? params.object.additionalProperty : [] }, (typeof params.object.method === 'string') ? { method: params.object.method } : undefined), (typeof params.object.name === 'string') ? { name: params.object.name } : undefined), (typeof accountId === 'string') ? { accountId } : undefined), (typeof params.object.description === 'string') ? { description: params.object.description } : undefined), (typeof params.object.fromLocation === 'string') ? { fromLocation: params.object.fromLocation } : undefined), (params.object.creditCard !== undefined) ? { creditCard: params.object.creditCard } : undefined), (Array.isArray(params.object.movieTickets)) ? { movieTickets: params.object.movieTickets } : undefined)
42
+ paymentMethod: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ typeOf: params.object.paymentMethod, amount: params.object.amount, additionalProperty: (Array.isArray(params.object.additionalProperty)) ? params.object.additionalProperty : [] }, (typeof params.object.method === 'string') ? { method: params.object.method } : undefined), (typeof params.object.name === 'string') ? { name: params.object.name } : undefined), (typeof accountId === 'string') ? { accountId } : undefined), (typeof params.object.description === 'string') ? { description: params.object.description } : undefined), (typeof params.object.fromLocation === 'string') ? { fromLocation: params.object.fromLocation } : undefined), (params.object.creditCard !== undefined) ? { creditCard: params.object.creditCard } : undefined), (Array.isArray(movieTickets)) ? { movieTickets } : undefined)
42
43
  }, expires: expires }, (typeof confirmationNumber === 'string')
43
44
  ? {
44
45
  purpose: {
@@ -51,6 +52,32 @@ function creatPayTransactionStartParams(params) {
51
52
  : undefined);
52
53
  }
53
54
  exports.creatPayTransactionStartParams = creatPayTransactionStartParams;
55
+ function createMovieTicket(params) {
56
+ var _a;
57
+ const serviceOutput = {
58
+ reservationFor: {
59
+ typeOf: params.serviceOutput.reservationFor.typeOf,
60
+ id: params.serviceOutput.reservationFor.id
61
+ },
62
+ reservedTicket: {
63
+ ticketedSeat: {
64
+ typeOf: factory.placeType.Seat,
65
+ seatNumber: params.serviceOutput.reservedTicket.ticketedSeat.seatNumber,
66
+ seatRow: params.serviceOutput.reservedTicket.ticketedSeat.seatRow,
67
+ seatSection: params.serviceOutput.reservedTicket.ticketedSeat.seatSection
68
+ }
69
+ }
70
+ };
71
+ return {
72
+ project: { id: params.project.id, typeOf: factory.organizationType.Project },
73
+ typeOf: params.typeOf,
74
+ identifier: params.identifier,
75
+ accessCode: params.accessCode,
76
+ category: { codeValue: (typeof ((_a = params.category) === null || _a === void 0 ? void 0 : _a.codeValue) === 'string') ? params.category.codeValue : '' },
77
+ serviceType: params.serviceType,
78
+ serviceOutput
79
+ };
80
+ }
54
81
  function createAuthorizeResult(params) {
55
82
  var _a, _b, _c, _d;
56
83
  const payTransactionObject = params.payTransaction.object;
@@ -97,10 +97,17 @@ exports.invalidatePaymentUrl = invalidatePaymentUrl;
97
97
  */
98
98
  function processVoidPayTransaction(params) {
99
99
  return (repos) => __awaiter(this, void 0, void 0, function* () {
100
- const transaction = yield repos.transaction.findById({
101
- typeOf: params.purpose.typeOf,
102
- id: params.purpose.id
103
- });
100
+ let transaction;
101
+ // アクションID指定の場合、進行中取引検証(2023-02-24~)
102
+ if (typeof params.id === 'string') {
103
+ transaction = yield repos.transaction.findInProgressById({ typeOf: params.purpose.typeOf, id: params.purpose.id });
104
+ }
105
+ else {
106
+ transaction = yield repos.transaction.findById({
107
+ typeOf: params.purpose.typeOf,
108
+ id: params.purpose.id
109
+ });
110
+ }
104
111
  // 承認アクションを取得
105
112
  let authorizeActions;
106
113
  if (typeof params.id === 'string') {
@@ -57,9 +57,14 @@ declare function checkByIdentifier(params: {
57
57
  project: ProjectRepo;
58
58
  }) => Promise<ICheckResult>;
59
59
  interface IAuthorizeResult {
60
- checkResult: ICheckResult;
61
- payAction?: factory.action.IAction<factory.action.IAttributes<factory.actionType.PayAction, any, any>>;
60
+ accountId: string;
61
+ checkResult?: ICheckResult;
62
+ payAction: factory.action.trade.pay.IAction;
62
63
  }
64
+ /**
65
+ * MovieTicket承認
66
+ * オーソリサービスが存在するわけではないので、実質着券する
67
+ */
63
68
  declare function authorize(params: factory.assetTransaction.pay.IStartParamsWithoutDetail, transaction: factory.assetTransaction.pay.ITransaction, paymentServiceId: string): (repos: {
64
69
  action: ActionRepo;
65
70
  accountingReport: AccountingReportRepo;