@chevre/domain 20.4.0-alpha.13 → 20.4.0-alpha.15

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.
@@ -16,7 +16,7 @@ async function main() {
16
16
 
17
17
  // const now = new Date();
18
18
  await chevre.service.aggregation.event.aggregateScreeningEvent({
19
- id: 'alb35u7m4'
19
+ id: 'blaqxj0ak'
20
20
  })({
21
21
  event: new chevre.repository.Event(mongoose.connection),
22
22
  eventAvailability: new chevre.repository.itemAvailability.ScreeningEvent(client),
@@ -0,0 +1,21 @@
1
+ // tslint:disable:no-console
2
+ import * as mongoose from 'mongoose';
3
+
4
+ import { chevre } from '../../../lib/index';
5
+
6
+ // const project = { id: String(process.env.PROJECT_ID) };
7
+
8
+ async function main() {
9
+ await mongoose.connect(<string>process.env.MONGOLAB_URI);
10
+
11
+ const priceSpecificationRepo = new chevre.repository.PriceSpecification(mongoose.connection);
12
+
13
+ const result = await priceSpecificationRepo.deleteUnnecessaryMovieTicketTypeChargePriceSpecs({
14
+ project: { id: 'cinerino' }
15
+ });
16
+ console.log('deleted', result);
17
+ }
18
+
19
+ main()
20
+ .then()
21
+ .catch(console.error);
@@ -22,10 +22,13 @@ async function main() {
22
22
  const productRepo = new chevre.repository.Product(mongoose.connection);
23
23
 
24
24
  const { ticketOffers } = await chevre.service.offer.event.searchEventTicketOffers({
25
- event: { id: 'ale6qiedf' },
25
+ event: { id: 'ale5c99n2' },
26
26
  onlyValid: true,
27
- sort: true,
28
- validateOfferRateLimit: true
27
+ sort: false,
28
+ validateOfferRateLimit: true,
29
+ addSortIndex: true,
30
+ limit: 100,
31
+ page: 1
29
32
  // ...(typeof availableAtId === 'string') ? { store: { id: availableAtId } } : undefined
30
33
  })({
31
34
  event: eventRepo,
@@ -34,6 +37,7 @@ async function main() {
34
37
  priceSpecification: priceSpecificationRepo,
35
38
  product: productRepo
36
39
  });
40
+ console.log(ticketOffers.map((o) => o.sortIndex));
37
41
  console.log(ticketOffers.length);
38
42
  }
39
43
 
@@ -9,7 +9,7 @@ async function main() {
9
9
 
10
10
  const offerRepo = new chevre.repository.Offer(mongoose.connection);
11
11
 
12
- const offers = await offerRepo.findOffersByOfferCatalogId({
12
+ const { offers } = await offerRepo.findOffersByOfferCatalogId({
13
13
  ids: ['al96nqj7z', 'xxx', '1001'],
14
14
  // ids: ['xx', 'xxx'],
15
15
  offerCatalog: {
@@ -10,7 +10,7 @@ export interface IUpdateAggregateReservationParams {
10
10
  $set: {
11
11
  updatedAt: Date;
12
12
  aggregateReservation: factory.event.screeningEvent.IAggregateReservation;
13
- aggregateOffer: factory.event.screeningEvent.IAggregateOffer;
13
+ aggregateOffer?: factory.event.screeningEvent.IAggregateOffer;
14
14
  maximumAttendeeCapacity?: number;
15
15
  remainingAttendeeCapacity?: number;
16
16
  checkInCount?: number;
@@ -28,7 +28,10 @@ export declare class MongoRepository {
28
28
  limit?: number;
29
29
  page?: number;
30
30
  sort: boolean;
31
- }): Promise<factory.unitPriceOffer.IUnitPriceOffer[]>;
31
+ }): Promise<{
32
+ offers: factory.unitPriceOffer.IUnitPriceOffer[];
33
+ sortedOfferIds: string[];
34
+ }>;
32
35
  findById(params: {
33
36
  id: string;
34
37
  }): Promise<factory.unitPriceOffer.IUnitPriceOffer>;
@@ -342,7 +342,7 @@ class MongoRepository {
342
342
  : [];
343
343
  let offers = [];
344
344
  if (sortedOfferIds.length > 0) {
345
- const searchOffersConditions = Object.assign(Object.assign({ id: { $in: sortedOfferIds } }, (typeof ((_a = params.availableAtOrFrom) === null || _a === void 0 ? void 0 : _a.id) === 'string')
345
+ const searchOffersConditions = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ id: { $in: sortedOfferIds } }, (typeof ((_a = params.availableAtOrFrom) === null || _a === void 0 ? void 0 : _a.id) === 'string')
346
346
  ? { availableAtOrFrom: { id: { $eq: params.availableAtOrFrom.id } } }
347
347
  : undefined), { priceSpecification: {
348
348
  appliesToMovieTicket: Object.assign(Object.assign({}, (Array.isArray(params.unacceptedPaymentMethod) && params.unacceptedPaymentMethod.length > 0)
@@ -356,14 +356,16 @@ class MongoRepository {
356
356
  serviceType: { $exists: false }
357
357
  }
358
358
  : undefined)
359
- } });
359
+ } }), (typeof params.limit === 'number' && typeof params.page === 'number')
360
+ ? { sort: { _id: factory.sortType.Ascending } }
361
+ : undefined), (typeof params.limit === 'number') ? { limit: params.limit } : undefined), (typeof params.page === 'number') ? { page: params.page } : undefined);
360
362
  offers = yield this.search(searchOffersConditions);
361
363
  if (params.sort) {
362
364
  // sorting
363
365
  offers = offers.sort((a, b) => sortedOfferIds.indexOf(String(a.id)) - sortedOfferIds.indexOf(String(b.id)));
364
366
  }
365
367
  }
366
- return offers;
368
+ return { offers, sortedOfferIds };
367
369
  });
368
370
  }
369
371
  findById(params) {
@@ -30,5 +30,15 @@ export declare class MongoRepository {
30
30
  id: string;
31
31
  };
32
32
  }): Promise<void>;
33
+ deleteUnnecessaryMovieTicketTypeChargePriceSpecs(params: {
34
+ project: {
35
+ id: string;
36
+ };
37
+ }): Promise<{
38
+ ok?: number | undefined;
39
+ n?: number | undefined;
40
+ } & {
41
+ deletedCount?: number | undefined;
42
+ }>;
33
43
  getCursor(conditions: any, projection: any): import("mongoose").QueryCursor<any>;
34
44
  }
@@ -277,6 +277,16 @@ class MongoRepository {
277
277
  .exec();
278
278
  });
279
279
  }
280
+ deleteUnnecessaryMovieTicketTypeChargePriceSpecs(params) {
281
+ return __awaiter(this, void 0, void 0, function* () {
282
+ return this.priceSpecificationModel.deleteMany({
283
+ 'project.id': { $eq: params.project.id },
284
+ typeOf: { $eq: factory.priceSpecificationType.MovieTicketTypeChargeSpecification },
285
+ price: { $eq: 0 }
286
+ })
287
+ .exec();
288
+ });
289
+ }
280
290
  getCursor(conditions, projection) {
281
291
  return this.priceSpecificationModel.find(conditions, projection)
282
292
  .sort({ price: factory.sortType.Ascending })
@@ -17,6 +17,7 @@ const createDebug = require("debug");
17
17
  const moment = require("moment-timezone");
18
18
  const event_1 = require("../../../repo/event");
19
19
  const factory = require("../../../factory");
20
+ const settings_1 = require("../../../settings");
20
21
  const debug = createDebug('chevre-domain:service');
21
22
  /**
22
23
  * イベントデータをID指定で集計する
@@ -28,31 +29,34 @@ function aggregateScreeningEvent(params) {
28
29
  // const event = await repos.event.findById<factory.eventType.ScreeningEvent | factory.eventType.Event>(params);
29
30
  const event = yield repos.event.findMinimizedIndividualEventById(params);
30
31
  let aggregatingEvents = [event];
31
- const availableOffers = yield findOffers({ event })(repos);
32
- const offerRateLimitExists = availableOffers.some((o) => { var _a; return typeof ((_a = o.validRateLimit) === null || _a === void 0 ? void 0 : _a.scope) === 'string'; });
33
- if (offerRateLimitExists) {
34
- // 同location、かつ同時間帯、のイベントに関しても集計する(ttts暫定対応)
35
- const startFrom = moment(event.startDate)
36
- .startOf('hour')
37
- .toDate();
38
- const startThrough = moment(startFrom)
39
- .add(1, 'hour')
40
- .add(-1, 'second')
41
- .toDate();
42
- // 取得属性最適化(2023-01-25~)
43
- aggregatingEvents = yield repos.event.search({
44
- limit: 100,
45
- page: 1,
46
- project: { id: { $eq: event.project.id } },
47
- typeOf: event.typeOf,
48
- eventStatuses: [factory.eventStatusType.EventScheduled],
49
- startFrom: startFrom,
50
- startThrough: startThrough,
51
- location: { branchCode: { $eq: event.location.branchCode } }
52
- }, event_1.PROJECTION_MINIMIZED_EVENT);
53
- // ID指定されたイベントについてはEventScheduledでなくても集計したいので、集計対象を調整
54
- aggregatingEvents = aggregatingEvents.filter((e) => e.id !== event.id);
55
- aggregatingEvents = [event, ...aggregatingEvents];
32
+ // プロジェクト限定(2023-02-22~)
33
+ if (settings_1.settings.useOfferRateLimitProjects.includes(event.project.id)) {
34
+ const availableOffers = yield findOffers({ event })(repos);
35
+ const offerRateLimitExists = availableOffers.some((o) => { var _a; return typeof ((_a = o.validRateLimit) === null || _a === void 0 ? void 0 : _a.scope) === 'string'; });
36
+ if (offerRateLimitExists) {
37
+ // 同location、かつ同時間帯、のイベントに関しても集計する(ttts暫定対応)
38
+ const startFrom = moment(event.startDate)
39
+ .startOf('hour')
40
+ .toDate();
41
+ const startThrough = moment(startFrom)
42
+ .add(1, 'hour')
43
+ .add(-1, 'second')
44
+ .toDate();
45
+ // 取得属性最適化(2023-01-25~)
46
+ aggregatingEvents = yield repos.event.search({
47
+ limit: 100,
48
+ page: 1,
49
+ project: { id: { $eq: event.project.id } },
50
+ typeOf: event.typeOf,
51
+ eventStatuses: [factory.eventStatusType.EventScheduled],
52
+ startFrom: startFrom,
53
+ startThrough: startThrough,
54
+ location: { branchCode: { $eq: event.location.branchCode } }
55
+ }, event_1.PROJECTION_MINIMIZED_EVENT);
56
+ // ID指定されたイベントについてはEventScheduledでなくても集計したいので、集計対象を調整
57
+ aggregatingEvents = aggregatingEvents.filter((e) => e.id !== event.id);
58
+ aggregatingEvents = [event, ...aggregatingEvents];
59
+ }
56
60
  }
57
61
  debug(aggregatingEvents.length, 'aggregatingEvents found', aggregatingEvents.map((e) => e.id));
58
62
  for (const aggregatingEvent of aggregatingEvents) {
@@ -79,41 +83,29 @@ function aggregateByEvent(params) {
79
83
  branchCode: { $eq: event.location.branchCode },
80
84
  containedInPlace: { id: { $eq: movieTheaterId } }
81
85
  });
82
- // 施設取得
83
- // const movieTheater = await findLocation(params)(repos);
84
- // // 万が一施設が存在しなければ処理終了
85
- // if (movieTheater === undefined) {
86
- // return;
87
- // }
88
- // const screeningRoom = <factory.place.screeningRoom.IPlace | undefined>
89
- // movieTheater.containsPlace.find((p) => p.branchCode === event.location.branchCode);
90
- // if (screeningRoom === undefined) {
91
- // // 基本的にありえないはずだが、万が一スクリーンが見つからなければcapacityは0のまま
92
- // // tslint:disable-next-line:no-console
93
- // console.error(new Error(`Screening room not found. branchCode: ${event.location.branchCode}`));
94
- // return;
95
- // }
96
86
  // 予約集計
97
87
  const { maximumAttendeeCapacity, remainingAttendeeCapacity, aggregateReservation } = yield aggregateReservationByEvent({
98
88
  aggregateDate: now,
99
89
  event: event,
100
90
  screeningRoom: screeningRoom
101
91
  })(repos);
92
+ // プロジェクト限定(2023-02-22~)
102
93
  // オファーごとの集計
103
- const aggregateOffer = yield aggregateOfferByEvent({
104
- aggregateDate: now,
105
- event: Object.assign(Object.assign({}, event), { maximumAttendeeCapacity,
106
- remainingAttendeeCapacity }),
107
- screeningRoom: screeningRoom
108
- })(repos);
109
- debug('offers aggregated', aggregateOffer);
94
+ let aggregateOffer;
95
+ if (settings_1.settings.useAggregateOfferProjects.includes(event.project.id)) {
96
+ aggregateOffer = yield aggregateOfferByEvent({
97
+ aggregateDate: now,
98
+ event: Object.assign(Object.assign({}, event), { maximumAttendeeCapacity,
99
+ remainingAttendeeCapacity }),
100
+ screeningRoom: screeningRoom
101
+ })(repos);
102
+ debug('offers aggregated', aggregateOffer);
103
+ }
110
104
  // 値がundefinedの場合に更新しないように注意
111
105
  const update = {
112
- $set: Object.assign(Object.assign(Object.assign(Object.assign({ updatedAt: new Date(), // $setオブジェクトが空だとMongoエラーになるので
113
- // aggregateEntranceGate,
114
- aggregateReservation,
115
- aggregateOffer }, (maximumAttendeeCapacity !== undefined) ? { maximumAttendeeCapacity: maximumAttendeeCapacity } : undefined), (remainingAttendeeCapacity !== undefined) ? { remainingAttendeeCapacity: remainingAttendeeCapacity } : undefined), (aggregateReservation.checkInCount !== undefined) ? { checkInCount: aggregateReservation.checkInCount } : undefined), (aggregateReservation.attendeeCount !== undefined) ? { attendeeCount: aggregateReservation.attendeeCount } : undefined),
116
- $unset: Object.assign(Object.assign({ noExistingAttributeName: 1 }, (maximumAttendeeCapacity === undefined) ? { maximumAttendeeCapacity: '' } : undefined), (remainingAttendeeCapacity === undefined) ? { remainingAttendeeCapacity: '' } : undefined)
106
+ $set: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ updatedAt: new Date(), // $setオブジェクトが空だとMongoエラーになるので
107
+ aggregateReservation }, (typeof (aggregateOffer === null || aggregateOffer === void 0 ? void 0 : aggregateOffer.typeOf) === 'string') ? { aggregateOffer: aggregateOffer } : undefined), (maximumAttendeeCapacity !== undefined) ? { maximumAttendeeCapacity: maximumAttendeeCapacity } : undefined), (remainingAttendeeCapacity !== undefined) ? { remainingAttendeeCapacity: remainingAttendeeCapacity } : undefined), (aggregateReservation.checkInCount !== undefined) ? { checkInCount: aggregateReservation.checkInCount } : undefined), (aggregateReservation.attendeeCount !== undefined) ? { attendeeCount: aggregateReservation.attendeeCount } : undefined),
108
+ $unset: Object.assign(Object.assign(Object.assign({ noExistingAttributeName: 1 }, (typeof (aggregateOffer === null || aggregateOffer === void 0 ? void 0 : aggregateOffer.typeOf) !== 'string') ? { aggregateOffer: '' } : undefined), (maximumAttendeeCapacity === undefined) ? { maximumAttendeeCapacity: '' } : undefined), (remainingAttendeeCapacity === undefined) ? { remainingAttendeeCapacity: '' } : undefined)
117
109
  };
118
110
  debug('update:', update);
119
111
  // 保管
@@ -125,37 +117,6 @@ function aggregateByEvent(params) {
125
117
  });
126
118
  }
127
119
  exports.aggregateByEvent = aggregateByEvent;
128
- /**
129
- * イベントロケーション取得
130
- * NotFoundエラーをハンドリングする
131
- */
132
- // function findLocation(params: {
133
- // event: factory.event.screeningEvent.IEvent | factory.event.event.IEvent;
134
- // }) {
135
- // return async (repos: {
136
- // place: PlaceRepo;
137
- // }): Promise<factory.place.movieTheater.IPlace | undefined> => {
138
- // let movieTheater: factory.place.movieTheater.IPlace | undefined;
139
- // try {
140
- // if (params.event.typeOf === factory.eventType.ScreeningEvent) {
141
- // movieTheater = await repos.place.findById({ id: params.event.superEvent.location.id });
142
- // } else {
143
- // const movieTheaterId: string =
144
- // String(params.event.offers?.itemOffered.availableChannel.serviceLocation.containedInPlace.id);
145
- // movieTheater = await repos.place.findById({ id: movieTheaterId });
146
- // }
147
- // } catch (error) {
148
- // let throwsError = true;
149
- // if (error instanceof factory.errors.NotFound) {
150
- // throwsError = false;
151
- // }
152
- // if (throwsError) {
153
- // throw error;
154
- // }
155
- // }
156
- // return movieTheater;
157
- // };
158
- // }
159
120
  /**
160
121
  * 集計後アクション
161
122
  */
@@ -208,11 +169,12 @@ function findOffers(params) {
208
169
  if (typeof ((_a = eventOffers === null || eventOffers === void 0 ? void 0 : eventOffers.itemOffered) === null || _a === void 0 ? void 0 : _a.id) === 'string') {
209
170
  const eventService = yield repos.product.findById({ id: eventOffers.itemOffered.id });
210
171
  if (typeof ((_b = eventService.hasOfferCatalog) === null || _b === void 0 ? void 0 : _b.id) === 'string') {
211
- availableOffers = yield repos.offer.findOffersByOfferCatalogId({
172
+ const findOffersByOfferCatalogIdResult = yield repos.offer.findOffersByOfferCatalogId({
212
173
  offerCatalog: { id: eventService.hasOfferCatalog.id },
213
174
  excludeAppliesToMovieTicket: false,
214
175
  sort: false // ソート不要(2023-01-27~)
215
176
  });
177
+ availableOffers = findOffersByOfferCatalogIdResult.offers;
216
178
  }
217
179
  }
218
180
  else {
@@ -91,11 +91,12 @@ function findOffers(params) {
91
91
  if (typeof ((_a = eventOffers === null || eventOffers === void 0 ? void 0 : eventOffers.itemOffered) === null || _a === void 0 ? void 0 : _a.id) === 'string') {
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
- availableOffers = yield repos.offer.findOffersByOfferCatalogId({
94
+ const findOffersByOfferCatalogIdResult = yield repos.offer.findOffersByOfferCatalogId({
95
95
  offerCatalog: { id: eventService.hasOfferCatalog.id },
96
96
  excludeAppliesToMovieTicket: false,
97
97
  sort: false // ソート不要(2023-01-27~)
98
98
  });
99
+ availableOffers = findOffersByOfferCatalogIdResult.offers;
99
100
  }
100
101
  }
101
102
  else {
@@ -118,6 +118,7 @@ function addReservations(params) {
118
118
  // 対応アプリケーション条件追加(2023-01-27~)
119
119
  store: { id: (_a = params.availableAtOrFrom) === null || _a === void 0 ? void 0 : _a.id },
120
120
  sort: false,
121
+ addSortIndex: false,
121
122
  validateOfferRateLimit: true
122
123
  })(repos);
123
124
  ticketOffers = searchEventTicketOffersResult.ticketOffers;
@@ -225,6 +225,7 @@ function validateAcceptedOffers(params) {
225
225
  event: { id: params.event.id },
226
226
  store: params.store,
227
227
  sort: false,
228
+ addSortIndex: false,
228
229
  validateOfferRateLimit: true
229
230
  })(repos);
230
231
  // 利用可能なチケットオファーであれば受け入れる
@@ -13,6 +13,9 @@ interface ISearchEventTicketOffersRepos {
13
13
  }
14
14
  declare type ISearchEventTicketOffersOperation<T> = (repos: ISearchEventTicketOffersRepos) => Promise<T>;
15
15
  declare type IAcceptedPaymentMethod = factory.paymentMethod.paymentCard.movieTicket.IMovieTicket;
16
+ declare type ITicketOfferWithSortIndex = factory.product.ITicketOffer & {
17
+ sortIndex?: number;
18
+ };
16
19
  /**
17
20
  * 興行オファー検索
18
21
  */
@@ -73,9 +76,10 @@ declare function searchEventTicketOffers(params: {
73
76
  limit?: number;
74
77
  page?: number;
75
78
  sort: boolean;
79
+ addSortIndex: boolean;
76
80
  validateOfferRateLimit: boolean;
77
81
  }): ISearchEventTicketOffersOperation<{
78
- ticketOffers: factory.product.ITicketOffer[];
82
+ ticketOffers: ITicketOfferWithSortIndex[];
79
83
  unitPriceOffers: factory.unitPriceOffer.IUnitPriceOffer[];
80
84
  }>;
81
85
  export { searchEventTicketOffers };
@@ -28,19 +28,21 @@ function searchTransportationEventTicketOffers(params) {
28
28
  // 上映方式がなければMovieTicket除外(2023-02-21~)
29
29
  const excludeAppliesToMovieTicket = videoFormatTypes.length === 0;
30
30
  let availableOffers = [];
31
+ let sortedOfferIds = [];
31
32
  // 興行設定があれば興行のカタログを参照する(2022-08-31~)
32
33
  const eventOffers = screeningEvent.offers;
33
34
  if (typeof ((_a = eventOffers === null || eventOffers === void 0 ? void 0 : eventOffers.itemOffered) === null || _a === void 0 ? void 0 : _a.id) === 'string') {
34
35
  const transportation = yield repos.product.findById({ id: eventOffers.itemOffered.id });
35
36
  if (typeof ((_b = transportation.hasOfferCatalog) === null || _b === void 0 ? void 0 : _b.id) === 'string') {
36
- availableOffers = yield repos.offer.findOffersByOfferCatalogId({
37
- ids: params.ids,
38
- offerCatalog: { id: transportation.hasOfferCatalog.id },
39
- availableAtOrFrom: { id: (_c = params.store) === null || _c === void 0 ? void 0 : _c.id },
40
- unacceptedPaymentMethod,
41
- excludeAppliesToMovieTicket,
42
- sort: params.sort
43
- });
37
+ const findOffersByOfferCatalogIdResult = yield repos.offer.findOffersByOfferCatalogId(Object.assign({ ids: params.ids, offerCatalog: { id: transportation.hasOfferCatalog.id }, availableAtOrFrom: { id: (_c = params.store) === null || _c === void 0 ? void 0 : _c.id }, unacceptedPaymentMethod,
38
+ excludeAppliesToMovieTicket, sort: params.sort }, (!params.sort)
39
+ ? {
40
+ limit: params.limit,
41
+ page: params.page
42
+ }
43
+ : undefined));
44
+ availableOffers = findOffersByOfferCatalogIdResult.offers;
45
+ sortedOfferIds = findOffersByOfferCatalogIdResult.sortedOfferIds;
44
46
  }
45
47
  }
46
48
  else {
@@ -80,19 +82,26 @@ function searchTransportationEventTicketOffers(params) {
80
82
  }
81
83
  });
82
84
  // paging処理を追加(2023-02-21~)
83
- if (typeof params.limit === 'number' && typeof params.page === 'number') {
84
- const start = params.limit * (params.page - 1);
85
- const end = params.limit * params.page;
86
- availableOffers = availableOffers.slice(start, end);
85
+ if (params.sort) {
86
+ if (typeof params.limit === 'number' && typeof params.page === 'number') {
87
+ const start = params.limit * (params.page - 1);
88
+ const end = params.limit * params.page;
89
+ availableOffers = availableOffers.slice(start, end);
90
+ }
87
91
  }
88
92
  let offers4event = availableOffers.map((availableOffer) => {
93
+ let sortIndex;
94
+ if (params.addSortIndex) {
95
+ sortIndex = sortedOfferIds.indexOf(String(availableOffer.id));
96
+ }
89
97
  return (0, factory_1.createCompoundPriceSpec4event)({
90
98
  eligibleQuantity: eventOffers.eligibleQuantity,
91
99
  offer: availableOffer,
92
100
  videoFormatChargeSpecifications,
93
101
  soundFormatChargeSpecifications,
94
102
  movieTicketTypeChargeSpecs,
95
- videoFormatTypes
103
+ videoFormatTypes,
104
+ sortIndex
96
105
  });
97
106
  });
98
107
  if (params.validateOfferRateLimit) {
@@ -141,19 +150,21 @@ function searchScreeningEventTicketOffers(params) {
141
150
  // 上映方式がなければMovieTicket除外(2023-02-21~)
142
151
  const excludeAppliesToMovieTicket = videoFormatTypes.length === 0;
143
152
  let availableOffers = [];
153
+ let sortedOfferIds = [];
144
154
  // 興行設定があれば興行のカタログを参照する(2022-08-31~)
145
155
  const eventOffers = screeningEvent.offers;
146
156
  if (typeof ((_a = eventOffers === null || eventOffers === void 0 ? void 0 : eventOffers.itemOffered) === null || _a === void 0 ? void 0 : _a.id) === 'string') {
147
157
  const eventService = yield repos.product.findById({ id: eventOffers.itemOffered.id });
148
158
  if (typeof ((_b = eventService.hasOfferCatalog) === null || _b === void 0 ? void 0 : _b.id) === 'string') {
149
- availableOffers = yield repos.offer.findOffersByOfferCatalogId({
150
- ids: params.ids,
151
- offerCatalog: { id: eventService.hasOfferCatalog.id },
152
- availableAtOrFrom: { id: (_c = params.store) === null || _c === void 0 ? void 0 : _c.id },
153
- unacceptedPaymentMethod,
154
- excludeAppliesToMovieTicket,
155
- sort: params.sort
156
- });
159
+ const findOffersByOfferCatalogIdResult = yield repos.offer.findOffersByOfferCatalogId(Object.assign({ ids: params.ids, offerCatalog: { id: eventService.hasOfferCatalog.id }, availableAtOrFrom: { id: (_c = params.store) === null || _c === void 0 ? void 0 : _c.id }, unacceptedPaymentMethod,
160
+ excludeAppliesToMovieTicket, sort: params.sort }, (!params.sort)
161
+ ? {
162
+ limit: params.limit,
163
+ page: params.page
164
+ }
165
+ : undefined));
166
+ availableOffers = findOffersByOfferCatalogIdResult.offers;
167
+ sortedOfferIds = findOffersByOfferCatalogIdResult.sortedOfferIds;
157
168
  }
158
169
  }
159
170
  else {
@@ -212,19 +223,26 @@ function searchScreeningEventTicketOffers(params) {
212
223
  });
213
224
  }
214
225
  // paging処理を追加(2023-02-21~)
215
- if (typeof params.limit === 'number' && typeof params.page === 'number') {
216
- const start = params.limit * (params.page - 1);
217
- const end = params.limit * params.page;
218
- availableOffers = availableOffers.slice(start, end);
226
+ if (params.sort) {
227
+ if (typeof params.limit === 'number' && typeof params.page === 'number') {
228
+ const start = params.limit * (params.page - 1);
229
+ const end = params.limit * params.page;
230
+ availableOffers = availableOffers.slice(start, end);
231
+ }
219
232
  }
220
233
  let offers4event = availableOffers.map((availableOffer) => {
234
+ let sortIndex;
235
+ if (params.addSortIndex) {
236
+ sortIndex = sortedOfferIds.indexOf(String(availableOffer.id));
237
+ }
221
238
  return (0, factory_1.createCompoundPriceSpec4event)({
222
239
  eligibleQuantity: eventOffers.eligibleQuantity,
223
240
  offer: availableOffer,
224
241
  videoFormatChargeSpecifications,
225
242
  soundFormatChargeSpecifications,
226
243
  movieTicketTypeChargeSpecs,
227
- videoFormatTypes
244
+ videoFormatTypes,
245
+ sortIndex
228
246
  });
229
247
  });
230
248
  if (params.validateOfferRateLimit) {
@@ -344,12 +362,13 @@ function searchAddOns(params) {
344
362
  const productWithAddOns = yield repos.product.findById({ id: productId });
345
363
  const offerCatalogId = (_b = productWithAddOns.hasOfferCatalog) === null || _b === void 0 ? void 0 : _b.id;
346
364
  if (typeof offerCatalogId === 'string') {
347
- offers = yield repos.offer.findOffersByOfferCatalogId({
365
+ const findOffersByOfferCatalogIdResult = yield repos.offer.findOffersByOfferCatalogId({
348
366
  offerCatalog: { id: offerCatalogId },
349
367
  availableAtOrFrom: { id: (_c = params.store) === null || _c === void 0 ? void 0 : _c.id },
350
368
  excludeAppliesToMovieTicket: false,
351
369
  sort: true
352
370
  });
371
+ offers = findOffersByOfferCatalogIdResult.offers;
353
372
  offers = offers.map((o) => {
354
373
  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: {
355
374
  description: productWithAddOns.description,
@@ -400,6 +419,7 @@ function searchEventTicketOffers(params) {
400
419
  limit: params.limit,
401
420
  page: params.page,
402
421
  sort: params.sort,
422
+ addSortIndex: params.addSortIndex,
403
423
  validateOfferRateLimit: params.validateOfferRateLimit
404
424
  })(repos);
405
425
  offers = searchOffersResult.ticketOffers;
@@ -413,6 +433,7 @@ function searchEventTicketOffers(params) {
413
433
  limit: params.limit,
414
434
  page: params.page,
415
435
  sort: params.sort,
436
+ addSortIndex: params.addSortIndex,
416
437
  validateOfferRateLimit: params.validateOfferRateLimit
417
438
  })(repos);
418
439
  offers = searchOffersResult.ticketOffers;
@@ -8,5 +8,8 @@ declare function createCompoundPriceSpec4event(params: {
8
8
  videoFormatChargeSpecifications: ICategoryCodeChargeSpecification[];
9
9
  soundFormatChargeSpecifications: ICategoryCodeChargeSpecification[];
10
10
  videoFormatTypes: string[];
11
- }): factory.product.ITicketOffer;
11
+ sortIndex?: number;
12
+ }): factory.product.ITicketOffer & {
13
+ sortIndex?: number;
14
+ };
12
15
  export { createCompoundPriceSpec4event };
@@ -104,6 +104,6 @@ function createCompoundPriceSpec4event(params) {
104
104
  };
105
105
  // 不要な属性を除外(2022-11-07~)
106
106
  const _b = params.offer, { project } = _b, unitOfferFields4ticketOffer = __rest(_b, ["project"]);
107
- return Object.assign(Object.assign({}, unitOfferFields4ticketOffer), { eligibleQuantity: params.eligibleQuantity, priceSpecification: compoundPriceSpecification });
107
+ return Object.assign(Object.assign(Object.assign({}, unitOfferFields4ticketOffer), { eligibleQuantity: params.eligibleQuantity, priceSpecification: compoundPriceSpecification }), (typeof params.sortIndex === 'number') ? { sortIndex: params.sortIndex } : undefined);
108
108
  }
109
109
  exports.createCompoundPriceSpec4event = createCompoundPriceSpec4event;
@@ -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({
26
+ const { offers } = yield repos.offer.findOffersByOfferCatalogId({
27
27
  offerCatalog: { id: offerCatalogId },
28
28
  excludeAppliesToMovieTicket: false,
29
29
  sort: params.sort
@@ -24,6 +24,8 @@ export declare type ISettings = factory.project.ISettings & {
24
24
  useEventWorkPerformed: boolean;
25
25
  useOffersAppliedToMovieTicketWithoutChargeSpecification: boolean;
26
26
  useAggregateEntranceGateProjects: string[];
27
+ useAggregateOfferProjects: string[];
28
+ useOfferRateLimitProjects: string[];
27
29
  };
28
30
  export declare const DEFAULT_PAYMENT_METHOD_TYPE_FOR_CREDIT_CARD: string;
29
31
  export declare const USE_ASSET_TRANSACTION_SYNC_PROCESSING: boolean;
@@ -96,4 +96,8 @@ exports.settings = Object.assign(Object.assign({ transactionWebhookUrls, onOrder
96
96
  ? { maxNumCreditCardPaymentMethod: MAX_NUM_CREDIT_CARD_PAYMENT_METHOD }
97
97
  : undefined), { useEventWorkPerformed: process.env.USE_EVENT_WORK_PERFORMED === '1', useOffersAppliedToMovieTicketWithoutChargeSpecification: process.env.USE_OFFERS_APPLIED_TO_MOVIE_TICKET_WITHOUT_PRICE_SPEC === '1', useAggregateEntranceGateProjects: (typeof process.env.USE_AGGREGATE_ENTRANCE_GATE_PROJECTS === 'string')
98
98
  ? process.env.USE_AGGREGATE_ENTRANCE_GATE_PROJECTS.split(',')
99
+ : [], useAggregateOfferProjects: (typeof process.env.USE_AGGREGATE_OFFER_PROJECTS === 'string')
100
+ ? process.env.USE_AGGREGATE_OFFER_PROJECTS.split(',')
101
+ : [], useOfferRateLimitProjects: (typeof process.env.USE_OFFER_RATE_LIMIT_PROJECTS === 'string')
102
+ ? process.env.USE_OFFER_RATE_LIMIT_PROJECTS.split(',')
99
103
  : [] });
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.4.0-alpha.13"
123
+ "version": "20.4.0-alpha.15"
124
124
  }