@chevre/domain 22.6.0-alpha.14 → 22.6.0-alpha.17

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.
@@ -122,8 +122,8 @@ function aggregateOfferByEvent(params) {
122
122
  function aggregateReservationByOffer(params) {
123
123
  return (repos) => __awaiter(this, void 0, void 0, function* () {
124
124
  let reservationCount4offer;
125
- let attendeeCount4offer;
126
- let checkInCount4offer;
125
+ // let attendeeCount4offer: number | undefined;
126
+ // let checkInCount4offer: number | undefined;
127
127
  let reservationType = factory.reservationType.EventReservation;
128
128
  if (params.event.typeOf === factory.eventType.Event) {
129
129
  reservationType = factory.reservationType.BusReservation;
@@ -142,32 +142,31 @@ function aggregateReservationByOffer(params) {
142
142
  // reservedTicket: { ticketType: { ids: [<string>params.offer.id] } }
143
143
  reservedTicket: { ticketType: { ids: offerIdsWithSameCategory } }
144
144
  });
145
- attendeeCount4offer = yield repos.reservation.count({
146
- typeOf: reservationType,
147
- reservationFor: { id: { $eq: params.event.id } },
148
- reservationStatuses: [factory.reservationStatusType.ReservationConfirmed],
149
- // オファーカテゴリーごとに集計する(2024-11-10~)
150
- // reservedTicket: { ticketType: { ids: [<string>params.offer.id] } },
151
- reservedTicket: { ticketType: { ids: offerIdsWithSameCategory } },
152
- attended: true
153
- });
154
- checkInCount4offer = yield repos.reservation.count({
155
- typeOf: reservationType,
156
- reservationFor: { id: { $eq: params.event.id } },
157
- reservationStatuses: [factory.reservationStatusType.ReservationConfirmed],
158
- // オファーカテゴリーごとに集計する(2024-11-10~)
159
- // reservedTicket: { ticketType: { ids: [<string>params.offer.id] } },
160
- reservedTicket: { ticketType: { ids: offerIdsWithSameCategory } },
161
- checkedIn: true
162
- });
145
+ // attendeeCount4offer = await repos.reservation.count({
146
+ // typeOf: reservationType,
147
+ // reservationFor: { id: { $eq: params.event.id } },
148
+ // reservationStatuses: [factory.reservationStatusType.ReservationConfirmed],
149
+ // // オファーカテゴリーごとに集計する(2024-11-10~)
150
+ // // reservedTicket: { ticketType: { ids: [<string>params.offer.id] } },
151
+ // reservedTicket: { ticketType: { ids: offerIdsWithSameCategory } },
152
+ // attended: true
153
+ // });
154
+ // checkInCount4offer = await repos.reservation.count({
155
+ // typeOf: reservationType,
156
+ // reservationFor: { id: { $eq: params.event.id } },
157
+ // reservationStatuses: [factory.reservationStatusType.ReservationConfirmed],
158
+ // // オファーカテゴリーごとに集計する(2024-11-10~)
159
+ // // reservedTicket: { ticketType: { ids: [<string>params.offer.id] } },
160
+ // reservedTicket: { ticketType: { ids: offerIdsWithSameCategory } },
161
+ // checkedIn: true
162
+ // });
163
163
  }
164
164
  const { maximumAttendeeCapacity, remainingAttendeeCapacity } = yield calculateCapacityByOffer(params)(repos);
165
165
  return Object.assign(Object.assign({ aggregateReservation: {
166
166
  typeOf: 'AggregateReservation',
167
- // aggregateDate: params.aggregateDate, // 最適化につき廃止(2024-03-26~)
168
- reservationCount: reservationCount4offer,
169
- attendeeCount: attendeeCount4offer,
170
- checkInCount: checkInCount4offer
167
+ reservationCount: reservationCount4offer
168
+ // attendeeCount: attendeeCount4offer, // discontinue(2024-11-10~)
169
+ // checkInCount: checkInCount4offer // discontinue(2024-11-10~)
171
170
  } }, (typeof maximumAttendeeCapacity === 'number') ? { maximumAttendeeCapacity } : undefined), (typeof remainingAttendeeCapacity === 'number') ? { remainingAttendeeCapacity } : undefined);
172
171
  });
173
172
  }
@@ -15,35 +15,44 @@ const moment = require("moment-timezone");
15
15
  const factory = require("../../../factory");
16
16
  const event_1 = require("../../event");
17
17
  const debug = createDebug('chevre-domain:service:task');
18
- // enum RoleName {
19
- // Customer = 'customer',
20
- // POS = 'pos'
21
- // }
22
- // const AVAILABLE_ROLE_NAMES: string[] = [RoleName.Customer, RoleName.POS];
23
- function createEvents(schedule
24
- // createDate?: Date
25
- ) {
26
- // tslint:disable-next-line:max-func-body-length
18
+ function createEvents(schedule, createDate) {
19
+ // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
27
20
  return (repos, settings) => __awaiter(this, void 0, void 0, function* () {
28
- var _a, _b, _c, _d, _e, _f, _g;
21
+ var _a, _b, _c, _d, _e, _f, _g, _h;
29
22
  const eventServiceId = (_b = (_a = schedule.offers) === null || _a === void 0 ? void 0 : _a.itemOffered) === null || _b === void 0 ? void 0 : _b.id;
30
23
  const makesOffer = (_d = (_c = schedule.offers) === null || _c === void 0 ? void 0 : _c.seller) === null || _d === void 0 ? void 0 : _d.makesOffer;
31
24
  const applicationIds = (Array.isArray(makesOffer))
32
25
  ? makesOffer.map(({ availableAtOrFrom }) => availableAtOrFrom.id)
33
26
  : [];
27
+ const eventSeriesId = (_e = schedule.superEvent) === null || _e === void 0 ? void 0 : _e.id;
34
28
  if (typeof eventServiceId !== 'string' || eventServiceId === '') {
35
29
  throw new factory.errors.NotFound('schedule.offers.itemOffered.id');
36
30
  }
31
+ if (typeof eventSeriesId !== 'string' || eventSeriesId === '') {
32
+ throw new factory.errors.NotFound('schedule.superEvent.id');
33
+ }
37
34
  const project = schedule.project;
38
35
  // 引数情報取得
39
- const targetInfo = getTargetInfoForCreateFromSetting(schedule);
36
+ const targetInfo = getTargetInfoForCreateFromSetting(schedule, createDate);
40
37
  debug(targetInfo.length, 'targetInfos ->', targetInfo);
38
+ // 施設コンテンツ検索
39
+ const screeningEventSeries = (yield repos.eventSeries.projectEventSeriesFields({
40
+ project: { id: { $eq: project.id } },
41
+ id: { $eq: eventSeriesId }
42
+ }, [
43
+ 'location', 'additionalProperty', 'description', 'endDate', 'headline', 'kanaName', 'name',
44
+ 'soundFormat', 'startDate', 'typeOf', 'videoFormat', 'workPerformed'
45
+ ])).shift();
46
+ if (screeningEventSeries === undefined) {
47
+ throw new factory.errors.NotFound(factory.eventType.ScreeningEventSeries);
48
+ }
49
+ const workPerformedIdentifier = screeningEventSeries.workPerformed.identifier;
41
50
  // 劇場検索
42
51
  const movieTheaters = yield repos.movieTheater.projectFields({
43
52
  limit: 1,
44
53
  page: 1,
45
54
  project: { id: { $eq: project.id } },
46
- branchCode: { $eq: schedule.theater }
55
+ branchCode: { $eq: screeningEventSeries.location.branchCode }
47
56
  }, ['id', 'branchCode', 'offers', 'parentOrganization']);
48
57
  const movieTheater = movieTheaters.shift();
49
58
  if (movieTheater === undefined) {
@@ -60,18 +69,6 @@ function createEvents(schedule
60
69
  if (screeningRoom === undefined) {
61
70
  throw new factory.errors.NotFound(factory.placeType.ScreeningRoom);
62
71
  }
63
- // 施設コンテンツ検索
64
- const workPerformedIdentifier = schedule.film;
65
- const screeningEventSeries = (yield repos.eventSeries.projectEventSeriesFields({
66
- project: { id: { $eq: project.id } },
67
- workPerformed: { identifiers: [workPerformedIdentifier] }
68
- }, [
69
- 'location', 'additionalProperty', 'description', 'endDate', 'headline', 'kanaName', 'name',
70
- 'soundFormat', 'startDate', 'typeOf', 'videoFormat', 'workPerformed'
71
- ])).shift();
72
- if (screeningEventSeries === undefined) {
73
- throw new factory.errors.NotFound(factory.eventType.ScreeningEventSeries);
74
- }
75
72
  // 興行検索
76
73
  // const eventServiceProductID = schedule.eventServiceProductID; // 興行設定に変更(2023-09-24~)
77
74
  const searchEventServicesResult = yield repos.product.projectFields({
@@ -113,7 +110,7 @@ function createEvents(schedule
113
110
  screeningRoom.branchCode,
114
111
  performanceInfo.start_time
115
112
  ].join('');
116
- const maxValue = (_f = (_e = movieTheater.offers) === null || _e === void 0 ? void 0 : _e.eligibleQuantity) === null || _f === void 0 ? void 0 : _f.maxValue;
113
+ const maxValue = (_g = (_f = movieTheater.offers) === null || _f === void 0 ? void 0 : _f.eligibleQuantity) === null || _g === void 0 ? void 0 : _g.maxValue;
117
114
  const availabilityEnds = moment(performanceInfo.end_date)
118
115
  .tz('Asia/Tokyo')
119
116
  .endOf('date')
@@ -168,7 +165,7 @@ function createEvents(schedule
168
165
  ? { name: screeningEventSeries.location.name }
169
166
  : undefined)
170
167
  }
171
- } }, { name: { ja: (typeof eventService.name === 'string') ? eventService.name : String((_g = eventService.name) === null || _g === void 0 ? void 0 : _g.ja) } }), seller: offersSeller }, {
168
+ } }, { name: { ja: (typeof eventService.name === 'string') ? eventService.name : String((_h = eventService.name) === null || _h === void 0 ? void 0 : _h.ja) } }), seller: offersSeller }, {
172
169
  // availabilityEnds, // discontinue(2024-10-16~)
173
170
  // availabilityStarts,
174
171
  // validThrough,
@@ -223,9 +220,9 @@ function createEvents(schedule
223
220
  /**
224
221
  * パフォーマンス作成・作成対象情報取得
225
222
  */
226
- function getTargetInfoForCreateFromSetting(settings) {
223
+ function getTargetInfoForCreateFromSetting(settings, createDate) {
227
224
  const performanceInfos = [];
228
- const { days, duration, noPerformanceTimes, createDate, hours, start, minutes, tours } = settings;
225
+ const { days, duration, noPerformanceTimes, hours, start, minutes, tours } = settings;
229
226
  // 作成対象時間: 9,10,11など
230
227
  // const hours: string[] = ['9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22'];
231
228
  // 作成開始が今日から何日後か: 30
@@ -290,7 +287,7 @@ function createEventBySchedule(params) {
290
287
  if (schedule === null) {
291
288
  throw new factory.errors.NotFound('Schedule');
292
289
  }
293
- yield createEvents(schedule)(repos, settings);
290
+ yield createEvents(schedule, (params.object.startDate instanceof Date) ? params.object.startDate : new Date())(repos, settings);
294
291
  });
295
292
  }
296
293
  exports.createEventBySchedule = createEventBySchedule;
package/package.json CHANGED
@@ -11,8 +11,8 @@
11
11
  "dependencies": {
12
12
  "@aws-sdk/client-cognito-identity-provider": "3.600.0",
13
13
  "@aws-sdk/credential-providers": "3.600.0",
14
- "@chevre/factory": "4.389.0-alpha.10",
15
- "@cinerino/sdk": "10.16.0-alpha.7",
14
+ "@chevre/factory": "4.389.0-alpha.12",
15
+ "@cinerino/sdk": "10.16.0-alpha.8",
16
16
  "@motionpicture/coa-service": "9.5.0",
17
17
  "@motionpicture/gmo-service": "5.3.0",
18
18
  "@sendgrid/mail": "6.4.0",
@@ -108,5 +108,5 @@
108
108
  "postversion": "git push origin --tags",
109
109
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
110
110
  },
111
- "version": "22.6.0-alpha.14"
111
+ "version": "22.6.0-alpha.17"
112
112
  }