@chevre/domain 21.2.0-alpha.6 → 21.2.0-alpha.60

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 (232) hide show
  1. package/example/src/chevre/aggregation/aggregateSystem.ts +58 -31
  2. package/example/src/chevre/countDelayedTasks.ts +17 -0
  3. package/example/src/chevre/countDelayedTransactions.ts +60 -0
  4. package/example/src/chevre/countMoneyTransferTransaction.ts +36 -0
  5. package/example/src/chevre/createManyEventsIfNotExist.ts +4 -1
  6. package/example/src/chevre/deleteTasksByName.ts +2 -1
  7. package/example/src/chevre/importEventsFromCOA.ts +3 -4
  8. package/example/src/chevre/migrateOrderAdditionalProperties.ts +85 -0
  9. package/example/src/chevre/migrateStockHolderKeys.ts +89 -0
  10. package/example/src/chevre/saveTasks.ts +13 -10
  11. package/example/src/chevre/searchAbortedTasks.ts +36 -0
  12. package/example/src/chevre/searchSendEmailActions.ts +44 -0
  13. package/example/src/chevre/task/executeTasks.ts +26 -0
  14. package/example/src/chevre/transaction/findCreditCard.ts +1 -1
  15. package/example/src/chevre/transaction/orderMembershipService.ts +1 -1
  16. package/example/src/chevre/transaction/startExportTasks.ts +20 -0
  17. package/example/src/chevre/updateTransaction.ts +1 -1
  18. package/lib/chevre/credentials.d.ts +1 -0
  19. package/lib/chevre/credentials.js +2 -1
  20. package/lib/chevre/eventEmitter/assetTransaction.d.ts +21 -0
  21. package/lib/chevre/eventEmitter/assetTransaction.js +25 -0
  22. package/lib/chevre/eventEmitter/task.d.ts +18 -0
  23. package/lib/chevre/eventEmitter/task.js +25 -0
  24. package/lib/chevre/eventEmitter/transaction.d.ts +21 -0
  25. package/lib/chevre/eventEmitter/transaction.js +25 -0
  26. package/lib/chevre/eventEmitter.d.ts +4 -0
  27. package/lib/chevre/eventEmitter.js +9 -0
  28. package/lib/chevre/index.d.ts +3 -2
  29. package/lib/chevre/index.js +5 -3
  30. package/lib/chevre/repo/account.js +0 -4
  31. package/lib/chevre/repo/accountTitle.js +0 -4
  32. package/lib/chevre/repo/accountTransaction.d.ts +3 -11
  33. package/lib/chevre/repo/accountTransaction.js +1 -58
  34. package/lib/chevre/repo/accountingReport.js +0 -4
  35. package/lib/chevre/repo/action.d.ts +29 -1
  36. package/lib/chevre/repo/action.js +32 -29
  37. package/lib/chevre/repo/additionalProperty.js +0 -4
  38. package/lib/chevre/repo/aggregation.js +0 -4
  39. package/lib/chevre/repo/assetTransaction.d.ts +23 -8
  40. package/lib/chevre/repo/assetTransaction.js +207 -68
  41. package/lib/chevre/repo/categoryCode.js +0 -4
  42. package/lib/chevre/repo/code.js +0 -4
  43. package/lib/chevre/repo/comment.d.ts +4 -1
  44. package/lib/chevre/repo/comment.js +20 -9
  45. package/lib/chevre/repo/confirmationNumber.d.ts +0 -1
  46. package/lib/chevre/repo/confirmationNumber.js +3 -15
  47. package/lib/chevre/repo/creativeWork.d.ts +1 -3
  48. package/lib/chevre/repo/creativeWork.js +0 -4
  49. package/lib/chevre/repo/customer.js +0 -4
  50. package/lib/chevre/repo/emailMessage.d.ts +1 -27
  51. package/lib/chevre/repo/emailMessage.js +0 -4
  52. package/lib/chevre/repo/event.d.ts +5 -1
  53. package/lib/chevre/repo/event.js +0 -4
  54. package/lib/chevre/repo/member.js +0 -4
  55. package/lib/chevre/repo/merchantReturnPolicy.d.ts +1 -3
  56. package/lib/chevre/repo/merchantReturnPolicy.js +0 -4
  57. package/lib/chevre/repo/mongoose/schemas/account.d.ts +5 -2
  58. package/lib/chevre/repo/mongoose/schemas/account.js +1 -0
  59. package/lib/chevre/repo/mongoose/schemas/accountTitle.d.ts +30 -3
  60. package/lib/chevre/repo/mongoose/schemas/accountTitle.js +1 -0
  61. package/lib/chevre/repo/mongoose/schemas/accountTransaction.d.ts +32 -3
  62. package/lib/chevre/repo/mongoose/schemas/accountTransaction.js +2 -1
  63. package/lib/chevre/repo/mongoose/schemas/accountingReport.d.ts +14 -3
  64. package/lib/chevre/repo/mongoose/schemas/accountingReport.js +1 -0
  65. package/lib/chevre/repo/mongoose/schemas/action.d.ts +44 -3
  66. package/lib/chevre/repo/mongoose/schemas/action.js +2 -1
  67. package/lib/chevre/repo/mongoose/schemas/additionalProperty.d.ts +18 -3
  68. package/lib/chevre/repo/mongoose/schemas/additionalProperty.js +1 -0
  69. package/lib/chevre/repo/mongoose/schemas/aggregation.d.ts +5 -2
  70. package/lib/chevre/repo/mongoose/schemas/aggregation.js +1 -0
  71. package/lib/chevre/repo/mongoose/schemas/assetTransaction.d.ts +45 -3
  72. package/lib/chevre/repo/mongoose/schemas/assetTransaction.js +3 -1
  73. package/lib/chevre/repo/mongoose/schemas/authorization.d.ts +20 -3
  74. package/lib/chevre/repo/mongoose/schemas/authorization.js +2 -1
  75. package/lib/chevre/repo/mongoose/schemas/categoryCode.d.ts +26 -3
  76. package/lib/chevre/repo/mongoose/schemas/categoryCode.js +1 -0
  77. package/lib/chevre/repo/mongoose/schemas/comments.d.ts +28 -3
  78. package/lib/chevre/repo/mongoose/schemas/comments.js +2 -1
  79. package/lib/chevre/repo/mongoose/schemas/creativeWork.d.ts +44 -3
  80. package/lib/chevre/repo/mongoose/schemas/creativeWork.js +1 -0
  81. package/lib/chevre/repo/mongoose/schemas/customer.d.ts +26 -3
  82. package/lib/chevre/repo/mongoose/schemas/customer.js +1 -0
  83. package/lib/chevre/repo/mongoose/schemas/emailMessages.d.ts +22 -3
  84. package/lib/chevre/repo/mongoose/schemas/emailMessages.js +1 -0
  85. package/lib/chevre/repo/mongoose/schemas/event.d.ts +72 -3
  86. package/lib/chevre/repo/mongoose/schemas/event.js +1 -0
  87. package/lib/chevre/repo/mongoose/schemas/member.d.ts +14 -3
  88. package/lib/chevre/repo/mongoose/schemas/member.js +1 -0
  89. package/lib/chevre/repo/mongoose/schemas/merchantReturnPolicy.d.ts +22 -3
  90. package/lib/chevre/repo/mongoose/schemas/merchantReturnPolicy.js +1 -0
  91. package/lib/chevre/repo/mongoose/schemas/offer.d.ts +66 -3
  92. package/lib/chevre/repo/mongoose/schemas/offer.js +1 -0
  93. package/lib/chevre/repo/mongoose/schemas/offerCatalog.d.ts +28 -3
  94. package/lib/chevre/repo/mongoose/schemas/offerCatalog.js +1 -0
  95. package/lib/chevre/repo/mongoose/schemas/offerItemCondition.d.ts +74 -0
  96. package/lib/chevre/repo/mongoose/schemas/offerItemCondition.js +45 -0
  97. package/lib/chevre/repo/mongoose/schemas/order.d.ts +52 -3
  98. package/lib/chevre/repo/mongoose/schemas/order.js +2 -1
  99. package/lib/chevre/repo/mongoose/schemas/ownershipInfo.d.ts +26 -3
  100. package/lib/chevre/repo/mongoose/schemas/ownershipInfo.js +2 -1
  101. package/lib/chevre/repo/mongoose/schemas/place.d.ts +50 -3
  102. package/lib/chevre/repo/mongoose/schemas/place.js +1 -0
  103. package/lib/chevre/repo/mongoose/schemas/priceSpecification.d.ts +30 -3
  104. package/lib/chevre/repo/mongoose/schemas/priceSpecification.js +1 -0
  105. package/lib/chevre/repo/mongoose/schemas/product.d.ts +32 -3
  106. package/lib/chevre/repo/mongoose/schemas/product.js +1 -0
  107. package/lib/chevre/repo/mongoose/schemas/project.d.ts +24 -3
  108. package/lib/chevre/repo/mongoose/schemas/project.js +1 -0
  109. package/lib/chevre/repo/mongoose/schemas/reservation.d.ts +62 -3
  110. package/lib/chevre/repo/mongoose/schemas/reservation.js +2 -1
  111. package/lib/chevre/repo/mongoose/schemas/role.d.ts +12 -3
  112. package/lib/chevre/repo/mongoose/schemas/role.js +1 -0
  113. package/lib/chevre/repo/mongoose/schemas/seller.d.ts +32 -3
  114. package/lib/chevre/repo/mongoose/schemas/seller.js +1 -0
  115. package/lib/chevre/repo/mongoose/schemas/serviceOutput.d.ts +12 -3
  116. package/lib/chevre/repo/mongoose/schemas/serviceOutput.js +2 -1
  117. package/lib/chevre/repo/mongoose/schemas/task.d.ts +31 -3
  118. package/lib/chevre/repo/mongoose/schemas/task.js +3 -1
  119. package/lib/chevre/repo/mongoose/schemas/telemetry.d.ts +22 -3
  120. package/lib/chevre/repo/mongoose/schemas/telemetry.js +1 -0
  121. package/lib/chevre/repo/mongoose/schemas/transaction.d.ts +41 -3
  122. package/lib/chevre/repo/mongoose/schemas/transaction.js +3 -1
  123. package/lib/chevre/repo/mongoose/schemas/trip.d.ts +12 -3
  124. package/lib/chevre/repo/mongoose/schemas/trip.js +1 -0
  125. package/lib/chevre/repo/offer.js +0 -5
  126. package/lib/chevre/repo/offerCatalog.js +0 -4
  127. package/lib/chevre/repo/offerItemCondition.d.ts +39 -0
  128. package/lib/chevre/repo/offerItemCondition.js +112 -0
  129. package/lib/chevre/repo/order.d.ts +25 -0
  130. package/lib/chevre/repo/order.js +5 -4
  131. package/lib/chevre/repo/ownershipInfo.js +0 -4
  132. package/lib/chevre/repo/permit.js +0 -4
  133. package/lib/chevre/repo/place.js +0 -4
  134. package/lib/chevre/repo/priceSpecification.js +0 -4
  135. package/lib/chevre/repo/product.js +0 -4
  136. package/lib/chevre/repo/project.js +0 -4
  137. package/lib/chevre/repo/reservation.js +0 -4
  138. package/lib/chevre/repo/role.js +0 -4
  139. package/lib/chevre/repo/seller.js +0 -4
  140. package/lib/chevre/repo/serviceOutput.js +0 -4
  141. package/lib/chevre/repo/stockHolder.js +30 -0
  142. package/lib/chevre/repo/task.d.ts +41 -2
  143. package/lib/chevre/repo/task.js +97 -12
  144. package/lib/chevre/repo/telemetry.js +0 -4
  145. package/lib/chevre/repo/transaction.d.ts +23 -3
  146. package/lib/chevre/repo/transaction.js +174 -58
  147. package/lib/chevre/repo/trip.js +0 -4
  148. package/lib/chevre/repository.d.ts +5 -2
  149. package/lib/chevre/repository.js +8 -4
  150. package/lib/chevre/service/aggregation/system.d.ts +67 -22
  151. package/lib/chevre/service/aggregation/system.js +101 -89
  152. package/lib/chevre/service/assetTransaction/cancelReservation.js +23 -25
  153. package/lib/chevre/service/assetTransaction/moneyTransfer.js +23 -21
  154. package/lib/chevre/service/assetTransaction/pay/potentialActions.js +17 -1
  155. package/lib/chevre/service/assetTransaction/pay.js +32 -24
  156. package/lib/chevre/service/assetTransaction/refund.js +23 -21
  157. package/lib/chevre/service/assetTransaction/registerService.js +23 -22
  158. package/lib/chevre/service/assetTransaction/reserve.js +23 -21
  159. package/lib/chevre/service/assetTransaction.d.ts +6 -2
  160. package/lib/chevre/service/assetTransaction.js +9 -5
  161. package/lib/chevre/service/event.js +3 -1
  162. package/lib/chevre/service/notification/factory.js +2 -2
  163. package/lib/chevre/service/notification.d.ts +3 -1
  164. package/lib/chevre/service/notification.js +41 -7
  165. package/lib/chevre/service/offer/event/voidTransaction.d.ts +2 -0
  166. package/lib/chevre/service/offer/event/voidTransaction.js +17 -1
  167. package/lib/chevre/service/offer.js +1 -1
  168. package/lib/chevre/service/order/deleteOrder.js +8 -8
  169. package/lib/chevre/service/order/onOrderStatusChanged/factory.js +25 -36
  170. package/lib/chevre/service/order/onOrderStatusChanged.js +1 -1
  171. package/lib/chevre/service/order/placeOrder.js +1 -1
  172. package/lib/chevre/service/order/returnOrder.js +1 -5
  173. package/lib/chevre/service/order/sendOrder.js +1 -1
  174. package/lib/chevre/service/payment/any/onPaid.js +1 -1
  175. package/lib/chevre/service/payment/any/onRefund.js +1 -1
  176. package/lib/chevre/service/payment/any.js +60 -10
  177. package/lib/chevre/service/payment/movieTicket/validation.d.ts +3 -2
  178. package/lib/chevre/service/payment/movieTicket/validation.js +12 -25
  179. package/lib/chevre/service/payment/movieTicket.d.ts +1 -1
  180. package/lib/chevre/service/payment/movieTicket.js +4 -3
  181. package/lib/chevre/service/product.js +1 -5
  182. package/lib/chevre/service/report/telemetry.d.ts +0 -11
  183. package/lib/chevre/service/report/telemetry.js +21 -24
  184. package/lib/chevre/service/reserve/cancelReservation.js +0 -2
  185. package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.d.ts +0 -3
  186. package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.js +20 -20
  187. package/lib/chevre/service/reserve/potentialActions/onReservationCheckedIn.js +2 -3
  188. package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.js +2 -31
  189. package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +2 -3
  190. package/lib/chevre/service/reserve/useReservation.js +1 -8
  191. package/lib/chevre/service/task/confirmRegisterServiceTransaction.js +1 -1
  192. package/lib/chevre/service/task/deleteTransaction.js +10 -8
  193. package/lib/chevre/service/task/importOffersFromCOA.js +4 -0
  194. package/lib/chevre/service/task/returnPayTransaction.js +2 -12
  195. package/lib/chevre/service/task/voidReserveTransaction.js +3 -1
  196. package/lib/chevre/service/task.d.ts +9 -0
  197. package/lib/chevre/service/task.js +43 -4
  198. package/lib/chevre/service/transaction/deleteTransaction.d.ts +21 -0
  199. package/lib/chevre/service/transaction/deleteTransaction.js +226 -0
  200. package/lib/chevre/service/transaction/moneyTransfer/exportTasks/factory.js +11 -1
  201. package/lib/chevre/service/transaction/moneyTransfer/factory.js +3 -1
  202. package/lib/chevre/service/transaction/moneyTransfer/potentialActions.d.ts +1 -0
  203. package/lib/chevre/service/transaction/moneyTransfer/potentialActions.js +1 -1
  204. package/lib/chevre/service/transaction/moneyTransfer.js +9 -12
  205. package/lib/chevre/service/transaction/orderProgramMembership.js +2 -1
  206. package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.js +42 -30
  207. package/lib/chevre/service/transaction/placeOrder.js +1 -5
  208. package/lib/chevre/service/transaction/placeOrderInProgress/factory.js +1 -1
  209. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/moneyTransfer.d.ts +1 -0
  210. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/moneyTransfer.js +1 -1
  211. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/registerService.d.ts +1 -0
  212. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/registerService.js +1 -1
  213. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions.d.ts +1 -0
  214. package/lib/chevre/service/transaction/placeOrderInProgress/result/acceptedOffers.d.ts +3 -0
  215. package/lib/chevre/service/transaction/placeOrderInProgress/result/acceptedOffers.js +7 -3
  216. package/lib/chevre/service/transaction/placeOrderInProgress/result.d.ts +1 -0
  217. package/lib/chevre/service/transaction/placeOrderInProgress/result.js +2 -2
  218. package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateMovieTicket.d.ts +1 -1
  219. package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateMovieTicket.js +2 -2
  220. package/lib/chevre/service/transaction/placeOrderInProgress/validation.d.ts +2 -1
  221. package/lib/chevre/service/transaction/placeOrderInProgress/validation.js +23 -17
  222. package/lib/chevre/service/transaction/placeOrderInProgress.d.ts +1 -3
  223. package/lib/chevre/service/transaction/placeOrderInProgress.js +22 -11
  224. package/lib/chevre/service/transaction/returnOrder/exportTasks/factory.js +10 -1
  225. package/lib/chevre/service/transaction/returnOrder.js +1 -5
  226. package/lib/chevre/service/transaction.d.ts +8 -13
  227. package/lib/chevre/service/transaction.js +12 -145
  228. package/lib/chevre/settings.d.ts +6 -1
  229. package/lib/chevre/settings.js +17 -5
  230. package/package.json +5 -5
  231. package/example/src/chevre/migrateMoneyTransferPendingTransactionIdentifier.ts +0 -96
  232. package/example/src/chevre/migrateMovieAdditionalProperties.ts +0 -98
@@ -7,6 +7,7 @@ const settings_1 = require("../../../../settings");
7
7
  /**
8
8
  * 取引のタスクを作成する
9
9
  */
10
+ // tslint:disable-next-line:max-func-body-length
10
11
  function createTasks(params) {
11
12
  const taskAttributes = [];
12
13
  const transaction = params.transaction;
@@ -35,7 +36,16 @@ function createTasks(params) {
35
36
  numberOfTried: 0,
36
37
  executionResults: [],
37
38
  data: {
38
- object: transaction
39
+ object: {
40
+ endDate: transaction.endDate,
41
+ id: transaction.id,
42
+ object: Object.assign({}, (transaction.object.pendingTransaction !== undefined)
43
+ ? { pendingTransaction: transaction.object.pendingTransaction }
44
+ : undefined),
45
+ project: transaction.project,
46
+ startDate: transaction.startDate,
47
+ typeOf: transaction.typeOf
48
+ }
39
49
  }
40
50
  };
41
51
  taskAttributes.push(deleteTransactionTask);
@@ -17,7 +17,9 @@ function createStartParams(params, passport, seller, amount, fromLocation, toLoc
17
17
  // ↓最適化(2022-05-24~)
18
18
  // ...{ project: seller.project }
19
19
  },
20
- object: Object.assign(Object.assign({ amount: amount, fromLocation: fromLocation, toLocation: toLocation, authorizeActions: [], pendingTransaction: Object.assign({ transactionNumber }, (typeof ((_a = params.object.pendingTransaction) === null || _a === void 0 ? void 0 : _a.identifier) === 'string')
20
+ object: Object.assign(Object.assign({ amount: amount, fromLocation: fromLocation, toLocation: toLocation,
21
+ // authorizeActions: [],
22
+ pendingTransaction: Object.assign({ transactionNumber }, (typeof ((_a = params.object.pendingTransaction) === null || _a === void 0 ? void 0 : _a.identifier) === 'string')
21
23
  ? { identifier: params.object.pendingTransaction.identifier }
22
24
  : undefined) }, (passport !== undefined) ? { passport } : undefined), (typeof params.object.description === 'string') ? { description: params.object.description } : undefined),
23
25
  expires: params.expires
@@ -4,5 +4,6 @@ export type IAuthorizeMoneyTransferOffer = factory.action.authorize.offer.moneyT
4
4
  * 取引のポストアクションを作成する
5
5
  */
6
6
  export declare function createPotentialActions(params: {
7
+ authorizeActions: factory.action.authorize.IAction<factory.action.authorize.IAttributes<any, any>>[];
7
8
  transaction: factory.transaction.ITransaction<factory.transactionType.MoneyTransfer>;
8
9
  }): Promise<factory.transaction.IPotentialActions<factory.transactionType.MoneyTransfer>>;
@@ -13,7 +13,7 @@ exports.createPotentialActions = void 0;
13
13
  const factory = require("../../../factory");
14
14
  function createMoneyTransferActions(params) {
15
15
  const moneyTransferActions = [];
16
- const authorizeMoneyTransferActions = params.transaction.object.authorizeActions
16
+ const authorizeMoneyTransferActions = params.authorizeActions
17
17
  .filter((a) => a.actionStatus === factory.actionStatusType.CompletedActionStatus)
18
18
  .filter((a) => a.object.typeOf === factory.offerType.Offer)
19
19
  .filter((a) => { var _a; return ((_a = a.object.itemOffered) === null || _a === void 0 ? void 0 : _a.typeOf) === factory.actionType.MoneyTransfer; });
@@ -519,19 +519,17 @@ function confirm(params) {
519
519
  // throw new factory.errors.Forbidden('Transaction not yours');
520
520
  // }
521
521
  // 取引に対する全ての承認アクションをマージ
522
- transaction.object.authorizeActions = yield searchAuthorizeActions({
522
+ const authorizeActions = yield searchAuthorizeActions({
523
523
  transaction: transaction,
524
524
  now: now
525
525
  })(repos);
526
526
  // ポストアクションを作成
527
- const potentialActions = yield (0, potentialActions_1.createPotentialActions)({
528
- transaction: transaction
529
- });
527
+ const potentialActions = yield (0, potentialActions_1.createPotentialActions)({ authorizeActions, transaction });
530
528
  // 取引確定
531
529
  yield repos.transaction.confirm({
532
530
  typeOf: factory.transactionType.MoneyTransfer,
533
531
  id: transaction.id,
534
- authorizeActions: transaction.object.authorizeActions,
532
+ authorizeActions: [],
535
533
  result: {},
536
534
  potentialActions: potentialActions
537
535
  });
@@ -545,13 +543,14 @@ function searchAuthorizeActions(params) {
545
543
  purpose: {
546
544
  typeOf: params.transaction.typeOf,
547
545
  id: params.transaction.id
548
- }
546
+ },
547
+ // Completedに絞る(2023-05-16~)
548
+ actionStatus: { $eq: factory.actionStatusType.CompletedActionStatus }
549
549
  });
550
550
  // 万が一このプロセス中に他処理が発生してもそれらを無視するように、endDateでフィルタリング
551
551
  authorizeActions = authorizeActions.filter((a) => {
552
- return a.endDate !== undefined
553
- && moment(a.endDate)
554
- .toDate() < params.now;
552
+ return (a.endDate instanceof Date) && moment(a.endDate)
553
+ .isBefore(moment(params.now));
555
554
  });
556
555
  return authorizeActions;
557
556
  });
@@ -576,9 +575,7 @@ function exportTasksById(params) {
576
575
  transaction,
577
576
  runsAt: taskRunsAt
578
577
  });
579
- // saveManyに変更(2023-02-01~)
580
- yield repos.task.saveMany(taskAttributes);
581
- // await Promise.all(taskAttributes.map(async (a) => repos.task.save(a)));
578
+ yield repos.task.saveMany(taskAttributes, { emitImmediately: true });
582
579
  });
583
580
  }
584
581
  exports.exportTasksById = exportTasksById;
@@ -213,7 +213,8 @@ function processPlaceOrder(params) {
213
213
  orderDate: new Date()
214
214
  }
215
215
  },
216
- potentialActions: params.potentialActions
216
+ potentialActions: params.potentialActions,
217
+ saveAuthorizeActions: true
217
218
  })(repos);
218
219
  });
219
220
  }
@@ -75,10 +75,49 @@ function createTasks(params) {
75
75
  numberOfTried: 0,
76
76
  executionResults: [],
77
77
  data: {
78
- object: transaction
78
+ object: {
79
+ endDate: transaction.endDate,
80
+ id: transaction.id,
81
+ object: Object.assign(Object.assign({}, (typeof transaction.object.confirmationNumber === 'string')
82
+ ? { confirmationNumber: transaction.object.confirmationNumber }
83
+ : undefined), (typeof transaction.object.orderNumber === 'string')
84
+ ? { orderNumber: transaction.object.orderNumber }
85
+ : undefined),
86
+ project: transaction.project,
87
+ startDate: transaction.startDate,
88
+ typeOf: transaction.typeOf
89
+ }
90
+ }
91
+ };
92
+ // 確定取引にも決済承認中止タスクを追加(2023-05-03~)
93
+ const voidPaymentTaskAttributes = {
94
+ project: transaction.project,
95
+ name: factory.taskName.VoidPayTransaction,
96
+ status: factory.taskStatus.Ready,
97
+ runsAt: taskRunsAt,
98
+ remainingNumberOfTries: 10,
99
+ numberOfTried: 0,
100
+ executionResults: [],
101
+ data: {
102
+ project: transaction.project,
103
+ purpose: { typeOf: transaction.typeOf, id: transaction.id }
79
104
  }
80
105
  };
81
- taskAttributes.push(...triggerWebhookTaskAttributes, deleteTransactionTask);
106
+ // 確定取引にも興行オファー承認中止タスクを追加(2023-05-09~)
107
+ const voidReserveTaskAttributes = {
108
+ project: transaction.project,
109
+ name: factory.taskName.VoidReserveTransaction,
110
+ status: factory.taskStatus.Ready,
111
+ runsAt: taskRunsAt,
112
+ remainingNumberOfTries: 10,
113
+ numberOfTried: 0,
114
+ executionResults: [],
115
+ data: {
116
+ project: transaction.project,
117
+ purpose: { typeOf: transaction.typeOf, id: transaction.id }
118
+ }
119
+ };
120
+ taskAttributes.push(...triggerWebhookTaskAttributes, deleteTransactionTask, voidPaymentTaskAttributes, voidReserveTaskAttributes);
82
121
  switch (transaction.status) {
83
122
  case factory.transactionStatusType.Confirmed:
84
123
  const potentialActions = transaction.potentialActions;
@@ -107,22 +146,8 @@ function createTasks(params) {
107
146
  };
108
147
  taskAttributes.push(placeOrderTaskAttributes);
109
148
  break;
110
- // 期限切れor中止の場合は、タスクリストを作成する
111
149
  case factory.transactionStatusType.Canceled:
112
150
  case factory.transactionStatusType.Expired:
113
- const voidReserveTaskAttributes = {
114
- project: transaction.project,
115
- name: factory.taskName.VoidReserveTransaction,
116
- status: factory.taskStatus.Ready,
117
- runsAt: taskRunsAt,
118
- remainingNumberOfTries: 10,
119
- numberOfTried: 0,
120
- executionResults: [],
121
- data: {
122
- project: transaction.project,
123
- purpose: { typeOf: transaction.typeOf, id: transaction.id }
124
- }
125
- };
126
151
  const voidRegisterServiceTaskAttributes = {
127
152
  project: transaction.project,
128
153
  name: factory.taskName.VoidRegisterServiceTransaction,
@@ -136,19 +161,6 @@ function createTasks(params) {
136
161
  purpose: { typeOf: transaction.typeOf, id: transaction.id }
137
162
  }
138
163
  };
139
- const voidPaymentTaskAttributes = {
140
- project: transaction.project,
141
- name: factory.taskName.VoidPayTransaction,
142
- status: factory.taskStatus.Ready,
143
- runsAt: taskRunsAt,
144
- remainingNumberOfTries: 10,
145
- numberOfTried: 0,
146
- executionResults: [],
147
- data: {
148
- project: transaction.project,
149
- purpose: { typeOf: transaction.typeOf, id: transaction.id }
150
- }
151
- };
152
164
  const voidMoneyTransferTaskAttributes = {
153
165
  project: transaction.project,
154
166
  name: factory.taskName.VoidMoneyTransferTransaction,
@@ -162,7 +174,7 @@ function createTasks(params) {
162
174
  purpose: { typeOf: transaction.typeOf, id: transaction.id }
163
175
  }
164
176
  };
165
- taskAttributes.push(voidReserveTaskAttributes, voidRegisterServiceTaskAttributes, voidPaymentTaskAttributes, voidMoneyTransferTaskAttributes);
177
+ taskAttributes.push(voidRegisterServiceTaskAttributes, voidMoneyTransferTaskAttributes);
166
178
  break;
167
179
  default:
168
180
  throw new factory.errors.NotImplemented(`Transaction status "${transaction.status}" not implemented.`);
@@ -36,11 +36,7 @@ function exportTasksById(params) {
36
36
  transaction,
37
37
  runsAt: taskRunsAt
38
38
  });
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
- // }));
39
+ yield repos.task.saveMany(taskAttributes, { emitImmediately: true });
44
40
  });
45
41
  }
46
42
  exports.exportTasksById = exportTasksById;
@@ -4,7 +4,7 @@ exports.createStartParams = void 0;
4
4
  const factory = require("../../../factory");
5
5
  function createStartParams(params, passport, seller, broker) {
6
6
  var _a, _b, _c, _d;
7
- const transactionObject = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ passportToken: (typeof ((_a = params.object.passport) === null || _a === void 0 ? void 0 : _a.token) === 'string') ? params.object.passport.token : undefined, authorizeActions: [] }, (passport !== undefined) ? { passport } : undefined), (params.object.clientUser !== undefined && params.object.clientUser !== null)
7
+ const transactionObject = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ passportToken: (typeof ((_a = params.object.passport) === null || _a === void 0 ? void 0 : _a.token) === 'string') ? params.object.passport.token : undefined }, (passport !== undefined) ? { passport } : undefined), (params.object.clientUser !== undefined && params.object.clientUser !== null)
8
8
  ? { clientUser: params.object.clientUser }
9
9
  : undefined), (typeof ((_b = params.object) === null || _b === void 0 ? void 0 : _b.name) === 'string') ? { name: (_c = params.object) === null || _c === void 0 ? void 0 : _c.name } : undefined), (typeof (broker === null || broker === void 0 ? void 0 : broker.typeOf) === 'string') ? { broker: broker } : undefined), (typeof ((_d = params.object.customer) === null || _d === void 0 ? void 0 : _d.typeOf) === 'string') ? { customer: params.object.customer } : undefined);
10
10
  if (typeof seller.id !== 'string') {
@@ -3,4 +3,5 @@ export type IAuthorizeMoneyTransferOffer = factory.action.authorize.offer.moneyT
3
3
  export declare function createMoneyTransferActions(params: {
4
4
  order: factory.order.IOrder;
5
5
  transaction: factory.transaction.placeOrder.ITransaction;
6
+ authorizeActions: factory.action.authorize.IAction<factory.action.authorize.IAttributes<any, any>>[];
6
7
  }): Promise<factory.action.interact.confirm.moneyTransfer.IAttributes[]>;
@@ -15,7 +15,7 @@ const order_1 = require("../../../../factory/order");
15
15
  function createMoneyTransferActions(params) {
16
16
  return __awaiter(this, void 0, void 0, function* () {
17
17
  const moneyTransferActions = [];
18
- const authorizeMoneyTransferActions = params.transaction.object.authorizeActions
18
+ const authorizeMoneyTransferActions = params.authorizeActions
19
19
  .filter((a) => a.actionStatus === factory.actionStatusType.CompletedActionStatus)
20
20
  .filter((a) => a.object.typeOf === factory.offerType.Offer)
21
21
  .filter((a) => { var _a; return ((_a = a.object.itemOffered) === null || _a === void 0 ? void 0 : _a.typeOf) === factory.actionType.MoneyTransfer; });
@@ -2,4 +2,5 @@ import * as factory from '../../../../factory';
2
2
  export declare function createRegisterServiceActions(params: {
3
3
  order: factory.order.IOrder;
4
4
  transaction: factory.transaction.placeOrder.ITransaction;
5
+ authorizeActions: factory.action.authorize.IAction<factory.action.authorize.IAttributes<any, any>>[];
5
6
  }): Promise<factory.action.interact.confirm.registerService.IAttributes[]>;
@@ -17,7 +17,7 @@ const order_1 = require("../../../../factory/order");
17
17
  function createRegisterServiceActions(params) {
18
18
  return __awaiter(this, void 0, void 0, function* () {
19
19
  const registerServiceActions = [];
20
- const authorizeProductOfferActions = params.transaction.object.authorizeActions
20
+ const authorizeProductOfferActions = params.authorizeActions
21
21
  .filter((a) => a.actionStatus === factory.actionStatusType.CompletedActionStatus)
22
22
  .filter((a) => Array.isArray(a.object)
23
23
  && a.object.length > 0
@@ -7,4 +7,5 @@ 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
+ authorizeActions: factory.action.authorize.IAction<factory.action.authorize.IAttributes<any, any>>[];
10
11
  }): Promise<factory.transaction.placeOrder.IPotentialActions>;
@@ -3,12 +3,14 @@ export type IAuthorizeMoneyTransferOffer = factory.action.authorize.offer.moneyT
3
3
  export type IAuthorizeSeatReservationOffer = factory.action.authorize.offer.seatReservation.IAction<factory.service.webAPI.Identifier>;
4
4
  export declare function createReservationAcceptedOffers(params: {
5
5
  transaction: factory.transaction.placeOrder.ITransaction;
6
+ authorizeActions: factory.action.authorize.IAction<factory.action.authorize.IAttributes<any, any>>[];
6
7
  }): {
7
8
  reservationAcceptedOffers: factory.order.IAcceptedOffer<factory.order.IReservation>[];
8
9
  reservationOrderItems: factory.order.IOrderedItem[];
9
10
  };
10
11
  export declare function createProductItems(params: {
11
12
  transaction: factory.transaction.placeOrder.ITransaction;
13
+ authorizeActions: factory.action.authorize.IAction<factory.action.authorize.IAttributes<any, any>>[];
12
14
  }): {
13
15
  productAcceptedOffers: factory.order.IAcceptedOffer<factory.order.IPermit>[];
14
16
  productOrderItems: factory.order.IOrderedItem[];
@@ -16,6 +18,7 @@ export declare function createProductItems(params: {
16
18
  export declare function createMoneyTransferAcceptedOffers(params: {
17
19
  transaction: factory.transaction.placeOrder.ITransaction;
18
20
  seller: factory.order.ISeller;
21
+ authorizeActions: factory.action.authorize.IAction<factory.action.authorize.IAttributes<any, any>>[];
19
22
  }): {
20
23
  moneyTransferAcceptedOffers: factory.order.IAcceptedOffer<factory.order.IMoneyTransfer>[];
21
24
  moneyTransferOrderItems: factory.order.IOrderedItem[];
@@ -7,7 +7,7 @@ function createReservationAcceptedOffers(params) {
7
7
  const acceptedOffers = [];
8
8
  const orderedItems = [];
9
9
  // 座席予約に対する承認アクション取り出す
10
- const seatReservationAuthorizeActions = params.transaction.object.authorizeActions
10
+ const seatReservationAuthorizeActions = params.authorizeActions
11
11
  .filter((a) => a.actionStatus === factory.actionStatusType.CompletedActionStatus
12
12
  && a.object.typeOf === factory.action.authorize.offer.seatReservation.ObjectType.SeatReservation);
13
13
  const eventIds = [];
@@ -85,7 +85,7 @@ function reservationOffers2orderedItem(params) {
85
85
  function createProductItems(params) {
86
86
  const acceptedOffers = [];
87
87
  const orderedItems = [];
88
- const authorizePaymentCardOfferActions = params.transaction.object.authorizeActions
88
+ const authorizePaymentCardOfferActions = params.authorizeActions
89
89
  .filter((a) => a.actionStatus === factory.actionStatusType.CompletedActionStatus)
90
90
  .filter((a) => Array.isArray(a.object)
91
91
  && a.object.length > 0
@@ -117,7 +117,11 @@ function createProductItems(params) {
117
117
  exports.createProductItems = createProductItems;
118
118
  function createMoneyTransferAcceptedOffers(params) {
119
119
  // 通貨転送承認アクション
120
- const authorizeMoneyTansferActions = params.transaction.object.authorizeActions
120
+ // const authorizeMoneyTansferActions = (<IAuthorizeMoneyTransferOffer[]>params.transaction.object.authorizeActions)
121
+ // .filter((a) => a.actionStatus === factory.actionStatusType.CompletedActionStatus)
122
+ // .filter((a) => a.object.typeOf === factory.offerType.Offer)
123
+ // .filter((a) => a.object.itemOffered?.typeOf === factory.actionType.MoneyTransfer);
124
+ const authorizeMoneyTansferActions = params.authorizeActions
121
125
  .filter((a) => a.actionStatus === factory.actionStatusType.CompletedActionStatus)
122
126
  .filter((a) => a.object.typeOf === factory.offerType.Offer)
123
127
  .filter((a) => { var _a; return ((_a = a.object.itemOffered) === null || _a === void 0 ? void 0 : _a.typeOf) === factory.actionType.MoneyTransfer; });
@@ -9,4 +9,5 @@ export declare function createOrder(params: {
9
9
  orderDate: Date;
10
10
  orderStatus: factory.orderStatus;
11
11
  isGift: boolean;
12
+ authorizeActions: factory.action.authorize.IAction<factory.action.authorize.IAttributes<any, any>>[];
12
13
  }): factory.order.IOrder;
@@ -23,7 +23,7 @@ function createOrder(params) {
23
23
  ];
24
24
  const orderedItems = [...reservationOrderItems, ...moneyTransferOrderItems, ...productOrderItems];
25
25
  // 決済方法をセット
26
- const { paymentMethods, price } = createPaymentMethods({ transaction: params.transaction });
26
+ const { paymentMethods, price } = createPaymentMethods({ transaction: params.transaction, authorizeActions: params.authorizeActions });
27
27
  const discounts = [];
28
28
  const name = (typeof params.transaction.object.name === 'string') ? params.transaction.object.name : undefined;
29
29
  const broker = (typeof ((_a = params.transaction.object.broker) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string') ? params.transaction.object.broker : undefined;
@@ -62,7 +62,7 @@ function createCustomer(params) {
62
62
  function createPaymentMethods(params) {
63
63
  const paymentMethods = [];
64
64
  let price = 0;
65
- const authorizePaymentActions = params.transaction.object.authorizeActions
65
+ const authorizePaymentActions = params.authorizeActions
66
66
  .filter((a) => {
67
67
  var _a;
68
68
  return a.actionStatus === factory.actionStatusType.CompletedActionStatus
@@ -2,4 +2,4 @@ import * as factory from '../../../../factory';
2
2
  /**
3
3
  * 座席予約オファー承認に対してムビチケ承認条件が整っているかどうか検証する
4
4
  */
5
- export declare function validateMovieTicket(paymentMethodType: string, transaction: factory.transaction.placeOrder.ITransaction): void;
5
+ export declare function validateMovieTicket(paymentMethodType: string, transaction: factory.transaction.placeOrder.ITransaction, authorizeActions: factory.action.authorize.IAction<factory.action.authorize.IAttributes<any, any>>[]): void;
@@ -10,8 +10,8 @@ const debug = createDebug('cinerino-domain:service:validateMovieTicket');
10
10
  /**
11
11
  * 座席予約オファー承認に対してムビチケ承認条件が整っているかどうか検証する
12
12
  */
13
- function validateMovieTicket(paymentMethodType, transaction) {
14
- const authorizeActions = transaction.object.authorizeActions;
13
+ function validateMovieTicket(paymentMethodType, transaction, authorizeActions) {
14
+ // const authorizeActions = transaction.object.authorizeActions;
15
15
  const authorizeMovieTicketActions = authorizeActions.filter((a) => {
16
16
  var _a, _b, _c;
17
17
  return a.actionStatus === factory.actionStatusType.CompletedActionStatus
@@ -7,7 +7,7 @@ export type IUnitPriceSpecification = factory.priceSpecification.IPriceSpecifica
7
7
  /**
8
8
  * 取引が確定可能な状態かどうかをチェックする
9
9
  */
10
- export declare function validateTransaction(transaction: factory.transaction.placeOrder.ITransaction): void;
10
+ export declare function validateTransaction(transaction: factory.transaction.placeOrder.ITransaction, authorizeActions: factory.action.authorize.IAction<factory.action.authorize.IAttributes<any, any>>[]): void;
11
11
  export type IConfirmationNumberGenerator = (order: factory.order.IOrder) => string;
12
12
  export type IOrderURLGenerator = (order: factory.order.IOrder) => string;
13
13
  export type IResultOrderParams = factory.transaction.placeOrder.IResultOrderParams & {
@@ -46,4 +46,5 @@ export declare function validatePaymentMethods(params: {
46
46
  export declare function validateEventOffers(params: {
47
47
  transaction: factory.transaction.placeOrder.ITransaction;
48
48
  order: factory.order.IOrder;
49
+ authorizeActions: factory.action.authorize.IAction<factory.action.authorize.IAttributes<any, any>>[];
49
50
  }): void;
@@ -13,18 +13,18 @@ const debug = createDebug('cinerino-domain:service');
13
13
  /**
14
14
  * 取引が確定可能な状態かどうかをチェックする
15
15
  */
16
- function validateTransaction(transaction) {
16
+ function validateTransaction(transaction, authorizeActions) {
17
17
  validateProfile(transaction);
18
- validatePrice(transaction);
18
+ validatePrice(transaction, authorizeActions);
19
19
  // 利用可能な通貨単位に対して取引検証
20
- validateMonetaryAmount(transaction);
20
+ validateMonetaryAmount(authorizeActions);
21
21
  // 利用可能なMovieTicketIF決済方法タイプに対して動的にコーディング
22
22
  // 検証すべきMovieTicketIF決済方法タイプのリストは、決済承認アクションのresult.issuedThrough.typeOf: MovieTicketで抽出できるのでは?
23
- const movieTicketPaymentMethodTypes = findMovieTicketPaymentMethodTypesFromTransaction(transaction);
23
+ const movieTicketPaymentMethodTypes = findMovieTicketPaymentMethodTypesFromTransaction(authorizeActions);
24
24
  if (Array.isArray(movieTicketPaymentMethodTypes) && movieTicketPaymentMethodTypes.length > 0) {
25
25
  movieTicketPaymentMethodTypes.forEach((paymentMethodType) => {
26
26
  try {
27
- (0, validateMovieTicket_1.validateMovieTicket)(paymentMethodType, transaction);
27
+ (0, validateMovieTicket_1.validateMovieTicket)(paymentMethodType, transaction, authorizeActions);
28
28
  }
29
29
  catch (error) {
30
30
  // 検証結果をlog(2022-06-04~)
@@ -35,11 +35,13 @@ function validateTransaction(transaction) {
35
35
  });
36
36
  }
37
37
  // 決済URLが発行されている場合、検証
38
- validatePaymentUrl(transaction);
38
+ validatePaymentUrl(transaction, authorizeActions);
39
39
  }
40
40
  exports.validateTransaction = validateTransaction;
41
- function findMovieTicketPaymentMethodTypesFromTransaction(transaction) {
42
- const authorizeActions = transaction.object.authorizeActions;
41
+ function findMovieTicketPaymentMethodTypesFromTransaction(
42
+ // transaction: factory.transaction.placeOrder.ITransaction,
43
+ authorizeActions) {
44
+ // const authorizeActions = transaction.object.authorizeActions;
43
45
  const authorizeMovieTicketPaymentActions = authorizeActions.filter((a) => {
44
46
  var _a, _b;
45
47
  return a.actionStatus === factory.actionStatusType.CompletedActionStatus
@@ -86,8 +88,8 @@ function validateProfile(transaction) {
86
88
  throw new factory.errors.Argument('Transaction', 'Customer Profile Required');
87
89
  }
88
90
  }
89
- function validatePrice(transaction) {
90
- const authorizeActions = transaction.object.authorizeActions;
91
+ function validatePrice(transaction, authorizeActions) {
92
+ // const authorizeActions = transaction.object.authorizeActions;
91
93
  let priceByAgent = 0;
92
94
  let priceBySeller = 0;
93
95
  // 決済承認を確認
@@ -110,9 +112,9 @@ function validatePrice(transaction) {
110
112
  throw new factory.errors.Argument('Transaction', 'Transaction cannot be confirmed because prices are not matched');
111
113
  }
112
114
  }
113
- function validatePaymentUrl(transaction) {
115
+ function validatePaymentUrl(transaction, authorizeActions) {
116
+ // const authorizeActions = transaction.object.authorizeActions;
114
117
  var _a, _b;
115
- const authorizeActions = transaction.object.authorizeActions;
116
118
  // 決済URLが発行されている場合、検証
117
119
  const paymentMethodId = (_a = transaction.object.paymentMethods) === null || _a === void 0 ? void 0 : _a.paymentMethodId;
118
120
  const paymentUrl = (_b = transaction.object.paymentMethods) === null || _b === void 0 ? void 0 : _b.paymentUrl;
@@ -135,10 +137,10 @@ function validatePaymentUrl(transaction) {
135
137
  /**
136
138
  * JPY以外の通貨について取引を検証する
137
139
  */
138
- function validateMonetaryAmount(transaction
139
- // currencies: string[]
140
- ) {
141
- const authorizeActions = transaction.object.authorizeActions;
140
+ function validateMonetaryAmount(
141
+ // transaction: factory.transaction.placeOrder.ITransaction,
142
+ authorizeActions) {
143
+ // const authorizeActions = transaction.object.authorizeActions;
142
144
  const authorizeMonetaryAmountActions = authorizeActions
143
145
  .filter((a) => {
144
146
  var _a, _b;
@@ -216,7 +218,11 @@ exports.validatePaymentMethods = validatePaymentMethods;
216
218
  * イベントオファー適用条件確認
217
219
  */
218
220
  function validateEventOffers(params) {
219
- const seatReservationAuthorizeActions = params.transaction.object.authorizeActions
221
+ // const seatReservationAuthorizeActions = <IAuthorizeSeatReservationOffer[]>
222
+ // params.transaction.object.authorizeActions
223
+ // .filter((a) => a.actionStatus === factory.actionStatusType.CompletedActionStatus)
224
+ // .filter((a) => a.object.typeOf === factory.action.authorize.offer.seatReservation.ObjectType.SeatReservation);
225
+ const seatReservationAuthorizeActions = params.authorizeActions
220
226
  .filter((a) => a.actionStatus === factory.actionStatusType.CompletedActionStatus)
221
227
  .filter((a) => a.object.typeOf === factory.action.authorize.offer.seatReservation.ObjectType.SeatReservation);
222
228
  seatReservationAuthorizeActions.forEach((a) => {
@@ -1,6 +1,3 @@
1
- /**
2
- * 進行中注文取引サービス
3
- */
4
1
  import * as factory from '../../factory';
5
2
  import { MongoRepository as ActionRepo } from '../../repo/action';
6
3
  import { RedisRepository as ConfirmationNumberRepo } from '../../repo/confirmationNumber';
@@ -60,6 +57,7 @@ export type IConfirmParams = factory.transaction.placeOrder.IConfirmParams & {
60
57
  result: {
61
58
  order: IResultOrderParams;
62
59
  };
60
+ saveAuthorizeActions: boolean;
63
61
  };
64
62
  /**
65
63
  * 注文取引を確定する
@@ -13,6 +13,7 @@ exports.voidAward = exports.authorizeAward = exports.publishOrderNumberIfNotExis
13
13
  /**
14
14
  * 進行中注文取引サービス
15
15
  */
16
+ const moment = require("moment");
16
17
  const factory = require("../../factory");
17
18
  const factory_1 = require("./placeOrderInProgress/factory");
18
19
  const potentialActions_1 = require("./placeOrderInProgress/potentialActions");
@@ -95,14 +96,15 @@ function confirm(params) {
95
96
  throw new factory.errors.Forbidden('Transaction not yours');
96
97
  }
97
98
  // 取引に対する全ての承認アクションをマージ
98
- transaction.object.authorizeActions = yield searchAuthorizeActions(params)(repos);
99
+ const authorizeActions = yield searchAuthorizeActions(params)(repos);
100
+ // transaction.object.authorizeActions = authorizeActions;
99
101
  // 注文番号を発行
100
102
  const orderNumber = yield publishOrderNumberIfNotExist({
101
103
  project: { id: transaction.project.id },
102
104
  id: transaction.id,
103
105
  object: { orderDate: params.result.order.orderDate }
104
106
  })(repos);
105
- const result = createResult(Object.assign(Object.assign({}, params), { orderNumber, transaction: transaction }));
107
+ const result = createResult(Object.assign(Object.assign({}, params), { orderNumber, transaction: transaction, authorizeActions }));
106
108
  // デフォルトEメールメッセージを検索
107
109
  let emailMessageOnOrderSent;
108
110
  if (repos.emailMessage !== undefined) {
@@ -119,14 +121,16 @@ function confirm(params) {
119
121
  order: result.order,
120
122
  potentialActions: params.potentialActions,
121
123
  transaction: transaction,
122
- emailMessage: emailMessageOnOrderSent
124
+ emailMessage: emailMessageOnOrderSent,
125
+ authorizeActions
123
126
  });
124
127
  // ステータス変更
125
128
  try {
126
129
  yield repos.transaction.confirm({
127
130
  typeOf: transaction.typeOf,
128
131
  id: transaction.id,
129
- authorizeActions: transaction.object.authorizeActions,
132
+ // 保管有無を設定化(2023-05-16~)
133
+ authorizeActions: (params.saveAuthorizeActions) ? authorizeActions : [],
130
134
  result: result,
131
135
  potentialActions: potentialActions
132
136
  });
@@ -214,18 +218,20 @@ exports.publishOrderNumberIfNotExist = publishOrderNumberIfNotExist;
214
218
  function createResult(params) {
215
219
  const transaction = params.transaction;
216
220
  // 取引の確定条件が全て整っているかどうか確認
217
- (0, validation_1.validateTransaction)(transaction);
221
+ (0, validation_1.validateTransaction)(transaction, params.authorizeActions);
218
222
  // 注文作成
219
223
  const order = (0, result_1.createOrder)({
220
224
  orderNumber: params.orderNumber,
221
225
  transaction: transaction,
222
226
  orderDate: params.result.order.orderDate,
223
227
  orderStatus: factory.orderStatus.OrderProcessing,
224
- isGift: false
228
+ isGift: false,
229
+ authorizeActions: params.authorizeActions
225
230
  });
226
231
  (0, validation_1.validateEventOffers)({
227
232
  transaction: transaction,
228
- order: order
233
+ order: order,
234
+ authorizeActions: params.authorizeActions
229
235
  });
230
236
  // 注文アイテム数制限確認
231
237
  (0, validation_1.validateNumItems)({
@@ -252,10 +258,15 @@ function searchAuthorizeActions(params) {
252
258
  purpose: {
253
259
  typeOf: factory.transactionType.PlaceOrder,
254
260
  id: params.id
255
- }
261
+ },
262
+ // Completedに絞る(2023-05-16~)
263
+ actionStatus: { $eq: factory.actionStatusType.CompletedActionStatus }
256
264
  });
257
265
  // 万が一このプロセス中に他処理が発生してもそれらを無視するように、endDateでフィルタリング
258
- authorizeActions = authorizeActions.filter((a) => (a.endDate !== undefined && a.endDate < params.result.order.orderDate));
266
+ authorizeActions = authorizeActions.filter((a) => {
267
+ return (a.endDate instanceof Date) && moment(a.endDate)
268
+ .isBefore(moment(params.result.order.orderDate));
269
+ });
259
270
  return authorizeActions;
260
271
  });
261
272
  }
@@ -311,7 +322,7 @@ function authorizeAward(params) {
311
322
  if (Array.isArray(givePointAwardParams)) {
312
323
  const pointAwardIdentifiers = givePointAwardParams.map((g) => { var _a; return String((_a = g.object) === null || _a === void 0 ? void 0 : _a.identifier); });
313
324
  // 取引にインセンティブ付与アクションパラメータを保管する
314
- yield repos.transaction.findByIdAndUpdate({
325
+ yield repos.transaction.findByIdAndUpdateInProgress({
315
326
  id: transaction.id,
316
327
  update: {
317
328
  $set: {
@@ -339,7 +350,7 @@ function voidAward(params) {
339
350
  if (transaction.agent.id !== params.agent.id) {
340
351
  throw new factory.errors.Forbidden('Transaction not yours');
341
352
  }
342
- yield repos.transaction.findByIdAndUpdate({
353
+ yield repos.transaction.findByIdAndUpdateInProgress({
343
354
  id: transaction.id,
344
355
  update: {
345
356
  $unset: {
@@ -36,7 +36,16 @@ function createTasks(params) {
36
36
  numberOfTried: 0,
37
37
  executionResults: [],
38
38
  data: {
39
- object: transaction
39
+ object: {
40
+ endDate: transaction.endDate,
41
+ id: transaction.id,
42
+ object: {
43
+ order: transaction.object.order
44
+ },
45
+ project: transaction.project,
46
+ startDate: transaction.startDate,
47
+ typeOf: transaction.typeOf
48
+ }
40
49
  }
41
50
  };
42
51
  taskAttributes.push(deleteTransactionTask);