@chevre/domain 20.2.0-alpha.32 → 20.2.0-alpha.34

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.
@@ -23,7 +23,8 @@ async function main() {
23
23
 
24
24
  const { ticketOffers } = await chevre.service.offer.event.searchEventTicketOffers({
25
25
  event: { id: 'al9ew43f5' },
26
- onlyValid: true
26
+ onlyValid: true,
27
+ sort: true
27
28
  // ...(typeof sellerId === 'string') ? { seller: { id: sellerId } } : undefined,
28
29
  // ...(typeof availableAtId === 'string') ? { store: { id: availableAtId } } : undefined
29
30
  })({
@@ -15,7 +15,8 @@ async function main() {
15
15
  offerCatalog: {
16
16
  id: '0001'
17
17
  // id: 'xxx'
18
- }
18
+ },
19
+ sort: true
19
20
  });
20
21
  console.log(offers.map((o) => o.id));
21
22
  console.log(offers.length);
@@ -20,6 +20,12 @@ export declare class MongoRepository {
20
20
  offerCatalog: {
21
21
  id: string;
22
22
  };
23
+ availableAtOrFrom?: {
24
+ id?: string;
25
+ };
26
+ limit?: number;
27
+ page?: number;
28
+ sort: boolean;
23
29
  }): Promise<factory.unitPriceOffer.IUnitPriceOffer[]>;
24
30
  findById(params: {
25
31
  id: string;
@@ -301,6 +301,7 @@ class MongoRepository {
301
301
  * カタログに登録されたオファーの順序は保証される
302
302
  */
303
303
  findOffersByOfferCatalogId(params) {
304
+ var _a;
304
305
  return __awaiter(this, void 0, void 0, function* () {
305
306
  // aggregateで再実装(2023-01-26~)
306
307
  const matchStages = [{ $match: { _id: { $eq: params.offerCatalog.id } } }];
@@ -345,9 +346,13 @@ class MongoRepository {
345
346
  // }
346
347
  let offers = [];
347
348
  if (sortedOfferIds.length > 0) {
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
+ offers = yield this.search(Object.assign({ id: { $in: sortedOfferIds } }, (typeof ((_a = params.availableAtOrFrom) === null || _a === void 0 ? void 0 : _a.id) === 'string')
350
+ ? { availableAtOrFrom: { id: { $eq: params.availableAtOrFrom.id } } }
351
+ : undefined));
352
+ if (params.sort) {
353
+ // sorting
354
+ offers = offers.sort((a, b) => sortedOfferIds.indexOf(String(a.id)) - sortedOfferIds.indexOf(String(b.id)));
355
+ }
351
356
  }
352
357
  return offers;
353
358
  });
@@ -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);
@@ -62,12 +62,24 @@ interface IConfirmRepo {
62
62
  task: TaskRepo;
63
63
  }
64
64
  export declare type IConfirmOperation<T> = (repos: IConfirmRepo) => Promise<T>;
65
+ declare type IStartParams = factory.assetTransaction.reserve.IStartParamsWithoutDetail & {
66
+ /**
67
+ * 承認アクションを介した場合に検索済のオファーリスト
68
+ */
69
+ preSearchedTicketOffers?: factory.product.ITicketOffer[];
70
+ /**
71
+ * 承認アクションを介した場合に検索済の単価オファーリスト
72
+ */
73
+ preSearchedUnitPriceOffers?: factory.unitPriceOffer.IUnitPriceOffer[];
74
+ availableAtOrFrom?: {
75
+ id?: string;
76
+ };
77
+ validateAppliesToMovieTicket: boolean;
78
+ };
65
79
  /**
66
80
  * 取引開始
67
81
  */
68
- export declare function start(params: factory.assetTransaction.reserve.IStartParamsWithoutDetail & {
69
- validateAppliesToMovieTicket: boolean;
70
- }): IStartOperation<factory.assetTransaction.ITransaction<factory.assetTransactionType.Reserve>>;
82
+ export declare function start(params: IStartParams): IStartOperation<factory.assetTransaction.ITransaction<factory.assetTransactionType.Reserve>>;
71
83
  /**
72
84
  * 取引確定
73
85
  */
@@ -26,7 +26,7 @@ const factory_1 = require("./reserve/factory");
26
26
  */
27
27
  function start(params) {
28
28
  return (repos) => __awaiter(this, void 0, void 0, function* () {
29
- var _a;
29
+ var _a, _b;
30
30
  // 自動発行廃止(2022-05-17~)
31
31
  const reservationNumber = params.transactionNumber;
32
32
  if (typeof reservationNumber !== 'string' || reservationNumber.length === 0) {
@@ -51,6 +51,9 @@ function start(params) {
51
51
  transaction = yield addReservations({
52
52
  id: transaction.id,
53
53
  object: params.object,
54
+ preSearchedTicketOffers: params.preSearchedTicketOffers,
55
+ preSearchedUnitPriceOffers: params.preSearchedUnitPriceOffers,
56
+ availableAtOrFrom: { id: (_b = params.availableAtOrFrom) === null || _b === void 0 ? void 0 : _b.id },
54
57
  validateAppliesToMovieTicket: params.validateAppliesToMovieTicket
55
58
  })(repos);
56
59
  }
@@ -64,7 +67,7 @@ exports.start = start;
64
67
  function addReservations(params) {
65
68
  // tslint:disable-next-line:max-func-body-length
66
69
  return (repos) => __awaiter(this, void 0, void 0, function* () {
67
- var _a;
70
+ var _a, _b;
68
71
  const now = new Date();
69
72
  let transaction = yield repos.assetTransaction.findById({ typeOf: factory.assetTransactionType.Reserve, id: params.id });
70
73
  // イベント存在確認
@@ -90,13 +93,26 @@ function addReservations(params) {
90
93
  }
91
94
  // 受け入れたオファーIDだけ取得する(2023-01-26~)
92
95
  const acceptedOfferIds = [...new Set(acceptedOffers.map((o) => String(o.id)))];
93
- // イベントオファー検索
94
- const { ticketOffers, unitPriceOffers } = yield OfferService.event.searchEventTicketOffers({
95
- ids: acceptedOfferIds,
96
- event: { id: event.id }
97
- })(repos);
96
+ let ticketOffers;
97
+ let availableOffers;
98
+ // 承認アクションを介した予約取引開始時の冗長なオファー検索処理について最適化(2023-01-27~)
99
+ if (Array.isArray(params.preSearchedTicketOffers) && Array.isArray(params.preSearchedUnitPriceOffers)) {
100
+ ticketOffers = params.preSearchedTicketOffers;
101
+ availableOffers = params.preSearchedUnitPriceOffers;
102
+ }
103
+ else {
104
+ // イベントオファー検索
105
+ const searchEventTicketOffersResult = yield OfferService.event.searchEventTicketOffers({
106
+ ids: acceptedOfferIds,
107
+ event: { id: event.id },
108
+ // 対応アプリケーション条件追加(2023-01-27~)
109
+ store: { id: (_b = params.availableAtOrFrom) === null || _b === void 0 ? void 0 : _b.id },
110
+ sort: false // ソート不要(2023-01-27~)
111
+ })(repos);
112
+ ticketOffers = searchEventTicketOffersResult.ticketOffers;
113
+ availableOffers = searchEventTicketOffersResult.unitPriceOffers;
114
+ }
98
115
  // 冗長なfindOffersByOfferCatalogId処理を削除(2023-01-26~)
99
- const availableOffers = unitPriceOffers;
100
116
  // let availableOffers: factory.unitPriceOffer.IUnitPriceOffer[] = [];
101
117
  // // 興行設定があれば興行のカタログを参照する(2022-08-31~)
102
118
  // const eventOffers = <factory.event.screeningEvent.IOffer | undefined>event.offers;
@@ -24,7 +24,7 @@ function authorize(params) {
24
24
  return (repos) => __awaiter(this, void 0, void 0, function* () {
25
25
  const now = new Date();
26
26
  const { transaction, event, bookingServiceIdentifire } = yield validateCreateRequest(Object.assign(Object.assign({}, params), { now, store: params.store }))({ event: repos.event, transaction: repos.transaction });
27
- const acceptedOffers = yield validateAcceptedOffers({
27
+ const { acceptedOffers, ticketOffers, unitPriceOffers } = yield validateAcceptedOffers({
28
28
  object: params.object,
29
29
  event,
30
30
  seller: { typeOf: transaction.seller.typeOf, id: String(transaction.seller.id) },
@@ -63,7 +63,10 @@ function authorize(params) {
63
63
  action,
64
64
  event,
65
65
  transactionNumber,
66
- transaction
66
+ transaction,
67
+ availableAtOrFrom: { id: params.store.id },
68
+ ticketOffers,
69
+ unitPriceOffers
67
70
  })(repos);
68
71
  // requestBody = processStartReserveResult.requestBody;
69
72
  // responseBody = processStartReserveResult.responseBody;
@@ -168,7 +171,7 @@ function processStartReserve4chevre(params) {
168
171
  // requestBody = startParams;
169
172
  const startParamObject = yield validateObjectWithoutDetail(startParams)(repos);
170
173
  // 予約取引開始
171
- responseBody = yield ReserveTransactionService.start(Object.assign(Object.assign({}, startParams), { object: startParamObject, validateAppliesToMovieTicket: true }))(repos);
174
+ responseBody = yield ReserveTransactionService.start(Object.assign(Object.assign({}, startParams), { object: startParamObject, preSearchedTicketOffers: params.ticketOffers, preSearchedUnitPriceOffers: params.unitPriceOffers, availableAtOrFrom: { id: params.availableAtOrFrom.id }, validateAppliesToMovieTicket: true }))(repos);
172
175
  // 予約取引からオファー情報を生成する
173
176
  acceptedOffers4result = (0, factory_1.responseBody2acceptedOffers4result)({
174
177
  responseBody: responseBody,
@@ -283,12 +286,13 @@ function validateAcceptedOffers(params) {
283
286
  ? [...new Set(acceptedOffersWithoutDetail.map((o) => o.id))]
284
287
  : [];
285
288
  // 利用可能なチケットオファーを検索
286
- const { ticketOffers } = yield (0, searchEventTicketOffers_1.searchEventTicketOffers)({
289
+ const { ticketOffers, unitPriceOffers } = yield (0, searchEventTicketOffers_1.searchEventTicketOffers)({
287
290
  // 受け入れたオファーIDだけ取得する(2023-01-26~)
288
291
  ids: offerIds,
289
292
  event: { id: params.event.id },
290
- seller: params.seller,
291
- store: params.store
293
+ // seller: params.seller,
294
+ store: params.store,
295
+ sort: false // ソート不要(2023-01-27~)
292
296
  })(repos);
293
297
  // 利用可能なチケットオファーであれば受け入れる
294
298
  const acceptedOffers = (Array.isArray(acceptedOffersWithoutDetail))
@@ -332,7 +336,7 @@ function validateAcceptedOffers(params) {
332
336
  }
333
337
  }
334
338
  });
335
- return acceptedOffers;
339
+ return { acceptedOffers, ticketOffers, unitPriceOffers };
336
340
  });
337
341
  }
338
342
  function acceptedOfferWithoutDetail2acceptedOffer(params) {
@@ -29,12 +29,10 @@ declare function searchEventTicketOffers(params: {
29
29
  };
30
30
  /**
31
31
  * どの販売者に対して
32
+ * 不要なので廃止(2023-01-27~)
32
33
  */
33
- seller?: {
34
- id?: string;
35
- };
36
34
  /**
37
- * どの店舗に対して
35
+ * どのアプリケーションに対して
38
36
  */
39
37
  store?: {
40
38
  id?: string;
@@ -76,6 +74,7 @@ declare function searchEventTicketOffers(params: {
76
74
  */
77
75
  kbnEisyahousiki: string;
78
76
  };
77
+ sort: boolean;
79
78
  }): ISearchEventTicketOffersOperation<{
80
79
  ticketOffers: factory.product.ITicketOffer[];
81
80
  unitPriceOffers: factory.unitPriceOffer.IUnitPriceOffer[];
@@ -19,7 +19,7 @@ const factory_1 = require("../factory");
19
19
  function searchTransportationEventTicketOffers(params) {
20
20
  // tslint:disable-next-line:max-func-body-length
21
21
  return (repos) => __awaiter(this, void 0, void 0, function* () {
22
- var _a, _b, _c;
22
+ var _a, _b, _c, _d;
23
23
  const screeningEvent = params.event;
24
24
  const soundFormatTypes = [];
25
25
  const videoFormatTypes = [];
@@ -31,7 +31,9 @@ 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
+ availableAtOrFrom: { id: (_c = params.store) === null || _c === void 0 ? void 0 : _c.id },
36
+ sort: params.sort
35
37
  });
36
38
  }
37
39
  }
@@ -108,9 +110,12 @@ function searchTransportationEventTicketOffers(params) {
108
110
  const offerAddOn = [];
109
111
  if (Array.isArray(offer.addOn)) {
110
112
  for (const addOn of offer.addOn) {
111
- const productId = (_c = addOn.itemOffered) === null || _c === void 0 ? void 0 : _c.id;
113
+ const productId = (_d = addOn.itemOffered) === null || _d === void 0 ? void 0 : _d.id;
112
114
  if (typeof productId === 'string') {
113
- const productOffers = yield searchAddOns({ product: { id: productId } })(repos);
115
+ const productOffers = yield searchAddOns({
116
+ product: { id: productId },
117
+ store: params.store
118
+ })(repos);
114
119
  offerAddOn.push(...productOffers);
115
120
  }
116
121
  }
@@ -129,7 +134,7 @@ function searchTransportationEventTicketOffers(params) {
129
134
  function searchScreeningEventTicketOffers(params) {
130
135
  // tslint:disable-next-line:max-func-body-length
131
136
  return (repos) => __awaiter(this, void 0, void 0, function* () {
132
- var _a, _b, _c;
137
+ var _a, _b, _c, _d;
133
138
  // イベント取得属性最適化(2023-01-23~)
134
139
  // const screeningEvent = await repos.event.findById<factory.eventType.ScreeningEvent>({ id: params.eventId });
135
140
  const screeningEvent = params.event;
@@ -145,7 +150,9 @@ function searchScreeningEventTicketOffers(params) {
145
150
  if (typeof ((_b = eventService.hasOfferCatalog) === null || _b === void 0 ? void 0 : _b.id) === 'string') {
146
151
  availableOffers = yield repos.offer.findOffersByOfferCatalogId({
147
152
  ids: params.ids,
148
- offerCatalog: { id: eventService.hasOfferCatalog.id }
153
+ offerCatalog: { id: eventService.hasOfferCatalog.id },
154
+ availableAtOrFrom: { id: (_c = params.store) === null || _c === void 0 ? void 0 : _c.id },
155
+ sort: params.sort
149
156
  });
150
157
  }
151
158
  }
@@ -222,7 +229,7 @@ function searchScreeningEventTicketOffers(params) {
222
229
  const offerAddOn = [];
223
230
  if (Array.isArray(offer.addOn)) {
224
231
  for (const addOn of offer.addOn) {
225
- const productId = (_c = addOn.itemOffered) === null || _c === void 0 ? void 0 : _c.id;
232
+ const productId = (_d = addOn.itemOffered) === null || _d === void 0 ? void 0 : _d.id;
226
233
  if (typeof productId === 'string') {
227
234
  const productOffers = yield searchAddOns({ product: { id: productId } })(repos);
228
235
  offerAddOn.push(...productOffers);
@@ -324,14 +331,18 @@ function checkAvailability(params) {
324
331
  */
325
332
  function searchAddOns(params) {
326
333
  return (repos) => __awaiter(this, void 0, void 0, function* () {
327
- var _a, _b;
334
+ var _a, _b, _c;
328
335
  let offers = [];
329
336
  const productId = (_a = params.product) === null || _a === void 0 ? void 0 : _a.id;
330
337
  if (typeof productId === 'string') {
331
338
  const productWithAddOns = yield repos.product.findById({ id: productId });
332
339
  const offerCatalogId = (_b = productWithAddOns.hasOfferCatalog) === null || _b === void 0 ? void 0 : _b.id;
333
340
  if (typeof offerCatalogId === 'string') {
334
- offers = yield repos.offer.findOffersByOfferCatalogId({ offerCatalog: { id: offerCatalogId } });
341
+ offers = yield repos.offer.findOffersByOfferCatalogId({
342
+ offerCatalog: { id: offerCatalogId },
343
+ availableAtOrFrom: { id: (_c = params.store) === null || _c === void 0 ? void 0 : _c.id },
344
+ sort: true
345
+ });
335
346
  offers = offers.map((o) => {
336
347
  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
348
  description: productWithAddOns.description,
@@ -353,7 +364,6 @@ function searchAddOns(params) {
353
364
  function searchEventTicketOffers(params) {
354
365
  // tslint:disable-next-line:max-func-body-length
355
366
  return (repos) => __awaiter(this, void 0, void 0, function* () {
356
- var _a;
357
367
  const now = moment();
358
368
  let event;
359
369
  // イベント取得属性最適化(2023-01-23~)
@@ -376,26 +386,37 @@ function searchEventTicketOffers(params) {
376
386
  default:
377
387
  // Chevreで券種オファーを検索
378
388
  if (event.typeOf === factory.eventType.ScreeningEvent) {
379
- const searchOffersResult = yield searchScreeningEventTicketOffers({ ids: params.ids, event })(repos);
389
+ const searchOffersResult = yield searchScreeningEventTicketOffers({
390
+ ids: params.ids,
391
+ event,
392
+ store: params.store,
393
+ sort: params.sort
394
+ })(repos);
380
395
  offers = searchOffersResult.ticketOffers;
381
396
  unitPriceOffers = searchOffersResult.unitPriceOffers;
382
397
  }
383
398
  else if (event.typeOf === factory.eventType.Event) {
384
- const searchOffersResult = yield searchTransportationEventTicketOffers({ ids: params.ids, event })(repos);
399
+ const searchOffersResult = yield searchTransportationEventTicketOffers({
400
+ ids: params.ids,
401
+ event,
402
+ store: params.store,
403
+ sort: params.sort
404
+ })(repos);
385
405
  offers = searchOffersResult.ticketOffers;
386
406
  unitPriceOffers = searchOffersResult.unitPriceOffers;
387
407
  }
388
408
  else {
389
409
  throw new factory.errors.NotImplemented(`'${event.typeOf}' not implemented`);
390
410
  }
391
- const specifiedStoreId = (_a = params.store) === null || _a === void 0 ? void 0 : _a.id;
392
- if (typeof specifiedStoreId === 'string') {
393
- // アプリケーションが利用可能なオファーに絞る
394
- offers = offers.filter((o) => {
395
- return Array.isArray(o.availableAtOrFrom)
396
- && o.availableAtOrFrom.some((availableApplication) => availableApplication.id === specifiedStoreId);
397
- });
398
- }
411
+ // store.idでのフィルターをmongoに移行(2023-01-27~)
412
+ // const specifiedStoreId = params.store?.id;
413
+ // if (typeof specifiedStoreId === 'string') {
414
+ // // アプリケーションが利用可能なオファーに絞る
415
+ // offers = offers.filter((o) => {
416
+ // return Array.isArray(o.availableAtOrFrom)
417
+ // && o.availableAtOrFrom.some((availableApplication) => availableApplication.id === specifiedStoreId);
418
+ // });
419
+ // }
399
420
  // 有効期間を適用
400
421
  if (params.onlyValid === true) {
401
422
  offers = offers.filter((o) => {
@@ -413,14 +434,17 @@ function searchEventTicketOffers(params) {
413
434
  }
414
435
  for (const offer of offers) {
415
436
  if (Array.isArray(offer.addOn)) {
437
+ // store.idでのフィルターをmongoに移行(2023-01-27~)
416
438
  // addOnsに対しても利用可能アプリケーション設定を適用
417
- if (typeof specifiedStoreId === 'string') {
418
- // アプリケーションが利用可能なオファーに絞る
419
- offer.addOn = offer.addOn.filter((offer4addOn) => {
420
- return Array.isArray(offer4addOn.availableAtOrFrom)
421
- && offer4addOn.availableAtOrFrom.some((availableApplication) => availableApplication.id === specifiedStoreId);
422
- });
423
- }
439
+ // if (typeof specifiedStoreId === 'string') {
440
+ // // アプリケーションが利用可能なオファーに絞る
441
+ // offer.addOn = offer.addOn.filter((offer4addOn) => {
442
+ // return Array.isArray(offer4addOn.availableAtOrFrom)
443
+ // && offer4addOn.availableAtOrFrom.some(
444
+ // (availableApplication) => availableApplication.id === specifiedStoreId
445
+ // );
446
+ // });
447
+ // }
424
448
  // addOnsに対しても有効期間を適用
425
449
  if (params.onlyValid === true) {
426
450
  offer.addOn = offer.addOn.filter((offer4addOn) => {
@@ -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.34"
124
124
  }