@chevre/domain 21.8.0-alpha.53 → 21.8.0-alpha.55

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.
@@ -82,12 +82,6 @@ export declare class MongoRepository {
82
82
  */
83
83
  sortedOfferIds: string[];
84
84
  }>;
85
- findById(params: {
86
- project: {
87
- id: string;
88
- };
89
- id: string;
90
- }): Promise<factory.unitPriceOffer.IUnitPriceOffer>;
91
85
  findAggregateOfferById(params: {
92
86
  project: {
93
87
  id: string;
@@ -825,21 +825,23 @@ class MongoRepository {
825
825
  return { offers, sortedOfferIds };
826
826
  });
827
827
  }
828
- findById(params) {
829
- return __awaiter(this, void 0, void 0, function* () {
830
- const offers = yield this.search({
831
- limit: 1,
832
- page: 1,
833
- project: { id: { $eq: params.project.id } },
834
- id: { $eq: params.id }
835
- });
836
- const unitPriceOffer = offers.shift();
837
- if (unitPriceOffer === undefined) {
838
- throw new factory.errors.NotFound(factory.offerType.Offer);
839
- }
840
- return unitPriceOffer;
841
- });
842
- }
828
+ // 不要なので廃止(2023-09-11~)
829
+ // public async findById(params: {
830
+ // project: { id: string };
831
+ // id: string;
832
+ // }): Promise<factory.unitPriceOffer.IUnitPriceOffer> {
833
+ // const offers = await this.search({
834
+ // limit: 1,
835
+ // page: 1,
836
+ // project: { id: { $eq: params.project.id } },
837
+ // id: { $eq: params.id }
838
+ // });
839
+ // const unitPriceOffer = offers.shift();
840
+ // if (unitPriceOffer === undefined) {
841
+ // throw new factory.errors.NotFound(factory.offerType.Offer);
842
+ // }
843
+ // return unitPriceOffer;
844
+ // }
843
845
  findAggregateOfferById(params) {
844
846
  return __awaiter(this, void 0, void 0, function* () {
845
847
  const doc = yield this.aggregateOfferModel.findOne({
@@ -182,7 +182,7 @@ function addReservations(params) {
182
182
  // await repos.reservation.createMany({ reservationFor, reservations: objectSubReservations });
183
183
  // }
184
184
  // ストックホルダー処理(stockHolderで残席数を集計しているので必要)
185
- yield onReservationsCreated({ event })(repos);
185
+ yield onReservationsCreated({ event, transaction: { transactionNumber: transaction.transactionNumber } })(repos);
186
186
  return { transaction, objectSubReservations, issuedThrough };
187
187
  });
188
188
  }
@@ -804,7 +804,8 @@ function onReservationsCreated(params) {
804
804
  yield OfferService.createAggregateScreeningEventIfNotExist({
805
805
  project: params.event.project,
806
806
  reservationFor: [{ id: params.event.id }],
807
- force: false
807
+ force: false,
808
+ identifier: `onReservationsCreated:${params.transaction.transactionNumber}`
808
809
  })({ task: repos.task });
809
810
  });
810
811
  }
@@ -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,
@@ -22,6 +22,12 @@ interface ICheckInReservationParams {
22
22
  ids?: string[];
23
23
  };
24
24
  };
25
+ purpose: {
26
+ /**
27
+ * 承認コード
28
+ */
29
+ code: string;
30
+ };
25
31
  }
26
32
  export declare function checkInReservation(params: ICheckInReservationParams & {
27
33
  reserveIfNotYet: boolean;
@@ -58,7 +58,8 @@ function checkInReservation(params) {
58
58
  ids: checkedInReservationIds,
59
59
  reservationFor: params.object.reservationFor
60
60
  },
61
- now
61
+ now,
62
+ purpose: params.purpose
62
63
  })({ task: repos.task });
63
64
  });
64
65
  }
@@ -32,6 +32,7 @@ useInformReservation,
32
32
  */
33
33
  reservationFor) {
34
34
  return (repos) => __awaiter(this, void 0, void 0, function* () {
35
+ var _a;
35
36
  if (Array.isArray(canceledReservations) && canceledReservations.length > 0) {
36
37
  const now = new Date();
37
38
  const project = canceledReservations[0].project;
@@ -96,7 +97,8 @@ reservationFor) {
96
97
  yield (0, offer_1.createAggregateScreeningEventIfNotExist)({
97
98
  project: { id: reservationFor.project.id },
98
99
  reservationFor: [{ id: reservationFor.id }],
99
- force: false
100
+ force: false,
101
+ identifier: `onReservationCanceled:${(_a = canceledReservations === null || canceledReservations === void 0 ? void 0 : canceledReservations[0]) === null || _a === void 0 ? void 0 : _a.reservationNumber}`
100
102
  })({ task: repos.task });
101
103
  }
102
104
  });
@@ -20,6 +20,12 @@ export declare function onReservationCheckedIn(params: {
20
20
  };
21
21
  };
22
22
  now: Date;
23
+ purpose: {
24
+ /**
25
+ * 承認コード
26
+ */
27
+ code: string;
28
+ };
23
29
  }): (repos: {
24
30
  task: TaskRepo;
25
31
  }) => Promise<void>;
@@ -109,10 +109,12 @@ function onReservationCheckedIn(params) {
109
109
  if (Array.isArray(reservationForIds)) {
110
110
  // イベント集計タスクを追加
111
111
  yield Promise.all(reservationForIds.map((reservationForId) => __awaiter(this, void 0, void 0, function* () {
112
+ var _b;
112
113
  yield (0, offer_1.createAggregateScreeningEventIfNotExist)({
113
114
  project: { id: params.project.id },
114
115
  reservationFor: [{ id: reservationForId }],
115
- force: false
116
+ force: false,
117
+ identifier: `onReservationCheckedIn:${(_b = params.purpose) === null || _b === void 0 ? void 0 : _b.code}`
116
118
  })({ task: repos.task });
117
119
  })));
118
120
  }
@@ -70,7 +70,8 @@ function onReservationConfirmed(confirmedReservations) {
70
70
  yield (0, offer_1.createAggregateScreeningEventIfNotExist)({
71
71
  project: confirmedReservations[0].project,
72
72
  reservationFor: [{ id: confirmedReservations[0].reservationFor.id }],
73
- force: false
73
+ force: false,
74
+ identifier: `onReservationConfirmed:${confirmedReservations[0].reservationNumber}`
74
75
  })({ task: repos.task });
75
76
  const now = new Date();
76
77
  const taskAttributes = [];
@@ -99,7 +99,8 @@ function onReservationUsed(action, attendedReservation) {
99
99
  yield (0, offer_1.createAggregateScreeningEventIfNotExist)({
100
100
  project: attendedReservation.project,
101
101
  reservationFor: [{ id: attendedReservation.reservationFor.id }],
102
- force: false
102
+ force: false,
103
+ identifier: `onReservationUsed:${attendedReservation.id}`
103
104
  })({ task: repos.task });
104
105
  });
105
106
  }
@@ -98,7 +98,8 @@ function onAuthorizationCreated(params) {
98
98
  reservationNumbers: reservationNumbers,
99
99
  reservationFor: { ids: reservationForIds }
100
100
  },
101
- reserveIfNotYet: params.reserveIfNotYet
101
+ reserveIfNotYet: params.reserveIfNotYet,
102
+ purpose: { code: params.code }
102
103
  })({
103
104
  action: repos.action,
104
105
  assetTransaction: repos.assetTransaction,
package/package.json CHANGED
@@ -117,5 +117,5 @@
117
117
  "postversion": "git push origin --tags",
118
118
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
119
119
  },
120
- "version": "21.8.0-alpha.53"
120
+ "version": "21.8.0-alpha.55"
121
121
  }