@chevre/domain 20.2.0-alpha.7 → 20.2.0-alpha.9

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.
@@ -230,21 +230,25 @@ function aggregateReservationByOffer(params) {
230
230
  let reservationCount4offer;
231
231
  let attendeeCount4offer;
232
232
  let checkInCount4offer;
233
+ let reservationType = factory.reservationType.EventReservation;
234
+ if (params.event.typeOf === factory.eventType.Event) {
235
+ reservationType = factory.reservationType.BusReservation;
236
+ }
233
237
  reservationCount4offer = yield repos.reservation.count({
234
- typeOf: factory.reservationType.EventReservation,
238
+ typeOf: reservationType,
235
239
  reservationFor: { ids: [params.event.id] },
236
240
  reservationStatuses: [factory.reservationStatusType.ReservationConfirmed],
237
241
  reservedTicket: { ticketType: { ids: [params.offer.id] } }
238
242
  });
239
243
  attendeeCount4offer = yield repos.reservation.count({
240
- typeOf: factory.reservationType.EventReservation,
244
+ typeOf: reservationType,
241
245
  reservationFor: { ids: [params.event.id] },
242
246
  reservationStatuses: [factory.reservationStatusType.ReservationConfirmed],
243
247
  reservedTicket: { ticketType: { ids: [params.offer.id] } },
244
248
  attended: true
245
249
  });
246
250
  checkInCount4offer = yield repos.reservation.count({
247
- typeOf: factory.reservationType.EventReservation,
251
+ typeOf: reservationType,
248
252
  reservationFor: { ids: [params.event.id] },
249
253
  reservationStatuses: [factory.reservationStatusType.ReservationConfirmed],
250
254
  reservedTicket: { ticketType: { ids: [params.offer.id] } },
@@ -397,8 +401,12 @@ function aggregateReservationByEvent(params) {
397
401
  let attendeeCount;
398
402
  let checkInCount;
399
403
  let reservationCount;
404
+ let reservationType = factory.reservationType.EventReservation;
405
+ if (params.event.typeOf === factory.eventType.Event) {
406
+ reservationType = factory.reservationType.BusReservation;
407
+ }
400
408
  reservationCount = yield repos.reservation.count({
401
- typeOf: factory.reservationType.EventReservation,
409
+ typeOf: reservationType,
402
410
  reservationFor: { ids: [params.event.id] },
403
411
  reservationStatuses: [factory.reservationStatusType.ReservationConfirmed]
404
412
  });
@@ -428,13 +436,13 @@ function aggregateReservationByEvent(params) {
428
436
  }
429
437
  }
430
438
  attendeeCount = yield repos.reservation.count({
431
- typeOf: factory.reservationType.EventReservation,
439
+ typeOf: reservationType,
432
440
  reservationFor: { ids: [params.event.id] },
433
441
  // reservationStatuses: [factory.reservationStatusType.ReservationConfirmed],
434
442
  attended: true
435
443
  });
436
444
  checkInCount = yield repos.reservation.count({
437
- typeOf: factory.reservationType.EventReservation,
445
+ typeOf: reservationType,
438
446
  reservationFor: { ids: [params.event.id] },
439
447
  // reservationStatuses: [factory.reservationStatusType.ReservationConfirmed],
440
448
  checkedIn: true
@@ -162,7 +162,8 @@ function movieTicket2reservation4invoice(movieTicket, order, paymentMethodType)
162
162
  }
163
163
  });
164
164
  }
165
- return o.itemOffered.typeOf === factory.reservationType.EventReservation
165
+ return (o.itemOffered.typeOf === factory.reservationType.EventReservation
166
+ || o.itemOffered.typeOf === factory.reservationType.BusReservation)
166
167
  && mvtkUnitPriceSpec !== undefined
167
168
  && o.itemOffered.reservationFor.id === movieTicket.serviceOutput.reservationFor.id
168
169
  && ((_d = o.itemOffered.reservedTicket.ticketedSeat) === null || _d === void 0 ? void 0 : _d.seatNumber) === movieTicket.serviceOutput.reservedTicket.ticketedSeat.seatNumber
@@ -22,6 +22,7 @@ function createOwnershipInfosFromOrder(params) {
22
22
  const ownedBy = createOwnedby(params);
23
23
  const itemOfferedType = itemOffered.typeOf;
24
24
  switch (itemOfferedType) {
25
+ case factory.reservationType.BusReservation:
25
26
  case factory.reservationType.EventReservation:
26
27
  ownershipInfo = (0, factory_2.createReservationOwnershipInfo)({
27
28
  project: params.order.project,
@@ -211,7 +211,7 @@ exports.responseBody2acceptedOffers4result = responseBody2acceptedOffers4result;
211
211
  */
212
212
  // tslint:disable-next-line:max-func-body-length
213
213
  function createReservation(params) {
214
- var _a;
214
+ var _a, _b, _c, _d;
215
215
  const itemOffered = params.itemOffered;
216
216
  const event = params.event;
217
217
  let reservationItem;
@@ -243,16 +243,36 @@ function createReservation(params) {
243
243
  .toDate(),
244
244
  // 最適化(2022-05-31~)
245
245
  superEvent: Object.assign(Object.assign({ typeOf: event.superEvent.typeOf, id: event.superEvent.id, kanaName: event.superEvent.kanaName, location: event.superEvent.location, name: event.superEvent.name, soundFormat: event.superEvent.soundFormat, videoFormat: event.superEvent.videoFormat, workPerformed }, (typeof event.superEvent.duration === 'string') ? { duration: event.superEvent.duration } : undefined), (event.superEvent.headline !== undefined) ? { headline: event.superEvent.headline } : undefined)
246
- // 廃止(superEvent.workPerformedへ完全移行)
247
- // workPerformed: {},
248
246
  };
249
- reservationItem = Object.assign({ project: itemOffered.project, typeOf: itemOffered.typeOf, additionalProperty: itemOffered.additionalProperty, additionalTicketText: itemOffered.additionalTicketText, id: itemOffered.id, issuedThrough: itemOffered.issuedThrough, reservationNumber: itemOffered.reservationNumber, reservationFor: reservationFor, reservedTicket: reservedTicket }, (typeof ((_a = itemOffered.programMembershipUsed) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string')
247
+ reservationItem = Object.assign({ project: itemOffered.project, typeOf: itemOffered.typeOf, additionalProperty: itemOffered.additionalProperty, additionalTicketText: itemOffered.additionalTicketText, id: itemOffered.id, issuedThrough: itemOffered.issuedThrough, reservationNumber: itemOffered.reservationNumber, reservationFor,
248
+ reservedTicket }, (typeof ((_a = itemOffered.programMembershipUsed) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string')
250
249
  ? { programMembershipUsed: itemOffered.programMembershipUsed }
251
250
  : undefined);
252
251
  }
253
252
  else if (itemOffered.typeOf === factory.reservationType.BusReservation
254
253
  && event.typeOf === factory.eventType.Event) {
255
- throw new factory.errors.NotImplemented(`${itemOffered.typeOf} not impelemented`);
254
+ const tripByEvent = (_c = (_b = event.offers) === null || _b === void 0 ? void 0 : _b.itemOffered.serviceOutput) === null || _c === void 0 ? void 0 : _c.reservationFor;
255
+ if (typeof (tripByEvent === null || tripByEvent === void 0 ? void 0 : tripByEvent.typeOf) !== 'string') {
256
+ throw new factory.errors.NotFound('event.offers.itemOffered.serviceOutput.reservationFor');
257
+ }
258
+ const reservationFor = {
259
+ typeOf: tripByEvent.typeOf,
260
+ id: event.id,
261
+ arrivalBusStop: tripByEvent.arrivalBusStop,
262
+ departureBusStop: tripByEvent.departureBusStop,
263
+ name: event.name,
264
+ departureTime: moment(tripByEvent.departureTime)
265
+ .toDate(),
266
+ arrivalTime: moment(tripByEvent.arrivalTime)
267
+ .toDate(),
268
+ busName: tripByEvent.busName,
269
+ busNumber: tripByEvent.busNumber,
270
+ identifier: tripByEvent.identifier
271
+ };
272
+ reservationItem = Object.assign({ project: itemOffered.project, typeOf: itemOffered.typeOf, additionalProperty: itemOffered.additionalProperty, additionalTicketText: itemOffered.additionalTicketText, id: itemOffered.id, issuedThrough: itemOffered.issuedThrough, reservationNumber: itemOffered.reservationNumber, reservationFor,
273
+ reservedTicket }, (typeof ((_d = itemOffered.programMembershipUsed) === null || _d === void 0 ? void 0 : _d.typeOf) === 'string')
274
+ ? { programMembershipUsed: itemOffered.programMembershipUsed }
275
+ : undefined);
256
276
  }
257
277
  else {
258
278
  throw new factory.errors.Argument('itemOffered');
@@ -184,7 +184,8 @@ function createConfirmReservationActionObject4ChevreByOrder(params) {
184
184
  const chevreReservationNumbers = (Array.isArray(params.order.acceptedOffers))
185
185
  ? params.order.acceptedOffers.filter((o) => {
186
186
  var _a;
187
- return o.itemOffered.typeOf === factory.reservationType.EventReservation
187
+ return (o.itemOffered.typeOf === factory.reservationType.EventReservation
188
+ || o.itemOffered.typeOf === factory.reservationType.BusReservation)
188
189
  && ((_a = o.offeredThrough) === null || _a === void 0 ? void 0 : _a.identifier) === factory.service.webAPI.Identifier.Chevre;
189
190
  })
190
191
  .map((o) => {
@@ -271,7 +271,8 @@ function createReturnReserveTransactionTasks(order, simpleOrder) {
271
271
  // 注文アイテムから返却アクションを作成する
272
272
  const acceptedOffers = (Array.isArray(order.acceptedOffers)) ? order.acceptedOffers : [];
273
273
  for (const acceptedOffer of acceptedOffers) {
274
- if (acceptedOffer.itemOffered.typeOf === factory.reservationType.EventReservation) {
274
+ if (acceptedOffer.itemOffered.typeOf === factory.reservationType.EventReservation
275
+ || acceptedOffer.itemOffered.typeOf === factory.reservationType.BusReservation) {
275
276
  const reservation = acceptedOffer.itemOffered;
276
277
  const reservationNumber = reservation.reservationNumber;
277
278
  // 予約番号ごとに返却アクションを作成する
@@ -41,6 +41,22 @@ function createOrder(params) {
41
41
  : undefined) });
42
42
  return Object.assign(Object.assign({}, o), { itemOffered });
43
43
  }
44
+ else if (o.itemOffered.typeOf === factory.reservationType.BusReservation) {
45
+ let itemOffered = o.itemOffered;
46
+ const reservationFor = itemOffered.reservationFor;
47
+ itemOffered = Object.assign(Object.assign({}, itemOffered), { reservationFor: Object.assign(Object.assign(Object.assign({}, reservationFor), (reservationFor.arrivalTime !== undefined)
48
+ ? {
49
+ arrivalTime: moment(reservationFor.arrivalTime)
50
+ .toDate()
51
+ }
52
+ : undefined), (reservationFor.departureTime !== undefined)
53
+ ? {
54
+ departureTime: moment(reservationFor.departureTime)
55
+ .toDate()
56
+ }
57
+ : undefined) });
58
+ return Object.assign(Object.assign({}, o), { itemOffered });
59
+ }
44
60
  else {
45
61
  return o;
46
62
  }
@@ -37,7 +37,8 @@ function verifyToken4reservation(params) {
37
37
  }
38
38
  const acceptedOffers = (Array.isArray(order.acceptedOffers)) ? order.acceptedOffers : [];
39
39
  const reservationExistsInOrder = acceptedOffers.some((offer) => {
40
- return offer.itemOffered.typeOf === factory.reservationType.EventReservation
40
+ return (offer.itemOffered.typeOf === factory.reservationType.EventReservation
41
+ || offer.itemOffered.typeOf === factory.reservationType.BusReservation)
41
42
  && offer.itemOffered.id === params.reservationId;
42
43
  });
43
44
  if (!reservationExistsInOrder) {
@@ -35,37 +35,52 @@ function createReservationAcceptedOffers(params) {
35
35
  }
36
36
  exports.createReservationAcceptedOffers = createReservationAcceptedOffers;
37
37
  function reservationOffers2orderedItem(params) {
38
- var _a, _b, _c, _d;
38
+ var _a, _b, _c, _d, _e;
39
39
  const reservationFor = params.reservationFor;
40
40
  const issuedThrough = params.issuedThrough;
41
- if (reservationFor.typeOf !== factory.eventType.ScreeningEvent) {
42
- throw new factory.errors.NotImplemented(`reservationFor.typeOf '${reservationFor.typeOf}' not implemented`);
43
- }
44
- const reservationFor4orderedItem = {
45
- location: {
46
- branchCode: (_a = reservationFor.location) === null || _a === void 0 ? void 0 : _a.branchCode,
47
- name: (_b = reservationFor.location) === null || _b === void 0 ? void 0 : _b.name,
41
+ if (reservationFor.typeOf === factory.eventType.ScreeningEvent
42
+ && issuedThrough.typeOf === factory.product.ProductType.EventService) {
43
+ const reservationFor4orderedItem = {
44
+ location: {
45
+ branchCode: (_a = reservationFor.location) === null || _a === void 0 ? void 0 : _a.branchCode,
46
+ name: (_b = reservationFor.location) === null || _b === void 0 ? void 0 : _b.name,
47
+ // 不要なので廃止(2022-12-19~)
48
+ // project: reservationFor.location?.project,
49
+ typeOf: (_c = reservationFor.location) === null || _c === void 0 ? void 0 : _c.typeOf
50
+ },
48
51
  // 不要なので廃止(2022-12-19~)
49
- // project: reservationFor.location?.project,
50
- typeOf: (_c = reservationFor.location) === null || _c === void 0 ? void 0 : _c.typeOf
51
- },
52
- // 不要なので廃止(2022-12-19~)
53
- // project: reservationFor.project,
54
- typeOf: reservationFor.typeOf,
55
- id: reservationFor.id,
56
- name: reservationFor.name,
57
- startDate: reservationFor.startDate,
58
- endDate: reservationFor.endDate
59
- };
60
- if (issuedThrough.typeOf !== factory.product.ProductType.EventService) {
61
- throw new factory.errors.NotImplemented(`issuedThrough.typeOf '${issuedThrough.typeOf}' not implemented`);
52
+ // project: reservationFor.project,
53
+ typeOf: reservationFor.typeOf,
54
+ id: reservationFor.id,
55
+ name: reservationFor.name,
56
+ startDate: reservationFor.startDate,
57
+ endDate: reservationFor.endDate
58
+ };
59
+ return Object.assign(Object.assign({ typeOf: issuedThrough.typeOf }, (typeof ((_d = issuedThrough.serviceType) === null || _d === void 0 ? void 0 : _d.typeOf) === 'string')
60
+ ? { serviceType: issuedThrough.serviceType }
61
+ : undefined), { serviceOutput: {
62
+ typeOf: factory.reservationType.EventReservation,
63
+ reservationFor: reservationFor4orderedItem
64
+ } });
65
+ }
66
+ else if (reservationFor.typeOf === factory.tripType.BusTrip
67
+ && issuedThrough.typeOf === factory.product.ProductType.Transportation) {
68
+ const reservationFor4orderedItem = {
69
+ typeOf: reservationFor.typeOf,
70
+ id: reservationFor.id,
71
+ departureTime: reservationFor.departureTime,
72
+ arrivalTime: reservationFor.arrivalTime
73
+ };
74
+ return Object.assign(Object.assign({ typeOf: issuedThrough.typeOf }, (typeof ((_e = issuedThrough.serviceType) === null || _e === void 0 ? void 0 : _e.typeOf) === 'string')
75
+ ? { serviceType: issuedThrough.serviceType }
76
+ : undefined), { serviceOutput: {
77
+ typeOf: factory.reservationType.ReservationPackage,
78
+ reservationFor: reservationFor4orderedItem
79
+ } });
80
+ }
81
+ else {
82
+ throw new factory.errors.ServiceUnavailable('unexpected params on reservationOffers2orderedItem');
62
83
  }
63
- return Object.assign(Object.assign({ typeOf: issuedThrough.typeOf }, (typeof ((_d = issuedThrough.serviceType) === null || _d === void 0 ? void 0 : _d.typeOf) === 'string')
64
- ? { serviceType: issuedThrough.serviceType }
65
- : undefined), { serviceOutput: {
66
- typeOf: factory.reservationType.EventReservation,
67
- reservationFor: reservationFor4orderedItem
68
- } });
69
84
  }
70
85
  function createProductItems(params) {
71
86
  const acceptedOffers = [];
package/package.json CHANGED
@@ -9,8 +9,8 @@
9
9
  }
10
10
  ],
11
11
  "dependencies": {
12
- "@chevre/factory": "4.281.0-alpha.2",
13
- "@cinerino/sdk": "3.135.0-alpha.6",
12
+ "@chevre/factory": "4.281.0-alpha.3",
13
+ "@cinerino/sdk": "3.135.0-alpha.7",
14
14
  "@motionpicture/coa-service": "9.2.0",
15
15
  "@motionpicture/gmo-service": "5.2.0",
16
16
  "@sendgrid/mail": "6.4.0",
@@ -120,5 +120,5 @@
120
120
  "postversion": "git push origin --tags",
121
121
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
122
122
  },
123
- "version": "20.2.0-alpha.7"
123
+ "version": "20.2.0-alpha.9"
124
124
  }