@chevre/domain 20.4.0-alpha.1 → 20.4.0-alpha.11

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.
Files changed (53) hide show
  1. package/example/src/chevre/createManyEventsIfNotExist.ts +10 -10
  2. package/example/src/chevre/migrateMoneyTransferPendingTransactionIdentifier.ts +96 -0
  3. package/example/src/chevre/searchEventTicketOffers.ts +1 -2
  4. package/example/src/chevre/unsetUnnecessaryFields.ts +32 -0
  5. package/lib/chevre/repo/account.d.ts +4 -10
  6. package/lib/chevre/repo/account.js +72 -60
  7. package/lib/chevre/repo/accountTransaction.d.ts +0 -1
  8. package/lib/chevre/repo/accountTransaction.js +1 -1
  9. package/lib/chevre/repo/assetTransaction.d.ts +1 -0
  10. package/lib/chevre/repo/assetTransaction.js +5 -0
  11. package/lib/chevre/repo/event.js +7 -1
  12. package/lib/chevre/repo/mongoose/model/comments.d.ts +1 -1
  13. package/lib/chevre/repo/mongoose/model/comments.js +1 -1
  14. package/lib/chevre/repo/offer.d.ts +1 -0
  15. package/lib/chevre/repo/offer.js +34 -35
  16. package/lib/chevre/repo/serviceOutput.d.ts +4 -0
  17. package/lib/chevre/repo/serviceOutput.js +6 -0
  18. package/lib/chevre/repository.d.ts +6 -3
  19. package/lib/chevre/repository.js +8 -5
  20. package/lib/chevre/service/account.d.ts +0 -8
  21. package/lib/chevre/service/account.js +16 -37
  22. package/lib/chevre/service/accountTransaction/deposit.js +2 -5
  23. package/lib/chevre/service/accountTransaction/factory.js +36 -40
  24. package/lib/chevre/service/accountTransaction/transfer.js +4 -6
  25. package/lib/chevre/service/accountTransaction/withdraw.js +2 -5
  26. package/lib/chevre/service/accountTransaction.js +1 -1
  27. package/lib/chevre/service/assetTransaction/moneyTransfer.js +19 -11
  28. package/lib/chevre/service/assetTransaction/pay.js +17 -11
  29. package/lib/chevre/service/assetTransaction/registerService/factory.js +9 -4
  30. package/lib/chevre/service/delivery.js +12 -3
  31. package/lib/chevre/service/event.js +3 -23
  32. package/lib/chevre/service/moneyTransfer.d.ts +1 -1
  33. package/lib/chevre/service/moneyTransfer.js +8 -9
  34. package/lib/chevre/service/offer/event/authorize.js +0 -1
  35. package/lib/chevre/service/offer/event/searchEventTicketOffers.d.ts +2 -4
  36. package/lib/chevre/service/offer/event/searchEventTicketOffers.js +35 -39
  37. package/lib/chevre/service/offer/moneyTransfer/authorize.js +0 -1
  38. package/lib/chevre/service/offer/moneyTransfer/returnMoneyTransfer.js +0 -1
  39. package/lib/chevre/service/payment/paymentCard.d.ts +6 -2
  40. package/lib/chevre/service/payment/paymentCard.js +16 -8
  41. package/lib/chevre/service/permit.d.ts +5 -1
  42. package/lib/chevre/service/permit.js +18 -11
  43. package/lib/chevre/service/transaction/moneyTransfer.js +0 -1
  44. package/lib/chevre/settings.d.ts +1 -0
  45. package/lib/chevre/settings.js +2 -2
  46. package/package.json +3 -3
  47. package/example/src/chevre/migrateAccountTitleAdditionalProperties.ts +0 -157
  48. package/example/src/chevre/migrateProjectSubscription.ts +0 -51
  49. package/example/src/chevre/migrateSection.ts +0 -105
  50. package/lib/chevre/repo/accountAction.d.ts +0 -42
  51. package/lib/chevre/repo/accountAction.js +0 -474
  52. package/lib/chevre/repo/mongoose/model/accountAction.d.ts +0 -7
  53. package/lib/chevre/repo/mongoose/model/accountAction.js +0 -177
@@ -220,26 +220,32 @@ function validateSeller(params) {
220
220
  }
221
221
  function processAuthorizeAccount(params, transaction, paymentServiceId) {
222
222
  return (repos) => __awaiter(this, void 0, void 0, function* () {
223
+ var _a;
224
+ const amount = (_a = params.object.paymentMethod) === null || _a === void 0 ? void 0 : _a.amount;
225
+ if (typeof amount !== 'number') {
226
+ throw new factory.errors.ArgumentNull('object.paymentMethod?.amount');
227
+ }
223
228
  yield (0, validation_1.validateAccount)(params)(repos);
224
- const authorizeResult = yield PaymentCardPayment.authorize(params, paymentServiceId)(repos);
229
+ const { pendingTransaction, currency, accountNumber } = yield PaymentCardPayment.authorize(params, paymentServiceId)(repos);
225
230
  const totalPaymentDue = {
226
231
  typeOf: 'MonetaryAmount',
227
- currency: authorizeResult.object.fromLocation.accountType,
228
- value: (typeof authorizeResult.object.amount === 'number')
229
- ? authorizeResult.object.amount
230
- : authorizeResult.object.amount.value
232
+ currency,
233
+ value: amount
234
+ // value: (typeof pendingTransaction.object.amount === 'number')
235
+ // ? pendingTransaction.object.amount
236
+ // : pendingTransaction.object.amount.value
231
237
  };
232
- const pendingTransaction = {
233
- typeOf: authorizeResult.typeOf,
234
- id: authorizeResult.id,
235
- transactionNumber: authorizeResult.transactionNumber,
236
- object: { fromLocation: { accountNumber: authorizeResult.object.fromLocation.accountNumber } }
238
+ const savingPendingTransaction = {
239
+ typeOf: pendingTransaction.typeOf,
240
+ id: pendingTransaction.id,
241
+ transactionNumber: pendingTransaction.transactionNumber,
242
+ object: { fromLocation: { accountNumber } }
237
243
  };
238
244
  return saveAuthorizeResult({
239
245
  id: transaction.id,
240
246
  update: {
241
247
  'object.paymentMethod.totalPaymentDue': totalPaymentDue,
242
- 'object.pendingTransaction': pendingTransaction
248
+ 'object.pendingTransaction': savingPendingTransaction
243
249
  }
244
250
  })(repos);
245
251
  });
@@ -58,13 +58,15 @@ function createServiceOutput(params) {
58
58
  throw new factory.errors.ArgumentNull('object.itemOffered.serviceOutput.accessCode');
59
59
  }
60
60
  paymentAccount = {
61
- project: { typeOf: product.project.typeOf, id: product.project.id },
61
+ // 廃止(2023-02-20~)
62
+ // project: { typeOf: product.project.typeOf, id: product.project.id },
62
63
  // ひとまず固定
63
64
  // 口座は複数のプロダクトに結合する可能性もあり、どのように利用されるかは知らない。ただbalanceを管理するだけ。通貨は知っている。
64
65
  typeOf: factory.accountType.Account,
65
66
  // ひとまずPermit識別子と口座番号は同一
66
- accountNumber: identifier,
67
- accountType: amount.currency
67
+ accountNumber: identifier
68
+ // 廃止(2023-02-16~)
69
+ // accountType: amount.currency
68
70
  };
69
71
  break;
70
72
  case factory.product.ProductType.MembershipService:
@@ -73,7 +75,10 @@ function createServiceOutput(params) {
73
75
  default:
74
76
  throw new factory.errors.NotImplemented(`Product type ${product.typeOf} not implemented`);
75
77
  }
76
- const issuedThrough = Object.assign({ project: { typeOf: product.project.typeOf, id: product.project.id }, typeOf: product.typeOf, id: product.id }, (typeof ((_m = product.serviceType) === null || _m === void 0 ? void 0 : _m.typeOf) === 'string') ? { serviceType: product.serviceType } : undefined);
78
+ const issuedThrough = Object.assign({
79
+ // 廃止(2023-02-20~)
80
+ // project: { typeOf: product.project.typeOf, id: product.project.id },
81
+ typeOf: product.typeOf, id: product.id }, (typeof ((_m = product.serviceType) === null || _m === void 0 ? void 0 : _m.typeOf) === 'string') ? { serviceType: product.serviceType } : undefined);
77
82
  return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ project: { typeOf: product.project.typeOf, id: product.project.id }, identifier: identifier, issuedThrough, typeOf: serviceOutputType, dateIssued: params.dateIssued }, (typeof accessCode === 'string') ? { accessCode } : undefined), (Array.isArray(additionalProperty)) ? { additionalProperty } : undefined), (typeof validFor === 'string') ? { validFor } : undefined), (name !== undefined) ? { name } : undefined), (amount !== undefined) ? { amount } : undefined), (depositAmount !== undefined) ? { depositAmount } : undefined), (paymentAmount !== undefined) ? { paymentAmount } : undefined), (paymentAccount !== undefined) ? { paymentAccount } : undefined), (issuedBy !== undefined) ? { issuedBy } : undefined);
78
83
  }
79
84
  exports.createServiceOutput = createServiceOutput;
@@ -88,7 +88,10 @@ function createGivePointAwardStartParams4moneyTransfer(params, transactionNumber
88
88
  : params.purpose.typeOf,
89
89
  fromLocation: agent,
90
90
  toLocation,
91
- pendingTransaction: { typeOf: factory.account.transactionType.Deposit, id: '', transactionNumber }
91
+ pendingTransaction: {
92
+ typeOf: factory.account.transactionType.Deposit,
93
+ transactionNumber
94
+ }
92
95
  } }, (typeof params.object.identifier === 'string') ? { identifier: params.object.identifier } : undefined);
93
96
  }
94
97
  /**
@@ -181,7 +184,10 @@ function processReturnPointAwardByTransactionIdentifier(params) {
181
184
  fromLocation,
182
185
  toLocation: depositTransaction.object.fromLocation,
183
186
  description: `[Return Award]${depositTransaction.object.description}`,
184
- pendingTransaction: { typeOf: factory.account.transactionType.Withdraw, id: '', transactionNumber },
187
+ pendingTransaction: {
188
+ typeOf: factory.account.transactionType.Withdraw,
189
+ transactionNumber
190
+ },
185
191
  force: true
186
192
  }
187
193
  })(repos);
@@ -260,7 +266,10 @@ function processReturnPointAwardByTransactionFromLocationIdentifier(params) {
260
266
  // },
261
267
  toLocation,
262
268
  description: `[Return Award]${returningTransaction.object.description}`,
263
- pendingTransaction: { typeOf: factory.account.transactionType.Transfer, id: '', transactionNumber },
269
+ pendingTransaction: {
270
+ typeOf: factory.account.transactionType.Transfer,
271
+ transactionNumber
272
+ },
264
273
  force: true
265
274
  }
266
275
  })(repos);
@@ -21,6 +21,7 @@ const difference = require("lodash.difference");
21
21
  const moment = require("moment-timezone");
22
22
  const credentials_1 = require("../credentials");
23
23
  const factory = require("../factory");
24
+ const settings_1 = require("../settings");
24
25
  const offer_1 = require("./offer");
25
26
  // const customsearch = google.customsearch('v1');
26
27
  const debug = createDebug('chevre-domain:service:event');
@@ -449,32 +450,11 @@ function createScreeningEventFromCOA(params) {
449
450
  priceCurrency: factory.priceCurrency.JPY
450
451
  };
451
452
  const { additionalProperty, coaInfo } = createScreeningEventAdditionalPropertyFromCOA(params);
452
- return {
453
- project: { typeOf: params.project.typeOf, id: params.project.id },
454
- typeOf: factory.eventType.ScreeningEvent,
455
- id: id,
456
- identifier: id,
457
- name: params.superEvent.name,
458
- eventStatus: factory.eventStatusType.EventScheduled,
459
- workPerformed: params.superEvent.workPerformed,
460
- location: {
461
- // 不要なので廃止(2022-12-19~)
462
- // project: { typeOf: params.project.typeOf, id: params.project.id },
453
+ return Object.assign({ project: { typeOf: params.project.typeOf, id: params.project.id }, typeOf: factory.eventType.ScreeningEvent, id: id, identifier: id, name: params.superEvent.name, eventStatus: factory.eventStatusType.EventScheduled, location: {
463
454
  typeOf: params.screenRoom.typeOf,
464
455
  branchCode: params.screenRoom.branchCode,
465
456
  name: params.screenRoom.name
466
- },
467
- endDate: endDate,
468
- startDate: startDate,
469
- superEvent: params.superEvent,
470
- coaInfo,
471
- offers: offers,
472
- checkInCount: 0,
473
- attendeeCount: 0,
474
- maximumAttendeeCapacity: params.screenRoom.maximumAttendeeCapacity,
475
- remainingAttendeeCapacity: params.screenRoom.maximumAttendeeCapacity,
476
- additionalProperty
477
- };
457
+ }, endDate: endDate, startDate: startDate, superEvent: params.superEvent, coaInfo, offers: offers, checkInCount: 0, attendeeCount: 0, maximumAttendeeCapacity: params.screenRoom.maximumAttendeeCapacity, remainingAttendeeCapacity: params.screenRoom.maximumAttendeeCapacity, additionalProperty }, (settings_1.settings.useEventWorkPerformed) ? { workPerformed: params.superEvent.workPerformed } : undefined);
478
458
  }
479
459
  function createScreeningEventAdditionalPropertyFromCOA(params) {
480
460
  const coaInfo = {
@@ -52,7 +52,7 @@ export declare function authorize(params: {
52
52
  typeOf: factory.assetTransactionType;
53
53
  id: string;
54
54
  };
55
- }): IAuthorizeOperation<factory.action.transfer.moneyTransfer.IPendingTransaction>;
55
+ }): IAuthorizeOperation<void>;
56
56
  /**
57
57
  * 口座承認取消
58
58
  */
@@ -28,9 +28,9 @@ function authorize(params) {
28
28
  id: params.purpose.id
29
29
  });
30
30
  // 口座取引開始
31
- let pendingTransaction;
31
+ // let pendingTransaction: factory.action.transfer.moneyTransfer.IPendingTransaction;
32
32
  try {
33
- pendingTransaction = yield processAccountTransaction({
33
+ yield processAccountTransaction({
34
34
  typeOf: params.typeOf,
35
35
  identifier: params.identifier,
36
36
  transactionNumber: params.transactionNumber,
@@ -46,13 +46,12 @@ function authorize(params) {
46
46
  error = (0, errorHandler_1.handlePecorinoError)(error);
47
47
  throw error;
48
48
  }
49
- return pendingTransaction;
49
+ // return pendingTransaction;
50
50
  });
51
51
  }
52
52
  exports.authorize = authorize;
53
53
  function processAccountTransaction(params) {
54
54
  return (repos) => __awaiter(this, void 0, void 0, function* () {
55
- let pendingTransaction;
56
55
  const transaction = params.transaction;
57
56
  const agent = createAccountTransactionAgent(params);
58
57
  const recipient = createAccountTransactionRecipient(params);
@@ -75,7 +74,7 @@ function processAccountTransaction(params) {
75
74
  });
76
75
  switch (params.typeOf) {
77
76
  case factory.account.transactionType.Deposit:
78
- pendingTransaction = yield processDepositTransaction({
77
+ yield processDepositTransaction({
79
78
  identifier: params.identifier,
80
79
  transactionNumber: params.transactionNumber,
81
80
  project: params.project,
@@ -88,7 +87,7 @@ function processAccountTransaction(params) {
88
87
  })({ permit: permitService });
89
88
  break;
90
89
  case factory.account.transactionType.Transfer:
91
- pendingTransaction = yield processTransferTransaction({
90
+ yield processTransferTransaction({
92
91
  identifier: params.identifier,
93
92
  transactionNumber: params.transactionNumber,
94
93
  project: params.project,
@@ -101,7 +100,7 @@ function processAccountTransaction(params) {
101
100
  })({ permit: permitService });
102
101
  break;
103
102
  case factory.account.transactionType.Withdraw:
104
- pendingTransaction = yield processWithdrawTransaction({
103
+ yield processWithdrawTransaction({
105
104
  identifier: params.identifier,
106
105
  transactionNumber: params.transactionNumber,
107
106
  project: params.project,
@@ -116,7 +115,7 @@ function processAccountTransaction(params) {
116
115
  default:
117
116
  throw new factory.errors.Argument('Object', 'At least one of accounts from and to must be specified');
118
117
  }
119
- return pendingTransaction;
118
+ // return pendingTransaction;
120
119
  });
121
120
  }
122
121
  function processDepositTransaction(params) {
@@ -513,7 +512,7 @@ function processDepositFromNow(params, permitServiceCredentials, transactionNumb
513
512
  recipient, object: {
514
513
  amount: { value: amount },
515
514
  description: description,
516
- fromLocation: params.fromLocation,
515
+ // fromLocation: params.fromLocation,
517
516
  toLocation: { accountNumber: String((_a = permit.paymentAccount) === null || _a === void 0 ? void 0 : _a.accountNumber) }
518
517
  } }, (typeof accountTransactionIdentifier === 'string') ? { identifier: accountTransactionIdentifier } : undefined));
519
518
  try {
@@ -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<{
@@ -23,6 +23,7 @@ function searchTransportationEventTicketOffers(params) {
23
23
  const screeningEvent = params.event;
24
24
  const soundFormatTypes = [];
25
25
  const videoFormatTypes = [];
26
+ const unacceptedPaymentMethod = getUnacceptedPaymentMethodByEvent({ event: screeningEvent });
26
27
  let availableOffers = [];
27
28
  // 興行設定があれば興行のカタログを参照する(2022-08-31~)
28
29
  const eventOffers = screeningEvent.offers;
@@ -33,6 +34,7 @@ function searchTransportationEventTicketOffers(params) {
33
34
  ids: params.ids,
34
35
  offerCatalog: { id: transportation.hasOfferCatalog.id },
35
36
  availableAtOrFrom: { id: (_c = params.store) === null || _c === void 0 ? void 0 : _c.id },
37
+ unacceptedPaymentMethod,
36
38
  sort: params.sort
37
39
  });
38
40
  }
@@ -42,24 +44,6 @@ function searchTransportationEventTicketOffers(params) {
42
44
  throw new factory.errors.NotFound('event.offers.itemOffered.id');
43
45
  }
44
46
  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
47
  // 適用決済カード条件がある場合、決済カード加算料金が存在しないオファーは除外する
64
48
  availableOffers = availableOffers.filter((o) => {
65
49
  var _a;
@@ -91,6 +75,12 @@ function searchTransportationEventTicketOffers(params) {
91
75
  return true;
92
76
  }
93
77
  });
78
+ // paging処理を追加(2023-02-21~)
79
+ if (typeof params.limit === 'number' && typeof params.page === 'number') {
80
+ const start = params.limit * (params.page - 1);
81
+ const end = params.limit * params.page;
82
+ availableOffers = availableOffers.slice(start, end);
83
+ }
94
84
  let offers4event = availableOffers.map((availableOffer) => {
95
85
  return (0, factory_1.createCompoundPriceSpec4event)({
96
86
  eligibleQuantity: eventOffers.eligibleQuantity,
@@ -138,12 +128,12 @@ function searchScreeningEventTicketOffers(params) {
138
128
  return (repos) => __awaiter(this, void 0, void 0, function* () {
139
129
  var _a, _b, _c, _d;
140
130
  // イベント取得属性最適化(2023-01-23~)
141
- // const screeningEvent = await repos.event.findById<factory.eventType.ScreeningEvent>({ id: params.eventId });
142
131
  const screeningEvent = params.event;
143
132
  // 取得属性最適化(2023-01-25~)
144
133
  const superEvent = yield repos.event.findById({ id: screeningEvent.superEvent.id }, { soundFormat: 1, videoFormat: 1 });
145
134
  const soundFormatTypes = (Array.isArray(superEvent.soundFormat)) ? superEvent.soundFormat.map((f) => f.typeOf) : [];
146
135
  const videoFormatTypes = (Array.isArray(superEvent.videoFormat)) ? superEvent.videoFormat.map((f) => f.typeOf) : [];
136
+ const unacceptedPaymentMethod = getUnacceptedPaymentMethodByEvent({ event: screeningEvent });
147
137
  let availableOffers = [];
148
138
  // 興行設定があれば興行のカタログを参照する(2022-08-31~)
149
139
  const eventOffers = screeningEvent.offers;
@@ -154,6 +144,7 @@ function searchScreeningEventTicketOffers(params) {
154
144
  ids: params.ids,
155
145
  offerCatalog: { id: eventService.hasOfferCatalog.id },
156
146
  availableAtOrFrom: { id: (_c = params.store) === null || _c === void 0 ? void 0 : _c.id },
147
+ unacceptedPaymentMethod,
157
148
  sort: params.sort
158
149
  });
159
150
  }
@@ -163,24 +154,22 @@ function searchScreeningEventTicketOffers(params) {
163
154
  throw new factory.errors.NotFound('event.offers.itemOffered.id');
164
155
  }
165
156
  const { soundFormatChargeSpecifications, videoFormatChargeSpecifications, movieTicketTypeChargeSpecs } = yield searchPriceSpecs4event({ project: { id: screeningEvent.project.id }, soundFormatTypes, videoFormatTypes })(repos);
166
- const unacceptedPaymentMethod = getUnacceptedPaymentMethodByEvent({ event: screeningEvent });
167
157
  // 不許可決済方法があれば、該当オファーを除外
168
- if (Array.isArray(unacceptedPaymentMethod) && unacceptedPaymentMethod.length > 0) {
169
- availableOffers = availableOffers.filter((o) => {
170
- var _a;
171
- // 複数決済カード対応(2022-07-11~)
172
- const priceSpecificationAppliesToMovieTicket = (_a = o.priceSpecification) === null || _a === void 0 ? void 0 : _a.appliesToMovieTicket;
173
- if (Array.isArray(priceSpecificationAppliesToMovieTicket)) {
174
- return priceSpecificationAppliesToMovieTicket.every((appliesToMovieTicket) => {
175
- return !unacceptedPaymentMethod.includes(appliesToMovieTicket.serviceOutput.typeOf);
176
- });
177
- }
178
- else {
179
- // Arrayでないケースは廃止(2022-09-10~)
180
- return true;
181
- }
182
- });
183
- }
158
+ // Mongoオファー検索条件へ移行(2023-02-21~)
159
+ // if (Array.isArray(unacceptedPaymentMethod) && unacceptedPaymentMethod.length > 0) {
160
+ // availableOffers = availableOffers.filter((o) => {
161
+ // // 複数決済カード対応(2022-07-11~)
162
+ // const priceSpecificationAppliesToMovieTicket = o.priceSpecification?.appliesToMovieTicket;
163
+ // if (Array.isArray(priceSpecificationAppliesToMovieTicket)) {
164
+ // return priceSpecificationAppliesToMovieTicket.every((appliesToMovieTicket) => {
165
+ // return !unacceptedPaymentMethod.includes(appliesToMovieTicket.serviceOutput.typeOf);
166
+ // });
167
+ // } else {
168
+ // // Arrayでないケースは廃止(2022-09-10~)
169
+ // return true;
170
+ // }
171
+ // });
172
+ // }
184
173
  // 適用決済カード条件がある場合、決済カード加算料金が存在しないオファーは除外する
185
174
  availableOffers = availableOffers.filter((o) => {
186
175
  var _a;
@@ -212,6 +201,12 @@ function searchScreeningEventTicketOffers(params) {
212
201
  return true;
213
202
  }
214
203
  });
204
+ // paging処理を追加(2023-02-21~)
205
+ if (typeof params.limit === 'number' && typeof params.page === 'number') {
206
+ const start = params.limit * (params.page - 1);
207
+ const end = params.limit * params.page;
208
+ availableOffers = availableOffers.slice(start, end);
209
+ }
215
210
  let offers4event = availableOffers.map((availableOffer) => {
216
211
  return (0, factory_1.createCompoundPriceSpec4event)({
217
212
  eligibleQuantity: eventOffers.eligibleQuantity,
@@ -253,9 +248,6 @@ function getUnacceptedPaymentMethodByEvent(params) {
253
248
  const eventOffers = params.event.offers;
254
249
  const unacceptedPaymentMethodByEvent = eventOffers === null || eventOffers === void 0 ? void 0 : eventOffers.unacceptedPaymentMethod;
255
250
  // 施設コンテンツを参照する必要はない(2022-10-31~)
256
- // if (Array.isArray(unacceptedPaymentMethodBySuperEvent)) {
257
- // unacceptedPaymentMethod = unacceptedPaymentMethodBySuperEvent;
258
- // }
259
251
  // イベントにunacceptedPaymentMethod設定があれば上書き
260
252
  if (Array.isArray(unacceptedPaymentMethodByEvent)) {
261
253
  unacceptedPaymentMethod = unacceptedPaymentMethodByEvent;
@@ -394,6 +386,8 @@ function searchEventTicketOffers(params) {
394
386
  ids: params.ids,
395
387
  event,
396
388
  store: params.store,
389
+ limit: params.limit,
390
+ page: params.page,
397
391
  sort: params.sort,
398
392
  validateOfferRateLimit: params.validateOfferRateLimit
399
393
  })(repos);
@@ -405,6 +399,8 @@ function searchEventTicketOffers(params) {
405
399
  ids: params.ids,
406
400
  event,
407
401
  store: params.store,
402
+ limit: params.limit,
403
+ page: params.page,
408
404
  sort: params.sort,
409
405
  validateOfferRateLimit: params.validateOfferRateLimit
410
406
  })(repos);
@@ -158,7 +158,6 @@ function processStartDepositTransaction(params) {
158
158
  description: description,
159
159
  pendingTransaction: {
160
160
  typeOf: factory.account.transactionType.Deposit,
161
- id: '',
162
161
  transactionNumber: params.transactionNumber
163
162
  }
164
163
  },
@@ -57,7 +57,6 @@ function returnMoneyTransfer(params) {
57
57
  toLocation: depositTransaction.object.fromLocation,
58
58
  pendingTransaction: {
59
59
  typeOf: factory.account.transactionType.Withdraw,
60
- id: '',
61
60
  transactionNumber: publishTransactionNumber4returnMoneyTransferResult.transactionNumber
62
61
  }
63
62
  }
@@ -6,11 +6,15 @@ import { MongoRepository as ProductRepo } from '../../repo/product';
6
6
  import { MongoRepository as ProjectRepo } from '../../repo/project';
7
7
  import { MongoRepository as TaskRepo } from '../../repo/task';
8
8
  import { RedisRepository as TransactionNumberRepo } from '../../repo/transactionNumber';
9
- declare type IPendingTransaction = factory.account.transaction.withdraw.ITransaction;
9
+ declare type IPendingTransaction = Pick<factory.account.transaction.withdraw.ITransaction, 'id' | 'transactionNumber' | 'typeOf'>;
10
10
  declare function authorize(params: factory.assetTransaction.pay.IStartParamsWithoutDetail, paymentServiceId: string): (repos: {
11
11
  product: ProductRepo;
12
12
  project: ProjectRepo;
13
- }) => Promise<IPendingTransaction>;
13
+ }) => Promise<{
14
+ pendingTransaction: IPendingTransaction;
15
+ currency: string;
16
+ accountNumber: string;
17
+ }>;
14
18
  declare function voidTransaction(params: factory.task.voidPayment.IData): (repos: {
15
19
  product: ProductRepo;
16
20
  }) => Promise<void>;
@@ -29,7 +29,7 @@ function authorize(params, paymentServiceId) {
29
29
  throw new factory.errors.ArgumentNull('transactionNumber');
30
30
  }
31
31
  // 決済方法検証
32
- const permit = yield validatePaymentMethod(params, paymentServiceId)(repos);
32
+ const { permit, currency } = yield validatePaymentMethod(params, paymentServiceId)(repos);
33
33
  const accountNumber = (_a = permit.paymentAccount) === null || _a === void 0 ? void 0 : _a.accountNumber;
34
34
  if (typeof accountNumber !== 'string') {
35
35
  throw new factory.errors.ArgumentNull('permit.paymentAccount.accountNumber');
@@ -55,13 +55,13 @@ function authorize(params, paymentServiceId) {
55
55
  // PecorinoAPIのエラーをハンドリング
56
56
  throw (0, errorHandler_1.handlePecorinoError)(error);
57
57
  }
58
- return pendingTransaction;
58
+ return { pendingTransaction, currency, accountNumber };
59
59
  });
60
60
  }
61
61
  exports.authorize = authorize;
62
62
  function validatePaymentMethod(params, paymentServiceId) {
63
63
  return (repos) => __awaiter(this, void 0, void 0, function* () {
64
- var _a, _b, _c, _d, _e, _f, _g, _h;
64
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
65
65
  const serviceOutputIdentifier = (_a = params.object.paymentMethod) === null || _a === void 0 ? void 0 : _a.accountId;
66
66
  const amount = (_b = params.object.paymentMethod) === null || _b === void 0 ? void 0 : _b.amount;
67
67
  const paymentMethodType = (_c = params.object.paymentMethod) === null || _c === void 0 ? void 0 : _c.typeOf;
@@ -74,6 +74,14 @@ function validatePaymentMethod(params, paymentServiceId) {
74
74
  if (typeof paymentMethodType !== 'string') {
75
75
  throw new factory.errors.ArgumentNull('object.paymentMethod.typeOf');
76
76
  }
77
+ // プロダクトから通貨区分を取得
78
+ const paymentCatdProduct = yield repos.product.findById({
79
+ id: paymentServiceId
80
+ });
81
+ const currency = (_e = (_d = paymentCatdProduct.serviceOutput) === null || _d === void 0 ? void 0 : _d.amount) === null || _e === void 0 ? void 0 : _e.currency;
82
+ if (typeof currency !== 'string') {
83
+ throw new factory.errors.NotFound('product.serviceOutput.amount.currency');
84
+ }
77
85
  // プロダクトのavailableChannelを取得する
78
86
  const availableChannel = yield repos.product.findAvailableChannel({
79
87
  project: { id: params.project.id },
@@ -83,9 +91,9 @@ function validatePaymentMethod(params, paymentServiceId) {
83
91
  const permitService = new pecorinoapi.service.Permit({
84
92
  endpoint: String(availableChannel.serviceUrl),
85
93
  auth: new pecorinoapi.auth.ClientCredentials({
86
- domain: String((_d = availableChannel.credentials) === null || _d === void 0 ? void 0 : _d.authorizeServerDomain),
87
- clientId: String((_e = availableChannel.credentials) === null || _e === void 0 ? void 0 : _e.clientId),
88
- clientSecret: String((_f = availableChannel.credentials) === null || _f === void 0 ? void 0 : _f.clientSecret),
94
+ domain: String((_f = availableChannel.credentials) === null || _f === void 0 ? void 0 : _f.authorizeServerDomain),
95
+ clientId: String((_g = availableChannel.credentials) === null || _g === void 0 ? void 0 : _g.clientId),
96
+ clientSecret: String((_h = availableChannel.credentials) === null || _h === void 0 ? void 0 : _h.clientSecret),
89
97
  scopes: [],
90
98
  state: ''
91
99
  })
@@ -97,7 +105,7 @@ function validatePaymentMethod(params, paymentServiceId) {
97
105
  issuedThrough: { typeOf: factory.product.ProductType.PaymentCard }
98
106
  });
99
107
  // サービスタイプを確認
100
- if (((_h = (_g = serviceOutput.issuedThrough) === null || _g === void 0 ? void 0 : _g.serviceType) === null || _h === void 0 ? void 0 : _h.codeValue) !== paymentMethodType) {
108
+ if (((_k = (_j = serviceOutput.issuedThrough) === null || _j === void 0 ? void 0 : _j.serviceType) === null || _k === void 0 ? void 0 : _k.codeValue) !== paymentMethodType) {
101
109
  throw new factory.errors.Argument('object.paymentMethod.accountId', 'paymentMethodType not matched');
102
110
  }
103
111
  // 出金金額設定を確認
@@ -112,7 +120,7 @@ function validatePaymentMethod(params, paymentServiceId) {
112
120
  throw new factory.errors.Argument('object.paymentMethod.amount', `maximum payment amount requirement not satisfied`);
113
121
  }
114
122
  }
115
- return serviceOutput;
123
+ return { permit: serviceOutput, currency };
116
124
  });
117
125
  }
118
126
  function processAccountTransaction(params) {
@@ -30,6 +30,9 @@ export declare function activate(params: {
30
30
  }): (repos: {
31
31
  serviceOutput: ServiceOutputRepo;
32
32
  }) => Promise<factory.permit.IPermit>;
33
+ declare type IPermitWithAccountDetail = Omit<factory.permit.IPermit, 'paymentAccount'> & {
34
+ paymentAccount?: factory.permit.IPaymentAccountWithDetail;
35
+ };
33
36
  /**
34
37
  * プロジェクト指定で、許可証を検索する(ペイメントカードプロダクトの場合、口座詳細込み)
35
38
  */
@@ -38,4 +41,5 @@ export declare function search(project: {
38
41
  }, params: factory.product.IServiceOutputSearchConditions, projection?: any): (repos: {
39
42
  account: AccountRepo;
40
43
  serviceOutput: ServiceOutputRepo;
41
- }) => Promise<factory.permit.IPermit[]>;
44
+ }) => Promise<IPermitWithAccountDetail[]>;
45
+ export {};
@@ -78,33 +78,40 @@ exports.activate = activate;
78
78
  function search(project, params, projection) {
79
79
  return (repos) => __awaiter(this, void 0, void 0, function* () {
80
80
  var _a, _b;
81
- let serviceOutputs;
81
+ let permitsWithAccountDetail;
82
82
  // アウトプット検索条件のプロジェクトは強制的に上書き
83
83
  const searchConditions = Object.assign(Object.assign({}, params), { project: { id: { $eq: project.id } } });
84
84
  const productType = (_b = (_a = params.issuedThrough) === null || _a === void 0 ? void 0 : _a.typeOf) === null || _b === void 0 ? void 0 : _b.$eq;
85
85
  switch (productType) {
86
86
  case factory.product.ProductType.PaymentCard:
87
- serviceOutputs = yield repos.serviceOutput.search(searchConditions, projection);
87
+ const permits = yield repos.serviceOutput.search(searchConditions, projection);
88
+ permitsWithAccountDetail = permits;
88
89
  // 口座詳細取得
89
- const accountNumbers = serviceOutputs.map((s) => { var _a; return (_a = s.paymentAccount) === null || _a === void 0 ? void 0 : _a.accountNumber; })
90
- .filter((a) => typeof a === 'string');
90
+ const accountNumbers = permits.map((permit) => { var _a; return (_a = permit.paymentAccount) === null || _a === void 0 ? void 0 : _a.accountNumber; })
91
+ .filter((accountNumber) => typeof accountNumber === 'string');
91
92
  if (accountNumbers.length > 0) {
92
93
  const accounts = yield repos.account.search({
93
94
  project: { id: { $eq: project.id } },
94
95
  accountNumbers: accountNumbers
95
96
  });
96
- serviceOutputs = serviceOutputs.map((s) => {
97
- const account = accounts.find((a) => { var _a; return a.accountNumber === ((_a = s.paymentAccount) === null || _a === void 0 ? void 0 : _a.accountNumber); });
98
- return Object.assign(Object.assign({}, s), (account !== undefined)
99
- ? { paymentAccount: account }
100
- : undefined);
97
+ permitsWithAccountDetail = permits.map((permit) => {
98
+ const account = accounts.find((a) => { var _a; return a.accountNumber === ((_a = permit.paymentAccount) === null || _a === void 0 ? void 0 : _a.accountNumber); });
99
+ const paymentAccount = (typeof (account === null || account === void 0 ? void 0 : account.typeOf) === 'string')
100
+ ? {
101
+ accountNumber: account.accountNumber,
102
+ availableBalance: account.availableBalance,
103
+ balance: account.balance,
104
+ typeOf: account.typeOf
105
+ }
106
+ : undefined;
107
+ return Object.assign(Object.assign({}, permit), { paymentAccount });
101
108
  });
102
109
  }
103
110
  break;
104
111
  default:
105
- serviceOutputs = yield repos.serviceOutput.search(searchConditions, projection);
112
+ permitsWithAccountDetail = (yield repos.serviceOutput.search(searchConditions, projection));
106
113
  }
107
- return serviceOutputs;
114
+ return permitsWithAccountDetail;
108
115
  });
109
116
  }
110
117
  exports.search = search;
@@ -328,7 +328,6 @@ function processMoneyTransferTransaction(params) {
328
328
  toLocation,
329
329
  pendingTransaction: {
330
330
  typeOf: factory.account.transactionType.Transfer,
331
- id: '',
332
331
  transactionNumber: params.transactionNumber
333
332
  },
334
333
  force: false
@@ -21,6 +21,7 @@ export declare type ISettings = factory.project.ISettings & {
21
21
  userPoolIdOld: string;
22
22
  userPoolIdNew: string;
23
23
  maxNumCreditCardPaymentMethod?: number;
24
+ useEventWorkPerformed: boolean;
24
25
  };
25
26
  export declare const DEFAULT_PAYMENT_METHOD_TYPE_FOR_CREDIT_CARD: string;
26
27
  export declare const USE_ASSET_TRANSACTION_SYNC_PROCESSING: boolean;
@@ -54,7 +54,7 @@ exports.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING = process.env.USE_PAY_ASSET_TR
54
54
  /**
55
55
  * グローバル設定
56
56
  */
57
- exports.settings = Object.assign({ transactionWebhookUrls, onOrderStatusChanged: {
57
+ exports.settings = Object.assign(Object.assign({ transactionWebhookUrls, onOrderStatusChanged: {
58
58
  informOrder: informOrderUrls
59
59
  .filter((url) => url.length > 0)
60
60
  .map((url) => {
@@ -94,4 +94,4 @@ exports.settings = Object.assign({ transactionWebhookUrls, onOrderStatusChanged:
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);
97
+ : undefined), { useEventWorkPerformed: process.env.USE_EVENT_WORK_PERFORMED === '1' });