@chevre/domain 20.2.0-alpha.32 → 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.
@@ -20,6 +20,9 @@ export declare class MongoRepository {
20
20
  offerCatalog: {
21
21
  id: string;
22
22
  };
23
+ limit?: number;
24
+ page?: number;
25
+ sort: boolean;
23
26
  }): Promise<factory.unitPriceOffer.IUnitPriceOffer[]>;
24
27
  findById(params: {
25
28
  id: string;
@@ -346,8 +346,10 @@ class MongoRepository {
346
346
  let offers = [];
347
347
  if (sortedOfferIds.length > 0) {
348
348
  offers = yield this.search({ id: { $in: sortedOfferIds } });
349
- // sorting
350
- 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
+ }
351
353
  }
352
354
  return offers;
353
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);
@@ -93,7 +93,8 @@ function addReservations(params) {
93
93
  // イベントオファー検索
94
94
  const { ticketOffers, unitPriceOffers } = yield OfferService.event.searchEventTicketOffers({
95
95
  ids: acceptedOfferIds,
96
- event: { id: event.id }
96
+ event: { id: event.id },
97
+ sort: false // ソート不要(2023-01-27~)
97
98
  })(repos);
98
99
  // 冗長なfindOffersByOfferCatalogId処理を削除(2023-01-26~)
99
100
  const availableOffers = unitPriceOffers;
@@ -288,7 +288,8 @@ function validateAcceptedOffers(params) {
288
288
  ids: offerIds,
289
289
  event: { id: params.event.id },
290
290
  seller: params.seller,
291
- store: params.store
291
+ store: params.store,
292
+ sort: false // ソート不要(2023-01-27~)
292
293
  })(repos);
293
294
  // 利用可能なチケットオファーであれば受け入れる
294
295
  const acceptedOffers = (Array.isArray(acceptedOffersWithoutDetail))
@@ -76,6 +76,7 @@ declare function searchEventTicketOffers(params: {
76
76
  */
77
77
  kbnEisyahousiki: string;
78
78
  };
79
+ sort: boolean;
79
80
  }): ISearchEventTicketOffersOperation<{
80
81
  ticketOffers: factory.product.ITicketOffer[];
81
82
  unitPriceOffers: factory.unitPriceOffer.IUnitPriceOffer[];
@@ -31,7 +31,8 @@ function searchTransportationEventTicketOffers(params) {
31
31
  if (typeof ((_b = transportation.hasOfferCatalog) === null || _b === void 0 ? void 0 : _b.id) === 'string') {
32
32
  availableOffers = yield repos.offer.findOffersByOfferCatalogId({
33
33
  ids: params.ids,
34
- offerCatalog: { id: transportation.hasOfferCatalog.id }
34
+ offerCatalog: { id: transportation.hasOfferCatalog.id },
35
+ sort: params.sort
35
36
  });
36
37
  }
37
38
  }
@@ -145,7 +146,8 @@ function searchScreeningEventTicketOffers(params) {
145
146
  if (typeof ((_b = eventService.hasOfferCatalog) === null || _b === void 0 ? void 0 : _b.id) === 'string') {
146
147
  availableOffers = yield repos.offer.findOffersByOfferCatalogId({
147
148
  ids: params.ids,
148
- offerCatalog: { id: eventService.hasOfferCatalog.id }
149
+ offerCatalog: { id: eventService.hasOfferCatalog.id },
150
+ sort: params.sort
149
151
  });
150
152
  }
151
153
  }
@@ -331,7 +333,10 @@ function searchAddOns(params) {
331
333
  const productWithAddOns = yield repos.product.findById({ id: productId });
332
334
  const offerCatalogId = (_b = productWithAddOns.hasOfferCatalog) === null || _b === void 0 ? void 0 : _b.id;
333
335
  if (typeof offerCatalogId === 'string') {
334
- offers = yield repos.offer.findOffersByOfferCatalogId({ offerCatalog: { id: offerCatalogId } });
336
+ offers = yield repos.offer.findOffersByOfferCatalogId({
337
+ offerCatalog: { id: offerCatalogId },
338
+ sort: true
339
+ });
335
340
  offers = offers.map((o) => {
336
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: {
337
342
  description: productWithAddOns.description,
@@ -376,12 +381,20 @@ function searchEventTicketOffers(params) {
376
381
  default:
377
382
  // Chevreで券種オファーを検索
378
383
  if (event.typeOf === factory.eventType.ScreeningEvent) {
379
- const searchOffersResult = yield searchScreeningEventTicketOffers({ ids: params.ids, event })(repos);
384
+ const searchOffersResult = yield searchScreeningEventTicketOffers({
385
+ ids: params.ids,
386
+ event,
387
+ sort: params.sort
388
+ })(repos);
380
389
  offers = searchOffersResult.ticketOffers;
381
390
  unitPriceOffers = searchOffersResult.unitPriceOffers;
382
391
  }
383
392
  else if (event.typeOf === factory.eventType.Event) {
384
- const searchOffersResult = yield searchTransportationEventTicketOffers({ ids: params.ids, event })(repos);
393
+ const searchOffersResult = yield searchTransportationEventTicketOffers({
394
+ ids: params.ids,
395
+ event,
396
+ sort: params.sort
397
+ })(repos);
385
398
  offers = searchOffersResult.ticketOffers;
386
399
  unitPriceOffers = searchOffersResult.unitPriceOffers;
387
400
  }
@@ -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
@@ -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.32"
123
+ "version": "20.2.0-alpha.33"
124
124
  }