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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/example/src/chevre/aggregateEventReservation.ts +37 -0
  2. package/example/src/chevre/aggregation/aggregateSystem.ts +112 -0
  3. package/example/src/chevre/findScreeningRoomsByBranchCode.ts +27 -0
  4. package/example/src/chevre/importEventsFromCOA.ts +8 -1
  5. package/example/src/chevre/migrateEventOffersItemOfferedAvailableChannel.ts +2 -1
  6. package/example/src/chevre/migrateProjectSubscription.ts +51 -0
  7. package/example/src/chevre/processReserve.ts +2 -0
  8. package/example/src/chevre/searchEventIds.ts +24 -0
  9. package/example/src/chevre/searchEventTicketOffers.ts +4 -4
  10. package/example/src/chevre/searchEvents.ts +20 -41
  11. package/example/src/chevre/searchOffersByCatalog.ts +27 -0
  12. package/example/src/chevre/updateTransaction.ts +38 -0
  13. package/lib/chevre/factory/event.d.ts +2 -0
  14. package/lib/chevre/factory/event.js +2 -0
  15. package/lib/chevre/repo/action.d.ts +67 -0
  16. package/lib/chevre/repo/action.js +209 -0
  17. package/lib/chevre/repo/aggregation.d.ts +37 -0
  18. package/lib/chevre/repo/aggregation.js +67 -0
  19. package/lib/chevre/repo/assetTransaction.d.ts +32 -0
  20. package/lib/chevre/repo/assetTransaction.js +148 -0
  21. package/lib/chevre/repo/event.d.ts +62 -16
  22. package/lib/chevre/repo/event.js +458 -156
  23. package/lib/chevre/repo/mongoose/model/aggregation.d.ts +7 -0
  24. package/lib/chevre/repo/mongoose/model/aggregation.js +47 -0
  25. package/lib/chevre/repo/mongoose/model/event.js +4 -3
  26. package/lib/chevre/repo/mongoose/model/offer.js +2 -1
  27. package/lib/chevre/repo/mongoose/model/project.js +7 -1
  28. package/lib/chevre/repo/mongoose/model/telemetry.js +4 -28
  29. package/lib/chevre/repo/offer.d.ts +10 -0
  30. package/lib/chevre/repo/offer.js +47 -16
  31. package/lib/chevre/repo/order.d.ts +2 -0
  32. package/lib/chevre/repo/order.js +29 -7
  33. package/lib/chevre/repo/place.d.ts +26 -1
  34. package/lib/chevre/repo/place.js +216 -12
  35. package/lib/chevre/repo/product.d.ts +1 -0
  36. package/lib/chevre/repo/product.js +5 -0
  37. package/lib/chevre/repo/project.d.ts +4 -1
  38. package/lib/chevre/repo/project.js +9 -10
  39. package/lib/chevre/repo/reservation.d.ts +0 -6
  40. package/lib/chevre/repo/reservation.js +106 -66
  41. package/lib/chevre/repo/task.d.ts +31 -3
  42. package/lib/chevre/repo/task.js +141 -27
  43. package/lib/chevre/repo/transaction.d.ts +45 -5
  44. package/lib/chevre/repo/transaction.js +187 -29
  45. package/lib/chevre/repo/trip.js +33 -27
  46. package/lib/chevre/repository.d.ts +3 -0
  47. package/lib/chevre/repository.js +5 -1
  48. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.d.ts +1 -1
  49. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +86 -59
  50. package/lib/chevre/service/aggregation/event/aggregateUseActionsOnEvent.js +5 -8
  51. package/lib/chevre/service/aggregation/system.d.ts +93 -0
  52. package/lib/chevre/service/aggregation/system.js +377 -0
  53. package/lib/chevre/service/aggregation.d.ts +2 -0
  54. package/lib/chevre/service/aggregation.js +3 -1
  55. package/lib/chevre/service/assetTransaction/pay/movieTicket/validation.js +5 -1
  56. package/lib/chevre/service/assetTransaction/pay/potentialActions.js +2 -4
  57. package/lib/chevre/service/assetTransaction/pay.d.ts +19 -4
  58. package/lib/chevre/service/assetTransaction/pay.js +65 -32
  59. package/lib/chevre/service/assetTransaction/registerService.js +4 -1
  60. package/lib/chevre/service/assetTransaction/reserve/factory.d.ts +3 -0
  61. package/lib/chevre/service/assetTransaction/reserve/factory.js +33 -2
  62. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.d.ts +16 -0
  63. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.js +84 -0
  64. package/lib/chevre/service/assetTransaction/reserve.d.ts +38 -6
  65. package/lib/chevre/service/assetTransaction/reserve.js +119 -94
  66. package/lib/chevre/service/delivery/factory.d.ts +1 -1
  67. package/lib/chevre/service/delivery/factory.js +1 -0
  68. package/lib/chevre/service/event.d.ts +2 -4
  69. package/lib/chevre/service/event.js +35 -14
  70. package/lib/chevre/service/offer/event/authorize.d.ts +4 -7
  71. package/lib/chevre/service/offer/event/authorize.js +26 -87
  72. package/lib/chevre/service/offer/event/cancel.js +0 -1
  73. package/lib/chevre/service/offer/event/factory.d.ts +3 -2
  74. package/lib/chevre/service/offer/event/factory.js +25 -5
  75. package/lib/chevre/service/offer/event/searchEventTicketOffers.d.ts +13 -7
  76. package/lib/chevre/service/offer/event/searchEventTicketOffers.js +81 -45
  77. package/lib/chevre/service/offer/event/voidTransaction.js +0 -2
  78. package/lib/chevre/service/offer/eventServiceByCOA/factory.d.ts +2 -1
  79. package/lib/chevre/service/offer/eventServiceByCOA.js +10 -2
  80. package/lib/chevre/service/offer/factory.js +10 -3
  81. package/lib/chevre/service/offer/product/searchProductOffers.d.ts +1 -0
  82. package/lib/chevre/service/offer/product/searchProductOffers.js +1 -1
  83. package/lib/chevre/service/offer/product.d.ts +1 -0
  84. package/lib/chevre/service/offer/product.js +6 -2
  85. package/lib/chevre/service/offer.d.ts +5 -1
  86. package/lib/chevre/service/offer.js +67 -46
  87. package/lib/chevre/service/order/onOrderStatusChanged/factory.js +2 -1
  88. package/lib/chevre/service/order/onOrderStatusChanged.js +2 -1
  89. package/lib/chevre/service/order/placeOrder.js +16 -0
  90. package/lib/chevre/service/order/returnOrder.js +1 -1
  91. package/lib/chevre/service/order/sendOrder.js +4 -2
  92. package/lib/chevre/service/payment/any.d.ts +5 -0
  93. package/lib/chevre/service/payment/any.js +1 -1
  94. package/lib/chevre/service/payment/movieTicket.d.ts +2 -2
  95. package/lib/chevre/service/payment/movieTicket.js +8 -2
  96. package/lib/chevre/service/reserve/confirmReservation.js +7 -10
  97. package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.js +2 -1
  98. package/lib/chevre/service/reserve/potentialActions/onReservationCheckedIn.js +2 -1
  99. package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.js +2 -1
  100. package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +2 -1
  101. package/lib/chevre/service/reserve/useReservation.js +7 -2
  102. package/lib/chevre/service/task/confirmPayTransaction.js +20 -1
  103. package/lib/chevre/service/task/confirmReserveTransaction.d.ts +4 -0
  104. package/lib/chevre/service/task/confirmReserveTransaction.js +5 -5
  105. package/lib/chevre/service/task/importEventsFromCOA.js +3 -1
  106. package/lib/chevre/service/task/returnPayTransaction.js +5 -1
  107. package/lib/chevre/service/task.js +6 -9
  108. package/lib/chevre/service/transaction/orderProgramMembership.js +2 -1
  109. package/lib/chevre/service/transaction/placeOrderInProgress/result/acceptedOffers.js +42 -27
  110. package/lib/chevre/service/transaction/placeOrderInProgress.js +7 -7
  111. package/lib/chevre/service/transaction/returnOrder.js +3 -3
  112. package/lib/chevre/settings.d.ts +2 -0
  113. package/lib/chevre/settings.js +7 -2
  114. package/package.json +3 -3
  115. package/example/src/chevre/aggregateReservationOnProject.ts +0 -32
  116. package/example/src/chevre/migratePlaceAdditionalProperties.ts +0 -162
@@ -32,18 +32,46 @@ class MongoRepository {
32
32
  }
33
33
  // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
34
34
  static CREATE_MONGO_CONDITIONS(conditions) {
35
- var _a, _b, _c;
35
+ var _a, _b, _c, _d, _e, _f;
36
36
  const andConditions = [{ typeOf: { $eq: conditions.typeOf } }];
37
37
  const projectIdEq = (_b = (_a = conditions.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
38
38
  if (typeof projectIdEq === 'string') {
39
- andConditions.push({
40
- 'project.id': { $eq: projectIdEq }
41
- });
39
+ andConditions.push({ 'project.id': { $eq: projectIdEq } });
42
40
  }
43
41
  const idIn = (_c = conditions.id) === null || _c === void 0 ? void 0 : _c.$in;
44
42
  if (Array.isArray(idIn)) {
43
+ andConditions.push({ _id: { $in: idIn } });
44
+ }
45
+ const identifierEq = (_d = conditions.identifier) === null || _d === void 0 ? void 0 : _d.$eq;
46
+ if (typeof identifierEq === 'string') {
47
+ andConditions.push({ identifier: { $eq: identifierEq } });
48
+ }
49
+ const nameRegex = (_e = conditions.name) === null || _e === void 0 ? void 0 : _e.$regex;
50
+ if (typeof nameRegex === 'string' && nameRegex.length > 0) {
51
+ andConditions.push({
52
+ $or: [
53
+ {
54
+ 'name.ja': {
55
+ $exists: true,
56
+ $regex: new RegExp(nameRegex)
57
+ }
58
+ },
59
+ {
60
+ 'name.en': {
61
+ $exists: true,
62
+ $regex: new RegExp(nameRegex)
63
+ }
64
+ }
65
+ ]
66
+ });
67
+ }
68
+ const additionalPropertyElemMatch = (_f = conditions.additionalProperty) === null || _f === void 0 ? void 0 : _f.$elemMatch;
69
+ if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
45
70
  andConditions.push({
46
- _id: { $in: idIn }
71
+ additionalProperty: {
72
+ $exists: true,
73
+ $elemMatch: additionalPropertyElemMatch
74
+ }
47
75
  });
48
76
  }
49
77
  return andConditions;
@@ -119,28 +147,6 @@ class MongoRepository {
119
147
  if (p.attributes.typeOf === factory.tripType.BusTrip) {
120
148
  // 上書き禁止属性を除外
121
149
  const _a = p.attributes, { identifier, project, typeOf } = _a, updateFields = __rest(_a, ["identifier", "project", "typeOf"]);
122
- bulkWriteOps.push({
123
- updateOne: {
124
- filter: {
125
- _id: p.id,
126
- typeOf: p.attributes.typeOf
127
- },
128
- // upsertの場合、createがありうるので属性を除外しない
129
- update: Object.assign({ $setOnInsert: {
130
- typeOf: p.attributes.typeOf,
131
- project: p.attributes.project,
132
- identifier: p.attributes.identifier
133
- // ...(typeof p.attributes.remainingAttendeeCapacity === 'number')
134
- // ? { remainingAttendeeCapacity: p.attributes.remainingAttendeeCapacity }
135
- // : undefined
136
- }, $set: updateFields }, (p.$unset !== undefined) ? { $unset: p.$unset } : undefined),
137
- upsert
138
- }
139
- });
140
- }
141
- else if (p.attributes.typeOf === factory.tripType.BusTripSeries) {
142
- // 上書き禁止属性を除外
143
- const _b = p.attributes, { identifier, project, typeOf } = _b, updateFields = __rest(_b, ["identifier", "project", "typeOf"]);
144
150
  bulkWriteOps.push({
145
151
  updateOne: {
146
152
  filter: {
@@ -7,6 +7,7 @@ import { MongoRepository as AccountTitleRepo } from './repo/accountTitle';
7
7
  import { MongoRepository as AccountTransactionRepo } from './repo/accountTransaction';
8
8
  import { MongoRepository as ActionRepo } from './repo/action';
9
9
  import { MongoRepository as AdditionalPropertyRepo } from './repo/additionalProperty';
10
+ import { MongoRepository as AggregationRepo } from './repo/aggregation';
10
11
  import { MongoRepository as AssetTransactionRepo } from './repo/assetTransaction';
11
12
  import { MongoRepository as CategoryCodeRepo } from './repo/categoryCode';
12
13
  import { MongoRepository as CodeRepo } from './repo/code';
@@ -69,6 +70,8 @@ export declare class Action extends ActionRepo {
69
70
  */
70
71
  export declare class AdditionalProperty extends AdditionalPropertyRepo {
71
72
  }
73
+ export declare class Aggregation extends AggregationRepo {
74
+ }
72
75
  export declare namespace action {
73
76
  class RegisterServiceInProgress extends RegisterServiceActionInProgress {
74
77
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.rateLimit = exports.itemAvailability = exports.Trip = exports.TransactionNumber = exports.Transaction = exports.Telemetry = exports.Task = exports.ServiceOutputIdentifier = exports.ServiceOutput = exports.Seller = exports.Role = exports.Reservation = exports.Project = exports.Product = exports.PriceSpecification = exports.Place = exports.Permit = exports.Person = exports.paymentMethod = exports.OwnershipInfo = exports.OrderNumber = exports.Order = exports.OfferCatalog = exports.Offer = exports.MerchantReturnPolicy = exports.Member = exports.Event = exports.EmailMessage = exports.Customer = exports.CreativeWork = exports.ConfirmationNumber = exports.Code = exports.CategoryCode = exports.AssetTransaction = exports.action = exports.AdditionalProperty = exports.Action = exports.AccountTransaction = exports.AccountTitle = exports.AccountingReport = exports.Account = void 0;
3
+ exports.rateLimit = exports.itemAvailability = exports.Trip = exports.TransactionNumber = exports.Transaction = exports.Telemetry = exports.Task = exports.ServiceOutputIdentifier = exports.ServiceOutput = exports.Seller = exports.Role = exports.Reservation = exports.Project = exports.Product = exports.PriceSpecification = exports.Place = exports.Permit = exports.Person = exports.paymentMethod = exports.OwnershipInfo = exports.OrderNumber = exports.Order = exports.OfferCatalog = exports.Offer = exports.MerchantReturnPolicy = exports.Member = exports.Event = exports.EmailMessage = exports.Customer = exports.CreativeWork = exports.ConfirmationNumber = exports.Code = exports.CategoryCode = exports.AssetTransaction = exports.action = exports.Aggregation = exports.AdditionalProperty = exports.Action = exports.AccountTransaction = exports.AccountTitle = exports.AccountingReport = exports.Account = void 0;
4
4
  // tslint:disable:max-classes-per-file completed-docs
5
5
  /**
6
6
  * リポジトリ
@@ -11,6 +11,7 @@ const accountTitle_1 = require("./repo/accountTitle");
11
11
  const accountTransaction_1 = require("./repo/accountTransaction");
12
12
  const action_1 = require("./repo/action");
13
13
  const additionalProperty_1 = require("./repo/additionalProperty");
14
+ const aggregation_1 = require("./repo/aggregation");
14
15
  const assetTransaction_1 = require("./repo/assetTransaction");
15
16
  const categoryCode_1 = require("./repo/categoryCode");
16
17
  const code_1 = require("./repo/code");
@@ -80,6 +81,9 @@ exports.Action = Action;
80
81
  class AdditionalProperty extends additionalProperty_1.MongoRepository {
81
82
  }
82
83
  exports.AdditionalProperty = AdditionalProperty;
84
+ class Aggregation extends aggregation_1.MongoRepository {
85
+ }
86
+ exports.Aggregation = Aggregation;
83
87
  var action;
84
88
  (function (action) {
85
89
  class RegisterServiceInProgress extends registerServiceInProgress_1.RedisRepository {
@@ -26,5 +26,5 @@ export declare function aggregateScreeningEvent(params: {
26
26
  id: string;
27
27
  }): IAggregateScreeningEventOperation<void>;
28
28
  export declare function aggregateByEvent(params: {
29
- event: factory.event.screeningEvent.IEvent;
29
+ event: factory.event.screeningEvent.IEvent | factory.event.event.IEvent;
30
30
  }): IAggregateScreeningEventOperation<void>;
@@ -15,6 +15,7 @@ exports.aggregateByEvent = exports.aggregateScreeningEvent = void 0;
15
15
  */
16
16
  const createDebug = require("debug");
17
17
  const moment = require("moment-timezone");
18
+ const event_1 = require("../../../repo/event");
18
19
  const factory = require("../../../factory");
19
20
  const debug = createDebug('chevre-domain:service');
20
21
  /**
@@ -23,7 +24,9 @@ const debug = createDebug('chevre-domain:service');
23
24
  function aggregateScreeningEvent(params) {
24
25
  return (repos) => __awaiter(this, void 0, void 0, function* () {
25
26
  // 集計対象イベント検索
26
- const event = yield repos.event.findById(params);
27
+ // イベント取得属性最適化(2023-01-23~)
28
+ // const event = await repos.event.findById<factory.eventType.ScreeningEvent | factory.eventType.Event>(params);
29
+ const event = yield repos.event.findMinimizedIndividualEventById(params);
27
30
  let aggregatingEvents = [event];
28
31
  const availableOffers = yield findOffers({ event })(repos);
29
32
  const offerRateLimitExists = availableOffers.some((o) => { var _a; return typeof ((_a = o.validRateLimit) === null || _a === void 0 ? void 0 : _a.scope) === 'string'; });
@@ -36,6 +39,7 @@ function aggregateScreeningEvent(params) {
36
39
  .add(1, 'hour')
37
40
  .add(-1, 'second')
38
41
  .toDate();
42
+ // 取得属性最適化(2023-01-25~)
39
43
  aggregatingEvents = yield repos.event.search({
40
44
  limit: 100,
41
45
  page: 1,
@@ -45,7 +49,7 @@ function aggregateScreeningEvent(params) {
45
49
  startFrom: startFrom,
46
50
  startThrough: startThrough,
47
51
  location: { branchCode: { $eq: event.location.branchCode } }
48
- });
52
+ }, event_1.PROJECTION_MINIMIZED_EVENT);
49
53
  // ID指定されたイベントについてはEventScheduledでなくても集計したいので、集計対象を調整
50
54
  aggregatingEvents = aggregatingEvents.filter((e) => e.id !== event.id);
51
55
  aggregatingEvents = [event, ...aggregatingEvents];
@@ -59,22 +63,36 @@ function aggregateScreeningEvent(params) {
59
63
  exports.aggregateScreeningEvent = aggregateScreeningEvent;
60
64
  function aggregateByEvent(params) {
61
65
  return (repos) => __awaiter(this, void 0, void 0, function* () {
66
+ var _a;
62
67
  const now = new Date();
63
68
  // 集計対象イベント検索
64
69
  let event = params.event;
65
- // 施設取得
66
- const movieTheater = yield findLocation(params)(repos);
67
- // 万が一施設が存在しなければ処理終了
68
- if (movieTheater === undefined) {
69
- return;
70
+ // 施設取得は冗長なので、ルーム検索に変更(2023-01-30~)
71
+ let movieTheaterId;
72
+ if (params.event.typeOf === factory.eventType.ScreeningEvent) {
73
+ movieTheaterId = params.event.superEvent.location.id;
70
74
  }
71
- const screeningRoom = movieTheater.containsPlace.find((p) => p.branchCode === event.location.branchCode);
72
- if (screeningRoom === undefined) {
73
- // 基本的にありえないはずだが、万が一スクリーンが見つからなければcapacityは0のまま
74
- // tslint:disable-next-line:no-console
75
- console.error(new Error(`Screening room not found. branchCode: ${event.location.branchCode}`));
76
- return;
75
+ else {
76
+ movieTheaterId = String((_a = params.event.offers) === null || _a === void 0 ? void 0 : _a.itemOffered.availableChannel.serviceLocation.containedInPlace.id);
77
77
  }
78
+ const screeningRoom = yield repos.place.findScreeningRoomsByBranchCode({
79
+ branchCode: { $eq: event.location.branchCode },
80
+ containedInPlace: { id: { $eq: movieTheaterId } }
81
+ });
82
+ // 施設取得
83
+ // const movieTheater = await findLocation(params)(repos);
84
+ // // 万が一施設が存在しなければ処理終了
85
+ // if (movieTheater === undefined) {
86
+ // return;
87
+ // }
88
+ // const screeningRoom = <factory.place.screeningRoom.IPlace | undefined>
89
+ // movieTheater.containsPlace.find((p) => p.branchCode === event.location.branchCode);
90
+ // if (screeningRoom === undefined) {
91
+ // // 基本的にありえないはずだが、万が一スクリーンが見つからなければcapacityは0のまま
92
+ // // tslint:disable-next-line:no-console
93
+ // console.error(new Error(`Screening room not found. branchCode: ${event.location.branchCode}`));
94
+ // return;
95
+ // }
78
96
  // 予約集計
79
97
  const { maximumAttendeeCapacity, remainingAttendeeCapacity, aggregateReservation } = yield aggregateReservationByEvent({
80
98
  aggregateDate: now,
@@ -89,13 +107,6 @@ function aggregateByEvent(params) {
89
107
  screeningRoom: screeningRoom
90
108
  })(repos);
91
109
  debug('offers aggregated', aggregateOffer);
92
- // 入場ゲートごとの集計
93
- // const aggregateEntranceGate = await aggregateEntranceGateByEvent({
94
- // aggregateDate: now,
95
- // event,
96
- // entranceGates: movieTheater.hasEntranceGate
97
- // })(repos);
98
- // debug('entrances aggregated', aggregateEntranceGate);
99
110
  // 値がundefinedの場合に更新しないように注意
100
111
  const update = {
101
112
  $set: Object.assign(Object.assign(Object.assign(Object.assign({ updatedAt: new Date(), // $setオブジェクトが空だとMongoエラーになるので
@@ -118,24 +129,33 @@ exports.aggregateByEvent = aggregateByEvent;
118
129
  * イベントロケーション取得
119
130
  * NotFoundエラーをハンドリングする
120
131
  */
121
- function findLocation(params) {
122
- return (repos) => __awaiter(this, void 0, void 0, function* () {
123
- let movieTheater;
124
- try {
125
- movieTheater = yield repos.place.findById({ id: params.event.superEvent.location.id });
126
- }
127
- catch (error) {
128
- let throwsError = true;
129
- if (error instanceof factory.errors.NotFound) {
130
- throwsError = false;
131
- }
132
- if (throwsError) {
133
- throw error;
134
- }
135
- }
136
- return movieTheater;
137
- });
138
- }
132
+ // function findLocation(params: {
133
+ // event: factory.event.screeningEvent.IEvent | factory.event.event.IEvent;
134
+ // }) {
135
+ // return async (repos: {
136
+ // place: PlaceRepo;
137
+ // }): Promise<factory.place.movieTheater.IPlace | undefined> => {
138
+ // let movieTheater: factory.place.movieTheater.IPlace | undefined;
139
+ // try {
140
+ // if (params.event.typeOf === factory.eventType.ScreeningEvent) {
141
+ // movieTheater = await repos.place.findById({ id: params.event.superEvent.location.id });
142
+ // } else {
143
+ // const movieTheaterId: string =
144
+ // String(params.event.offers?.itemOffered.availableChannel.serviceLocation.containedInPlace.id);
145
+ // movieTheater = await repos.place.findById({ id: movieTheaterId });
146
+ // }
147
+ // } catch (error) {
148
+ // let throwsError = true;
149
+ // if (error instanceof factory.errors.NotFound) {
150
+ // throwsError = false;
151
+ // }
152
+ // if (throwsError) {
153
+ // throw error;
154
+ // }
155
+ // }
156
+ // return movieTheater;
157
+ // };
158
+ // }
139
159
  /**
140
160
  * 集計後アクション
141
161
  */
@@ -189,20 +209,13 @@ function findOffers(params) {
189
209
  const eventService = yield repos.product.findById({ id: eventOffers.itemOffered.id });
190
210
  if (typeof ((_b = eventService.hasOfferCatalog) === null || _b === void 0 ? void 0 : _b.id) === 'string') {
191
211
  availableOffers = yield repos.offer.findOffersByOfferCatalogId({
192
- offerCatalog: { id: eventService.hasOfferCatalog.id }
212
+ offerCatalog: { id: eventService.hasOfferCatalog.id },
213
+ sort: false // ソート不要(2023-01-27~)
193
214
  });
194
215
  }
195
216
  }
196
217
  else {
197
- // hasOfferCatalog参照廃止(2022-09-02~)
198
218
  throw new factory.errors.NotFound('event.offers.itemOffered.id');
199
- // if (typeof params.event.hasOfferCatalog?.id === 'string') {
200
- // availableOffers = await repos.offer.findOffersByOfferCatalogId({
201
- // offerCatalog: {
202
- // id: params.event.hasOfferCatalog.id
203
- // }
204
- // });
205
- // }
206
219
  }
207
220
  }
208
221
  catch (error) {
@@ -223,22 +236,29 @@ function aggregateReservationByOffer(params) {
223
236
  let reservationCount4offer;
224
237
  let attendeeCount4offer;
225
238
  let checkInCount4offer;
239
+ let reservationType = factory.reservationType.EventReservation;
240
+ if (params.event.typeOf === factory.eventType.Event) {
241
+ reservationType = factory.reservationType.BusReservation;
242
+ }
226
243
  reservationCount4offer = yield repos.reservation.count({
227
- typeOf: factory.reservationType.EventReservation,
228
- reservationFor: { ids: [params.event.id] },
244
+ typeOf: reservationType,
245
+ // reservationFor: { ids: [params.event.id] },
246
+ reservationFor: { id: { $eq: params.event.id } },
229
247
  reservationStatuses: [factory.reservationStatusType.ReservationConfirmed],
230
248
  reservedTicket: { ticketType: { ids: [params.offer.id] } }
231
249
  });
232
250
  attendeeCount4offer = yield repos.reservation.count({
233
- typeOf: factory.reservationType.EventReservation,
234
- reservationFor: { ids: [params.event.id] },
251
+ typeOf: reservationType,
252
+ // reservationFor: { ids: [params.event.id] },
253
+ reservationFor: { id: { $eq: params.event.id } },
235
254
  reservationStatuses: [factory.reservationStatusType.ReservationConfirmed],
236
255
  reservedTicket: { ticketType: { ids: [params.offer.id] } },
237
256
  attended: true
238
257
  });
239
258
  checkInCount4offer = yield repos.reservation.count({
240
- typeOf: factory.reservationType.EventReservation,
241
- reservationFor: { ids: [params.event.id] },
259
+ typeOf: reservationType,
260
+ // reservationFor: { ids: [params.event.id] },
261
+ reservationFor: { id: { $eq: params.event.id } },
242
262
  reservationStatuses: [factory.reservationStatusType.ReservationConfirmed],
243
263
  reservedTicket: { ticketType: { ids: [params.offer.id] } },
244
264
  checkedIn: true
@@ -390,9 +410,14 @@ function aggregateReservationByEvent(params) {
390
410
  let attendeeCount;
391
411
  let checkInCount;
392
412
  let reservationCount;
413
+ let reservationType = factory.reservationType.EventReservation;
414
+ if (params.event.typeOf === factory.eventType.Event) {
415
+ reservationType = factory.reservationType.BusReservation;
416
+ }
393
417
  reservationCount = yield repos.reservation.count({
394
- typeOf: factory.reservationType.EventReservation,
395
- reservationFor: { ids: [params.event.id] },
418
+ typeOf: reservationType,
419
+ // reservationFor: { ids: [params.event.id] },
420
+ reservationFor: { id: { $eq: params.event.id } },
396
421
  reservationStatuses: [factory.reservationStatusType.ReservationConfirmed]
397
422
  });
398
423
  // maximumAttendeeCapacityを決定
@@ -421,14 +446,16 @@ function aggregateReservationByEvent(params) {
421
446
  }
422
447
  }
423
448
  attendeeCount = yield repos.reservation.count({
424
- typeOf: factory.reservationType.EventReservation,
425
- reservationFor: { ids: [params.event.id] },
449
+ typeOf: reservationType,
450
+ // reservationFor: { ids: [params.event.id] },
451
+ reservationFor: { id: { $eq: params.event.id } },
426
452
  // reservationStatuses: [factory.reservationStatusType.ReservationConfirmed],
427
453
  attended: true
428
454
  });
429
455
  checkInCount = yield repos.reservation.count({
430
- typeOf: factory.reservationType.EventReservation,
431
- reservationFor: { ids: [params.event.id] },
456
+ typeOf: reservationType,
457
+ // reservationFor: { ids: [params.event.id] },
458
+ reservationFor: { id: { $eq: params.event.id } },
432
459
  // reservationStatuses: [factory.reservationStatusType.ReservationConfirmed],
433
460
  checkedIn: true
434
461
  });
@@ -20,7 +20,9 @@ function aggregateUseActionsOnEvent(params) {
20
20
  return (repos) => __awaiter(this, void 0, void 0, function* () {
21
21
  const now = new Date();
22
22
  // 集計対象イベント検索
23
- const event = yield repos.event.findById(params);
23
+ // イベント取得属性最適化(2023-01-23~)
24
+ // const event = await repos.event.findById<factory.eventType.ScreeningEvent>(params);
25
+ const event = yield repos.event.findMinimizedIndividualEventById(params);
24
26
  // 入場ゲート検索
25
27
  const entranceGates = yield findEntranceGates({ event })(repos);
26
28
  // 入場ゲートごとの集計
@@ -90,18 +92,13 @@ function findOffers(params) {
90
92
  const eventService = yield repos.product.findById({ id: eventOffers.itemOffered.id });
91
93
  if (typeof ((_b = eventService.hasOfferCatalog) === null || _b === void 0 ? void 0 : _b.id) === 'string') {
92
94
  availableOffers = yield repos.offer.findOffersByOfferCatalogId({
93
- offerCatalog: { id: eventService.hasOfferCatalog.id }
95
+ offerCatalog: { id: eventService.hasOfferCatalog.id },
96
+ sort: false // ソート不要(2023-01-27~)
94
97
  });
95
98
  }
96
99
  }
97
100
  else {
98
- // hasOfferCatalog参照廃止(2022-09-02~)
99
101
  throw new factory.errors.NotFound('event.offers.itemOffered.id');
100
- // if (typeof params.event.hasOfferCatalog?.id === 'string') {
101
- // availableOffers = await repos.offer.findOffersByOfferCatalogId({
102
- // offerCatalog: { id: params.event.hasOfferCatalog.id }
103
- // });
104
- // }
105
102
  }
106
103
  }
107
104
  catch (error) {
@@ -0,0 +1,93 @@
1
+ import { MongoRepository as ActionRepo } from '../../repo/action';
2
+ import { MongoRepository as AggregationRepo } from '../../repo/aggregation';
3
+ import { MongoRepository as AssetTransactionRepo } from '../../repo/assetTransaction';
4
+ import { MongoRepository as EventRepo } from '../../repo/event';
5
+ import { MongoRepository as TasKRepo } from '../../repo/task';
6
+ import { MongoRepository as TransactionRepo } from '../../repo/transaction';
7
+ declare function aggregateEvent(params: {
8
+ aggregationDays: number;
9
+ excludedProjectId?: string;
10
+ }): (repos: {
11
+ agregation: AggregationRepo;
12
+ event: EventRepo;
13
+ }) => Promise<void>;
14
+ /**
15
+ * 注文取引集計
16
+ */
17
+ declare function aggregatePlaceOrder(params: {
18
+ aggregationDays: number;
19
+ excludedProjectId?: string;
20
+ clientIds?: string[];
21
+ }): (repos: {
22
+ agregation: AggregationRepo;
23
+ transaction: TransactionRepo;
24
+ }) => Promise<void>;
25
+ /**
26
+ * 興行オファー承認アクション集計
27
+ */
28
+ declare function aggregateAuthorizeEventServiceOfferAction(params: {
29
+ aggregationDays: number;
30
+ excludedProjectId?: string;
31
+ }): (repos: {
32
+ agregation: AggregationRepo;
33
+ action: ActionRepo;
34
+ }) => Promise<void>;
35
+ /**
36
+ * 決済承認アクション集計
37
+ */
38
+ declare function aggregateAuthorizePaymentAction(params: {
39
+ aggregationDays: number;
40
+ excludedProjectId?: string;
41
+ }): (repos: {
42
+ agregation: AggregationRepo;
43
+ action: ActionRepo;
44
+ }) => Promise<void>;
45
+ declare function aggregateAuthorizeOrderAction(params: {
46
+ aggregationDays: number;
47
+ excludedProjectId?: string;
48
+ }): (repos: {
49
+ agregation: AggregationRepo;
50
+ action: ActionRepo;
51
+ }) => Promise<void>;
52
+ /**
53
+ * 使用アクション集計
54
+ */
55
+ declare function aggregateUseAction(params: {
56
+ aggregationDays: number;
57
+ excludedProjectId?: string;
58
+ }): (repos: {
59
+ agregation: AggregationRepo;
60
+ action: ActionRepo;
61
+ }) => Promise<void>;
62
+ declare function aggregateCheckMovieTicketAction(params: {
63
+ aggregationDays: number;
64
+ excludedProjectId?: string;
65
+ }): (repos: {
66
+ agregation: AggregationRepo;
67
+ action: ActionRepo;
68
+ }) => Promise<void>;
69
+ declare function aggregatePayTransaction(params: {
70
+ aggregationDays: number;
71
+ excludedProjectId?: string;
72
+ }): (repos: {
73
+ agregation: AggregationRepo;
74
+ assetTransaction: AssetTransactionRepo;
75
+ }) => Promise<void>;
76
+ /**
77
+ * 予約集計
78
+ */
79
+ declare function aggregateReserveTransaction(params: {
80
+ aggregationDays: number;
81
+ excludedProjectId?: string;
82
+ }): (repos: {
83
+ agregation: AggregationRepo;
84
+ assetTransaction: AssetTransactionRepo;
85
+ }) => Promise<void>;
86
+ declare function aggregateTask(params: {
87
+ aggregationDays: number;
88
+ excludedProjectId?: string;
89
+ }): (repos: {
90
+ agregation: AggregationRepo;
91
+ task: TasKRepo;
92
+ }) => Promise<void>;
93
+ export { aggregateAuthorizeEventServiceOfferAction, aggregateAuthorizeOrderAction, aggregateAuthorizePaymentAction, aggregateCheckMovieTicketAction, aggregateEvent, aggregatePayTransaction, aggregatePlaceOrder, aggregateReserveTransaction, aggregateTask, aggregateUseAction };