@chevre/domain 20.4.0-alpha.21 → 20.4.0-alpha.23

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.
@@ -0,0 +1,22 @@
1
+ // tslint:disable:no-console
2
+ import * as mongoose from 'mongoose';
3
+
4
+ import { chevre } from '../../../lib/index';
5
+
6
+ async function main() {
7
+ await mongoose.connect(<string>process.env.MONGOLAB_URI);
8
+
9
+ const taskRepo = new chevre.repository.Task(mongoose.connection);
10
+
11
+ const tasks = await taskRepo.search({
12
+ limit: 100,
13
+ page: 1,
14
+ id: { $eq: '63b7a54d8ba861284895937f' }
15
+ });
16
+ console.log(tasks);
17
+ console.log(tasks.length);
18
+ }
19
+
20
+ main()
21
+ .then(console.log)
22
+ .catch(console.error);
@@ -29,9 +29,13 @@ class MongoRepository {
29
29
  }
30
30
  // tslint:disable-next-line:max-func-body-length
31
31
  static CREATE_MONGO_CONDITIONS(params) {
32
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
32
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
33
33
  const andConditions = [];
34
- const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
34
+ const idEq = (_a = params.id) === null || _a === void 0 ? void 0 : _a.$eq;
35
+ if (typeof idEq === 'string') {
36
+ andConditions.push({ _id: { $eq: idEq } });
37
+ }
38
+ const projectIdEq = (_c = (_b = params.project) === null || _b === void 0 ? void 0 : _b.id) === null || _c === void 0 ? void 0 : _c.$eq;
35
39
  if (typeof projectIdEq === 'string') {
36
40
  andConditions.push({ 'project.id': { $eq: projectIdEq } });
37
41
  }
@@ -39,11 +43,11 @@ class MongoRepository {
39
43
  andConditions.push({ name: { $eq: params.name } });
40
44
  }
41
45
  else {
42
- const nameIn = (_c = params.name) === null || _c === void 0 ? void 0 : _c.$in;
46
+ const nameIn = (_d = params.name) === null || _d === void 0 ? void 0 : _d.$in;
43
47
  if (Array.isArray(nameIn)) {
44
48
  andConditions.push({ name: { $in: nameIn } });
45
49
  }
46
- const nameNin = (_d = params.name) === null || _d === void 0 ? void 0 : _d.$nin;
50
+ const nameNin = (_e = params.name) === null || _e === void 0 ? void 0 : _e.$nin;
47
51
  if (Array.isArray(nameNin)) {
48
52
  andConditions.push({ name: { $nin: nameNin } });
49
53
  }
@@ -89,7 +93,7 @@ class MongoRepository {
89
93
  }
90
94
  });
91
95
  }
92
- const dateAbortedGte = (_e = params.dateAborted) === null || _e === void 0 ? void 0 : _e.$gte;
96
+ const dateAbortedGte = (_f = params.dateAborted) === null || _f === void 0 ? void 0 : _f.$gte;
93
97
  if (dateAbortedGte instanceof Date) {
94
98
  andConditions.push({
95
99
  dateAborted: {
@@ -98,7 +102,7 @@ class MongoRepository {
98
102
  }
99
103
  });
100
104
  }
101
- const dateAbortedLte = (_f = params.dateAborted) === null || _f === void 0 ? void 0 : _f.$lte;
105
+ const dateAbortedLte = (_g = params.dateAborted) === null || _g === void 0 ? void 0 : _g.$lte;
102
106
  if (dateAbortedLte instanceof Date) {
103
107
  andConditions.push({
104
108
  dateAborted: {
@@ -107,7 +111,7 @@ class MongoRepository {
107
111
  }
108
112
  });
109
113
  }
110
- const objectTransactionNumberEq = (_j = (_h = (_g = params.data) === null || _g === void 0 ? void 0 : _g.object) === null || _h === void 0 ? void 0 : _h.transactionNumber) === null || _j === void 0 ? void 0 : _j.$eq;
114
+ const objectTransactionNumberEq = (_k = (_j = (_h = params.data) === null || _h === void 0 ? void 0 : _h.object) === null || _j === void 0 ? void 0 : _j.transactionNumber) === null || _k === void 0 ? void 0 : _k.$eq;
111
115
  if (typeof objectTransactionNumberEq === 'string') {
112
116
  andConditions.push({
113
117
  'data.object.transactionNumber': {
@@ -116,7 +120,7 @@ class MongoRepository {
116
120
  }
117
121
  });
118
122
  }
119
- const objectPurposeIdEq = (_m = (_l = (_k = params.data) === null || _k === void 0 ? void 0 : _k.purpose) === null || _l === void 0 ? void 0 : _l.id) === null || _m === void 0 ? void 0 : _m.$eq;
123
+ const objectPurposeIdEq = (_o = (_m = (_l = params.data) === null || _l === void 0 ? void 0 : _l.purpose) === null || _m === void 0 ? void 0 : _m.id) === null || _o === void 0 ? void 0 : _o.$eq;
120
124
  if (typeof objectPurposeIdEq === 'string') {
121
125
  andConditions.push({
122
126
  'data.purpose.id': {
@@ -125,7 +129,7 @@ class MongoRepository {
125
129
  }
126
130
  });
127
131
  }
128
- const objectPurposeOrderNumberEq = (_q = (_p = (_o = params.data) === null || _o === void 0 ? void 0 : _o.purpose) === null || _p === void 0 ? void 0 : _p.orderNumber) === null || _q === void 0 ? void 0 : _q.$eq;
132
+ const objectPurposeOrderNumberEq = (_r = (_q = (_p = params.data) === null || _p === void 0 ? void 0 : _p.purpose) === null || _q === void 0 ? void 0 : _q.orderNumber) === null || _r === void 0 ? void 0 : _r.$eq;
129
133
  if (typeof objectPurposeOrderNumberEq === 'string') {
130
134
  andConditions.push({
131
135
  'data.purpose.orderNumber': {
@@ -12,242 +12,100 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.searchEventTicketOffers = void 0;
13
13
  const moment = require("moment-timezone");
14
14
  const factory = require("../../../factory");
15
- const settings_1 = require("../../../settings");
16
15
  const factory_1 = require("../factory");
17
- /**
18
- * 旅客オファー検索
19
- */
20
- function searchTransportationEventTicketOffers(params) {
21
- // tslint:disable-next-line:max-func-body-length
16
+ function searchTicketOffersByItemOffered(params) {
22
17
  return (repos) => __awaiter(this, void 0, void 0, function* () {
23
18
  var _a, _b, _c, _d;
24
- const screeningEvent = params.event;
25
- const soundFormatTypes = [];
26
- const videoFormatTypes = [];
27
- const unacceptedPaymentMethod = getUnacceptedPaymentMethodByEvent({ event: screeningEvent });
28
- // 上映方式がなければMovieTicket除外(2023-02-21~)
29
- const excludeAppliesToMovieTicket = videoFormatTypes.length === 0;
30
- let availableOffers = [];
31
- let sortedOfferIds = [];
32
- // 興行設定があれば興行のカタログを参照する(2022-08-31~)
33
- const eventOffers = screeningEvent.offers;
34
- if (typeof ((_a = eventOffers === null || eventOffers === void 0 ? void 0 : eventOffers.itemOffered) === null || _a === void 0 ? void 0 : _a.id) === 'string') {
35
- const transportation = yield repos.product.findById({ id: eventOffers.itemOffered.id });
36
- if (typeof ((_b = transportation.hasOfferCatalog) === null || _b === void 0 ? void 0 : _b.id) === 'string') {
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, onlyValid: params.onlyValid === true, 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;
19
+ let catalogId;
20
+ if (typeof ((_a = params.itemOffered) === null || _a === void 0 ? void 0 : _a.id) === 'string') {
21
+ const eventService = yield repos.product.findById({ id: (_b = params.itemOffered) === null || _b === void 0 ? void 0 : _b.id });
22
+ if (typeof ((_c = eventService.hasOfferCatalog) === null || _c === void 0 ? void 0 : _c.id) === 'string') {
23
+ catalogId = eventService.hasOfferCatalog.id;
46
24
  }
47
25
  }
48
- else {
49
- // hasOfferCatalog参照廃止(2022-09-02~)
50
- throw new factory.errors.NotFound('event.offers.itemOffered.id');
26
+ if (typeof catalogId !== 'string') {
27
+ throw new factory.errors.NotFound('itemOffered.hasOfferCatalog');
51
28
  }
52
- const { soundFormatChargeSpecifications, videoFormatChargeSpecifications, movieTicketTypeChargeSpecs } = yield searchPriceSpecs4event({ project: { id: screeningEvent.project.id }, soundFormatTypes, videoFormatTypes })(repos);
53
- // 適用決済カード条件がある場合、決済カード加算料金が存在しないオファーは除外する
54
- availableOffers = availableOffers.filter((o) => {
55
- var _a;
56
- // 複数決済カード対応(2022-07-26~)
57
- const priceSpecificationAppliesToMovieTicket = (_a = o.priceSpecification) === null || _a === void 0 ? void 0 : _a.appliesToMovieTicket;
58
- if (Array.isArray(priceSpecificationAppliesToMovieTicket)) {
59
- // 適用決済カード数が0であれば除外
60
- if (priceSpecificationAppliesToMovieTicket.length === 0) {
61
- return false;
62
- }
63
- // 上映方式がなければ除外(2022-11-03~)
64
- // if (videoFormatTypes.length === 0) {
65
- // return false;
66
- // }
67
- return priceSpecificationAppliesToMovieTicket.every((appliesToMovieTicket) => {
68
- // すべての上映方式について検証する(2022-10-29~)
69
- return videoFormatTypes.every((videoFormat) => {
70
- return movieTicketTypeChargeSpecs.some((s) => {
71
- var _a, _b, _c, _d;
72
- return ((_b = (_a = s.appliesToMovieTicket) === null || _a === void 0 ? void 0 : _a.serviceOutput) === null || _b === void 0 ? void 0 : _b.typeOf) === ((_c = appliesToMovieTicket.serviceOutput) === null || _c === void 0 ? void 0 : _c.typeOf)
73
- && ((_d = s.appliesToMovieTicket) === null || _d === void 0 ? void 0 : _d.serviceType) === appliesToMovieTicket.serviceType
74
- && s.appliesToVideoFormat === videoFormat;
75
- });
76
- });
77
- });
78
- }
79
- else {
80
- // Arrayでないケースは廃止(2022-09-10~)
81
- return true;
29
+ const findOffersByOfferCatalogIdResult = yield repos.offer.findOffersByOfferCatalogId(Object.assign({ ids: params.ids, offerCatalog: { id: catalogId }, availableAtOrFrom: { id: (_d = params.store) === null || _d === void 0 ? void 0 : _d.id }, unacceptedPaymentMethod: params.unacceptedPaymentMethod, excludeAppliesToMovieTicket: params.excludeAppliesToMovieTicket, onlyValid: params.onlyValid === true, sort: params.sort }, (!params.sort)
30
+ ? {
31
+ limit: params.limit,
32
+ page: params.page
82
33
  }
83
- });
84
- let offers4event = availableOffers.map((availableOffer) => {
85
- let sortIndex;
86
- if (params.addSortIndex) {
87
- sortIndex = sortedOfferIds.indexOf(String(availableOffer.id));
88
- }
89
- return (0, factory_1.createCompoundPriceSpec4event)({
90
- eligibleQuantity: eventOffers.eligibleQuantity,
91
- offer: availableOffer,
92
- videoFormatChargeSpecifications,
93
- soundFormatChargeSpecifications,
94
- movieTicketTypeChargeSpecs,
95
- videoFormatTypes,
96
- sortIndex
97
- });
98
- });
99
- if (params.validateOfferRateLimit) {
100
- // レート制限を確認
101
- offers4event = yield Promise.all(offers4event.map((offer) => __awaiter(this, void 0, void 0, function* () {
102
- return checkAvailability({ event: screeningEvent, offer })(repos);
103
- })));
104
- }
105
- // アドオン設定があれば、プロダクトオファーを検索
106
- for (const offer of offers4event) {
107
- const offerAddOn = [];
108
- if (Array.isArray(offer.addOn)) {
109
- for (const addOn of offer.addOn) {
110
- const productId = (_d = addOn.itemOffered) === null || _d === void 0 ? void 0 : _d.id;
111
- if (typeof productId === 'string') {
112
- const productOffers = yield searchAddOns({
113
- product: { id: productId },
114
- store: params.store
115
- })(repos);
116
- offerAddOn.push(...productOffers);
117
- }
118
- }
119
- }
120
- offer.addOn = offerAddOn;
121
- }
122
- return {
123
- ticketOffers: offers4event,
124
- unitPriceOffers: availableOffers
125
- };
34
+ : undefined));
35
+ const availableOffers = findOffersByOfferCatalogIdResult.offers;
36
+ const sortedOfferIds = findOffersByOfferCatalogIdResult.sortedOfferIds;
37
+ return { availableOffers, sortedOfferIds };
126
38
  });
127
39
  }
128
40
  /**
129
- * 興行オファー全検索
41
+ * イベントから興行(旅客)オファーを検索する
130
42
  */
131
- function searchScreeningEventTicketOffers(params) {
132
- // tslint:disable-next-line:max-func-body-length
43
+ function searchEventTicketOffersByEvent(params) {
133
44
  return (repos) => __awaiter(this, void 0, void 0, function* () {
134
- var _a, _b, _c, _d;
135
- // イベント取得属性最適化(2023-01-23~)
136
- const screeningEvent = params.event;
137
- // 取得属性最適化(2023-01-25~)
138
- const superEvent = yield repos.event.findById({ id: screeningEvent.superEvent.id }, { soundFormat: 1, videoFormat: 1 });
139
- const soundFormatTypes = (Array.isArray(superEvent.soundFormat)) ? superEvent.soundFormat.map((f) => f.typeOf) : [];
140
- const videoFormatTypes = (Array.isArray(superEvent.videoFormat)) ? superEvent.videoFormat.map((f) => f.typeOf) : [];
141
- const unacceptedPaymentMethod = getUnacceptedPaymentMethodByEvent({ event: screeningEvent });
45
+ var _a, _b;
46
+ const event = params.event;
47
+ let soundFormatTypes = [];
48
+ let videoFormatTypes = [];
49
+ if (event.typeOf === factory.eventType.ScreeningEvent) {
50
+ // 取得属性最適化(2023-01-25~)
51
+ const superEvent = yield repos.event.findById({ id: event.superEvent.id }, { soundFormat: 1, videoFormat: 1 });
52
+ soundFormatTypes = (Array.isArray(superEvent.soundFormat)) ? superEvent.soundFormat.map((f) => f.typeOf) : [];
53
+ videoFormatTypes = (Array.isArray(superEvent.videoFormat)) ? superEvent.videoFormat.map((f) => f.typeOf) : [];
54
+ }
55
+ const unacceptedPaymentMethod = getUnacceptedPaymentMethodByEvent({ event });
142
56
  // 上映方式がなければMovieTicket除外(2023-02-21~)
143
57
  const excludeAppliesToMovieTicket = videoFormatTypes.length === 0;
144
- let availableOffers = [];
145
- let sortedOfferIds = [];
146
58
  // 興行設定があれば興行のカタログを参照する(2022-08-31~)
147
- const eventOffers = screeningEvent.offers;
148
- if (typeof ((_a = eventOffers === null || eventOffers === void 0 ? void 0 : eventOffers.itemOffered) === null || _a === void 0 ? void 0 : _a.id) === 'string') {
149
- const eventService = yield repos.product.findById({ id: eventOffers.itemOffered.id });
150
- if (typeof ((_b = eventService.hasOfferCatalog) === null || _b === void 0 ? void 0 : _b.id) === 'string') {
151
- 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,
152
- excludeAppliesToMovieTicket, onlyValid: params.onlyValid === true, sort: params.sort }, (!params.sort)
153
- ? {
154
- limit: params.limit,
155
- page: params.page
156
- }
157
- : undefined));
158
- availableOffers = findOffersByOfferCatalogIdResult.offers;
159
- sortedOfferIds = findOffersByOfferCatalogIdResult.sortedOfferIds;
160
- }
161
- }
162
- else {
163
- // hasOfferCatalog参照廃止(2022-09-02~)
164
- throw new factory.errors.NotFound('event.offers.itemOffered.id');
165
- }
166
- const { soundFormatChargeSpecifications, videoFormatChargeSpecifications, movieTicketTypeChargeSpecs } = yield searchPriceSpecs4event({ project: { id: screeningEvent.project.id }, soundFormatTypes, videoFormatTypes })(repos);
167
- // 不許可決済方法があれば、該当オファーを除外
168
- // Mongoオファー検索条件へ移行(2023-02-21~)
169
- // if (Array.isArray(unacceptedPaymentMethod) && unacceptedPaymentMethod.length > 0) {
170
- // availableOffers = availableOffers.filter((o) => {
171
- // // 複数決済カード対応(2022-07-11~)
172
- // const priceSpecificationAppliesToMovieTicket = o.priceSpecification?.appliesToMovieTicket;
173
- // if (Array.isArray(priceSpecificationAppliesToMovieTicket)) {
174
- // return priceSpecificationAppliesToMovieTicket.every((appliesToMovieTicket) => {
175
- // return !unacceptedPaymentMethod.includes(appliesToMovieTicket.serviceOutput.typeOf);
176
- // });
177
- // } else {
178
- // // Arrayでないケースは廃止(2022-09-10~)
179
- // return true;
180
- // }
181
- // });
182
- // }
59
+ const eventOffers = event.offers;
60
+ const { availableOffers, sortedOfferIds } = yield searchTicketOffersByItemOffered({
61
+ itemOffered: { id: (_a = eventOffers === null || eventOffers === void 0 ? void 0 : eventOffers.itemOffered) === null || _a === void 0 ? void 0 : _a.id },
62
+ ids: params.ids,
63
+ store: params.store,
64
+ limit: params.limit,
65
+ page: params.page,
66
+ sort: params.sort,
67
+ onlyValid: params.onlyValid,
68
+ unacceptedPaymentMethod,
69
+ excludeAppliesToMovieTicket
70
+ })(repos);
71
+ const { soundFormatChargeSpecifications, videoFormatChargeSpecifications, movieTicketTypeChargeSpecs } = yield searchPriceSpecs4event({ project: { id: event.project.id }, soundFormatTypes, videoFormatTypes })(repos);
183
72
  // 決済カード加算料金が存在しない場合自動補完する(2023-02-21~)
184
- if (!settings_1.settings.useOffersAppliedToMovieTicketWithoutChargeSpecification) {
185
- // 適用決済カード条件がある場合、決済カード加算料金が存在しないオファーは除外する
186
- availableOffers = availableOffers.filter((o) => {
187
- var _a;
188
- // 複数決済カード対応(2022-07-26~)
189
- const priceSpecificationAppliesToMovieTicket = (_a = o.priceSpecification) === null || _a === void 0 ? void 0 : _a.appliesToMovieTicket;
190
- if (Array.isArray(priceSpecificationAppliesToMovieTicket)) {
191
- // 適用決済カード数が0であれば除外
192
- if (priceSpecificationAppliesToMovieTicket.length === 0) {
193
- return false;
194
- }
195
- // 上映方式がなければ除外(2022-11-03~)
196
- // if (videoFormatTypes.length === 0) {
197
- // return false;
198
- // }
199
- return priceSpecificationAppliesToMovieTicket.every((appliesToMovieTicket) => {
200
- // すべての上映方式について検証する(2022-10-29~)
201
- return videoFormatTypes.every((videoFormat) => {
202
- return movieTicketTypeChargeSpecs.some((s) => {
203
- var _a, _b, _c, _d;
204
- return ((_b = (_a = s.appliesToMovieTicket) === null || _a === void 0 ? void 0 : _a.serviceOutput) === null || _b === void 0 ? void 0 : _b.typeOf) === ((_c = appliesToMovieTicket.serviceOutput) === null || _c === void 0 ? void 0 : _c.typeOf)
205
- && ((_d = s.appliesToMovieTicket) === null || _d === void 0 ? void 0 : _d.serviceType) === appliesToMovieTicket.serviceType
206
- && s.appliesToVideoFormat === videoFormat;
207
- });
208
- });
209
- });
210
- }
211
- else {
212
- // Arrayでないケースは廃止(2022-09-10~)
213
- return true;
214
- }
215
- });
216
- }
217
- let offers4event = availableOffers.map((availableOffer) => {
73
+ // if (!settings.useOffersAppliedToMovieTicketWithoutChargeSpecification) {
74
+ // }
75
+ const offers4event = [];
76
+ // 単価オファーから興行オファーを生成(順に処理)
77
+ for (const availableOffer of availableOffers) {
218
78
  let sortIndex;
219
79
  if (params.addSortIndex) {
220
80
  sortIndex = sortedOfferIds.indexOf(String(availableOffer.id));
221
81
  }
222
- return (0, factory_1.createCompoundPriceSpec4event)({
82
+ let availability;
83
+ if (params.validateOfferRateLimit) {
84
+ // レート制限を確認
85
+ availability = yield checkAvailability({ event, unitPriceOffer: availableOffer })(repos);
86
+ }
87
+ // アドオン設定があれば、プロダクトオファーを検索
88
+ const offerAddOn = [];
89
+ if (Array.isArray(availableOffer.addOn)) {
90
+ for (const addOn of availableOffer.addOn) {
91
+ const productId = (_b = addOn.itemOffered) === null || _b === void 0 ? void 0 : _b.id;
92
+ if (typeof productId === 'string') {
93
+ const productOffers = yield searchAddOns({ product: { id: productId }, onlyValid: params.onlyValid })(repos);
94
+ offerAddOn.push(...productOffers);
95
+ }
96
+ }
97
+ }
98
+ offers4event.push((0, factory_1.createCompoundPriceSpec4event)({
223
99
  eligibleQuantity: eventOffers.eligibleQuantity,
224
100
  offer: availableOffer,
225
101
  videoFormatChargeSpecifications,
226
102
  soundFormatChargeSpecifications,
227
103
  movieTicketTypeChargeSpecs,
228
104
  videoFormatTypes,
105
+ availability,
106
+ addOn: offerAddOn,
229
107
  sortIndex
230
- });
231
- });
232
- if (params.validateOfferRateLimit) {
233
- // レート制限を確認
234
- offers4event = yield Promise.all(offers4event.map((offer) => __awaiter(this, void 0, void 0, function* () {
235
- return checkAvailability({ event: screeningEvent, offer })(repos);
236
- })));
237
- }
238
- // アドオン設定があれば、プロダクトオファーを検索
239
- for (const offer of offers4event) {
240
- const offerAddOn = [];
241
- if (Array.isArray(offer.addOn)) {
242
- for (const addOn of offer.addOn) {
243
- const productId = (_d = addOn.itemOffered) === null || _d === void 0 ? void 0 : _d.id;
244
- if (typeof productId === 'string') {
245
- const productOffers = yield searchAddOns({ product: { id: productId } })(repos);
246
- offerAddOn.push(...productOffers);
247
- }
248
- }
249
- }
250
- offer.addOn = offerAddOn;
108
+ }));
251
109
  }
252
110
  return {
253
111
  ticketOffers: offers4event,
@@ -305,10 +163,11 @@ function searchPriceSpecs4event(params) {
305
163
  function checkAvailability(params) {
306
164
  return (repos) => __awaiter(this, void 0, void 0, function* () {
307
165
  var _a, _b;
308
- const offer4event = params.offer;
166
+ const unitPriceOffer = params.unitPriceOffer;
167
+ let availability;
309
168
  // レート制限を確認
310
- const scope = (_a = offer4event.validRateLimit) === null || _a === void 0 ? void 0 : _a.scope;
311
- const unitInSeconds = (_b = offer4event.validRateLimit) === null || _b === void 0 ? void 0 : _b.unitInSeconds;
169
+ const scope = (_a = unitPriceOffer.validRateLimit) === null || _a === void 0 ? void 0 : _a.scope;
170
+ const unitInSeconds = (_b = unitPriceOffer.validRateLimit) === null || _b === void 0 ? void 0 : _b.unitInSeconds;
312
171
  if (typeof scope === 'string' && typeof unitInSeconds === 'number') {
313
172
  const rateLimitKey = {
314
173
  reservedTicket: {
@@ -328,10 +187,10 @@ function checkAvailability(params) {
328
187
  const holder = yield repos.offerRateLimit.getHolder(rateLimitKey);
329
188
  // ロックされていればOutOfStock
330
189
  if (typeof holder === 'string' && holder.length > 0) {
331
- offer4event.availability = factory.itemAvailability.OutOfStock;
190
+ availability = factory.itemAvailability.OutOfStock;
332
191
  }
333
192
  }
334
- return offer4event;
193
+ return availability;
335
194
  });
336
195
  }
337
196
  /**
@@ -350,6 +209,7 @@ function searchAddOns(params) {
350
209
  offerCatalog: { id: offerCatalogId },
351
210
  availableAtOrFrom: { id: (_c = params.store) === null || _c === void 0 ? void 0 : _c.id },
352
211
  excludeAppliesToMovieTicket: false,
212
+ onlyValid: params.onlyValid === true,
353
213
  sort: true
354
214
  });
355
215
  offers = findOffersByOfferCatalogIdResult.offers;
@@ -372,15 +232,9 @@ function searchAddOns(params) {
372
232
  * 興行オファー検索
373
233
  */
374
234
  function searchEventTicketOffers(params) {
375
- // tslint:disable-next-line:max-func-body-length
376
235
  return (repos) => __awaiter(this, void 0, void 0, function* () {
377
- const now = moment();
378
- let event;
379
- // イベント取得属性最適化(2023-01-23~)
380
- // event = await repos.event.findById<factory.eventType.ScreeningEvent | factory.eventType.Event>({ id: params.event.id });
381
- event = yield repos.event.findMinimizedIndividualEventById({
382
- id: params.event.id
383
- });
236
+ // const now = moment();
237
+ const event = yield repos.event.findMinimizedIndividualEventById({ id: params.event.id });
384
238
  let offers;
385
239
  let unitPriceOffers;
386
240
  const eventOffers = event.offers;
@@ -394,95 +248,55 @@ function searchEventTicketOffers(params) {
394
248
  case factory.service.webAPI.Identifier.COA:
395
249
  throw new factory.errors.NotImplemented(`booking service '${eventOffers.offeredThrough.identifier}' not implemented`);
396
250
  default:
397
- // Chevreで券種オファーを検索
398
- if (event.typeOf === factory.eventType.ScreeningEvent) {
399
- const searchOffersResult = yield searchScreeningEventTicketOffers({
400
- ids: params.ids,
401
- event,
402
- store: params.store,
403
- limit: params.limit,
404
- page: params.page,
405
- sort: params.sort,
406
- addSortIndex: params.addSortIndex,
407
- validateOfferRateLimit: params.validateOfferRateLimit,
408
- onlyValid: params.onlyValid === true
409
- })(repos);
410
- offers = searchOffersResult.ticketOffers;
411
- unitPriceOffers = searchOffersResult.unitPriceOffers;
412
- }
413
- else if (event.typeOf === factory.eventType.Event) {
414
- const searchOffersResult = yield searchTransportationEventTicketOffers({
415
- ids: params.ids,
416
- event,
417
- store: params.store,
418
- limit: params.limit,
419
- page: params.page,
420
- sort: params.sort,
421
- addSortIndex: params.addSortIndex,
422
- validateOfferRateLimit: params.validateOfferRateLimit,
423
- onlyValid: params.onlyValid === true
424
- })(repos);
425
- offers = searchOffersResult.ticketOffers;
426
- unitPriceOffers = searchOffersResult.unitPriceOffers;
427
- }
428
- else {
429
- throw new factory.errors.NotImplemented(`'${event.typeOf}' not implemented`);
430
- }
431
- // store.idでのフィルターをmongoに移行(2023-01-27~)
432
- // const specifiedStoreId = params.store?.id;
433
- // if (typeof specifiedStoreId === 'string') {
434
- // // アプリケーションが利用可能なオファーに絞る
435
- // offers = offers.filter((o) => {
436
- // return Array.isArray(o.availableAtOrFrom)
437
- // && o.availableAtOrFrom.some((availableApplication) => availableApplication.id === specifiedStoreId);
438
- // });
439
- // }
440
- // mongo条件へ移行(2023-02-24~)
441
- // 有効期間を適用
442
- // if (params.onlyValid === true) {
443
- // offers = offers.filter((o) => {
444
- // let isvalid = true;
445
- // if (o.validFrom !== undefined && moment(o.validFrom)
446
- // .isAfter(now)) {
447
- // isvalid = false;
448
- // }
449
- // if (o.validThrough !== undefined && moment(o.validThrough)
450
- // .isBefore(now)) {
451
- // isvalid = false;
452
- // }
453
- // return isvalid;
454
- // });
455
- // }
456
- for (const offer of offers) {
457
- if (Array.isArray(offer.addOn)) {
458
- // store.idでのフィルターをmongoに移行(2023-01-27~)
459
- // addOnsに対しても利用可能アプリケーション設定を適用
460
- // if (typeof specifiedStoreId === 'string') {
461
- // // アプリケーションが利用可能なオファーに絞る
462
- // offer.addOn = offer.addOn.filter((offer4addOn) => {
463
- // return Array.isArray(offer4addOn.availableAtOrFrom)
464
- // && offer4addOn.availableAtOrFrom.some(
465
- // (availableApplication) => availableApplication.id === specifiedStoreId
466
- // );
467
- // });
468
- // }
469
- // addOnsに対しても有効期間を適用
470
- if (params.onlyValid === true) {
471
- offer.addOn = offer.addOn.filter((offer4addOn) => {
472
- let isvalid = true;
473
- if (offer4addOn.validFrom !== undefined && moment(offer4addOn.validFrom)
474
- .isAfter(now)) {
475
- isvalid = false;
476
- }
477
- if (offer4addOn.validThrough !== undefined && moment(offer4addOn.validThrough)
478
- .isBefore(now)) {
479
- isvalid = false;
480
- }
481
- return isvalid;
482
- });
483
- }
484
- }
485
- }
251
+ const searchOffersResult = yield searchEventTicketOffersByEvent({
252
+ ids: params.ids,
253
+ event,
254
+ store: params.store,
255
+ limit: params.limit,
256
+ page: params.page,
257
+ sort: params.sort,
258
+ addSortIndex: params.addSortIndex,
259
+ validateOfferRateLimit: params.validateOfferRateLimit,
260
+ onlyValid: params.onlyValid === true
261
+ })(repos);
262
+ offers = searchOffersResult.ticketOffers;
263
+ unitPriceOffers = searchOffersResult.unitPriceOffers;
264
+ // mongo条件へ移行(2023-02-24~)
265
+ // 有効期間を適用
266
+ // if (params.onlyValid === true) {
267
+ // offers = offers.filter((o) => {
268
+ // let isvalid = true;
269
+ // if (o.validFrom !== undefined && moment(o.validFrom)
270
+ // .isAfter(now)) {
271
+ // isvalid = false;
272
+ // }
273
+ // if (o.validThrough !== undefined && moment(o.validThrough)
274
+ // .isBefore(now)) {
275
+ // isvalid = false;
276
+ // }
277
+ // return isvalid;
278
+ // });
279
+ // }
280
+ // mongo条件へ移行(2023-02-27~)
281
+ // for (const offer of offers) {
282
+ // if (Array.isArray(offer.addOn)) {
283
+ // // addOnsに対しても有効期間を適用
284
+ // if (params.onlyValid === true) {
285
+ // offer.addOn = offer.addOn.filter((offer4addOn) => {
286
+ // let isvalid = true;
287
+ // if (offer4addOn.validFrom !== undefined && moment(offer4addOn.validFrom)
288
+ // .isAfter(now)) {
289
+ // isvalid = false;
290
+ // }
291
+ // if (offer4addOn.validThrough !== undefined && moment(offer4addOn.validThrough)
292
+ // .isBefore(now)) {
293
+ // isvalid = false;
294
+ // }
295
+ // return isvalid;
296
+ // });
297
+ // }
298
+ // }
299
+ // }
486
300
  }
487
301
  return { ticketOffers: offers, unitPriceOffers };
488
302
  });
@@ -8,6 +8,8 @@ declare function createCompoundPriceSpec4event(params: {
8
8
  videoFormatChargeSpecifications: ICategoryCodeChargeSpecification[];
9
9
  soundFormatChargeSpecifications: ICategoryCodeChargeSpecification[];
10
10
  videoFormatTypes: string[];
11
+ availability?: factory.itemAvailability;
12
+ addOn: factory.offer.IAddOn[];
11
13
  sortIndex?: number;
12
14
  }): factory.product.ITicketOffer & {
13
15
  sortIndex?: number;
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createCompoundPriceSpec4event = void 0;
4
4
  const factory = require("../../factory");
5
- const settings_1 = require("../../settings");
6
5
  function categoryCodeChargePriceSpec2component(params) {
7
6
  var _a;
8
7
  return Object.assign({ id: params.id, typeOf: params.typeOf, name: params.name, price: params.price, priceCurrency: params.priceCurrency, valueAddedTaxIncluded: params.valueAddedTaxIncluded, appliesToCategoryCode: params.appliesToCategoryCode }, (typeof ((_a = params.accounting) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string') ? { accounting: params.accounting } : undefined);
@@ -31,50 +30,36 @@ function createCompoundPriceSpec4event(params) {
31
30
  // 複数決済カード対応(2022-07-11~)
32
31
  if (Array.isArray(unitPriceSpec.appliesToMovieTicket)) {
33
32
  // 決済カード加算料金自動補完(2023-02-21~)
34
- if (settings_1.settings.useOffersAppliedToMovieTicketWithoutChargeSpecification) {
35
- unitPriceSpec.appliesToMovieTicket.forEach((appliesToMovieTicket) => {
36
- // すべての上映方式に該当する加算料金を追加
37
- params.videoFormatTypes.forEach((videoFormatType) => {
38
- let existingMvtkSpec4appliesToMovieTicket = params.movieTicketTypeChargeSpecs.find((s) => {
39
- var _a;
40
- return ((_a = s.appliesToMovieTicket.serviceOutput) === null || _a === void 0 ? void 0 : _a.typeOf) === appliesToMovieTicket.serviceOutput.typeOf
41
- && s.appliesToMovieTicket.serviceType === appliesToMovieTicket.serviceType
42
- && s.appliesToVideoFormat === videoFormatType;
43
- });
44
- // 加算料金が存在しなければprice: 0で自動補完
45
- if (existingMvtkSpec4appliesToMovieTicket === undefined) {
46
- existingMvtkSpec4appliesToMovieTicket = {
47
- typeOf: factory.priceSpecificationType.MovieTicketTypeChargeSpecification,
48
- price: 0,
49
- priceCurrency: factory.priceCurrency.JPY,
50
- appliesToVideoFormat: videoFormatType,
51
- valueAddedTaxIncluded: true,
52
- project: params.offer.project,
53
- id: '',
54
- name: params.offer.name,
55
- appliesToMovieTicket: {
56
- typeOf: factory.service.paymentService.PaymentServiceType.MovieTicket,
57
- serviceType: appliesToMovieTicket.serviceType,
58
- serviceOutput: { typeOf: appliesToMovieTicket.serviceOutput.typeOf }
59
- }
60
- };
61
- }
62
- mvtkPriceComponents.push(mvtkChargePriceSpec2component(existingMvtkSpec4appliesToMovieTicket));
63
- });
64
- });
65
- }
66
- else {
67
- unitPriceSpec.appliesToMovieTicket.forEach((appliesToMovieTicket) => {
68
- // すべての上映方式に該当する加算料金を追加(2022-10-29~)
69
- const mvtkSpecs4appliesToMovieTicket = params.movieTicketTypeChargeSpecs.filter((s) => {
33
+ unitPriceSpec.appliesToMovieTicket.forEach((appliesToMovieTicket) => {
34
+ // すべての上映方式に該当する加算料金を追加
35
+ params.videoFormatTypes.forEach((videoFormatType) => {
36
+ let existingMvtkSpec4appliesToMovieTicket = params.movieTicketTypeChargeSpecs.find((s) => {
70
37
  var _a;
71
38
  return ((_a = s.appliesToMovieTicket.serviceOutput) === null || _a === void 0 ? void 0 : _a.typeOf) === appliesToMovieTicket.serviceOutput.typeOf
72
39
  && s.appliesToMovieTicket.serviceType === appliesToMovieTicket.serviceType
73
- && params.videoFormatTypes.includes(s.appliesToVideoFormat);
40
+ && s.appliesToVideoFormat === videoFormatType;
74
41
  });
75
- mvtkPriceComponents.push(...mvtkSpecs4appliesToMovieTicket.map(mvtkChargePriceSpec2component));
42
+ // 加算料金が存在しなければprice: 0で自動補完
43
+ if (existingMvtkSpec4appliesToMovieTicket === undefined) {
44
+ existingMvtkSpec4appliesToMovieTicket = {
45
+ typeOf: factory.priceSpecificationType.MovieTicketTypeChargeSpecification,
46
+ price: 0,
47
+ priceCurrency: factory.priceCurrency.JPY,
48
+ appliesToVideoFormat: videoFormatType,
49
+ valueAddedTaxIncluded: true,
50
+ project: params.offer.project,
51
+ id: '',
52
+ name: params.offer.name,
53
+ appliesToMovieTicket: {
54
+ typeOf: factory.service.paymentService.PaymentServiceType.MovieTicket,
55
+ serviceType: appliesToMovieTicket.serviceType,
56
+ serviceOutput: { typeOf: appliesToMovieTicket.serviceOutput.typeOf }
57
+ }
58
+ };
59
+ }
60
+ mvtkPriceComponents.push(mvtkChargePriceSpec2component(existingMvtkSpec4appliesToMovieTicket));
76
61
  });
77
- }
62
+ });
78
63
  }
79
64
  // 区分加算料金は決済カード適用でも価格要素に含まれるはず(2022-11-02~)
80
65
  const priceComponent = [
@@ -93,14 +78,16 @@ function createCompoundPriceSpec4event(params) {
93
78
  };
94
79
  // 必要な属性のみに限定(2023-02-24~)
95
80
  // const { project, ...unitOfferFields4ticketOffer } = params.offer;
96
- const { name, description, alternateName, color, typeOf, id, addOn, availability, availableAtOrFrom, category, eligibleMembershipType, eligibleSeatingType, eligibleMonetaryAmount, eligibleSubReservation, priceCurrency, validFrom, validThrough, validRateLimit, additionalProperty, identifier, itemOffered } = params.offer;
97
- return Object.assign({
98
- // ...unitOfferFields4ticketOffer,
99
- name, description, alternateName, color, typeOf, id,
100
- addOn, availability, availableAtOrFrom, category,
81
+ const { name, description, alternateName, color, typeOf, id,
82
+ // addOn,
83
+ availability, availableAtOrFrom, category, eligibleMembershipType, eligibleSeatingType, eligibleMonetaryAmount, eligibleSubReservation, priceCurrency, validFrom, validThrough, validRateLimit, additionalProperty, identifier, itemOffered } = params.offer;
84
+ return Object.assign(Object.assign({ name, description, alternateName, color, typeOf, id,
85
+ // addOn,
86
+ // availability,
87
+ availableAtOrFrom, category,
101
88
  eligibleMembershipType, eligibleSeatingType, eligibleMonetaryAmount, eligibleSubReservation,
102
89
  priceCurrency,
103
90
  validFrom, validThrough, validRateLimit, additionalProperty,
104
- identifier, itemOffered, eligibleQuantity: params.eligibleQuantity, priceSpecification: compoundPriceSpecification }, (typeof params.sortIndex === 'number') ? { sortIndex: params.sortIndex } : undefined);
91
+ identifier, itemOffered, addOn: params.addOn, eligibleQuantity: params.eligibleQuantity, priceSpecification: compoundPriceSpecification }, (typeof params.availability === 'string') ? { availability: params.availability } : { availability }), (typeof params.sortIndex === 'number') ? { sortIndex: params.sortIndex } : undefined);
105
92
  }
106
93
  exports.createCompoundPriceSpec4event = createCompoundPriceSpec4event;
@@ -22,7 +22,6 @@ export declare type ISettings = factory.project.ISettings & {
22
22
  userPoolIdNew: string;
23
23
  maxNumCreditCardPaymentMethod?: number;
24
24
  useEventWorkPerformed: boolean;
25
- useOffersAppliedToMovieTicketWithoutChargeSpecification: boolean;
26
25
  useAggregateEntranceGateProjects: string[];
27
26
  useAggregateOfferProjects: string[];
28
27
  useOfferRateLimitProjects: string[];
@@ -94,7 +94,7 @@ exports.settings = Object.assign(Object.assign({ transactionWebhookUrls, onOrder
94
94
  timeout: triggerWebhookTimeout
95
95
  }, maximumReservationGracePeriodInDays: MAXIMUM_RESERVATION_GRACE_PERIOD_IN_DAYS, userPoolIdOld: String(process.env.USERPOOL_ID_OLD), userPoolIdNew: String(process.env.USERPOOL_ID_NEW) }, (typeof MAX_NUM_CREDIT_CARD_PAYMENT_METHOD === 'number')
96
96
  ? { maxNumCreditCardPaymentMethod: MAX_NUM_CREDIT_CARD_PAYMENT_METHOD }
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')
97
+ : undefined), { useEventWorkPerformed: process.env.USE_EVENT_WORK_PERFORMED === '1', useAggregateEntranceGateProjects: (typeof process.env.USE_AGGREGATE_ENTRANCE_GATE_PROJECTS === 'string')
98
98
  ? process.env.USE_AGGREGATE_ENTRANCE_GATE_PROJECTS.split(',')
99
99
  : [], useAggregateOfferProjects: (typeof process.env.USE_AGGREGATE_OFFER_PROJECTS === 'string')
100
100
  ? process.env.USE_AGGREGATE_OFFER_PROJECTS.split(',')
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  }
10
10
  ],
11
11
  "dependencies": {
12
- "@chevre/factory": "4.289.0-alpha.15",
12
+ "@chevre/factory": "4.289.0",
13
13
  "@cinerino/sdk": "3.140.0-alpha.16",
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.4.0-alpha.21"
123
+ "version": "20.4.0-alpha.23"
124
124
  }
@@ -1,31 +0,0 @@
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 offerCatalogRepo = new chevre.repository.OfferCatalog(mongoose.connection);
11
-
12
- const catalogs = await offerCatalogRepo.search({
13
- limit: 100,
14
- page: 1,
15
- // id: { $in: ['0001'] },
16
- itemListElement: {
17
- id: {
18
- $all: ['901', '3001']
19
- // $in: ['1001'],
20
- // $nin: ['1005']
21
- }
22
- },
23
- itemOffered: { typeOf: { $eq: chevre.factory.product.ProductType.EventService } }
24
- });
25
- console.log(catalogs);
26
- console.log(catalogs.length);
27
- }
28
-
29
- main()
30
- .then(console.log)
31
- .catch(console.error);