@chevre/domain 20.2.0-alpha.31 → 20.2.0-alpha.33

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.
@@ -21,7 +21,7 @@ async function main() {
21
21
  const offerRateLimitRepo = new chevre.repository.rateLimit.Offer(client);
22
22
  const productRepo = new chevre.repository.Product(mongoose.connection);
23
23
 
24
- const offers = await chevre.service.offer.event.searchEventTicketOffers({
24
+ const { ticketOffers } = await chevre.service.offer.event.searchEventTicketOffers({
25
25
  event: { id: 'al9ew43f5' },
26
26
  onlyValid: true
27
27
  // ...(typeof sellerId === 'string') ? { seller: { id: sellerId } } : undefined,
@@ -33,8 +33,7 @@ async function main() {
33
33
  priceSpecification: priceSpecificationRepo,
34
34
  product: productRepo
35
35
  });
36
- // console.log(offers);
37
- console.log(offers.length);
36
+ console.log(ticketOffers.length);
38
37
  }
39
38
 
40
39
  main()
@@ -0,0 +1,26 @@
1
+ // tslint:disable:no-console
2
+ // import * as redis from 'redis';
3
+ import * as mongoose from 'mongoose';
4
+
5
+ import { chevre } from '../../../lib/index';
6
+
7
+ async function main() {
8
+ await mongoose.connect(<string>process.env.MONGOLAB_URI);
9
+
10
+ const offerRepo = new chevre.repository.Offer(mongoose.connection);
11
+
12
+ const offers = await offerRepo.findOffersByOfferCatalogId({
13
+ ids: ['al96nqj7z', 'xxx', '1001'],
14
+ // ids: ['xx', 'xxx'],
15
+ offerCatalog: {
16
+ id: '0001'
17
+ // id: 'xxx'
18
+ }
19
+ });
20
+ console.log(offers.map((o) => o.id));
21
+ console.log(offers.length);
22
+ }
23
+
24
+ main()
25
+ .then(console.log)
26
+ .catch(console.error);
@@ -10,7 +10,7 @@ async function main() {
10
10
  const transactionRepo = new chevre.repository.Transaction(mongoose.connection);
11
11
  const transactionId = '63ce4d501c45c2000bdb2f9d';
12
12
  let update = {
13
- 'object.modifiedTime': new Date()
13
+ $set: { 'object.modifiedTime': new Date() }
14
14
  };
15
15
 
16
16
  let now = moment();
@@ -22,7 +22,7 @@ async function main() {
22
22
  .diff(now));
23
23
 
24
24
  update = {
25
- 'object.modifiedTime': new Date()
25
+ $set: { 'object.modifiedTime': new Date() }
26
26
  };
27
27
  now = moment();
28
28
  // await transactionRepo.updateById({
@@ -41,7 +41,8 @@ const schema = new mongoose.Schema({
41
41
  eligibleRegion: mongoose.SchemaTypes.Mixed,
42
42
  eligibleSeatingType: mongoose.SchemaTypes.Mixed,
43
43
  eligibleSubReservation: mongoose.SchemaTypes.Mixed,
44
- // eligibleMovieTicketType: String,
44
+ // settings追加(2023-01-26~)
45
+ settings: mongoose.SchemaTypes.Mixed,
45
46
  validFrom: Date,
46
47
  validThrough: Date,
47
48
  validRateLimit: mongoose.SchemaTypes.Mixed
@@ -13,9 +13,16 @@ export declare class MongoRepository {
13
13
  * カタログに登録されたオファーの順序は保証される
14
14
  */
15
15
  findOffersByOfferCatalogId(params: {
16
+ /**
17
+ * 指定したIDのオファーだけ取得する場合
18
+ */
19
+ ids?: string[];
16
20
  offerCatalog: {
17
21
  id: string;
18
22
  };
23
+ limit?: number;
24
+ page?: number;
25
+ sort: boolean;
19
26
  }): Promise<factory.unitPriceOffer.IUnitPriceOffer[]>;
20
27
  findById(params: {
21
28
  id: string;
@@ -302,26 +302,54 @@ class MongoRepository {
302
302
  */
303
303
  findOffersByOfferCatalogId(params) {
304
304
  return __awaiter(this, void 0, void 0, function* () {
305
- const offerCatalog = yield this.offerCatalogModel.findById(params.offerCatalog.id, {
306
- __v: 0,
307
- createdAt: 0,
308
- updatedAt: 0
309
- })
310
- .exec()
311
- .then((doc) => {
312
- if (doc === null) {
313
- throw new factory.errors.NotFound(this.offerCatalogModel.modelName);
305
+ // aggregateで再実装(2023-01-26~)
306
+ const matchStages = [{ $match: { _id: { $eq: params.offerCatalog.id } } }];
307
+ if (Array.isArray(params.ids)) {
308
+ matchStages.push({
309
+ $match: { 'itemListElement.id': { $exists: true, $in: params.ids } }
310
+ });
311
+ }
312
+ const aggregate = this.offerCatalogModel.aggregate([
313
+ { $unwind: '$itemListElement' },
314
+ ...matchStages,
315
+ {
316
+ $project: {
317
+ _id: 0,
318
+ id: '$itemListElement.id'
319
+ }
314
320
  }
315
- return doc.toObject();
316
- });
317
- const sortedOfferIds = (Array.isArray(offerCatalog.itemListElement))
318
- ? offerCatalog.itemListElement.map((element) => element.id)
321
+ ]);
322
+ const itemListElements = yield aggregate.exec();
323
+ const sortedOfferIds = (Array.isArray(itemListElements))
324
+ ? itemListElements.map((element) => element.id)
319
325
  : [];
326
+ // const offerCatalog = await this.offerCatalogModel.findById(
327
+ // params.offerCatalog.id,
328
+ // {
329
+ // itemListElement: 1
330
+ // }
331
+ // )
332
+ // .exec()
333
+ // .then((doc) => {
334
+ // if (doc === null) {
335
+ // throw new factory.errors.NotFound(this.offerCatalogModel.modelName);
336
+ // }
337
+ // return <Pick<factory.offerCatalog.IOfferCatalog, 'itemListElement'>>doc.toObject();
338
+ // });
339
+ // let sortedOfferIds: string[] = (Array.isArray(offerCatalog.itemListElement))
340
+ // ? offerCatalog.itemListElement.map((element) => element.id)
341
+ // : [];
342
+ // const filteredIds = params.ids;
343
+ // if (Array.isArray(filteredIds)) {
344
+ // sortedOfferIds = sortedOfferIds.filter((id) => filteredIds.includes(id));
345
+ // }
320
346
  let offers = [];
321
347
  if (sortedOfferIds.length > 0) {
322
348
  offers = yield this.search({ id: { $in: sortedOfferIds } });
323
- // sorting
324
- offers = offers.sort((a, b) => sortedOfferIds.indexOf(String(a.id)) - sortedOfferIds.indexOf(String(b.id)));
349
+ if (params.sort) {
350
+ // sorting
351
+ offers = offers.sort((a, b) => sortedOfferIds.indexOf(String(a.id)) - sortedOfferIds.indexOf(String(b.id)));
352
+ }
325
353
  }
326
354
  return offers;
327
355
  });
@@ -93,13 +93,6 @@ function aggregateByEvent(params) {
93
93
  screeningRoom: screeningRoom
94
94
  })(repos);
95
95
  debug('offers aggregated', aggregateOffer);
96
- // 入場ゲートごとの集計
97
- // const aggregateEntranceGate = await aggregateEntranceGateByEvent({
98
- // aggregateDate: now,
99
- // event,
100
- // entranceGates: movieTheater.hasEntranceGate
101
- // })(repos);
102
- // debug('entrances aggregated', aggregateEntranceGate);
103
96
  // 値がundefinedの場合に更新しないように注意
104
97
  const update = {
105
98
  $set: Object.assign(Object.assign(Object.assign(Object.assign({ updatedAt: new Date(), // $setオブジェクトが空だとMongoエラーになるので
@@ -200,20 +193,13 @@ function findOffers(params) {
200
193
  const eventService = yield repos.product.findById({ id: eventOffers.itemOffered.id });
201
194
  if (typeof ((_b = eventService.hasOfferCatalog) === null || _b === void 0 ? void 0 : _b.id) === 'string') {
202
195
  availableOffers = yield repos.offer.findOffersByOfferCatalogId({
203
- offerCatalog: { id: eventService.hasOfferCatalog.id }
196
+ offerCatalog: { id: eventService.hasOfferCatalog.id },
197
+ sort: false // ソート不要(2023-01-27~)
204
198
  });
205
199
  }
206
200
  }
207
201
  else {
208
- // hasOfferCatalog参照廃止(2022-09-02~)
209
202
  throw new factory.errors.NotFound('event.offers.itemOffered.id');
210
- // if (typeof params.event.hasOfferCatalog?.id === 'string') {
211
- // availableOffers = await repos.offer.findOffersByOfferCatalogId({
212
- // offerCatalog: {
213
- // id: params.event.hasOfferCatalog.id
214
- // }
215
- // });
216
- // }
217
203
  }
218
204
  }
219
205
  catch (error) {
@@ -92,18 +92,13 @@ function findOffers(params) {
92
92
  const eventService = yield repos.product.findById({ id: eventOffers.itemOffered.id });
93
93
  if (typeof ((_b = eventService.hasOfferCatalog) === null || _b === void 0 ? void 0 : _b.id) === 'string') {
94
94
  availableOffers = yield repos.offer.findOffersByOfferCatalogId({
95
- offerCatalog: { id: eventService.hasOfferCatalog.id }
95
+ offerCatalog: { id: eventService.hasOfferCatalog.id },
96
+ sort: false // ソート不要(2023-01-27~)
96
97
  });
97
98
  }
98
99
  }
99
100
  else {
100
- // hasOfferCatalog参照廃止(2022-09-02~)
101
101
  throw new factory.errors.NotFound('event.offers.itemOffered.id');
102
- // if (typeof params.event.hasOfferCatalog?.id === 'string') {
103
- // availableOffers = await repos.offer.findOffersByOfferCatalogId({
104
- // offerCatalog: { id: params.event.hasOfferCatalog.id }
105
- // });
106
- // }
107
102
  }
108
103
  }
109
104
  catch (error) {
@@ -93,7 +93,10 @@ exports.start = start;
93
93
  function createTransactionObject(params) {
94
94
  return (repos) => __awaiter(this, void 0, void 0, function* () {
95
95
  // オファー検索
96
- const offers = yield (0, searchProductOffers_1.searchProductOffers)({ itemOffered: { id: String(params.product.id) } })(repos);
96
+ const offers = yield (0, searchProductOffers_1.searchProductOffers)({
97
+ itemOffered: { id: String(params.product.id) },
98
+ sort: false // ソート不要(2023-01-27~)
99
+ })(repos);
97
100
  const transactionObject = [];
98
101
  for (const acceptedOffer of params.acceptedOffers) {
99
102
  const offer = offers.find((o) => o.id === acceptedOffer.id);
@@ -64,7 +64,7 @@ exports.start = start;
64
64
  function addReservations(params) {
65
65
  // tslint:disable-next-line:max-func-body-length
66
66
  return (repos) => __awaiter(this, void 0, void 0, function* () {
67
- var _a, _b, _c;
67
+ var _a;
68
68
  const now = new Date();
69
69
  let transaction = yield repos.assetTransaction.findById({ typeOf: factory.assetTransactionType.Reserve, id: params.id });
70
70
  // イベント存在確認
@@ -88,26 +88,34 @@ function addReservations(params) {
88
88
  if (event.typeOf === factory.eventType.ScreeningEvent || event.typeOf === factory.eventType.Event) {
89
89
  validateEvent({ now, event });
90
90
  }
91
+ // 受け入れたオファーIDだけ取得する(2023-01-26~)
92
+ const acceptedOfferIds = [...new Set(acceptedOffers.map((o) => String(o.id)))];
91
93
  // イベントオファー検索
92
- const ticketOffers = yield OfferService.event.searchEventTicketOffers({ event: { id: event.id } })(repos);
93
- let availableOffers = [];
94
- // 興行設定があれば興行のカタログを参照する(2022-08-31~)
95
- const eventOffers = event.offers;
96
- if (typeof ((_b = eventOffers === null || eventOffers === void 0 ? void 0 : eventOffers.itemOffered) === null || _b === void 0 ? void 0 : _b.id) === 'string') {
97
- const eventService = yield repos.product.findById({ id: eventOffers.itemOffered.id });
98
- if (typeof ((_c = eventService.hasOfferCatalog) === null || _c === void 0 ? void 0 : _c.id) === 'string') {
99
- availableOffers = yield repos.offer.findOffersByOfferCatalogId({
100
- offerCatalog: { id: eventService.hasOfferCatalog.id }
101
- });
102
- }
103
- }
104
- else {
105
- throw new factory.errors.NotFound('event.offers.itemOffered.id');
106
- }
94
+ const { ticketOffers, unitPriceOffers } = yield OfferService.event.searchEventTicketOffers({
95
+ ids: acceptedOfferIds,
96
+ event: { id: event.id },
97
+ sort: false // ソート不要(2023-01-27~)
98
+ })(repos);
99
+ // 冗長なfindOffersByOfferCatalogId処理を削除(2023-01-26~)
100
+ const availableOffers = unitPriceOffers;
101
+ // let availableOffers: factory.unitPriceOffer.IUnitPriceOffer[] = [];
102
+ // // 興行設定があれば興行のカタログを参照する(2022-08-31~)
103
+ // const eventOffers = <factory.event.screeningEvent.IOffer | undefined>event.offers;
104
+ // if (typeof eventOffers?.itemOffered?.id === 'string') {
105
+ // const eventService = <factory.product.IProduct>await repos.product.findById({ id: eventOffers.itemOffered.id });
106
+ // if (typeof eventService.hasOfferCatalog?.id === 'string') {
107
+ // availableOffers = await repos.offer.findOffersByOfferCatalogId({
108
+ // offerCatalog: { id: eventService.hasOfferCatalog.id }
109
+ // });
110
+ // }
111
+ // } else {
112
+ // throw new factory.errors.NotFound('event.offers.itemOffered.id');
113
+ // }
107
114
  const availableSeatOffers = yield searchAvailableSeatOffers({ acceptedOffers, event: { id: event.id } })(repos);
108
115
  // 仮予約作成
109
116
  const { acceptedOffers4transactionObject, objectSubReservations } = yield createAcceptedOffers4transactionObject({
110
- acceptedOffers, ticketOffers,
117
+ acceptedOffers,
118
+ ticketOffers,
111
119
  availableOffers, now,
112
120
  event, availableSeatOffers,
113
121
  transaction,
@@ -221,10 +229,10 @@ function createAcceptedOffers4transactionObject(params) {
221
229
  return { acceptedOffers4transactionObject, objectSubReservations };
222
230
  });
223
231
  }
224
- // tslint:disable-next-line:max-func-body-length
225
232
  function createReservations4transactionObject(params) {
233
+ // tslint:disable-next-line:max-func-body-length
226
234
  return (repos) => __awaiter(this, void 0, void 0, function* () {
227
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
235
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
228
236
  // 予約番号
229
237
  const reservationNumber = params.transaction.object.reservationNumber;
230
238
  if (typeof reservationNumber !== 'string') {
@@ -264,18 +272,22 @@ function createReservations4transactionObject(params) {
264
272
  const additionalProperty = (0, factory_1.createAdditionalProperty)({ acceptedOffer });
265
273
  // 座席指定であれば、座席タイプチャージを検索する
266
274
  const seatPriceComponent = [];
267
- const seatSection = (_c = reservedTicket.ticketedSeat) === null || _c === void 0 ? void 0 : _c.seatSection;
268
- const seatNumber = (_d = reservedTicket.ticketedSeat) === null || _d === void 0 ? void 0 : _d.seatNumber;
269
- if (typeof seatSection === 'string' && typeof seatNumber === 'string') {
270
- const offersOnSeat = (_e = params.availableSeatOffers.find((o) => {
271
- var _a;
272
- return o.branchCode === seatNumber && ((_a = o.containedInPlace) === null || _a === void 0 ? void 0 : _a.branchCode) === seatSection;
273
- })) === null || _e === void 0 ? void 0 : _e.offers;
274
- if (Array.isArray(offersOnSeat)) {
275
- const availableSeatOffer = offersOnSeat[0];
276
- const seatPriceSpecs = (_f = availableSeatOffer === null || availableSeatOffer === void 0 ? void 0 : availableSeatOffer.priceSpecification) === null || _f === void 0 ? void 0 : _f.priceComponent;
277
- if (Array.isArray(seatPriceSpecs)) {
278
- seatPriceComponent.push(...seatPriceSpecs);
275
+ // 区分加算料金を適用しないオプションを追加(2023-01-26~)
276
+ const ignoreCategoryCodeChargeSpec = ((_c = ticketType.settings) === null || _c === void 0 ? void 0 : _c.ignoreCategoryCodeChargeSpec) === true;
277
+ if (!ignoreCategoryCodeChargeSpec) {
278
+ const seatSection = (_d = reservedTicket.ticketedSeat) === null || _d === void 0 ? void 0 : _d.seatSection;
279
+ const seatNumber = (_e = reservedTicket.ticketedSeat) === null || _e === void 0 ? void 0 : _e.seatNumber;
280
+ if (typeof seatSection === 'string' && typeof seatNumber === 'string') {
281
+ const offersOnSeat = (_f = params.availableSeatOffers.find((o) => {
282
+ var _a;
283
+ return o.branchCode === seatNumber && ((_a = o.containedInPlace) === null || _a === void 0 ? void 0 : _a.branchCode) === seatSection;
284
+ })) === null || _f === void 0 ? void 0 : _f.offers;
285
+ if (Array.isArray(offersOnSeat)) {
286
+ const availableSeatOffer = offersOnSeat[0];
287
+ const seatPriceSpecs = (_g = availableSeatOffer === null || availableSeatOffer === void 0 ? void 0 : availableSeatOffer.priceSpecification) === null || _g === void 0 ? void 0 : _g.priceComponent;
288
+ if (Array.isArray(seatPriceSpecs)) {
289
+ seatPriceComponent.push(...seatPriceSpecs);
290
+ }
279
291
  }
280
292
  }
281
293
  }
@@ -286,7 +298,7 @@ function createReservations4transactionObject(params) {
286
298
  if (Array.isArray(availableAddOns) && Array.isArray(acceptedAddOnParams)) {
287
299
  acceptedAddOns = availableAddOns.filter((availableAddOn) => acceptedAddOnParams.some((acceptedAddOn) => availableAddOn.id === acceptedAddOn.id));
288
300
  }
289
- const subReservation = (_h = (_g = acceptedOffer.itemOffered) === null || _g === void 0 ? void 0 : _g.serviceOutput) === null || _h === void 0 ? void 0 : _h.subReservation;
301
+ const subReservation = (_j = (_h = acceptedOffer.itemOffered) === null || _h === void 0 ? void 0 : _h.serviceOutput) === null || _j === void 0 ? void 0 : _j.subReservation;
290
302
  const reservationId = `${reservationNumber}-${reservationIndex}`;
291
303
  reservations.push((0, factory_1.createReservation)({
292
304
  project: params.transaction.project,
@@ -305,7 +317,7 @@ function createReservations4transactionObject(params) {
305
317
  subReservation: subReservation,
306
318
  programMembershipUsed,
307
319
  availableOffer: ticketType,
308
- appliesToMovieTicket: (_j = acceptedOffer.priceSpecification) === null || _j === void 0 ? void 0 : _j.appliesToMovieTicket,
320
+ appliesToMovieTicket: (_k = acceptedOffer.priceSpecification) === null || _k === void 0 ? void 0 : _k.appliesToMovieTicket,
309
321
  validateAppliesToMovieTicket: params.validateAppliesToMovieTicket
310
322
  }));
311
323
  }
@@ -278,18 +278,24 @@ function validateEvent(params) {
278
278
  */
279
279
  function validateAcceptedOffers(params) {
280
280
  return (repos) => __awaiter(this, void 0, void 0, function* () {
281
+ const acceptedOffersWithoutDetail = params.object.acceptedOffer;
282
+ const offerIds = (Array.isArray(acceptedOffersWithoutDetail))
283
+ ? [...new Set(acceptedOffersWithoutDetail.map((o) => o.id))]
284
+ : [];
281
285
  // 利用可能なチケットオファーを検索
282
- const availableTicketOffers = yield (0, searchEventTicketOffers_1.searchEventTicketOffers)({
286
+ const { ticketOffers } = yield (0, searchEventTicketOffers_1.searchEventTicketOffers)({
287
+ // 受け入れたオファーIDだけ取得する(2023-01-26~)
288
+ ids: offerIds,
283
289
  event: { id: params.event.id },
284
290
  seller: params.seller,
285
- store: params.store
291
+ store: params.store,
292
+ sort: false // ソート不要(2023-01-27~)
286
293
  })(repos);
287
- const acceptedOffersWithoutDetail = params.object.acceptedOffer;
288
294
  // 利用可能なチケットオファーであれば受け入れる
289
295
  const acceptedOffers = (Array.isArray(acceptedOffersWithoutDetail))
290
296
  ? yield Promise.all(acceptedOffersWithoutDetail.map((offerWithoutDetail) => __awaiter(this, void 0, void 0, function* () {
291
297
  return acceptedOfferWithoutDetail2acceptedOffer({
292
- availableTicketOffers,
298
+ availableTicketOffers: ticketOffers,
293
299
  offerWithoutDetail,
294
300
  event: params.event,
295
301
  transaction: params.transaction,
@@ -298,7 +304,6 @@ function validateAcceptedOffers(params) {
298
304
  })))
299
305
  : [];
300
306
  // オファーIDごとにオファー適用条件を確認
301
- const offerIds = [...new Set(acceptedOffers.map((o) => o.id))];
302
307
  offerIds.forEach((offerId) => {
303
308
  var _a;
304
309
  const acceptedOffersByOfferId = acceptedOffers.filter((o) => o.id === offerId);
@@ -17,6 +17,10 @@ declare type IAcceptedPaymentMethod = factory.paymentMethod.paymentCard.movieTic
17
17
  * 興行オファー検索
18
18
  */
19
19
  declare function searchEventTicketOffers(params: {
20
+ /**
21
+ * 指定したIDのオファーだけ取得する場合
22
+ */
23
+ ids?: string[];
20
24
  /**
21
25
  * どのイベントに対して
22
26
  */
@@ -72,5 +76,9 @@ declare function searchEventTicketOffers(params: {
72
76
  */
73
77
  kbnEisyahousiki: string;
74
78
  };
75
- }): ISearchEventTicketOffersOperation<factory.product.ITicketOffer[]>;
79
+ sort: boolean;
80
+ }): ISearchEventTicketOffersOperation<{
81
+ ticketOffers: factory.product.ITicketOffer[];
82
+ unitPriceOffers: factory.unitPriceOffer.IUnitPriceOffer[];
83
+ }>;
76
84
  export { searchEventTicketOffers };
@@ -30,7 +30,9 @@ function searchTransportationEventTicketOffers(params) {
30
30
  const transportation = yield repos.product.findById({ id: eventOffers.itemOffered.id });
31
31
  if (typeof ((_b = transportation.hasOfferCatalog) === null || _b === void 0 ? void 0 : _b.id) === 'string') {
32
32
  availableOffers = yield repos.offer.findOffersByOfferCatalogId({
33
- offerCatalog: { id: transportation.hasOfferCatalog.id }
33
+ ids: params.ids,
34
+ offerCatalog: { id: transportation.hasOfferCatalog.id },
35
+ sort: params.sort
34
36
  });
35
37
  }
36
38
  }
@@ -116,7 +118,10 @@ function searchTransportationEventTicketOffers(params) {
116
118
  }
117
119
  offer.addOn = offerAddOn;
118
120
  }
119
- return offers4event;
121
+ return {
122
+ ticketOffers: offers4event,
123
+ unitPriceOffers: availableOffers
124
+ };
120
125
  });
121
126
  }
122
127
  /**
@@ -140,7 +145,9 @@ function searchScreeningEventTicketOffers(params) {
140
145
  const eventService = yield repos.product.findById({ id: eventOffers.itemOffered.id });
141
146
  if (typeof ((_b = eventService.hasOfferCatalog) === null || _b === void 0 ? void 0 : _b.id) === 'string') {
142
147
  availableOffers = yield repos.offer.findOffersByOfferCatalogId({
143
- offerCatalog: { id: eventService.hasOfferCatalog.id }
148
+ ids: params.ids,
149
+ offerCatalog: { id: eventService.hasOfferCatalog.id },
150
+ sort: params.sort
144
151
  });
145
152
  }
146
153
  }
@@ -226,7 +233,10 @@ function searchScreeningEventTicketOffers(params) {
226
233
  }
227
234
  offer.addOn = offerAddOn;
228
235
  }
229
- return offers4event;
236
+ return {
237
+ ticketOffers: offers4event,
238
+ unitPriceOffers: availableOffers
239
+ };
230
240
  });
231
241
  }
232
242
  function getUnacceptedPaymentMethodByEvent(params) {
@@ -323,7 +333,10 @@ function searchAddOns(params) {
323
333
  const productWithAddOns = yield repos.product.findById({ id: productId });
324
334
  const offerCatalogId = (_b = productWithAddOns.hasOfferCatalog) === null || _b === void 0 ? void 0 : _b.id;
325
335
  if (typeof offerCatalogId === 'string') {
326
- offers = yield repos.offer.findOffersByOfferCatalogId({ offerCatalog: { id: offerCatalogId } });
336
+ offers = yield repos.offer.findOffersByOfferCatalogId({
337
+ offerCatalog: { id: offerCatalogId },
338
+ sort: true
339
+ });
327
340
  offers = offers.map((o) => {
328
341
  return Object.assign(Object.assign({ additionalProperty: Array.isArray(o.additionalProperty) ? o.additionalProperty : [], alternateName: o.alternateName, availability: o.availability, availableAtOrFrom: o.availableAtOrFrom, color: o.color, description: o.description, id: o.id, identifier: o.identifier, itemOffered: {
329
342
  description: productWithAddOns.description,
@@ -342,8 +355,8 @@ function searchAddOns(params) {
342
355
  /**
343
356
  * 興行オファー検索
344
357
  */
345
- // tslint:disable-next-line:max-func-body-length
346
358
  function searchEventTicketOffers(params) {
359
+ // tslint:disable-next-line:max-func-body-length
347
360
  return (repos) => __awaiter(this, void 0, void 0, function* () {
348
361
  var _a;
349
362
  const now = moment();
@@ -354,6 +367,7 @@ function searchEventTicketOffers(params) {
354
367
  id: params.event.id
355
368
  });
356
369
  let offers;
370
+ let unitPriceOffers;
357
371
  const eventOffers = event.offers;
358
372
  if (eventOffers === undefined) {
359
373
  throw new factory.errors.NotFound('EventOffers', 'Event offers undefined');
@@ -367,10 +381,22 @@ function searchEventTicketOffers(params) {
367
381
  default:
368
382
  // Chevreで券種オファーを検索
369
383
  if (event.typeOf === factory.eventType.ScreeningEvent) {
370
- offers = yield searchScreeningEventTicketOffers({ event })(repos);
384
+ const searchOffersResult = yield searchScreeningEventTicketOffers({
385
+ ids: params.ids,
386
+ event,
387
+ sort: params.sort
388
+ })(repos);
389
+ offers = searchOffersResult.ticketOffers;
390
+ unitPriceOffers = searchOffersResult.unitPriceOffers;
371
391
  }
372
392
  else if (event.typeOf === factory.eventType.Event) {
373
- offers = yield searchTransportationEventTicketOffers({ event })(repos);
393
+ const searchOffersResult = yield searchTransportationEventTicketOffers({
394
+ ids: params.ids,
395
+ event,
396
+ sort: params.sort
397
+ })(repos);
398
+ offers = searchOffersResult.ticketOffers;
399
+ unitPriceOffers = searchOffersResult.unitPriceOffers;
374
400
  }
375
401
  else {
376
402
  throw new factory.errors.NotImplemented(`'${event.typeOf}' not implemented`);
@@ -426,7 +452,7 @@ function searchEventTicketOffers(params) {
426
452
  }
427
453
  }
428
454
  }
429
- return offers;
455
+ return { ticketOffers: offers, unitPriceOffers };
430
456
  });
431
457
  }
432
458
  exports.searchEventTicketOffers = searchEventTicketOffers;
@@ -22,13 +22,20 @@ function mvtkChargePriceSpec2component(params) {
22
22
  return Object.assign({ id: params.id, typeOf: params.typeOf, name: params.name, price: params.price, priceCurrency: params.priceCurrency, valueAddedTaxIncluded: params.valueAddedTaxIncluded, appliesToVideoFormat: params.appliesToVideoFormat, appliesToMovieTicket: params.appliesToMovieTicket }, (typeof ((_a = params.accounting) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string') ? { accounting: params.accounting } : undefined);
23
23
  }
24
24
  function createCompoundPriceSpec4event(params) {
25
+ var _a;
25
26
  // priceSpecificationはマスタ管理の仕様上必ず存在するはず
26
27
  if (params.offer.priceSpecification === undefined) {
27
28
  throw new factory.errors.NotFound(`priceSpecification of the offer: ${params.offer.id}`);
28
29
  }
29
30
  const unitPriceSpec = Object.assign(Object.assign({}, params.offer.priceSpecification), { name: params.offer.name });
30
- const videoFormatChargeSpecComponents = params.videoFormatChargeSpecifications.map(categoryCodeChargePriceSpec2component);
31
- const soundFormatChargeSpecComponents = params.soundFormatChargeSpecifications.map(categoryCodeChargePriceSpec2component);
31
+ let videoFormatChargeSpecComponents = [];
32
+ let soundFormatChargeSpecComponents = [];
33
+ // 区分加算料金を適用しないオプションを追加(2023-01-26~)
34
+ const ignoreCategoryCodeChargeSpec = ((_a = params.offer.settings) === null || _a === void 0 ? void 0 : _a.ignoreCategoryCodeChargeSpec) === true;
35
+ if (!ignoreCategoryCodeChargeSpec) {
36
+ videoFormatChargeSpecComponents = params.videoFormatChargeSpecifications.map(categoryCodeChargePriceSpec2component);
37
+ soundFormatChargeSpecComponents = params.soundFormatChargeSpecifications.map(categoryCodeChargePriceSpec2component);
38
+ }
32
39
  const mvtkPriceComponents = [];
33
40
  // 複数決済カード対応(2022-07-11~)
34
41
  if (Array.isArray(unitPriceSpec.appliesToMovieTicket)) {
@@ -62,7 +69,7 @@ function createCompoundPriceSpec4event(params) {
62
69
  priceComponent
63
70
  };
64
71
  // 不要な属性を除外(2022-11-07~)
65
- const _a = params.offer, { project } = _a, unitOfferFields4ticketOffer = __rest(_a, ["project"]);
72
+ const _b = params.offer, { project } = _b, unitOfferFields4ticketOffer = __rest(_b, ["project"]);
66
73
  return Object.assign(Object.assign({}, unitOfferFields4ticketOffer), { eligibleQuantity: params.eligibleQuantity, priceSpecification: compoundPriceSpecification });
67
74
  }
68
75
  exports.createCompoundPriceSpec4event = createCompoundPriceSpec4event;
@@ -8,6 +8,7 @@ export declare function searchProductOffers(params: {
8
8
  itemOffered: {
9
9
  id: string;
10
10
  };
11
+ sort: boolean;
11
12
  }): (repos: {
12
13
  offer: OfferRepo;
13
14
  product: ProductRepo;
@@ -23,7 +23,7 @@ function searchProductOffers(params) {
23
23
  if (typeof offerCatalogId !== 'string') {
24
24
  return [];
25
25
  }
26
- const offers = yield repos.offer.findOffersByOfferCatalogId({ offerCatalog: { id: offerCatalogId } });
26
+ const offers = yield repos.offer.findOffersByOfferCatalogId({ offerCatalog: { id: offerCatalogId }, sort: params.sort });
27
27
  return offers.map((o) => {
28
28
  const unitSpec = o.priceSpecification;
29
29
  const compoundPriceSpecification = {
@@ -50,6 +50,7 @@ export declare function search(params: {
50
50
  id: string;
51
51
  };
52
52
  onlyValid: boolean;
53
+ sort: boolean;
53
54
  }): (repos: {
54
55
  offer: OfferRepo;
55
56
  product: ProductRepo;
@@ -58,7 +58,10 @@ function search(params) {
58
58
  return offers;
59
59
  }
60
60
  }
61
- offers = yield (0, searchProductOffers_1.searchProductOffers)({ itemOffered: { id: params.itemOffered.id } })(repos);
61
+ offers = yield (0, searchProductOffers_1.searchProductOffers)({
62
+ itemOffered: { id: params.itemOffered.id },
63
+ sort: params.sort
64
+ })(repos);
62
65
  // 店舗条件によって対象を絞る
63
66
  const storeId = (_b = params.availableAt) === null || _b === void 0 ? void 0 : _b.id;
64
67
  if (typeof storeId === 'string') {
@@ -198,7 +201,8 @@ function fixProductAndOffers(params) {
198
201
  if (product === undefined) {
199
202
  throw new factory.errors.NotFound('Product');
200
203
  }
201
- const availableOffers = yield search(Object.assign({ project: { id: params.project.id }, itemOffered: { id: String(product.id) }, onlyValid: true }, (typeof ((_c = params.location) === null || _c === void 0 ? void 0 : _c.id) === 'string') ? { availableAt: { id: params.location.id } } : undefined))(repos);
204
+ const availableOffers = yield search(Object.assign(Object.assign({ project: { id: params.project.id }, itemOffered: { id: String(product.id) }, onlyValid: true }, (typeof ((_c = params.location) === null || _c === void 0 ? void 0 : _c.id) === 'string') ? { availableAt: { id: params.location.id } } : undefined), { sort: false // ソート不要(2023-01-27~)
205
+ }))(repos);
202
206
  return { product, availableOffers };
203
207
  });
204
208
  }
@@ -218,7 +218,8 @@ function processAuthorizeProductOffer(params) {
218
218
  project: { id: params.project.id },
219
219
  itemOffered: { id: params.product.id },
220
220
  seller: { id: String(seller.id) },
221
- onlyValid: true
221
+ onlyValid: true,
222
+ sort: false // ソート不要(2023-01-27~)
222
223
  })(repos);
223
224
  const acceptedProductOffer = offers.find((o) => o.identifier === acceptedOffer.identifier);
224
225
  if (acceptedProductOffer === undefined) {
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  }
10
10
  ],
11
11
  "dependencies": {
12
- "@chevre/factory": "4.283.0",
12
+ "@chevre/factory": "4.284.0-alpha.0",
13
13
  "@cinerino/sdk": "3.136.0",
14
14
  "@motionpicture/coa-service": "9.2.0",
15
15
  "@motionpicture/gmo-service": "5.2.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.31"
123
+ "version": "20.2.0-alpha.33"
124
124
  }