@chevre/domain 20.11.0-alpha.2 → 20.11.0

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.
@@ -22,7 +22,7 @@ export declare function responseBody2acceptedOffers4result(params: {
22
22
  responseBody: factory.action.authorize.offer.seatReservation.IResponseBody<factory.service.webAPI.Identifier.COA>;
23
23
  object: factory.action.authorize.offer.seatReservation.IObject<factory.service.webAPI.Identifier.COA>;
24
24
  event: IMinimizedIndividualEvent<factory.eventType.ScreeningEvent>;
25
- seller: factory.transaction.placeOrder.ISeller;
25
+ seller: Pick<factory.transaction.placeOrder.ISeller, 'typeOf' | 'name'>;
26
26
  bookingTime: Date;
27
27
  totalPrice: number;
28
28
  }): IResultAcceptedOffer[];
@@ -71,11 +71,11 @@ exports.offers2resultPrice = offers2resultPrice;
71
71
  function responseBody2acceptedOffers4result(params) {
72
72
  const acceptedOffers4result = [];
73
73
  const event = params.event;
74
- const updTmpReserveSeatResult = params.responseBody;
74
+ const reservationNumber = String(params.responseBody.tmpReserveNum);
75
75
  // 座席仮予約からオファー情報を生成する
76
76
  // tslint:disable-next-line:max-func-body-length
77
- acceptedOffers4result.push(...updTmpReserveSeatResult.listTmpReserve.map((tmpReserve, index) => {
78
- var _a, _b, _c, _d, _e;
77
+ acceptedOffers4result.push(...params.responseBody.listTmpReserve.map((tmpReserve, index) => {
78
+ var _a, _b, _c, _d;
79
79
  const requestedOffer = params.object.acceptedOffer.find((o) => {
80
80
  var _a, _b, _c, _d;
81
81
  return ((_d = (_c = (_b = (_a = o.itemOffered) === null || _a === void 0 ? void 0 : _a.serviceOutput) === null || _b === void 0 ? void 0 : _b.reservedTicket) === null || _c === void 0 ? void 0 : _c.ticketedSeat) === null || _d === void 0 ? void 0 : _d.seatNumber) === tmpReserve.seatNum
@@ -84,14 +84,7 @@ function responseBody2acceptedOffers4result(params) {
84
84
  if (requestedOffer === undefined) {
85
85
  throw new factory.errors.Argument('offers', '要求された供給情報と仮予約結果が一致しません');
86
86
  }
87
- let coaInfo;
88
- if (event.coaInfo !== undefined) {
89
- coaInfo = event.coaInfo;
90
- }
91
- else {
92
- const coaInfoProperty = (_a = event.additionalProperty) === null || _a === void 0 ? void 0 : _a.find((p) => p.name === 'coaInfo');
93
- coaInfo = (coaInfoProperty !== undefined) ? JSON.parse(coaInfoProperty.value) : undefined;
94
- }
87
+ const coaInfo = event.coaInfo;
95
88
  if (coaInfo === undefined) {
96
89
  throw new factory.errors.NotFound('Event COA Info');
97
90
  }
@@ -100,11 +93,10 @@ function responseBody2acceptedOffers4result(params) {
100
93
  coaInfo.theaterCode,
101
94
  coaInfo.dateJouei,
102
95
  // tslint:disable-next-line:no-magic-numbers
103
- (`00000000${updTmpReserveSeatResult.tmpReserveNum}`).slice(-8),
96
+ (`00000000${reservationNumber}`).slice(-8),
104
97
  // tslint:disable-next-line:no-magic-numbers
105
98
  (`000${index + 1}`).slice(-3)
106
99
  ].join('');
107
- const reservationNumber = String(updTmpReserveSeatResult.tmpReserveNum);
108
100
  const reservationId = `${reservationNumber}-${index.toString()}`;
109
101
  const workPerformed = {
110
102
  id: event.superEvent.workPerformed.id,
@@ -159,8 +151,8 @@ function responseBody2acceptedOffers4result(params) {
159
151
  name: requestedOffer.name
160
152
  }
161
153
  };
162
- const additionalProperty = (_c = (_b = requestedOffer.itemOffered) === null || _b === void 0 ? void 0 : _b.serviceOutput) === null || _c === void 0 ? void 0 : _c.additionalProperty;
163
- const additionalTicketText = (_e = (_d = requestedOffer.itemOffered) === null || _d === void 0 ? void 0 : _d.serviceOutput) === null || _e === void 0 ? void 0 : _e.additionalTicketText;
154
+ const additionalProperty = (_b = (_a = requestedOffer.itemOffered) === null || _a === void 0 ? void 0 : _a.serviceOutput) === null || _b === void 0 ? void 0 : _b.additionalProperty;
155
+ const additionalTicketText = (_d = (_c = requestedOffer.itemOffered) === null || _c === void 0 ? void 0 : _c.serviceOutput) === null || _d === void 0 ? void 0 : _d.additionalTicketText;
164
156
  const issuedThrough = {
165
157
  typeOf: factory.product.ProductType.EventService,
166
158
  id: '',
@@ -15,7 +15,7 @@ declare function validateAcceptedOffers(params: {
15
15
  project: {
16
16
  id: string;
17
17
  };
18
- screeningEvent: Pick<factory.event.screeningEvent.IEvent, 'id' | 'superEvent'>;
18
+ screeningEvent: Pick<factory.event.screeningEvent.IEvent, 'id' | 'superEvent' | 'coaInfo'>;
19
19
  availablePaymentMethodTypes: factory.categoryCode.ICategoryCode[];
20
20
  seatingTypes: factory.categoryCode.ICategoryCode[];
21
21
  videoFormatTypes: factory.categoryCode.ICategoryCode[];
@@ -245,29 +245,37 @@ function createPriceComponent(params) {
245
245
  /**
246
246
  * 受け入れらたオファーの内容を検証
247
247
  */
248
+ // tslint:disable-next-line:max-func-body-length
248
249
  function validateAcceptedOffers(params) {
250
+ // tslint:disable-next-line:max-func-body-length
249
251
  return (repos) => __awaiter(this, void 0, void 0, function* () {
250
- const offerIds = (Array.isArray(params.object.acceptedOffer))
251
- ? [...new Set(params.object.acceptedOffer.map((o) => o.id))]
252
+ var _a;
253
+ const theaterCode = String((_a = params.screeningEvent.coaInfo) === null || _a === void 0 ? void 0 : _a.theaterCode);
254
+ const offerIdentifiers = (Array.isArray(params.object.acceptedOffer))
255
+ ? [...new Set((params.object.acceptedOffer).map((o) => {
256
+ return `COA-${theaterCode}-${String(o.ticketInfo.ticketCode)}`;
257
+ }))]
252
258
  : [];
253
259
  let availableUnitPriceOffers = [];
254
260
  // 指定された単価オファーを検索
255
- if (offerIds.length > 0) {
261
+ // ticketCodeで検索(2023-03-22~)
262
+ if (offerIdentifiers.length > 0) {
256
263
  availableUnitPriceOffers = yield repos.offer.search({
257
- id: { $in: offerIds },
264
+ identifier: { $in: offerIdentifiers },
258
265
  project: { id: { $eq: params.project.id } }
259
266
  });
260
267
  }
261
268
  const acceptedOffers = params.object.acceptedOffer.map((acceptedOffer) => {
262
- var _a, _b, _c, _d, _e, _f;
263
- const availableUnitPriceOffer = availableUnitPriceOffers.find((unitPriceOffer) => unitPriceOffer.id === acceptedOffer.id);
269
+ var _a, _b, _c, _d, _e, _f, _g, _h;
270
+ const availableUnitPriceOffer = availableUnitPriceOffers.find((unitPriceOffer) => {
271
+ var _a, _b;
272
+ const ticketCodeByUnitPriceOffer = (_b = (_a = unitPriceOffer.additionalProperty) === null || _a === void 0 ? void 0 : _a.find((p) => p.name === 'ticketCode')) === null || _b === void 0 ? void 0 : _b.value;
273
+ return ticketCodeByUnitPriceOffer === acceptedOffer.ticketInfo.ticketCode;
274
+ });
264
275
  if (availableUnitPriceOffer === undefined) {
265
- throw new factory.errors.NotFound(factory.offerType.Offer, `${acceptedOffer.id} not found`);
276
+ throw new factory.errors.NotFound(factory.offerType.Offer, `${acceptedOffer.ticketInfo.ticketCode} not found`);
266
277
  }
267
278
  const { additionalProperty, itemOffered, name, ticketInfo } = acceptedOffer;
268
- // if (priceSpecification === undefined) {
269
- // throw new factory.errors.NotFound('priceSpecification');
270
- // }
271
279
  // priceComponentを再生成(2023-03-14~)
272
280
  const { priceComponent, eligibleMonetaryAmount } = createPriceComponent({
273
281
  project: { id: params.project.id },
@@ -297,20 +305,23 @@ function validateAcceptedOffers(params) {
297
305
  ticketInfo.addGlasses,
298
306
  ticketInfo.spseatAdd1
299
307
  ].reduce((a, b) => a + b, 0);
308
+ const usePointValue = (_b = (_a = availableUnitPriceOffer.additionalProperty) === null || _a === void 0 ? void 0 : _a.find((p) => p.name === 'usePoint')) === null || _b === void 0 ? void 0 : _b.value;
300
309
  return Object.assign(Object.assign({ additionalProperty,
301
310
  itemOffered,
302
311
  name,
303
312
  price,
304
- priceSpecification, ticketInfo: Object.assign(Object.assign({}, ticketInfo), { salePrice // COAに渡す販売金額を上書き(2023-03-20~)
313
+ priceSpecification, ticketInfo: Object.assign(Object.assign({}, ticketInfo), {
314
+ // usePointを自動設定(2023-03-22~)
315
+ usePoint: (typeof usePointValue === 'string') ? Number(usePointValue) : 0, salePrice // COAに渡す販売金額を上書き(2023-03-20~)
305
316
  }),
306
317
  // 以下属性については単価オファーから読む(2023-03-09~)
307
318
  priceCurrency: availableUnitPriceOffer.priceCurrency, id: String(availableUnitPriceOffer.id), identifier: String(availableUnitPriceOffer.identifier), typeOf: availableUnitPriceOffer.typeOf }, (Array.isArray(eligibleMonetaryAmount)) ? { eligibleMonetaryAmount } : undefined), {
308
319
  // tslint:disable-next-line:no-suspicious-comment
309
320
  // TODO itemOfferedに完全置き換え
310
- seatNumber: (_c = (_b = (_a = itemOffered.serviceOutput) === null || _a === void 0 ? void 0 : _a.reservedTicket) === null || _b === void 0 ? void 0 : _b.ticketedSeat) === null || _c === void 0 ? void 0 : _c.seatNumber,
321
+ seatNumber: (_e = (_d = (_c = itemOffered.serviceOutput) === null || _c === void 0 ? void 0 : _c.reservedTicket) === null || _d === void 0 ? void 0 : _d.ticketedSeat) === null || _e === void 0 ? void 0 : _e.seatNumber,
311
322
  // tslint:disable-next-line:no-suspicious-comment
312
323
  // TODO itemOfferedに完全置き換え
313
- seatSection: (_f = (_e = (_d = itemOffered.serviceOutput) === null || _d === void 0 ? void 0 : _d.reservedTicket) === null || _e === void 0 ? void 0 : _e.ticketedSeat) === null || _f === void 0 ? void 0 : _f.seatSection
324
+ seatSection: (_h = (_g = (_f = itemOffered.serviceOutput) === null || _f === void 0 ? void 0 : _f.reservedTicket) === null || _g === void 0 ? void 0 : _g.ticketedSeat) === null || _h === void 0 ? void 0 : _h.seatSection
314
325
  });
315
326
  });
316
327
  return { acceptedOffers };
package/package.json CHANGED
@@ -9,8 +9,8 @@
9
9
  }
10
10
  ],
11
11
  "dependencies": {
12
- "@chevre/factory": "4.305.0",
13
- "@cinerino/sdk": "3.151.0-alpha.1",
12
+ "@chevre/factory": "4.306.0",
13
+ "@cinerino/sdk": "3.151.0-alpha.2",
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.11.0-alpha.2"
123
+ "version": "20.11.0"
124
124
  }