@chevre/domain 20.2.0-alpha.9 → 20.2.0

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 (135) hide show
  1. package/example/src/chevre/aggregateEventReservation.ts +37 -0
  2. package/example/src/chevre/aggregation/aggregateSystem.ts +116 -0
  3. package/example/src/chevre/attendIfNotAttended.ts +22 -0
  4. package/example/src/chevre/createManyEventsIfNotExist.ts +209 -0
  5. package/example/src/chevre/findByOrderNumberAndReservationId.ts +20 -0
  6. package/example/src/chevre/findScreeningRoomsByBranchCode.ts +27 -0
  7. package/example/src/chevre/importEventsFromCOA.ts +8 -1
  8. package/example/src/chevre/migrateEventOffersItemOfferedAvailableChannel.ts +2 -1
  9. package/example/src/chevre/migrateOwnershipInfos2newUserPool.ts +1 -1
  10. package/example/src/chevre/migrateProjectSubscription.ts +51 -0
  11. package/example/src/chevre/ownershipInfosCsv2peopleJson.ts +2 -2
  12. package/example/src/chevre/processReserve.ts +2 -0
  13. package/example/src/chevre/searchEventIds.ts +24 -0
  14. package/example/src/chevre/searchEventTicketOffers.ts +5 -4
  15. package/example/src/chevre/searchEvents.ts +20 -41
  16. package/example/src/chevre/searchOffersByCatalog.ts +27 -0
  17. package/example/src/chevre/updateTransaction.ts +38 -0
  18. package/lib/chevre/factory/event.d.ts +2 -0
  19. package/lib/chevre/factory/event.js +2 -0
  20. package/lib/chevre/repo/action.d.ts +77 -1
  21. package/lib/chevre/repo/action.js +249 -6
  22. package/lib/chevre/repo/aggregation.d.ts +38 -0
  23. package/lib/chevre/repo/aggregation.js +68 -0
  24. package/lib/chevre/repo/assetTransaction.d.ts +32 -0
  25. package/lib/chevre/repo/assetTransaction.js +148 -0
  26. package/lib/chevre/repo/code.d.ts +13 -16
  27. package/lib/chevre/repo/code.js +33 -19
  28. package/lib/chevre/repo/creativeWork.js +13 -12
  29. package/lib/chevre/repo/event.d.ts +64 -17
  30. package/lib/chevre/repo/event.js +456 -156
  31. package/lib/chevre/repo/mongoose/model/aggregation.d.ts +7 -0
  32. package/lib/chevre/repo/mongoose/model/aggregation.js +47 -0
  33. package/lib/chevre/repo/mongoose/model/event.js +4 -3
  34. package/lib/chevre/repo/mongoose/model/offer.js +2 -1
  35. package/lib/chevre/repo/mongoose/model/project.js +7 -1
  36. package/lib/chevre/repo/mongoose/model/telemetry.js +4 -28
  37. package/lib/chevre/repo/offer.d.ts +10 -0
  38. package/lib/chevre/repo/offer.js +47 -16
  39. package/lib/chevre/repo/order.d.ts +6 -0
  40. package/lib/chevre/repo/order.js +53 -7
  41. package/lib/chevre/repo/place.d.ts +26 -1
  42. package/lib/chevre/repo/place.js +216 -12
  43. package/lib/chevre/repo/product.d.ts +1 -0
  44. package/lib/chevre/repo/product.js +5 -0
  45. package/lib/chevre/repo/project.d.ts +7 -1
  46. package/lib/chevre/repo/project.js +15 -6
  47. package/lib/chevre/repo/reservation.d.ts +7 -8
  48. package/lib/chevre/repo/reservation.js +181 -76
  49. package/lib/chevre/repo/task.d.ts +31 -4
  50. package/lib/chevre/repo/task.js +146 -33
  51. package/lib/chevre/repo/transaction.d.ts +57 -5
  52. package/lib/chevre/repo/transaction.js +228 -34
  53. package/lib/chevre/repo/trip.js +33 -27
  54. package/lib/chevre/repository.d.ts +3 -0
  55. package/lib/chevre/repository.js +5 -1
  56. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +72 -60
  57. package/lib/chevre/service/aggregation/event/aggregateUseActionsOnEvent.js +5 -8
  58. package/lib/chevre/service/aggregation/system.d.ts +100 -0
  59. package/lib/chevre/service/aggregation/system.js +409 -0
  60. package/lib/chevre/service/aggregation.d.ts +2 -0
  61. package/lib/chevre/service/aggregation.js +3 -1
  62. package/lib/chevre/service/assetTransaction/pay/movieTicket/validation.js +5 -1
  63. package/lib/chevre/service/assetTransaction/pay/potentialActions.js +0 -3
  64. package/lib/chevre/service/assetTransaction/pay.d.ts +19 -4
  65. package/lib/chevre/service/assetTransaction/pay.js +65 -32
  66. package/lib/chevre/service/assetTransaction/registerService.js +4 -1
  67. package/lib/chevre/service/assetTransaction/reserve/factory.d.ts +3 -0
  68. package/lib/chevre/service/assetTransaction/reserve/factory.js +33 -2
  69. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.d.ts +16 -0
  70. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.js +84 -0
  71. package/lib/chevre/service/assetTransaction/reserve.d.ts +38 -6
  72. package/lib/chevre/service/assetTransaction/reserve.js +120 -94
  73. package/lib/chevre/service/assetTransaction.d.ts +1 -1
  74. package/lib/chevre/service/code.d.ts +2 -3
  75. package/lib/chevre/service/delivery/factory.d.ts +1 -1
  76. package/lib/chevre/service/delivery/product/factory.js +9 -3
  77. package/lib/chevre/service/event.d.ts +2 -4
  78. package/lib/chevre/service/event.js +35 -14
  79. package/lib/chevre/service/offer/event/authorize.d.ts +4 -7
  80. package/lib/chevre/service/offer/event/authorize.js +33 -87
  81. package/lib/chevre/service/offer/event/cancel.js +0 -1
  82. package/lib/chevre/service/offer/event/factory.d.ts +3 -2
  83. package/lib/chevre/service/offer/event/searchEventTicketOffers.d.ts +14 -7
  84. package/lib/chevre/service/offer/event/searchEventTicketOffers.js +95 -53
  85. package/lib/chevre/service/offer/event/voidTransaction.js +0 -2
  86. package/lib/chevre/service/offer/eventServiceByCOA/factory.d.ts +2 -1
  87. package/lib/chevre/service/offer/eventServiceByCOA.js +10 -2
  88. package/lib/chevre/service/offer/factory.js +10 -3
  89. package/lib/chevre/service/offer/product/searchProductOffers.d.ts +1 -0
  90. package/lib/chevre/service/offer/product/searchProductOffers.js +1 -1
  91. package/lib/chevre/service/offer/product.d.ts +1 -0
  92. package/lib/chevre/service/offer/product.js +7 -2
  93. package/lib/chevre/service/offer.d.ts +13 -2
  94. package/lib/chevre/service/offer.js +68 -46
  95. package/lib/chevre/service/order/onOrderStatusChanged/factory.js +23 -26
  96. package/lib/chevre/service/order/returnOrder.js +6 -4
  97. package/lib/chevre/service/order/sendOrder.js +4 -2
  98. package/lib/chevre/service/payment/any.d.ts +9 -0
  99. package/lib/chevre/service/payment/any.js +16 -1
  100. package/lib/chevre/service/payment/movieTicket.d.ts +2 -2
  101. package/lib/chevre/service/payment/movieTicket.js +8 -2
  102. package/lib/chevre/service/product.js +5 -3
  103. package/lib/chevre/service/report/telemetry.js +1 -1
  104. package/lib/chevre/service/reserve/checkInReservation.js +2 -2
  105. package/lib/chevre/service/reserve/confirmReservation.js +7 -10
  106. package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.js +2 -1
  107. package/lib/chevre/service/reserve/potentialActions/onReservationCheckedIn.js +2 -1
  108. package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.js +2 -1
  109. package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +32 -35
  110. package/lib/chevre/service/reserve/useReservation.d.ts +0 -3
  111. package/lib/chevre/service/reserve/useReservation.js +58 -33
  112. package/lib/chevre/service/task/confirmPayTransaction.js +20 -1
  113. package/lib/chevre/service/task/confirmReserveTransaction.d.ts +4 -0
  114. package/lib/chevre/service/task/confirmReserveTransaction.js +5 -5
  115. package/lib/chevre/service/task/importEventsFromCOA.js +3 -1
  116. package/lib/chevre/service/task/returnPayTransaction.js +10 -4
  117. package/lib/chevre/service/task.js +6 -9
  118. package/lib/chevre/service/transaction/moneyTransfer.js +9 -1
  119. package/lib/chevre/service/transaction/orderProgramMembership/findPaymentCardPermit.d.ts +1 -1
  120. package/lib/chevre/service/transaction/orderProgramMembership.js +6 -6
  121. package/lib/chevre/service/transaction/placeOrder.js +5 -3
  122. package/lib/chevre/service/transaction/placeOrderInProgress/factory.d.ts +1 -1
  123. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions.d.ts +0 -2
  124. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions.js +2 -11
  125. package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateSeller.d.ts +1 -1
  126. package/lib/chevre/service/transaction/placeOrderInProgress.d.ts +3 -8
  127. package/lib/chevre/service/transaction/placeOrderInProgress.js +92 -107
  128. package/lib/chevre/service/transaction/returnOrder.js +8 -6
  129. package/lib/chevre/settings.d.ts +2 -0
  130. package/lib/chevre/settings.js +20 -12
  131. package/package.json +3 -3
  132. package/example/src/chevre/aggregateReservationOnProject.ts +0 -32
  133. package/example/src/chevre/migratePlaceAdditionalProperties.ts +0 -162
  134. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/confirmPay.d.ts +0 -6
  135. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/confirmPay.js +0 -65
@@ -15,6 +15,8 @@ const factory = require("../../factory");
15
15
  const action_1 = require("../../repo/action");
16
16
  const assetTransaction_1 = require("../../repo/assetTransaction");
17
17
  const order_1 = require("../../repo/order");
18
+ const reservation_1 = require("../../repo/reservation");
19
+ const task_1 = require("../../repo/task");
18
20
  const ReserveTransactionService = require("../assetTransaction/reserve");
19
21
  const credentials_1 = require("../../credentials");
20
22
  const coaAuthClient = new COA.auth.RefreshToken({
@@ -29,7 +31,9 @@ function call(data) {
29
31
  yield confirmReserveTransaction(data)({
30
32
  action: new action_1.MongoRepository(settings.connection),
31
33
  assetTransaction: new assetTransaction_1.MongoRepository(settings.connection),
32
- order: new order_1.MongoRepository(settings.connection)
34
+ order: new order_1.MongoRepository(settings.connection),
35
+ reservation: new reservation_1.MongoRepository(settings.connection),
36
+ task: new task_1.MongoRepository(settings.connection)
33
37
  });
34
38
  });
35
39
  }
@@ -44,9 +48,6 @@ function confirmReserveTransaction(params) {
44
48
  const action = yield repos.action.start(confirmActionAttributes);
45
49
  try {
46
50
  let object = confirmActionAttributes.object;
47
- // if (params.instrument === undefined) {
48
- // params.instrument = { typeOf: 'WebAPI', identifier: factory.service.webAPI.Identifier.Chevre };
49
- // }
50
51
  switch (params.instrument.identifier) {
51
52
  case factory.service.webAPI.Identifier.COA:
52
53
  // COA本予約
@@ -72,7 +73,6 @@ function confirmReserveTransaction(params) {
72
73
  object = object;
73
74
  yield ReserveTransactionService.confirm({
74
75
  transactionNumber: object.transactionNumber,
75
- // object: object.object,
76
76
  potentialActions: object.potentialActions
77
77
  })(repos);
78
78
  }
@@ -14,6 +14,7 @@ const action_1 = require("../../repo/action");
14
14
  const categoryCode_1 = require("../../repo/categoryCode");
15
15
  const event_1 = require("../../repo/event");
16
16
  const place_1 = require("../../repo/place");
17
+ const seller_1 = require("../../repo/seller");
17
18
  const EventService = require("../event");
18
19
  /**
19
20
  * タスク実行関数
@@ -24,7 +25,8 @@ function call(data) {
24
25
  action: new action_1.MongoRepository(settings.connection),
25
26
  categoryCode: new categoryCode_1.MongoRepository(settings.connection),
26
27
  event: new event_1.MongoRepository(settings.connection),
27
- place: new place_1.MongoRepository(settings.connection)
28
+ place: new place_1.MongoRepository(settings.connection),
29
+ seller: new seller_1.MongoRepository(settings.connection)
28
30
  });
29
31
  });
30
32
  }
@@ -64,7 +64,11 @@ function returnPayTransaction(params) {
64
64
  if (typeof paymentServiceType !== 'string' || paymentServiceType.length === 0) {
65
65
  throw new factory.errors.ArgumentNull('object.issuedThrough.typeOf');
66
66
  }
67
- const order = yield repos.order.findByOrderNumber({ orderNumber });
67
+ const order = yield repos.order.findByOrderNumber({
68
+ orderNumber,
69
+ inclusion: ['seller', 'project', 'dateReturned'],
70
+ exclusion: []
71
+ });
68
72
  const action = yield repos.action.start(refundActionAttributes);
69
73
  let refundTransaction;
70
74
  try {
@@ -213,8 +217,10 @@ function onRefund(refundActionAttributes) {
213
217
  });
214
218
  }
215
219
  // タスク保管
216
- yield Promise.all(taskAttributes.map((taskAttribute) => __awaiter(this, void 0, void 0, function* () {
217
- return repos.task.save(taskAttribute);
218
- })));
220
+ // saveManyに変更(2023-02-01~)
221
+ yield repos.task.saveMany(taskAttributes);
222
+ // await Promise.all(taskAttributes.map(async (taskAttribute) => {
223
+ // return repos.task.save(taskAttribute);
224
+ // }));
219
225
  });
220
226
  }
@@ -113,16 +113,13 @@ function abort(params) {
113
113
  exports.abort = abort;
114
114
  function notifyAbortedTasks(params) {
115
115
  return (repos) => __awaiter(this, void 0, void 0, function* () {
116
- let abortedTasks = yield repos.task.search({
117
- statuses: [factory.taskStatus.Aborted],
118
- dateAborted: {
119
- $gte: params.dateAbortedGte
120
- }
121
- });
116
+ const abortedTasks = yield repos.task.search(Object.assign({ statuses: [factory.taskStatus.Aborted], dateAborted: { $gte: params.dateAbortedGte } }, (settings_1.ABORTED_TASKS_WITHOUT_REPORT.length > 0)
117
+ ? { name: { $nin: settings_1.ABORTED_TASKS_WITHOUT_REPORT } }
118
+ : undefined));
122
119
  // 中止を報告しないタスク以外にフィルター
123
- abortedTasks = abortedTasks.filter((task) => {
124
- return !settings_1.ABORTED_TASKS_WITHOUT_REPORT.includes(task.name);
125
- });
120
+ // abortedTasks = abortedTasks.filter((task) => {
121
+ // return !ABORTED_TASKS_WITHOUT_REPORT.includes(task.name);
122
+ // });
126
123
  if (abortedTasks.length > 0) {
127
124
  // 開発者へ報告
128
125
  const message = (0, factory_1.tasks2lineNotify)({ tasks: abortedTasks });
@@ -386,6 +386,12 @@ function validateFromLocation(project, fromLocationBeforeStart, issuedThrough) {
386
386
  agent: { id: project.id, typeOf: factory.organizationType.Project },
387
387
  token: fromLocation
388
388
  })({ action: repos.action });
389
+ if (paymentCardOwnershipInfo.typeOf !== 'OwnershipInfo') {
390
+ throw new factory.errors.Argument('fromLocation', 'must be OwnershipInfo');
391
+ }
392
+ if (paymentCardOwnershipInfo.typeOfGood.typeOf !== factory.permit.PermitType.Permit) {
393
+ throw new factory.errors.Argument('fromLocation', 'must be Permit');
394
+ }
389
395
  fromLocation = {
390
396
  typeOf: paymentCardOwnershipInfo.typeOfGood.typeOf,
391
397
  identifier: paymentCardOwnershipInfo.typeOfGood.identifier,
@@ -576,7 +582,9 @@ function exportTasksById(params) {
576
582
  transaction,
577
583
  runsAt: taskRunsAt
578
584
  });
579
- yield Promise.all(taskAttributes.map((a) => __awaiter(this, void 0, void 0, function* () { return repos.task.save(a); })));
585
+ // saveManyに変更(2023-02-01~)
586
+ yield repos.task.saveMany(taskAttributes);
587
+ // await Promise.all(taskAttributes.map(async (a) => repos.task.save(a)));
580
588
  });
581
589
  }
582
590
  exports.exportTasksById = exportTasksById;
@@ -23,4 +23,4 @@ export declare function findPaymentCardPermit(params: {
23
23
  }): (repos: {
24
24
  ownershipInfo: OwnershipInfoRepo;
25
25
  product: ProductRepo;
26
- }) => Promise<factory.ownershipInfo.IPermit>;
26
+ }) => Promise<factory.ownershipInfo.IPermitAsGood>;
@@ -144,6 +144,7 @@ function processPlaceOrder(params) {
144
144
  }
145
145
  // 注文番号を先に発行
146
146
  const orderNumber = yield TransactionService.placeOrderInProgress.publishOrderNumberIfNotExist({
147
+ project: { id: transaction.project.id },
147
148
  id: transaction.id,
148
149
  object: { orderDate: now }
149
150
  })(repos);
@@ -193,9 +194,7 @@ function processPlaceOrder(params) {
193
194
  orderDate: new Date()
194
195
  }
195
196
  },
196
- potentialActions: params.potentialActions,
197
- createConfirmPayActions: false,
198
- createConfirmReserveActions: false
197
+ potentialActions: params.potentialActions
199
198
  })(repos);
200
199
  });
201
200
  }
@@ -218,7 +217,8 @@ function processAuthorizeProductOffer(params) {
218
217
  project: { id: params.project.id },
219
218
  itemOffered: { id: params.product.id },
220
219
  seller: { id: String(seller.id) },
221
- onlyValid: true
220
+ onlyValid: true,
221
+ sort: false // ソート不要(2023-01-27~)
222
222
  })(repos);
223
223
  const acceptedProductOffer = offers.find((o) => o.identifier === acceptedOffer.identifier);
224
224
  if (acceptedProductOffer === undefined) {
@@ -317,8 +317,8 @@ function processAuthorizeCreditCard(params) {
317
317
  issuedThrough: { id: String(creditCardPaymentService.id) }
318
318
  },
319
319
  purpose: params.purpose,
320
- paymentServiceType: factory.service.paymentService.PaymentServiceType.CreditCard
321
- // iss: params.iss
320
+ paymentServiceType: factory.service.paymentService.PaymentServiceType.CreditCard,
321
+ useCancelPayTransactionOnFailed: false
322
322
  })(repos);
323
323
  });
324
324
  }
@@ -36,9 +36,11 @@ function exportTasksById(params) {
36
36
  transaction,
37
37
  runsAt: taskRunsAt
38
38
  });
39
- yield Promise.all(taskAttributes.map((taskAttribute) => __awaiter(this, void 0, void 0, function* () {
40
- yield repos.task.save(taskAttribute);
41
- })));
39
+ // saveManyに変更(2023-02-01~)
40
+ yield repos.task.saveMany(taskAttributes);
41
+ // await Promise.all(taskAttributes.map(async (taskAttribute) => {
42
+ // await repos.task.save(taskAttribute);
43
+ // }));
42
44
  });
43
45
  }
44
46
  exports.exportTasksById = exportTasksById;
@@ -1,2 +1,2 @@
1
1
  import * as factory from '../../../factory';
2
- export declare function createStartParams(params: factory.transaction.placeOrder.IStartParamsWithoutDetail, passport: factory.waiter.passport.IPassport | undefined, seller: factory.seller.ISeller, broker?: factory.order.IBroker): factory.transaction.placeOrder.IStartParams;
2
+ export declare function createStartParams(params: factory.transaction.placeOrder.IStartParamsWithoutDetail, passport: factory.waiter.passport.IPassport | undefined, seller: Pick<factory.seller.ISeller, 'id' | 'name' | 'typeOf' | 'project'>, broker?: factory.order.IBroker): factory.transaction.placeOrder.IStartParams;
@@ -7,6 +7,4 @@ export declare function createPotentialActions(params: {
7
7
  potentialActions?: factory.transaction.placeOrder.IPotentialActionsParams;
8
8
  transaction: factory.transaction.placeOrder.ITransaction;
9
9
  emailMessage?: factory.creativeWork.message.email.ICreativeWork;
10
- createConfirmPayActions: boolean;
11
- createConfirmReserveActions: boolean;
12
10
  }): Promise<factory.transaction.placeOrder.IPotentialActions>;
@@ -10,8 +10,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.createPotentialActions = void 0;
13
- const confirmPay_1 = require("./potentialActions/confirmPay");
14
- // import { createConfirmReservationActions } from './potentialActions/confirmReservation';
15
13
  const givePointAward_1 = require("./potentialActions/givePointAward");
16
14
  const moneyTransfer_1 = require("./potentialActions/moneyTransfer");
17
15
  const registerService_1 = require("./potentialActions/registerService");
@@ -23,13 +21,9 @@ const order_1 = require("../../../factory/order");
23
21
  */
24
22
  function createPotentialActions(params) {
25
23
  return __awaiter(this, void 0, void 0, function* () {
26
- // 予約確定アクション
27
- // const confirmReservationActions = await createConfirmReservationActions(params);
28
24
  const registerServiceActions = yield (0, registerService_1.createRegisterServiceActions)(params);
29
25
  // 通貨転送アクション
30
26
  const moneyTransferActions = yield (0, moneyTransfer_1.createMoneyTransferActions)(params);
31
- // 決済確定アクション
32
- const confirmPayActions = yield (0, confirmPay_1.createConfirmPayActions)(params);
33
27
  // ポイントインセンティブに対する承認アクションの分だけ、ポイントインセンティブ付与アクションを作成する
34
28
  const givePointAwardActions = yield (0, givePointAward_1.createGivePointAwardActions)(params);
35
29
  // 注文配送メール送信設定
@@ -53,16 +47,13 @@ function createPotentialActions(params) {
53
47
  typeOf: factory.actionType.SendAction,
54
48
  // 取引から注文作成するように変更したのでminimizeする(2022-04-18~)
55
49
  object: simpleOrder,
56
- // agentをプロジェクトに変更(2022-05-18~)
57
50
  agent: params.transaction.project,
58
- // agent: params.transaction.seller,
59
51
  recipient: {
60
52
  typeOf: params.order.customer.typeOf,
61
53
  id: params.order.customer.id,
62
54
  name: String(params.order.customer.name)
63
55
  },
64
56
  potentialActions: {
65
- // confirmReservation: confirmReservationActions,
66
57
  moneyTransfer: moneyTransferActions,
67
58
  registerService: registerServiceActions,
68
59
  sendEmailMessage: sendEmailMessageActions
@@ -75,10 +66,10 @@ function createPotentialActions(params) {
75
66
  // 取引から注文作成するように変更したのでminimizeする(2022-04-18~)
76
67
  object: simpleOrder,
77
68
  agent: params.transaction.project,
78
- // agent: params.transaction.agent,
79
69
  potentialActions: {
80
70
  givePointAward: givePointAwardActions,
81
- pay: confirmPayActions,
71
+ // 完全廃止(2023-02-03~)
72
+ // pay: confirmPayActions,
82
73
  sendOrder: sendOrderActionAttributes
83
74
  },
84
75
  purpose: {
@@ -1,6 +1,6 @@
1
1
  import * as factory from '../../../../factory';
2
2
  export declare function validateSeller(params: {
3
- seller: factory.seller.ISeller;
3
+ seller: Pick<factory.seller.ISeller, 'makesOffer'>;
4
4
  clientUser?: factory.clientUser.IClientUser;
5
5
  }): {
6
6
  makesOfferFromClient: factory.seller.IMakesOffer;
@@ -60,14 +60,6 @@ export declare type IConfirmParams = factory.transaction.placeOrder.IConfirmPara
60
60
  result: {
61
61
  order: IResultOrderParams;
62
62
  };
63
- /**
64
- * confirmPayActionをchevreへ完全移行後に廃止
65
- */
66
- createConfirmPayActions: boolean;
67
- /**
68
- * confirmReserveActionをchevreへ完全移行後に廃止
69
- */
70
- createConfirmReserveActions: boolean;
71
63
  };
72
64
  /**
73
65
  * 注文取引を確定する
@@ -92,6 +84,9 @@ export declare function publishConfirmationNumberIfNotExist(params: {
92
84
  * 未発行であれば、注文番号を発行して取引に保管する
93
85
  */
94
86
  export declare function publishOrderNumberIfNotExist(params: {
87
+ project: {
88
+ id: string;
89
+ };
95
90
  /**
96
91
  * 取引ID
97
92
  */
@@ -28,7 +28,10 @@ exports.POINT_AWARD_IDENTIFIER_NAME = 'pointAwardIdentifiers';
28
28
  function start(params) {
29
29
  return (repos) => __awaiter(this, void 0, void 0, function* () {
30
30
  var _a;
31
- const seller = yield repos.seller.findById({ id: params.seller.id });
31
+ const seller = yield repos.seller.findById({ id: params.seller.id }, {
32
+ hasMerchantReturnPolicy: 0,
33
+ paymentAccepted: 0
34
+ });
32
35
  let makesOfferFromClient;
33
36
  // 販売者オファー検証(2022-10-14~)
34
37
  if (params.validateSeller === true) {
@@ -68,13 +71,13 @@ exports.start = start;
68
71
  */
69
72
  function confirm(params) {
70
73
  return (repos) => __awaiter(this, void 0, void 0, function* () {
71
- var _a, _b;
74
+ var _a;
72
75
  // 確認番号を事前発行
73
76
  yield publishConfirmationNumberIfNotExist({
74
77
  id: params.id,
75
78
  object: { orderDate: params.result.order.orderDate }
76
79
  })(repos);
77
- let transaction = yield repos.transaction.findById({
80
+ const transaction = yield repos.transaction.findById({
78
81
  typeOf: factory.transactionType.PlaceOrder,
79
82
  id: params.id
80
83
  });
@@ -95,10 +98,11 @@ function confirm(params) {
95
98
  transaction.object.authorizeActions = yield searchAuthorizeActions(params)(repos);
96
99
  // 注文番号を発行
97
100
  const orderNumber = yield publishOrderNumberIfNotExist({
101
+ project: { id: transaction.project.id },
98
102
  id: transaction.id,
99
103
  object: { orderDate: params.result.order.orderDate }
100
104
  })(repos);
101
- const result = yield createResult(Object.assign(Object.assign({}, params), { orderNumber, transaction: transaction }))();
105
+ const result = createResult(Object.assign(Object.assign({}, params), { orderNumber, transaction: transaction }));
102
106
  // デフォルトEメールメッセージを検索
103
107
  let emailMessageOnOrderSent;
104
108
  if (repos.emailMessage !== undefined) {
@@ -115,13 +119,11 @@ function confirm(params) {
115
119
  order: result.order,
116
120
  potentialActions: params.potentialActions,
117
121
  transaction: transaction,
118
- emailMessage: emailMessageOnOrderSent,
119
- createConfirmPayActions: params.createConfirmPayActions,
120
- createConfirmReserveActions: params.createConfirmReserveActions
122
+ emailMessage: emailMessageOnOrderSent
121
123
  });
122
124
  // ステータス変更
123
125
  try {
124
- transaction = yield repos.transaction.confirm({
126
+ yield repos.transaction.confirm({
125
127
  typeOf: transaction.typeOf,
126
128
  id: transaction.id,
127
129
  authorizeActions: transaction.object.authorizeActions,
@@ -140,10 +142,10 @@ function confirm(params) {
140
142
  throw error;
141
143
  }
142
144
  // 万が一処理が想定通りでない場合orderNumberが存在しない
143
- if (typeof ((_b = transaction.result) === null || _b === void 0 ? void 0 : _b.order.typeOf) !== 'string') {
144
- throw new factory.errors.ServiceUnavailable('transaction.result not found');
145
- }
146
- return transaction.result;
145
+ // if (typeof transaction.result?.order.typeOf !== 'string') {
146
+ // throw new factory.errors.ServiceUnavailable('transaction.result not found');
147
+ // }
148
+ return result;
147
149
  });
148
150
  }
149
151
  exports.confirm = confirm;
@@ -152,33 +154,27 @@ exports.confirm = confirm;
152
154
  */
153
155
  function publishConfirmationNumberIfNotExist(params) {
154
156
  return (repos) => __awaiter(this, void 0, void 0, function* () {
155
- let transaction = yield repos.transaction.findInProgressById({
156
- typeOf: factory.transactionType.PlaceOrder,
157
- id: params.id
158
- });
157
+ // 最適化(2023-02-03~)
158
+ let confirmationNumber = yield repos.transaction.findInProgressConfirmationNumberById({ id: params.id });
159
159
  // すでに発行済であれば何もしない
160
- if (typeof transaction.object.confirmationNumber === 'string') {
161
- return transaction.object.confirmationNumber;
160
+ if (typeof confirmationNumber === 'string') {
161
+ return confirmationNumber;
162
162
  }
163
163
  // 確認番号を発行
164
- const confirmationNumber = (yield repos.confirmationNumber.publish({
165
- orderDate: params.object.orderDate
166
- })).toString();
164
+ confirmationNumber = yield repos.confirmationNumber.publish({ orderDate: params.object.orderDate });
167
165
  // 取引に存在しなければ保管
168
166
  yield repos.transaction.saveConfirmationNumberIfNotExist({
169
- id: transaction.id,
167
+ id: params.id,
170
168
  confirmationNumber
171
169
  });
172
170
  // 確認番号を取引から再取得
173
- transaction = yield repos.transaction.findInProgressById({
174
- typeOf: factory.transactionType.PlaceOrder,
175
- id: params.id
176
- });
171
+ // 最適化(2023-02-03~)
172
+ confirmationNumber = yield repos.transaction.findInProgressConfirmationNumberById({ id: params.id });
177
173
  // 万が一処理が想定通りでない場合confirmationNumberが存在しない
178
- if (typeof transaction.object.confirmationNumber !== 'string') {
174
+ if (typeof confirmationNumber !== 'string') {
179
175
  throw new factory.errors.ServiceUnavailable('transaction.object.confirmationNumber not found');
180
176
  }
181
- return transaction.object.confirmationNumber;
177
+ return confirmationNumber;
182
178
  });
183
179
  }
184
180
  exports.publishConfirmationNumberIfNotExist = publishConfirmationNumberIfNotExist;
@@ -187,75 +183,66 @@ exports.publishConfirmationNumberIfNotExist = publishConfirmationNumberIfNotExis
187
183
  */
188
184
  function publishOrderNumberIfNotExist(params) {
189
185
  return (repos) => __awaiter(this, void 0, void 0, function* () {
190
- let transaction = yield repos.transaction.findInProgressById({
191
- typeOf: factory.transactionType.PlaceOrder,
192
- id: params.id
193
- });
186
+ // 最適化(2023-02-03~)
187
+ let orderNumber = yield repos.transaction.findInProgressOrderNumberById({ id: params.id });
194
188
  // すでに発行済であれば何もしない
195
- if (typeof transaction.object.orderNumber === 'string') {
196
- return transaction.object.orderNumber;
189
+ if (typeof orderNumber === 'string') {
190
+ return orderNumber;
197
191
  }
198
192
  // 注文番号を発行
199
- const project = yield repos.project.findById({ id: transaction.project.id });
200
- if (typeof project.alternateName !== 'string') {
193
+ const { alternateName } = yield repos.project.findAlternateNameById({ id: params.project.id });
194
+ if (typeof alternateName !== 'string') {
201
195
  throw new factory.errors.NotFound('project.alternateName');
202
196
  }
203
- const orderNumber = yield repos.orderNumber.publishByTimestamp({
204
- project: { alternateName: project.alternateName },
197
+ orderNumber = yield repos.orderNumber.publishByTimestamp({
198
+ project: { alternateName },
205
199
  orderDate: params.object.orderDate
206
200
  });
207
201
  // 取引に存在しなければ保管
208
- yield repos.transaction.saveOrderNumberIfNotExist({
209
- id: transaction.id,
210
- orderNumber
211
- });
202
+ yield repos.transaction.saveOrderNumberIfNotExist({ id: params.id, orderNumber });
212
203
  // 注文番号を取引から再取得
213
- transaction = yield repos.transaction.findInProgressById({
214
- typeOf: factory.transactionType.PlaceOrder,
215
- id: params.id
216
- });
204
+ // 最適化(2023-02-03~)
205
+ orderNumber = yield repos.transaction.findInProgressOrderNumberById({ id: params.id });
217
206
  // 万が一処理が想定通りでない場合orderNumberが存在しない
218
- if (typeof transaction.object.orderNumber !== 'string') {
207
+ if (typeof orderNumber !== 'string') {
219
208
  throw new factory.errors.ServiceUnavailable('transaction.object.orderNumber not found');
220
209
  }
221
- return transaction.object.orderNumber;
210
+ return orderNumber;
222
211
  });
223
212
  }
224
213
  exports.publishOrderNumberIfNotExist = publishOrderNumberIfNotExist;
225
214
  function createResult(params) {
226
- return () => __awaiter(this, void 0, void 0, function* () {
227
- const transaction = params.transaction;
228
- // 取引の確定条件が全て整っているかどうか確認
229
- (0, validation_1.validateTransaction)(transaction);
230
- // 注文作成
231
- const order = (0, result_1.createOrder)({
232
- orderNumber: params.orderNumber,
233
- transaction: transaction,
234
- orderDate: params.result.order.orderDate,
235
- orderStatus: factory.orderStatus.OrderProcessing,
236
- isGift: false
237
- });
238
- (0, validation_1.validateEventOffers)({
239
- transaction: transaction,
240
- order: order
241
- });
242
- // 注文アイテム数制限確認
243
- (0, validation_1.validateNumItems)({
244
- order: order,
245
- result: params.result
246
- });
247
- (0, validation_1.validatePaymentMethods)({ order });
248
- // 確認番号を発行
249
- const { confirmationNumber, identifier, url } = yield createConfirmationNumber({
250
- order: order,
251
- transaction: transaction,
252
- result: params.result
253
- })();
254
- order.confirmationNumber = confirmationNumber;
255
- order.identifier = identifier;
256
- order.url = url;
257
- return { order };
215
+ const transaction = params.transaction;
216
+ // 取引の確定条件が全て整っているかどうか確認
217
+ (0, validation_1.validateTransaction)(transaction);
218
+ // 注文作成
219
+ const order = (0, result_1.createOrder)({
220
+ orderNumber: params.orderNumber,
221
+ transaction: transaction,
222
+ orderDate: params.result.order.orderDate,
223
+ orderStatus: factory.orderStatus.OrderProcessing,
224
+ isGift: false
258
225
  });
226
+ (0, validation_1.validateEventOffers)({
227
+ transaction: transaction,
228
+ order: order
229
+ });
230
+ // 注文アイテム数制限確認
231
+ (0, validation_1.validateNumItems)({
232
+ order: order,
233
+ result: params.result
234
+ });
235
+ (0, validation_1.validatePaymentMethods)({ order });
236
+ // 確認番号を発行
237
+ const { confirmationNumber, identifier, url } = createConfirmationNumber({
238
+ order: order,
239
+ transaction: transaction,
240
+ result: params.result
241
+ });
242
+ order.confirmationNumber = confirmationNumber;
243
+ order.identifier = identifier;
244
+ order.url = url;
245
+ return { order };
259
246
  }
260
247
  function searchAuthorizeActions(params) {
261
248
  return (repos) => __awaiter(this, void 0, void 0, function* () {
@@ -273,34 +260,32 @@ function searchAuthorizeActions(params) {
273
260
  });
274
261
  }
275
262
  function createConfirmationNumber(params) {
276
- return () => __awaiter(this, void 0, void 0, function* () {
277
- const confirmationNumber = params.transaction.object.confirmationNumber;
278
- let url = '';
279
- let identifier = [];
280
- // 取引に確認番号が保管されていなければ、確認番号を発行
281
- if (typeof confirmationNumber !== 'string') {
282
- // 事前に発行済なはずなので、ありえないフロー
283
- throw new factory.errors.ServiceUnavailable('object.confirmationNumber undefined');
284
- }
285
- // URLの指定があれば上書き
263
+ const confirmationNumber = params.transaction.object.confirmationNumber;
264
+ let url = '';
265
+ let identifier = [];
266
+ // 取引に確認番号が保管されていなければ、確認番号を発行
267
+ if (typeof confirmationNumber !== 'string') {
268
+ // 事前に発行済なはずなので、ありえないフロー
269
+ throw new factory.errors.ServiceUnavailable('object.confirmationNumber undefined');
270
+ }
271
+ // URLの指定があれば上書き
272
+ // tslint:disable-next-line:no-single-line-block-comment
273
+ /* istanbul ignore if */
274
+ if (typeof params.result.order.url === 'string') {
275
+ url = params.result.order.url;
276
+ }
277
+ else /* istanbul ignore next */ if (typeof params.result.order.url === 'function') {
286
278
  // tslint:disable-next-line:no-single-line-block-comment
287
- /* istanbul ignore if */
288
- if (typeof params.result.order.url === 'string') {
289
- url = params.result.order.url;
290
- }
291
- else /* istanbul ignore next */ if (typeof params.result.order.url === 'function') {
292
- // tslint:disable-next-line:no-single-line-block-comment
293
- /* istanbul ignore next */
294
- url = params.result.order.url(params.order);
295
- }
296
- // 識別子の指定があれば上書き
297
- identifier = [
298
- ...(Array.isArray(params.result.order.identifier)) ? params.result.order.identifier : [],
299
- // 取引に指定があれば追加
300
- ...(Array.isArray(params.transaction.object.identifier)) ? params.transaction.object.identifier : []
301
- ];
302
- return { confirmationNumber, url, identifier };
303
- });
279
+ /* istanbul ignore next */
280
+ url = params.result.order.url(params.order);
281
+ }
282
+ // 識別子の指定があれば上書き
283
+ identifier = [
284
+ ...(Array.isArray(params.result.order.identifier)) ? params.result.order.identifier : [],
285
+ // 取引に指定があれば追加
286
+ ...(Array.isArray(params.transaction.object.identifier)) ? params.transaction.object.identifier : []
287
+ ];
288
+ return { confirmationNumber, url, identifier };
304
289
  }
305
290
  /**
306
291
  * インセンティブ承認
@@ -306,7 +306,7 @@ function validateAppliedReturnPolicy(params) {
306
306
  function confirm(params) {
307
307
  return (repos) => __awaiter(this, void 0, void 0, function* () {
308
308
  var _a;
309
- let transaction = yield repos.transaction.findById({ typeOf: factory.transactionType.ReturnOrder, id: params.id });
309
+ const transaction = yield repos.transaction.findById({ typeOf: factory.transactionType.ReturnOrder, id: params.id });
310
310
  if (transaction.status === factory.transactionStatusType.Confirmed) {
311
311
  // すでに確定済の場合
312
312
  return transaction.result;
@@ -356,14 +356,14 @@ function confirm(params) {
356
356
  // useConfirmRefund: params.useConfirmRefund
357
357
  });
358
358
  // ステータス変更
359
- transaction = yield repos.transaction.confirm({
359
+ yield repos.transaction.confirm({
360
360
  typeOf: transaction.typeOf,
361
361
  id: transaction.id,
362
362
  authorizeActions: [],
363
363
  result: result,
364
364
  potentialActions: potentialActions
365
365
  });
366
- return transaction.result;
366
+ return result;
367
367
  });
368
368
  }
369
369
  exports.confirm = confirm;
@@ -386,9 +386,11 @@ function exportTasksById(params) {
386
386
  transaction,
387
387
  runsAt: taskRunsAt
388
388
  });
389
- yield Promise.all(taskAttributes.map((taskAttribute) => __awaiter(this, void 0, void 0, function* () {
390
- yield repos.task.save(taskAttribute);
391
- })));
389
+ // saveManyに変更(2023-02-01~)
390
+ yield repos.task.saveMany(taskAttributes);
391
+ // await Promise.all(taskAttributes.map(async (taskAttribute) => {
392
+ // await repos.task.save(taskAttribute);
393
+ // }));
392
394
  });
393
395
  }
394
396
  exports.exportTasksById = exportTasksById;
@@ -23,6 +23,8 @@ export declare type ISettings = factory.project.ISettings & {
23
23
  maxNumCreditCardPaymentMethod?: number;
24
24
  };
25
25
  export declare const DEFAULT_PAYMENT_METHOD_TYPE_FOR_CREDIT_CARD: string;
26
+ export declare const USE_ASSET_TRANSACTION_SYNC_PROCESSING: boolean;
27
+ export declare const USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING: boolean;
26
28
  /**
27
29
  * グローバル設定
28
30
  */