@chevre/domain 20.4.0-alpha.10 → 20.4.0-alpha.12

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.
@@ -22,11 +22,10 @@ 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: 'al9ew43f5' },
25
+ event: { id: 'ale6qiedf' },
26
26
  onlyValid: true,
27
27
  sort: true,
28
28
  validateOfferRateLimit: true
29
- // ...(typeof sellerId === 'string') ? { seller: { id: sellerId } } : undefined,
30
29
  // ...(typeof availableAtId === 'string') ? { store: { id: availableAtId } } : undefined
31
30
  })({
32
31
  event: eventRepo,
@@ -16,6 +16,7 @@ async function main() {
16
16
  id: '0001'
17
17
  // id: 'xxx'
18
18
  },
19
+ excludeAppliesToMovieTicket: false,
19
20
  sort: true
20
21
  });
21
22
  console.log(offers.map((o) => o.id));
@@ -6,17 +6,23 @@ import { chevre } from '../../../lib/index';
6
6
  async function main() {
7
7
  await mongoose.connect(<string>process.env.MONGOLAB_URI);
8
8
 
9
- const accountRepo = new chevre.repository.Account(mongoose.connection);
9
+ // const accountRepo = new chevre.repository.Account(mongoose.connection);
10
10
  const permitRepo = new chevre.repository.ServiceOutput(mongoose.connection);
11
11
 
12
- let updateResult = await accountRepo.unsetUnnecessaryFields({
13
- filter: { status: { $exists: true } },
14
- $unset: { status: 1 }
12
+ let updateResult: any;
13
+ // updateResult = await accountRepo.unsetUnnecessaryFields({
14
+ // filter: { status: { $exists: true } },
15
+ // $unset: { status: 1 }
16
+ // });
17
+ // console.log('accounts unset.', updateResult);
18
+ updateResult = await permitRepo.unsetUnnecessaryFields({
19
+ filter: { 'paymentAccount.project': { $exists: true } },
20
+ $unset: { 'paymentAccount.project': 1 }
15
21
  });
16
- console.log('accounts unset.', updateResult);
22
+ console.log('permits unset', updateResult);
17
23
  updateResult = await permitRepo.unsetUnnecessaryFields({
18
- filter: { 'paymentAccount.accountType': { $exists: true } },
19
- $unset: { 'paymentAccount.accountType': 1 }
24
+ filter: { 'issuedThrough.project': { $exists: true } },
25
+ $unset: { 'issuedThrough.project': 1 }
20
26
  });
21
27
  console.log('permits unset', updateResult);
22
28
  }
@@ -23,6 +23,8 @@ export declare class MongoRepository {
23
23
  availableAtOrFrom?: {
24
24
  id?: string;
25
25
  };
26
+ unacceptedPaymentMethod?: string[];
27
+ excludeAppliesToMovieTicket: boolean;
26
28
  limit?: number;
27
29
  page?: number;
28
30
  sort: boolean;
@@ -35,7 +35,7 @@ class MongoRepository {
35
35
  }
36
36
  // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
37
37
  static CREATE_OFFER_MONGO_CONDITIONS(params) {
38
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24;
38
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31;
39
39
  // MongoDB検索条件
40
40
  const andConditions = [];
41
41
  const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
@@ -166,7 +166,15 @@ class MongoRepository {
166
166
  }
167
167
  });
168
168
  }
169
- const appliesToMovieTicketServiceTypeEq = (_w = (_v = (_u = params.priceSpecification) === null || _u === void 0 ? void 0 : _u.appliesToMovieTicket) === null || _v === void 0 ? void 0 : _v.serviceType) === null || _w === void 0 ? void 0 : _w.$eq;
169
+ const appliesToMovieTicketServiceTypeExist = (_w = (_v = (_u = params.priceSpecification) === null || _u === void 0 ? void 0 : _u.appliesToMovieTicket) === null || _v === void 0 ? void 0 : _v.serviceType) === null || _w === void 0 ? void 0 : _w.$exists;
170
+ if (typeof appliesToMovieTicketServiceTypeExist === 'boolean') {
171
+ andConditions.push({
172
+ 'priceSpecification.appliesToMovieTicket.serviceType': {
173
+ $exists: appliesToMovieTicketServiceTypeExist
174
+ }
175
+ });
176
+ }
177
+ const appliesToMovieTicketServiceTypeEq = (_z = (_y = (_x = params.priceSpecification) === null || _x === void 0 ? void 0 : _x.appliesToMovieTicket) === null || _y === void 0 ? void 0 : _y.serviceType) === null || _z === void 0 ? void 0 : _z.$eq;
170
178
  if (typeof appliesToMovieTicketServiceTypeEq === 'string') {
171
179
  andConditions.push({
172
180
  'priceSpecification.appliesToMovieTicket.serviceType': {
@@ -175,7 +183,7 @@ class MongoRepository {
175
183
  }
176
184
  });
177
185
  }
178
- const appliesToMovieTicketServiceOutputTypeOfEq = (_0 = (_z = (_y = (_x = params.priceSpecification) === null || _x === void 0 ? void 0 : _x.appliesToMovieTicket) === null || _y === void 0 ? void 0 : _y.serviceOutput) === null || _z === void 0 ? void 0 : _z.typeOf) === null || _0 === void 0 ? void 0 : _0.$eq;
186
+ const appliesToMovieTicketServiceOutputTypeOfEq = (_3 = (_2 = (_1 = (_0 = params.priceSpecification) === null || _0 === void 0 ? void 0 : _0.appliesToMovieTicket) === null || _1 === void 0 ? void 0 : _1.serviceOutput) === null || _2 === void 0 ? void 0 : _2.typeOf) === null || _3 === void 0 ? void 0 : _3.$eq;
179
187
  if (typeof appliesToMovieTicketServiceOutputTypeOfEq === 'string') {
180
188
  andConditions.push({
181
189
  'priceSpecification.appliesToMovieTicket.serviceOutput.typeOf': {
@@ -184,8 +192,16 @@ class MongoRepository {
184
192
  }
185
193
  });
186
194
  }
195
+ const appliesToMovieTicketServiceOutputTypeOfNin = (_7 = (_6 = (_5 = (_4 = params.priceSpecification) === null || _4 === void 0 ? void 0 : _4.appliesToMovieTicket) === null || _5 === void 0 ? void 0 : _5.serviceOutput) === null || _6 === void 0 ? void 0 : _6.typeOf) === null || _7 === void 0 ? void 0 : _7.$nin;
196
+ if (Array.isArray(appliesToMovieTicketServiceOutputTypeOfNin)) {
197
+ andConditions.push({
198
+ 'priceSpecification.appliesToMovieTicket.serviceOutput.typeOf': {
199
+ $nin: appliesToMovieTicketServiceOutputTypeOfNin
200
+ }
201
+ });
202
+ }
187
203
  if (params.priceSpecification !== undefined && params.priceSpecification !== null) {
188
- const priceSpecificationPriceGte = (_1 = params.priceSpecification.price) === null || _1 === void 0 ? void 0 : _1.$gte;
204
+ const priceSpecificationPriceGte = (_8 = params.priceSpecification.price) === null || _8 === void 0 ? void 0 : _8.$gte;
189
205
  if (typeof priceSpecificationPriceGte === 'number') {
190
206
  andConditions.push({
191
207
  'priceSpecification.price': {
@@ -194,7 +210,7 @@ class MongoRepository {
194
210
  }
195
211
  });
196
212
  }
197
- const priceSpecificationPriceLte = (_2 = params.priceSpecification.price) === null || _2 === void 0 ? void 0 : _2.$lte;
213
+ const priceSpecificationPriceLte = (_9 = params.priceSpecification.price) === null || _9 === void 0 ? void 0 : _9.$lte;
198
214
  if (typeof priceSpecificationPriceLte === 'number') {
199
215
  andConditions.push({
200
216
  'priceSpecification.price': {
@@ -203,7 +219,7 @@ class MongoRepository {
203
219
  }
204
220
  });
205
221
  }
206
- const accountsReceivableGte = (_4 = (_3 = params.priceSpecification.accounting) === null || _3 === void 0 ? void 0 : _3.accountsReceivable) === null || _4 === void 0 ? void 0 : _4.$gte;
222
+ const accountsReceivableGte = (_11 = (_10 = params.priceSpecification.accounting) === null || _10 === void 0 ? void 0 : _10.accountsReceivable) === null || _11 === void 0 ? void 0 : _11.$gte;
207
223
  if (typeof accountsReceivableGte === 'number') {
208
224
  andConditions.push({
209
225
  'priceSpecification.accounting.accountsReceivable': {
@@ -212,7 +228,7 @@ class MongoRepository {
212
228
  }
213
229
  });
214
230
  }
215
- const accountsReceivableLte = (_6 = (_5 = params.priceSpecification.accounting) === null || _5 === void 0 ? void 0 : _5.accountsReceivable) === null || _6 === void 0 ? void 0 : _6.$lte;
231
+ const accountsReceivableLte = (_13 = (_12 = params.priceSpecification.accounting) === null || _12 === void 0 ? void 0 : _12.accountsReceivable) === null || _13 === void 0 ? void 0 : _13.$lte;
216
232
  if (typeof accountsReceivableLte === 'number') {
217
233
  andConditions.push({
218
234
  'priceSpecification.accounting.accountsReceivable': {
@@ -221,7 +237,7 @@ class MongoRepository {
221
237
  }
222
238
  });
223
239
  }
224
- const accountingCodeValueEq = (_9 = (_8 = (_7 = params.priceSpecification.accounting) === null || _7 === void 0 ? void 0 : _7.operatingRevenue) === null || _8 === void 0 ? void 0 : _8.codeValue) === null || _9 === void 0 ? void 0 : _9.$eq;
240
+ const accountingCodeValueEq = (_16 = (_15 = (_14 = params.priceSpecification.accounting) === null || _14 === void 0 ? void 0 : _14.operatingRevenue) === null || _15 === void 0 ? void 0 : _15.codeValue) === null || _16 === void 0 ? void 0 : _16.$eq;
225
241
  if (typeof accountingCodeValueEq === 'string') {
226
242
  andConditions.push({
227
243
  'priceSpecification.accounting.operatingRevenue.codeValue': {
@@ -230,7 +246,7 @@ class MongoRepository {
230
246
  }
231
247
  });
232
248
  }
233
- const accountingCodeValueIn = (_12 = (_11 = (_10 = params.priceSpecification.accounting) === null || _10 === void 0 ? void 0 : _10.operatingRevenue) === null || _11 === void 0 ? void 0 : _11.codeValue) === null || _12 === void 0 ? void 0 : _12.$in;
249
+ const accountingCodeValueIn = (_19 = (_18 = (_17 = params.priceSpecification.accounting) === null || _17 === void 0 ? void 0 : _17.operatingRevenue) === null || _18 === void 0 ? void 0 : _18.codeValue) === null || _19 === void 0 ? void 0 : _19.$in;
234
250
  if (Array.isArray(accountingCodeValueIn)) {
235
251
  andConditions.push({
236
252
  'priceSpecification.accounting.operatingRevenue.codeValue': {
@@ -239,7 +255,7 @@ class MongoRepository {
239
255
  }
240
256
  });
241
257
  }
242
- const referenceQuantityValueEq = (_14 = (_13 = params.priceSpecification.referenceQuantity) === null || _13 === void 0 ? void 0 : _13.value) === null || _14 === void 0 ? void 0 : _14.$eq;
258
+ const referenceQuantityValueEq = (_21 = (_20 = params.priceSpecification.referenceQuantity) === null || _20 === void 0 ? void 0 : _20.value) === null || _21 === void 0 ? void 0 : _21.$eq;
243
259
  if (typeof referenceQuantityValueEq === 'number') {
244
260
  andConditions.push({
245
261
  'priceSpecification.referenceQuantity.value': {
@@ -249,7 +265,7 @@ class MongoRepository {
249
265
  });
250
266
  }
251
267
  }
252
- const availableAtOrFromIdEq = (_16 = (_15 = params.availableAtOrFrom) === null || _15 === void 0 ? void 0 : _15.id) === null || _16 === void 0 ? void 0 : _16.$eq;
268
+ const availableAtOrFromIdEq = (_23 = (_22 = params.availableAtOrFrom) === null || _22 === void 0 ? void 0 : _22.id) === null || _23 === void 0 ? void 0 : _23.$eq;
253
269
  if (typeof availableAtOrFromIdEq === 'string') {
254
270
  andConditions.push({
255
271
  'availableAtOrFrom.id': {
@@ -258,7 +274,7 @@ class MongoRepository {
258
274
  }
259
275
  });
260
276
  }
261
- const availableAtOrFromIdIn = (_18 = (_17 = params.availableAtOrFrom) === null || _17 === void 0 ? void 0 : _17.id) === null || _18 === void 0 ? void 0 : _18.$in;
277
+ const availableAtOrFromIdIn = (_25 = (_24 = params.availableAtOrFrom) === null || _24 === void 0 ? void 0 : _24.id) === null || _25 === void 0 ? void 0 : _25.$in;
262
278
  if (Array.isArray(availableAtOrFromIdIn)) {
263
279
  andConditions.push({
264
280
  'availableAtOrFrom.id': {
@@ -267,7 +283,7 @@ class MongoRepository {
267
283
  }
268
284
  });
269
285
  }
270
- const addOnItemOfferedIdEq = (_21 = (_20 = (_19 = params.addOn) === null || _19 === void 0 ? void 0 : _19.itemOffered) === null || _20 === void 0 ? void 0 : _20.id) === null || _21 === void 0 ? void 0 : _21.$eq;
286
+ const addOnItemOfferedIdEq = (_28 = (_27 = (_26 = params.addOn) === null || _26 === void 0 ? void 0 : _26.itemOffered) === null || _27 === void 0 ? void 0 : _27.id) === null || _28 === void 0 ? void 0 : _28.$eq;
271
287
  if (typeof addOnItemOfferedIdEq === 'string') {
272
288
  andConditions.push({
273
289
  'addOn.itemOffered.id': {
@@ -276,7 +292,7 @@ class MongoRepository {
276
292
  }
277
293
  });
278
294
  }
279
- const hasMerchantReturnPolicyIdEq = (_23 = (_22 = params.hasMerchantReturnPolicy) === null || _22 === void 0 ? void 0 : _22.id) === null || _23 === void 0 ? void 0 : _23.$eq;
295
+ const hasMerchantReturnPolicyIdEq = (_30 = (_29 = params.hasMerchantReturnPolicy) === null || _29 === void 0 ? void 0 : _29.id) === null || _30 === void 0 ? void 0 : _30.$eq;
280
296
  if (typeof hasMerchantReturnPolicyIdEq === 'string') {
281
297
  andConditions.push({
282
298
  'hasMerchantReturnPolicy.id': {
@@ -285,7 +301,7 @@ class MongoRepository {
285
301
  }
286
302
  });
287
303
  }
288
- const additionalPropertyElemMatch = (_24 = params.additionalProperty) === null || _24 === void 0 ? void 0 : _24.$elemMatch;
304
+ const additionalPropertyElemMatch = (_31 = params.additionalProperty) === null || _31 === void 0 ? void 0 : _31.$elemMatch;
289
305
  if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
290
306
  andConditions.push({
291
307
  additionalProperty: {
@@ -324,31 +340,24 @@ class MongoRepository {
324
340
  const sortedOfferIds = (Array.isArray(itemListElements))
325
341
  ? itemListElements.map((element) => element.id)
326
342
  : [];
327
- // const offerCatalog = await this.offerCatalogModel.findById(
328
- // params.offerCatalog.id,
329
- // {
330
- // itemListElement: 1
331
- // }
332
- // )
333
- // .exec()
334
- // .then((doc) => {
335
- // if (doc === null) {
336
- // throw new factory.errors.NotFound(this.offerCatalogModel.modelName);
337
- // }
338
- // return <Pick<factory.offerCatalog.IOfferCatalog, 'itemListElement'>>doc.toObject();
339
- // });
340
- // let sortedOfferIds: string[] = (Array.isArray(offerCatalog.itemListElement))
341
- // ? offerCatalog.itemListElement.map((element) => element.id)
342
- // : [];
343
- // const filteredIds = params.ids;
344
- // if (Array.isArray(filteredIds)) {
345
- // sortedOfferIds = sortedOfferIds.filter((id) => filteredIds.includes(id));
346
- // }
347
343
  let offers = [];
348
344
  if (sortedOfferIds.length > 0) {
349
- offers = yield this.search(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({ id: { $in: sortedOfferIds } }, (typeof ((_a = params.availableAtOrFrom) === null || _a === void 0 ? void 0 : _a.id) === 'string')
350
346
  ? { availableAtOrFrom: { id: { $eq: params.availableAtOrFrom.id } } }
351
- : undefined));
347
+ : undefined), { priceSpecification: {
348
+ appliesToMovieTicket: Object.assign(Object.assign({}, (Array.isArray(params.unacceptedPaymentMethod) && params.unacceptedPaymentMethod.length > 0)
349
+ ? {
350
+ serviceOutput: {
351
+ typeOf: { $nin: params.unacceptedPaymentMethod }
352
+ }
353
+ }
354
+ : undefined), (params.excludeAppliesToMovieTicket)
355
+ ? {
356
+ serviceType: { $exists: false }
357
+ }
358
+ : undefined)
359
+ } });
360
+ offers = yield this.search(searchOffersConditions);
352
361
  if (params.sort) {
353
362
  // sorting
354
363
  offers = offers.sort((a, b) => sortedOfferIds.indexOf(String(a.id)) - sortedOfferIds.indexOf(String(b.id)));
@@ -210,6 +210,7 @@ function findOffers(params) {
210
210
  if (typeof ((_b = eventService.hasOfferCatalog) === null || _b === void 0 ? void 0 : _b.id) === 'string') {
211
211
  availableOffers = yield repos.offer.findOffersByOfferCatalogId({
212
212
  offerCatalog: { id: eventService.hasOfferCatalog.id },
213
+ excludeAppliesToMovieTicket: false,
213
214
  sort: false // ソート不要(2023-01-27~)
214
215
  });
215
216
  }
@@ -93,6 +93,7 @@ function findOffers(params) {
93
93
  if (typeof ((_b = eventService.hasOfferCatalog) === null || _b === void 0 ? void 0 : _b.id) === 'string') {
94
94
  availableOffers = yield repos.offer.findOffersByOfferCatalogId({
95
95
  offerCatalog: { id: eventService.hasOfferCatalog.id },
96
+ excludeAppliesToMovieTicket: false,
96
97
  sort: false // ソート不要(2023-01-27~)
97
98
  });
98
99
  }
@@ -223,7 +223,6 @@ function validateAcceptedOffers(params) {
223
223
  // 受け入れたオファーIDだけ取得する(2023-01-26~)
224
224
  ids: offerIds,
225
225
  event: { id: params.event.id },
226
- // seller: params.seller,
227
226
  store: params.store,
228
227
  sort: false,
229
228
  validateOfferRateLimit: true
@@ -27,10 +27,6 @@ declare function searchEventTicketOffers(params: {
27
27
  event: {
28
28
  id: string;
29
29
  };
30
- /**
31
- * どの販売者に対して
32
- * 不要なので廃止(2023-01-27~)
33
- */
34
30
  /**
35
31
  * どのアプリケーションに対して
36
32
  */
@@ -74,6 +70,8 @@ declare function searchEventTicketOffers(params: {
74
70
  */
75
71
  kbnEisyahousiki: string;
76
72
  };
73
+ limit?: number;
74
+ page?: number;
77
75
  sort: boolean;
78
76
  validateOfferRateLimit: boolean;
79
77
  }): ISearchEventTicketOffersOperation<{
@@ -12,6 +12,7 @@ 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");
15
16
  const factory_1 = require("../factory");
16
17
  /**
17
18
  * 旅客オファー検索
@@ -23,6 +24,9 @@ function searchTransportationEventTicketOffers(params) {
23
24
  const screeningEvent = params.event;
24
25
  const soundFormatTypes = [];
25
26
  const videoFormatTypes = [];
27
+ const unacceptedPaymentMethod = getUnacceptedPaymentMethodByEvent({ event: screeningEvent });
28
+ // 上映方式がなければMovieTicket除外(2023-02-21~)
29
+ const excludeAppliesToMovieTicket = videoFormatTypes.length === 0;
26
30
  let availableOffers = [];
27
31
  // 興行設定があれば興行のカタログを参照する(2022-08-31~)
28
32
  const eventOffers = screeningEvent.offers;
@@ -33,6 +37,8 @@ function searchTransportationEventTicketOffers(params) {
33
37
  ids: params.ids,
34
38
  offerCatalog: { id: transportation.hasOfferCatalog.id },
35
39
  availableAtOrFrom: { id: (_c = params.store) === null || _c === void 0 ? void 0 : _c.id },
40
+ unacceptedPaymentMethod,
41
+ excludeAppliesToMovieTicket,
36
42
  sort: params.sort
37
43
  });
38
44
  }
@@ -42,24 +48,6 @@ function searchTransportationEventTicketOffers(params) {
42
48
  throw new factory.errors.NotFound('event.offers.itemOffered.id');
43
49
  }
44
50
  const { soundFormatChargeSpecifications, videoFormatChargeSpecifications, movieTicketTypeChargeSpecs } = yield searchPriceSpecs4event({ project: { id: screeningEvent.project.id }, soundFormatTypes, videoFormatTypes })(repos);
45
- const unacceptedPaymentMethod = getUnacceptedPaymentMethodByEvent({ event: screeningEvent });
46
- // 不許可決済方法があれば、該当オファーを除外
47
- if (Array.isArray(unacceptedPaymentMethod) && unacceptedPaymentMethod.length > 0) {
48
- availableOffers = availableOffers.filter((o) => {
49
- var _a;
50
- // 複数決済カード対応(2022-07-11~)
51
- const priceSpecificationAppliesToMovieTicket = (_a = o.priceSpecification) === null || _a === void 0 ? void 0 : _a.appliesToMovieTicket;
52
- if (Array.isArray(priceSpecificationAppliesToMovieTicket)) {
53
- return priceSpecificationAppliesToMovieTicket.every((appliesToMovieTicket) => {
54
- return !unacceptedPaymentMethod.includes(appliesToMovieTicket.serviceOutput.typeOf);
55
- });
56
- }
57
- else {
58
- // Arrayでないケースは廃止(2022-09-10~)
59
- return true;
60
- }
61
- });
62
- }
63
51
  // 適用決済カード条件がある場合、決済カード加算料金が存在しないオファーは除外する
64
52
  availableOffers = availableOffers.filter((o) => {
65
53
  var _a;
@@ -71,9 +59,9 @@ function searchTransportationEventTicketOffers(params) {
71
59
  return false;
72
60
  }
73
61
  // 上映方式がなければ除外(2022-11-03~)
74
- if (videoFormatTypes.length === 0) {
75
- return false;
76
- }
62
+ // if (videoFormatTypes.length === 0) {
63
+ // return false;
64
+ // }
77
65
  return priceSpecificationAppliesToMovieTicket.every((appliesToMovieTicket) => {
78
66
  // すべての上映方式について検証する(2022-10-29~)
79
67
  return videoFormatTypes.every((videoFormat) => {
@@ -91,6 +79,12 @@ function searchTransportationEventTicketOffers(params) {
91
79
  return true;
92
80
  }
93
81
  });
82
+ // 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);
87
+ }
94
88
  let offers4event = availableOffers.map((availableOffer) => {
95
89
  return (0, factory_1.createCompoundPriceSpec4event)({
96
90
  eligibleQuantity: eventOffers.eligibleQuantity,
@@ -138,12 +132,14 @@ function searchScreeningEventTicketOffers(params) {
138
132
  return (repos) => __awaiter(this, void 0, void 0, function* () {
139
133
  var _a, _b, _c, _d;
140
134
  // イベント取得属性最適化(2023-01-23~)
141
- // const screeningEvent = await repos.event.findById<factory.eventType.ScreeningEvent>({ id: params.eventId });
142
135
  const screeningEvent = params.event;
143
136
  // 取得属性最適化(2023-01-25~)
144
137
  const superEvent = yield repos.event.findById({ id: screeningEvent.superEvent.id }, { soundFormat: 1, videoFormat: 1 });
145
138
  const soundFormatTypes = (Array.isArray(superEvent.soundFormat)) ? superEvent.soundFormat.map((f) => f.typeOf) : [];
146
139
  const videoFormatTypes = (Array.isArray(superEvent.videoFormat)) ? superEvent.videoFormat.map((f) => f.typeOf) : [];
140
+ const unacceptedPaymentMethod = getUnacceptedPaymentMethodByEvent({ event: screeningEvent });
141
+ // 上映方式がなければMovieTicket除外(2023-02-21~)
142
+ const excludeAppliesToMovieTicket = videoFormatTypes.length === 0;
147
143
  let availableOffers = [];
148
144
  // 興行設定があれば興行のカタログを参照する(2022-08-31~)
149
145
  const eventOffers = screeningEvent.offers;
@@ -154,6 +150,8 @@ function searchScreeningEventTicketOffers(params) {
154
150
  ids: params.ids,
155
151
  offerCatalog: { id: eventService.hasOfferCatalog.id },
156
152
  availableAtOrFrom: { id: (_c = params.store) === null || _c === void 0 ? void 0 : _c.id },
153
+ unacceptedPaymentMethod,
154
+ excludeAppliesToMovieTicket,
157
155
  sort: params.sort
158
156
  });
159
157
  }
@@ -163,16 +161,48 @@ function searchScreeningEventTicketOffers(params) {
163
161
  throw new factory.errors.NotFound('event.offers.itemOffered.id');
164
162
  }
165
163
  const { soundFormatChargeSpecifications, videoFormatChargeSpecifications, movieTicketTypeChargeSpecs } = yield searchPriceSpecs4event({ project: { id: screeningEvent.project.id }, soundFormatTypes, videoFormatTypes })(repos);
166
- const unacceptedPaymentMethod = getUnacceptedPaymentMethodByEvent({ event: screeningEvent });
167
164
  // 不許可決済方法があれば、該当オファーを除外
168
- if (Array.isArray(unacceptedPaymentMethod) && unacceptedPaymentMethod.length > 0) {
165
+ // Mongoオファー検索条件へ移行(2023-02-21~)
166
+ // if (Array.isArray(unacceptedPaymentMethod) && unacceptedPaymentMethod.length > 0) {
167
+ // availableOffers = availableOffers.filter((o) => {
168
+ // // 複数決済カード対応(2022-07-11~)
169
+ // const priceSpecificationAppliesToMovieTicket = o.priceSpecification?.appliesToMovieTicket;
170
+ // if (Array.isArray(priceSpecificationAppliesToMovieTicket)) {
171
+ // return priceSpecificationAppliesToMovieTicket.every((appliesToMovieTicket) => {
172
+ // return !unacceptedPaymentMethod.includes(appliesToMovieTicket.serviceOutput.typeOf);
173
+ // });
174
+ // } else {
175
+ // // Arrayでないケースは廃止(2022-09-10~)
176
+ // return true;
177
+ // }
178
+ // });
179
+ // }
180
+ // 決済カード加算料金が存在しない場合自動補完する(2023-02-21~)
181
+ if (!settings_1.settings.useOffersAppliedToMovieTicketWithoutChargeSpecification) {
182
+ // 適用決済カード条件がある場合、決済カード加算料金が存在しないオファーは除外する
169
183
  availableOffers = availableOffers.filter((o) => {
170
184
  var _a;
171
- // 複数決済カード対応(2022-07-11~)
185
+ // 複数決済カード対応(2022-07-26~)
172
186
  const priceSpecificationAppliesToMovieTicket = (_a = o.priceSpecification) === null || _a === void 0 ? void 0 : _a.appliesToMovieTicket;
173
187
  if (Array.isArray(priceSpecificationAppliesToMovieTicket)) {
188
+ // 適用決済カード数が0であれば除外
189
+ if (priceSpecificationAppliesToMovieTicket.length === 0) {
190
+ return false;
191
+ }
192
+ // 上映方式がなければ除外(2022-11-03~)
193
+ // if (videoFormatTypes.length === 0) {
194
+ // return false;
195
+ // }
174
196
  return priceSpecificationAppliesToMovieTicket.every((appliesToMovieTicket) => {
175
- return !unacceptedPaymentMethod.includes(appliesToMovieTicket.serviceOutput.typeOf);
197
+ // すべての上映方式について検証する(2022-10-29~)
198
+ return videoFormatTypes.every((videoFormat) => {
199
+ return movieTicketTypeChargeSpecs.some((s) => {
200
+ var _a, _b, _c, _d;
201
+ 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)
202
+ && ((_d = s.appliesToMovieTicket) === null || _d === void 0 ? void 0 : _d.serviceType) === appliesToMovieTicket.serviceType
203
+ && s.appliesToVideoFormat === videoFormat;
204
+ });
205
+ });
176
206
  });
177
207
  }
178
208
  else {
@@ -181,37 +211,12 @@ function searchScreeningEventTicketOffers(params) {
181
211
  }
182
212
  });
183
213
  }
184
- // 適用決済カード条件がある場合、決済カード加算料金が存在しないオファーは除外する
185
- availableOffers = availableOffers.filter((o) => {
186
- var _a;
187
- // 複数決済カード対応(2022-07-26~)
188
- const priceSpecificationAppliesToMovieTicket = (_a = o.priceSpecification) === null || _a === void 0 ? void 0 : _a.appliesToMovieTicket;
189
- if (Array.isArray(priceSpecificationAppliesToMovieTicket)) {
190
- // 適用決済カード数が0であれば除外
191
- if (priceSpecificationAppliesToMovieTicket.length === 0) {
192
- return false;
193
- }
194
- // 上映方式がなければ除外(2022-11-03~)
195
- if (videoFormatTypes.length === 0) {
196
- return false;
197
- }
198
- return priceSpecificationAppliesToMovieTicket.every((appliesToMovieTicket) => {
199
- // すべての上映方式について検証する(2022-10-29~)
200
- return videoFormatTypes.every((videoFormat) => {
201
- return movieTicketTypeChargeSpecs.some((s) => {
202
- var _a, _b, _c, _d;
203
- 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)
204
- && ((_d = s.appliesToMovieTicket) === null || _d === void 0 ? void 0 : _d.serviceType) === appliesToMovieTicket.serviceType
205
- && s.appliesToVideoFormat === videoFormat;
206
- });
207
- });
208
- });
209
- }
210
- else {
211
- // Arrayでないケースは廃止(2022-09-10~)
212
- return true;
213
- }
214
- });
214
+ // 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);
219
+ }
215
220
  let offers4event = availableOffers.map((availableOffer) => {
216
221
  return (0, factory_1.createCompoundPriceSpec4event)({
217
222
  eligibleQuantity: eventOffers.eligibleQuantity,
@@ -253,9 +258,6 @@ function getUnacceptedPaymentMethodByEvent(params) {
253
258
  const eventOffers = params.event.offers;
254
259
  const unacceptedPaymentMethodByEvent = eventOffers === null || eventOffers === void 0 ? void 0 : eventOffers.unacceptedPaymentMethod;
255
260
  // 施設コンテンツを参照する必要はない(2022-10-31~)
256
- // if (Array.isArray(unacceptedPaymentMethodBySuperEvent)) {
257
- // unacceptedPaymentMethod = unacceptedPaymentMethodBySuperEvent;
258
- // }
259
261
  // イベントにunacceptedPaymentMethod設定があれば上書き
260
262
  if (Array.isArray(unacceptedPaymentMethodByEvent)) {
261
263
  unacceptedPaymentMethod = unacceptedPaymentMethodByEvent;
@@ -345,6 +347,7 @@ function searchAddOns(params) {
345
347
  offers = yield repos.offer.findOffersByOfferCatalogId({
346
348
  offerCatalog: { id: offerCatalogId },
347
349
  availableAtOrFrom: { id: (_c = params.store) === null || _c === void 0 ? void 0 : _c.id },
350
+ excludeAppliesToMovieTicket: false,
348
351
  sort: true
349
352
  });
350
353
  offers = offers.map((o) => {
@@ -394,6 +397,8 @@ function searchEventTicketOffers(params) {
394
397
  ids: params.ids,
395
398
  event,
396
399
  store: params.store,
400
+ limit: params.limit,
401
+ page: params.page,
397
402
  sort: params.sort,
398
403
  validateOfferRateLimit: params.validateOfferRateLimit
399
404
  })(repos);
@@ -405,6 +410,8 @@ function searchEventTicketOffers(params) {
405
410
  ids: params.ids,
406
411
  event,
407
412
  store: params.store,
413
+ limit: params.limit,
414
+ page: params.page,
408
415
  sort: params.sort,
409
416
  validateOfferRateLimit: params.validateOfferRateLimit
410
417
  })(repos);
@@ -13,6 +13,7 @@ var __rest = (this && this.__rest) || function (s, e) {
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
14
  exports.createCompoundPriceSpec4event = void 0;
15
15
  const factory = require("../../factory");
16
+ const settings_1 = require("../../settings");
16
17
  function categoryCodeChargePriceSpec2component(params) {
17
18
  var _a;
18
19
  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);
@@ -21,6 +22,7 @@ function mvtkChargePriceSpec2component(params) {
21
22
  var _a;
22
23
  return Object.assign({ id: params.id, typeOf: params.typeOf, name: params.name, price: params.price, priceCurrency: params.priceCurrency, valueAddedTaxIncluded: params.valueAddedTaxIncluded, appliesToVideoFormat: params.appliesToVideoFormat, appliesToMovieTicket: params.appliesToMovieTicket }, (typeof ((_a = params.accounting) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string') ? { accounting: params.accounting } : undefined);
23
24
  }
25
+ // tslint:disable-next-line:max-func-body-length
24
26
  function createCompoundPriceSpec4event(params) {
25
27
  var _a;
26
28
  // priceSpecificationはマスタ管理の仕様上必ず存在するはず
@@ -39,19 +41,51 @@ function createCompoundPriceSpec4event(params) {
39
41
  const mvtkPriceComponents = [];
40
42
  // 複数決済カード対応(2022-07-11~)
41
43
  if (Array.isArray(unitPriceSpec.appliesToMovieTicket)) {
42
- unitPriceSpec.appliesToMovieTicket.forEach((appliesToMovieTicket) => {
43
- // すべての上映方式に該当する加算料金を追加(2022-10-29~)
44
- const mvtkSpecs4appliesToMovieTicket = params.movieTicketTypeChargeSpecs.filter((s) => {
45
- var _a;
46
- return ((_a = s.appliesToMovieTicket.serviceOutput) === null || _a === void 0 ? void 0 : _a.typeOf) === appliesToMovieTicket.serviceOutput.typeOf
47
- && s.appliesToMovieTicket.serviceType === appliesToMovieTicket.serviceType
48
- && params.videoFormatTypes.includes(s.appliesToVideoFormat);
44
+ // 決済カード加算料金自動補完(2023-02-21~)
45
+ if (settings_1.settings.useOffersAppliedToMovieTicketWithoutChargeSpecification) {
46
+ unitPriceSpec.appliesToMovieTicket.forEach((appliesToMovieTicket) => {
47
+ // すべての上映方式に該当する加算料金を追加
48
+ params.videoFormatTypes.forEach((videoFormatType) => {
49
+ let existingMvtkSpec4appliesToMovieTicket = params.movieTicketTypeChargeSpecs.find((s) => {
50
+ var _a;
51
+ return ((_a = s.appliesToMovieTicket.serviceOutput) === null || _a === void 0 ? void 0 : _a.typeOf) === appliesToMovieTicket.serviceOutput.typeOf
52
+ && s.appliesToMovieTicket.serviceType === appliesToMovieTicket.serviceType
53
+ && s.appliesToVideoFormat === videoFormatType;
54
+ });
55
+ // 加算料金が存在しなければprice: 0で自動補完
56
+ if (existingMvtkSpec4appliesToMovieTicket === undefined) {
57
+ existingMvtkSpec4appliesToMovieTicket = {
58
+ typeOf: factory.priceSpecificationType.MovieTicketTypeChargeSpecification,
59
+ price: 0,
60
+ priceCurrency: factory.priceCurrency.JPY,
61
+ appliesToVideoFormat: videoFormatType,
62
+ valueAddedTaxIncluded: true,
63
+ project: params.offer.project,
64
+ id: '',
65
+ name: params.offer.name,
66
+ appliesToMovieTicket: {
67
+ typeOf: factory.service.paymentService.PaymentServiceType.MovieTicket,
68
+ serviceType: appliesToMovieTicket.serviceType,
69
+ serviceOutput: { typeOf: appliesToMovieTicket.serviceOutput.typeOf }
70
+ }
71
+ };
72
+ }
73
+ mvtkPriceComponents.push(mvtkChargePriceSpec2component(existingMvtkSpec4appliesToMovieTicket));
74
+ });
49
75
  });
50
- mvtkPriceComponents.push(...mvtkSpecs4appliesToMovieTicket.map(mvtkChargePriceSpec2component));
51
- });
52
- }
53
- else {
54
- // Arrayでないケースは廃止(2022-09-12~)
76
+ }
77
+ else {
78
+ unitPriceSpec.appliesToMovieTicket.forEach((appliesToMovieTicket) => {
79
+ // すべての上映方式に該当する加算料金を追加(2022-10-29~)
80
+ const mvtkSpecs4appliesToMovieTicket = params.movieTicketTypeChargeSpecs.filter((s) => {
81
+ var _a;
82
+ return ((_a = s.appliesToMovieTicket.serviceOutput) === null || _a === void 0 ? void 0 : _a.typeOf) === appliesToMovieTicket.serviceOutput.typeOf
83
+ && s.appliesToMovieTicket.serviceType === appliesToMovieTicket.serviceType
84
+ && params.videoFormatTypes.includes(s.appliesToVideoFormat);
85
+ });
86
+ mvtkPriceComponents.push(...mvtkSpecs4appliesToMovieTicket.map(mvtkChargePriceSpec2component));
87
+ });
88
+ }
55
89
  }
56
90
  // 区分加算料金は決済カード適用でも価格要素に含まれるはず(2022-11-02~)
57
91
  const priceComponent = [
@@ -23,7 +23,11 @@ function searchProductOffers(params) {
23
23
  if (typeof offerCatalogId !== 'string') {
24
24
  return [];
25
25
  }
26
- const offers = yield repos.offer.findOffersByOfferCatalogId({ offerCatalog: { id: offerCatalogId }, sort: params.sort });
26
+ const offers = yield repos.offer.findOffersByOfferCatalogId({
27
+ offerCatalog: { id: offerCatalogId },
28
+ excludeAppliesToMovieTicket: false,
29
+ sort: params.sort
30
+ });
27
31
  return offers.map((o) => {
28
32
  const unitSpec = o.priceSpecification;
29
33
  const compoundPriceSpecification = {
@@ -22,6 +22,7 @@ export declare type ISettings = factory.project.ISettings & {
22
22
  userPoolIdNew: string;
23
23
  maxNumCreditCardPaymentMethod?: number;
24
24
  useEventWorkPerformed: boolean;
25
+ useOffersAppliedToMovieTicketWithoutChargeSpecification: boolean;
25
26
  };
26
27
  export declare const DEFAULT_PAYMENT_METHOD_TYPE_FOR_CREDIT_CARD: string;
27
28
  export declare const USE_ASSET_TRANSACTION_SYNC_PROCESSING: boolean;
@@ -94,4 +94,4 @@ 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' });
97
+ : undefined), { useEventWorkPerformed: process.env.USE_EVENT_WORK_PERFORMED === '1', useOffersAppliedToMovieTicketWithoutChargeSpecification: process.env.USE_OFFERS_APPLIED_TO_MOVIE_TICKET_WITHOUT_PRICE_SPEC === '1' });
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  }
10
10
  ],
11
11
  "dependencies": {
12
- "@chevre/factory": "4.289.0-alpha.9",
12
+ "@chevre/factory": "4.289.0-alpha.11",
13
13
  "@cinerino/sdk": "3.140.0-alpha.11",
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.10"
123
+ "version": "20.4.0-alpha.12"
124
124
  }