@chevre/domain 20.4.0-alpha.3 → 20.4.0-alpha.31

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 (86) hide show
  1. package/example/src/chevre/aggregateEventReservation.ts +1 -1
  2. package/example/src/chevre/createManyEventsIfNotExist.ts +10 -10
  3. package/example/src/chevre/deleteMovieTicketCategoryChargePriceSpecs.ts +21 -0
  4. package/example/src/chevre/{deleteReservationTicketUnderNames.ts → deleteTasksByName.ts} +4 -2
  5. package/example/src/chevre/migrateMoneyTransferPendingTransactionIdentifier.ts +96 -0
  6. package/example/src/chevre/reIndex.ts +25 -0
  7. package/example/src/chevre/searchEventTicketOffers.ts +6 -4
  8. package/example/src/chevre/searchOfferCatalogs.ts +14 -16
  9. package/example/src/chevre/searchOffersByCatalog.ts +2 -1
  10. package/example/src/chevre/searchTasks.ts +22 -0
  11. package/example/src/chevre/unsetUnnecessaryFields.ts +21 -0
  12. package/lib/chevre/repo/account.d.ts +4 -10
  13. package/lib/chevre/repo/account.js +72 -60
  14. package/lib/chevre/repo/assetTransaction.d.ts +1 -0
  15. package/lib/chevre/repo/assetTransaction.js +5 -0
  16. package/lib/chevre/repo/code.d.ts +0 -7
  17. package/lib/chevre/repo/code.js +0 -17
  18. package/lib/chevre/repo/event.d.ts +5 -4
  19. package/lib/chevre/repo/event.js +12 -30
  20. package/lib/chevre/repo/mongoose/model/comments.d.ts +1 -1
  21. package/lib/chevre/repo/mongoose/model/comments.js +1 -1
  22. package/lib/chevre/repo/mongoose/model/offer.js +19 -9
  23. package/lib/chevre/repo/mongoose/model/priceSpecification.js +19 -52
  24. package/lib/chevre/repo/offer.d.ts +17 -2
  25. package/lib/chevre/repo/offer.js +77 -44
  26. package/lib/chevre/repo/offerCatalog.d.ts +3 -5
  27. package/lib/chevre/repo/offerCatalog.js +78 -37
  28. package/lib/chevre/repo/priceSpecification.d.ts +11 -0
  29. package/lib/chevre/repo/priceSpecification.js +44 -66
  30. package/lib/chevre/repo/serviceOutput.d.ts +4 -0
  31. package/lib/chevre/repo/serviceOutput.js +6 -0
  32. package/lib/chevre/repo/task.d.ts +8 -0
  33. package/lib/chevre/repo/task.js +21 -9
  34. package/lib/chevre/repository.d.ts +6 -0
  35. package/lib/chevre/repository.js +8 -1
  36. package/lib/chevre/service/account.d.ts +0 -8
  37. package/lib/chevre/service/account.js +16 -10
  38. package/lib/chevre/service/accountTransaction/deposit.js +2 -1
  39. package/lib/chevre/service/accountTransaction/factory.js +25 -20
  40. package/lib/chevre/service/accountTransaction/transfer.js +4 -2
  41. package/lib/chevre/service/accountTransaction/withdraw.js +2 -1
  42. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +46 -83
  43. package/lib/chevre/service/aggregation/event/aggregateUseActionsOnEvent.js +3 -1
  44. package/lib/chevre/service/assetTransaction/moneyTransfer.js +19 -11
  45. package/lib/chevre/service/assetTransaction/pay.js +19 -14
  46. package/lib/chevre/service/assetTransaction/registerService/factory.js +9 -4
  47. package/lib/chevre/service/assetTransaction/registerService.js +3 -1
  48. package/lib/chevre/service/assetTransaction/reserve.js +2 -15
  49. package/lib/chevre/service/assetTransaction.d.ts +1 -1
  50. package/lib/chevre/service/code.d.ts +0 -8
  51. package/lib/chevre/service/code.js +1 -38
  52. package/lib/chevre/service/delivery.js +12 -3
  53. package/lib/chevre/service/event.js +0 -3
  54. package/lib/chevre/service/moneyTransfer.d.ts +1 -1
  55. package/lib/chevre/service/moneyTransfer.js +7 -8
  56. package/lib/chevre/service/offer/event/authorize.js +3 -4
  57. package/lib/chevre/service/offer/event/factory.js +1 -1
  58. package/lib/chevre/service/offer/event/searchEventTicketOffers.d.ts +6 -7
  59. package/lib/chevre/service/offer/event/searchEventTicketOffers.js +164 -314
  60. package/lib/chevre/service/offer/factory.d.ts +6 -1
  61. package/lib/chevre/service/offer/factory.js +42 -24
  62. package/lib/chevre/service/offer/moneyTransfer/authorize.js +0 -1
  63. package/lib/chevre/service/offer/moneyTransfer/returnMoneyTransfer.js +0 -1
  64. package/lib/chevre/service/offer/product/searchProductOffers.d.ts +9 -1
  65. package/lib/chevre/service/offer/product/searchProductOffers.js +13 -7
  66. package/lib/chevre/service/offer/product.d.ts +5 -1
  67. package/lib/chevre/service/offer/product.js +53 -46
  68. package/lib/chevre/service/payment/any/factory.js +29 -2
  69. package/lib/chevre/service/payment/any.js +11 -4
  70. package/lib/chevre/service/payment/movieTicket.d.ts +7 -2
  71. package/lib/chevre/service/payment/movieTicket.js +17 -8
  72. package/lib/chevre/service/payment/paymentCard.d.ts +6 -2
  73. package/lib/chevre/service/payment/paymentCard.js +16 -8
  74. package/lib/chevre/service/permit.d.ts +5 -1
  75. package/lib/chevre/service/permit.js +18 -11
  76. package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +25 -53
  77. package/lib/chevre/service/transaction/moneyTransfer.js +0 -1
  78. package/lib/chevre/service/transaction/orderProgramMembership.js +1 -1
  79. package/lib/chevre/settings.d.ts +4 -0
  80. package/lib/chevre/settings.js +8 -2
  81. package/package.json +3 -3
  82. package/example/src/chevre/migrateAccountTitleAdditionalProperties.ts +0 -157
  83. package/example/src/chevre/migrateProjectSubscription.ts +0 -51
  84. package/example/src/chevre/migrateSection.ts +0 -105
  85. package/lib/chevre/service/task/deleteAuthorization.d.ts +0 -6
  86. package/lib/chevre/service/task/deleteAuthorization.js +0 -29
@@ -1,15 +1,4 @@
1
1
  "use strict";
2
- var __rest = (this && this.__rest) || function (s, e) {
3
- var t = {};
4
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
- t[p] = s[p];
6
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
- t[p[i]] = s[p[i]];
10
- }
11
- return t;
12
- };
13
2
  Object.defineProperty(exports, "__esModule", { value: true });
14
3
  exports.createCompoundPriceSpec4event = void 0;
15
4
  const factory = require("../../factory");
@@ -21,6 +10,7 @@ function mvtkChargePriceSpec2component(params) {
21
10
  var _a;
22
11
  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
12
  }
13
+ // tslint:disable-next-line:max-func-body-length
24
14
  function createCompoundPriceSpec4event(params) {
25
15
  var _a;
26
16
  // priceSpecificationはマスタ管理の仕様上必ず存在するはず
@@ -39,20 +29,38 @@ function createCompoundPriceSpec4event(params) {
39
29
  const mvtkPriceComponents = [];
40
30
  // 複数決済カード対応(2022-07-11~)
41
31
  if (Array.isArray(unitPriceSpec.appliesToMovieTicket)) {
32
+ // 決済カード加算料金自動補完(2023-02-21~)
42
33
  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);
34
+ // すべての上映方式に該当する加算料金を追加
35
+ params.videoFormatTypes.forEach((videoFormatType) => {
36
+ let existingMvtkSpec4appliesToMovieTicket = params.movieTicketTypeChargeSpecs.find((s) => {
37
+ var _a;
38
+ return ((_a = s.appliesToMovieTicket.serviceOutput) === null || _a === void 0 ? void 0 : _a.typeOf) === appliesToMovieTicket.serviceOutput.typeOf
39
+ && s.appliesToMovieTicket.serviceType === appliesToMovieTicket.serviceType
40
+ && s.appliesToVideoFormat === videoFormatType;
41
+ });
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));
49
61
  });
50
- mvtkPriceComponents.push(...mvtkSpecs4appliesToMovieTicket.map(mvtkChargePriceSpec2component));
51
62
  });
52
63
  }
53
- else {
54
- // Arrayでないケースは廃止(2022-09-12~)
55
- }
56
64
  // 区分加算料金は決済カード適用でも価格要素に含まれるはず(2022-11-02~)
57
65
  const priceComponent = [
58
66
  unitPriceSpec,
@@ -68,8 +76,18 @@ function createCompoundPriceSpec4event(params) {
68
76
  valueAddedTaxIncluded: true,
69
77
  priceComponent
70
78
  };
71
- // 不要な属性を除外(2022-11-07~)
72
- const _b = params.offer, { project } = _b, unitOfferFields4ticketOffer = __rest(_b, ["project"]);
73
- return Object.assign(Object.assign({}, unitOfferFields4ticketOffer), { eligibleQuantity: params.eligibleQuantity, priceSpecification: compoundPriceSpecification });
79
+ // 必要な属性のみに限定(2023-02-24~)
80
+ // const { project, ...unitOfferFields4ticketOffer } = params.offer;
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,
88
+ eligibleMembershipType, eligibleSeatingType, eligibleMonetaryAmount, eligibleSubReservation,
89
+ priceCurrency,
90
+ validFrom, validThrough, validRateLimit, additionalProperty,
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);
74
92
  }
75
93
  exports.createCompoundPriceSpec4event = createCompoundPriceSpec4event;
@@ -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
  }
@@ -5,10 +5,18 @@ import { MongoRepository as ProductRepo } from '../../../repo/product';
5
5
  * プロダクトオファーを検索する
6
6
  */
7
7
  export declare function searchProductOffers(params: {
8
+ /**
9
+ * 指定したIDのオファーだけ取得する場合
10
+ */
11
+ ids?: string[];
8
12
  itemOffered: {
9
13
  id: string;
10
14
  };
11
- sort: boolean;
15
+ availableAt?: {
16
+ id: string;
17
+ };
18
+ onlyValid: boolean;
19
+ addSortIndex: boolean;
12
20
  }): (repos: {
13
21
  offer: OfferRepo;
14
22
  product: ProductRepo;
@@ -23,12 +23,21 @@ 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, sortedOfferIds } = yield repos.offer.findOffersByOfferCatalogId({
27
+ ids: params.ids,
28
+ offerCatalog: { id: offerCatalogId },
29
+ excludeAppliesToMovieTicket: false,
30
+ sort: false,
31
+ onlyValid: params.onlyValid === true,
32
+ availableAtOrFrom: params.availableAt
33
+ });
27
34
  return offers.map((o) => {
35
+ let sortIndex;
36
+ if (params.addSortIndex) {
37
+ sortIndex = sortedOfferIds.indexOf(String(o.id));
38
+ }
28
39
  const unitSpec = o.priceSpecification;
29
40
  const compoundPriceSpecification = {
30
- // 不要な属性を除外(2022-11-02~)
31
- // project: productWithOffers.project,
32
41
  typeOf: factory.priceSpecificationType.CompoundPriceSpecification,
33
42
  priceCurrency: factory.priceCurrency.JPY,
34
43
  valueAddedTaxIncluded: true,
@@ -36,10 +45,7 @@ function searchProductOffers(params) {
36
45
  ...(unitSpec !== undefined) ? [unitSpec] : []
37
46
  ]
38
47
  };
39
- return Object.assign(Object.assign({ additionalProperty: (Array.isArray(o.additionalProperty)) ? o.additionalProperty : [], alternateName: o.alternateName, availability: o.availability, availableAtOrFrom: o.availableAtOrFrom, color: o.color, description: o.description, id: o.id, identifier: o.identifier, itemOffered: o.itemOffered, name: o.name, priceCurrency: o.priceCurrency,
40
- // 不要な属性を除外(2022-11-07~)
41
- // project: o.project,
42
- typeOf: o.typeOf, priceSpecification: compoundPriceSpecification }, (o.validFrom instanceof Date) ? { validFrom: o.validFrom } : undefined), (o.validThrough instanceof Date) ? { validThrough: o.validThrough } : undefined);
48
+ return Object.assign(Object.assign(Object.assign({ additionalProperty: (Array.isArray(o.additionalProperty)) ? o.additionalProperty : [], alternateName: o.alternateName, availability: o.availability, availableAtOrFrom: o.availableAtOrFrom, color: o.color, description: o.description, id: o.id, identifier: o.identifier, itemOffered: o.itemOffered, name: o.name, priceCurrency: o.priceCurrency, typeOf: o.typeOf, priceSpecification: compoundPriceSpecification }, (o.validFrom instanceof Date) ? { validFrom: o.validFrom } : undefined), (o.validThrough instanceof Date) ? { validThrough: o.validThrough } : undefined), (typeof sortIndex === 'number') ? { sortIndex } : undefined);
43
49
  });
44
50
  });
45
51
  }
@@ -37,6 +37,10 @@ export { searchProductOffers };
37
37
  * プロダクトオファーを検索する
38
38
  */
39
39
  export declare function search(params: {
40
+ /**
41
+ * 指定したIDのオファーだけ取得する場合
42
+ */
43
+ ids?: string[];
40
44
  project: {
41
45
  id: string;
42
46
  };
@@ -50,7 +54,7 @@ export declare function search(params: {
50
54
  id: string;
51
55
  };
52
56
  onlyValid: boolean;
53
- sort: boolean;
57
+ addSortIndex: boolean;
54
58
  }): (repos: {
55
59
  offer: OfferRepo;
56
60
  product: ProductRepo;
@@ -25,9 +25,8 @@ exports.ERROR_MESSAGE_ALREADY_REGISTERED = 'Already registered';
25
25
  */
26
26
  function search(params) {
27
27
  return (repos) => __awaiter(this, void 0, void 0, function* () {
28
- var _a, _b;
28
+ var _a;
29
29
  const now = moment();
30
- let offers = [];
31
30
  const searchProductsResult = yield repos.product.search({
32
31
  limit: 1,
33
32
  page: 1,
@@ -39,54 +38,63 @@ function search(params) {
39
38
  throw new factory.errors.NotFound('Product');
40
39
  }
41
40
  // 販売者指定の場合、検証
42
- if (typeof ((_a = params.seller) === null || _a === void 0 ? void 0 : _a.id) === 'string') {
43
- const productOffers = product.offers;
44
- if (!Array.isArray(productOffers)) {
45
- return offers;
46
- }
47
- const hasValidOffer = productOffers.some((o) => {
48
- var _a, _b;
49
- return ((_a = o.seller) === null || _a === void 0 ? void 0 : _a.id) === ((_b = params.seller) === null || _b === void 0 ? void 0 : _b.id)
50
- && o.validFrom !== undefined
51
- && moment(o.validFrom)
52
- .isSameOrBefore(now)
53
- && o.validThrough !== undefined
54
- && moment(o.validThrough)
55
- .isSameOrAfter(now);
56
- });
57
- if (!hasValidOffer) {
58
- return offers;
41
+ if (product.typeOf === factory.product.ProductType.MembershipService
42
+ || product.typeOf === factory.product.ProductType.PaymentCard) {
43
+ if (typeof ((_a = params.seller) === null || _a === void 0 ? void 0 : _a.id) === 'string') {
44
+ const productOffers = product.offers;
45
+ if (!Array.isArray(productOffers)) {
46
+ return [];
47
+ }
48
+ const hasValidOffer = productOffers.some((o) => {
49
+ var _a, _b;
50
+ return ((_a = o.seller) === null || _a === void 0 ? void 0 : _a.id) === ((_b = params.seller) === null || _b === void 0 ? void 0 : _b.id)
51
+ && o.validFrom !== undefined
52
+ && moment(o.validFrom)
53
+ .isSameOrBefore(now)
54
+ && o.validThrough !== undefined
55
+ && moment(o.validThrough)
56
+ .isSameOrAfter(now);
57
+ });
58
+ if (!hasValidOffer) {
59
+ return [];
60
+ }
59
61
  }
60
62
  }
61
- offers = yield (0, searchProductOffers_1.searchProductOffers)({
63
+ // let offers: factory.product.ITicketOffer[] = [];
64
+ return (0, searchProductOffers_1.searchProductOffers)({
65
+ ids: params.ids,
62
66
  itemOffered: { id: params.itemOffered.id },
63
- sort: params.sort
67
+ availableAt: params.availableAt,
68
+ onlyValid: params.onlyValid,
69
+ addSortIndex: params.addSortIndex
64
70
  })(repos);
71
+ // Mongoへ移行(2023-03-01~)
65
72
  // 店舗条件によって対象を絞る
66
- const storeId = (_b = params.availableAt) === null || _b === void 0 ? void 0 : _b.id;
67
- if (typeof storeId === 'string') {
68
- // アプリケーションが利用可能なオファーに絞る
69
- offers = offers.filter((o) => {
70
- return Array.isArray(o.availableAtOrFrom)
71
- && o.availableAtOrFrom.some((availableApplication) => availableApplication.id === storeId);
72
- });
73
- }
73
+ // const storeId = params.availableAt?.id;
74
+ // if (typeof storeId === 'string') {
75
+ // // アプリケーションが利用可能なオファーに絞る
76
+ // offers = offers.filter((o) => {
77
+ // return Array.isArray(o.availableAtOrFrom)
78
+ // && o.availableAtOrFrom.some((availableApplication) => availableApplication.id === storeId);
79
+ // });
80
+ // }
81
+ // Mongoへ移行(2023-03-01~)
74
82
  // 有効期間を適用
75
- if (params.onlyValid === true) {
76
- offers = offers.filter((o) => {
77
- let isValid = true;
78
- if (o.validFrom !== undefined && moment(o.validFrom)
79
- .isAfter(now)) {
80
- isValid = false;
81
- }
82
- if (o.validThrough !== undefined && moment(o.validThrough)
83
- .isBefore(now)) {
84
- isValid = false;
85
- }
86
- return isValid;
87
- });
88
- }
89
- return offers;
83
+ // if (params.onlyValid === true) {
84
+ // offers = offers.filter((o) => {
85
+ // let isValid = true;
86
+ // if (o.validFrom !== undefined && moment(o.validFrom)
87
+ // .isAfter(now)) {
88
+ // isValid = false;
89
+ // }
90
+ // if (o.validThrough !== undefined && moment(o.validThrough)
91
+ // .isBefore(now)) {
92
+ // isValid = false;
93
+ // }
94
+ // return isValid;
95
+ // });
96
+ // }
97
+ // return offers;
90
98
  });
91
99
  }
92
100
  exports.search = search;
@@ -202,8 +210,7 @@ function fixProductAndOffers(params) {
202
210
  if (product === undefined) {
203
211
  throw new factory.errors.NotFound('Product');
204
212
  }
205
- const availableOffers = yield search(Object.assign(Object.assign({ project: { id: params.project.id }, itemOffered: { id: String(product.id) }, onlyValid: true }, (typeof ((_c = params.location) === null || _c === void 0 ? void 0 : _c.id) === 'string') ? { availableAt: { id: params.location.id } } : undefined), { sort: false // ソート不要(2023-01-27~)
206
- }))(repos);
213
+ const availableOffers = yield search(Object.assign({ ids: params.object.map((o) => String(o.id)), project: { id: params.project.id }, itemOffered: { id: String(product.id) }, onlyValid: true, addSortIndex: false }, (typeof ((_c = params.location) === null || _c === void 0 ? void 0 : _c.id) === 'string') ? { availableAt: { id: params.location.id } } : undefined))(repos);
207
214
  return { product, availableOffers };
208
215
  });
209
216
  }
@@ -13,8 +13,9 @@ function creatPayTransactionStartParams(params) {
13
13
  const accountId = (typeof params.accountId === 'string')
14
14
  ? params.accountId
15
15
  : (typeof params.object.accountId === 'string') ? params.object.accountId : undefined;
16
+ // movieTickets最適化(2023-02-24~)
17
+ const movieTickets = (Array.isArray(params.object.movieTickets)) ? params.object.movieTickets.map(createMovieTicket) : undefined;
16
18
  return Object.assign(Object.assign({ project: { id: params.transaction.project.id, typeOf: factory.organizationType.Project }, typeOf: factory.assetTransactionType.Pay, transactionNumber: params.transactionNumber, agent: {
17
- // Sellerに変更(2022-05-30~)
18
19
  typeOf: params.transaction.seller.typeOf,
19
20
  id: String(params.transaction.seller.id),
20
21
  name: (typeof params.transaction.seller.name === 'string')
@@ -38,7 +39,7 @@ function creatPayTransactionStartParams(params) {
38
39
  typeOf: params.paymentServiceType,
39
40
  // 決済サービスIDを連携(2022-04-12~)
40
41
  id: issuedThroughId,
41
- paymentMethod: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ typeOf: params.object.paymentMethod, amount: params.object.amount, additionalProperty: (Array.isArray(params.object.additionalProperty)) ? params.object.additionalProperty : [] }, (typeof params.object.method === 'string') ? { method: params.object.method } : undefined), (typeof params.object.name === 'string') ? { name: params.object.name } : undefined), (typeof accountId === 'string') ? { accountId } : undefined), (typeof params.object.description === 'string') ? { description: params.object.description } : undefined), (typeof params.object.fromLocation === 'string') ? { fromLocation: params.object.fromLocation } : undefined), (params.object.creditCard !== undefined) ? { creditCard: params.object.creditCard } : undefined), (Array.isArray(params.object.movieTickets)) ? { movieTickets: params.object.movieTickets } : undefined)
42
+ paymentMethod: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ typeOf: params.object.paymentMethod, amount: params.object.amount, additionalProperty: (Array.isArray(params.object.additionalProperty)) ? params.object.additionalProperty : [] }, (typeof params.object.method === 'string') ? { method: params.object.method } : undefined), (typeof params.object.name === 'string') ? { name: params.object.name } : undefined), (typeof accountId === 'string') ? { accountId } : undefined), (typeof params.object.description === 'string') ? { description: params.object.description } : undefined), (typeof params.object.fromLocation === 'string') ? { fromLocation: params.object.fromLocation } : undefined), (params.object.creditCard !== undefined) ? { creditCard: params.object.creditCard } : undefined), (Array.isArray(movieTickets)) ? { movieTickets } : undefined)
42
43
  }, expires: expires }, (typeof confirmationNumber === 'string')
43
44
  ? {
44
45
  purpose: {
@@ -51,6 +52,32 @@ function creatPayTransactionStartParams(params) {
51
52
  : undefined);
52
53
  }
53
54
  exports.creatPayTransactionStartParams = creatPayTransactionStartParams;
55
+ function createMovieTicket(params) {
56
+ var _a;
57
+ const serviceOutput = {
58
+ reservationFor: {
59
+ typeOf: params.serviceOutput.reservationFor.typeOf,
60
+ id: params.serviceOutput.reservationFor.id
61
+ },
62
+ reservedTicket: {
63
+ ticketedSeat: {
64
+ typeOf: factory.placeType.Seat,
65
+ seatNumber: params.serviceOutput.reservedTicket.ticketedSeat.seatNumber,
66
+ seatRow: params.serviceOutput.reservedTicket.ticketedSeat.seatRow,
67
+ seatSection: params.serviceOutput.reservedTicket.ticketedSeat.seatSection
68
+ }
69
+ }
70
+ };
71
+ return {
72
+ project: { id: params.project.id, typeOf: factory.organizationType.Project },
73
+ typeOf: params.typeOf,
74
+ identifier: params.identifier,
75
+ accessCode: params.accessCode,
76
+ category: { codeValue: (typeof ((_a = params.category) === null || _a === void 0 ? void 0 : _a.codeValue) === 'string') ? params.category.codeValue : '' },
77
+ serviceType: params.serviceType,
78
+ serviceOutput
79
+ };
80
+ }
54
81
  function createAuthorizeResult(params) {
55
82
  var _a, _b, _c, _d;
56
83
  const payTransactionObject = params.payTransaction.object;
@@ -97,10 +97,17 @@ exports.invalidatePaymentUrl = invalidatePaymentUrl;
97
97
  */
98
98
  function processVoidPayTransaction(params) {
99
99
  return (repos) => __awaiter(this, void 0, void 0, function* () {
100
- const transaction = yield repos.transaction.findById({
101
- typeOf: params.purpose.typeOf,
102
- id: params.purpose.id
103
- });
100
+ let transaction;
101
+ // アクションID指定の場合、進行中取引検証(2023-02-24~)
102
+ if (typeof params.id === 'string') {
103
+ transaction = yield repos.transaction.findInProgressById({ typeOf: params.purpose.typeOf, id: params.purpose.id });
104
+ }
105
+ else {
106
+ transaction = yield repos.transaction.findById({
107
+ typeOf: params.purpose.typeOf,
108
+ id: params.purpose.id
109
+ });
110
+ }
104
111
  // 承認アクションを取得
105
112
  let authorizeActions;
106
113
  if (typeof params.id === 'string') {
@@ -57,9 +57,14 @@ declare function checkByIdentifier(params: {
57
57
  project: ProjectRepo;
58
58
  }) => Promise<ICheckResult>;
59
59
  interface IAuthorizeResult {
60
- checkResult: ICheckResult;
61
- payAction?: factory.action.IAction<factory.action.IAttributes<factory.actionType.PayAction, any, any>>;
60
+ accountId: string;
61
+ checkResult?: ICheckResult;
62
+ payAction: factory.action.trade.pay.IAction;
62
63
  }
64
+ /**
65
+ * MovieTicket承認
66
+ * オーソリサービスが存在するわけではないので、実質着券する
67
+ */
63
68
  declare function authorize(params: factory.assetTransaction.pay.IStartParamsWithoutDetail, transaction: factory.assetTransaction.pay.ITransaction, paymentServiceId: string): (repos: {
64
69
  action: ActionRepo;
65
70
  accountingReport: AccountingReportRepo;
@@ -17,6 +17,7 @@ const surfrock = require("@surfrock/sdk");
17
17
  const moment = require("moment-timezone");
18
18
  const credentials_1 = require("../../credentials");
19
19
  const factory = require("../../factory");
20
+ const settings_1 = require("../../settings");
20
21
  const factory_1 = require("./movieTicket/factory");
21
22
  const validation_1 = require("../assetTransaction/pay/movieTicket/validation");
22
23
  const errorHandler_1 = require("../../errorHandler");
@@ -258,14 +259,22 @@ function purchaseNumberAuthResult2movieTickets(params) {
258
259
  }
259
260
  return movieTickets;
260
261
  }
262
+ /**
263
+ * MovieTicket承認
264
+ * オーソリサービスが存在するわけではないので、実質着券する
265
+ */
261
266
  function authorize(params, transaction, paymentServiceId) {
262
267
  return (repos) => __awaiter(this, void 0, void 0, function* () {
263
268
  var _a, _b;
269
+ let accountId;
264
270
  let checkResult;
265
271
  let payAction;
266
272
  try {
267
- // MovieTicket決済の場合、認証
268
- checkResult = yield (0, validation_1.validateMovieTicket)(params, paymentServiceId)(repos);
273
+ // オプション追加(2023-02-24~)
274
+ if (settings_1.settings.useCheckMovieTicketBeforePay) {
275
+ // MovieTicket決済の場合、認証
276
+ checkResult = yield (0, validation_1.validateMovieTicket)(params, paymentServiceId)(repos);
277
+ }
269
278
  const paymentMethod = transaction.object.paymentMethod;
270
279
  const paymentMethodType = String(paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.typeOf);
271
280
  const additionalProperty = paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.additionalProperty;
@@ -273,7 +282,10 @@ function authorize(params, transaction, paymentServiceId) {
273
282
  ? paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.paymentMethodId
274
283
  : transaction.id;
275
284
  const paymentMethodName = (typeof (paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.name) === 'string') ? paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.name : paymentMethodType;
276
- const accountId = (Array.isArray(paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.movieTickets)) ? (_a = paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.movieTickets[0]) === null || _a === void 0 ? void 0 : _a.identifier : undefined;
285
+ accountId = (Array.isArray(paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.movieTickets)) ? (_a = paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.movieTickets[0]) === null || _a === void 0 ? void 0 : _a.identifier : undefined;
286
+ if (typeof accountId !== 'string' || accountId.length === 0) {
287
+ throw new factory.errors.ArgumentNull('object.paymentMethod.movieTickets.identifier');
288
+ }
277
289
  const payObject = {
278
290
  typeOf: factory.service.paymentService.PaymentServiceType.MovieTicket,
279
291
  id: paymentServiceId,
@@ -284,10 +296,7 @@ function authorize(params, transaction, paymentServiceId) {
284
296
  }, typeOf: paymentMethodType }, (typeof accountId === 'string') ? { accountId } : undefined),
285
297
  movieTickets: paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.movieTickets
286
298
  };
287
- const payActionAttributes = Object.assign({ project: transaction.project, typeOf: factory.actionType.PayAction, object: [payObject],
288
- // agent:Projectに変更(2022-05-19~)
289
- // agent: transaction.agent,
290
- agent: transaction.project, recipient: transaction.recipient }, (params.purpose !== undefined)
299
+ const payActionAttributes = Object.assign({ project: transaction.project, typeOf: factory.actionType.PayAction, object: [payObject], agent: transaction.project, recipient: transaction.recipient }, (params.purpose !== undefined)
291
300
  ? { purpose: params.purpose }
292
301
  : { purpose: { typeOf: transaction.typeOf, transactionNumber: transaction.transactionNumber, id: transaction.id } });
293
302
  // 着券させざるをえないが、informPaymentはしない(注文がまだ存在しないため)
@@ -296,7 +305,7 @@ function authorize(params, transaction, paymentServiceId) {
296
305
  catch (error) {
297
306
  throw (0, errorHandler_1.handleMvtkReserveError)(error);
298
307
  }
299
- return Object.assign({ checkResult }, (payAction !== undefined) ? { payAction } : undefined);
308
+ return { accountId, checkResult, payAction };
300
309
  });
301
310
  }
302
311
  exports.authorize = authorize;
@@ -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 = Pick<factory.account.transaction.withdraw.ITransaction, 'id' | 'object' | 'transactionNumber' | 'typeOf'>;
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 {};